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_dsm.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_dsm.c')
-rw-r--r-- | apps/plugins/mikmod/load_dsm.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/apps/plugins/mikmod/load_dsm.c b/apps/plugins/mikmod/load_dsm.c index 59abf0bcfe..e995f7dfad 100644 --- a/apps/plugins/mikmod/load_dsm.c +++ b/apps/plugins/mikmod/load_dsm.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_dsm.c,v 1.3 2005/04/07 19:57:38 realtech Exp $ | 23 | $Id$ |
24 | 24 | ||
25 | DSIK internal format (DSM) module loader | 25 | DSIK internal format (DSM) module loader |
26 | 26 | ||
@@ -89,9 +89,9 @@ typedef struct DSMNOTE { | |||
89 | 89 | ||
90 | /*========== Loader variables */ | 90 | /*========== Loader variables */ |
91 | 91 | ||
92 | static CHAR* SONGID="SONG"; | 92 | static const CHAR* SONGID="SONG"; |
93 | static CHAR* INSTID="INST"; | 93 | static const CHAR* INSTID="INST"; |
94 | static CHAR* PATTID="PATT"; | 94 | static const CHAR* PATTID="PATT"; |
95 | 95 | ||
96 | static UBYTE blockid[4]; | 96 | static UBYTE blockid[4]; |
97 | static ULONG blockln; | 97 | static ULONG blockln; |
@@ -101,7 +101,7 @@ static DSMNOTE* dsmbuf=NULL; | |||
101 | 101 | ||
102 | static CHAR DSM_Version[]="DSIK DSM-format"; | 102 | static CHAR DSM_Version[]="DSIK DSM-format"; |
103 | 103 | ||
104 | static unsigned char DSMSIG[4+4]={'R','I','F','F','D','S','M','F'}; | 104 | static const unsigned char DSMSIG[4+4]={'R','I','F','F','D','S','M','F'}; |
105 | 105 | ||
106 | /*========== Loader code */ | 106 | /*========== Loader code */ |
107 | 107 | ||
@@ -126,6 +126,8 @@ static void DSM_Cleanup(void) | |||
126 | { | 126 | { |
127 | MikMod_free(dsmbuf); | 127 | MikMod_free(dsmbuf); |
128 | MikMod_free(mh); | 128 | MikMod_free(mh); |
129 | dsmbuf = NULL; | ||
130 | mh = NULL; | ||
129 | } | 131 | } |
130 | 132 | ||
131 | static int GetBlockHeader(void) | 133 | static int GetBlockHeader(void) |
@@ -133,7 +135,7 @@ static int GetBlockHeader(void) | |||
133 | /* make sure we're at the right position for reading the | 135 | /* make sure we're at the right position for reading the |
134 | next riff block, no matter how many bytes read */ | 136 | next riff block, no matter how many bytes read */ |
135 | _mm_fseek(modreader, blocklp+blockln, SEEK_SET); | 137 | _mm_fseek(modreader, blocklp+blockln, SEEK_SET); |
136 | 138 | ||
137 | while(1) { | 139 | while(1) { |
138 | _mm_read_UBYTES(blockid,4,modreader); | 140 | _mm_read_UBYTES(blockid,4,modreader); |
139 | blockln=_mm_read_I_ULONG(modreader); | 141 | blockln=_mm_read_I_ULONG(modreader); |
@@ -237,7 +239,7 @@ static int DSM_Load(int curious) | |||
237 | DSMINST s; | 239 | DSMINST s; |
238 | SAMPLE *q; | 240 | SAMPLE *q; |
239 | int cursmp=0,curpat=0,track=0; | 241 | int cursmp=0,curpat=0,track=0; |
240 | (void)curious; | 242 | (void)curious; |
241 | 243 | ||
242 | blocklp=0; | 244 | blocklp=0; |
243 | blockln=12; | 245 | blockln=12; |
@@ -266,7 +268,7 @@ static int DSM_Load(int curious) | |||
266 | /* set module variables */ | 268 | /* set module variables */ |
267 | of.initspeed=mh->speed; | 269 | of.initspeed=mh->speed; |
268 | of.inittempo=mh->bpm; | 270 | of.inittempo=mh->bpm; |
269 | of.modtype=StrDup(DSM_Version); | 271 | of.modtype=MikMod_strdup(DSM_Version); |
270 | of.numchn=mh->numtrk; | 272 | of.numchn=mh->numtrk; |
271 | of.numpat=mh->numpat; | 273 | of.numpat=mh->numpat; |
272 | of.numtrk=of.numchn*of.numpat; | 274 | of.numtrk=of.numchn*of.numpat; |
@@ -286,6 +288,11 @@ static int DSM_Load(int curious) | |||
286 | for(t=0;t<mh->numord;t++) { | 288 | for(t=0;t<mh->numord;t++) { |
287 | int order=mh->orders[t]; | 289 | int order=mh->orders[t]; |
288 | if(order==255) order=LAST_PATTERN; | 290 | if(order==255) order=LAST_PATTERN; |
291 | else if (of.positions[t]>of.numpat) { /* SANITIY CHECK */ | ||
292 | /* fprintf(stderr,"positions[%d]=%d > numpat=%d\n",t,of.positions[t],of.numpat);*/ | ||
293 | _mm_errno = MMERR_LOADING_HEADER; | ||
294 | return 0; | ||
295 | } | ||
289 | of.positions[of.numpos]=order; | 296 | of.positions[of.numpos]=order; |
290 | if(mh->orders[t]<254) of.numpos++; | 297 | if(mh->orders[t]<254) of.numpos++; |
291 | } | 298 | } |
@@ -344,7 +351,7 @@ static CHAR *DSM_LoadTitle(void) | |||
344 | 351 | ||
345 | _mm_fseek(modreader,12,SEEK_SET); | 352 | _mm_fseek(modreader,12,SEEK_SET); |
346 | if(!_mm_read_UBYTES(s,28,modreader)) return NULL; | 353 | if(!_mm_read_UBYTES(s,28,modreader)) return NULL; |
347 | 354 | ||
348 | return(DupStr(s,28,1)); | 355 | return(DupStr(s,28,1)); |
349 | } | 356 | } |
350 | 357 | ||