Mercurial > hg > xmms-sid
annotate src/xs_sidplay.h @ 657:acaba070cf49
Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 02 Apr 2008 19:46:59 +0300 |
parents | eafcd84a8c59 |
children | b0743dc9165d |
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> |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
7 (C) Copyright 2005-2007 Tecnic Software productions (TNSP) |
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 */ |
657
acaba070cf49
Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents:
631
diff
changeset
|
29 xs_tuneinfo_t *TFUNCTION(const gchar *sidFilename) |
76 | 30 { |
657
acaba070cf49
Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents:
631
diff
changeset
|
31 xs_tuneinfo_t *pResult; |
479
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
32 TTUNEINFO myInfo; |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
33 TTUNE *myTune; |
527
fe8b41abd923
Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
34 guint8 *buf = NULL; |
fe8b41abd923
Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
35 size_t bufSize = 0; |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
36 |
527
fe8b41abd923
Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
37 /* Load file */ |
fe8b41abd923
Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
38 if (!sidFilename) return NULL; |
fe8b41abd923
Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
39 |
fe8b41abd923
Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
40 if (xs_fload_buffer(sidFilename, &buf, &bufSize) != 0) |
fe8b41abd923
Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
41 return NULL; |
fe8b41abd923
Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
42 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
43 /* Check if the tune exists and is readable */ |
527
fe8b41abd923
Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
44 if ((myTune = new TTUNE(buf, bufSize)) == NULL) { |
fe8b41abd923
Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
45 g_free(buf); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
46 return NULL; |
527
fe8b41abd923
Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
47 } |
fe8b41abd923
Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
48 g_free(buf); |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
49 |
479
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
50 if (!myTune->getStatus()) { |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
51 delete myTune; |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
52 return NULL; |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
53 } |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
54 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
55 /* Get general tune information */ |
526
fa95d942f226
Header cleanup; Moved some types from xmms-sid.h to xs_player.h; Renamed few functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
479
diff
changeset
|
56 #ifdef XS_SIDPLAY1_H |
479
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
57 myTune->getInfo(myInfo); |
95 | 58 #endif |
526
fa95d942f226
Header cleanup; Moved some types from xmms-sid.h to xs_player.h; Renamed few functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
479
diff
changeset
|
59 #ifdef XS_SIDPLAY2_H |
479
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
60 myInfo = myTune->getInfo(); |
95 | 61 #endif |
62 | |
479
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
63 /* Allocate tuneinfo structure and set information */ |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
64 pResult = xs_tuneinfo_new(sidFilename, |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
65 myInfo.songs, myInfo.startSong, |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
66 myInfo.infoString[0], myInfo.infoString[1], myInfo.infoString[2], |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
67 myInfo.loadAddr, myInfo.initAddr, myInfo.playAddr, |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
68 myInfo.dataFileLen, myInfo.formatString, myInfo.sidModel); |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
69 |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
70 /* NOTICE! libSIDPlay[12] headers specifically state that sidModel, |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
71 * songSpeed and clockSpeed are "undefined" before song initialization, |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
72 * but in practice sidModel is known after getInfo() invocation... |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
73 * This of course does not take the sub-tune specific changes into account, |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
74 * but at least we have a reasonable guesstimate. |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
75 */ |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
76 |
479
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
77 delete myTune; |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
78 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
79 return pResult; |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
80 } |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
81 |
445
f277dad3180f
Working on the localization and fixing up the breakage in song information
Matti Hamalainen <ccr@tnsp.org>
parents:
412
diff
changeset
|
82 |
479
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
83 /* 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
|
84 */ |
657
acaba070cf49
Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents:
631
diff
changeset
|
85 gboolean TFUNCTION2(xs_status_t *myStatus) |
445
f277dad3180f
Working on the localization and fixing up the breakage in song information
Matti Hamalainen <ccr@tnsp.org>
parents:
412
diff
changeset
|
86 { |
468 | 87 TTUNEINFO myInfo; |
88 TTUNE *myTune; | |
89 TENGINE *myEngine; | |
657
acaba070cf49
Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents:
631
diff
changeset
|
90 xs_tuneinfo_t *i; |
468 | 91 |
92 /* Check if we have required structures initialized */ | |
93 if (!myStatus || !myStatus->tuneInfo || !myStatus->sidEngine) | |
94 return FALSE; | |
460 | 95 |
468 | 96 myEngine = (TENGINE *) myStatus->sidEngine; |
97 myTune = myEngine->currTune; | |
98 if (!myTune) | |
460 | 99 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
|
100 |
468 | 101 /* Get currently playing tune information */ |
526
fa95d942f226
Header cleanup; Moved some types from xmms-sid.h to xs_player.h; Renamed few functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
479
diff
changeset
|
102 #ifdef XS_SIDPLAY1_H |
468 | 103 myTune->getInfo(myInfo); |
445
f277dad3180f
Working on the localization and fixing up the breakage in song information
Matti Hamalainen <ccr@tnsp.org>
parents:
412
diff
changeset
|
104 #endif |
526
fa95d942f226
Header cleanup; Moved some types from xmms-sid.h to xs_player.h; Renamed few functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
479
diff
changeset
|
105 #ifdef XS_SIDPLAY2_H |
468 | 106 myInfo = myTune->getInfo(); |
445
f277dad3180f
Working on the localization and fixing up the breakage in song information
Matti Hamalainen <ccr@tnsp.org>
parents:
412
diff
changeset
|
107 #endif |
f277dad3180f
Working on the localization and fixing up the breakage in song information
Matti Hamalainen <ccr@tnsp.org>
parents:
412
diff
changeset
|
108 |
479
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
109 /* NOTICE! Here we assume that libSIDPlay[12] headers define |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
110 * SIDTUNE_SIDMODEL_* similarly to our enums in xs_config.h ... |
468 | 111 */ |
112 i = myStatus->tuneInfo; | |
113 i->sidModel = myInfo.sidModel; | |
114 | |
472 | 115 if ((myStatus->currSong > 0) && (myStatus->currSong <= i->nsubTunes)) { |
116 gint tmpSpeed = -1; | |
468 | 117 |
472 | 118 switch (myInfo.clockSpeed) { |
479
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
119 case SIDTUNE_CLOCK_PAL: |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
120 tmpSpeed = XS_CLOCK_PAL; |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
121 break; |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
122 case SIDTUNE_CLOCK_NTSC: |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
123 tmpSpeed = XS_CLOCK_NTSC; |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
124 break; |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
125 case SIDTUNE_CLOCK_ANY: |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
126 tmpSpeed = XS_CLOCK_ANY; |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
127 break; |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
128 case SIDTUNE_CLOCK_UNKNOWN: |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
129 switch (myInfo.songSpeed) { |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
130 case SIDTUNE_SPEED_VBI: |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
131 tmpSpeed = XS_CLOCK_VBI; |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
132 break; |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
133 case SIDTUNE_SPEED_CIA_1A: |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
134 tmpSpeed = XS_CLOCK_CIA; |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
135 break; |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
136 default: |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
137 tmpSpeed = myInfo.songSpeed; |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
138 break; |
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
139 } |
468 | 140 default: |
479
99f05a74de5b
Improvements in titlestring handling and information passing in
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
141 tmpSpeed = myInfo.clockSpeed; |
468 | 142 break; |
143 } | |
472 | 144 |
145 i->subTunes[myStatus->currSong - 1].tuneSpeed = tmpSpeed; | |
468 | 146 } |
445
f277dad3180f
Working on the localization and fixing up the breakage in song information
Matti Hamalainen <ccr@tnsp.org>
parents:
412
diff
changeset
|
147 |
460 | 148 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
|
149 } |
f277dad3180f
Working on the localization and fixing up the breakage in song information
Matti Hamalainen <ccr@tnsp.org>
parents:
412
diff
changeset
|
150 |
95 | 151 /* Undefine these */ |
202 | 152 #undef TFUNCTION |
460 | 153 #undef TFUNCTION2 |
95 | 154 #undef TTUNEINFO |
155 #undef TTUNE |