From f6d627d8582bec0ff5c618fb2a19ee901f087b93 Mon Sep 17 00:00:00 2001 From: ds-sloth <72112344+ds-sloth@users.noreply.github.com> Date: Wed, 4 Dec 2024 13:40:49 -0500 Subject: [PATCH] mm_loader.c: fix callback loader (#12) --- source_calico/mm_loader.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source_calico/mm_loader.c b/source_calico/mm_loader.c index 2cea0a9..f14d184 100644 --- a/source_calico/mm_loader.c +++ b/source_calico/mm_loader.c @@ -92,7 +92,7 @@ void mmSetCustomSoundBankHandler(mm_callback p_loader) static void _mmLoadSample(mm_word sample_ID) { - mm_word* bank = (mm_word*)s_mmState.mem_bank + s_mmFile.hdr.moduleCount; + mm_word* bank = (mm_word*)s_mmState.mem_bank + s_mmState.mod_count; if (bank[sample_ID] >= MM_SAMP_REF) { bank[sample_ID] += MM_SAMP_REF; // addref @@ -110,7 +110,7 @@ static void _mmLoadSample(mm_word sample_ID) static void _mmUnloadSample(mm_word sample_ID) { - mm_word* bank = (mm_word*)s_mmState.mem_bank + s_mmFile.hdr.moduleCount; + mm_word* bank = (mm_word*)s_mmState.mem_bank + s_mmState.mod_count; mm_word entry = bank[sample_ID]; if (entry < MM_SAMP_REF) { @@ -128,7 +128,7 @@ static void _mmUnloadSample(mm_word sample_ID) static void _mmFlushBank(void) { - armDCacheFlush(s_mmState.mem_bank, sizeof(void*) * (s_mmFile.hdr.moduleCount + s_mmFile.hdr.sampleCount)); + armDCacheFlush(s_mmState.mem_bank, sizeof(void*) * (s_mmState.mod_count + s_mmState.samp_count)); } void mmLoad(mm_word module_ID) @@ -219,7 +219,7 @@ mm_word _mmFileLoadCallback(mm_word msg, mm_word param) return 0; case MMCB_SONGREQUEST: - param += s_mmFile.hdr.sampleCount; + param += s_mmState.samp_count; // fallthrough case MMCB_SAMPREQUEST: {