From fb06e4a3c94ae17b73df6d3aecf2d18213aa183e Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 26 Jun 2019 08:13:38 -0400 Subject: Modernize code Can compile with arm-none-eabi-gcc 8.3.0 gbafix correctly handles ELF input --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 40381bb68..d0c9ff7b4 100644 --- a/src/main.c +++ b/src/main.c @@ -85,7 +85,7 @@ void EnableVCountIntrAtLine150(void); void AgbMain() { - RegisterRamReset(RESET_ALL); + RegisterRamReset(MODERN ? RESET_ALL & ~RESET_IWRAM : RESET_ALL); *(vu16 *)BG_PLTT = 0x7FFF; InitGpuRegManager(); REG_WAITCNT = WAITCNT_PREFETCH_ENABLE | WAITCNT_WS0_S_1 | WAITCNT_WS0_N_3; -- cgit v1.2.3 From b839c213073f99d73d03bb28f0fd350e13afba09 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 26 Jun 2019 16:23:00 -0400 Subject: Fix/suppress warnings when building with gcc-8 --- src/main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index d0c9ff7b4..47a957ce0 100644 --- a/src/main.c +++ b/src/main.c @@ -85,7 +85,14 @@ void EnableVCountIntrAtLine150(void); void AgbMain() { - RegisterRamReset(MODERN ? RESET_ALL & ~RESET_IWRAM : RESET_ALL); +#if MODERN + // Modern compilers are liberal with the stack on entry to this function, + // so RegisterRamReset may crash if it resets IWRAM. + RegisterRamReset(RESET_ALL & ~RESET_IWRAM); + DmaFill32(3, 0, IWRAM_START, 0x7E00); +#else + RegisterRamReset(RESET_ALL); +#endif //MODERN *(vu16 *)BG_PLTT = 0x7FFF; InitGpuRegManager(); REG_WAITCNT = WAITCNT_PREFETCH_ENABLE | WAITCNT_WS0_S_1 | WAITCNT_WS0_N_3; -- cgit v1.2.3 From 7fd327d63279bb01492da57be6d6091be435d19c Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 7 Jul 2019 21:07:30 -0400 Subject: Stack-free IWRAM clear --- src/main.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 47a957ce0..06425e661 100644 --- a/src/main.c +++ b/src/main.c @@ -89,7 +89,20 @@ void AgbMain() // Modern compilers are liberal with the stack on entry to this function, // so RegisterRamReset may crash if it resets IWRAM. RegisterRamReset(RESET_ALL & ~RESET_IWRAM); - DmaFill32(3, 0, IWRAM_START, 0x7E00); + asm("mov\tr1, #0xC0\n" + "\tlsl\tr1, r1, #0x12\n" + "\tmov r2, #0xFC\n" + "\tlsl r2, r2, #0x7\n" + "\tadd\tr2, r1, r2\n" + "\tmov\tr0, #0\n" + "\tmov\tr3, r0\n" + "\tmov\tr4, r0\n" + "\tmov\tr5, r0\n" + ".LCU0:\n" + "\tstmia r1!, {r0, r3, r4, r5}\n" + "\tcmp\tr1, r2\n" + "\tbcc\t.LCU0\n" + ); #else RegisterRamReset(RESET_ALL); #endif //MODERN -- cgit v1.2.3