From e03efa73ef8cbebdc89e0b39524b635b9c5698b0 Mon Sep 17 00:00:00 2001 From: zeromus Date: Thu, 14 Jan 2010 00:18:32 +0000 Subject: [PATCH] core: set default cpu stacks, necessary for bitbox demo sound --- desmume/src/NDSSystem.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/desmume/src/NDSSystem.cpp b/desmume/src/NDSSystem.cpp index 87c2d241b..ff29b0217 100644 --- a/desmume/src/NDSSystem.cpp +++ b/desmume/src/NDSSystem.cpp @@ -2062,8 +2062,24 @@ void NDS_Reset() armcpu_init(&NDS_ARM7, header->ARM7exe); armcpu_init(&NDS_ARM9, header->ARM9exe); + + //bitbox 4k demo is so stripped down it relies on default stack values + //otherwise the arm7 will crash before making a sound + //(these according to gbatek softreset bios docs) + NDS_ARM7.R13_svc = 0x0380FFDC; + NDS_ARM7.R13_irq = 0x0380FFB0; + NDS_ARM7.R13_usr = 0x0380FF00; + NDS_ARM7.R[13] = NDS_ARM7.R13_usr; + //and let's set these for the arm9 while we're at it, though we have no proof + NDS_ARM9.R13_svc = 0x00803FC0; + NDS_ARM9.R13_irq = 0x00803FA0; + NDS_ARM9.R13_usr = 0x00803EC0; + NDS_ARM9.R[13] = NDS_ARM9.R13_usr; + //n.b.: im not sure about all these, I dont know enough about arm9 svc/irq/etc modes + //and how theyre named in desmume to match them up correctly. i just guessed. } + nds.wifiCycle = 0; memset(nds.timerCycle, 0, sizeof(u64) * 2 * 4); nds.VCount = 0;