mardi, mars 13, 2012

guruMediationDump()

I love it when my wish have been granted even before I'm aware of the wish. In this case, devkitpro team has revamped the way exceptions are handled in libnds "r32". The large "wizardry" part of the guru mediation screen, that dumps registers and all has been extracted in a guruMeditationDump() library function, and the default handler is a 2-lines function that definitely locks the DS once the dump has occured.

Ah, bin au moins, je ne me fatiguerai pas trop à retrouver comment-j'avais-modifié-guru-meditation-pour-mon-usage-personnel: l'équipe de devkitpro m'a mâché la besogne en plaçant tout ce qui était utile dans une fonction et tout ce que je ne voulais plus (ou presque) dans une autre ^_^. Je vais pouvoir reprendre mes tests sur la school zone très prochainement (dès que je n'ai plus les yeux qui piquent et "OIUY" imprimé sur mon front à la fin de la journée, quoi :P)

Instead, I used in "r21" to define a die() function that allows me to perform recovery such as leaving to moonshell or inspecting memory. So all I should need is to redefine my own 2-lines function and use setExceptionHandler() rather than defaultExceptionHandler(). Let's see whether that helps me figuring out why the school zone is so freaky.


edit: it looks like using scanKeys() in die() is not such a good idea. With the r32, it relies on some working communication between arm7 and arm9, which afaik requires the Fifo (and thus the interrupts) to work. If for some reason the crash comes from an interrupt handler, you'll find yourself unable to see keys changes. Polling the following register could help:


//! Key input register.
/*! On the ARM9, the hinge "button," the touch status, and the
X and Y buttons cannot be accessed directly.
*/
#define REG_KEYINPUT (*(vuint16*)0x04000130)

and checking the value of REG_IE and REG_IF could explain the situation as well.

3 commentaires:

PypeBros a dit…

ok, messing up directly with REG_KEYINPUT was actually not needed. All we need is masking of the keysHeld() bits so that those bits that won't be updated when an IRQ triggered the error aren't checked.

PypeBros a dit…

I can't completely exclude that FIFO content would also prevent the resetARM7() call to have any effect when runNdsFile() is called from die() ...
that's unfortunate.

REG_IPC_FIFO_CR = IPC_FIFO_SEND_CLEAR | IPC_FIFO_RECV_EMPTY | IPC_FIFO_SEND_EMPTY;
REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_RECV_IRQ;
would help ?

Thomas a dit…

Tu n'oublies pas un mode gaucher, parrain ?