2017-02-04 01:44:06 +01:00
|
|
|
#include "global.h"
|
2017-11-13 07:01:27 +01:00
|
|
|
#include "crt0.h"
|
2019-09-09 03:07:54 +02:00
|
|
|
#include "malloc.h"
|
2017-11-09 01:29:37 +01:00
|
|
|
#include "link.h"
|
2017-11-13 07:01:27 +01:00
|
|
|
#include "link_rfu.h"
|
|
|
|
#include "librfu.h"
|
2017-03-05 08:35:03 +01:00
|
|
|
#include "m4a.h"
|
2017-11-13 07:01:27 +01:00
|
|
|
#include "bg.h"
|
2017-03-05 08:35:03 +01:00
|
|
|
#include "rtc.h"
|
2018-02-03 15:42:19 +01:00
|
|
|
#include "scanline_effect.h"
|
2017-11-13 07:01:27 +01:00
|
|
|
#include "overworld.h"
|
|
|
|
#include "play_time.h"
|
2017-12-05 19:27:33 +01:00
|
|
|
#include "random.h"
|
2017-03-05 08:35:03 +01:00
|
|
|
#include "dma3.h"
|
2017-02-04 01:44:06 +01:00
|
|
|
#include "gba/flash_internal.h"
|
2017-11-13 07:01:27 +01:00
|
|
|
#include "load_save.h"
|
|
|
|
#include "gpu_regs.h"
|
|
|
|
#include "agb_flash.h"
|
|
|
|
#include "sound.h"
|
2017-09-05 20:13:34 +02:00
|
|
|
#include "battle.h"
|
2017-11-13 07:01:27 +01:00
|
|
|
#include "battle_controllers.h"
|
|
|
|
#include "text.h"
|
|
|
|
#include "intro.h"
|
|
|
|
#include "main.h"
|
2019-01-13 13:15:23 +01:00
|
|
|
#include "trainer_hill.h"
|
2021-03-01 20:19:41 +01:00
|
|
|
#include "constants/rgb.h"
|
2017-02-04 01:44:06 +01:00
|
|
|
|
|
|
|
static void VBlankIntr(void);
|
|
|
|
static void HBlankIntr(void);
|
|
|
|
static void VCountIntr(void);
|
|
|
|
static void SerialIntr(void);
|
|
|
|
static void IntrDummy(void);
|
|
|
|
|
2018-10-06 07:57:39 +02:00
|
|
|
const u8 gGameVersion = GAME_VERSION;
|
2017-02-04 01:44:06 +01:00
|
|
|
|
|
|
|
const u8 gGameLanguage = GAME_LANGUAGE; // English
|
|
|
|
|
|
|
|
const char BuildDateTime[] = "2005 02 21 11:10";
|
|
|
|
|
|
|
|
const IntrFunc gIntrTableTemplate[] =
|
|
|
|
{
|
|
|
|
VCountIntr, // V-count interrupt
|
|
|
|
SerialIntr, // Serial interrupt
|
|
|
|
Timer3Intr, // Timer 3 interrupt
|
|
|
|
HBlankIntr, // H-blank interrupt
|
|
|
|
VBlankIntr, // V-blank interrupt
|
|
|
|
IntrDummy, // Timer 0 interrupt
|
|
|
|
IntrDummy, // Timer 1 interrupt
|
|
|
|
IntrDummy, // Timer 2 interrupt
|
|
|
|
IntrDummy, // DMA 0 interrupt
|
|
|
|
IntrDummy, // DMA 1 interrupt
|
|
|
|
IntrDummy, // DMA 2 interrupt
|
|
|
|
IntrDummy, // DMA 3 interrupt
|
|
|
|
IntrDummy, // Key interrupt
|
|
|
|
IntrDummy, // Game Pak interrupt
|
|
|
|
};
|
|
|
|
|
|
|
|
#define INTR_COUNT ((int)(sizeof(gIntrTableTemplate)/sizeof(IntrFunc)))
|
|
|
|
|
2017-09-30 15:32:46 +02:00
|
|
|
static u16 gUnknown_03000000;
|
2017-02-04 01:44:06 +01:00
|
|
|
|
2017-11-08 05:53:30 +01:00
|
|
|
u16 gKeyRepeatStartDelay;
|
2017-11-11 06:05:44 +01:00
|
|
|
bool8 gLinkTransferringData;
|
2017-11-08 05:53:30 +01:00
|
|
|
struct Main gMain;
|
|
|
|
u16 gKeyRepeatContinueDelay;
|
|
|
|
bool8 gSoftResetDisabled;
|
|
|
|
IntrFunc gIntrTable[INTR_COUNT];
|
2017-11-11 06:05:44 +01:00
|
|
|
u8 gLinkVSyncDisabled;
|
2017-11-08 05:53:30 +01:00
|
|
|
u32 IntrMain_Buffer[0x200];
|
2018-11-28 17:14:32 +01:00
|
|
|
s8 gPcmDmaCounter;
|
2017-02-04 01:44:06 +01:00
|
|
|
|
2017-11-08 05:53:30 +01:00
|
|
|
static EWRAM_DATA u16 gTrainerId = 0;
|
2017-02-04 01:44:06 +01:00
|
|
|
|
2017-11-08 05:53:30 +01:00
|
|
|
//EWRAM_DATA void (**gFlashTimerIntrFunc)(void) = NULL;
|
2017-02-04 01:44:06 +01:00
|
|
|
|
|
|
|
static void UpdateLinkAndCallCallbacks(void);
|
|
|
|
static void InitMainCallbacks(void);
|
|
|
|
static void CallCallbacks(void);
|
2021-01-11 16:36:53 +01:00
|
|
|
static void SeedRngWithRtc(void);
|
2017-02-04 01:44:06 +01:00
|
|
|
static void ReadKeys(void);
|
2017-02-15 22:25:21 +01:00
|
|
|
void InitIntrHandlers(void);
|
2017-02-04 01:44:06 +01:00
|
|
|
static void WaitForVBlank(void);
|
2017-03-05 08:35:03 +01:00
|
|
|
void EnableVCountIntrAtLine150(void);
|
2017-02-04 01:44:06 +01:00
|
|
|
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
|
|
|
#define B_START_SELECT (B_BUTTON | START_BUTTON | SELECT_BUTTON)
|
|
|
|
|
2017-02-04 01:44:06 +01:00
|
|
|
void AgbMain()
|
|
|
|
{
|
2019-06-26 22:23:00 +02:00
|
|
|
// Modern compilers are liberal with the stack on entry to this function,
|
|
|
|
// so RegisterRamReset may crash if it resets IWRAM.
|
2020-11-06 18:29:40 +01:00
|
|
|
#if !MODERN
|
2019-06-26 22:23:00 +02:00
|
|
|
RegisterRamReset(RESET_ALL);
|
|
|
|
#endif //MODERN
|
2021-03-01 19:23:03 +01:00
|
|
|
*(vu16 *)BG_PLTT = RGB_WHITE; // Set the backdrop to white on startup
|
2017-02-04 01:44:06 +01:00
|
|
|
InitGpuRegManager();
|
|
|
|
REG_WAITCNT = WAITCNT_PREFETCH_ENABLE | WAITCNT_WS0_S_1 | WAITCNT_WS0_N_3;
|
|
|
|
InitKeys();
|
|
|
|
InitIntrHandlers();
|
|
|
|
m4aSoundInit();
|
|
|
|
EnableVCountIntrAtLine150();
|
2020-06-06 22:46:19 +02:00
|
|
|
InitRFU();
|
2017-02-04 01:44:06 +01:00
|
|
|
RtcInit();
|
|
|
|
CheckForFlashMemory();
|
|
|
|
InitMainCallbacks();
|
|
|
|
InitMapMusic();
|
2021-01-11 16:36:53 +01:00
|
|
|
#ifdef BUGFIX
|
|
|
|
SeedRngWithRtc(); // see comment at SeedRngWithRtc definition below
|
|
|
|
#endif
|
2017-02-04 01:44:06 +01:00
|
|
|
ClearDma3Requests();
|
|
|
|
ResetBgs();
|
|
|
|
SetDefaultFontsPointer();
|
2018-01-06 07:35:48 +01:00
|
|
|
InitHeap(gHeap, HEAP_SIZE);
|
2017-02-04 01:44:06 +01:00
|
|
|
|
|
|
|
gSoftResetDisabled = FALSE;
|
|
|
|
|
|
|
|
if (gFlashMemoryPresent != TRUE)
|
|
|
|
SetMainCallback2(NULL);
|
|
|
|
|
2017-11-11 06:05:44 +01:00
|
|
|
gLinkTransferringData = FALSE;
|
2017-02-04 01:44:06 +01:00
|
|
|
gUnknown_03000000 = 0xFC0;
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
ReadKeys();
|
|
|
|
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
|
|
|
if (gSoftResetDisabled == FALSE
|
|
|
|
&& (gMain.heldKeysRaw & A_BUTTON)
|
|
|
|
&& (gMain.heldKeysRaw & B_START_SELECT) == B_START_SELECT)
|
2017-02-04 01:44:06 +01:00
|
|
|
{
|
|
|
|
rfu_REQ_stopMode();
|
|
|
|
rfu_waitREQComplete();
|
|
|
|
DoSoftReset();
|
|
|
|
}
|
|
|
|
|
2021-03-30 00:32:22 +02:00
|
|
|
if (Overworld_SendKeysToLinkIsRunning() == TRUE)
|
2017-02-04 01:44:06 +01:00
|
|
|
{
|
2017-11-11 06:05:44 +01:00
|
|
|
gLinkTransferringData = TRUE;
|
2017-02-04 01:44:06 +01:00
|
|
|
UpdateLinkAndCallCallbacks();
|
2017-11-11 06:05:44 +01:00
|
|
|
gLinkTransferringData = FALSE;
|
2017-02-04 01:44:06 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-11-11 06:05:44 +01:00
|
|
|
gLinkTransferringData = FALSE;
|
2017-02-04 01:44:06 +01:00
|
|
|
UpdateLinkAndCallCallbacks();
|
|
|
|
|
2021-03-30 00:32:22 +02:00
|
|
|
if (Overworld_RecvKeysFromLinkIsRunning() == TRUE)
|
2017-02-04 01:44:06 +01:00
|
|
|
{
|
|
|
|
gMain.newKeys = 0;
|
2017-09-01 19:43:26 +02:00
|
|
|
ClearSpriteCopyRequests();
|
2017-11-11 06:05:44 +01:00
|
|
|
gLinkTransferringData = TRUE;
|
2017-02-04 01:44:06 +01:00
|
|
|
UpdateLinkAndCallCallbacks();
|
2017-11-11 06:05:44 +01:00
|
|
|
gLinkTransferringData = FALSE;
|
2017-02-04 01:44:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PlayTimeCounter_Update();
|
|
|
|
MapMusicMain();
|
|
|
|
WaitForVBlank();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void UpdateLinkAndCallCallbacks(void)
|
|
|
|
{
|
|
|
|
if (!HandleLinkConnection())
|
|
|
|
CallCallbacks();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void InitMainCallbacks(void)
|
|
|
|
{
|
|
|
|
gMain.vblankCounter1 = 0;
|
2019-03-01 07:49:11 +01:00
|
|
|
gTrainerHillVBlankCounter = NULL;
|
2017-02-04 01:44:06 +01:00
|
|
|
gMain.vblankCounter2 = 0;
|
|
|
|
gMain.callback1 = NULL;
|
2018-02-15 23:54:34 +01:00
|
|
|
SetMainCallback2(CB2_InitCopyrightScreenAfterBootup);
|
2017-09-04 18:26:39 +02:00
|
|
|
gSaveBlock2Ptr = &gSaveblock2;
|
2017-09-06 18:39:03 +02:00
|
|
|
gPokemonStoragePtr = &gPokemonStorage;
|
2017-02-04 01:44:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void CallCallbacks(void)
|
|
|
|
{
|
|
|
|
if (gMain.callback1)
|
|
|
|
gMain.callback1();
|
|
|
|
|
|
|
|
if (gMain.callback2)
|
|
|
|
gMain.callback2();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetMainCallback2(MainCallback callback)
|
|
|
|
{
|
|
|
|
gMain.callback2 = callback;
|
|
|
|
gMain.state = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void StartTimer1(void)
|
|
|
|
{
|
|
|
|
REG_TM1CNT_H = 0x80;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SeedRngAndSetTrainerId(void)
|
|
|
|
{
|
|
|
|
u16 val = REG_TM1CNT_L;
|
|
|
|
SeedRng(val);
|
|
|
|
REG_TM1CNT_H = 0;
|
|
|
|
gTrainerId = val;
|
|
|
|
}
|
|
|
|
|
2017-09-03 22:50:17 +02:00
|
|
|
u16 GetGeneratedTrainerIdLower(void)
|
2017-02-04 01:44:06 +01:00
|
|
|
{
|
|
|
|
return gTrainerId;
|
|
|
|
}
|
|
|
|
|
2017-02-15 22:25:21 +01:00
|
|
|
void EnableVCountIntrAtLine150(void)
|
|
|
|
{
|
2017-02-17 19:56:19 +01:00
|
|
|
u16 gpuReg = (GetGpuReg(REG_OFFSET_DISPSTAT) & 0xFF) | (150 << 8);
|
|
|
|
SetGpuReg(REG_OFFSET_DISPSTAT, gpuReg | DISPSTAT_VCOUNT_INTR);
|
|
|
|
EnableInterrupts(INTR_FLAG_VCOUNT);
|
2017-02-15 22:25:21 +01:00
|
|
|
}
|
|
|
|
|
2021-01-11 16:36:53 +01:00
|
|
|
// FRLG commented this out to remove RTC, however Emerald didn't undo this!
|
|
|
|
#ifdef BUGFIX
|
|
|
|
static void SeedRngWithRtc(void)
|
|
|
|
{
|
|
|
|
u32 seed = RtcGetMinuteCount();
|
|
|
|
seed = (seed >> 16) ^ (seed & 0xFFFF);
|
|
|
|
SeedRng(seed);
|
|
|
|
}
|
|
|
|
#endif
|
2020-05-14 22:33:19 +02:00
|
|
|
|
2017-02-04 01:44:06 +01:00
|
|
|
void InitKeys(void)
|
|
|
|
{
|
|
|
|
gKeyRepeatContinueDelay = 5;
|
|
|
|
gKeyRepeatStartDelay = 40;
|
2017-02-17 19:52:03 +01:00
|
|
|
|
2017-02-04 01:44:06 +01:00
|
|
|
gMain.heldKeys = 0;
|
|
|
|
gMain.newKeys = 0;
|
|
|
|
gMain.newAndRepeatedKeys = 0;
|
|
|
|
gMain.heldKeysRaw = 0;
|
|
|
|
gMain.newKeysRaw = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ReadKeys(void)
|
|
|
|
{
|
|
|
|
u16 keyInput = REG_KEYINPUT ^ KEYS_MASK;
|
|
|
|
gMain.newKeysRaw = keyInput & ~gMain.heldKeysRaw;
|
|
|
|
gMain.newKeys = gMain.newKeysRaw;
|
|
|
|
gMain.newAndRepeatedKeys = gMain.newKeysRaw;
|
|
|
|
|
|
|
|
// BUG: Key repeat won't work when pressing L using L=A button mode
|
|
|
|
// because it compares the raw key input with the remapped held keys.
|
|
|
|
// Note that newAndRepeatedKeys is never remapped either.
|
|
|
|
|
|
|
|
if (keyInput != 0 && gMain.heldKeys == keyInput)
|
|
|
|
{
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
|
|
|
gMain.keyRepeatCounter--;
|
|
|
|
|
|
|
|
if (gMain.keyRepeatCounter == 0)
|
2017-02-04 01:44:06 +01:00
|
|
|
{
|
|
|
|
gMain.newAndRepeatedKeys = keyInput;
|
|
|
|
gMain.keyRepeatCounter = gKeyRepeatContinueDelay;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// If there is no input or the input has changed, reset the counter.
|
|
|
|
gMain.keyRepeatCounter = gKeyRepeatStartDelay;
|
|
|
|
}
|
|
|
|
|
|
|
|
gMain.heldKeysRaw = keyInput;
|
|
|
|
gMain.heldKeys = gMain.heldKeysRaw;
|
|
|
|
|
|
|
|
// Remap L to A if the L=A option is enabled.
|
2020-07-14 11:13:03 +02:00
|
|
|
if (gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_L_EQUALS_A)
|
2017-02-04 01:44:06 +01:00
|
|
|
{
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(L_BUTTON))
|
2017-02-04 01:44:06 +01:00
|
|
|
gMain.newKeys |= A_BUTTON;
|
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_HELD(L_BUTTON))
|
2017-02-04 01:44:06 +01:00
|
|
|
gMain.heldKeys |= A_BUTTON;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gMain.newKeys & gMain.watchedKeysMask)
|
|
|
|
gMain.watchedKeysPressed = TRUE;
|
|
|
|
}
|
|
|
|
|
2017-02-15 22:25:21 +01:00
|
|
|
void InitIntrHandlers(void)
|
2017-02-04 01:44:06 +01:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < INTR_COUNT; i++)
|
|
|
|
gIntrTable[i] = gIntrTableTemplate[i];
|
|
|
|
|
|
|
|
DmaCopy32(3, IntrMain, IntrMain_Buffer, sizeof(IntrMain_Buffer));
|
|
|
|
|
|
|
|
INTR_VECTOR = IntrMain_Buffer;
|
|
|
|
|
|
|
|
SetVBlankCallback(NULL);
|
|
|
|
SetHBlankCallback(NULL);
|
|
|
|
SetSerialCallback(NULL);
|
|
|
|
|
|
|
|
REG_IME = 1;
|
2017-02-17 19:52:03 +01:00
|
|
|
|
2021-01-26 03:37:04 +01:00
|
|
|
EnableInterrupts(INTR_FLAG_VBLANK);
|
2017-02-04 01:44:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetVBlankCallback(IntrCallback callback)
|
|
|
|
{
|
|
|
|
gMain.vblankCallback = callback;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetHBlankCallback(IntrCallback callback)
|
|
|
|
{
|
|
|
|
gMain.hblankCallback = callback;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetVCountCallback(IntrCallback callback)
|
|
|
|
{
|
|
|
|
gMain.vcountCallback = callback;
|
|
|
|
}
|
|
|
|
|
2017-02-15 22:25:21 +01:00
|
|
|
void RestoreSerialTimer3IntrHandlers(void)
|
|
|
|
{
|
|
|
|
gIntrTable[1] = SerialIntr;
|
|
|
|
gIntrTable[2] = Timer3Intr;
|
|
|
|
}
|
|
|
|
|
2017-02-04 01:44:06 +01:00
|
|
|
void SetSerialCallback(IntrCallback callback)
|
|
|
|
{
|
|
|
|
gMain.serialCallback = callback;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void VBlankIntr(void)
|
|
|
|
{
|
2017-11-14 14:44:32 +01:00
|
|
|
if (gWirelessCommType != 0)
|
|
|
|
RfuVSync();
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
|
|
|
else if (gLinkVSyncDisabled == FALSE)
|
2017-11-14 14:44:32 +01:00
|
|
|
LinkVSync();
|
2017-02-04 01:44:06 +01:00
|
|
|
|
2017-02-17 19:52:03 +01:00
|
|
|
gMain.vblankCounter1++;
|
|
|
|
|
2019-03-01 07:49:11 +01:00
|
|
|
if (gTrainerHillVBlankCounter && *gTrainerHillVBlankCounter < 0xFFFFFFFF)
|
|
|
|
(*gTrainerHillVBlankCounter)++;
|
2017-02-04 01:44:06 +01:00
|
|
|
|
|
|
|
if (gMain.vblankCallback)
|
|
|
|
gMain.vblankCallback();
|
|
|
|
|
|
|
|
gMain.vblankCounter2++;
|
2017-02-17 19:52:03 +01:00
|
|
|
|
2017-02-15 22:25:21 +01:00
|
|
|
CopyBufferedValuesToGpuRegs();
|
|
|
|
ProcessDma3Requests();
|
2017-02-04 01:44:06 +01:00
|
|
|
|
|
|
|
gPcmDmaCounter = gSoundInfo.pcmDmaCounter;
|
|
|
|
|
|
|
|
m4aSoundMain();
|
2021-01-22 08:48:22 +01:00
|
|
|
TryReceiveLinkBattleData();
|
2017-02-15 22:25:21 +01:00
|
|
|
|
2017-09-05 20:13:34 +02:00
|
|
|
if (!gMain.inBattle || !(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_FRONTIER | BATTLE_TYPE_RECORDED)))
|
2017-02-15 22:25:21 +01:00
|
|
|
Random();
|
2017-02-04 01:44:06 +01:00
|
|
|
|
2020-06-07 23:37:09 +02:00
|
|
|
UpdateWirelessStatusIndicatorSprite();
|
2017-02-15 22:25:21 +01:00
|
|
|
|
2017-02-17 19:52:03 +01:00
|
|
|
INTR_CHECK |= INTR_FLAG_VBLANK;
|
2017-02-04 01:44:06 +01:00
|
|
|
gMain.intrCheck |= INTR_FLAG_VBLANK;
|
|
|
|
}
|
|
|
|
|
2017-09-04 18:26:39 +02:00
|
|
|
void InitFlashTimer(void)
|
2017-02-04 01:44:06 +01:00
|
|
|
{
|
2017-02-15 22:25:21 +01:00
|
|
|
SetFlashTimerIntr(2, gIntrTable + 0x7);
|
2017-02-04 01:44:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void HBlankIntr(void)
|
|
|
|
{
|
|
|
|
if (gMain.hblankCallback)
|
|
|
|
gMain.hblankCallback();
|
|
|
|
|
|
|
|
INTR_CHECK |= INTR_FLAG_HBLANK;
|
|
|
|
gMain.intrCheck |= INTR_FLAG_HBLANK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void VCountIntr(void)
|
|
|
|
{
|
|
|
|
if (gMain.vcountCallback)
|
|
|
|
gMain.vcountCallback();
|
|
|
|
|
2017-02-15 22:25:21 +01:00
|
|
|
m4aSoundVSync();
|
2017-02-17 19:52:03 +01:00
|
|
|
INTR_CHECK |= INTR_FLAG_VCOUNT;
|
2017-02-04 01:44:06 +01:00
|
|
|
gMain.intrCheck |= INTR_FLAG_VCOUNT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SerialIntr(void)
|
|
|
|
{
|
|
|
|
if (gMain.serialCallback)
|
|
|
|
gMain.serialCallback();
|
|
|
|
|
2017-02-17 19:52:03 +01:00
|
|
|
INTR_CHECK |= INTR_FLAG_SERIAL;
|
2017-02-04 01:44:06 +01:00
|
|
|
gMain.intrCheck |= INTR_FLAG_SERIAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void IntrDummy(void)
|
|
|
|
{}
|
|
|
|
|
|
|
|
static void WaitForVBlank(void)
|
|
|
|
{
|
|
|
|
gMain.intrCheck &= ~INTR_FLAG_VBLANK;
|
2017-02-17 19:52:03 +01:00
|
|
|
|
2017-02-17 19:58:42 +01:00
|
|
|
while (!(gMain.intrCheck & INTR_FLAG_VBLANK))
|
2017-02-15 22:25:21 +01:00
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2019-03-01 07:49:11 +01:00
|
|
|
void SetTrainerHillVBlankCounter(u32 *counter)
|
2017-02-15 22:25:21 +01:00
|
|
|
{
|
2019-03-01 07:49:11 +01:00
|
|
|
gTrainerHillVBlankCounter = counter;
|
2017-02-15 22:25:21 +01:00
|
|
|
}
|
|
|
|
|
2019-03-01 07:49:11 +01:00
|
|
|
void ClearTrainerHillVBlankCounter(void)
|
2017-02-15 22:25:21 +01:00
|
|
|
{
|
2019-03-01 07:49:11 +01:00
|
|
|
gTrainerHillVBlankCounter = NULL;
|
2017-02-04 01:44:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void DoSoftReset(void)
|
|
|
|
{
|
|
|
|
REG_IME = 0;
|
|
|
|
m4aSoundVSyncOff();
|
2018-01-16 18:59:06 +01:00
|
|
|
ScanlineEffect_Stop();
|
2017-02-04 01:44:06 +01:00
|
|
|
DmaStop(1);
|
|
|
|
DmaStop(2);
|
|
|
|
DmaStop(3);
|
|
|
|
SiiRtcProtect();
|
|
|
|
SoftReset(RESET_ALL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClearPokemonCrySongs(void)
|
|
|
|
{
|
|
|
|
CpuFill16(0, gPokemonCrySongs, MAX_POKEMON_CRIES * sizeof(struct PokemonCrySong));
|
|
|
|
}
|