Mercurial > hg > xmms-sid
comparison src/xs_sidplay1.cc @ 230:608f31f6c095
Raw cleanup.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 21 Dec 2004 09:25:03 +0000 |
parents | fe684a2ccdc7 |
children | e613873c3379 |
comparison
equal
deleted
inserted
replaced
229:7bb9e20e3092 | 230:608f31f6c095 |
---|---|
21 */ | 21 */ |
22 #include "xmms-sid.h" | 22 #include "xmms-sid.h" |
23 | 23 |
24 #ifdef HAVE_SIDPLAY1 | 24 #ifdef HAVE_SIDPLAY1 |
25 | 25 |
26 extern "C" { | |
27 #include "xs_sidplay1.h" | 26 #include "xs_sidplay1.h" |
28 #include <stdio.h> | 27 #include <stdio.h> |
29 #include "xs_config.h" | 28 #include "xs_config.h" |
30 #include "xs_length.h" | 29 #include "xs_length.h" |
31 #include "xs_title.h" | 30 #include "xs_title.h" |
32 } | |
33 | 31 |
34 #include <sidplay/player.h> | 32 #include <sidplay/player.h> |
35 #include <sidplay/myendian.h> | 33 #include <sidplay/myendian.h> |
36 #include <sidplay/fformat.h> | 34 #include <sidplay/fformat.h> |
37 | 35 |
71 /* | 69 /* |
72 * Initialize SIDPlay1 | 70 * Initialize SIDPlay1 |
73 */ | 71 */ |
74 gboolean xs_sidplay1_init(t_xs_status *myStatus) | 72 gboolean xs_sidplay1_init(t_xs_status *myStatus) |
75 { | 73 { |
76 t_xs_sidplay1 *myPlayer; | 74 t_xs_sidplay1 *myEngine; |
77 assert(myStatus); | 75 assert(myStatus); |
78 | 76 |
79 /* Allocate internal structures */ | 77 /* Allocate internal structures */ |
80 myPlayer = (t_xs_sidplay1 *) g_malloc0(sizeof(t_xs_sidplay1)); | 78 myEngine = (t_xs_sidplay1 *) g_malloc0(sizeof(t_xs_sidplay1)); |
81 if (!myPlayer) return FALSE; | 79 if (!myEngine) return FALSE; |
82 | 80 |
83 /* Initialize engine */ | 81 /* Initialize engine */ |
84 myPlayer->currEng = new emuEngine(); | 82 myEngine->currEng = new emuEngine(); |
85 if (!myPlayer->currEng) | 83 if (!myEngine->currEng) |
86 { | 84 { |
87 XSERR("Could not initialize libSIDPlay1 emulation engine\n"); | 85 XSERR("Could not initialize libSIDPlay1 emulation engine\n"); |
88 g_free(myPlayer); | 86 g_free(myEngine); |
89 return FALSE; | 87 return FALSE; |
90 } | 88 } |
91 | 89 |
92 /* Verify endianess */ | 90 /* Verify endianess */ |
93 if (!myPlayer->currEng->verifyEndianess()) | 91 if (!myEngine->currEng->verifyEndianess()) |
94 { | 92 { |
95 XSERR("Endianess verification failed\n"); | 93 XSERR("Endianess verification failed\n"); |
96 delete myPlayer->currEng; | 94 delete myEngine->currEng; |
97 g_free(myPlayer); | 95 g_free(myEngine); |
98 return FALSE; | 96 return FALSE; |
99 } | 97 } |
100 | 98 |
101 myStatus->player = myPlayer; | 99 myStatus->sidEngine = myEngine; |
102 return TRUE; | 100 return TRUE; |
103 } | 101 } |
104 | 102 |
105 | 103 |
106 /* | 104 /* |
107 * Close SIDPlay1 | 105 * Close SIDPlay1 |
108 */ | 106 */ |
109 void xs_sidplay1_close(t_xs_status *myStatus) | 107 void xs_sidplay1_close(t_xs_status *myStatus) |
110 { | 108 { |
111 t_xs_sidplay1 *myPlayer; | 109 t_xs_sidplay1 *myEngine; |
112 assert(myStatus); | 110 assert(myStatus); |
113 | 111 |
114 /* Free internals */ | 112 /* Free internals */ |
115 myPlayer = (t_xs_sidplay1 *) myStatus->player; | 113 myEngine = (t_xs_sidplay1 *) myStatus->sidEngine; |
116 if (myPlayer->currEng) | 114 if (myEngine->currEng) |
117 { | 115 { |
118 delete myPlayer->currEng; | 116 delete myEngine->currEng; |
119 myPlayer->currEng = NULL; | 117 myEngine->currEng = NULL; |
120 } | 118 } |
121 | 119 |
122 g_free(myPlayer); | 120 g_free(myEngine); |
123 myStatus->player = NULL; | 121 myStatus->sidEngine = NULL; |
124 } | 122 } |
125 | 123 |
126 | 124 |
127 gboolean xs_sidplay1_initsong(t_xs_status *myStatus) | 125 gboolean xs_sidplay1_initsong(t_xs_status *myStatus) |
128 { | 126 { |
129 t_xs_sidplay1 *myPlayer = (t_xs_sidplay1 *) myStatus->player; | 127 t_xs_sidplay1 *myEngine = (t_xs_sidplay1 *) myStatus->sidEngine; |
130 | 128 |
131 if (!myPlayer) return FALSE; | 129 if (!myEngine) return FALSE; |
132 | 130 |
133 if (!myPlayer->currTune) | 131 if (!myEngine->currTune) |
134 { | 132 { |
135 XSERR("Tune was NULL\n"); | 133 XSERR("Tune was NULL\n"); |
136 return FALSE; | 134 return FALSE; |
137 } | 135 } |
138 | 136 |
139 if (!myPlayer->currTune->getStatus()) | 137 if (!myEngine->currTune->getStatus()) |
140 { | 138 { |
141 XSERR("Tune status check failed\n"); | 139 XSERR("Tune status check failed\n"); |
142 return FALSE; | 140 return FALSE; |
143 } | 141 } |
144 | 142 |
145 return sidEmuInitializeSong( | 143 return sidEmuInitializeSong( |
146 *myPlayer->currEng, | 144 *myEngine->currEng, |
147 *myPlayer->currTune, | 145 *myEngine->currTune, |
148 myStatus->currSong); | 146 myStatus->currSong); |
149 } | 147 } |
150 | 148 |
151 | 149 |
152 guint xs_sidplay1_fillbuffer(t_xs_status *myStatus, gchar *audioBuffer, guint audioBufSize) | 150 guint xs_sidplay1_fillbuffer(t_xs_status *myStatus, gchar *audioBuffer, guint audioBufSize) |
153 { | 151 { |
154 t_xs_sidplay1 *myPlayer = (t_xs_sidplay1 *) myStatus->player; | 152 t_xs_sidplay1 *myEngine = (t_xs_sidplay1 *) myStatus->sidEngine; |
155 | 153 |
156 if (!myPlayer) return FALSE; | 154 if (!myEngine) return FALSE; |
157 | 155 |
158 sidEmuFillBuffer( | 156 sidEmuFillBuffer( |
159 *myPlayer->currEng, | 157 *myEngine->currEng, |
160 *myPlayer->currTune, | 158 *myEngine->currTune, |
161 audioBuffer, | 159 audioBuffer, |
162 audioBufSize); | 160 audioBufSize); |
163 | 161 |
164 return audioBufSize; | 162 return audioBufSize; |
165 } | 163 } |
166 | 164 |
167 | 165 |
168 gboolean xs_sidplay1_loadsid(t_xs_status *myStatus, gchar *pcFilename) | 166 gboolean xs_sidplay1_loadsid(t_xs_status *myStatus, gchar *pcFilename) |
169 { | 167 { |
170 t_xs_sidplay1 *myPlayer = (t_xs_sidplay1 *) myStatus->player; | 168 t_xs_sidplay1 *myEngine = (t_xs_sidplay1 *) myStatus->sidEngine; |
171 sidTune *newTune; | 169 sidTune *newTune; |
172 assert(myStatus); | 170 assert(myStatus); |
173 | 171 |
174 /* Try to get the tune */ | 172 /* Try to get the tune */ |
175 if (!pcFilename) return FALSE; | 173 if (!pcFilename) return FALSE; |
176 newTune = new sidTune(pcFilename); | 174 newTune = new sidTune(pcFilename); |
177 if (!newTune) return FALSE; | 175 if (!newTune) return FALSE; |
178 | 176 |
179 /* Get current configuration */ | 177 /* Get current configuration */ |
180 myPlayer->currEng->getConfig(myPlayer->currConfig); | 178 myEngine->currEng->getConfig(myEngine->currConfig); |
181 | 179 |
182 /* Configure channels and stuff */ | 180 /* Configure channels and stuff */ |
183 switch (myStatus->audioChannels) { | 181 switch (myStatus->audioChannels) { |
184 | 182 |
185 case XS_CHN_AUTOPAN: | 183 case XS_CHN_AUTOPAN: |
186 myPlayer->currConfig.channels = SIDEMU_STEREO; | 184 myEngine->currConfig.channels = SIDEMU_STEREO; |
187 myPlayer->currConfig.autoPanning = SIDEMU_CENTEREDAUTOPANNING; | 185 myEngine->currConfig.autoPanning = SIDEMU_CENTEREDAUTOPANNING; |
188 myPlayer->currConfig.volumeControl = SIDEMU_FULLPANNING; | 186 myEngine->currConfig.volumeControl = SIDEMU_FULLPANNING; |
189 break; | 187 break; |
190 | 188 |
191 case XS_CHN_STEREO: | 189 case XS_CHN_STEREO: |
192 myPlayer->currConfig.channels = SIDEMU_STEREO; | 190 myEngine->currConfig.channels = SIDEMU_STEREO; |
193 myPlayer->currConfig.autoPanning = SIDEMU_NONE; | 191 myEngine->currConfig.autoPanning = SIDEMU_NONE; |
194 myPlayer->currConfig.volumeControl = SIDEMU_NONE; | 192 myEngine->currConfig.volumeControl = SIDEMU_NONE; |
195 break; | 193 break; |
196 | 194 |
197 case XS_CHN_MONO: | 195 case XS_CHN_MONO: |
198 default: | 196 default: |
199 myPlayer->currConfig.channels = SIDEMU_MONO; | 197 myEngine->currConfig.channels = SIDEMU_MONO; |
200 myPlayer->currConfig.autoPanning = SIDEMU_NONE; | 198 myEngine->currConfig.autoPanning = SIDEMU_NONE; |
201 myPlayer->currConfig.volumeControl = SIDEMU_NONE; | 199 myEngine->currConfig.volumeControl = SIDEMU_NONE; |
202 break; | 200 break; |
203 } | 201 } |
204 | 202 |
205 | 203 |
206 /* Memory mode settings */ | 204 /* Memory mode settings */ |
207 switch (xs_cfg.memoryMode) { | 205 switch (xs_cfg.memoryMode) { |
208 case XS_MPU_BANK_SWITCHING: | 206 case XS_MPU_BANK_SWITCHING: |
209 myPlayer->currConfig.memoryMode = MPU_BANK_SWITCHING; | 207 myEngine->currConfig.memoryMode = MPU_BANK_SWITCHING; |
210 break; | 208 break; |
211 | 209 |
212 case XS_MPU_TRANSPARENT_ROM: | 210 case XS_MPU_TRANSPARENT_ROM: |
213 myPlayer->currConfig.memoryMode = MPU_TRANSPARENT_ROM; | 211 myEngine->currConfig.memoryMode = MPU_TRANSPARENT_ROM; |
214 break; | 212 break; |
215 | 213 |
216 case XS_MPU_PLAYSID_ENVIRONMENT: | 214 case XS_MPU_PLAYSID_ENVIRONMENT: |
217 myPlayer->currConfig.memoryMode = MPU_PLAYSID_ENVIRONMENT; | 215 myEngine->currConfig.memoryMode = MPU_PLAYSID_ENVIRONMENT; |
218 break; | 216 break; |
219 | 217 |
220 default: | 218 default: |
221 myPlayer->currConfig.memoryMode = MPU_BANK_SWITCHING; | 219 myEngine->currConfig.memoryMode = MPU_BANK_SWITCHING; |
222 break; | 220 break; |
223 } | 221 } |
224 | 222 |
225 | 223 |
226 /* Clockspeed settings */ | 224 /* Clockspeed settings */ |
227 switch (xs_cfg.clockSpeed) { | 225 switch (xs_cfg.clockSpeed) { |
228 case XS_CLOCK_NTSC: | 226 case XS_CLOCK_NTSC: |
229 myPlayer->currConfig.clockSpeed = SIDTUNE_CLOCK_NTSC; | 227 myEngine->currConfig.clockSpeed = SIDTUNE_CLOCK_NTSC; |
230 break; | 228 break; |
231 | 229 |
232 case XS_CLOCK_PAL: | 230 case XS_CLOCK_PAL: |
233 default: | 231 default: |
234 myPlayer->currConfig.clockSpeed = SIDTUNE_CLOCK_PAL; | 232 myEngine->currConfig.clockSpeed = SIDTUNE_CLOCK_PAL; |
235 break; | 233 break; |
236 } | 234 } |
237 | 235 |
238 | 236 |
239 /* Configure rest of the emulation */ | 237 /* Configure rest of the emulation */ |
240 myPlayer->currConfig.mos8580 = xs_cfg.mos8580; | 238 myEngine->currConfig.mos8580 = xs_cfg.mos8580; |
241 myPlayer->currConfig.emulateFilter = xs_cfg.emulateFilters; | 239 myEngine->currConfig.emulateFilter = xs_cfg.emulateFilters; |
242 myPlayer->currConfig.filterFs = xs_cfg.filterFs; | 240 myEngine->currConfig.filterFs = xs_cfg.filterFs; |
243 myPlayer->currConfig.filterFm = xs_cfg.filterFm; | 241 myEngine->currConfig.filterFm = xs_cfg.filterFm; |
244 myPlayer->currConfig.filterFt = xs_cfg.filterFt; | 242 myEngine->currConfig.filterFt = xs_cfg.filterFt; |
245 | 243 |
246 myPlayer->currConfig.bitsPerSample = myStatus->audioBitsPerSample; | 244 myEngine->currConfig.bitsPerSample = myStatus->audioBitsPerSample; |
247 myPlayer->currConfig.frequency = myStatus->audioFrequency; | 245 myEngine->currConfig.frequency = myStatus->audioFrequency; |
248 | 246 |
249 switch (myStatus->audioBitsPerSample) { | 247 switch (myStatus->audioBitsPerSample) { |
250 case XS_RES_8BIT: | 248 case XS_RES_8BIT: |
251 switch (myStatus->audioFormat) { | 249 switch (myStatus->audioFormat) { |
252 case FMT_S8: | 250 case FMT_S8: |
253 myPlayer->currConfig.sampleFormat = SIDEMU_SIGNED_PCM; | 251 myEngine->currConfig.sampleFormat = SIDEMU_SIGNED_PCM; |
254 break; | 252 break; |
255 | 253 |
256 case FMT_U8: | 254 case FMT_U8: |
257 default: | 255 default: |
258 myStatus->audioFormat = FMT_U8; | 256 myStatus->audioFormat = FMT_U8; |
259 myPlayer->currConfig.sampleFormat = SIDEMU_UNSIGNED_PCM; | 257 myEngine->currConfig.sampleFormat = SIDEMU_UNSIGNED_PCM; |
260 break; | 258 break; |
261 } | 259 } |
262 break; | 260 break; |
263 | 261 |
264 case XS_RES_16BIT: | 262 case XS_RES_16BIT: |
265 switch (myStatus->audioFormat) { | 263 switch (myStatus->audioFormat) { |
266 case FMT_U16_NE: | 264 case FMT_U16_NE: |
267 case FMT_U16_LE: | 265 case FMT_U16_LE: |
268 case FMT_U16_BE: | 266 case FMT_U16_BE: |
269 myStatus->audioFormat = FMT_U16_NE; | 267 myStatus->audioFormat = FMT_U16_NE; |
270 myPlayer->currConfig.sampleFormat = SIDEMU_UNSIGNED_PCM; | 268 myEngine->currConfig.sampleFormat = SIDEMU_UNSIGNED_PCM; |
271 break; | 269 break; |
272 | 270 |
273 case FMT_S16_NE: | 271 case FMT_S16_NE: |
274 case FMT_S16_LE: | 272 case FMT_S16_LE: |
275 case FMT_S16_BE: | 273 case FMT_S16_BE: |
276 default: | 274 default: |
277 myStatus->audioFormat = FMT_S16_NE; | 275 myStatus->audioFormat = FMT_S16_NE; |
278 myPlayer->currConfig.sampleFormat = SIDEMU_SIGNED_PCM; | 276 myEngine->currConfig.sampleFormat = SIDEMU_SIGNED_PCM; |
279 break; | 277 break; |
280 } | 278 } |
281 break; | 279 break; |
282 } | 280 } |
283 | 281 |
284 /* Now set the emulator configuration */ | 282 /* Now set the emulator configuration */ |
285 if (!myPlayer->currEng->setConfig(myPlayer->currConfig)) | 283 if (!myEngine->currEng->setConfig(myEngine->currConfig)) |
286 { | 284 { |
287 XSERR("Emulator engine configuration failed!\n"); | 285 XSERR("Emulator engine configuration failed!\n"); |
288 return FALSE; | 286 return FALSE; |
289 } | 287 } |
290 | 288 |
291 /* Initialize status information */ | 289 /* Initialize status information */ |
292 myPlayer->currTune = newTune; | 290 myEngine->currTune = newTune; |
293 | 291 |
294 return TRUE; | 292 return TRUE; |
295 } | 293 } |
296 | 294 |
297 | 295 |
298 /* | 296 /* |
299 * Delete INTERNAL information | 297 * Delete INTERNAL information |
300 */ | 298 */ |
301 void xs_sidplay1_deletesid(t_xs_status *myStatus) | 299 void xs_sidplay1_deletesid(t_xs_status *myStatus) |
302 { | 300 { |
303 t_xs_sidplay1 *myPlayer; | 301 t_xs_sidplay1 *myEngine; |
304 assert(myStatus); | 302 assert(myStatus); |
305 | 303 |
306 myPlayer = (t_xs_sidplay1 *) myStatus->player; | 304 myEngine = (t_xs_sidplay1 *) myStatus->sidEngine; |
307 if (!myPlayer) return; | 305 if (!myEngine) return; |
308 | 306 |
309 if (myPlayer->currTune) | 307 if (myEngine->currTune) |
310 { | 308 { |
311 delete myPlayer->currTune; | 309 delete myEngine->currTune; |
312 myPlayer->currTune = NULL; | 310 myEngine->currTune = NULL; |
313 } | 311 } |
314 } | 312 } |
315 | 313 |
316 | 314 |
317 /* | 315 /* |