gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Audio > AAS mod-playing = crash

#37129 - mr_square - Mon Mar 07, 2005 8:43 pm

Arg - I'm having a weird problem where my game randomly crashes after a few minutes of play. The gameplay freezes, the sound screws up (and goes into a high pitched ringing noise) and the % counter on VisualBoyAdvance drops from 100% to about 80%. This happens even if I just leave the game on the menu screen.

If I don't play any mod-files using AAS though, its fine. Removing the last two lines from the code below sorts it out, but then, obviously, I can't have any music running :S. Any ideas on whats going on?

Code:

AAS_SetConfig( AAS_CONFIG_MIX_16KHZ, AAS_CONFIG_CHANS_8, AAS_CONFIG_SPATIAL_MONO, AAS_CONFIG_DYNAMIC_OFF );
AAS_MOD_Play( AAS_DATA_MOD_youandme );
AAS_MOD_SetLoop(true);

#37163 - kashiwa - Tue Mar 08, 2005 11:54 am

Does the stack suffice?
Check your LinkerScript about __sp_usr & __sp_irq, though it might be not the point.

#37345 - jd - Thu Mar 10, 2005 6:43 pm

mr_square wrote:

If I don't play any mod-files using AAS though, its fine. Removing the last two lines from the code below sorts it out, but then, obviously, I can't have any music running :S. Any ideas on whats going on?


There's two possible causes I can think of:

1) You're directly using DMA3 in your code. You'll need to use AAS_DoDMA3 (or a single stmia instruction to write out all the parameters) instead. It might also be worth checking you're not using DMA1, DMA2, Timer 0 or Timer 1 as these are also used by AAS.

2) As kashiwa suggested, you might be running out of IWRAM - AAS takes an extra 3.2K. This might be enough to make your stack collide with your IWRAM data. It's also conceivable that you're running out of EWRAM (AAS takes an extra 3.3K).

#37346 - mr_square - Thu Mar 10, 2005 6:47 pm

Is there any way I can reduce the amount of data stored in IWRAM/EWRAM? Can any of that be put into ROM?

#37351 - jd - Thu Mar 10, 2005 7:35 pm

mr_square wrote:
Is there any way I can reduce the amount of data stored in IWRAM/EWRAM? Can any of that be put into ROM?


You can't reduce the amount of IWRAM/EWRAM used by AAS (I could make you a version that doesn't use IWRAM but it would be much slower). In your own code you should declare anything that doesn't change as const so it's put in ROM. Variables that are only accessed rarely should be put in EWRAM rather than IWRAM. Recursion can also use a lot of stack space if you're not careful. It would be useful to know more details of your project so I can offer more specific suggestions.