comparison src/xs_sidplay.h @ 762:03c5cde1dfbb

Cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 05 Nov 2012 22:38:41 +0200
parents 36c6a6e629bb
children dfda3d47baf7
comparison
equal deleted inserted replaced
761:641b7693fecc 762:03c5cde1dfbb
26 * (those variables that are only set by libSIDPlay when tune is initialized). 26 * (those variables that are only set by libSIDPlay when tune is initialized).
27 * Rest of the information is acquired in TFUNCTION2() 27 * Rest of the information is acquired in TFUNCTION2()
28 */ 28 */
29 XSTuneInfo *TFUNCTION(const gchar *sidFilename) 29 XSTuneInfo *TFUNCTION(const gchar *sidFilename)
30 { 30 {
31 XSTuneInfo *pResult; 31 XSTuneInfo *res;
32 TTUNEINFO myInfo; 32 TTUNEINFO myInfo;
33 TTUNE *myTune; 33 TTUNE *myTune;
34 guint8 *buf = NULL; 34 guint8 *buf = NULL;
35 size_t bufSize = 0; 35 size_t bufSize = 0;
36 36
37 /* Load file */ 37 /* Load file */
38 if (!sidFilename) return NULL;
39
40 if (xs_fload_buffer(sidFilename, &buf, &bufSize) != 0) 38 if (xs_fload_buffer(sidFilename, &buf, &bufSize) != 0)
41 return NULL; 39 return NULL;
42 40
43 /* Check if the tune exists and is readable */ 41 /* Check if the tune exists and is readable */
44 if ((myTune = new TTUNE(buf, bufSize)) == NULL) { 42 if ((myTune = new TTUNE(buf, bufSize)) == NULL)
43 {
45 g_free(buf); 44 g_free(buf);
46 return NULL; 45 return NULL;
47 } 46 }
48 g_free(buf); 47 g_free(buf);
49 48
50 if (!myTune->getStatus()) { 49 if (!myTune->getStatus())
50 {
51 delete myTune; 51 delete myTune;
52 return NULL; 52 return NULL;
53 } 53 }
54 54
55 /* Get general tune information */ 55 /* Get general tune information */
59 #ifdef XS_SIDPLAY2_H 59 #ifdef XS_SIDPLAY2_H
60 myInfo = myTune->getInfo(); 60 myInfo = myTune->getInfo();
61 #endif 61 #endif
62 62
63 /* Allocate tuneinfo structure and set information */ 63 /* Allocate tuneinfo structure and set information */
64 pResult = xs_tuneinfo_new(sidFilename, 64 res = xs_tuneinfo_new(sidFilename,
65 myInfo.songs, myInfo.startSong, 65 myInfo.songs, myInfo.startSong,
66 myInfo.infoString[0], myInfo.infoString[1], myInfo.infoString[2], 66 myInfo.infoString[0], myInfo.infoString[1], myInfo.infoString[2],
67 myInfo.loadAddr, myInfo.initAddr, myInfo.playAddr, 67 myInfo.loadAddr, myInfo.initAddr, myInfo.playAddr,
68 myInfo.dataFileLen, myInfo.formatString, 68 myInfo.dataFileLen, myInfo.formatString,
69 #if defined(XS_SIDPLAY2_H) && defined(HAVE_SIDPLAY2_FP) 69 #if defined(XS_SIDPLAY2_H) && defined(HAVE_SIDPLAY2_FP)
80 * but at least we have a reasonable guesstimate. 80 * but at least we have a reasonable guesstimate.
81 */ 81 */
82 82
83 delete myTune; 83 delete myTune;
84 84
85 return pResult; 85 return res;
86 } 86 }
87 87
88 88
89 /* Updates the information of currently playing tune 89 /* Updates the information of currently playing tune
90 */ 90 */
91 gboolean TFUNCTION2(XSEngineState *myStatus) 91 gboolean TFUNCTION2(XSEngineState *state)
92 { 92 {
93 TTUNEINFO myInfo; 93 TTUNEINFO myInfo;
94 TTUNE *myTune; 94 TTUNE *myTune;
95 TENGINE *myEngine; 95 TENGINE *engine;
96 XSTuneInfo *i; 96 XSTuneInfo *i;
97 97
98 /* Check if we have required structures initialized */ 98 /* Check if we have required structures initialized */
99 if (!myStatus || !myStatus->tuneInfo || !myStatus->internal) 99 if (!state || !state->tuneInfo || !state->internal)
100 return FALSE; 100 return FALSE;
101 101
102 myEngine = (TENGINE *) myStatus->internal; 102 engine = (TENGINE *) state->internal;
103 myTune = myEngine->currTune; 103 myTune = engine->tune;
104 if (!myTune) 104 if (!myTune)
105 return FALSE; 105 return FALSE;
106 106
107 /* Get currently playing tune information */ 107 /* Get currently playing tune information */
108 #ifdef XS_SIDPLAY1_H 108 #ifdef XS_SIDPLAY1_H
113 #endif 113 #endif
114 114
115 /* NOTICE! Here we assume that libSIDPlay[12] headers define 115 /* NOTICE! Here we assume that libSIDPlay[12] headers define
116 * SIDTUNE_SIDMODEL_* similarly to our enums in xs_config.h ... 116 * SIDTUNE_SIDMODEL_* similarly to our enums in xs_config.h ...
117 */ 117 */
118 i = myStatus->tuneInfo; 118 i = state->tuneInfo;
119 #if defined(XS_SIDPLAY2_H) && defined(HAVE_SIDPLAY2_FP) 119 #if defined(XS_SIDPLAY2_H) && defined(HAVE_SIDPLAY2_FP)
120 i->sidModel = myInfo.sidModel1; 120 i->sidModel = myInfo.sidModel1;
121 #else 121 #else
122 i->sidModel = myInfo.sidModel; 122 i->sidModel = myInfo.sidModel;
123 #endif 123 #endif
124 124
125 if ((myStatus->currSong > 0) && (myStatus->currSong <= i->nsubTunes)) { 125 if (state->currSong > 0 && state->currSong <= i->nsubTunes)
126 {
126 gint tmpSpeed = -1; 127 gint tmpSpeed = -1;
127 128
128 switch (myInfo.clockSpeed) { 129 switch (myInfo.clockSpeed)
129 case SIDTUNE_CLOCK_PAL: 130 {
130 tmpSpeed = XS_CLOCK_PAL; 131 case SIDTUNE_CLOCK_PAL:
131 break; 132 tmpSpeed = XS_CLOCK_PAL;
132 case SIDTUNE_CLOCK_NTSC:
133 tmpSpeed = XS_CLOCK_NTSC;
134 break;
135 case SIDTUNE_CLOCK_ANY:
136 tmpSpeed = XS_CLOCK_ANY;
137 break;
138 case SIDTUNE_CLOCK_UNKNOWN:
139 switch (myInfo.songSpeed) {
140 case SIDTUNE_SPEED_VBI:
141 tmpSpeed = XS_CLOCK_VBI;
142 break; 133 break;
143 case SIDTUNE_SPEED_CIA_1A: 134 case SIDTUNE_CLOCK_NTSC:
144 tmpSpeed = XS_CLOCK_CIA; 135 tmpSpeed = XS_CLOCK_NTSC;
145 break; 136 break;
137 case SIDTUNE_CLOCK_ANY:
138 tmpSpeed = XS_CLOCK_ANY;
139 break;
140 case SIDTUNE_CLOCK_UNKNOWN:
141 switch (myInfo.songSpeed)
142 {
143 case SIDTUNE_SPEED_VBI:
144 tmpSpeed = XS_CLOCK_VBI;
145 break;
146 case SIDTUNE_SPEED_CIA_1A:
147 tmpSpeed = XS_CLOCK_CIA;
148 break;
149 default:
150 tmpSpeed = myInfo.songSpeed;
151 break;
152 }
146 default: 153 default:
147 tmpSpeed = myInfo.songSpeed; 154 tmpSpeed = myInfo.clockSpeed;
148 break; 155 break;
149 }
150 default:
151 tmpSpeed = myInfo.clockSpeed;
152 break;
153 } 156 }
154 157
155 i->subTunes[myStatus->currSong - 1].tuneSpeed = tmpSpeed; 158 i->subTunes[state->currSong - 1].tuneSpeed = tmpSpeed;
156 } 159 }
157 160
158 return TRUE; 161 return TRUE;
159 } 162 }
160 163