Clear all arm9 cpu registers before jumping to the arm9 entry point. Fixes Cake Ninja DSiWare titles.

This commit is contained in:
Gericom
2025-11-30 13:00:35 +01:00
parent 4701b9d1b7
commit b2fabe5d97
3 changed files with 36 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
#pragma once
/// @brief Clears all cpu registers and jumps to the specified \p arm9EntryPoint.
/// @param arm9EntryPoint The arm9 entry point to jump to.
extern "C" void jumpToArm9EntryPoint(void* arm9EntryPoint);

View File

@@ -0,0 +1,29 @@
.section ".itcm", "ax"
.arm
// r0: arm9EntryPoint
.global jumpToArm9EntryPoint
.type jumpToArm9EntryPoint, %function
jumpToArm9EntryPoint:
str r0, entry_point
// Clear all registers
mov r0, #0
mov r1, #0
mov r2, #0
mov r3, #0
mov r4, #0
mov r5, #0
mov r6, #0
mov r7, #0
mov r8, #0
mov r9, #0
mov r10, #0
mov r11, #0
mov r12, #0
mov sp, #0
mov lr, #0
// Jump to the arm9 entry point
ldr pc, entry_point
entry_point:
.word 0

View File

@@ -26,6 +26,7 @@
#include "arm9Clock.h"
#include "errorDisplay/ErrorDisplay.h"
#include "LoaderInfo.h"
#include "jumpToArm9EntryPoint.h"
typedef void (*entrypoint_t)(void);
@@ -109,7 +110,7 @@ static void bootArm9()
while (gfx_getVCount() == 191);
REG_IF = ~0u; // final clear of REG_IF bits
auto romHeader = (const nds_header_ntr_t*)TWL_SHARED_MEMORY->ntrSharedMem.romHeader;
((entrypoint_t)romHeader->arm9EntryAddress)();
jumpToArm9EntryPoint((void*)romHeader->arm9EntryAddress);
}
static void handleInitializeSdCardCommand()