maxmod with tonc

support for the gba/nds sound library from www.maxmod.org

Moderator: eKid

Post Reply
danger
Posts: 3
Joined: Sat Jan 24, 2009 11:47 pm

maxmod with tonc

Post by danger » Sat Jan 24, 2009 11:50 pm

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?

Chano
Posts: 28
Joined: Fri Dec 12, 2008 7:38 pm

Re: maxmod with tonc

Post by Chano » Mon Jan 26, 2009 1:05 am

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 [email protected]
with this:

Code: Select all

define bin2o
	bin2s $< | $(PREFIX)as $(ARCH) -o [email protected]

danger
Posts: 3
Joined: Sat Jan 24, 2009 11:47 pm

Re: maxmod with tonc

Post by danger » Mon Jan 26, 2009 6:05 am

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?

Chano
Posts: 28
Joined: Fri Dec 12, 2008 7:38 pm

Re: maxmod with tonc

Post by Chano » Mon Jan 26, 2009 8:17 am

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);
}

danger
Posts: 3
Joined: Sat Jan 24, 2009 11:47 pm

Re: maxmod with tonc

Post by danger » Tue Jan 27, 2009 9:31 am

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!)

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest