summaryrefslogtreecommitdiffstats
path: root/apps/plugins/mikmod/load_gdm.c
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2020-08-08 21:56:15 -0400
committerSolomon Peachy <pizza@shaftnet.org>2020-08-11 03:29:12 +0000
commitb4e70422a3455e327433a7471c929ef100ef3b10 (patch)
treee96c5431a1b22af1fcbc628322b79fb8c3162427 /apps/plugins/mikmod/load_gdm.c
parent8c7780bafc9eabac6b92cfe5a5a00831c3d5fd9d (diff)
downloadrockbox-b4e70422a3455e327433a7471c929ef100ef3b10.tar.gz
rockbox-b4e70422a3455e327433a7471c929ef100ef3b10.tar.bz2
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_gdm.c')
-rw-r--r--apps/plugins/mikmod/load_gdm.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/apps/plugins/mikmod/load_gdm.c b/apps/plugins/mikmod/load_gdm.c
index 694d534236..5f06f9c70b 100644
--- a/apps/plugins/mikmod/load_gdm.c
+++ b/apps/plugins/mikmod/load_gdm.c
@@ -20,7 +20,7 @@
/*==============================================================================
- $Id: load_gdm.c,v 1.3 2005/04/07 19:57:38 realtech Exp $
+ $Id$
General DigiMusic (GDM) module loader
@@ -114,7 +114,7 @@ typedef struct GDMSAMPLE {
static GDMHEADER *mh=NULL; /* pointer to GDM header */
static GDMNOTE *gdmbuf=NULL; /* pointer to a complete GDM pattern */
-CHAR GDM_Version[]="General DigiMusic 1.xx";
+static CHAR GDM_Version[]="General DigiMusic 1.xx";
static int GDM_Test(void)
{
@@ -146,36 +146,45 @@ static void GDM_Cleanup(void)
{
MikMod_free(mh);
MikMod_free(gdmbuf);
+ mh=NULL;
+ gdmbuf=NULL;
}
static int GDM_ReadPattern(void)
{
- int pos,flag,ch,i,maxch;
+ int pos,flag,ch,i;
GDMNOTE n;
- UWORD length,x=0;
+ SLONG length,x=0;
/* get pattern length */
- length=_mm_read_I_UWORD(modreader)-2;
+ length=(SLONG)_mm_read_I_UWORD(modreader);
+ length-=2;
/* clear pattern data */
memset(gdmbuf,255,32*64*sizeof(GDMNOTE));
pos=0;
- maxch=0;
while (x<length) {
memset(&n,255,sizeof(GDMNOTE));
flag=_mm_read_UBYTE(modreader);
x++;
- if (_mm_eof(modreader)) {
- _mm_errno=MMERR_LOADING_PATTERN;
+ if (_mm_eof(modreader))
return 0;
- }
ch=flag&31;
- if (ch>maxch) maxch=ch;
+ if (ch > of.numchn)
+ return 0;
+
if (!flag) {
pos++;
+ if (x==length) {
+ if (pos > 64)
+ return 0;
+ } else {
+ if (pos >= 64)
+ return 0;
+ }
continue;
}
if (flag&0x60) {
@@ -343,7 +352,7 @@ static int GDM_Load(int curious)
SAMPLE *q;
GDMSAMPLE s;
ULONG position;
- (void)curious;
+ (void)curious;
/* read header */
_mm_read_string(mh->id1,4,modreader);
@@ -390,7 +399,7 @@ static int GDM_Load(int curious)
}
/* now we fill */
- of.modtype=StrDup(GDM_Version);
+ of.modtype=MikMod_strdup(GDM_Version);
of.modtype[18]=mh->majorver+'0';
of.modtype[20]=mh->minorver/10+'0';
of.modtype[21]=mh->minorver%10+'0';