diff --git a/src/crt0.s b/src/crt0.s index a0d8a4b55..ce84f2f96 100644 --- a/src/crt0.s +++ b/src/crt0.s @@ -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 diff --git a/src/main.c b/src/main.c index 542b0f5d1..f9444a83b 100644 --- a/src/main.c +++ b/src/main.c @@ -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;