Mercurial > hg > xmms-sid
comparison src/xs_sidplay.h @ 796:dfda3d47baf7
Clean up the variables etc.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 07 Nov 2012 11:05:42 +0200 |
parents | 03c5cde1dfbb |
children | 778531e968ed |
comparison
equal
deleted
inserted
replaced
795:3e305ce076e8 | 796:dfda3d47baf7 |
---|---|
24 | 24 |
25 /* This function gets most of the information, though we do miss some | 25 /* This function gets most of the information, though we do miss some |
26 * (those variables that are only set by libSIDPlay when tune is initialized). | 26 * (those variables that are only set by libSIDPlay when tune is initialized). |
27 * Rest of the information is acquired in TFUNCTION2() | 27 * Rest of the information is acquired in TFUNCTION2() |
28 */ | 28 */ |
29 XSTuneInfo *TFUNCTION(const gchar *sidFilename) | 29 XSTuneInfo *TFUNCTION(const gchar *filename) |
30 { | 30 { |
31 XSTuneInfo *res; | 31 XSTuneInfo *res; |
32 TTUNEINFO myInfo; | 32 TTUNEINFO info; |
33 TTUNE *myTune; | 33 TTUNE *tune; |
34 guint8 *buf = NULL; | 34 guint8 *buf = NULL; |
35 size_t bufSize = 0; | 35 size_t bufSize = 0; |
36 | 36 |
37 /* Load file */ | 37 /* Load file */ |
38 if (xs_fload_buffer(sidFilename, &buf, &bufSize) != 0) | 38 if (xs_fload_buffer(filename, &buf, &bufSize) != 0) |
39 return NULL; | 39 return NULL; |
40 | 40 |
41 /* Check if the tune exists and is readable */ | 41 /* Check if the tune exists and is readable */ |
42 if ((myTune = new TTUNE(buf, bufSize)) == NULL) | 42 if ((tune = new TTUNE(buf, bufSize)) == NULL) |
43 { | 43 { |
44 g_free(buf); | 44 g_free(buf); |
45 return NULL; | 45 return NULL; |
46 } | 46 } |
47 g_free(buf); | 47 g_free(buf); |
48 | 48 |
49 if (!myTune->getStatus()) | 49 if (!tune->getStatus()) |
50 { | 50 { |
51 delete myTune; | 51 delete tune; |
52 return NULL; | 52 return NULL; |
53 } | 53 } |
54 | 54 |
55 /* Get general tune information */ | 55 /* Get general tune information */ |
56 #ifdef XS_SIDPLAY1_H | 56 #ifdef XS_SIDPLAY1_H |
57 myTune->getInfo(myInfo); | 57 tune->getInfo(info); |
58 #endif | 58 #endif |
59 | |
59 #ifdef XS_SIDPLAY2_H | 60 #ifdef XS_SIDPLAY2_H |
60 myInfo = myTune->getInfo(); | 61 info = tune->getInfo(); |
61 #endif | 62 #endif |
62 | 63 |
63 /* Allocate tuneinfo structure and set information */ | 64 /* Allocate tuneinfo structure and set information */ |
64 res = xs_tuneinfo_new(sidFilename, | 65 res = xs_tuneinfo_new(filename, |
65 myInfo.songs, myInfo.startSong, | 66 info.songs, info.startSong, |
66 myInfo.infoString[0], myInfo.infoString[1], myInfo.infoString[2], | 67 info.infoString[0], info.infoString[1], info.infoString[2], |
67 myInfo.loadAddr, myInfo.initAddr, myInfo.playAddr, | 68 info.loadAddr, info.initAddr, info.playAddr, |
68 myInfo.dataFileLen, myInfo.formatString, | 69 info.dataFileLen, info.formatString, |
69 #if defined(XS_SIDPLAY2_H) && defined(HAVE_SIDPLAY2_FP) | 70 #if defined(XS_SIDPLAY2_H) && defined(HAVE_SIDPLAY2_FP) |
70 myInfo.sidModel1 | 71 info.sidModel1 |
71 #else | 72 #else |
72 myInfo.sidModel | 73 info.sidModel |
73 #endif | 74 #endif |
74 ); | 75 ); |
75 | 76 |
76 /* NOTICE! libSIDPlay[12] headers specifically state that sidModel, | 77 /* NOTICE! libSIDPlay[12] headers specifically state that sidModel, |
77 * songSpeed and clockSpeed are "undefined" before song initialization, | 78 * songSpeed and clockSpeed are "undefined" before song initialization, |
78 * but in practice sidModel is known after getInfo() invocation... | 79 * but in practice sidModel is known after getInfo() invocation... |
79 * This of course does not take the sub-tune specific changes into account, | 80 * This of course does not take the sub-tune specific changes into account, |
80 * but at least we have a reasonable guesstimate. | 81 * but at least we have a reasonable guesstimate. |
81 */ | 82 */ |
82 | 83 |
83 delete myTune; | 84 delete tune; |
84 | 85 |
85 return res; | 86 return res; |
86 } | 87 } |
87 | 88 |
88 | 89 |
89 /* Updates the information of currently playing tune | 90 /* Updates the information of currently playing tune |
90 */ | 91 */ |
91 gboolean TFUNCTION2(XSEngineState *state) | 92 gboolean TFUNCTION2(XSEngineState *state) |
92 { | 93 { |
93 TTUNEINFO myInfo; | 94 TTUNEINFO info; |
94 TTUNE *myTune; | 95 TTUNE *tune; |
95 TENGINE *engine; | 96 TENGINE *engine; |
96 XSTuneInfo *i; | |
97 | 97 |
98 /* Check if we have required structures initialized */ | 98 /* Check if we have required structures initialized */ |
99 if (!state || !state->tuneInfo || !state->internal) | 99 if (!state || !state->tuneInfo || !state->internal) |
100 return FALSE; | 100 return FALSE; |
101 | 101 |
102 engine = (TENGINE *) state->internal; | 102 engine = (TENGINE *) state->internal; |
103 myTune = engine->tune; | 103 tune = engine->tune; |
104 if (!myTune) | 104 if (!tune) |
105 return FALSE; | 105 return FALSE; |
106 | 106 |
107 /* Get currently playing tune information */ | 107 /* Get currently playing tune information */ |
108 #ifdef XS_SIDPLAY1_H | 108 #ifdef XS_SIDPLAY1_H |
109 myTune->getInfo(myInfo); | 109 tune->getInfo(info); |
110 #endif | 110 #endif |
111 #ifdef XS_SIDPLAY2_H | 111 #ifdef XS_SIDPLAY2_H |
112 myInfo = myTune->getInfo(); | 112 info = tune->getInfo(); |
113 #endif | 113 #endif |
114 | 114 |
115 /* NOTICE! Here we assume that libSIDPlay[12] headers define | 115 /* NOTICE! Here we assume that libSIDPlay[12] headers define |
116 * SIDTUNE_SIDMODEL_* similarly to our enums in xs_config.h ... | 116 * SIDTUNE_SIDMODEL_* similarly to our enums in xs_config.h ... |
117 */ | 117 */ |
118 i = state->tuneInfo; | |
119 #if defined(XS_SIDPLAY2_H) && defined(HAVE_SIDPLAY2_FP) | 118 #if defined(XS_SIDPLAY2_H) && defined(HAVE_SIDPLAY2_FP) |
120 i->sidModel = myInfo.sidModel1; | 119 state->tuneInfo->sidModel = info.sidModel1; |
121 #else | 120 #else |
122 i->sidModel = myInfo.sidModel; | 121 state->tuneInfo->sidModel = info.sidModel; |
123 #endif | 122 #endif |
124 | 123 |
125 if (state->currSong > 0 && state->currSong <= i->nsubTunes) | 124 if (state->currSong > 0 && state->currSong <= state->tuneInfo->nsubTunes) |
126 { | 125 { |
127 gint tmpSpeed = -1; | 126 gint tmpSpeed = -1; |
128 | 127 |
129 switch (myInfo.clockSpeed) | 128 switch (info.clockSpeed) |
130 { | 129 { |
131 case SIDTUNE_CLOCK_PAL: | 130 case SIDTUNE_CLOCK_PAL: |
132 tmpSpeed = XS_CLOCK_PAL; | 131 tmpSpeed = XS_CLOCK_PAL; |
133 break; | 132 break; |
134 case SIDTUNE_CLOCK_NTSC: | 133 case SIDTUNE_CLOCK_NTSC: |
136 break; | 135 break; |
137 case SIDTUNE_CLOCK_ANY: | 136 case SIDTUNE_CLOCK_ANY: |
138 tmpSpeed = XS_CLOCK_ANY; | 137 tmpSpeed = XS_CLOCK_ANY; |
139 break; | 138 break; |
140 case SIDTUNE_CLOCK_UNKNOWN: | 139 case SIDTUNE_CLOCK_UNKNOWN: |
141 switch (myInfo.songSpeed) | 140 switch (info.songSpeed) |
142 { | 141 { |
143 case SIDTUNE_SPEED_VBI: | 142 case SIDTUNE_SPEED_VBI: |
144 tmpSpeed = XS_CLOCK_VBI; | 143 tmpSpeed = XS_CLOCK_VBI; |
145 break; | 144 break; |
146 case SIDTUNE_SPEED_CIA_1A: | 145 case SIDTUNE_SPEED_CIA_1A: |
147 tmpSpeed = XS_CLOCK_CIA; | 146 tmpSpeed = XS_CLOCK_CIA; |
148 break; | 147 break; |
149 default: | 148 default: |
150 tmpSpeed = myInfo.songSpeed; | 149 tmpSpeed = info.songSpeed; |
151 break; | 150 break; |
152 } | 151 } |
153 default: | 152 default: |
154 tmpSpeed = myInfo.clockSpeed; | 153 tmpSpeed = info.clockSpeed; |
155 break; | 154 break; |
156 } | 155 } |
157 | 156 |
158 i->subTunes[state->currSong - 1].tuneSpeed = tmpSpeed; | 157 state->tuneInfo->subTunes[state->currSong - 1].tuneSpeed = tmpSpeed; |
159 } | 158 } |
160 | 159 |
161 return TRUE; | 160 return TRUE; |
162 } | 161 } |
163 | 162 |