summaryrefslogtreecommitdiff
path: root/apps/plugins/mikmod/load_669.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/mikmod/load_669.c')
-rw-r--r--apps/plugins/mikmod/load_669.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/apps/plugins/mikmod/load_669.c b/apps/plugins/mikmod/load_669.c
index 000e51d985..0872043f65 100644
--- a/apps/plugins/mikmod/load_669.c
+++ b/apps/plugins/mikmod/load_669.c
@@ -6,12 +6,12 @@
6 it under the terms of the GNU Library General Public License as 6 it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of 7 published by the Free Software Foundation; either version 2 of
8 the License, or (at your option) any later version. 8 the License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Library General Public License for more details. 13 GNU Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public 15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the Free Software 16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
@@ -20,7 +20,7 @@
20 20
21/*============================================================================== 21/*==============================================================================
22 22
23 $Id: load_669.c,v 1.3 2005/04/07 19:57:38 realtech Exp $ 23 $Id: $
24 24
25 Composer 669 module loader 25 Composer 669 module loader
26 26
@@ -49,11 +49,11 @@ extern int fprintf(FILE *, const char *, ...);
49/*========== Module structure */ 49/*========== Module structure */
50 50
51/* header */ 51/* header */
52typedef struct S69HEADER { 52typedef struct S69HEADER {
53 UBYTE marker[2]; 53 UBYTE marker[2];
54 CHAR message[108]; 54 CHAR message[108];
55 UBYTE nos; 55 UBYTE nos;
56 UBYTE rbnop; 56 UBYTE RBnop;
57 UBYTE looporder; 57 UBYTE looporder;
58 UBYTE orders[0x80]; 58 UBYTE orders[0x80];
59 UBYTE tempos[0x80]; 59 UBYTE tempos[0x80];
@@ -81,7 +81,7 @@ static S69NOTE* s69pat=NULL;
81static S69HEADER* mh=NULL; 81static S69HEADER* mh=NULL;
82 82
83/* file type identification */ 83/* file type identification */
84static CHAR* S69_Version[]={ 84static const CHAR* S69_Version[]={
85 "Composer 669", 85 "Composer 669",
86 "Extended 669" 86 "Extended 669"
87}; 87};
@@ -134,6 +134,8 @@ static void S69_Cleanup(void)
134{ 134{
135 MikMod_free(s69pat); 135 MikMod_free(s69pat);
136 MikMod_free(mh); 136 MikMod_free(mh);
137 mh=NULL;
138 s69pat=NULL;
137} 139}
138 140
139static int S69_LoadPatterns(void) 141static int S69_LoadPatterns(void)
@@ -142,7 +144,7 @@ static int S69_LoadPatterns(void)
142 UBYTE note,inst,vol,effect,lastfx,lastval; 144 UBYTE note,inst,vol,effect,lastfx,lastval;
143 S69NOTE *cur; 145 S69NOTE *cur;
144 int tracks=0; 146 int tracks=0;
145 147
146 if(!AllocPatterns()) return 0; 148 if(!AllocPatterns()) return 0;
147 if(!AllocTracks()) return 0; 149 if(!AllocTracks()) return 0;
148 150
@@ -226,7 +228,7 @@ static int S69_LoadPatterns(void)
226 case 5: /* set speed */ 228 case 5: /* set speed */
227 if (effect) 229 if (effect)
228 UniPTEffect(0xf,effect); 230 UniPTEffect(0xf,effect);
229 else 231 else
230 if(mh->marker[0]!=0x69) { 232 if(mh->marker[0]!=0x69) {
231#ifdef MIKMOD_DEBUG 233#ifdef MIKMOD_DEBUG
232 fprintf(stderr,"\r669: unsupported super fast tempo at pat=%d row=%d chan=%d\n", 234 fprintf(stderr,"\r669: unsupported super fast tempo at pat=%d row=%d chan=%d\n",
@@ -250,13 +252,13 @@ static int S69_Load(int curious)
250 int i; 252 int i;
251 SAMPLE *current; 253 SAMPLE *current;
252 S69SAMPLE sample; 254 S69SAMPLE sample;
253 (void)curious; 255 (void)curious;
254 256
255 /* module header */ 257 /* module header */
256 _mm_read_UBYTES(mh->marker,2,modreader); 258 _mm_read_UBYTES(mh->marker,2,modreader);
257 _mm_read_UBYTES(mh->message,108,modreader); 259 _mm_read_UBYTES(mh->message,108,modreader);
258 mh->nos=_mm_read_UBYTE(modreader); 260 mh->nos=_mm_read_UBYTE(modreader);
259 mh->rbnop=_mm_read_UBYTE(modreader); 261 mh->RBnop=_mm_read_UBYTE(modreader);
260 mh->looporder=_mm_read_UBYTE(modreader); 262 mh->looporder=_mm_read_UBYTE(modreader);
261 _mm_read_UBYTES(mh->orders,0x80,modreader); 263 _mm_read_UBYTES(mh->orders,0x80,modreader);
262 for(i=0;i<0x80;i++) 264 for(i=0;i<0x80;i++)
@@ -281,9 +283,9 @@ static int S69_Load(int curious)
281 of.initspeed=4; 283 of.initspeed=4;
282 of.inittempo=78; 284 of.inittempo=78;
283 of.songname=DupStr(mh->message,36,1); 285 of.songname=DupStr(mh->message,36,1);
284 of.modtype=StrDup(S69_Version[memcmp(mh->marker,"JN",2)==0]); 286 of.modtype=MikMod_strdup(S69_Version[memcmp(mh->marker,"JN",2)==0]);
285 of.numchn=8; 287 of.numchn=8;
286 of.numpat=mh->rbnop; 288 of.numpat=mh->RBnop;
287 of.numins=of.numsmp=mh->nos; 289 of.numins=of.numsmp=mh->nos;
288 of.numtrk=of.numchn*of.numpat; 290 of.numtrk=of.numchn*of.numpat;
289 of.flags=UF_XMPERIODS|UF_LINEAR; 291 of.flags=UF_XMPERIODS|UF_LINEAR;
@@ -292,7 +294,7 @@ static int S69_Load(int curious)
292 for(i=36+35;(i>=36+0)&&(mh->message[i]==' ');i--) mh->message[i]=0; 294 for(i=36+35;(i>=36+0)&&(mh->message[i]==' ');i--) mh->message[i]=0;
293 for(i=72+35;(i>=72+0)&&(mh->message[i]==' ');i--) mh->message[i]=0; 295 for(i=72+35;(i>=72+0)&&(mh->message[i]==' ');i--) mh->message[i]=0;
294 if((mh->message[0])||(mh->message[36])||(mh->message[72])) 296 if((mh->message[0])||(mh->message[36])||(mh->message[72]))
295 if((of.comment=(CHAR*)MikMod_malloc(3*(36+1)+1))) { 297 if((of.comment=(CHAR*)MikMod_malloc(3*(36+1)+1)) != NULL) {
296 strncpy(of.comment,mh->message,36); 298 strncpy(of.comment,mh->message,36);
297 strcat(of.comment,"\r"); 299 strcat(of.comment,"\r");
298 if (mh->message[36]) strncat(of.comment,mh->message+36,36); 300 if (mh->message[36]) strncat(of.comment,mh->message+36,36);
@@ -304,7 +306,7 @@ static int S69_Load(int curious)
304 306
305 if(!AllocPositions(0x80)) return 0; 307 if(!AllocPositions(0x80)) return 0;
306 for(i=0;i<0x80;i++) { 308 for(i=0;i<0x80;i++) {
307 if(mh->orders[i]>=mh->rbnop) break; 309 if(mh->orders[i]>=mh->RBnop) break;
308 of.positions[i]=mh->orders[i]; 310 of.positions[i]=mh->orders[i];
309 } 311 }
310 of.numpos=i; 312 of.numpos=i;