summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPikalaxALT <PikalaxALT@users.noreply.github.com>2020-09-05 10:25:10 -0400
committerGitHub <noreply@github.com>2020-09-05 10:25:10 -0400
commit16ecbc6446f4e8d308e71aa5e649c69acb8a6b3e (patch)
tree309ee7f0dd15192ad2ead860c8a6e2cabe5b9214 /src
parentbb98e346e537ffa71a529db71688975b9a850cfa (diff)
parent3e25d9e5a2e0346a53b1bfdf9e14f98e14cceb21 (diff)
Merge pull request #1177 from PokeCodec/MatchEmerald
Match All but 2 remaining naked functions
Diffstat (limited to 'src')
-rw-r--r--src/apprentice.c4
-rwxr-xr-xsrc/battle_anim_effects_3.c59
-rw-r--r--src/battle_anim_flying.c56
-rw-r--r--src/battle_bg.c2
-rw-r--r--src/battle_controller_player.c74
-rw-r--r--src/battle_controller_safari.c10
-rw-r--r--src/battle_dome.c301
-rw-r--r--src/battle_factory_screen.c54
-rw-r--r--src/battle_gfx_sfx_util.c2
-rw-r--r--src/battle_main.c10
-rw-r--r--src/battle_pyramid.c13
-rw-r--r--src/battle_pyramid_bag.c26
-rw-r--r--src/battle_records.c2
-rw-r--r--src/battle_script_commands.c32
-rw-r--r--src/battle_tv.c347
-rwxr-xr-xsrc/berry_crush.c8
-rw-r--r--src/berry_fix_program.c8
-rw-r--r--src/berry_tag_screen.c4
-rw-r--r--src/cable_club.c10
-rw-r--r--src/contest.c12
-rw-r--r--src/contest_painting.c2
-rw-r--r--src/contest_util.c367
-rw-r--r--src/credits.c2
-rw-r--r--src/daycare.c4
-rw-r--r--src/decoration.c27
-rw-r--r--src/diploma.c2
-rw-r--r--src/dodrio_berry_picking.c20
-rw-r--r--src/easy_chat.c64
-rwxr-xr-xsrc/ereader_screen.c10
-rw-r--r--src/evolution_scene.c8
-rw-r--r--src/field_player_avatar.c4
-rw-r--r--src/field_special_scene.c2
-rw-r--r--src/frontier_pass.c18
-rw-r--r--src/frontier_util.c245
-rw-r--r--src/hall_of_fame.c12
-rw-r--r--src/intro_credits_graphics.c4
-rwxr-xr-xsrc/item_menu.c42
-rwxr-xr-xsrc/item_use.c4
-rw-r--r--src/link.c16
-rw-r--r--src/link_rfu_2.c3
-rw-r--r--src/link_rfu_3.c14
-rw-r--r--src/list_menu.c20
-rw-r--r--src/mail.c2
-rw-r--r--src/main.c20
-rw-r--r--src/main_menu.c16
-rw-r--r--src/match_call.c6
-rw-r--r--src/menu.c80
-rw-r--r--src/menu_helpers.c16
-rw-r--r--src/mirage_tower.c150
-rw-r--r--src/mon_markings.c8
-rw-r--r--src/move_relearner.c4
-rw-r--r--src/mystery_event_menu.c10
-rw-r--r--src/mystery_gift.c10
-rw-r--r--src/option_menu.c26
-rw-r--r--src/overworld.c17
-rwxr-xr-xsrc/party_menu.c18
-rw-r--r--src/player_pc.c14
-rw-r--r--src/pokeblock.c8
-rw-r--r--src/pokedex.c185
-rwxr-xr-xsrc/pokedex_area_screen.c4
-rwxr-xr-xsrc/pokemon_jump.c6
-rw-r--r--src/pokemon_storage_system.c163
-rw-r--r--src/pokemon_summary_screen.c50
-rw-r--r--src/pokenav_conditions_1.c8
-rw-r--r--src/pokenav_conditions_3.c15
-rw-r--r--src/pokenav_main_menu.c183
-rwxr-xr-xsrc/pokenav_match_call_1.c28
-rwxr-xr-xsrc/pokenav_match_call_2.c2
-rw-r--r--src/pokenav_menu_handler_1.c26
-rwxr-xr-xsrc/pokenav_region_map.c2
-rw-r--r--src/pokenav_ribbons_1.c12
-rw-r--r--src/pokenav_ribbons_2.c18
-rw-r--r--src/region_map.c24
-rw-r--r--src/reset_rtc_screen.c16
-rw-r--r--src/save.c8
-rw-r--r--src/save_failed_screen.c4
-rw-r--r--src/scrcmd.c4
-rw-r--r--src/script_menu.c2
-rwxr-xr-xsrc/shop.c8
-rw-r--r--src/slot_machine.c83
-rw-r--r--src/start_menu.c14
-rw-r--r--src/title_screen.c8
-rw-r--r--src/trade.c20
-rwxr-xr-xsrc/trainer_card.c8
-rw-r--r--src/union_room.c22
-rwxr-xr-xsrc/union_room_chat.c24
-rw-r--r--src/unk_text_util_2.c10
-rw-r--r--src/walda_phrase.c4
-rw-r--r--src/wallclock.c8
89 files changed, 970 insertions, 2328 deletions
diff --git a/src/apprentice.c b/src/apprentice.c
index 7f493a136..3dc33cad4 100644
--- a/src/apprentice.c
+++ b/src/apprentice.c
@@ -1297,13 +1297,13 @@ const u8 *GetApprenticeNameInLanguage(u32 apprenticeId, s32 language)
// Functionally unused
static void Task_SwitchToFollowupFuncAfterButtonPress(u8 taskId)
{
- if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON))
SwitchTaskToFollowupFunc(taskId);
}
static void Task_ExecuteFuncAfterButtonPress(u8 taskId)
{
- if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON))
{
gApprenticeFunc = (void*)(u32)(((u16)gTasks[taskId].data[0] | (gTasks[taskId].data[1] << 16)));
gApprenticeFunc();
diff --git a/src/battle_anim_effects_3.c b/src/battle_anim_effects_3.c
index bad46f144..58d335197 100755
--- a/src/battle_anim_effects_3.c
+++ b/src/battle_anim_effects_3.c
@@ -5003,11 +5003,11 @@ void AnimTask_GetReturnPowerLevel(u8 taskId)
void AnimTask_SnatchOpposingMonMove(u8 taskId)
{
u8 spriteId, spriteId2;
- int personality;
- int otId;
+ u32 personality;
+ u32 otId;
u16 species;
u8 subpriority;
- u8 isBackPic;
+ bool8 isBackPic;
s16 x;
switch (gTasks[taskId].data[0])
@@ -5035,37 +5035,34 @@ void AnimTask_SnatchOpposingMonMove(u8 taskId)
otId = gContestResources->moveAnim->otId;
species = gContestResources->moveAnim->species;
subpriority = GetBattlerSpriteSubpriority(gBattleAnimAttacker);
- isBackPic = 0;
+ isBackPic = FALSE;
x = -32;
}
- else
+ else if (GetBattlerSide(gBattleAnimAttacker) == B_SIDE_PLAYER)
{
- if (GetBattlerSide(gBattleAnimAttacker) == B_SIDE_PLAYER)
- {
- personality = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_PERSONALITY);
- otId = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_OT_ID);
- if (gBattleSpritesDataPtr->battlerData[gBattleAnimAttacker].transformSpecies == SPECIES_NONE)
- species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_SPECIES);
- else
- species = gBattleSpritesDataPtr->battlerData[gBattleAnimAttacker].transformSpecies;
+ personality = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_PERSONALITY);
+ otId = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_OT_ID);
+ if (gBattleSpritesDataPtr->battlerData[gBattleAnimAttacker].transformSpecies == SPECIES_NONE)
+ species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_SPECIES);
+ else
+ species = gBattleSpritesDataPtr->battlerData[gBattleAnimAttacker].transformSpecies;
- subpriority = gSprites[GetAnimBattlerSpriteId(ANIM_TARGET)].subpriority + 1;
- isBackPic = 0;
- x = 272;
- }
+ subpriority = gSprites[GetAnimBattlerSpriteId(ANIM_TARGET)].subpriority + 1;
+ isBackPic = FALSE;
+ x = 272;
+ }
+ else
+ {
+ personality = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_PERSONALITY);
+ otId = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_OT_ID);
+ if (gBattleSpritesDataPtr->battlerData[gBattleAnimAttacker].transformSpecies == SPECIES_NONE)
+ species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_SPECIES);
else
- {
- personality = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_PERSONALITY);
- otId = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_OT_ID);
- if (gBattleSpritesDataPtr->battlerData[gBattleAnimAttacker].transformSpecies == SPECIES_NONE)
- species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_SPECIES);
- else
- species = gBattleSpritesDataPtr->battlerData[gBattleAnimAttacker].transformSpecies;
+ species = gBattleSpritesDataPtr->battlerData[gBattleAnimAttacker].transformSpecies;
- subpriority = gSprites[GetAnimBattlerSpriteId(ANIM_TARGET)].subpriority - 1;
- isBackPic = 1;
- x = -32;
- }
+ subpriority = gSprites[GetAnimBattlerSpriteId(ANIM_TARGET)].subpriority - 1;
+ isBackPic = TRUE;
+ x = -32;
}
spriteId2 = sub_80A8394(species, isBackPic, 0, x, GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y), subpriority, personality, otId, gBattleAnimAttacker, 0);
@@ -5092,7 +5089,7 @@ void AnimTask_SnatchOpposingMonMove(u8 taskId)
if (x < GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X))
{
gTasks[taskId].data[14]++;
- gBattleAnimArgs[7] = 0xFFFF;
+ gBattleAnimArgs[7] = -1;
}
}
else
@@ -5100,7 +5097,7 @@ void AnimTask_SnatchOpposingMonMove(u8 taskId)
if (x > GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X))
{
gTasks[taskId].data[14]++;
- gBattleAnimArgs[7] = 0xFFFF;
+ gBattleAnimArgs[7] = -1;
}
}
}
@@ -5138,7 +5135,7 @@ void AnimTask_SnatchOpposingMonMove(u8 taskId)
gSprites[spriteId].pos2.x = 0;
}
- gTasks[taskId].data[1] = (u8)gTasks[taskId].data[1];
+ gTasks[taskId].data[1] &= 0xFF;
if (gSprites[spriteId].pos2.x == 0)
DestroyAnimVisualTask(taskId);
break;
diff --git a/src/battle_anim_flying.c b/src/battle_anim_flying.c
index 3fc4f20f2..fe94dc9a2 100644
--- a/src/battle_anim_flying.c
+++ b/src/battle_anim_flying.c
@@ -563,14 +563,23 @@ struct FeatherDanceData
u16 unkE_1:15;
};
+#define ANIM_SWITCH(sprite) \
+ { \
+ (sprite)->hFlip ^= 1; \
+ (sprite)->animNum = (sprite)->hFlip; \
+ (sprite)->animBeginning = TRUE; \
+ (sprite)->animEnded = FALSE; \
+ }
+
static void AnimFallingFeather(struct Sprite *sprite)
{
- u8 battler, matrixNum, sinIndex;
+ u8 battler, sinIndex;
+ u32 matrixNum;
s16 sinVal;
struct FeatherDanceData *data = (struct FeatherDanceData *)sprite->data;
- battler = (gBattleAnimArgs[7] & 0x100) ? gBattleAnimAttacker : gBattleAnimTarget;
+ battler = (gBattleAnimArgs[7] & 0x100) ? gBattleAnimAttacker : gBattleAnimTarget;
if (GetBattlerSide(battler) == B_SIDE_PLAYER)
gBattleAnimArgs[0] = -gBattleAnimArgs[0];
@@ -583,12 +592,12 @@ static void AnimFallingFeather(struct Sprite *sprite)
data->unkE_1 = (u16)(sinVal + gBattleAnimArgs[6]);
data->unk0_0c = 1;
data->unk2 = (u16)(gBattleAnimArgs[2] & 0xFF);
- data->unkA = (u16)((gBattleAnimArgs[2] >> 8) & 0xFF) ;
+ data->unkA = (u16)gBattleAnimArgs[2] >> 8;
data->unk4 = gBattleAnimArgs[3];
data->unk6 = (u16)gBattleAnimArgs[4];
- *(u16*)(data->unkC) = (u16)gBattleAnimArgs[5];
+ *(u16 *)(data->unkC) = (u16)gBattleAnimArgs[5];
- if (data->unk2 >= 64 && data->unk2 <= 191)
+ if (data->unk2 >= 64 && data->unk2 < 192)
{
if (!IsContest())
sprite->oam.priority = GetBattlerSpriteBGPriority(battler) + 1;
@@ -599,11 +608,7 @@ static void AnimFallingFeather(struct Sprite *sprite)
if (!(data->unk4 & 0x8000))
{
- sprite->hFlip ^= 1;
- sprite->animNum = sprite->hFlip;
-
- sprite->animBeginning = 1;
- sprite->animEnded = 0;
+ ANIM_SWITCH(sprite);
}
}
else
@@ -613,15 +618,11 @@ static void AnimFallingFeather(struct Sprite *sprite)
if (data->unk4 & 0x8000)
{
- sprite->hFlip ^= 1;
- sprite->animNum = sprite->hFlip;
-
- sprite->animBeginning = 1;
- sprite->animEnded = 0;
+ ANIM_SWITCH(sprite);
}
}
- data->unk0_1 = data->unk2/64;
+ data->unk0_1 = data->unk2 / 64;
sprite->pos2.x = (gSineTable[data->unk2] * (s32)data->unkC[0]) >> 8;
matrixNum = sprite->oam.matrixNum;
@@ -637,7 +638,8 @@ static void AnimFallingFeather(struct Sprite *sprite)
static void sub_810E520(struct Sprite *sprite)
{
- u8 matrixNum, sinIndex;
+ u8 sinIndex;
+ u32 matrixNum;
s16 sinVal = 0;
struct FeatherDanceData *data = (struct FeatherDanceData *)sprite->data;
if (data->unk0_0a)
@@ -667,10 +669,7 @@ static void sub_810E520(struct Sprite *sprite)
}
else if (data->unk0_0d)
{
- sprite->hFlip ^= 1;
- sprite->animNum = sprite->hFlip;
- sprite->animBeginning = TRUE;
- sprite->animEnded = FALSE;
+ ANIM_SWITCH(sprite);
if (data->unk0_0c)
{
if (!IsContest())
@@ -718,10 +717,7 @@ static void sub_810E520(struct Sprite *sprite)
}
else if (data->unk0_0d)
{
- sprite->hFlip ^= 1;
- sprite->animNum = sprite->hFlip;
- sprite->animBeginning = TRUE;
- sprite->animEnded = FALSE;
+ ANIM_SWITCH(sprite);
if (data->unk0_0c)
{
if (!IsContest())
@@ -769,10 +765,7 @@ static void sub_810E520(struct Sprite *sprite)
}
else if (data->unk0_0d)
{
- sprite->hFlip ^= 1;
- sprite->animNum = sprite->hFlip;
- sprite->animBeginning = TRUE;
- sprite->animEnded = FALSE;
+ ANIM_SWITCH(sprite);
if (data->unk0_0c)
{
if (!IsContest())
@@ -819,10 +812,7 @@ static void sub_810E520(struct Sprite *sprite)
}
else if (data->unk0_0d)
{
- sprite->hFlip ^= 1;
- sprite->animNum = sprite->hFlip;
- sprite->animBeginning = TRUE;
- sprite->animEnded = FALSE;
+ ANIM_SWITCH(sprite);
if (data->unk0_0c)
{
if (!IsContest())
diff --git a/src/battle_bg.c b/src/battle_bg.c
index 7c9b05b25..6a0e4c10c 100644
--- a/src/battle_bg.c
+++ b/src/battle_bg.c
@@ -1126,7 +1126,7 @@ void DrawBattleEntryBackground(void)
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
{
LZDecompressVram(gUnknown_08D778F0, (void*)(BG_CHAR_ADDR(1)));
- LZDecompressVram(gVsLettersGfx, (void*)(VRAM + 0x10000));
+ LZDecompressVram(gVsLettersGfx, (void*)(OBJ_VRAM0));
LoadCompressedPalette(gUnknown_08D77AE4, 0x60, 0x20);
SetBgAttribute(1, BG_ATTR_SCREENSIZE, 1);
SetGpuReg(REG_OFFSET_BG1CNT, 0x5C04);
diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c
index d8005e808..7c34efd44 100644
--- a/src/battle_controller_player.c
+++ b/src/battle_controller_player.c
@@ -240,12 +240,12 @@ static void HandleInputChooseAction(void)
DoBounceEffect(gActiveBattler, BOUNCE_HEALTHBOX, 7, 1);
DoBounceEffect(gActiveBattler, BOUNCE_MON, 7, 1);
- if (gMain.newAndRepeatedKeys & DPAD_ANY && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_L_EQUALS_A)
+ if (JOY_REPEAT(DPAD_ANY) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_L_EQUALS_A)
gPlayerDpadHoldFrames++;
else
gPlayerDpadHoldFrames = 0;
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
@@ -266,7 +266,7 @@ static void HandleInputChooseAction(void)
}
PlayerBufferExecCompleted();
}
- else if (gMain.newKeys & DPAD_LEFT)
+ else if (JOY_NEW(DPAD_LEFT))
{
if (gActionSelectionCursor[gActiveBattler] & 1) // if is B_ACTION_USE_ITEM or B_ACTION_RUN
{
@@ -276,7 +276,7 @@ static void HandleInputChooseAction(void)
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0);
}
}
- else if (gMain.newKeys & DPAD_RIGHT)
+ else if (JOY_NEW(DPAD_RIGHT))
{
if (!(gActionSelectionCursor[gActiveBattler] & 1)) // if is B_ACTION_USE_MOVE or B_ACTION_SWITCH
{
@@ -286,7 +286,7 @@ static void HandleInputChooseAction(void)
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0);
}
}
- else if (gMain.newKeys & DPAD_UP)
+ else if (JOY_NEW(DPAD_UP))
{
if (gActionSelectionCursor[gActiveBattler] & 2) // if is B_ACTION_SWITCH or B_ACTION_RUN
{
@@ -296,7 +296,7 @@ static void HandleInputChooseAction(void)
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0);
}
}
- else if (gMain.newKeys & DPAD_DOWN)
+ else if (JOY_NEW(DPAD_DOWN))
{
if (!(gActionSelectionCursor[gActiveBattler] & 2)) // if is B_ACTION_USE_MOVE or B_ACTION_USE_ITEM
{
@@ -306,7 +306,7 @@ static void HandleInputChooseAction(void)
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0);
}
}
- else if (gMain.newKeys & B_BUTTON || gPlayerDpadHoldFrames > 59)
+ else if (JOY_NEW(B_BUTTON) || gPlayerDpadHoldFrames > 59)
{
if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
&& GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_RIGHT
@@ -326,7 +326,7 @@ static void HandleInputChooseAction(void)
PlayerBufferExecCompleted();
}
}
- else if (gMain.newKeys & START_BUTTON)
+ else if (JOY_NEW(START_BUTTON))
{
SwapHpBarsWithHpText();
}
@@ -359,12 +359,12 @@ static void HandleInputChooseTarget(void)
} while (i < gBattlersCount);
}
- if (gMain.heldKeys & DPAD_ANY && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_L_EQUALS_A)
+ if (JOY_HELD(DPAD_ANY) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_L_EQUALS_A)
gPlayerDpadHoldFrames++;
else
gPlayerDpadHoldFrames = 0;
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
gSprites[gBattlerSpriteIds[gMultiUsePlayerCursor]].callback = SpriteCb_HideAsMoveTarget;
@@ -372,7 +372,7 @@ static void HandleInputChooseTarget(void)
EndBounceEffect(gMultiUsePlayerCursor, BOUNCE_HEALTHBOX);
PlayerBufferExecCompleted();
}
- else if (gMain.newKeys & B_BUTTON || gPlayerDpadHoldFrames > 59)
+ else if (JOY_NEW(B_BUTTON) || gPlayerDpadHoldFrames > 59)
{
PlaySE(SE_SELECT);
gSprites[gBattlerSpriteIds[gMultiUsePlayerCursor]].callback = SpriteCb_HideAsMoveTarget;
@@ -381,7 +381,7 @@ static void HandleInputChooseTarget(void)
DoBounceEffect(gActiveBattler, BOUNCE_MON, 7, 1);
EndBounceEffect(gMultiUsePlayerCursor, BOUNCE_HEALTHBOX);
}
- else if (gMain.newKeys & (DPAD_LEFT | DPAD_UP))
+ else if (JOY_NEW(DPAD_LEFT | DPAD_UP))
{
PlaySE(SE_SELECT);
gSprites[gBattlerSpriteIds[gMultiUsePlayerCursor]].callback = SpriteCb_HideAsMoveTarget;
@@ -423,7 +423,7 @@ static void HandleInputChooseTarget(void)
} while (i == 0);
gSprites[gBattlerSpriteIds[gMultiUsePlayerCursor]].callback = SpriteCb_ShowAsMoveTarget;
}
- else if (gMain.newKeys & (DPAD_RIGHT | DPAD_DOWN))
+ else if (JOY_NEW(DPAD_RIGHT | DPAD_DOWN))
{
PlaySE(SE_SELECT);
gSprites[gBattlerSpriteIds[gMultiUsePlayerCursor]].callback = SpriteCb_HideAsMoveTarget;
@@ -472,12 +472,12 @@ static void HandleInputChooseMove(void)
bool32 canSelectTarget = FALSE;
struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBattler][4]);
- if (gMain.heldKeys & DPAD_ANY && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_L_EQUALS_A)
+ if (JOY_HELD(DPAD_ANY) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_L_EQUALS_A)
gPlayerDpadHoldFrames++;
else
gPlayerDpadHoldFrames = 0;
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
u8 moveTarget;
@@ -539,13 +539,13 @@ static void HandleInputChooseMove(void)
gSprites[gBattlerSpriteIds[gMultiUsePlayerCursor]].callback = SpriteCb_ShowAsMoveTarget;
}
}
- else if (gMain.newKeys & B_BUTTON || gPlayerDpadHoldFrames > 59)
+ else if (JOY_NEW(B_BUTTON) || gPlayerDpadHoldFrames > 59)
{
PlaySE(SE_SELECT);
BtlController_EmitTwoReturnValues(1, 10, 0xFFFF);
PlayerBufferExecCompleted();
}
- else if (gMain.newKeys & DPAD_LEFT)
+ else if (JOY_NEW(DPAD_LEFT))
{
if (gMoveSelectionCursor[gActiveBattler] & 1)
{
@@ -557,7 +557,7 @@ static void HandleInputChooseMove(void)
MoveSelectionDisplayMoveType();
}
}
- else if (gMain.newKeys & DPAD_RIGHT)
+ else if (JOY_NEW(DPAD_RIGHT))
{
if (!(gMoveSelectionCursor[gActiveBattler] & 1)
&& (gMoveSelectionCursor[gActiveBattler] ^ 1) < gNumberOfMovesToChoose)
@@ -570,7 +570,7 @@ static void HandleInputChooseMove(void)
MoveSelectionDisplayMoveType();
}
}
- else if (gMain.newKeys & DPAD_UP)
+ else if (JOY_NEW(DPAD_UP))
{
if (gMoveSelectionCursor[gActiveBattler] & 2)
{
@@ -582,7 +582,7 @@ static void HandleInputChooseMove(void)
MoveSelectionDisplayMoveType();
}
}
- else if (gMain.newKeys & DPAD_DOWN)
+ else if (JOY_NEW(DPAD_DOWN))
{
if (!(gMoveSelectionCursor[gActiveBattler] & 2)
&& (gMoveSelectionCursor[gActiveBattler] ^ 2) < gNumberOfMovesToChoose)
@@ -595,7 +595,7 @@ static void HandleInputChooseMove(void)
MoveSelectionDisplayMoveType();
}
}
- else if (gMain.newKeys & SELECT_BUTTON)
+ else if (JOY_NEW(SELECT_BUTTON))
{
if (gNumberOfMovesToChoose > 1 && !(gBattleTypeFlags & BATTLE_TYPE_LINK))
{
@@ -617,26 +617,26 @@ u32 sub_8057FBC(void) // unused
{
u32 var = 0;
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
var = 1;
}
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
gBattle_BG0_X = 0;
gBattle_BG0_Y = 0x140;
var = 0xFF;
}
- if (gMain.newKeys & DPAD_LEFT && gMoveSelectionCursor[gActiveBattler] & 1)
+ if (JOY_NEW(DPAD_LEFT) && gMoveSelectionCursor[gActiveBattler] & 1)
{
MoveSelectionDestroyCursorAt(gMoveSelectionCursor[gActiveBattler]);
gMoveSelectionCursor[gActiveBattler] ^= 1;
PlaySE(SE_SELECT);
MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBattler], 0);
}
- if (gMain.newKeys & DPAD_RIGHT && !(gMoveSelectionCursor[gActiveBattler] & 1)
+ if (JOY_NEW(DPAD_RIGHT) && !(gMoveSelectionCursor[gActiveBattler] & 1)
&& (gMoveSelectionCursor[gActiveBattler] ^ 1) < gNumberOfMovesToChoose)
{
MoveSelectionDestroyCursorAt(gMoveSelectionCursor[gActiveBattler]);
@@ -644,14 +644,14 @@ u32 sub_8057FBC(void) // unused
PlaySE(SE_SELECT);
MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBattler], 0);
}
- if (gMain.newKeys & DPAD_UP && gMoveSelectionCursor[gActiveBattler] & 2)
+ if (JOY_NEW(DPAD_UP) && gMoveSelectionCursor[gActiveBattler] & 2)
{
MoveSelectionDestroyCursorAt(gMoveSelectionCursor[gActiveBattler]);
gMoveSelectionCursor[gActiveBattler] ^= 2;
PlaySE(SE_SELECT);
MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBattler], 0);
}
- if (gMain.newKeys & DPAD_DOWN && !(gMoveSelectionCursor[gActiveBattler] & 2)
+ if (JOY_NEW(DPAD_DOWN) && !(gMoveSelectionCursor[gActiveBattler] & 2)
&& (gMoveSelectionCursor[gActiveBattler] ^ 2) < gNumberOfMovesToChoose)
{
MoveSelectionDestroyCursorAt(gMoveSelectionCursor[gActiveBattler]);
@@ -669,7 +669,7 @@ static void HandleMoveSwitching(void)
struct ChooseMoveStruct moveStruct;
u8 totalPPBonuses;
- if (gMain.newKeys & (A_BUTTON | SELECT_BUTTON))
+ if (JOY_NEW(A_BUTTON | SELECT_BUTTON))
{
PlaySE(SE_SELECT);
@@ -763,7 +763,7 @@ static void HandleMoveSwitching(void)
MoveSelectionDisplayPpNumber();
MoveSelectionDisplayMoveType();
}
- else if (gMain.newKeys & (B_BUTTON | SELECT_BUTTON))
+ else if (JOY_NEW(B_BUTTON | SELECT_BUTTON))
{
PlaySE(SE_SELECT);
MoveSelectionDestroyCursorAt(gMultiUsePlayerCursor);
@@ -773,7 +773,7 @@ static void HandleMoveSwitching(void)
MoveSelectionDisplayPpNumber();
MoveSelectionDisplayMoveType();
}
- else if (gMain.newKeys & DPAD_LEFT)
+ else if (JOY_NEW(DPAD_LEFT))
{
if (gMultiUsePlayerCursor & 1)
{
@@ -791,7 +791,7 @@ static void HandleMoveSwitching(void)
MoveSelectionCreateCursorAt(gMultiUsePlayerCursor, 27);
}
}
- else if (gMain.newKeys & DPAD_RIGHT)
+ else if (JOY_NEW(DPAD_RIGHT))
{
if (!(gMultiUsePlayerCursor & 1) && (gMultiUsePlayerCursor ^ 1) < gNumberOfMovesToChoose)
{
@@ -809,7 +809,7 @@ static void HandleMoveSwitching(void)
MoveSelectionCreateCursorAt(gMultiUsePlayerCursor, 27);
}
}
- else if (gMain.newKeys & DPAD_UP)
+ else if (JOY_NEW(DPAD_UP))
{
if (gMultiUsePlayerCursor & 2)
{
@@ -827,7 +827,7 @@ static void HandleMoveSwitching(void)
MoveSelectionCreateCursorAt(gMultiUsePlayerCursor, 27);
}
}
- else if (gMain.newKeys & DPAD_DOWN)
+ else if (JOY_NEW(DPAD_DOWN))
{
if (!(gMultiUsePlayerCursor & 2) && (gMultiUsePlayerCursor ^ 2) < gNumberOfMovesToChoose)
{
@@ -1402,21 +1402,21 @@ static void DoHitAnimBlinkSpriteEffect(void)
static void PlayerHandleUnknownYesNoInput(void)
{
- if (gMain.newKeys & DPAD_UP && gMultiUsePlayerCursor != 0)
+ if (JOY_NEW(DPAD_UP) && gMultiUsePlayerCursor != 0)
{
PlaySE(SE_SELECT);
BattleDestroyYesNoCursorAt(gMultiUsePlayerCursor);
gMultiUsePlayerCursor = 0;
BattleCreateYesNoCursorAt(0);
}
- if (gMain.newKeys & DPAD_DOWN && gMultiUsePlayerCursor == 0)
+ if (JOY_NEW(DPAD_DOWN) && gMultiUsePlayerCursor == 0)
{
PlaySE(SE_SELECT);
BattleDestroyYesNoCursorAt(gMultiUsePlayerCursor);
gMultiUsePlayerCursor = 1;
BattleCreateYesNoCursorAt(1);
}
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
HandleBattleWindow(0x18, 8, 0x1D, 0xD, WINDOW_CLEAR);
PlaySE(SE_SELECT);
@@ -1428,7 +1428,7 @@ static void PlayerHandleUnknownYesNoInput(void)
PlayerBufferExecCompleted();
}
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
HandleBattleWindow(0x18, 8, 0x1D, 0xD, WINDOW_CLEAR);
PlaySE(SE_SELECT);
diff --git a/src/battle_controller_safari.c b/src/battle_controller_safari.c
index 70e41cf8d..9cb427e12 100644
--- a/src/battle_controller_safari.c
+++ b/src/battle_controller_safari.c
@@ -170,7 +170,7 @@ static void SafariBufferRunCommand(void)
static void HandleInputChooseAction(void)
{
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
@@ -191,7 +191,7 @@ static void HandleInputChooseAction(void)
}
SafariBufferExecCompleted();
}
- else if (gMain.newKeys & DPAD_LEFT)
+ else if (JOY_NEW(DPAD_LEFT))
{
if (gActionSelectionCursor[gActiveBattler] & 1)
{
@@ -201,7 +201,7 @@ static void HandleInputChooseAction(void)
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0);
}
}
- else if (gMain.newKeys & DPAD_RIGHT)
+ else if (JOY_NEW(DPAD_RIGHT))
{
if (!(gActionSelectionCursor[gActiveBattler] & 1))
{
@@ -211,7 +211,7 @@ static void HandleInputChooseAction(void)
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0);
}
}
- else if (gMain.newKeys & DPAD_UP)
+ else if (JOY_NEW(DPAD_UP))
{
if (gActionSelectionCursor[gActiveBattler] & 2)
{
@@ -221,7 +221,7 @@ static void HandleInputChooseAction(void)
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0);
}
}
- else if (gMain.newKeys & DPAD_DOWN)
+ else if (JOY_NEW(DPAD_DOWN))
{
if (!(gActionSelectionCursor[gActiveBattler] & 2))
{
diff --git a/src/battle_dome.c b/src/battle_dome.c
index 452997ebd..2f6df5dca 100644
--- a/src/battle_dome.c
+++ b/src/battle_dome.c
@@ -2731,9 +2731,6 @@ static int SelectOpponentMonsFromParty(int *partyMovePoints, bool8 allowRandom)
#define TYPE_x2 40
#define TYPE_x4 80
-// Functionally equivalent, while loop is impossible to match.
-// arg2 is either 2, a personality, or an OTID
-#ifdef NONMATCHING
static int GetTypeEffectivenessPoints(int move, int targetSpecies, int arg2)
{
int defType1, defType2, defAbility, moveType;
@@ -2762,13 +2759,15 @@ static int GetTypeEffectivenessPoints(int move, int targetSpecies, int arg2)
i += 3;
continue;
}
- else if (TYPE_EFFECT_ATK_TYPE(i) == moveType)
+ if (TYPE_EFFECT_ATK_TYPE(i) == moveType)
{
- // BUG: * 2 is not necessary and makes the condition always false if the ability is wonder guard.
- if (TYPE_EFFECT_DEF_TYPE(i) == defType1 && (defAbility != ABILITY_WONDER_GUARD || TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE * 2))
- typePower = (typePower * TYPE_EFFECT_MULTIPLIER(i)) / 10;
- if (TYPE_EFFECT_DEF_TYPE(i) == defType2 && defType1 != defType2 && (defAbility != ABILITY_WONDER_GUARD || TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE * 2))
- typePower = (typePower * TYPE_EFFECT_MULTIPLIER(i)) / 10;
+ // BUG: TYPE_x2 is not necessary and makes the condition always false if the ability is wonder guard.
+ if (TYPE_EFFECT_DEF_TYPE(i) == defType1)
+ if ((defAbility == ABILITY_WONDER_GUARD && TYPE_EFFECT_MULTIPLIER(i) == TYPE_x2) || defAbility != ABILITY_WONDER_GUARD)
+ typePower = typePower * TYPE_EFFECT_MULTIPLIER(i) / 10;
+ if (TYPE_EFFECT_DEF_TYPE(i) == defType2 && defType1 != defType2)
+ if ((defAbility == ABILITY_WONDER_GUARD && TYPE_EFFECT_MULTIPLIER(i) == TYPE_x2) || defAbility != ABILITY_WONDER_GUARD)
+ typePower = typePower * TYPE_EFFECT_MULTIPLIER(i) / 10;
}
i += 3;
}
@@ -2779,10 +2778,10 @@ static int GetTypeEffectivenessPoints(int move, int targetSpecies, int arg2)
case 0:
switch (typePower)
{
- case TYPE_x0_50:
- case TYPE_x0_25:
- case TYPE_x0:
default:
+ case TYPE_x0:
+ case TYPE_x0_25:
+ case TYPE_x0_50:
typePower = 0;
break;
case TYPE_x1:
@@ -2799,19 +2798,19 @@ static int GetTypeEffectivenessPoints(int move, int targetSpecies, int arg2)
case 1:
switch (typePower)
{
- default:
- case TYPE_x1:
- typePower = 0;
+ case TYPE_x0:
+ typePower = 8;
break;
case TYPE_x0_25:
typePower = 4;
break;
- case TYPE_x0:
- typePower = 8;
- break;
case TYPE_x0_50:
typePower = 2;
break;
+ default:
+ case TYPE_x1:
+ typePower = 0;
+ break;
case TYPE_x2:
typePower = -2;
break;
@@ -2829,8 +2828,8 @@ static int GetTypeEffectivenessPoints(int move, int targetSpecies, int arg2)
case TYPE_x0_25:
typePower = -8;
break;
- case TYPE_x0_50:
default:
+ case TYPE_x0_50:
typePower = 0;
break;
case TYPE_x1:
@@ -2848,246 +2847,6 @@ static int GetTypeEffectivenessPoints(int move, int targetSpecies, int arg2)
return typePower;
}
-#else
-NAKED
-static int GetTypeEffectivenessPoints(int move, int species, int arg2)
-{
- asm_unified(
- "push {r4-r7,lr}\n\
- mov r7, r10\n\
- mov r6, r9\n\
- mov r5, r8\n\
- push {r5-r7}\n\
- sub sp, 0x8\n\
- adds r3, r0, 0\n\
- adds r4, r1, 0\n\
- str r2, [sp]\n\
- movs r6, 0\n\
- movs r2, 0x14\n\
- cmp r3, 0\n\
- beq _0818FFF0\n\
- ldr r0, =0x0000ffff\n\
- cmp r3, r0\n\
- beq _0818FFF0\n\
- ldr r0, =gBattleMoves\n\
- lsls r1, r3, 1\n\
- adds r1, r3\n\
- lsls r1, 2\n\
- adds r3, r1, r0\n\
- ldrb r0, [r3, 0x1]\n\
- cmp r0, 0\n\
- bne _0818FFFC\n\
-_0818FFF0:\n\
- movs r0, 0\n\
- b _08190156\n\
- .pool\n\
-_0818FFFC:\n\
- ldr r1, =gBaseStats\n\
- lsls r0, r4, 3\n\
- subs r0, r4\n\
- lsls r0, 2\n\
- adds r0, r1\n\
- ldrb r1, [r0, 0x6]\n\
- mov r10, r1\n\
- ldrb r1, [r0, 0x7]\n\
- mov r9, r1\n\
- ldrb r0, [r0, 0x16]\n\
- mov r8, r0\n\
- ldrb r3, [r3, 0x2]\n\
- str r3, [sp, 0x4]\n\
- cmp r0, 0x1A\n\
- bne _0819002C\n\
- cmp r3, 0x4\n\
- bne _0819002C\n\
- ldr r0, [sp]\n\
- cmp r0, 0x1\n\
- bne _081900AA\n\
- movs r2, 0x8\n\
- b _081900A4\n\
- .pool\n\
-_0819002C:\n\
- ldr r0, =gTypeEffectiveness\n\
- adds r1, r6, r0\n\
- ldrb r0, [r1]\n\
- ldr r7, =gTypeEffectiveness\n\
- cmp r0, 0xFF\n\
- beq _081900A4\n\
- adds r4, r1, 0\n\
-_0819003A:\n\
- ldrb r0, [r4]\n\
- cmp r0, 0xFE\n\
- beq _08190096\n\
- ldrb r0, [r4]\n\
- ldr r1, [sp, 0x4]\n\
- cmp r0, r1\n\
- bne _08190096\n\
- ldrb r0, [r4, 0x1]\n\
- adds r5, r6, 0x1\n\
- cmp r0, r10\n\
- bne _0819006C\n\
- adds r1, r6, 0x2\n\
- mov r0, r8\n\
- cmp r0, 0x19\n\
- bne _0819005E\n\
- ldrb r0, [r4, 0x2]\n\
- cmp r0, 0x28\n\
- bne _0819006C\n\
-_0819005E:\n\
- adds r0, r1, r7\n\
- ldrb r0, [r0]\n\
- muls r0, r2\n\
- movs r1, 0xA\n\
- bl __divsi3\n\
- adds r2, r0, 0\n\
-_0819006C:\n\
- adds r0, r5, r7\n\
- ldrb r0, [r0]\n\
- cmp r0, r9\n\
- bne _08190096\n\
- cmp r10, r9\n\
- beq _08190096\n\
- adds r1, r6, 0x2\n\
- mov r0, r8\n\
- cmp r0, 0x19\n\
- bne _08190088\n\
- adds r0, r1, r7\n\
- ldrb r0, [r0]\n\
- cmp r0, 0x28\n\
- bne _08190096\n\
-_08190088:\n\
- adds r0, r1, r7\n\
- ldrb r0, [r0]\n\
- muls r0, r2\n\
- movs r1, 0xA\n\
- bl __divsi3\n\
- adds r2, r0, 0\n\
-_08190096:\n\
- adds r4, 0x3\n\
- adds r6, 0x3\n\
- ldr r1, =gTypeEffectiveness\n\
- adds r0, r6, r1\n\
- ldrb r0, [r0]\n\
- cmp r0, 0xFF\n\
- bne _0819003A\n\
-_081900A4:\n\
- ldr r0, [sp]\n\
- cmp r0, 0x1\n\
- beq _081900E0\n\
-_081900AA:\n\
- ldr r1, [sp]\n\
- cmp r1, 0x1\n\
- bgt _081900BC\n\
- cmp r1, 0\n\
- beq _081900C4\n\
- b _08190154\n\
- .pool\n\
-_081900BC:\n\
- ldr r0, [sp]\n\
- cmp r0, 0x2\n\
- beq _08190114\n\
- b _08190154\n\
-_081900C4:\n\
- cmp r2, 0xA\n\
- beq _08190146\n\
- cmp r2, 0xA\n\
- ble _08190146\n\
- cmp r2, 0x28\n\
- beq _0819014A\n\
- cmp r2, 0x28\n\
- bgt _081900DA\n\
- cmp r2, 0x14\n\
- beq _08190104\n\
- b _08190146\n\
-_081900DA:\n\
- cmp r2, 0x50\n\
- bne _08190146\n\
- b _08190100\n\
-_081900E0:\n\
- cmp r2, 0xA\n\
- beq _08190104\n\
- cmp r2, 0xA\n\
- bgt _081900F2\n\
- cmp r2, 0\n\
- beq _08190100\n\
- cmp r2, 0x5\n\
- beq _0819014A\n\
- b _08190146\n\
-_081900F2:\n\
- cmp r2, 0x28\n\
- beq _08190108\n\
- cmp r2, 0x28\n\
- ble _08190146\n\
- cmp r2, 0x50\n\
- beq _0819010E\n\
- b _08190146\n\
-_08190100:\n\
- movs r2, 0x8\n\
- b _08190154\n\
-_08190104:\n\
- movs r2, 0x2\n\
- b _08190154\n\
-_08190108:\n\
- movs r2, 0x2\n\
- negs r2, r2\n\
- b _08190154\n\
-_0819010E:\n\
- movs r2, 0x4\n\
- negs r2, r2\n\
- b _08190154\n\
-_08190114:\n\
- cmp r2, 0xA\n\
- beq _08190146\n\
- cmp r2, 0xA\n\
- bgt _08190126\n\
- cmp r2, 0\n\
- beq _0819013A\n\
- cmp r2, 0x5\n\
- beq _08190140\n\
- b _08190146\n\
-_08190126:\n\
- cmp r2, 0x28\n\
- beq _0819014E\n\
- cmp r2, 0x28\n\
- bgt _08190134\n\
- cmp r2, 0x14\n\
- beq _0819014A\n\
- b _08190146\n\
-_08190134:\n\
- cmp r2, 0x50\n\
- beq _08190152\n\
- b _08190146\n\
-_0819013A:\n\
- movs r2, 0x10\n\
- negs r2, r2\n\
- b _08190154\n\
-_08190140:\n\
- movs r2, 0x8\n\
- negs r2, r2\n\
- b _08190154\n\
-_08190146:\n\
- movs r2, 0\n\
- b _08190154\n\
-_0819014A:\n\
- movs r2, 0x4\n\
- b _08190154\n\
-_0819014E:\n\
- movs r2, 0xC\n\
- b _08190154\n\
-_08190152:\n\
- movs r2, 0x14\n\
-_08190154:\n\
- adds r0, r2, 0\n\
-_08190156:\n\
- add sp, 0x8\n\
- pop {r3-r5}\n\
- mov r8, r3\n\
- mov r9, r4\n\
- mov r10, r5\n\
- pop {r4-r7}\n\
- pop {r1}\n\
- bx r1");
-}
-#endif // NONMATCHING
// Duplicate of GetFrontierTrainerFixedIvs
// NOTE: In CreateDomeOpponentMon a tournament trainer ID (0-15) is passed instead, resulting in all IVs of 3
@@ -4352,7 +4111,7 @@ static u8 Task_GetInfoCardInput(u8 taskId)
u8 tourneyId = sTourneyTreeTrainerIds[position];
u16 roundId = gSaveBlock2Ptr->frontier.curChallengeBattleNum;
- if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ if (JOY_NEW(A_BUTTON | B_BUTTON))
input = INFOCARD_INPUT_AB;
// Next opponent card cant scroll
@@ -4363,7 +4122,7 @@ static u8 Task_GetInfoCardInput(u8 taskId)
{
// For trainer info cards, pos is 0 when on a trainer info card (not viewing that trainer's match progression)
// Scrolling up/down from a trainer info card goes to other trainer info cards
- if (gMain.newKeys & DPAD_UP && sInfoCard->pos == 0)
+ if (JOY_NEW(DPAD_UP) && sInfoCard->pos == 0)
{
if (position == 0)
position = DOME_TOURNAMENT_TRAINERS_COUNT - 1;
@@ -4371,7 +4130,7 @@ static u8 Task_GetInfoCardInput(u8 taskId)
position--;
input = TRAINERCARD_INPUT_UP;
}
- else if (gMain.newKeys & DPAD_DOWN && sInfoCard->pos == 0)
+ else if (JOY_NEW(DPAD_DOWN) && sInfoCard->pos == 0)
{
if (position == DOME_TOURNAMENT_TRAINERS_COUNT - 1)
position = 0;
@@ -4380,13 +4139,13 @@ static u8 Task_GetInfoCardInput(u8 taskId)
input = TRAINERCARD_INPUT_DOWN;
}
// Scrolling left can only be done after scrolling right
- else if (gMain.newKeys & DPAD_LEFT && sInfoCard->pos != 0)
+ else if (JOY_NEW(DPAD_LEFT) && sInfoCard->pos != 0)
{
sInfoCard->pos--;
input = TRAINERCARD_INPUT_LEFT;
}
// Scrolling right from a trainer info card shows their match progression
- else if (gMain.newKeys & DPAD_RIGHT)
+ else if (JOY_NEW(DPAD_RIGHT))
{
// Can only scroll right from a trainer card until the round they were eliminated
if (DOME_TRAINERS[tourneyId].isEliminated && sInfoCard->pos - 1 < DOME_TRAINERS[tourneyId].eliminatedAt)
@@ -4414,7 +4173,7 @@ static u8 Task_GetInfoCardInput(u8 taskId)
{
// For match info cards, pos is 1 when on the match card, 0 when on the left trainer, and 1 when on the right trainer
// Scrolling up/down from a match info card goes to the next/previous match
- if (gMain.newKeys & DPAD_UP && sInfoCard->pos == 1)
+ if (JOY_NEW(DPAD_UP) && sInfoCard->pos == 1)
{
if (position == DOME_TOURNAMENT_TRAINERS_COUNT)
position = sLastMatchCardNum[roundId];
@@ -4422,7 +4181,7 @@ static u8 Task_GetInfoCardInput(u8 taskId)
position--;
input = MATCHCARD_INPUT_UP;
}
- else if (gMain.newKeys & DPAD_DOWN && sInfoCard->pos == 1)
+ else if (JOY_NEW(DPAD_DOWN) && sInfoCard->pos == 1)
{
if (position == sLastMatchCardNum[roundId])
position = DOME_TOURNAMENT_TRAINERS_COUNT;
@@ -4431,12 +4190,12 @@ static u8 Task_GetInfoCardInput(u8 taskId)
input = MATCHCARD_INPUT_DOWN;
}
// Scrolling left/right from a match info card shows the trainer info card of the competitors for that match
- else if (gMain.newKeys & DPAD_LEFT && sInfoCard->pos != 0)
+ else if (JOY_NEW(DPAD_LEFT) && sInfoCard->pos != 0)
{
input = MATCHCARD_INPUT_LEFT;
sInfoCard->pos--;
}
- else if (gMain.newKeys & DPAD_RIGHT && (sInfoCard->pos == 0 || sInfoCard->pos == 1))
+ else if (JOY_NEW(DPAD_RIGHT) && (sInfoCard->pos == 0 || sInfoCard->pos == 1))
{
input = MATCHCARD_INPUT_RIGHT;
sInfoCard->pos++;
@@ -5284,12 +5043,12 @@ static u8 UpdateTourneyTreeCursor(u8 taskId)
int tourneyTreeCursorSpriteId = gTasks[taskId].data[1];
int roundId = gSaveBlock2Ptr->frontier.curChallengeBattleNum;
- if (gMain.newKeys == B_BUTTON || (gMain.newKeys & A_BUTTON && tourneyTreeCursorSpriteId == TOURNEY_TREE_CLOSE_BUTTON))
+ if (gMain.newKeys == B_BUTTON || (JOY_NEW(A_BUTTON) && tourneyTreeCursorSpriteId == TOURNEY_TREE_CLOSE_BUTTON))
{
PlaySE(SE_SELECT);
selection = TOURNEY_TREE_SELECTED_CLOSE;
}
- else if (gMain.newKeys & A_BUTTON)
+ else if (JOY_NEW(A_BUTTON))
{
if (tourneyTreeCursorSpriteId < DOME_TOURNAMENT_TRAINERS_COUNT)
{
@@ -5793,7 +5552,7 @@ static void Task_HandleStaticTourneyTreeInput(u8 taskId)
gTasks[taskId].tState = STATE_WAIT_FOR_INPUT;
break;
case STATE_WAIT_FOR_INPUT:
- if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ if (JOY_NEW(A_BUTTON | B_BUTTON))
{
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK);
gTasks[taskId].tState = STATE_CLOSE_TOURNEY_TREE;
diff --git a/src/battle_factory_screen.c b/src/battle_factory_screen.c
index 388881a1c..a3fa275c5 100644
--- a/src/battle_factory_screen.c
+++ b/src/battle_factory_screen.c
@@ -1478,7 +1478,7 @@ static void Task_HandleSelectionScreenYesNo(u8 taskId)
gTasks[taskId].data[0] = 5;
break;
case 5:
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
if (sFactorySelectScreen->yesNoCursorPos == 0)
@@ -1496,7 +1496,7 @@ static void Task_HandleSelectionScreenYesNo(u8 taskId)
gTasks[taskId].func = Task_HandleSelectionScreenChooseMons;
}
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
sub_819B958(4);
@@ -1505,12 +1505,12 @@ static void Task_HandleSelectionScreenYesNo(u8 taskId)
gTasks[taskId].data[0] = 1;
gTasks[taskId].func = Task_HandleSelectionScreenChooseMons;
}
- else if (gMain.newAndRepeatedKeys & DPAD_UP)
+ else if (JOY_REPEAT(DPAD_UP))
{
PlaySE(SE_SELECT);
Select_UpdateYesNoCursorPosition(-1);
}
- else if (gMain.newAndRepeatedKeys & DPAD_DOWN)
+ else if (JOY_REPEAT(DPAD_DOWN))
{
PlaySE(SE_SELECT);
Select_UpdateYesNoCursorPosition(1);
@@ -1538,7 +1538,7 @@ static void Task_HandleSelectionScreenMenu(u8 taskId)
}
break;
case 3:
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
u8 retVal;
PlaySE(SE_SELECT);
@@ -1565,7 +1565,7 @@ static void Task_HandleSelectionScreenMenu(u8 taskId)
gTasks[taskId].func = Task_FromSelectScreenToSummaryScreen;
}
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
sub_819F3F8(sFactorySelectScreen->unk294[1], &sFactorySelectScreen->unk2A0, FALSE);
@@ -1574,12 +1574,12 @@ static void Task_HandleSelectionScreenMenu(u8 taskId)
gTasks[taskId].data[0] = 1;
gTasks[taskId].func = Task_HandleSelectionScreenChooseMons;
}
- else if (gMain.newAndRepeatedKeys & DPAD_UP)
+ else if (JOY_REPEAT(DPAD_UP))
{
PlaySE(SE_SELECT);
Select_UpdateMenuCursorPosition(-1);
}
- else if (gMain.newAndRepeatedKeys & DPAD_DOWN)
+ else if (JOY_REPEAT(DPAD_DOWN))
{
PlaySE(SE_SELECT);
Select_UpdateMenuCursorPosition(1);
@@ -1618,21 +1618,21 @@ static void Task_HandleSelectionScreenChooseMons(u8 taskId)
}
break;
case 1:
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
sFactorySelectScreen->unk2A2 = FALSE;
gTasks[taskId].data[0] = 2;
gTasks[taskId].func = Task_HandleSelectionScreenMenu;
}
- else if (gMain.newAndRepeatedKeys & DPAD_LEFT)
+ else if (JOY_REPEAT(DPAD_LEFT))
{
PlaySE(SE_SELECT);
Select_UpdateBallCursorPosition(-1);
Select_PrintMonCategory();
Select_PrintMonSpecies();
}
- else if (gMain.newAndRepeatedKeys & DPAD_RIGHT)
+ else if (JOY_REPEAT(DPAD_RIGHT))
{
PlaySE(SE_SELECT);
Select_UpdateBallCursorPosition(1);
@@ -1641,7 +1641,7 @@ static void Task_HandleSelectionScreenChooseMons(u8 taskId)
}
break;
case 11:
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
sub_819F3F8(sFactorySelectScreen->unk294[1], &sFactorySelectScreen->unk2A0, FALSE);
@@ -2361,7 +2361,7 @@ static void Task_HandleSwapScreenYesNo(u8 taskId)
gTasks[taskId].data[0] = 5;
break;
case 5:
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
if (sFactorySwapScreen->yesNoCursorPos == 0)
@@ -2380,7 +2380,7 @@ static void Task_HandleSwapScreenYesNo(u8 taskId)
gTasks[taskId].func = (void*)((hiPtr << 16) | loPtr);
}
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
gTasks[taskId].data[1] = 0;
@@ -2389,12 +2389,12 @@ static void Task_HandleSwapScreenYesNo(u8 taskId)
loPtr = gTasks[taskId].data[7];
gTasks[taskId].func = (void*)((hiPtr << 16) | loPtr);
}
- else if (gMain.newAndRepeatedKeys & DPAD_UP)
+ else if (JOY_REPEAT(DPAD_UP))
{
PlaySE(SE_SELECT);
Swap_UpdateYesNoCursorPosition(-1);
}
- else if (gMain.newAndRepeatedKeys & DPAD_DOWN)
+ else if (JOY_REPEAT(DPAD_DOWN))
{
PlaySE(SE_SELECT);
Swap_UpdateYesNoCursorPosition(1);
@@ -2485,12 +2485,12 @@ static void Task_HandleSwapScreenMenu(u8 taskId)
case 3:
if (sFactorySwapScreen->unk30 != TRUE)
{
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
Swap_RunMenuOptionFunc(taskId);
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
sub_819F3F8(sFactorySwapScreen->unk2C, &sFactorySwapScreen->unk30, TRUE);
@@ -2501,11 +2501,11 @@ static void Task_HandleSwapScreenMenu(u8 taskId)
gTasks[taskId].data[5] = 1;
gTasks[taskId].func = sub_819D770;
}
- else if (gMain.newAndRepeatedKeys & DPAD_UP)
+ else if (JOY_REPEAT(DPAD_UP))
{
Swap_UpdateMenuCursorPosition(-1);
}
- else if (gMain.newAndRepeatedKeys & DPAD_DOWN)
+ else if (JOY_REPEAT(DPAD_DOWN))
{
Swap_UpdateMenuCursorPosition(1);
}
@@ -2526,7 +2526,7 @@ static void Task_HandleSwapScreenChooseMons(u8 taskId)
}
break;
case 1:
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
sFactorySwapScreen->unk22 = FALSE;
@@ -2534,7 +2534,7 @@ static void Task_HandleSwapScreenChooseMons(u8 taskId)
sub_819EAC0();
Swap_RunActionFunc(taskId);
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
sFactorySwapScreen->unk22 = FALSE;
@@ -2546,25 +2546,25 @@ static void Task_HandleSwapScreenChooseMons(u8 taskId)
gTasks[taskId].data[5] = 0;
gTasks[taskId].func = sub_819D588;
}
- else if (gMain.newAndRepeatedKeys & DPAD_LEFT)
+ else if (JOY_REPEAT(DPAD_LEFT))
{
Swap_UpdateBallCursorPosition(-1);
Swap_PrintMonCategory();
Swap_PrintMonSpecies();
}
- else if (gMain.newAndRepeatedKeys & DPAD_RIGHT)
+ else if (JOY_REPEAT(DPAD_RIGHT))
{
Swap_UpdateBallCursorPosition(1);
Swap_PrintMonCategory();
Swap_PrintMonSpecies();
}
- else if (gMain.newAndRepeatedKeys & DPAD_DOWN)
+ else if (JOY_REPEAT(DPAD_DOWN))
{
Swap_UpdateActionCursorPosition(1);
Swap_PrintMonCategory();
Swap_PrintMonSpecies();
}
- else if (gMain.newAndRepeatedKeys & DPAD_UP)
+ else if (JOY_REPEAT(DPAD_UP))
{
Swap_UpdateActionCursorPosition(-1);
Swap_PrintMonCategory();
@@ -3929,7 +3929,7 @@ static void Task_SwapCantHaveSameMons(u8 taskId)
gTasks[taskId].data[0]++;
break;
case 1:
- if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
sub_819F3F8(sFactorySwapScreen->unk2C, &sFactorySwapScreen->unk30, TRUE);
diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c
index b1bb61aaf..e3e63f0e8 100644
--- a/src/battle_gfx_sfx_util.c
+++ b/src/battle_gfx_sfx_util.c
@@ -957,7 +957,7 @@ void HandleSpeciesGfxDataChange(u8 battlerAtk, u8 battlerDef, bool8 notTransform
}
src = gMonSpritesGfxPtr->sprites[position];
- dst = (void *)(VRAM + 0x10000 + gSprites[gBattlerSpriteIds[battlerAtk]].oam.tileNum * 32);
+ dst = (void *)(OBJ_VRAM0 + gSprites[gBattlerSpriteIds[battlerAtk]].oam.tileNum * 32);
DmaCopy32(3, src, dst, 0x800);
paletteOffset = 0x100 + battlerAtk * 16;
lzPaletteData = GetMonSpritePalFromSpeciesAndPersonality(targetSpecies, otId, personalityValue);
diff --git a/src/battle_main.c b/src/battle_main.c
index 2c3df2e34..193fffaf2 100644
--- a/src/battle_main.c
+++ b/src/battle_main.c
@@ -1854,7 +1854,7 @@ void BattleMainCB2(void)
UpdatePaletteFade();
RunTasks();
- if (gMain.heldKeys & B_BUTTON && gBattleTypeFlags & BATTLE_TYPE_RECORDED && sub_8186450())
+ if (JOY_HELD(B_BUTTON) && gBattleTypeFlags & BATTLE_TYPE_RECORDED && sub_8186450())
{
gSpecialVar_Result = gBattleOutcome = B_OUTCOME_PLAYER_TELEPORTED;
ResetPaletteFadeControl();
@@ -2510,7 +2510,7 @@ static void sub_803939C(void)
}
break;
case 5:
- if (gMain.newKeys & DPAD_UP)
+ if (JOY_NEW(DPAD_UP))
{
if (gBattleCommunication[CURSOR_POSITION] != 0)
{
@@ -2520,7 +2520,7 @@ static void sub_803939C(void)
BattleCreateYesNoCursorAt(0);
}
}
- else if (gMain.newKeys & DPAD_DOWN)
+ else if (JOY_NEW(DPAD_DOWN))
{
if (gBattleCommunication[CURSOR_POSITION] == 0)
{
@@ -2530,7 +2530,7 @@ static void sub_803939C(void)
BattleCreateYesNoCursorAt(1);
}
}
- else if (gMain.newKeys & A_BUTTON)
+ else if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
if (gBattleCommunication[CURSOR_POSITION] == 0)
@@ -2544,7 +2544,7 @@ static void sub_803939C(void)
gBattleCommunication[MULTIUSE_STATE]++;
}
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
gBattleCommunication[MULTIUSE_STATE]++;
diff --git a/src/battle_pyramid.c b/src/battle_pyramid.c
index b015f3e0e..9e881d3a3 100644
--- a/src/battle_pyramid.c
+++ b/src/battle_pyramid.c
@@ -523,6 +523,19 @@ static const u8 sTrainerTextGroups[50][2] =
{FACILITY_CLASS_HIKER, 4},
};
+enum
+{
+ HINT_EXIT_DIRECTION,
+ HINT_REMAINING_ITEMS,
+ HINT_REMAINING_TRAINERS,
+ HINT_EXIT_SHORT_REMAINING_TRAINERS,
+ HINT_EXIT_SHORT_REMAINING_ITEMS,
+ HINT_EXIT_MEDIUM_REMAINING_TRAINERS,
+ HINT_EXIT_MEDIUM_REMAINING_ITEMS,
+ HINT_EXIT_FAR_REMAINING_TRAINERS,
+ HINT_EXIT_FAR_REMAINING_ITEMS,
+};
+
static const u8 *const sExitDirectionHintTexts1[] =
{
BattlePyramid_Text_ExitHintUp1,
diff --git a/src/battle_pyramid_bag.c b/src/battle_pyramid_bag.c
index e038e71e1..8fee57855 100644
--- a/src/battle_pyramid_bag.c
+++ b/src/battle_pyramid_bag.c
@@ -839,7 +839,7 @@ static void Task_HandlePyramidBagInput(u8 taskId)
s16 *data = gTasks[taskId].data;
if (MenuHelpers_CallLinkSomething() != TRUE && !gPaletteFade.active)
{
- if (gMain.newKeys & SELECT_BUTTON)
+ if (JOY_NEW(SELECT_BUTTON))
{
if (gPyramidBagCursorData.unk4 != 2)
{
@@ -965,7 +965,7 @@ static void HandleMenuActionInput(u8 taskId)
if (MenuHelpers_CallLinkSomething() != TRUE)
{
s8 id = Menu_GetCursorPos();
- if (gMain.newKeys & DPAD_UP)
+ if (JOY_NEW(DPAD_UP))
{
if (id > 0 && IsValidMenuAction(id - 2))
{
@@ -973,7 +973,7 @@ static void HandleMenuActionInput(u8 taskId)
ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_UP);
}
}
- else if (gMain.newKeys & DPAD_DOWN)
+ else if (JOY_NEW(DPAD_DOWN))
{
if (id < gPyramidBagResources->menuActionsCount - 2 && IsValidMenuAction(id + 2))
{
@@ -981,7 +981,7 @@ static void HandleMenuActionInput(u8 taskId)
ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_DOWN);
}
}
- else if (gMain.newKeys & DPAD_LEFT || GetLRKeysPressed() == MENU_L_PRESSED)
+ else if (JOY_NEW(DPAD_LEFT) || GetLRKeysPressed() == MENU_L_PRESSED)
{
if (id & 1 && IsValidMenuAction(id - 1))
{
@@ -989,7 +989,7 @@ static void HandleMenuActionInput(u8 taskId)
ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_LEFT, MENU_CURSOR_DELTA_NONE);
}
}
- else if (gMain.newKeys & DPAD_RIGHT || GetLRKeysPressed() == MENU_R_PRESSED)
+ else if (JOY_NEW(DPAD_RIGHT) || GetLRKeysPressed() == MENU_R_PRESSED)
{
if (!(id & 1) && IsValidMenuAction(id + 1))
{
@@ -997,13 +997,13 @@ static void HandleMenuActionInput(u8 taskId)
ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_RIGHT, MENU_CURSOR_DELTA_NONE);
}
}
- else if (gMain.newKeys & A_BUTTON)
+ else if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
if (sMenuActions[gPyramidBagResources->menuActionIds[id]].func.void_u8 != NULL)
sMenuActions[gPyramidBagResources->menuActionIds[id]].func.void_u8(taskId);
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
sMenuActions[ACTION_CANCEL].func.void_u8(taskId);
@@ -1143,7 +1143,7 @@ static void sub_81C64B4(u8 taskId)
{
sub_81C645C(data[8]);
}
- else if (gMain.newKeys & A_BUTTON)
+ else if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
ClearStdWindowAndFrameToTransparent(3, 0);
@@ -1151,7 +1151,7 @@ static void sub_81C64B4(u8 taskId)
ScheduleBgCopyTilemapToVram(1);
sub_81C6350(taskId);
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
ClearStdWindowAndFrameToTransparent(3, 0);
@@ -1179,7 +1179,7 @@ static void sub_81C65CC(u8 taskId)
u16 *scrollOffset = &gPyramidBagCursorData.scrollPosition;
u16 *selectedRow = &gPyramidBagCursorData.cursorPosition;
- if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ if (JOY_NEW(A_BUTTON | B_BUTTON))
{
PlaySE(SE_SELECT);
RemovePyramidBagItem(gSpecialVar_ItemId, data[8]);
@@ -1220,7 +1220,7 @@ static void sub_81C66AC(u8 taskId)
static void sub_81C66EC(u8 taskId)
{
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
Task_CloseBattlePyramidBagMessage(taskId);
@@ -1277,7 +1277,7 @@ static void Task_ItemSwapHandleInput(u8 taskId)
s16 *data = gTasks[taskId].data;
if (MenuHelpers_CallLinkSomething() != TRUE)
{
- if (gMain.newKeys & SELECT_BUTTON)
+ if (JOY_NEW(SELECT_BUTTON))
{
PlaySE(SE_SELECT);
ListMenuGetScrollAndRow(data[0], &gPyramidBagCursorData.scrollPosition, &gPyramidBagCursorData.cursorPosition);
@@ -1295,7 +1295,7 @@ static void Task_ItemSwapHandleInput(u8 taskId)
break;
case LIST_CANCEL:
PlaySE(SE_SELECT);
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
PerformItemSwap(taskId);
else
sub_81C6A14(taskId);
diff --git a/src/battle_records.c b/src/battle_records.c
index 680733527..a8b9ead14 100644
--- a/src/battle_records.c
+++ b/src/battle_records.c
@@ -356,7 +356,7 @@ static void Task_CloseTrainerHillRecordsOnButton(u8 taskId)
{
struct Task *task = &gTasks[taskId];
- if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
task->func = Task_BeginPaletteFade;
diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c
index 9ff5e8fc6..7ded6fcd8 100644
--- a/src/battle_script_commands.c
+++ b/src/battle_script_commands.c
@@ -5360,21 +5360,21 @@ static void Cmd_yesnoboxlearnmove(void)
BattleCreateYesNoCursorAt(0);
break;
case 1:
- if (gMain.newKeys & DPAD_UP && gBattleCommunication[CURSOR_POSITION] != 0)
+ if (JOY_NEW(DPAD_UP) && gBattleCommunication[CURSOR_POSITION] != 0)
{
PlaySE(SE_SELECT);
BattleDestroyYesNoCursorAt(gBattleCommunication[CURSOR_POSITION]);
gBattleCommunication[CURSOR_POSITION] = 0;
BattleCreateYesNoCursorAt(0);
}
- if (gMain.newKeys & DPAD_DOWN && gBattleCommunication[CURSOR_POSITION] == 0)
+ if (JOY_NEW(DPAD_DOWN) && gBattleCommunication[CURSOR_POSITION] == 0)
{
PlaySE(SE_SELECT);
BattleDestroyYesNoCursorAt(gBattleCommunication[CURSOR_POSITION]);
gBattleCommunication[CURSOR_POSITION] = 1;
BattleCreateYesNoCursorAt(1);
}
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
if (gBattleCommunication[1] == 0)
@@ -5388,7 +5388,7 @@ static void Cmd_yesnoboxlearnmove(void)
gBattleScripting.learnMoveState = 5;
}
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
gBattleScripting.learnMoveState = 5;
@@ -5477,21 +5477,21 @@ static void Cmd_yesnoboxstoplearningmove(void)
BattleCreateYesNoCursorAt(0);
break;
case 1:
- if (gMain.newKeys & DPAD_UP && gBattleCommunication[CURSOR_POSITION] != 0)
+ if (JOY_NEW(DPAD_UP) && gBattleCommunication[CURSOR_POSITION] != 0)
{
PlaySE(SE_SELECT);
BattleDestroyYesNoCursorAt(gBattleCommunication[CURSOR_POSITION]);
gBattleCommunication[CURSOR_POSITION] = 0;
BattleCreateYesNoCursorAt(0);
}
- if (gMain.newKeys & DPAD_DOWN && gBattleCommunication[CURSOR_POSITION] == 0)
+ if (JOY_NEW(DPAD_DOWN) && gBattleCommunication[CURSOR_POSITION] == 0)
{
PlaySE(SE_SELECT);
BattleDestroyYesNoCursorAt(gBattleCommunication[CURSOR_POSITION]);
gBattleCommunication[CURSOR_POSITION] = 1;
BattleCreateYesNoCursorAt(1);
}
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
@@ -5502,7 +5502,7 @@ static void Cmd_yesnoboxstoplearningmove(void)
HandleBattleWindow(0x18, 0x8, 0x1D, 0xD, WINDOW_CLEAR);
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
@@ -5772,28 +5772,28 @@ static void Cmd_yesnobox(void)
BattleCreateYesNoCursorAt(0);
break;
case 1:
- if (gMain.newKeys & DPAD_UP && gBattleCommunication[CURSOR_POSITION] != 0)
+ if (JOY_NEW(DPAD_UP) && gBattleCommunication[CURSOR_POSITION] != 0)
{
PlaySE(SE_SELECT);
BattleDestroyYesNoCursorAt(gBattleCommunication[CURSOR_POSITION]);
gBattleCommunication[CURSOR_POSITION] = 0;
BattleCreateYesNoCursorAt(0);
}
- if (gMain.newKeys & DPAD_DOWN && gBattleCommunication[CURSOR_POSITION] == 0)
+ if (JOY_NEW(DPAD_DOWN) && gBattleCommunication[CURSOR_POSITION] == 0)
{
PlaySE(SE_SELECT);
BattleDestroyYesNoCursorAt(gBattleCommunication[CURSOR_POSITION]);
gBattleCommunication[CURSOR_POSITION] = 1;
BattleCreateYesNoCursorAt(1);
}
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
gBattleCommunication[CURSOR_POSITION] = 1;
PlaySE(SE_SELECT);
HandleBattleWindow(0x18, 8, 0x1D, 0xD, WINDOW_CLEAR);
gBattlescriptCurrInstr++;
}
- else if (gMain.newKeys & A_BUTTON)
+ else if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
HandleBattleWindow(0x18, 8, 0x1D, 0xD, WINDOW_CLEAR);
@@ -10076,21 +10076,21 @@ static void Cmd_trygivecaughtmonnick(void)
BattleCreateYesNoCursorAt(0);
break;
case 1:
- if (gMain.newKeys & DPAD_UP && gBattleCommunication[CURSOR_POSITION] != 0)
+ if (JOY_NEW(DPAD_UP) && gBattleCommunication[CURSOR_POSITION] != 0)
{
PlaySE(SE_SELECT);
BattleDestroyYesNoCursorAt(gBattleCommunication[CURSOR_POSITION]);
gBattleCommunication[CURSOR_POSITION] = 0;
BattleCreateYesNoCursorAt(0);
}
- if (gMain.newKeys & DPAD_DOWN && gBattleCommunication[CURSOR_POSITION] == 0)
+ if (JOY_NEW(DPAD_DOWN) && gBattleCommunication[CURSOR_POSITION] == 0)
{
PlaySE(SE_SELECT);
BattleDestroyYesNoCursorAt(gBattleCommunication[CURSOR_POSITION]);
gBattleCommunication[CURSOR_POSITION] = 1;
BattleCreateYesNoCursorAt(1);
}
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
if (gBattleCommunication[CURSOR_POSITION] == 0)
@@ -10103,7 +10103,7 @@ static void Cmd_trygivecaughtmonnick(void)
gBattleCommunication[MULTIUSE_STATE] = 4;
}
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
gBattleCommunication[MULTIUSE_STATE] = 4;
diff --git a/src/battle_tv.c b/src/battle_tv.c
index c84ae827b..e3dec9a6c 100644
--- a/src/battle_tv.c
+++ b/src/battle_tv.c
@@ -713,20 +713,18 @@ void BattleTv_SetDataBasedOnAnimation(u8 animationId)
}
}
-#ifdef NONMATCHING
-// for loop has an unused stack variable
void TryPutLinkBattleTvShowOnAir(void)
{
- u16 playerBestSpecies = 0, opponentBestSpecies = 0;
- s16 playerBestSum = 0, opponentBestSum = SHRT_MAX;
+ u16 playerBestSpecies = 0, opponentBestSpecies = 0, moveId = 0;
+ s16 sum = 0, playerBestSum = 0, opponentBestSum = SHRT_MAX;
u8 playerBestMonId = 0, opponentBestMonId = 0;
struct BattleTvMovePoints *movePoints = NULL;
u8 countPlayer = 0, countOpponent = 0;
- s16 sum = 0;
- u16 species = 0;
- u16 moveId = 0;
+ u16 species;
s32 i, j;
+ int zero = 0, one = 1; // stupid variables needed to match. Feel free to get rid of them.
+
if (gBattleStruct->anyMonHasTransformed)
return;
@@ -748,7 +746,7 @@ void TryPutLinkBattleTvShowOnAir(void)
if (species != SPECIES_NONE && !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG, NULL))
{
for (sum = 0, j = 0; j < MAX_MON_MOVES; j++)
- sum += movePoints->points[0][i * 4 + j];
+ sum += movePoints->points[zero][i * 4 + j];
if (playerBestSum < sum)
{
@@ -762,7 +760,7 @@ void TryPutLinkBattleTvShowOnAir(void)
if (species != SPECIES_NONE && !GetMonData(&gEnemyParty[i], MON_DATA_IS_EGG, NULL))
{
for (sum = 0, j = 0; j < MAX_MON_MOVES; j++)
- sum += movePoints->points[1][i * 4 + j];
+ sum += movePoints->points[one][i * 4 + j];
if (opponentBestSum == sum)
{
@@ -784,9 +782,9 @@ void TryPutLinkBattleTvShowOnAir(void)
for (sum = 0, i = 0, j = 0; j < MAX_MON_MOVES; j++)
{
- if (sum < movePoints->points[0][playerBestMonId * 4 + j])
+ if (sum < movePoints->points[zero][playerBestMonId * 4 + j])
{
- sum = movePoints->points[0][playerBestMonId * 4 + j];
+ sum = movePoints->points[zero][playerBestMonId * 4 + j];
i = j;
}
}
@@ -810,333 +808,6 @@ void TryPutLinkBattleTvShowOnAir(void)
}
}
-#else
-NAKED
-void TryPutLinkBattleTvShowOnAir(void)
-{
- asm_unified(
- "push {r4-r7,lr}\n\
- mov r7, r10\n\
- mov r6, r9\n\
- mov r5, r8\n\
- push {r5-r7}\n\
- sub sp, 0x20\n\
- movs r0, 0\n\
- str r0, [sp]\n\
- movs r1, 0\n\
- str r1, [sp, 0x4]\n\
- movs r2, 0\n\
- str r2, [sp, 0x8]\n\
- ldr r3, =0x00007fff\n\
- str r3, [sp, 0xC]\n\
- movs r4, 0\n\
- str r4, [sp, 0x10]\n\
- movs r7, 0\n\
- str r7, [sp, 0x14]\n\
- mov r8, r0\n\
- ldr r0, =gBattleStruct\n\
- ldr r1, [r0]\n\
- adds r0, r1, 0\n\
- adds r0, 0xB3\n\
- ldrb r0, [r0]\n\
- cmp r0, 0\n\
- beq _0817E42A\n\
- b _0817E670\n\
-_0817E42A:\n\
- movs r2, 0xD2\n\
- lsls r2, 1\n\
- adds r2, r1\n\
- mov r10, r2\n\
- movs r6, 0\n\
-_0817E434:\n\
- movs r0, 0x64\n\
- adds r4, r6, 0\n\
- muls r4, r0\n\
- ldr r0, =gPlayerParty\n\
- adds r0, r4, r0\n\
- movs r1, 0xB\n\
- movs r2, 0\n\
- bl GetMonData\n\
- cmp r0, 0\n\
- beq _0817E454\n\
- mov r0, r8\n\
- adds r0, 0x1\n\
- lsls r0, 24\n\
- lsrs r0, 24\n\
- mov r8, r0\n\
-_0817E454:\n\
- ldr r5, =gEnemyParty\n\
- adds r0, r4, r5\n\
- movs r1, 0xB\n\
- movs r2, 0\n\
- bl GetMonData\n\
- cmp r0, 0\n\
- beq _0817E46A\n\
- adds r0, r7, 0x1\n\
- lsls r0, 24\n\
- lsrs r7, r0, 24\n\
-_0817E46A:\n\
- adds r6, 0x1\n\
- cmp r6, 0x5\n\
- ble _0817E434\n\
- ldr r0, =gBattleTypeFlags\n\
- ldr r0, [r0]\n\
- movs r1, 0x2\n\
- ands r0, r1\n\
- cmp r0, 0\n\
- bne _0817E47E\n\
- b _0817E670\n\
-_0817E47E:\n\
- cmp r8, r7\n\
- beq _0817E484\n\
- b _0817E670\n\
-_0817E484:\n\
- movs r6, 0\n\
- lsls r3, r6, 1\n\
- str r3, [sp, 0x18]\n\
- movs r4, 0x64\n\
- mov r8, r4\n\
-_0817E48E:\n\
- mov r1, r8\n\
- muls r1, r6\n\
- ldr r0, =gPlayerParty\n\
- adds r4, r1, r0\n\
- adds r0, r4, 0\n\
- movs r1, 0xB\n\
- movs r2, 0\n\
- bl GetMonData\n\
- lsls r0, 16\n\
- lsrs r7, r0, 16\n\
- adds r0, r6, 0x1\n\
- mov r9, r0\n\
- cmp r7, 0\n\
- beq _0817E4EE\n\
- adds r0, r4, 0\n\
- movs r1, 0x2D\n\
- movs r2, 0\n\
- bl GetMonData\n\
- cmp r0, 0\n\
- bne _0817E4EE\n\
- movs r4, 0\n\
- lsls r0, r6, 3\n\
- mov r2, r10\n\
- adds r1, r0, r2\n\
- movs r3, 0x3\n\
-_0817E4C4:\n\
- lsls r0, r4, 16\n\
- asrs r0, 16\n\
- ldrh r4, [r1]\n\
- adds r0, r4\n\
- lsls r0, 16\n\
- lsrs r4, r0, 16\n\
- adds r1, 0x2\n\
- subs r3, 0x1\n\
- cmp r3, 0\n\
- bge _0817E4C4\n\
- ldr r1, [sp, 0x8]\n\
- lsls r0, r1, 16\n\
- lsls r1, r4, 16\n\
- cmp r0, r1\n\
- bge _0817E4EE\n\
- lsls r0, r6, 24\n\
- lsrs r0, 24\n\
- str r0, [sp, 0x10]\n\
- lsrs r1, 16\n\
- str r1, [sp, 0x8]\n\
- str r7, [sp]\n\
-_0817E4EE:\n\
- mov r0, r8\n\
- muls r0, r6\n\
- ldr r2, =gEnemyParty\n\
- adds r4, r0, r2\n\
- adds r0, r4, 0\n\
- movs r1, 0xB\n\
- movs r2, 0\n\
- bl GetMonData\n\
- lsls r0, 16\n\
- lsrs r7, r0, 16\n\
- ldr r3, [sp, 0x8]\n\
- lsls r3, 16\n\
- str r3, [sp, 0x1C]\n\
- cmp r7, 0\n\
- beq _0817E5A0\n\
- adds r0, r4, 0\n\
- movs r1, 0x2D\n\
- movs r2, 0\n\
- bl GetMonData\n\
- cmp r0, 0\n\
- bne _0817E5A0\n\
- movs r4, 0\n\
- ldr r0, [sp, 0xC]\n\
- lsls r2, r0, 16\n\
- movs r3, 0x1\n\
- lsls r1, r3, 1\n\
- adds r1, 0x1\n\
- lsls r1, 4\n\
- lsls r0, r6, 3\n\
- adds r0, r1\n\
- mov r3, r10\n\
- adds r1, r0, r3\n\
- movs r3, 0x3\n\
-_0817E534:\n\
- lsls r0, r4, 16\n\
- asrs r0, 16\n\
- ldrh r4, [r1]\n\
- adds r0, r4\n\
- lsls r0, 16\n\
- lsrs r4, r0, 16\n\
- adds r1, 0x2\n\
- subs r3, 0x1\n\
- cmp r3, 0\n\
- bge _0817E534\n\
- asrs r1, r2, 16\n\
- lsls r5, r4, 16\n\
- asrs r0, r5, 16\n\
- cmp r1, r0\n\
- bne _0817E590\n\
- mov r0, r8\n\
- muls r0, r6\n\
- ldr r1, =gEnemyParty\n\
- adds r0, r1\n\
- movs r1, 0x19\n\
- movs r2, 0\n\
- bl GetMonData\n\
- adds r4, r0, 0\n\
- ldr r2, [sp, 0x14]\n\
- mov r0, r8\n\
- muls r0, r2\n\
- ldr r3, =gEnemyParty\n\
- adds r0, r3\n\
- movs r1, 0x19\n\
- movs r2, 0\n\
- bl GetMonData\n\
- cmp r4, r0\n\
- bls _0817E5A0\n\
- b _0817E594\n\
- .pool\n\
-_0817E590:\n\
- cmp r1, r0\n\
- ble _0817E5A0\n\
-_0817E594:\n\
- lsls r0, r6, 24\n\
- lsrs r0, 24\n\
- str r0, [sp, 0x14]\n\
- lsrs r5, 16\n\
- str r5, [sp, 0xC]\n\
- str r7, [sp, 0x4]\n\
-_0817E5A0:\n\
- mov r6, r9\n\
- cmp r6, 0x5\n\
- bgt _0817E5A8\n\
- b _0817E48E\n\
-_0817E5A8:\n\
- movs r4, 0\n\
- movs r6, 0\n\
- movs r3, 0\n\
- ldr r5, =gPlayerParty\n\
- ldr r7, [sp, 0x10]\n\
- lsls r0, r7, 3\n\
- mov r1, r10\n\
- adds r2, r0, r1\n\
-_0817E5B8:\n\
- lsls r0, r4, 16\n\
- asrs r0, 16\n\
- movs r7, 0\n\
- ldrsh r1, [r2, r7]\n\
- cmp r0, r1\n\
- bge _0817E5C8\n\
- ldrh r4, [r2]\n\
- adds r6, r3, 0\n\
-_0817E5C8:\n\
- adds r2, 0x2\n\
- adds r3, 0x1\n\
- cmp r3, 0x3\n\
- ble _0817E5B8\n\
- movs r0, 0x64\n\
- ldr r1, [sp, 0x10]\n\
- muls r0, r1\n\
- adds r0, r5\n\
- adds r1, r6, 0\n\
- adds r1, 0xD\n\
- movs r2, 0\n\
- bl GetMonData\n\
- lsls r0, 16\n\
- lsrs r4, r0, 16\n\
- ldr r2, [sp, 0x1C]\n\
- cmp r2, 0\n\
- beq _0817E670\n\
- cmp r4, 0\n\
- beq _0817E670\n\
- ldr r0, =gBattleTypeFlags\n\
- ldr r0, [r0]\n\
- movs r1, 0x40\n\
- ands r0, r1\n\
- cmp r0, 0\n\
- beq _0817E65C\n\
- ldr r3, [sp, 0x10]\n\
- cmp r3, 0x2\n\
- bhi _0817E620\n\
- ldr r0, =gBattleScripting\n\
- adds r0, 0x25\n\
- ldrb r0, [r0]\n\
- bl GetLinkTrainerFlankId\n\
- lsls r0, 16\n\
- cmp r0, 0\n\
- beq _0817E630\n\
- b _0817E670\n\
- .pool\n\
-_0817E620:\n\
- ldr r0, =gBattleScripting\n\
- adds r0, 0x25\n\
- ldrb r0, [r0]\n\
- bl GetLinkTrainerFlankId\n\
- lsls r0, 16\n\
- cmp r0, 0\n\
- beq _0817E670\n\
-_0817E630:\n\
- movs r3, 0\n\
- ldr r7, [sp, 0x14]\n\
- cmp r7, 0x2\n\
- bls _0817E63A\n\
- movs r3, 0x1\n\
-_0817E63A:\n\
- lsls r0, r3, 24\n\
- lsrs r0, 24\n\
- ldr r1, =gBattleScripting\n\
- adds r1, 0x25\n\
- ldrb r1, [r1]\n\
- bl sub_806EF84\n\
- lsls r0, 24\n\
- lsrs r0, 24\n\
- adds r1, r4, 0\n\
- ldr r2, [sp]\n\
- ldr r3, [sp, 0x4]\n\
- bl PutBattleUpdateOnTheAir\n\
- b _0817E670\n\
- .pool\n\
-_0817E65C:\n\
- ldr r0, =gBattleScripting\n\
- adds r0, 0x25\n\
- ldrb r1, [r0]\n\
- movs r0, 0x1\n\
- eors r0, r1\n\
- adds r1, r4, 0\n\
- ldr r2, [sp]\n\
- ldr r3, [sp, 0x4]\n\
- bl PutBattleUpdateOnTheAir\n\
-_0817E670:\n\
- add sp, 0x20\n\
- pop {r3-r5}\n\
- mov r8, r3\n\
- mov r9, r4\n\
- mov r10, r5\n\
- pop {r4-r7}\n\
- pop {r0}\n\
- bx r0\n\
- .pool");
-}
-#endif
-
static void AddMovePoints(u8 caseId, u16 arg1, u8 arg2, u8 arg3)
{
struct BattleTvMovePoints *movePoints = &gBattleStruct->tvMovePoints;
diff --git a/src/berry_crush.c b/src/berry_crush.c
index d753e603c..dbbbd20fc 100755
--- a/src/berry_crush.c
+++ b/src/berry_crush.c
@@ -1665,7 +1665,7 @@ static void Task_ShowBerryCrushRankings(u8 taskId)
CopyWindowToVram(data[1], 3);
break;
case 2:
- if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ if (JOY_NEW(A_BUTTON | B_BUTTON))
break;
else
return;
@@ -2498,9 +2498,9 @@ void sub_8023558(struct BerryCrushGame *r3)
void sub_80236B8(struct BerryCrushGame *r5)
{
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
r5->unk5C.unk02_2 = 1;
- if (gMain.heldKeys & A_BUTTON)
+ if (JOY_HELD(A_BUTTON))
{
if (r5->unk68.as_four_players.others[r5->unk8].unk4.as_hwords[5] < r5->unk28)
++r5->unk68.as_four_players.others[r5->unk8].unk4.as_hwords[5];
@@ -2966,7 +2966,7 @@ static u32 sub_8024048(struct BerryCrushGame *r5, u8 *r6)
--r5->unk138.unk0;
return 0;
}
- if (!(gMain.newKeys & A_BUTTON))
+ if (!(JOY_NEW(A_BUTTON)))
return 0;
PlaySE(SE_SELECT);
sub_802222C(r5);
diff --git a/src/berry_fix_program.c b/src/berry_fix_program.c
index dcc21d036..4c4a010b2 100644
--- a/src/berry_fix_program.c
+++ b/src/berry_fix_program.c
@@ -190,13 +190,13 @@ static void berry_fix_main(void)
berry_fix_mb_manager->state = 1;
break;
case 1:
- if (berry_fix_text_update(5) == 5 && (gMain.newKeys & A_BUTTON))
+ if (berry_fix_text_update(5) == 5 && (JOY_NEW(A_BUTTON)))
{
berry_fix_mb_manager->state = 2;
}
break;
case 2:
- if (berry_fix_text_update(0) == 0 && (gMain.newKeys & A_BUTTON))
+ if (berry_fix_text_update(0) == 0 && (JOY_NEW(A_BUTTON)))
{
berry_fix_mb_manager->state = 3;
}
@@ -235,13 +235,13 @@ static void berry_fix_main(void)
}
break;
case 6:
- if (berry_fix_text_update(3) == 3 && gMain.newKeys & A_BUTTON)
+ if (berry_fix_text_update(3) == 3 && JOY_NEW(A_BUTTON))
{
DoSoftReset();
}
break;
case 7:
- if (berry_fix_text_update(4) == 4 && gMain.newKeys & A_BUTTON)
+ if (berry_fix_text_update(4) == 4 && JOY_NEW(A_BUTTON))
{
berry_fix_mb_manager->state = 1;
}
diff --git a/src/berry_tag_screen.c b/src/berry_tag_screen.c
index e5c89bdb7..089228b17 100644
--- a/src/berry_tag_screen.c
+++ b/src/berry_tag_screen.c
@@ -536,12 +536,12 @@ static void Task_HandleInput(u8 taskId)
{
if (!gPaletteFade.active)
{
- u16 arrowKeys = gMain.newAndRepeatedKeys & DPAD_ANY;
+ u16 arrowKeys = JOY_REPEAT(DPAD_ANY);
if (arrowKeys == DPAD_UP)
TryChangeDisplayedBerry(taskId, -1);
else if (arrowKeys == DPAD_DOWN)
TryChangeDisplayedBerry(taskId, 1);
- else if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ else if (JOY_NEW(A_BUTTON | B_BUTTON))
PrepareToCloseBerryTagScreen(taskId);
}
}
diff --git a/src/cable_club.c b/src/cable_club.c
index 93f87ec9b..f02683c9d 100644
--- a/src/cable_club.c
+++ b/src/cable_club.c
@@ -163,7 +163,7 @@ static bool32 CheckLinkErrored(u8 taskId)
static bool32 CheckLinkCanceledBeforeConnection(u8 taskId)
{
- if ((gMain.newKeys & B_BUTTON)
+ if ((JOY_NEW(B_BUTTON))
&& IsLinkConnectionEstablished() == FALSE)
{
gLinkType = 0;
@@ -178,7 +178,7 @@ static bool32 CheckLinkCanceled(u8 taskId)
if (IsLinkConnectionEstablished())
SetSuppressLinkErrorMessage(TRUE);
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
gLinkType = 0;
gTasks[taskId].func = Task_LinkupFailed;
@@ -277,7 +277,7 @@ static void Task_LinkupAwaitConfirmation(u8 taskId)
UpdateLinkPlayerCountDisplay(taskId, linkPlayerCount);
- if (!(gMain.newKeys & A_BUTTON))
+ if (!(JOY_NEW(A_BUTTON)))
return;
if (linkPlayerCount < tMinPlayers)
@@ -304,12 +304,12 @@ static void Task_LinkupTryConfirmation(u8 taskId)
ShowFieldAutoScrollMessage(gText_ConfirmLinkWhenPlayersReady);
gTasks[taskId].func = Task_LinkupConfirmWhenReady;
}
- else if (gMain.heldKeys & B_BUTTON)
+ else if (JOY_HELD(B_BUTTON))
{
ShowFieldAutoScrollMessage(gText_ConfirmLinkWhenPlayersReady);
gTasks[taskId].func = Task_LinkupConfirmWhenReady;
}
- else if (gMain.heldKeys & A_BUTTON)
+ else if (JOY_HELD(A_BUTTON))
{
PlaySE(SE_SELECT);
CheckShouldAdvanceLinkState();
diff --git a/src/contest.c b/src/contest.c
index a84d72aa9..612d79562 100644
--- a/src/contest.c
+++ b/src/contest.c
@@ -1493,7 +1493,7 @@ static void Task_DisplayAppealNumberText(u8 taskId)
static void Task_TryShowMoveSelectScreen(u8 taskId)
{
// Wait for button press to show move select screen
- if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys == B_BUTTON))
+ if ((JOY_NEW(A_BUTTON)) || (gMain.newKeys == B_BUTTON))
{
PlaySE(SE_SELECT);
if (!Contest_IsMonsTurnDisabled(gContestPlayerMonIndex))
@@ -1559,7 +1559,7 @@ static void Task_HandleMoveSelectInput(u8 taskId)
numMoves++;
}
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
gTasks[taskId].func = Task_SelectedMove;
@@ -4137,12 +4137,12 @@ static u8 CreateContestantBoxBlinkSprites(u8 contestant)
CpuFill32(0, gContestResources->boxBlinkTiles2 + 0x500, 0x300);
RequestDma3Copy(gContestResources->boxBlinkTiles1,
- (u8 *)(VRAM + 0x10000 + gSprites[spriteId1].oam.tileNum * 32),
+ (u8 *)(OBJ_VRAM0 + gSprites[spriteId1].oam.tileNum * 32),
0x800,
1);
RequestDma3Copy(gContestResources->boxBlinkTiles2,
- (u8 *)(VRAM + 0x10000 + gSprites[spriteId2].oam.tileNum * 32),
+ (u8 *)(OBJ_VRAM0 + gSprites[spriteId2].oam.tileNum * 32),
0x800,
1);
@@ -4728,8 +4728,8 @@ static void UpdateApplauseMeter(void)
src = &gContestApplauseMeterGfx[64];
else
src = gContestApplauseMeterGfx;
- CpuCopy32(src, (void *)(VRAM + 0x10000 + (gSprites[eContest.applauseMeterSpriteId].oam.tileNum + 17 + i) * 32), 32);
- CpuCopy32(src + 32, (void *)(VRAM + 0x10000 + (gSprites[eContest.applauseMeterSpriteId].oam.tileNum + 25 + i) * 32), 32);
+ CpuCopy32(src, (void *)(OBJ_VRAM0 + (gSprites[eContest.applauseMeterSpriteId].oam.tileNum + 17 + i) * 32), 32);
+ CpuCopy32(src + 32, (void *)(OBJ_VRAM0 + (gSprites[eContest.applauseMeterSpriteId].oam.tileNum + 25 + i) * 32), 32);
if (eContest.applauseLevel > 4)
StartApplauseOverflowAnimation();
diff --git a/src/contest_painting.c b/src/contest_painting.c
index a0c39dfc7..292b11bf4 100644
--- a/src/contest_painting.c
+++ b/src/contest_painting.c
@@ -248,7 +248,7 @@ static void HoldContestPainting(void)
gContestPaintingFadeCounter--;
break;
case 1:
- if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON))
+ if ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON)))
{
gContestPaintingState++;
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0));
diff --git a/src/contest_util.c b/src/contest_util.c
index 123d3e8eb..ae76eda6b 100644
--- a/src/contest_util.c
+++ b/src/contest_util.c
@@ -1148,350 +1148,71 @@ static void TryCreateWirelessSprites(void)
}
}
-// Functionally equivalent, the same except compiler generated variables from
-// src are placed on different stack positions.
-
-#ifdef NONMATCHING
static s32 DrawResultsTextWindow(const u8 *text, u8 spriteId)
{
- u8 *windowTilesPtr;
u16 windowId;
- int origWidth;
- struct WindowTemplate windowTemplate;
- int strWidth;
+ s32 origWidth, strWidth;
u8 *spriteTilePtrs[4];
u8 *dst;
- int i;
- struct Sprite *sprite;
- const u8 *src; // The culprit.
- memset(&windowTemplate, 0, sizeof(windowTemplate));
- windowTemplate.width = 30;
- windowTemplate.height = 2;
- windowId = AddWindow(&windowTemplate);
- FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
+ {
+ struct WindowTemplate windowTemplate; //It's important the lifetime of this struct ends after the clear
+ memset(&windowTemplate, 0, sizeof(windowTemplate));
+ windowTemplate.width = 30;
+ windowTemplate.height = 2;
+ windowId = AddWindow(&windowTemplate);
+ FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
+ }
origWidth = GetStringWidth(1, text, 0);
- strWidth = (origWidth + 9) / 8;
- if (strWidth > 30)
- strWidth = 30;
+ if ((strWidth = (origWidth + 9) / 8) > 30)
+ strWidth = 30;
AddTextPrinterParameterized3(windowId, 1, (strWidth * 8 - origWidth) / 2, 1, sContestLinkTextColors, -1, text);
- windowTilesPtr = (u8 *)(GetWindowAttribute(windowId, WINDOW_TILE_DATA));
- src = (u8 *)(sUnknown_0858D6D0);
- sprite = &gSprites[spriteId];
- spriteTilePtrs[0] = (u8 *)(sprite->oam.tileNum * 32 + VRAM + 0x10000);
+ {
+ s32 i;
+ struct Sprite *sprite;
+ const u8 *src, *windowTilesPtr;
+ windowTilesPtr = (const u8 *)(GetWindowAttribute(windowId, WINDOW_TILE_DATA));
+ src = sUnknown_0858D6D0;
+
+ sprite = &gSprites[spriteId];
+ spriteTilePtrs[0] = (u8 *)((OBJ_VRAM0) + sprite->oam.tileNum * 32);
- for (i = 1; i < 4; i++)
- spriteTilePtrs[i] = (void*)(gSprites[sprite->data[i - 1]].oam.tileNum * 32 + VRAM + 0x10000);
+ for (i = 1; i < 4; i++)
+ spriteTilePtrs[i] = (u8 *)((OBJ_VRAM0) + gSprites[sprite->data[i - 1]].oam.tileNum * 32);
- for (i = 0; i < 4; i++)
- CpuFill32(0, spriteTilePtrs[i], 0x400);
+ for (i = 0; i < 4; i++)
+ CpuFill32(0, spriteTilePtrs[i], 0x400);
- dst = spriteTilePtrs[0];
- CpuCopy32(src, dst, 0x20);
- CpuCopy32(src + 128, dst + 0x100, 0x20);
- CpuCopy32(src + 128, dst + 0x200, 0x20);
- CpuCopy32(src + 64, dst + 0x300, 0x20);
+ dst = spriteTilePtrs[0];
+ CpuCopy32(src, dst, 0x20);
+ CpuCopy32(src + 128, dst + 0x100, 0x20);
+ CpuCopy32(src + 128, dst + 0x200, 0x20);
+ CpuCopy32(src + 64, dst + 0x300, 0x20);
+
+ for (i = 0; i < strWidth; i++)
+ {
+ dst = &spriteTilePtrs[(i + 1) / 8][((i + 1) % 8) * 32];
+ CpuCopy32(src + 192, dst, 0x20);
+ CpuCopy32(windowTilesPtr, dst + 0x100, 0x20);
+ CpuCopy32(windowTilesPtr + 960, dst + 0x200, 0x20);
+ CpuCopy32(src + 224, dst + 0x300, 0x20);
+ windowTilesPtr += 0x20;
+ }
- for (i = 0; i < strWidth; i++)
- {
dst = &spriteTilePtrs[(i + 1) / 8][((i + 1) % 8) * 32];
- CpuCopy32(src + 192, dst, 0x20);
- CpuCopy32(windowTilesPtr, dst + 0x100, 0x20);
- CpuCopy32(windowTilesPtr + 960, dst + 0x200, 0x20);
- CpuCopy32(src + 224, dst + 0x300, 0x20);
- windowTilesPtr += 0x20;
- }
-
- dst = &spriteTilePtrs[(i + 1) / 8][((i + 1) % 8) * 32];
- CpuCopy32(src + 32, dst, 0x20);
- CpuCopy32(src + 160, dst + 0x100, 0x20);
- CpuCopy32(src + 160, dst + 0x200, 0x20);
- CpuCopy32(src + 96, dst + 0x300, 0x20);
+ CpuCopy32(src + 32, dst, 0x20);
+ CpuCopy32(src + 160, dst + 0x100, 0x20);
+ CpuCopy32(src + 160, dst + 0x200, 0x20);
+ CpuCopy32(src + 96, dst + 0x300, 0x20);
+ }
RemoveWindow(windowId);
return (240 - (strWidth + 2) * 8) / 2;
}
-#else
-NAKED
-static s32 DrawResultsTextWindow(const u8 *text, u8 spriteId)
-{
- asm_unified(
- "push {r4-r7,lr}\n\
- mov r7, r10\n\
- mov r6, r9\n\
- mov r5, r8\n\
- push {r5-r7}\n\
- sub sp, 0x44\n\
- adds r5, r0, 0\n\
- lsls r1, 24\n\
- lsrs r7, r1, 24\n\
- add r4, sp, 0x20\n\
- adds r0, r4, 0\n\
- movs r1, 0\n\
- movs r2, 0x8\n\
- bl memset\n\
- movs r0, 0x1E\n\
- strb r0, [r4, 0x3]\n\
- movs r0, 0x2\n\
- strb r0, [r4, 0x4]\n\
- adds r0, r4, 0\n\
- bl AddWindow\n\
- lsls r6, r0, 24\n\
- lsrs r4, r6, 24\n\
- adds r0, r4, 0\n\
- movs r1, 0x11\n\
- bl FillWindowPixelBuffer\n\
- movs r0, 0x1\n\
- adds r1, r5, 0\n\
- movs r2, 0\n\
- bl GetStringWidth\n\
- adds r2, r0, 0\n\
- adds r2, 0x9\n\
- cmp r2, 0\n\
- bge _080F6BC4\n\
- adds r2, 0x7\n\
-_080F6BC4:\n\
- asrs r2, 3\n\
- mov r10, r2\n\
- cmp r2, 0x1E\n\
- ble _080F6BD0\n\
- movs r1, 0x1E\n\
- mov r10, r1\n\
-_080F6BD0:\n\
- mov r1, r10\n\
- lsls r2, r1, 3\n\
- subs r2, r0\n\
- lsrs r0, r2, 31\n\
- adds r2, r0\n\
- asrs r2, 1\n\
- lsls r2, 24\n\
- lsrs r2, 24\n\
- ldr r0, =sContestLinkTextColors\n\
- str r0, [sp]\n\
- movs r0, 0x1\n\
- negs r0, r0\n\
- str r0, [sp, 0x4]\n\
- str r5, [sp, 0x8]\n\
- adds r0, r4, 0\n\
- movs r1, 0x1\n\
- movs r3, 0x1\n\
- bl AddTextPrinterParameterized3\n\
- adds r0, r4, 0\n\
- movs r1, 0x7\n\
- bl GetWindowAttribute\n\
- mov r9, r0\n\
- ldr r2, =sUnknown_0858D6D0\n\
- mov r8, r2\n\
- lsls r1, r7, 4\n\
- adds r1, r7\n\
- lsls r1, 2\n\
- ldr r3, =gSprites\n\
- adds r1, r3\n\
- ldrh r0, [r1, 0x4]\n\
- lsls r0, 22\n\
- lsrs r0, 17\n\
- ldr r2, =0x06010000\n\
- adds r0, r2\n\
- str r0, [sp, 0xC]\n\
- str r6, [sp, 0x38]\n\
- mov r7, sp\n\
- adds r7, 0x1C\n\
- str r7, [sp, 0x2C]\n\
- mov r0, r10\n\
- adds r0, 0x2\n\
- str r0, [sp, 0x30]\n\
- movs r5, 0\n\
- add r7, sp, 0x10\n\
- mov r12, r7\n\
- adds r6, r1, 0\n\
- adds r6, 0x2E\n\
- movs r4, 0x2\n\
-_080F6C34:\n\
- adds r0, r6, r5\n\
- movs r7, 0\n\
- ldrsh r1, [r0, r7]\n\
- lsls r0, r1, 4\n\
- adds r0, r1\n\
- lsls r0, 2\n\
- adds r0, r3\n\
- ldrh r0, [r0, 0x4]\n\
- lsls r0, 22\n\
- lsrs r0, 17\n\
- adds r0, r2\n\
- mov r1, r12\n\
- adds r1, 0x4\n\
- mov r12, r1\n\
- subs r1, 0x4\n\
- stm r1!, {r0}\n\
- adds r5, 0x2\n\
- subs r4, 0x1\n\
- cmp r4, 0\n\
- bge _080F6C34\n\
- mov r7, r8\n\
- adds r7, 0x80\n\
- mov r2, r8\n\
- adds r2, 0x40\n\
- str r2, [sp, 0x28]\n\
- mov r0, r8\n\
- adds r0, 0x20\n\
- str r0, [sp, 0x3C]\n\
- mov r1, r8\n\
- adds r1, 0xA0\n\
- str r1, [sp, 0x40]\n\
- adds r2, 0x20\n\
- str r2, [sp, 0x34]\n\
- add r5, sp, 0xC\n\
- movs r6, 0\n\
- movs r4, 0x3\n\
-_080F6C7C:\n\
- str r6, [sp, 0x1C]\n\
- ldm r5!, {r1}\n\
- ldr r0, [sp, 0x2C]\n\
- ldr r2, =0x05000100\n\
- bl CpuSet\n\
- subs r4, 0x1\n\
- cmp r4, 0\n\
- bge _080F6C7C\n\
- ldr r5, [sp, 0xC]\n\
- ldr r6, =0x04000008\n\
- mov r0, r8\n\
- adds r1, r5, 0\n\
- adds r2, r6, 0\n\
- bl CpuSet\n\
- movs r0, 0x80\n\
- lsls r0, 1\n\
- adds r1, r5, r0\n\
- adds r0, r7, 0\n\
- adds r2, r6, 0\n\
- bl CpuSet\n\
- movs r2, 0x80\n\
- lsls r2, 2\n\
- adds r1, r5, r2\n\
- adds r0, r7, 0\n\
- adds r2, r6, 0\n\
- bl CpuSet\n\
- movs r7, 0xC0\n\
- lsls r7, 2\n\
- adds r1, r5, r7\n\
- ldr r0, [sp, 0x28]\n\
- adds r2, r6, 0\n\
- bl CpuSet\n\
- movs r4, 0\n\
- cmp r4, r10\n\
- bge _080F6D32\n\
- adds r7, r6, 0\n\
-_080F6CCE:\n\
- adds r6, r4, 0x1\n\
- adds r0, r6, 0\n\
- cmp r6, 0\n\
- bge _080F6CDA\n\
- adds r0, r4, 0\n\
- adds r0, 0x8\n\
-_080F6CDA:\n\
- asrs r0, 3\n\
- lsls r1, r0, 2\n\
- add r1, sp\n\
- adds r1, 0xC\n\
- lsls r0, 3\n\
- subs r0, r6, r0\n\
- lsls r0, 5\n\
- ldr r1, [r1]\n\
- adds r5, r1, r0\n\
- mov r0, r8\n\
- adds r0, 0xC0\n\
- adds r1, r5, 0\n\
- adds r2, r7, 0\n\
- bl CpuSet\n\
- movs r0, 0x80\n\
- lsls r0, 1\n\
- adds r1, r5, r0\n\
- mov r0, r9\n\
- adds r2, r7, 0\n\
- bl CpuSet\n\
- movs r0, 0xF0\n\
- lsls r0, 2\n\
- add r0, r9\n\
- movs r2, 0x80\n\
- lsls r2, 2\n\
- adds r1, r5, r2\n\
- adds r2, r7, 0\n\
- bl CpuSet\n\
- movs r0, 0xC0\n\
- lsls r0, 2\n\
- adds r1, r5, r0\n\
- mov r0, r8\n\
- adds r0, 0xE0\n\
- adds r2, r7, 0\n\
- bl CpuSet\n\
- movs r1, 0x20\n\
- add r9, r1\n\
- adds r4, r6, 0\n\
- cmp r4, r10\n\
- blt _080F6CCE\n\
-_080F6D32:\n\
- adds r2, r4, 0x1\n\
- adds r0, r2, 0\n\
- cmp r2, 0\n\
- bge _080F6D3E\n\
- adds r0, r4, 0\n\
- adds r0, 0x8\n\
-_080F6D3E:\n\
- asrs r0, 3\n\
- lsls r1, r0, 2\n\
- add r1, sp\n\
- adds r1, 0xC\n\
- lsls r0, 3\n\
- subs r0, r2, r0\n\
- lsls r0, 5\n\
- ldr r1, [r1]\n\
- adds r5, r1, r0\n\
- ldr r4, =0x04000008\n\
- ldr r0, [sp, 0x3C]\n\
- adds r1, r5, 0\n\
- adds r2, r4, 0\n\
- bl CpuSet\n\
- movs r2, 0x80\n\
- lsls r2, 1\n\
- adds r1, r5, r2\n\
- ldr r0, [sp, 0x40]\n\
- adds r2, r4, 0\n\
- bl CpuSet\n\
- movs r7, 0x80\n\
- lsls r7, 2\n\
- adds r1, r5, r7\n\
- ldr r0, [sp, 0x40]\n\
- adds r2, r4, 0\n\
- bl CpuSet\n\
- movs r0, 0xC0\n\
- lsls r0, 2\n\
- adds r1, r5, r0\n\
- ldr r0, [sp, 0x34]\n\
- adds r2, r4, 0\n\
- bl CpuSet\n\
- ldr r1, [sp, 0x38]\n\
- lsrs r0, r1, 24\n\
- bl RemoveWindow\n\
- ldr r2, [sp, 0x30]\n\
- lsls r1, r2, 3\n\
- movs r0, 0xF0\n\
- subs r0, r1\n\
- asrs r0, 1\n\
- add sp, 0x44\n\
- pop {r3-r5}\n\
- mov r8, r3\n\
- mov r9, r4\n\
- mov r10, r5\n\
- pop {r4-r7}\n\
- pop {r1}\n\
- bx r1\n\
- .pool");
-}
-#endif // NONMATCHING
-
static void LoadContestResultSprites(void)
{
int i;
diff --git a/src/credits.c b/src/credits.c
index 5f331097b..86a659d5a 100644
--- a/src/credits.c
+++ b/src/credits.c
@@ -1143,7 +1143,7 @@ static void CB2_RunCreditsSequence(void)
RunTasks();
AnimateSprites();
- if ((gMain.heldKeys & B_BUTTON)
+ if ((JOY_HELD(B_BUTTON))
&& gHasHallOfFameRecords != 0
&& gTasks[gUnknown_0203BCE2].func == Task_ProgressCreditTasks)
{
diff --git a/src/daycare.c b/src/daycare.c
index b87c326e9..69043a513 100644
--- a/src/daycare.c
+++ b/src/daycare.c
@@ -1237,7 +1237,7 @@ static void Task_HandleDaycareLevelMenuInput(u8 taskId)
{
u32 input = ListMenu_ProcessInput(gTasks[taskId].tMenuListTaskId);
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
switch (input)
{
@@ -1255,7 +1255,7 @@ static void Task_HandleDaycareLevelMenuInput(u8 taskId)
DestroyTask(taskId);
EnableBothScriptContexts();
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
gSpecialVar_Result = DAYCARE_EXITED_LEVEL_MENU;
DestroyListMenuTask(gTasks[taskId].tMenuListTaskId, NULL, NULL);
diff --git a/src/decoration.c b/src/decoration.c
index 40cccbe5e..22ae327f9 100644
--- a/src/decoration.c
+++ b/src/decoration.c
@@ -1147,7 +1147,7 @@ static void DontTossDecoration(u8 taskId)
static void ReturnToDecorationItemsAfterInvalidSelection(u8 taskId)
{
- if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ if (JOY_NEW(A_BUTTON | B_BUTTON))
{
ClearDialogWindowAndFrame(0, 0);
AddDecorationWindow(WINDOW_DECORATION_CATEGORIES);
@@ -1803,7 +1803,7 @@ static bool8 ApplyCursorMovement_IsInvalid(u8 taskId)
static bool8 IsHoldingDirection(void)
{
- u16 heldKeys = gMain.heldKeys & DPAD_ANY;
+ u16 heldKeys = JOY_HELD(DPAD_ANY);
if (heldKeys != DPAD_UP && heldKeys != DPAD_DOWN && heldKeys != DPAD_LEFT && heldKeys != DPAD_RIGHT)
return FALSE;
@@ -1827,13 +1827,14 @@ static void Task_SelectLocation(u8 taskId)
sPlacePutAwayYesNoFunctions[tDecorationItemsMenuCommand].yesFunc(taskId);
return;
}
- else if (tButton == B_BUTTON)
+
+ if (tButton == B_BUTTON)
{
sPlacePutAwayYesNoFunctions[tDecorationItemsMenuCommand].noFunc(taskId);
return;
}
- if ((gMain.heldKeys & DPAD_ANY) == DPAD_UP)
+ if ((JOY_HELD(DPAD_ANY)) == DPAD_UP)
{
sDecorationLastDirectionMoved = DIR_SOUTH;
gSprites[sDecor_CameraSpriteObjectIdx1].data[2] = 0;
@@ -1841,7 +1842,7 @@ static void Task_SelectLocation(u8 taskId)
tCursorY--;
}
- if ((gMain.heldKeys & DPAD_ANY) == DPAD_DOWN)
+ if ((JOY_HELD(DPAD_ANY)) == DPAD_DOWN)
{
sDecorationLastDirectionMoved = DIR_NORTH;
gSprites[sDecor_CameraSpriteObjectIdx1].data[2] = 0;
@@ -1849,7 +1850,7 @@ static void Task_SelectLocation(u8 taskId)
tCursorY++;
}
- if ((gMain.heldKeys & DPAD_ANY) == DPAD_LEFT)
+ if ((JOY_HELD(DPAD_ANY)) == DPAD_LEFT)
{
sDecorationLastDirectionMoved = DIR_WEST;
gSprites[sDecor_CameraSpriteObjectIdx1].data[2] = -2;
@@ -1857,7 +1858,7 @@ static void Task_SelectLocation(u8 taskId)
tCursorX--;
}
- if ((gMain.heldKeys & DPAD_ANY) == DPAD_RIGHT)
+ if ((JOY_HELD(DPAD_ANY)) == DPAD_RIGHT)
{
sDecorationLastDirectionMoved = DIR_EAST;
gSprites[sDecor_CameraSpriteObjectIdx1].data[2] = 2;
@@ -1877,10 +1878,10 @@ static void Task_SelectLocation(u8 taskId)
if (!tButton)
{
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
tButton = A_BUTTON;
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
tButton = B_BUTTON;
}
}
@@ -1895,7 +1896,7 @@ static void ContinueDecorating(u8 taskId)
static void CantPlaceDecorationPrompt(u8 taskId)
{
- if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON))
ContinueDecorating(taskId);
}
@@ -1928,7 +1929,7 @@ static void CopyTile(u8 *dest, u16 tile)
case BG_TILE_H_FLIP(0) >> 10:
for (i = 0; i < 8; i++)
{
- dest[4 * i] = (buffer[4 * (i + 1) - 1] >> 4) + ((buffer[4 * (i + 1) - 1] & 0x0F) << 4);
+ dest[4 * i + 0] = (buffer[4 * (i + 1) - 1] >> 4) + ((buffer[4 * (i + 1) - 1] & 0x0F) << 4);
dest[4 * i + 1] = (buffer[4 * (i + 1) - 2] >> 4) + ((buffer[4 * (i + 1) - 2] & 0x0F) << 4);
dest[4 * i + 2] = (buffer[4 * (i + 1) - 3] >> 4) + ((buffer[4 * (i + 1) - 3] & 0x0F) << 4);
dest[4 * i + 3] = (buffer[4 * (i + 1) - 4] >> 4) + ((buffer[4 * (i + 1) - 4] & 0x0F) << 4);
@@ -1937,7 +1938,7 @@ static void CopyTile(u8 *dest, u16 tile)
case BG_TILE_V_FLIP(0) >> 10:
for (i = 0; i < 8; i++)
{
- dest[4 * i] = buffer[4 * (7 - i)];
+ dest[4 * i + 0] = buffer[4 * (7 - i) + 0];
dest[4 * i + 1] = buffer[4 * (7 - i) + 1];
dest[4 * i + 2] = buffer[4 * (7 - i) + 2];
dest[4 * i + 3] = buffer[4 * (7 - i) + 3];
@@ -2386,7 +2387,7 @@ static void AttemptPutAwayDecoration_(u8 taskId)
static void ContinuePuttingAwayDecorationsPrompt(u8 taskId)
{
- if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON))
ContinuePuttingAwayDecorations(taskId);
}
diff --git a/src/diploma.c b/src/diploma.c
index 7eb3b0e81..f243d09f9 100644
--- a/src/diploma.c
+++ b/src/diploma.c
@@ -107,7 +107,7 @@ static void Task_DiplomaFadeIn(u8 taskId)
static void Task_DiplomaWaitForKeyPress(u8 taskId)
{
- if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ if (JOY_NEW(A_BUTTON | B_BUTTON))
{
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
gTasks[taskId].func = Task_DiplomaFadeOut;
diff --git a/src/dodrio_berry_picking.c b/src/dodrio_berry_picking.c
index 34f73126b..9cbc73c73 100644
--- a/src/dodrio_berry_picking.c
+++ b/src/dodrio_berry_picking.c
@@ -2355,19 +2355,19 @@ static void sub_8027554(void)
{
if (gUnknown_02022C98->unkB0[gUnknown_02022C98->multiplayerId] == 0)
{
- if (gMain.newKeys & DPAD_UP)
+ if (JOY_NEW(DPAD_UP))
{
gUnknown_02022C98->unk31A0[gUnknown_02022C98->multiplayerId].unk2C.unk0 = 2;
gUnknown_02022C98->unkB0[gUnknown_02022C98->multiplayerId] = 6;
PlaySE(SE_M_CHARM);
}
- else if (gMain.newKeys & DPAD_LEFT)
+ else if (JOY_NEW(DPAD_LEFT))
{
gUnknown_02022C98->unk31A0[gUnknown_02022C98->multiplayerId].unk2C.unk0 = 3;
gUnknown_02022C98->unkB0[gUnknown_02022C98->multiplayerId] = 6;
PlaySE(SE_M_CHARM);
}
- else if (gMain.newKeys & DPAD_RIGHT)
+ else if (JOY_NEW(DPAD_RIGHT))
{
gUnknown_02022C98->unk31A0[gUnknown_02022C98->multiplayerId].unk2C.unk0 = 1;
gUnknown_02022C98->unkB0[gUnknown_02022C98->multiplayerId] = 6;
@@ -2653,7 +2653,7 @@ static void Task_ShowDodrioBerryPickingRecords(u8 taskId)
data[0]++;
break;
case 2:
- if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ if (JOY_NEW(A_BUTTON | B_BUTTON))
{
rbox_fill_rectangle(data[1]);
CopyWindowToVram(data[1], 1);
@@ -4266,7 +4266,7 @@ static void sub_802988C(void)
gUnknown_02022CF8->state++;
break;
case 4:
- if (++gUnknown_02022CF8->unk301C >= 30 && gMain.newKeys & A_BUTTON)
+ if (++gUnknown_02022CF8->unk301C >= 30 && JOY_NEW(A_BUTTON))
{
gUnknown_02022CF8->unk301C = 0;
PlaySE(SE_SELECT);
@@ -4298,7 +4298,7 @@ static void sub_802988C(void)
gUnknown_02022CF8->state++;
break;
case 8:
- if (++gUnknown_02022CF8->unk301C >= 30 && gMain.newKeys & A_BUTTON)
+ if (++gUnknown_02022CF8->unk301C >= 30 && JOY_NEW(A_BUTTON))
{
gUnknown_02022CF8->unk301C = 0;
PlaySE(SE_SELECT);
@@ -4358,7 +4358,7 @@ static void sub_802988C(void)
gUnknown_02022CF8->state++;
break;
case 11:
- if (++gUnknown_02022CF8->unk301C >= 30 && gMain.newKeys & A_BUTTON)
+ if (++gUnknown_02022CF8->unk301C >= 30 && JOY_NEW(A_BUTTON))
{
gUnknown_02022CF8->unk301C = 0;
PlaySE(SE_SELECT);
@@ -4424,14 +4424,14 @@ static void sub_802A010(void)
AddTextPrinterParameterized(gUnknown_02022CF8->unk3008[1], 1, gText_SelectorArrow2, 0, ((y - 1) * 16) + 1, -1, NULL);
CopyWindowToVram(gUnknown_02022CF8->unk3008[1], 3);
// Increment state only if A or B button have been pressed.
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
if (gUnknown_02022CF8->unk3020 == 0)
gUnknown_02022CF8->unk3020 = 1;
gUnknown_02022CF8->state++;
}
- else if (gMain.newKeys & (DPAD_UP | DPAD_DOWN))
+ else if (JOY_NEW(DPAD_UP | DPAD_DOWN))
{
PlaySE(SE_SELECT);
switch (gUnknown_02022CF8->unk3020)
@@ -4447,7 +4447,7 @@ static void sub_802A010(void)
break;
}
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
gUnknown_02022CF8->unk3020 = 2;
diff --git a/src/easy_chat.c b/src/easy_chat.c
index 8e1044591..e08f0bb75 100644
--- a/src/easy_chat.c
+++ b/src/easy_chat.c
@@ -1523,7 +1523,7 @@ static u16 sub_811AB68(void)
{
do
{
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
sub_811BF78();
sEasyChatScreen->state = 2;
@@ -1532,30 +1532,30 @@ static u16 sub_811AB68(void)
sEasyChatScreen->unk_0c = 0;
return 9;
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
return sub_811B150();
}
- else if (gMain.newKeys & START_BUTTON)
+ else if (JOY_NEW(START_BUTTON))
{
return sub_811B1B4();
}
- else if (gMain.newKeys & DPAD_UP)
+ else if (JOY_NEW(DPAD_UP))
{
sEasyChatScreen->mainCursorRow--;
break;
}
- else if (gMain.newKeys & DPAD_LEFT)
+ else if (JOY_NEW(DPAD_LEFT))
{
sEasyChatScreen->mainCursorColumn--;
break;
}
- else if (gMain.newKeys & DPAD_DOWN)
+ else if (JOY_NEW(DPAD_DOWN))
{
sEasyChatScreen->mainCursorRow++;
break;
}
- else if (gMain.newKeys & DPAD_RIGHT)
+ else if (JOY_NEW(DPAD_RIGHT))
{
sEasyChatScreen->mainCursorColumn++;
break;
@@ -1595,7 +1595,7 @@ static u16 sub_811ACDC(void)
{
do
{
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
switch (sEasyChatScreen->mainCursorColumn)
{
@@ -1610,30 +1610,30 @@ static u16 sub_811ACDC(void)
}
}
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
return sub_811B150();
}
- else if (gMain.newKeys & START_BUTTON)
+ if (JOY_NEW(START_BUTTON))
{
return sub_811B1B4();
}
- else if (gMain.newKeys & DPAD_UP)
+ if (JOY_NEW(DPAD_UP))
{
sEasyChatScreen->mainCursorRow--;
break;
}
- else if (gMain.newKeys & DPAD_LEFT)
+ if (JOY_NEW(DPAD_LEFT))
{
sEasyChatScreen->mainCursorColumn--;
break;
}
- else if (gMain.newKeys & DPAD_DOWN)
+ if (JOY_NEW(DPAD_DOWN))
{
sEasyChatScreen->mainCursorRow = 0;
break;
}
- else if (gMain.newKeys & DPAD_RIGHT)
+ if (JOY_NEW(DPAD_RIGHT))
{
sEasyChatScreen->mainCursorColumn++;
break;
@@ -1666,10 +1666,10 @@ static u16 sub_811ACDC(void)
static u16 sub_811AE44(void)
{
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
return sub_811B32C();
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
if (sEasyChatScreen->unk_0a != -1)
return sub_811B2B0();
@@ -1685,19 +1685,19 @@ static u16 sub_811AE44(void)
}
}
- if (gMain.newKeys & SELECT_BUTTON)
+ if (JOY_NEW(SELECT_BUTTON))
return sub_811B33C();
- if (gMain.newAndRepeatedKeys & DPAD_UP)
+ if (JOY_REPEAT(DPAD_UP))
return sub_811B528(2);
- if (gMain.newAndRepeatedKeys & DPAD_DOWN)
+ if (JOY_REPEAT(DPAD_DOWN))
return sub_811B528(3);
- if (gMain.newAndRepeatedKeys & DPAD_LEFT)
+ if (JOY_REPEAT(DPAD_LEFT))
return sub_811B528(1);
- if (gMain.newAndRepeatedKeys & DPAD_RIGHT)
+ if (JOY_REPEAT(DPAD_RIGHT))
return sub_811B528(0);
return 0;
@@ -1705,31 +1705,31 @@ static u16 sub_811AE44(void)
static u16 sub_811AF00(void)
{
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
sEasyChatScreen->state = 2;
return 14;
}
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
return sub_811B394();
- if (gMain.newKeys & START_BUTTON)
+ if (JOY_NEW(START_BUTTON))
return sub_811B794(4);
- if (gMain.newKeys & SELECT_BUTTON)
+ if (JOY_NEW(SELECT_BUTTON))
return sub_811B794(5);
- if (gMain.newAndRepeatedKeys & DPAD_UP)
+ if (JOY_REPEAT(DPAD_UP))
return sub_811B794(2);
- if (gMain.newAndRepeatedKeys & DPAD_DOWN)
+ if (JOY_REPEAT(DPAD_DOWN))
return sub_811B794(3);
- if (gMain.newAndRepeatedKeys & DPAD_LEFT)
+ if (JOY_REPEAT(DPAD_LEFT))
return sub_811B794(1);
- if (gMain.newAndRepeatedKeys & DPAD_RIGHT)
+ if (JOY_REPEAT(DPAD_RIGHT))
return sub_811B794(0);
return 0;
@@ -1794,10 +1794,10 @@ static u16 sub_811B040(void)
static u16 sub_811B08C(void)
{
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
return 26;
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
return sub_811B150();
return 0;
@@ -1805,7 +1805,7 @@ static u16 sub_811B08C(void)
static u16 sub_811B0BC(void)
{
- if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ if (JOY_NEW(A_BUTTON | B_BUTTON))
{
sEasyChatScreen->state = sub_811B2A4();
return 7;
diff --git a/src/ereader_screen.c b/src/ereader_screen.c
index b4a9164b3..3f2cf3217 100755
--- a/src/ereader_screen.c
+++ b/src/ereader_screen.c
@@ -137,7 +137,7 @@ static u32 sub_81D4EE4(u8 *arg0, u16 *arg1)
{
*arg0 = 1;
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
*arg0 = 0;
return 1;
@@ -158,7 +158,7 @@ static u32 sub_81D4EE4(u8 *arg0, u16 *arg1)
*arg1 = 0;
*arg0 = 3;
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
*arg0 = 0;
return 1;
@@ -288,7 +288,7 @@ static void sub_81D5084(u8 taskId)
OpenEReaderLink();
data->unk8 = 6;
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
sub_81D505C(&data->unk0);
PlaySE(SE_SELECT);
@@ -296,7 +296,7 @@ static void sub_81D5084(u8 taskId)
}
break;
case 6:
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
CloseLink();
@@ -436,7 +436,7 @@ static void sub_81D5084(u8 taskId)
}
break;
case 19:
- if (IsFanfareTaskInactive() && (gMain.newKeys & (A_BUTTON | B_BUTTON)))
+ if (IsFanfareTaskInactive() && (JOY_NEW(A_BUTTON | B_BUTTON)))
data->unk8 = 26;
break;
case 23:
diff --git a/src/evolution_scene.c b/src/evolution_scene.c
index 41d4900f7..61065367c 100644
--- a/src/evolution_scene.c
+++ b/src/evolution_scene.c
@@ -859,21 +859,21 @@ static void Task_EvolutionScene(u8 taskID)
}
break;
case 4:
- if (gMain.newKeys & DPAD_UP && sEvoCursorPos != 0)
+ if (JOY_NEW(DPAD_UP) && sEvoCursorPos != 0)
{
PlaySE(SE_SELECT);
BattleDestroyYesNoCursorAt(sEvoCursorPos);
sEvoCursorPos = 0;
BattleCreateYesNoCursorAt(0);
}
- if (gMain.newKeys & DPAD_DOWN && sEvoCursorPos == 0)
+ if (JOY_NEW(DPAD_DOWN) && sEvoCursorPos == 0)
{
PlaySE(SE_SELECT);
BattleDestroyYesNoCursorAt(sEvoCursorPos);
sEvoCursorPos = 1;
BattleCreateYesNoCursorAt(1);
}
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
HandleBattleWindow(0x18, 8, 0x1D, 0xD, WINDOW_CLEAR);
PlaySE(SE_SELECT);
@@ -889,7 +889,7 @@ static void Task_EvolutionScene(u8 taskID)
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK);
}
}
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
HandleBattleWindow(0x18, 8, 0x1D, 0xD, WINDOW_CLEAR);
PlaySE(SE_SELECT);
diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c
index 5fab2489b..e907af5b9 100644
--- a/src/field_player_avatar.c
+++ b/src/field_player_avatar.c
@@ -1789,7 +1789,7 @@ static bool8 Fishing_ShowDots(struct Task *task)
AlignFishingAnimationFrames();
task->tFrameCounter++;
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
task->tStep = FISHING_NO_BITE;
if (task->tRoundsPlayed != 0)
@@ -1878,7 +1878,7 @@ static bool8 Fishing_WaitForA(struct Task *task)
task->tFrameCounter++;
if (task->tFrameCounter >= reelTimeouts[task->tFishingRod])
task->tStep = FISHING_GOT_AWAY;
- else if (gMain.newKeys & A_BUTTON)
+ else if (JOY_NEW(A_BUTTON))
task->tStep++;
return FALSE;
}
diff --git a/src/field_special_scene.c b/src/field_special_scene.c
index bd6c833af..6b41c5423 100644
--- a/src/field_special_scene.c
+++ b/src/field_special_scene.c
@@ -280,7 +280,7 @@ void Task_HandlePorthole(u8 taskId)
}
break;
case IDLE_CHECK:
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
data[1] = 1;
if (!ScriptMovement_IsObjectMovementFinished(OBJ_EVENT_ID_PLAYER, location->mapNum, location->mapGroup))
return;
diff --git a/src/frontier_pass.c b/src/frontier_pass.c
index 702f6c098..1178cdbb4 100644
--- a/src/frontier_pass.c
+++ b/src/frontier_pass.c
@@ -937,14 +937,14 @@ static void Task_HandleFrontierPassInput(u8 taskId)
{
u8 var = FALSE; // Reused, first informs whether the cursor moves, then used as the new cursor area.
- if (gMain.heldKeys & DPAD_UP && sPassGfx->cursorSprite->pos1.y >= 9)
+ if (JOY_HELD(DPAD_UP) && sPassGfx->cursorSprite->pos1.y >= 9)
{
sPassGfx->cursorSprite->pos1.y -= 2;
if (sPassGfx->cursorSprite->pos1.y <= 7)
sPassGfx->cursorSprite->pos1.y = 2;
var = TRUE;
}
- if (gMain.heldKeys & DPAD_DOWN && sPassGfx->cursorSprite->pos1.y <= 135)
+ if (JOY_HELD(DPAD_DOWN) && sPassGfx->cursorSprite->pos1.y <= 135)
{
sPassGfx->cursorSprite->pos1.y += 2;
if (sPassGfx->cursorSprite->pos1.y >= 137)
@@ -952,14 +952,14 @@ static void Task_HandleFrontierPassInput(u8 taskId)
var = TRUE;
}
- if (gMain.heldKeys & DPAD_LEFT && sPassGfx->cursorSprite->pos1.x >= 6)
+ if (JOY_HELD(DPAD_LEFT) && sPassGfx->cursorSprite->pos1.x >= 6)
{
sPassGfx->cursorSprite->pos1.x -= 2;
if (sPassGfx->cursorSprite->pos1.x <= 4)
sPassGfx->cursorSprite->pos1.x = 5;
var = TRUE;
}
- if (gMain.heldKeys & DPAD_RIGHT && sPassGfx->cursorSprite->pos1.x <= 231)
+ if (JOY_HELD(DPAD_RIGHT) && sPassGfx->cursorSprite->pos1.x <= 231)
{
sPassGfx->cursorSprite->pos1.x += 2;
if (sPassGfx->cursorSprite->pos1.x >= 233)
@@ -969,7 +969,7 @@ static void Task_HandleFrontierPassInput(u8 taskId)
if (!var) // Cursor did not change.
{
- if (sPassData->cursorArea != CURSOR_AREA_NOTHING && gMain.newKeys & A_BUTTON)
+ if (sPassData->cursorArea != CURSOR_AREA_NOTHING && JOY_NEW(A_BUTTON))
{
if (sPassData->cursorArea <= CURSOR_AREA_RECORD) // Map, Card, Record
{
@@ -986,7 +986,7 @@ static void Task_HandleFrontierPassInput(u8 taskId)
}
}
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_PC_OFF);
SetMainCallback2(CB2_HideFrontierPass);
@@ -1471,19 +1471,19 @@ static void Task_HandleFrontierMap(u8 taskId)
break;
return;
case 1:
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_PC_OFF);
data[0] = 4;
}
- else if (gMain.newKeys & DPAD_DOWN)
+ else if (JOY_NEW(DPAD_DOWN))
{
if (sMapData->cursorPos >= NUM_FRONTIER_FACILITIES - 1)
HandleFrontierMapCursorMove(0);
else
data[0] = 2;
}
- else if (gMain.newKeys & DPAD_UP)
+ else if (JOY_NEW(DPAD_UP))
{
if (sMapData->cursorPos == 0)
HandleFrontierMapCursorMove(1);
diff --git a/src/frontier_util.c b/src/frontier_util.c
index 3e7fecb48..a36e2ec9f 100644
--- a/src/frontier_util.c
+++ b/src/frontier_util.c
@@ -2486,7 +2486,6 @@ void SetFrontierBrainObjEventGfx_2(void)
#define FRONTIER_BRAIN_OTID 61226
-#ifdef NONMATCHING
void CreateFrontierBrainPokemon(void)
{
s32 i, j;
@@ -2509,11 +2508,13 @@ void CreateFrontierBrainPokemon(void)
{
if (!(selectedMonBits & 1))
continue;
-
do
{
- j = Random32();
- } while (IsShinyOtIdPersonality(FRONTIER_BRAIN_OTID, j) || sFrontierBrainsMons[facility][symbol][i].nature != GetNatureFromPersonality(j));
+ do
+ {
+ j = Random32(); //Should be one while loop, but that doesn't match
+ } while (IsShinyOtIdPersonality(FRONTIER_BRAIN_OTID, j));
+ } while (sFrontierBrainsMons[facility][symbol][i].nature != GetNatureFromPersonality(j));
CreateMon(&gEnemyParty[monPartyId],
sFrontierBrainsMons[facility][symbol][i].species,
monLevel,
@@ -2535,242 +2536,6 @@ void CreateFrontierBrainPokemon(void)
monPartyId++;
}
}
-#else
-NAKED
-void CreateFrontierBrainPokemon(void)
-{
- asm_unified(
- "push {r4-r7,lr}\n\
- mov r7, r10\n\
- mov r6, r9\n\
- mov r5, r8\n\
- push {r5-r7}\n\
- sub sp, 0x44\n\
- ldr r0, =0x000040cf\n\
- bl VarGet\n\
- lsls r0, 16\n\
- lsrs r0, 16\n\
- str r0, [sp, 0x20]\n\
- bl GetFronterBrainSymbol\n\
- str r0, [sp, 0x24]\n\
- ldr r0, [sp, 0x20]\n\
- cmp r0, 0x1\n\
- bne _081A4E44\n\
- ldr r0, =0x000003fe\n\
- bl TrainerIdToDomeTournamentId\n\
- lsls r0, 16\n\
- lsrs r0, 16\n\
- bl GetDomeTrainerSelectedMons\n\
- adds r4, r0, 0\n\
- b _081A4E46\n\
- .pool\n\
-_081A4E44:\n\
- movs r4, 0x7\n\
-_081A4E46:\n\
- bl ZeroEnemyPartyMons\n\
- movs r1, 0\n\
- str r1, [sp, 0x18]\n\
- bl SetFacilityPtrsGetLevel\n\
- lsls r0, 24\n\
- lsrs r0, 24\n\
- str r0, [sp, 0x1C]\n\
- movs r2, 0\n\
- str r2, [sp, 0x14]\n\
-_081A4E5C:\n\
- movs r0, 0x1\n\
- ands r0, r4\n\
- asrs r4, 1\n\
- str r4, [sp, 0x30]\n\
- ldr r3, [sp, 0x14]\n\
- adds r3, 0x1\n\
- str r3, [sp, 0x28]\n\
- cmp r0, 0\n\
- bne _081A4E70\n\
- b _081A4FC4\n\
-_081A4E70:\n\
- ldr r4, [sp, 0x14]\n\
- lsls r4, 2\n\
- mov r9, r4\n\
- ldr r0, [sp, 0x24]\n\
- lsls r0, 4\n\
- str r0, [sp, 0x38]\n\
- ldr r1, [sp, 0x20]\n\
- lsls r1, 4\n\
- str r1, [sp, 0x34]\n\
- ldr r2, [sp, 0x1C]\n\
- lsls r2, 24\n\
- str r2, [sp, 0x3C]\n\
- ldr r3, [sp, 0x18]\n\
- adds r3, 0x1\n\
- str r3, [sp, 0x2C]\n\
- ldr r0, [sp, 0x14]\n\
- add r0, r9\n\
- lsls r0, 2\n\
- mov r8, r0\n\
-_081A4E96:\n\
- bl Random\n\
- adds r4, r0, 0\n\
- bl Random\n\
- lsls r4, 16\n\
- lsrs r7, r4, 16\n\
- lsls r0, 16\n\
- orrs r7, r0\n\
- ldr r0, =0x0000ef2a\n\
- adds r1, r7, 0\n\
- bl IsShinyOtIdPersonality\n\
- lsls r0, 24\n\
- cmp r0, 0\n\
- bne _081A4E96\n\
- ldr r4, [sp, 0x38]\n\
- ldr r1, [sp, 0x24]\n\
- subs r0, r4, r1\n\
- lsls r5, r0, 2\n\
- mov r2, r8\n\
- adds r4, r2, r5\n\
- ldr r3, [sp, 0x34]\n\
- ldr r1, [sp, 0x20]\n\
- subs r0, r3, r1\n\
- lsls r6, r0, 3\n\
- adds r4, r6\n\
- ldr r2, =sFrontierBrainsMons\n\
- adds r4, r2\n\
- adds r0, r7, 0\n\
- bl GetNatureFromPersonality\n\
- ldrb r1, [r4, 0x5]\n\
- lsls r0, 24\n\
- lsrs r0, 24\n\
- cmp r1, r0\n\
- bne _081A4E96\n\
- ldr r4, [sp, 0x18]\n\
- movs r0, 0x64\n\
- adds r3, r4, 0\n\
- muls r3, r0\n\
- mov r8, r3\n\
- ldr r1, =gEnemyParty\n\
- add r1, r8\n\
- mov r10, r1\n\
- ldr r4, [sp, 0x14]\n\
- add r4, r9\n\
- lsls r4, 2\n\
- adds r0, r4, r5\n\
- adds r0, r6\n\
- ldr r2, =sFrontierBrainsMons\n\
- adds r0, r2\n\
- ldrh r1, [r0]\n\
- ldr r3, [sp, 0x3C]\n\
- lsrs r2, r3, 24\n\
- ldrb r3, [r0, 0x4]\n\
- movs r0, 0x1\n\
- str r0, [sp]\n\
- str r7, [sp, 0x4]\n\
- str r0, [sp, 0x8]\n\
- ldr r0, =0x0000ef2a\n\
- str r0, [sp, 0xC]\n\
- mov r0, r10\n\
- bl CreateMon\n\
- ldr r0, =sFrontierBrainsMons\n\
- adds r5, r0\n\
- adds r5, r6, r5\n\
- adds r4, r5, r4\n\
- adds r4, 0x2\n\
- mov r0, r10\n\
- movs r1, 0xC\n\
- adds r2, r4, 0\n\
- bl SetMonData\n\
- movs r7, 0\n\
- mov r6, r8\n\
- ldr r3, =gEnemyParty\n\
-_081A4F32:\n\
- adds r1, r7, 0\n\
- adds r1, 0x1A\n\
- ldr r0, [sp, 0x14]\n\
- add r0, r9\n\
- lsls r4, r0, 2\n\
- adds r2, r5, r4\n\
- adds r0, r7, 0x6\n\
- adds r2, r0\n\
- adds r0, r6, r3\n\
- str r3, [sp, 0x40]\n\
- bl SetMonData\n\
- adds r7, 0x1\n\
- ldr r3, [sp, 0x40]\n\
- cmp r7, 0x5\n\
- ble _081A4F32\n\
- movs r1, 0xFF\n\
- add r0, sp, 0x10\n\
- strb r1, [r0]\n\
- movs r7, 0\n\
- ldr r1, [sp, 0x18]\n\
- movs r2, 0x64\n\
- adds r6, r1, 0\n\
- muls r6, r2\n\
- ldr r3, =sFrontierBrainsMons + 0xC\n\
- mov r8, r3\n\
- ldr r3, =gEnemyParty\n\
- adds r5, r4, 0\n\
-_081A4F6A:\n\
- ldr r4, [sp, 0x38]\n\
- ldr r0, [sp, 0x24]\n\
- subs r1, r4, r0\n\
- lsls r1, 2\n\
- adds r1, r5, r1\n\
- ldr r2, [sp, 0x34]\n\
- ldr r4, [sp, 0x20]\n\
- subs r0, r2, r4\n\
- lsls r0, 3\n\
- adds r1, r0\n\
- add r1, r8\n\
- ldrh r4, [r1]\n\
- lsls r2, r7, 24\n\
- lsrs r2, 24\n\
- adds r0, r6, r3\n\
- adds r1, r4, 0\n\
- str r3, [sp, 0x40]\n\
- bl SetMonMoveSlot\n\
- ldr r3, [sp, 0x40]\n\
- cmp r4, 0xDA\n\
- bne _081A4F9C\n\
- movs r1, 0\n\
- add r0, sp, 0x10\n\
- strb r1, [r0]\n\
-_081A4F9C:\n\
- adds r5, 0x2\n\
- adds r7, 0x1\n\
- cmp r7, 0x3\n\
- ble _081A4F6A\n\
- ldr r0, [sp, 0x18]\n\
- movs r1, 0x64\n\
- adds r4, r0, 0\n\
- muls r4, r1\n\
- ldr r0, =gEnemyParty\n\
- adds r4, r0\n\
- adds r0, r4, 0\n\
- movs r1, 0x20\n\
- add r2, sp, 0x10\n\
- bl SetMonData\n\
- adds r0, r4, 0\n\
- bl CalculateMonStats\n\
- ldr r2, [sp, 0x2C]\n\
- str r2, [sp, 0x18]\n\
-_081A4FC4:\n\
- ldr r4, [sp, 0x30]\n\
- ldr r3, [sp, 0x28]\n\
- str r3, [sp, 0x14]\n\
- cmp r3, 0x2\n\
- bgt _081A4FD0\n\
- b _081A4E5C\n\
-_081A4FD0:\n\
- add sp, 0x44\n\
- pop {r3-r5}\n\
- mov r8, r3\n\
- mov r9, r4\n\
- mov r10, r5\n\
- pop {r4-r7}\n\
- pop {r0}\n\
- bx r0\n\
- .pool");
-}
-#endif
u16 GetFrontierBrainMonSpecies(u8 monId)
{
diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c
index 2b548dea2..a13543d6a 100644
--- a/src/hall_of_fame.c
+++ b/src/hall_of_fame.c
@@ -730,7 +730,7 @@ static void Task_Hof_WaitAndPrintPlayerInfo(u8 taskId)
static void Task_Hof_ExitOnKeyPressed(u8 taskId)
{
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
FadeOutBGM(4);
gTasks[taskId].func = Task_Hof_HandlePaletteOnExit;
@@ -992,7 +992,7 @@ static void Task_HofPC_HandleInput(u8 taskId)
{
u16 i;
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
if (gTasks[taskId].tCurrTeamNo != 0) // prepare another team to view
{
@@ -1020,7 +1020,7 @@ static void Task_HofPC_HandleInput(u8 taskId)
gTasks[taskId].func = Task_HofPC_HandlePaletteOnExit;
}
}
- else if (gMain.newKeys & B_BUTTON) // turn off hall of fame PC
+ else if (JOY_NEW(B_BUTTON)) // turn off hall of fame PC
{
if (IsCryPlayingOrClearCrySongs())
{
@@ -1029,12 +1029,12 @@ static void Task_HofPC_HandleInput(u8 taskId)
}
gTasks[taskId].func = Task_HofPC_HandlePaletteOnExit;
}
- else if (gMain.newKeys & DPAD_UP && gTasks[taskId].tCurrMonId != 0) // change mon -1
+ else if (JOY_NEW(DPAD_UP) && gTasks[taskId].tCurrMonId != 0) // change mon -1
{
gTasks[taskId].tCurrMonId--;
gTasks[taskId].func = Task_HofPC_PrintMonInfo;
}
- else if (gMain.newKeys & DPAD_DOWN && gTasks[taskId].tCurrMonId < gTasks[taskId].tMonNo - 1) // change mon +1
+ else if (JOY_NEW(DPAD_DOWN) && gTasks[taskId].tCurrMonId < gTasks[taskId].tMonNo - 1) // change mon +1
{
gTasks[taskId].tCurrMonId++;
gTasks[taskId].func = Task_HofPC_PrintMonInfo;
@@ -1098,7 +1098,7 @@ static void Task_HofPC_PrintDataIsCorrupted(u8 taskId)
static void Task_HofPC_ExitOnButtonPress(u8 taskId)
{
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
gTasks[taskId].func = Task_HofPC_HandlePaletteOnExit;
}
diff --git a/src/intro_credits_graphics.c b/src/intro_credits_graphics.c
index 04e2216f6..45cc24e5c 100644
--- a/src/intro_credits_graphics.c
+++ b/src/intro_credits_graphics.c
@@ -824,7 +824,7 @@ void sub_817B1C8(u8 a)
LZ77UnCompVram(gUnknown_085F1398, (void *)(BG_SCREEN_ADDR(6)));
LoadPalette(&gUnknown_085F0CFC, 0, 96);
LoadCompressedSpriteSheet(gUnknown_085F5064);
- LZ77UnCompVram(gUnknown_085F16A8, (void *)(VRAM + 0x10000));
+ LZ77UnCompVram(gUnknown_085F16A8, (void *)(OBJ_VRAM0));
LoadPalette(&gUnknown_085F1668, 256, 32);
sub_817B76C();
break;
@@ -834,7 +834,7 @@ void sub_817B1C8(u8 a)
LZ77UnCompVram(gUnknown_085F1398, (void *)(BG_SCREEN_ADDR(6)));
LoadPalette(&gUnknown_085F0D5C, 0, 96);
LoadCompressedSpriteSheet(gUnknown_085F5064);
- LZ77UnCompVram(gUnknown_085F16A8, (void *)(VRAM + 0x10000));
+ LZ77UnCompVram(gUnknown_085F16A8, (void *)(OBJ_VRAM0));
LoadPalette(&gUnknown_085F1688, 256, 32);
sub_817B76C();
break;
diff --git a/src/item_menu.c b/src/item_menu.c
index ace2fd11e..1d74210c7 100755
--- a/src/item_menu.c
+++ b/src/item_menu.c
@@ -1167,7 +1167,7 @@ void Task_BagMenu_HandleInput(u8 taskId)
SwitchBagPocket(taskId, MENU_CURSOR_DELTA_RIGHT, 0);
return;
default:
- if (gMain.newKeys & SELECT_BUTTON)
+ if (JOY_NEW(SELECT_BUTTON))
{
if (CanSwapItems() == TRUE)
{
@@ -1229,12 +1229,12 @@ static u8 GetSwitchBagPocketDirection(void)
if (gBagMenu->pocketSwitchDisabled)
return SWITCH_POCKET_NONE;
LRKeys = GetLRKeysPressed();
- if ((gMain.newKeys & DPAD_LEFT) || LRKeys == MENU_L_PRESSED)
+ if (JOY_NEW(DPAD_LEFT) || LRKeys == MENU_L_PRESSED)
{
PlaySE(SE_SELECT);
return SWITCH_POCKET_LEFT;
}
- if ((gMain.newKeys & DPAD_RIGHT) || LRKeys == MENU_R_PRESSED)
+ if (JOY_NEW(DPAD_RIGHT) || LRKeys == MENU_R_PRESSED)
{
PlaySE(SE_SELECT);
return SWITCH_POCKET_RIGHT;
@@ -1388,7 +1388,7 @@ static void Task_HandleSwappingItemsInput(u8 taskId)
if (MenuHelpers_CallLinkSomething() != TRUE)
{
- if (gMain.newKeys & SELECT_BUTTON)
+ if (JOY_NEW(SELECT_BUTTON))
{
PlaySE(SE_SELECT);
ListMenuGetScrollAndRow(data[0], &gBagPositionStruct.scrollPosition[gBagPositionStruct.pocket], &gBagPositionStruct.cursorPosition[gBagPositionStruct.pocket]);
@@ -1406,7 +1406,7 @@ static void Task_HandleSwappingItemsInput(u8 taskId)
break;
case LIST_CANCEL:
PlaySE(SE_SELECT);
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
sub_81AC498(taskId);
else
sub_81AC590(taskId);
@@ -1645,7 +1645,7 @@ void Task_HandleOutOfBattleItemMenuInput(u8 taskId)
if (MenuHelpers_CallLinkSomething() != TRUE)
{
s8 cursorPos = Menu_GetCursorPos();
- if (gMain.newKeys & DPAD_UP)
+ if (JOY_NEW(DPAD_UP))
{
if (cursorPos > 0 && sub_81ACDFC(cursorPos - 2))
{
@@ -1653,7 +1653,7 @@ void Task_HandleOutOfBattleItemMenuInput(u8 taskId)
ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_UP);
}
}
- else if (gMain.newKeys & DPAD_DOWN)
+ else if (JOY_NEW(DPAD_DOWN))
{
if (cursorPos < (gBagMenu->contextMenuNumItems - 2) && sub_81ACDFC(cursorPos + 2))
{
@@ -1661,7 +1661,7 @@ void Task_HandleOutOfBattleItemMenuInput(u8 taskId)
ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_DOWN);
}
}
- else if ((gMain.newKeys & DPAD_LEFT) || GetLRKeysPressed() == MENU_L_PRESSED)
+ else if ((JOY_NEW(DPAD_LEFT)) || GetLRKeysPressed() == MENU_L_PRESSED)
{
if ((cursorPos & 1) && sub_81ACDFC(cursorPos - 1))
{
@@ -1669,7 +1669,7 @@ void Task_HandleOutOfBattleItemMenuInput(u8 taskId)
ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_LEFT, MENU_CURSOR_DELTA_NONE);
}
}
- else if ((gMain.newKeys & DPAD_RIGHT) || GetLRKeysPressed() == MENU_R_PRESSED)
+ else if (JOY_NEW(DPAD_RIGHT) || GetLRKeysPressed() == MENU_R_PRESSED)
{
if (!(cursorPos & 1) && sub_81ACDFC(cursorPos + 1))
{
@@ -1677,12 +1677,12 @@ void Task_HandleOutOfBattleItemMenuInput(u8 taskId)
ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_RIGHT, MENU_CURSOR_DELTA_NONE);
}
}
- else if (gMain.newKeys & A_BUTTON)
+ else if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
sItemMenuActions[gBagMenu->contextMenuItemsPtr[cursorPos]].func.void_u8(taskId);
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
sItemMenuActions[ITEMMENUACTION_CANCEL].func.void_u8(taskId);
@@ -1786,13 +1786,13 @@ void Task_ChooseHowManyToToss(u8 taskId)
{
PrintItemDepositAmount(gBagMenu->windowPointers[7], tItemCount);
}
- else if (gMain.newKeys & A_BUTTON)
+ else if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
BagMenu_RemoveWindow(7);
BagMenu_TossItems(taskId);
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
BagMenu_RemoveWindow(7);
@@ -1818,7 +1818,7 @@ void Task_ActuallyToss(u8 taskId)
u16* scrollPos = &gBagPositionStruct.scrollPosition[gBagPositionStruct.pocket];
u16* cursorPos = &gBagPositionStruct.cursorPosition[gBagPositionStruct.pocket];
- if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ if (JOY_NEW(A_BUTTON | B_BUTTON))
{
PlaySE(SE_SELECT);
RemoveBagItem(gSpecialVar_ItemId, tItemCount);
@@ -1886,7 +1886,7 @@ static void BagMenu_PrintItemCantBeHeld(u8 taskId)
void sub_81AD350(u8 taskId)
{
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
BagMenu_InitListsMenu(taskId);
@@ -2060,13 +2060,13 @@ static void Task_SellHowManyDialogueHandleInput(u8 taskId)
{
PrintItemSoldAmount(gBagMenu->windowPointers[8], tItemCount, (ItemId_GetPrice(gSpecialVar_ItemId) / 2) * tItemCount);
}
- else if (gMain.newKeys & A_BUTTON)
+ else if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
BagMenu_RemoveWindow(8);
DisplaySellItemPriceAndConfirm(taskId);
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
BagMenu_PrintCursor_(data[0], 0);
@@ -2108,7 +2108,7 @@ static void BagMenu_Sell_UpdateItemListAndMoney(u8 taskId)
static void BagMenu_Sell_WaitForABPress(u8 taskId)
{
- if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ if (JOY_NEW(A_BUTTON | B_BUTTON))
{
PlaySE(SE_SELECT);
RemoveMoneyWindow();
@@ -2144,13 +2144,13 @@ static void Task_ChooseHowManyToDeposit(u8 taskId)
{
PrintItemDepositAmount(gBagMenu->windowPointers[7], tItemCount);
}
- else if (gMain.newKeys & A_BUTTON)
+ else if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
BagMenu_RemoveWindow(7);
BagMenu_TryDepositItem(taskId);
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
BagMenu_PrintDescription(data[1]);
@@ -2189,7 +2189,7 @@ static void BagMenu_Deposit_WaitForABPress(u8 taskId)
{
s16* data = gTasks[taskId].data;
- if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ if (JOY_NEW(A_BUTTON | B_BUTTON))
{
PlaySE(SE_SELECT);
BagMenu_PrintDescription(data[1]);
diff --git a/src/item_use.c b/src/item_use.c
index a9132ae5e..f9d1ff824 100755
--- a/src/item_use.c
+++ b/src/item_use.c
@@ -792,7 +792,7 @@ static void BootUpSoundTMHM(u8 taskId)
static void Task_ShowTMHMContainedMessage(u8 taskId)
{
- if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ if (JOY_NEW(A_BUTTON | B_BUTTON))
{
StringCopy(gStringVar1, gMoveNames[ItemIdToBattleMoveId(gSpecialVar_ItemId)]);
StringExpandPlaceholders(gStringVar4, gText_TMHMContainedVar1);
@@ -956,7 +956,7 @@ void ItemUseInBattle_PokeBall(u8 taskId)
static void Task_CloseStatIncreaseMessage(u8 taskId)
{
- if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ if (JOY_NEW(A_BUTTON | B_BUTTON))
{
if (!InBattlePyramid())
Task_FadeAndCloseBagMenu(taskId);
diff --git a/src/link.c b/src/link.c
index cdaf58469..9fd35a10b 100644
--- a/src/link.c
+++ b/src/link.c
@@ -445,27 +445,27 @@ static void TestBlockTransfer(u8 nothing, u8 is, u8 used)
static void LinkTestProcessKeyInput(void)
{
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
gShouldAdvanceLinkState = 1;
}
- if (gMain.heldKeys & B_BUTTON)
+ if (JOY_HELD(B_BUTTON))
{
InitBlockSend(gHeap + 0x4000, 0x00002004);
}
- if (gMain.newKeys & L_BUTTON)
+ if (JOY_NEW(L_BUTTON))
{
BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB(2, 0, 0));
}
- if (gMain.newKeys & START_BUTTON)
+ if (JOY_NEW(START_BUTTON))
{
SetSuppressLinkErrorMessage(TRUE);
}
- if (gMain.newKeys & R_BUTTON)
+ if (JOY_NEW(R_BUTTON))
{
TrySavingData(SAVE_LINK);
}
- if (gMain.newKeys & SELECT_BUTTON)
+ if (JOY_NEW(SELECT_BUTTON))
{
SetCloseLinkCallback();
}
@@ -1754,7 +1754,7 @@ static void CB2_PrintErrorMessage(void)
{
if (gWirelessCommType == 1)
{
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_PIN);
gWirelessCommType = 0;
@@ -1764,7 +1764,7 @@ static void CB2_PrintErrorMessage(void)
}
else if (gWirelessCommType == 2)
{
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
rfu_REQ_stopMode();
rfu_waitREQComplete();
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/list_menu.c b/src/list_menu.c
index 1e549a34a..7784dd338 100644
--- a/src/list_menu.c
+++ b/src/list_menu.c
@@ -335,11 +335,11 @@ u32 DoMysteryGiftListMenu(const struct WindowTemplate *windowTemplate, const str
break;
case 1:
sMysteryGiftLinkMenu.currItemId = ListMenu_ProcessInput(sMysteryGiftLinkMenu.listTaskId);
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
sMysteryGiftLinkMenu.state = 2;
}
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
sMysteryGiftLinkMenu.currItemId = LIST_CANCEL;
sMysteryGiftLinkMenu.state = 2;
@@ -410,20 +410,20 @@ s32 ListMenu_ProcessInput(u8 listTaskId)
{
struct ListMenu *list = (void*) gTasks[listTaskId].data;
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
return list->template.items[list->scrollOffset + list->selectedRow].id;
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
return LIST_CANCEL;
}
- else if (gMain.newAndRepeatedKeys & DPAD_UP)
+ else if (JOY_REPEAT(DPAD_UP))
{
ListMenuChangeSelection(list, TRUE, 1, FALSE);
return LIST_NOTHING_CHOSEN;
}
- else if (gMain.newAndRepeatedKeys & DPAD_DOWN)
+ else if (JOY_REPEAT(DPAD_DOWN))
{
ListMenuChangeSelection(list, TRUE, 1, TRUE);
return LIST_NOTHING_CHOSEN;
@@ -439,12 +439,12 @@ s32 ListMenu_ProcessInput(u8 listTaskId)
rightButton = FALSE;
break;
case LIST_MULTIPLE_SCROLL_DPAD:
- leftButton = gMain.newAndRepeatedKeys & DPAD_LEFT;
- rightButton = gMain.newAndRepeatedKeys & DPAD_RIGHT;
+ leftButton = JOY_REPEAT(DPAD_LEFT);
+ rightButton = JOY_REPEAT(DPAD_RIGHT);
break;
case LIST_MULTIPLE_SCROLL_L_R:
- leftButton = gMain.newAndRepeatedKeys & L_BUTTON;
- rightButton = gMain.newAndRepeatedKeys & R_BUTTON;
+ leftButton = JOY_REPEAT(L_BUTTON);
+ rightButton = JOY_REPEAT(R_BUTTON);
break;
}
diff --git a/src/mail.c b/src/mail.c
index 0fc62678a..55bc9ed00 100644
--- a/src/mail.c
+++ b/src/mail.c
@@ -525,7 +525,7 @@ static void CB2_WaitForPaletteExitOnKeyPress(void)
static void CB2_ExitOnKeyPress(void)
{
- if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ if (JOY_NEW(A_BUTTON | B_BUTTON))
{
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
sMailRead->callback2 = CB2_ExitMailReadFreeVars;
diff --git a/src/main.c b/src/main.c
index 454fefc5c..b3b76b1fb 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
- && (gMain.heldKeysRaw & A_BUTTON)
- && (gMain.heldKeysRaw & B_START_SELECT) == B_START_SELECT)
+ if (!gSoftResetDisabled
+ && JOY_HELD_RAW(A_BUTTON)
+ && JOY_HELD_RAW(B_BUTTON)
+ && JOY_HELD_RAW(START_BUTTON)
+ && JOY_HELD_RAW(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;
@@ -282,10 +280,10 @@ static void ReadKeys(void)
// Remap L to A if the L=A option is enabled.
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;
}
@@ -343,7 +341,7 @@ static void VBlankIntr(void)
{
if (gWirelessCommType != 0)
RfuVSync();
- else if (gLinkVSyncDisabled == FALSE)
+ else if (!gLinkVSyncDisabled)
LinkVSync();
gMain.vblankCounter1++;
diff --git a/src/main_menu.c b/src/main_menu.c
index f4bf37ce1..e8403cdb1 100644
--- a/src/main_menu.c
+++ b/src/main_menu.c
@@ -696,7 +696,7 @@ static void Task_MainMenuCheckSaveFile(u8 taskId)
static void Task_WaitForSaveFileErrorWindow(u8 taskId)
{
RunTextPrinters();
- if (!IsTextPrinterActive(7) && (gMain.newKeys & A_BUTTON))
+ if (!IsTextPrinterActive(7) && (JOY_NEW(A_BUTTON)))
{
ClearWindowTilemap(7);
ClearMainMenuWindowTilemap(&sWindowTemplates_MainMenu[7]);
@@ -731,7 +731,7 @@ static void Task_MainMenuCheckBattery(u8 taskId)
static void Task_WaitForBatteryDryErrorWindow(u8 taskId)
{
RunTextPrinters();
- if (!IsTextPrinterActive(7) && (gMain.newKeys & A_BUTTON))
+ if (!IsTextPrinterActive(7) && (JOY_NEW(A_BUTTON)))
{
ClearWindowTilemap(7);
ClearMainMenuWindowTilemap(&sWindowTemplates_MainMenu[7]);
@@ -887,14 +887,14 @@ static bool8 HandleMainMenuInput(u8 taskId)
{
s16* data = gTasks[taskId].data;
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
IsWirelessAdapterConnected(); // why bother calling this here? debug? Task_HandleMainMenuAPressed will check too
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK);
gTasks[taskId].func = Task_HandleMainMenuAPressed;
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_WHITEALPHA);
@@ -902,7 +902,7 @@ static bool8 HandleMainMenuInput(u8 taskId)
SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(0, 160));
gTasks[taskId].func = Task_HandleMainMenuBPressed;
}
- else if ((gMain.newKeys & DPAD_UP) && tCurrItem > 0)
+ else if ((JOY_NEW(DPAD_UP)) && tCurrItem > 0)
{
if (tMenuType == HAS_MYSTERY_EVENTS && tIsScrolled == TRUE && tCurrItem == 1)
{
@@ -914,7 +914,7 @@ static bool8 HandleMainMenuInput(u8 taskId)
sCurrItemAndOptionMenuCheck = tCurrItem;
return TRUE;
}
- else if ((gMain.newKeys & DPAD_DOWN) && tCurrItem < tItemCount - 1)
+ else if ((JOY_NEW(DPAD_DOWN)) && tCurrItem < tItemCount - 1)
{
if (tMenuType == HAS_MYSTERY_EVENTS && tCurrItem == 3 && tIsScrolled == FALSE)
{
@@ -1151,7 +1151,7 @@ static void Task_DisplayMainMenuInvalidActionError(u8 taskId)
gTasks[taskId].tCurrItem++;
break;
case 3:
- if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ if (JOY_NEW(A_BUTTON | B_BUTTON))
{
PlaySE(SE_SELECT);
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
@@ -1594,7 +1594,7 @@ static void Task_NewGameBirchSpeech_WaitForWhatsYourNameToPrint(u8 taskId)
static void Task_NewGameBirchSpeech_WaitPressBeforeNameChoice(u8 taskId)
{
- if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON))
+ if ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON)))
{
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
gTasks[taskId].func = Task_NewGameBirchSpeech_StartNamingScreen;
diff --git a/src/match_call.c b/src/match_call.c
index aaf6f29d2..1899eabf0 100644
--- a/src/match_call.c
+++ b/src/match_call.c
@@ -1253,7 +1253,7 @@ static bool32 sub_81962D8(u8 taskId)
static bool32 sub_8196330(u8 taskId)
{
s16 *taskData = gTasks[taskId].data;
- if (!ExecuteMatchCallTextPrinter(taskData[2]) && !IsSEPlaying() && gMain.newKeys & (A_BUTTON | B_BUTTON))
+ if (!ExecuteMatchCallTextPrinter(taskData[2]) && !IsSEPlaying() && JOY_NEW(A_BUTTON | B_BUTTON))
{
FillWindowPixelBuffer(taskData[2], PIXEL_FILL(8));
CopyWindowToVram(taskData[2], 2);
@@ -1346,7 +1346,7 @@ static void InitMatchCallTextPrinter(int windowId, const u8 *str)
static bool32 ExecuteMatchCallTextPrinter(int windowId)
{
- if (gMain.heldKeys & A_BUTTON)
+ if (JOY_HELD(A_BUTTON))
gTextFlags.canABSpeedUpPrint = 1;
else
gTextFlags.canABSpeedUpPrint = 0;
@@ -1774,7 +1774,7 @@ static int GetNumOwnedBadges(void)
static bool32 sub_8196D74(int matchCallId)
{
int dayCount;
- int otId;
+ u32 otId;
u16 easyChatWord;
int numRematchTrainersFought;
int var0, var1, var2;
diff --git a/src/menu.c b/src/menu.c
index 85275b6bc..9c5dec024 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -981,23 +981,23 @@ u8 Menu_GetCursorPos(void)
s8 Menu_ProcessInput(void)
{
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
if (!sMenu.APressMuted)
PlaySE(SE_SELECT);
return sMenu.cursorPos;
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
return MENU_B_PRESSED;
}
- else if (gMain.newKeys & DPAD_UP)
+ else if (JOY_NEW(DPAD_UP))
{
PlaySE(SE_SELECT);
Menu_MoveCursor(-1);
return MENU_NOTHING_CHOSEN;
}
- else if (gMain.newKeys & DPAD_DOWN)
+ else if (JOY_NEW(DPAD_DOWN))
{
PlaySE(SE_SELECT);
Menu_MoveCursor(1);
@@ -1011,23 +1011,23 @@ s8 Menu_ProcessInputNoWrap(void)
{
u8 oldPos = sMenu.cursorPos;
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
if (!sMenu.APressMuted)
PlaySE(SE_SELECT);
return sMenu.cursorPos;
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
return MENU_B_PRESSED;
}
- else if (gMain.newKeys & DPAD_UP)
+ else if (JOY_NEW(DPAD_UP))
{
if (oldPos != Menu_MoveCursorNoWrapAround(-1))
PlaySE(SE_SELECT);
return MENU_NOTHING_CHOSEN;
}
- else if (gMain.newKeys & DPAD_DOWN)
+ else if (JOY_NEW(DPAD_DOWN))
{
if (oldPos != Menu_MoveCursorNoWrapAround(1))
PlaySE(SE_SELECT);
@@ -1039,23 +1039,23 @@ s8 Menu_ProcessInputNoWrap(void)
s8 ProcessMenuInput_other(void)
{
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
if (!sMenu.APressMuted)
PlaySE(SE_SELECT);
return sMenu.cursorPos;
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
return MENU_B_PRESSED;
}
- else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP)
+ else if (JOY_REPEAT(DPAD_ANY) == DPAD_UP)
{
PlaySE(SE_SELECT);
Menu_MoveCursor(-1);
return MENU_NOTHING_CHOSEN;
}
- else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN)
+ else if (JOY_REPEAT(DPAD_ANY) == DPAD_DOWN)
{
PlaySE(SE_SELECT);
Menu_MoveCursor(1);
@@ -1069,23 +1069,23 @@ s8 Menu_ProcessInputNoWrapAround_other(void)
{
u8 oldPos = sMenu.cursorPos;
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
if (!sMenu.APressMuted)
PlaySE(SE_SELECT);
return sMenu.cursorPos;
}
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
return MENU_B_PRESSED;
}
- if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP)
+ if (JOY_REPEAT(DPAD_ANY) == DPAD_UP)
{
if (oldPos != Menu_MoveCursorNoWrapAround(-1))
PlaySE(SE_SELECT);
return MENU_NOTHING_CHOSEN;
}
- if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN)
+ if (JOY_REPEAT(DPAD_ANY) == DPAD_DOWN)
{
if (oldPos != Menu_MoveCursorNoWrapAround(1))
PlaySE(SE_SELECT);
@@ -1407,34 +1407,34 @@ u8 ChangeGridMenuCursorPosition(s8 deltaX, s8 deltaY)
s8 sub_8199284(void)
{
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
return sMenu.cursorPos;
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
return MENU_B_PRESSED;
}
- else if (gMain.newKeys & DPAD_UP)
+ else if (JOY_NEW(DPAD_UP))
{
PlaySE(SE_SELECT);
ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_UP);
return MENU_NOTHING_CHOSEN;
}
- else if (gMain.newKeys & DPAD_DOWN)
+ else if (JOY_NEW(DPAD_DOWN))
{
PlaySE(SE_SELECT);
ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_DOWN);
return MENU_NOTHING_CHOSEN;
}
- else if (gMain.newKeys & DPAD_LEFT || GetLRKeysPressed() == MENU_L_PRESSED)
+ else if (JOY_NEW(DPAD_LEFT) || GetLRKeysPressed() == MENU_L_PRESSED)
{
PlaySE(SE_SELECT);
ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_LEFT, MENU_CURSOR_DELTA_NONE);
return MENU_NOTHING_CHOSEN;
}
- else if (gMain.newKeys & DPAD_RIGHT || GetLRKeysPressed() == MENU_R_PRESSED)
+ else if (JOY_NEW(DPAD_RIGHT) || GetLRKeysPressed() == MENU_R_PRESSED)
{
PlaySE(SE_SELECT);
ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_RIGHT, MENU_CURSOR_DELTA_NONE);
@@ -1448,34 +1448,34 @@ s8 Menu_ProcessInputGridLayout(void)
{
u8 oldPos = sMenu.cursorPos;
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
return sMenu.cursorPos;
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
return MENU_B_PRESSED;
}
- else if (gMain.newKeys & DPAD_UP)
+ else if (JOY_NEW(DPAD_UP))
{
if (oldPos != ChangeGridMenuCursorPosition(0, -1))
PlaySE(SE_SELECT);
return MENU_NOTHING_CHOSEN;
}
- else if (gMain.newKeys & DPAD_DOWN)
+ else if (JOY_NEW(DPAD_DOWN))
{
if (oldPos != ChangeGridMenuCursorPosition(0, 1))
PlaySE(SE_SELECT);
return MENU_NOTHING_CHOSEN;
}
- else if (gMain.newKeys & DPAD_LEFT || GetLRKeysPressed() == MENU_L_PRESSED)
+ else if (JOY_NEW(DPAD_LEFT) || GetLRKeysPressed() == MENU_L_PRESSED)
{
if (oldPos != ChangeGridMenuCursorPosition(-1, 0))
PlaySE(SE_SELECT);
return MENU_NOTHING_CHOSEN;
}
- else if (gMain.newKeys & DPAD_RIGHT || GetLRKeysPressed() == MENU_R_PRESSED)
+ else if (JOY_NEW(DPAD_RIGHT) || GetLRKeysPressed() == MENU_R_PRESSED)
{
if (oldPos != ChangeGridMenuCursorPosition(1, 0))
PlaySE(SE_SELECT);
@@ -1487,34 +1487,34 @@ s8 Menu_ProcessInputGridLayout(void)
s8 sub_81993D8(void)
{
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
return sMenu.cursorPos;
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
return MENU_B_PRESSED;
}
- else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP)
+ else if (JOY_REPEAT(DPAD_ANY) == DPAD_UP)
{
PlaySE(SE_SELECT);
ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_UP);
return MENU_NOTHING_CHOSEN;
}
- else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN)
+ else if (JOY_REPEAT(DPAD_ANY) == DPAD_DOWN)
{
PlaySE(SE_SELECT);
ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_DOWN);
return MENU_NOTHING_CHOSEN;
}
- else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_LEFT || GetLRKeysPressedAndHeld() == MENU_L_PRESSED)
+ else if (JOY_REPEAT(DPAD_ANY) == DPAD_LEFT || GetLRKeysPressedAndHeld() == MENU_L_PRESSED)
{
PlaySE(SE_SELECT);
ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_LEFT, MENU_CURSOR_DELTA_NONE);
return MENU_NOTHING_CHOSEN;
}
- else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_RIGHT || GetLRKeysPressedAndHeld() == MENU_R_PRESSED)
+ else if (JOY_REPEAT(DPAD_ANY) == DPAD_RIGHT || GetLRKeysPressedAndHeld() == MENU_R_PRESSED)
{
PlaySE(SE_SELECT);
ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_RIGHT, MENU_CURSOR_DELTA_NONE);
@@ -1529,34 +1529,34 @@ s8 sub_8199484(void)
{
u8 oldPos = sMenu.cursorPos;
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
return sMenu.cursorPos;
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
return MENU_B_PRESSED;
}
- else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP)
+ else if (JOY_REPEAT(DPAD_ANY) == DPAD_UP)
{
if (oldPos != ChangeGridMenuCursorPosition(0, -1))
PlaySE(SE_SELECT);
return MENU_NOTHING_CHOSEN;
}
- else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN)
+ else if (JOY_REPEAT(DPAD_ANY) == DPAD_DOWN)
{
if (oldPos != ChangeGridMenuCursorPosition(0, 1))
PlaySE(SE_SELECT);
return MENU_NOTHING_CHOSEN;
}
- else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_LEFT || GetLRKeysPressedAndHeld() == MENU_L_PRESSED)
+ else if (JOY_REPEAT(DPAD_ANY) == DPAD_LEFT || GetLRKeysPressedAndHeld() == MENU_L_PRESSED)
{
if (oldPos != ChangeGridMenuCursorPosition(-1, 0))
PlaySE(SE_SELECT);
return MENU_NOTHING_CHOSEN;
}
- else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_RIGHT || GetLRKeysPressedAndHeld() == MENU_R_PRESSED)
+ else if (JOY_REPEAT(DPAD_ANY) == DPAD_RIGHT || GetLRKeysPressedAndHeld() == MENU_R_PRESSED)
{
if (oldPos != ChangeGridMenuCursorPosition(1, 0))
PlaySE(SE_SELECT);
diff --git a/src/menu_helpers.c b/src/menu_helpers.c
index 69443d309..c80e52d27 100644
--- a/src/menu_helpers.c
+++ b/src/menu_helpers.c
@@ -183,7 +183,7 @@ bool8 AdjustQuantityAccordingToDPadInput(s16 *arg0, u16 arg1)
{
s16 valBefore = (*arg0);
- if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP)
+ if (JOY_REPEAT(DPAD_ANY) == DPAD_UP)
{
(*arg0)++;
if ((*arg0) > arg1)
@@ -199,7 +199,7 @@ bool8 AdjustQuantityAccordingToDPadInput(s16 *arg0, u16 arg1)
return TRUE;
}
}
- else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN)
+ else if (JOY_REPEAT(DPAD_ANY) == DPAD_DOWN)
{
(*arg0)--;
if ((*arg0) <= 0)
@@ -215,7 +215,7 @@ bool8 AdjustQuantityAccordingToDPadInput(s16 *arg0, u16 arg1)
return TRUE;
}
}
- else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_RIGHT)
+ else if (JOY_REPEAT(DPAD_ANY) == DPAD_RIGHT)
{
(*arg0) += 10;
if ((*arg0) > arg1)
@@ -231,7 +231,7 @@ bool8 AdjustQuantityAccordingToDPadInput(s16 *arg0, u16 arg1)
return TRUE;
}
}
- else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_LEFT)
+ else if (JOY_REPEAT(DPAD_ANY) == DPAD_LEFT)
{
(*arg0) -= 10;
if ((*arg0) <= 0)
@@ -255,9 +255,9 @@ u8 GetLRKeysPressed(void)
{
if (gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR)
{
- if (gMain.newKeys & L_BUTTON)
+ if (JOY_NEW(L_BUTTON))
return MENU_L_PRESSED;
- if (gMain.newKeys & R_BUTTON)
+ if (JOY_NEW(R_BUTTON))
return MENU_R_PRESSED;
}
@@ -268,9 +268,9 @@ u8 GetLRKeysPressedAndHeld(void)
{
if (gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR)
{
- if (gMain.newAndRepeatedKeys & L_BUTTON)
+ if (JOY_REPEAT(L_BUTTON))
return MENU_L_PRESSED;
- if (gMain.newAndRepeatedKeys & R_BUTTON)
+ if (JOY_REPEAT(R_BUTTON))
return MENU_R_PRESSED;
}
diff --git a/src/mirage_tower.c b/src/mirage_tower.c
index c980d76df..607083e26 100644
--- a/src/mirage_tower.c
+++ b/src/mirage_tower.c
@@ -723,144 +723,40 @@ static void sub_81BF248(struct Sprite *sprite)
}
}
-#ifdef NONMATCHING
static void sub_81BF2B8(u8* a, u16 b, u8 c, u8 d, u8 e)
{
- u8 r5, r4, r0, r2;
- u16 var;
+ u16 var, var2;
+ u8 r0, r5, r4, r2;
+ u8 r2_1, r4_1;
+ u8 b2, c2;
- r4 = r5 = b / d;
+ r4 = b / d;
gUnknown_030012A8[0] = r4;
- r0 = r2 = b % d;
+ r2 = b % d;
gUnknown_030012A8[1] = r2;
- r4 &= 7;
- r2 &= 7;
- gUnknown_030012A8[2] = r4;
- gUnknown_030012A8[3] = r2;
+ r4_1 = r4 & 7;
+ r2_1 = r2 & 7;
- r0 /= 8;
- r5 /= 8;
- gUnknown_030012A8[4] = r0;
- gUnknown_030012A8[5] = r5;
+ gUnknown_030012A8[2] = r4 & 7; //should be r4_1 but that doesn't match
+ gUnknown_030012A8[3] = r2 & 7; //should be r2_1 but that doesn't match
- var = ((d / 8) * (r5 * 64)) + (r0 * 64);
- gUnknown_030012A8[6] = var;
+ r0 = r2 / 8;
+ r5 = r4 / 8;
- var += (r4 * 8) + r2;
- gUnknown_030012A8[7] = var;
+ gUnknown_030012A8[4] = r2 / 8; //should just be r0, but that doesn't match
+ gUnknown_030012A8[5] = r4 / 8; //should be just r5 but that doesn't match
- // This part is non-matching. 99% sure it IS functionally equivalent, though.
- b = (b & 1) ^ 1;
- c = (c << ((b) << 2)) | (15 << ((b ^ 1) << 2));
+ var = (d / 8) * (r5 * 64) + (r0 * 64);
- a[(var / 2) + (e * 32)] &= c;
-}
+ gUnknown_030012A8[6] = var;
-#else
-NAKED
-static void sub_81BF2B8(u8* a, u16 b, u8 c, u8 d, u8 e)
-{
- asm_unified(
- "push {r4-r7,lr}\n\
- mov r7, r10\n\
- mov r6, r9\n\
- mov r5, r8\n\
- push {r5-r7}\n\
- sub sp, 0x8\n\
- str r0, [sp]\n\
- mov r10, r1\n\
- adds r6, r2, 0\n\
- mov r8, r3\n\
- ldr r0, [sp, 0x28]\n\
- mov r9, r0\n\
- lsls r1, 16\n\
- lsrs r1, 16\n\
- mov r10, r1\n\
- lsls r6, 24\n\
- lsrs r6, 24\n\
- mov r0, r8\n\
- lsls r0, 24\n\
- mov r8, r0\n\
- lsrs r7, r0, 24\n\
- mov r1, r9\n\
- lsls r1, 24\n\
- lsrs r1, 24\n\
- mov r9, r1\n\
- mov r0, r10\n\
- adds r1, r7, 0\n\
- bl __divsi3\n\
- adds r5, r0, 0\n\
- lsls r5, 24\n\
- lsrs r4, r5, 24\n\
- ldr r3, =gUnknown_030012A8\n\
- strh r4, [r3]\n\
- mov r0, r10\n\
- adds r1, r7, 0\n\
- str r3, [sp, 0x4]\n\
- bl __modsi3\n\
- lsls r0, 24\n\
- lsrs r2, r0, 24\n\
- ldr r3, [sp, 0x4]\n\
- strh r2, [r3, 0x2]\n\
- movs r1, 0x7\n\
- ands r4, r1\n\
- ands r2, r1\n\
- strh r4, [r3, 0x4]\n\
- strh r2, [r3, 0x6]\n\
- lsrs r0, 27\n\
- lsrs r5, 27\n\
- strh r0, [r3, 0x8]\n\
- strh r5, [r3, 0xA]\n\
- mov r1, r8\n\
- lsrs r1, 27\n\
- lsls r1, 6\n\
- mov r8, r1\n\
- mov r1, r8\n\
- muls r1, r5\n\
- lsls r0, 6\n\
- adds r1, r0\n\
- lsls r1, 16\n\
- lsrs r1, 16\n\
- strh r1, [r3, 0xC]\n\
- lsls r4, 3\n\
- adds r4, r2\n\
- adds r1, r4\n\
- lsls r4, r1, 16\n\
- lsrs r4, 17\n\
- strh r1, [r3, 0xE]\n\
- movs r1, 0x1\n\
- mov r0, r10\n\
- ands r1, r0\n\
- movs r2, 0x1\n\
- eors r1, r2\n\
- lsls r0, r1, 2\n\
- lsls r6, r0\n\
- eors r1, r2\n\
- lsls r1, 2\n\
- movs r0, 0xF\n\
- lsls r0, r1\n\
- orrs r6, r0\n\
- lsls r6, 24\n\
- lsrs r6, 24\n\
- mov r1, r9\n\
- lsls r1, 5\n\
- mov r9, r1\n\
- add r9, r4\n\
- ldr r1, [sp]\n\
- add r1, r9\n\
- ldrb r0, [r1]\n\
- ands r6, r0\n\
- strb r6, [r1]\n\
- add sp, 0x8\n\
- pop {r3-r5}\n\
- mov r8, r3\n\
- mov r9, r4\n\
- mov r10, r5\n\
- pop {r4-r7}\n\
- pop {r0}\n\
- bx r0\n\
- .pool");
+ var2 = var + ((r4_1 * 8) + r2_1);
+ var2 /= 2;
+ gUnknown_030012A8[7] = var + ((r4_1 * 8) + r2_1); // should be var2 with var2 being divided by 2 AFTER this assignment, but that doesn't match.
+
+ b2 = ((b % 2) ^ 1);
+ c2 = (c << (b2 << 2)) | (15 << (((b2 ^ 1) << 2)));
+ a[var2 + (e * 32)] &= c2;
}
-#endif // NONMATCHING
diff --git a/src/mon_markings.c b/src/mon_markings.c
index db5df07e8..c2afdda83 100644
--- a/src/mon_markings.c
+++ b/src/mon_markings.c
@@ -394,7 +394,7 @@ bool8 sub_811FBA4(void)
{
u16 i;
- if (gMain.newKeys & DPAD_UP)
+ if (JOY_NEW(DPAD_UP))
{
s8 pos;
PlaySE(SE_SELECT);
@@ -404,7 +404,7 @@ bool8 sub_811FBA4(void)
return TRUE;
}
- if (gMain.newKeys & DPAD_DOWN)
+ if (JOY_NEW(DPAD_DOWN))
{
s8 pos;
PlaySE(SE_SELECT);
@@ -414,7 +414,7 @@ bool8 sub_811FBA4(void)
return TRUE;
}
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
@@ -433,7 +433,7 @@ bool8 sub_811FBA4(void)
return TRUE;
}
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
return FALSE;
diff --git a/src/move_relearner.c b/src/move_relearner.c
index 3e7caf133..cd4da5835 100644
--- a/src/move_relearner.c
+++ b/src/move_relearner.c
@@ -732,7 +732,7 @@ static void DoMoveRelearnerMain(void)
}
break;
case MENU_STATE_WAIT_FOR_A_BUTTON:
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
sMoveRelearnerStruct->state = MENU_STATE_FADE_AND_RETURN;
@@ -778,7 +778,7 @@ static void HandleInput(bool8 showContest)
switch (itemId)
{
case LIST_NOTHING_CHOSEN:
- if (!(gMain.newKeys & (DPAD_LEFT | DPAD_RIGHT)) && !GetLRKeysPressed())
+ if (!(JOY_NEW(DPAD_LEFT | DPAD_RIGHT)) && !GetLRKeysPressed())
{
break;
}
diff --git a/src/mystery_event_menu.c b/src/mystery_event_menu.c
index 032cc3340..00dcbf0e3 100644
--- a/src/mystery_event_menu.c
+++ b/src/mystery_event_menu.c
@@ -163,7 +163,7 @@ static void CB2_MysteryEventMenu(void)
PrintMysteryMenuText(0, gText_PressAToLoadEvent, 1, 2, 1);
gMain.state++;
}
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
CloseLink();
@@ -177,7 +177,7 @@ static void CB2_MysteryEventMenu(void)
case 5:
if (GetLinkPlayerCount_2() == 2)
{
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
CheckShouldAdvanceLinkState();
@@ -187,7 +187,7 @@ static void CB2_MysteryEventMenu(void)
CopyWindowToVram(1, 3);
gMain.state++;
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
CloseLink();
@@ -227,7 +227,7 @@ static void CB2_MysteryEventMenu(void)
}
}
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
CloseLink();
@@ -274,7 +274,7 @@ static void CB2_MysteryEventMenu(void)
}
break;
case 14:
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
gMain.state++;
diff --git a/src/mystery_gift.c b/src/mystery_gift.c
index ca5ab1baf..a23f159b2 100644
--- a/src/mystery_gift.c
+++ b/src/mystery_gift.c
@@ -561,7 +561,7 @@ bool32 MG_PrintTextOnWindow1AndWaitButton(u8 *textState, const u8 *str)
goto inc;
case 1:
DrawDownArrow(1, 0xD0, 0x14, 1, FALSE, &sDownArrowCounterAndYCoordIdx[0], &sDownArrowCounterAndYCoordIdx[1]);
- if (({gMain.newKeys & (A_BUTTON | B_BUTTON);}))
+ if (({JOY_NEW(A_BUTTON | B_BUTTON);}))
{
inc:
(*textState)++;
@@ -595,7 +595,7 @@ bool32 unref_HideDownArrowAndWaitButton(u8 * textState)
{
case 0:
HideDownArrow();
- if (({gMain.newKeys & (A_BUTTON | B_BUTTON);}))
+ if (({JOY_NEW(A_BUTTON | B_BUTTON);}))
{
(*textState)++;
}
@@ -930,7 +930,7 @@ static bool32 mevent_save_game(u8 * state)
(*state)++;
break;
case 3:
- if (({gMain.newKeys & (A_BUTTON | B_BUTTON);}))
+ if (({JOY_NEW(A_BUTTON | B_BUTTON);}))
{
(*state)++;
}
@@ -1458,11 +1458,11 @@ void task00_mystery_gift(u8 taskId)
case 20:
if (data->IsCardOrNews == 0)
{
- if (({gMain.newKeys & A_BUTTON;}))
+ if (({JOY_NEW(A_BUTTON);}))
{
data->state = 21;
}
- if (({gMain.newKeys & B_BUTTON;}))
+ if (({JOY_NEW(B_BUTTON);}))
{
data->state = 27;
}
diff --git a/src/option_menu.c b/src/option_menu.c
index 1cf0bad2e..b6440a89c 100644
--- a/src/option_menu.c
+++ b/src/option_menu.c
@@ -271,16 +271,16 @@ static void Task_OptionMenuFadeIn(u8 taskId)
static void Task_OptionMenuProcessInput(u8 taskId)
{
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
if (gTasks[taskId].data[TD_MENUSELECTION] == MENUITEM_CANCEL)
gTasks[taskId].func = Task_OptionMenuSave;
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
gTasks[taskId].func = Task_OptionMenuSave;
}
- else if (gMain.newKeys & DPAD_UP)
+ else if (JOY_NEW(DPAD_UP))
{
if (gTasks[taskId].data[TD_MENUSELECTION] > 0)
gTasks[taskId].data[TD_MENUSELECTION]--;
@@ -288,7 +288,7 @@ static void Task_OptionMenuProcessInput(u8 taskId)
gTasks[taskId].data[TD_MENUSELECTION] = MENUITEM_CANCEL;
HighlightOptionMenuItem(gTasks[taskId].data[TD_MENUSELECTION]);
}
- else if (gMain.newKeys & DPAD_DOWN)
+ else if (JOY_NEW(DPAD_DOWN))
{
if (gTasks[taskId].data[TD_MENUSELECTION] < MENUITEM_CANCEL)
gTasks[taskId].data[TD_MENUSELECTION]++;
@@ -405,7 +405,7 @@ static void DrawOptionMenuChoice(const u8 *text, u8 x, u8 y, u8 style)
static u8 TextSpeed_ProcessInput(u8 selection)
{
- if (gMain.newKeys & DPAD_RIGHT)
+ if (JOY_NEW(DPAD_RIGHT))
{
if (selection <= 1)
selection++;
@@ -414,7 +414,7 @@ static u8 TextSpeed_ProcessInput(u8 selection)
sArrowPressed = TRUE;
}
- if (gMain.newKeys & DPAD_LEFT)
+ if (JOY_NEW(DPAD_LEFT))
{
if (selection != 0)
selection--;
@@ -451,7 +451,7 @@ static void TextSpeed_DrawChoices(u8 selection)
static u8 BattleScene_ProcessInput(u8 selection)
{
- if (gMain.newKeys & (DPAD_LEFT | DPAD_RIGHT))
+ if (JOY_NEW(DPAD_LEFT | DPAD_RIGHT))
{
selection ^= 1;
sArrowPressed = TRUE;
@@ -474,7 +474,7 @@ static void BattleScene_DrawChoices(u8 selection)
static u8 BattleStyle_ProcessInput(u8 selection)
{
- if (gMain.newKeys & (DPAD_LEFT | DPAD_RIGHT))
+ if (JOY_NEW(DPAD_LEFT | DPAD_RIGHT))
{
selection ^= 1;
sArrowPressed = TRUE;
@@ -497,7 +497,7 @@ static void BattleStyle_DrawChoices(u8 selection)
static u8 Sound_ProcessInput(u8 selection)
{
- if (gMain.newKeys & (DPAD_LEFT | DPAD_RIGHT))
+ if (JOY_NEW(DPAD_LEFT | DPAD_RIGHT))
{
selection ^= 1;
SetPokemonCryStereo(selection);
@@ -521,7 +521,7 @@ static void Sound_DrawChoices(u8 selection)
static u8 FrameType_ProcessInput(u8 selection)
{
- if (gMain.newKeys & DPAD_RIGHT)
+ if (JOY_NEW(DPAD_RIGHT))
{
if (selection < WINDOW_FRAMES_COUNT - 1)
selection++;
@@ -532,7 +532,7 @@ static u8 FrameType_ProcessInput(u8 selection)
LoadPalette(GetWindowFrameTilesPal(selection)->pal, 0x70, 0x20);
sArrowPressed = TRUE;
}
- if (gMain.newKeys & DPAD_LEFT)
+ if (JOY_NEW(DPAD_LEFT))
{
if (selection != 0)
selection--;
@@ -579,7 +579,7 @@ static void FrameType_DrawChoices(u8 selection)
static u8 ButtonMode_ProcessInput(u8 selection)
{
- if (gMain.newKeys & DPAD_RIGHT)
+ if (JOY_NEW(DPAD_RIGHT))
{
if (selection <= 1)
selection++;
@@ -588,7 +588,7 @@ static u8 ButtonMode_ProcessInput(u8 selection)
sArrowPressed = TRUE;
}
- if (gMain.newKeys & DPAD_LEFT)
+ if (JOY_NEW(DPAD_LEFT))
{
if (selection != 0)
selection--;
diff --git a/src/overworld.c b/src/overworld.c
index d18e3d3bc..2d798f2ec 100644
--- a/src/overworld.c
+++ b/src/overworld.c
@@ -2454,20 +2454,19 @@ static void UpdateHeldKeyCode(u16 key)
static u16 KeyInterCB_ReadButtons(u32 key)
{
- if (gMain.heldKeys & DPAD_UP)
+ if (JOY_HELD(DPAD_UP))
return LINK_KEY_CODE_DPAD_UP;
- else if (gMain.heldKeys & DPAD_DOWN)
+ if (JOY_HELD(DPAD_DOWN))
return LINK_KEY_CODE_DPAD_DOWN;
- else if (gMain.heldKeys & DPAD_LEFT)
+ if (JOY_HELD(DPAD_LEFT))
return LINK_KEY_CODE_DPAD_LEFT;
- else if (gMain.heldKeys & DPAD_RIGHT)
+ if (JOY_HELD(DPAD_RIGHT))
return LINK_KEY_CODE_DPAD_RIGHT;
- else if (gMain.newKeys & START_BUTTON)
+ if (JOY_NEW(START_BUTTON))
return LINK_KEY_CODE_START_BUTTON;
- else if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
return LINK_KEY_CODE_A_BUTTON;
- else
- return LINK_KEY_CODE_EMPTY;
+ return LINK_KEY_CODE_EMPTY;
}
static u16 GetDirectionForDpadKey(u16 a1)
@@ -2574,7 +2573,7 @@ static u16 sub_8087170(u32 keyOrPlayerId)
{
if (sPlayerTradingStates[keyOrPlayerId] == PLAYER_TRADING_STATE_UNK_2)
{
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
SetKeyInterceptCallback(KeyInterCB_DoNothingAndKeepAlive);
return LINK_KEY_CODE_UNK_7;
diff --git a/src/party_menu.c b/src/party_menu.c
index 7514cf545..e509ef6e0 100755
--- a/src/party_menu.c
+++ b/src/party_menu.c
@@ -1411,7 +1411,7 @@ static u16 PartyMenuButtonHandler(s8 *slotPtr)
break;
}
- if (gMain.newKeys & START_BUTTON)
+ if (JOY_NEW(START_BUTTON))
return 8;
if (movementDir)
@@ -1421,10 +1421,10 @@ static u16 PartyMenuButtonHandler(s8 *slotPtr)
}
// Pressed Cancel
- if ((gMain.newKeys & A_BUTTON) && *slotPtr == PARTY_SIZE + 1)
+ if ((JOY_NEW(A_BUTTON)) && *slotPtr == PARTY_SIZE + 1)
return 2;
- return gMain.newKeys & (A_BUTTON | B_BUTTON);
+ return JOY_NEW(A_BUTTON | B_BUTTON);
}
static void UpdateCurrentPartySelection(s8 *slotPtr, s8 movementDir)
@@ -3765,7 +3765,7 @@ static u16 GetFieldMoveMonSpecies(void)
static void Task_CancelAfterAorBPress(u8 taskId)
{
- if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON))
+ if ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON)))
CursorCb_Cancel1(taskId);
}
@@ -4722,7 +4722,7 @@ static void Task_DoLearnedMoveFanfareAfterText(u8 taskId)
static void Task_LearnNextMoveOrClosePartyMenu(u8 taskId)
{
- if (IsFanfareTaskInactive() && ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)))
+ if (IsFanfareTaskInactive() && ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON))))
{
if (gPartyMenu.learnMoveState == 1)
Task_TryLearningNextMove(taskId);
@@ -4931,7 +4931,7 @@ static void UpdateMonDisplayInfoAfterRareCandy(u8 slot, struct Pokemon *mon)
static void Task_DisplayLevelUpStatsPg1(u8 taskId)
{
- if (WaitFanfare(FALSE) && IsPartyMenuTextPrinterActive() != TRUE && ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)))
+ if (WaitFanfare(FALSE) && IsPartyMenuTextPrinterActive() != TRUE && ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON))))
{
PlaySE(SE_SELECT);
DisplayLevelUpStatsPg1(taskId);
@@ -4941,7 +4941,7 @@ static void Task_DisplayLevelUpStatsPg1(u8 taskId)
static void Task_DisplayLevelUpStatsPg2(u8 taskId)
{
- if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON))
+ if ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON)))
{
PlaySE(SE_SELECT);
DisplayLevelUpStatsPg2(taskId);
@@ -4972,7 +4972,7 @@ static void Task_TryLearnNewMoves(u8 taskId)
{
u16 learnMove;
- if (WaitFanfare(0) && ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)))
+ if (WaitFanfare(0) && ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON))))
{
RemoveLevelUpStatsWindow();
learnMove = MonTryLearningNewMove(&gPlayerParty[gPartyMenu.slotId], TRUE);
@@ -5609,7 +5609,7 @@ static void Task_ValidateChosenHalfParty(u8 taskId)
static void Task_ContinueChoosingHalfParty(u8 taskId)
{
- if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON))
+ if ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON)))
{
PlaySE(SE_SELECT);
DisplayPartyMenuStdMessage(PARTY_MSG_CHOOSE_MON);
diff --git a/src/player_pc.c b/src/player_pc.c
index 2010d84f8..238424ee3 100644
--- a/src/player_pc.c
+++ b/src/player_pc.c
@@ -1134,7 +1134,7 @@ static void ItemStorage_ProcessInput(u8 taskId)
s32 id;
data = gTasks[taskId].data;
- if (gMain.newKeys & SELECT_BUTTON)
+ if (JOY_NEW(SELECT_BUTTON))
{
ListMenuGetScrollAndRow(data[5], &(playerPCItemPageInfo.itemsAbove), &(playerPCItemPageInfo.cursorPos));
if ((playerPCItemPageInfo.itemsAbove + playerPCItemPageInfo.cursorPos) != (playerPCItemPageInfo.count - 1))
@@ -1212,7 +1212,7 @@ static void sub_816C4FC(u8 taskId)
s32 id;
data = gTasks[taskId].data;
- if (gMain.newKeys & SELECT_BUTTON)
+ if (JOY_NEW(SELECT_BUTTON))
{
ListMenuGetScrollAndRow(data[5], &(playerPCItemPageInfo.itemsAbove), &(playerPCItemPageInfo.cursorPos));
ItemStorage_DoItemSwap(taskId, FALSE);
@@ -1227,7 +1227,7 @@ static void sub_816C4FC(u8 taskId)
case LIST_NOTHING_CHOSEN:
break;
case LIST_CANCEL:
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
ItemStorage_DoItemSwap(taskId, FALSE);
}
@@ -1332,7 +1332,7 @@ static void ItemStorage_HandleQuantityRolling(u8 taskId)
sub_816C6BC(sub_816BC7C(4), data[2], STR_CONV_MODE_LEADING_ZEROS, 8, 1, 3);
else
{
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
sub_816BCC4(4);
@@ -1341,7 +1341,7 @@ static void ItemStorage_HandleQuantityRolling(u8 taskId)
else
ItemStorage_DoItemToss(taskId);
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
sub_816BCC4(4);
@@ -1412,7 +1412,7 @@ static void ItemStorage_HandleRemoveItem(u8 taskId)
s16 *data;
data = gTasks[taskId].data;
- if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ if (JOY_NEW(A_BUTTON | B_BUTTON))
{
RemovePCItem((playerPCItemPageInfo.cursorPos + playerPCItemPageInfo.itemsAbove), data[2]);
DestroyListMenuTask(data[5], &(playerPCItemPageInfo.itemsAbove), &(playerPCItemPageInfo.cursorPos));
@@ -1429,7 +1429,7 @@ static void ItemStorage_WaitPressHandleResumeProcessInput(u8 taskId)
s16 *data;
data = gTasks[taskId].data;
- if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ if (JOY_NEW(A_BUTTON | B_BUTTON))
{
ItemStorage_PrintItemPcResponse(ItemStorage_GetItemPcResponse(gSaveBlock1Ptr->pcItems[(playerPCItemPageInfo.itemsAbove + playerPCItemPageInfo.cursorPos)].itemId));
ItemStorage_StartScrollIndicatorAndProcessInput(taskId);
diff --git a/src/pokeblock.c b/src/pokeblock.c
index fc5451b0a..b44112b88 100644
--- a/src/pokeblock.c
+++ b/src/pokeblock.c
@@ -984,7 +984,7 @@ static void Task_HandlePokeblockMenuInput(u8 taskId)
if (!gPaletteFade.active && MenuHelpers_CallLinkSomething() != TRUE)
{
- if (gMain.newKeys & SELECT_BUTTON)
+ if (JOY_NEW(SELECT_BUTTON))
{
ListMenuGetScrollAndRow(data[0], &sSavedPokeblockData.lastItemPage, &sSavedPokeblockData.lastItemPos);
if (sSavedPokeblockData.lastItemPage + sSavedPokeblockData.lastItemPos != sPokeblockMenu->itemsNo - 1)
@@ -1035,7 +1035,7 @@ static void Task_HandlePokeblocksSwapInput(u8 taskId)
if (MenuHelpers_CallLinkSomething() == TRUE)
return;
- if (gMain.newKeys & SELECT_BUTTON)
+ if (JOY_NEW(SELECT_BUTTON))
{
PlaySE(SE_SELECT);
ListMenuGetScrollAndRow(data[0], &sSavedPokeblockData.lastItemPage, &sSavedPokeblockData.lastItemPos);
@@ -1069,7 +1069,7 @@ static void Task_HandlePokeblocksSwapInput(u8 taskId)
break;
case LIST_CANCEL: // same id as STOW CASE field
PlaySE(SE_SELECT);
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
HandlePokeblocksSwap(taskId, FALSE);
else
HandlePokeblocksSwap(taskId, TRUE);
@@ -1193,7 +1193,7 @@ static void TossPokeblockChoice_Yes(u8 taskId)
static void HandleErasePokeblock(u8 taskId)
{
- if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ if (JOY_NEW(A_BUTTON | B_BUTTON))
{
s16 *data;
u16 *lastPage, *lastPos;
diff --git a/src/pokedex.c b/src/pokedex.c
index 4f41c5557..e49911891 100644
--- a/src/pokedex.c
+++ b/src/pokedex.c
@@ -1673,7 +1673,7 @@ static void Task_HandlePokedexInput(u8 taskId)
}
else
{
- if ((gMain.newKeys & A_BUTTON) && sPokedexView->pokedexList[sPokedexView->selectedPokemon].seen)
+ if ((JOY_NEW(A_BUTTON)) && sPokedexView->pokedexList[sPokedexView->selectedPokemon].seen)
{
UpdateSelectedMonSpriteId();
BeginNormalPaletteFade(~(1 << (gSprites[sPokedexView->selectedMonSpriteId].oam.paletteNum + 16)), 0, 0, 0x10, RGB_BLACK);
@@ -1682,7 +1682,7 @@ static void Task_HandlePokedexInput(u8 taskId)
PlaySE(SE_PIN);
FreeWindowAndBgBuffers();
}
- else if (gMain.newKeys & START_BUTTON)
+ else if (JOY_NEW(START_BUTTON))
{
sPokedexView->menuY = 0;
sPokedexView->menuIsOpen = TRUE;
@@ -1690,7 +1690,7 @@ static void Task_HandlePokedexInput(u8 taskId)
gTasks[taskId].func = Task_HandlePokedexStartMenuInput;
PlaySE(SE_SELECT);
}
- else if (gMain.newKeys & SELECT_BUTTON)
+ else if (JOY_NEW(SELECT_BUTTON))
{
PlaySE(SE_SELECT);
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK);
@@ -1704,7 +1704,7 @@ static void Task_HandlePokedexInput(u8 taskId)
PlaySE(SE_PC_LOGIN);
FreeWindowAndBgBuffers();
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK);
gTasks[taskId].func = Task_ClosePokedex;
@@ -1737,7 +1737,7 @@ static void Task_HandlePokedexStartMenuInput(u8 taskId)
}
else
{
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
switch (sPokedexView->menuCursorPos)
{
@@ -1768,18 +1768,18 @@ static void Task_HandlePokedexStartMenuInput(u8 taskId)
}
//Exit menu when Start or B is pressed
- if (gMain.newKeys & (START_BUTTON | B_BUTTON))
+ if (JOY_NEW(START_BUTTON | B_BUTTON))
{
sPokedexView->menuIsOpen = FALSE;
gTasks[taskId].func = Task_HandlePokedexInput;
PlaySE(SE_SELECT);
}
- else if ((gMain.newAndRepeatedKeys & DPAD_UP) && sPokedexView->menuCursorPos != 0)
+ else if ((JOY_REPEAT(DPAD_UP)) && sPokedexView->menuCursorPos != 0)
{
sPokedexView->menuCursorPos--;
PlaySE(SE_SELECT);
}
- else if ((gMain.newAndRepeatedKeys & DPAD_DOWN) && sPokedexView->menuCursorPos < 3)
+ else if ((JOY_REPEAT(DPAD_DOWN)) && sPokedexView->menuCursorPos < 3)
{
sPokedexView->menuCursorPos++;
PlaySE(SE_SELECT);
@@ -1873,7 +1873,7 @@ static void Task_HandleSearchResultsInput(u8 taskId)
}
else
{
- if ((gMain.newKeys & A_BUTTON) && sPokedexView->pokedexList[sPokedexView->selectedPokemon].seen)
+ if ((JOY_NEW(A_BUTTON)) && sPokedexView->pokedexList[sPokedexView->selectedPokemon].seen)
{
u32 a;
@@ -1885,7 +1885,7 @@ static void Task_HandleSearchResultsInput(u8 taskId)
PlaySE(SE_PIN);
FreeWindowAndBgBuffers();
}
- else if (gMain.newKeys & START_BUTTON)
+ else if (JOY_NEW(START_BUTTON))
{
sPokedexView->menuY = 0;
sPokedexView->menuIsOpen = TRUE;
@@ -1893,7 +1893,7 @@ static void Task_HandleSearchResultsInput(u8 taskId)
gTasks[taskId].func = Task_HandleSearchResultsStartMenuInput;
PlaySE(SE_SELECT);
}
- else if (gMain.newKeys & SELECT_BUTTON)
+ else if (JOY_NEW(SELECT_BUTTON))
{
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK);
gTasks[taskId].tTaskId = LoadSearchMenu();
@@ -1902,7 +1902,7 @@ static void Task_HandleSearchResultsInput(u8 taskId)
PlaySE(SE_PC_LOGIN);
FreeWindowAndBgBuffers();
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK);
gTasks[taskId].func = Task_ReturnToPokedexFromSearchResults;
@@ -1934,7 +1934,7 @@ static void Task_HandleSearchResultsStartMenuInput(u8 taskId)
}
else
{
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
switch (sPokedexView->menuCursorPos)
{
@@ -1970,18 +1970,18 @@ static void Task_HandleSearchResultsStartMenuInput(u8 taskId)
}
//Exit menu when Start or B is pressed
- if (gMain.newKeys & (START_BUTTON | B_BUTTON))
+ if (JOY_NEW(START_BUTTON | B_BUTTON))
{
sPokedexView->menuIsOpen = FALSE;
gTasks[taskId].func = Task_HandleSearchResultsInput;
PlaySE(SE_SELECT);
}
- else if ((gMain.newAndRepeatedKeys & DPAD_UP) && sPokedexView->menuCursorPos)
+ else if ((JOY_REPEAT(DPAD_UP)) && sPokedexView->menuCursorPos)
{
sPokedexView->menuCursorPos--;
PlaySE(SE_SELECT);
}
- else if ((gMain.newAndRepeatedKeys & DPAD_DOWN) && sPokedexView->menuCursorPos < 4)
+ else if ((JOY_REPEAT(DPAD_DOWN)) && sPokedexView->menuCursorPos < 4)
{
sPokedexView->menuCursorPos++;
PlaySE(SE_SELECT);
@@ -2590,7 +2590,7 @@ static u16 TryDoPokedexScroll(u16 selectedMon, u16 ignored)
u16 startingPos;
u8 scrollDir = 0;
- if ((gMain.heldKeys & DPAD_UP) && (selectedMon > 0))
+ if ((JOY_HELD(DPAD_UP)) && (selectedMon > 0))
{
scrollDir = 1;
selectedMon = GetNextPosition(1, selectedMon, 0, sPokedexView->pokemonListCount - 1);
@@ -2598,7 +2598,7 @@ static u16 TryDoPokedexScroll(u16 selectedMon, u16 ignored)
CreateMonListEntry(1, selectedMon, ignored);
PlaySE(SE_DEX_SCROLL);
}
- else if ((gMain.heldKeys & DPAD_DOWN) && (selectedMon < sPokedexView->pokemonListCount - 1))
+ else if (JOY_HELD(DPAD_DOWN) && (selectedMon < sPokedexView->pokemonListCount - 1))
{
scrollDir = 2;
selectedMon = GetNextPosition(0, selectedMon, 0, sPokedexView->pokemonListCount - 1);
@@ -2606,7 +2606,7 @@ static u16 TryDoPokedexScroll(u16 selectedMon, u16 ignored)
CreateMonListEntry(2, selectedMon, ignored);
PlaySE(SE_DEX_SCROLL);
}
- else if ((gMain.newKeys & DPAD_LEFT) && (selectedMon > 0))
+ else if (JOY_NEW(DPAD_LEFT) && (selectedMon > 0))
{
startingPos = selectedMon;
@@ -2617,7 +2617,7 @@ static u16 TryDoPokedexScroll(u16 selectedMon, u16 ignored)
CreateMonSpritesAtPos(selectedMon, 0xE);
PlaySE(SE_DEX_PAGE);
}
- else if ((gMain.newKeys & DPAD_RIGHT) && (selectedMon < sPokedexView->pokemonListCount - 1))
+ else if ((JOY_NEW(DPAD_RIGHT)) && (selectedMon < sPokedexView->pokemonListCount - 1))
{
startingPos = selectedMon;
for (i = 0; i < 7; i++)
@@ -2666,7 +2666,7 @@ static bool8 TryDoInfoScreenScroll(void)
u16 nextPokemon;
u16 selectedPokemon = sPokedexView->selectedPokemon;
- if ((gMain.newKeys & DPAD_UP) && selectedPokemon)
+ if ((JOY_NEW(DPAD_UP)) && selectedPokemon)
{
nextPokemon = selectedPokemon;
while (nextPokemon != 0)
@@ -2689,7 +2689,7 @@ static bool8 TryDoInfoScreenScroll(void)
return TRUE;
}
}
- else if ((gMain.newKeys & DPAD_DOWN) && selectedPokemon < sPokedexView->pokemonListCount - 1)
+ else if ((JOY_NEW(DPAD_DOWN)) && selectedPokemon < sPokedexView->pokemonListCount - 1)
{
nextPokemon = selectedPokemon;
while (nextPokemon < sPokedexView->pokemonListCount - 1)
@@ -3356,14 +3356,14 @@ static void Task_HandleInfoScreenInput(u8 taskId)
PlaySE(SE_DEX_SCROLL);
return;
}
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
gTasks[taskId].func = Task_ExitInfoScreen;
PlaySE(SE_PC_OFF);
return;
}
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
switch (sPokedexView->selectedScreen)
{
@@ -3400,8 +3400,8 @@ static void Task_HandleInfoScreenInput(u8 taskId)
}
return;
}
- if (((gMain.newKeys & DPAD_LEFT)
- || ((gMain.newKeys & L_BUTTON) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR))
+ if ((JOY_NEW(DPAD_LEFT)
+ || (JOY_NEW(L_BUTTON) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR))
&& sPokedexView->selectedScreen > 0)
{
sPokedexView->selectedScreen--;
@@ -3409,8 +3409,8 @@ static void Task_HandleInfoScreenInput(u8 taskId)
PlaySE(SE_DEX_PAGE);
return;
}
- if (((gMain.newKeys & DPAD_RIGHT)
- || ((gMain.newKeys & R_BUTTON) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR))
+ if ((JOY_NEW(DPAD_RIGHT)
+ || (JOY_NEW(R_BUTTON) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR))
&& sPokedexView->selectedScreen < CANCEL_SCREEN)
{
sPokedexView->selectedScreen++;
@@ -3630,7 +3630,7 @@ static void Task_HandleCryScreenInput(u8 taskId)
else
LoadPlayArrowPalette(FALSE);
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
LoadPlayArrowPalette(TRUE);
CryScreenPlayButton(NationalPokedexNumToSpecies(sPokedexListItem->dexNum));
@@ -3638,7 +3638,7 @@ static void Task_HandleCryScreenInput(u8 taskId)
}
else if (!gPaletteFade.active)
{
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 0x10, RGB_BLACK);
m4aMPlayContinue(&gMPlayInfo_BGM);
@@ -3647,8 +3647,8 @@ static void Task_HandleCryScreenInput(u8 taskId)
PlaySE(SE_PC_OFF);
return;
}
- if ((gMain.newKeys & DPAD_LEFT)
- || ((gMain.newKeys & L_BUTTON) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR))
+ if ((JOY_NEW(DPAD_LEFT))
+ || ((JOY_NEW(L_BUTTON)) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR))
{
BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 0x10, RGB_BLACK);
m4aMPlayContinue(&gMPlayInfo_BGM);
@@ -3657,8 +3657,8 @@ static void Task_HandleCryScreenInput(u8 taskId)
PlaySE(SE_DEX_PAGE);
return;
}
- if ((gMain.newKeys & DPAD_RIGHT)
- || ((gMain.newKeys & R_BUTTON) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR))
+ if (JOY_NEW(DPAD_RIGHT)
+ || (JOY_NEW(R_BUTTON) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR))
{
if (!sPokedexListItem->owned)
{
@@ -3810,15 +3810,15 @@ static void Task_LoadSizeScreen(u8 taskId)
static void Task_HandleSizeScreenInput(u8 taskId)
{
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 0x10, RGB_BLACK);
sPokedexView->screenSwitchState = 1;
gTasks[taskId].func = Task_SwitchScreensFromSizeScreen;
PlaySE(SE_PC_OFF);
}
- else if ((gMain.newKeys & DPAD_LEFT)
- || ((gMain.newKeys & L_BUTTON) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR))
+ else if ((JOY_NEW(DPAD_LEFT))
+ || ((JOY_NEW(L_BUTTON)) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR))
{
BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 0x10, RGB_BLACK);
sPokedexView->screenSwitchState = 2;
@@ -4010,7 +4010,7 @@ static void Task_DisplayCaughtMonDexPage(u8 taskId)
static void Task_HandleCaughtMonPageInput(u8 taskId)
{
- if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ if (JOY_NEW(A_BUTTON | B_BUTTON))
{
BeginNormalPaletteFade(0x0000FFFF, 0, 0, 16, RGB_BLACK);
gSprites[gTasks[taskId].tMonSpriteId].callback = SpriteCB_SlideCaughtMonToCenter;
@@ -4907,13 +4907,13 @@ static void Task_SwitchToSearchMenuTopBar(u8 taskId)
static void Task_HandleSearchTopBarInput(u8 taskId)
{
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_PC_OFF);
gTasks[taskId].func = Task_ExitSearch;
return;
}
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
switch (gTasks[taskId].tTopBarItem)
{
@@ -4934,7 +4934,7 @@ static void Task_HandleSearchTopBarInput(u8 taskId)
}
return;
}
- if ((gMain.newKeys & DPAD_LEFT) && gTasks[taskId].tTopBarItem > SEARCH_TOPBAR_SEARCH)
+ if ((JOY_NEW(DPAD_LEFT)) && gTasks[taskId].tTopBarItem > SEARCH_TOPBAR_SEARCH)
{
PlaySE(SE_DEX_PAGE);
gTasks[taskId].tTopBarItem--;
@@ -4942,7 +4942,7 @@ static void Task_HandleSearchTopBarInput(u8 taskId)
CopyWindowToVram(0, 2);
CopyBgTilemapBufferToVram(3);
}
- if ((gMain.newKeys & DPAD_RIGHT) && gTasks[taskId].tTopBarItem < SEARCH_TOPBAR_CANCEL)
+ if ((JOY_NEW(DPAD_RIGHT)) && gTasks[taskId].tTopBarItem < SEARCH_TOPBAR_CANCEL)
{
PlaySE(SE_DEX_PAGE);
gTasks[taskId].tTopBarItem++;
@@ -4981,14 +4981,14 @@ static void Task_HandleSearchMenuInput(u8 taskId)
movementMap = sSearchMovementMap_SearchNatDex;
}
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_BALL);
SetDefaultSearchModeAndOrder(taskId);
gTasks[taskId].func = Task_SwitchToSearchMenuTopBar;
return;
}
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
if (gTasks[taskId].tMenuItem == SEARCH_OK)
{
@@ -5023,7 +5023,7 @@ static void Task_HandleSearchMenuInput(u8 taskId)
return;
}
- if ((gMain.newKeys & DPAD_LEFT) && movementMap[gTasks[taskId].tMenuItem][0] != 0xFF)
+ if ((JOY_NEW(DPAD_LEFT)) && movementMap[gTasks[taskId].tMenuItem][0] != 0xFF)
{
PlaySE(SE_SELECT);
gTasks[taskId].tMenuItem = movementMap[gTasks[taskId].tMenuItem][0];
@@ -5031,7 +5031,7 @@ static void Task_HandleSearchMenuInput(u8 taskId)
CopyWindowToVram(0, 2);
CopyBgTilemapBufferToVram(3);
}
- if ((gMain.newKeys & DPAD_RIGHT) && movementMap[gTasks[taskId].tMenuItem][1] != 0xFF)
+ if (JOY_NEW(DPAD_RIGHT) && movementMap[gTasks[taskId].tMenuItem][1] != 0xFF)
{
PlaySE(SE_SELECT);
gTasks[taskId].tMenuItem = movementMap[gTasks[taskId].tMenuItem][1];
@@ -5039,7 +5039,7 @@ static void Task_HandleSearchMenuInput(u8 taskId)
CopyWindowToVram(0, 2);
CopyBgTilemapBufferToVram(3);
}
- if ((gMain.newKeys & DPAD_UP) && movementMap[gTasks[taskId].tMenuItem][2] != 0xFF)
+ if ((JOY_NEW(DPAD_UP)) && movementMap[gTasks[taskId].tMenuItem][2] != 0xFF)
{
PlaySE(SE_SELECT);
gTasks[taskId].tMenuItem = movementMap[gTasks[taskId].tMenuItem][2];
@@ -5047,7 +5047,7 @@ static void Task_HandleSearchMenuInput(u8 taskId)
CopyWindowToVram(0, 2);
CopyBgTilemapBufferToVram(3);
}
- if ((gMain.newKeys & DPAD_DOWN) && movementMap[gTasks[taskId].tMenuItem][3] != 0xFF)
+ if ((JOY_NEW(DPAD_DOWN)) && movementMap[gTasks[taskId].tMenuItem][3] != 0xFF)
{
PlaySE(SE_SELECT);
gTasks[taskId].tMenuItem = movementMap[gTasks[taskId].tMenuItem][3];
@@ -5091,7 +5091,7 @@ static void Task_WaitAndCompleteSearch(u8 taskId)
static void Task_SearchCompleteWaitForInput(u8 taskId)
{
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
if (sPokedexView->pokemonListCount != 0)
{
@@ -5144,7 +5144,7 @@ static void Task_HandleSearchParameterInput(u8 taskId)
cursorPos = &gTasks[taskId].data[sSearchOptions[menuItem].taskDataCursorPos];
scrollOffset = &gTasks[taskId].data[sSearchOptions[menuItem].taskDataScrollOffset];
maxOption = sSearchOptions[menuItem].numOptions - 1;
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_PIN);
ClearSearchParameterBoxText();
@@ -5154,7 +5154,7 @@ static void Task_HandleSearchParameterInput(u8 taskId)
CopyBgTilemapBufferToVram(3);
return;
}
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_BALL);
ClearSearchParameterBoxText();
@@ -5167,7 +5167,7 @@ static void Task_HandleSearchParameterInput(u8 taskId)
return;
}
moved = FALSE;
- if (gMain.newAndRepeatedKeys & DPAD_UP)
+ if (JOY_REPEAT(DPAD_UP))
{
if (*cursorPos != 0)
{
@@ -5193,7 +5193,7 @@ static void Task_HandleSearchParameterInput(u8 taskId)
}
return;
}
- if (gMain.newAndRepeatedKeys & DPAD_DOWN)
+ if (JOY_REPEAT(DPAD_DOWN))
{
if (*cursorPos < MAX_SEARCH_PARAM_CURSOR_POS && *cursorPos < maxOption)
{
@@ -5236,83 +5236,24 @@ static void Task_ExitSearchWaitForFade(u8 taskId)
}
}
-#ifdef NONMATCHING
-// This doesn't match because gcc flips the naming of the r7 and r6
-// registers. It also does one of the additions backwards.
void SetSearchRectHighlight(u8 flags, u8 x, u8 y, u8 width)
{
- u16 i;
- u16* ptr = GetBgTilemapBuffer(3);
+ u16 i, temp; //This would have been better as a pointer but here we are
+ u32 ptr = (u32)GetBgTilemapBuffer(3); //This should be a pointer, but this only matches as a u32.
- u16* temp;
for (i = 0; i < width; i++)
{
- // This addition is supposed to be done in this order; however,
- // gcc will always do it in ptr + (y * 32) order.
- temp = (y * 32) + ptr;
- temp[x + i] %= 0x1000;
- temp[x + i] |= flags * 0x1000;
+ temp = *(u16 *)(ptr + (y + 0) * 64 + (x + i) * 2);
+ temp &= 0x0fff;
+ temp |= (flags << 12);
+ *(u16 *)(ptr + (y + 0) * 64 + (x + i) * 2) = temp;
- temp[x + i + 32] %= 0x1000;
- temp[x + i + 32] |= flags * 0x1000;
+ temp = *(u16 *)(ptr + (y + 1) * 64 + (x + i) * 2);
+ temp &= 0x0fff;
+ temp |= (flags << 12);
+ *(u16 *)(ptr + (y + 1) * 64 + (x + i) * 2) = temp;
}
}
-#else
-NAKED
-void SetSearchRectHighlight(u8 flags, u8 x, u8 y, u8 width)
-{
- asm_unified(
- "push {r4-r7,lr}\n\
- mov r7, r8\n\
- push {r7}\n\
- adds r4, r3, 0\n\
- lsls r0, 24\n\
- lsrs r6, r0, 24\n\
- lsls r1, 24\n\
- lsrs r1, 24\n\
- mov r8, r1\n\
- lsls r2, 24\n\
- lsrs r5, r2, 24\n\
- lsls r4, 24\n\
- lsrs r4, 24\n\
- movs r0, 0x3\n\
- bl GetBgTilemapBuffer\n\
- adds r2, r0, 0\n\
- movs r3, 0\n\
- cmp r3, r4\n\
- bcs _080C1DEC\n\
- lsls r0, r5, 6\n\
- adds r7, r0, r2\n\
- ldr r5, =0x00000fff\n\
- lsls r2, r6, 12\n\
-_080C1DC8:\n\
- mov r0, r8\n\
- adds r1, r0, r3\n\
- lsls r1, 1\n\
- adds r1, r7\n\
- ldrh r0, [r1]\n\
- ands r0, r5\n\
- orrs r0, r2\n\
- strh r0, [r1]\n\
- adds r1, 0x40\n\
- ldrh r0, [r1]\n\
- ands r0, r5\n\
- orrs r0, r2\n\
- strh r0, [r1]\n\
- adds r0, r3, 0x1\n\
- lsls r0, 16\n\
- lsrs r3, r0, 16\n\
- cmp r3, r4\n\
- bcc _080C1DC8\n\
-_080C1DEC:\n\
- pop {r3}\n\
- mov r8, r3\n\
- pop {r4-r7}\n\
- pop {r0}\n\
- bx r0\n\
- .pool");
-}
-#endif
#define SEARCH_BG_SEARCH SEARCH_TOPBAR_SEARCH
#define SEARCH_BG_SHIFT SEARCH_TOPBAR_SHIFT
diff --git a/src/pokedex_area_screen.c b/src/pokedex_area_screen.c
index 8450f8530..fdbd2f40c 100755
--- a/src/pokedex_area_screen.c
+++ b/src/pokedex_area_screen.c
@@ -724,12 +724,12 @@ static void Task_HandlePokedexAreaScreenInput(u8 taskId)
return;
break;
case 1:
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
gTasks[taskId].data[1] = 1;
PlaySE(SE_PC_OFF);
}
- else if (gMain.newKeys & DPAD_RIGHT || (gMain.newKeys & R_BUTTON && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR))
+ else if (JOY_NEW(DPAD_RIGHT) || (JOY_NEW(R_BUTTON) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR))
{
gTasks[taskId].data[1] = 2;
PlaySE(SE_DEX_PAGE);
diff --git a/src/pokemon_jump.c b/src/pokemon_jump.c
index 07f6bc54b..84d869a1a 100755
--- a/src/pokemon_jump.c
+++ b/src/pokemon_jump.c
@@ -1245,7 +1245,7 @@ static bool32 sub_802B8CC(void)
break;
// fall through
case 1:
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
sub_802C164();
sub_802AE14(3);
@@ -1336,7 +1336,7 @@ static bool32 sub_802BA58(void)
case 2:
case 5:
gUnknown_02022CFC->unk3C++;
- if (gMain.newKeys & (A_BUTTON | B_BUTTON) || gUnknown_02022CFC->unk3C > 180)
+ if (JOY_NEW(A_BUTTON | B_BUTTON) || gUnknown_02022CFC->unk3C > 180)
{
sub_802DA14();
gUnknown_02022CFC->unkA++;
@@ -3922,7 +3922,7 @@ static void Task_ShowPokemonJumpRecords(u8 taskId)
data[0]++;
break;
case 2:
- if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ if (JOY_NEW(A_BUTTON | B_BUTTON))
{
rbox_fill_rectangle(data[1]);
CopyWindowToVram(data[1], 1);
diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c
index fcca744c2..ae334504e 100644
--- a/src/pokemon_storage_system.c
+++ b/src/pokemon_storage_system.c
@@ -1756,10 +1756,10 @@ static void Task_PokemonStorageSystemPC(u8 taskId)
{
case MENU_NOTHING_CHOSEN:
task->data[3] = task->data[1];
- if (gMain.newKeys & DPAD_UP && --task->data[3] < 0)
+ if (JOY_NEW(DPAD_UP) && --task->data[3] < 0)
task->data[3] = 4;
- if (gMain.newKeys & DPAD_DOWN && ++task->data[3] > 4)
+ if (JOY_NEW(DPAD_DOWN) && ++task->data[3] > 4)
task->data[3] = 0;
if (task->data[1] != task->data[3])
{
@@ -1798,13 +1798,13 @@ static void Task_PokemonStorageSystemPC(u8 taskId)
}
break;
case 3:
- if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ if (JOY_NEW(A_BUTTON | B_BUTTON))
{
FillWindowPixelBuffer(0, PIXEL_FILL(1));
AddTextPrinterParameterized2(0, 1, gUnknown_085716C0[task->data[1]].desc, 0, NULL, 2, 1, 3);
task->data[0] = 2;
}
- else if (gMain.newKeys & DPAD_UP)
+ else if (JOY_NEW(DPAD_UP))
{
if (--task->data[1] < 0)
task->data[1] = 4;
@@ -1814,7 +1814,7 @@ static void Task_PokemonStorageSystemPC(u8 taskId)
AddTextPrinterParameterized2(0, 1, gUnknown_085716C0[task->data[1]].desc, 0, NULL, 2, 1, 3);
task->data[0] = 2;
}
- else if (gMain.newKeys & DPAD_DOWN)
+ else if (JOY_NEW(DPAD_DOWN))
{
if (++task->data[1] > 3)
task->data[1] = 0;
@@ -1976,22 +1976,22 @@ static void sub_80C78E4(void)
static u8 HandleBoxChooseSelectionInput(void)
{
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
return 201;
}
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
return gUnknown_02039D04->curBox;
}
- if (gMain.newKeys & DPAD_LEFT)
+ if (JOY_NEW(DPAD_LEFT))
{
PlaySE(SE_SELECT);
sub_80C7BB4();
}
- else if (gMain.newKeys & DPAD_RIGHT)
+ else if (JOY_NEW(DPAD_RIGHT))
{
PlaySE(SE_SELECT);
sub_80C7B80();
@@ -2393,7 +2393,7 @@ static void Cb_ReshowPSS(u8 taskId)
}
break;
case 2:
- if (!IsDma3ManagerBusyWithBgCopy() && gMain.newKeys & (A_BUTTON | B_BUTTON))
+ if (!IsDma3ManagerBusyWithBgCopy() && JOY_NEW(A_BUTTON | B_BUTTON))
{
ClearBottomWindow();
sPSSData->state++;
@@ -2615,7 +2615,7 @@ static void Cb_MainPSS(u8 taskId)
}
break;
case 3:
- if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
{
ClearBottomWindow();
sPSSData->state = 0;
@@ -2632,7 +2632,7 @@ static void Cb_MainPSS(u8 taskId)
sPSSData->state = 6;
break;
case 6:
- if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
{
ClearBottomWindow();
SetPSSCallback(Cb_MainPSS);
@@ -2858,7 +2858,7 @@ static void Cb_OnSelectedMon(u8 taskId)
sPSSData->state = 6;
break;
case 6:
- if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
{
ClearBottomWindow();
SetPSSCallback(Cb_MainPSS);
@@ -2943,7 +2943,7 @@ static void Cb_WithdrawMon(u8 taskId)
}
break;
case 1:
- if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
{
ClearBottomWindow();
SetPSSCallback(Cb_MainPSS);
@@ -3034,7 +3034,7 @@ static void Cb_DepositMenu(u8 taskId)
}
break;
case 4:
- if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
{
PrintStorageActionText(PC_TEXT_DEPOSIT_IN_WHICH_BOX);
sPSSData->state = 1;
@@ -3095,14 +3095,14 @@ static void Cb_ReleaseMon(u8 taskId)
sPSSData->state++;
break;
case 4:
- if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
{
PrintStorageActionText(PC_TEXT_BYE_BYE);
sPSSData->state++;
}
break;
case 5:
- if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
{
ClearBottomWindow();
if (sInPartyMenu)
@@ -3134,14 +3134,14 @@ static void Cb_ReleaseMon(u8 taskId)
sPSSData->state++;
break;
case 9:
- if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
{
PrintStorageActionText(PC_TEXT_SURPRISE);
sPSSData->state++;
}
break;
case 10:
- if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
{
ClearBottomWindow();
sub_80CC064();
@@ -3157,14 +3157,14 @@ static void Cb_ReleaseMon(u8 taskId)
}
break;
case 12:
- if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
{
PrintStorageActionText(PC_TEXT_WORRIED);
sPSSData->state++;
}
break;
case 13:
- if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
{
ClearBottomWindow();
SetPSSCallback(Cb_MainPSS);
@@ -3257,7 +3257,7 @@ static void Cb_GiveMovingItemToMon(u8 taskId)
}
break;
case 3:
- if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
{
ClearBottomWindow();
sPSSData->state++;
@@ -3296,7 +3296,7 @@ static void Cb_ItemToBag(u8 taskId)
}
break;
case 2:
- if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
{
ClearBottomWindow();
sub_80CE00C();
@@ -3309,7 +3309,7 @@ static void Cb_ItemToBag(u8 taskId)
SetPSSCallback(Cb_MainPSS);
break;
case 3:
- if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
{
ClearBottomWindow();
SetPSSCallback(Cb_MainPSS);
@@ -3349,7 +3349,7 @@ static void Cb_SwitchSelectedItem(u8 taskId)
}
break;
case 3:
- if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
{
ClearBottomWindow();
sPSSData->state++;
@@ -3388,7 +3388,7 @@ static void Cb_ShowItemInfo(u8 taskId)
sPSSData->state++;
break;
case 4:
- if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
{
PlaySE(SE_WIN_OPEN);
sPSSData->state++;
@@ -3438,7 +3438,7 @@ static void Cb_CloseBoxWhileHoldingItem(u8 taskId)
}
break;
case 2:
- if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
{
ClearBottomWindow();
sPSSData->state = 5;
@@ -3494,7 +3494,7 @@ static void Cb_PrintCantStoreMail(u8 taskId)
sPSSData->state++;
break;
case 2:
- if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
{
ClearBottomWindow();
sPSSData->state++;
@@ -3759,7 +3759,7 @@ static void Cb_OnCloseBoxPressed(u8 taskId)
}
break;
case 1:
- if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
{
ClearBottomWindow();
SetPSSCallback(Cb_MainPSS);
@@ -3820,7 +3820,7 @@ static void Cb_OnBPressed(u8 taskId)
}
break;
case 1:
- if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
{
ClearBottomWindow();
SetPSSCallback(Cb_MainPSS);
@@ -5462,7 +5462,7 @@ static void sub_80CCA3C(const void *tilemap, s8 direction, u8 arg2)
if (direction == 0)
return;
- else if (direction > 0)
+ if (direction > 0)
x *= 1, x += 0x14; // x * 1 is needed to match, but can be safely removed as it makes no functional difference
else
x -= 4;
@@ -6940,7 +6940,7 @@ static u8 InBoxInput_Normal(void)
sPSSData->field_CD3 = 0;
sPSSData->field_CD7 = 0;
- if (gMain.newAndRepeatedKeys & DPAD_UP)
+ if (JOY_REPEAT(DPAD_UP))
{
retVal = TRUE;
if (sBoxCursorPosition >= IN_BOX_ROWS)
@@ -6954,7 +6954,7 @@ static u8 InBoxInput_Normal(void)
}
break;
}
- else if (gMain.newAndRepeatedKeys & DPAD_DOWN)
+ else if (JOY_REPEAT(DPAD_DOWN))
{
retVal = TRUE;
cursorPosition += IN_BOX_ROWS;
@@ -6968,7 +6968,7 @@ static u8 InBoxInput_Normal(void)
}
break;
}
- else if (gMain.newAndRepeatedKeys & DPAD_LEFT)
+ else if (JOY_REPEAT(DPAD_LEFT))
{
retVal = TRUE;
if (sBoxCursorPosition % IN_BOX_ROWS != 0)
@@ -6982,7 +6982,7 @@ static u8 InBoxInput_Normal(void)
}
break;
}
- else if (gMain.newAndRepeatedKeys & DPAD_RIGHT)
+ else if (JOY_REPEAT(DPAD_RIGHT))
{
retVal = TRUE;
if ((sBoxCursorPosition + 1) % IN_BOX_ROWS != 0)
@@ -6996,7 +6996,7 @@ static u8 InBoxInput_Normal(void)
}
break;
}
- else if (gMain.newKeys & START_BUTTON)
+ else if (JOY_NEW(START_BUTTON))
{
retVal = TRUE;
cursorArea = CURSOR_AREA_BOX;
@@ -7004,7 +7004,7 @@ static u8 InBoxInput_Normal(void)
break;
}
- if ((gMain.newKeys & A_BUTTON) && sub_80CFA5C())
+ if ((JOY_NEW(A_BUTTON)) && sub_80CFA5C())
{
if (!sCanOnlyMove)
return 8;
@@ -7038,18 +7038,18 @@ static u8 InBoxInput_Normal(void)
}
}
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
return 19;
if (gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR)
{
- if (gMain.heldKeys & L_BUTTON)
+ if (JOY_HELD(L_BUTTON))
return 10;
- if (gMain.heldKeys & R_BUTTON)
+ if (JOY_HELD(R_BUTTON))
return 9;
}
- if (gMain.newKeys & SELECT_BUTTON)
+ if (JOY_NEW(SELECT_BUTTON))
{
sub_80CFDC4();
return 0;
@@ -7067,9 +7067,9 @@ static u8 InBoxInput_Normal(void)
static u8 InBoxInput_GrabbingMultiple(void)
{
- if (gMain.heldKeys & A_BUTTON)
+ if (JOY_HELD(A_BUTTON))
{
- if (gMain.newAndRepeatedKeys & DPAD_UP)
+ if (JOY_REPEAT(DPAD_UP))
{
if (sBoxCursorPosition / IN_BOX_ROWS != 0)
{
@@ -7081,7 +7081,7 @@ static u8 InBoxInput_GrabbingMultiple(void)
return 24;
}
}
- else if (gMain.newAndRepeatedKeys & DPAD_DOWN)
+ else if (JOY_REPEAT(DPAD_DOWN))
{
if (sBoxCursorPosition + IN_BOX_ROWS < IN_BOX_COUNT)
{
@@ -7093,7 +7093,7 @@ static u8 InBoxInput_GrabbingMultiple(void)
return 24;
}
}
- else if (gMain.newAndRepeatedKeys & DPAD_LEFT)
+ else if (JOY_REPEAT(DPAD_LEFT))
{
if (sBoxCursorPosition % IN_BOX_ROWS != 0)
{
@@ -7105,7 +7105,7 @@ static u8 InBoxInput_GrabbingMultiple(void)
return 24;
}
}
- else if (gMain.newAndRepeatedKeys & DPAD_RIGHT)
+ else if (JOY_REPEAT(DPAD_RIGHT))
{
if ((sBoxCursorPosition + 1) % IN_BOX_ROWS != 0)
{
@@ -7142,7 +7142,7 @@ static u8 InBoxInput_GrabbingMultiple(void)
static u8 InBoxInput_MovingMultiple(void)
{
- if (gMain.newAndRepeatedKeys & DPAD_UP)
+ if (JOY_REPEAT(DPAD_UP))
{
if (sub_80D0580(0))
{
@@ -7154,7 +7154,7 @@ static u8 InBoxInput_MovingMultiple(void)
return 24;
}
}
- else if (gMain.newAndRepeatedKeys & DPAD_DOWN)
+ else if (JOY_REPEAT(DPAD_DOWN))
{
if (sub_80D0580(1))
{
@@ -7166,7 +7166,7 @@ static u8 InBoxInput_MovingMultiple(void)
return 24;
}
}
- else if (gMain.newAndRepeatedKeys & DPAD_LEFT)
+ else if (JOY_REPEAT(DPAD_LEFT))
{
if (sub_80D0580(2))
{
@@ -7178,7 +7178,7 @@ static u8 InBoxInput_MovingMultiple(void)
return 10;
}
}
- else if (gMain.newAndRepeatedKeys & DPAD_RIGHT)
+ else if (JOY_REPEAT(DPAD_RIGHT))
{
if (sub_80D0580(3))
{
@@ -7190,7 +7190,7 @@ static u8 InBoxInput_MovingMultiple(void)
return 9;
}
}
- else if (gMain.newKeys & A_BUTTON)
+ else if (JOY_NEW(A_BUTTON))
{
if (sub_80D0BC0())
{
@@ -7203,7 +7203,7 @@ static u8 InBoxInput_MovingMultiple(void)
return 24;
}
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
return 24;
}
@@ -7211,9 +7211,9 @@ static u8 InBoxInput_MovingMultiple(void)
{
if (gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR)
{
- if (gMain.heldKeys & L_BUTTON)
+ if (JOY_HELD(L_BUTTON))
return 10;
- if (gMain.heldKeys & R_BUTTON)
+ if (JOY_HELD(R_BUTTON))
return 9;
}
@@ -7238,7 +7238,7 @@ static u8 HandleInput_InParty(void)
gotoBox = FALSE;
retVal = 0;
- if (gMain.newAndRepeatedKeys & DPAD_UP)
+ if (JOY_REPEAT(DPAD_UP))
{
if (--cursorPosition < 0)
cursorPosition = PARTY_SIZE;
@@ -7246,7 +7246,7 @@ static u8 HandleInput_InParty(void)
retVal = 1;
break;
}
- else if (gMain.newAndRepeatedKeys & DPAD_DOWN)
+ else if (JOY_REPEAT(DPAD_DOWN))
{
if (++cursorPosition > PARTY_SIZE)
cursorPosition = 0;
@@ -7254,14 +7254,14 @@ static u8 HandleInput_InParty(void)
retVal = 1;
break;
}
- else if (gMain.newAndRepeatedKeys & DPAD_LEFT && sBoxCursorPosition != 0)
+ else if (JOY_REPEAT(DPAD_LEFT) && sBoxCursorPosition != 0)
{
retVal = 1;
sPSSData->field_CD6 = sBoxCursorPosition;
cursorPosition = 0;
break;
}
- else if (gMain.newAndRepeatedKeys & DPAD_RIGHT)
+ else if (JOY_REPEAT(DPAD_RIGHT))
{
if (sBoxCursorPosition == 0)
{
@@ -7277,7 +7277,7 @@ static u8 HandleInput_InParty(void)
break;
}
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
if (sBoxCursorPosition == PARTY_SIZE)
{
@@ -7313,7 +7313,7 @@ static u8 HandleInput_InParty(void)
}
}
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
if (sPSSData->boxOption == BOX_OPTION_DEPOSIT)
return 19;
@@ -7327,7 +7327,7 @@ static u8 HandleInput_InParty(void)
cursorArea = CURSOR_AREA_IN_BOX;
cursorPosition = 0;
}
- else if (gMain.newKeys & SELECT_BUTTON)
+ else if (JOY_NEW(SELECT_BUTTON))
{
sub_80CFDC4();
return 0;
@@ -7356,7 +7356,7 @@ static u8 HandleInput_OnBox(void)
sPSSData->field_CD2 = 0;
sPSSData->field_CD7 = 0;
- if (gMain.newAndRepeatedKeys & DPAD_UP)
+ if (JOY_REPEAT(DPAD_UP))
{
retVal = 1;
cursorArea = CURSOR_AREA_BUTTONS;
@@ -7364,7 +7364,7 @@ static u8 HandleInput_OnBox(void)
sPSSData->field_CD7 = 1;
break;
}
- else if (gMain.newAndRepeatedKeys & DPAD_DOWN)
+ else if (JOY_REPEAT(DPAD_DOWN))
{
retVal = 1;
cursorArea = CURSOR_AREA_IN_BOX;
@@ -7372,30 +7372,30 @@ static u8 HandleInput_OnBox(void)
break;
}
- if (gMain.heldKeys & DPAD_LEFT)
+ if (JOY_HELD(DPAD_LEFT))
return 10;
- if (gMain.heldKeys & DPAD_RIGHT)
+ if (JOY_HELD(DPAD_RIGHT))
return 9;
if (gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR)
{
- if (gMain.heldKeys & L_BUTTON)
+ if (JOY_HELD(L_BUTTON))
return 10;
- if (gMain.heldKeys & R_BUTTON)
+ if (JOY_HELD(R_BUTTON))
return 9;
}
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
sub_80CD1A8(FALSE);
AddBoxMenu();
return 7;
}
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
return 19;
- if (gMain.newKeys & SELECT_BUTTON)
+ if (JOY_NEW(SELECT_BUTTON))
{
sub_80CFDC4();
return 0;
@@ -7429,7 +7429,7 @@ static u8 HandleInput_OnButtons(void)
sPSSData->field_CD2 = 0;
sPSSData->field_CD7 = 0;
- if (gMain.newAndRepeatedKeys & DPAD_UP)
+ if (JOY_REPEAT(DPAD_UP))
{
retVal = 1;
cursorArea = CURSOR_AREA_IN_BOX;
@@ -7441,7 +7441,8 @@ static u8 HandleInput_OnButtons(void)
sPSSData->field_CD7 = 1;
break;
}
- else if (gMain.newAndRepeatedKeys & (DPAD_DOWN | START_BUTTON))
+
+ if (JOY_REPEAT(DPAD_DOWN | START_BUTTON))
{
retVal = 1;
cursorArea = CURSOR_AREA_BOX;
@@ -7450,14 +7451,14 @@ static u8 HandleInput_OnButtons(void)
break;
}
- if (gMain.newAndRepeatedKeys & DPAD_LEFT)
+ if (JOY_REPEAT(DPAD_LEFT))
{
retVal = 1;
if (--cursorPosition < 0)
cursorPosition = 1;
break;
}
- else if (gMain.newAndRepeatedKeys & DPAD_RIGHT)
+ else if (JOY_REPEAT(DPAD_RIGHT))
{
retVal = 1;
if (++cursorPosition > 1)
@@ -7465,12 +7466,12 @@ static u8 HandleInput_OnButtons(void)
break;
}
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
return (cursorPosition == 0) ? 5 : 4;
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
return 19;
- if (gMain.newKeys & SELECT_BUTTON)
+ if (JOY_NEW(SELECT_BUTTON))
{
sub_80CFDC4();
return 0;
@@ -7919,23 +7920,23 @@ static s16 sub_80D00AC(void)
do
{
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
textId = Menu_GetCursorPos();
break;
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
textId = -1;
}
- if (gMain.newKeys & DPAD_UP)
+ if (JOY_NEW(DPAD_UP))
{
PlaySE(SE_SELECT);
Menu_MoveCursor(-1);
}
- else if (gMain.newKeys & DPAD_DOWN)
+ else if (JOY_NEW(DPAD_DOWN))
{
PlaySE(SE_SELECT);
Menu_MoveCursor(1);
diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c
index d016c455c..bfd849229 100644
--- a/src/pokemon_summary_screen.c
+++ b/src/pokemon_summary_screen.c
@@ -1497,23 +1497,23 @@ static void Task_HandleInput(u8 taskId)
{
if (MenuHelpers_CallLinkSomething() != TRUE && !gPaletteFade.active)
{
- if (gMain.newKeys & DPAD_UP)
+ if (JOY_NEW(DPAD_UP))
{
ChangeSummaryPokemon(taskId, -1);
}
- else if (gMain.newKeys & DPAD_DOWN)
+ else if (JOY_NEW(DPAD_DOWN))
{
ChangeSummaryPokemon(taskId, 1);
}
- else if ((gMain.newKeys & DPAD_LEFT) || GetLRKeysPressed() == MENU_L_PRESSED)
+ else if (JOY_NEW(DPAD_LEFT) || GetLRKeysPressed() == MENU_L_PRESSED)
{
ChangePage(taskId, -1);
}
- else if ((gMain.newKeys & DPAD_RIGHT) || GetLRKeysPressed() == MENU_R_PRESSED)
+ else if (JOY_NEW(DPAD_RIGHT) || GetLRKeysPressed() == MENU_R_PRESSED)
{
ChangePage(taskId, 1);
}
- else if (gMain.newKeys & A_BUTTON)
+ else if (JOY_NEW(A_BUTTON))
{
if (sMonSummaryScreen->currPageIndex != PSS_PAGE_SKILLS)
{
@@ -1530,7 +1530,7 @@ static void Task_HandleInput(u8 taskId)
}
}
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
StopPokemonAnimations();
PlaySE(SE_SELECT);
@@ -1878,17 +1878,17 @@ static void Task_HandleInput_MoveSelect(u8 taskId)
if (MenuHelpers_CallLinkSomething() != 1)
{
- if (gMain.newKeys & DPAD_UP)
+ if (JOY_NEW(DPAD_UP))
{
data[0] = 4;
ChangeSelectedMove(data, -1, &sMonSummaryScreen->firstMoveIndex);
}
- else if (gMain.newKeys & DPAD_DOWN)
+ else if (JOY_NEW(DPAD_DOWN))
{
data[0] = 4;
ChangeSelectedMove(data, 1, &sMonSummaryScreen->firstMoveIndex);
}
- else if (gMain.newKeys & A_BUTTON)
+ else if (JOY_NEW(A_BUTTON))
{
if (sMonSummaryScreen->lockMovesFlag == TRUE
|| (sMonSummaryScreen->newMove == MOVE_NONE && sMonSummaryScreen->firstMoveIndex == MAX_MON_MOVES))
@@ -1906,7 +1906,7 @@ static void Task_HandleInput_MoveSelect(u8 taskId)
PlaySE(SE_FAILURE);
}
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
CloseMoveSelectMode(taskId);
@@ -2018,24 +2018,24 @@ static void Task_HandleInput_MovePositionSwitch(u8 taskId)
if (MenuHelpers_CallLinkSomething() != TRUE)
{
- if (gMain.newKeys & DPAD_UP)
+ if (JOY_NEW(DPAD_UP))
{
data[0] = 3;
ChangeSelectedMove(&data[0], -1, &sMonSummaryScreen->secondMoveIndex);
}
- else if (gMain.newKeys & DPAD_DOWN)
+ else if (JOY_NEW(DPAD_DOWN))
{
data[0] = 3;
ChangeSelectedMove(&data[0], 1, &sMonSummaryScreen->secondMoveIndex);
}
- else if (gMain.newKeys & A_BUTTON)
+ else if (JOY_NEW(A_BUTTON))
{
if (sMonSummaryScreen->firstMoveIndex == sMonSummaryScreen->secondMoveIndex)
ExitMovePositionSwitchMode(taskId, FALSE);
else
ExitMovePositionSwitchMode(taskId, TRUE);
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
ExitMovePositionSwitchMode(taskId, FALSE);
}
@@ -2161,25 +2161,25 @@ static void Task_HandleReplaceMoveInput(u8 taskId)
{
if (gPaletteFade.active != TRUE)
{
- if (gMain.newKeys & DPAD_UP)
+ if (JOY_NEW(DPAD_UP))
{
data[0] = 4;
ChangeSelectedMove(data, -1, &sMonSummaryScreen->firstMoveIndex);
}
- else if (gMain.newKeys & DPAD_DOWN)
+ else if (JOY_NEW(DPAD_DOWN))
{
data[0] = 4;
ChangeSelectedMove(data, 1, &sMonSummaryScreen->firstMoveIndex);
}
- else if (gMain.newKeys & DPAD_LEFT || GetLRKeysPressed() == MENU_L_PRESSED)
+ else if (JOY_NEW(DPAD_LEFT) || GetLRKeysPressed() == MENU_L_PRESSED)
{
ChangePage(taskId, -1);
}
- else if (gMain.newKeys & DPAD_RIGHT || GetLRKeysPressed() == MENU_R_PRESSED)
+ else if (JOY_NEW(DPAD_RIGHT) || GetLRKeysPressed() == MENU_R_PRESSED)
{
ChangePage(taskId, 1);
}
- else if (gMain.newKeys & A_BUTTON)
+ else if (JOY_NEW(A_BUTTON))
{
if (CanReplaceMove() == TRUE)
{
@@ -2195,7 +2195,7 @@ static void Task_HandleReplaceMoveInput(u8 taskId)
ShowCantForgetHMsWindow(taskId);
}
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
StopPokemonAnimations();
PlaySE(SE_SELECT);
@@ -2235,7 +2235,7 @@ static void Task_HandleInputCantForgetHMsMoves(u8 taskId)
u16 move;
if (FuncIsActiveTask(Task_ShowPowerAccWindow) != 1)
{
- if (gMain.newKeys & DPAD_UP)
+ if (JOY_NEW(DPAD_UP))
{
data[1] = 1;
data[0] = 4;
@@ -2243,7 +2243,7 @@ static void Task_HandleInputCantForgetHMsMoves(u8 taskId)
data[1] = 0;
gTasks[taskId].func = Task_HandleReplaceMoveInput;
}
- else if (gMain.newKeys & DPAD_DOWN)
+ else if (JOY_NEW(DPAD_DOWN))
{
data[1] = 1;
data[0] = 4;
@@ -2251,7 +2251,7 @@ static void Task_HandleInputCantForgetHMsMoves(u8 taskId)
data[1] = 0;
gTasks[taskId].func = Task_HandleReplaceMoveInput;
}
- else if (gMain.newKeys & DPAD_LEFT || GetLRKeysPressed() == MENU_L_PRESSED)
+ else if (JOY_NEW(DPAD_LEFT) || GetLRKeysPressed() == MENU_L_PRESSED)
{
if (sMonSummaryScreen->currPageIndex != PSS_PAGE_BATTLE_MOVES)
{
@@ -2265,7 +2265,7 @@ static void Task_HandleInputCantForgetHMsMoves(u8 taskId)
HandleAppealJamTilemap(9, -2, move);
}
}
- else if (gMain.newKeys & DPAD_RIGHT || GetLRKeysPressed() == MENU_R_PRESSED)
+ else if (JOY_NEW(DPAD_RIGHT) || GetLRKeysPressed() == MENU_R_PRESSED)
{
if (sMonSummaryScreen->currPageIndex != PSS_PAGE_CONTEST_MOVES)
{
@@ -2279,7 +2279,7 @@ static void Task_HandleInputCantForgetHMsMoves(u8 taskId)
HandleAppealJamTilemap(9, -2, move);
}
}
- else if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ else if (JOY_NEW(A_BUTTON | B_BUTTON))
{
ClearWindowTilemap(PSS_LABEL_WINDOW_PORTRAIT_SPECIES);
if (!gSprites[sMonSummaryScreen->spriteIds[SPRITE_ARR_ID_STATUS]].invisible)
diff --git a/src/pokenav_conditions_1.c b/src/pokenav_conditions_1.c
index 1c7573a44..488d40d13 100644
--- a/src/pokenav_conditions_1.c
+++ b/src/pokenav_conditions_1.c
@@ -89,13 +89,13 @@ u32 sub_81CD08C(struct PokenavSub11 *structPtr)
if (ret == 0)
{
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
structPtr->unk6304 = sub_81CD19C;
ret = 2;
}
- else if (gMain.newKeys & A_BUTTON)
+ else if (JOY_NEW(A_BUTTON))
{
if (structPtr->unk6300 == 0)
{
@@ -166,7 +166,7 @@ u8 sub_81CD1E4(struct PokenavSub11 *structPtr)
struct PokenavSub18 *unkPtr = GetSubstructPtr(18);
u8 ret = 0;
- if (gMain.heldKeys & DPAD_UP)
+ if (JOY_HELD(DPAD_UP))
{
if (structPtr->unk6300 == 0 || unkPtr->unk2 != 0)
{
@@ -174,7 +174,7 @@ u8 sub_81CD1E4(struct PokenavSub11 *structPtr)
ret = sub_81CD258(1);
}
}
- else if (gMain.heldKeys & DPAD_DOWN)
+ else if (JOY_HELD(DPAD_DOWN))
{
if (structPtr->unk6300 == 0 || unkPtr->unk2 < unkPtr->unk0 - 1)
{
diff --git a/src/pokenav_conditions_3.c b/src/pokenav_conditions_3.c
index eea4aa397..15b687a42 100644
--- a/src/pokenav_conditions_3.c
+++ b/src/pokenav_conditions_3.c
@@ -170,29 +170,28 @@ static bool32 sub_81CF010(struct PokenavSub7 *structPtr)
static u32 sub_81CF030(struct PokenavSub7 *structPtr)
{
- if (gMain.newAndRepeatedKeys & DPAD_UP)
+ if (JOY_REPEAT(DPAD_UP))
return 1;
- else if (gMain.newAndRepeatedKeys & DPAD_DOWN)
+ if (JOY_REPEAT(DPAD_DOWN))
return 2;
- else if (gMain.newKeys & DPAD_LEFT)
+ if (JOY_NEW(DPAD_LEFT))
return 3;
- else if (gMain.newKeys & DPAD_RIGHT)
+ if (JOY_NEW(DPAD_RIGHT))
return 4;
- else if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
structPtr->unk1C = 0;
structPtr->unk0 = sub_81CF0B0;
return 5;
}
- else if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
structPtr->unkPtr->unk2 = GetSelectedMatchCall();
structPtr->unk1C = 1;
structPtr->unk0 = sub_81CF0B8;
return 6;
}
- else
- return 0;
+ return 0;
}
static u32 sub_81CF0B0(struct PokenavSub7 *structPtr)
diff --git a/src/pokenav_main_menu.c b/src/pokenav_main_menu.c
index 0e2425d4e..f2b9b0dcc 100644
--- a/src/pokenav_main_menu.c
+++ b/src/pokenav_main_menu.c
@@ -436,9 +436,10 @@ static u32 LoopedTask_ScrollMenuHeaderUp(s32 a0)
if (ChangeBgY(0, 384, 2) <= 0)
{
ChangeBgY(0, 0, 0);
- return 4;
+ return LT_FINISH;
}
- return 2;
+
+ return LT_PAUSE;
}
void CopyPaletteIntoBufferUnfaded(const u16 *palette, u32 bufferOffset, u32 size)
@@ -458,11 +459,9 @@ void Pokenav_AllocAndLoadPalettes(const struct SpritePalette *palettes)
{
break;
}
- else
- {
- index = (index * 16) + 0x100;
- CopyPaletteIntoBufferUnfaded(current->data, index, 0x20);
- }
+
+ index = (index * 16) + 0x100;
+ CopyPaletteIntoBufferUnfaded(current->data, index, 0x20);
}
}
@@ -471,139 +470,41 @@ void sub_81C7990(u32 a0, u16 a1)
CpuFill16(a1, gPlttBufferFaded + 0x100 + (a0 * 16), 16 * sizeof(u16));
}
-NAKED
-void sub_81C79BC(const u16 *a0, const u16 *a1, u32 a2, u32 a3, u32 a4, u16 *a5)
-{
- asm_unified(
- "push {r4-r7,lr}\n\
- mov r7, r10\n\
- mov r6, r9\n\
- mov r5, r8\n\
- push {r5-r7}\n\
- sub sp, 0xC\n\
- str r0, [sp]\n\
- str r1, [sp, 0x4]\n\
- mov r10, r2\n\
- str r3, [sp, 0x8]\n\
- ldr r0, [sp, 0x2C]\n\
- cmp r0, 0\n\
- bne _081C79E4\n\
- ldr r2, =0x001fffff\n\
- mov r1, r10\n\
- ands r2, r1\n\
- ldr r0, [sp]\n\
- b _081C79F4\n\
- .pool\n\
-_081C79E4:\n\
- ldr r2, [sp, 0x2C]\n\
- ldr r0, [sp, 0x8]\n\
- cmp r2, r0\n\
- blt _081C7A00\n\
- ldr r2, =0x001fffff\n\
- mov r1, r10\n\
- ands r2, r1\n\
- ldr r0, [sp, 0x4]\n\
-_081C79F4:\n\
- ldr r1, [sp, 0x30]\n\
- bl CpuSet\n\
- b _081C7AAE\n\
- .pool\n\
-_081C7A00:\n\
- movs r2, 0x1\n\
- negs r2, r2\n\
- add r10, r2\n\
- b _081C7AA6\n\
-_081C7A08:\n\
- ldr r1, [sp]\n\
- ldrh r0, [r1]\n\
- movs r2, 0x1F\n\
- mov r9, r2\n\
- mov r1, r9\n\
- ands r1, r0\n\
- mov r9, r1\n\
- lsls r0, 16\n\
- lsrs r2, r0, 21\n\
- movs r1, 0x1F\n\
- ands r1, r2\n\
- mov r8, r1\n\
- lsrs r7, r0, 26\n\
- movs r2, 0x1F\n\
- ands r7, r2\n\
- ldr r0, [sp, 0x4]\n\
- ldrh r4, [r0]\n\
- movs r0, 0x1F\n\
- ands r0, r4\n\
- mov r1, r9\n\
- subs r0, r1\n\
- lsls r0, 8\n\
- ldr r1, [sp, 0x8]\n\
- bl __divsi3\n\
- ldr r2, [sp, 0x2C]\n\
- adds r6, r0, 0\n\
- muls r6, r2\n\
- asrs r6, 8\n\
- lsls r4, 16\n\
- lsrs r0, r4, 21\n\
- movs r1, 0x1F\n\
- ands r0, r1\n\
- mov r2, r8\n\
- subs r0, r2\n\
- lsls r0, 8\n\
- ldr r1, [sp, 0x8]\n\
- bl __divsi3\n\
- ldr r1, [sp, 0x2C]\n\
- adds r5, r0, 0\n\
- muls r5, r1\n\
- asrs r5, 8\n\
- lsrs r4, 26\n\
- movs r2, 0x1F\n\
- ands r4, r2\n\
- subs r4, r7\n\
- lsls r4, 8\n\
- adds r0, r4, 0\n\
- ldr r1, [sp, 0x8]\n\
- bl __divsi3\n\
- ldr r1, [sp, 0x2C]\n\
- muls r0, r1\n\
- asrs r0, 8\n\
- add r6, r9\n\
- movs r2, 0x1F\n\
- ands r6, r2\n\
- add r5, r8\n\
- ands r5, r2\n\
- adds r0, r7, r0\n\
- ands r0, r2\n\
- lsls r0, 10\n\
- lsls r5, 5\n\
- orrs r0, r5\n\
- orrs r0, r6\n\
- ldr r1, [sp, 0x30]\n\
- strh r0, [r1]\n\
- ldr r2, [sp]\n\
- adds r2, 0x2\n\
- str r2, [sp]\n\
- ldr r0, [sp, 0x4]\n\
- adds r0, 0x2\n\
- str r0, [sp, 0x4]\n\
- adds r1, 0x2\n\
- str r1, [sp, 0x30]\n\
- movs r1, 0x1\n\
- negs r1, r1\n\
- add r10, r1\n\
-_081C7AA6:\n\
- movs r0, 0x1\n\
- negs r0, r0\n\
- cmp r10, r0\n\
- bne _081C7A08\n\
-_081C7AAE:\n\
- add sp, 0xC\n\
- pop {r3-r5}\n\
- mov r8, r3\n\
- mov r9, r4\n\
- mov r10, r5\n\
- pop {r4-r7}\n\
- pop {r0}\n\
- bx r0");
+void sub_81C79BC(const u16 *a0, const u16 *a1, int a2, int a3, int a4, u16 *palette)
+{
+
+ if (a4 == 0)
+ {
+ CpuCopy16(a0, palette, a2 * 2);
+ }
+ else if (a4 >= a3)
+ {
+ CpuCopy16(a1, palette, a2 * 2);
+ }
+ else
+ {
+ int r, g, b;
+ int r1, g1, b1;
+ while (a2--)
+ {
+ r = GET_R(*a0);
+ g = GET_G(*a0);
+ b = GET_B(*a0);
+
+ r1 = ((((GET_R(*a1) << 8) - (r << 8)) / a3) * a4) >> 8;
+ g1 = ((((GET_G(*a1) << 8) - (g << 8)) / a3) * a4) >> 8;
+ b1 = ((((GET_B(*a1) << 8) - (b << 8)) / a3) * a4) >> 8;
+
+ r = (r + r1) & 0x1F; //_RGB(r + r1, g + g1, b + b1); doesn't match; I have to assign the value of ((r + r1) & 0x1F) to r1
+ g = (g + g1) & 0x1F; //See above
+ b = (b + b1) & 0x1F; //See above
+
+ *palette = RGB2(r, g, b); //See above comment
+
+ a0++, a1++;
+ palette++;
+ }
+ }
}
void PokenavFadeScreen(s32 fadeType)
@@ -780,7 +681,7 @@ static void LoadLeftHeaderGfxForMenu(u32 menuGfxId)
size = GetDecompressedDataSize(sPokenavMenuLeftHeaderSpriteSheets[menuGfxId].data);
LoadPalette(&gPokenavLeftHeader_Pal[tag * 16], (IndexOfSpritePaletteTag(1) * 16) + 0x100, 0x20);
LZ77UnCompWram(sPokenavMenuLeftHeaderSpriteSheets[menuGfxId].data, gDecompressionBuffer);
- RequestDma3Copy(gDecompressionBuffer, (void *)VRAM + 0x10000 + (GetSpriteTileStartByTag(2) * 32), size, 1);
+ RequestDma3Copy(gDecompressionBuffer, (void *)OBJ_VRAM0 + (GetSpriteTileStartByTag(2) * 32), size, 1);
structPtr->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + sPokenavMenuLeftHeaderSpriteSheets[menuGfxId].size;
if (menuGfxId == POKENAV_GFX_MAP_MENU_ZOOMED_OUT || menuGfxId == POKENAV_GFX_MAP_MENU_ZOOMED_IN)
diff --git a/src/pokenav_match_call_1.c b/src/pokenav_match_call_1.c
index 265259394..d919a4dbf 100755
--- a/src/pokenav_match_call_1.c
+++ b/src/pokenav_match_call_1.c
@@ -79,16 +79,16 @@ static u32 CB2_HandleMatchCallInput(struct Pokenav3Struct *state)
{
int selection;
- if (gMain.newAndRepeatedKeys & DPAD_UP)
+ if (JOY_REPEAT(DPAD_UP))
return POKENAV_MC_FUNC_UP;
- if (gMain.newAndRepeatedKeys & DPAD_DOWN)
+ if (JOY_REPEAT(DPAD_DOWN))
return POKENAV_MC_FUNC_DOWN;
- if (gMain.newAndRepeatedKeys & DPAD_LEFT)
+ if (JOY_REPEAT(DPAD_LEFT))
return POKENAV_MC_FUNC_PG_UP;
- if (gMain.newAndRepeatedKeys & DPAD_RIGHT)
+ if (JOY_REPEAT(DPAD_RIGHT))
return POKENAV_MC_FUNC_PG_DOWN;
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
state->callback = CB2_HandleMatchCallOptionsInput;
state->optionCursorPos = 0;
@@ -108,7 +108,7 @@ static u32 CB2_HandleMatchCallInput(struct Pokenav3Struct *state)
return POKENAV_MC_FUNC_SELECT;
}
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
if (GetPokenavMode() != POKENAV_MODE_FORCE_CALL_READY)
{
@@ -132,19 +132,19 @@ static u32 GetExitMatchCallMenuId(struct Pokenav3Struct *state)
static u32 CB2_HandleMatchCallOptionsInput(struct Pokenav3Struct *state)
{
- if ((gMain.newKeys & DPAD_UP) && state->optionCursorPos)
+ if ((JOY_NEW(DPAD_UP)) && state->optionCursorPos)
{
state->optionCursorPos--;
return POKENAV_MC_FUNC_MOVE_OPTIONS_CURSOR;
}
- if ((gMain.newKeys & DPAD_DOWN) && state->optionCursorPos < state->maxOptionId)
+ if ((JOY_NEW(DPAD_DOWN)) && state->optionCursorPos < state->maxOptionId)
{
state->optionCursorPos++;
return POKENAV_MC_FUNC_MOVE_OPTIONS_CURSOR;
}
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
switch (state->matchCallOptions[state->optionCursorPos])
{
@@ -166,7 +166,7 @@ static u32 CB2_HandleMatchCallOptionsInput(struct Pokenav3Struct *state)
}
}
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
state->callback = CB2_HandleMatchCallInput;
return POKENAV_MC_FUNC_CANCEL;
@@ -177,12 +177,12 @@ static u32 CB2_HandleMatchCallOptionsInput(struct Pokenav3Struct *state)
static u32 CB2_HandleCheckPageInput(struct Pokenav3Struct *state)
{
- if (gMain.newAndRepeatedKeys & DPAD_UP)
+ if (JOY_REPEAT(DPAD_UP))
return POKENAV_MC_FUNC_CHECK_PAGE_UP;
- if (gMain.newAndRepeatedKeys & DPAD_DOWN)
+ if (JOY_REPEAT(DPAD_DOWN))
return POKENAV_MC_FUNC_CHECK_PAGE_DOWN;
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
state->callback = CB2_HandleMatchCallInput;
return POKENAV_MC_FUNC_EXIT_CHECK_PAGE;
@@ -193,7 +193,7 @@ static u32 CB2_HandleCheckPageInput(struct Pokenav3Struct *state)
static u32 CB2_HandleCallInput(struct Pokenav3Struct *state)
{
- if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ if (JOY_NEW(A_BUTTON | B_BUTTON))
{
state->callback = CB2_HandleMatchCallInput;
return POKENAV_MC_FUNC_10;
diff --git a/src/pokenav_match_call_2.c b/src/pokenav_match_call_2.c
index 60091577e..424882670 100755
--- a/src/pokenav_match_call_2.c
+++ b/src/pokenav_match_call_2.c
@@ -1126,7 +1126,7 @@ static void PrintMatchCallMessage(struct Pokenav4Struct *state)
static bool32 WaitForMatchCallMessageText(struct Pokenav4Struct *state)
{
- if (gMain.heldKeys & A_BUTTON)
+ if (JOY_HELD(A_BUTTON))
gTextFlags.canABSpeedUpPrint = 1;
else
gTextFlags.canABSpeedUpPrint = 0;
diff --git a/src/pokenav_menu_handler_1.c b/src/pokenav_menu_handler_1.c
index d8d8e1509..6002d731b 100644
--- a/src/pokenav_menu_handler_1.c
+++ b/src/pokenav_menu_handler_1.c
@@ -216,7 +216,7 @@ static u32 HandleMainMenuInput(struct Pokenav1Struct *state)
if (UpdateMenuCursorPos(state))
return POKENAV_MENU_FUNC_MOVE_CURSOR;
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
switch (sMenuItems[state->menuType][state->cursorPos])
{
@@ -251,7 +251,7 @@ static u32 HandleMainMenuInput(struct Pokenav1Struct *state)
}
}
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
return -1;
return POKENAV_MENU_FUNC_NONE;
@@ -263,7 +263,7 @@ static u32 HandleMainMenuInputTutorial(struct Pokenav1Struct *state)
if (UpdateMenuCursorPos(state))
return POKENAV_MENU_FUNC_MOVE_CURSOR;
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
if (sMenuItems[state->menuType][state->cursorPos] == POKENAV_MENUITEM_MATCH_CALL)
{
@@ -278,7 +278,7 @@ static u32 HandleMainMenuInputTutorial(struct Pokenav1Struct *state)
}
}
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_FAILURE);
return POKENAV_MENU_FUNC_NONE;
@@ -293,7 +293,7 @@ static u32 HandleMainMenuInputEndTutorial(struct Pokenav1Struct *state)
if (UpdateMenuCursorPos(state))
return POKENAV_MENU_FUNC_MOVE_CURSOR;
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
u32 menuItem = sMenuItems[state->menuType][state->cursorPos];
if (menuItem != POKENAV_MENUITEM_MATCH_CALL && menuItem != POKENAV_MENUITEM_SWITCH_OFF)
@@ -312,7 +312,7 @@ static u32 HandleMainMenuInputEndTutorial(struct Pokenav1Struct *state)
return -1;
}
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
return -1;
}
@@ -329,7 +329,7 @@ static u32 HandleCantOpenRibbonsInput(struct Pokenav1Struct *state)
return POKENAV_MENU_FUNC_MOVE_CURSOR;
}
- if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ if (JOY_NEW(A_BUTTON | B_BUTTON))
{
state->callback = GetMainMenuInputHandler();
return POKENAV_MENU_FUNC_RESHOW_DESCRIPTION;
@@ -343,7 +343,7 @@ static u32 HandleConditionMenuInput(struct Pokenav1Struct *state)
if (UpdateMenuCursorPos(state))
return POKENAV_MENU_FUNC_MOVE_CURSOR;
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
switch (sMenuItems[state->menuType][state->cursorPos])
{
@@ -363,7 +363,7 @@ static u32 HandleConditionMenuInput(struct Pokenav1Struct *state)
return POKENAV_MENU_FUNC_RETURN_TO_MAIN;
}
}
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
if (state->cursorPos != sLastCursorPositions[state->menuType])
{
@@ -387,7 +387,7 @@ static u32 HandleConditionSearchMenuInput(struct Pokenav1Struct *state)
if (UpdateMenuCursorPos(state))
return POKENAV_MENU_FUNC_MOVE_CURSOR;
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
u8 menuItem = sMenuItems[state->menuType][state->cursorPos];
if (menuItem != POKENAV_MENUITEM_CONDITION_SEARCH_CANCEL)
@@ -404,7 +404,7 @@ static u32 HandleConditionSearchMenuInput(struct Pokenav1Struct *state)
return POKENAV_MENU_FUNC_RETURN_TO_CONDITION;
}
}
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
if (state->cursorPos != sLastCursorPositions[state->menuType])
{
@@ -463,7 +463,7 @@ static void ReturnToConditionMenu(struct Pokenav1Struct *state)
static bool32 UpdateMenuCursorPos(struct Pokenav1Struct *state)
{
- if (gMain.newKeys & DPAD_UP)
+ if (JOY_NEW(DPAD_UP))
{
if (--state->cursorPos < 0)
state->cursorPos = sLastCursorPositions[state->menuType];
@@ -471,7 +471,7 @@ static bool32 UpdateMenuCursorPos(struct Pokenav1Struct *state)
state->currMenuItem = sMenuItems[state->menuType][state->cursorPos];
return TRUE;
}
- else if (gMain.newKeys & DPAD_DOWN)
+ else if (JOY_NEW(DPAD_DOWN))
{
state->cursorPos++;
if (state->cursorPos > sLastCursorPositions[state->menuType])
diff --git a/src/pokenav_region_map.c b/src/pokenav_region_map.c
index e858fad4a..394b40907 100755
--- a/src/pokenav_region_map.c
+++ b/src/pokenav_region_map.c
@@ -219,7 +219,7 @@ static u32 HandleRegionMapInput(struct Pokenav5Struct *state)
static u32 HandleRegionMapInputZoomDisabled(struct Pokenav5Struct *state)
{
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
state->callback = GetExitRegionMapMenuId;
return POKENAV_MAP_FUNC_EXIT;
diff --git a/src/pokenav_ribbons_1.c b/src/pokenav_ribbons_1.c
index aad0053a8..fd47b27ad 100644
--- a/src/pokenav_ribbons_1.c
+++ b/src/pokenav_ribbons_1.c
@@ -162,21 +162,21 @@ static u32 sub_81CFA68(struct PokenavSub9 *structPtr)
static u32 sub_81CFA88(struct PokenavSub9 *structPtr)
{
- if (gMain.newAndRepeatedKeys & DPAD_UP)
+ if (JOY_REPEAT(DPAD_UP))
return 1;
- if (gMain.newAndRepeatedKeys & DPAD_DOWN)
+ if (JOY_REPEAT(DPAD_DOWN))
return 2;
- if (gMain.newKeys & DPAD_LEFT)
+ if (JOY_NEW(DPAD_LEFT))
return 3;
- if (gMain.newKeys & DPAD_RIGHT)
+ if (JOY_NEW(DPAD_RIGHT))
return 4;
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
structPtr->unk18 = 0;
structPtr->unk0 = sub_81CFB08;
return 5;
}
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
structPtr->unk1C->unk2 = GetSelectedMatchCall();
structPtr->unk18 = 1;
diff --git a/src/pokenav_ribbons_2.c b/src/pokenav_ribbons_2.c
index e5a89acad..6eabc9b33 100644
--- a/src/pokenav_ribbons_2.c
+++ b/src/pokenav_ribbons_2.c
@@ -188,26 +188,26 @@ void sub_81D04B8(void)
u32 sub_81D04C4(struct PokenavSub13 *structPtr)
{
- if (gMain.newAndRepeatedKeys & DPAD_UP && structPtr->field_8->unk2 != 0)
+ if (JOY_REPEAT(DPAD_UP) && structPtr->field_8->unk2 != 0)
{
structPtr->field_8->unk2--;
structPtr->field_C = 0;
sub_81D0814(structPtr);
return 1;
}
- else if (gMain.newAndRepeatedKeys & DPAD_DOWN && structPtr->field_8->unk2 < structPtr->field_8->unk0 - 1)
+ if (JOY_REPEAT(DPAD_DOWN) && structPtr->field_8->unk2 < structPtr->field_8->unk0 - 1)
{
structPtr->field_8->unk2++;
structPtr->field_C = 0;
sub_81D0814(structPtr);
return 1;
}
- else if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
structPtr->field_98 = sub_81D0548;
return 2;
}
- else if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
structPtr->field_98 = sub_81D05D4;
return 5;
@@ -217,15 +217,15 @@ u32 sub_81D04C4(struct PokenavSub13 *structPtr)
u32 sub_81D0548(struct PokenavSub13 *structPtr)
{
- if (gMain.newAndRepeatedKeys & DPAD_UP && sub_81D05DC(structPtr))
+ if (JOY_REPEAT(DPAD_UP) && sub_81D05DC(structPtr))
return 3;
- else if (gMain.newAndRepeatedKeys & DPAD_DOWN && sub_81D061C(structPtr))
+ if (JOY_REPEAT(DPAD_DOWN) && sub_81D061C(structPtr))
return 3;
- else if (gMain.newAndRepeatedKeys & DPAD_LEFT && sub_81D0664(structPtr))
+ if (JOY_REPEAT(DPAD_LEFT) && sub_81D0664(structPtr))
return 3;
- else if (gMain.newAndRepeatedKeys & DPAD_RIGHT && sub_81D0688(structPtr))
+ if (JOY_REPEAT(DPAD_RIGHT) && sub_81D0688(structPtr))
return 3;
- else if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
structPtr->field_98 = sub_81D04C4;
return 4;
diff --git a/src/region_map.c b/src/region_map.c
index 3438ea3ed..49b21be07 100644
--- a/src/region_map.c
+++ b/src/region_map.c
@@ -651,31 +651,31 @@ static u8 ProcessRegionMapInput_Full(void)
input = MAP_INPUT_NONE;
gRegionMap->cursorDeltaX = 0;
gRegionMap->cursorDeltaY = 0;
- if (gMain.heldKeys & DPAD_UP && gRegionMap->cursorPosY > MAPCURSOR_Y_MIN)
+ if (JOY_HELD(DPAD_UP) && gRegionMap->cursorPosY > MAPCURSOR_Y_MIN)
{
gRegionMap->cursorDeltaY = -1;
input = MAP_INPUT_MOVE_START;
}
- if (gMain.heldKeys & DPAD_DOWN && gRegionMap->cursorPosY < MAPCURSOR_Y_MAX)
+ if (JOY_HELD(DPAD_DOWN) && gRegionMap->cursorPosY < MAPCURSOR_Y_MAX)
{
gRegionMap->cursorDeltaY = +1;
input = MAP_INPUT_MOVE_START;
}
- if (gMain.heldKeys & DPAD_LEFT && gRegionMap->cursorPosX > MAPCURSOR_X_MIN)
+ if (JOY_HELD(DPAD_LEFT) && gRegionMap->cursorPosX > MAPCURSOR_X_MIN)
{
gRegionMap->cursorDeltaX = -1;
input = MAP_INPUT_MOVE_START;
}
- if (gMain.heldKeys & DPAD_RIGHT && gRegionMap->cursorPosX < MAPCURSOR_X_MAX)
+ if (JOY_HELD(DPAD_RIGHT) && gRegionMap->cursorPosX < MAPCURSOR_X_MAX)
{
gRegionMap->cursorDeltaX = +1;
input = MAP_INPUT_MOVE_START;
}
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
input = MAP_INPUT_A_BUTTON;
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
input = MAP_INPUT_B_BUTTON;
}
@@ -730,31 +730,31 @@ static u8 ProcessRegionMapInput_Zoomed(void)
input = MAP_INPUT_NONE;
gRegionMap->zoomedCursorDeltaX = 0;
gRegionMap->zoomedCursorDeltaY = 0;
- if (gMain.heldKeys & DPAD_UP && gRegionMap->scrollY > -0x34)
+ if (JOY_HELD(DPAD_UP) && gRegionMap->scrollY > -0x34)
{
gRegionMap->zoomedCursorDeltaY = -1;
input = MAP_INPUT_MOVE_START;
}
- if (gMain.heldKeys & DPAD_DOWN && gRegionMap->scrollY < 0x3c)
+ if (JOY_HELD(DPAD_DOWN) && gRegionMap->scrollY < 0x3c)
{
gRegionMap->zoomedCursorDeltaY = +1;
input = MAP_INPUT_MOVE_START;
}
- if (gMain.heldKeys & DPAD_LEFT && gRegionMap->scrollX > -0x2c)
+ if (JOY_HELD(DPAD_LEFT) && gRegionMap->scrollX > -0x2c)
{
gRegionMap->zoomedCursorDeltaX = -1;
input = MAP_INPUT_MOVE_START;
}
- if (gMain.heldKeys & DPAD_RIGHT && gRegionMap->scrollX < 0xac)
+ if (JOY_HELD(DPAD_RIGHT) && gRegionMap->scrollX < 0xac)
{
gRegionMap->zoomedCursorDeltaX = +1;
input = MAP_INPUT_MOVE_START;
}
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
input = MAP_INPUT_A_BUTTON;
}
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
input = MAP_INPUT_B_BUTTON;
}
diff --git a/src/reset_rtc_screen.c b/src/reset_rtc_screen.c
index 204eb6733..d0e815816 100644
--- a/src/reset_rtc_screen.c
+++ b/src/reset_rtc_screen.c
@@ -380,7 +380,7 @@ static void Task_ResetRtc_1(u8 taskId)
u8 selection = data[2];
const struct ResetRtcStruct *selectionInfo = &sUnknown_08510428[selection - 1];
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
gTasks[taskId].func = Task_ResetRtc_2;
data[1] = 0;
@@ -389,7 +389,7 @@ static void Task_ResetRtc_1(u8 taskId)
return;
}
- if (gMain.newKeys & DPAD_RIGHT)
+ if (JOY_NEW(DPAD_RIGHT))
{
if (selectionInfo->right)
{
@@ -399,7 +399,7 @@ static void Task_ResetRtc_1(u8 taskId)
}
}
- if (gMain.newKeys & DPAD_LEFT)
+ if (JOY_NEW(DPAD_LEFT))
{
if (selectionInfo->left)
{
@@ -411,7 +411,7 @@ static void Task_ResetRtc_1(u8 taskId)
if (selection == 5)
{
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
gLocalTime.days = data[3];
gLocalTime.hours = data[4];
@@ -423,7 +423,7 @@ static void Task_ResetRtc_1(u8 taskId)
data[2] = 6;
}
}
- else if (MoveTimeUpDown(&data[selectionInfo->dataIndex], selectionInfo->minVal, selectionInfo->maxVal, gMain.newAndRepeatedKeys & (DPAD_UP | DPAD_DOWN)))
+ else if (MoveTimeUpDown(&data[selectionInfo->dataIndex], selectionInfo->minVal, selectionInfo->maxVal, JOY_REPEAT(DPAD_UP | DPAD_DOWN)))
{
PlaySE(SE_SELECT);
PrintTime(data[8], 0, 1, data[3], data[4], data[5], data[6]);
@@ -532,12 +532,12 @@ static void Task_ShowResetRtcPrompt(u8 taskId)
ScheduleBgCopyTilemapToVram(0);
data[0]++;
case 1:
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
DestroyTask(taskId);
DoSoftReset();
}
- else if (gMain.newKeys & A_BUTTON)
+ else if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
DestroyTask(taskId);
@@ -620,7 +620,7 @@ static void Task_ResetRtcScreen(u8 taskId)
}
data[0] = 5;
case 5:
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
BeginNormalPaletteFade(0xFFFFFFFF, 1, 0, 0x10, RGB_WHITEALPHA);
data[0] = 6;
diff --git a/src/save.c b/src/save.c
index 3ae2f6fd5..0a2a4e799 100644
--- a/src/save.c
+++ b/src/save.c
@@ -13,7 +13,7 @@
#include "link.h"
#include "constants/game_stat.h"
-static u16 CalculateChecksum(void *data, u16 size);
+static u16 CalculateChecksum(const void *data, u16 size);
static bool8 DoReadFlashWholeSection(u8 sector, struct SaveSection *section);
static u8 GetSaveValidStatus(const struct SaveSectionLocation *location);
static u8 sub_8152E10(u16 a1, const struct SaveSectionLocation *location);
@@ -621,7 +621,7 @@ static bool8 DoReadFlashWholeSection(u8 sector, struct SaveSection *section)
return TRUE;
}
-static u16 CalculateChecksum(void *data, u16 size)
+static u16 CalculateChecksum(const void *data, u16 size)
{
u16 i;
u32 checksum = 0;
@@ -648,12 +648,10 @@ static void UpdateSaveAddresses(void)
gRamSaveSectionLocations[i].size = sSaveSectionOffsets[i].size;
}
- for (i = SECTOR_ID_PKMN_STORAGE_START; i <= SECTOR_ID_PKMN_STORAGE_END; i++)
+ for (; i <= SECTOR_ID_PKMN_STORAGE_END; i++) //i = SECTOR_ID_PKMN_STORAGE_START; in the initialization clause does not match
{
gRamSaveSectionLocations[i].data = (void*)(gPokemonStoragePtr) + sSaveSectionOffsets[i].toAdd;
gRamSaveSectionLocations[i].size = sSaveSectionOffsets[i].size;
-
- i++;i--; // needed to match
}
}
diff --git a/src/save_failed_screen.c b/src/save_failed_screen.c
index 7c824e82d..9bf0e7ed4 100644
--- a/src/save_failed_screen.c
+++ b/src/save_failed_screen.c
@@ -306,7 +306,7 @@ static void CB2_GameplayCannotBeContinued(void)
{
gSaveFailedClockInfo[CLOCK_RUNNING] = FALSE;
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
FillWindowPixelBuffer(gSaveFailedWindowIds[TEXT_WIN_ID], PIXEL_FILL(1));
SaveFailedScreenTextPrint(gText_GamePlayCannotBeContinued, 1, 0);
@@ -319,7 +319,7 @@ static void CB2_FadeAndReturnToTitleScreen(void)
{
gSaveFailedClockInfo[CLOCK_RUNNING] = FALSE;
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
SetVBlankCallback(VBlankCB);
diff --git a/src/scrcmd.c b/src/scrcmd.c
index d2ebcbb85..578e357fa 100644
--- a/src/scrcmd.c
+++ b/src/scrcmd.c
@@ -1325,9 +1325,9 @@ bool8 ScrCmd_closemessage(struct ScriptContext *ctx)
static bool8 WaitForAorBPress(void)
{
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
return TRUE;
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
return TRUE;
return FALSE;
}
diff --git a/src/script_menu.c b/src/script_menu.c
index 2b135e301..425cdc251 100644
--- a/src/script_menu.c
+++ b/src/script_menu.c
@@ -170,7 +170,7 @@ static void Task_HandleMultichoiceInput(u8 taskId)
else
selection = Menu_ProcessInput();
- if (gMain.newKeys & (DPAD_UP | DPAD_DOWN))
+ if (JOY_NEW(DPAD_UP | DPAD_DOWN))
{
DrawLinkServicesMultichoiceMenu(tMultichoiceId);
}
diff --git a/src/shop.c b/src/shop.c
index 5cba2767d..6e2e82a52 100755
--- a/src/shop.c
+++ b/src/shop.c
@@ -1017,7 +1017,7 @@ static void Task_BuyHowManyDialogueHandleInput(u8 taskId)
}
else
{
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
ClearStdWindowAndFrameToTransparent(4, 0);
@@ -1030,7 +1030,7 @@ static void Task_BuyHowManyDialogueHandleInput(u8 taskId)
ConvertIntToDecimalStringN(gStringVar3, gShopDataPtr->totalCost, STR_CONV_MODE_LEFT_ALIGN, 6);
BuyMenuDisplayMessage(taskId, gText_Var1AndYouWantedVar2, BuyMenuConfirmPurchase);
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
ClearStdWindowAndFrameToTransparent(4, 0);
@@ -1106,7 +1106,7 @@ static void Task_ReturnToItemListAfterItemPurchase(u8 taskId)
{
s16 *data = gTasks[taskId].data;
- if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ if (JOY_NEW(A_BUTTON | B_BUTTON))
{
PlaySE(SE_SELECT);
if (tItemId == ITEM_POKE_BALL && tItemCount > 9 && AddBagItem(ITEM_PREMIER_BALL, 1) == TRUE)
@@ -1122,7 +1122,7 @@ static void Task_ReturnToItemListAfterItemPurchase(u8 taskId)
static void Task_ReturnToItemListAfterDecorationPurchase(u8 taskId)
{
- if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ if (JOY_NEW(A_BUTTON | B_BUTTON))
{
PlaySE(SE_SELECT);
BuyMenuReturnToItemList(taskId);
diff --git a/src/slot_machine.c b/src/slot_machine.c
index 9d19fc9a7..cc001bcc9 100644
--- a/src/slot_machine.c
+++ b/src/slot_machine.c
@@ -252,8 +252,8 @@ struct SlotMachine
/*0x0E*/ s16 payout;
/*0x10*/ s16 netCoinLoss; // coins lost to machine (but never goes below 0)
/*0x12*/ s16 bet;
- /*0x14*/ s16 reeltimePixelOffset;
- /*0x16*/ s16 reeltimePosition;
+ /*0x14*/ s16 reelTimePixelOffset;
+ /*0x16*/ s16 reelTimePosition;
/*0x18*/ s16 currReel;
/*0x1A*/ s16 reelIncrement; // speed of reel
/*0x1C*/ s16 reelPixelOffsets[NUM_REELS];
@@ -584,7 +584,7 @@ static const u16 *const sDigitalDisplay_Pal;
static const s16 sInitialReelPositions[NUM_REELS][2];
static const u8 sLuckyFlagProbabilities_Top3[][6];
static const u8 sLuckyFlagProbabilities_NotTop3[][6];
-static const u8 sReeltimeProbabilities_UnluckyGame[][17];
+static const u8 sReelTimeProbabilities_UnluckyGame[][17];
static const u8 sReelTimeProbabilities_LuckyGame[][17];
static const u8 sSymToMatch[];
static const u8 sReelTimeTags[];
@@ -682,7 +682,7 @@ static const struct WindowTemplate sWindowTemplate_InfoBox =
.baseBlock = 1
};
-static const u8 sColors_ReeltimeHelp[] = {TEXT_COLOR_LIGHT_GREY, TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GREY};
+static const u8 sColors_ReelTimeHelp[] = {TEXT_COLOR_LIGHT_GREY, TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GREY};
static bool8 (*const sSlotActions[])(struct Task *task) =
{
@@ -1744,13 +1744,13 @@ static u8 AttemptsAtLuckyFlags_NotTop3(void)
static u8 GetReelTimeProbability(u8 reelTimeDraw)
{
- if (sSlotMachine->luckyGame == FALSE)
- return sReeltimeProbabilities_UnluckyGame[reelTimeDraw][sSlotMachine->pikaPower];
- else
- return sReelTimeProbabilities_LuckyGame[reelTimeDraw][sSlotMachine->pikaPower];
+ if (!sSlotMachine->luckyGame)
+ return sReelTimeProbabilities_UnluckyGame[reelTimeDraw][sSlotMachine->pikaPower];
+
+ return sReelTimeProbabilities_LuckyGame[reelTimeDraw][sSlotMachine->pikaPower];
}
-static void GetReeltimeDraw(void)
+static void GetReelTimeDraw(void)
{
u8 rval;
s16 reelTimeDraw;
@@ -1773,15 +1773,13 @@ static bool8 ShouldReelTimeMachineExplode(u16 i)
u16 rval = Random() & 0xff;
if (rval < sReelTimeExplodeProbability[i])
return TRUE;
- else
- return FALSE;
+ return FALSE;
}
static u16 SlowReelSpeed(void)
{
u8 i = 0;
- u8 rval;
- u8 value;
+ u8 rval, value;
if (sSlotMachine->netCoinLoss >= 300)
i = 4;
else if (sSlotMachine->netCoinLoss >= 250)
@@ -1911,8 +1909,7 @@ static bool8 IsFinalTask_RunAwardPayoutActions(void)
{
if (FindTaskIdByFunc(RunAwardPayoutActions) == TAIL_SENTINEL)
return TRUE;
- else
- return FALSE;
+ return FALSE;
}
static void RunAwardPayoutActions(u8 taskId)
@@ -1945,7 +1942,7 @@ static bool8 AwardPayoutAction_GivePayoutToPlayer(struct Task *task)
if (sSlotMachine->coins < MAX_COINS)
sSlotMachine->coins++;
task->data[1] = 8;
- if (gMain.heldKeys & A_BUTTON)
+ if (JOY_HELD(A_BUTTON))
task->data[1] = 4;
}
if (IsFanfareTaskInactive() && JOY_NEW(START_BUTTON))
@@ -2000,7 +1997,7 @@ static u8 GetTag(u8 reel, s16 offset)
static u8 GetNearbyReelTimeTag(s16 n)
{
- s16 newPosition = (sSlotMachine->reeltimePosition + n) % 6;
+ s16 newPosition = (sSlotMachine->reelTimePosition + n) % 6;
if (newPosition < 0)
newPosition += 6;
return sReelTimeTags[newPosition];
@@ -2026,22 +2023,22 @@ s16 AdvanceSlotReelToNextTag(u8 reelIndex, s16 value)
return offset;
}
-static void AdvanceReeltimeReel(s16 value)
+static void AdvanceReelTimeReel(s16 value)
{
- sSlotMachine->reeltimePixelOffset += value;
- sSlotMachine->reeltimePixelOffset %= 120;
- sSlotMachine->reeltimePosition = 6 - sSlotMachine->reeltimePixelOffset / 20;
+ sSlotMachine->reelTimePixelOffset += value;
+ sSlotMachine->reelTimePixelOffset %= 120;
+ sSlotMachine->reelTimePosition = 6 - sSlotMachine->reelTimePixelOffset / 20;
}
-s16 AdvanceReeltimeReelToNextTag(s16 value)
+s16 AdvanceReelTimeReelToNextTag(s16 value)
{
- s16 offset = sSlotMachine->reeltimePixelOffset % 20;
+ s16 offset = sSlotMachine->reelTimePixelOffset % 20;
if (offset != 0)
{
if (offset < value)
value = offset;
- AdvanceReeltimeReel(value);
- offset = sSlotMachine->reeltimePixelOffset % 20;
+ AdvanceReelTimeReel(value);
+ offset = sSlotMachine->reelTimePixelOffset % 20;
}
return offset;
}
@@ -3080,8 +3077,8 @@ static void Task_ReelTime(u8 taskId)
static void ReelTime_Init(struct Task *task)
{
sSlotMachine->reelTimeSpinsLeft = 0;
- sSlotMachine->reeltimePixelOffset = 0;
- sSlotMachine->reeltimePosition = 0;
+ sSlotMachine->reelTimePixelOffset = 0;
+ sSlotMachine->reelTimePosition = 0;
task->tState++;
task->data[1] = 0;
task->data[2] = 30;
@@ -3096,7 +3093,7 @@ static void ReelTime_Init(struct Task *task)
CreateReelTimeNumberSprites();
CreateReelTimeShadowSprites();
CreateReelTimeNumberGapSprite();
- GetReeltimeDraw();
+ GetReelTimeDraw();
StopMapMusic();
PlayNewMapMusic(MUS_ROULETTE);
}
@@ -3119,12 +3116,12 @@ static void ReelTime_WindowEnter(struct Task *task)
task->tState++;
task->data[3] = 0;
}
- AdvanceReeltimeReel(task->data[4] >> 8);
+ AdvanceReelTimeReel(task->data[4] >> 8);
}
static void ReelTime_WaitStartPikachu(struct Task *task)
{
- AdvanceReeltimeReel(task->data[4] >> 8);
+ AdvanceReelTimeReel(task->data[4] >> 8);
if (++task->data[5] >= 60)
{
task->tState++;
@@ -3144,7 +3141,7 @@ static void ReelTime_PikachuSpeedUp1(struct Task *task)
memcpy(reelTimeBoltDelays, sReelTimeBoltDelays, sizeof(sReelTimeBoltDelays));
memcpy(pikachuAuraFlashDelays, sPikachuAuraFlashDelays, sizeof(sPikachuAuraFlashDelays));
- AdvanceReeltimeReel(task->data[4] >> 8);
+ AdvanceReelTimeReel(task->data[4] >> 8);
// gradually slow down the reel
task->data[4] -= 4;
i = 4 - (task->data[4] >> 8);
@@ -3162,7 +3159,7 @@ static void ReelTime_PikachuSpeedUp1(struct Task *task)
static void ReelTime_PikachuSpeedUp2(struct Task *task)
{
- AdvanceReeltimeReel(task->data[4] >> 8);
+ AdvanceReelTimeReel(task->data[4] >> 8);
if (++task->data[5] >= 80)
{
task->tState++;
@@ -3174,7 +3171,7 @@ static void ReelTime_PikachuSpeedUp2(struct Task *task)
static void ReelTime_WaitReel(struct Task *task)
{
- AdvanceReeltimeReel(task->data[4] >> 8);
+ AdvanceReelTimeReel(task->data[4] >> 8);
task->data[4] = (u8)task->data[4] + 0x80;
if (++task->data[5] >= 80)
{
@@ -3185,7 +3182,7 @@ static void ReelTime_WaitReel(struct Task *task)
static void ReelTime_CheckExplode(struct Task *task)
{
- AdvanceReeltimeReel(task->data[4] >> 8);
+ AdvanceReelTimeReel(task->data[4] >> 8);
task->data[4] = (u8)task->data[4] + 0x40;
if (++task->data[5] >= 40)
{
@@ -3209,19 +3206,19 @@ static void ReelTime_CheckExplode(struct Task *task)
static void ReelTime_LandOnOutcome(struct Task *task)
{
- s16 reeltimePixelOffset = sSlotMachine->reeltimePixelOffset % 20;
- if (reeltimePixelOffset)
+ s16 reelTimePixelOffset = sSlotMachine->reelTimePixelOffset % 20;
+ if (reelTimePixelOffset)
{
- reeltimePixelOffset = AdvanceReeltimeReelToNextTag(task->data[4] >> 8);
+ reelTimePixelOffset = AdvanceReelTimeReelToNextTag(task->data[4] >> 8);
task->data[4] = (u8)task->data[4] + 0x40;
}
else if (GetNearbyReelTimeTag(1) != sSlotMachine->reelTimeDraw)
{
- AdvanceReeltimeReel(task->data[4] >> 8);
- reeltimePixelOffset = sSlotMachine->reeltimePixelOffset % 20;
+ AdvanceReelTimeReel(task->data[4] >> 8);
+ reelTimePixelOffset = sSlotMachine->reelTimePixelOffset % 20;
task->data[4] = (u8)task->data[4] + 0x40;
}
- if (reeltimePixelOffset == 0 && GetNearbyReelTimeTag(1) == sSlotMachine->reelTimeDraw)
+ if (reelTimePixelOffset == 0 && GetNearbyReelTimeTag(1) == sSlotMachine->reelTimeDraw)
{
task->data[4] = 0; // stop moving
task->tState++;
@@ -3444,7 +3441,7 @@ static void InfoBox_DrawWindow(struct Task *task)
static void InfoBox_AddText(struct Task *task)
{
- AddTextPrinterParameterized3(1, 1, 2, 5, sColors_ReeltimeHelp, 0, gText_ReelTimeHelp);
+ AddTextPrinterParameterized3(1, 1, 2, 5, sColors_ReelTimeHelp, 0, gText_ReelTimeHelp);
CopyWindowToVram(1, 3);
BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB(0, 0, 0));
task->tState++;
@@ -3774,7 +3771,7 @@ static void CreateReelTimeNumberSprites(void)
static void SpriteCB_ReelTimeNumbers(struct Sprite *sprite)
{
- s16 r0 = (u16)(sSlotMachine->reeltimePixelOffset + sprite->data[7]);
+ s16 r0 = (u16)(sSlotMachine->reelTimePixelOffset + sprite->data[7]);
r0 %= 40;
sprite->pos1.y = r0 + 59;
StartSpriteAnimIfDifferent(sprite, GetNearbyReelTimeTag(r0 / 20));
@@ -4830,7 +4827,7 @@ static const u8 sLuckyFlagProbabilities_NotTop3[][6] = {
{40, 40, 35, 35, 40, 40}
};
-static const u8 sReeltimeProbabilities_UnluckyGame[][17] = {
+static const u8 sReelTimeProbabilities_UnluckyGame[][17] = {
{243, 243, 243, 80, 80, 80, 80, 40, 40, 40, 40, 40, 40, 5, 5, 5, 5},
{ 5, 5, 5, 150, 150, 150, 150, 130, 130, 130, 130, 130, 130, 100, 100, 100, 5},
{ 4, 4, 4, 20, 20, 20, 20, 80, 80, 80, 80, 80, 80, 100, 100, 100, 40},
diff --git a/src/start_menu.c b/src/start_menu.c
index f470a58b2..fa51766e8 100644
--- a/src/start_menu.c
+++ b/src/start_menu.c
@@ -550,19 +550,19 @@ void ShowStartMenu(void)
static bool8 HandleStartMenuInput(void)
{
- if (gMain.newKeys & DPAD_UP)
+ if (JOY_NEW(DPAD_UP))
{
PlaySE(SE_SELECT);
sStartMenuCursorPos = Menu_MoveCursor(-1);
}
- if (gMain.newKeys & DPAD_DOWN)
+ if (JOY_NEW(DPAD_DOWN))
{
PlaySE(SE_SELECT);
sStartMenuCursorPos = Menu_MoveCursor(1);
}
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
if (sStartMenuItems[sCurrentStartMenuActions[sStartMenuCursorPos]].func.u8_void == StartMenuPokedexCallback)
@@ -584,7 +584,7 @@ static bool8 HandleStartMenuInput(void)
return FALSE;
}
- if (gMain.newKeys & (START_BUTTON | B_BUTTON))
+ if (JOY_NEW(START_BUTTON | B_BUTTON))
{
RemoveExtraStartMenuWindows();
HideStartMenu();
@@ -906,12 +906,12 @@ static bool8 SaveSuccesTimer(void)
{
sSaveDialogTimer--;
- if (gMain.heldKeys & A_BUTTON)
+ if (JOY_HELD(A_BUTTON))
{
PlaySE(SE_SELECT);
return TRUE;
}
- else if (sSaveDialogTimer == 0)
+ if (sSaveDialogTimer == 0)
{
return TRUE;
}
@@ -925,7 +925,7 @@ static bool8 SaveErrorTimer(void)
{
sSaveDialogTimer--;
}
- else if (gMain.heldKeys & A_BUTTON)
+ else if (JOY_HELD(A_BUTTON))
{
return TRUE;
}
diff --git a/src/title_screen.c b/src/title_screen.c
index 108601685..1d6f90d74 100644
--- a/src/title_screen.c
+++ b/src/title_screen.c
@@ -727,24 +727,24 @@ static void Task_TitleScreenPhase2(u8 taskId)
// Show Rayquaza silhouette and process main title screen input
static void Task_TitleScreenPhase3(u8 taskId)
{
- if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & START_BUTTON))
+ if ((JOY_NEW(A_BUTTON)) || (JOY_NEW(START_BUTTON)))
{
FadeOutBGM(4);
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_WHITEALPHA);
SetMainCallback2(CB2_GoToMainMenu);
}
- else if ((gMain.heldKeys & CLEAR_SAVE_BUTTON_COMBO) == CLEAR_SAVE_BUTTON_COMBO)
+ else if (JOY_HELD(CLEAR_SAVE_BUTTON_COMBO) == CLEAR_SAVE_BUTTON_COMBO)
{
SetMainCallback2(CB2_GoToClearSaveDataScreen);
}
- else if ((gMain.heldKeys & RESET_RTC_BUTTON_COMBO) == RESET_RTC_BUTTON_COMBO
+ else if (JOY_HELD(RESET_RTC_BUTTON_COMBO) == RESET_RTC_BUTTON_COMBO
&& CanResetRTC() == TRUE)
{
FadeOutBGM(4);
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK);
SetMainCallback2(CB2_GoToResetRtcScreen);
}
- else if ((gMain.heldKeys & BERRY_UPDATE_BUTTON_COMBO) == BERRY_UPDATE_BUTTON_COMBO)
+ else if (JOY_HELD(BERRY_UPDATE_BUTTON_COMBO) == BERRY_UPDATE_BUTTON_COMBO)
{
FadeOutBGM(4);
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK);
diff --git a/src/trade.c b/src/trade.c
index 3072b8585..17aaba565 100644
--- a/src/trade.c
+++ b/src/trade.c
@@ -1353,24 +1353,24 @@ static void SetReadyToTrade(void)
static void TradeMenuProcessInput(void)
{
- if (gMain.newAndRepeatedKeys & DPAD_UP)
+ if (JOY_REPEAT(DPAD_UP))
{
TradeMenuMoveCursor(&sTradeMenuData->cursorPosition, 0);
}
- else if (gMain.newAndRepeatedKeys & DPAD_DOWN)
+ else if (JOY_REPEAT(DPAD_DOWN))
{
TradeMenuMoveCursor(&sTradeMenuData->cursorPosition, 1);
}
- else if (gMain.newAndRepeatedKeys & DPAD_LEFT)
+ else if (JOY_REPEAT(DPAD_LEFT))
{
TradeMenuMoveCursor(&sTradeMenuData->cursorPosition, 2);
}
- else if (gMain.newAndRepeatedKeys & DPAD_RIGHT)
+ else if (JOY_REPEAT(DPAD_RIGHT))
{
TradeMenuMoveCursor(&sTradeMenuData->cursorPosition, 3);
}
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
@@ -1451,7 +1451,7 @@ static void TradeMenuProcessInput_SelectedMon(void)
static void ChooseMonAfterButtonPress(void)
{
- if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON))
+ if ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON)))
{
PlaySE(SE_SELECT);
TradeMenuChooseMon();
@@ -1626,7 +1626,7 @@ static void RedrawTradeMenuAfterPressA(void)
{
int i;
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
rbox_fill_rectangle(0);
@@ -1698,7 +1698,7 @@ static void LinkTradeWaitForQueue(void)
static void PartnersMonWasInvalid(void)
{
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
SetLinkData(LINKCMD_READY_CANCEL_TRADE, 0);
sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_STANDBY;
@@ -3728,7 +3728,7 @@ static bool8 AnimateTradeSequenceCable(void)
{
return TRUE;
}
- else if (gMain.newKeys & A_BUTTON)
+ else if (JOY_NEW(A_BUTTON))
{
sTradeData->state++;
}
@@ -4243,7 +4243,7 @@ static bool8 AnimateTradeSequenceWireless(void)
{
return TRUE;
}
- else if (gMain.newKeys & A_BUTTON)
+ else if (JOY_NEW(A_BUTTON))
{
sTradeData->state++;
}
diff --git a/src/trainer_card.c b/src/trainer_card.c
index 9d6838176..2d9ec2b09 100755
--- a/src/trainer_card.c
+++ b/src/trainer_card.c
@@ -438,13 +438,13 @@ static void Task_TrainerCard(u8 taskId)
DrawTrainerCardWindow(1);
sData->timeColonNeedDraw = FALSE;
}
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
FlipTrainerCard();
PlaySE(SE_RG_CARD_FLIP);
sData->mainState = STATE_WAIT_FLIP_TO_BACK;
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
if (gReceivedRemoteLinkPlayers && sData->isLink && InUnionRoom() == TRUE)
{
@@ -465,7 +465,7 @@ static void Task_TrainerCard(u8 taskId)
}
break;
case STATE_HANDLE_INPUT_BACK:
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
if (gReceivedRemoteLinkPlayers && sData->isLink && InUnionRoom() == TRUE)
{
@@ -483,7 +483,7 @@ static void Task_TrainerCard(u8 taskId)
PlaySE(SE_RG_CARD_FLIP);
}
}
- else if (gMain.newKeys & A_BUTTON)
+ else if (JOY_NEW(A_BUTTON))
{
if (gReceivedRemoteLinkPlayers && sData->isLink && InUnionRoom() == TRUE)
{
diff --git a/src/union_room.c b/src/union_room.c
index f886d0383..05bd8cfb0 100644
--- a/src/union_room.c
+++ b/src/union_room.c
@@ -445,7 +445,7 @@ static void Task_TryBecomeLinkLeader(u8 taskId)
break;
case LL_STATE_AWAIT_PLAYERS:
Leader_SetStateIfMemberListChanged(data, LL_STATE_ACCEPT_NEW_MEMBER_PROMPT, LL_STATE_MEMBER_LEFT);
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
if (data->playerCount == 1)
data->state = LL_STATE_SHUTDOWN_AND_FAIL;
@@ -458,7 +458,7 @@ static void Task_TryBecomeLinkLeader(u8 taskId)
&& data->playerCount > GROUP_MIN(sPlayerActivityGroupSize) - 1
&& GROUP_MAX(sPlayerActivityGroupSize) != 0
&& sub_8012240()
- && gMain.newKeys & START_BUTTON)
+ && JOY_NEW(START_BUTTON))
{
data->state = LL_STATE_MEMBERS_OK_PROMPT;
LinkRfu_StopManagerAndFinalizeSlots();
@@ -1005,7 +1005,7 @@ static void Task_TryJoinLinkGroup(u8 taskId)
break;
case 0:
id = ListMenu_ProcessInput(data->listTaskId);
- if (gMain.newKeys & A_BUTTON && id != -1)
+ if (JOY_NEW(A_BUTTON) && id != -1)
{
// this unused variable along with the assignment is needed to match
u32 activity = data->field_0->arr[id].gname_uname.gname.activity;
@@ -1032,7 +1032,7 @@ static void Task_TryJoinLinkGroup(u8 taskId)
PlaySE(SE_WALL_HIT);
}
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
data->state = LG_STATE_CANCEL_CHOOSE_LEADER;
}
@@ -1135,7 +1135,7 @@ static void Task_TryJoinLinkGroup(u8 taskId)
break;
}
- if (RfuGetStatus() == RFU_STATUS_OK && gMain.newKeys & B_BUTTON)
+ if (RfuGetStatus() == RFU_STATUS_OK && JOY_NEW(B_BUTTON))
data->state = LG_STATE_ASK_LEAVE_GROUP;
break;
case LG_STATE_ASK_LEAVE_GROUP:
@@ -1889,7 +1889,7 @@ static void Task_MEvent_Leader(u8 taskId)
break;
case 4:
Leader_SetStateIfMemberListChanged(data, 5, 6);
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
{
data->state = 13;
DestroyWirelessStatusIndicatorSprite();
@@ -2104,7 +2104,7 @@ static void Task_CardOrNewsWithFriend(u8 taskId)
break;
case 0:
id = ListMenu_ProcessInput(data->listTaskId);
- if (gMain.newKeys & A_BUTTON && id != -1)
+ if (JOY_NEW(A_BUTTON) && id != -1)
{
// this unused variable along with the assignment is needed to match
u32 unusedVar;
@@ -2126,7 +2126,7 @@ static void Task_CardOrNewsWithFriend(u8 taskId)
PlaySE(SE_WALL_HIT);
}
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
data->state = 6;
}
@@ -2289,7 +2289,7 @@ static void Task_CardOrNewsOverWireless(u8 taskId)
}
}
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
data->state = 6;
data->refreshTimer = 0;
@@ -2547,7 +2547,7 @@ static void Task_RunUnionRoom(u8 taskId)
}
else if (ScriptContext2_IsEnabled() != TRUE)
{
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
if (TryInteractWithUnionRoomMember(uroom->field_0, &taskData[0], &taskData[1], uroom->spriteIds))
{
@@ -2881,7 +2881,7 @@ static void Task_RunUnionRoom(u8 taskId)
break;
case UR_STATE_HANDLE_CONTACT_DATA:
ReceiveUnionRoomActivityPacket(uroom);
- if (UnionRoom_HandleContactFromOtherPlayer(uroom) && gMain.newKeys & B_BUTTON)
+ if (UnionRoom_HandleContactFromOtherPlayer(uroom) && JOY_NEW(B_BUTTON))
{
sub_8011DE0(1);
StringCopy(gStringVar4, sText_ChatEnded);
diff --git a/src/union_room_chat.c b/src/union_room_chat.c
index a7df14dd7..ed39d3acf 100755
--- a/src/union_room_chat.c
+++ b/src/union_room_chat.c
@@ -1017,12 +1017,12 @@ static void Chat_HandleInput(void)
switch (sChat->funcState)
{
case 0:
- if (gMain.newKeys & START_BUTTON)
+ if (JOY_NEW(START_BUTTON))
{
if (sChat->bufferCursorPos)
SetChatFunction(CHAT_FUNC_SEND);
}
- else if (gMain.newKeys & SELECT_BUTTON)
+ else if (JOY_NEW(SELECT_BUTTON))
{
SetChatFunction(CHAT_FUNC_SWITCH);
}
@@ -1039,14 +1039,14 @@ static void Chat_HandleInput(void)
SetChatFunction(CHAT_FUNC_ASK_QUIT);
}
}
- else if (gMain.newKeys & A_BUTTON)
+ else if (JOY_NEW(A_BUTTON))
{
AppendTextToMessage();
StartDisplaySubtask(CHATDISPLAY_FUNC_UPDATE_MSG, 0);
StartDisplaySubtask(CHATDISPLAY_FUNC_CURSOR_BLINK, 1);
sChat->funcState = 1;
}
- else if (gMain.newKeys & R_BUTTON)
+ else if (JOY_NEW(R_BUTTON))
{
if (sChat->currentPage != UNION_ROOM_KB_PAGE_REGISTER)
{
@@ -1100,7 +1100,7 @@ static void Chat_Switch(void)
shouldSwitchPages = FALSE;
break;
case MENU_NOTHING_CHOSEN:
- if (gMain.newKeys & SELECT_BUTTON)
+ if (JOY_NEW(SELECT_BUTTON))
{
PlaySE(SE_SELECT);
Menu_MoveCursor(1);
@@ -1420,13 +1420,13 @@ static void Chat_Register(void)
}
break;
case 1:
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
RegisterTextAtRow();
StartDisplaySubtask(CHATDISPLAY_FUNC_RETURN_TO_KB, 0);
sChat->funcState = 3;
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
StartDisplaySubtask(CHATDISPLAY_FUNC_CANCEL_REGISTER, 0);
sChat->funcState = 4;
@@ -1457,7 +1457,7 @@ static void Chat_Register(void)
sChat->funcState = 6;
break;
case 6:
- if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ if (JOY_NEW(A_BUTTON | B_BUTTON))
{
StartDisplaySubtask(CHATDISPLAY_FUNC_DESTROY_YESNO, 0);
sChat->funcState = 4;
@@ -1591,7 +1591,7 @@ static bool32 HandleDPadInput(void)
{
do
{
- if (gMain.newAndRepeatedKeys & DPAD_UP)
+ if (JOY_REPEAT(DPAD_UP))
{
if (sChat->currentRow > 0)
sChat->currentRow--;
@@ -1599,7 +1599,7 @@ static bool32 HandleDPadInput(void)
sChat->currentRow = sKeyboardPageMaxRow[sChat->currentPage];
break;
}
- if (gMain.newAndRepeatedKeys & DPAD_DOWN)
+ if (JOY_REPEAT(DPAD_DOWN))
{
if (sChat->currentRow < sKeyboardPageMaxRow[sChat->currentPage])
sChat->currentRow++;
@@ -1609,7 +1609,7 @@ static bool32 HandleDPadInput(void)
}
if (sChat->currentPage != UNION_ROOM_KB_PAGE_REGISTER)
{
- if (gMain.newAndRepeatedKeys & DPAD_LEFT)
+ if (JOY_REPEAT(DPAD_LEFT))
{
if (sChat->currentCol > 0)
sChat->currentCol--;
@@ -1617,7 +1617,7 @@ static bool32 HandleDPadInput(void)
sChat->currentCol = 4;
break;
}
- else if (gMain.newAndRepeatedKeys & DPAD_RIGHT)
+ else if (JOY_REPEAT(DPAD_RIGHT))
{
if (sChat->currentCol < 4)
sChat->currentCol++;
diff --git a/src/unk_text_util_2.c b/src/unk_text_util_2.c
index 2ff8c6507..b92b34fbd 100644
--- a/src/unk_text_util_2.c
+++ b/src/unk_text_util_2.c
@@ -19,14 +19,14 @@ u16 Font6Func(struct TextPrinter *textPrinter)
switch (textPrinter->state)
{
case 0:
- if (gMain.heldKeys & (A_BUTTON | B_BUTTON) && subStruct->hasPrintBeenSpedUp)
+ if (JOY_HELD(A_BUTTON | B_BUTTON) && subStruct->hasPrintBeenSpedUp)
{
textPrinter->delayCounter = 0;
}
if (textPrinter->delayCounter && textPrinter->textSpeed)
{
textPrinter->delayCounter --;
- if (gTextFlags.canABSpeedUpPrint && gMain.newKeys & (A_BUTTON | B_BUTTON))
+ if (gTextFlags.canABSpeedUpPrint && JOY_NEW(A_BUTTON | B_BUTTON))
{
subStruct->hasPrintBeenSpedUp = TRUE;
textPrinter->delayCounter = 0;
@@ -135,7 +135,7 @@ u16 Font6Func(struct TextPrinter *textPrinter)
}
DecompressGlyphFont6(char_);
CopyGlyphToWindow(textPrinter);
- textPrinter->printerTemplate.currentX += gUnknown_03002F90.unk80 + textPrinter->printerTemplate.letterSpacing;
+ textPrinter->printerTemplate.currentX += gUnknown_03002F90.width + textPrinter->printerTemplate.letterSpacing;
return 0;
case 1:
if (TextPrinterWait(textPrinter))
@@ -210,8 +210,8 @@ static void DecompressGlyphFont6(u16 glyph)
DecompressGlyphTile(glyphs + 0x8, (u16 *)(gUnknown_03002F90.unk20));
DecompressGlyphTile(glyphs + 0x80, (u16 *)(gUnknown_03002F90.unk40));
DecompressGlyphTile(glyphs + 0x88, (u16 *)(gUnknown_03002F90.unk60));
- gUnknown_03002F90.unk80 = 0x10;
- gUnknown_03002F90.unk81 = 0x10;
+ gUnknown_03002F90.width = 0x10;
+ gUnknown_03002F90.height = 0x10;
}
u32 GetGlyphWidthFont6(u16 glyphId, bool32 isJapanese)
diff --git a/src/walda_phrase.c b/src/walda_phrase.c
index 4b617e3b8..2b11add76 100644
--- a/src/walda_phrase.c
+++ b/src/walda_phrase.c
@@ -118,8 +118,8 @@ static u8 GetLetterTableId(u8 letter)
static bool32 TryCalculateWallpaper(u16* backgroundClr, u16 *foregroundClr, u8 *iconId, u8 *patternId, u16 trainerId, u8 *phrase)
{
s32 i;
- ALIGNED(2) u8 array[12];
- u8 charsByTableId[16];
+ u8 array[9];
+ u8 charsByTableId[15];
u16 *ptr;
if (StringLength(phrase) != 15)
diff --git a/src/wallclock.c b/src/wallclock.c
index bed04928e..c38dd99e3 100644
--- a/src/wallclock.c
+++ b/src/wallclock.c
@@ -795,7 +795,7 @@ static void Task_SetClock_HandleInput(u8 taskId)
{
gTasks[taskId].tMinuteHandAngle = gTasks[taskId].tMinutes * 6;
gTasks[taskId].tHourHandAngle = (gTasks[taskId].tHours % 12) * 30 + (gTasks[taskId].tMinutes / 10) * 5;
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
gTasks[taskId].func = Task_SetClock_AskConfirm;
}
@@ -803,10 +803,10 @@ static void Task_SetClock_HandleInput(u8 taskId)
{
gTasks[taskId].tMoveDir = MOVE_NONE;
- if (gMain.heldKeys & DPAD_LEFT)
+ if (JOY_HELD(DPAD_LEFT))
gTasks[taskId].tMoveDir = MOVE_BACKWARD;
- if (gMain.heldKeys & DPAD_RIGHT)
+ if (JOY_HELD(DPAD_RIGHT))
gTasks[taskId].tMoveDir = MOVE_FORWARD;
if (gTasks[taskId].tMoveDir != MOVE_NONE)
@@ -878,7 +878,7 @@ static void Task_ViewClock_WaitFadeIn(u8 taskId)
static void Task_ViewClock_HandleInput(u8 taskId)
{
InitClockWithRtc(taskId);
- if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ if (JOY_NEW(A_BUTTON | B_BUTTON))
gTasks[taskId].func = Task_ViewClock_FadeOut;
}