Mercurial > hg > dmlib
annotate minijss/jloadjss.c @ 2472:fd02e78f6fdc
Allocate empty pattern for JSSMOD as well.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 27 Apr 2020 03:15:19 +0300 |
parents | dcf1016f3d27 |
children | 9807ae37ad69 |
rev | line source |
---|---|
0 | 1 /* |
2 * miniJSS - JSSMOD module loader | |
3 * Programmed and designed by Matti 'ccr' Hamalainen | |
2279 | 4 * (C) Copyright 2007-2019 Tecnic Software productions (TNSP) |
0 | 5 */ |
6 #include "jssmod.h" | |
7 | |
8 | |
1196 | 9 // If all pattern modes are required, enable them here |
0 | 10 #ifdef JM_SUP_PATMODE_ALL |
282 | 11 # define JM_SUP_PATMODE_1 1 |
12 # define JM_SUP_PATMODE_2 1 | |
13 # define JM_SUP_PATMODE_3 1 | |
14 # define JM_SUP_PATMODE_4 1 | |
15 # define JM_SUP_PATMODE_5 1 | |
2303
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
16 # define JM_SUP_PATMODE_6 1 |
0 | 17 #endif |
18 | |
19 | |
2278
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
20 static inline JSSNote * jssGetNotePtr(JSSPattern *pattern, const int channel, const int row) |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
21 { |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
22 return pattern->data + (pattern->nchannels * row) + pattern->map[channel]; |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
23 } |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
24 |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
25 |
1196 | 26 // Short helper macros for reading data |
27 #define JSGETBYTE(XV) \ | |
28 if (!dmf_read_byte(inFile, XV)) \ | |
29 return DMERR_OUT_OF_DATA | |
0 | 30 |
31 | |
2278
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
32 static int jssDoGetConvertedNote(DMResource *inFile, JSSNote *pnote, const Uint8 note) |
0 | 33 { |
34 Uint8 tmp; | |
35 | |
1208
fa758951720f
Remove some code duplication.
Matti Hamalainen <ccr@tnsp.org>
parents:
1198
diff
changeset
|
36 if (note == 127) |
1197 | 37 pnote->note = jsetNoteOff; |
1208
fa758951720f
Remove some code duplication.
Matti Hamalainen <ccr@tnsp.org>
parents:
1198
diff
changeset
|
38 else |
fa758951720f
Remove some code duplication.
Matti Hamalainen <ccr@tnsp.org>
parents:
1198
diff
changeset
|
39 if (note == 0) |
1197 | 40 pnote->note = jsetNotSet; |
0 | 41 else |
1208
fa758951720f
Remove some code duplication.
Matti Hamalainen <ccr@tnsp.org>
parents:
1198
diff
changeset
|
42 pnote->note = note - 1; |
0 | 43 |
44 JSGETBYTE(&tmp); | |
1197 | 45 pnote->instrument = (tmp > 0) ? tmp - 1 : jsetNotSet; |
0 | 46 |
47 JSGETBYTE(&tmp); | |
1197 | 48 pnote->volume = (tmp > 0) ? tmp - 1 : jsetNotSet; |
0 | 49 |
50 JSGETBYTE(&tmp); | |
1197 | 51 pnote->effect = (tmp > 0) ? tmp - 1 : jsetNotSet; |
0 | 52 |
53 JSGETBYTE(&tmp); | |
1197 | 54 pnote->param = (tmp == 0 && pnote->effect == jsetNotSet) ? jsetNotSet : tmp; |
0 | 55 |
56 return DMERR_OK; | |
57 } | |
1208
fa758951720f
Remove some code duplication.
Matti Hamalainen <ccr@tnsp.org>
parents:
1198
diff
changeset
|
58 |
fa758951720f
Remove some code duplication.
Matti Hamalainen <ccr@tnsp.org>
parents:
1198
diff
changeset
|
59 |
2278
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
60 static inline int jssGetConvertedNote(DMResource *inFile, |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
61 JSSPattern *pattern, const int channel, const int row) |
1208
fa758951720f
Remove some code duplication.
Matti Hamalainen <ccr@tnsp.org>
parents:
1198
diff
changeset
|
62 { |
fa758951720f
Remove some code duplication.
Matti Hamalainen <ccr@tnsp.org>
parents:
1198
diff
changeset
|
63 Uint8 tmp; |
2278
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
64 int res; |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
65 |
1208
fa758951720f
Remove some code duplication.
Matti Hamalainen <ccr@tnsp.org>
parents:
1198
diff
changeset
|
66 JSGETBYTE(&tmp); |
2278
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
67 if ((res = jssDoGetConvertedNote(inFile, |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
68 jssGetNotePtr(pattern, channel, row), tmp)) != DMERR_OK) |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
69 JSSERROR(res, res, "Error converting note on row=%d, chn=%d\n", |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
70 row, channel); |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
71 |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
72 return res; |
1208
fa758951720f
Remove some code duplication.
Matti Hamalainen <ccr@tnsp.org>
parents:
1198
diff
changeset
|
73 } |
0 | 74 |
75 | |
204
d3a9a3804079
Implement pattern mode 5 in the JMOD jloader.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
76 #if defined(JM_SUP_PATMODE_2) || defined(JM_SUP_PATMODE_4) |
2278
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
77 static int jssGetCompressedNoteDo(DMResource *inFile, |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
78 JSSPattern *pattern, const int channel, const int row) |
0 | 79 { |
2278
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
80 JSSNote *pnote = jssGetNotePtr(pattern, channel, row); |
0 | 81 Uint8 packb, tmp; |
2278
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
82 int res = DMERR_OK; |
0 | 83 |
84 JSGETBYTE(&packb); | |
85 if (packb & 0x80) | |
86 { | |
1210
6b48bad13399
Rename pattern note packing flag COMP_* constants to JM_COMP_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
1208
diff
changeset
|
87 if (packb & JM_COMP_NOTE) |
0 | 88 { |
89 JSGETBYTE(&tmp); | |
90 if (tmp == 127) | |
1197 | 91 pnote->note = jsetNoteOff; |
0 | 92 else |
1197 | 93 pnote->note = tmp; |
0 | 94 } |
95 | |
1210
6b48bad13399
Rename pattern note packing flag COMP_* constants to JM_COMP_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
1208
diff
changeset
|
96 if (packb & JM_COMP_INSTRUMENT) |
0 | 97 { |
98 JSGETBYTE(&tmp); | |
1197 | 99 pnote->instrument = tmp; |
0 | 100 } |
101 | |
1210
6b48bad13399
Rename pattern note packing flag COMP_* constants to JM_COMP_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
1208
diff
changeset
|
102 if (packb & JM_COMP_VOLUME) |
0 | 103 { |
104 JSGETBYTE(&tmp); | |
1197 | 105 pnote->volume = tmp; |
0 | 106 } |
107 | |
1210
6b48bad13399
Rename pattern note packing flag COMP_* constants to JM_COMP_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
1208
diff
changeset
|
108 if (packb & JM_COMP_EFFECT) |
0 | 109 { |
110 JSGETBYTE(&tmp); | |
1197 | 111 pnote->effect = tmp; |
112 pnote->param = 0; | |
0 | 113 } |
114 | |
1210
6b48bad13399
Rename pattern note packing flag COMP_* constants to JM_COMP_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
1208
diff
changeset
|
115 if (packb & JM_COMP_PARAM) |
0 | 116 { |
117 JSGETBYTE(&tmp); | |
1197 | 118 pnote->param = tmp; |
0 | 119 } |
120 } | |
121 else | |
122 { | |
2278
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
123 res = jssDoGetConvertedNote(inFile, pnote, packb); |
0 | 124 } |
125 | |
2278
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
126 return res; |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
127 } |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
128 |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
129 |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
130 static int jssGetCompressedNote(DMResource *inFile, |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
131 JSSPattern *pattern, const int channel, const int row) |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
132 { |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
133 int res = jssGetCompressedNoteDo(inFile, pattern, channel, row); |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
134 |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
135 if (res != DMERR_OK) |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
136 JSSERROR(res, res, "Error uncompressing note on row=%d, chn=%d\n", |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
137 row, channel); |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
138 |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
139 return res; |
0 | 140 } |
141 #endif | |
142 | |
143 | |
204
d3a9a3804079
Implement pattern mode 5 in the JMOD jloader.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
144 #ifdef JM_SUP_PATMODE_2 |
777
ed60a7ee3ebb
Change JSSMOD loader to use DMResources.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
145 static int jssGetPatternCompHoriz(DMResource *inFile, JSSPattern *pattern) |
0 | 146 { |
2278
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
147 for (int row = 0; row < pattern->nrows; row++) |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
148 for (int channel = 0; channel < pattern->nmap; channel++) |
0 | 149 { |
2278
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
150 int res = jssGetCompressedNote(inFile, pattern, channel, row); |
0 | 151 if (res != DMERR_OK) |
2278
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
152 return res; |
0 | 153 } |
154 | |
155 return DMERR_OK; | |
156 } | |
157 #endif | |
158 | |
159 | |
204
d3a9a3804079
Implement pattern mode 5 in the JMOD jloader.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
160 #ifdef JM_SUP_PATMODE_4 |
777
ed60a7ee3ebb
Change JSSMOD loader to use DMResources.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
161 static int jssGetPatternCompVert(DMResource *inFile, JSSPattern *pattern) |
0 | 162 { |
2278
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
163 for (int channel = 0; channel < pattern->nmap; channel++) |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
164 for (int row = 0; row < pattern->nrows; row++) |
0 | 165 { |
2278
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
166 int res = jssGetCompressedNote(inFile, pattern, channel, row); |
0 | 167 if (res != DMERR_OK) |
2278
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
168 return res; |
0 | 169 } |
170 | |
171 return DMERR_OK; | |
172 } | |
173 #endif | |
174 | |
175 | |
204
d3a9a3804079
Implement pattern mode 5 in the JMOD jloader.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
176 #ifdef JM_SUP_PATMODE_1 |
777
ed60a7ee3ebb
Change JSSMOD loader to use DMResources.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
177 static int jssGetPatternRawHoriz(DMResource *inFile, JSSPattern *pattern) |
0 | 178 { |
2278
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
179 for (int row = 0; row < pattern->nrows; row++) |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
180 for (int channel = 0; channel < pattern->nmap; channel++) |
0 | 181 { |
2278
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
182 int res = jssGetConvertedNote(inFile, pattern, channel, row); |
0 | 183 if (res != DMERR_OK) |
2278
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
184 return res; |
0 | 185 } |
186 | |
187 return DMERR_OK; | |
188 } | |
189 #endif | |
190 | |
191 | |
204
d3a9a3804079
Implement pattern mode 5 in the JMOD jloader.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
192 #ifdef JM_SUP_PATMODE_3 |
777
ed60a7ee3ebb
Change JSSMOD loader to use DMResources.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
193 static int jssGetPatternRawVert(DMResource *inFile, JSSPattern *pattern) |
0 | 194 { |
2278
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
195 for (int channel = 0; channel < pattern->nmap; channel++) |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
196 for (int row = 0; row < pattern->nrows; row++) |
0 | 197 { |
2278
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
198 int res = jssGetConvertedNote(inFile, pattern, channel, row); |
0 | 199 if (res != DMERR_OK) |
2278
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
200 return res; |
0 | 201 } |
202 | |
203 return DMERR_OK; | |
204 } | |
205 #endif | |
206 | |
207 | |
204
d3a9a3804079
Implement pattern mode 5 in the JMOD jloader.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
208 #ifdef JM_SUP_PATMODE_5 |
d3a9a3804079
Implement pattern mode 5 in the JMOD jloader.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
209 |
d3a9a3804079
Implement pattern mode 5 in the JMOD jloader.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
210 #undef JSGETBYTE |
777
ed60a7ee3ebb
Change JSSMOD loader to use DMResources.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
211 #define JSGETBYTE(XV) if (!dmf_read_byte(inFile, XV)) return DMERR_OUT_OF_DATA |
204
d3a9a3804079
Implement pattern mode 5 in the JMOD jloader.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
212 |
2278
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
213 #define JSFOREACHNOTE1 \ |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
214 for (int channel = 0; channel < pattern->nmap; channel++) \ |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
215 for (int row = 0; row < pattern->nrows; row++) { \ |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
216 JSSNote *pnote = pattern->data + (pattern->nchannels * row) + pattern->map[channel]; |
204
d3a9a3804079
Implement pattern mode 5 in the JMOD jloader.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
217 |
d3a9a3804079
Implement pattern mode 5 in the JMOD jloader.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
218 #define JSFOREACHNOTE2 } |
d3a9a3804079
Implement pattern mode 5 in the JMOD jloader.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
219 |
2278
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
220 |
777
ed60a7ee3ebb
Change JSSMOD loader to use DMResources.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
221 static int jssGetPatternRawVertElem(DMResource *inFile, JSSPattern *pattern) |
0 | 222 { |
204
d3a9a3804079
Implement pattern mode 5 in the JMOD jloader.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
223 Uint8 tmp; |
0 | 224 |
204
d3a9a3804079
Implement pattern mode 5 in the JMOD jloader.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
225 JSFOREACHNOTE1 |
d3a9a3804079
Implement pattern mode 5 in the JMOD jloader.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
226 JSGETBYTE(&tmp); |
d3a9a3804079
Implement pattern mode 5 in the JMOD jloader.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
227 if (tmp == 0) |
1197 | 228 pnote->note = jsetNotSet; |
204
d3a9a3804079
Implement pattern mode 5 in the JMOD jloader.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
229 else if (tmp == 127) |
1197 | 230 pnote->note = jsetNoteOff; |
204
d3a9a3804079
Implement pattern mode 5 in the JMOD jloader.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
231 else |
1197 | 232 pnote->note = tmp - 1; |
204
d3a9a3804079
Implement pattern mode 5 in the JMOD jloader.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
233 JSFOREACHNOTE2 |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1118
diff
changeset
|
234 |
204
d3a9a3804079
Implement pattern mode 5 in the JMOD jloader.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
235 JSFOREACHNOTE1 |
d3a9a3804079
Implement pattern mode 5 in the JMOD jloader.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
236 JSGETBYTE(&tmp); |
1197 | 237 pnote->instrument = (tmp > 0) ? tmp - 1 : jsetNotSet; |
204
d3a9a3804079
Implement pattern mode 5 in the JMOD jloader.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
238 JSFOREACHNOTE2 |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1118
diff
changeset
|
239 |
204
d3a9a3804079
Implement pattern mode 5 in the JMOD jloader.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
240 JSFOREACHNOTE1 |
d3a9a3804079
Implement pattern mode 5 in the JMOD jloader.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
241 JSGETBYTE(&tmp); |
1197 | 242 pnote->volume = (tmp > 0) ? tmp - 1 : jsetNotSet; |
204
d3a9a3804079
Implement pattern mode 5 in the JMOD jloader.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
243 JSFOREACHNOTE2 |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1118
diff
changeset
|
244 |
204
d3a9a3804079
Implement pattern mode 5 in the JMOD jloader.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
245 JSFOREACHNOTE1 |
d3a9a3804079
Implement pattern mode 5 in the JMOD jloader.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
246 JSGETBYTE(&tmp); |
1197 | 247 pnote->effect = (tmp > 0) ? tmp - 1 : jsetNotSet; |
204
d3a9a3804079
Implement pattern mode 5 in the JMOD jloader.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
248 JSFOREACHNOTE2 |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1118
diff
changeset
|
249 |
204
d3a9a3804079
Implement pattern mode 5 in the JMOD jloader.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
250 JSFOREACHNOTE1 |
d3a9a3804079
Implement pattern mode 5 in the JMOD jloader.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
251 JSGETBYTE(&tmp); |
1197 | 252 pnote->param = (tmp == 0 && pnote->effect == jsetNotSet) ? jsetNotSet : tmp; |
204
d3a9a3804079
Implement pattern mode 5 in the JMOD jloader.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
253 JSFOREACHNOTE2 |
d3a9a3804079
Implement pattern mode 5 in the JMOD jloader.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
254 |
0 | 255 return DMERR_OK; |
256 } | |
2303
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
257 |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
258 #undef JSFOREACHNOTE1 |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
259 #undef JSFOREACHNOTE2 |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
260 #endif |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
261 |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
262 |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
263 #ifdef JM_SUP_PATMODE_6 |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
264 |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
265 #undef JSGETBYTE |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
266 #define JSGETBYTE(XV) if (!dmf_read_byte(inFile, XV)) return DMERR_OUT_OF_DATA |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
267 |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
268 #define JSFOREACHNOTE1 \ |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
269 for (int row = 0; row < pattern->nrows; row++) \ |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
270 for (int channel = 0; channel < pattern->nmap; channel++) { \ |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
271 JSSNote *pnote = pattern->data + (pattern->nchannels * row) + pattern->map[channel]; |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
272 |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
273 #define JSFOREACHNOTE2 } |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
274 |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
275 |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
276 static int jssGetPatternRawHorizElem(DMResource *inFile, JSSPattern *pattern) |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
277 { |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
278 Uint8 tmp; |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
279 |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
280 JSFOREACHNOTE1 |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
281 JSGETBYTE(&tmp); |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
282 if (tmp == 0) |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
283 pnote->note = jsetNotSet; |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
284 else if (tmp == 127) |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
285 pnote->note = jsetNoteOff; |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
286 else |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
287 pnote->note = tmp - 1; |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
288 JSFOREACHNOTE2 |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
289 |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
290 JSFOREACHNOTE1 |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
291 JSGETBYTE(&tmp); |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
292 pnote->instrument = (tmp > 0) ? tmp - 1 : jsetNotSet; |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
293 JSFOREACHNOTE2 |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
294 |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
295 JSFOREACHNOTE1 |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
296 JSGETBYTE(&tmp); |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
297 pnote->volume = (tmp > 0) ? tmp - 1 : jsetNotSet; |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
298 JSFOREACHNOTE2 |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
299 |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
300 JSFOREACHNOTE1 |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
301 JSGETBYTE(&tmp); |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
302 pnote->effect = (tmp > 0) ? tmp - 1 : jsetNotSet; |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
303 JSFOREACHNOTE2 |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
304 |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
305 JSFOREACHNOTE1 |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
306 JSGETBYTE(&tmp); |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
307 pnote->param = (tmp == 0 && pnote->effect == jsetNotSet) ? jsetNotSet : tmp; |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
308 JSFOREACHNOTE2 |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
309 |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
310 return DMERR_OK; |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
311 } |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
312 |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
313 #undef JSFOREACHNOTE1 |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
314 #undef JSFOREACHNOTE2 |
0 | 315 #endif |
316 | |
317 | |
318 #ifdef JM_SUP_EXT_INSTR | |
1247
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
319 static int jssMODLoadEnvelope(DMResource *inFile, |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
320 JSSEnvelope *env, const char *name, const int ninst) |
0 | 321 { |
1247
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
322 JSSMODEnvelope jssEnv; |
0 | 323 |
1350
dcb5c16ecdb9
Silence warnings about unused function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1349
diff
changeset
|
324 (void) name; |
dcb5c16ecdb9
Silence warnings about unused function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1349
diff
changeset
|
325 (void) ninst; |
dcb5c16ecdb9
Silence warnings about unused function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1349
diff
changeset
|
326 |
1247
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
327 // Read envelope data |
1250
99852310dc02
Some more work on the loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1247
diff
changeset
|
328 if (!dmf_read_byte(inFile, &jssEnv.flags) || |
99852310dc02
Some more work on the loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1247
diff
changeset
|
329 !dmf_read_byte(inFile, &jssEnv.npoints) || |
99852310dc02
Some more work on the loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1247
diff
changeset
|
330 !dmf_read_byte(inFile, &jssEnv.sustain) || |
99852310dc02
Some more work on the loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1247
diff
changeset
|
331 !dmf_read_byte(inFile, &jssEnv.loopS) || |
99852310dc02
Some more work on the loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1247
diff
changeset
|
332 !dmf_read_byte(inFile, &jssEnv.loopE)) |
1314 | 333 { |
1247
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
334 JSSERROR(DMERR_FREAD, DMERR_FREAD, |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
335 "Failed to read %s-envelope data for instrument #%d.\n", |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
336 name, ninst); |
1314 | 337 } |
1247
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
338 |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
339 // Do some sanity checking |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
340 if (jssEnv.npoints > jsetMaxEnvPoints || |
1331
c0479e984242
Fix a envelope "sanity check" in jmod loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1316
diff
changeset
|
341 jssEnv.loopS > jssEnv.loopE || |
1247
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
342 jssEnv.loopS > jssEnv.npoints || |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
343 jssEnv.loopE > jssEnv.npoints) |
1314 | 344 { |
1247
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
345 JSSERROR(DMERR_INVALID_DATA, DMERR_INVALID_DATA, |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
346 "Invalid values in %s-envelope for instrument #%d.\n", |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
347 name, ninst); |
1314 | 348 } |
0 | 349 |
1247
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
350 // Copy data |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
351 env->flags = jssEnv.flags; |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
352 env->npoints = jssEnv.npoints; |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
353 env->sustain = jssEnv.sustain; |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
354 env->loopS = jssEnv.loopS; |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
355 env->loopE = jssEnv.loopE; |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
356 |
1314 | 357 for (int i = 0; i < jssEnv.npoints; i++) |
0 | 358 { |
1247
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
359 Uint16 frame, value; |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
360 if (!dmf_read_le16(inFile, &frame) || |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
361 !dmf_read_le16(inFile, &value)) |
1314 | 362 { |
1247
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
363 JSSERROR(DMERR_FREAD, DMERR_FREAD, |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
364 "Failed to read %s-envelope values (%d) for instrument #%d.\n", |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
365 name, i, ninst); |
1314 | 366 } |
1247
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
367 |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
368 env->points[i].frame = frame; |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
369 env->points[i].value = value; |
0 | 370 } |
1247
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
371 |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
372 return DMERR_OK; |
0 | 373 } |
374 #endif | |
375 | |
376 | |
1256 | 377 int jssLoadJSSMOD(DMResource *inFile, JSSModule **pmodule, BOOL probe) |
0 | 378 { |
379 JSSModule *module; | |
380 JSSMODHeader jssH; | |
1247
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
381 int index, ret = DMERR_OK; |
0 | 382 |
1256 | 383 *pmodule = NULL; |
0 | 384 |
385 // Check the JSSMOD header | |
1247
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
386 if (!dmf_read_str(inFile, &jssH.idMagic, sizeof(jssH.idMagic)) || |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
387 !dmf_read_byte(inFile, &jssH.idVersion)) |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
388 JSSERROR(DMERR_FREAD, DMERR_FREAD, |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
389 "Failed to read JSSMOD header #1.\n"); |
0 | 390 |
391 if (memcmp(jssH.idMagic, "JM", 2) != 0) | |
392 { | |
796 | 393 if (probe) |
394 return DMERR_NOT_SUPPORTED; | |
395 else | |
1310
dce4730372c7
Add some blocks, cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
1271
diff
changeset
|
396 { |
796 | 397 JSSERROR(DMERR_NOT_SUPPORTED, DMERR_NOT_SUPPORTED, |
398 "Not a JSSMOD file, header signature mismatch!\n"); | |
1310
dce4730372c7
Add some blocks, cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
1271
diff
changeset
|
399 } |
0 | 400 } |
401 | |
402 if (jssH.idVersion != JSSMOD_VERSION) | |
403 { | |
1198 | 404 if (probe) |
405 return DMERR_VERSION; | |
406 else | |
1310
dce4730372c7
Add some blocks, cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
1271
diff
changeset
|
407 { |
dce4730372c7
Add some blocks, cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
1271
diff
changeset
|
408 JSSERROR(DMERR_VERSION, DMERR_VERSION, |
dce4730372c7
Add some blocks, cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
1271
diff
changeset
|
409 "Unsupported version of JSSMOD 0x%2x, this version only supports 0x%2x!\n", |
dce4730372c7
Add some blocks, cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
1271
diff
changeset
|
410 jssH.idVersion, JSSMOD_VERSION); |
dce4730372c7
Add some blocks, cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
1271
diff
changeset
|
411 } |
0 | 412 } |
413 | |
1247
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
414 // Read rest of the header |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
415 if (!dmf_read_le16(inFile, &jssH.defFlags) || |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
416 !dmf_read_le16(inFile, &jssH.intVersion) || |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
417 !dmf_read_le16(inFile, &jssH.norders) || |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
418 !dmf_read_le16(inFile, &jssH.npatterns) || |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
419 !dmf_read_le16(inFile, &jssH.nextInstruments) || |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
420 !dmf_read_le16(inFile, &jssH.ninstruments) || |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
421 !dmf_read_le16(inFile, &jssH.defRestartPos) || |
1310
dce4730372c7
Add some blocks, cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
1271
diff
changeset
|
422 |
1247
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
423 !dmf_read_byte(inFile, &jssH.nchannels) || |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
424 !dmf_read_byte(inFile, &jssH.defSpeed) || |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
425 !dmf_read_byte(inFile, &jssH.defTempo) || |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
426 !dmf_read_byte(inFile, &jssH.patMode)) |
1310
dce4730372c7
Add some blocks, cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
1271
diff
changeset
|
427 { |
1247
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
428 JSSERROR(DMERR_FREAD, DMERR_FREAD, |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
429 "Failed to read JSSMOD header #2.\n"); |
1310
dce4730372c7
Add some blocks, cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
1271
diff
changeset
|
430 } |
1247
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
431 |
1198 | 432 if (probe) |
433 return DMERR_OK; | |
434 | |
1218
30c2dbf05841
Add a sanity check for JSSMOD header values.
Matti Hamalainen <ccr@tnsp.org>
parents:
1214
diff
changeset
|
435 // Check some of the things for sanity |
30c2dbf05841
Add a sanity check for JSSMOD header values.
Matti Hamalainen <ccr@tnsp.org>
parents:
1214
diff
changeset
|
436 if (jssH.nchannels > jsetMaxChannels || |
30c2dbf05841
Add a sanity check for JSSMOD header values.
Matti Hamalainen <ccr@tnsp.org>
parents:
1214
diff
changeset
|
437 jssH.nchannels == 0 || |
30c2dbf05841
Add a sanity check for JSSMOD header values.
Matti Hamalainen <ccr@tnsp.org>
parents:
1214
diff
changeset
|
438 jssH.norders > jsetMaxOrders || |
30c2dbf05841
Add a sanity check for JSSMOD header values.
Matti Hamalainen <ccr@tnsp.org>
parents:
1214
diff
changeset
|
439 jssH.npatterns > jsetMaxPatterns || |
30c2dbf05841
Add a sanity check for JSSMOD header values.
Matti Hamalainen <ccr@tnsp.org>
parents:
1214
diff
changeset
|
440 jssH.nextInstruments > jsetMaxInstruments || |
30c2dbf05841
Add a sanity check for JSSMOD header values.
Matti Hamalainen <ccr@tnsp.org>
parents:
1214
diff
changeset
|
441 jssH.ninstruments > jsetMaxInstruments) |
30c2dbf05841
Add a sanity check for JSSMOD header values.
Matti Hamalainen <ccr@tnsp.org>
parents:
1214
diff
changeset
|
442 { |
30c2dbf05841
Add a sanity check for JSSMOD header values.
Matti Hamalainen <ccr@tnsp.org>
parents:
1214
diff
changeset
|
443 JSSERROR(DMERR_INVALID_DATA, DMERR_INVALID_DATA, |
30c2dbf05841
Add a sanity check for JSSMOD header values.
Matti Hamalainen <ccr@tnsp.org>
parents:
1214
diff
changeset
|
444 "Invalid values in JSSMOD header.\n"); |
30c2dbf05841
Add a sanity check for JSSMOD header values.
Matti Hamalainen <ccr@tnsp.org>
parents:
1214
diff
changeset
|
445 } |
30c2dbf05841
Add a sanity check for JSSMOD header values.
Matti Hamalainen <ccr@tnsp.org>
parents:
1214
diff
changeset
|
446 |
0 | 447 // Allocate the module |
1256 | 448 if ((*pmodule = module = jssAllocateModule()) == NULL) |
0 | 449 { |
450 JSSERROR(DMERR_MALLOC, DMERR_MALLOC, | |
451 "Could not allocate memory for module structure.\n"); | |
452 } | |
453 | |
454 // Copy header information | |
1216 | 455 module->defFlags = jssH.defFlags; |
456 module->intVersion = jssH.intVersion; | |
457 | |
0 | 458 module->norders = jssH.norders; |
459 module->npatterns = jssH.npatterns; | |
460 module->nchannels = jssH.nchannels; | |
461 module->nextInstruments = jssH.nextInstruments; | |
462 module->ninstruments = jssH.ninstruments; | |
463 module->defRestartPos = jssH.defRestartPos; | |
464 module->defSpeed = jssH.defSpeed; | |
465 module->defTempo = jssH.defTempo; | |
466 | |
467 // Get the orders list | |
468 for (index = 0; index < module->norders; index++) | |
469 { | |
1247
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
470 Uint16 tmp; |
1250
99852310dc02
Some more work on the loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1247
diff
changeset
|
471 if (!dmf_read_le16(inFile, &tmp)) |
1247
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
472 JSSERROR(DMERR_FREAD, DMERR_FREAD, |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
473 "Failed to read orders list entry #%d.\n", |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
474 index); |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
475 |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
476 if (tmp != 0xffff && tmp > jssH.npatterns) |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
477 JSSERROR(DMERR_INVALID_DATA, DMERR_INVALID_DATA, |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
478 "Invalid orders list entry #%d value %d > %d.\n", |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
479 index, tmp, jssH.npatterns); |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
480 |
1311 | 481 module->orderList[index] = (tmp == 0xffff) ? jsetNotSet : tmp; |
0 | 482 } |
483 | |
2472
fd02e78f6fdc
Allocate empty pattern for JSSMOD as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
2303
diff
changeset
|
484 // Allocate the empty pattern |
fd02e78f6fdc
Allocate empty pattern for JSSMOD as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
2303
diff
changeset
|
485 module->patterns[jsetMaxPatterns] = jssAllocatePattern(64, module->nchannels); |
fd02e78f6fdc
Allocate empty pattern for JSSMOD as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
2303
diff
changeset
|
486 |
0 | 487 // Parse the patterns |
488 for (index = 0; index < module->npatterns; index++) | |
489 { | |
1255
f9bf71071f0b
Some work on JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1250
diff
changeset
|
490 JSSPattern *pattern; |
0 | 491 JSSMODPattern jssP; |
492 | |
1255
f9bf71071f0b
Some work on JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1250
diff
changeset
|
493 // Read pattern header |
f9bf71071f0b
Some work on JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1250
diff
changeset
|
494 if (!dmf_read_le32(inFile, &jssP.size) || |
2278
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
495 !dmf_read_le16(inFile, &jssP.nrows) || |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
496 !dmf_read_le16(inFile, &jssP.nchannels)) |
1255
f9bf71071f0b
Some work on JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1250
diff
changeset
|
497 JSSERROR(DMERR_FREAD, DMERR_FREAD, |
f9bf71071f0b
Some work on JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1250
diff
changeset
|
498 "Failed to read JSSMOD pattern header #%d.\n", |
f9bf71071f0b
Some work on JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1250
diff
changeset
|
499 index); |
f9bf71071f0b
Some work on JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1250
diff
changeset
|
500 |
f9bf71071f0b
Some work on JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1250
diff
changeset
|
501 // Validate |
f9bf71071f0b
Some work on JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1250
diff
changeset
|
502 if (jssP.nrows == 0 || jssP.nrows > jsetMaxRows) |
f9bf71071f0b
Some work on JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1250
diff
changeset
|
503 JSSERROR(DMERR_INVALID_DATA, DMERR_INVALID_DATA, |
f9bf71071f0b
Some work on JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1250
diff
changeset
|
504 "Invalid number of rows in pattern #%d: %d.\n", |
1257 | 505 index, jssP.nrows); |
0 | 506 |
2278
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
507 if (jssP.nchannels == 0 || jssP.nchannels > module->nchannels) |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
508 JSSERROR(DMERR_INVALID_DATA, DMERR_INVALID_DATA, |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
509 "Invalid number of channels in pattern #%d: %d.\n", |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
510 index, jssP.nchannels); |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
511 |
0 | 512 // Allocate pattern |
1255
f9bf71071f0b
Some work on JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1250
diff
changeset
|
513 pattern = module->patterns[index] = jssAllocatePattern(jssP.nrows, module->nchannels); |
f9bf71071f0b
Some work on JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1250
diff
changeset
|
514 if (pattern == NULL) |
1310
dce4730372c7
Add some blocks, cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
1271
diff
changeset
|
515 { |
0 | 516 JSSERROR(DMERR_MALLOC, DMERR_MALLOC, |
1212 | 517 "Could not allocate memory for pattern #%d.\n", |
518 index); | |
1310
dce4730372c7
Add some blocks, cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
1271
diff
changeset
|
519 } |
0 | 520 |
2278
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
521 // Read channel mappings, if any |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
522 pattern->nmap = jssP.nchannels; |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
523 if (jssP.nchannels != module->nchannels) |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
524 { |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
525 if (!dmf_read_str(inFile, pattern->map, |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
526 sizeof(pattern->map[0]) * jssP.nchannels)) |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
527 JSSERROR(DMERR_FREAD, DMERR_FREAD, |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
528 "Failed to read JSSMOD channel mapping data for pattern #%d.\n", |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
529 index); |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
530 |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
531 // Check mapping |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
532 for (int nch = 0; nch < jssP.nchannels; nch++) |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
533 { |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
534 if (pattern->map[nch] >= module->nchannels) |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
535 { |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
536 JSSERROR(DMERR_INVALID_DATA, DMERR_INVALID_DATA, |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
537 "Invalid channel mapping in pattern #%d: chn %d -> %d.\n", |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
538 index, nch, pattern->map[nch]); |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
539 } |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
540 } |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
541 } |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1817
diff
changeset
|
542 |
0 | 543 // Get pattern data |
544 switch (jssH.patMode) | |
545 { | |
546 #ifdef JM_SUP_PATMODE_1 | |
547 case PATMODE_RAW_HORIZ: | |
1255
f9bf71071f0b
Some work on JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1250
diff
changeset
|
548 ret = jssGetPatternRawHoriz(inFile, pattern); |
0 | 549 break; |
550 #endif | |
551 #ifdef JM_SUP_PATMODE_2 | |
552 case PATMODE_COMP_HORIZ: | |
1255
f9bf71071f0b
Some work on JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1250
diff
changeset
|
553 ret = jssGetPatternCompHoriz(inFile, pattern); |
0 | 554 break; |
555 #endif | |
556 #ifdef JM_SUP_PATMODE_3 | |
557 case PATMODE_RAW_VERT: | |
1255
f9bf71071f0b
Some work on JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1250
diff
changeset
|
558 ret = jssGetPatternRawVert(inFile, pattern); |
0 | 559 break; |
560 #endif | |
561 #ifdef JM_SUP_PATMODE_4 | |
562 case PATMODE_COMP_VERT: | |
1255
f9bf71071f0b
Some work on JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1250
diff
changeset
|
563 ret = jssGetPatternCompVert(inFile, pattern); |
0 | 564 break; |
565 #endif | |
566 #ifdef JM_SUP_PATMODE_5 | |
2303
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
567 case PATMODE_RAW_ELEM_VERT: |
1255
f9bf71071f0b
Some work on JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1250
diff
changeset
|
568 ret = jssGetPatternRawVertElem(inFile, pattern); |
0 | 569 break; |
570 #endif | |
2303
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
571 #ifdef JM_SUP_PATMODE_6 |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
572 case PATMODE_RAW_ELEM_HORIZ: |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
573 ret = jssGetPatternRawHorizElem(inFile, pattern); |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
574 break; |
dcf1016f3d27
Implement new (horizontal raw element) pattern storage mode for JSSMOD. Bump
Matti Hamalainen <ccr@tnsp.org>
parents:
2279
diff
changeset
|
575 #endif |
0 | 576 default: |
577 JSSERROR(DMERR_INVALID_DATA, DMERR_INVALID_DATA, | |
1212 | 578 "Unsupported pattern mode %d. Check compilation options.", |
579 jssH.patMode); | |
0 | 580 break; |
581 } | |
582 | |
1247
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
583 if (ret != DMERR_OK) |
0 | 584 { |
1247
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
585 JSSERROR(ret, ret, |
1212 | 586 "Error in unpacking pattern #%d data.\n", |
587 index); | |
0 | 588 } |
589 } | |
590 | |
591 #ifdef JM_SUP_EXT_INSTR | |
592 // Read extended instruments | |
593 for (index = 0; index < module->nextInstruments; index++) | |
594 { | |
595 JSSMODExtInstrument jssE; | |
596 JSSExtInstrument *einst; | |
597 int i; | |
598 | |
1247
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
599 // Read header data |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
600 if (!dmf_read_byte(inFile, &jssE.nsamples) || |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
601 !dmf_read_byte(inFile, &jssE.vibratoType) || |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
602 !dmf_read_le16(inFile, &jssE.vibratoSweep) || |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
603 !dmf_read_le16(inFile, &jssE.vibratoDepth) || |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
604 !dmf_read_le16(inFile, &jssE.vibratoRate) || |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
605 !dmf_read_le16(inFile, &jssE.fadeOut)) |
1271 | 606 { |
1247
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
607 JSSERROR(DMERR_FREAD, DMERR_FREAD, |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
608 "Failed to read ext.instrument #%d header.\n", |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
609 index); |
1271 | 610 } |
1817 | 611 |
1247
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
612 // Allocate instrument |
1311 | 613 einst = module->extInstruments[index] = jssAllocateExtInstrument(); |
614 if (einst == NULL) | |
0 | 615 { |
616 JSSERROR(DMERR_MALLOC, DMERR_MALLOC, | |
1214 | 617 "Could not allocate extended instrument structure #%d\n", index); |
0 | 618 } |
619 | |
620 einst->nsamples = jssE.nsamples; | |
621 einst->vibratoType = jssE.vibratoType; | |
622 einst->vibratoSweep = jssE.vibratoSweep; | |
623 einst->vibratoDepth = jssE.vibratoDepth; | |
624 einst->vibratoRate = jssE.vibratoRate; | |
625 einst->fadeOut = jssE.fadeOut; | |
626 | |
1247
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
627 // Read and somewhat validate sNumForNotes |
0 | 628 for (i = 0; i < jsetNNotes; i++) |
629 { | |
1247
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
630 int snum; |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
631 Uint32 tmp; |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
632 |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
633 if (!dmf_read_le32(inFile, &tmp)) |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
634 { |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
635 JSSERROR(DMERR_FREAD, DMERR_FREAD, |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
636 "Failed to read ext.instrument #%d sNumForNotes[%d].\n", |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
637 index, i); |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
638 } |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
639 |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
640 einst->sNumForNotes[i] = snum = (tmp > 0) ? ((int) tmp - 1) : jsetNotSet; |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
641 |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
642 if (snum != jsetNotSet && snum > module->ninstruments) |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
643 { |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
644 JSSERROR(DMERR_INVALID_DATA, DMERR_INVALID_DATA, |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
645 "Ext.instrument #%d has invalid sNumForNotes[%d] = %d > %d max.\n", |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
646 index, i, snum, module->ninstruments); |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
647 } |
0 | 648 } |
649 | |
1247
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
650 // Read and validate envelopes |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
651 if ((ret = jssMODLoadEnvelope(inFile, &einst->volumeEnv, "volume", index)) != DMERR_OK || |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
652 (ret = jssMODLoadEnvelope(inFile, &einst->panningEnv, "panning", index)) != DMERR_OK) |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
653 return ret; |
0 | 654 } |
655 | |
656 #ifdef JM_SUP_INSTR | |
657 // Read sample instrument headers | |
658 for (index = 0; index < module->ninstruments; index++) | |
659 { | |
660 JSSMODInstrument jssI; | |
661 JSSInstrument *inst; | |
662 | |
1247
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
663 // Read header data |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
664 if (!dmf_read_le32(inFile, &jssI.size) || |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
665 !dmf_read_le32(inFile, &jssI.loopS) || |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
666 !dmf_read_le32(inFile, &jssI.loopE) || |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
667 !dmf_read_le16(inFile, &jssI.flags) || |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
668 !dmf_read_le16(inFile, &jssI.C4BaseSpeed) || |
1349
5adf67d1dea4
Fix loading of instrument relative note, finetune and panning values, which should be signed.
Matti Hamalainen <ccr@tnsp.org>
parents:
1331
diff
changeset
|
669 !dmf_read_le16(inFile, (Uint16 *) &jssI.ERelNote) || |
5adf67d1dea4
Fix loading of instrument relative note, finetune and panning values, which should be signed.
Matti Hamalainen <ccr@tnsp.org>
parents:
1331
diff
changeset
|
670 !dmf_read_le16(inFile, (Uint16 *) &jssI.EFineTune) || |
5adf67d1dea4
Fix loading of instrument relative note, finetune and panning values, which should be signed.
Matti Hamalainen <ccr@tnsp.org>
parents:
1331
diff
changeset
|
671 !dmf_read_le16(inFile, (Uint16 *) &jssI.EPanning) || |
1247
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
672 !dmf_read_byte(inFile, &jssI.volume) || |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
673 !dmf_read_byte(inFile, &jssI.convFlags)) |
0 | 674 { |
1247
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
675 JSSERROR(DMERR_FREAD, DMERR_FREAD, |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
676 "Failed to read sample instrument #%d header.\n", |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
677 index); |
0 | 678 } |
679 | |
1247
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
680 // Validate what we can |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
681 if (jssI.loopS > jssI.size || |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
682 jssI.loopE > jssI.size || |
1311 | 683 jssI.loopS > jssI.loopE) |
1247
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
684 { |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
685 JSSERROR(DMERR_INVALID_DATA, DMERR_INVALID_DATA, |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
686 "Invalid or corrupted sample instrument #%d.\n", |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
687 index); |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
688 } |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
689 |
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
690 // Allocate instrument |
1311 | 691 inst = module->instruments[index] = jssAllocateInstrument(); |
692 if (inst == NULL) | |
693 { | |
694 JSSERROR(DMERR_MALLOC, DMERR_MALLOC, | |
695 "Could not allocate sample instrument structure #%d\n", | |
696 index); | |
697 } | |
0 | 698 |
1231 | 699 // Copy data |
0 | 700 inst->size = jssI.size; |
701 inst->loopS = jssI.loopS; | |
702 inst->loopE = jssI.loopE; | |
703 inst->flags = jssI.flags; | |
704 inst->C4BaseSpeed = jssI.C4BaseSpeed; | |
705 inst->ERelNote = jssI.ERelNote; | |
706 inst->EFineTune = jssI.EFineTune; | |
707 inst->EPanning = jssI.EPanning; | |
1247
5ae2ce21c7ae
Some work on refactoring the JSSMOD loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1239
diff
changeset
|
708 inst->volume = jssI.volume; |
0 | 709 inst->convFlags = jssI.convFlags; |
710 } | |
711 | |
712 #ifdef JM_SUP_SAMPLES | |
713 // Read sample data | |
714 for (index = 0; index < module->ninstruments; index++) | |
715 { | |
716 JSSInstrument *inst = module->instruments[index]; | |
1312 | 717 if (inst != NULL && (inst->convFlags & jsampHasData) != 0) |
0 | 718 { |
1129
e466d10dae6d
Change API of jssDecodeSample{8,16}() functions to return dmlib error codes
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
719 int ret; |
1213
505317227ab4
Rename variable, improve two error messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
1212
diff
changeset
|
720 size_t bsize = (inst->flags & jsf16bit) ? sizeof(Uint16) : sizeof(Uint8); |
505317227ab4
Rename variable, improve two error messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
1212
diff
changeset
|
721 bsize *= inst->size; |
0 | 722 |
1316 | 723 // Allocate sample data memory |
1213
505317227ab4
Rename variable, improve two error messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
1212
diff
changeset
|
724 if ((inst->data = dmMalloc(bsize)) == NULL) |
0 | 725 { |
726 JSSERROR(DMERR_MALLOC, DMERR_MALLOC, | |
1213
505317227ab4
Rename variable, improve two error messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
1212
diff
changeset
|
727 "Could not allocate %d bytes of sample data #%d\n", |
505317227ab4
Rename variable, improve two error messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
1212
diff
changeset
|
728 bsize, index); |
0 | 729 } |
730 | |
1316 | 731 // Read data |
1213
505317227ab4
Rename variable, improve two error messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
1212
diff
changeset
|
732 if (!dmf_read_str(inFile, inst->data, bsize)) |
777
ed60a7ee3ebb
Change JSSMOD loader to use DMResources.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
733 { |
ed60a7ee3ebb
Change JSSMOD loader to use DMResources.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
734 JSSERROR(DMERR_FREAD, DMERR_FREAD, |
1213
505317227ab4
Rename variable, improve two error messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
1212
diff
changeset
|
735 "Could not read %d bytes of sample data for #%d\n", |
505317227ab4
Rename variable, improve two error messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
1212
diff
changeset
|
736 bsize, index); |
777
ed60a7ee3ebb
Change JSSMOD loader to use DMResources.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
737 } |
0 | 738 |
739 // Convert, if needed | |
740 if (inst->flags & jsf16bit) | |
1129
e466d10dae6d
Change API of jssDecodeSample{8,16}() functions to return dmlib error codes
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
741 ret = jssDecodeSample16(inst->data, inst->size, inst->convFlags); |
0 | 742 else |
1129
e466d10dae6d
Change API of jssDecodeSample{8,16}() functions to return dmlib error codes
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
743 ret = jssDecodeSample8(inst->data, inst->size, inst->convFlags); |
e466d10dae6d
Change API of jssDecodeSample{8,16}() functions to return dmlib error codes
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
744 |
e466d10dae6d
Change API of jssDecodeSample{8,16}() functions to return dmlib error codes
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
745 if (ret != DMERR_OK) |
e466d10dae6d
Change API of jssDecodeSample{8,16}() functions to return dmlib error codes
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
746 { |
e466d10dae6d
Change API of jssDecodeSample{8,16}() functions to return dmlib error codes
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
747 JSSERROR(ret, ret, |
e466d10dae6d
Change API of jssDecodeSample{8,16}() functions to return dmlib error codes
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
748 "Failed to decode sample data for #%d\n", index); |
e466d10dae6d
Change API of jssDecodeSample{8,16}() functions to return dmlib error codes
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
749 } |
0 | 750 } |
751 } | |
752 #else | |
282 | 753 # warning Not including JSSMOD sample loading! |
0 | 754 #endif // JM_SUP_SAMPLES |
755 #else | |
282 | 756 # warning Not including JSSMOD instrument loading! |
0 | 757 #endif // JM_SUP_INSTR |
758 #else | |
282 | 759 # warning Not including JSSMOD ext.instrument loading! |
0 | 760 #endif // JM_SUP_EXT_INSTR |
761 | |
762 return DMERR_OK; | |
763 } |