Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mm_loader.c: fix callback loader #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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