diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2020-08-08 21:56:15 -0400 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2020-08-11 03:29:12 +0000 |
commit | b4e70422a3455e327433a7471c929ef100ef3b10 (patch) | |
tree | e96c5431a1b22af1fcbc628322b79fb8c3162427 /apps/plugins/mikmod/load_far.c | |
parent | 8c7780bafc9eabac6b92cfe5a5a00831c3d5fd9d (diff) | |
download | rockbox-b4e70422a3455e327433a7471c929ef100ef3b10.tar.gz rockbox-b4e70422a3455e327433a7471c929ef100ef3b10.zip |
mikmod: Upgrade mikmod core from v3.2.0 to v3.3.11
* Get rid of the non-functional GT2 loader
* Add the UMX loader
* Add HQ mixer routines (and make it configurable)
* Allow samplerate to be configured at run/playtime
* Support >64KHz mixing/playback
* Correctly restore non-boost status
(The diff to upstream is much smaller now too!)
Change-Id: Iaa4ac901ba9cd4123bb225656976e78271353a72
Diffstat (limited to 'apps/plugins/mikmod/load_far.c')
-rw-r--r-- | apps/plugins/mikmod/load_far.c | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/apps/plugins/mikmod/load_far.c b/apps/plugins/mikmod/load_far.c index 2a1a44eda9..643cf15d49 100644 --- a/apps/plugins/mikmod/load_far.c +++ b/apps/plugins/mikmod/load_far.c | |||
@@ -6,12 +6,12 @@ | |||
6 | it under the terms of the GNU Library General Public License as | 6 | it under the terms of the GNU Library General Public License as |
7 | published by the Free Software Foundation; either version 2 of | 7 | published by the Free Software Foundation; either version 2 of |
8 | the License, or (at your option) any later version. | 8 | the License, or (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU Library General Public License for more details. | 13 | GNU Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public | 15 | You should have received a copy of the GNU Library General Public |
16 | License along with this library; if not, write to the Free Software | 16 | License along with this library; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
@@ -20,7 +20,7 @@ | |||
20 | 20 | ||
21 | /*============================================================================== | 21 | /*============================================================================== |
22 | 22 | ||
23 | $Id: load_far.c,v 1.3 2005/04/07 19:57:38 realtech Exp $ | 23 | $Id$ |
24 | 24 | ||
25 | Farandole (FAR) module loader | 25 | Farandole (FAR) module loader |
26 | 26 | ||
@@ -92,7 +92,7 @@ static FARHEADER1 *mh1 = NULL; | |||
92 | static FARHEADER2 *mh2 = NULL; | 92 | static FARHEADER2 *mh2 = NULL; |
93 | static FARNOTE *pat = NULL; | 93 | static FARNOTE *pat = NULL; |
94 | 94 | ||
95 | static unsigned char FARSIG[4+3]={'F','A','R',0xfe,13,10,26}; | 95 | static const unsigned char FARSIG[4+3]={'F','A','R',0xfe,13,10,26}; |
96 | 96 | ||
97 | /*========== Loader code */ | 97 | /*========== Loader code */ |
98 | 98 | ||
@@ -119,6 +119,9 @@ static void FAR_Cleanup(void) | |||
119 | MikMod_free(mh1); | 119 | MikMod_free(mh1); |
120 | MikMod_free(mh2); | 120 | MikMod_free(mh2); |
121 | MikMod_free(pat); | 121 | MikMod_free(pat); |
122 | mh1 = NULL; | ||
123 | mh2 = NULL; | ||
124 | pat = NULL; | ||
122 | } | 125 | } |
123 | 126 | ||
124 | static UBYTE *FAR_ConvertTrack(FARNOTE* n,int rows) | 127 | static UBYTE *FAR_ConvertTrack(FARNOTE* n,int rows) |
@@ -180,7 +183,7 @@ static int FAR_Load(int curious) | |||
180 | FARSAMPLE s; | 183 | FARSAMPLE s; |
181 | FARNOTE *crow; | 184 | FARNOTE *crow; |
182 | UBYTE smap[8]; | 185 | UBYTE smap[8]; |
183 | (void)curious; | 186 | (void)curious; |
184 | 187 | ||
185 | /* try to read module header (first part) */ | 188 | /* try to read module header (first part) */ |
186 | _mm_read_UBYTES(mh1->id,4,modreader); | 189 | _mm_read_UBYTES(mh1->id,4,modreader); |
@@ -196,7 +199,7 @@ static int FAR_Load(int curious) | |||
196 | mh1->stlen = _mm_read_I_UWORD (modreader); | 199 | mh1->stlen = _mm_read_I_UWORD (modreader); |
197 | 200 | ||
198 | /* init modfile data */ | 201 | /* init modfile data */ |
199 | of.modtype = StrDup(FAR_Version); | 202 | of.modtype = MikMod_strdup(FAR_Version); |
200 | of.songname = DupStr(mh1->songname,40,1); | 203 | of.songname = DupStr(mh1->songname,40,1); |
201 | of.numchn = 16; | 204 | of.numchn = 16; |
202 | of.initspeed = mh1->speed; | 205 | of.initspeed = mh1->speed; |
@@ -207,7 +210,12 @@ static int FAR_Load(int curious) | |||
207 | 210 | ||
208 | /* read songtext into comment field */ | 211 | /* read songtext into comment field */ |
209 | if(mh1->stlen) | 212 | if(mh1->stlen) |
210 | if (!ReadLinedComment(mh1->stlen, 66)) return 0; | 213 | if (!ReadLinedComment(mh1->stlen, 132)) return 0; |
214 | |||
215 | if(_mm_eof(modreader)) { | ||
216 | _mm_errno = MMERR_LOADING_HEADER; | ||
217 | return 0; | ||
218 | } | ||
211 | 219 | ||
212 | /* try to read module header (second part) */ | 220 | /* try to read module header (second part) */ |
213 | _mm_read_UBYTES(mh2->orders,256,modreader); | 221 | _mm_read_UBYTES(mh2->orders,256,modreader); |
@@ -238,12 +246,14 @@ static int FAR_Load(int curious) | |||
238 | if(!AllocPatterns()) return 0; | 246 | if(!AllocPatterns()) return 0; |
239 | 247 | ||
240 | for(t=0;t<of.numpat;t++) { | 248 | for(t=0;t<of.numpat;t++) { |
241 | UBYTE rows=0/* ,tempo */; | 249 | UBYTE rows=0; |
250 | UBYTE tempo; | ||
242 | 251 | ||
243 | memset(pat,0,256*16*4*sizeof(FARNOTE)); | 252 | memset(pat,0,256*16*4*sizeof(FARNOTE)); |
244 | if(mh2->patsiz[t]) { | 253 | if(mh2->patsiz[t]) { |
245 | rows = _mm_read_UBYTE(modreader); | 254 | rows = _mm_read_UBYTE(modreader); |
246 | /* tempo = */ (void)_mm_read_UBYTE(modreader); | 255 | tempo = _mm_read_UBYTE(modreader); |
256 | (void)tempo; /* unused */ | ||
247 | 257 | ||
248 | crow = pat; | 258 | crow = pat; |
249 | /* file often allocates 64 rows even if there are less in pattern */ | 259 | /* file often allocates 64 rows even if there are less in pattern */ |
@@ -284,7 +294,7 @@ static int FAR_Load(int curious) | |||
284 | of.numins = 0; | 294 | of.numins = 0; |
285 | for(t=0;t<64;t++) | 295 | for(t=0;t<64;t++) |
286 | if(smap[t>>3]&(1<<(t&7))) of.numins=t+1; | 296 | if(smap[t>>3]&(1<<(t&7))) of.numins=t+1; |
287 | of.numsmp = of.numins; | 297 | of.numsmp = of.numins; |
288 | 298 | ||
289 | /* alloc sample structs */ | 299 | /* alloc sample structs */ |
290 | if(!AllocSamples()) return 0; | 300 | if(!AllocSamples()) return 0; |
@@ -314,8 +324,8 @@ static int FAR_Load(int curious) | |||
314 | 324 | ||
315 | q->seekpos = _mm_ftell(modreader); | 325 | q->seekpos = _mm_ftell(modreader); |
316 | _mm_fseek(modreader,q->length,SEEK_CUR); | 326 | _mm_fseek(modreader,q->length,SEEK_CUR); |
317 | } else | 327 | } else |
318 | q->samplename = DupStr(NULL,0,0); | 328 | q->samplename = MikMod_strdup(""); |
319 | q++; | 329 | q++; |
320 | } | 330 | } |
321 | return 1; | 331 | return 1; |
@@ -327,8 +337,8 @@ static CHAR *FAR_LoadTitle(void) | |||
327 | 337 | ||
328 | _mm_fseek(modreader,4,SEEK_SET); | 338 | _mm_fseek(modreader,4,SEEK_SET); |
329 | if(!_mm_read_UBYTES(s,40,modreader)) return NULL; | 339 | if(!_mm_read_UBYTES(s,40,modreader)) return NULL; |
330 | 340 | ||
331 | return(DupStr(s,40,1)); | 341 | return (DupStr(s,40,1)); |
332 | } | 342 | } |
333 | 343 | ||
334 | /*========== Loader information */ | 344 | /*========== Loader information */ |