mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
FS#13539: Resync mikmod plugin with upstream
Brings it up to libmikmod 3.3.12, relased 2024-12-31 Also fix a segfault that only happened on simulators when using non-default samplerates. Change-Id: I2ade2d72a00edab5395328fe76a88a88516aac72
This commit is contained in:
parent
08c32cee7c
commit
af7ed73f31
29 changed files with 1860 additions and 706 deletions
|
@ -58,8 +58,12 @@ typedef struct MSAMPINFO {
|
|||
|
||||
typedef struct MODULEHEADER {
|
||||
CHAR songname[21];
|
||||
UBYTE initspeed;
|
||||
UBYTE inittempo;
|
||||
UBYTE num_samples;
|
||||
UBYTE num_patterns; /* number of patterns used */
|
||||
UBYTE num_orders;
|
||||
UBYTE reppos;
|
||||
UBYTE positions[256]; /* which pattern to play at pos */
|
||||
MSAMPINFO samples[64]; /* all sampleinfo */
|
||||
} MODULEHEADER;
|
||||
|
@ -177,7 +181,7 @@ static int ConvertNote(MODNOTE *n)
|
|||
|
||||
if (instrument) {
|
||||
/* if instrument does not exist, note cut */
|
||||
if ((instrument > 31) || (!mh->samples[instrument - 1].length)) {
|
||||
if ((instrument > mh->num_samples) || (!mh->samples[instrument - 1].length)) {
|
||||
UniPTEffect(0xc, 0);
|
||||
if (effect == 0xc)
|
||||
effect = effdat = 0;
|
||||
|
@ -194,7 +198,6 @@ static int ConvertNote(MODNOTE *n)
|
|||
* played */
|
||||
if (effect || effdat) {
|
||||
UniInstrument(instrument - 1);
|
||||
note = lastnote;
|
||||
} else
|
||||
UniPTEffect(0xc,
|
||||
mh->samples[instrument -
|
||||
|
@ -294,22 +297,33 @@ static int ASY_Load(int curious)
|
|||
/* no title in asylum amf files :( */
|
||||
mh->songname[0] = '\0';
|
||||
|
||||
_mm_fseek(modreader, 0x23, SEEK_SET);
|
||||
_mm_fseek(modreader, 0x20, SEEK_SET);
|
||||
mh->initspeed = _mm_read_UBYTE(modreader);
|
||||
mh->inittempo = _mm_read_UBYTE(modreader);
|
||||
mh->num_samples = _mm_read_UBYTE(modreader);
|
||||
mh->num_patterns = _mm_read_UBYTE(modreader);
|
||||
mh->num_orders = _mm_read_UBYTE(modreader);
|
||||
mh->reppos = _mm_read_UBYTE(modreader);
|
||||
|
||||
/* skip unknown byte */
|
||||
_mm_skip_BYTE(modreader);
|
||||
_mm_read_UBYTES(mh->positions, 256, modreader);
|
||||
|
||||
#ifdef MIKMOD_DEBUG
|
||||
fprintf(stderr, "ASY: bpm=%d, spd=%d, numins=%d, numpat=%d\n",
|
||||
mh->inittempo, mh->initspeed, mh->num_samples, mh->num_patterns);
|
||||
#endif
|
||||
if (!mh->initspeed || !mh->inittempo || mh->num_samples > 64) {
|
||||
_mm_errno = MMERR_NOT_A_MODULE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* read samples headers*/
|
||||
for (t = 0; t < 64; t++) {
|
||||
for (t = 0; t < mh->num_samples; t++) {
|
||||
s = &mh->samples[t];
|
||||
|
||||
_mm_fseek(modreader, 0x126 + (t*37), SEEK_SET);
|
||||
|
||||
_mm_read_string(s->samplename, 22, modreader);
|
||||
s->samplename[21] = 0; /* just in case */
|
||||
s->samplename[22] = 0;
|
||||
|
||||
s->finetune = _mm_read_UBYTE(modreader);
|
||||
s->volume = _mm_read_UBYTE(modreader);
|
||||
|
@ -324,14 +338,16 @@ static int ASY_Load(int curious)
|
|||
return 0;
|
||||
}
|
||||
|
||||
_mm_fseek(modreader, 37*(64-mh->num_samples), SEEK_CUR);
|
||||
|
||||
/* set module variables */
|
||||
of.initspeed = 6;
|
||||
of.inittempo = 125;
|
||||
of.initspeed = mh->initspeed;
|
||||
of.inittempo = mh->inittempo;
|
||||
of.numchn = 8;
|
||||
modtype = 0;
|
||||
of.songname = DupStr(mh->songname, 21, 1);
|
||||
of.songname = MikMod_strdup("");
|
||||
of.numpos = mh->num_orders;
|
||||
of.reppos = 0;
|
||||
of.reppos = mh->reppos;
|
||||
of.numpat = mh->num_patterns;
|
||||
of.numtrk = of.numpat * of.numchn;
|
||||
|
||||
|
@ -348,8 +364,8 @@ static int ASY_Load(int curious)
|
|||
}
|
||||
|
||||
/* Finally, init the sampleinfo structures */
|
||||
of.numins = 31;
|
||||
of.numsmp = 31;
|
||||
of.numins = mh->num_samples;
|
||||
of.numsmp = mh->num_samples;
|
||||
if (!AllocSamples())
|
||||
return 0;
|
||||
s = mh->samples;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue