Mercurial > hg > xmms-sid
annotate src/xs_sidplay.h @ 849:2663b1ac9ce6
Improve debugging.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 08 Nov 2012 23:02:05 +0200 |
parents | ae1f6418d093 |
children |
rev | line source |
---|---|
479
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
1 /* |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
2 XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS) |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
3 |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
4 libSIDPlay skeleton functions used both by v1 and 2 of the backends |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
5 |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
6 Programmed and designed by Matti 'ccr' Hamalainen <ccr@tnsp.org> |
723 | 7 (C) Copyright 2005-2009 Tecnic Software productions (TNSP) |
479
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
8 |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
9 This program is free software; you can redistribute it and/or modify |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
10 it under the terms of the GNU General Public License as published by |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
11 the Free Software Foundation; either version 2 of the License, or |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
12 (at your option) any later version. |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
13 |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
14 This program is distributed in the hope that it will be useful, |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
15 but WITHOUT ANY WARRANTY; without even the implied warranty of |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
17 GNU General Public License for more details. |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
18 |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
19 You should have received a copy of the GNU General Public License along |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
20 with this program; if not, write to the Free Software Foundation, Inc., |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
21 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
22 */ |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
23 |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
24 |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
25 /* This function gets most of the information, though we do miss some |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
26 * (those variables that are only set by libSIDPlay when tune is initialized). |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
27 * Rest of the information is acquired in TFUNCTION2() |
76 | 28 */ |
796
dfda3d47baf7
Clean up the variables etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
762
diff
changeset
|
29 XSTuneInfo *TFUNCTION(const gchar *filename) |
76 | 30 { |
762 | 31 XSTuneInfo *res; |
796
dfda3d47baf7
Clean up the variables etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
762
diff
changeset
|
32 TTUNEINFO info; |
dfda3d47baf7
Clean up the variables etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
762
diff
changeset
|
33 TTUNE *tune; |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
34 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
35 /* Check if the tune exists and is readable */ |
849 | 36 if ((tune = new TTUNE(filename)) == NULL) |
762 | 37 { |
849 | 38 XSDEBUG("could not initialize tune from '%s'.\n", filename); |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
39 return NULL; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
40 } |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
41 |
796
dfda3d47baf7
Clean up the variables etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
762
diff
changeset
|
42 if (!tune->getStatus()) |
762 | 43 { |
849 | 44 XSDEBUG("tune->getStatus() returned false for '%s'.\n", filename); |
796
dfda3d47baf7
Clean up the variables etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
762
diff
changeset
|
45 delete tune; |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
46 return NULL; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
47 } |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
48 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
49 /* Get general tune information */ |
849 | 50 #if defined(XS_SIDPLAY1_H) |
796
dfda3d47baf7
Clean up the variables etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
762
diff
changeset
|
51 tune->getInfo(info); |
849 | 52 #elif defined(XS_SIDPLAY2_H) |
53 info = tune->getInfo(); | |
54 #elif defined(XS_SIDPLAYFP_H) | |
796
dfda3d47baf7
Clean up the variables etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
762
diff
changeset
|
55 info = tune->getInfo(); |
95 | 56 #endif |
57 | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
58 /* Allocate tuneinfo structure and set information */ |
796
dfda3d47baf7
Clean up the variables etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
762
diff
changeset
|
59 res = xs_tuneinfo_new(filename, |
dfda3d47baf7
Clean up the variables etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
762
diff
changeset
|
60 info.songs, info.startSong, |
dfda3d47baf7
Clean up the variables etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
762
diff
changeset
|
61 info.infoString[0], info.infoString[1], info.infoString[2], |
dfda3d47baf7
Clean up the variables etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
762
diff
changeset
|
62 info.loadAddr, info.initAddr, info.playAddr, |
dfda3d47baf7
Clean up the variables etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
762
diff
changeset
|
63 info.dataFileLen, info.formatString, |
838
ae1f6418d093
libSIDPlay2-FP backend interface is now in a separate module. Configuration
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
64 #if defined(XS_SIDPLAYFP_H) && defined(HAVE_SIDPLAYFP) |
796
dfda3d47baf7
Clean up the variables etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
762
diff
changeset
|
65 info.sidModel1 |
744
c7fa50576c70
Initial implementation for supporting libSIDPlay2-FP (or libSIDPlay-FP, as
Matti Hamalainen <ccr@tnsp.org>
parents:
723
diff
changeset
|
66 #else |
796
dfda3d47baf7
Clean up the variables etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
762
diff
changeset
|
67 info.sidModel |
744
c7fa50576c70
Initial implementation for supporting libSIDPlay2-FP (or libSIDPlay-FP, as
Matti Hamalainen <ccr@tnsp.org>
parents:
723
diff
changeset
|
68 #endif |
c7fa50576c70
Initial implementation for supporting libSIDPlay2-FP (or libSIDPlay-FP, as
Matti Hamalainen <ccr@tnsp.org>
parents:
723
diff
changeset
|
69 ); |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
70 |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
71 /* NOTICE! libSIDPlay[12] headers specifically state that sidModel, |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
72 * songSpeed and clockSpeed are "undefined" before song initialization, |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
73 * but in practice sidModel is known after getInfo() invocation... |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
74 * This of course does not take the sub-tune specific changes into account, |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
75 * but at least we have a reasonable guesstimate. |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
76 */ |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
77 |
796
dfda3d47baf7
Clean up the variables etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
762
diff
changeset
|
78 delete tune; |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
79 |
762 | 80 return res; |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
81 } |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
82 |
445
f277dad3180f
Working on the localization and fixing up the breakage in song information
Matti Hamalainen <ccr@tnsp.org>
parents:
412
diff
changeset
|
83 |
479
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
84 /* Updates the information of currently playing tune |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
85 */ |
762 | 86 gboolean TFUNCTION2(XSEngineState *state) |
445
f277dad3180f
Working on the localization and fixing up the breakage in song information
Matti Hamalainen <ccr@tnsp.org>
parents:
412
diff
changeset
|
87 { |
796
dfda3d47baf7
Clean up the variables etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
762
diff
changeset
|
88 TTUNEINFO info; |
762 | 89 TENGINE *engine; |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
90 |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
91 /* Check if we have required structures initialized */ |
762 | 92 if (!state || !state->tuneInfo || !state->internal) |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
93 return FALSE; |
460 | 94 |
762 | 95 engine = (TENGINE *) state->internal; |
820 | 96 if (!(engine->tune)) |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
97 return FALSE; |
445
f277dad3180f
Working on the localization and fixing up the breakage in song information
Matti Hamalainen <ccr@tnsp.org>
parents:
412
diff
changeset
|
98 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
99 /* Get currently playing tune information */ |
838
ae1f6418d093
libSIDPlay2-FP backend interface is now in a separate module. Configuration
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
100 #if defined(XS_SIDPLAY1_H) |
820 | 101 engine->tune->getInfo(info); |
838
ae1f6418d093
libSIDPlay2-FP backend interface is now in a separate module. Configuration
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
102 #elif defined(XS_SIDPLAY2_H) |
ae1f6418d093
libSIDPlay2-FP backend interface is now in a separate module. Configuration
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
103 info = engine->tune.getInfo(); |
ae1f6418d093
libSIDPlay2-FP backend interface is now in a separate module. Configuration
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
104 #elif defined(XS_SIDPLAYFP_H) |
820 | 105 info = engine->tune.getInfo(); |
445
f277dad3180f
Working on the localization and fixing up the breakage in song information
Matti Hamalainen <ccr@tnsp.org>
parents:
412
diff
changeset
|
106 #endif |
f277dad3180f
Working on the localization and fixing up the breakage in song information
Matti Hamalainen <ccr@tnsp.org>
parents:
412
diff
changeset
|
107 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
108 /* NOTICE! Here we assume that libSIDPlay[12] headers define |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
109 * SIDTUNE_SIDMODEL_* similarly to our enums in xs_config.h ... |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
110 */ |
838
ae1f6418d093
libSIDPlay2-FP backend interface is now in a separate module. Configuration
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
111 #if defined(XS_SIDPLAYFP_H) && defined(HAVE_SIDPLAYFP) |
796
dfda3d47baf7
Clean up the variables etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
762
diff
changeset
|
112 state->tuneInfo->sidModel = info.sidModel1; |
744
c7fa50576c70
Initial implementation for supporting libSIDPlay2-FP (or libSIDPlay-FP, as
Matti Hamalainen <ccr@tnsp.org>
parents:
723
diff
changeset
|
113 #else |
796
dfda3d47baf7
Clean up the variables etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
762
diff
changeset
|
114 state->tuneInfo->sidModel = info.sidModel; |
744
c7fa50576c70
Initial implementation for supporting libSIDPlay2-FP (or libSIDPlay-FP, as
Matti Hamalainen <ccr@tnsp.org>
parents:
723
diff
changeset
|
115 #endif |
468 | 116 |
796
dfda3d47baf7
Clean up the variables etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
762
diff
changeset
|
117 if (state->currSong > 0 && state->currSong <= state->tuneInfo->nsubTunes) |
762 | 118 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
119 gint tmpSpeed = -1; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
120 |
796
dfda3d47baf7
Clean up the variables etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
762
diff
changeset
|
121 switch (info.clockSpeed) |
762 | 122 { |
123 case SIDTUNE_CLOCK_PAL: | |
124 tmpSpeed = XS_CLOCK_PAL; | |
125 break; | |
126 case SIDTUNE_CLOCK_NTSC: | |
127 tmpSpeed = XS_CLOCK_NTSC; | |
128 break; | |
129 case SIDTUNE_CLOCK_ANY: | |
130 tmpSpeed = XS_CLOCK_ANY; | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
131 break; |
762 | 132 case SIDTUNE_CLOCK_UNKNOWN: |
796
dfda3d47baf7
Clean up the variables etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
762
diff
changeset
|
133 switch (info.songSpeed) |
762 | 134 { |
135 case SIDTUNE_SPEED_VBI: | |
136 tmpSpeed = XS_CLOCK_VBI; | |
137 break; | |
138 case SIDTUNE_SPEED_CIA_1A: | |
139 tmpSpeed = XS_CLOCK_CIA; | |
140 break; | |
141 default: | |
796
dfda3d47baf7
Clean up the variables etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
762
diff
changeset
|
142 tmpSpeed = info.songSpeed; |
762 | 143 break; |
144 } | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
145 default: |
796
dfda3d47baf7
Clean up the variables etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
762
diff
changeset
|
146 tmpSpeed = info.clockSpeed; |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
147 break; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
148 } |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
149 |
796
dfda3d47baf7
Clean up the variables etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
762
diff
changeset
|
150 state->tuneInfo->subTunes[state->currSong - 1].tuneSpeed = tmpSpeed; |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
151 } |
445
f277dad3180f
Working on the localization and fixing up the breakage in song information
Matti Hamalainen <ccr@tnsp.org>
parents:
412
diff
changeset
|
152 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
153 return TRUE; |
445
f277dad3180f
Working on the localization and fixing up the breakage in song information
Matti Hamalainen <ccr@tnsp.org>
parents:
412
diff
changeset
|
154 } |
f277dad3180f
Working on the localization and fixing up the breakage in song information
Matti Hamalainen <ccr@tnsp.org>
parents:
412
diff
changeset
|
155 |
95 | 156 /* Undefine these */ |
202 | 157 #undef TFUNCTION |
460 | 158 #undef TFUNCTION2 |
95 | 159 #undef TTUNEINFO |
160 #undef TTUNE |