Skip to content

Commit

Permalink
mm_loader.c: fix callback loader (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
ds-sloth authored Dec 4, 2024
1 parent 85b9d50 commit f6d627d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions source_calico/mm_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand All @@ -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)
Expand Down Expand Up @@ -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: {
Expand Down

0 comments on commit f6d627d

Please sign in to comment.