annotate playercode/load_669.c @ 14:6218f9885552

Clean up the Makefile
author darius
date Thu, 23 Apr 1998 07:21:28 +0000
parents 5d614bcc4287
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1 /*
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
2
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
3 Name: LOAD_669.C
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
4
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
5 Description:
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
6 Tran's 669 module loader
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
7
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
8 Portability:
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
9 All systems - all compilers (hopefully)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
10
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
11 If this module is found to not be portable to any particular platform,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
12 please contact Jake Stine at dracoirs@epix.net (see MIKMOD.TXT for
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
13 more information on contacting the author).
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
14
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
15 */
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
16
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
17 #include <string.h>
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
18 #include "mikmod.h"
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
19
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
20
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
21 // Raw 669 header struct:
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
22
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
23 typedef struct S69HEADER
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
24 { UBYTE marker[2];
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
25 CHAR message[108];
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
26 UBYTE nos;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
27 UBYTE nop;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
28 UBYTE looporder;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
29 UBYTE orders[0x80];
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
30 UBYTE tempos[0x80];
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
31 UBYTE breaks[0x80];
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
32 } S69HEADER;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
33
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
34
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
35 // Raw 669 sampleinfo struct:
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
36
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
37 typedef struct S69SAMPLE
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
38 { CHAR filename[13];
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
39 SLONG length;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
40 SLONG loopbeg;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
41 SLONG loopend;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
42 } S69SAMPLE;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
43
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
44
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
45 // Raw 669 Note struct
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
46
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
47 typedef struct S69NOTE
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
48 { UBYTE a,b,c;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
49 } S69NOTE;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
50
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
51
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
52 static S69NOTE *s69pat = NULL;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
53 static S69HEADER *mh = NULL;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
54
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
55 static CHAR *S69_Version[] =
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
56 { "669",
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
57 "Extended 669"
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
58 };
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
59
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
60
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
61 BOOL S69_Test(void)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
62 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
63 UBYTE id[2];
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
64
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
65 if(!_mm_read_UBYTES(id,2,modfp)) return 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
66 if(!memcmp(id,"if",2) || !memcmp(id,"JN",2))
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
67 { _mm_fseek(modfp,108,SEEK_CUR);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
68 if(_mm_read_UBYTE(modfp) > 64) return 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
69 if(_mm_read_UBYTE(modfp) > 128) return 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
70 if(_mm_read_UBYTE(modfp) > 120) return 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
71 return 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
72 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
73 return 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
74 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
75
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
76
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
77 BOOL S69_Init(void)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
78 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
79 if(!(s69pat=(S69NOTE *)_mm_malloc(64*8*sizeof(S69NOTE)))) return 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
80 if(!(mh=(S69HEADER *)_mm_calloc(1,sizeof(S69HEADER)))) return 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
81 return 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
82 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
83
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
84
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
85 void S69_Cleanup(void)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
86 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
87 if(s69pat!=NULL) free(s69pat);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
88 if(mh!=NULL) free(mh);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
89
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
90 mh = NULL;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
91 s69pat = NULL;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
92 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
93
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
94
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
95 BOOL S69_LoadPatterns(void)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
96 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
97 int t,s,q,tracks=0,t2,t3;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
98 UBYTE note,inst,vol,a,b,c, lo;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
99 S69NOTE *cur;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
100
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
101 if(!AllocPatterns()) return 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
102 if(!AllocTracks()) return 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
103
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
104 for(t=0; t<of.numpat; t++)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
105 { of.pattrows[t] = mh->breaks[t]+1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
106
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
107 // Load the pattern into the temp buffer
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
108 // and convert it into the 3-byte format
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
109
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
110 cur = s69pat;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
111 for(t2=64; t2; t2--)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
112 { for(t3=8; t3; t3--, cur++)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
113 { cur->a = _mm_read_UBYTE(modfp);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
114 cur->b = _mm_read_UBYTE(modfp);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
115 cur->c = _mm_read_UBYTE(modfp);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
116 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
117 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
118
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
119 if(feof(modfp))
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
120 { _mm_errno = MMERR_LOADING_PATTERN;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
121 return 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
122 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
123
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
124 for(s=0; s<8; s++)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
125 { UniReset();
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
126 UniPTEffect(0xf,75); // was 78
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
127 UniPTEffect(0xf,3);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
128
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
129 for(q=0; q<64; q++)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
130 { a = s69pat[(q*8)+s].a;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
131 b = s69pat[(q*8)+s].b;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
132 c = s69pat[(q*8)+s].c;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
133
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
134 note = a >> 2;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
135 inst = ((a & 0x3) << 4) | ((b & 0xf0) >> 4);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
136 vol = b & 0xf;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
137
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
138 if(note < 0x3e)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
139 { UniInstrument(inst);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
140 UniNote(note+24);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
141 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
142
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
143 if(note < 0x3f) UniPTEffect(0xc,vol<<2);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
144
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
145 lo = c & 0xf;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
146 switch(c >> 4)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
147 { case 0:
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
148 UniPTEffect(0x1,lo);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
149 break;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
150
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
151 case 1:
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
152 UniPTEffect(0x2,lo);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
153 break;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
154
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
155 case 2:
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
156 UniPTEffect(0x3,lo);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
157 break;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
158
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
159 case 4:
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
160 UniPTEffect(0x4,lo);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
161 break;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
162 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
163 UniNewline();
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
164 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
165 if(!(of.tracks[tracks++]=UniDup())) return 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
166 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
167 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
168 return 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
169 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
170
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
171
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
172 BOOL S69_Load(void)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
173 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
174 int t;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
175 S69SAMPLE s;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
176 SAMPLE *q;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
177
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
178 // try to read module header
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
179
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
180 _mm_read_UBYTES(mh->marker,2,modfp);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
181 _mm_read_UBYTES((UBYTE *)mh->message,108,modfp);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
182 mh->nos = _mm_read_UBYTE(modfp);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
183 mh->nop = _mm_read_UBYTE(modfp);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
184 mh->looporder = _mm_read_UBYTE(modfp);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
185 _mm_read_UBYTES(mh->orders,0x80,modfp);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
186 _mm_read_UBYTES(mh->tempos,0x80,modfp);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
187 _mm_read_UBYTES(mh->breaks,0x80,modfp);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
188
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
189 // set module variables
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
190
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
191 of.initspeed = 6;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
192 of.inittempo = 125;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
193 of.songname = DupStr(mh->message,108);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
194 of.modtype = strdup(S69_Version[memcmp(mh->marker,"JN",2)==0]);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
195 of.numchn = 8;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
196 of.numpat = mh->nop;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
197 of.numins = of.numsmp = mh->nos;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
198 of.numtrk = of.numchn*of.numpat;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
199 of.flags = UF_XMPERIODS; // | UF_LINEAR;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
200
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
201 if(!AllocPositions(0x80)) return 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
202 for(t=0; t<0x80; t++)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
203 { if(mh->orders[t]==0xff) break;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
204 of.positions[t] = mh->orders[t];
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
205 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
206
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
207 of.numpos = t;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
208
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
209 if(!AllocSamples()) return 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
210 q = of.samples;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
211
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
212 for(t=0; t<of.numins; t++)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
213 { // try to read sample info
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
214
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
215 _mm_read_UBYTES((UBYTE *)s.filename,13,modfp);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
216 s.length = _mm_read_I_SLONG(modfp);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
217 s.loopbeg = _mm_read_I_SLONG(modfp);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
218 s.loopend = _mm_read_I_SLONG(modfp);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
219
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
220 if((s.length < 0) || (s.loopbeg < -1) || (s.loopend < -1))
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
221 { _mm_errno = MMERR_LOADING_HEADER;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
222 return 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
223 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
224
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
225 q->samplename = DupStr(s.filename,13);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
226
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
227 q->seekpos = 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
228 q->speed = 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
229 q->length = s.length;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
230 q->loopstart = s.loopbeg;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
231 q->loopend = (s.loopend<s.length) ? s.loopend : s.length;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
232 q->flags = (s.loopbeg<s.loopend) ? SF_LOOP : 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
233 q->volume = 64;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
234
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
235 q++;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
236 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
237
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
238 if(!S69_LoadPatterns()) return 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
239
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
240 return 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
241 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
242
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
243
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
244 MLOADER load_669 =
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
245 { NULL,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
246 "669",
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
247 "Portable 669 loader v0.1",
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
248 S69_Init,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
249 S69_Test,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
250 S69_Load,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
251 S69_Cleanup,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
252 NULL
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
253 };
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
254
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
255