Mercurial > audlegacy-plugins
comparison src/sid/xs_sidplay.h @ 2509:1223e8510d8a
Change tabs to 4 spaces, everywhere.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 03 Apr 2008 00:52:14 +0300 |
parents | 251336bee085 |
children |
comparison
equal
deleted
inserted
replaced
2508:58889ccbe807 | 2509:1223e8510d8a |
---|---|
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 xs_tuneinfo_t *TFUNCTION(const gchar *sidFilename) | 29 xs_tuneinfo_t *TFUNCTION(const gchar *sidFilename) |
30 { | 30 { |
31 xs_tuneinfo_t *pResult; | 31 xs_tuneinfo_t *pResult; |
32 TTUNEINFO myInfo; | 32 TTUNEINFO myInfo; |
33 TTUNE *myTune; | 33 TTUNE *myTune; |
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 (!sidFilename) return NULL; | 38 if (!sidFilename) return NULL; |
39 | 39 |
40 if (xs_fload_buffer(sidFilename, &buf, &bufSize) != 0) | 40 if (xs_fload_buffer(sidFilename, &buf, &bufSize) != 0) |
41 return NULL; | 41 return NULL; |
42 | 42 |
43 /* Check if the tune exists and is readable */ | 43 /* Check if the tune exists and is readable */ |
44 if ((myTune = new TTUNE(buf, bufSize)) == NULL) { | 44 if ((myTune = new TTUNE(buf, bufSize)) == NULL) { |
45 g_free(buf); | 45 g_free(buf); |
46 return NULL; | 46 return NULL; |
47 } | 47 } |
48 g_free(buf); | 48 g_free(buf); |
49 | 49 |
50 if (!myTune->getStatus()) { | 50 if (!myTune->getStatus()) { |
51 delete myTune; | 51 delete myTune; |
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 myTune->getInfo(myInfo); |
58 #endif | 58 #endif |
59 #ifdef XS_SIDPLAY2_H | 59 #ifdef XS_SIDPLAY2_H |
60 myInfo = myTune->getInfo(); | 60 myInfo = myTune->getInfo(); |
61 #endif | 61 #endif |
62 | 62 |
63 /* Allocate tuneinfo structure and set information */ | 63 /* Allocate tuneinfo structure and set information */ |
64 pResult = xs_tuneinfo_new(sidFilename, | 64 pResult = xs_tuneinfo_new(sidFilename, |
65 myInfo.songs, myInfo.startSong, | 65 myInfo.songs, myInfo.startSong, |
66 myInfo.infoString[0], myInfo.infoString[1], myInfo.infoString[2], | 66 myInfo.infoString[0], myInfo.infoString[1], myInfo.infoString[2], |
67 myInfo.loadAddr, myInfo.initAddr, myInfo.playAddr, | 67 myInfo.loadAddr, myInfo.initAddr, myInfo.playAddr, |
68 myInfo.dataFileLen, myInfo.formatString, myInfo.sidModel); | 68 myInfo.dataFileLen, myInfo.formatString, myInfo.sidModel); |
69 | 69 |
70 /* NOTICE! libSIDPlay[12] headers specifically state that sidModel, | 70 /* NOTICE! libSIDPlay[12] headers specifically state that sidModel, |
71 * songSpeed and clockSpeed are "undefined" before song initialization, | 71 * songSpeed and clockSpeed are "undefined" before song initialization, |
72 * but in practice sidModel is known after getInfo() invocation... | 72 * but in practice sidModel is known after getInfo() invocation... |
73 * This of course does not take the sub-tune specific changes into account, | 73 * This of course does not take the sub-tune specific changes into account, |
74 * but at least we have a reasonable guesstimate. | 74 * but at least we have a reasonable guesstimate. |
75 */ | 75 */ |
76 | 76 |
77 delete myTune; | 77 delete myTune; |
78 | 78 |
79 return pResult; | 79 return pResult; |
80 } | 80 } |
81 | 81 |
82 | 82 |
83 /* Updates the information of currently playing tune | 83 /* Updates the information of currently playing tune |
84 */ | 84 */ |
85 gboolean TFUNCTION2(xs_status_t *myStatus) | 85 gboolean TFUNCTION2(xs_status_t *myStatus) |
86 { | 86 { |
87 TTUNEINFO myInfo; | 87 TTUNEINFO myInfo; |
88 TTUNE *myTune; | 88 TTUNE *myTune; |
89 TENGINE *myEngine; | 89 TENGINE *myEngine; |
90 xs_tuneinfo_t *i; | 90 xs_tuneinfo_t *i; |
91 | 91 |
92 /* Check if we have required structures initialized */ | 92 /* Check if we have required structures initialized */ |
93 if (!myStatus || !myStatus->tuneInfo || !myStatus->sidEngine) | 93 if (!myStatus || !myStatus->tuneInfo || !myStatus->sidEngine) |
94 return FALSE; | 94 return FALSE; |
95 | 95 |
96 myEngine = (TENGINE *) myStatus->sidEngine; | 96 myEngine = (TENGINE *) myStatus->sidEngine; |
97 myTune = myEngine->currTune; | 97 myTune = myEngine->currTune; |
98 if (!myTune) | 98 if (!myTune) |
99 return FALSE; | 99 return FALSE; |
100 | 100 |
101 /* Get currently playing tune information */ | 101 /* Get currently playing tune information */ |
102 #ifdef XS_SIDPLAY1_H | 102 #ifdef XS_SIDPLAY1_H |
103 myTune->getInfo(myInfo); | 103 myTune->getInfo(myInfo); |
104 #endif | 104 #endif |
105 #ifdef XS_SIDPLAY2_H | 105 #ifdef XS_SIDPLAY2_H |
106 myInfo = myTune->getInfo(); | 106 myInfo = myTune->getInfo(); |
107 #endif | 107 #endif |
108 | 108 |
109 /* NOTICE! Here we assume that libSIDPlay[12] headers define | 109 /* NOTICE! Here we assume that libSIDPlay[12] headers define |
110 * SIDTUNE_SIDMODEL_* similarly to our enums in xs_config.h ... | 110 * SIDTUNE_SIDMODEL_* similarly to our enums in xs_config.h ... |
111 */ | 111 */ |
112 i = myStatus->tuneInfo; | 112 i = myStatus->tuneInfo; |
113 i->sidModel = myInfo.sidModel; | 113 i->sidModel = myInfo.sidModel; |
114 | 114 |
115 if ((myStatus->currSong > 0) && (myStatus->currSong <= i->nsubTunes)) { | 115 if ((myStatus->currSong > 0) && (myStatus->currSong <= i->nsubTunes)) { |
116 gint tmpSpeed = -1; | 116 gint tmpSpeed = -1; |
117 | 117 |
118 switch (myInfo.clockSpeed) { | 118 switch (myInfo.clockSpeed) { |
119 case SIDTUNE_CLOCK_PAL: | 119 case SIDTUNE_CLOCK_PAL: |
120 tmpSpeed = XS_CLOCK_PAL; | 120 tmpSpeed = XS_CLOCK_PAL; |
121 break; | 121 break; |
122 case SIDTUNE_CLOCK_NTSC: | 122 case SIDTUNE_CLOCK_NTSC: |
123 tmpSpeed = XS_CLOCK_NTSC; | 123 tmpSpeed = XS_CLOCK_NTSC; |
124 break; | 124 break; |
125 case SIDTUNE_CLOCK_ANY: | 125 case SIDTUNE_CLOCK_ANY: |
126 tmpSpeed = XS_CLOCK_ANY; | 126 tmpSpeed = XS_CLOCK_ANY; |
127 break; | 127 break; |
128 case SIDTUNE_CLOCK_UNKNOWN: | 128 case SIDTUNE_CLOCK_UNKNOWN: |
129 switch (myInfo.songSpeed) { | 129 switch (myInfo.songSpeed) { |
130 case SIDTUNE_SPEED_VBI: | 130 case SIDTUNE_SPEED_VBI: |
131 tmpSpeed = XS_CLOCK_VBI; | 131 tmpSpeed = XS_CLOCK_VBI; |
132 break; | 132 break; |
133 case SIDTUNE_SPEED_CIA_1A: | 133 case SIDTUNE_SPEED_CIA_1A: |
134 tmpSpeed = XS_CLOCK_CIA; | 134 tmpSpeed = XS_CLOCK_CIA; |
135 break; | 135 break; |
136 default: | 136 default: |
137 tmpSpeed = myInfo.songSpeed; | 137 tmpSpeed = myInfo.songSpeed; |
138 break; | 138 break; |
139 } | 139 } |
140 default: | 140 default: |
141 tmpSpeed = myInfo.clockSpeed; | 141 tmpSpeed = myInfo.clockSpeed; |
142 break; | 142 break; |
143 } | 143 } |
144 | 144 |
145 i->subTunes[myStatus->currSong - 1].tuneSpeed = tmpSpeed; | 145 i->subTunes[myStatus->currSong - 1].tuneSpeed = tmpSpeed; |
146 } | 146 } |
147 | 147 |
148 return TRUE; | 148 return TRUE; |
149 } | 149 } |
150 | 150 |
151 /* Undefine these */ | 151 /* Undefine these */ |
152 #undef TFUNCTION | 152 #undef TFUNCTION |
153 #undef TFUNCTION2 | 153 #undef TFUNCTION2 |