Mercurial > hg > xmms-sid
diff 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 |
line wrap: on
line diff
--- a/src/xs_sidplay2.cpp Fri Nov 09 00:19:21 2012 +0200 +++ b/src/xs_sidplay2.cpp Fri Nov 09 02:11:21 2012 +0200 @@ -75,16 +75,6 @@ extern "C" { -/* Return song information - */ -#define TFUNCTION xs_sidplay2_getinfo -#define TFUNCTION2 xs_sidplay2_updateinfo -#define TENGINE XSSIDPlay2 -#define TTUNEINFO SidTuneInfo -#define TTUNE SidTune -#include "xs_sidplay.h" - - /* Check if we can play the given file */ gboolean xs_sidplay2_probe(XSFile *f) @@ -445,6 +435,94 @@ } +/* This function gets most of the information, though we do miss some + * (those variables that are only set by libSIDPlay when tune is initialized). + * Rest of the information is acquired in xs_sidplay2_updateinfo() + */ +XSTuneInfo *xs_sidplay2_getinfo(const gchar *filename) +{ + XSTuneInfo *res; + SidTune *tune; + SidTuneInfo info; + + /* Check if the tune exists and is readable */ + if ((tune = new SidTune(filename)) == NULL) + { + XSDEBUG("could not initialize tune from '%s'.\n", filename); + return NULL; + } + + if (!tune->getStatus()) + { + XSDEBUG("tune->getStatus() returned false for '%s'.\n", filename); + delete tune; + return NULL; + } + + /* Get general tune information */ + tune->getInfo(info); + + /* Allocate tuneinfo structure and set information */ + res = xs_tuneinfo_new(filename, + info.songs, info.startSong, + info.infoString[0], info.infoString[1], info.infoString[2], + info.loadAddr, info.initAddr, info.playAddr, + info.dataFileLen, info.formatString, + info.sidModel + ); + + delete tune; + return res; +} + + +/* Updates the information of currently playing tune + */ +gboolean xs_sidplay2_updateinfo(XSEngineState *state) +{ + XSSIDPlay2 *engine; + SidTuneInfo info; + + /* Check if we have required structures initialized */ + if (!state || !state->tuneInfo || !state->internal) + return FALSE; + + engine = (XSSIDPlay2 *) state->internal; + if (!(engine->tune)) + return FALSE; + + /* Get general tune information */ + engine->tune.getInfo(info); + + /* NOTICE! Here we assume that libSIDPlay[12] headers define + * SIDTUNE_SIDMODEL_* similarly to our enums in xs_config.h ... + */ + state->tuneInfo->sidModel = info.sidModel; + + if (state->currSong > 0 && state->currSong <= state->tuneInfo->nsubTunes) + { + gint tmpSpeed = info.clockSpeed; + switch (info.clockSpeed) + { + case SIDTUNE_CLOCK_PAL: tmpSpeed = XS_CLOCK_PAL; break; + case SIDTUNE_CLOCK_NTSC: tmpSpeed = XS_CLOCK_NTSC; break; + case SIDTUNE_CLOCK_ANY: tmpSpeed = XS_CLOCK_ANY; break; + case SIDTUNE_CLOCK_UNKNOWN: + switch (info.songSpeed) + { + case SIDTUNE_SPEED_VBI: tmpSpeed = XS_CLOCK_VBI; break; + case SIDTUNE_SPEED_CIA_1A: tmpSpeed = XS_CLOCK_CIA; break; + default: tmpSpeed = info.songSpeed; break; + } + break; + } + state->tuneInfo->subTunes[state->currSong - 1].tuneSpeed = tmpSpeed; + } + + return TRUE; +} + + } /* extern "C" */ #endif /* HAVE_SIDPLAY2 */