diff options
author | PokeCodec <67983839+PokeCodec@users.noreply.github.com> | 2020-09-04 10:18:32 -0400 |
---|---|---|
committer | PokeCodec <67983839+PokeCodec@users.noreply.github.com> | 2020-09-04 20:21:07 -0400 |
commit | 99448002e1e393e347b19e4d519f658d13438e3f (patch) | |
tree | 8f1d70b2199e498f7e1b60dcf7dbf4dbcb5be449 | |
parent | 3d87a88067c36e1296612bfaf3dc741884bc9bd4 (diff) |
Refactor InitStateHandlers so each key in the reset combo is checked
-rw-r--r-- | src/link_rfu_2.c | 3 | ||||
-rw-r--r-- | src/link_rfu_3.c | 14 | ||||
-rw-r--r-- | src/main.c | 14 |
3 files changed, 12 insertions, 19 deletions
diff --git a/src/link_rfu_2.c b/src/link_rfu_2.c index 1ea6f4fce..41b28ec5f 100644 --- a/src/link_rfu_2.c +++ b/src/link_rfu_2.c @@ -2044,8 +2044,7 @@ void sub_80110B8(u32 a0) if ((r8 >> i) & 1) { child_sprite_genders |= ((0x80 | ((gLinkPlayers[Rfu.linkPlayerIdx[i]].gender & 1) << 3) | (gLinkPlayers[Rfu.linkPlayerIdx[i]].trainerId & 7)) << (numConnectedChildren << 3)); - numConnectedChildren++; - if (numConnectedChildren == a0 - 1) + if (++numConnectedChildren == a0 - 1) break; } } diff --git a/src/link_rfu_3.c b/src/link_rfu_3.c index c4c000a6e..821b2d118 100644 --- a/src/link_rfu_3.c +++ b/src/link_rfu_3.c @@ -309,8 +309,7 @@ static const struct SpriteTemplate sWirelessStatusIndicatorSpriteTemplate = { void RfuRecvQueue_Reset(struct RfuRecvQueue *queue) { - s32 i; - s32 j; + s32 i, j; for (i = 0; i < RECV_QUEUE_NUM_SLOTS; i++) { @@ -327,8 +326,7 @@ void RfuRecvQueue_Reset(struct RfuRecvQueue *queue) void RfuSendQueue_Reset(struct RfuSendQueue *queue) { - s32 i; - s32 j; + s32 i, j; for (i = 0; i < SEND_QUEUE_NUM_SLOTS; i++) { @@ -345,8 +343,7 @@ void RfuSendQueue_Reset(struct RfuSendQueue *queue) static void RfuUnusedQueue_Reset(struct RfuUnusedQueue *queue) { - s32 i; - s32 j; + s32 i, j; for (i = 0; i < UNUSED_QUEUE_NUM_SLOTS; i++) { @@ -631,7 +628,7 @@ static u8 GetConnectedChildStrength(u8 maxFlags) if (gRfuLinkStatus->parentChild == MODE_PARENT) { - for (i = 0; i < 4; i++) + for (i = 0; i < RFU_CHILD_MAX; i++) { if (flags & 1) { @@ -925,8 +922,7 @@ void RecordMixTrainerNames(void) { if (gWirelessCommType != 0) { - s32 i; - s32 j; + s32 i, j; s32 nextSpace; s32 connectedTrainerRecordIndices[5]; struct TrainerNameRecord *newRecords = calloc(ARRAY_COUNT(gSaveBlock1Ptr->trainerNameRecords), sizeof(struct TrainerNameRecord)); diff --git a/src/main.c b/src/main.c index 454fefc5c..4e52216a4 100644 --- a/src/main.c +++ b/src/main.c @@ -81,8 +81,6 @@ void InitIntrHandlers(void); static void WaitForVBlank(void); void EnableVCountIntrAtLine150(void); -#define B_START_SELECT (B_BUTTON | START_BUTTON | SELECT_BUTTON) - void AgbMain() { #if MODERN @@ -136,9 +134,11 @@ void AgbMain() { ReadKeys(); - if (gSoftResetDisabled == FALSE + if (!gSoftResetDisabled && (gMain.heldKeysRaw & A_BUTTON) - && (gMain.heldKeysRaw & B_START_SELECT) == B_START_SELECT) + && (gMain.heldKeysRaw & B_BUTTON) + && (gMain.heldKeysRaw & START_BUTTON) + && (gMain.heldKeysRaw & SELECT_BUTTON)) //The reset key combo A + B + START + SELECT { rfu_REQ_stopMode(); rfu_waitREQComplete(); @@ -262,9 +262,7 @@ static void ReadKeys(void) if (keyInput != 0 && gMain.heldKeys == keyInput) { - gMain.keyRepeatCounter--; - - if (gMain.keyRepeatCounter == 0) + if (--gMain.keyRepeatCounter == 0) { gMain.newAndRepeatedKeys = keyInput; gMain.keyRepeatCounter = gKeyRepeatContinueDelay; @@ -343,7 +341,7 @@ static void VBlankIntr(void) { if (gWirelessCommType != 0) RfuVSync(); - else if (gLinkVSyncDisabled == FALSE) + else if (!gLinkVSyncDisabled) LinkVSync(); gMain.vblankCounter1++; |