Mercurial > hg > xmms-sid
annotate src/xs_sidplay2.cpp @ 980:1cd7dead1b56
Add dedication to Taneli, as well. :(
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 28 Mar 2013 15:09:47 +0200 |
parents | be2a8436461a |
children | ede5374e9294 |
rev | line source |
---|---|
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1 /* |
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
2 XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS) |
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
3 |
838
ae1f6418d093
libSIDPlay2-FP backend interface is now in a separate module. Configuration
Matti Hamalainen <ccr@tnsp.org>
parents:
834
diff
changeset
|
4 libSIDPlay2 support |
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
5 |
324 | 6 Programmed and designed by Matti 'ccr' Hamalainen <ccr@tnsp.org> |
744
c7fa50576c70
Initial implementation for supporting libSIDPlay2-FP (or libSIDPlay-FP, as
Matti Hamalainen <ccr@tnsp.org>
parents:
723
diff
changeset
|
7 (C) Copyright 1999-2012 Tecnic Software productions (TNSP) |
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
8 |
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
9 This program is free software; you can redistribute it and/or modify |
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
10 it under the terms of the GNU General Public License as published by |
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
11 the Free Software Foundation; either version 2 of the License, or |
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
12 (at your option) any later version. |
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
13 |
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
14 This program is distributed in the hope that it will be useful, |
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
15 but WITHOUT ANY WARRANTY; without even the implied warranty of |
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
17 GNU General Public License for more details. |
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
18 |
412
7f694e5a1493
Updated GNU GPL (new FSF address) and some cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
19 You should have received a copy of the GNU General Public License along |
7f694e5a1493
Updated GNU GPL (new FSF address) and some cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
20 with this program; if not, write to the Free Software Foundation, Inc., |
7f694e5a1493
Updated GNU GPL (new FSF address) and some cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
21 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
22 */ |
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
23 #include "xmms-sid.h" |
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
24 |
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
25 #ifdef HAVE_SIDPLAY2 |
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
26 |
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
27 #include "xs_sidplay2.h" |
832 | 28 #include "xs_slsup.h" |
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
29 #include "xs_config.h" |
402
f997b79a7251
More work on merging of improved STIL/SLDB handling code with completely
Matti Hamalainen <ccr@tnsp.org>
parents:
396
diff
changeset
|
30 |
833
c0e892fa914a
Begin moving libSIDPlay2-FP stuff to a separete module by removing the
Matti Hamalainen <ccr@tnsp.org>
parents:
832
diff
changeset
|
31 #include <sidplay/sidplay2.h> |
c0e892fa914a
Begin moving libSIDPlay2-FP stuff to a separete module by removing the
Matti Hamalainen <ccr@tnsp.org>
parents:
832
diff
changeset
|
32 #if G_BYTE_ORDER == G_BIG_ENDIAN |
c0e892fa914a
Begin moving libSIDPlay2-FP stuff to a separete module by removing the
Matti Hamalainen <ccr@tnsp.org>
parents:
832
diff
changeset
|
33 # define SID2_NATIVE_UNSIGNED SID2_BIG_UNSIGNED |
c0e892fa914a
Begin moving libSIDPlay2-FP stuff to a separete module by removing the
Matti Hamalainen <ccr@tnsp.org>
parents:
832
diff
changeset
|
34 # define SID2_NATIVE_SIGNED SID2_BIG_SIGNED |
c0e892fa914a
Begin moving libSIDPlay2-FP stuff to a separete module by removing the
Matti Hamalainen <ccr@tnsp.org>
parents:
832
diff
changeset
|
35 #elif G_BYTE_ORDER == G_LITTLE_ENDIAN |
c0e892fa914a
Begin moving libSIDPlay2-FP stuff to a separete module by removing the
Matti Hamalainen <ccr@tnsp.org>
parents:
832
diff
changeset
|
36 # define SID2_NATIVE_UNSIGNED SID2_LITTLE_UNSIGNED |
c0e892fa914a
Begin moving libSIDPlay2-FP stuff to a separete module by removing the
Matti Hamalainen <ccr@tnsp.org>
parents:
832
diff
changeset
|
37 # define SID2_NATIVE_SIGNED SID2_LITTLE_SIGNED |
744
c7fa50576c70
Initial implementation for supporting libSIDPlay2-FP (or libSIDPlay-FP, as
Matti Hamalainen <ccr@tnsp.org>
parents:
723
diff
changeset
|
38 #else |
833
c0e892fa914a
Begin moving libSIDPlay2-FP stuff to a separete module by removing the
Matti Hamalainen <ccr@tnsp.org>
parents:
832
diff
changeset
|
39 # error Unsupported endianess! |
692
0126579b6652
Actually compiles now with libsidplay2 COM API, but does not work yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
40 #endif |
694
fd81a16434ed
Move builder header inclusions.
Matti Hamalainen <ccr@tnsp.org>
parents:
693
diff
changeset
|
41 |
757
9c135d421676
Clean up endianess handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
756
diff
changeset
|
42 |
756
8299288df6d2
Rename internal structures.
Matti Hamalainen <ccr@tnsp.org>
parents:
754
diff
changeset
|
43 class XSSIDPlay2 { |
695 | 44 public: |
770 | 45 sidplay2 emu; |
765 | 46 sid2_config_t config; |
820 | 47 SidTune tune; |
765 | 48 |
756
8299288df6d2
Rename internal structures.
Matti Hamalainen <ccr@tnsp.org>
parents:
754
diff
changeset
|
49 XSSIDPlay2(void); |
795
3e305ce076e8
Make old libSIDPlay2 support work again, the one available in most distros, such as Debian.
Matti Hamalainen <ccr@tnsp.org>
parents:
791
diff
changeset
|
50 virtual ~XSSIDPlay2(void); |
695 | 51 }; |
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
52 |
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
53 |
694
fd81a16434ed
Move builder header inclusions.
Matti Hamalainen <ccr@tnsp.org>
parents:
693
diff
changeset
|
54 #ifdef HAVE_RESID_BUILDER |
833
c0e892fa914a
Begin moving libSIDPlay2-FP stuff to a separete module by removing the
Matti Hamalainen <ccr@tnsp.org>
parents:
832
diff
changeset
|
55 # include <sidplay/builders/resid.h> |
694
fd81a16434ed
Move builder header inclusions.
Matti Hamalainen <ccr@tnsp.org>
parents:
693
diff
changeset
|
56 #endif |
744
c7fa50576c70
Initial implementation for supporting libSIDPlay2-FP (or libSIDPlay-FP, as
Matti Hamalainen <ccr@tnsp.org>
parents:
723
diff
changeset
|
57 |
694
fd81a16434ed
Move builder header inclusions.
Matti Hamalainen <ccr@tnsp.org>
parents:
693
diff
changeset
|
58 #ifdef HAVE_HARDSID_BUILDER |
833
c0e892fa914a
Begin moving libSIDPlay2-FP stuff to a separete module by removing the
Matti Hamalainen <ccr@tnsp.org>
parents:
832
diff
changeset
|
59 # include <sidplay/builders/hardsid.h> |
694
fd81a16434ed
Move builder header inclusions.
Matti Hamalainen <ccr@tnsp.org>
parents:
693
diff
changeset
|
60 #endif |
fd81a16434ed
Move builder header inclusions.
Matti Hamalainen <ccr@tnsp.org>
parents:
693
diff
changeset
|
61 |
fd81a16434ed
Move builder header inclusions.
Matti Hamalainen <ccr@tnsp.org>
parents:
693
diff
changeset
|
62 |
820 | 63 XSSIDPlay2::XSSIDPlay2(void) : tune(0) |
695 | 64 { |
65 } | |
66 | |
67 | |
795
3e305ce076e8
Make old libSIDPlay2 support work again, the one available in most distros, such as Debian.
Matti Hamalainen <ccr@tnsp.org>
parents:
791
diff
changeset
|
68 XSSIDPlay2::~XSSIDPlay2(void) |
3e305ce076e8
Make old libSIDPlay2 support work again, the one available in most distros, such as Debian.
Matti Hamalainen <ccr@tnsp.org>
parents:
791
diff
changeset
|
69 { |
820 | 70 emu.load(NULL); |
795
3e305ce076e8
Make old libSIDPlay2 support work again, the one available in most distros, such as Debian.
Matti Hamalainen <ccr@tnsp.org>
parents:
791
diff
changeset
|
71 } |
3e305ce076e8
Make old libSIDPlay2 support work again, the one available in most distros, such as Debian.
Matti Hamalainen <ccr@tnsp.org>
parents:
791
diff
changeset
|
72 |
3e305ce076e8
Make old libSIDPlay2 support work again, the one available in most distros, such as Debian.
Matti Hamalainen <ccr@tnsp.org>
parents:
791
diff
changeset
|
73 |
270
583f5651abff
Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
74 /* We need to 'export' all this pseudo-C++ crap */ |
396 | 75 extern "C" { |
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
76 |
75
653c9b0d1320
SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents:
74
diff
changeset
|
77 |
270
583f5651abff
Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
78 /* Check if we can play the given file |
75
653c9b0d1320
SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents:
74
diff
changeset
|
79 */ |
751 | 80 gboolean xs_sidplay2_probe(XSFile *f) |
364
421e4fc13bce
More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
81 { |
954
a5b118c853f5
Use xs_fread_str() and improve the probing of each backend to be more
Matti Hamalainen <ccr@tnsp.org>
parents:
869
diff
changeset
|
82 gchar probe[16]; |
a5b118c853f5
Use xs_fread_str() and improve the probing of each backend to be more
Matti Hamalainen <ccr@tnsp.org>
parents:
869
diff
changeset
|
83 |
a5b118c853f5
Use xs_fread_str() and improve the probing of each backend to be more
Matti Hamalainen <ccr@tnsp.org>
parents:
869
diff
changeset
|
84 if (f == NULL || !xs_fread_str(f, (guint8 *) probe, sizeof(probe))) |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
85 return FALSE; |
954
a5b118c853f5
Use xs_fread_str() and improve the probing of each backend to be more
Matti Hamalainen <ccr@tnsp.org>
parents:
869
diff
changeset
|
86 |
a5b118c853f5
Use xs_fread_str() and improve the probing of each backend to be more
Matti Hamalainen <ccr@tnsp.org>
parents:
869
diff
changeset
|
87 // Old libSIDPlay2 does not support PSIDv3, afaik |
a5b118c853f5
Use xs_fread_str() and improve the probing of each backend to be more
Matti Hamalainen <ccr@tnsp.org>
parents:
869
diff
changeset
|
88 if (!strncmp(probe, "PSID", 4) && probe[4] == 0 && |
a5b118c853f5
Use xs_fread_str() and improve the probing of each backend to be more
Matti Hamalainen <ccr@tnsp.org>
parents:
869
diff
changeset
|
89 probe[5] >= 1 && probe[5] <= 2) |
a5b118c853f5
Use xs_fread_str() and improve the probing of each backend to be more
Matti Hamalainen <ccr@tnsp.org>
parents:
869
diff
changeset
|
90 return TRUE; |
a5b118c853f5
Use xs_fread_str() and improve the probing of each backend to be more
Matti Hamalainen <ccr@tnsp.org>
parents:
869
diff
changeset
|
91 else |
a5b118c853f5
Use xs_fread_str() and improve the probing of each backend to be more
Matti Hamalainen <ccr@tnsp.org>
parents:
869
diff
changeset
|
92 if (!strncmp(probe, "RSID", 4) && |
a5b118c853f5
Use xs_fread_str() and improve the probing of each backend to be more
Matti Hamalainen <ccr@tnsp.org>
parents:
869
diff
changeset
|
93 probe[4] == 0 && probe[5] == 2) |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
94 return TRUE; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
95 else |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
96 return FALSE; |
364
421e4fc13bce
More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
97 } |
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
98 |
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
99 |
270
583f5651abff
Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
100 /* Initialize SIDPlay2 |
75
653c9b0d1320
SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents:
74
diff
changeset
|
101 */ |
754
5557837fe5b6
Rename some more variables.
Matti Hamalainen <ccr@tnsp.org>
parents:
753
diff
changeset
|
102 gboolean xs_sidplay2_init(XSEngineState * state) |
364
421e4fc13bce
More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
103 { |
958
828dce1195e6
Oops, fix issues caused by previous changesets.
Matti Hamalainen <ccr@tnsp.org>
parents:
957
diff
changeset
|
104 (void) state; |
957
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
105 return TRUE; |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
106 } |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
107 |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
108 |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
109 /* Close SIDPlay2 engine |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
110 */ |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
111 void xs_sidplay2_close(XSEngineState * state) |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
112 { |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
113 XSDEBUG("SIDPlay2 backend shutdown.\n"); |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
114 |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
115 xs_sidplay2_delete(state); |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
116 } |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
117 |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
118 |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
119 /* Initialize current song and sub-tune |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
120 */ |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
121 gboolean xs_sidplay2_initsong(XSEngineState * state) |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
122 { |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
123 XSSIDPlay2 *engine = (XSSIDPlay2 *) state->internal; |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
124 |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
125 if (!engine) |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
126 return FALSE; |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
127 |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
128 if (!engine->tune.selectSong(state->currSong)) |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
129 { |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
130 xs_error("[SIDPlay2] tune.selectSong() failed\n"); |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
131 return FALSE; |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
132 } |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
133 |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
134 if (engine->emu.load(&(engine->tune)) < 0) |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
135 { |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
136 xs_error("[SIDPlay2] emu.load() failed\n"); |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
137 return FALSE; |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
138 } |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
139 |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
140 if (engine->emu.config(engine->config) < 0) |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
141 { |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
142 xs_error("[SIDPlay2] Emulator engine configuration failed!\n"); |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
143 return FALSE; |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
144 } |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
145 |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
146 return TRUE; |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
147 } |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
148 |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
149 |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
150 /* Emulate and render audio data to given buffer |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
151 */ |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
152 guint xs_sidplay2_fillbuffer(XSEngineState * state, gchar * audioBuffer, guint audioBufSize) |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
153 { |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
154 XSSIDPlay2 *engine = (XSSIDPlay2 *) state->internal; |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
155 |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
156 if (!engine) |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
157 return 0; |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
158 |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
159 return engine->emu.play(audioBuffer, audioBufSize); |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
160 } |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
161 |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
162 |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
163 /* Load a given SID-tune file |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
164 */ |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
165 gboolean xs_sidplay2_load(XSEngineState * state, gchar * filename) |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
166 { |
756
8299288df6d2
Rename internal structures.
Matti Hamalainen <ccr@tnsp.org>
parents:
754
diff
changeset
|
167 XSSIDPlay2 *engine; |
957
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
168 guint8 *buf = NULL; |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
169 size_t bufSize; |
766
19e2745f75d8
Cosmetics and leftover cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
765
diff
changeset
|
170 gint i; |
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
171 |
847
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
172 XSDEBUG("SIDPlay2 backend initializing.\n"); |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
173 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
174 /* Allocate internal structures */ |
756
8299288df6d2
Rename internal structures.
Matti Hamalainen <ccr@tnsp.org>
parents:
754
diff
changeset
|
175 engine = new XSSIDPlay2(); |
754
5557837fe5b6
Rename some more variables.
Matti Hamalainen <ccr@tnsp.org>
parents:
753
diff
changeset
|
176 state->internal = engine; |
770 | 177 if (!engine) |
957
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
178 { |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
179 xs_error("Allocating XSSIDPlay2 compound backend object failed.\n"); |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
180 goto error; |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
181 } |
75
653c9b0d1320
SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents:
74
diff
changeset
|
182 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
183 /* Get current configuration */ |
847
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
184 XSDEBUG("SIDPlay2 emulation configuration\n"); |
770 | 185 engine->config = engine->emu.config(); |
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
186 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
187 /* Configure channels and stuff */ |
766
19e2745f75d8
Cosmetics and leftover cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
765
diff
changeset
|
188 switch (state->audioChannels) |
19e2745f75d8
Cosmetics and leftover cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
765
diff
changeset
|
189 { |
744
c7fa50576c70
Initial implementation for supporting libSIDPlay2-FP (or libSIDPlay-FP, as
Matti Hamalainen <ccr@tnsp.org>
parents:
723
diff
changeset
|
190 case XS_CHN_AUTOPAN: |
765 | 191 engine->config.playback = sid2_stereo; |
744
c7fa50576c70
Initial implementation for supporting libSIDPlay2-FP (or libSIDPlay-FP, as
Matti Hamalainen <ccr@tnsp.org>
parents:
723
diff
changeset
|
192 break; |
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
193 |
744
c7fa50576c70
Initial implementation for supporting libSIDPlay2-FP (or libSIDPlay-FP, as
Matti Hamalainen <ccr@tnsp.org>
parents:
723
diff
changeset
|
194 case XS_CHN_STEREO: |
765 | 195 engine->config.playback = sid2_stereo; |
744
c7fa50576c70
Initial implementation for supporting libSIDPlay2-FP (or libSIDPlay-FP, as
Matti Hamalainen <ccr@tnsp.org>
parents:
723
diff
changeset
|
196 break; |
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
197 |
744
c7fa50576c70
Initial implementation for supporting libSIDPlay2-FP (or libSIDPlay-FP, as
Matti Hamalainen <ccr@tnsp.org>
parents:
723
diff
changeset
|
198 case XS_CHN_MONO: |
c7fa50576c70
Initial implementation for supporting libSIDPlay2-FP (or libSIDPlay-FP, as
Matti Hamalainen <ccr@tnsp.org>
parents:
723
diff
changeset
|
199 default: |
765 | 200 engine->config.playback = sid2_mono; |
754
5557837fe5b6
Rename some more variables.
Matti Hamalainen <ccr@tnsp.org>
parents:
753
diff
changeset
|
201 state->audioChannels = XS_CHN_MONO; |
744
c7fa50576c70
Initial implementation for supporting libSIDPlay2-FP (or libSIDPlay-FP, as
Matti Hamalainen <ccr@tnsp.org>
parents:
723
diff
changeset
|
202 break; |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
203 } |
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
204 |
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
205 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
206 /* Memory mode settings */ |
766
19e2745f75d8
Cosmetics and leftover cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
765
diff
changeset
|
207 switch (xs_cfg.memoryMode) |
19e2745f75d8
Cosmetics and leftover cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
765
diff
changeset
|
208 { |
744
c7fa50576c70
Initial implementation for supporting libSIDPlay2-FP (or libSIDPlay-FP, as
Matti Hamalainen <ccr@tnsp.org>
parents:
723
diff
changeset
|
209 case XS_MPU_BANK_SWITCHING: |
765 | 210 engine->config.environment = sid2_envBS; |
744
c7fa50576c70
Initial implementation for supporting libSIDPlay2-FP (or libSIDPlay-FP, as
Matti Hamalainen <ccr@tnsp.org>
parents:
723
diff
changeset
|
211 break; |
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
212 |
744
c7fa50576c70
Initial implementation for supporting libSIDPlay2-FP (or libSIDPlay-FP, as
Matti Hamalainen <ccr@tnsp.org>
parents:
723
diff
changeset
|
213 case XS_MPU_TRANSPARENT_ROM: |
765 | 214 engine->config.environment = sid2_envTP; |
744
c7fa50576c70
Initial implementation for supporting libSIDPlay2-FP (or libSIDPlay-FP, as
Matti Hamalainen <ccr@tnsp.org>
parents:
723
diff
changeset
|
215 break; |
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
216 |
744
c7fa50576c70
Initial implementation for supporting libSIDPlay2-FP (or libSIDPlay-FP, as
Matti Hamalainen <ccr@tnsp.org>
parents:
723
diff
changeset
|
217 case XS_MPU_PLAYSID_ENVIRONMENT: |
765 | 218 engine->config.environment = sid2_envPS; |
744
c7fa50576c70
Initial implementation for supporting libSIDPlay2-FP (or libSIDPlay-FP, as
Matti Hamalainen <ccr@tnsp.org>
parents:
723
diff
changeset
|
219 break; |
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
220 |
744
c7fa50576c70
Initial implementation for supporting libSIDPlay2-FP (or libSIDPlay-FP, as
Matti Hamalainen <ccr@tnsp.org>
parents:
723
diff
changeset
|
221 case XS_MPU_REAL: |
c7fa50576c70
Initial implementation for supporting libSIDPlay2-FP (or libSIDPlay-FP, as
Matti Hamalainen <ccr@tnsp.org>
parents:
723
diff
changeset
|
222 default: |
765 | 223 engine->config.environment = sid2_envR; |
744
c7fa50576c70
Initial implementation for supporting libSIDPlay2-FP (or libSIDPlay-FP, as
Matti Hamalainen <ccr@tnsp.org>
parents:
723
diff
changeset
|
224 xs_cfg.memoryMode = XS_MPU_REAL; |
c7fa50576c70
Initial implementation for supporting libSIDPlay2-FP (or libSIDPlay-FP, as
Matti Hamalainen <ccr@tnsp.org>
parents:
723
diff
changeset
|
225 break; |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
226 } |
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
227 |
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
228 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
229 /* Audio parameters sanity checking and setup */ |
765 | 230 engine->config.precision = state->audioBitsPerSample; |
231 engine->config.frequency = state->audioFrequency; | |
748
d9d769b5dbe2
Remove oversampling support.
Matti Hamalainen <ccr@tnsp.org>
parents:
744
diff
changeset
|
232 |
74 | 233 |
766
19e2745f75d8
Cosmetics and leftover cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
765
diff
changeset
|
234 switch (state->audioBitsPerSample) |
19e2745f75d8
Cosmetics and leftover cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
765
diff
changeset
|
235 { |
757
9c135d421676
Clean up endianess handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
756
diff
changeset
|
236 case XS_RES_8BIT: |
9c135d421676
Clean up endianess handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
756
diff
changeset
|
237 state->audioFormat = FMT_U8; |
765 | 238 engine->config.sampleFormat = SID2_LITTLE_UNSIGNED; |
758 | 239 break; |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
352
diff
changeset
|
240 |
757
9c135d421676
Clean up endianess handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
756
diff
changeset
|
241 case XS_RES_16BIT: |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
242 default: |
766
19e2745f75d8
Cosmetics and leftover cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
765
diff
changeset
|
243 switch (state->audioFormat) |
19e2745f75d8
Cosmetics and leftover cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
765
diff
changeset
|
244 { |
757
9c135d421676
Clean up endianess handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
756
diff
changeset
|
245 case FMT_U16_LE: |
765 | 246 engine->config.sampleFormat = SID2_LITTLE_UNSIGNED; |
757
9c135d421676
Clean up endianess handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
756
diff
changeset
|
247 break; |
9c135d421676
Clean up endianess handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
756
diff
changeset
|
248 |
9c135d421676
Clean up endianess handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
756
diff
changeset
|
249 case FMT_U16_BE: |
765 | 250 engine->config.sampleFormat = SID2_BIG_UNSIGNED; |
757
9c135d421676
Clean up endianess handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
756
diff
changeset
|
251 break; |
127
ddb513bd2610
Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
252 |
757
9c135d421676
Clean up endianess handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
756
diff
changeset
|
253 case FMT_U16_NE: |
765 | 254 engine->config.sampleFormat = SID2_NATIVE_UNSIGNED; |
757
9c135d421676
Clean up endianess handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
756
diff
changeset
|
255 break; |
9c135d421676
Clean up endianess handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
756
diff
changeset
|
256 |
9c135d421676
Clean up endianess handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
756
diff
changeset
|
257 case FMT_S16_LE: |
765 | 258 engine->config.sampleFormat = SID2_LITTLE_SIGNED; |
757
9c135d421676
Clean up endianess handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
756
diff
changeset
|
259 break; |
9c135d421676
Clean up endianess handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
756
diff
changeset
|
260 |
9c135d421676
Clean up endianess handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
756
diff
changeset
|
261 case FMT_S16_BE: |
765 | 262 engine->config.sampleFormat = SID2_BIG_SIGNED; |
757
9c135d421676
Clean up endianess handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
756
diff
changeset
|
263 break; |
9c135d421676
Clean up endianess handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
756
diff
changeset
|
264 |
9c135d421676
Clean up endianess handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
756
diff
changeset
|
265 default: |
821
dea579b6c3b3
Oops, need to set FMT_S16_NE audio format for XMMS output backend as well
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
266 state->audioFormat = FMT_S16_NE; |
765 | 267 engine->config.sampleFormat = SID2_NATIVE_SIGNED; |
757
9c135d421676
Clean up endianess handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
756
diff
changeset
|
268 break; |
766
19e2745f75d8
Cosmetics and leftover cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
765
diff
changeset
|
269 } |
19e2745f75d8
Cosmetics and leftover cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
765
diff
changeset
|
270 break; |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
271 } |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
272 |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
273 /* Clockspeed settings */ |
765 | 274 switch (xs_cfg.clockSpeed) |
275 { | |
276 case XS_CLOCK_NTSC: | |
277 engine->config.clockDefault = SID2_CLOCK_NTSC; | |
278 break; | |
366
29c4484f1de2
Fixes in emulator engine configuration, make 'forceModel' option work.
Matti Hamalainen <ccr@tnsp.org>
parents:
364
diff
changeset
|
279 |
765 | 280 default: |
281 case XS_CLOCK_PAL: | |
282 engine->config.clockDefault = SID2_CLOCK_PAL; | |
283 xs_cfg.clockSpeed = XS_CLOCK_PAL; | |
284 break; | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
285 } |
366
29c4484f1de2
Fixes in emulator engine configuration, make 'forceModel' option work.
Matti Hamalainen <ccr@tnsp.org>
parents:
364
diff
changeset
|
286 |
29c4484f1de2
Fixes in emulator engine configuration, make 'forceModel' option work.
Matti Hamalainen <ccr@tnsp.org>
parents:
364
diff
changeset
|
287 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
288 /* Configure rest of the emulation */ |
765 | 289 if (xs_cfg.forceSpeed) |
290 { | |
291 engine->config.clockForced = true; | |
292 engine->config.clockSpeed = engine->config.clockDefault; | |
293 } | |
294 else | |
295 { | |
296 engine->config.clockForced = false; | |
297 engine->config.clockSpeed = SID2_CLOCK_CORRECT; | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
298 } |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
299 |
710
a6283cf95c99
Updated to work with latest distortion patched libSIDPlay2+reSID from Antti
Matti Hamalainen <ccr@tnsp.org>
parents:
702
diff
changeset
|
300 |
761 | 301 if (xs_cfg.sid2OptLevel < 0 || xs_cfg.sid2OptLevel > SID2_MAX_OPTIMISATION) |
302 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
303 xs_error("Invalid sid2OptLevel=%d, falling back to %d.\n", |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
304 xs_cfg.sid2OptLevel, SID2_DEFAULT_OPTIMISATION); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
305 |
761 | 306 xs_cfg.sid2OptLevel = SID2_DEFAULT_OPTIMISATION; |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
307 } |
766
19e2745f75d8
Cosmetics and leftover cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
765
diff
changeset
|
308 engine->config.optimisation = xs_cfg.sid2OptLevel; |
366
29c4484f1de2
Fixes in emulator engine configuration, make 'forceModel' option work.
Matti Hamalainen <ccr@tnsp.org>
parents:
364
diff
changeset
|
309 |
765 | 310 engine->config.sidDefault = xs_cfg.mos8580 ? SID2_MOS8580 : SID2_MOS6581; |
311 engine->config.sidModel = xs_cfg.forceModel ? engine->config.sidDefault : SID2_MODEL_CORRECT; | |
312 engine->config.sidSamples = TRUE; | |
321
45ad9f7c1628
Improved compatibility, some fixes in reSID emulation initialization.
Matti Hamalainen <ccr@tnsp.org>
parents:
270
diff
changeset
|
313 |
847
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
314 |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
315 /* Initialize builder object */ |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
316 XSDEBUG("init builder #%i, maxsids=%i\n", xs_cfg.sid2Builder, (engine->emu.info()).maxsids); |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
317 |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
318 switch (xs_cfg.sid2Builder) |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
319 { |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
320 #ifdef HAVE_RESID_BUILDER |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
321 case XS_BLD_RESID: |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
322 { |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
323 ReSIDBuilder *rs = new ReSIDBuilder("ReSID builder"); |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
324 if (rs) |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
325 { |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
326 engine->config.sidEmulation = rs; |
958
828dce1195e6
Oops, fix issues caused by previous changesets.
Matti Hamalainen <ccr@tnsp.org>
parents:
957
diff
changeset
|
327 if (!*rs) goto error; |
847
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
328 rs->create((engine->emu.info()).maxsids); |
958
828dce1195e6
Oops, fix issues caused by previous changesets.
Matti Hamalainen <ccr@tnsp.org>
parents:
957
diff
changeset
|
329 if (!*rs) goto error; |
847
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
330 } |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
331 } |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
332 break; |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
333 #endif |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
334 |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
335 #ifdef HAVE_HARDSID_BUILDER |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
336 case XS_BLD_HARDSID: |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
337 { |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
338 HardSIDBuilder *hs = new HardSIDBuilder("HardSID builder (FP)"); |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
339 engine->config.sidEmulation = (sidbuilder *) hs; |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
340 if (hs) |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
341 { |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
342 hs->create((engine->emu.info()).maxsids); |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
343 if (!*hs) |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
344 { |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
345 xs_error("hardSID->create() failed.\n"); |
958
828dce1195e6
Oops, fix issues caused by previous changesets.
Matti Hamalainen <ccr@tnsp.org>
parents:
957
diff
changeset
|
346 goto error; |
847
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
347 } |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
348 } |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
349 } |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
350 break; |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
351 #endif |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
352 |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
353 default: |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
354 xs_error("[SIDPlay2] Invalid or unsupported builder selected.\n"); |
958
828dce1195e6
Oops, fix issues caused by previous changesets.
Matti Hamalainen <ccr@tnsp.org>
parents:
957
diff
changeset
|
355 goto error; |
847
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
356 } |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
357 |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
358 if (!engine->config.sidEmulation) |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
359 { |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
360 xs_error("[SIDPlay2] Could not initialize SIDBuilder object.\n"); |
958
828dce1195e6
Oops, fix issues caused by previous changesets.
Matti Hamalainen <ccr@tnsp.org>
parents:
957
diff
changeset
|
361 goto error; |
847
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
362 } |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
363 |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
364 XSDEBUG("%s\n", engine->config.sidEmulation->credits()); |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
365 |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
366 |
869
3a9bf45178ff
Use xs_fload_buffer() again, to support potential VFS backends.
Matti Hamalainen <ccr@tnsp.org>
parents:
862
diff
changeset
|
367 if (!xs_fload_buffer(filename, &buf, &bufSize, XS_SIDBUF_SIZE, TRUE)) |
3a9bf45178ff
Use xs_fload_buffer() again, to support potential VFS backends.
Matti Hamalainen <ccr@tnsp.org>
parents:
862
diff
changeset
|
368 goto error; |
3a9bf45178ff
Use xs_fload_buffer() again, to support potential VFS backends.
Matti Hamalainen <ccr@tnsp.org>
parents:
862
diff
changeset
|
369 |
3a9bf45178ff
Use xs_fload_buffer() again, to support potential VFS backends.
Matti Hamalainen <ccr@tnsp.org>
parents:
862
diff
changeset
|
370 engine->tune.read(buf, bufSize); |
820 | 371 if (!engine->tune) |
372 { | |
373 xs_error("Could not load file '%s': %s\n", | |
374 filename, (engine->tune.getInfo()).statusString); | |
869
3a9bf45178ff
Use xs_fload_buffer() again, to support potential VFS backends.
Matti Hamalainen <ccr@tnsp.org>
parents:
862
diff
changeset
|
375 goto error; |
820 | 376 } |
869
3a9bf45178ff
Use xs_fload_buffer() again, to support potential VFS backends.
Matti Hamalainen <ccr@tnsp.org>
parents:
862
diff
changeset
|
377 |
958
828dce1195e6
Oops, fix issues caused by previous changesets.
Matti Hamalainen <ccr@tnsp.org>
parents:
957
diff
changeset
|
378 g_free(buf); |
828dce1195e6
Oops, fix issues caused by previous changesets.
Matti Hamalainen <ccr@tnsp.org>
parents:
957
diff
changeset
|
379 return TRUE; |
869
3a9bf45178ff
Use xs_fload_buffer() again, to support potential VFS backends.
Matti Hamalainen <ccr@tnsp.org>
parents:
862
diff
changeset
|
380 |
3a9bf45178ff
Use xs_fload_buffer() again, to support potential VFS backends.
Matti Hamalainen <ccr@tnsp.org>
parents:
862
diff
changeset
|
381 error: |
958
828dce1195e6
Oops, fix issues caused by previous changesets.
Matti Hamalainen <ccr@tnsp.org>
parents:
957
diff
changeset
|
382 if (engine) |
828dce1195e6
Oops, fix issues caused by previous changesets.
Matti Hamalainen <ccr@tnsp.org>
parents:
957
diff
changeset
|
383 delete engine; |
828dce1195e6
Oops, fix issues caused by previous changesets.
Matti Hamalainen <ccr@tnsp.org>
parents:
957
diff
changeset
|
384 state->internal = NULL; |
869
3a9bf45178ff
Use xs_fload_buffer() again, to support potential VFS backends.
Matti Hamalainen <ccr@tnsp.org>
parents:
862
diff
changeset
|
385 g_free(buf); |
958
828dce1195e6
Oops, fix issues caused by previous changesets.
Matti Hamalainen <ccr@tnsp.org>
parents:
957
diff
changeset
|
386 return FALSE; |
364
421e4fc13bce
More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
387 } |
270
583f5651abff
Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
388 |
583f5651abff
Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
389 |
583f5651abff
Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
390 /* Delete INTERNAL information |
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
391 */ |
754
5557837fe5b6
Rename some more variables.
Matti Hamalainen <ccr@tnsp.org>
parents:
753
diff
changeset
|
392 void xs_sidplay2_delete(XSEngineState * state) |
364
421e4fc13bce
More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
393 { |
957
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
394 XSSIDPlay2 *engine = (XSSIDPlay2 *) state->internal; |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
395 |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
396 if (engine) |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
397 delete engine; |
0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
Matti Hamalainen <ccr@tnsp.org>
parents:
954
diff
changeset
|
398 state->internal = NULL; |
526
fa95d942f226
Header cleanup; Moved some types from xmms-sid.h to xs_player.h; Renamed few functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
474
diff
changeset
|
399 } |
fa95d942f226
Header cleanup; Moved some types from xmms-sid.h to xs_player.h; Renamed few functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
474
diff
changeset
|
400 |
fa95d942f226
Header cleanup; Moved some types from xmms-sid.h to xs_player.h; Renamed few functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
474
diff
changeset
|
401 |
fa95d942f226
Header cleanup; Moved some types from xmms-sid.h to xs_player.h; Renamed few functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
474
diff
changeset
|
402 /* Hardware backend flushing |
fa95d942f226
Header cleanup; Moved some types from xmms-sid.h to xs_player.h; Renamed few functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
474
diff
changeset
|
403 */ |
754
5557837fe5b6
Rename some more variables.
Matti Hamalainen <ccr@tnsp.org>
parents:
753
diff
changeset
|
404 void xs_sidplay2_flush(XSEngineState * state) |
526
fa95d942f226
Header cleanup; Moved some types from xmms-sid.h to xs_player.h; Renamed few functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
474
diff
changeset
|
405 { |
779
8fb51f9ef44e
Fix some HardSID builder related things.
Matti Hamalainen <ccr@tnsp.org>
parents:
776
diff
changeset
|
406 XSSIDPlay2 *engine = (XSSIDPlay2 *) state->internal; |
526
fa95d942f226
Header cleanup; Moved some types from xmms-sid.h to xs_player.h; Renamed few functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
474
diff
changeset
|
407 |
fa95d942f226
Header cleanup; Moved some types from xmms-sid.h to xs_player.h; Renamed few functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
474
diff
changeset
|
408 #ifdef HAVE_HARDSID_BUILDER |
768 | 409 if (xs_cfg.sid2Builder == XS_BLD_HARDSID) |
410 { | |
779
8fb51f9ef44e
Fix some HardSID builder related things.
Matti Hamalainen <ccr@tnsp.org>
parents:
776
diff
changeset
|
411 ((HardSIDBuilder *) engine->config.sidEmulation)->flush(); |
768 | 412 } |
526
fa95d942f226
Header cleanup; Moved some types from xmms-sid.h to xs_player.h; Renamed few functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
474
diff
changeset
|
413 #endif |
364
421e4fc13bce
More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
414 } |
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
415 |
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
416 |
862
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
417 /* This function gets most of the information, though we do miss some |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
418 * (those variables that are only set by libSIDPlay when tune is initialized). |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
419 * Rest of the information is acquired in xs_sidplay2_updateinfo() |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
420 */ |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
421 XSTuneInfo *xs_sidplay2_getinfo(const gchar *filename) |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
422 { |
869
3a9bf45178ff
Use xs_fload_buffer() again, to support potential VFS backends.
Matti Hamalainen <ccr@tnsp.org>
parents:
862
diff
changeset
|
423 XSTuneInfo *res = NULL; |
3a9bf45178ff
Use xs_fload_buffer() again, to support potential VFS backends.
Matti Hamalainen <ccr@tnsp.org>
parents:
862
diff
changeset
|
424 SidTune *tune = NULL; |
862
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
425 SidTuneInfo info; |
869
3a9bf45178ff
Use xs_fload_buffer() again, to support potential VFS backends.
Matti Hamalainen <ccr@tnsp.org>
parents:
862
diff
changeset
|
426 guint8 *buf = NULL; |
3a9bf45178ff
Use xs_fload_buffer() again, to support potential VFS backends.
Matti Hamalainen <ccr@tnsp.org>
parents:
862
diff
changeset
|
427 size_t bufSize; |
862
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
428 |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
429 /* Check if the tune exists and is readable */ |
869
3a9bf45178ff
Use xs_fload_buffer() again, to support potential VFS backends.
Matti Hamalainen <ccr@tnsp.org>
parents:
862
diff
changeset
|
430 if (!xs_fload_buffer(filename, &buf, &bufSize, XS_SIDBUF_SIZE, TRUE)) |
3a9bf45178ff
Use xs_fload_buffer() again, to support potential VFS backends.
Matti Hamalainen <ccr@tnsp.org>
parents:
862
diff
changeset
|
431 { |
3a9bf45178ff
Use xs_fload_buffer() again, to support potential VFS backends.
Matti Hamalainen <ccr@tnsp.org>
parents:
862
diff
changeset
|
432 XSDEBUG("could not load file '%s'.\n", filename); |
3a9bf45178ff
Use xs_fload_buffer() again, to support potential VFS backends.
Matti Hamalainen <ccr@tnsp.org>
parents:
862
diff
changeset
|
433 goto error; |
3a9bf45178ff
Use xs_fload_buffer() again, to support potential VFS backends.
Matti Hamalainen <ccr@tnsp.org>
parents:
862
diff
changeset
|
434 } |
3a9bf45178ff
Use xs_fload_buffer() again, to support potential VFS backends.
Matti Hamalainen <ccr@tnsp.org>
parents:
862
diff
changeset
|
435 |
3a9bf45178ff
Use xs_fload_buffer() again, to support potential VFS backends.
Matti Hamalainen <ccr@tnsp.org>
parents:
862
diff
changeset
|
436 if ((tune = new SidTune(buf, bufSize)) == NULL) |
862
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
437 { |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
438 XSDEBUG("could not initialize tune from '%s'.\n", filename); |
869
3a9bf45178ff
Use xs_fload_buffer() again, to support potential VFS backends.
Matti Hamalainen <ccr@tnsp.org>
parents:
862
diff
changeset
|
439 goto error; |
862
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
440 } |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
441 |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
442 if (!tune->getStatus()) |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
443 { |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
444 XSDEBUG("tune->getStatus() returned false for '%s'.\n", filename); |
869
3a9bf45178ff
Use xs_fload_buffer() again, to support potential VFS backends.
Matti Hamalainen <ccr@tnsp.org>
parents:
862
diff
changeset
|
445 goto error; |
862
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
446 } |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
447 |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
448 /* Get general tune information */ |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
449 tune->getInfo(info); |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
450 |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
451 /* Allocate tuneinfo structure and set information */ |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
452 res = xs_tuneinfo_new(filename, |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
453 info.songs, info.startSong, |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
454 info.infoString[0], info.infoString[1], info.infoString[2], |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
455 info.loadAddr, info.initAddr, info.playAddr, |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
456 info.dataFileLen, info.formatString, |
961
be2a8436461a
Add display of second SID chip to titles, and also new custom format tokens
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
457 info.sidModel, XS_SIDMODEL_UNKNOWN |
862
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
458 ); |
869
3a9bf45178ff
Use xs_fload_buffer() again, to support potential VFS backends.
Matti Hamalainen <ccr@tnsp.org>
parents:
862
diff
changeset
|
459 |
3a9bf45178ff
Use xs_fload_buffer() again, to support potential VFS backends.
Matti Hamalainen <ccr@tnsp.org>
parents:
862
diff
changeset
|
460 error: |
3a9bf45178ff
Use xs_fload_buffer() again, to support potential VFS backends.
Matti Hamalainen <ccr@tnsp.org>
parents:
862
diff
changeset
|
461 if (tune) |
3a9bf45178ff
Use xs_fload_buffer() again, to support potential VFS backends.
Matti Hamalainen <ccr@tnsp.org>
parents:
862
diff
changeset
|
462 delete tune; |
3a9bf45178ff
Use xs_fload_buffer() again, to support potential VFS backends.
Matti Hamalainen <ccr@tnsp.org>
parents:
862
diff
changeset
|
463 |
3a9bf45178ff
Use xs_fload_buffer() again, to support potential VFS backends.
Matti Hamalainen <ccr@tnsp.org>
parents:
862
diff
changeset
|
464 g_free(buf); |
862
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
465 return res; |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
466 } |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
467 |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
468 |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
469 /* Updates the information of currently playing tune |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
470 */ |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
471 gboolean xs_sidplay2_updateinfo(XSEngineState *state) |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
472 { |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
473 XSSIDPlay2 *engine; |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
474 SidTuneInfo info; |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
475 |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
476 /* Check if we have required structures initialized */ |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
477 if (!state || !state->tuneInfo || !state->internal) |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
478 return FALSE; |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
479 |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
480 engine = (XSSIDPlay2 *) state->internal; |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
481 if (!(engine->tune)) |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
482 return FALSE; |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
483 |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
484 /* Get general tune information */ |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
485 engine->tune.getInfo(info); |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
486 |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
487 /* NOTICE! Here we assume that libSIDPlay[12] headers define |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
488 * SIDTUNE_SIDMODEL_* similarly to our enums in xs_config.h ... |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
489 */ |
961
be2a8436461a
Add display of second SID chip to titles, and also new custom format tokens
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
490 state->tuneInfo->sidModel1 = info.sidModel; |
be2a8436461a
Add display of second SID chip to titles, and also new custom format tokens
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
491 state->tuneInfo->sidModel2 = XS_SIDMODEL_UNKNOWN; |
862
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
492 |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
493 if (state->currSong > 0 && state->currSong <= state->tuneInfo->nsubTunes) |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
494 { |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
495 gint tmpSpeed = info.clockSpeed; |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
496 switch (info.clockSpeed) |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
497 { |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
498 case SIDTUNE_CLOCK_PAL: tmpSpeed = XS_CLOCK_PAL; break; |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
499 case SIDTUNE_CLOCK_NTSC: tmpSpeed = XS_CLOCK_NTSC; break; |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
500 case SIDTUNE_CLOCK_ANY: tmpSpeed = XS_CLOCK_ANY; break; |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
501 case SIDTUNE_CLOCK_UNKNOWN: |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
502 switch (info.songSpeed) |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
503 { |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
504 case SIDTUNE_SPEED_VBI: tmpSpeed = XS_CLOCK_VBI; break; |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
505 case SIDTUNE_SPEED_CIA_1A: tmpSpeed = XS_CLOCK_CIA; break; |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
506 default: tmpSpeed = info.songSpeed; break; |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
507 } |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
508 break; |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
509 } |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
510 state->tuneInfo->subTunes[state->currSong - 1].tuneSpeed = tmpSpeed; |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
511 } |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
512 |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
513 return TRUE; |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
514 } |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
515 |
011ba70e271e
Major cleanups, make SIDPlayFP backend compile with libSIDPlayFP v1.0.0
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
516 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
517 } /* extern "C" */ |
847
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
518 #endif /* HAVE_SIDPLAY2 |
5b93bd8c7814
Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
519 */ |