Page 1 of 1

maxmod with tonc

Posted: Sat Jan 24, 2009 11:50 pm
by danger
Has anybody had any luck getting maxmod working with tonc instead of libgba? I tried modifying mm_init_default.s to call tonc's irq_set and irq_enable functions instead of libgba's, but that didn't seem to work. Is there more to it than that?

Re: maxmod with tonc

Posted: Mon Jan 26, 2009 1:05 am
by Chano
I have maxmod working with TONC.

The only change I did (in order to get mmutil working) is in tonc_rules file. Replace this:

Code: Select all

define bin2o
	bin2s $< | $(AS) $(ARCH) -o $@
with this:

Code: Select all

define bin2o
	bin2s $< | $(PREFIX)as $(ARCH) -o $@

Re: maxmod with tonc

Posted: Mon Jan 26, 2009 6:05 am
by danger
Right, I had to make a similar change in order to get the soundbank.bin.o file to build correctly. My test application builds successfully, and runs, but at runtime I don't hear any sound.

My suspicion is that I don't have the interrupts set up correctly. Could you post code for your tonc/maxmod initialization, including the relevant interrupt handler setup? As I mentioned in my original post, I had to modify the code to mmInitDefault() to call tonc's IRQ functions instead of libgba's (since linking both -lgb and -ltonc produced a bunch of linker errors). Is that a step in the right direction?

Re: maxmod with tonc

Posted: Mon Jan 26, 2009 8:17 am
by Chano
There's no need to call mmInitDefault, so there's no need to modify anything.

Interrupt code (before maxmod initialization):

Code: Select all

irq_init(NULL);
irq_add(II_VBLANK, mmVBlank);
And maxmod initialization code:

Code: Select all

#define CFG_MAX_CHANNELS    18

static MEM_ALIGNED u8 maxmodMixingBuffer[MM_MIXLEN_16KHZ];
static MEM_EWRAM MEM_ALIGNED u8 maxmodEngineBuffer[CFG_MAX_CHANNELS * (MM_SIZEOF_MODCH + MM_SIZEOF_ACTCH + MM_SIZEOF_MIXCH) + MM_MIXLEN_16KHZ];
static MEM_ALIGNED mm_gba_system maxmodInfo;

void maxmodInit(void)
{
    maxmodInfo.mixing_mode = MM_MIX_16KHZ;
    maxmodInfo.mod_channel_count = CFG_MAX_CHANNELS;
    maxmodInfo.mix_channel_count = CFG_MAX_CHANNELS;
    maxmodInfo.module_channels = (mm_addr)(maxmodEngineBuffer);
    maxmodInfo.active_channels = (mm_addr)(maxmodEngineBuffer + (CFG_MAX_CHANNELS * MM_SIZEOF_MODCH));
    maxmodInfo.mixing_channels = (mm_addr)(maxmodEngineBuffer +
		(CFG_MAX_CHANNELS * (MM_SIZEOF_MODCH + MM_SIZEOF_ACTCH)));
    maxmodInfo.mixing_memory = (mm_addr)maxmodMixingBuffer;
    maxmodInfo.wave_memory = (mm_addr)(maxmodEngineBuffer +
		(CFG_MAX_CHANNELS * (MM_SIZEOF_MODCH + MM_SIZEOF_ACTCH + MM_SIZEOF_MIXCH)));
    maxmodInfo.soundbank = (mm_addr)soundbank_bin;

    mmInit(&maxmodInfo);
}

Re: maxmod with tonc

Posted: Tue Jan 27, 2009 9:31 am
by danger
Yup, that worked like a charm! Thanks for the tip!

(I'm ashamed to admit this, but apparently the .S3M file I hastily grabbed to test with was actually completely silent. I was probably doing everything correct right from the beginning, successfully reproducing no music at all. Let this be a warning!)