Mercurial > hg > xmms-sid
comparison src/xs_sidplay2.cpp @ 862:011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
alphas .. does not work for some reason yet, though. (Only plays silence.)
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 09 Nov 2012 02:11:21 +0200 |
parents | 2663b1ac9ce6 |
children | 3a9bf45178ff |
comparison
equal
deleted
inserted
replaced
861:c6cf203be443 | 862:011ba70e271e |
---|---|
71 } | 71 } |
72 | 72 |
73 | 73 |
74 /* We need to 'export' all this pseudo-C++ crap */ | 74 /* We need to 'export' all this pseudo-C++ crap */ |
75 extern "C" { | 75 extern "C" { |
76 | |
77 | |
78 /* Return song information | |
79 */ | |
80 #define TFUNCTION xs_sidplay2_getinfo | |
81 #define TFUNCTION2 xs_sidplay2_updateinfo | |
82 #define TENGINE XSSIDPlay2 | |
83 #define TTUNEINFO SidTuneInfo | |
84 #define TTUNE SidTune | |
85 #include "xs_sidplay.h" | |
86 | 76 |
87 | 77 |
88 /* Check if we can play the given file | 78 /* Check if we can play the given file |
89 */ | 79 */ |
90 gboolean xs_sidplay2_probe(XSFile *f) | 80 gboolean xs_sidplay2_probe(XSFile *f) |
443 } | 433 } |
444 #endif | 434 #endif |
445 } | 435 } |
446 | 436 |
447 | 437 |
438 /* This function gets most of the information, though we do miss some | |
439 * (those variables that are only set by libSIDPlay when tune is initialized). | |
440 * Rest of the information is acquired in xs_sidplay2_updateinfo() | |
441 */ | |
442 XSTuneInfo *xs_sidplay2_getinfo(const gchar *filename) | |
443 { | |
444 XSTuneInfo *res; | |
445 SidTune *tune; | |
446 SidTuneInfo info; | |
447 | |
448 /* Check if the tune exists and is readable */ | |
449 if ((tune = new SidTune(filename)) == NULL) | |
450 { | |
451 XSDEBUG("could not initialize tune from '%s'.\n", filename); | |
452 return NULL; | |
453 } | |
454 | |
455 if (!tune->getStatus()) | |
456 { | |
457 XSDEBUG("tune->getStatus() returned false for '%s'.\n", filename); | |
458 delete tune; | |
459 return NULL; | |
460 } | |
461 | |
462 /* Get general tune information */ | |
463 tune->getInfo(info); | |
464 | |
465 /* Allocate tuneinfo structure and set information */ | |
466 res = xs_tuneinfo_new(filename, | |
467 info.songs, info.startSong, | |
468 info.infoString[0], info.infoString[1], info.infoString[2], | |
469 info.loadAddr, info.initAddr, info.playAddr, | |
470 info.dataFileLen, info.formatString, | |
471 info.sidModel | |
472 ); | |
473 | |
474 delete tune; | |
475 return res; | |
476 } | |
477 | |
478 | |
479 /* Updates the information of currently playing tune | |
480 */ | |
481 gboolean xs_sidplay2_updateinfo(XSEngineState *state) | |
482 { | |
483 XSSIDPlay2 *engine; | |
484 SidTuneInfo info; | |
485 | |
486 /* Check if we have required structures initialized */ | |
487 if (!state || !state->tuneInfo || !state->internal) | |
488 return FALSE; | |
489 | |
490 engine = (XSSIDPlay2 *) state->internal; | |
491 if (!(engine->tune)) | |
492 return FALSE; | |
493 | |
494 /* Get general tune information */ | |
495 engine->tune.getInfo(info); | |
496 | |
497 /* NOTICE! Here we assume that libSIDPlay[12] headers define | |
498 * SIDTUNE_SIDMODEL_* similarly to our enums in xs_config.h ... | |
499 */ | |
500 state->tuneInfo->sidModel = info.sidModel; | |
501 | |
502 if (state->currSong > 0 && state->currSong <= state->tuneInfo->nsubTunes) | |
503 { | |
504 gint tmpSpeed = info.clockSpeed; | |
505 switch (info.clockSpeed) | |
506 { | |
507 case SIDTUNE_CLOCK_PAL: tmpSpeed = XS_CLOCK_PAL; break; | |
508 case SIDTUNE_CLOCK_NTSC: tmpSpeed = XS_CLOCK_NTSC; break; | |
509 case SIDTUNE_CLOCK_ANY: tmpSpeed = XS_CLOCK_ANY; break; | |
510 case SIDTUNE_CLOCK_UNKNOWN: | |
511 switch (info.songSpeed) | |
512 { | |
513 case SIDTUNE_SPEED_VBI: tmpSpeed = XS_CLOCK_VBI; break; | |
514 case SIDTUNE_SPEED_CIA_1A: tmpSpeed = XS_CLOCK_CIA; break; | |
515 default: tmpSpeed = info.songSpeed; break; | |
516 } | |
517 break; | |
518 } | |
519 state->tuneInfo->subTunes[state->currSong - 1].tuneSpeed = tmpSpeed; | |
520 } | |
521 | |
522 return TRUE; | |
523 } | |
524 | |
525 | |
448 } /* extern "C" */ | 526 } /* extern "C" */ |
449 #endif /* HAVE_SIDPLAY2 | 527 #endif /* HAVE_SIDPLAY2 |
450 */ | 528 */ |