comparison src/xs_sidplay2.cc @ 692:0126579b6652

Actually compiles now with libsidplay2 COM API, but does not work yet.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 22 May 2008 09:22:49 +0300
parents b0743dc9165d
children 56514f717cc3
comparison
equal deleted inserted replaced
691:c21908e9e7d7 692:0126579b6652
28 #include "xs_sidplay2.h" 28 #include "xs_sidplay2.h"
29 #include "xs_config.h" 29 #include "xs_config.h"
30 30
31 31
32 #include <sidplay/sidplay2.h> 32 #include <sidplay/sidplay2.h>
33 #ifdef HAVE_SIDPLAY2_COMI
34 # include <sidplay/sidlazyiptr.h>
35 #endif
33 #ifdef HAVE_RESID_BUILDER 36 #ifdef HAVE_RESID_BUILDER
34 #include <sidplay/builders/resid.h> 37 # include <sidplay/builders/resid.h>
35 #endif 38 #endif
36 #ifdef HAVE_HARDSID_BUILDER 39 #ifdef HAVE_HARDSID_BUILDER
37 #include <sidplay/builders/hardsid.h> 40 # include <sidplay/builders/hardsid.h>
38 #endif 41 #endif
39
40 42
41 typedef struct { 43 typedef struct {
44 #ifdef HAVE_SIDPLAY2_COMI
45 SidIPtr<ISidplay2> currEng;
46 SidLazyIPtr<ISidUnknown> currBuilder;
47 #else
42 sidplay2 *currEng; 48 sidplay2 *currEng;
43 sidbuilder *currBuilder; 49 sidbuilder *currBuilder;
50 #endif
44 sid2_config_t currConfig; 51 sid2_config_t currConfig;
45 SidTune *currTune; 52 SidTune *currTune;
46 guint8 *buf; 53 guint8 *buf;
47 size_t bufSize; 54 size_t bufSize;
48 } xs_sidplay2_t; 55 } xs_sidplay2_t;
52 extern "C" { 59 extern "C" {
53 60
54 61
55 /* Return song information 62 /* Return song information
56 */ 63 */
57 #define TFUNCTION xs_sidplay2_getinfo 64 #define TFUNCTION xs_sidplay2_getinfo
58 #define TFUNCTION2 xs_sidplay2_updateinfo 65 #define TFUNCTION2 xs_sidplay2_updateinfo
59 #define TTUNEINFO SidTuneInfo 66 #define TTUNEINFO SidTuneInfo
60 #define TTUNE SidTune 67 #define TTUNE SidTune
61 #define TENGINE xs_sidplay2_t 68 #define TENGINE xs_sidplay2_t
62 #include "xs_sidplay.h" 69 #include "xs_sidplay.h"
63 70
64 71
65 /* Check if we can play the given file 72 /* Check if we can play the given file
66 */ 73 */
94 myEngine = (xs_sidplay2_t *) g_malloc0(sizeof(xs_sidplay2_t)); 101 myEngine = (xs_sidplay2_t *) g_malloc0(sizeof(xs_sidplay2_t));
95 myStatus->sidEngine = myEngine; 102 myStatus->sidEngine = myEngine;
96 if (!myEngine) return FALSE; 103 if (!myEngine) return FALSE;
97 104
98 /* Initialize the engine */ 105 /* Initialize the engine */
106 #ifdef HAVE_SIDPLAY2_COMI
107 // myEngine->currEng();
108 #else
99 myEngine->currEng = new sidplay2; 109 myEngine->currEng = new sidplay2;
110 #endif
100 if (!myEngine->currEng) { 111 if (!myEngine->currEng) {
101 xs_error("[SIDPlay2] Could not initialize emulation engine.\n"); 112 xs_error("[SIDPlay2] Could not initialize emulation engine.\n");
102 return FALSE; 113 return FALSE;
103 } 114 }
104 115
226 237
227 /* Initialize builder object */ 238 /* Initialize builder object */
228 XSDEBUG("init builder #%i, maxsids=%i\n", xs_cfg.sid2Builder, (myEngine->currEng->info()).maxsids); 239 XSDEBUG("init builder #%i, maxsids=%i\n", xs_cfg.sid2Builder, (myEngine->currEng->info()).maxsids);
229 #ifdef HAVE_RESID_BUILDER 240 #ifdef HAVE_RESID_BUILDER
230 if (xs_cfg.sid2Builder == XS_BLD_RESID) { 241 if (xs_cfg.sid2Builder == XS_BLD_RESID) {
242 #ifdef HAVE_SIDPLAY2_COMI
243 myEngine->currBuilder = ReSIDBuilderCreate("");
244 SidLazyIPtr<IReSIDBuilder> rs(myEngine->currBuilder);
245 if (rs) {
246 myEngine->currConfig.sidEmulation = rs->iaggregate();
247 #else
231 ReSIDBuilder *rs = new ReSIDBuilder("ReSID builder"); 248 ReSIDBuilder *rs = new ReSIDBuilder("ReSID builder");
232 myEngine->currBuilder = (sidbuilder *) rs; 249 myEngine->currBuilder = (sidbuilder *) rs;
233 if (rs) { 250 if (rs) {
251 #endif
234 /* Builder object created, initialize it */ 252 /* Builder object created, initialize it */
235 rs->create((myEngine->currEng->info()).maxsids); 253 rs->create((myEngine->currEng->info()).maxsids);
236 if (!*rs) { 254 if (!*rs) {
237 xs_error("reSID->create() failed.\n"); 255 xs_error("reSID->create() failed.\n");
238 return FALSE; 256 return FALSE;
264 } 282 }
265 } 283 }
266 #endif 284 #endif
267 #ifdef HAVE_HARDSID_BUILDER 285 #ifdef HAVE_HARDSID_BUILDER
268 if (xs_cfg.sid2Builder == XS_BLD_HARDSID) { 286 if (xs_cfg.sid2Builder == XS_BLD_HARDSID) {
287 #ifdef HAVE_SIDPLAY2_COMI
288 myEngine->currBuilder = HardSIDBuilderCreate("");
289 SidLazyIPtr<IReSIDBuilder> hs(myEngine->currBuilder);
290 if (hs) {
291 myEngine->currConfig.sidEmulation = hs->iaggregate();
292 #else
269 HardSIDBuilder *hs = new HardSIDBuilder("HardSID builder"); 293 HardSIDBuilder *hs = new HardSIDBuilder("HardSID builder");
270 myEngine->currBuilder = (sidbuilder *) hs; 294 myEngine->currBuilder = (sidbuilder *) hs;
271 if (hs) { 295 if (hs) {
296 #endif
272 /* Builder object created, initialize it */ 297 /* Builder object created, initialize it */
273 hs->create((myEngine->currEng->info()).maxsids); 298 hs->create((myEngine->currEng->info()).maxsids);
274 if (!*hs) { 299 if (!*hs) {
275 xs_error("hardSID->create() failed.\n"); 300 xs_error("hardSID->create() failed.\n");
276 return FALSE; 301 return FALSE;
288 if (!myEngine->currBuilder) { 313 if (!myEngine->currBuilder) {
289 xs_error("[SIDPlay2] Could not initialize SIDBuilder object.\n"); 314 xs_error("[SIDPlay2] Could not initialize SIDBuilder object.\n");
290 return FALSE; 315 return FALSE;
291 } 316 }
292 317
318 #ifndef HAVE_SIDPLAY2_COMI
319 myEngine->currConfig.sidEmulation = myEngine->currBuilder;
293 XSDEBUG("%s\n", myEngine->currBuilder->credits()); 320 XSDEBUG("%s\n", myEngine->currBuilder->credits());
294 321 #endif
295 322
296 /* Clockspeed settings */ 323 /* Clockspeed settings */
297 switch (xs_cfg.clockSpeed) { 324 switch (xs_cfg.clockSpeed) {
298 case XS_CLOCK_NTSC: 325 case XS_CLOCK_NTSC:
299 myEngine->currConfig.clockDefault = SID2_CLOCK_NTSC; 326 myEngine->currConfig.clockDefault = SID2_CLOCK_NTSC;
309 break; 336 break;
310 } 337 }
311 338
312 339
313 /* Configure rest of the emulation */ 340 /* Configure rest of the emulation */
314 myEngine->currConfig.sidEmulation = myEngine->currBuilder;
315 341
316 if (xs_cfg.forceSpeed) { 342 if (xs_cfg.forceSpeed) {
317 myEngine->currConfig.clockForced = true; 343 myEngine->currConfig.clockForced = true;
318 myEngine->currConfig.clockSpeed = myEngine->currConfig.clockDefault; 344 myEngine->currConfig.clockSpeed = myEngine->currConfig.clockDefault;
319 } else { 345 } else {
372 398
373 myEngine = (xs_sidplay2_t *) myStatus->sidEngine; 399 myEngine = (xs_sidplay2_t *) myStatus->sidEngine;
374 400
375 /* Free internals */ 401 /* Free internals */
376 if (myEngine->currBuilder) { 402 if (myEngine->currBuilder) {
403 #ifndef HAVE_SIDPLAY2_COMI
377 delete myEngine->currBuilder; 404 delete myEngine->currBuilder;
405 #endif
378 myEngine->currBuilder = NULL; 406 myEngine->currBuilder = NULL;
379 } 407 }
380 408
409 #ifndef HAVE_SIDPLAY2_COMI
381 if (myEngine->currEng) { 410 if (myEngine->currEng) {
382 delete myEngine->currEng; 411 delete myEngine->currEng;
383 myEngine->currEng = NULL; 412 myEngine->currEng = NULL;
384 } 413 }
414 #endif
385 415
386 if (myEngine->currTune) { 416 if (myEngine->currTune) {
387 delete myEngine->currTune; 417 delete myEngine->currTune;
388 myEngine->currTune = NULL; 418 myEngine->currTune = NULL;
389 } 419 }