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 > sound interrupts messing with OAM

#168265 - moonlightcheese - Fri Apr 17, 2009 3:55 pm

so after calling the kragInit function, my OAM entries get all screwed up. i can't see what kragInit actually does since it's compiled into that library archive (can i?). i remember reading something about not being able to update OAM during VDraw but i don't know if that's related... i'm... once again... lost.

EDIT: i don't know if this has anything to do with interrupts or not since, when i don't call kragInit, the sprites work fine (just slower) and they animate properly after the calls to irqInit, irqSet (for both the TIMER1 and VBLANK interrupts) and work fine with VBlankIntrWait() in the main loop, with the kramWorker() function in Vblank()... i could be wrong...

#168266 - moonlightcheese - Fri Apr 17, 2009 4:06 pm

wow... that was the quickest fix ever...

what was going on was, i had a define in a header file thusly:
Code:

#define SPRITE_OAM ((OBJATTR*)EWRAM

and i'm guessing that this places a pointer to OBJATTR right at the beginning of EWRAM and the kragInit call needs this space for buffering or something possibly. after i got rid of the define and just declared it inside the header file without the preprocessor directive like this:
Code:

OBJATTR SPRITE_OAM[128];

it compiled and ran perfectly.

#168267 - Miked0801 - Fri Apr 17, 2009 4:23 pm

Which means other stuff is now being eaten by Krawall. Make sure that the space is truly reserved...

#168289 - Ruben - Sun Apr 19, 2009 3:33 pm

And btw, any global variables declared with no section usually go in IWRAM, so you may have to explicitly tell it to be placed in EWRAM

#168291 - moonlightcheese - Sun Apr 19, 2009 6:46 pm

Ruben wrote:
And btw, any global variables declared with no section usually go in IWRAM, so you may have to explicitly tell it to be placed in EWRAM

"no section"?

#168292 - Ruben - Sun Apr 19, 2009 7:00 pm

As in, when you don't explicitly define a section or "const"

Example

Code:
const u32 MyConstVar; //Goes into ROM
u32 MyVar0; //Goes into BSS by default
u32 MyVar1 = 0x12345678; //Goes into IWRAM by default
IN_EWRAM MyVar2 = 4; //Goes into EWRAM
IN_SBSS MyVar3; //Goes into SBSS
IN_IWRAM MyVar4 = 0xC0DE; //Goes into IWRAM
IN_BSS MyVar5; //Goes into BSS

#168300 - gauauu - Sun Apr 19, 2009 9:46 pm

Miked0801 wrote:
Which means other stuff is now being eaten by Krawall. Make sure that the space is truly reserved...


Well, the fact that the first try was just a define, which didn't reserve anything, makes it rather different from the 2nd, which actually allocated a variable array....