diff --git a/port/include/mixer.h b/port/include/mixer.h index d8cb061f2..85f74faa2 100644 --- a/port/include/mixer.h +++ b/port/include/mixer.h @@ -34,7 +34,7 @@ void aEnvMixerImpl(uint8_t flags, ENVMIX_STATE state, int16_t some_vol); void aSetVolumeImpl(uint8_t flags, int16_t v, int16_t t, int16_t r); void aPoleFilterImpl(uint8_t flags, int16_t gain, uint32_t t, uint32_t addr); void aDisableImpl(uint16_t outp, uint32_t b, uint32_t c); -void aPlayMP3Impl(const void *mp3file, u32 mp3size, void *out); +void aPlayMP3Impl(const void *mp3file, u32 mp3size, void *out, int reset); #define aDisable(pkt, o, b, c) aDisableImpl(o, b, c) #define aClearBuffer(pkt, d, c) aClearBufferImpl(d, c) @@ -50,6 +50,6 @@ void aPlayMP3Impl(const void *mp3file, u32 mp3size, void *out); #define aEnvMixer(pkt, f, t, s) aEnvMixerImpl(f, (void *)(s), t) #define aSetVolume(pkt, f, v, t, r) aSetVolumeImpl(f, v, t, r) #define aPoleFilter(pkt, f, g, t, s) aPoleFilterImpl(f, g, t, s) -#define aPlayMP3(pkt, a, b, c) aPlayMP3Impl((void *)(a), b, (void *)(c)) +#define aPlayMP3(pkt, a, b, c, r) aPlayMP3Impl((void *)(a), b, (void *)(c), r) #endif diff --git a/port/src/mixer.c b/port/src/mixer.c index 9fff8538a..1a42ae2ae 100644 --- a/port/src/mixer.c +++ b/port/src/mixer.c @@ -681,12 +681,12 @@ void aSetVolumeImpl(uint8_t flags, int16_t v, int16_t t, int16_t r) { } } -void aPlayMP3Impl(const void *mp3file, u32 mp3size, void *out) { +void aPlayMP3Impl(const void *mp3file, u32 mp3size, void *out, int reset) { static mp3dec_t mp3d; static const u8 *curdata = NULL; // pointer to the mp3 we're currently processing static s32 dataptr = 0; // byte index into curdata - if (mp3file != curdata) { + if (mp3file != curdata || reset) { // new mp3, reinit decoder mp3dec_init(&mp3d); curdata = mp3file; diff --git a/src/include/types.h b/src/include/types.h index a0749d2cd..193be47f5 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -5695,6 +5695,9 @@ struct mp3vars { /*0x5e*/ s16 var8009c3ee; /*0x60*/ u8 var8009c3f0; /*0x61*/ u8 var8009c3f1; +#ifndef PLATFORM_N64 + /*0x62*/ u8 reset; +#endif }; struct rdptask { diff --git a/src/lib/mp3.c b/src/lib/mp3.c index c91bb51de..270340c1d 100644 --- a/src/lib/mp3.c +++ b/src/lib/mp3.c @@ -31,7 +31,7 @@ #include "mixer.h" -#define acmd07(pkt, a, b, c) aPlayMP3(pkt, a, b, c) +#define acmd07(pkt, a, b, c, r) aPlayMP3(pkt, a, b, c, r) #define acmd08(pkt, a) do { } while(0) #endif @@ -100,6 +100,9 @@ void mp3PlayFile(s32 romaddr, s32 filesize) g_Mp3Vars.var8009c3e8 = 0; g_Mp3Vars.var8009c3e4 = 0x7fff; g_Mp3Vars.var8009c3f0 = 5; +#ifndef PLATFORM_N64 + g_Mp3Vars.reset = 1; +#endif mp3Dma(); @@ -251,7 +254,8 @@ s32 func00037fc0(s32 arg0, Acmd **cmd) acmd07((*cmd)++, g_Mp3Vars.var8009c3d8, osVirtualToPhysical(sp58)); #else // hijack the command to pass the entirety of the mp3 data to the mixer - acmd07((*cmd)++, g_Mp3Vars.romaddr, g_Mp3Vars.filesize, osVirtualToPhysical(sp58)); + acmd07((*cmd)++, g_Mp3Vars.romaddr, g_Mp3Vars.filesize, osVirtualToPhysical(sp58), g_Mp3Vars.reset); + g_Mp3Vars.reset = 0; #endif sp58++;