0001-sid-Add-support-for-libsidplayfp.patch
configure.ac | ||
---|---|---|
1166 | 1166 |
echo " Commodore 64 audio (SID): $have_sidplay $xs_have_sidplay2_api" |
1167 | 1167 |
echo " -> libSIDPlay1 support: $xs_have_sidplay1" |
1168 | 1168 |
echo " -> libSIDPlay2 support: $xs_have_sidplay2" |
1169 |
echo " -> libSIDPlayFP support: $xs_have_sidplayfp" |
|
1169 | 1170 |
echo " -> distortion patched libSIDPlay2: $xs_have_distortion" |
1170 | 1171 |
echo " Game music (spc, nsf & gbs): $have_console" |
1171 | 1172 |
echo " PlayStation (psf/psf2) audio: $enable_psf" |
extra.mk.in | ||
---|---|---|
91 | 91 |
SIDPLAY1_LIBS ?= @SIDPLAY1_LIBS@ |
92 | 92 |
SIDPLAY2_CFLAGS ?= @SIDPLAY2_CFLAGS@ |
93 | 93 |
SIDPLAY2_LIBS ?= @SIDPLAY2_LIBS@ |
94 |
SIDPLAYFP_CFLAGS ?= @SIDPLAYFP_CFLAGS@ |
|
95 |
SIDPLAYFP_LIBS ?= @SIDPLAYFP_LIBS@ |
|
94 | 96 |
SNDFILE_CFLAGS ?= @SNDFILE_CFLAGS@ |
95 | 97 |
SNDFILE_LIBS ?= @SNDFILE_LIBS@ |
96 | 98 |
SNDIO_LIBS ?= @SNDIO_LIBS@ |
m4/sid.m4 | ||
---|---|---|
21 | 21 |
fi |
22 | 22 |
fi |
23 | 23 | |
24 |
XS_ARG_WITH([sidplayfp], [libsidplayfp], [XS_PATH_LIBSIDPLAYFP]) |
|
25 |
if test "x$xs_have_sidplayfp" = "xyes"; then |
|
26 |
AC_DEFINE([HAVE_SIDPLAYFP]) |
|
27 |
AC_LANG_PUSH([C++]) |
|
28 |
AC_CHECK_HEADERS([sidplayfp/builders/residfp.h sidplayfp/builders/resid.h sidplayfp/builders/hardsid.h]) |
|
29 |
fi |
|
30 | ||
24 | 31 |
if test "x$xs_have_sidplay2" = "xyes"; then |
25 | 32 |
dnl *** Check for new COMI API |
26 | 33 |
AC_MSG_CHECKING([libSIDPlay2 API style]) |
... | ... | |
64 | 71 |
CPPFLAGS="$tmp_CPPFLAGS" |
65 | 72 |
fi |
66 | 73 | |
67 |
if test "x$xs_have_sidplay1" = "xyes" || test "x$xs_have_sidplay2" = "xyes"; then |
|
74 |
if test "x$xs_have_sidplay1" = "xyes" || test "x$xs_have_sidplay2" = "xyes" || test "x$xs_have_sidplayfp" = "xyes"; then
|
|
68 | 75 |
m4_ifvaln([$1], [$1], [:]) |
69 | 76 |
m4_ifvaln([$2], [else $2]) |
70 | 77 |
fi |
m4/sidplay.m4 | ||
---|---|---|
383 | 383 |
AC_MSG_RESULT([$xs_builders_works]) |
384 | 384 |
AC_SUBST([BUILDERS_LIBS]) |
385 | 385 |
]) |
386 | ||
387 |
dnl ------------------------------------------------------------------------- |
|
388 |
dnl Try to find SIDPLAYFP library and header files. |
|
389 |
dnl $xs_have_sidplayfp will be "yes" or "no" |
|
390 |
dnl @SIDPLAYFP_LIBS@ will be substituted with linker parameters |
|
391 |
dnl @SIDPLAYFP_INCLUDES@ will be substituted with compiler parameters |
|
392 |
dnl ------------------------------------------------------------------------- |
|
393 |
AC_DEFUN([XS_PATH_LIBSIDPLAYFP], |
|
394 |
[ |
|
395 |
PKG_CHECK_MODULES(SIDPLAYFP, [libsidplayfp], |
|
396 |
[xs_have_sidplayfp=yes], [xs_have_sidplayfp=no]) |
|
397 |
]) |
src/sid/Makefile | ||
---|---|---|
9 | 9 |
xs_filter.c \ |
10 | 10 |
xs_sidplay1.cc \ |
11 | 11 |
xs_sidplay2.cc \ |
12 |
xs_sidplayfp.cc \ |
|
12 | 13 |
xs_slsup.c \ |
13 | 14 |
xs_player.c \ |
14 | 15 |
xmms-sid.c |
... | ... | |
21 | 22 |
LD = ${CXX} |
22 | 23 |
CFLAGS += ${PLUGIN_CFLAGS} |
23 | 24 |
CXXFLAGS += ${PLUGIN_CFLAGS} |
24 |
CPPFLAGS += ${PLUGIN_CPPFLAGS} -D_REENTRANT -I../.. ${SIDPLAY1_CFLAGS} ${SIDPLAY2_CFLAGS} ${BUILDERS_CFLAGS} ${GLIB_CFLAGS} |
|
25 |
LIBS += -lm ${BUILDERS_LDFLAGS} ${SIDPLAY1_LIBS} ${SIDPLAY2_LIBS} ${BUILDERS_LIBS} ${GLIB_LIBS} |
|
25 |
CPPFLAGS += ${PLUGIN_CPPFLAGS} -D_REENTRANT -DDATADIR="\"$(datadir)/\"" -I../.. ${SIDPLAY1_CFLAGS} ${SIDPLAY2_CFLAGS} ${SIDPLAYFP_CFLAGS} ${BUILDERS_CFLAGS} ${GLIB_CFLAGS} |
|
26 |
LIBS += -lm ${BUILDERS_LDFLAGS} ${SIDPLAY1_LIBS} ${SIDPLAY2_LIBS} ${SIDPLAYFP_LIBS} ${BUILDERS_LIBS} ${GLIB_LIBS} |
src/sid/xs_config.c | ||
---|---|---|
53 | 53 |
xs_cfg.sid1Filter.fm = XS_SIDPLAY1_FM; |
54 | 54 |
xs_cfg.sid1Filter.ft = XS_SIDPLAY1_FT; |
55 | 55 | |
56 |
#ifdef HAVE_SIDPLAY2 |
|
56 |
#if defined HAVE_SIDPLAYFP |
|
57 |
xs_cfg.playerEngine = XS_ENG_SIDPLAYFP; |
|
58 |
#elif defined HAVE_SIDPLAY2 |
|
57 | 59 |
xs_cfg.playerEngine = XS_ENG_SIDPLAY2; |
58 | 60 |
xs_cfg.memoryMode = XS_MPU_REAL; |
59 |
#else |
|
60 |
#ifdef HAVE_SIDPLAY1 |
|
61 |
#elif defined HAVE_SIDPLAY1 |
|
61 | 62 |
xs_cfg.playerEngine = XS_ENG_SIDPLAY1; |
62 | 63 |
xs_cfg.memoryMode = XS_MPU_BANK_SWITCHING; |
63 | 64 |
#else |
64 | 65 |
#error This should not happen! No emulator engines configured in! |
65 | 66 |
#endif |
66 |
#endif |
|
67 | 67 | |
68 | 68 |
xs_cfg.clockSpeed = XS_CLOCK_PAL; |
69 | 69 |
xs_cfg.forceSpeed = FALSE; |
... | ... | |
71 | 71 |
xs_cfg.sid2OptLevel = 0; |
72 | 72 |
xs_cfg.sid2NFilterPresets = 0; |
73 | 73 | |
74 |
#ifdef HAVE_RESID_BUILDER |
|
74 |
#if defined HAVE_SIDPLAYFP_BUILDERS_RESIDFP_H |
|
75 |
xs_cfg.sid2Builder = XS_BLD_RESIDFP; |
|
76 |
#elif defined HAVE_SIDPLAYFP_BUILDERS_RESID_H || defined HAVE_RESID_BUILDER |
|
75 | 77 |
xs_cfg.sid2Builder = XS_BLD_RESID; |
76 |
#else |
|
77 |
#ifdef HAVE_HARDSID_BUILDER |
|
78 |
#elif defined HAVE_SIDPLAYFP_BUILDERS_HARDSID_H || defined HAVE_HARDSID_BUILDER |
|
78 | 79 |
xs_cfg.sid2Builder = XS_BLD_HARDSID; |
79 |
#else |
|
80 |
#ifdef HAVE_SIDPLAY2 |
|
80 |
#elif defined HAVE_SIDPLAYFP || defined HAVE_SIDPLAY2 |
|
81 | 81 |
#error This should not happen! No supported SIDPlay2 builders configured in! |
82 | 82 |
#endif |
83 |
#endif |
|
84 |
#endif |
|
85 | 83 | |
86 | 84 |
xs_cfg.oversampleEnable = FALSE; |
87 | 85 |
xs_cfg.oversampleFactor = XS_MIN_OVERSAMPLE; |
src/sid/xs_config.h | ||
---|---|---|
12 | 12 |
*/ |
13 | 13 |
enum XS_EMUENGINE { |
14 | 14 |
XS_ENG_SIDPLAY1 = 1, |
15 |
XS_ENG_SIDPLAY2 |
|
15 |
XS_ENG_SIDPLAY2, |
|
16 |
XS_ENG_SIDPLAYFP |
|
16 | 17 |
}; |
17 | 18 | |
18 | 19 | |
19 | 20 |
enum XS_BUILDER { |
20 | 21 |
XS_BLD_RESID = 1, |
22 |
XS_BLD_RESIDFP, |
|
21 | 23 |
XS_BLD_HARDSID |
22 | 24 |
}; |
23 | 25 |
src/sid/xs_player.c | ||
---|---|---|
6 | 6 |
#ifdef HAVE_SIDPLAY2 |
7 | 7 |
#include "xs_sidplay2.h" |
8 | 8 |
#endif |
9 |
#ifdef HAVE_SIDPLAYFP |
|
10 |
#include "xs_sidplayfp.h" |
|
11 |
#endif |
|
9 | 12 | |
10 | 13 | |
11 | 14 |
/* List of emulator engines |
... | ... | |
31 | 34 |
xs_sidplay2_flush |
32 | 35 |
}, |
33 | 36 |
#endif |
37 |
#ifdef HAVE_SIDPLAYFP |
|
38 |
{XS_ENG_SIDPLAYFP, |
|
39 |
xs_sidplayfp_probe, |
|
40 |
xs_sidplayfp_init, xs_sidplayfp_close, |
|
41 |
xs_sidplayfp_initsong, xs_sidplayfp_fillbuffer, |
|
42 |
xs_sidplayfp_load, xs_sidplayfp_delete, |
|
43 |
xs_sidplayfp_getinfo, xs_sidplayfp_updateinfo, |
|
44 |
xs_sidplayfp_flush |
|
45 |
}, |
|
46 |
#endif |
|
34 | 47 |
}; |
35 | 48 | |
36 | 49 |
static const gint xs_nenginelist = (sizeof(xs_enginelist) / sizeof(xs_enginelist[0])); |
src/sid/xs_sidplay.h | ||
---|---|---|
22 | 22 |
*/ |
23 | 23 | |
24 | 24 | |
25 |
#ifndef XS_SIDPLAYFP_H |
|
25 | 26 |
/* This function gets most of the information, though we do miss some |
26 | 27 |
* (those variables that are only set by libSIDPlay when tune is initialized). |
27 | 28 |
* Rest of the information is acquired in TFUNCTION2() |
... | ... | |
78 | 79 | |
79 | 80 |
return pResult; |
80 | 81 |
} |
82 |
#endif |
|
81 | 83 | |
82 | 84 | |
83 | 85 |
/* Updates the information of currently playing tune |
... | ... | |
101 | 103 |
/* Get currently playing tune information */ |
102 | 104 |
#ifdef XS_SIDPLAY1_H |
103 | 105 |
myTune->getInfo(myInfo); |
104 |
#endif |
|
105 |
#ifdef XS_SIDPLAY2_H |
|
106 |
#else |
|
106 | 107 |
myInfo = myTune->getInfo(); |
107 | 108 |
#endif |
108 | 109 | |
... | ... | |
110 | 111 |
* SIDTUNE_SIDMODEL_* similarly to our enums in xs_config.h ... |
111 | 112 |
*/ |
112 | 113 |
i = myStatus->tuneInfo; |
113 |
i->sidModel = myInfo.sidModel; |
|
114 |
#ifdef XS_SIDPLAYFP_H |
|
115 |
i->sidModel = myInfo->sidModel1(); |
|
116 |
#else |
|
117 |
i->sidModel = myInfo.sidModel1; |
|
118 |
#endif |
|
114 | 119 | |
115 | 120 |
if ((myStatus->currSong > 0) && (myStatus->currSong <= i->nsubTunes)) { |
116 | 121 |
gint tmpSpeed = -1; |
117 | 122 |
|
123 |
#ifdef XS_SIDPLAYFP_H |
|
124 |
switch (myInfo->clockSpeed()) { |
|
125 |
#else |
|
118 | 126 |
switch (myInfo.clockSpeed) { |
127 |
#endif |
|
119 | 128 |
case SIDTUNE_CLOCK_PAL: |
120 | 129 |
tmpSpeed = XS_CLOCK_PAL; |
121 | 130 |
break; |
... | ... | |
126 | 135 |
tmpSpeed = XS_CLOCK_ANY; |
127 | 136 |
break; |
128 | 137 |
case SIDTUNE_CLOCK_UNKNOWN: |
138 |
#ifdef XS_SIDPLAYFP_H |
|
139 |
switch (myInfo->songSpeed()) { |
|
140 |
#else |
|
129 | 141 |
switch (myInfo.songSpeed) { |
142 |
#endif |
|
130 | 143 |
case SIDTUNE_SPEED_VBI: |
131 | 144 |
tmpSpeed = XS_CLOCK_VBI; |
132 | 145 |
break; |
... | ... | |
134 | 147 |
tmpSpeed = XS_CLOCK_CIA; |
135 | 148 |
break; |
136 | 149 |
default: |
150 |
#ifdef XS_SIDPLAYFP_H |
|
151 |
tmpSpeed = myInfo->songSpeed(); |
|
152 |
#else |
|
137 | 153 |
tmpSpeed = myInfo.songSpeed; |
154 |
#endif |
|
138 | 155 |
break; |
139 | 156 |
} |
140 | 157 |
default: |
158 |
#ifdef XS_SIDPLAYFP_H |
|
159 |
tmpSpeed = myInfo->clockSpeed(); |
|
160 |
#else |
|
141 | 161 |
tmpSpeed = myInfo.clockSpeed; |
162 |
#endif |
|
142 | 163 |
break; |
143 | 164 |
} |
144 | 165 |
|
src/sid/xs_sidplayfp.cc | ||
---|---|---|
1 |
/* |
|
2 |
XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS) |
|
3 | ||
4 |
libSIDPlay FP support |
|
5 | ||
6 |
Programmed and designed by Matti 'ccr' Hamalainen <ccr@tnsp.org> |
|
7 |
(C) Copyright 1999-2009 Tecnic Software productions (TNSP) |
|
8 | ||
9 |
This program is free software; you can redistribute it and/or modify |
|
10 |
it under the terms of the GNU General Public License as published by |
|
11 |
the Free Software Foundation; either version 2 of the License, or |
|
12 |
(at your option) any later version. |
|
13 | ||
14 |
This program is distributed in the hope that it will be useful, |
|
15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17 |
GNU General Public License for more details. |
|
18 | ||
19 |
You should have received a copy of the GNU General Public License along |
|
20 |
with this program; if not, write to the Free Software Foundation, Inc., |
|
21 |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|
22 |
*/ |
|
23 |
#include "xmms-sid.h" |
|
24 | ||
25 |
#ifdef HAVE_SIDPLAYFP |
|
26 | ||
27 |
#include <stdio.h> |
|
28 |
#include "xs_sidplayfp.h" |
|
29 |
#include "xs_config.h" |
|
30 | ||
31 | ||
32 |
#include <sidplayfp/sidplayfp.h> |
|
33 |
#include <sidplayfp/SidDatabase.h> |
|
34 |
#include <sidplayfp/SidInfo.h> |
|
35 |
#include <sidplayfp/SidTune.h> |
|
36 |
#include <sidplayfp/SidTuneInfo.h> |
|
37 |
#include <sidplayfp/sidbuilder.h> |
|
38 | ||
39 |
class xs_sidplayfp_t { |
|
40 |
public: |
|
41 |
sidplayfp *currEng; |
|
42 |
sidbuilder *currBuilder; |
|
43 |
SidConfig currConfig; |
|
44 |
SidTune *currTune; |
|
45 |
guint8 *buf; |
|
46 |
size_t bufSize; |
|
47 | ||
48 |
xs_sidplayfp_t(void); |
|
49 |
virtual ~xs_sidplayfp_t(void) { ; } |
|
50 |
}; |
|
51 | ||
52 | ||
53 |
#ifdef HAVE_SIDPLAYFP_BUILDERS_RESID_H |
|
54 |
# include <sidplayfp/builders/resid.h> |
|
55 |
#endif |
|
56 |
#ifdef HAVE_SIDPLAYFP_BUILDERS_RESIDFP_H |
|
57 |
# include <sidplayfp/builders/residfp.h> |
|
58 |
#endif |
|
59 |
#ifdef HAVE_SIDPLAYFP_BUILDERS_HARDSID_H |
|
60 |
# include <sidplayfp/builders/hardsid.h> |
|
61 |
#endif |
|
62 | ||
63 | ||
64 |
xs_sidplayfp_t::xs_sidplayfp_t(void) |
|
65 |
:currEng(NULL) |
|
66 |
{ |
|
67 |
buf = NULL; |
|
68 |
bufSize = 0; |
|
69 |
currTune = NULL; |
|
70 |
currBuilder = NULL; |
|
71 |
} |
|
72 | ||
73 | ||
74 |
/* We need to 'export' all this pseudo-C++ crap */ |
|
75 |
extern "C" { |
|
76 | ||
77 | ||
78 |
/* Return song information |
|
79 |
*/ |
|
80 |
#define TFUNCTION2 xs_sidplayfp_updateinfo |
|
81 |
#define TTUNEINFO const SidTuneInfo * |
|
82 |
#define TTUNE SidTune |
|
83 |
#define TENGINE xs_sidplayfp_t |
|
84 |
#define SIDTUNE_CLOCK_UNKNOWN SidTuneInfo::CLOCK_UNKNOWN |
|
85 |
#define SIDTUNE_CLOCK_PAL SidTuneInfo::CLOCK_PAL |
|
86 |
#define SIDTUNE_CLOCK_NTSC SidTuneInfo::CLOCK_NTSC |
|
87 |
#define SIDTUNE_CLOCK_ANY SidTuneInfo::CLOCK_ANY |
|
88 |
#define SIDTUNE_SPEED_VBI SidTuneInfo::SPEED_VBI |
|
89 |
#define SIDTUNE_SPEED_CIA_1A SidTuneInfo::SPEED_CIA_1A |
|
90 |
#include "xs_sidplay.h" |
|
91 | ||
92 |
/* Check if we can play the given file |
|
93 |
*/ |
|
94 |
gboolean xs_sidplayfp_probe(xs_file_t *f) |
|
95 |
{ |
|
96 |
gchar tmpBuf[5]; |
|
97 | ||
98 |
if (f == NULL) return FALSE; |
|
99 | ||
100 |
if (xs_fread(tmpBuf, sizeof(gchar), 4, f) != 4) |
|
101 |
return FALSE; |
|
102 | ||
103 |
if (!strncmp(tmpBuf, "PSID", 4) || !strncmp(tmpBuf, "RSID", 4)) |
|
104 |
return TRUE; |
|
105 |
else |
|
106 |
return FALSE; |
|
107 |
} |
|
108 | ||
109 | ||
110 |
/* Initialize SIDPlayFP |
|
111 |
*/ |
|
112 |
gboolean xs_sidplayfp_init(xs_status_t * status) |
|
113 |
{ |
|
114 |
xs_sidplayfp_t *engine; |
|
115 |
assert(status != NULL); |
|
116 | ||
117 |
/* Allocate internal structures */ |
|
118 |
engine = new xs_sidplayfp_t(); |
|
119 |
status->sidEngine = engine; |
|
120 |
if (!engine) return FALSE; |
|
121 | ||
122 |
/* Initialize the engine */ |
|
123 |
engine->currEng = new sidplayfp; |
|
124 |
if (!engine->currEng) { |
|
125 |
xs_error("[SIDPlayFP] Could not initialize emulation engine.\n"); |
|
126 |
return FALSE; |
|
127 |
} |
|
128 | ||
129 |
/* Get current configuration */ |
|
130 |
engine->currConfig = engine->currEng->config(); |
|
131 | ||
132 |
/* Configure channels and stuff */ |
|
133 |
switch (status->audioChannels) { |
|
134 | ||
135 |
case XS_CHN_AUTOPAN: |
|
136 |
engine->currConfig.playback = SidConfig::MONO; |
|
137 |
break; |
|
138 | ||
139 |
case XS_CHN_STEREO: |
|
140 |
engine->currConfig.playback = SidConfig::STEREO; |
|
141 |
break; |
|
142 | ||
143 |
case XS_CHN_MONO: |
|
144 |
default: |
|
145 |
engine->currConfig.playback = SidConfig::MONO; |
|
146 |
status->audioChannels = XS_CHN_MONO; |
|
147 |
break; |
|
148 |
} |
|
149 |
status->audioFormat = FMT_S16_NE; |
|
150 | ||
151 |
/* Audio parameters sanity checking and setup */ |
|
152 |
engine->currConfig.frequency = status->audioFrequency; |
|
153 |
if (status->oversampleEnable) |
|
154 |
engine->currConfig.frequency *= status->oversampleFactor; |
|
155 | ||
156 |
/* Initialize builder object */ |
|
157 |
XSDEBUG("init builder #%i, maxsids=%i\n", xs_cfg.sid2Builder, engine->currEng->info().maxsids()); |
|
158 |
#ifdef HAVE_SIDPLAYFP_BUILDERS_RESID_H |
|
159 |
if (xs_cfg.sid2Builder == XS_BLD_RESID) { |
|
160 |
ReSIDBuilder *rs = new ReSIDBuilder("ReSID builder"); |
|
161 |
engine->currBuilder = (sidbuilder *) rs; |
|
162 |
} |
|
163 |
#endif |
|
164 |
#ifdef HAVE_SIDPLAYFP_BUILDERS_RESIDFP_H |
|
165 |
if (xs_cfg.sid2Builder == XS_BLD_RESIDFP) { |
|
166 |
ReSIDfpBuilder *rs = new ReSIDfpBuilder("ReSIDfp builder"); |
|
167 |
engine->currBuilder = (sidbuilder *) rs; |
|
168 |
} |
|
169 |
#endif |
|
170 |
#ifdef HAVE_SIDPLAYFP_BUILDERS_HARDSID_H |
|
171 |
if (xs_cfg.sid2Builder == XS_BLD_HARDSID) { |
|
172 |
HardSIDBuilder *hs = new HardSIDBuilder("HardSID builder"); |
|
173 |
engine->currBuilder = (sidbuilder *) hs; |
|
174 |
} |
|
175 |
#endif |
|
176 | ||
177 |
if (!engine->currBuilder) { |
|
178 |
xs_error("[SIDPlayFP] Could not initialize SIDBuilder object.\n"); |
|
179 |
return FALSE; |
|
180 |
} |
|
181 | ||
182 |
/* Builder object created, initialize it */ |
|
183 |
engine->currBuilder->create(engine->currEng->info().maxsids()); |
|
184 |
if (!engine->currBuilder->getStatus()) { |
|
185 |
xs_error("reSID->create() failed.\n"); |
|
186 |
return FALSE; |
|
187 |
} |
|
188 | ||
189 |
XSDEBUG("filter setting NOT supported with libsidplayfp.\n"); |
|
190 | ||
191 |
engine->currBuilder->filter(xs_cfg.emulateFilters); |
|
192 |
if (!engine->currBuilder->getStatus()) { |
|
193 |
xs_error("reSID->filter(%d) failed.\n", xs_cfg.emulateFilters); |
|
194 |
return FALSE; |
|
195 |
} |
|
196 | ||
197 |
engine->currConfig.sidEmulation = engine->currBuilder; |
|
198 |
XSDEBUG("%s\n", engine->currBuilder->credits()); |
|
199 | ||
200 |
/* Clockspeed settings */ |
|
201 |
switch (xs_cfg.clockSpeed) { |
|
202 |
case XS_CLOCK_NTSC: |
|
203 |
engine->currConfig.defaultC64Model = SidConfig::NTSC; |
|
204 |
break; |
|
205 | ||
206 |
default: |
|
207 |
xs_error("[SIDPlayFP] Invalid clockSpeed=%d, falling back to PAL.\n", |
|
208 |
xs_cfg.clockSpeed); |
|
209 | ||
210 |
case XS_CLOCK_PAL: |
|
211 |
engine->currConfig.defaultC64Model = SidConfig::PAL; |
|
212 |
xs_cfg.clockSpeed = XS_CLOCK_PAL; |
|
213 |
break; |
|
214 |
} |
|
215 | ||
216 |
/* Configure rest of the emulation */ |
|
217 |
if (xs_cfg.mos8580) |
|
218 |
engine->currConfig.defaultSidModel = SidConfig::MOS8580; |
|
219 |
else |
|
220 |
engine->currConfig.defaultSidModel = SidConfig::MOS6581; |
|
221 | ||
222 |
engine->currConfig.forceSidModel = xs_cfg.forceModel; |
|
223 | ||
224 |
/* Now set the emulator configuration */ |
|
225 |
if (engine->currEng->config(engine->currConfig) < 0) { |
|
226 |
xs_error("[SIDPlayFP] Emulator engine configuration failed!\n"); |
|
227 |
return FALSE; |
|
228 |
} |
|
229 | ||
230 |
/* Create the sidtune */ |
|
231 |
engine->currTune = new SidTune(0); |
|
232 |
if (!engine->currTune) { |
|
233 |
xs_error("[SIDPlayFP] Could not initialize SIDTune object.\n"); |
|
234 |
return FALSE; |
|
235 |
} |
|
236 | ||
237 |
return TRUE; |
|
238 |
} |
|
239 | ||
240 | ||
241 |
/* Close SIDPlayFP engine |
|
242 |
*/ |
|
243 |
void xs_sidplayfp_close(xs_status_t * status) |
|
244 |
{ |
|
245 |
xs_sidplayfp_t *engine; |
|
246 |
assert(status != NULL); |
|
247 | ||
248 |
engine = (xs_sidplayfp_t *) status->sidEngine; |
|
249 | ||
250 |
/* Free internals */ |
|
251 |
if (engine->currBuilder) { |
|
252 |
delete engine->currBuilder; |
|
253 |
engine->currBuilder = NULL; |
|
254 |
} |
|
255 | ||
256 |
if (engine->currEng) { |
|
257 |
delete engine->currEng; |
|
258 |
engine->currEng = NULL; |
|
259 |
} |
|
260 | ||
261 |
if (engine->currTune) { |
|
262 |
delete engine->currTune; |
|
263 |
engine->currTune = NULL; |
|
264 |
} |
|
265 | ||
266 |
xs_sidplayfp_delete(status); |
|
267 | ||
268 |
delete engine; |
|
269 |
status->sidEngine = NULL; |
|
270 |
} |
|
271 | ||
272 | ||
273 |
/* Initialize current song and sub-tune |
|
274 |
*/ |
|
275 |
gboolean xs_sidplayfp_initsong(xs_status_t * status) |
|
276 |
{ |
|
277 |
xs_sidplayfp_t *engine; |
|
278 |
assert(status != NULL); |
|
279 | ||
280 |
engine = (xs_sidplayfp_t *) status->sidEngine; |
|
281 |
if (engine == NULL) return FALSE; |
|
282 | ||
283 |
if (!engine->currTune->selectSong(status->currSong)) { |
|
284 |
xs_error("[SIDPlayFP] currTune->selectSong() failed\n"); |
|
285 |
return FALSE; |
|
286 |
} |
|
287 | ||
288 |
if (engine->currEng->load(engine->currTune) < 0) { |
|
289 |
xs_error("[SIDPlayFP] currEng->load() failed\n"); |
|
290 |
return FALSE; |
|
291 |
} |
|
292 | ||
293 |
status->isInitialized = TRUE; |
|
294 | ||
295 |
return TRUE; |
|
296 |
} |
|
297 | ||
298 | ||
299 |
/* Emulate and render audio data to given buffer |
|
300 |
*/ |
|
301 |
guint xs_sidplayfp_fillbuffer(xs_status_t * status, gchar * audioBuffer, guint audioBufSize) |
|
302 |
{ |
|
303 |
xs_sidplayfp_t *engine; |
|
304 |
assert(status != NULL); |
|
305 | ||
306 |
engine = (xs_sidplayfp_t *) status->sidEngine; |
|
307 |
if (!engine) return 0; |
|
308 | ||
309 |
return engine->currEng->play((short *)audioBuffer, audioBufSize / 2) * 2; |
|
310 |
} |
|
311 | ||
312 | ||
313 |
/* Load a given SID-tune file |
|
314 |
*/ |
|
315 |
gboolean xs_sidplayfp_load(xs_status_t * status, const gchar * pcFilename) |
|
316 |
{ |
|
317 |
/* This is safe, since xmms-sid.c always calls us with xs_status locked */ |
|
318 |
static int loaded_roms = 0; |
|
319 | ||
320 |
xs_sidplayfp_t *engine; |
|
321 |
assert(status != NULL); |
|
322 |
status->isInitialized = FALSE; |
|
323 | ||
324 |
engine = (xs_sidplayfp_t *) status->sidEngine; |
|
325 |
if (!engine) return FALSE; |
|
326 | ||
327 |
/* In xs_sidplayfp_init aud-vfs is not initialized yet, so try to load |
|
328 |
the optional rom files on the first xs_sidplayfp_load call. */ |
|
329 |
if (!loaded_roms) { |
|
330 |
size_t size = 0; |
|
331 |
guint8 *kernal = NULL, *basic = NULL, *chargen = NULL; |
|
332 | ||
333 |
if (xs_fload_buffer("file://" DATADIR "sidplayfp/kernal", |
|
334 |
&kernal, &size) != 0 || size != 8192) { |
|
335 |
g_free(kernal); |
|
336 |
kernal = NULL; |
|
337 |
} |
|
338 |
if (xs_fload_buffer("file://" DATADIR "sidplayfp/basic", |
|
339 |
&basic, &size) != 0 || size != 8192) { |
|
340 |
g_free(basic); |
|
341 |
basic = NULL; |
|
342 |
} |
|
343 |
if (xs_fload_buffer("file://" DATADIR "sidplayfp/chargen", |
|
344 |
&chargen, &size) != 0 || size != 4096) { |
|
345 |
g_free(chargen); |
|
346 |
chargen = NULL; |
|
347 |
} |
|
348 |
engine->currEng->setRoms(kernal, basic, chargen); |
|
349 |
g_free(kernal); |
|
350 |
g_free(basic); |
|
351 |
g_free(chargen); |
|
352 |
loaded_roms = 1; |
|
353 |
} |
|
354 | ||
355 |
/* Try to get the tune */ |
|
356 |
if (!pcFilename) return FALSE; |
|
357 | ||
358 |
if (xs_fload_buffer(pcFilename, &(engine->buf), &(engine->bufSize)) != 0) |
|
359 |
return FALSE; |
|
360 | ||
361 |
engine->currTune->read(engine->buf, engine->bufSize); |
|
362 | ||
363 |
return engine->currTune->getStatus(); |
|
364 |
} |
|
365 | ||
366 | ||
367 |
/* Delete INTERNAL information |
|
368 |
*/ |
|
369 |
void xs_sidplayfp_delete(xs_status_t * status) |
|
370 |
{ |
|
371 |
xs_sidplayfp_t *engine; |
|
372 |
assert(status != NULL); |
|
373 | ||
374 |
engine = (xs_sidplayfp_t *) status->sidEngine; |
|
375 |
if (engine == NULL) return; |
|
376 | ||
377 |
g_free(engine->buf); |
|
378 |
engine->buf = NULL; |
|
379 |
engine->bufSize = 0; |
|
380 |
} |
|
381 | ||
382 | ||
383 |
/* Hardware backend flushing |
|
384 |
*/ |
|
385 |
void xs_sidplayfp_flush(xs_status_t * status) |
|
386 |
{ |
|
387 |
assert(status != NULL); |
|
388 | ||
389 |
#ifdef HAVE_HARDSID_BUILDER |
|
390 |
if (xs_cfg.sid2Builder == XS_BLD_HARDSID) |
|
391 |
((HardSIDBuilder *) status->currBuilder)->flush(); |
|
392 |
#endif |
|
393 |
} |
|
394 | ||
395 |
xs_tuneinfo_t* xs_sidplayfp_getinfo(const gchar *sidFilename) |
|
396 |
{ |
|
397 |
/* This is safe, since xmms-sid.c always calls us with xs_status locked */ |
|
398 |
static int got_db = -1; |
|
399 |
static SidDatabase database; |
|
400 | ||
401 |
xs_tuneinfo_t *result; |
|
402 |
const SidTuneInfo *myInfo; |
|
403 |
SidTune *myTune; |
|
404 |
guint8 *buf = NULL; |
|
405 |
size_t bufSize = 0; |
|
406 | ||
407 |
/* Load file */ |
|
408 |
if (!sidFilename) return NULL; |
|
409 | ||
410 |
if (xs_fload_buffer(sidFilename, &buf, &bufSize) != 0) |
|
411 |
return NULL; |
|
412 | ||
413 |
/* Check if the tune exists and is readable */ |
|
414 |
if ((myTune = new SidTune(buf, bufSize)) == NULL) { |
|
415 |
g_free(buf); |
|
416 |
return NULL; |
|
417 |
} |
|
418 |
g_free(buf); |
|
419 | ||
420 |
if (!myTune->getStatus()) { |
|
421 |
delete myTune; |
|
422 |
return NULL; |
|
423 |
} |
|
424 | ||
425 |
/* Get general tune information */ |
|
426 |
myInfo = myTune->getInfo(); |
|
427 | ||
428 |
/* Allocate tuneinfo structure and set information */ |
|
429 |
result = xs_tuneinfo_new(sidFilename, |
|
430 |
myInfo->songs(), myInfo->startSong(), |
|
431 |
myInfo->infoString(0), myInfo->infoString(1), myInfo->infoString(2), |
|
432 |
myInfo->loadAddr(), myInfo->initAddr(), myInfo->playAddr(), |
|
433 |
myInfo->dataFileLen(), myInfo->formatString(), myInfo->sidModel1()); |
|
434 | ||
435 |
for (int i = 0; i < result->nsubTunes; i++) { |
|
436 |
if (result->subTunes[i].tuneLength >= 0) |
|
437 |
continue; |
|
438 | ||
439 |
if (got_db == -1) |
|
440 |
got_db = database.open(DATADIR "sidplayfp/Songlengths.txt"); |
|
441 | ||
442 |
if (got_db) { |
|
443 |
myTune->selectSong(i + 1); |
|
444 |
result->subTunes[i].tuneLength = database.length(*myTune); |
|
445 |
} |
|
446 |
} |
|
447 | ||
448 |
delete myTune; |
|
449 | ||
450 |
return result; |
|
451 |
} |
|
452 | ||
453 |
} /* extern "C" */ |
|
454 |
#endif /* HAVE_SIDPLAYFP */ |
src/sid/xs_sidplayfp.h | ||
---|---|---|
1 |
#ifndef XS_SIDPLAYFP_H |
|
2 |
#define XS_SIDPLAYFP_H |
|
3 | ||
4 |
#include "xs_player.h" |
|
5 |
#include "xs_support.h" |
|
6 |
#include "xs_slsup.h" |
|
7 | ||
8 |
#ifdef __cplusplus |
|
9 |
extern "C" { |
|
10 |
#endif |
|
11 | ||
12 |
gboolean xs_sidplayfp_probe(xs_file_t *); |
|
13 |
void xs_sidplayfp_close(xs_status_t *); |
|
14 |
gboolean xs_sidplayfp_init(xs_status_t *); |
|
15 |
gboolean xs_sidplayfp_initsong(xs_status_t *); |
|
16 |
guint xs_sidplayfp_fillbuffer(xs_status_t *, gchar *, guint); |
|
17 |
gboolean xs_sidplayfp_load(xs_status_t *, const gchar *); |
|
18 |
void xs_sidplayfp_delete(xs_status_t *); |
|
19 |
xs_tuneinfo_t* xs_sidplayfp_getinfo(const gchar *); |
|
20 |
gboolean xs_sidplayfp_updateinfo(xs_status_t *); |
|
21 |
void xs_sidplayfp_flush(xs_status_t *); |
|
22 | ||
23 |
#ifdef __cplusplus |
|
24 |
} |
|
25 |
#endif |
|
26 |
#endif /* XS_SIDPLAYFP_H */ |
|
0 |
- |