summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorPikalaxALT <PikalaxALT@users.noreply.github.com>2020-04-12 10:12:37 -0400
committerGitHub <noreply@github.com>2020-04-12 10:12:37 -0400
commit6001e107993d1da69decdf479abf8a661ad57dda (patch)
tree9a430f0b70e0a24965378724f1bd28cd1a193dc1 /src/main.c
parent2880cf2a51ea36fa36f00d9ecf07177e5955c882 (diff)
parent7a562d6bae78fd7c62ed2f804fd8dcc555d85d18 (diff)
Merge pull request #321 from PikalaxALT/modern_gcc
Get pokefirered_modern to build
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c52
1 files changed, 43 insertions, 9 deletions
diff --git a/src/main.c b/src/main.c
index be025c79f..1573a2c5b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -28,11 +28,15 @@ const u8 gGameVersion = GAME_VERSION;
const u8 gGameLanguage = GAME_LANGUAGE;
+#if MODERN
+const char BuildDateTime[] = __DATE__ " " __TIME__;
+#else
#if REVISION == 0
const char BuildDateTime[] = "2004 04 26 11:20";
#else
const char BuildDateTime[] = "2004 07 20 09:30";
-#endif
+#endif //REVISION
+#endif //MODERN
const IntrFunc gIntrTableTemplate[] =
{
@@ -84,7 +88,37 @@ void EnableVCountIntrAtLine150(void);
void AgbMain()
{
+#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);
+ 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
*(vu16 *)BG_PLTT = RGB_WHITE;
InitGpuRegManager();
REG_WAITCNT = WAITCNT_PREFETCH_ENABLE | WAITCNT_WS0_S_1 | WAITCNT_WS0_N_3;
@@ -98,7 +132,7 @@ void AgbMain()
InitMapMusic();
ClearDma3Requests();
ResetBgs();
- InitHeap(gHeap, 0x1C000);
+ InitHeap(gHeap, HEAP_SIZE);
SetDefaultFontsPointer();
gSoftResetDisabled = FALSE;
@@ -128,7 +162,7 @@ void AgbMain()
DoSoftReset();
}
- if (sub_80582E0() == 1)
+ if (Overworld_SendKeysToLinkIsRunning() == TRUE)
{
gLinkTransferringData = TRUE;
UpdateLinkAndCallCallbacks();
@@ -139,7 +173,7 @@ void AgbMain()
gLinkTransferringData = FALSE;
UpdateLinkAndCallCallbacks();
- if (sub_8058274() == 1)
+ if (Overworld_RecvKeysFromLinkIsRunning() == 1)
{
gMain.newKeys = 0;
ClearSpriteCopyRequests();
@@ -259,16 +293,16 @@ static void ReadKeys(void)
gMain.heldKeys = gMain.heldKeysRaw;
// Remap L to A if the L=A option is enabled.
- if (gSaveBlock2Ptr->optionsButtonMode == 2)
+ if (gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_L_EQUALS_A)
{
- if (gMain.newKeys & L_BUTTON)
+ if (JOY_NEW(L_BUTTON))
gMain.newKeys |= A_BUTTON;
- if (gMain.heldKeys & L_BUTTON)
+ if (JOY_HELD(L_BUTTON))
gMain.heldKeys |= A_BUTTON;
}
- if (gMain.newKeys & gMain.watchedKeysMask)
+ if (JOY_NEW(gMain.watchedKeysMask))
gMain.watchedKeysPressed = TRUE;
}
@@ -289,7 +323,7 @@ void InitIntrHandlers(void)
REG_IME = 1;
- EnableInterrupts(0x1);
+ EnableInterrupts(INTR_FLAG_VBLANK);
}
void SetVBlankCallback(IntrCallback callback)