comparison src/xs_sidplayfp.cpp @ 991:34259889b2b1 dev-0_9_1

Add support for libSIDPlay-FP v1.1.x.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 11 Oct 2013 14:37:20 +0300
parents 9bd29db2d1bf
children fca16a15145e
comparison
equal deleted inserted replaced
990:15995c18e410 991:34259889b2b1
27 #include "xs_sidplayfp.h" 27 #include "xs_sidplayfp.h"
28 #include "xs_slsup.h" 28 #include "xs_slsup.h"
29 #include "xs_config.h" 29 #include "xs_config.h"
30 30
31 31
32 #ifdef HAVE_SIDPLAYFP_V1 32 #if defined(HAVE_SIDPLAYFP_V10) || defined(HAVE_SIDPLAYFP_V11)
33 # include <sidplayfp/SidTune.h> 33 # include <sidplayfp/SidTune.h>
34 # include <sidplayfp/sidplayfp.h> 34 # include <sidplayfp/sidplayfp.h>
35 # include <sidplayfp/event.h> 35 # include <sidplayfp/event.h>
36 # include <sidplayfp/SidConfig.h> 36 # include <sidplayfp/SidConfig.h>
37 # include <sidplayfp/SidInfo.h> 37 # include <sidplayfp/SidInfo.h>
43 #endif 43 #endif
44 44
45 45
46 class XSSIDPlayFP { 46 class XSSIDPlayFP {
47 public: 47 public:
48 #ifdef HAVE_SIDPLAYFP_V1 48 #if defined(HAVE_SIDPLAYFP_V10) || defined(HAVE_SIDPLAYFP_V11)
49 sidplayfp emu; 49 sidplayfp emu;
50 SidConfig config; 50 SidConfig config;
51 #else 51 #else
52 sidplay2 emu; 52 sidplay2 emu;
53 sid2_config_t config; 53 sid2_config_t config;
89 extern "C" { 89 extern "C" {
90 90
91 91
92 /* Return song information 92 /* Return song information
93 */ 93 */
94 #ifdef HAVE_SIDPLAYFP_V1 94 #if defined(HAVE_SIDPLAYFP_V10) || defined(HAVE_SIDPLAYFP_V11)
95 #define sid2_mono SidConfig::MONO 95 #define sid2_mono SidConfig::MONO
96 #define sid2_stereo SidConfig::STEREO 96 #define sid2_stereo SidConfig::STEREO
97 97
98 #define SID2_INTERPOLATE SidConfig::INTERPOLATE 98 #define SID2_INTERPOLATE SidConfig::INTERPOLATE
99 #define SID2_RESAMPLE_INTERPOLATE SidConfig::RESAMPLE_INTERPOLATE 99 #define SID2_RESAMPLE_INTERPOLATE SidConfig::RESAMPLE_INTERPOLATE
251 251
252 /* Clockspeed settings */ 252 /* Clockspeed settings */
253 switch (xs_cfg.clockSpeed) 253 switch (xs_cfg.clockSpeed)
254 { 254 {
255 case XS_CLOCK_NTSC: 255 case XS_CLOCK_NTSC:
256 #ifdef HAVE_SIDPLAYFP_V1 256 #if defined(HAVE_SIDPLAYFP_V10) || defined(HAVE_SIDPLAYFP_V11)
257 engine->config.defaultC64Model = SID2_CLOCK_NTSC; 257 engine->config.defaultC64Model = SID2_CLOCK_NTSC;
258 #else 258 #else
259 engine->config.clockDefault = SID2_CLOCK_NTSC; 259 engine->config.clockDefault = SID2_CLOCK_NTSC;
260 #endif 260 #endif
261 break; 261 break;
262 262
263 default: 263 default:
264 case XS_CLOCK_PAL: 264 case XS_CLOCK_PAL:
265 #ifdef HAVE_SIDPLAYFP_V1 265 #if defined(HAVE_SIDPLAYFP_V10) || defined(HAVE_SIDPLAYFP_V11)
266 #else 266 #else
267 engine->config.defaultC64Model = SID2_CLOCK_PAL; 267 engine->config.defaultC64Model = SID2_CLOCK_PAL;
268 #endif 268 #endif
269 xs_cfg.clockSpeed = XS_CLOCK_PAL; 269 xs_cfg.clockSpeed = XS_CLOCK_PAL;
270 break; 270 break;
271 } 271 }
272 272
273 273
274 /* Configure rest of the emulation */ 274 /* Configure rest of the emulation */
275 275
276 #ifdef HAVE_SIDPLAYFP_V1 276 #if defined(HAVE_SIDPLAYFP_V10) || defined(HAVE_SIDPLAYFP_V11)
277 engine->config.forceC64Model = xs_cfg.forceSpeed; 277 engine->config.forceC64Model = xs_cfg.forceSpeed;
278 engine->config.defaultSidModel = xs_cfg.mos8580 ? SID2_MOS8580 : SID2_MOS6581; 278 engine->config.defaultSidModel = xs_cfg.mos8580 ? SID2_MOS8580 : SID2_MOS6581;
279 XSDEBUG("init builder #%i, maxsids=%i\n", xs_cfg.sid2Builder, (engine->emu.info()).maxsids()); 279 XSDEBUG("init builder #%i, maxsids=%i\n", xs_cfg.sid2Builder, (engine->emu.info()).maxsids());
280 #else 280 #else
281 engine->config.sidDefault = xs_cfg.mos8580 ? SID2_MOS8580 : SID2_MOS6581; 281 engine->config.sidDefault = xs_cfg.mos8580 ? SID2_MOS8580 : SID2_MOS6581;
292 { 292 {
293 #ifdef HAVE_RESID_BUILDER 293 #ifdef HAVE_RESID_BUILDER
294 case XS_BLD_RESID: 294 case XS_BLD_RESID:
295 { 295 {
296 ReSIDBuilder *rs = new ReSIDBuilder("ReSID builder"); 296 ReSIDBuilder *rs = new ReSIDBuilder("ReSID builder");
297 #ifdef HAVE_SIDPLAYFP_V1 297 #if defined(HAVE_SIDPLAYFP_V10) || defined(HAVE_SIDPLAYFP_V11)
298 if (rs && rs->getStatus()) 298 if (rs && rs->getStatus())
299 { 299 {
300 engine->config.sidEmulation = rs; 300 engine->config.sidEmulation = rs;
301 if (!rs->getStatus()) goto error; 301 if (!rs->getStatus()) goto error;
302 rs->create((engine->emu.info()).maxsids()); 302 rs->create((engine->emu.info()).maxsids());
319 319
320 #ifdef HAVE_RESID_FP_BUILDER 320 #ifdef HAVE_RESID_FP_BUILDER
321 case XS_BLD_RESID_FP: 321 case XS_BLD_RESID_FP:
322 { 322 {
323 ReSIDfpBuilder *rs = new ReSIDfpBuilder("ReSID builder FP!"); 323 ReSIDfpBuilder *rs = new ReSIDfpBuilder("ReSID builder FP!");
324 #ifdef HAVE_SIDPLAYFP_V1 324 #if defined(HAVE_SIDPLAYFP_V10) || defined(HAVE_SIDPLAYFP_V11)
325 if (rs && rs->getStatus()) 325 if (rs && rs->getStatus())
326 { 326 {
327 engine->config.sidEmulation = rs; 327 engine->config.sidEmulation = rs;
328 if (!rs->getStatus()) goto error; 328 if (!rs->getStatus()) goto error;
329 rs->create((engine->emu.info()).maxsids()); 329 rs->create((engine->emu.info()).maxsids());
347 #ifdef HAVE_HARDSID_BUILDER 347 #ifdef HAVE_HARDSID_BUILDER
348 case XS_BLD_HARDSID: 348 case XS_BLD_HARDSID:
349 { 349 {
350 HardSIDBuilder *hs = new HardSIDBuilder("HardSID builder (FP)"); 350 HardSIDBuilder *hs = new HardSIDBuilder("HardSID builder (FP)");
351 engine->config.sidEmulation = (sidbuilder *) hs; 351 engine->config.sidEmulation = (sidbuilder *) hs;
352 #ifdef HAVE_SIDPLAYFP_V1 352 #if defined(HAVE_SIDPLAYFP_V10) || defined(HAVE_SIDPLAYFP_V11)
353 if (hs && hs->getStatus()) 353 if (hs && hs->getStatus())
354 { 354 {
355 hs->create((engine->emu.info()).maxsids()); 355 hs->create((engine->emu.info()).maxsids());
356 if (!hs->getStatus()) goto error; 356 if (!hs->getStatus()) goto error;
357 } 357 }
378 goto error; 378 goto error;
379 } 379 }
380 380
381 // Setup filter 381 // Setup filter
382 engine->config.sidEmulation->filter(xs_cfg.emulateFilters); 382 engine->config.sidEmulation->filter(xs_cfg.emulateFilters);
383 #ifdef HAVE_SIDPLAYFP_V1 383 #if defined(HAVE_SIDPLAYFP_V10) || defined(HAVE_SIDPLAYFP_V11)
384 if (!engine->config.sidEmulation->getStatus()) 384 if (!engine->config.sidEmulation->getStatus())
385 #else 385 #else
386 if (!*(engine->config.sidEmulation)) 386 if (!*(engine->config.sidEmulation))
387 #endif 387 #endif
388 { 388 {
390 goto error; 390 goto error;
391 } 391 }
392 392
393 XSDEBUG("%s\n", engine->config.sidEmulation->credits()); 393 XSDEBUG("%s\n", engine->config.sidEmulation->credits());
394 394
395 #ifdef HAVE_SIDPLAYFP_V1 395 #if defined(HAVE_SIDPLAYFP_V10) || defined(HAVE_SIDPLAYFP_V11)
396 engine->emu.setRoms(xs_rom_imagedata[0], xs_rom_imagedata[1], xs_rom_imagedata[2]); 396 engine->emu.setRoms(xs_rom_imagedata[0], xs_rom_imagedata[1], xs_rom_imagedata[2]);
397 #endif 397 #endif
398 398
399 399
400 400
401 if (!xs_fload_buffer(filename, &buf, &bufSize, XS_SIDBUF_SIZE, TRUE)) 401 if (!xs_fload_buffer(filename, &buf, &bufSize, XS_SIDBUF_SIZE, TRUE))
402 goto error; 402 goto error;
403 403
404 engine->tune.read(buf, bufSize); 404 engine->tune.read(buf, bufSize);
405 405
406 #ifdef HAVE_SIDPLAYFP_V1 406 #if defined(HAVE_SIDPLAYFP_V10) || defined(HAVE_SIDPLAYFP_V11)
407 if (!engine->tune.getStatus()) 407 if (!engine->tune.getStatus())
408 #else 408 #else
409 if (!engine->tune) 409 if (!engine->tune)
410 #endif 410 #endif
411 { 411 {
482 goto error; 482 goto error;
483 } 483 }
484 484
485 /* Get general tune information */ 485 /* Get general tune information */
486 { 486 {
487 #ifdef HAVE_SIDPLAYFP_V1 487 #if defined(HAVE_SIDPLAYFP_V11)
488 const SidTuneInfo *info = tune->getInfo();
489
490 res = xs_tuneinfo_new(filename,
491 info->songs(), info->startSong(),
492 info->infoString(0), info->infoString(1), info->infoString(2),
493 info->loadAddr(), info->initAddr(), info->playAddr(),
494 info->dataFileLen(), info->formatString(),
495 info->sidModel(1), info->sidModel(2)
496 );
497 #elif defined(HAVE_SIDPLAYFP_V10) || defined(HAVE_SIDPLAYFP_V11)
488 const SidTuneInfo *info = tune->getInfo(); 498 const SidTuneInfo *info = tune->getInfo();
489 499
490 res = xs_tuneinfo_new(filename, 500 res = xs_tuneinfo_new(filename,
491 info->songs(), info->startSong(), 501 info->songs(), info->startSong(),
492 info->infoString(0), info->infoString(1), info->infoString(2), 502 info->infoString(0), info->infoString(1), info->infoString(2),
526 if (!state || !state->tuneInfo || !state->internal) 536 if (!state || !state->tuneInfo || !state->internal)
527 return FALSE; 537 return FALSE;
528 538
529 engine = (XSSIDPlayFP *) state->internal; 539 engine = (XSSIDPlayFP *) state->internal;
530 540
531 #ifdef HAVE_SIDPLAYFP_V1 541 #if defined(HAVE_SIDPLAYFP_V10) || defined(HAVE_SIDPLAYFP_V11)
532 if (!engine->tune.getStatus()) 542 if (!engine->tune.getStatus())
533 return FALSE; 543 return FALSE;
534 544
535 const SidTuneInfo *info = engine->tune.getInfo(); 545 const SidTuneInfo *info = engine->tune.getInfo();
536 546
547 #if defined(HAVE_SIDPLAYFP_V11)
548 state->tuneInfo->sidModel1 = info->sidModel(1);
549 state->tuneInfo->sidModel2 = info->sidModel(2);
550 #else
537 state->tuneInfo->sidModel1 = info->sidModel1(); 551 state->tuneInfo->sidModel1 = info->sidModel1();
538 state->tuneInfo->sidModel2 = info->sidModel2(); 552 state->tuneInfo->sidModel2 = info->sidModel2();
553 #endif
539 554
540 if (state->currSong > 0 && state->currSong <= state->tuneInfo->nsubTunes) 555 if (state->currSong > 0 && state->currSong <= state->tuneInfo->nsubTunes)
541 { 556 {
542 gint tmpSpeed = info->clockSpeed(); 557 gint tmpSpeed = info->clockSpeed();
543 switch (info->clockSpeed()) 558 switch (info->clockSpeed())