Do the syscall in crt0 in UBFIX instead of Main

Harmless in practice but do this before setting up the vector, not after, since it will mess it up.
This commit is contained in:
AZero13
2026-03-22 20:04:36 -04:00
parent 5bbc876c44
commit f4e78fd6b8
2 changed files with 8 additions and 30 deletions

View File

@@ -14,6 +14,10 @@ start_vector:
mov r0, #PSR_SYS_MODE
msr cpsr_cf, r0
ldr sp, sp_usr
.if MODERN
mov r0, #255 @ RESET_ALL
svc #1 << 16
.endif @ MODERN
ldr r1, =INTR_VECTOR
adr r0, intr_main
str r0, [r1]
@@ -98,7 +102,7 @@ jump_intr:
orr r0, r0, #INTR_FLAG_GAMEPAK
orr r1, r0, #INTR_FLAG_SERIAL | INTR_FLAG_TIMER3 | INTR_FLAG_VCOUNT | INTR_FLAG_HBLANK
and r1, r1, r2
strh r1, [r3, #0]
strh r1, [r3]
mrs r3, cpsr
bic r3, r3, #PSR_I_BIT | PSR_F_BIT | PSR_MODE_MASK
orr r3, r3, #PSR_SYS_MODE

View File

@@ -102,37 +102,11 @@ void AgbMain()
#if REVISION >= 0xA
svc_stubbed();
#endif
#if MODERN
// Modern compilers are liberal with the stack on entry to this function,
#if !MODERN
// Some compilers, especially modern ones, are liberal with the stack on entry to this function,
// so RegisterRamReset may crash if it resets IWRAM.
RegisterRamReset(RESET_ALL & ~RESET_IWRAM);
asm("mov\tr1, #0xC0\n"
"\tlsl\tr1, r1, #0x12\n"
"\tmov\tr2, #0xFC\n"
"\tlsl\tr2, r2, #0x7\n"
"\tadd\tr2, r1, r2\n"
"\tmov\tr0, #0\n"
"\tmov\tr3, r0\n"
"\tmov\tr4, r0\n"
"\tmov\tr5, r0\n"
".LCU%=:\n"
"\tstmia\tr1!, {r0, r3, r4, r5}\n"
"\tstmia\tr1!, {r0, r3, r4, r5}\n"
"\tstmia\tr1!, {r0, r3, r4, r5}\n"
"\tstmia\tr1!, {r0, r3, r4, r5}\n"
"\tstmia\tr1!, {r0, r3, r4, r5}\n"
"\tstmia\tr1!, {r0, r3, r4, r5}\n"
"\tstmia\tr1!, {r0, r3, r4, r5}\n"
"\tstmia\tr1!, {r0, r3, r4, r5}\n"
"\tcmp\tr1, r2\n"
"\tbcc\t.LCU%=\n"
:
:
: "r0", "r1", "r2", "r3", "r4", "r5", "memory"
);
#else
RegisterRamReset(RESET_ALL);
#endif //MODERN
#endif // !MODERN
#if REVISION >= 0xA
*(vu16 *)BG_PLTT = RGB_BLACK;