From 41847cd5aa45f3fd171e2f014d53dfc8b011913c Mon Sep 17 00:00:00 2001 From: GriffinR Date: Fri, 4 Aug 2023 16:27:45 -0400 Subject: [PATCH 01/48] STAT_ANIM constant usage --- include/battle_anim.h | 20 +++++++-- src/battle_anim_status_effects.c | 76 ++++++++++++++++---------------- src/battle_anim_utility_funcs.c | 17 +++---- src/battle_script_commands.c | 16 +++---- src/battle_util.c | 10 ++--- 5 files changed, 75 insertions(+), 64 deletions(-) diff --git a/include/battle_anim.h b/include/battle_anim.h index f99af9059bcd..455bf5f4cd84 100644 --- a/include/battle_anim.h +++ b/include/battle_anim.h @@ -192,14 +192,26 @@ u8 GetBattlerSpriteDefault_Y(u8 battlerId); u8 GetSubstituteSpriteDefault_Y(u8 battlerId); // battle_anim_status_effects.c -#define STAT_ANIM_PLUS1 15 -#define STAT_ANIM_PLUS2 39 -#define STAT_ANIM_MINUS1 22 -#define STAT_ANIM_MINUS2 46 +#define STAT_ANIM_PLUS1 14 +#define STAT_ANIM_PLUS2 38 +#define STAT_ANIM_MINUS1 21 +#define STAT_ANIM_MINUS2 45 #define STAT_ANIM_MULTIPLE_PLUS1 55 #define STAT_ANIM_MULTIPLE_PLUS2 56 #define STAT_ANIM_MULTIPLE_MINUS1 57 #define STAT_ANIM_MULTIPLE_MINUS2 58 + +enum { + STAT_ANIM_PAL_ATK, + STAT_ANIM_PAL_DEF, + STAT_ANIM_PAL_ACC, + STAT_ANIM_PAL_SPEED, + STAT_ANIM_PAL_EVASION, + STAT_ANIM_PAL_SPATK, + STAT_ANIM_PAL_SPDEF, + STAT_ANIM_PAL_MULTIPLE = 0xFF +}; + void LaunchStatusAnimation(u8 battlerId, u8 statusAnimId); // battle_anim_ground.c diff --git a/src/battle_anim_status_effects.c b/src/battle_anim_status_effects.c index 5000e11096c4..e09a368509a1 100644 --- a/src/battle_anim_status_effects.c +++ b/src/battle_anim_status_effects.c @@ -480,8 +480,6 @@ static void AnimTask_FrozenIceCube_Step4(u8 taskId) } } -#define CASE(by, stat) case (STAT_ANIM_##by + stat - 1) - void AnimTask_StatsChange(u8 taskId) { bool16 goesDown = FALSE; @@ -490,42 +488,42 @@ void AnimTask_StatsChange(u8 taskId) switch (gBattleSpritesDataPtr->animationData->animArg) { - CASE(PLUS1, STAT_ATK): goesDown = FALSE; animStatId = 0; break; - CASE(PLUS1, STAT_DEF): goesDown = FALSE; animStatId = 1; break; - CASE(PLUS1, STAT_SPEED): goesDown = FALSE; animStatId = 3; break; - CASE(PLUS1, STAT_SPATK): goesDown = FALSE; animStatId = 5; break; - CASE(PLUS1, STAT_SPDEF): goesDown = FALSE; animStatId = 6; break; - CASE(PLUS1, STAT_ACC): goesDown = FALSE; animStatId = 2; break; - CASE(PLUS1, STAT_EVASION): goesDown = FALSE; animStatId = 4; break; - - CASE(MINUS1, STAT_ATK): goesDown = TRUE; animStatId = 0; break; - CASE(MINUS1, STAT_DEF): goesDown = TRUE; animStatId = 1; break; - CASE(MINUS1, STAT_SPEED): goesDown = TRUE; animStatId = 3; break; - CASE(MINUS1, STAT_SPATK): goesDown = TRUE; animStatId = 5; break; - CASE(MINUS1, STAT_SPDEF): goesDown = TRUE; animStatId = 6; break; - CASE(MINUS1, STAT_ACC): goesDown = TRUE; animStatId = 2; break; - CASE(MINUS1, STAT_EVASION): goesDown = TRUE; animStatId = 4; break; - - CASE(PLUS2, STAT_ATK): goesDown = FALSE; animStatId = 0; sharply = TRUE; break; - CASE(PLUS2, STAT_DEF): goesDown = FALSE; animStatId = 1; sharply = TRUE; break; - CASE(PLUS2, STAT_SPEED): goesDown = FALSE; animStatId = 3; sharply = TRUE; break; - CASE(PLUS2, STAT_SPATK): goesDown = FALSE; animStatId = 5; sharply = TRUE; break; - CASE(PLUS2, STAT_SPDEF): goesDown = FALSE; animStatId = 6; sharply = TRUE; break; - CASE(PLUS2, STAT_ACC): goesDown = FALSE; animStatId = 2; sharply = TRUE; break; - CASE(PLUS2, STAT_EVASION): goesDown = FALSE; animStatId = 4; sharply = TRUE; break; - - CASE(MINUS2, STAT_ATK): goesDown = TRUE; animStatId = 0; sharply = TRUE; break; - CASE(MINUS2, STAT_DEF): goesDown = TRUE; animStatId = 1; sharply = TRUE; break; - CASE(MINUS2, STAT_SPEED): goesDown = TRUE; animStatId = 3; sharply = TRUE; break; - CASE(MINUS2, STAT_SPATK): goesDown = TRUE; animStatId = 5; sharply = TRUE; break; - CASE(MINUS2, STAT_SPDEF): goesDown = TRUE; animStatId = 6; sharply = TRUE; break; - CASE(MINUS2, STAT_ACC): goesDown = TRUE; animStatId = 2; sharply = TRUE; break; - CASE(MINUS2, STAT_EVASION): goesDown = TRUE; animStatId = 4; sharply = TRUE; break; - - case STAT_ANIM_MULTIPLE_PLUS1: goesDown = FALSE; animStatId = 0xFF; sharply = FALSE; break; - case STAT_ANIM_MULTIPLE_PLUS2: goesDown = FALSE; animStatId = 0xFF; sharply = TRUE; break; - case STAT_ANIM_MULTIPLE_MINUS1: goesDown = TRUE; animStatId = 0xFF; sharply = FALSE; break; - case STAT_ANIM_MULTIPLE_MINUS2: goesDown = TRUE; animStatId = 0xFF; sharply = TRUE; break; + case STAT_ANIM_PLUS1 + STAT_ATK: goesDown = FALSE; animStatId = STAT_ANIM_PAL_ATK; break; + case STAT_ANIM_PLUS1 + STAT_DEF: goesDown = FALSE; animStatId = STAT_ANIM_PAL_DEF; break; + case STAT_ANIM_PLUS1 + STAT_SPEED: goesDown = FALSE; animStatId = STAT_ANIM_PAL_SPEED; break; + case STAT_ANIM_PLUS1 + STAT_SPATK: goesDown = FALSE; animStatId = STAT_ANIM_PAL_SPATK; break; + case STAT_ANIM_PLUS1 + STAT_SPDEF: goesDown = FALSE; animStatId = STAT_ANIM_PAL_SPDEF; break; + case STAT_ANIM_PLUS1 + STAT_ACC: goesDown = FALSE; animStatId = STAT_ANIM_PAL_ACC; break; + case STAT_ANIM_PLUS1 + STAT_EVASION: goesDown = FALSE; animStatId = STAT_ANIM_PAL_EVASION; break; + + case STAT_ANIM_MINUS1 + STAT_ATK: goesDown = TRUE; animStatId = STAT_ANIM_PAL_ATK; break; + case STAT_ANIM_MINUS1 + STAT_DEF: goesDown = TRUE; animStatId = STAT_ANIM_PAL_DEF; break; + case STAT_ANIM_MINUS1 + STAT_SPEED: goesDown = TRUE; animStatId = STAT_ANIM_PAL_SPEED; break; + case STAT_ANIM_MINUS1 + STAT_SPATK: goesDown = TRUE; animStatId = STAT_ANIM_PAL_SPATK; break; + case STAT_ANIM_MINUS1 + STAT_SPDEF: goesDown = TRUE; animStatId = STAT_ANIM_PAL_SPDEF; break; + case STAT_ANIM_MINUS1 + STAT_ACC: goesDown = TRUE; animStatId = STAT_ANIM_PAL_ACC; break; + case STAT_ANIM_MINUS1 + STAT_EVASION: goesDown = TRUE; animStatId = STAT_ANIM_PAL_EVASION; break; + + case STAT_ANIM_PLUS2 + STAT_ATK: goesDown = FALSE; animStatId = STAT_ANIM_PAL_ATK; sharply = TRUE; break; + case STAT_ANIM_PLUS2 + STAT_DEF: goesDown = FALSE; animStatId = STAT_ANIM_PAL_DEF; sharply = TRUE; break; + case STAT_ANIM_PLUS2 + STAT_SPEED: goesDown = FALSE; animStatId = STAT_ANIM_PAL_SPEED; sharply = TRUE; break; + case STAT_ANIM_PLUS2 + STAT_SPATK: goesDown = FALSE; animStatId = STAT_ANIM_PAL_SPATK; sharply = TRUE; break; + case STAT_ANIM_PLUS2 + STAT_SPDEF: goesDown = FALSE; animStatId = STAT_ANIM_PAL_SPDEF; sharply = TRUE; break; + case STAT_ANIM_PLUS2 + STAT_ACC: goesDown = FALSE; animStatId = STAT_ANIM_PAL_ACC; sharply = TRUE; break; + case STAT_ANIM_PLUS2 + STAT_EVASION: goesDown = FALSE; animStatId = STAT_ANIM_PAL_EVASION; sharply = TRUE; break; + + case STAT_ANIM_MINUS2 + STAT_ATK: goesDown = TRUE; animStatId = STAT_ANIM_PAL_ATK; sharply = TRUE; break; + case STAT_ANIM_MINUS2 + STAT_DEF: goesDown = TRUE; animStatId = STAT_ANIM_PAL_DEF; sharply = TRUE; break; + case STAT_ANIM_MINUS2 + STAT_SPEED: goesDown = TRUE; animStatId = STAT_ANIM_PAL_SPEED; sharply = TRUE; break; + case STAT_ANIM_MINUS2 + STAT_SPATK: goesDown = TRUE; animStatId = STAT_ANIM_PAL_SPATK; sharply = TRUE; break; + case STAT_ANIM_MINUS2 + STAT_SPDEF: goesDown = TRUE; animStatId = STAT_ANIM_PAL_SPDEF; sharply = TRUE; break; + case STAT_ANIM_MINUS2 + STAT_ACC: goesDown = TRUE; animStatId = STAT_ANIM_PAL_ACC; sharply = TRUE; break; + case STAT_ANIM_MINUS2 + STAT_EVASION: goesDown = TRUE; animStatId = STAT_ANIM_PAL_EVASION; sharply = TRUE; break; + + case STAT_ANIM_MULTIPLE_PLUS1: goesDown = FALSE; animStatId = STAT_ANIM_PAL_MULTIPLE; sharply = FALSE; break; + case STAT_ANIM_MULTIPLE_PLUS2: goesDown = FALSE; animStatId = STAT_ANIM_PAL_MULTIPLE; sharply = TRUE; break; + case STAT_ANIM_MULTIPLE_MINUS1: goesDown = TRUE; animStatId = STAT_ANIM_PAL_MULTIPLE; sharply = FALSE; break; + case STAT_ANIM_MULTIPLE_MINUS2: goesDown = TRUE; animStatId = STAT_ANIM_PAL_MULTIPLE; sharply = TRUE; break; default: DestroyAnimVisualTask(taskId); @@ -538,7 +536,7 @@ void AnimTask_StatsChange(u8 taskId) gBattleAnimArgs[3] = 0; gBattleAnimArgs[4] = sharply; gTasks[taskId].func = InitStatsChangeAnimation; - InitStatsChangeAnimation(taskId); + gTasks[taskId].func(taskId); } #undef CASE diff --git a/src/battle_anim_utility_funcs.c b/src/battle_anim_utility_funcs.c index afc3d61ce4a6..9375fda43067 100644 --- a/src/battle_anim_utility_funcs.c +++ b/src/battle_anim_utility_funcs.c @@ -393,7 +393,7 @@ void InitStatsChangeAnimation(u8 taskId) u8 i; sAnimStatsChangeData = AllocZeroed(sizeof(struct AnimStatsChangeData)); - for (i = 0; i < 8; i++) + for (i = 0; i < ARRAY_COUNT(sAnimStatsChangeData->data); i++) sAnimStatsChangeData->data[i] = gBattleAnimArgs[i]; gTasks[taskId].func = StatsChangeAnimation_Step1; @@ -477,28 +477,29 @@ static void StatsChangeAnimation_Step2(u8 taskId) AnimLoadCompressedBgGfx(animBgData.bgId, gBattleStatMask_Gfx, animBgData.tilesOffset); switch (sAnimStatsChangeData->data[1]) { - case 0: + case STAT_ANIM_PAL_ATK: LoadCompressedPalette(gBattleStatMask2_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP); break; - case 1: + case STAT_ANIM_PAL_DEF: LoadCompressedPalette(gBattleStatMask1_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP); break; - case 2: + case STAT_ANIM_PAL_ACC: LoadCompressedPalette(gBattleStatMask3_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP); break; - case 3: + case STAT_ANIM_PAL_SPEED: LoadCompressedPalette(gBattleStatMask4_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP); break; - case 4: + case STAT_ANIM_PAL_EVASION: LoadCompressedPalette(gBattleStatMask6_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP); break; - case 5: + case STAT_ANIM_PAL_SPATK: LoadCompressedPalette(gBattleStatMask7_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP); break; - case 6: + case STAT_ANIM_PAL_SPDEF: LoadCompressedPalette(gBattleStatMask8_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP); break; default: + // case STAT_ANIM_PAL_MULTIPLE: LoadCompressedPalette(gBattleStatMask5_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP); break; } diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index bf9197a0e8f2..d86c1433ab22 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -4061,16 +4061,16 @@ static void Cmd_setgraphicalstatchangevalues(void) switch (GET_STAT_BUFF_VALUE2(gBattleScripting.statChanger)) { case SET_STAT_BUFF_VALUE(1): // +1 - value = STAT_ANIM_PLUS1; + value = STAT_ANIM_PLUS1 + 1; break; case SET_STAT_BUFF_VALUE(2): // +2 - value = STAT_ANIM_PLUS2; + value = STAT_ANIM_PLUS2 + 1; break; case SET_STAT_BUFF_VALUE(1) | STAT_BUFF_NEGATIVE: // -1 - value = STAT_ANIM_MINUS1; + value = STAT_ANIM_MINUS1 + 1; break; case SET_STAT_BUFF_VALUE(2) | STAT_BUFF_NEGATIVE: // -2 - value = STAT_ANIM_MINUS2; + value = STAT_ANIM_MINUS2 + 1; break; } gBattleScripting.animArg1 = GET_STAT_BUFF_ID(gBattleScripting.statChanger) + value - 1; @@ -4092,9 +4092,9 @@ static void Cmd_playstatchangeanimation(void) { s16 startingStatAnimId; if (gBattlescriptCurrInstr[3] & STAT_CHANGE_BY_TWO) - startingStatAnimId = STAT_ANIM_MINUS2 - 1; + startingStatAnimId = STAT_ANIM_MINUS2; else - startingStatAnimId = STAT_ANIM_MINUS1 - 1; + startingStatAnimId = STAT_ANIM_MINUS1; while (statsToCheck != 0) { @@ -4136,9 +4136,9 @@ static void Cmd_playstatchangeanimation(void) { s16 startingStatAnimId; if (gBattlescriptCurrInstr[3] & STAT_CHANGE_BY_TWO) - startingStatAnimId = STAT_ANIM_PLUS2 - 1; + startingStatAnimId = STAT_ANIM_PLUS2; else - startingStatAnimId = STAT_ANIM_PLUS1 - 1; + startingStatAnimId = STAT_ANIM_PLUS1; while (statsToCheck != 0) { diff --git a/src/battle_util.c b/src/battle_util.c index 68a5b6adaae9..837fdc3c71f6 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -374,7 +374,7 @@ void HandleAction_UseItem(void) gBattleTextBuff1[2]++; } - gBattleScripting.animArg1 = gBattleTextBuff1[2] + 14; + gBattleScripting.animArg1 = gBattleTextBuff1[2] + STAT_ANIM_PLUS1; gBattleScripting.animArg2 = 0; } break; @@ -2625,7 +2625,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA if (gBattleMons[battler].statStages[STAT_SPEED] < MAX_STAT_STAGE && gDisableStructs[battler].isFirstTurn != 2) { gBattleMons[battler].statStages[STAT_SPEED]++; - gBattleScripting.animArg1 = 14 + STAT_SPEED; + gBattleScripting.animArg1 = STAT_ANIM_PLUS1 + STAT_SPEED; gBattleScripting.animArg2 = 0; BattleScriptPushCursorAndCallback(BattleScript_SpeedBoostActivates); gBattleScripting.battler = battler; @@ -3229,7 +3229,7 @@ enum PREPARE_STAT_BUFFER(gBattleTextBuff1, stat); \ gEffectBattler = battlerId; \ SET_STATCHANGER(stat, 1, FALSE); \ - gBattleScripting.animArg1 = 14 + (stat); \ + gBattleScripting.animArg1 = STAT_ANIM_PLUS1 + (stat); \ gBattleScripting.animArg2 = 0; \ BattleScriptExecute(BattleScript_BerryStatRaiseEnd2); \ effect = ITEM_STATS_CHANGE; \ @@ -3415,7 +3415,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) PREPARE_STRING_BUFFER(gBattleTextBuff2, STRINGID_STATROSE); // Only the Attack stat-up berry has this gEffectBattler = battlerId; SET_STATCHANGER(STAT_ATK, 1, FALSE); - gBattleScripting.animArg1 = 14 + STAT_ATK; + gBattleScripting.animArg1 = STAT_ANIM_PLUS1 + STAT_ATK; gBattleScripting.animArg2 = 0; BattleScriptExecute(BattleScript_BerryStatRaiseEnd2); effect = ITEM_STATS_CHANGE; @@ -3470,7 +3470,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) gEffectBattler = battlerId; SET_STATCHANGER(i + 1, 2, FALSE); - gBattleScripting.animArg1 = 0x21 + i + 6; + gBattleScripting.animArg1 = STAT_ANIM_PLUS2 + (i + 1); gBattleScripting.animArg2 = 0; BattleScriptExecute(BattleScript_BerryStatRaiseEnd2); effect = ITEM_STATS_CHANGE; From 6598cb30bc1ebeed495e7921d0c2cfb4c5bbd630 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Tue, 8 Aug 2023 23:37:21 -0400 Subject: [PATCH 02/48] Document stat change animation --- .../stat3.pal => stat_change/accuracy.pal} | 0 .../stat2.pal => stat_change/attack.pal} | 0 .../decrease.bin} | 0 .../stat1.pal => stat_change/defense.pal} | 0 .../stat6.pal => stat_change/evasion.pal} | 0 .../increase.bin} | Bin .../stat5.pal => stat_change/multiple.pal} | 0 .../stat7.pal => stat_change/sp_attack.pal} | 0 .../stat8.pal => stat_change/sp_defense.pal} | 0 .../stat4.pal => stat_change/speed.pal} | 0 .../{masks/stat.png => stat_change/tiles.png} | Bin include/graphics.h | 23 +-- src/battle_anim_status_effects.c | 4 +- src/battle_anim_utility_funcs.c | 170 +++++++++++------- src/graphics.c | 23 ++- 15 files changed, 131 insertions(+), 89 deletions(-) rename graphics/battle_anims/{masks/stat3.pal => stat_change/accuracy.pal} (100%) rename graphics/battle_anims/{masks/stat2.pal => stat_change/attack.pal} (100%) rename graphics/battle_anims/{masks/stat_tilemap_2.bin => stat_change/decrease.bin} (100%) rename graphics/battle_anims/{masks/stat1.pal => stat_change/defense.pal} (100%) rename graphics/battle_anims/{masks/stat6.pal => stat_change/evasion.pal} (100%) rename graphics/battle_anims/{masks/stat_tilemap_1.bin => stat_change/increase.bin} (100%) rename graphics/battle_anims/{masks/stat5.pal => stat_change/multiple.pal} (100%) rename graphics/battle_anims/{masks/stat7.pal => stat_change/sp_attack.pal} (100%) rename graphics/battle_anims/{masks/stat8.pal => stat_change/sp_defense.pal} (100%) rename graphics/battle_anims/{masks/stat4.pal => stat_change/speed.pal} (100%) rename graphics/battle_anims/{masks/stat.png => stat_change/tiles.png} (100%) diff --git a/graphics/battle_anims/masks/stat3.pal b/graphics/battle_anims/stat_change/accuracy.pal similarity index 100% rename from graphics/battle_anims/masks/stat3.pal rename to graphics/battle_anims/stat_change/accuracy.pal diff --git a/graphics/battle_anims/masks/stat2.pal b/graphics/battle_anims/stat_change/attack.pal similarity index 100% rename from graphics/battle_anims/masks/stat2.pal rename to graphics/battle_anims/stat_change/attack.pal diff --git a/graphics/battle_anims/masks/stat_tilemap_2.bin b/graphics/battle_anims/stat_change/decrease.bin similarity index 100% rename from graphics/battle_anims/masks/stat_tilemap_2.bin rename to graphics/battle_anims/stat_change/decrease.bin diff --git a/graphics/battle_anims/masks/stat1.pal b/graphics/battle_anims/stat_change/defense.pal similarity index 100% rename from graphics/battle_anims/masks/stat1.pal rename to graphics/battle_anims/stat_change/defense.pal diff --git a/graphics/battle_anims/masks/stat6.pal b/graphics/battle_anims/stat_change/evasion.pal similarity index 100% rename from graphics/battle_anims/masks/stat6.pal rename to graphics/battle_anims/stat_change/evasion.pal diff --git a/graphics/battle_anims/masks/stat_tilemap_1.bin b/graphics/battle_anims/stat_change/increase.bin similarity index 100% rename from graphics/battle_anims/masks/stat_tilemap_1.bin rename to graphics/battle_anims/stat_change/increase.bin diff --git a/graphics/battle_anims/masks/stat5.pal b/graphics/battle_anims/stat_change/multiple.pal similarity index 100% rename from graphics/battle_anims/masks/stat5.pal rename to graphics/battle_anims/stat_change/multiple.pal diff --git a/graphics/battle_anims/masks/stat7.pal b/graphics/battle_anims/stat_change/sp_attack.pal similarity index 100% rename from graphics/battle_anims/masks/stat7.pal rename to graphics/battle_anims/stat_change/sp_attack.pal diff --git a/graphics/battle_anims/masks/stat8.pal b/graphics/battle_anims/stat_change/sp_defense.pal similarity index 100% rename from graphics/battle_anims/masks/stat8.pal rename to graphics/battle_anims/stat_change/sp_defense.pal diff --git a/graphics/battle_anims/masks/stat4.pal b/graphics/battle_anims/stat_change/speed.pal similarity index 100% rename from graphics/battle_anims/masks/stat4.pal rename to graphics/battle_anims/stat_change/speed.pal diff --git a/graphics/battle_anims/masks/stat.png b/graphics/battle_anims/stat_change/tiles.png similarity index 100% rename from graphics/battle_anims/masks/stat.png rename to graphics/battle_anims/stat_change/tiles.png diff --git a/include/graphics.h b/include/graphics.h index 04ad64606d4a..b3d87e77e7eb 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -4769,17 +4769,18 @@ extern const u32 gMetalShineTilemap[]; extern const u32 gBattleAnimMaskImage_Curse[]; extern const u32 gBattleAnimMaskTilemap_Curse[]; -extern const u32 gBattleStatMask_Gfx[]; -extern const u32 gBattleStatMask1_Tilemap[]; -extern const u32 gBattleStatMask2_Tilemap[]; -extern const u32 gBattleStatMask1_Pal[]; -extern const u32 gBattleStatMask2_Pal[]; -extern const u32 gBattleStatMask3_Pal[]; -extern const u32 gBattleStatMask4_Pal[]; -extern const u32 gBattleStatMask5_Pal[]; -extern const u32 gBattleStatMask6_Pal[]; -extern const u32 gBattleStatMask7_Pal[]; -extern const u32 gBattleStatMask8_Pal[]; + +extern const u32 gStatAnim_Gfx[]; +extern const u32 gStatAnim_Increase_Tilemap[]; +extern const u32 gStatAnim_Decrease_Tilemap[]; +extern const u32 gStatAnim_Defense_Pal[]; +extern const u32 gStatAnim_Attack_Pal[]; +extern const u32 gStatAnim_Accuracy_Pal[]; +extern const u32 gStatAnim_Speed_Pal[]; +extern const u32 gStatAnim_Multiple_Pal[]; +extern const u32 gStatAnim_Evasion_Pal[]; +extern const u32 gStatAnim_SpAttack_Pal[]; +extern const u32 gStatAnim_SpDefense_Pal[]; extern const u32 gContestInterfaceGfx[]; extern const u32 gContestAudienceGfx[]; diff --git a/src/battle_anim_status_effects.c b/src/battle_anim_status_effects.c index e09a368509a1..b987ad33a358 100644 --- a/src/battle_anim_status_effects.c +++ b/src/battle_anim_status_effects.c @@ -532,8 +532,8 @@ void AnimTask_StatsChange(u8 taskId) gBattleAnimArgs[0] = goesDown; gBattleAnimArgs[1] = animStatId; - gBattleAnimArgs[2] = 0; - gBattleAnimArgs[3] = 0; + gBattleAnimArgs[2] = FALSE; // Whether it's the target, rather than attacker + gBattleAnimArgs[3] = FALSE; // Whether it hits multiple battlers gBattleAnimArgs[4] = sharply; gTasks[taskId].func = InitStatsChangeAnimation; gTasks[taskId].func(taskId); diff --git a/src/battle_anim_utility_funcs.c b/src/battle_anim_utility_funcs.c index 9375fda43067..ccbc7f902b58 100644 --- a/src/battle_anim_utility_funcs.c +++ b/src/battle_anim_utility_funcs.c @@ -16,7 +16,7 @@ struct AnimStatsChangeData { u8 battler1; u8 battler2; - u8 higherPriority; + bool8 hidBattler2; s16 data[8]; u16 species; }; @@ -388,6 +388,27 @@ static void AnimTask_DrawFallingWhiteLinesOnAttacker_Step(u8 taskId) } } +// Defines for data array in sAnimStatsChangeData +#define aDecrease data[0] +#define aAnimStatId data[1] +#define aIsTarget data[2] +#define aMultipleBattlers data[3] // Always false. Changes for multiple battlers are instead run sequentially. +#define aSharply data[4] + +// Task data defines for InitStatsChangeAnimation +#define tAnimSpriteId1 data[0] +#define tVelocity data[1] +#define tMultipleBattlers data[2] +#define tAnimSpriteId2 data[3] +#define tTargetBlend data[4] +#define tWaitTime data[5] +#define tHidBattler2 data[6] +#define tBattler2SpriteId data[7] +#define tWaitTimer data[10] +#define tFadeTimer data[11] +#define tBlend data[12] +#define tState data[15] + void InitStatsChangeAnimation(u8 taskId) { u8 i; @@ -401,21 +422,19 @@ void InitStatsChangeAnimation(u8 taskId) static void StatsChangeAnimation_Step1(u8 taskId) { - if (sAnimStatsChangeData->data[2] == 0) + if (!sAnimStatsChangeData->aIsTarget) sAnimStatsChangeData->battler1 = gBattleAnimAttacker; else sAnimStatsChangeData->battler1 = gBattleAnimTarget; sAnimStatsChangeData->battler2 = BATTLE_PARTNER(sAnimStatsChangeData->battler1); - if (IsContest() || (sAnimStatsChangeData->data[3] && !IsBattlerSpriteVisible(sAnimStatsChangeData->battler2))) - sAnimStatsChangeData->data[3] = 0; + if (IsContest() || (sAnimStatsChangeData->aMultipleBattlers && !IsBattlerSpriteVisible(sAnimStatsChangeData->battler2))) + sAnimStatsChangeData->aMultipleBattlers = FALSE; gBattle_WIN0H = 0; gBattle_WIN0V = 0; - SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR - | WININ_WIN1_BG_ALL | WININ_WIN1_OBJ | WININ_WIN1_CLR); - SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR - | WINOUT_WINOBJ_BG_ALL | WINOUT_WINOBJ_OBJ | WINOUT_WINOBJ_CLR); + SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_ALL | WININ_WIN1_ALL); + SetGpuReg(REG_OFFSET_WINOUT, (WINOUT_WIN01_ALL & ~WINOUT_WIN01_BG1) | WINOUT_WINOBJ_ALL); SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_OBJWIN_ON); SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG1 | BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND); SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0, 16)); @@ -424,16 +443,17 @@ static void StatsChangeAnimation_Step1(u8 taskId) if (!IsContest()) SetAnimBgAttribute(1, BG_ANIM_CHAR_BASE_BLOCK, 1); - if (IsDoubleBattle() && sAnimStatsChangeData->data[3] == 0) + if (IsDoubleBattle() && !sAnimStatsChangeData->aMultipleBattlers) { if (GetBattlerPosition(sAnimStatsChangeData->battler1) == B_POSITION_OPPONENT_RIGHT || GetBattlerPosition(sAnimStatsChangeData->battler1) == B_POSITION_PLAYER_LEFT) { if (IsBattlerSpriteVisible(sAnimStatsChangeData->battler2) == TRUE) { - gSprites[gBattlerSpriteIds[sAnimStatsChangeData->battler2]].oam.priority -= 1; + // Push the battler not being animated back so it doesn't receive the animation. + gSprites[gBattlerSpriteIds[sAnimStatsChangeData->battler2]].oam.priority--; SetAnimBgAttribute(1, BG_ANIM_PRIORITY, 1); - sAnimStatsChangeData->higherPriority = 1; + sAnimStatsChangeData->hidBattler2 = TRUE; } } } @@ -462,80 +482,80 @@ static void StatsChangeAnimation_Step2(u8 taskId) spriteId2 = 0; battlerSpriteId = gBattlerSpriteIds[sAnimStatsChangeData->battler1]; spriteId = CreateInvisibleSpriteCopy(sAnimStatsChangeData->battler1, battlerSpriteId, sAnimStatsChangeData->species); - if (sAnimStatsChangeData->data[3]) + if (sAnimStatsChangeData->aMultipleBattlers) { battlerSpriteId = gBattlerSpriteIds[sAnimStatsChangeData->battler2]; spriteId2 = CreateInvisibleSpriteCopy(sAnimStatsChangeData->battler2, battlerSpriteId, sAnimStatsChangeData->species); } GetBattleAnimBg1Data(&animBgData); - if (sAnimStatsChangeData->data[0] == 0) - AnimLoadCompressedBgTilemapHandleContest(&animBgData, gBattleStatMask1_Tilemap, FALSE); + if (!sAnimStatsChangeData->aDecrease) + AnimLoadCompressedBgTilemapHandleContest(&animBgData, gStatAnim_Increase_Tilemap, FALSE); else - AnimLoadCompressedBgTilemapHandleContest(&animBgData, gBattleStatMask2_Tilemap, FALSE); + AnimLoadCompressedBgTilemapHandleContest(&animBgData, gStatAnim_Decrease_Tilemap, FALSE); - AnimLoadCompressedBgGfx(animBgData.bgId, gBattleStatMask_Gfx, animBgData.tilesOffset); - switch (sAnimStatsChangeData->data[1]) + AnimLoadCompressedBgGfx(animBgData.bgId, gStatAnim_Gfx, animBgData.tilesOffset); + switch (sAnimStatsChangeData->aAnimStatId) { case STAT_ANIM_PAL_ATK: - LoadCompressedPalette(gBattleStatMask2_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP); + LoadCompressedPalette(gStatAnim_Attack_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP); break; case STAT_ANIM_PAL_DEF: - LoadCompressedPalette(gBattleStatMask1_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP); + LoadCompressedPalette(gStatAnim_Defense_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP); break; case STAT_ANIM_PAL_ACC: - LoadCompressedPalette(gBattleStatMask3_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP); + LoadCompressedPalette(gStatAnim_Accuracy_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP); break; case STAT_ANIM_PAL_SPEED: - LoadCompressedPalette(gBattleStatMask4_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP); + LoadCompressedPalette(gStatAnim_Speed_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP); break; case STAT_ANIM_PAL_EVASION: - LoadCompressedPalette(gBattleStatMask6_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP); + LoadCompressedPalette(gStatAnim_Evasion_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP); break; case STAT_ANIM_PAL_SPATK: - LoadCompressedPalette(gBattleStatMask7_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP); + LoadCompressedPalette(gStatAnim_SpAttack_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP); break; case STAT_ANIM_PAL_SPDEF: - LoadCompressedPalette(gBattleStatMask8_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP); + LoadCompressedPalette(gStatAnim_SpDefense_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP); break; default: // case STAT_ANIM_PAL_MULTIPLE: - LoadCompressedPalette(gBattleStatMask5_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP); + LoadCompressedPalette(gStatAnim_Multiple_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP); break; } gBattle_BG1_X = 0; gBattle_BG1_Y = 0; - if (sAnimStatsChangeData->data[0] == 1) + if (sAnimStatsChangeData->aDecrease == TRUE) { gBattle_BG1_X = 64; - gTasks[taskId].data[1] = -3; + gTasks[taskId].tVelocity = -3; } else { - gTasks[taskId].data[1] = 3; + gTasks[taskId].tVelocity = 3; } - if (sAnimStatsChangeData->data[4] == 0) + if (!sAnimStatsChangeData->aSharply) { - gTasks[taskId].data[4] = 10; - gTasks[taskId].data[5] = 20; + gTasks[taskId].tTargetBlend = 10; + gTasks[taskId].tWaitTime = 20; } else { - gTasks[taskId].data[4] = 13; - gTasks[taskId].data[5] = 30; + gTasks[taskId].tTargetBlend = 13; + gTasks[taskId].tWaitTime = 30; } - gTasks[taskId].data[0] = spriteId; - gTasks[taskId].data[2] = sAnimStatsChangeData->data[3]; - gTasks[taskId].data[3] = spriteId2; - gTasks[taskId].data[6] = sAnimStatsChangeData->higherPriority; - gTasks[taskId].data[7] = gBattlerSpriteIds[sAnimStatsChangeData->battler2]; + gTasks[taskId].tAnimSpriteId1 = spriteId; + gTasks[taskId].tMultipleBattlers = sAnimStatsChangeData->aMultipleBattlers; + gTasks[taskId].tAnimSpriteId2 = spriteId2; + gTasks[taskId].tHidBattler2 = sAnimStatsChangeData->hidBattler2; + gTasks[taskId].tBattler2SpriteId = gBattlerSpriteIds[sAnimStatsChangeData->battler2]; gTasks[taskId].func = StatsChangeAnimation_Step3; - if (sAnimStatsChangeData->data[0] == 0) + if (!sAnimStatsChangeData->aDecrease) PlaySE12WithPanning(SE_M_STAT_INCREASE, BattleAnimAdjustPanning2(SOUND_PAN_ATTACKER)); else PlaySE12WithPanning(SE_M_STAT_DECREASE, BattleAnimAdjustPanning2(SOUND_PAN_ATTACKER)); @@ -543,44 +563,46 @@ static void StatsChangeAnimation_Step2(u8 taskId) static void StatsChangeAnimation_Step3(u8 taskId) { - gBattle_BG1_Y += gTasks[taskId].data[1]; + gBattle_BG1_Y += gTasks[taskId].tVelocity; - switch (gTasks[taskId].data[15]) + switch (gTasks[taskId].tState) { case 0: - if (gTasks[taskId].data[11]++ > 0) + // Fade in + if (gTasks[taskId].tFadeTimer++ > 0) { - gTasks[taskId].data[11] = 0; - gTasks[taskId].data[12]++; - SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(gTasks[taskId].data[12], 16 - gTasks[taskId].data[12])); - if (gTasks[taskId].data[12] == gTasks[taskId].data[4]) - gTasks[taskId].data[15]++; + gTasks[taskId].tFadeTimer = 0; + gTasks[taskId].tBlend++; + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(gTasks[taskId].tBlend, 16 - gTasks[taskId].tBlend)); + if (gTasks[taskId].tBlend == gTasks[taskId].tTargetBlend) + gTasks[taskId].tState++; } break; case 1: - if (++gTasks[taskId].data[10] == gTasks[taskId].data[5]) - gTasks[taskId].data[15]++; + // Wait + if (++gTasks[taskId].tWaitTimer == gTasks[taskId].tWaitTime) + gTasks[taskId].tState++; break; case 2: - if (gTasks[taskId].data[11]++ > 0) + // Fade out + if (gTasks[taskId].tFadeTimer++ > 0) { - gTasks[taskId].data[11] = 0; - gTasks[taskId].data[12]--; - SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(gTasks[taskId].data[12], 16 - gTasks[taskId].data[12])); - if (gTasks[taskId].data[12] == 0) + gTasks[taskId].tFadeTimer = 0; + gTasks[taskId].tBlend--; + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(gTasks[taskId].tBlend, 16 - gTasks[taskId].tBlend)); + if (gTasks[taskId].tBlend == 0) { ResetBattleAnimBg(FALSE); - gTasks[taskId].data[15]++; + gTasks[taskId].tState++; } } break; case 3: + // Reset gBattle_WIN0H = 0; gBattle_WIN0V = 0; - SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR - | WININ_WIN1_BG_ALL | WININ_WIN1_OBJ | WININ_WIN1_CLR); - SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG_ALL | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR - | WINOUT_WINOBJ_BG_ALL | WINOUT_WINOBJ_OBJ | WINOUT_WINOBJ_CLR); + SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_ALL | WININ_WIN1_ALL); + SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_ALL | WINOUT_WINOBJ_ALL); if (!IsContest()) SetAnimBgAttribute(1, BG_ANIM_CHAR_BASE_BLOCK, 0); @@ -588,12 +610,14 @@ static void StatsChangeAnimation_Step3(u8 taskId) SetGpuReg(REG_OFFSET_DISPCNT, GetGpuReg(REG_OFFSET_DISPCNT) ^ DISPCNT_OBJWIN_ON); SetGpuReg(REG_OFFSET_BLDCNT, 0); SetGpuReg(REG_OFFSET_BLDALPHA, 0); - DestroySprite(&gSprites[gTasks[taskId].data[0]]); - if (gTasks[taskId].data[2]) - DestroySprite(&gSprites[gTasks[taskId].data[3]]); - if (gTasks[taskId].data[6] == 1) - gSprites[gTasks[taskId].data[7]].oam.priority++; + DestroySprite(&gSprites[gTasks[taskId].tAnimSpriteId1]); + if (gTasks[taskId].tMultipleBattlers) + DestroySprite(&gSprites[gTasks[taskId].tAnimSpriteId2]); + + // Restore battler 2's priority + if (gTasks[taskId].tHidBattler2 == TRUE) + gSprites[gTasks[taskId].tBattler2SpriteId].oam.priority++; FREE_AND_SET_NULL(sAnimStatsChangeData); DestroyAnimVisualTask(taskId); @@ -601,6 +625,24 @@ static void StatsChangeAnimation_Step3(u8 taskId) } } +#undef aDecrease +#undef aAnimStatId +#undef aIsTarget +#undef aMultipleBattlers +#undef aSharply +#undef tAnimSpriteId1 +#undef tVelocity +#undef tMultipleBattlers +#undef tAnimSpriteId2 +#undef tTargetBlend +#undef tWaitTime +#undef tHidBattler2 +#undef tBattler2SpriteId +#undef tWaitTimer +#undef tFadeTimer +#undef tBlend +#undef tState + void AnimTask_Flash(u8 taskId) { u32 selectedPalettes = GetBattleMonSpritePalettesMask(1, 1, 1, 1); diff --git a/src/graphics.c b/src/graphics.c index 3cfd47ea76a0..976e52f48e21 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -865,18 +865,17 @@ const u32 gBattleAnimSpritePal_PinkCloud[] = INCBIN_U32("graphics/battle_anims/s const u32 gBattleAnimSpriteGfx_SweatDrop[] = INCBIN_U32("graphics/battle_anims/sprites/sweat_drop.4bpp.lz"); const u32 gBattleAnimSpritePal_SweatDrop[] = INCBIN_U32("graphics/battle_anims/sprites/sweat_drop.gbapal.lz"); -const u32 gBattleStatMask_Gfx[] = INCBIN_U32("graphics/battle_anims/masks/stat.4bpp.lz"); -const u32 gBattleStatMask1_Tilemap[] = INCBIN_U32("graphics/battle_anims/masks/stat_tilemap_1.bin.lz"); -const u32 gBattleStatMask2_Tilemap[] = INCBIN_U32("graphics/battle_anims/masks/stat_tilemap_2.bin.lz"); - -const u32 gBattleStatMask1_Pal[] = INCBIN_U32("graphics/battle_anims/masks/stat1.gbapal.lz"); -const u32 gBattleStatMask2_Pal[] = INCBIN_U32("graphics/battle_anims/masks/stat2.gbapal.lz"); -const u32 gBattleStatMask3_Pal[] = INCBIN_U32("graphics/battle_anims/masks/stat3.gbapal.lz"); -const u32 gBattleStatMask4_Pal[] = INCBIN_U32("graphics/battle_anims/masks/stat4.gbapal.lz"); -const u32 gBattleStatMask5_Pal[] = INCBIN_U32("graphics/battle_anims/masks/stat5.gbapal.lz"); -const u32 gBattleStatMask6_Pal[] = INCBIN_U32("graphics/battle_anims/masks/stat6.gbapal.lz"); -const u32 gBattleStatMask7_Pal[] = INCBIN_U32("graphics/battle_anims/masks/stat7.gbapal.lz"); -const u32 gBattleStatMask8_Pal[] = INCBIN_U32("graphics/battle_anims/masks/stat8.gbapal.lz"); +const u32 gStatAnim_Gfx[] = INCBIN_U32("graphics/battle_anims/stat_change/tiles.4bpp.lz"); +const u32 gStatAnim_Increase_Tilemap[] = INCBIN_U32("graphics/battle_anims/stat_change/increase.bin.lz"); +const u32 gStatAnim_Decrease_Tilemap[] = INCBIN_U32("graphics/battle_anims/stat_change/decrease.bin.lz"); +const u32 gStatAnim_Defense_Pal[] = INCBIN_U32("graphics/battle_anims/stat_change/defense.gbapal.lz"); +const u32 gStatAnim_Attack_Pal[] = INCBIN_U32("graphics/battle_anims/stat_change/attack.gbapal.lz"); +const u32 gStatAnim_Accuracy_Pal[] = INCBIN_U32("graphics/battle_anims/stat_change/accuracy.gbapal.lz"); +const u32 gStatAnim_Speed_Pal[] = INCBIN_U32("graphics/battle_anims/stat_change/speed.gbapal.lz"); +const u32 gStatAnim_Multiple_Pal[] = INCBIN_U32("graphics/battle_anims/stat_change/multiple.gbapal.lz"); +const u32 gStatAnim_Evasion_Pal[] = INCBIN_U32("graphics/battle_anims/stat_change/evasion.gbapal.lz"); +const u32 gStatAnim_SpAttack_Pal[] = INCBIN_U32("graphics/battle_anims/stat_change/sp_attack.gbapal.lz"); +const u32 gStatAnim_SpDefense_Pal[] = INCBIN_U32("graphics/battle_anims/stat_change/sp_defense.gbapal.lz"); const u32 gCureBubblesGfx[] = INCBIN_U32("graphics/battle_anims/masks/cure_bubbles.4bpp.lz"); const u32 gCureBubblesPal[] = INCBIN_U32("graphics/battle_anims/masks/cure_bubbles.gbapal.lz"); From 18319e8da3a2fec83bd2ff5112bd8a924da86a3e Mon Sep 17 00:00:00 2001 From: GriffinR Date: Thu, 10 Aug 2023 01:21:38 -0400 Subject: [PATCH 03/48] Misc missing constant use --- include/constants/contest.h | 2 + src/battle_ai_script_commands.c | 16 +-- src/battle_ai_switch_items.c | 8 +- src/battle_script_commands.c | 9 ++ src/battle_util.c | 6 +- src/berry_tag_screen.c | 88 +++++++------ src/cable_club.c | 2 +- src/contest.c | 22 ++-- src/contest_ai.c | 10 +- src/contest_effect.c | 28 ++--- src/contest_util.c | 10 +- src/data/contest_opponents.h | 211 ++++++++++++++++---------------- src/decoration.c | 11 +- src/dewford_trend.c | 2 +- src/ereader_helpers.c | 4 +- src/field_specials.c | 19 ++- src/librfu_rfu.c | 10 +- src/link_rfu_2.c | 3 +- src/main_menu.c | 3 +- src/palette.c | 2 +- src/region_map.c | 2 +- src/secret_base.c | 4 +- 22 files changed, 254 insertions(+), 218 deletions(-) diff --git a/include/constants/contest.h b/include/constants/contest.h index 775dcbe62b91..905306203af1 100644 --- a/include/constants/contest.h +++ b/include/constants/contest.h @@ -6,6 +6,8 @@ #define CONTEST_LAST_APPEAL (CONTEST_NUM_APPEALS - 1) #define MAX_CONTEST_MOVE_HEARTS 8 +#define CONTESTANT_NONE 0xFF + #define LINK_CONTEST_FLAG_IS_LINK (1 << 0) #define LINK_CONTEST_FLAG_IS_WIRELESS (1 << 1) #define LINK_CONTEST_FLAG_HAS_RS_PLAYER (1 << 2) diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c index 2152be374ae5..b2c900b422a5 100644 --- a/src/battle_ai_script_commands.c +++ b/src/battle_ai_script_commands.c @@ -13,16 +13,13 @@ #include "constants/abilities.h" #include "constants/battle_ai.h" #include "constants/battle_move_effects.h" +#include "constants/items.h" #include "constants/moves.h" -#define AI_ACTION_DONE 0x0001 -#define AI_ACTION_FLEE 0x0002 -#define AI_ACTION_WATCH 0x0004 -#define AI_ACTION_DO_NOT_ATTACK 0x0008 -#define AI_ACTION_UNK5 0x0010 -#define AI_ACTION_UNK6 0x0020 -#define AI_ACTION_UNK7 0x0040 -#define AI_ACTION_UNK8 0x0080 +#define AI_ACTION_DONE (1 << 0) +#define AI_ACTION_FLEE (1 << 1) +#define AI_ACTION_WATCH (1 << 2) +#define AI_ACTION_DO_NOT_ATTACK (1 << 3) #define AI_THINKING_STRUCT ((struct AI_ThinkingStruct *)(gBattleResources->ai)) #define BATTLE_HISTORY ((struct BattleHistory *)(gBattleResources->battleHistory)) @@ -283,7 +280,6 @@ static const u16 sIgnoredPowerfulMoveEffects[] = IGNORED_MOVES_END }; -// code void BattleAI_HandleItemUseBeforeAISetup(u8 defaultScoreMoves) { s32 i; @@ -302,7 +298,7 @@ void BattleAI_HandleItemUseBeforeAISetup(u8 defaultScoreMoves) { for (i = 0; i < MAX_TRAINER_ITEMS; i++) { - if (gTrainers[gTrainerBattleOpponent_A].items[i] != 0) + if (gTrainers[gTrainerBattleOpponent_A].items[i] != ITEM_NONE) { BATTLE_HISTORY->trainerItems[BATTLE_HISTORY->itemsNo] = gTrainers[gTrainerBattleOpponent_A].items[i]; BATTLE_HISTORY->itemsNo++; diff --git a/src/battle_ai_switch_items.c b/src/battle_ai_switch_items.c index 5789a3ff6f32..06cdd6c82fff 100644 --- a/src/battle_ai_switch_items.c +++ b/src/battle_ai_switch_items.c @@ -687,7 +687,7 @@ u8 GetMostSuitableMonToSwitchInto(void) invalidMons = 0; - while (invalidMons != 0x3F) // All mons are invalid. + while (invalidMons != (1 << PARTY_SIZE) - 1) // All mons are invalid. { bestDmg = TYPE_MUL_NO_EFFECT; bestMonId = PARTY_SIZE; @@ -741,7 +741,7 @@ u8 GetMostSuitableMonToSwitchInto(void) } else { - invalidMons = 0x3F; // No viable mon to switch. + invalidMons = (1 << PARTY_SIZE) - 1; // No viable mon to switch. } } @@ -862,7 +862,7 @@ static bool8 ShouldUseItem(void) shouldUse = TRUE; break; case AI_ITEM_HEAL_HP: - paramOffset = GetItemEffectParamOffset(item, 4, 4); + paramOffset = GetItemEffectParamOffset(item, 4, ITEM4_HEAL_HP); if (paramOffset == 0) break; if (gBattleMons[gActiveBattler].hp == 0) @@ -935,7 +935,7 @@ static bool8 ShouldUseItem(void) { BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_USE_ITEM, 0); *(gBattleStruct->chosenItem + (gActiveBattler / 2) * 2) = item; - gBattleResources->battleHistory->trainerItems[i] = 0; + gBattleResources->battleHistory->trainerItems[i] = ITEM_NONE; return shouldUse; } } diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index bf9197a0e8f2..0161103045c3 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -7812,9 +7812,18 @@ static void Cmd_metronome(void) { s32 i; + #if MOVES_COUNT < 512 + // Original GF method of move selection is to pick a random + // number between 1-511. 355-511 are not valid moves, so if it + // picks in this range it retries. If MOVES_COUNT exceeds 511 we + // instead use a simpler solution. gCurrentMove = (Random() & 0x1FF) + 1; if (gCurrentMove >= MOVES_COUNT) continue; + #else + // Just pick a valid move value (between 1 and MOVES_COUNT-1) + gCurrentMove = (Random() % (MOVES_COUNT - 1)) + 1; + #endif for (i = 0; i < MAX_MON_MOVES; i++); // ? diff --git a/src/battle_util.c b/src/battle_util.c index 68a5b6adaae9..51fbaa3cfb34 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -342,7 +342,11 @@ void HandleAction_UseItem(void) gBattleCommunication[MULTISTRING_CHOOSER] = AI_HEAL_CONFUSION; if (*(gBattleStruct->AI_itemFlags + gBattlerAttacker / 2) & (1 << AI_HEAL_CONFUSION)) { - if (*(gBattleStruct->AI_itemFlags + gBattlerAttacker / 2) & 0x3E) + if (*(gBattleStruct->AI_itemFlags + gBattlerAttacker / 2) & ((1 << AI_HEAL_PARALYSIS) + | (1 << AI_HEAL_FREEZE) + | (1 << AI_HEAL_BURN) + | (1 << AI_HEAL_POISON) + | (1 << AI_HEAL_SLEEP))) gBattleCommunication[MULTISTRING_CHOOSER] = AI_HEAL_SLEEP; } else diff --git a/src/berry_tag_screen.c b/src/berry_tag_screen.c index 448ee3384875..415f22e59eb9 100644 --- a/src/berry_tag_screen.c +++ b/src/berry_tag_screen.c @@ -310,6 +310,8 @@ static void HandleInitBackgrounds(void) ShowBg(3); } +#define BG_TILE 0x42 + static bool8 LoadBerryTagGfx(void) { u16 i; @@ -333,15 +335,16 @@ static bool8 LoadBerryTagGfx(void) sBerryTag->gfxState++; break; case 3: + // Palette of the bg tiles changes depending on the player's gender if (gSaveBlock2Ptr->playerGender == MALE) { for (i = 0; i < ARRAY_COUNT(sBerryTag->tilemapBuffers[1]); i++) - sBerryTag->tilemapBuffers[1][i] = 0x4042; + sBerryTag->tilemapBuffers[1][i] = (4 << 12) | BG_TILE; } else { for (i = 0; i < ARRAY_COUNT(sBerryTag->tilemapBuffers[1]); i++) - sBerryTag->tilemapBuffers[1][i] = 0x5042; + sBerryTag->tilemapBuffers[1][i] = (5 << 12) | BG_TILE; } sBerryTag->gfxState++; break; @@ -545,6 +548,9 @@ static void Task_HandleInput(u8 taskId) } } +#define tBerryY data[0] +#define tBgOp data[1] + static void TryChangeDisplayedBerry(u8 taskId, s8 toMove) { s16 *data = gTasks[taskId].data; @@ -553,11 +559,11 @@ static void TryChangeDisplayedBerry(u8 taskId, s8 toMove) if (newPocketPosition < ITEM_TO_BERRY(MAX_BERRY_INDEX) && BagGetItemIdByPocketPosition(POCKET_BERRIES, newPocketPosition) != ITEM_NONE) { if (toMove < 0) - data[1] = 2; + tBgOp = BG_COORD_SUB; else - data[1] = 1; + tBgOp = BG_COORD_ADD; - data[0] = 0; + tBerryY = 0; PlaySE(SE_SELECT); HandleBagCursorPositionChange(toMove); gTasks[taskId].func = Task_DisplayAnotherBerry; @@ -586,101 +592,103 @@ static void HandleBagCursorPositionChange(s8 toMove) sBerryTag->berryId = ItemIdToBerryType(BagGetItemIdByPocketPosition(POCKET_BERRIES, *scrollPos + *cursorPos)); } +#define DISPLAY_SPEED 16 + static void Task_DisplayAnotherBerry(u8 taskId) { u16 i; - s16 posY; + s16 y; s16 *data = gTasks[taskId].data; - data[0] += 0x10; - data[0] &= 0xFF; + tBerryY += DISPLAY_SPEED; + tBerryY &= 0xFF; - if (data[1] == 1) + if (tBgOp == BG_COORD_ADD) { - switch (data[0]) + switch (tBerryY) { - case 0x30: + case 3 * DISPLAY_SPEED: FillWindowPixelBuffer(WIN_BERRY_NAME, PIXEL_FILL(0)); break; - case 0x40: + case 4 * DISPLAY_SPEED: PrintBerryNumberAndName(); break; - case 0x50: + case 5 * DISPLAY_SPEED: DestroyBerrySprite(); CreateBerrySprite(); break; - case 0x60: + case 6 * DISPLAY_SPEED: FillWindowPixelBuffer(WIN_SIZE_FIRM, PIXEL_FILL(0)); break; - case 0x70: + case 7 * DISPLAY_SPEED: PrintBerrySize(); break; - case 0x80: + case 8 * DISPLAY_SPEED: PrintBerryFirmness(); break; - case 0x90: + case 9 * DISPLAY_SPEED: SetFlavorCirclesVisiblity(); break; - case 0xA0: + case 10 * DISPLAY_SPEED: FillWindowPixelBuffer(WIN_DESC, PIXEL_FILL(0)); break; - case 0xB0: + case 11 * DISPLAY_SPEED: PrintBerryDescription1(); break; - case 0xC0: + case 12 * DISPLAY_SPEED: PrintBerryDescription2(); break; } } - else + else // BG_COORD_SUB { - switch (data[0]) + switch (tBerryY) { - case 0x30: + case 3 * DISPLAY_SPEED: FillWindowPixelBuffer(WIN_DESC, PIXEL_FILL(0)); break; - case 0x40: + case 4 * DISPLAY_SPEED: PrintBerryDescription2(); break; - case 0x50: + case 5 * DISPLAY_SPEED: PrintBerryDescription1(); break; - case 0x60: + case 6 * DISPLAY_SPEED: SetFlavorCirclesVisiblity(); break; - case 0x70: + case 7 * DISPLAY_SPEED: FillWindowPixelBuffer(WIN_SIZE_FIRM, PIXEL_FILL(0)); break; - case 0x80: + case 8 * DISPLAY_SPEED: PrintBerryFirmness(); break; - case 0x90: + case 9 * DISPLAY_SPEED: PrintBerrySize(); break; - case 0xA0: + case 10 * DISPLAY_SPEED: DestroyBerrySprite(); CreateBerrySprite(); break; - case 0xB0: + case 11 * DISPLAY_SPEED: FillWindowPixelBuffer(WIN_BERRY_NAME, PIXEL_FILL(0)); break; - case 0xC0: + case 12 * DISPLAY_SPEED: PrintBerryNumberAndName(); break; } } - if (data[1] == 1) - posY = -data[0]; + if (tBgOp == BG_COORD_ADD) + y = -tBerryY; else - posY = data[0]; + y = tBerryY; - gSprites[sBerryTag->berrySpriteId].y2 = posY; + gSprites[sBerryTag->berrySpriteId].y2 = y; for (i = 0; i < FLAVOR_COUNT; i++) - gSprites[sBerryTag->flavorCircleIds[i]].y2 = posY; + gSprites[sBerryTag->flavorCircleIds[i]].y2 = y; - ChangeBgY(1, 0x1000, data[1]); - ChangeBgY(2, 0x1000, data[1]); + ChangeBgY(1, 0x1000, tBgOp); + ChangeBgY(2, 0x1000, tBgOp); - if (data[0] == 0) + if (tBerryY == 0) gTasks[taskId].func = Task_HandleInput; } diff --git a/src/cable_club.c b/src/cable_club.c index 913a1b72872d..b12a50920f31 100644 --- a/src/cable_club.c +++ b/src/cable_club.c @@ -725,7 +725,7 @@ void TryContestEModeLinkup(void) u8 CreateTask_ReestablishCableClubLink(void) { if (FuncIsActiveTask(Task_ReestablishLink) != FALSE) - return 0xFF; + return TASK_NONE; switch (gSpecialVar_0x8004) { diff --git a/src/contest.c b/src/contest.c index 741a0e12db9d..3449d25f639b 100644 --- a/src/contest.c +++ b/src/contest.c @@ -1112,10 +1112,10 @@ static void InitContestResources(void) for (i = 0; i < CONTESTANT_COUNT; i++) { - eContestantStatus[i].nextTurnOrder = 0xFF; + eContestantStatus[i].nextTurnOrder = CONTESTANT_NONE; eContest.prevTurnOrder[i] = gContestantTurnOrder[i]; } - // Calling this here while all the nextTurnOrder values are 0xFF will actually + // Calling this here while all the nextTurnOrder values are CONTESTANT_NONE will actually // just reverse the turn order. ApplyNextTurnOrder(); memset(gContestResources->tv, 0, sizeof(*gContestResources->tv) * CONTESTANT_COUNT); @@ -2891,7 +2891,7 @@ void SetContestants(u8 contestType, u8 rank) opponents[opponentsCount++] = i; } } - opponents[opponentsCount] = 0xFF; + opponents[opponentsCount] = CONTESTANT_NONE; // Choose three random opponents from the list for (i = 0; i < CONTESTANT_COUNT - 1; i++) @@ -2900,7 +2900,7 @@ void SetContestants(u8 contestType, u8 rank) s32 j; gContestMons[i] = gContestOpponents[opponents[rnd]]; - for (j = rnd; opponents[j] != 0xFF; j++) + for (j = rnd; opponents[j] != CONTESTANT_NONE; j++) opponents[j] = opponents[j + 1]; opponentsCount--; } @@ -2940,7 +2940,7 @@ void SetLinkAIContestants(u8 contestType, u8 rank, bool32 isPostgame) || (contestType == CONTEST_CATEGORY_TOUGH && gContestOpponents[i].aiPool_Tough)) opponents[opponentsCount++] = i; } - opponents[opponentsCount] = 0xFF; + opponents[opponentsCount] = CONTESTANT_NONE; // Fill remaining contestant slots with random AI opponents from the list for (i = 0; i < CONTESTANT_COUNT - gNumLinkContestPlayers; i++) @@ -2950,7 +2950,7 @@ void SetLinkAIContestants(u8 contestType, u8 rank, bool32 isPostgame) gContestMons[gNumLinkContestPlayers + i] = gContestOpponents[opponents[rnd]]; StripPlayerNameForLinkContest(gContestMons[gNumLinkContestPlayers + i].trainerName); StripMonNameForLinkContest(gContestMons[gNumLinkContestPlayers + i].nickname, GAME_LANGUAGE); - for (j = rnd; opponents[j] != 0xFF; j++) + for (j = rnd; opponents[j] != CONTESTANT_NONE; j++) opponents[j] = opponents[j + 1]; opponentsCount--; } @@ -4370,7 +4370,7 @@ void SortContestants(bool8 useRanking) // Note that ranking is calculated so that shared places still take up a ranking // space. A ranking like [1, 2, 2, 3] is not possible; it would be [1, 2, 2, 4] // instead. - memset(scratch, 0xFF, sizeof(scratch)); + memset(scratch, CONTESTANT_NONE, sizeof(scratch)); for (i = 0; i < CONTESTANT_COUNT; i++) { u8 j = eContestantStatus[i].ranking; @@ -4378,7 +4378,7 @@ void SortContestants(bool8 useRanking) while (1) { u8 *ptr = &scratch[j]; - if (*ptr == 0xFF) + if (*ptr == CONTESTANT_NONE) { *ptr = i; gContestantTurnOrder[i] = j; @@ -4636,7 +4636,7 @@ static void ApplyNextTurnOrder(void) // First, look for the first unassigned contestant. for (j = 0; j < CONTESTANT_COUNT; j++) { - if (!isContestantOrdered[j] && eContestantStatus[j].nextTurnOrder == 0xFF) + if (!isContestantOrdered[j] && eContestantStatus[j].nextTurnOrder == CONTESTANT_NONE) { nextContestant = j; j++; @@ -4647,7 +4647,7 @@ static void ApplyNextTurnOrder(void) // Then, look for a better candidate, with a higher turn order. for (; j < CONTESTANT_COUNT; j++) { - if (!isContestantOrdered[j] && eContestantStatus[j].nextTurnOrder == 0xFF + if (!isContestantOrdered[j] && eContestantStatus[j].nextTurnOrder == CONTESTANT_NONE && gContestantTurnOrder[nextContestant] > gContestantTurnOrder[j]) nextContestant = j; } @@ -4661,7 +4661,7 @@ static void ApplyNextTurnOrder(void) for (i = 0; i < CONTESTANT_COUNT; i++) { eContestAppealResults.turnOrder[i] = newTurnOrder[i]; - eContestantStatus[i].nextTurnOrder = 0xFF; + eContestantStatus[i].nextTurnOrder = CONTESTANT_NONE; eContestantStatus[i].turnOrderMod = 0; gContestantTurnOrder[i] = newTurnOrder[i]; } diff --git a/src/contest_ai.c b/src/contest_ai.c index 7aeba828a62f..8753ed170dca 100644 --- a/src/contest_ai.c +++ b/src/contest_ai.c @@ -6,6 +6,8 @@ #include "contest_effect.h" #include "constants/moves.h" +#define AI_ACTION_DONE (1 << 0) + extern const u8 *gAIScriptPtr; extern const u8 *gContestAI_ScriptsTable[]; @@ -362,9 +364,9 @@ static void ContestAI_DoAIProcessing(void) else { eContestAI.moveScores[eContestAI.nextMoveIndex] = 0; // don't consider a move that doesn't exist. - eContestAI.aiAction |= 1; + eContestAI.aiAction |= AI_ACTION_DONE; } - if (eContestAI.aiAction & 1) + if (eContestAI.aiAction & AI_ACTION_DONE) { eContestAI.nextMoveIndex++; if (eContestAI.nextMoveIndex < MAX_MON_MOVES) @@ -372,7 +374,7 @@ static void ContestAI_DoAIProcessing(void) else // aiState = CONTESTAI_FINISHED eContestAI.aiState++; - eContestAI.aiAction &= 0xFE; // TODO: Define action flags + eContestAI.aiAction &= ~AI_ACTION_DONE; } break; } @@ -1667,7 +1669,7 @@ static void ContestAICmd_call(void) static void ContestAICmd_end(void) { if (!AIStackPop()) - eContestAI.aiAction |= 1; + eContestAI.aiAction |= AI_ACTION_DONE; } static void AIStackPushVar(const u8 *ptr) diff --git a/src/contest_effect.c b/src/contest_effect.c index 864805a54f85..b927943036c8 100644 --- a/src/contest_effect.c +++ b/src/contest_effect.c @@ -147,7 +147,7 @@ static void ContestEffect_StartleFrontMon(void) break; } eContestAppealResults.jamQueue[0] = i; - eContestAppealResults.jamQueue[1] = 0xFF; + eContestAppealResults.jamQueue[1] = CONTESTANT_NONE; idx = WasAtLeastOneOpponentJammed(); } if (idx == 0) @@ -171,7 +171,7 @@ static void ContestEffect_StartlePrevMons(void) eContestAppealResults.jamQueue[j++] = i; } - eContestAppealResults.jamQueue[j] = 0xFF; + eContestAppealResults.jamQueue[j] = CONTESTANT_NONE; idx = WasAtLeastOneOpponentJammed(); } if (idx == 0) @@ -214,7 +214,7 @@ static void ContestEffect_StartlePrevMons2(void) u8 rval, jam; eContestAppealResults.jamQueue[0] = i; - eContestAppealResults.jamQueue[1] = 0xFF; + eContestAppealResults.jamQueue[1] = CONTESTANT_NONE; rval = Random() % 10; if (rval == 0) @@ -291,7 +291,7 @@ static void ContestEffect_StartleMonWithJudgesAttention(void) else eContestAppealResults.jam = 10; eContestAppealResults.jamQueue[0] = i; - eContestAppealResults.jamQueue[1] = 0xFF; + eContestAppealResults.jamQueue[1] = CONTESTANT_NONE; if (WasAtLeastOneOpponentJammed()) numStartled++; } @@ -396,7 +396,7 @@ static void ContestEffect_MakeFollowingMonsNervous(void) s16 oddsMod[CONTESTANT_COUNT]; s16 odds[CONTESTANT_COUNT]; - memset(contestantIds, 0xFF, ARRAY_COUNT(contestantIds)); + memset(contestantIds, CONTESTANT_NONE, ARRAY_COUNT(contestantIds)); for (i = 0, numAfter = 0; i < CONTESTANT_COUNT; i++) { if (eContestAppealResults.turnOrder[eContestAppealResults.contestant] < eContestAppealResults.turnOrder[i] && @@ -434,7 +434,7 @@ static void ContestEffect_MakeFollowingMonsNervous(void) } if (odds[0] != 0) { - for (i = 0; contestantIds[i] != 0xFF; i++) + for (i = 0; contestantIds[i] != CONTESTANT_NONE; i++) { if (Random() % 100 < odds[i] + oddsMod[contestantIds[i]]) { @@ -507,7 +507,7 @@ static void ContestEffect_BadlyStartlesMonsInGoodCondition(void) else eContestAppealResults.jam = 10; eContestAppealResults.jamQueue[0] = i; - eContestAppealResults.jamQueue[1] = 0xFF; + eContestAppealResults.jamQueue[1] = CONTESTANT_NONE; if (WasAtLeastOneOpponentJammed()) numHit++; } @@ -758,7 +758,7 @@ static void ContestEffect_NextAppealEarlier(void) for (i = 0; i < CONTESTANT_COUNT; i++) turnOrder[i] = eContestantStatus[i].nextTurnOrder; - turnOrder[eContestAppealResults.contestant] = 0xFF; + turnOrder[eContestAppealResults.contestant] = CONTESTANT_NONE; for (i = 0; i < CONTESTANT_COUNT; i++) { @@ -800,7 +800,7 @@ static void ContestEffect_NextAppealLater(void) for (i = 0; i < CONTESTANT_COUNT; i++) turnOrder[i] = eContestantStatus[i].nextTurnOrder; - turnOrder[eContestAppealResults.contestant] = 0xFF; + turnOrder[eContestAppealResults.contestant] = CONTESTANT_NONE; for (i = CONTESTANT_COUNT - 1; i > -1; i--) { @@ -858,12 +858,12 @@ static void ContestEffect_ScrambleNextTurnOrder(void) for (j = 0; j < CONTESTANT_COUNT; j++) { - if (unselectedContestants[j] != 0xFF) + if (unselectedContestants[j] != CONTESTANT_NONE) { if (rval == 0) { turnOrder[j] = i; - unselectedContestants[j] = 0xFF; + unselectedContestants[j] = CONTESTANT_NONE; break; } else @@ -909,7 +909,7 @@ static void ContestEffect_BadlyStartleMonsWithGoodAppeals(void) else eContestAppealResults.jam = 10; eContestAppealResults.jamQueue[0] = i; - eContestAppealResults.jamQueue[1] = 0xFF; + eContestAppealResults.jamQueue[1] = CONTESTANT_NONE; if (WasAtLeastOneOpponentJammed()) numJammed++; } @@ -977,7 +977,7 @@ static void JamByMoveCategory(u8 category) else eContestAppealResults.jam = 10; eContestAppealResults.jamQueue[0] = i; - eContestAppealResults.jamQueue[1] = 0xFF; + eContestAppealResults.jamQueue[1] = CONTESTANT_NONE; if (WasAtLeastOneOpponentJammed()) numJammed++; } @@ -1016,7 +1016,7 @@ static bool8 WasAtLeastOneOpponentJammed(void) s16 jamBuffer[CONTESTANT_COUNT] = {0}; int i; - for (i = 0; eContestAppealResults.jamQueue[i] != 0xFF; i++) + for (i = 0; eContestAppealResults.jamQueue[i] != CONTESTANT_NONE; i++) { u8 contestant = eContestAppealResults.jamQueue[i]; if (CanUnnerveContestant(contestant)) diff --git a/src/contest_util.c b/src/contest_util.c index ec999be92493..e0e80a70912a 100644 --- a/src/contest_util.c +++ b/src/contest_util.c @@ -2011,7 +2011,7 @@ void GiveMonContestRibbon(void) { case CONTEST_CATEGORY_COOL: ribbonData = GetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_COOL_RIBBON); - if (ribbonData <= gSpecialVar_ContestRank && ribbonData < 4) + if (ribbonData <= gSpecialVar_ContestRank && ribbonData <= CONTEST_RANK_MASTER) { ribbonData++; SetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_COOL_RIBBON, &ribbonData); @@ -2021,7 +2021,7 @@ void GiveMonContestRibbon(void) break; case CONTEST_CATEGORY_BEAUTY: ribbonData = GetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_BEAUTY_RIBBON); - if (ribbonData <= gSpecialVar_ContestRank && ribbonData < 4) + if (ribbonData <= gSpecialVar_ContestRank && ribbonData <= CONTEST_RANK_MASTER) { ribbonData++; SetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_BEAUTY_RIBBON, &ribbonData); @@ -2031,7 +2031,7 @@ void GiveMonContestRibbon(void) break; case CONTEST_CATEGORY_CUTE: ribbonData = GetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_CUTE_RIBBON); - if (ribbonData <= gSpecialVar_ContestRank && ribbonData < 4) + if (ribbonData <= gSpecialVar_ContestRank && ribbonData <= CONTEST_RANK_MASTER) { ribbonData++; SetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_CUTE_RIBBON, &ribbonData); @@ -2041,7 +2041,7 @@ void GiveMonContestRibbon(void) break; case CONTEST_CATEGORY_SMART: ribbonData = GetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_SMART_RIBBON); - if (ribbonData <= gSpecialVar_ContestRank && ribbonData < 4) + if (ribbonData <= gSpecialVar_ContestRank && ribbonData <= CONTEST_RANK_MASTER) { ribbonData++; SetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_SMART_RIBBON, &ribbonData); @@ -2051,7 +2051,7 @@ void GiveMonContestRibbon(void) break; case CONTEST_CATEGORY_TOUGH: ribbonData = GetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_TOUGH_RIBBON); - if (ribbonData <= gSpecialVar_ContestRank && ribbonData < 4) + if (ribbonData <= gSpecialVar_ContestRank && ribbonData <= CONTEST_RANK_MASTER) { ribbonData++; SetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_TOUGH_RIBBON, &ribbonData); diff --git a/src/data/contest_opponents.h b/src/data/contest_opponents.h index 7c3aad315140..d8241c4f0c1e 100644 --- a/src/data/contest_opponents.h +++ b/src/data/contest_opponents.h @@ -138,11 +138,14 @@ enum { #define CONTEST_AI_SET_20 (CONTEST_AI_COMMON | CONTEST_AI_DUMMY_12 | CONTEST_AI_DUMMY_25) #define CONTEST_AI_SET_21 (CONTEST_AI_COMMON | CONTEST_AI_DUMMY_7 | CONTEST_AI_DUMMY_25) +// All AI contestants have the same trainer ID +#define CONTEST_AI_TRAINER_ID 0xFFFF + const struct ContestWinner gDefaultContestWinners[] = { [CONTEST_WINNER_HALL_1 - 1] = { .personality = 0, - .trainerId = 0xFFFF, + .trainerId = CONTEST_AI_TRAINER_ID, .species = SPECIES_ELECTRIKE, .contestCategory = CONTEST_CATEGORY_CUTE, .monName = _("ELECTER"), @@ -151,7 +154,7 @@ const struct ContestWinner gDefaultContestWinners[] = }, [CONTEST_WINNER_HALL_2 - 1] = { .personality = 0, - .trainerId = 0xFFFF, + .trainerId = CONTEST_AI_TRAINER_ID, .species = SPECIES_TROPIUS, .contestCategory = CONTEST_CATEGORY_COOL, .monName = _("TROPO"), @@ -160,7 +163,7 @@ const struct ContestWinner gDefaultContestWinners[] = }, [CONTEST_WINNER_HALL_3 - 1] = { .personality = 0, - .trainerId = 0xFFFF, + .trainerId = CONTEST_AI_TRAINER_ID, .species = SPECIES_XATU, .contestCategory = CONTEST_CATEGORY_BEAUTY, .monName = _("TUXA"), @@ -169,7 +172,7 @@ const struct ContestWinner gDefaultContestWinners[] = }, [CONTEST_WINNER_HALL_4 - 1] = { .personality = 0, - .trainerId = 0xFFFF, + .trainerId = CONTEST_AI_TRAINER_ID, .species = SPECIES_PLUSLE, .contestCategory = CONTEST_CATEGORY_TOUGH, .monName = _("PULSE"), @@ -178,7 +181,7 @@ const struct ContestWinner gDefaultContestWinners[] = }, [CONTEST_WINNER_HALL_5 - 1] = { .personality = 0, - .trainerId = 0xFFFF, + .trainerId = CONTEST_AI_TRAINER_ID, .species = SPECIES_SHUPPET, .contestCategory = CONTEST_CATEGORY_SMART, .monName = _("SHUPUP"), @@ -187,7 +190,7 @@ const struct ContestWinner gDefaultContestWinners[] = }, [CONTEST_WINNER_HALL_6 - 1] = { .personality = 0, - .trainerId = 0xFFFF, + .trainerId = CONTEST_AI_TRAINER_ID, .species = SPECIES_ZANGOOSE, .contestCategory = CONTEST_CATEGORY_COOL, .monName = _("GOOZAN"), @@ -196,7 +199,7 @@ const struct ContestWinner gDefaultContestWinners[] = }, [CONTEST_WINNER_HALL_UNUSED_1 - 1] = { .personality = 0, - .trainerId = 0xFFFF, + .trainerId = CONTEST_AI_TRAINER_ID, .species = SPECIES_LOUDRED, .contestCategory = CONTEST_CATEGORY_BEAUTY, .monName = _("LOUDED"), @@ -205,7 +208,7 @@ const struct ContestWinner gDefaultContestWinners[] = }, [CONTEST_WINNER_HALL_UNUSED_2 - 1] = { .personality = 0, - .trainerId = 0xFFFF, + .trainerId = CONTEST_AI_TRAINER_ID, .species = SPECIES_DELCATTY, .contestCategory = CONTEST_CATEGORY_CUTE, .monName = _("KITSY"), @@ -242,7 +245,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 4, .sheen = 50, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_EDITH] = { .species = SPECIES_ILLUMISE, @@ -270,7 +273,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 2, .sheen = 60, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_EVAN] = { .species = SPECIES_DUSTOX, @@ -298,7 +301,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 4, .sheen = 70, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_KELSEY] = { .species = SPECIES_SEEDOT, @@ -326,7 +329,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 7, .sheen = 80, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_MADISON] = { .species = SPECIES_TAILLOW, @@ -354,7 +357,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 4, .sheen = 90, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_RAYMOND] = { .species = SPECIES_NINCADA, @@ -382,7 +385,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 8, .sheen = 100, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_GRANT] = { .species = SPECIES_SHROOMISH, @@ -410,7 +413,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 2, .sheen = 50, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_PAIGE] = { .species = SPECIES_SPHEAL, @@ -438,7 +441,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 10, .sheen = 60, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_ALEC] = { .species = SPECIES_SLAKOTH, @@ -466,7 +469,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 18, .sheen = 70, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_SYDNEY] = { .species = SPECIES_WHISMUR, @@ -494,7 +497,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 7, .sheen = 80, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_MORRIS] = { .species = SPECIES_MAKUHITA, @@ -522,7 +525,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 1, .sheen = 90, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_MARIAH] = { .species = SPECIES_ARON, @@ -550,7 +553,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 2, .sheen = 100, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_RUSSELL] = { .species = SPECIES_CROBAT, @@ -578,7 +581,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 10, .sheen = 50, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_MELANIE] = { .species = SPECIES_GULPIN, @@ -606,7 +609,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 5, .sheen = 60, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_CHANCE] = { .species = SPECIES_MANECTRIC, @@ -634,7 +637,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 1, .sheen = 70, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_AGATHA] = { .species = SPECIES_BULBASAUR, @@ -662,7 +665,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 4, .sheen = 50, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_BEAU] = { .species = SPECIES_BUTTERFREE, @@ -690,7 +693,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 4, .sheen = 60, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_KAY] = { .species = SPECIES_PIDGEOTTO, @@ -718,7 +721,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 3, .sheen = 70, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_CALE] = { .species = SPECIES_DIGLETT, @@ -746,7 +749,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 10, .sheen = 80, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_CAITLIN] = { .species = SPECIES_POLIWAG, @@ -774,7 +777,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 10, .sheen = 90, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_COLBY] = { .species = SPECIES_TOTODILE, @@ -802,7 +805,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 5, .sheen = 100, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_KYLIE] = { .species = SPECIES_LEDYBA, @@ -830,7 +833,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 2, .sheen = 90, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_LIAM] = { .species = SPECIES_DELIBIRD, @@ -858,7 +861,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 3, .sheen = 80, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_MILO] = { .species = SPECIES_LARVITAR, @@ -886,7 +889,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 10, .sheen = 70, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_KARINA] = { .species = SPECIES_ROSELIA, @@ -914,7 +917,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 20, .sheen = 100, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_BOBBY] = { .species = SPECIES_DODRIO, @@ -942,7 +945,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 35, .sheen = 110, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_CLAIRE] = { .species = SPECIES_TRAPINCH, @@ -970,7 +973,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 25, .sheen = 120, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_WILLIE] = { .species = SPECIES_CACNEA, @@ -998,7 +1001,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 25, .sheen = 130, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_CASSIDY] = { .species = SPECIES_SANDSLASH, @@ -1026,7 +1029,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 100, .sheen = 140, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_MORGAN] = { .species = SPECIES_BALTOY, @@ -1054,7 +1057,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 35, .sheen = 150, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_SUMMER] = { .species = SPECIES_MEDICHAM, @@ -1082,7 +1085,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 40, .sheen = 100, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_MILES] = { .species = SPECIES_SPINDA, @@ -1110,7 +1113,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 25, .sheen = 110, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_AUDREY] = { .species = SPECIES_SWABLU, @@ -1138,7 +1141,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 25, .sheen = 120, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_AVERY] = { .species = SPECIES_SPOINK, @@ -1166,7 +1169,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 30, .sheen = 130, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_ARIANA] = { .species = SPECIES_KECLEON, @@ -1194,7 +1197,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 35, .sheen = 140, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_ASHTON] = { .species = SPECIES_GOLDEEN, @@ -1222,7 +1225,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 25, .sheen = 150, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_SANDRA] = { .species = SPECIES_BARBOACH, @@ -1250,7 +1253,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 15, .sheen = 100, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_CARSON] = { .species = SPECIES_SKARMORY, @@ -1278,7 +1281,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 20, .sheen = 110, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_KATRINA] = { .species = SPECIES_LOTAD, @@ -1306,7 +1309,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 75, .sheen = 120, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_LUKE] = { .species = SPECIES_SLOWBRO, @@ -1334,7 +1337,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 20, .sheen = 100, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_RAUL] = { .species = SPECIES_FARFETCHD, @@ -1362,7 +1365,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 20, .sheen = 110, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_JADA] = { .species = SPECIES_SEEL, @@ -1390,7 +1393,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 20, .sheen = 120, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_ZEEK] = { .species = SPECIES_DROWZEE, @@ -1418,7 +1421,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 45, .sheen = 130, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_DIEGO] = { .species = SPECIES_HITMONCHAN, @@ -1446,7 +1449,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 45, .sheen = 140, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_ALIYAH] = { .species = SPECIES_BLISSEY, @@ -1474,7 +1477,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 20, .sheen = 150, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_NATALIA] = { .species = SPECIES_ELEKID, @@ -1502,7 +1505,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 25, .sheen = 140, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_DEVIN] = { .species = SPECIES_SNUBBULL, @@ -1530,7 +1533,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 20, .sheen = 130, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_TYLOR] = { .species = SPECIES_MISDREAVUS, @@ -1558,7 +1561,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 20, .sheen = 120, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_RONNIE] = { .species = SPECIES_LAIRON, @@ -1586,7 +1589,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 90, .sheen = 200, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_CLAUDIA] = { .species = SPECIES_SHIFTRY, @@ -1614,7 +1617,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 70, .sheen = 210, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_ELIAS] = { .species = SPECIES_NINJASK, @@ -1642,7 +1645,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 70, .sheen = 220, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_JADE] = { .species = SPECIES_SWELLOW, @@ -1670,7 +1673,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 40, .sheen = 230, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_FRANCIS] = { .species = SPECIES_MIGHTYENA, @@ -1698,7 +1701,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 70, .sheen = 240, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_ALISHA] = { .species = SPECIES_BEAUTIFLY, @@ -1726,7 +1729,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 100, .sheen = 250, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_SAUL] = { .species = SPECIES_SEAKING, @@ -1754,7 +1757,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 90, .sheen = 200, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_FELICIA] = { .species = SPECIES_CASTFORM, @@ -1782,7 +1785,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 65, .sheen = 210, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_EMILIO] = { .species = SPECIES_MACHOKE, @@ -1810,7 +1813,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 50, .sheen = 220, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_KARLA] = { .species = SPECIES_LOMBRE, @@ -1838,7 +1841,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 70, .sheen = 230, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_DARRYL] = { .species = SPECIES_SEVIPER, @@ -1866,7 +1869,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 100, .sheen = 240, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_SELENA] = { .species = SPECIES_WAILMER, @@ -1894,7 +1897,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 30, .sheen = 250, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_NOEL] = { .species = SPECIES_MAGIKARP, @@ -1922,7 +1925,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 160, .sheen = 255, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_LACEY] = { .species = SPECIES_LUNATONE, @@ -1950,7 +1953,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 50, .sheen = 210, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_CORBIN] = { .species = SPECIES_ABSOL, @@ -1978,7 +1981,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 35, .sheen = 220, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_GRACIE] = { .species = SPECIES_EXEGGUTOR, @@ -2006,7 +2009,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 80, .sheen = 200, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_COLTIN] = { .species = SPECIES_CUBONE, @@ -2034,7 +2037,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 100, .sheen = 210, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_ELLIE] = { .species = SPECIES_HITMONLEE, @@ -2062,7 +2065,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 100, .sheen = 220, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_MARCUS] = { .species = SPECIES_SQUIRTLE, @@ -2090,7 +2093,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 95, .sheen = 230, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_KIARA] = { .species = SPECIES_KANGASKHAN, @@ -2118,7 +2121,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 100, .sheen = 240, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_BRYCE] = { .species = SPECIES_PINECO, @@ -2146,7 +2149,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 80, .sheen = 250, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_JAMIE] = { .species = SPECIES_DUNSPARCE, @@ -2174,7 +2177,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 110, .sheen = 240, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_JORGE] = { .species = SPECIES_HOUNDOOM, @@ -2202,7 +2205,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 80, .sheen = 230, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_DEVON] = { .species = SPECIES_MILTANK, @@ -2230,7 +2233,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 40, .sheen = 220, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_JUSTINA] = { .species = SPECIES_GYARADOS, @@ -2258,7 +2261,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 160, .sheen = 255, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_RALPH] = { .species = SPECIES_LOUDRED, @@ -2286,7 +2289,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 160, .sheen = 255, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_ROSA] = { .species = SPECIES_SKITTY, @@ -2314,7 +2317,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 60, .sheen = 255, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_KEATON] = { .species = SPECIES_SLAKING, @@ -2342,7 +2345,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 150, .sheen = 255, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_MAYRA] = { .species = SPECIES_ALTARIA, @@ -2370,7 +2373,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 90, .sheen = 255, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_LAMAR] = { .species = SPECIES_KIRLIA, @@ -2398,7 +2401,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 80, .sheen = 255, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_AUBREY] = { .species = SPECIES_BELLOSSOM, @@ -2426,7 +2429,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 40, .sheen = 255, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_NIGEL] = { .species = SPECIES_SABLEYE, @@ -2454,7 +2457,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 160, .sheen = 255, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_CAMILLE] = { .species = SPECIES_NATU, @@ -2482,7 +2485,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 170, .sheen = 255, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_DEON] = { .species = SPECIES_SHARPEDO, @@ -2510,7 +2513,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 100, .sheen = 255, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_JANELLE] = { .species = SPECIES_LUVDISC, @@ -2538,7 +2541,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 190, .sheen = 255, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_HEATH] = { .species = SPECIES_HERACROSS, @@ -2566,7 +2569,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 140, .sheen = 255, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_SASHA] = { .species = SPECIES_ELECTRODE, @@ -2594,7 +2597,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 50, .sheen = 255, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_FRANKIE] = { .species = SPECIES_PICHU, @@ -2622,7 +2625,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 120, .sheen = 255, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_HELEN] = { .species = SPECIES_WOBBUFFET, @@ -2650,7 +2653,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 210, .sheen = 255, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_CAMILE] = { .species = SPECIES_GENGAR, @@ -2678,7 +2681,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 180, .sheen = 255, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_MARTIN] = { .species = SPECIES_PORYGON, @@ -2706,7 +2709,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 130, .sheen = 255, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_SERGIO] = { .species = SPECIES_DRAGONITE, @@ -2734,7 +2737,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 150, .sheen = 255, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_KAILEY] = { .species = SPECIES_MEOWTH, @@ -2762,7 +2765,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 80, .sheen = 255, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_PERLA] = { .species = SPECIES_JYNX, @@ -2790,7 +2793,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 120, .sheen = 255, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_CLARA] = { .species = SPECIES_TOGEPI, @@ -2818,7 +2821,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 80, .sheen = 255, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_JAKOB] = { .species = SPECIES_ESPEON, @@ -2846,7 +2849,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 150, .sheen = 255, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_TREY] = { .species = SPECIES_SLOWKING, @@ -2874,7 +2877,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 170, .sheen = 255, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, }, [CONTEST_OPPONENT_LANE] = { .species = SPECIES_URSARING, @@ -2902,7 +2905,7 @@ const struct ContestPokemon gContestOpponents[] = .tough = 190, .sheen = 255, .personality = 0, - .otId = 0xFFFF + .otId = CONTEST_AI_TRAINER_ID, } }; diff --git a/src/decoration.c b/src/decoration.c index b33580d2d3f0..688018b2db17 100644 --- a/src/decoration.c +++ b/src/decoration.c @@ -422,7 +422,16 @@ static const u8 sDecorationSlideElevation[] = }; static const u16 sDecorShapeSizes[] = { - 0x04, 0x08, 0x10, 0x20, 0x10, 0x08, 0x10, 0x20, 0x40, 0x20 + [DECORSHAPE_1x1] = 4, + [DECORSHAPE_2x1] = 8, + [DECORSHAPE_3x1] = 16, + [DECORSHAPE_4x2] = 32, + [DECORSHAPE_2x2] = 16, + [DECORSHAPE_1x2] = 8, + [DECORSHAPE_1x3] = 16, + [DECORSHAPE_2x4] = 32, + [DECORSHAPE_3x3] = 64, + [DECORSHAPE_3x2] = 32, }; static const u16 sBrendanPalette[] = INCBIN_U16("graphics/decorations/brendan.gbapal"); diff --git a/src/dewford_trend.c b/src/dewford_trend.c index 08dd9afe0ba0..45c18f6013db 100644 --- a/src/dewford_trend.c +++ b/src/dewford_trend.c @@ -224,7 +224,7 @@ static void SortTrends(struct DewfordTrend *trends, u16 numTrends, u8 mode) } #define SAVED_TRENDS_SIZE (sizeof(struct DewfordTrend) * SAVED_TRENDS_COUNT) -#define BUFFER_SIZE (SAVED_TRENDS_SIZE * MAX_LINK_PLAYERS > 0x100 ? SAVED_TRENDS_SIZE * MAX_LINK_PLAYERS : 0x100) // More space was allocated than needed +#define BUFFER_SIZE max(SAVED_TRENDS_SIZE * MAX_LINK_PLAYERS, 0x100) // More space was allocated than needed void ReceiveDewfordTrendData(struct DewfordTrend *linkedTrends, size_t size, u8 unused) { diff --git a/src/ereader_helpers.c b/src/ereader_helpers.c index 894ad00123c9..c5b8712b5c6b 100755 --- a/src/ereader_helpers.c +++ b/src/ereader_helpers.c @@ -753,11 +753,11 @@ void EReaderHelper_SerialCallback(void) switch (sSendRecvMgr.state) { case EREADER_XFR_STATE_HANDSHAKE: - REG_SIOMLT_SEND = 0xCCD0; // Handshake id + REG_SIOMLT_SEND = EREADER_HANDSHAKE; *(u64 *)recv = REG_SIOMLT_RECV; for (i = 0, cnt1 = 0, cnt2 = 0; i < 4; i++) { - if (recv[i] == 0xCCD0) + if (recv[i] == EREADER_HANDSHAKE) cnt1++; else if (recv[i] != 0xFFFF) cnt2++; diff --git a/src/field_specials.c b/src/field_specials.c index 38746c97a48a..53084c8291c5 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -3260,6 +3260,7 @@ void ScrollableMultichoice_ClosePersistentMenu(void) #undef tTaskId #define DEOXYS_ROCK_LEVELS 11 +#define ROCK_PAL_ID 10 void DoDeoxysRockInteraction(void) { @@ -3339,7 +3340,7 @@ static void Task_DeoxysRockInteraction(u8 taskId) static void ChangeDeoxysRockLevel(u8 rockLevel) { u8 objectEventId; - LoadPalette(&sDeoxysRockPalettes[rockLevel], OBJ_PLTT_ID(10), PLTT_SIZEOF(4)); + LoadPalette(&sDeoxysRockPalettes[rockLevel], OBJ_PLTT_ID(ROCK_PAL_ID), PLTT_SIZEOF(4)); TryGetObjectEventIdByLocalIdAndMap(LOCALID_BIRTH_ISLAND_EXTERIOR_ROCK, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, &objectEventId); if (rockLevel == 0) @@ -3376,21 +3377,20 @@ static void WaitForDeoxysRockMovement(u8 taskId) void IncrementBirthIslandRockStepCount(void) { - u16 var = VarGet(VAR_DEOXYS_ROCK_STEP_COUNT); + u16 stepCount = VarGet(VAR_DEOXYS_ROCK_STEP_COUNT); if (gSaveBlock1Ptr->location.mapNum == MAP_NUM(BIRTH_ISLAND_EXTERIOR) && gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(BIRTH_ISLAND_EXTERIOR)) { - var++; - if (var > 99) + if (++stepCount > 99) VarSet(VAR_DEOXYS_ROCK_STEP_COUNT, 0); else - VarSet(VAR_DEOXYS_ROCK_STEP_COUNT, var); + VarSet(VAR_DEOXYS_ROCK_STEP_COUNT, stepCount); } } void SetDeoxysRockPalette(void) { - LoadPalette(&sDeoxysRockPalettes[(u8)VarGet(VAR_DEOXYS_ROCK_LEVEL)], OBJ_PLTT_ID(10), PLTT_SIZEOF(4)); - BlendPalettes(0x04000000, 16, 0); + LoadPalette(&sDeoxysRockPalettes[(u8)VarGet(VAR_DEOXYS_ROCK_LEVEL)], OBJ_PLTT_ID(ROCK_PAL_ID), PLTT_SIZEOF(4)); + BlendPalettes(1 << (ROCK_PAL_ID + 16), 16, 0); } void SetPCBoxToSendMon(u8 boxId) @@ -3957,16 +3957,15 @@ bool8 InPokemonCenter(void) #define FANCLUB_BITFIELD (gSaveBlock1Ptr->vars[VAR_FANCLUB_FAN_COUNTER - VARS_START]) #define FANCLUB_COUNTER 0x007F -#define FANCLUB_FAN_FLAGS 0xFF80 #define GET_TRAINER_FAN_CLUB_FLAG(flag) (FANCLUB_BITFIELD >> (flag) & 1) #define SET_TRAINER_FAN_CLUB_FLAG(flag) (FANCLUB_BITFIELD |= 1 << (flag)) #define FLIP_TRAINER_FAN_CLUB_FLAG(flag)(FANCLUB_BITFIELD ^= 1 << (flag)) #define GET_TRAINER_FAN_CLUB_COUNTER (FANCLUB_BITFIELD & FANCLUB_COUNTER) -#define SET_TRAINER_FAN_CLUB_COUNTER(count) (FANCLUB_BITFIELD = (FANCLUB_BITFIELD & FANCLUB_FAN_FLAGS) | (count)) +#define SET_TRAINER_FAN_CLUB_COUNTER(count) (FANCLUB_BITFIELD = (FANCLUB_BITFIELD & ~FANCLUB_COUNTER) | (count)) #define INCR_TRAINER_FAN_CLUB_COUNTER(count)(FANCLUB_BITFIELD += (count)) -#define CLEAR_TRAINER_FAN_CLUB_COUNTER (FANCLUB_BITFIELD &= ~(FANCLUB_COUNTER)) +#define CLEAR_TRAINER_FAN_CLUB_COUNTER (FANCLUB_BITFIELD &= ~FANCLUB_COUNTER) void ResetFanClub(void) { diff --git a/src/librfu_rfu.c b/src/librfu_rfu.c index 319743d0d2f4..da37b8fc112d 100644 --- a/src/librfu_rfu.c +++ b/src/librfu_rfu.c @@ -139,7 +139,7 @@ u16 rfu_initializeAPI(u32 *APIBuffer, u16 buffByteSize, IntrFunc *sioIntrTable_p u16 buffByteSizeMax; // is in EWRAM? - if (((uintptr_t)APIBuffer & 0xF000000) == 0x2000000 && copyInterruptToRam) + if (((uintptr_t)APIBuffer & 0xF000000) == EWRAM_START && copyInterruptToRam) return ERR_RFU_API_BUFF_ADR; // is not 4-byte aligned? if ((u32)APIBuffer & 3) @@ -338,7 +338,7 @@ u16 rfu_getRFUStatus(u8 *rfuState) u16 rfu_MBOOT_CHILD_inheritanceLinkStatus(void) { const char *s1 = str_checkMbootLL; - char *s2 = (char *)0x30000F0; + char *s2 = (char *)(IWRAM_START + 0xF0); u16 checksum; u16 *mb_buff_iwram_p; u8 i; @@ -347,15 +347,15 @@ u16 rfu_MBOOT_CHILD_inheritanceLinkStatus(void) while (*s1 != '\0') if (*s1++ != *s2++) return 1; - mb_buff_iwram_p = (u16 *)0x3000000; + mb_buff_iwram_p = (u16 *)IWRAM_START; // The size of struct RfuLinkStatus is 180 checksum = 0; for (i = 0; i < 180/2; ++i) checksum += *mb_buff_iwram_p++; - if (checksum != *(u16 *)0x30000FA) + if (checksum != *(u16 *)(IWRAM_START + 0xFA)) return 1; - CpuCopy16((u16 *)0x3000000, gRfuLinkStatus, sizeof(struct RfuLinkStatus)); + CpuCopy16((u16 *)IWRAM_START, gRfuLinkStatus, sizeof(struct RfuLinkStatus)); gRfuStatic->flags |= 0x80; // mboot return 0; } diff --git a/src/link_rfu_2.c b/src/link_rfu_2.c index 9d66a1837858..6c84ffefe008 100644 --- a/src/link_rfu_2.c +++ b/src/link_rfu_2.c @@ -1918,7 +1918,8 @@ static void Task_PlayerExchangeUpdate(u8 taskId) for (i = 0; i < RFU_CHILD_MAX; i++) sio->linkPlayerIdx[i] = gRfu.linkPlayerIdx[i]; memcpy(sio->linkPlayers, gLinkPlayers, sizeof(gLinkPlayers)); - if (SendBlock(0, gBlockSendBuffer, 0xa0)) + // Send SioInfo but exclude the 92 unused bytes at the end + if (SendBlock(0, gBlockSendBuffer, offsetof(struct SioInfo, filler))) gTasks[taskId].tState++; break; case 5: diff --git a/src/main_menu.c b/src/main_menu.c index ef4bbd636d34..ddbcda5fd299 100644 --- a/src/main_menu.c +++ b/src/main_menu.c @@ -4,6 +4,7 @@ #include "constants/rgb.h" #include "constants/songs.h" #include "constants/trainers.h" +#include "data.h" #include "decompress.h" #include "event_data.h" #include "field_effect.h" @@ -1900,7 +1901,7 @@ static void AddBirchSpeechObjects(u8 taskId) gSprites[brendanSpriteId].invisible = TRUE; gSprites[brendanSpriteId].oam.priority = 0; gTasks[taskId].tBrendanSpriteId = brendanSpriteId; - maySpriteId = CreateTrainerSprite(FacilityClassToPicIndex(FACILITY_CLASS_MAY), 120, 60, 0, &gDecompressionBuffer[0x800]); + maySpriteId = CreateTrainerSprite(FacilityClassToPicIndex(FACILITY_CLASS_MAY), 120, 60, 0, &gDecompressionBuffer[TRAINER_PIC_SIZE]); gSprites[maySpriteId].callback = SpriteCB_Null; gSprites[maySpriteId].invisible = TRUE; gSprites[maySpriteId].oam.priority = 0; diff --git a/src/palette.c b/src/palette.c index 43a4c213c71a..e3606646274b 100644 --- a/src/palette.c +++ b/src/palette.c @@ -440,7 +440,7 @@ static u8 UpdateNormalPaletteFade(void) else { selectedPalettes = gPaletteFade_selectedPalettes >> 16; - paletteOffset = 256; + paletteOffset = OBJ_PLTT_OFFSET; } while (selectedPalettes) diff --git a/src/region_map.c b/src/region_map.c index f6123359be8b..7d5fe93654f6 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -1419,7 +1419,7 @@ void CreateRegionMapCursor(u16 tileTag, u16 paletteTag) sRegionMap->cursorSprite->y = 8 * sRegionMap->cursorPosY + 4; } sRegionMap->cursorSprite->data[1] = 2; - sRegionMap->cursorSprite->data[2] = (IndexOfSpritePaletteTag(paletteTag) << 4) + 0x101; + sRegionMap->cursorSprite->data[2] = OBJ_PLTT_ID(IndexOfSpritePaletteTag(paletteTag)) + 1; sRegionMap->cursorSprite->data[3] = TRUE; } } diff --git a/src/secret_base.c b/src/secret_base.c index 1a4a0ac9cdc6..9509cd0fc5c2 100644 --- a/src/secret_base.c +++ b/src/secret_base.c @@ -47,6 +47,8 @@ #include "constants/songs.h" #include "constants/trainers.h" +#define TAG_SCROLL_ARROW 5112 + // Values for registryStatus enum { UNREGISTERED, @@ -985,7 +987,7 @@ static void FinalizeRegistryMenu(u8 taskId) static void AddRegistryMenuScrollArrows(u8 taskId) { s16 *data = gTasks[taskId].data; - tArrowTaskId = AddScrollIndicatorArrowPairParameterized(SCROLL_ARROW_UP, 188, 12, 148, tNumBases - tMaxShownItems, 0x13f8, 0x13f8, &tScrollOffset); + tArrowTaskId = AddScrollIndicatorArrowPairParameterized(SCROLL_ARROW_UP, 188, 12, 148, tNumBases - tMaxShownItems, TAG_SCROLL_ARROW, TAG_SCROLL_ARROW, &tScrollOffset); } static void HandleRegistryMenuInput(u8 taskId) From d5d46bb4382174e60f730c385c7a4010a6740fbc Mon Sep 17 00:00:00 2001 From: GriffinR Date: Thu, 10 Aug 2023 01:42:38 -0400 Subject: [PATCH 04/48] More DISPLAY_WIDTH/HEIGHT constant usage --- src/battle_anim_effects_1.c | 6 +++--- src/battle_anim_effects_3.c | 6 +++--- src/battle_anim_ground.c | 6 +++--- src/battle_anim_ice.c | 6 +++--- src/battle_anim_throw.c | 2 +- src/battle_intro.c | 36 ++++++++++++++++++------------------ src/battle_main.c | 7 ++----- src/berry_blender.c | 8 ++++---- src/credits.c | 2 +- src/field_effect.c | 2 +- src/intro.c | 10 +++++----- src/pokedex.c | 14 +++++++------- src/slot_machine.c | 18 +++++++++--------- src/title_screen.c | 2 +- src/util.c | 2 +- 15 files changed, 62 insertions(+), 65 deletions(-) diff --git a/src/battle_anim_effects_1.c b/src/battle_anim_effects_1.c index e328849407d1..c0ad548f17f9 100644 --- a/src/battle_anim_effects_1.c +++ b/src/battle_anim_effects_1.c @@ -3578,13 +3578,13 @@ static void AnimFlyingParticle(struct Sprite *sprite) { sprite->data[4] = 0; sprite->data[2] = gBattleAnimArgs[3]; - sprite->x = 0xFFF0; + sprite->x = -16; } else { sprite->data[4] = 1; sprite->data[2] = -gBattleAnimArgs[3]; - sprite->x = 0x100; + sprite->x = DISPLAY_WIDTH + 16; } sprite->data[1] = gBattleAnimArgs[1]; @@ -3623,7 +3623,7 @@ static void AnimFlyingParticle_Step(struct Sprite *sprite) sprite->data[0] = (sprite->data[3] * a) & 0xFF; if (!sprite->data[4]) { - if (sprite->x2 + sprite->x <= 0xF7) + if (sprite->x2 + sprite->x < DISPLAY_WIDTH + 8) return; } else diff --git a/src/battle_anim_effects_3.c b/src/battle_anim_effects_3.c index 6c5fd59c86db..5168641c6acf 100755 --- a/src/battle_anim_effects_3.c +++ b/src/battle_anim_effects_3.c @@ -3056,7 +3056,7 @@ static void AnimFlatterConfetti(struct Sprite *sprite) if (sprite->data[2] == ANIM_ATTACKER) sprite->x = -8; else - sprite->x = 248; + sprite->x = DISPLAY_WIDTH + 8; sprite->y = 104; sprite->callback = AnimFlatterConfetti_Step; @@ -3414,8 +3414,8 @@ static void AnimTask_AcidArmor_Step(u8 taskId) var0 *= 2; while (var0 >= 0) { - gScanlineEffectRegBuffers[0][var0] = bgX + 240; - gScanlineEffectRegBuffers[1][var0] = bgX + 240; + gScanlineEffectRegBuffers[0][var0] = bgX + DISPLAY_WIDTH; + gScanlineEffectRegBuffers[1][var0] = bgX + DISPLAY_WIDTH; var0 -= 2; } diff --git a/src/battle_anim_ground.c b/src/battle_anim_ground.c index 7b810b56c2e6..d6d8137bcdd7 100644 --- a/src/battle_anim_ground.c +++ b/src/battle_anim_ground.c @@ -481,10 +481,10 @@ static void SetDigScanlineEffect(u8 useBG1, s16 y, s16 endY) y++; } - while (y < 160) + while (y < DISPLAY_HEIGHT) { - gScanlineEffectRegBuffers[0][y] = bgX + 240; - gScanlineEffectRegBuffers[1][y] = bgX + 240; + gScanlineEffectRegBuffers[0][y] = bgX + DISPLAY_WIDTH; + gScanlineEffectRegBuffers[1][y] = bgX + DISPLAY_WIDTH; y++; } diff --git a/src/battle_anim_ice.c b/src/battle_anim_ice.c index f870ff4f8753..273721e1625b 100644 --- a/src/battle_anim_ice.c +++ b/src/battle_anim_ice.c @@ -1305,11 +1305,11 @@ static void MovePoisonGasCloud(struct Sprite *sprite) sprite->data[3] = sprite->y += sprite->y2; sprite->data[4] = sprite->y + 4; if (IsContest()) - sprite->data[2] = -0x10; + sprite->data[2] = -16; else if (GET_BATTLER_SIDE2(gBattleAnimTarget) != B_SIDE_PLAYER) - sprite->data[2] = 0x100; + sprite->data[2] = DISPLAY_WIDTH + 16; else - sprite->data[2] = -0x10; + sprite->data[2] = -16; sprite->data[7]++; sprite->x2 = sprite->y2 = 0; diff --git a/src/battle_anim_throw.c b/src/battle_anim_throw.c index e7c7a560b275..fea67a6e3c61 100755 --- a/src/battle_anim_throw.c +++ b/src/battle_anim_throw.c @@ -2117,7 +2117,7 @@ void AnimTask_SwapMonSpriteToFromSubstitute(u8 taskId) gTasks[taskId].data[0] &= 0xFF; x = gSprites[spriteId].x + gSprites[spriteId].x2 + 32; - if (x > 304) + if (x > DISPLAY_WIDTH + 64) gTasks[taskId].data[10]++; break; case 1: diff --git a/src/battle_intro.c b/src/battle_intro.c index 42fe659746bd..3cdc879a86a0 100644 --- a/src/battle_intro.c +++ b/src/battle_intro.c @@ -182,7 +182,7 @@ static void BattleIntroSlide1(u8 taskId) if ((gBattle_WIN0V & 0xFF00) == 0x3000) { gTasks[taskId].tState++; - gTasks[taskId].data[2] = 240; + gTasks[taskId].data[2] = DISPLAY_WIDTH; gTasks[taskId].data[3] = 32; gIntroSlideFlags &= ~1; } @@ -213,13 +213,13 @@ static void BattleIntroSlide1(u8 taskId) gTasks[taskId].data[2] -= 2; // Scanline settings have already been set in CB2_InitBattleInternal() - for (i = 0; i < 80; i++) + for (i = 0; i < DISPLAY_HEIGHT / 2; i++) gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = gTasks[taskId].data[2]; - for (; i < 160; i++) + for (; i < DISPLAY_HEIGHT; i++) gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = -gTasks[taskId].data[2]; - if (!gTasks[taskId].data[2]) + if (gTasks[taskId].data[2] == 0) { gScanlineEffect.state = 3; gTasks[taskId].tState++; @@ -290,7 +290,7 @@ static void BattleIntroSlide2(u8 taskId) if ((gBattle_WIN0V & 0xFF00) == 0x3000) { gTasks[taskId].tState++; - gTasks[taskId].data[2] = 240; + gTasks[taskId].data[2] = DISPLAY_WIDTH; gTasks[taskId].data[3] = 32; gTasks[taskId].data[5] = 1; gIntroSlideFlags &= ~1; @@ -322,13 +322,13 @@ static void BattleIntroSlide2(u8 taskId) gTasks[taskId].data[2] -= 2; // Scanline settings have already been set in CB2_InitBattleInternal() - for (i = 0; i < 80; i++) + for (i = 0; i < DISPLAY_HEIGHT / 2; i++) gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = gTasks[taskId].data[2]; - for (; i < 160; i++) + for (; i < DISPLAY_HEIGHT; i++) gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = -gTasks[taskId].data[2]; - if (!gTasks[taskId].data[2]) + if (gTasks[taskId].data[2] == 0) { gScanlineEffect.state = 3; gTasks[taskId].tState++; @@ -383,7 +383,7 @@ static void BattleIntroSlide3(u8 taskId) if ((gBattle_WIN0V & 0xFF00) == 0x3000) { gTasks[taskId].tState++; - gTasks[taskId].data[2] = 240; + gTasks[taskId].data[2] = DISPLAY_WIDTH; gTasks[taskId].data[3] = 32; gTasks[taskId].data[5] = 1; gIntroSlideFlags &= ~1; @@ -410,13 +410,13 @@ static void BattleIntroSlide3(u8 taskId) gTasks[taskId].data[2] -= 2; // Scanline settings have already been set in CB2_InitBattleInternal() - for (i = 0; i < 80; i++) + for (i = 0; i < DISPLAY_HEIGHT / 2; i++) gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = gTasks[taskId].data[2]; - for (; i < 160; i++) + for (; i < DISPLAY_HEIGHT; i++) gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = -gTasks[taskId].data[2]; - if (!gTasks[taskId].data[2]) + if (gTasks[taskId].data[2] == 0) { gScanlineEffect.state = 3; gTasks[taskId].tState++; @@ -479,7 +479,7 @@ static void BattleIntroSlideLink(u8 taskId) if ((gBattle_WIN0V & 0xFF00) == 0x3000) { gTasks[taskId].tState++; - gTasks[taskId].data[2] = 240; + gTasks[taskId].data[2] = DISPLAY_WIDTH; gTasks[taskId].data[3] = 32; gIntroSlideFlags &= ~1; } @@ -492,13 +492,13 @@ static void BattleIntroSlideLink(u8 taskId) gTasks[taskId].data[2] -= 2; // Scanline settings have already been set in CB2_InitBattleInternal() - for (i = 0; i < 80; i++) + for (i = 0; i < DISPLAY_HEIGHT / 2; i++) gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = gTasks[taskId].data[2]; - for (; i < 160; i++) + for (; i < DISPLAY_HEIGHT; i++) gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = -gTasks[taskId].data[2]; - if (!gTasks[taskId].data[2]) + if (gTasks[taskId].data[2] == 0) { gScanlineEffect.state = 3; gTasks[taskId].tState++; @@ -544,7 +544,7 @@ static void BattleIntroSlidePartner(u8 taskId) if ((gBattle_WIN0V & 0xFF00) == 0x2000) { gTasks[taskId].tState++; - gTasks[taskId].data[2] = 240; + gTasks[taskId].data[2] = DISPLAY_WIDTH; gIntroSlideFlags &= ~1; } break; @@ -557,7 +557,7 @@ static void BattleIntroSlidePartner(u8 taskId) gBattle_BG1_X = gTasks[taskId].data[2]; gBattle_BG2_X = -gTasks[taskId].data[2]; - if (!gTasks[taskId].data[2]) + if (gTasks[taskId].data[2] == 0) gTasks[taskId].tState++; break; case 4: diff --git a/src/battle_main.c b/src/battle_main.c index b8fea024ee66..e1c6a514a7f5 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -644,19 +644,16 @@ static void CB2_InitBattleInternal(void) gBattle_WIN0V = WIN_RANGE(DISPLAY_HEIGHT / 2, DISPLAY_HEIGHT / 2 + 1); ScanlineEffect_Clear(); - i = 0; - while (i < 80) + for (i = 0; i < DISPLAY_HEIGHT / 2; i++) { gScanlineEffectRegBuffers[0][i] = 0xF0; gScanlineEffectRegBuffers[1][i] = 0xF0; - i++; } - while (i < 160) + for (; i < DISPLAY_HEIGHT; i++) { gScanlineEffectRegBuffers[0][i] = 0xFF10; gScanlineEffectRegBuffers[1][i] = 0xFF10; - i++; } ScanlineEffect_SetParams(sIntroScanlineParams16Bit); diff --git a/src/berry_blender.c b/src/berry_blender.c index 10b02c86b7ac..b882fc12d970 100644 --- a/src/berry_blender.c +++ b/src/berry_blender.c @@ -3109,10 +3109,10 @@ static void DrawBlenderCenter(struct BgAffineSrcData *dest) { struct BgAffineSrcData affineSrc; - affineSrc.texX = 0x7800; - affineSrc.texY = 0x5000; - affineSrc.scrX = 0x78 - sBerryBlender->bg_X; - affineSrc.scrY = 0x50 - sBerryBlender->bg_Y; + affineSrc.texX = (DISPLAY_WIDTH / 2) << 8; + affineSrc.texY = (DISPLAY_HEIGHT / 2) << 8; + affineSrc.scrX = DISPLAY_WIDTH / 2 - sBerryBlender->bg_X; + affineSrc.scrY = DISPLAY_HEIGHT / 2 - sBerryBlender->bg_Y; affineSrc.sx = sBerryBlender->centerScale; affineSrc.sy = sBerryBlender->centerScale; affineSrc.alpha = sBerryBlender->arrowPos; diff --git a/src/credits.c b/src/credits.c index bf636f74f6d1..b412b29e27bd 100644 --- a/src/credits.c +++ b/src/credits.c @@ -1370,7 +1370,7 @@ static void SpriteCB_Player(struct Sprite *sprite) break; case 4: StartSpriteAnimIfDifferent(sprite, 0); - if (sprite->x > 120) + if (sprite->x > DISPLAY_WIDTH / 2) sprite->x--; break; case 5: diff --git a/src/field_effect.c b/src/field_effect.c index d51c6ab88af4..8d6b6342d1fa 100644 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -2416,7 +2416,7 @@ static void TeleportWarpOutFieldEffect_SpinExit(struct Task *task) { sprite->subspriteMode = SUBSPRITES_IGNORE_PRIORITY; } - if (task->data[4] >= 0xa8) + if (task->data[4] >= DISPLAY_HEIGHT + 8) { task->tState++; TryFadeOutOldMapMusic(); diff --git a/src/intro.c b/src/intro.c index ed50208e7d55..e5e6a23dd23c 100644 --- a/src/intro.c +++ b/src/intro.c @@ -1195,7 +1195,7 @@ static void Task_Scene1_Load(u8 taskId) CpuCopy16(&gPlttBufferUnfaded[OBJ_PLTT_ID(0)], &gPlttBufferUnfaded[OBJ_PLTT_ID(11) + 4], PLTT_SIZEOF(16 - 4)); CpuCopy16(&gPlttBufferUnfaded[OBJ_PLTT_ID(0)], &gPlttBufferUnfaded[OBJ_PLTT_ID(10) + 5], PLTT_SIZEOF(16 - 5)); CpuCopy16(&gPlttBufferUnfaded[OBJ_PLTT_ID(0)], &gPlttBufferUnfaded[OBJ_PLTT_ID( 9) + 6], PLTT_SIZEOF(16 - 6)); - CreateGameFreakLogoSprites(120, 80, 0); + CreateGameFreakLogoSprites(DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2, 0); gTasks[taskId].sBigDropSpriteId = CreateWaterDrop(236, -14, 0x200, 1, 0x78, FALSE); gTasks[taskId].func = Task_Scene1_FadeIn; } @@ -1722,7 +1722,7 @@ static void Task_Scene3_Load(u8 taskId) gTasks[taskId].tZoomDiv = 0; gTasks[taskId].tZoomDivSpeed = 0; gTasks[taskId].data[3] = 0; - PanFadeAndZoomScreen(0x78, 0x50, 0, 0); + PanFadeAndZoomScreen(DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2, 0, 0); ResetSpriteData(); FreeAllSpritePalettes(); BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB_WHITEALPHA); @@ -1746,7 +1746,7 @@ static void Task_Scene3_SpinPokeball(u8 taskId) gTasks[taskId].func = Task_Scene3_WaitGroudon; } - PanFadeAndZoomScreen(0x78, 0x50, SAFE_DIV(0x10000, gTasks[taskId].tZoomDiv), gTasks[taskId].tAlpha); + PanFadeAndZoomScreen(DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2, SAFE_DIV(0x10000, gTasks[taskId].tZoomDiv), gTasks[taskId].tAlpha); if (gIntroFrameCounter == TIMER_POKEBALL_FADE) BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_WHITEALPHA); @@ -1848,7 +1848,7 @@ static void Task_Scene3_StartGroudon(u8 taskId) { gTasks[taskId].tState = 0; gTasks[taskId].func = Task_Scene3_Groudon; - ScanlineEffect_InitWave(0, 160, 4, 4, 1, SCANLINE_EFFECT_REG_BG1HOFS, FALSE); + ScanlineEffect_InitWave(0, DISPLAY_HEIGHT, 4, 4, 1, SCANLINE_EFFECT_REG_BG1HOFS, FALSE); } #define tScreenX data[1] @@ -2058,7 +2058,7 @@ static void Task_Scene3_LoadKyogre(u8 taskId) gTasks[taskId].tDelay = 16; gTasks[taskId].tZoom = 256; PanFadeAndZoomScreen(gTasks[taskId].tScreenX, gTasks[taskId].tScreenY, gTasks[taskId].tZoom, 0); - ScanlineEffect_InitWave(0, 0xA0, 4, 4, 1, SCANLINE_EFFECT_REG_BG1VOFS, FALSE); + ScanlineEffect_InitWave(0, DISPLAY_HEIGHT, 4, 4, 1, SCANLINE_EFFECT_REG_BG1VOFS, FALSE); } static void Task_Scene3_Kyogre(u8 taskId) diff --git a/src/pokedex.c b/src/pokedex.c index 7bb8e1c17fea..3f5ab22431f2 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -3755,7 +3755,7 @@ static void Task_LoadSizeScreen(u8 taskId) StringCopy(string, gText_SizeComparedTo); StringAppend(string, gSaveBlock2Ptr->playerName); - PrintInfoScreenText(string, GetStringCenterAlignXOffset(FONT_NORMAL, string, 0xF0), 0x79); + PrintInfoScreenText(string, GetStringCenterAlignXOffset(FONT_NORMAL, string, DISPLAY_WIDTH), 121); gMain.state++; } break; @@ -4072,14 +4072,14 @@ static void Task_ExitCaughtMonPage(u8 taskId) static void SpriteCB_SlideCaughtMonToCenter(struct Sprite *sprite) { - if (sprite->x < 0x78) + if (sprite->x < DISPLAY_WIDTH / 2) sprite->x += 2; - if (sprite->x > 0x78) + if (sprite->x > DISPLAY_WIDTH / 2) sprite->x -= 2; - if (sprite->y < 0x50) + if (sprite->y < DISPLAY_HEIGHT / 2) sprite->y += 1; - if (sprite->y > 0x50) + if (sprite->y > DISPLAY_HEIGHT / 2) sprite->y -= 1; } @@ -4103,7 +4103,7 @@ static void PrintMonInfo(u32 num, u32 value, u32 owned, u32 newEntry) const u8 *description; if (newEntry) - PrintInfoScreenText(gText_PokedexRegistration, GetStringCenterAlignXOffset(FONT_NORMAL, gText_PokedexRegistration, 0xF0), 0); + PrintInfoScreenText(gText_PokedexRegistration, GetStringCenterAlignXOffset(FONT_NORMAL, gText_PokedexRegistration, DISPLAY_WIDTH), 0); if (value == 0) value = NationalToHoennOrder(num); else @@ -4142,7 +4142,7 @@ static void PrintMonInfo(u32 num, u32 value, u32 owned, u32 newEntry) description = gPokedexEntries[num].description; else description = sExpandedPlaceholder_PokedexDescription; - PrintInfoScreenText(description, GetStringCenterAlignXOffset(FONT_NORMAL, description, 0xF0), 0x5F); + PrintInfoScreenText(description, GetStringCenterAlignXOffset(FONT_NORMAL, description, DISPLAY_WIDTH), 95); } static void PrintMonHeight(u16 height, u8 left, u8 top) diff --git a/src/slot_machine.c b/src/slot_machine.c index 5b058b970217..20386a2528b5 100644 --- a/src/slot_machine.c +++ b/src/slot_machine.c @@ -4672,9 +4672,9 @@ static void SpriteCB_DigitalDisplay_Reel(struct Sprite *sprite) { case 0: sprite->x += 4; - if (sprite->x >= 0xd0) + if (sprite->x >= DISPLAY_WIDTH - 32) { - sprite->x = 0xd0; + sprite->x = DISPLAY_WIDTH - 32; sprite->sState++; } break; @@ -4684,7 +4684,7 @@ static void SpriteCB_DigitalDisplay_Reel(struct Sprite *sprite) break; case 2: sprite->x += 4; - if (sprite->x >= 0x110) + if (sprite->x >= DISPLAY_WIDTH + 32) sprite->sState++; break; case 3: @@ -4700,9 +4700,9 @@ static void SpriteCB_DigitalDisplay_Time(struct Sprite *sprite) { case 0: sprite->x -= 4; - if (sprite->x <= 0xd0) + if (sprite->x <= DISPLAY_WIDTH - 32) { - sprite->x = 0xd0; + sprite->x = DISPLAY_WIDTH - 32; sprite->sState++; } break; @@ -4712,7 +4712,7 @@ static void SpriteCB_DigitalDisplay_Time(struct Sprite *sprite) break; case 2: sprite->x -= 4; - if (sprite->x <= 0x90) + if (sprite->x <= 144) sprite->sState++; break; case 3: @@ -4738,9 +4738,9 @@ static void SpriteCB_DigitalDisplay_ReelTimeNumber(struct Sprite *sprite) break; case 2: sprite->x += 4; - if (sprite->x >= 0xd0) + if (sprite->x >= DISPLAY_WIDTH - 32) { - sprite->x = 0xd0; + sprite->x = DISPLAY_WIDTH - 32; sprite->sState++; } break; @@ -4750,7 +4750,7 @@ static void SpriteCB_DigitalDisplay_ReelTimeNumber(struct Sprite *sprite) break; case 4: sprite->x += 4; - if (sprite->x >= 0xf8) + if (sprite->x >= DISPLAY_WIDTH + 8) sprite->sState++; break; case 5: diff --git a/src/title_screen.c b/src/title_screen.c index bb73df5bc5b7..87bf0d970ea5 100644 --- a/src/title_screen.c +++ b/src/title_screen.c @@ -584,7 +584,7 @@ void CB2_InitTitleScreen(void) gMain.state = 4; break; case 4: - PanFadeAndZoomScreen(0x78, 0x50, 0x100, 0); + PanFadeAndZoomScreen(DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2, 0x100, 0); SetGpuReg(REG_OFFSET_BG2X_L, -29 * 256); SetGpuReg(REG_OFFSET_BG2X_H, -1); SetGpuReg(REG_OFFSET_BG2Y_L, -32 * 256); diff --git a/src/util.c b/src/util.c index ab5603b867a4..09381fcaf317 100644 --- a/src/util.c +++ b/src/util.c @@ -118,7 +118,7 @@ const u8 gMiscBlank_Gfx[] = INCBIN_U8("graphics/interface/blank.4bpp"); u8 CreateInvisibleSpriteWithCallback(void (*callback)(struct Sprite *)) { - u8 sprite = CreateSprite(&sInvisibleSpriteTemplate, 248, 168, 14); + u8 sprite = CreateSprite(&sInvisibleSpriteTemplate, DISPLAY_WIDTH + 8, DISPLAY_HEIGHT + 8, 14); gSprites[sprite].invisible = TRUE; gSprites[sprite].callback = callback; return sprite; From aca7998b9338e8033c57672afe571854b44e6402 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Tue, 23 May 2023 13:07:52 -0400 Subject: [PATCH 05/48] Add missing use of ALL_MOVES_MASK --- include/constants/global.h | 1 + src/battle_ai_script_commands.c | 4 ++-- src/battle_controller_opponent.c | 2 +- src/battle_controller_player_partner.c | 2 +- src/battle_gfx_sfx_util.c | 8 +++++--- src/battle_script_commands.c | 2 +- src/battle_util.c | 4 +--- 7 files changed, 12 insertions(+), 11 deletions(-) diff --git a/include/constants/global.h b/include/constants/global.h index 199acfe6c609..2b70378ff518 100644 --- a/include/constants/global.h +++ b/include/constants/global.h @@ -80,6 +80,7 @@ #define TRAINER_ID_LENGTH 4 #define MAX_MON_MOVES 4 +#define ALL_MOVES_MASK ((1 << MAX_MON_MOVES) - 1) #define CONTESTANT_COUNT 4 #define CONTEST_CATEGORY_COOL 0 diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c index b2c900b422a5..aa34f46ec796 100644 --- a/src/battle_ai_script_commands.c +++ b/src/battle_ai_script_commands.c @@ -478,9 +478,9 @@ static u8 ChooseMoveOrAction_Doubles(void) else { if (gBattleTypeFlags & BATTLE_TYPE_PALACE) - BattleAI_SetupAIData(gBattleStruct->palaceFlags >> 4); + BattleAI_SetupAIData(gBattleStruct->palaceFlags >> MAX_BATTLERS_COUNT); else - BattleAI_SetupAIData((1 << MAX_MON_MOVES) - 1); + BattleAI_SetupAIData(ALL_MOVES_MASK); gBattlerTarget = i; diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c index 12402f91ea20..41afa9505f59 100644 --- a/src/battle_controller_opponent.c +++ b/src/battle_controller_opponent.c @@ -1555,7 +1555,7 @@ static void OpponentHandleChooseMove(void) if (gBattleTypeFlags & (BATTLE_TYPE_TRAINER | BATTLE_TYPE_FIRST_BATTLE | BATTLE_TYPE_SAFARI | BATTLE_TYPE_ROAMER)) { - BattleAI_SetupAIData(0xF); + BattleAI_SetupAIData(ALL_MOVES_MASK); chosenMoveId = BattleAI_ChooseMoveOrAction(); switch (chosenMoveId) diff --git a/src/battle_controller_player_partner.c b/src/battle_controller_player_partner.c index 6127e2d655de..236a66ce83df 100644 --- a/src/battle_controller_player_partner.c +++ b/src/battle_controller_player_partner.c @@ -1515,7 +1515,7 @@ static void PlayerPartnerHandleChooseMove(void) u8 chosenMoveId; struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct *)(&gBattleBufferA[gActiveBattler][4]); - BattleAI_SetupAIData(0xF); + BattleAI_SetupAIData(ALL_MOVES_MASK); chosenMoveId = BattleAI_ChooseMoveOrAction(); if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & (MOVE_TARGET_USER | MOVE_TARGET_USER_OR_SELECTED)) diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c index 55ed328b8909..b610654cef70 100644 --- a/src/battle_gfx_sfx_util.c +++ b/src/battle_gfx_sfx_util.c @@ -157,8 +157,10 @@ u16 ChooseMoveAndTargetInBattlePalace(void) // Pass selected moves to AI, pick one if (selectedMoves != 0) { - gBattleStruct->palaceFlags &= 0xF; - gBattleStruct->palaceFlags |= (selectedMoves << 4); + // Lower 4 bits of palaceFlags are flags for each battler. + // Clear the rest of palaceFlags, then set the selected moves in the upper 4 bits. + gBattleStruct->palaceFlags &= (1 << MAX_BATTLERS_COUNT) - 1; + gBattleStruct->palaceFlags |= (selectedMoves << MAX_BATTLERS_COUNT); BattleAI_SetupAIData(selectedMoves); chosenMoveId = BattleAI_ChooseMoveOrAction(); } @@ -168,7 +170,7 @@ u16 ChooseMoveAndTargetInBattlePalace(void) // If a move is chosen this way, there's a 50% chance that it will be unable to use it anyway if (chosenMoveId == -1) { - if (unusableMovesBits != 0xF) + if (unusableMovesBits != ALL_MOVES_MASK) { validMoveFlags = 0, numValidMoveGroups = 0; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 277b70d7b17c..ab8e6ad8eda1 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8179,7 +8179,7 @@ static void Cmd_trychoosesleeptalkmove(void) } unusableMovesBits = CheckMoveLimitations(gBattlerAttacker, unusableMovesBits, ~MOVE_LIMITATION_PP); - if (unusableMovesBits == (1 << MAX_MON_MOVES) - 1) // all 4 moves cannot be chosen + if (unusableMovesBits == ALL_MOVES_MASK) // all 4 moves cannot be chosen { gBattlescriptCurrInstr += 5; } diff --git a/src/battle_util.c b/src/battle_util.c index 51fbaa3cfb34..6a0137a93865 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -1110,7 +1110,6 @@ u8 CheckMoveLimitations(u8 battlerId, u8 unusableMoves, u8 check) return unusableMoves; } -#define ALL_MOVES_MASK ((1 << MAX_MON_MOVES) - 1) bool8 AreAllMovesUnusable(void) { u8 unusable = CheckMoveLimitations(gActiveBattler, 0, MOVE_LIMITATIONS_ALL); @@ -1127,7 +1126,6 @@ bool8 AreAllMovesUnusable(void) return (unusable == ALL_MOVES_MASK); } -#undef ALL_MOVES_MASK u8 GetImprisonedMovesCount(u8 battlerId, u16 move) { @@ -3954,7 +3952,7 @@ u8 IsMonDisobedient(void) if (calc < obedienceLevel) { calc = CheckMoveLimitations(gBattlerAttacker, gBitTable[gCurrMovePos], MOVE_LIMITATIONS_ALL); - if (calc == 0xF) // all moves cannot be used + if (calc == ALL_MOVES_MASK) // all moves cannot be used { // Randomly select, then print a disobedient string // B_MSG_LOAFING, B_MSG_WONT_OBEY, B_MSG_TURNED_AWAY, or B_MSG_PRETEND_NOT_NOTICE From 057928438a824705bd306b52bc3dd43d72989ac0 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 16 Aug 2023 16:41:29 -0400 Subject: [PATCH 06/48] Document ChooseMoveAndTargetInBattlePalace --- include/battle.h | 7 ++- src/battle_gfx_sfx_util.c | 93 ++++++++++++++++++++++-------------- src/battle_script_commands.c | 2 +- 3 files changed, 65 insertions(+), 37 deletions(-) diff --git a/include/battle.h b/include/battle.h index 118d560984ab..bb0e42fb837e 100644 --- a/include/battle.h +++ b/include/battle.h @@ -392,7 +392,7 @@ struct BattleStruct u8 expGetterBattlerId; u8 unused_5; u8 absentBattlerFlags; - u8 palaceFlags; // First 4 bits are "is < 50% HP and not asleep" for each battler, last 4 bits are selected moves to pass to AI + u8 palaceFlags; // First 4 bits are "is <= 50% HP and not asleep" for each battler, last 4 bits are selected moves to pass to AI u8 field_93; // related to choosing pokemon? u8 wallyBattleState; u8 wallyMovesState; @@ -440,6 +440,11 @@ struct BattleStruct u8 alreadyStatusedMoveAttempt; // As bits for battlers; For example when using Thunder Wave on an already paralyzed pokemon. }; +// The palaceFlags member of struct BattleStruct contains 1 flag per move to indicate which moves the AI should consider, +// and 1 flag per battler to indicate whether the battler is awake and at <= 50% HP (which affects move choice). +// The assert below is to ensure palaceFlags is large enough to store these flags without overlap. +STATIC_ASSERT(sizeof(((struct BattleStruct *)0)->palaceFlags) * 8 >= MAX_BATTLERS_COUNT + MAX_MON_MOVES, PalaceFlagsTooSmall) + #define F_DYNAMIC_TYPE_1 (1 << 6) #define F_DYNAMIC_TYPE_2 (1 << 7) #define DYNAMIC_TYPE_MASK (F_DYNAMIC_TYPE_1 - 1) diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c index b610654cef70..d98809be461a 100644 --- a/src/battle_gfx_sfx_util.c +++ b/src/battle_gfx_sfx_util.c @@ -121,9 +121,9 @@ u16 ChooseMoveAndTargetInBattlePalace(void) #define selectedGroup percent #define selectedMoves var2 #define moveTarget var1 - #define validMoveFlags var1 - #define numValidMoveGroups var2 - #define validMoveGroup var2 + #define numMovesPerGroup var1 + #define numMultipleMoveGroups var2 + #define randSelectGroup var2 // If battler is < 50% HP and not asleep, use second set of move group likelihoods // otherwise use first set @@ -172,32 +172,45 @@ u16 ChooseMoveAndTargetInBattlePalace(void) { if (unusableMovesBits != ALL_MOVES_MASK) { - validMoveFlags = 0, numValidMoveGroups = 0; + numMovesPerGroup = 0, numMultipleMoveGroups = 0; for (i = 0; i < MAX_MON_MOVES; i++) { - // validMoveFlags is used here as a bitfield for which moves can be used for each move group type - // first 4 bits are for attack (1 for each move), then 4 bits for defense, and 4 for support + // Count the number of usable moves the battler has in each move group. + // The totals will be stored separately in 3 groups of 4 bits each in numMovesPerGroup. if (GetBattlePalaceMoveGroup(moveInfo->moves[i]) == PALACE_MOVE_GROUP_ATTACK && !(gBitTable[i] & unusableMovesBits)) - validMoveFlags += (1 << 0); + numMovesPerGroup += (1 << 0); if (GetBattlePalaceMoveGroup(moveInfo->moves[i]) == PALACE_MOVE_GROUP_DEFENSE && !(gBitTable[i] & unusableMovesBits)) - validMoveFlags += (1 << 4); + numMovesPerGroup += (1 << 4); if (GetBattlePalaceMoveGroup(moveInfo->moves[i]) == PALACE_MOVE_GROUP_SUPPORT && !(gBitTable[i] & unusableMovesBits)) - validMoveFlags += (1 << 8); + numMovesPerGroup += (1 << 8); } - // Count the move groups the pokemon has - if ((validMoveFlags & 0xF) > 1) - numValidMoveGroups++; - if ((validMoveFlags & 0xF0) > 0x1F) - numValidMoveGroups++; - if ((validMoveFlags & 0xF0) > 0x1FF) - numValidMoveGroups++; - - - // If more than 1 possible move group, or no possible move groups - // then choose move randomly - if (numValidMoveGroups > 1 || numValidMoveGroups == 0) + // Count the number of move groups for which the battler has at least 2 usable moves. + // This is a roundabout way to determine if there is a move group that should be + // preferred, because it has multiple move options and the others do not. + // The condition intended to check the total for the Support group is accidentally + // checking the Defense total, and is never true. As a result the preferences for + // random move selection here will skew away from the Support move group. + if ((numMovesPerGroup & 0xF) >= 2) + numMultipleMoveGroups++; + if ((numMovesPerGroup & (0xF << 4)) >= (2 << 4)) + numMultipleMoveGroups++; +#ifdef BUGFIX + if ((numMovesPerGroup & (0xF << 8)) >= (2 << 8)) +#else + if ((numMovesPerGroup & (0xF << 4)) >= (2 << 8)) +#endif + numMultipleMoveGroups++; + + + // By this point we already know the battler only has usable moves from at most 2 of the 3 move groups, + // because they had no usable moves from the move group that was selected based on Nature. + // + // The below condition is effectively 'numMultipleMoveGroups != 1'. + // There is no stand-out group with multiple moves to choose from, so we pick randomly. + // Note that because of the bug above the battler may actually have any number of Support moves. + if (numMultipleMoveGroups > 1 || numMultipleMoveGroups == 0) { do { @@ -206,27 +219,36 @@ u16 ChooseMoveAndTargetInBattlePalace(void) chosenMoveId = i; } while (chosenMoveId == -1); } - // Otherwise randomly choose move of only available move group else { - if ((validMoveFlags & 0xF) > 1) - validMoveGroup = PALACE_MOVE_GROUP_ATTACK; - if ((validMoveFlags & 0xF0) > 0x1F) - validMoveGroup = PALACE_MOVE_GROUP_DEFENSE; - if ((validMoveFlags & 0xF0) > 0x1FF) - validMoveGroup = PALACE_MOVE_GROUP_SUPPORT; + // The battler has just 1 move group with multiple move options to choose from. + // Choose a move randomly from this group. + + // Same bug as the previous set of conditions (the condition for Support is never true). + // This bug won't cause a softlock below, because if Support is the only group with multiple + // moves then it won't have been counted, and the 'numMultipleMoveGroups == 0' above will be true. + if ((numMovesPerGroup & 0xF) >= 2) + randSelectGroup = PALACE_MOVE_GROUP_ATTACK; + if ((numMovesPerGroup & (0xF << 4)) >= (2 << 4)) + randSelectGroup = PALACE_MOVE_GROUP_DEFENSE; +#ifdef BUGFIX + if ((numMovesPerGroup & (0xF << 8)) >= (2 << 8)) +#else + if ((numMovesPerGroup & (0xF << 4)) >= (2 << 8)) +#endif + randSelectGroup = PALACE_MOVE_GROUP_SUPPORT; do { i = Random() % MAX_MON_MOVES; - if (!(gBitTable[i] & unusableMovesBits) && validMoveGroup == GetBattlePalaceMoveGroup(moveInfo->moves[i])) + if (!(gBitTable[i] & unusableMovesBits) && randSelectGroup == GetBattlePalaceMoveGroup(moveInfo->moves[i])) chosenMoveId = i; } while (chosenMoveId == -1); } - // If a move was selected (and in this case was not from the Nature-chosen group) - // then there's a 50% chance it won't be used anyway - if (Random() % 100 > 49) + // Because the selected move was not from the Nature-chosen move group there's a 50% chance + // that it will be unable to use it. This could have been checked earlier to avoid the above work. + if (Random() % 100 >= 50) { gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE; return 0; @@ -234,6 +256,7 @@ u16 ChooseMoveAndTargetInBattlePalace(void) } else { + // All the battler's moves were flagged as unusable. gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE; return 0; } @@ -266,9 +289,9 @@ u16 ChooseMoveAndTargetInBattlePalace(void) #undef selectedGroup #undef selectedMoves #undef moveTarget -#undef validMoveFlags -#undef numValidMoveGroups -#undef validMoveGroup +#undef numMovesPerGroup +#undef numMultipleMoveGroups +#undef randSelectGroup static u8 GetBattlePalaceMoveGroup(u16 move) { diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index ab8e6ad8eda1..63569d60c4af 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -849,7 +849,7 @@ static const u8 sBallCatchBonuses[] = // In Battle Palace, moves are chosen based on the pokemons nature rather than by the player // Moves are grouped into "Attack", "Defense", or "Support" (see PALACE_MOVE_GROUP_*) // Each nature has a certain percent chance of selecting a move from a particular group -// and a separate percent chance for each group when below 50% HP +// and a separate percent chance for each group when at or below 50% HP // The table below doesn't list percentages for Support because you can subtract the other two // Support percentages are listed in comments off to the side instead #define PALACE_STYLE(atk, def, atkLow, defLow) {atk, atk + def, atkLow, atkLow + defLow} From bdc0ea1037ddeb5b9909078c11e9964aeadf4a55 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 16 Aug 2023 16:44:45 -0400 Subject: [PATCH 07/48] Add MOD to match mod with powers of 2 --- include/global.h | 6 ++++++ src/battle_controller_opponent.c | 2 +- src/battle_pyramid.c | 4 ++-- src/battle_script_commands.c | 4 ++-- src/battle_util.c | 11 ++++++----- src/contest_ai.c | 2 +- src/intro.c | 2 +- src/naming_screen.c | 4 ++-- 8 files changed, 21 insertions(+), 14 deletions(-) diff --git a/include/global.h b/include/global.h index e0cecafd077a..e6d58f36e0fe 100644 --- a/include/global.h +++ b/include/global.h @@ -85,6 +85,12 @@ #define SAFE_DIV(a, b) ((a) / (b)) #endif +// The below macro does a%n, but (to match) will switch to a&(n-1) if n is a power of 2. +// There are cases where GF does a&(n-1) where we would really like to have a%n, because +// if n is changed to a value that isn't a power of 2 then a&(n-1) is unlikely to work as +// intended, and a%n for powers of 2 isn't always optimized to use &. +#define MOD(a, n)(((n) & ((n)-1)) ? ((a) % (n)) : ((a) & ((n)-1))) + // Extracts the upper 16 bits of a 32-bit number #define HIHALF(n) (((n) & 0xFFFF0000) >> 16) diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c index 41afa9505f59..e434e3ee6237 100644 --- a/src/battle_controller_opponent.c +++ b/src/battle_controller_opponent.c @@ -1588,7 +1588,7 @@ static void OpponentHandleChooseMove(void) u16 move; do { - chosenMoveId = Random() & 3; + chosenMoveId = MOD(Random(), MAX_MON_MOVES); move = moveInfo->moves[chosenMoveId]; } while (move == MOVE_NONE); diff --git a/src/battle_pyramid.c b/src/battle_pyramid.c index a1f1ee542cb8..e51f804981b2 100644 --- a/src/battle_pyramid.c +++ b/src/battle_pyramid.c @@ -38,7 +38,7 @@ #include "constants/moves.h" #include "constants/trainers.h" -#define NUM_LAYOUT_OFFSETS 8 // Assumed to be a power of 2 +#define NUM_LAYOUT_OFFSETS 8 extern const struct MapLayout *const gMapLayouts[]; @@ -1904,7 +1904,7 @@ static void GetPyramidFloorLayoutOffsets(u8 *layoutOffsets) for (i = 0; i < NUM_PYRAMID_FLOOR_SQUARES; i++) { - layoutOffsets[i] = sPyramidFloorTemplates[id].layoutOffsets[rand & (NUM_LAYOUT_OFFSETS - 1)]; + layoutOffsets[i] = sPyramidFloorTemplates[id].layoutOffsets[MOD(rand, NUM_LAYOUT_OFFSETS)]; rand >>= 3; if (i == 7) { diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 63569d60c4af..60a91e2b4858 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -7350,7 +7350,7 @@ static void Cmd_tryconversiontypechange(void) { do { - while ((moveChecked = Random() & (MAX_MON_MOVES - 1)) >= validMoves); + while ((moveChecked = MOD(Random(), MAX_MON_MOVES)) >= validMoves); moveType = gBattleMoves[gBattleMons[gBattlerAttacker].moves[moveChecked]].type; @@ -8189,7 +8189,7 @@ static void Cmd_trychoosesleeptalkmove(void) do { - movePosition = Random() & (MAX_MON_MOVES - 1); + movePosition = MOD(Random(), MAX_MON_MOVES); } while ((gBitTable[movePosition] & unusableMovesBits)); gCalledMove = gBattleMons[gBattlerAttacker].moves[movePosition]; diff --git a/src/battle_util.c b/src/battle_util.c index 6a0137a93865..0856b6d8566f 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -2773,11 +2773,12 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA { do { + // Pick either MOVE_EFFECT_SLEEP, MOVE_EFFECT_POISON or MOVE_EFFECT_BURN gBattleCommunication[MOVE_EFFECT_BYTE] = Random() & 3; } while (gBattleCommunication[MOVE_EFFECT_BYTE] == 0); - + // Replace MOVE_EFFECT_BURN with MOVE_EFFECT_PARALYSIS if (gBattleCommunication[MOVE_EFFECT_BYTE] == MOVE_EFFECT_BURN) - gBattleCommunication[MOVE_EFFECT_BYTE] += 2; // 5 MOVE_EFFECT_PARALYSIS + gBattleCommunication[MOVE_EFFECT_BYTE] += (MOVE_EFFECT_PARALYSIS - MOVE_EFFECT_BURN); gBattleCommunication[MOVE_EFFECT_BYTE] += MOVE_EFFECT_AFFECTS_USER; BattleScriptPushCursor(); @@ -3956,7 +3957,7 @@ u8 IsMonDisobedient(void) { // Randomly select, then print a disobedient string // B_MSG_LOAFING, B_MSG_WONT_OBEY, B_MSG_TURNED_AWAY, or B_MSG_PRETEND_NOT_NOTICE - gBattleCommunication[MULTISTRING_CHOOSER] = Random() & (NUM_LOAF_STRINGS - 1); + gBattleCommunication[MULTISTRING_CHOOSER] = MOD(Random(), NUM_LOAF_STRINGS); gBattlescriptCurrInstr = BattleScript_MoveUsedLoafingAround; return 1; } @@ -3964,7 +3965,7 @@ u8 IsMonDisobedient(void) { do { - gCurrMovePos = gChosenMovePos = Random() & (MAX_MON_MOVES - 1); + gCurrMovePos = gChosenMovePos = MOD(Random(), MAX_MON_MOVES); } while (gBitTable[gCurrMovePos] & calc); gCalledMove = gBattleMons[gBattlerAttacker].moves[gCurrMovePos]; @@ -4007,7 +4008,7 @@ u8 IsMonDisobedient(void) { // Randomly select, then print a disobedient string // B_MSG_LOAFING, B_MSG_WONT_OBEY, B_MSG_TURNED_AWAY, or B_MSG_PRETEND_NOT_NOTICE - gBattleCommunication[MULTISTRING_CHOOSER] = Random() & (NUM_LOAF_STRINGS - 1); + gBattleCommunication[MULTISTRING_CHOOSER] = MOD(Random(), NUM_LOAF_STRINGS); gBattlescriptCurrInstr = BattleScript_MoveUsedLoafingAround; return 1; } diff --git a/src/contest_ai.c b/src/contest_ai.c index 8753ed170dca..a4bb5b454904 100644 --- a/src/contest_ai.c +++ b/src/contest_ai.c @@ -326,7 +326,7 @@ u8 ContestAI_GetActionToUse(void) { // Randomly choose a move index. If it's the move // with the highest (or tied highest) score, return - u8 moveIdx = Random() & (MAX_MON_MOVES - 1); // % MAX_MON_MOVES doesn't match + u8 moveIdx = MOD(Random(), MAX_MON_MOVES); u8 score = eContestAI.moveScores[moveIdx]; int i; for (i = 0; i < MAX_MON_MOVES; i++) diff --git a/src/intro.c b/src/intro.c index e5e6a23dd23c..6a6a58ddd5d4 100644 --- a/src/intro.c +++ b/src/intro.c @@ -1163,7 +1163,7 @@ void CB2_InitCopyrightScreenAfterTitleScreen(void) static void Task_Scene1_Load(u8 taskId) { SetVBlankCallback(NULL); - sIntroCharacterGender = Random() & 1; + sIntroCharacterGender = MOD(Random(), GENDER_COUNT); IntroResetGpuRegs(); SetGpuReg(REG_OFFSET_BG3VOFS, 0); SetGpuReg(REG_OFFSET_BG2VOFS, 80); diff --git a/src/naming_screen.c b/src/naming_screen.c index 6dd45aa7e1cd..6acb29ffbf84 100644 --- a/src/naming_screen.c +++ b/src/naming_screen.c @@ -1067,7 +1067,7 @@ static void SpriteCB_InputArrow(struct Sprite *sprite) if (sprite->sDelay == 0 || --sprite->sDelay == 0) { sprite->sDelay = 8; - sprite->sXPosId = (sprite->sXPosId + 1) & (ARRAY_COUNT(x) - 1); + sprite->sXPosId = MOD(sprite->sXPosId + 1, ARRAY_COUNT(x)); } sprite->x2 = x[sprite->sXPosId]; } @@ -1097,7 +1097,7 @@ static void SpriteCB_Underscore(struct Sprite *sprite) sprite->sDelay++; if (sprite->sDelay > 8) { - sprite->sYPosId = (sprite->sYPosId + 1) & (ARRAY_COUNT(y) - 1); + sprite->sYPosId = MOD(sprite->sYPosId + 1, ARRAY_COUNT(y)); sprite->sDelay = 0; } } From 63f39133ab9cfb2293f8a91272ea2fbaebe58b5a Mon Sep 17 00:00:00 2001 From: AnonymousRandomPerson Date: Fri, 18 Aug 2023 22:16:04 -0400 Subject: [PATCH 08/48] Added newer decomp projects to readme --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c23965485fe7..bca4fd10411a 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,14 @@ Other disassembly and/or decompilation projects: * [**Pokémon Pinball: Ruby & Sapphire**](https://github.com/pret/pokepinballrs) * [**Pokémon FireRed and LeafGreen**](https://github.com/pret/pokefirered) * [**Pokémon Mystery Dungeon: Red Rescue Team**](https://github.com/pret/pmd-red) - +* [**Pokémon Diamond and Pearl**](https://github.com/pret/pokediamond) +* [**Pokémon Platinum**](https://github.com/pret/pokeplatinum) +* [**Pokémon HeartGold and SoulSilver**](https://github.com/pret/pokeheartgold) +* [**Pokémon Mystery Dungeon: Explorers of Sky**](https://github.com/pret/pmd-sky) ## Contacts -You can find us on [Discord](https://discord.gg/d5dubZ3) and [IRC](https://web.libera.chat/?#pret). +You can find us on: + +* [Discord (PRET, #pokeemerald)](https://discord.gg/d5dubZ3) +* [IRC](https://web.libera.chat/?#pret) From 5beec06d9d0056e0168a10bd6a8252e9259a1399 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sat, 19 Aug 2023 17:20:53 -0400 Subject: [PATCH 09/48] Document Task_MapNamePopUpWindow --- src/map_name_popup.c | 97 ++++++++++++++++++++++++++++---------------- 1 file changed, 62 insertions(+), 35 deletions(-) diff --git a/src/map_name_popup.c b/src/map_name_popup.c index 93a282583372..7e5fbc909587 100644 --- a/src/map_name_popup.c +++ b/src/map_name_popup.c @@ -206,22 +206,45 @@ static bool8 StartMenu_ShowMapNamePopup(void) return TRUE; } +// States and data defines for Task_MapNamePopUpWindow +enum { + STATE_SLIDE_IN, + STATE_WAIT, + STATE_SLIDE_OUT, + STATE_UNUSED, + STATE_ERASE, + STATE_END, + STATE_PRINT, // For some reason the first state is numerically last. +}; + +#define POPUP_OFFSCREEN_Y 40 +#define POPUP_SLIDE_SPEED 2 + +#define tState data[0] +#define tOnscreenTimer data[1] +#define tYOffset data[2] +#define tIncomingPopUp data[3] +#define tPrintTimer data[4] + void ShowMapNamePopup(void) { if (FlagGet(FLAG_HIDE_MAP_NAME_POPUP) != TRUE) { if (!FuncIsActiveTask(Task_MapNamePopUpWindow)) { + // New pop up window sPopupTaskId = CreateTask(Task_MapNamePopUpWindow, 90); - SetGpuReg(REG_OFFSET_BG0VOFS, 40); - gTasks[sPopupTaskId].data[0] = 6; - gTasks[sPopupTaskId].data[2] = 40; + SetGpuReg(REG_OFFSET_BG0VOFS, POPUP_OFFSCREEN_Y); + gTasks[sPopupTaskId].tState = STATE_PRINT; + gTasks[sPopupTaskId].tYOffset = POPUP_OFFSCREEN_Y; } else { - if (gTasks[sPopupTaskId].data[0] != 2) - gTasks[sPopupTaskId].data[0] = 2; - gTasks[sPopupTaskId].data[3] = 1; + // There's already a pop up window running. + // Hurry the old pop up offscreen so the new one can appear. + if (gTasks[sPopupTaskId].tState != STATE_SLIDE_OUT) + gTasks[sPopupTaskId].tState = STATE_SLIDE_OUT; + gTasks[sPopupTaskId].tIncomingPopUp = TRUE; } } } @@ -230,61 +253,65 @@ static void Task_MapNamePopUpWindow(u8 taskId) { struct Task *task = &gTasks[taskId]; - switch (task->data[0]) + switch (task->tState) { - case 6: - task->data[4]++; - if (task->data[4] > 30) + case STATE_PRINT: + // Wait, then create and print the pop up window + if (++task->tPrintTimer > 30) { - task->data[0] = 0; - task->data[4] = 0; + task->tState = STATE_SLIDE_IN; + task->tPrintTimer = 0; ShowMapNamePopUpWindow(); } break; - case 0: - task->data[2] -= 2; - if (task->data[2] <= 0 ) + case STATE_SLIDE_IN: + // Slide the window onscreen. + task->tYOffset -= POPUP_SLIDE_SPEED; + if (task->tYOffset <= 0 ) { - task->data[2] = 0; - task->data[0] = 1; + task->tYOffset = 0; + task->tState = STATE_WAIT; gTasks[sPopupTaskId].data[1] = 0; } break; - case 1: - task->data[1]++; - if (task->data[1] > 120 ) + case STATE_WAIT: + // Wait while the window is fully onscreen. + if (++task->tOnscreenTimer > 120) { - task->data[1] = 0; - task->data[0] = 2; + task->tOnscreenTimer = 0; + task->tState = STATE_SLIDE_OUT; } break; - case 2: - task->data[2] += 2; - if (task->data[2] > 39) + case STATE_SLIDE_OUT: + // Slide the window offscreen. + task->tYOffset += POPUP_SLIDE_SPEED; + if (task->tYOffset >= POPUP_OFFSCREEN_Y) { - task->data[2] = 40; - if (task->data[3]) + task->tYOffset = POPUP_OFFSCREEN_Y; + if (task->tIncomingPopUp) { - task->data[0] = 6; - task->data[4] = 0; - task->data[3] = 0; + // A new pop up window is incoming, + // return to the first state to show it. + task->tState = STATE_PRINT; + task->tPrintTimer = 0; + task->tIncomingPopUp = FALSE; } else { - task->data[0] = 4; + task->tState = STATE_ERASE; return; } } break; - case 4: + case STATE_ERASE: ClearStdWindowAndFrame(GetMapNamePopUpWindowId(), TRUE); - task->data[0] = 5; + task->tState = STATE_END; break; - case 5: + case STATE_END: HideMapNamePopUpWindow(); return; } - SetGpuReg(REG_OFFSET_BG0VOFS, task->data[2]); + SetGpuReg(REG_OFFSET_BG0VOFS, task->tYOffset); } void HideMapNamePopUpWindow(void) From 6792028254dfb39111ea30f499ee27cefbc77d29 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sun, 20 Aug 2023 01:18:44 -0400 Subject: [PATCH 10/48] Document title screen task data --- src/title_screen.c | 258 +++++++++++++++++++++++++++------------------ 1 file changed, 155 insertions(+), 103 deletions(-) diff --git a/src/title_screen.c b/src/title_screen.c index 87bf0d970ea5..12015b8bd8aa 100644 --- a/src/title_screen.c +++ b/src/title_screen.c @@ -23,6 +23,12 @@ #include "constants/rgb.h" #include "constants/songs.h" +enum { + TAG_VERSION = 1000, + TAG_PRESS_START_COPYRIGHT, + TAG_LOGO_SHINE, +}; + #define VERSION_BANNER_RIGHT_TILEOFFSET 64 #define VERSION_BANNER_LEFT_X 98 #define VERSION_BANNER_RIGHT_X 162 @@ -158,8 +164,8 @@ static const union AnimCmd *const sVersionBannerRightAnimTable[] = static const struct SpriteTemplate sVersionBannerLeftSpriteTemplate = { - .tileTag = 1000, - .paletteTag = 1000, + .tileTag = TAG_VERSION, + .paletteTag = TAG_VERSION, .oam = &sVersionBannerLeftOamData, .anims = sVersionBannerLeftAnimTable, .images = NULL, @@ -169,8 +175,8 @@ static const struct SpriteTemplate sVersionBannerLeftSpriteTemplate = static const struct SpriteTemplate sVersionBannerRightSpriteTemplate = { - .tileTag = 1000, - .paletteTag = 1000, + .tileTag = TAG_VERSION, + .paletteTag = TAG_VERSION, .oam = &sVersionBannerRightOamData, .anims = sVersionBannerRightAnimTable, .images = NULL, @@ -183,7 +189,7 @@ static const struct CompressedSpriteSheet sSpriteSheet_EmeraldVersion[] = { .data = gTitleScreenEmeraldVersionGfx, .size = 0x1000, - .tag = 1000 + .tag = TAG_VERSION }, {}, }; @@ -205,75 +211,80 @@ static const struct OamData sOamData_CopyrightBanner = .affineParam = 0, }; -static const union AnimCmd sCopyrightBannerAnim0[] = +static const union AnimCmd sAnim_PressStart_0[] = { ANIMCMD_FRAME(1, 4), ANIMCMD_END, }; -static const union AnimCmd sCopyrightBannerAnim1[] = +static const union AnimCmd sAnim_PressStart_1[] = { ANIMCMD_FRAME(5, 4), ANIMCMD_END, }; -static const union AnimCmd sCopyrightBannerAnim2[] = +static const union AnimCmd sAnim_PressStart_2[] = { ANIMCMD_FRAME(9, 4), ANIMCMD_END, }; -static const union AnimCmd sCopyrightBannerAnim3[] = +static const union AnimCmd sAnim_PressStart_3[] = { ANIMCMD_FRAME(13, 4), ANIMCMD_END, }; -static const union AnimCmd sCopyrightBannerAnim4[] = +static const union AnimCmd sAnim_PressStart_4[] = { ANIMCMD_FRAME(17, 4), ANIMCMD_END, }; -static const union AnimCmd sCopyrightBannerAnim5[] = +static const union AnimCmd sAnim_Copyright_0[] = { ANIMCMD_FRAME(21, 4), ANIMCMD_END, }; -static const union AnimCmd sCopyrightBannerAnim6[] = +static const union AnimCmd sAnim_Copyright_1[] = { ANIMCMD_FRAME(25, 4), ANIMCMD_END, }; -static const union AnimCmd sCopyrightBannerAnim7[] = +static const union AnimCmd sAnim_Copyright_2[] = { ANIMCMD_FRAME(29, 4), ANIMCMD_END, }; -static const union AnimCmd sCopyrightBannerAnim8[] = +static const union AnimCmd sAnim_Copyright_3[] = { ANIMCMD_FRAME(33, 4), ANIMCMD_END, }; -static const union AnimCmd sCopyrightBannerAnim9[] = +static const union AnimCmd sAnim_Copyright_4[] = { ANIMCMD_FRAME(37, 4), ANIMCMD_END, }; -static const union AnimCmd *const sStartCopyrightBannerAnimTable[] = -{ - sCopyrightBannerAnim0, - sCopyrightBannerAnim1, - sCopyrightBannerAnim2, - sCopyrightBannerAnim3, - sCopyrightBannerAnim4, - sCopyrightBannerAnim5, - sCopyrightBannerAnim6, - sCopyrightBannerAnim7, - sCopyrightBannerAnim8, - sCopyrightBannerAnim9, +// The "Press Start" and copyright graphics are each 5 32x8 segments long +#define NUM_PRESS_START_FRAMES 5 +#define NUM_COPYRIGHT_FRAMES 5 + +static const union AnimCmd *const sStartCopyrightBannerAnimTable[NUM_PRESS_START_FRAMES + NUM_COPYRIGHT_FRAMES] = +{ + sAnim_PressStart_0, + sAnim_PressStart_1, + sAnim_PressStart_2, + sAnim_PressStart_3, + sAnim_PressStart_4, + [NUM_PRESS_START_FRAMES] = + sAnim_Copyright_0, + sAnim_Copyright_1, + sAnim_Copyright_2, + sAnim_Copyright_3, + sAnim_Copyright_4, }; static const struct SpriteTemplate sStartCopyrightBannerSpriteTemplate = { - .tileTag = 1001, - .paletteTag = 1001, + .tileTag = TAG_PRESS_START_COPYRIGHT, + .paletteTag = TAG_PRESS_START_COPYRIGHT, .oam = &sOamData_CopyrightBanner, .anims = sStartCopyrightBannerAnimTable, .images = NULL, @@ -286,7 +297,7 @@ static const struct CompressedSpriteSheet sSpriteSheet_PressStart[] = { .data = gTitleScreenPressStartGfx, .size = 0x520, - .tag = 1001 + .tag = TAG_PRESS_START_COPYRIGHT }, {}, }; @@ -295,7 +306,7 @@ static const struct SpritePalette sSpritePalette_PressStart[] = { { .data = gTitleScreenPressStartPal, - .tag = 1001 + .tag = TAG_PRESS_START_COPYRIGHT }, {}, }; @@ -330,8 +341,8 @@ static const union AnimCmd *const sPokemonLogoShineAnimTable[] = static const struct SpriteTemplate sPokemonLogoShineSpriteTemplate = { - .tileTag = 1002, - .paletteTag = 1001, + .tileTag = TAG_LOGO_SHINE, + .paletteTag = TAG_PRESS_START_COPYRIGHT, .oam = &sPokemonLogoShineOamData, .anims = sPokemonLogoShineAnimTable, .images = NULL, @@ -344,15 +355,25 @@ static const struct CompressedSpriteSheet sPokemonLogoShineSpriteSheet[] = { .data = sTitleScreenLogoShineGfx, .size = 0x800, - .tag = 1002 + .tag = TAG_LOGO_SHINE }, {}, }; -// code +// Task data for the main title screen tasks (Task_TitleScreenPhase#) +#define tCounter data[0] +#define tSkipToNext data[1] +#define tPointless data[2] // Incremented but never used to do anything. +#define tBg2Y data[3] +#define tBg1Y data[4] + +// Sprite data for sVersionBannerLeftSpriteTemplate / sVersionBannerRightSpriteTemplate +#define sAlphaBlendIdx data[0] +#define sParentTaskId data[1] + static void SpriteCB_VersionBannerLeft(struct Sprite *sprite) { - if (gTasks[sprite->data[1]].data[1] != 0) + if (gTasks[sprite->sParentTaskId].tSkipToNext) { sprite->oam.objMode = ST_OAM_OBJ_NORMAL; sprite->y = VERSION_BANNER_Y_GOAL; @@ -361,15 +382,15 @@ static void SpriteCB_VersionBannerLeft(struct Sprite *sprite) { if (sprite->y != VERSION_BANNER_Y_GOAL) sprite->y++; - if (sprite->data[0] != 0) - sprite->data[0]--; - SetGpuReg(REG_OFFSET_BLDALPHA, gTitleScreenAlphaBlend[sprite->data[0]]); + if (sprite->sAlphaBlendIdx != 0) + sprite->sAlphaBlendIdx--; + SetGpuReg(REG_OFFSET_BLDALPHA, gTitleScreenAlphaBlend[sprite->sAlphaBlendIdx]); } } static void SpriteCB_VersionBannerRight(struct Sprite *sprite) { - if (gTasks[sprite->data[1]].data[1] != 0) + if (gTasks[sprite->sParentTaskId].tSkipToNext) { sprite->oam.objMode = ST_OAM_OBJ_NORMAL; sprite->y = VERSION_BANNER_Y_GOAL; @@ -381,13 +402,16 @@ static void SpriteCB_VersionBannerRight(struct Sprite *sprite) } } +// Sprite data for SpriteCB_PressStartCopyrightBanner +#define sAnimate data[0] +#define sTimer data[1] + static void SpriteCB_PressStartCopyrightBanner(struct Sprite *sprite) { - if (sprite->data[0] == 1) + if (sprite->sAnimate == TRUE) { - sprite->data[1]++; // Alternate between hidden and shown every 16th frame - if (sprite->data[1] & 16) + if (++sprite->sTimer & 16) sprite->invisible = FALSE; else sprite->invisible = TRUE; @@ -404,11 +428,11 @@ static void CreatePressStartBanner(s16 x, s16 y) u8 spriteId; x -= 64; - for (i = 0; i < 5; i++, x += 32) + for (i = 0; i < NUM_PRESS_START_FRAMES; i++, x += 32) { spriteId = CreateSprite(&sStartCopyrightBannerSpriteTemplate, x, y, 0); StartSpriteAnim(&gSprites[spriteId], i); - gSprites[spriteId].data[0] = 1; + gSprites[spriteId].sAnimate = TRUE; } } @@ -418,93 +442,122 @@ static void CreateCopyrightBanner(s16 x, s16 y) u8 spriteId; x -= 64; - for (i = 0; i < 5; i++, x += 32) + for (i = 0; i < NUM_COPYRIGHT_FRAMES; i++, x += 32) { spriteId = CreateSprite(&sStartCopyrightBannerSpriteTemplate, x, y, 0); - StartSpriteAnim(&gSprites[spriteId], i + 5); + StartSpriteAnim(&gSprites[spriteId], i + NUM_PRESS_START_FRAMES); } } +#undef sAnimate +#undef sTimer + +// Defines for SpriteCB_PokemonLogoShine +enum { + SHINE_MODE_SINGLE_NO_BG_COLOR, + SHINE_MODE_DOUBLE, + SHINE_MODE_SINGLE, +}; + +#define SHINE_SPEED 4 + +#define sMode data[0] +#define sBgColor data[1] + static void SpriteCB_PokemonLogoShine(struct Sprite *sprite) { if (sprite->x < DISPLAY_WIDTH + 32) { - if (sprite->data[0]) // Flash background + // In any mode except SHINE_MODE_SINGLE_NO_BG_COLOR the background + // color will change, in addition to the shine sprite moving. + if (sprite->sMode != SHINE_MODE_SINGLE_NO_BG_COLOR) { u16 backgroundColor; if (sprite->x < DISPLAY_WIDTH / 2) { // Brighten background color - if (sprite->data[1] < 31) - sprite->data[1]++; - if (sprite->data[1] < 31) - sprite->data[1]++; + if (sprite->sBgColor < 31) + sprite->sBgColor++; + if (sprite->sBgColor < 31) + sprite->sBgColor++; } else { // Darken background color - if (sprite->data[1] != 0) - sprite->data[1]--; - if (sprite->data[1] != 0) - sprite->data[1]--; + if (sprite->sBgColor != 0) + sprite->sBgColor--; + if (sprite->sBgColor != 0) + sprite->sBgColor--; } - backgroundColor = _RGB(sprite->data[1], sprite->data[1], sprite->data[1]); - if (sprite->x == DISPLAY_WIDTH / 2 + 12 - || sprite->x == DISPLAY_WIDTH / 2 + 16 - || sprite->x == DISPLAY_WIDTH / 2 + 20 - || sprite->x == DISPLAY_WIDTH / 2 + 24) + backgroundColor = _RGB(sprite->sBgColor, sprite->sBgColor, sprite->sBgColor); + + // Flash the background green for 4 frames of movement. + // Otherwise use the updating color. + if (sprite->x == DISPLAY_WIDTH / 2 + (3 * SHINE_SPEED) + || sprite->x == DISPLAY_WIDTH / 2 + (4 * SHINE_SPEED) + || sprite->x == DISPLAY_WIDTH / 2 + (5 * SHINE_SPEED) + || sprite->x == DISPLAY_WIDTH / 2 + (6 * SHINE_SPEED)) gPlttBufferFaded[0] = RGB(24, 31, 12); else gPlttBufferFaded[0] = backgroundColor; } - sprite->x += 4; + + sprite->x += SHINE_SPEED; } else { + // Sprite has moved fully offscreen gPlttBufferFaded[0] = RGB_BLACK; DestroySprite(sprite); } } -static void SpriteCB_PokemonLogoShine2(struct Sprite *sprite) +static void SpriteCB_PokemonLogoShine_Fast(struct Sprite *sprite) { if (sprite->x < DISPLAY_WIDTH + 32) - sprite->x += 8; + sprite->x += SHINE_SPEED * 2; else DestroySprite(sprite); } -static void StartPokemonLogoShine(u8 flashBg) +static void StartPokemonLogoShine(u8 mode) { u8 spriteId; - switch (flashBg) + switch (mode) { - case 0: - case 2: + case SHINE_MODE_SINGLE_NO_BG_COLOR: + case SHINE_MODE_SINGLE: + // Create one regular shine sprite. + // If mode is SHINE_MODE_SINGLE it will also change the background color. spriteId = CreateSprite(&sPokemonLogoShineSpriteTemplate, 0, 68, 0); gSprites[spriteId].oam.objMode = ST_OAM_OBJ_WINDOW; - gSprites[spriteId].data[0] = flashBg; + gSprites[spriteId].sMode = mode; break; - case 1: + case SHINE_MODE_DOUBLE: + // Create an invisible sprite with mode set to update the background color spriteId = CreateSprite(&sPokemonLogoShineSpriteTemplate, 0, 68, 0); gSprites[spriteId].oam.objMode = ST_OAM_OBJ_WINDOW; - gSprites[spriteId].data[0] = flashBg; + gSprites[spriteId].sMode = mode; gSprites[spriteId].invisible = TRUE; + // Create two faster shine sprites spriteId = CreateSprite(&sPokemonLogoShineSpriteTemplate, 0, 68, 0); - gSprites[spriteId].callback = SpriteCB_PokemonLogoShine2; + gSprites[spriteId].callback = SpriteCB_PokemonLogoShine_Fast; gSprites[spriteId].oam.objMode = ST_OAM_OBJ_WINDOW; spriteId = CreateSprite(&sPokemonLogoShineSpriteTemplate, -80, 68, 0); - gSprites[spriteId].callback = SpriteCB_PokemonLogoShine2; + gSprites[spriteId].callback = SpriteCB_PokemonLogoShine_Fast; gSprites[spriteId].oam.objMode = ST_OAM_OBJ_WINDOW; break; } } +#undef sMode +#undef sBgColor + static void VBlankCB(void) { ScanlineEffect_InitHBlankDmaTransfer(); @@ -514,9 +567,6 @@ static void VBlankCB(void) SetGpuReg(REG_OFFSET_BG1VOFS, gBattle_BG1_Y); } -#define tCounter data[0] -#define tSkipToNext data[1] - void CB2_InitTitleScreen(void) { switch (gMain.state) @@ -573,13 +623,13 @@ void CB2_InitTitleScreen(void) gTasks[taskId].tCounter = 256; gTasks[taskId].tSkipToNext = FALSE; - gTasks[taskId].data[2] = -16; - gTasks[taskId].data[3] = -32; + gTasks[taskId].tPointless = -16; + gTasks[taskId].tBg2Y = -32; gMain.state = 3; break; } case 3: - BeginNormalPaletteFade(PALETTES_ALL, 1, 0x10, 0, RGB_WHITEALPHA); + BeginNormalPaletteFade(PALETTES_ALL, 1, 16, 0, RGB_WHITEALPHA); SetVBlankCallback(VBlankCB); gMain.state = 4; break; @@ -614,7 +664,7 @@ void CB2_InitTitleScreen(void) case 5: if (!UpdatePaletteFade()) { - StartPokemonLogoShine(0); + StartPokemonLogoShine(SHINE_MODE_SINGLE_NO_BG_COLOR); ScanlineEffect_InitWave(0, DISPLAY_HEIGHT, 4, 4, 0, SCANLINE_EFFECT_REG_BG1HOFS, TRUE); SetMainCallback2(MainCB2); } @@ -634,7 +684,7 @@ static void MainCB2(void) static void Task_TitleScreenPhase1(u8 taskId) { // Skip to next phase when A, B, Start, or Select is pressed - if (JOY_NEW(A_B_START_SELECT) || gTasks[taskId].data[1] != 0) + if (JOY_NEW(A_B_START_SELECT) || gTasks[taskId].tSkipToNext) { gTasks[taskId].tSkipToNext = TRUE; gTasks[taskId].tCounter = 0; @@ -644,9 +694,9 @@ static void Task_TitleScreenPhase1(u8 taskId) { u16 frameNum = gTasks[taskId].tCounter; if (frameNum == 176) - StartPokemonLogoShine(1); + StartPokemonLogoShine(SHINE_MODE_DOUBLE); else if (frameNum == 64) - StartPokemonLogoShine(2); + StartPokemonLogoShine(SHINE_MODE_SINGLE); gTasks[taskId].tCounter--; } @@ -663,18 +713,21 @@ static void Task_TitleScreenPhase1(u8 taskId) // Create left side of version banner spriteId = CreateSprite(&sVersionBannerLeftSpriteTemplate, VERSION_BANNER_LEFT_X, VERSION_BANNER_Y, 0); - gSprites[spriteId].data[0] = 64; - gSprites[spriteId].data[1] = taskId; + gSprites[spriteId].sAlphaBlendIdx = ARRAY_COUNT(gTitleScreenAlphaBlend); + gSprites[spriteId].sParentTaskId = taskId; // Create right side of version banner spriteId = CreateSprite(&sVersionBannerRightSpriteTemplate, VERSION_BANNER_RIGHT_X, VERSION_BANNER_Y, 0); - gSprites[spriteId].data[1] = taskId; + gSprites[spriteId].sParentTaskId = taskId; gTasks[taskId].tCounter = 144; gTasks[taskId].func = Task_TitleScreenPhase2; } } +#undef sParentTaskId +#undef sAlphaBlendIdx + // Create "Press Start" and copyright banners, and slide Pokemon logo up static void Task_TitleScreenPhase2(u8 taskId) { @@ -705,31 +758,31 @@ static void Task_TitleScreenPhase2(u8 taskId) | DISPCNT_OBJ_ON); CreatePressStartBanner(START_BANNER_X, 108); CreateCopyrightBanner(START_BANNER_X, 148); - gTasks[taskId].data[4] = 0; + gTasks[taskId].tBg1Y = 0; gTasks[taskId].func = Task_TitleScreenPhase3; } - if (!(gTasks[taskId].tCounter & 3) && gTasks[taskId].data[2] != 0) - gTasks[taskId].data[2]++; - if (!(gTasks[taskId].tCounter & 1) && gTasks[taskId].data[3] != 0) - gTasks[taskId].data[3]++; + if (!(gTasks[taskId].tCounter & 3) && gTasks[taskId].tPointless != 0) + gTasks[taskId].tPointless++; + if (!(gTasks[taskId].tCounter & 1) && gTasks[taskId].tBg2Y != 0) + gTasks[taskId].tBg2Y++; // Slide Pokemon logo up - yPos = gTasks[taskId].data[3] * 256; + yPos = gTasks[taskId].tBg2Y * 256; SetGpuReg(REG_OFFSET_BG2Y_L, yPos); SetGpuReg(REG_OFFSET_BG2Y_H, yPos / 0x10000); - gTasks[taskId].data[5] = 15; - gTasks[taskId].data[6] = 6; + gTasks[taskId].data[5] = 15; // Unused + gTasks[taskId].data[6] = 6; // Unused } // Show Rayquaza silhouette and process main title screen input static void Task_TitleScreenPhase3(u8 taskId) { - if ((JOY_NEW(A_BUTTON)) || (JOY_NEW(START_BUTTON))) + if (JOY_NEW(A_BUTTON) || JOY_NEW(START_BUTTON)) { FadeOutBGM(4); - BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 0x10, RGB_WHITEALPHA); + BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_WHITEALPHA); SetMainCallback2(CB2_GoToMainMenu); } else if (JOY_HELD(CLEAR_SAVE_BUTTON_COMBO) == CLEAR_SAVE_BUTTON_COMBO) @@ -740,30 +793,29 @@ static void Task_TitleScreenPhase3(u8 taskId) && CanResetRTC() == TRUE) { FadeOutBGM(4); - BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 0x10, RGB_BLACK); + BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK); SetMainCallback2(CB2_GoToResetRtcScreen); } else if (JOY_HELD(BERRY_UPDATE_BUTTON_COMBO) == BERRY_UPDATE_BUTTON_COMBO) { FadeOutBGM(4); - BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 0x10, RGB_BLACK); + BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK); SetMainCallback2(CB2_GoToBerryFixScreen); } else { SetGpuReg(REG_OFFSET_BG2Y_L, 0); SetGpuReg(REG_OFFSET_BG2Y_H, 0); - gTasks[taskId].tCounter++; - if (gTasks[taskId].tCounter & 1) + if (++gTasks[taskId].tCounter & 1) { - gTasks[taskId].data[4]++; - gBattle_BG1_Y = gTasks[taskId].data[4] / 2; + gTasks[taskId].tBg1Y++; + gBattle_BG1_Y = gTasks[taskId].tBg1Y / 2; gBattle_BG1_X = 0; } UpdateLegendaryMarkingColor(gTasks[taskId].tCounter); if ((gMPlayInfo_BGM.status & 0xFFFF) == 0) { - BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 0x10, RGB_WHITEALPHA); + BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_WHITEALPHA); SetMainCallback2(CB2_GoToCopyrightScreen); } } From e70577d59badd1257571123d2faf51d9b84d75f5 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sun, 20 Aug 2023 17:22:29 -0400 Subject: [PATCH 11/48] Add missing sizeof in trainer_see --- src/trainer_see.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/trainer_see.c b/src/trainer_see.c index 97c2bc95e759..dd4acc7f36b1 100644 --- a/src/trainer_see.c +++ b/src/trainer_see.c @@ -131,11 +131,11 @@ static const struct SpriteFrameImage sSpriteImageTable_ExclamationQuestionMark[] { { .data = sEmotion_ExclamationMarkGfx, - .size = 0x80 + .size = sizeof(sEmotion_ExclamationMarkGfx) }, { .data = sEmotion_QuestionMarkGfx, - .size = 0x80 + .size = sizeof(sEmotion_QuestionMarkGfx) } }; @@ -143,7 +143,7 @@ static const struct SpriteFrameImage sSpriteImageTable_HeartIcon[] = { { .data = sEmotion_HeartGfx, - .size = 0x80 + .size = sizeof(sEmotion_HeartGfx) } }; From 56ff4ce998225b7ff0f99db466022e29f8097aba Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sun, 20 Aug 2023 01:35:51 -0400 Subject: [PATCH 12/48] Add defines for field effect sprite data, misc task data --- src/field_effect_helpers.c | 686 +++++++++++++++++++------------------ src/use_pokeblock.c | 37 +- 2 files changed, 369 insertions(+), 354 deletions(-) diff --git a/src/field_effect_helpers.c b/src/field_effect_helpers.c index 9421aaf27aca..237e543deec2 100755 --- a/src/field_effect_helpers.c +++ b/src/field_effect_helpers.c @@ -32,8 +32,12 @@ static void UpdateBobbingEffect(struct ObjectEvent *, struct Sprite *, struct Sp static void SpriteCB_UnderwaterSurfBlob(struct Sprite *); static u32 ShowDisguiseFieldEffect(u8, u8, u8); -// Used by several field effects to determine which of a group it is -#define sFldEff data[1] +// Data used by all the field effects that share UpdateJumpImpactEffect +#define sJumpElevation data[0] +#define sJumpFldEff data[1] + +// Data used by all the field effects that share WaitFieldEffectSpriteAnim +#define sWaitFldEff data[0] #define sReflectionObjEventId data[0] #define sReflectionObjEventLocalId data[1] @@ -44,7 +48,7 @@ void SetUpReflection(struct ObjectEvent *objectEvent, struct Sprite *sprite, boo { struct Sprite *reflectionSprite; - reflectionSprite = &gSprites[CreateCopySpriteAt(sprite, sprite->x, sprite->y, 0x98)]; + reflectionSprite = &gSprites[CreateCopySpriteAt(sprite, sprite->x, sprite->y, 152)]; reflectionSprite->callback = UpdateObjectReflectionSprite; reflectionSprite->oam.priority = 3; reflectionSprite->oam.paletteNum = gReflectionEffectPaletteMap[reflectionSprite->oam.paletteNum]; @@ -92,9 +96,7 @@ static void LoadObjectReflectionPalette(struct ObjectEvent *objectEvent, struct static void LoadObjectRegularReflectionPalette(struct ObjectEvent *objectEvent, u8 paletteIndex) { - const struct ObjectEventGraphicsInfo *graphicsInfo; - - graphicsInfo = GetObjectEventGraphicsInfo(objectEvent->graphicsId); + const struct ObjectEventGraphicsInfo *graphicsInfo = GetObjectEventGraphicsInfo(objectEvent->graphicsId); if (graphicsInfo->reflectionPaletteTag != OBJ_EVENT_PAL_TAG_NONE) { if (graphicsInfo->paletteSlot == PALSLOT_PLAYER) @@ -111,9 +113,7 @@ static void LoadObjectRegularReflectionPalette(struct ObjectEvent *objectEvent, // This is so the sprite blends in with the dark water metatile underneath the bridge. static void LoadObjectHighBridgeReflectionPalette(struct ObjectEvent *objectEvent, u8 paletteNum) { - const struct ObjectEventGraphicsInfo *graphicsInfo; - - graphicsInfo = GetObjectEventGraphicsInfo(objectEvent->graphicsId); + const struct ObjectEventGraphicsInfo *graphicsInfo = GetObjectEventGraphicsInfo(objectEvent->graphicsId); if (graphicsInfo->reflectionPaletteTag != OBJ_EVENT_PAL_TAG_NONE) { PatchObjectPalette(graphicsInfo->reflectionPaletteTag, paletteNum); @@ -123,11 +123,8 @@ static void LoadObjectHighBridgeReflectionPalette(struct ObjectEvent *objectEven static void UpdateObjectReflectionSprite(struct Sprite *reflectionSprite) { - struct ObjectEvent *objectEvent; - struct Sprite *mainSprite; - - objectEvent = &gObjectEvents[reflectionSprite->sReflectionObjEventId]; - mainSprite = &gSprites[objectEvent->spriteId]; + struct ObjectEvent *objectEvent = &gObjectEvents[reflectionSprite->sReflectionObjEventId]; + struct Sprite *mainSprite = &gSprites[objectEvent->spriteId]; if (!objectEvent->active || !objectEvent->hasReflection || objectEvent->localId != reflectionSprite->sReflectionObjEventLocalId) { reflectionSprite->inUse = FALSE; @@ -172,15 +169,15 @@ static void UpdateObjectReflectionSprite(struct Sprite *reflectionSprite) extern const struct SpriteTemplate *const gFieldEffectObjectTemplatePointers[]; +#define sPrevX data[0] +#define sPrevY data[1] + u8 CreateWarpArrowSprite(void) { - u8 spriteId; - struct Sprite *sprite; - - spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_ARROW], 0, 0, 0x52); + u8 spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_ARROW], 0, 0, 82); if (spriteId != MAX_SPRITES) { - sprite = &gSprites[spriteId]; + struct Sprite *sprite = &gSprites[spriteId]; sprite->oam.priority = 1; sprite->coordOffsetEnabled = TRUE; sprite->invisible = TRUE; @@ -195,24 +192,24 @@ void SetSpriteInvisible(u8 spriteId) void ShowWarpArrowSprite(u8 spriteId, u8 direction, s16 x, s16 y) { - s16 x2; - s16 y2; - struct Sprite *sprite; - - sprite = &gSprites[spriteId]; - if (sprite->invisible || sprite->data[0] != x || sprite->data[1] != y) + struct Sprite *sprite = &gSprites[spriteId]; + if (sprite->invisible || sprite->sPrevX != x || sprite->sPrevY != y) { + s16 x2, y2; SetSpritePosToMapCoords(x, y, &x2, &y2); sprite = &gSprites[spriteId]; sprite->x = x2 + 8; sprite->y = y2 + 8; sprite->invisible = FALSE; - sprite->data[0] = x; - sprite->data[1] = y; + sprite->sPrevX = x; + sprite->sPrevY = y; StartSpriteAnim(sprite, direction - 1); } } +#undef sPrevX +#undef sPrevY + static const u8 sShadowEffectTemplateIds[] = { FLDEFFOBJ_SHADOW_S, FLDEFFOBJ_SHADOW_M, @@ -227,22 +224,24 @@ const u16 gShadowVerticalOffsets[] = { 16 }; +// Sprite data for FLDEFF_SHADOW +#define sLocalId data[0] +#define sMapNum data[1] +#define sMapGroup data[2] +#define sYOffset data[3] + u32 FldEff_Shadow(void) { - u8 objectEventId; - const struct ObjectEventGraphicsInfo *graphicsInfo; - u8 spriteId; - - objectEventId = GetObjectEventIdByLocalIdAndMap(gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); - graphicsInfo = GetObjectEventGraphicsInfo(gObjectEvents[objectEventId].graphicsId); - spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[sShadowEffectTemplateIds[graphicsInfo->shadowSize]], 0, 0, 0x94); + u8 objectEventId = GetObjectEventIdByLocalIdAndMap(gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); + const struct ObjectEventGraphicsInfo *graphicsInfo = GetObjectEventGraphicsInfo(gObjectEvents[objectEventId].graphicsId); + u8 spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[sShadowEffectTemplateIds[graphicsInfo->shadowSize]], 0, 0, 148); if (spriteId != MAX_SPRITES) { gSprites[spriteId].coordOffsetEnabled = TRUE; - gSprites[spriteId].data[0] = gFieldEffectArguments[0]; - gSprites[spriteId].data[1] = gFieldEffectArguments[1]; - gSprites[spriteId].data[2] = gFieldEffectArguments[2]; - gSprites[spriteId].data[3] = (graphicsInfo->height >> 1) - gShadowVerticalOffsets[graphicsInfo->shadowSize]; + gSprites[spriteId].sLocalId = gFieldEffectArguments[0]; + gSprites[spriteId].sMapNum = gFieldEffectArguments[1]; + gSprites[spriteId].sMapGroup = gFieldEffectArguments[2]; + gSprites[spriteId].sYOffset = (graphicsInfo->height >> 1) - gShadowVerticalOffsets[graphicsInfo->shadowSize]; } return 0; } @@ -250,20 +249,18 @@ u32 FldEff_Shadow(void) void UpdateShadowFieldEffect(struct Sprite *sprite) { u8 objectEventId; - struct ObjectEvent *objectEvent; - struct Sprite *linkedSprite; - if (TryGetObjectEventIdByLocalIdAndMap(sprite->data[0], sprite->data[1], sprite->data[2], &objectEventId)) + if (TryGetObjectEventIdByLocalIdAndMap(sprite->sLocalId, sprite->sMapNum, sprite->sMapGroup, &objectEventId)) { FieldEffectStop(sprite, FLDEFF_SHADOW); } else { - objectEvent = &gObjectEvents[objectEventId]; - linkedSprite = &gSprites[objectEvent->spriteId]; + struct ObjectEvent *objectEvent = &gObjectEvents[objectEventId]; + struct Sprite *linkedSprite = &gSprites[objectEvent->spriteId]; sprite->oam.priority = linkedSprite->oam.priority; sprite->x = linkedSprite->x; - sprite->y = linkedSprite->y + sprite->data[3]; + sprite->y = linkedSprite->y + sprite->sYOffset; if (!objectEvent->active || !objectEvent->hasShadow || MetatileBehavior_IsPokeGrass(objectEvent->currentMetatileBehavior) || MetatileBehavior_IsSurfableWaterOrUnderwater(objectEvent->currentMetatileBehavior) @@ -276,6 +273,11 @@ void UpdateShadowFieldEffect(struct Sprite *sprite) } } +#undef sLocalId +#undef sMapNum +#undef sMapGroup +#undef sYOffset + // Sprite data for FLDEFF_TALL_GRASS and FLDEFF_LONG_GRASS #define sElevation data[0] #define sX data[1] @@ -288,18 +290,14 @@ void UpdateShadowFieldEffect(struct Sprite *sprite) u32 FldEff_TallGrass(void) { - s16 x; - s16 y; u8 spriteId; - struct Sprite *sprite; - - x = gFieldEffectArguments[0]; - y = gFieldEffectArguments[1]; + s16 x = gFieldEffectArguments[0]; + s16 y = gFieldEffectArguments[1]; SetSpritePosToOffsetMapCoords(&x, &y, 8, 8); spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_TALL_GRASS], x, y, 0); if (spriteId != MAX_SPRITES) { - sprite = &gSprites[spriteId]; + struct Sprite *sprite = &gSprites[spriteId]; sprite->coordOffsetEnabled = TRUE; sprite->oam.priority = gFieldEffectArguments[3]; sprite->sElevation = gFieldEffectArguments[2]; @@ -317,15 +315,12 @@ u32 FldEff_TallGrass(void) void UpdateTallGrassFieldEffect(struct Sprite *sprite) { - u8 mapNum; - u8 mapGroup; u8 metatileBehavior; u8 localId; u8 objectEventId; - struct ObjectEvent *objectEvent; + u8 mapNum = sprite->sCurrentMap >> 8; + u8 mapGroup = sprite->sCurrentMap; - mapNum = sprite->sCurrentMap >> 8; - mapGroup = sprite->sCurrentMap; if (gCamera.active && (gSaveBlock1Ptr->location.mapNum != mapNum || gSaveBlock1Ptr->location.mapGroup != mapGroup)) { sprite->sX -= gCamera.x; @@ -346,11 +341,9 @@ void UpdateTallGrassFieldEffect(struct Sprite *sprite) else { // Check if the object that triggered the effect has moved away - objectEvent = &gObjectEvents[objectEventId]; - if ((objectEvent->currentCoords.x != sprite->sX - || objectEvent->currentCoords.y != sprite->sY) - && (objectEvent->previousCoords.x != sprite->sX - || objectEvent->previousCoords.y != sprite->sY)) + struct ObjectEvent *objectEvent = &gObjectEvents[objectEventId]; + if ((objectEvent->currentCoords.x != sprite->sX || objectEvent->currentCoords.y != sprite->sY) + && (objectEvent->previousCoords.x != sprite->sX || objectEvent->previousCoords.y != sprite->sY)) sprite->sObjectMoved = TRUE; // Metatile behavior var re-used as subpriority @@ -366,31 +359,28 @@ void UpdateTallGrassFieldEffect(struct Sprite *sprite) u32 FldEff_JumpTallGrass(void) { u8 spriteId; - struct Sprite *sprite; SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 12); spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_JUMP_TALL_GRASS], gFieldEffectArguments[0], gFieldEffectArguments[1], 0); if (spriteId != MAX_SPRITES) { - sprite = &gSprites[spriteId]; + struct Sprite *sprite = &gSprites[spriteId]; sprite->coordOffsetEnabled = TRUE; sprite->oam.priority = gFieldEffectArguments[3]; - sprite->sElevation = gFieldEffectArguments[2]; - sprite->sFldEff = FLDEFF_JUMP_TALL_GRASS; + sprite->sJumpElevation = gFieldEffectArguments[2]; + sprite->sJumpFldEff = FLDEFF_JUMP_TALL_GRASS; } return 0; } u8 FindTallGrassFieldEffectSpriteId(u8 localId, u8 mapNum, u8 mapGroup, s16 x, s16 y) { - struct Sprite *sprite; u8 i; - for (i = 0; i < MAX_SPRITES; i ++) { if (gSprites[i].inUse) { - sprite = &gSprites[i]; + struct Sprite *sprite = &gSprites[i]; if (sprite->callback == UpdateTallGrassFieldEffect && (x == sprite->sX && y == sprite->sY) && localId == (u8)(sprite->sLocalId) @@ -404,18 +394,14 @@ u8 FindTallGrassFieldEffectSpriteId(u8 localId, u8 mapNum, u8 mapGroup, s16 x, s u32 FldEff_LongGrass(void) { - s16 x; - s16 y; u8 spriteId; - struct Sprite *sprite; - - x = gFieldEffectArguments[0]; - y = gFieldEffectArguments[1]; + s16 x = gFieldEffectArguments[0]; + s16 y = gFieldEffectArguments[1]; SetSpritePosToOffsetMapCoords(&x, &y, 8, 8); spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_LONG_GRASS], x, y, 0); if (spriteId != MAX_SPRITES) { - sprite = &gSprites[spriteId]; + struct Sprite *sprite = &gSprites[spriteId]; sprite->coordOffsetEnabled = TRUE; sprite->oam.priority = ElevationToPriority(gFieldEffectArguments[2]); sprite->sElevation = gFieldEffectArguments[2]; @@ -433,15 +419,12 @@ u32 FldEff_LongGrass(void) void UpdateLongGrassFieldEffect(struct Sprite *sprite) { - u8 mapNum; - u8 mapGroup; u8 metatileBehavior; u8 localId; u8 objectEventId; - struct ObjectEvent *objectEvent; + u8 mapNum = sprite->sCurrentMap >> 8; + u8 mapGroup = sprite->sCurrentMap; - mapNum = sprite->sCurrentMap >> 8; - mapGroup = sprite->sCurrentMap; if (gCamera.active && (gSaveBlock1Ptr->location.mapNum != mapNum || gSaveBlock1Ptr->location.mapGroup != mapGroup)) { sprite->sX -= gCamera.x; @@ -451,7 +434,7 @@ void UpdateLongGrassFieldEffect(struct Sprite *sprite) localId = sprite->sLocalId; mapNum = sprite->sMapNum; mapGroup = sprite->sMapGroup; - metatileBehavior = MapGridGetMetatileBehaviorAt(sprite->data[1], sprite->data[2]); + metatileBehavior = MapGridGetMetatileBehaviorAt(sprite->sX, sprite->sY); if (TryGetObjectEventIdByLocalIdAndMap(localId, mapNum, mapGroup, &objectEventId) || !MetatileBehavior_IsLongGrass(metatileBehavior) || (sprite->sObjectMoved && sprite->animEnded)) @@ -461,11 +444,9 @@ void UpdateLongGrassFieldEffect(struct Sprite *sprite) else { // Check if the object that triggered the effect has moved away - objectEvent = &gObjectEvents[objectEventId]; - if ((objectEvent->currentCoords.x != sprite->data[1] - || objectEvent->currentCoords.y != sprite->data[2]) - && (objectEvent->previousCoords.x != sprite->data[1] - || objectEvent->previousCoords.y != sprite->data[2])) + struct ObjectEvent *objectEvent = &gObjectEvents[objectEventId]; + if ((objectEvent->currentCoords.x != sprite->sX || objectEvent->currentCoords.y != sprite->sY) + && (objectEvent->previousCoords.x != sprite->sX || objectEvent->previousCoords.y != sprite->sY)) sprite->sObjectMoved = TRUE; UpdateObjectEventSpriteInvisibility(sprite, FALSE); @@ -473,6 +454,7 @@ void UpdateLongGrassFieldEffect(struct Sprite *sprite) } } +#undef sElevation #undef sX #undef sY #undef sMapNum @@ -486,41 +468,42 @@ void UpdateLongGrassFieldEffect(struct Sprite *sprite) u32 FldEff_JumpLongGrass(void) { u8 spriteId; - struct Sprite *sprite; SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8); spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_JUMP_LONG_GRASS], gFieldEffectArguments[0], gFieldEffectArguments[1], 0); if (spriteId != MAX_SPRITES) { - sprite = &gSprites[spriteId]; + struct Sprite *sprite = &gSprites[spriteId]; sprite->coordOffsetEnabled = TRUE; sprite->oam.priority = gFieldEffectArguments[3]; - sprite->sElevation = gFieldEffectArguments[2]; - sprite->sFldEff = FLDEFF_JUMP_LONG_GRASS; + sprite->sJumpElevation = gFieldEffectArguments[2]; + sprite->sJumpFldEff = FLDEFF_JUMP_LONG_GRASS; } return 0; } +// Sprite data for FLDEFF_SHORT_GRASS +#define sLocalId data[0] +#define sMapNum data[1] +#define sMapGroup data[2] +#define sPrevX data[3] +#define sPrevY data[4] + u32 FldEff_ShortGrass(void) { - u8 objectEventId; - struct ObjectEvent *objectEvent; - u8 spriteId; - struct Sprite *sprite; - - objectEventId = GetObjectEventIdByLocalIdAndMap(gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); - objectEvent = &gObjectEvents[objectEventId]; - spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_SHORT_GRASS], 0, 0, 0); + u8 objectEventId = GetObjectEventIdByLocalIdAndMap(gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); + struct ObjectEvent *objectEvent = &gObjectEvents[objectEventId]; + u8 spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_SHORT_GRASS], 0, 0, 0); if (spriteId != MAX_SPRITES) { - sprite = &(gSprites[spriteId]); + struct Sprite *sprite = &(gSprites[spriteId]); sprite->coordOffsetEnabled = TRUE; sprite->oam.priority = gSprites[objectEvent->spriteId].oam.priority; - sprite->data[0] = gFieldEffectArguments[0]; - sprite->data[1] = gFieldEffectArguments[1]; - sprite->data[2] = gFieldEffectArguments[2]; - sprite->data[3] = gSprites[objectEvent->spriteId].x; - sprite->data[4] = gSprites[objectEvent->spriteId].y; + sprite->sLocalId = gFieldEffectArguments[0]; + sprite->sMapNum = gFieldEffectArguments[1]; + sprite->sMapGroup = gFieldEffectArguments[2]; + sprite->sPrevX = gSprites[objectEvent->spriteId].x; + sprite->sPrevY = gSprites[objectEvent->spriteId].y; } return 0; } @@ -528,32 +511,28 @@ u32 FldEff_ShortGrass(void) void UpdateShortGrassFieldEffect(struct Sprite *sprite) { u8 objectEventId; - s16 x; - s16 y; - const struct ObjectEventGraphicsInfo *graphicsInfo; - struct Sprite *linkedSprite; - if (TryGetObjectEventIdByLocalIdAndMap(sprite->data[0], sprite->data[1], sprite->data[2], &objectEventId) || !gObjectEvents[objectEventId].inShortGrass) + if (TryGetObjectEventIdByLocalIdAndMap(sprite->sLocalId, sprite->sMapNum, sprite->sMapGroup, &objectEventId) || !gObjectEvents[objectEventId].inShortGrass) { FieldEffectStop(sprite, FLDEFF_SHORT_GRASS); } else { - graphicsInfo = GetObjectEventGraphicsInfo(gObjectEvents[objectEventId].graphicsId); - linkedSprite = &gSprites[gObjectEvents[objectEventId].spriteId]; - y = linkedSprite->y; - x = linkedSprite->x; - if (x != sprite->data[3] || y != sprite->data[4]) + const struct ObjectEventGraphicsInfo *graphicsInfo = GetObjectEventGraphicsInfo(gObjectEvents[objectEventId].graphicsId); + struct Sprite *linkedSprite = &gSprites[gObjectEvents[objectEventId].spriteId]; + s16 parentY = linkedSprite->y; + s16 parentX = linkedSprite->x; + if (parentX != sprite->sPrevX || parentY != sprite->sPrevY) { - sprite->data[3] = x; - sprite->data[4] = y; + // Parent sprite moved, try to restart the animation + sprite->sPrevX = parentX; + sprite->sPrevY = parentY; if (sprite->animEnded) - { StartSpriteAnim(sprite, 0); - } } - sprite->x = x; - sprite->y = y; + sprite->x = parentX; + sprite->y = parentY; + // Offset the grass sprite halfway down the parent sprite. sprite->y2 = (graphicsInfo->height >> 1) - 8; sprite->subpriority = linkedSprite->subpriority - 1; sprite->oam.priority = linkedSprite->oam.priority; @@ -561,19 +540,29 @@ void UpdateShortGrassFieldEffect(struct Sprite *sprite) } } +#undef sLocalId +#undef sMapNum +#undef sMapGroup +#undef sPrevX +#undef sPrevY + +// Sprite data for FLDEFF_SAND_FOOTPRINTS, FLDEFF_DEEP_SAND_FOOTPRINTS, and FLDEFF_BIKE_TIRE_TRACKS +#define sState data[0] +#define sTimer data[1] +#define sFldEff data[7] + u32 FldEff_SandFootprints(void) { u8 spriteId; - struct Sprite *sprite; SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8); spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_SAND_FOOTPRINTS], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); if (spriteId != MAX_SPRITES) { - sprite = &gSprites[spriteId]; + struct Sprite *sprite = &gSprites[spriteId]; sprite->coordOffsetEnabled = TRUE; sprite->oam.priority = gFieldEffectArguments[3]; - sprite->data[7] = FLDEFF_SAND_FOOTPRINTS; + sprite->sFldEff = FLDEFF_SAND_FOOTPRINTS; StartSpriteAnim(sprite, gFieldEffectArguments[4]); } return 0; @@ -582,16 +571,15 @@ u32 FldEff_SandFootprints(void) u32 FldEff_DeepSandFootprints(void) { u8 spriteId; - struct Sprite *sprite; SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8); spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_DEEP_SAND_FOOTPRINTS], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); if (spriteId != MAX_SPRITES) { - sprite = &gSprites[spriteId]; + struct Sprite *sprite = &gSprites[spriteId]; sprite->coordOffsetEnabled = TRUE; sprite->oam.priority = gFieldEffectArguments[3]; - sprite->data[7] = FLDEFF_DEEP_SAND_FOOTPRINTS; + sprite->sFldEff = FLDEFF_DEEP_SAND_FOOTPRINTS; StartSpriteAnim(sprite, gFieldEffectArguments[4]); } return spriteId; @@ -600,16 +588,15 @@ u32 FldEff_DeepSandFootprints(void) u32 FldEff_BikeTireTracks(void) { u8 spriteId; - struct Sprite *sprite; SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8); spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_BIKE_TIRE_TRACKS], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); if (spriteId != MAX_SPRITES) { - sprite = &gSprites[spriteId]; + struct Sprite *sprite = &gSprites[spriteId]; sprite->coordOffsetEnabled = TRUE; sprite->oam.priority = gFieldEffectArguments[3]; - sprite->data[7] = FLDEFF_BIKE_TIRE_TRACKS; + sprite->sFldEff = FLDEFF_BIKE_TIRE_TRACKS; StartSpriteAnim(sprite, gFieldEffectArguments[4]); } return spriteId; @@ -622,14 +609,14 @@ void (*const gFadeFootprintsTireTracksFuncs[])(struct Sprite *) = { void UpdateFootprintsTireTracksFieldEffect(struct Sprite *sprite) { - gFadeFootprintsTireTracksFuncs[sprite->data[0]](sprite); + gFadeFootprintsTireTracksFuncs[sprite->sState](sprite); } static void FadeFootprintsTireTracks_Step0(struct Sprite *sprite) { // Wait 40 frames before the flickering starts. - if (++sprite->data[1] > 40) - sprite->data[0] = 1; + if (++sprite->sTimer > 40) + sprite->sState = 1; UpdateObjectEventSpriteInvisibility(sprite, FALSE); } @@ -637,36 +624,37 @@ static void FadeFootprintsTireTracks_Step0(struct Sprite *sprite) static void FadeFootprintsTireTracks_Step1(struct Sprite *sprite) { sprite->invisible ^= 1; - sprite->data[1]++; + sprite->sTimer++; UpdateObjectEventSpriteInvisibility(sprite, sprite->invisible); - if (sprite->data[1] > 56) - { - FieldEffectStop(sprite, sprite->data[7]); - } + if (sprite->sTimer > 56) + FieldEffectStop(sprite, sprite->sFldEff); } +#undef sState +#undef sTimer +#undef sFldEff + +// Sprite data for FLDEFF_SPLASH +#define sLocalId data[0] +#define sMapNum data[1] +#define sMapGroup data[2] + u32 FldEff_Splash(void) { - u8 objectEventId; - struct ObjectEvent *objectEvent; - u8 spriteId; - struct Sprite *sprite; - const struct ObjectEventGraphicsInfo *graphicsInfo; - struct Sprite *linkedSprite; - - objectEventId = GetObjectEventIdByLocalIdAndMap(gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); - objectEvent = &gObjectEvents[objectEventId]; - spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_SPLASH], 0, 0, 0); + u8 objectEventId = GetObjectEventIdByLocalIdAndMap(gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); + struct ObjectEvent *objectEvent = &gObjectEvents[objectEventId]; + u8 spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_SPLASH], 0, 0, 0); if (spriteId != MAX_SPRITES) { - graphicsInfo = GetObjectEventGraphicsInfo(objectEvent->graphicsId); - sprite = &gSprites[spriteId]; + struct Sprite *linkedSprite; + const struct ObjectEventGraphicsInfo *graphicsInfo = GetObjectEventGraphicsInfo(objectEvent->graphicsId); + struct Sprite *sprite = &gSprites[spriteId]; sprite->coordOffsetEnabled = TRUE; linkedSprite = &gSprites[objectEvent->spriteId]; sprite->oam.priority = linkedSprite->oam.priority; - sprite->data[0] = gFieldEffectArguments[0]; - sprite->data[1] = gFieldEffectArguments[1]; - sprite->data[2] = gFieldEffectArguments[2]; + sprite->sLocalId = gFieldEffectArguments[0]; + sprite->sMapNum = gFieldEffectArguments[1]; + sprite->sMapGroup = gFieldEffectArguments[2]; sprite->y2 = (graphicsInfo->height >> 1) - 4; PlaySE(SE_PUDDLE); } @@ -677,7 +665,7 @@ void UpdateSplashFieldEffect(struct Sprite *sprite) { u8 objectEventId; - if (sprite->animEnded || TryGetObjectEventIdByLocalIdAndMap(sprite->data[0], sprite->data[1], sprite->data[2], &objectEventId)) + if (sprite->animEnded || TryGetObjectEventIdByLocalIdAndMap(sprite->sLocalId, sprite->sMapNum, sprite->sMapGroup, &objectEventId)) { FieldEffectStop(sprite, FLDEFF_SPLASH); } @@ -689,20 +677,23 @@ void UpdateSplashFieldEffect(struct Sprite *sprite) } } +#undef sLocalId +#undef sMapNum +#undef sMapGroup + u32 FldEff_JumpSmallSplash(void) { u8 spriteId; - struct Sprite *sprite; SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 12); spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_JUMP_SMALL_SPLASH], gFieldEffectArguments[0], gFieldEffectArguments[1], 0); if (spriteId != MAX_SPRITES) { - sprite = &gSprites[spriteId]; + struct Sprite *sprite = &gSprites[spriteId]; sprite->coordOffsetEnabled = TRUE; sprite->oam.priority = gFieldEffectArguments[3]; - sprite->data[0] = gFieldEffectArguments[2]; - sprite->data[1] = FLDEFF_JUMP_SMALL_SPLASH; + sprite->sJumpElevation = gFieldEffectArguments[2]; + sprite->sJumpFldEff = FLDEFF_JUMP_SMALL_SPLASH; } return 0; } @@ -710,44 +701,44 @@ u32 FldEff_JumpSmallSplash(void) u32 FldEff_JumpBigSplash(void) { u8 spriteId; - struct Sprite *sprite; SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8); spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_JUMP_BIG_SPLASH], gFieldEffectArguments[0], gFieldEffectArguments[1], 0); if (spriteId != MAX_SPRITES) { - sprite = &gSprites[spriteId]; + struct Sprite *sprite = &gSprites[spriteId]; sprite->coordOffsetEnabled = TRUE; sprite->oam.priority = gFieldEffectArguments[3]; - sprite->data[0] = gFieldEffectArguments[2]; - sprite->data[1] = FLDEFF_JUMP_BIG_SPLASH; + sprite->sJumpElevation = gFieldEffectArguments[2]; + sprite->sJumpFldEff = FLDEFF_JUMP_BIG_SPLASH; } return 0; } +// Sprite data for FLDEFF_FEET_IN_FLOWING_WATER +#define sLocalId data[0] +#define sMapNum data[1] +#define sMapGroup data[2] +#define sPrevX data[3] +#define sPrevY data[4] + u32 FldEff_FeetInFlowingWater(void) { - u8 objectEventId; - struct ObjectEvent *objectEvent; - u8 spriteId; - struct Sprite *sprite; - const struct ObjectEventGraphicsInfo *graphicsInfo; - - objectEventId = GetObjectEventIdByLocalIdAndMap(gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); - objectEvent = &gObjectEvents[objectEventId]; - spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_SPLASH], 0, 0, 0); + u8 objectEventId = GetObjectEventIdByLocalIdAndMap(gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); + struct ObjectEvent *objectEvent = &gObjectEvents[objectEventId]; + u8 spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_SPLASH], 0, 0, 0); if (spriteId != MAX_SPRITES) { - graphicsInfo = GetObjectEventGraphicsInfo(objectEvent->graphicsId); - sprite = &gSprites[spriteId]; + const struct ObjectEventGraphicsInfo *graphicsInfo = GetObjectEventGraphicsInfo(objectEvent->graphicsId); + struct Sprite *sprite = &gSprites[spriteId]; sprite->callback = UpdateFeetInFlowingWaterFieldEffect; sprite->coordOffsetEnabled = TRUE; sprite->oam.priority = gSprites[objectEvent->spriteId].oam.priority; - sprite->data[0] = gFieldEffectArguments[0]; - sprite->data[1] = gFieldEffectArguments[1]; - sprite->data[2] = gFieldEffectArguments[2]; - sprite->data[3] = -1; - sprite->data[4] = -1; + sprite->sLocalId = gFieldEffectArguments[0]; + sprite->sMapNum = gFieldEffectArguments[1]; + sprite->sMapGroup = gFieldEffectArguments[2]; + sprite->sPrevX = -1; + sprite->sPrevY = -1; sprite->y2 = (graphicsInfo->height >> 1) - 4; StartSpriteAnim(sprite, 1); } @@ -757,69 +748,70 @@ u32 FldEff_FeetInFlowingWater(void) static void UpdateFeetInFlowingWaterFieldEffect(struct Sprite *sprite) { u8 objectEventId; - struct Sprite *linkedSprite; - struct ObjectEvent *objectEvent; - if (TryGetObjectEventIdByLocalIdAndMap(sprite->data[0], sprite->data[1], sprite->data[2], &objectEventId) || !gObjectEvents[objectEventId].inShallowFlowingWater) + if (TryGetObjectEventIdByLocalIdAndMap(sprite->sLocalId, sprite->sMapNum, sprite->sMapGroup, &objectEventId) || !gObjectEvents[objectEventId].inShallowFlowingWater) { FieldEffectStop(sprite, FLDEFF_FEET_IN_FLOWING_WATER); } else { - objectEvent = &gObjectEvents[objectEventId]; - linkedSprite = &gSprites[objectEvent->spriteId]; + struct ObjectEvent *objectEvent = &gObjectEvents[objectEventId]; + struct Sprite *linkedSprite = &gSprites[objectEvent->spriteId]; sprite->x = linkedSprite->x; sprite->y = linkedSprite->y; sprite->subpriority = linkedSprite->subpriority; UpdateObjectEventSpriteInvisibility(sprite, FALSE); - if (objectEvent->currentCoords.x != sprite->data[3] || objectEvent->currentCoords.y != sprite->data[4]) + if (objectEvent->currentCoords.x != sprite->sPrevX || objectEvent->currentCoords.y != sprite->sPrevY) { - sprite->data[3] = objectEvent->currentCoords.x; - sprite->data[4] = objectEvent->currentCoords.y; + sprite->sPrevX = objectEvent->currentCoords.x; + sprite->sPrevY = objectEvent->currentCoords.y; if (!sprite->invisible) - { PlaySE(SE_PUDDLE); - } } } } +#undef sLocalId +#undef sMapNum +#undef sMapGroup +#undef sPrevX +#undef sPrevY + u32 FldEff_Ripple(void) { - u8 spriteId; - struct Sprite *sprite; - - spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_RIPPLE], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); + u8 spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_RIPPLE], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); if (spriteId != MAX_SPRITES) { - sprite = &gSprites[spriteId]; + struct Sprite *sprite = &gSprites[spriteId]; sprite->coordOffsetEnabled = TRUE; sprite->oam.priority = gFieldEffectArguments[3]; - sprite->data[0] = FLDEFF_RIPPLE; + sprite->sWaitFldEff = FLDEFF_RIPPLE; } return 0; } +// Sprite data for FLDEFF_HOT_SPRINGS_WATER +#define sLocalId data[0] +#define sMapNum data[1] +#define sMapGroup data[2] +#define sPrevX data[3] +#define sPrevY data[4] + u32 FldEff_HotSpringsWater(void) { - u8 objectEventId; - struct ObjectEvent *objectEvent; - u8 spriteId; - struct Sprite *sprite; - - objectEventId = GetObjectEventIdByLocalIdAndMap(gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); - objectEvent = &gObjectEvents[objectEventId]; - spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_HOT_SPRINGS_WATER], 0, 0, 0); + u8 objectEventId = GetObjectEventIdByLocalIdAndMap(gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); + struct ObjectEvent *objectEvent = &gObjectEvents[objectEventId]; + u8 spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_HOT_SPRINGS_WATER], 0, 0, 0); if (spriteId != MAX_SPRITES) { - sprite = &gSprites[spriteId]; + struct Sprite *sprite = &gSprites[spriteId]; sprite->coordOffsetEnabled = TRUE; sprite->oam.priority = gSprites[objectEvent->spriteId].oam.priority; - sprite->data[0] = gFieldEffectArguments[0]; - sprite->data[1] = gFieldEffectArguments[1]; - sprite->data[2] = gFieldEffectArguments[2]; - sprite->data[3] = gSprites[objectEvent->spriteId].x; - sprite->data[4] = gSprites[objectEvent->spriteId].y; + sprite->sLocalId = gFieldEffectArguments[0]; + sprite->sMapNum = gFieldEffectArguments[1]; + sprite->sMapGroup = gFieldEffectArguments[2]; + sprite->sPrevX = gSprites[objectEvent->spriteId].x; // Unused + sprite->sPrevY = gSprites[objectEvent->spriteId].y; // Unused } return 0; } @@ -827,17 +819,15 @@ u32 FldEff_HotSpringsWater(void) void UpdateHotSpringsWaterFieldEffect(struct Sprite *sprite) { u8 objectEventId; - const struct ObjectEventGraphicsInfo *graphicsInfo; - struct Sprite *linkedSprite; - if (TryGetObjectEventIdByLocalIdAndMap(sprite->data[0], sprite->data[1], sprite->data[2], &objectEventId) || !gObjectEvents[objectEventId].inHotSprings) + if (TryGetObjectEventIdByLocalIdAndMap(sprite->sLocalId, sprite->sMapNum, sprite->sMapGroup, &objectEventId) || !gObjectEvents[objectEventId].inHotSprings) { FieldEffectStop(sprite, FLDEFF_HOT_SPRINGS_WATER); } else { - graphicsInfo = GetObjectEventGraphicsInfo(gObjectEvents[objectEventId].graphicsId); - linkedSprite = &gSprites[gObjectEvents[objectEventId].spriteId]; + const struct ObjectEventGraphicsInfo *graphicsInfo = GetObjectEventGraphicsInfo(gObjectEvents[objectEventId].graphicsId); + struct Sprite *linkedSprite = &gSprites[gObjectEvents[objectEventId].spriteId]; sprite->x = linkedSprite->x; sprite->y = (graphicsInfo->height >> 1) + linkedSprite->y - 8; sprite->subpriority = linkedSprite->subpriority - 1; @@ -845,19 +835,24 @@ void UpdateHotSpringsWaterFieldEffect(struct Sprite *sprite) } } +#undef sLocalId +#undef sMapNum +#undef sMapGroup +#undef sPrevX +#undef sPrevY + u32 FldEff_UnusedGrass(void) { u8 spriteId; - struct Sprite *sprite; SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8); spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_UNUSED_GRASS], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); if (spriteId != MAX_SPRITES) { - sprite = &gSprites[spriteId]; + struct Sprite *sprite = &gSprites[spriteId]; sprite->coordOffsetEnabled = TRUE; sprite->oam.priority = gFieldEffectArguments[3]; - sprite->data[0] = FLDEFF_UNUSED_GRASS; + sprite->sWaitFldEff = FLDEFF_UNUSED_GRASS; } return 0; } @@ -865,16 +860,15 @@ u32 FldEff_UnusedGrass(void) u32 FldEff_UnusedGrass2(void) { u8 spriteId; - struct Sprite *sprite; SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8); spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_UNUSED_GRASS_2], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); if (spriteId != MAX_SPRITES) { - sprite = &gSprites[spriteId]; + struct Sprite *sprite = &gSprites[spriteId]; sprite->coordOffsetEnabled = TRUE; sprite->oam.priority = gFieldEffectArguments[3]; - sprite->data[0] = FLDEFF_UNUSED_GRASS_2; + sprite->sWaitFldEff = FLDEFF_UNUSED_GRASS_2; } return 0; } @@ -882,16 +876,15 @@ u32 FldEff_UnusedGrass2(void) u32 FldEff_UnusedSand(void) { u8 spriteId; - struct Sprite *sprite; SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8); spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_UNUSED_SAND], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); if (spriteId != MAX_SPRITES) { - sprite = &gSprites[spriteId]; + struct Sprite *sprite = &gSprites[spriteId]; sprite->coordOffsetEnabled = TRUE; sprite->oam.priority = gFieldEffectArguments[3]; - sprite->data[0] = FLDEFF_UNUSED_SAND; + sprite->sWaitFldEff = FLDEFF_UNUSED_SAND; } return 0; } @@ -899,16 +892,15 @@ u32 FldEff_UnusedSand(void) u32 FldEff_WaterSurfacing(void) { u8 spriteId; - struct Sprite *sprite; SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8); spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_WATER_SURFACING], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); if (spriteId != MAX_SPRITES) { - sprite = &gSprites[spriteId]; + struct Sprite *sprite = &gSprites[spriteId]; sprite->coordOffsetEnabled = TRUE; sprite->oam.priority = gFieldEffectArguments[3]; - sprite->data[0] = FLDEFF_WATER_SURFACING; + sprite->sWaitFldEff = FLDEFF_WATER_SURFACING; } return 0; } @@ -933,18 +925,15 @@ void StartAshFieldEffect(s16 x, s16 y, u16 metatileId, s16 delay) u32 FldEff_Ash(void) { - s16 x; - s16 y; u8 spriteId; - struct Sprite *sprite; - x = gFieldEffectArguments[0]; - y = gFieldEffectArguments[1]; + s16 x = gFieldEffectArguments[0]; + s16 y = gFieldEffectArguments[1]; SetSpritePosToOffsetMapCoords(&x, &y, 8, 8); spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_ASH], x, y, gFieldEffectArguments[2]); if (spriteId != MAX_SPRITES) { - sprite = &gSprites[spriteId]; + struct Sprite *sprite = &gSprites[spriteId]; sprite->coordOffsetEnabled = TRUE; sprite->oam.priority = gFieldEffectArguments[3]; sprite->sX = gFieldEffectArguments[0]; @@ -998,27 +987,30 @@ static void UpdateAshFieldEffect_End(struct Sprite *sprite) #undef sDelay // Sprite data for FLDEFF_SURF_BLOB -#define tBitfield data[0] -#define tPlayerOffset data[1] -#define tPlayerObjId data[2] - +#define sBitfield data[0] +#define sPlayerOffset data[1] +#define sPlayerObjId data[2] +#define sVelocity data[3] +#define sTimer data[4] +#define sIntervalIdx data[5] +#define sPrevX data[6] +#define sPrevY data[7] u32 FldEff_SurfBlob(void) { u8 spriteId; - struct Sprite *sprite; SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8); - spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_SURF_BLOB], gFieldEffectArguments[0], gFieldEffectArguments[1], 0x96); + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_SURF_BLOB], gFieldEffectArguments[0], gFieldEffectArguments[1], 150); if (spriteId != MAX_SPRITES) { - sprite = &gSprites[spriteId]; + struct Sprite *sprite = &gSprites[spriteId]; sprite->coordOffsetEnabled = TRUE; sprite->oam.paletteNum = 0; - sprite->tPlayerObjId = gFieldEffectArguments[2]; - sprite->data[3] = -1; - sprite->data[6] = -1; - sprite->data[7] = -1; + sprite->sPlayerObjId = gFieldEffectArguments[2]; + sprite->sVelocity = -1; + sprite->sPrevX = -1; + sprite->sPrevY = -1; } FieldEffectActiveListRemove(FLDEFF_SURF_BLOB); return spriteId; @@ -1027,43 +1019,40 @@ u32 FldEff_SurfBlob(void) void SetSurfBlob_BobState(u8 spriteId, u8 state) { - gSprites[spriteId].data[0] = (gSprites[spriteId].data[0] & ~0xF) | (state & 0xF); + gSprites[spriteId].sBitfield = (gSprites[spriteId].sBitfield & ~0xF) | (state & 0xF); } void SetSurfBlob_DontSyncAnim(u8 spriteId, bool8 dontSync) { - gSprites[spriteId].data[0] = (gSprites[spriteId].data[0] & ~0xF0) | ((dontSync & 0xF) << 4); + gSprites[spriteId].sBitfield = (gSprites[spriteId].sBitfield & ~0xF0) | ((dontSync & 0xF) << 4); } void SetSurfBlob_PlayerOffset(u8 spriteId, bool8 hasOffset, s16 offset) { - gSprites[spriteId].data[0] = (gSprites[spriteId].data[0] & ~0xF00) | ((hasOffset & 0xF) << 8); - gSprites[spriteId].tPlayerOffset = offset; + gSprites[spriteId].sBitfield = (gSprites[spriteId].sBitfield & ~0xF00) | ((hasOffset & 0xF) << 8); + gSprites[spriteId].sPlayerOffset = offset; } static u8 GetSurfBlob_BobState(struct Sprite *sprite) { - return sprite->data[0] & 0xF; + return sprite->sBitfield & 0xF; } // Never TRUE static u8 GetSurfBlob_DontSyncAnim(struct Sprite *sprite) { - return (sprite->data[0] & 0xF0) >> 4; + return (sprite->sBitfield & 0xF0) >> 4; } static u8 GetSurfBlob_HasPlayerOffset(struct Sprite *sprite) { - return (sprite->data[0] & 0xF00) >> 8; + return (sprite->sBitfield & 0xF00) >> 8; } void UpdateSurfBlobFieldEffect(struct Sprite *sprite) { - struct ObjectEvent *playerObj; - struct Sprite *playerSprite; - - playerObj = &gObjectEvents[sprite->tPlayerObjId]; - playerSprite = &gSprites[playerObj->spriteId]; + struct ObjectEvent *playerObj = &gObjectEvents[sprite->sPlayerObjId]; + struct Sprite *playerSprite = &gSprites[playerObj->spriteId]; SynchroniseSurfAnim(playerObj, sprite); SynchroniseSurfPosition(playerObj, sprite); UpdateBobbingEffect(playerObj, playerSprite, sprite); @@ -1096,17 +1085,19 @@ void SynchroniseSurfPosition(struct ObjectEvent *playerObj, struct Sprite *sprit s16 y = playerObj->currentCoords.y; s32 spriteY = sprite->y2; - if (spriteY == 0 && (x != sprite->data[6] || y != sprite->data[7])) + if (spriteY == 0 && (x != sprite->sPrevX || y != sprite->sPrevY)) { - sprite->data[5] = spriteY; - sprite->data[6] = x; - sprite->data[7] = y; - for (i = DIR_SOUTH; i <= DIR_EAST; i++, x = sprite->data[6], y = sprite->data[7]) + // Player is moving while surfing, update position. + sprite->sIntervalIdx = 0; + sprite->sPrevX = x; + sprite->sPrevY = y; + for (i = DIR_SOUTH; i <= DIR_EAST; i++, x = sprite->sPrevX, y = sprite->sPrevY) { MoveCoords(i, &x, &y); if (MapGridGetElevationAt(x, y) == 3) { - sprite->data[5]++; + // While dismounting the surf blob bobs at a slower rate + sprite->sIntervalIdx++; break; } } @@ -1115,46 +1106,54 @@ void SynchroniseSurfPosition(struct ObjectEvent *playerObj, struct Sprite *sprit static void UpdateBobbingEffect(struct ObjectEvent *playerObj, struct Sprite *playerSprite, struct Sprite *sprite) { - u16 intervals[] = {3, 7}; + // The frame interval at which to update the blob's y movement. + // Normally every 4th frame, but every 8th frame while dismounting. + u16 intervals[] = {0x3, 0x7}; + u8 bobState = GetSurfBlob_BobState(sprite); if (bobState != BOB_NONE) { - // Update bobbing position of surf blob - if (((u16)(++sprite->data[4]) & intervals[sprite->data[5]]) == 0) - { - sprite->y2 += sprite->data[3]; - } - if ((sprite->data[4] & 15) == 0) - { - sprite->data[3] = -sprite->data[3]; - } + // Update vertical position of surf blob + if (((u16)(++sprite->sTimer) & intervals[sprite->sIntervalIdx]) == 0) + sprite->y2 += sprite->sVelocity; + + // Reverse bob direction + if ((sprite->sTimer & 15) == 0) + sprite->sVelocity = -sprite->sVelocity; + if (bobState != BOB_JUST_MON) { - // Update bobbing position of player + // Update vertical position of player if (!GetSurfBlob_HasPlayerOffset(sprite)) playerSprite->y2 = sprite->y2; else - playerSprite->y2 = sprite->tPlayerOffset + sprite->y2; + playerSprite->y2 = sprite->sPlayerOffset + sprite->y2; sprite->x = playerSprite->x; sprite->y = playerSprite->y + 8; } } } +#undef sBitfield +#undef sPlayerOffset +#undef sPlayerObjId +#undef sVelocity +#undef sTimer +#undef sIntervalIdx +#undef sPrevX +#undef sPrevY + #define sSpriteId data[0] #define sBobY data[1] #define sTimer data[2] u8 StartUnderwaterSurfBlobBobbing(u8 blobSpriteId) { - u8 spriteId; - struct Sprite *sprite; - // Create a dummy sprite with its own callback // that tracks the actual surf blob sprite and // makes it bob up and down underwater - spriteId = CreateSpriteAtEnd(&gDummySpriteTemplate, 0, 0, -1); - sprite = &gSprites[spriteId]; + u8 spriteId = CreateSpriteAtEnd(&gDummySpriteTemplate, 0, 0, -1); + struct Sprite *sprite = &gSprites[spriteId]; sprite->callback = SpriteCB_UnderwaterSurfBlob; sprite->invisible = TRUE; sprite->sSpriteId = blobSpriteId; @@ -1164,17 +1163,14 @@ u8 StartUnderwaterSurfBlobBobbing(u8 blobSpriteId) static void SpriteCB_UnderwaterSurfBlob(struct Sprite *sprite) { - struct Sprite *blobSprite; + struct Sprite *blobSprite = &gSprites[sprite->sSpriteId]; - blobSprite = &gSprites[sprite->sSpriteId]; + // Update vertical position of surf blob if (((sprite->sTimer++) & 3) == 0) - { blobSprite->y2 += sprite->sBobY; - } + // Reverse direction if ((sprite->sTimer & 15) == 0) - { sprite->sBobY = -sprite->sBobY; - } } #undef sSpriteId @@ -1184,43 +1180,43 @@ static void SpriteCB_UnderwaterSurfBlob(struct Sprite *sprite) u32 FldEff_Dust(void) { u8 spriteId; - struct Sprite *sprite; SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 12); spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_GROUND_IMPACT_DUST], gFieldEffectArguments[0], gFieldEffectArguments[1], 0); if (spriteId != MAX_SPRITES) { - sprite = &gSprites[spriteId]; + struct Sprite *sprite = &gSprites[spriteId]; sprite->coordOffsetEnabled = TRUE; sprite->oam.priority = gFieldEffectArguments[3]; - sprite->data[0] = gFieldEffectArguments[2]; - sprite->data[1] = FLDEFF_DUST; + sprite->sJumpElevation = gFieldEffectArguments[2]; + sprite->sJumpFldEff = FLDEFF_DUST; } return 0; } +// Sprite data for FLDEFF_SAND_PILE +#define sLocalId data[0] +#define sMapNum data[1] +#define sMapGroup data[2] +#define sPrevX data[3] +#define sPrevY data[4] + u32 FldEff_SandPile(void) { - u8 objectEventId; - struct ObjectEvent *objectEvent; - u8 spriteId; - struct Sprite *sprite; - const struct ObjectEventGraphicsInfo *graphicsInfo; - - objectEventId = GetObjectEventIdByLocalIdAndMap(gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); - objectEvent = &gObjectEvents[objectEventId]; - spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_SAND_PILE], 0, 0, 0); + u8 objectEventId = GetObjectEventIdByLocalIdAndMap(gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); + struct ObjectEvent *objectEvent = &gObjectEvents[objectEventId]; + u8 spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_SAND_PILE], 0, 0, 0); if (spriteId != MAX_SPRITES) { - graphicsInfo = GetObjectEventGraphicsInfo(objectEvent->graphicsId); - sprite = &gSprites[spriteId]; + const struct ObjectEventGraphicsInfo *graphicsInfo = GetObjectEventGraphicsInfo(objectEvent->graphicsId); + struct Sprite *sprite = &gSprites[spriteId]; sprite->coordOffsetEnabled = TRUE; sprite->oam.priority = gSprites[objectEvent->spriteId].oam.priority; - sprite->data[0] = gFieldEffectArguments[0]; - sprite->data[1] = gFieldEffectArguments[1]; - sprite->data[2] = gFieldEffectArguments[2]; - sprite->data[3] = gSprites[objectEvent->spriteId].x; - sprite->data[4] = gSprites[objectEvent->spriteId].y; + sprite->sLocalId = gFieldEffectArguments[0]; + sprite->sMapNum = gFieldEffectArguments[1]; + sprite->sMapGroup = gFieldEffectArguments[2]; + sprite->sPrevX = gSprites[objectEvent->spriteId].x; + sprite->sPrevY = gSprites[objectEvent->spriteId].y; sprite->y2 = (graphicsInfo->height >> 1) - 2; SeekSpriteAnim(sprite, 2); } @@ -1230,81 +1226,85 @@ u32 FldEff_SandPile(void) void UpdateSandPileFieldEffect(struct Sprite *sprite) { u8 objectEventId; - s16 x; - s16 y; - if (TryGetObjectEventIdByLocalIdAndMap(sprite->data[0], sprite->data[1], sprite->data[2], &objectEventId) || !gObjectEvents[objectEventId].inSandPile) + if (TryGetObjectEventIdByLocalIdAndMap(sprite->sLocalId, sprite->sMapNum, sprite->sMapGroup, &objectEventId) || !gObjectEvents[objectEventId].inSandPile) { FieldEffectStop(sprite, FLDEFF_SAND_PILE); } else { - y = gSprites[gObjectEvents[objectEventId].spriteId].y; - x = gSprites[gObjectEvents[objectEventId].spriteId].x; - if (x != sprite->data[3] || y != sprite->data[4]) + s16 parentY = gSprites[gObjectEvents[objectEventId].spriteId].y; + s16 parentX = gSprites[gObjectEvents[objectEventId].spriteId].x; + if (parentX != sprite->sPrevX || parentY != sprite->sPrevY) { - sprite->data[3] = x; - sprite->data[4] = y; + sprite->sPrevX = parentX; + sprite->sPrevY = parentY; if (sprite->animEnded) - { StartSpriteAnim(sprite, 0); - } } - sprite->x = x; - sprite->y = y; + sprite->x = parentX; + sprite->y = parentY; sprite->subpriority = gSprites[gObjectEvents[objectEventId].spriteId].subpriority; UpdateObjectEventSpriteInvisibility(sprite, FALSE); } } +#undef sLocalId +#undef sMapNum +#undef sMapGroup +#undef sPrevX +#undef sPrevY + u32 FldEff_Bubbles(void) { u8 spriteId; - struct Sprite *sprite; SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 0); - spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_BUBBLES], gFieldEffectArguments[0], gFieldEffectArguments[1], 0x52); + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_BUBBLES], gFieldEffectArguments[0], gFieldEffectArguments[1], 82); if (spriteId != MAX_SPRITES) { - sprite = &gSprites[spriteId]; + struct Sprite *sprite = &gSprites[spriteId]; sprite->coordOffsetEnabled = TRUE; sprite->oam.priority = 1; } return 0; } +#define sY data[0] + void UpdateBubblesFieldEffect(struct Sprite *sprite) { - sprite->data[0] += 0x80; - sprite->data[0] &= 0x100; - sprite->y -= sprite->data[0] >> 8; + // Move up 1 every other frame. + sprite->sY += ((1 << 8) / 2); + sprite->sY &= (1 << 8); + sprite->y -= sprite->sY >> 8; UpdateObjectEventSpriteInvisibility(sprite, FALSE); if (sprite->invisible || sprite->animEnded) - { FieldEffectStop(sprite, FLDEFF_BUBBLES); - } } +#undef sY + u32 FldEff_BerryTreeGrowthSparkle(void) { u8 spriteId; - struct Sprite *sprite; SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 4); spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_SPARKLE], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); if (spriteId != MAX_SPRITES) { - sprite = &gSprites[spriteId]; + struct Sprite *sprite = &gSprites[spriteId]; sprite->coordOffsetEnabled = TRUE; sprite->oam.priority = gFieldEffectArguments[3]; sprite->oam.paletteNum = 5; - sprite->data[0] = FLDEFF_BERRY_TREE_GROWTH_SPARKLE; + sprite->sWaitFldEff = FLDEFF_BERRY_TREE_GROWTH_SPARKLE; } return 0; } // Sprite data for FLDEFF_TREE_DISGUISE / FLDEFF_MOUNTAIN_DISGUISE / FLDEFF_SAND_DISGUISE #define sState data[0] +#define sFldEff data[1] #define sLocalId data[2] #define sMapNum data[3] #define sMapGroup data[4] @@ -1328,7 +1328,6 @@ u32 ShowSandDisguiseFieldEffect(void) static u32 ShowDisguiseFieldEffect(u8 fldEff, u8 fldEffObj, u8 paletteNum) { u8 spriteId; - struct Sprite *sprite; if (TryGetObjectEventIdByLocalIdAndMap(gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2], &spriteId)) { @@ -1338,7 +1337,7 @@ static u32 ShowDisguiseFieldEffect(u8 fldEff, u8 fldEffObj, u8 paletteNum) spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[fldEffObj], 0, 0, 0); if (spriteId != MAX_SPRITES) { - sprite = &gSprites[spriteId]; + struct Sprite *sprite = &gSprites[spriteId]; sprite->coordOffsetEnabled ++; sprite->oam.paletteNum = paletteNum; sprite->sFldEff = fldEff; @@ -1405,6 +1404,7 @@ bool8 UpdateRevealDisguise(struct ObjectEvent *objectEvent) } #undef sState +#undef sFldEff #undef sLocalId #undef sMapNum #undef sMapGroup @@ -1421,7 +1421,7 @@ u32 FldEff_Sparkle(void) gFieldEffectArguments[0] += MAP_OFFSET; gFieldEffectArguments[1] += MAP_OFFSET; SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8); - spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_SMALL_SPARKLE], gFieldEffectArguments[0], gFieldEffectArguments[1], 0x52); + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_SMALL_SPARKLE], gFieldEffectArguments[0], gFieldEffectArguments[1], 82); if (spriteId != MAX_SPRITES) { gSprites[spriteId].oam.priority = gFieldEffectArguments[2]; @@ -1449,7 +1449,9 @@ void UpdateSparkleFieldEffect(struct Sprite *sprite) #undef sEndTimer #define sTimer data[0] +#define sMoveTimer data[1] #define sState data[2] +#define sVelocity data[3] #define sStartY data[4] #define sCounter data[5] #define sAnimCounter data[6] @@ -1615,41 +1617,44 @@ void UpdateRayquazaSpotlightEffect(struct Sprite *sprite) if (sprite->sState == 1) { - if ((sprite->data[1] & 7) == 0) - sprite->y2 += sprite->data[3]; - if ((sprite->data[1] & 15) == 0) - sprite->data[3] = -sprite->data[3]; - sprite->data[1]++; + // Update movement + if ((sprite->sMoveTimer & 7) == 0) + sprite->y2 += sprite->sVelocity; + // Reverse direction + if ((sprite->sMoveTimer & 15) == 0) + sprite->sVelocity = -sprite->sVelocity; + sprite->sMoveTimer++; } sprite->sTimer++; } #undef sTimer +#undef sMoveTimer #undef sState #undef sStartY +#undef sVelocity #undef sCounter #undef sAnimCounter #undef sAnimState -// Used by FLDEFF_JUMP_TALL_GRASS and FLDEFF_JUMP_LONG_GRASS void UpdateJumpImpactEffect(struct Sprite *sprite) { if (sprite->animEnded) { - FieldEffectStop(sprite, sprite->sFldEff); + FieldEffectStop(sprite, sprite->sJumpFldEff); } else { UpdateObjectEventSpriteInvisibility(sprite, FALSE); - SetObjectSubpriorityByElevation(sprite->sElevation, sprite, 0); + SetObjectSubpriorityByElevation(sprite->sJumpElevation, sprite, 0); } } void WaitFieldEffectSpriteAnim(struct Sprite *sprite) { if (sprite->animEnded) - FieldEffectStop(sprite, sprite->data[0]); + FieldEffectStop(sprite, sprite->sWaitFldEff); else UpdateObjectEventSpriteInvisibility(sprite, FALSE); } @@ -1658,8 +1663,6 @@ static void UpdateGrassFieldEffectSubpriority(struct Sprite *sprite, u8 elevatio { u8 i; s16 var, xhi, lyhi, yhi, ylo; - const struct ObjectEventGraphicsInfo *graphicsInfo; // Unused Variable - struct Sprite *linkedSprite; SetObjectSubpriorityByElevation(elevation, sprite, subpriority); for (i = 0; i < OBJECT_EVENTS_COUNT; i ++) @@ -1667,8 +1670,9 @@ static void UpdateGrassFieldEffectSubpriority(struct Sprite *sprite, u8 elevatio struct ObjectEvent *objectEvent = &gObjectEvents[i]; if (objectEvent->active) { - graphicsInfo = GetObjectEventGraphicsInfo(objectEvent->graphicsId); - linkedSprite = &gSprites[objectEvent->spriteId]; + const struct ObjectEventGraphicsInfo *graphicsInfo = GetObjectEventGraphicsInfo(objectEvent->graphicsId); // Unused + struct Sprite *linkedSprite = &gSprites[objectEvent->spriteId]; + xhi = sprite->x + sprite->centerToCornerVecX; var = sprite->x - sprite->centerToCornerVecX; if (xhi < linkedSprite->x && var > linkedSprite->x) diff --git a/src/use_pokeblock.c b/src/use_pokeblock.c index 06df5d0a3349..b01427ebdfd4 100644 --- a/src/use_pokeblock.c +++ b/src/use_pokeblock.c @@ -1116,7 +1116,7 @@ static u8 GetPartyIdFromSelectionId_(u8 selectionId) static void LoadAndCreateUpDownSprites(void) { - u16 i, spriteId; + u16 i; LoadSpriteSheet(&sSpriteSheet_UpDown); LoadSpritePalette(&sSpritePalette_UpDown); @@ -1126,7 +1126,7 @@ static void LoadAndCreateUpDownSprites(void) { if (sInfo->enhancements[i] != 0) { - spriteId = CreateSprite(&sSpriteTemplate_UpDown, sUpDownCoordsOnGraph[i][0], sUpDownCoordsOnGraph[i][1], 0); + u16 spriteId = CreateSprite(&sSpriteTemplate_UpDown, sUpDownCoordsOnGraph[i][0], sUpDownCoordsOnGraph[i][1], 0); if (spriteId != MAX_SPRITES) { if (sInfo->enhancements[i] != 0) // Always true here @@ -1137,20 +1137,24 @@ static void LoadAndCreateUpDownSprites(void) } } +#define tTimer data[0] + static void SpriteCB_UpDown(struct Sprite *sprite) { - if (sprite->data[0] < 6) + if (sprite->tTimer < 6) sprite->y2 -= 2; - else if (sprite->data[0] < 12) + else if (sprite->tTimer < 12) sprite->y2 += 2; - if (++sprite->data[0] > 60) + if (++sprite->tTimer > 60) { DestroySprite(sprite); sInfo->numEnhancements--; } } +#undef tTimer + static void LoadPartyInfo(void) { u16 i; @@ -1612,12 +1616,15 @@ static void LoadConditionGfx(void) LoadSpritePalette(&spritePalette); } +#define sSpeed data[0] +#define sTargetX data[1] + static void CreateConditionSprite(void) { u16 i; s16 xDiff, xStart; int yStart = 17; - int var = 8; + int speed = 8; struct Sprite **sprites = sMenu->condition; const struct SpriteTemplate *template = &sSpriteTemplate_Condition; @@ -1626,9 +1633,9 @@ static void CreateConditionSprite(void) u8 spriteId = CreateSprite(template, i * xDiff + xStart, yStart, 0); if (spriteId != MAX_SPRITES) { - gSprites[spriteId].data[0] = var; - gSprites[spriteId].data[1] = (i * xDiff) | 0x20; - gSprites[spriteId].data[2] = i; + gSprites[spriteId].sSpeed = speed; + gSprites[spriteId].sTargetX = (i * xDiff) | 0x20; + gSprites[spriteId].data[2] = i; // Unused StartSpriteAnim(&gSprites[spriteId], i); sprites[i] = &gSprites[spriteId]; } @@ -1657,11 +1664,15 @@ static void SpriteCB_Condition(struct Sprite *sprite) { s16 prevX = sprite->x; - sprite->x += sprite->data[0]; - if ((prevX <= sprite->data[1] && sprite->x >= sprite->data[1]) - || (prevX >= sprite->data[1] && sprite->x <= sprite->data[1])) + // Slide onscreen + sprite->x += sprite->sSpeed; + + // Check if target position has been reached/surpassed + if ((prevX <= sprite->sTargetX && sprite->x >= sprite->sTargetX) + || (prevX >= sprite->sTargetX && sprite->x <= sprite->sTargetX)) { - sprite->x = sprite->data[1]; + // End slide onscreen, become static sprite. + sprite->x = sprite->sTargetX; sprite->callback = SpriteCallbackDummy; } } From 9d170c7e3532cec8e7869ea1ad1bd0d9aede91ce Mon Sep 17 00:00:00 2001 From: grunt-lucas Date: Tue, 22 Aug 2023 07:37:48 -0700 Subject: [PATCH 13/48] gbagfx to respect user CC setting --- tools/gbagfx/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/gbagfx/Makefile b/tools/gbagfx/Makefile index 8728fa8d094c..8a52d52d3742 100644 --- a/tools/gbagfx/Makefile +++ b/tools/gbagfx/Makefile @@ -1,4 +1,4 @@ -CC = gcc +CC ?= gcc CFLAGS = -Wall -Wextra -Werror -Wno-sign-compare -std=c11 -O2 -DPNG_SKIP_SETJMP_CHECK CFLAGS += $(shell pkg-config --cflags libpng) From 5abeb6718dbbd7c2e38667f7115025c34bbce0c5 Mon Sep 17 00:00:00 2001 From: WhenGryphonsFly <84215159+WhenGryphonsFly@users.noreply.github.com> Date: Sun, 27 Aug 2023 14:30:57 -0500 Subject: [PATCH 14/48] Correct KEY_INTR_ENABLE --- include/gba/io_reg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/gba/io_reg.h b/include/gba/io_reg.h index 148ce31db432..53021185e3cc 100644 --- a/include/gba/io_reg.h +++ b/include/gba/io_reg.h @@ -707,7 +707,7 @@ #define R_BUTTON 0x0100 #define L_BUTTON 0x0200 #define KEYS_MASK 0x03FF -#define KEY_INTR_ENABLE 0x0400 +#define KEY_INTR_ENABLE 0x4000 #define KEY_OR_INTR 0x0000 #define KEY_AND_INTR 0x8000 #define DPAD_ANY ((DPAD_RIGHT | DPAD_LEFT | DPAD_UP | DPAD_DOWN)) From a8d0a0d709282e9580ad6d96b5af9e99b6173dbc Mon Sep 17 00:00:00 2001 From: AnonymousRandomPerson Date: Wed, 30 Aug 2023 00:08:19 -0400 Subject: [PATCH 15/48] Replaced decomp list with pret.github.io link --- README.md | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/README.md b/README.md index bca4fd10411a..d9148b32ecff 100644 --- a/README.md +++ b/README.md @@ -8,30 +8,4 @@ It builds the following ROM: To set up the repository, see [INSTALL.md](INSTALL.md). - -## See also - -Other disassembly and/or decompilation projects: -* [**Pokémon Red and Blue**](https://github.com/pret/pokered) -* [**Pokémon Gold and Silver (Space World '97 demo)**](https://github.com/pret/pokegold-spaceworld) -* [**Pokémon Yellow**](https://github.com/pret/pokeyellow) -* [**Pokémon Trading Card Game**](https://github.com/pret/poketcg) -* [**Pokémon Pinball**](https://github.com/pret/pokepinball) -* [**Pokémon Stadium**](https://github.com/pret/pokestadium) -* [**Pokémon Gold and Silver**](https://github.com/pret/pokegold) -* [**Pokémon Crystal**](https://github.com/pret/pokecrystal) -* [**Pokémon Ruby and Sapphire**](https://github.com/pret/pokeruby) -* [**Pokémon Pinball: Ruby & Sapphire**](https://github.com/pret/pokepinballrs) -* [**Pokémon FireRed and LeafGreen**](https://github.com/pret/pokefirered) -* [**Pokémon Mystery Dungeon: Red Rescue Team**](https://github.com/pret/pmd-red) -* [**Pokémon Diamond and Pearl**](https://github.com/pret/pokediamond) -* [**Pokémon Platinum**](https://github.com/pret/pokeplatinum) -* [**Pokémon HeartGold and SoulSilver**](https://github.com/pret/pokeheartgold) -* [**Pokémon Mystery Dungeon: Explorers of Sky**](https://github.com/pret/pmd-sky) - -## Contacts - -You can find us on: - -* [Discord (PRET, #pokeemerald)](https://discord.gg/d5dubZ3) -* [IRC](https://web.libera.chat/?#pret) +For contacts and other pret projects, see [pret.github.io](https://pret.github.io/). From 4439253f3970d6402ee087d91886401a003c7bb7 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sun, 3 Sep 2023 20:57:54 -0400 Subject: [PATCH 16/48] Add include guards for assembly constants files --- constants/gba_constants.inc | 5 +++++ constants/global.inc | 5 +++++ constants/m4a_constants.inc | 5 +++++ constants/tms_hms.inc | 5 +++++ 4 files changed, 20 insertions(+) diff --git a/constants/gba_constants.inc b/constants/gba_constants.inc index 3ff857ee8dfb..9f51b0f02b02 100644 --- a/constants/gba_constants.inc +++ b/constants/gba_constants.inc @@ -1,3 +1,6 @@ +#ifndef GUARD_CONSTANTS_GBA_CONSTANTS_INC +#define GUARD_CONSTANTS_GBA_CONSTANTS_INC + .set PSR_USR_MODE, 0x00000010 .set PSR_FIQ_MODE, 0x00000011 .set PSR_IRQ_MODE, 0x00000012 @@ -511,3 +514,5 @@ .set BLDCNT_TGT2_OBJ, 1 << 12 .set BLDCNT_TGT2_BD, 1 << 13 .set BLDCNT_TGT2_ALL, BLDCNT_TGT2_BG0 | BLDCNT_TGT2_BG1 | BLDCNT_TGT2_BG2 | BLDCNT_TGT2_BG3 | BLDCNT_TGT2_OBJ | BLDCNT_TGT2_BD + +#endif @ GUARD_CONSTANTS_GBA_CONSTANTS_INC diff --git a/constants/global.inc b/constants/global.inc index 621ba2af89d2..b9462fa26b62 100644 --- a/constants/global.inc +++ b/constants/global.inc @@ -1,3 +1,6 @@ +#ifndef GUARD_CONSTANTS_GLOBAL_INC +#define GUARD_CONSTANTS_GLOBAL_INC + .set TRUE, 1 .set FALSE, 0 @@ -20,3 +23,5 @@ .set OBJ_IMAGE_ANIM_H_FLIP, 1 << 6 .set OBJ_IMAGE_ANIM_V_FLIP, 1 << 7 + +#endif @ GUARD_CONSTANTS_GLOBAL_INC diff --git a/constants/m4a_constants.inc b/constants/m4a_constants.inc index 1a744dc7fb6a..2599b6c4aa0f 100644 --- a/constants/m4a_constants.inc +++ b/constants/m4a_constants.inc @@ -1,3 +1,6 @@ +#ifndef GUARD_CONSTANTS_M4A_CONSTANTS_INC +#define GUARD_CONSTANTS_M4A_CONSTANTS_INC + .equiv ID_NUMBER, 0x68736d53 .equiv PCM_DMA_BUF_SIZE, 1584 @@ -250,3 +253,5 @@ struct_field o_CgbChannel_nextChannelPointer, 4 struct_field o_CgbChannel_dummy4, 8 struct_field CgbChannel_size, 0 + +#endif @ GUARD_CONSTANTS_M4A_CONSTANTS_INC diff --git a/constants/tms_hms.inc b/constants/tms_hms.inc index 3450aa73bad8..4ce6d903285c 100644 --- a/constants/tms_hms.inc +++ b/constants/tms_hms.inc @@ -1,3 +1,6 @@ +#ifndef GUARD_CONSTANTS_TMS_HMS_INC +#define GUARD_CONSTANTS_TMS_HMS_INC + #include "constants/tms_hms.h" /* Expands to: @@ -15,3 +18,5 @@ FOREACH_TM(EQUIV_TM) FOREACH_HM(EQUIV_HM) #undef EQUIV_TM #undef EQUIV_HM + +#endif @ GUARD_CONSTANTS_TMS_HMS_INC From d31b168522afe0151378b5fc9a0a433ed8315f5c Mon Sep 17 00:00:00 2001 From: citrusbolt Date: Tue, 5 Sep 2023 06:17:10 -0600 Subject: [PATCH 17/48] Add `blockBoxRS` field to `struct BoxPokemon` --- include/pokemon.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/pokemon.h b/include/pokemon.h index f4f6d6989e61..6d08f487469b 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -202,7 +202,8 @@ struct BoxPokemon u8 isBadEgg:1; u8 hasSpecies:1; u8 isEgg:1; - u8 unused:5; + u8 blockBoxRS:1; // Unused, but Pokémon Box Ruby & Sapphire will refuse to deposit a Pokémon with this flag set + u8 unused:4; u8 otName[PLAYER_NAME_LENGTH]; u8 markings; u16 checksum; From b89722500f776781c30c8b18fbc81986d5089a68 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Tue, 12 Sep 2023 13:09:56 -0300 Subject: [PATCH 18/48] Fixed Mr. Mime capitalization --- include/graphics.h | 14 +++++++------- src/anim_mon_front_pics.c | 2 +- src/data/graphics/pokemon.h | 12 ++++++------ src/data/pokemon/level_up_learnset_pointers.h | 2 +- src/data/pokemon/level_up_learnsets.h | 2 +- src/data/pokemon/pokedex_entries.h | 2 +- src/data/pokemon/pokedex_text.h | 2 +- src/data/pokemon_graphics/back_pic_table.h | 2 +- src/data/pokemon_graphics/footprint_table.h | 2 +- src/data/pokemon_graphics/front_pic_table.h | 2 +- src/data/pokemon_graphics/palette_table.h | 2 +- src/data/pokemon_graphics/shiny_palette_table.h | 2 +- src/data/pokemon_graphics/still_front_pic_table.h | 2 +- src/pokemon_icon.c | 2 +- 14 files changed, 25 insertions(+), 25 deletions(-) diff --git a/include/graphics.h b/include/graphics.h index 9fab084f27f3..5b13ab562f31 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -881,13 +881,13 @@ extern const u32 gMonShinyPalette_Starmie[]; extern const u32 gMonStillFrontPic_Starmie[]; extern const u8 gMonIcon_Starmie[]; extern const u8 gMonFootprint_Starmie[]; -extern const u32 gMonFrontPic_Mrmime[]; -extern const u32 gMonPalette_Mrmime[]; -extern const u32 gMonBackPic_Mrmime[]; -extern const u32 gMonShinyPalette_Mrmime[]; -extern const u32 gMonStillFrontPic_Mrmime[]; -extern const u8 gMonIcon_Mrmime[]; -extern const u8 gMonFootprint_Mrmime[]; +extern const u32 gMonFrontPic_MrMime[]; +extern const u32 gMonPalette_MrMime[]; +extern const u32 gMonBackPic_MrMime[]; +extern const u32 gMonShinyPalette_MrMime[]; +extern const u32 gMonStillFrontPic_MrMime[]; +extern const u8 gMonIcon_MrMime[]; +extern const u8 gMonFootprint_MrMime[]; extern const u32 gMonFrontPic_Scyther[]; extern const u32 gMonPalette_Scyther[]; extern const u32 gMonBackPic_Scyther[]; diff --git a/src/anim_mon_front_pics.c b/src/anim_mon_front_pics.c index e36cf3492d36..de7014607885 100644 --- a/src/anim_mon_front_pics.c +++ b/src/anim_mon_front_pics.c @@ -123,7 +123,7 @@ const u32 gMonFrontPic_Goldeen[] = INCBIN_U32("graphics/pokemon/goldeen/anim_fro const u32 gMonFrontPic_Seaking[] = INCBIN_U32("graphics/pokemon/seaking/anim_front.4bpp.lz"); const u32 gMonFrontPic_Staryu[] = INCBIN_U32("graphics/pokemon/staryu/anim_front.4bpp.lz"); const u32 gMonFrontPic_Starmie[] = INCBIN_U32("graphics/pokemon/starmie/anim_front.4bpp.lz"); -const u32 gMonFrontPic_Mrmime[] = INCBIN_U32("graphics/pokemon/mr_mime/anim_front.4bpp.lz"); +const u32 gMonFrontPic_MrMime[] = INCBIN_U32("graphics/pokemon/mr_mime/anim_front.4bpp.lz"); const u32 gMonFrontPic_Scyther[] = INCBIN_U32("graphics/pokemon/scyther/anim_front.4bpp.lz"); const u32 gMonFrontPic_Jynx[] = INCBIN_U32("graphics/pokemon/jynx/anim_front.4bpp.lz"); const u32 gMonFrontPic_Electabuzz[] = INCBIN_U32("graphics/pokemon/electabuzz/anim_front.4bpp.lz"); diff --git a/src/data/graphics/pokemon.h b/src/data/graphics/pokemon.h index f69fafec84c6..fdd9fd87cc46 100644 --- a/src/data/graphics/pokemon.h +++ b/src/data/graphics/pokemon.h @@ -845,12 +845,12 @@ const u32 gMonShinyPalette_Starmie[] = INCBIN_U32("graphics/pokemon/starmie/shin const u8 gMonIcon_Starmie[] = INCBIN_U8("graphics/pokemon/starmie/icon.4bpp"); const u8 gMonFootprint_Starmie[] = INCBIN_U8("graphics/pokemon/starmie/footprint.1bpp"); -const u32 gMonStillFrontPic_Mrmime[] = INCBIN_U32("graphics/pokemon/mr_mime/front.4bpp.lz"); -const u32 gMonPalette_Mrmime[] = INCBIN_U32("graphics/pokemon/mr_mime/normal.gbapal.lz"); -const u32 gMonBackPic_Mrmime[] = INCBIN_U32("graphics/pokemon/mr_mime/back.4bpp.lz"); -const u32 gMonShinyPalette_Mrmime[] = INCBIN_U32("graphics/pokemon/mr_mime/shiny.gbapal.lz"); -const u8 gMonIcon_Mrmime[] = INCBIN_U8("graphics/pokemon/mr_mime/icon.4bpp"); -const u8 gMonFootprint_Mrmime[] = INCBIN_U8("graphics/pokemon/mr_mime/footprint.1bpp"); +const u32 gMonStillFrontPic_MrMime[] = INCBIN_U32("graphics/pokemon/mr_mime/front.4bpp.lz"); +const u32 gMonPalette_MrMime[] = INCBIN_U32("graphics/pokemon/mr_mime/normal.gbapal.lz"); +const u32 gMonBackPic_MrMime[] = INCBIN_U32("graphics/pokemon/mr_mime/back.4bpp.lz"); +const u32 gMonShinyPalette_MrMime[] = INCBIN_U32("graphics/pokemon/mr_mime/shiny.gbapal.lz"); +const u8 gMonIcon_MrMime[] = INCBIN_U8("graphics/pokemon/mr_mime/icon.4bpp"); +const u8 gMonFootprint_MrMime[] = INCBIN_U8("graphics/pokemon/mr_mime/footprint.1bpp"); const u32 gMonStillFrontPic_Scyther[] = INCBIN_U32("graphics/pokemon/scyther/front.4bpp.lz"); const u32 gMonPalette_Scyther[] = INCBIN_U32("graphics/pokemon/scyther/normal.gbapal.lz"); diff --git a/src/data/pokemon/level_up_learnset_pointers.h b/src/data/pokemon/level_up_learnset_pointers.h index 5ac7b3bd74a7..661458ce383e 100644 --- a/src/data/pokemon/level_up_learnset_pointers.h +++ b/src/data/pokemon/level_up_learnset_pointers.h @@ -122,7 +122,7 @@ const u16 *const gLevelUpLearnsets[NUM_SPECIES] = [SPECIES_SEAKING] = sSeakingLevelUpLearnset, [SPECIES_STARYU] = sStaryuLevelUpLearnset, [SPECIES_STARMIE] = sStarmieLevelUpLearnset, - [SPECIES_MR_MIME] = sMrmimeLevelUpLearnset, + [SPECIES_MR_MIME] = sMrMimeLevelUpLearnset, [SPECIES_SCYTHER] = sScytherLevelUpLearnset, [SPECIES_JYNX] = sJynxLevelUpLearnset, [SPECIES_ELECTABUZZ] = sElectabuzzLevelUpLearnset, diff --git a/src/data/pokemon/level_up_learnsets.h b/src/data/pokemon/level_up_learnsets.h index c78b9ef0a7c9..212b969a70e0 100644 --- a/src/data/pokemon/level_up_learnsets.h +++ b/src/data/pokemon/level_up_learnsets.h @@ -1681,7 +1681,7 @@ static const u16 sStarmieLevelUpLearnset[] = { LEVEL_UP_END }; -static const u16 sMrmimeLevelUpLearnset[] = { +static const u16 sMrMimeLevelUpLearnset[] = { LEVEL_UP_MOVE( 1, MOVE_BARRIER), LEVEL_UP_MOVE( 5, MOVE_CONFUSION), LEVEL_UP_MOVE( 9, MOVE_SUBSTITUTE), diff --git a/src/data/pokemon/pokedex_entries.h b/src/data/pokemon/pokedex_entries.h index 007c73248e1c..8a15a18567fc 100644 --- a/src/data/pokemon/pokedex_entries.h +++ b/src/data/pokemon/pokedex_entries.h @@ -1469,7 +1469,7 @@ const struct PokedexEntry gPokedexEntries[] = .categoryName = _("BARRIER"), .height = 13, .weight = 545, - .description = gMrmimePokedexText, + .description = gMrMimePokedexText, .pokemonScale = 258, .pokemonOffset = 6, .trainerScale = 256, diff --git a/src/data/pokemon/pokedex_text.h b/src/data/pokemon/pokedex_text.h index 0daf7fc86c26..ec4a831f86de 100644 --- a/src/data/pokemon/pokedex_text.h +++ b/src/data/pokemon/pokedex_text.h @@ -730,7 +730,7 @@ const u8 gStarmiePokedexText[] = _( "reflections of stars that twinkled on\n" "gentle waves at night."); -const u8 gMrmimePokedexText[] = _( +const u8 gMrMimePokedexText[] = _( "A MR. MIME is a master of pantomime. It can\n" "convince others that something unseeable\n" "actually exists. Once believed, the\n" diff --git a/src/data/pokemon_graphics/back_pic_table.h b/src/data/pokemon_graphics/back_pic_table.h index 9a98927aaccc..1a51f9ccdd40 100644 --- a/src/data/pokemon_graphics/back_pic_table.h +++ b/src/data/pokemon_graphics/back_pic_table.h @@ -122,7 +122,7 @@ const struct CompressedSpriteSheet gMonBackPicTable[] = SPECIES_SPRITE(SEAKING, gMonBackPic_Seaking), SPECIES_SPRITE(STARYU, gMonBackPic_Staryu), SPECIES_SPRITE(STARMIE, gMonBackPic_Starmie), - SPECIES_SPRITE(MR_MIME, gMonBackPic_Mrmime), + SPECIES_SPRITE(MR_MIME, gMonBackPic_MrMime), SPECIES_SPRITE(SCYTHER, gMonBackPic_Scyther), SPECIES_SPRITE(JYNX, gMonBackPic_Jynx), SPECIES_SPRITE(ELECTABUZZ, gMonBackPic_Electabuzz), diff --git a/src/data/pokemon_graphics/footprint_table.h b/src/data/pokemon_graphics/footprint_table.h index 86ca067901f9..d63e33e5b75b 100644 --- a/src/data/pokemon_graphics/footprint_table.h +++ b/src/data/pokemon_graphics/footprint_table.h @@ -122,7 +122,7 @@ const u8 *const gMonFootprintTable[] = [SPECIES_SEAKING] = gMonFootprint_Seaking, [SPECIES_STARYU] = gMonFootprint_Staryu, [SPECIES_STARMIE] = gMonFootprint_Starmie, - [SPECIES_MR_MIME] = gMonFootprint_Mrmime, + [SPECIES_MR_MIME] = gMonFootprint_MrMime, [SPECIES_SCYTHER] = gMonFootprint_Scyther, [SPECIES_JYNX] = gMonFootprint_Jynx, [SPECIES_ELECTABUZZ] = gMonFootprint_Electabuzz, diff --git a/src/data/pokemon_graphics/front_pic_table.h b/src/data/pokemon_graphics/front_pic_table.h index 82af860d3006..acb0bba25258 100644 --- a/src/data/pokemon_graphics/front_pic_table.h +++ b/src/data/pokemon_graphics/front_pic_table.h @@ -122,7 +122,7 @@ const struct CompressedSpriteSheet gMonFrontPicTable[] = SPECIES_SPRITE(SEAKING, gMonFrontPic_Seaking), SPECIES_SPRITE(STARYU, gMonFrontPic_Staryu), SPECIES_SPRITE(STARMIE, gMonFrontPic_Starmie), - SPECIES_SPRITE(MR_MIME, gMonFrontPic_Mrmime), + SPECIES_SPRITE(MR_MIME, gMonFrontPic_MrMime), SPECIES_SPRITE(SCYTHER, gMonFrontPic_Scyther), SPECIES_SPRITE(JYNX, gMonFrontPic_Jynx), SPECIES_SPRITE(ELECTABUZZ, gMonFrontPic_Electabuzz), diff --git a/src/data/pokemon_graphics/palette_table.h b/src/data/pokemon_graphics/palette_table.h index 35edcc76c13b..8bdfd2dbd9dd 100644 --- a/src/data/pokemon_graphics/palette_table.h +++ b/src/data/pokemon_graphics/palette_table.h @@ -122,7 +122,7 @@ const struct CompressedSpritePalette gMonPaletteTable[] = SPECIES_PAL(SEAKING, gMonPalette_Seaking), SPECIES_PAL(STARYU, gMonPalette_Staryu), SPECIES_PAL(STARMIE, gMonPalette_Starmie), - SPECIES_PAL(MR_MIME, gMonPalette_Mrmime), + SPECIES_PAL(MR_MIME, gMonPalette_MrMime), SPECIES_PAL(SCYTHER, gMonPalette_Scyther), SPECIES_PAL(JYNX, gMonPalette_Jynx), SPECIES_PAL(ELECTABUZZ, gMonPalette_Electabuzz), diff --git a/src/data/pokemon_graphics/shiny_palette_table.h b/src/data/pokemon_graphics/shiny_palette_table.h index 8b1cfcaacadf..1db14d864a8a 100644 --- a/src/data/pokemon_graphics/shiny_palette_table.h +++ b/src/data/pokemon_graphics/shiny_palette_table.h @@ -122,7 +122,7 @@ const struct CompressedSpritePalette gMonShinyPaletteTable[] = SPECIES_SHINY_PAL(SEAKING, gMonShinyPalette_Seaking), SPECIES_SHINY_PAL(STARYU, gMonShinyPalette_Staryu), SPECIES_SHINY_PAL(STARMIE, gMonShinyPalette_Starmie), - SPECIES_SHINY_PAL(MR_MIME, gMonShinyPalette_Mrmime), + SPECIES_SHINY_PAL(MR_MIME, gMonShinyPalette_MrMime), SPECIES_SHINY_PAL(SCYTHER, gMonShinyPalette_Scyther), SPECIES_SHINY_PAL(JYNX, gMonShinyPalette_Jynx), SPECIES_SHINY_PAL(ELECTABUZZ, gMonShinyPalette_Electabuzz), diff --git a/src/data/pokemon_graphics/still_front_pic_table.h b/src/data/pokemon_graphics/still_front_pic_table.h index 985a3aa2fdea..9a77855ab4f8 100644 --- a/src/data/pokemon_graphics/still_front_pic_table.h +++ b/src/data/pokemon_graphics/still_front_pic_table.h @@ -122,7 +122,7 @@ const struct CompressedSpriteSheet gMonStillFrontPicTable[] = SPECIES_SPRITE(SEAKING, gMonStillFrontPic_Seaking), SPECIES_SPRITE(STARYU, gMonStillFrontPic_Staryu), SPECIES_SPRITE(STARMIE, gMonStillFrontPic_Starmie), - SPECIES_SPRITE(MR_MIME, gMonStillFrontPic_Mrmime), + SPECIES_SPRITE(MR_MIME, gMonStillFrontPic_MrMime), SPECIES_SPRITE(SCYTHER, gMonStillFrontPic_Scyther), SPECIES_SPRITE(JYNX, gMonStillFrontPic_Jynx), SPECIES_SPRITE(ELECTABUZZ, gMonStillFrontPic_Electabuzz), diff --git a/src/pokemon_icon.c b/src/pokemon_icon.c index 8e37018cba6a..e659eebe21b0 100644 --- a/src/pokemon_icon.c +++ b/src/pokemon_icon.c @@ -146,7 +146,7 @@ const u8 *const gMonIconTable[] = [SPECIES_SEAKING] = gMonIcon_Seaking, [SPECIES_STARYU] = gMonIcon_Staryu, [SPECIES_STARMIE] = gMonIcon_Starmie, - [SPECIES_MR_MIME] = gMonIcon_Mrmime, + [SPECIES_MR_MIME] = gMonIcon_MrMime, [SPECIES_SCYTHER] = gMonIcon_Scyther, [SPECIES_JYNX] = gMonIcon_Jynx, [SPECIES_ELECTABUZZ] = gMonIcon_Electabuzz, From 4ed4b690198357a5bd68759b977c57e7d3f07f39 Mon Sep 17 00:00:00 2001 From: sbird Date: Fri, 15 Sep 2023 19:11:25 +0200 Subject: [PATCH 19/48] [BUGFIX] for abilities affecting wild encounter tables fixes a potential buffer overread in TryGetAbilityInfluencedWildMonIndex. The bug can occur if an electric type mon is in the first slots of a fishing encounter table and the player carries a mon with the `ABILITY_STATIC` ability. This never happens in the vanilla codebase. --- src/wild_encounter.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/wild_encounter.c b/src/wild_encounter.c index 87d7d866bbc9..3a7f6cab230e 100644 --- a/src/wild_encounter.c +++ b/src/wild_encounter.c @@ -52,7 +52,11 @@ static void FeebasSeedRng(u16 seed); static bool8 IsWildLevelAllowedByRepel(u8 level); static void ApplyFluteEncounterRateMod(u32 *encRate); static void ApplyCleanseTagEncounterRateMod(u32 *encRate); +#ifdef BUGFIX +static bool8 TryGetAbilityInfluencedWildMonIndex(const struct WildPokemon *wildMon, u8 type, u8 ability, u8 *monIndex, u32 size); +#else static bool8 TryGetAbilityInfluencedWildMonIndex(const struct WildPokemon *wildMon, u8 type, u8 ability, u8 *monIndex); +#endif static bool8 IsAbilityAllowingEncounter(u8 level); EWRAM_DATA static u8 sWildEncountersDisabled = 0; @@ -409,6 +413,11 @@ static void CreateWildMon(u16 species, u8 level) CreateMonWithNature(&gEnemyParty[0], species, level, USE_RANDOM_IVS, PickWildMonNature()); } +#ifdef BUGFIX +#define TRY_GET_ABILITY_INFLUENCED_WILD_MON_INDEX(wildPokemon, type, ability, ptr, count) TryGetAbilityInfluencedWildMonIndex(wildPokemon, type, ability, ptr, count) +#else +#define TRY_GET_ABILITY_INFLUENCED_WILD_MON_INDEX(wildPokemon, type, ability, ptr, count) TryGetAbilityInfluencedWildMonIndex(wildPokemon, type, ability, ptr) +#endif static bool8 TryGenerateWildMon(const struct WildPokemonInfo *wildMonInfo, u8 area, u8 flags) { @@ -418,15 +427,15 @@ static bool8 TryGenerateWildMon(const struct WildPokemonInfo *wildMonInfo, u8 ar switch (area) { case WILD_AREA_LAND: - if (TryGetAbilityInfluencedWildMonIndex(wildMonInfo->wildPokemon, TYPE_STEEL, ABILITY_MAGNET_PULL, &wildMonIndex)) + if (TRY_GET_ABILITY_INFLUENCED_WILD_MON_INDEX(wildMonInfo->wildPokemon, TYPE_STEEL, ABILITY_MAGNET_PULL, &wildMonIndex, LAND_WILD_COUNT)) break; - if (TryGetAbilityInfluencedWildMonIndex(wildMonInfo->wildPokemon, TYPE_ELECTRIC, ABILITY_STATIC, &wildMonIndex)) + if (TRY_GET_ABILITY_INFLUENCED_WILD_MON_INDEX(wildMonInfo->wildPokemon, TYPE_ELECTRIC, ABILITY_STATIC, &wildMonIndex, LAND_WILD_COUNT)) break; wildMonIndex = ChooseWildMonIndex_Land(); break; case WILD_AREA_WATER: - if (TryGetAbilityInfluencedWildMonIndex(wildMonInfo->wildPokemon, TYPE_ELECTRIC, ABILITY_STATIC, &wildMonIndex)) + if (TRY_GET_ABILITY_INFLUENCED_WILD_MON_INDEX(wildMonInfo->wildPokemon, TYPE_ELECTRIC, ABILITY_STATIC, &wildMonIndex, WATER_WILD_COUNT)) break; wildMonIndex = ChooseWildMonIndex_WaterRock(); @@ -923,8 +932,11 @@ static bool8 TryGetRandomWildMonIndexByType(const struct WildPokemon *wildMon, u *monIndex = validIndexes[Random() % validMonCount]; return TRUE; } - +#ifdef BUGFIX +static bool8 TryGetAbilityInfluencedWildMonIndex(const struct WildPokemon *wildMon, u8 type, u8 ability, u8 *monIndex, u32 size) +#else static bool8 TryGetAbilityInfluencedWildMonIndex(const struct WildPokemon *wildMon, u8 type, u8 ability, u8 *monIndex) +#endif { if (GetMonData(&gPlayerParty[0], MON_DATA_SANITY_IS_EGG)) return FALSE; @@ -933,7 +945,11 @@ static bool8 TryGetAbilityInfluencedWildMonIndex(const struct WildPokemon *wildM else if (Random() % 2 != 0) return FALSE; +#ifdef BUGFIX + return TryGetRandomWildMonIndexByType(wildMon, type, size, monIndex); +#else return TryGetRandomWildMonIndexByType(wildMon, type, LAND_WILD_COUNT, monIndex); +#endif } static void ApplyFluteEncounterRateMod(u32 *encRate) From fb6f45b2c325b22f43d939b11fcba751b390c2f0 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sun, 17 Sep 2023 13:45:06 -0300 Subject: [PATCH 20/48] Slight RTC documentation + Evolution times constants --- include/siirtc.h | 7 ++++++- src/pokemon.c | 10 ++++++++-- src/rtc.c | 48 ++++++++++++++++++++++++------------------------ 3 files changed, 38 insertions(+), 27 deletions(-) diff --git a/include/siirtc.h b/include/siirtc.h index de4fd634df90..24573e4429f6 100644 --- a/include/siirtc.h +++ b/include/siirtc.h @@ -9,6 +9,10 @@ #define SIIRTCINFO_24HOUR 0x40 // 0: 12-hour mode, 1: 24-hour mode #define SIIRTCINFO_POWER 0x80 // power on or power failure occurred +#define DAY_HOURS 24 +#define HOUR_MINUTES 60 +#define MINUTE_SECONDS 60 + enum { MONTH_JAN = 1, @@ -22,7 +26,8 @@ enum MONTH_SEP, MONTH_OCT, MONTH_NOV, - MONTH_DEC + MONTH_DEC, + MONTH_COUNT = MONTH_DEC }; struct SiiRtcInfo diff --git a/src/pokemon.c b/src/pokemon.c index 7bc9f3bee317..fe93c14c192c 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -48,6 +48,12 @@ #include "constants/trainers.h" #include "constants/union_room.h" +#define DAY_EVO_HOUR_BEGIN 12 +#define DAY_EVO_HOUR_END DAY_HOURS + +#define NIGHT_EVO_HOUR_BEGIN 0 +#define NIGHT_EVO_HOUR_END 12 + struct SpeciesItem { u16 species; @@ -5498,12 +5504,12 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 mode, u16 evolutionItem) break; case EVO_FRIENDSHIP_DAY: RtcCalcLocalTime(); - if (gLocalTime.hours >= 12 && gLocalTime.hours < 24 && friendship >= 220) + if (gLocalTime.hours >= DAY_EVO_HOUR_BEGIN && gLocalTime.hours < DAY_EVO_HOUR_END && friendship >= 220) targetSpecies = gEvolutionTable[species][i].targetSpecies; break; case EVO_FRIENDSHIP_NIGHT: RtcCalcLocalTime(); - if (gLocalTime.hours >= 0 && gLocalTime.hours < 12 && friendship >= 220) + if (gLocalTime.hours >= NIGHT_EVO_HOUR_BEGIN && gLocalTime.hours < NIGHT_EVO_HOUR_END && friendship >= 220) targetSpecies = gEvolutionTable[species][i].targetSpecies; break; case EVO_LEVEL: diff --git a/src/rtc.c b/src/rtc.c index b135a675a844..a4920025cf93 100644 --- a/src/rtc.c +++ b/src/rtc.c @@ -16,20 +16,20 @@ struct Time gLocalTime; static const struct SiiRtcInfo sRtcDummy = {0, MONTH_JAN, 1}; // 2000 Jan 1 -static const s32 sNumDaysInMonths[12] = +static const s32 sNumDaysInMonths[MONTH_COUNT] = { - 31, - 28, - 31, - 30, - 31, - 30, - 31, - 31, - 30, - 31, - 30, - 31, + [MONTH_JAN - 1] = 31, + [MONTH_FEB - 1] = 28, + [MONTH_MAR - 1] = 31, + [MONTH_APR - 1] = 30, + [MONTH_MAY - 1] = 31, + [MONTH_JUN - 1] = 30, + [MONTH_JUL - 1] = 31, + [MONTH_AUG - 1] = 31, + [MONTH_SEP - 1] = 30, + [MONTH_OCT - 1] = 31, + [MONTH_NOV - 1] = 30, + [MONTH_DEC - 1] = 31, }; void RtcDisableInterrupts(void) @@ -171,7 +171,7 @@ u16 RtcCheckInfo(struct SiiRtcInfo *rtc) month = ConvertBcdToBinary(rtc->month); - if (month == 0xFF || month == 0 || month > 12) + if (month == 0xFF || month == 0 || month > MONTH_COUNT) errorFlags |= RTC_ERR_INVALID_MONTH; value = ConvertBcdToBinary(rtc->day); @@ -192,17 +192,17 @@ u16 RtcCheckInfo(struct SiiRtcInfo *rtc) value = ConvertBcdToBinary(rtc->hour); - if (value > 24) + if (value > DAY_HOURS) errorFlags |= RTC_ERR_INVALID_HOUR; value = ConvertBcdToBinary(rtc->minute); - if (value > 60) + if (value > HOUR_MINUTES) errorFlags |= RTC_ERR_INVALID_MINUTE; value = ConvertBcdToBinary(rtc->second); - if (value > 60) + if (value > MINUTE_SECONDS) errorFlags |= RTC_ERR_INVALID_SECOND; return errorFlags; @@ -270,19 +270,19 @@ void RtcCalcTimeDifference(struct SiiRtcInfo *rtc, struct Time *result, struct T if (result->seconds < 0) { - result->seconds += 60; + result->seconds += MINUTE_SECONDS; --result->minutes; } if (result->minutes < 0) { - result->minutes += 60; + result->minutes += HOUR_MINUTES; --result->hours; } if (result->hours < 0) { - result->hours += 24; + result->hours += DAY_HOURS; --result->days; } } @@ -317,19 +317,19 @@ void CalcTimeDifference(struct Time *result, struct Time *t1, struct Time *t2) if (result->seconds < 0) { - result->seconds += 60; + result->seconds += MINUTE_SECONDS; --result->minutes; } if (result->minutes < 0) { - result->minutes += 60; + result->minutes += HOUR_MINUTES; --result->hours; } if (result->hours < 0) { - result->hours += 24; + result->hours += DAY_HOURS; --result->days; } } @@ -337,7 +337,7 @@ void CalcTimeDifference(struct Time *result, struct Time *t1, struct Time *t2) u32 RtcGetMinuteCount(void) { RtcGetInfo(&sRtc); - return (24 * 60) * RtcGetDayCount(&sRtc) + 60 * sRtc.hour + sRtc.minute; + return (DAY_HOURS * HOUR_MINUTES) * RtcGetDayCount(&sRtc) + HOUR_MINUTES * sRtc.hour + sRtc.minute; } u32 RtcGetLocalDayCount(void) From af210da97214ed916f2736dc20699b9043b98a0e Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Wed, 20 Sep 2023 19:01:08 -0300 Subject: [PATCH 21/48] Solved a bunch of -Wall errors on modern --- gflib/string_util.c | 4 +- gflib/text.c | 6 +- gflib/window.c | 2 +- src/AgbRfu_LinkManager.c | 8 +- src/apprentice.c | 9 +- src/battle_ai_script_commands.c | 2 +- src/battle_anim_bug.c | 2 +- src/battle_anim_effects_1.c | 14 +- src/battle_anim_effects_2.c | 10 +- src/battle_anim_effects_3.c | 7 +- src/battle_anim_flying.c | 3 +- src/battle_anim_mons.c | 21 +- src/battle_anim_status_effects.c | 3 +- src/battle_anim_throw.c | 4 +- src/battle_anim_utility_funcs.c | 5 +- src/battle_arena.c | 3 +- src/battle_bg.c | 6 +- src/battle_controller_player.c | 4 +- src/battle_controller_recorded_opponent.c | 2 +- src/battle_controller_safari.c | 4 +- src/battle_controller_wally.c | 4 +- src/battle_controllers.c | 42 +- src/battle_dome.c | 4 +- src/battle_gfx_sfx_util.c | 5 +- src/battle_interface.c | 6 +- src/battle_intro.c | 2 +- src/battle_main.c | 15 +- src/battle_pike.c | 3 +- src/battle_pyramid.c | 3 +- src/battle_pyramid_bag.c | 19 +- src/battle_script_commands.c | 2 +- src/battle_setup.c | 2 +- src/battle_tent.c | 1 - src/battle_tower.c | 17 +- src/battle_transition.c | 9 +- src/battle_util.c | 7 +- src/berry_blender.c | 14 +- src/berry_crush.c | 2 +- src/berry_fix_graphics.c | 4 +- src/berry_powder.c | 10 +- src/braille_puzzles.c | 2 +- src/cable_club.c | 18 +- src/contest.c | 12 +- src/credits.c | 2 +- src/data.c | 100 +-- src/data/credits.h | 730 +++++++++++----------- src/data/pointillism_points.h | 2 +- src/data/trade.h | 4 +- src/daycare.c | 13 +- src/decompress.c | 2 +- src/decoration.c | 2 +- src/dodrio_berry_picking.c | 13 +- src/easy_chat.c | 14 +- src/egg_hatch.c | 2 +- src/event_object_movement.c | 29 +- src/evolution_scene.c | 3 +- src/field_control_avatar.c | 3 +- src/field_door.c | 6 +- src/field_effect.c | 5 +- src/field_effect_helpers.c | 2 +- src/field_message_box.c | 6 +- src/field_specials.c | 4 +- src/field_tasks.c | 2 +- src/field_weather.c | 7 +- src/field_weather_effect.c | 3 +- src/fieldmap.c | 8 +- src/fldeff_escalator.c | 14 +- src/graphics.c | 2 +- src/intro.c | 4 +- src/intro_credits_graphics.c | 2 +- src/item_menu.c | 39 +- src/item_use.c | 2 +- src/librfu_rfu.c | 4 + src/link.c | 25 +- src/link_rfu_2.c | 12 +- src/link_rfu_3.c | 13 +- src/m4a_tables.c | 7 +- src/mail_data.c | 2 +- src/main.c | 2 + src/main_menu.c | 4 +- src/map_name_popup.c | 3 +- src/mauville_old_man.c | 3 +- src/menu.c | 64 +- src/menu_specialized.c | 3 +- src/mini_printf.c | 4 +- src/minigame_countdown.c | 7 +- src/mirage_tower.c | 2 +- src/mystery_gift_menu.c | 5 +- src/naming_screen.c | 10 +- src/overworld.c | 18 +- src/palette.c | 16 +- src/palette_util.c | 7 +- src/party_menu.c | 12 +- src/player_pc.c | 24 +- src/pokeball.c | 2 +- src/pokeblock.c | 12 +- src/pokedex.c | 10 +- src/pokemon.c | 6 +- src/pokemon_animation.c | 4 +- src/pokemon_jump.c | 2 +- src/pokemon_storage_system.c | 35 +- src/pokemon_summary_screen.c | 18 +- src/pokenav_conditions_gfx.c | 2 +- src/pokenav_match_call_list.c | 12 +- src/pokenav_ribbons_list.c | 6 +- src/rayquaza_scene.c | 2 +- src/recorded_battle.c | 3 +- src/region_map.c | 6 +- src/roulette.c | 5 +- src/scrcmd.c | 12 +- src/script_menu.c | 3 +- src/slot_machine.c | 72 +-- src/sound.c | 3 +- src/start_menu.c | 2 +- src/trade.c | 4 +- src/trainer_hill.c | 5 +- src/trainer_pokemon_sprites.c | 6 +- src/trainer_see.c | 4 +- src/tv.c | 3 +- src/union_room.c | 8 +- src/union_room_chat.c | 10 +- src/use_pokeblock.c | 3 +- 122 files changed, 862 insertions(+), 992 deletions(-) diff --git a/gflib/string_util.c b/gflib/string_util.c index 8d969d1bf5b8..d515c14cdaf1 100644 --- a/gflib/string_util.c +++ b/gflib/string_util.c @@ -298,7 +298,7 @@ u8 *ConvertIntToHexStringN(u8 *dest, s32 value, enum StringConvertMode mode, u8 if (state == WRITING_DIGITS) { - char *out = dest++; + u8 *out = dest++; if (digit <= 0xF) c = sDigits[digit]; @@ -309,7 +309,7 @@ u8 *ConvertIntToHexStringN(u8 *dest, s32 value, enum StringConvertMode mode, u8 } else if (digit != 0 || powerOfSixteen == 1) { - char *out; + u8 *out; state = WRITING_DIGITS; out = dest++; diff --git a/gflib/text.c b/gflib/text.c index 1bded26b5a52..bc917c7ced85 100644 --- a/gflib/text.c +++ b/gflib/text.c @@ -554,8 +554,7 @@ void DecompressGlyphTile(const void *src_, void *dest_) *(dest++) = ((sFontHalfRowLookupTable[sFontHalfRowOffsets[temp & 0xFF]]) << 16) | (sFontHalfRowLookupTable[sFontHalfRowOffsets[temp >> 8]]); } -// Unused -static u8 GetLastTextColor(u8 colorType) +static u8 UNUSED GetLastTextColor(u8 colorType) { switch (colorType) { @@ -1224,8 +1223,7 @@ static u16 RenderText(struct TextPrinter *textPrinter) return RENDER_FINISH; } -// Unused -static u32 GetStringWidthFixedWidthFont(const u8 *str, u8 fontId, u8 letterSpacing) +static u32 UNUSED GetStringWidthFixedWidthFont(const u8 *str, u8 fontId, u8 letterSpacing) { int i; u8 width; diff --git a/gflib/window.c b/gflib/window.c index 76e863f10ea8..6f7af457d3ed 100644 --- a/gflib/window.c +++ b/gflib/window.c @@ -411,7 +411,7 @@ void BlitBitmapRectToWindow(u8 windowId, const u8 *pixels, u16 srcX, u16 srcY, u BlitBitmapRect4Bit(&sourceRect, &destRect, srcX, srcY, destX, destY, rectWidth, rectHeight, 0); } -static void BlitBitmapRectToWindowWithColorKey(u8 windowId, const u8 *pixels, u16 srcX, u16 srcY, u16 srcWidth, int srcHeight, u16 destX, u16 destY, u16 rectWidth, u16 rectHeight, u8 colorKey) +static void UNUSED BlitBitmapRectToWindowWithColorKey(u8 windowId, const u8 *pixels, u16 srcX, u16 srcY, u16 srcWidth, int srcHeight, u16 destX, u16 destY, u16 rectWidth, u16 rectHeight, u8 colorKey) { struct Bitmap sourceRect; struct Bitmap destRect; diff --git a/src/AgbRfu_LinkManager.c b/src/AgbRfu_LinkManager.c index 747a6c784937..e4ee377f7b7d 100644 --- a/src/AgbRfu_LinkManager.c +++ b/src/AgbRfu_LinkManager.c @@ -229,7 +229,7 @@ u8 rfu_LMAN_CHILD_connectParent(u16 parentId, u16 connect_period) return 0; } -static void rfu_LMAN_PARENT_stopWaitLinkRecoveryAndDisconnect(u8 bm_targetSlot) +static void UNUSED rfu_LMAN_PARENT_stopWaitLinkRecoveryAndDisconnect(u8 bm_targetSlot) { u8 i; @@ -1295,7 +1295,7 @@ void rfu_LMAN_setMSCCallback(void (*MSC_callback_p)(u16)) rfu_setMSCCallback(rfu_LMAN_MSC_callback); } -static void rfu_LMAN_setLMANCallback(void (*func)(u8, u8)) +static void UNUSED rfu_LMAN_setLMANCallback(void (*func)(u8, u8)) { lman.LMAN_callback = func; } @@ -1315,7 +1315,7 @@ u8 rfu_LMAN_setLinkRecovery(u8 enable_flag, u16 recovery_period) return 0; } -static u8 rfu_LMAN_setNIFailCounterLimit(u16 NI_failCounter_limit) +static u8 UNUSED rfu_LMAN_setNIFailCounterLimit(u16 NI_failCounter_limit) { if (gRfuLinkStatus->sendSlotNIFlag | gRfuLinkStatus->recvSlotNIFlag) { @@ -1327,7 +1327,7 @@ static u8 rfu_LMAN_setNIFailCounterLimit(u16 NI_failCounter_limit) return 0; } -static u8 rfu_LMAN_setFastSearchParent(u8 enable_flag) +static u8 UNUSED rfu_LMAN_setFastSearchParent(u8 enable_flag) { if (lman.state == LMAN_STATE_START_SEARCH_PARENT || lman.state == LMAN_STATE_POLL_SEARCH_PARENT || lman.state == LMAN_STATE_END_SEARCH_PARENT) { diff --git a/src/apprentice.c b/src/apprentice.c index 9ce5ec0dc214..2280412fe7af 100644 --- a/src/apprentice.c +++ b/src/apprentice.c @@ -623,6 +623,9 @@ static void CreateApprenticeMenu(u8 menu) default: left = 0; top = 0; +#ifdef UBFIX + return; +#endif break; } @@ -1278,8 +1281,7 @@ const u8 *GetApprenticeNameInLanguage(u32 apprenticeId, s32 language) } } -// Functionally unused -static void Task_SwitchToFollowupFuncAfterButtonPress(u8 taskId) +static void UNUSED Task_SwitchToFollowupFuncAfterButtonPress(u8 taskId) { if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) SwitchTaskToFollowupFunc(taskId); @@ -1302,8 +1304,7 @@ static void ExecuteFuncAfterButtonPress(void (*func)(void)) gTasks[taskId].data[1] = (u32)(func) >> 16; } -// Unused -static void ExecuteFollowupFuncAfterButtonPress(TaskFunc task) +static void UNUSED ExecuteFollowupFuncAfterButtonPress(TaskFunc task) { u8 taskId = CreateTask(Task_SwitchToFollowupFuncAfterButtonPress, 1); SetTaskFuncWithFollowupFunc(taskId, Task_SwitchToFollowupFuncAfterButtonPress, task); diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c index aa34f46ec796..9a63031dd2bd 100644 --- a/src/battle_ai_script_commands.c +++ b/src/battle_ai_script_commands.c @@ -2252,7 +2252,7 @@ static void AIStackPushVar(const u8 *var) gBattleResources->AI_ScriptsStack->ptr[gBattleResources->AI_ScriptsStack->size++] = var; } -static void AIStackPushVar_cursor(void) +static void UNUSED AIStackPushVar_cursor(void) { gBattleResources->AI_ScriptsStack->ptr[gBattleResources->AI_ScriptsStack->size++] = gAIScriptPtr; } diff --git a/src/battle_anim_bug.c b/src/battle_anim_bug.c index 377665684a0c..a5875a376fda 100644 --- a/src/battle_anim_bug.c +++ b/src/battle_anim_bug.c @@ -443,7 +443,7 @@ static void AnimMissileArc_Step(struct Sprite *sprite) else { s16 tempData[8]; - u16 *data = sprite->data; + s16 *data = sprite->data; u16 x1 = sprite->x; s16 x2 = sprite->x2; u16 y1 = sprite->y; diff --git a/src/battle_anim_effects_1.c b/src/battle_anim_effects_1.c index c0ad548f17f9..0368adcf800d 100644 --- a/src/battle_anim_effects_1.c +++ b/src/battle_anim_effects_1.c @@ -2765,7 +2765,7 @@ static void AnimConstrictBinding(struct Sprite *sprite) static void AnimConstrictBinding_Step1(struct Sprite *sprite) { - u8 spriteId; + u8 UNUSED spriteId; if ((u16)gBattleAnimArgs[7] == 0xFFFF) { @@ -2778,7 +2778,7 @@ static void AnimConstrictBinding_Step1(struct Sprite *sprite) static void AnimConstrictBinding_Step2(struct Sprite *sprite) { - u8 spriteId = GetAnimBattlerSpriteId(ANIM_TARGET); + u8 UNUSED spriteId = GetAnimBattlerSpriteId(ANIM_TARGET); if (!sprite->data[2]) sprite->data[0] += 11; else @@ -3884,7 +3884,7 @@ static void AnimSlice_Step(struct Sprite *sprite) } } -static void UnusedFlickerAnim(struct Sprite *sprite) +static void UNUSED UnusedFlickerAnim(struct Sprite *sprite) { if (sprite->data[2] > 1) { @@ -4734,7 +4734,7 @@ static void AnimFalseSwipeSlice(struct Sprite *sprite) static void AnimFalseSwipePositionedSlice(struct Sprite *sprite) { - sprite->x = sprite->x = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2) + 0xFFD0 + gBattleAnimArgs[0]; + sprite->x = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2) + 0xFFD0 + gBattleAnimArgs[0]; sprite->y = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET); StartSpriteAnim(sprite, 1); sprite->data[0] = 0; @@ -4917,8 +4917,7 @@ void AnimTask_Conversion2AlphaBlend(u8 taskId) } } -// Unused -static void AnimTask_HideBattlersHealthbox(u8 taskId) +static void UNUSED AnimTask_HideBattlersHealthbox(u8 taskId) { u8 i; for (i = 0; i < gBattlersCount; i++) @@ -4933,8 +4932,7 @@ static void AnimTask_HideBattlersHealthbox(u8 taskId) DestroyAnimVisualTask(taskId); } -// Unused -static void AnimTask_ShowBattlersHealthbox(u8 taskId) +static void UNUSED AnimTask_ShowBattlersHealthbox(u8 taskId) { u8 i; for (i = 0; i < gBattlersCount; i++) diff --git a/src/battle_anim_effects_2.c b/src/battle_anim_effects_2.c index c10bc02b8e7f..d26e0ba4c7ca 100755 --- a/src/battle_anim_effects_2.c +++ b/src/battle_anim_effects_2.c @@ -2551,8 +2551,8 @@ static void AnimPencil_Step(struct Sprite *sprite) static void AnimBlendThinRing(struct Sprite *sprite) { u8 battler = 0; - u16 sp0 = 0; - u16 sp1 = 0; + s16 x = 0; + s16 y = 0; u8 r4; if (gBattleAnimArgs[2] == 0) @@ -2563,16 +2563,16 @@ static void AnimBlendThinRing(struct Sprite *sprite) r4 = gBattleAnimArgs[3] ^ 1; if (IsDoubleBattle() && IsBattlerSpriteVisible(BATTLE_PARTNER(battler))) { - SetAverageBattlerPositions(battler, r4, &sp0, &sp1); + SetAverageBattlerPositions(battler, r4, &x, &y); if (r4 == 0) r4 = GetBattlerSpriteCoord(battler, BATTLER_COORD_X); else r4 = GetBattlerSpriteCoord(battler, BATTLER_COORD_X_2); if (GetBattlerSide(battler) != B_SIDE_PLAYER) - gBattleAnimArgs[0] -= (sp0 - r4) - gBattleAnimArgs[0]; // This is weird. + gBattleAnimArgs[0] -= (x - r4) - gBattleAnimArgs[0]; // This is weird. else - gBattleAnimArgs[0] = sp0 - r4; + gBattleAnimArgs[0] = x - r4; } sprite->callback = AnimSpriteOnMonPos; diff --git a/src/battle_anim_effects_3.c b/src/battle_anim_effects_3.c index 5168641c6acf..6b169c54307b 100755 --- a/src/battle_anim_effects_3.c +++ b/src/battle_anim_effects_3.c @@ -1428,8 +1428,7 @@ static void FadeScreenToWhite_Step(u8 taskId) static void AnimSpikes(struct Sprite *sprite) { - u16 x; - u16 y; + s16 x, y; InitSpritePosToAnimAttacker(sprite, TRUE); SetAverageBattlerPositions(gBattleAnimTarget, FALSE, &x, &y); @@ -4758,8 +4757,8 @@ static void AnimMeteorMashStar_Step(struct Sprite *sprite) // arg 4: duration static void AnimMeteorMashStar(struct Sprite *sprite) { - s16 y = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2); // unused local variable - s16 x = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET); // unused local variable + s16 UNUSED y = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2); + s16 UNUSED x = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET); if (GetBattlerSide(gBattleAnimTarget) == B_SIDE_PLAYER || IsContest()) { diff --git a/src/battle_anim_flying.c b/src/battle_anim_flying.c index 7e5c5e9393bd..c5e59a65af7d 100644 --- a/src/battle_anim_flying.c +++ b/src/battle_anim_flying.c @@ -1220,8 +1220,7 @@ void AnimSkyAttackBird_Step(struct Sprite *sprite) DestroySpriteAndMatrix(sprite); } -// Unused -static void AnimTask_SetAttackerVisibility(u8 taskId) +static void UNUSED AnimTask_SetAttackerVisibility(u8 taskId) { if (gBattleAnimArgs[0] == 0) { diff --git a/src/battle_anim_mons.c b/src/battle_anim_mons.c index d9fd6523118c..6dd0d208524a 100644 --- a/src/battle_anim_mons.c +++ b/src/battle_anim_mons.c @@ -485,9 +485,8 @@ void TranslateSpriteInGrowingCircle(struct Sprite *sprite) } } -// Unused // Exact shape depends on arguments. Can move in a figure-8-like pattern, or circular, etc. -static void TranslateSpriteInLissajousCurve(struct Sprite *sprite) +static void UNUSED TranslateSpriteInLissajousCurve(struct Sprite *sprite) { if (sprite->sDuration) { @@ -639,8 +638,7 @@ static void TranslateSpriteLinearFixedPointIconFrame(struct Sprite *sprite) UpdateMonIconFrame(sprite); } -// Unused -static void TranslateSpriteToBattleTargetPos(struct Sprite *sprite) +static void UNUSED TranslateSpriteToBattleTargetPos(struct Sprite *sprite) { sprite->sStartX = sprite->x + sprite->x2; sprite->sStartY = sprite->y + sprite->y2; @@ -707,8 +705,7 @@ void DestroySpriteAndMatrix(struct Sprite *sprite) DestroyAnimSprite(sprite); } -// Unused -static void TranslateSpriteToBattleAttackerPos(struct Sprite *sprite) +static void UNUSED TranslateSpriteToBattleAttackerPos(struct Sprite *sprite) { sprite->sStartX = sprite->x + sprite->x2; sprite->sStartY = sprite->y + sprite->y2; @@ -723,8 +720,7 @@ static void TranslateSpriteToBattleAttackerPos(struct Sprite *sprite) #undef sStartY #undef sTargetY -// Unused -static void EndUnkPaletteAnim(struct Sprite *sprite) +static void UNUSED EndUnkPaletteAnim(struct Sprite *sprite) { PaletteStruct_ResetById(sprite->data[5]); DestroySpriteAndMatrix(sprite); @@ -1103,8 +1099,7 @@ void StartAnimLinearTranslation(struct Sprite *sprite) sprite->callback(sprite); } -// Unused -static void StartAnimLinearTranslation_SetCornerVecX(struct Sprite *sprite) +static void UNUSED StartAnimLinearTranslation_SetCornerVecX(struct Sprite *sprite) { sprite->data[1] = sprite->x; sprite->data[3] = sprite->y; @@ -1512,8 +1507,7 @@ u8 GetSpritePalIdxByBattler(u8 battler) return battler; } -// Unused -static u8 GetSpritePalIdxByPosition(u8 position) +static u8 UNUSED GetSpritePalIdxByPosition(u8 position) { return GetBattlerAtPosition(position); } @@ -2012,8 +2006,7 @@ void AnimTask_GetFrustrationPowerLevel(u8 taskId) DestroyAnimVisualTask(taskId); } -// Unused -static void SetPriorityForVisibleBattlers(u8 priority) +static void UNUSED SetPriorityForVisibleBattlers(u8 priority) { if (IsBattlerSpriteVisible(gBattleAnimTarget)) gSprites[gBattlerSpriteIds[gBattleAnimTarget]].oam.priority = priority; diff --git a/src/battle_anim_status_effects.c b/src/battle_anim_status_effects.c index b987ad33a358..cc04843b7f2e 100644 --- a/src/battle_anim_status_effects.c +++ b/src/battle_anim_status_effects.c @@ -270,8 +270,7 @@ static const struct SpriteTemplate sFlashingCircleImpactSpriteTemplate = .callback = AnimFlashingCircleImpact, }; -// Unused -static u8 Task_FlashingCircleImpacts(u8 battlerId, bool8 red) +static u8 UNUSED Task_FlashingCircleImpacts(u8 battlerId, bool8 red) { u8 battlerSpriteId = gBattlerSpriteIds[battlerId]; u8 taskId = CreateTask(Task_UpdateFlashingCircleImpacts, 10); diff --git a/src/battle_anim_throw.c b/src/battle_anim_throw.c index fea67a6e3c61..8296126f149b 100755 --- a/src/battle_anim_throw.c +++ b/src/battle_anim_throw.c @@ -2386,11 +2386,11 @@ static void SpriteCB_ShinyStars_Diagonal(struct Sprite *sprite) void AnimTask_LoadPokeblockGfx(u8 taskId) { - u8 paletteIndex; + u8 UNUSED paletteIndex; LoadCompressedSpriteSheetUsingHeap(&gBattleAnimPicTable[ANIM_TAG_POKEBLOCK - ANIM_SPRITES_START]); LoadCompressedSpritePaletteUsingHeap(&gBattleAnimPaletteTable[ANIM_TAG_POKEBLOCK - ANIM_SPRITES_START]); - paletteIndex = IndexOfSpritePaletteTag(ANIM_TAG_POKEBLOCK); // unused + paletteIndex = IndexOfSpritePaletteTag(ANIM_TAG_POKEBLOCK); DestroyAnimVisualTask(taskId); } diff --git a/src/battle_anim_utility_funcs.c b/src/battle_anim_utility_funcs.c index ccbc7f902b58..18a599a4c18b 100644 --- a/src/battle_anim_utility_funcs.c +++ b/src/battle_anim_utility_funcs.c @@ -69,6 +69,9 @@ void AnimTask_BlendBattleAnimPalExclude(u8 taskId) selectedPalettes = 0; // fall through case ANIM_ATTACKER: +#ifdef UBFIX + default: +#endif animBattlers[0] = gBattleAnimAttacker; break; case 3: @@ -806,7 +809,7 @@ void AnimTask_SetAllNonAttackersInvisiblity(u8 taskId) DestroyAnimVisualTask(taskId); } -void StartMonScrollingBgMask(u8 taskId, int unused, u16 scrollSpeed, u8 battler, bool8 includePartner, u8 numFadeSteps, u8 fadeStepDelay, u8 duration, const u32 *gfx, const u32 *tilemap, const u32 *palette) +void StartMonScrollingBgMask(u8 taskId, int UNUSED unused, u16 scrollSpeed, u8 battler, bool8 includePartner, u8 numFadeSteps, u8 fadeStepDelay, u8 duration, const u32 *gfx, const u32 *tilemap, const u32 *palette) { u16 species; u8 spriteId, spriteId2; diff --git a/src/battle_arena.c b/src/battle_arena.c index 98ec43fc1d7a..ed3cf16dfd02 100644 --- a/src/battle_arena.c +++ b/src/battle_arena.c @@ -651,8 +651,7 @@ void BattleArena_DeductSkillPoints(u8 battler, u16 stringId) } } -// Unused -static void UpdateHPAtStart(u8 battler) +static void UNUSED UpdateHPAtStart(u8 battler) { u16 *hpAtStart = gBattleStruct->arenaStartHp; diff --git a/src/battle_bg.c b/src/battle_bg.c index b3091d965ee7..05073db96dd8 100644 --- a/src/battle_bg.c +++ b/src/battle_bg.c @@ -692,9 +692,9 @@ static const struct BattleBackground sBattleTerrainTable[] = }, }; -static void CB2_UnusedBattleInit(void); +static void UNUSED CB2_UnusedBattleInit(void); -static void UnusedBattleInit(void) +static void UNUSED UnusedBattleInit(void) { u8 spriteId; @@ -704,7 +704,7 @@ static void UnusedBattleInit(void) SetMainCallback2(CB2_UnusedBattleInit); } -static void CB2_UnusedBattleInit(void) +static void UNUSED CB2_UnusedBattleInit(void) { AnimateSprites(); BuildOamBuffer(); diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index cdc5fe8429c5..357912d4b63d 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -329,7 +329,7 @@ static void HandleInputChooseAction(void) } } -static void UnusedEndBounceEffect(void) +static void UNUSED UnusedEndBounceEffect(void) { EndBounceEffect(gActiveBattler, BOUNCE_HEALTHBOX); EndBounceEffect(gActiveBattler, BOUNCE_MON); @@ -614,7 +614,7 @@ static void HandleInputChooseMove(void) } } -static u32 HandleMoveInputUnused(void) +static u32 UNUSED HandleMoveInputUnused(void) { u32 var = 0; diff --git a/src/battle_controller_recorded_opponent.c b/src/battle_controller_recorded_opponent.c index b2db595f8aa9..9c37cd0a92bd 100644 --- a/src/battle_controller_recorded_opponent.c +++ b/src/battle_controller_recorded_opponent.c @@ -186,7 +186,7 @@ static void CompleteOnBattlerSpriteCallbackDummy(void) RecordedOpponentBufferExecCompleted(); } -static void CompleteOnBankSpriteCallbackDummy2(void) +static void UNUSED CompleteOnBankSpriteCallbackDummy2(void) { if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) RecordedOpponentBufferExecCompleted(); diff --git a/src/battle_controller_safari.c b/src/battle_controller_safari.c index 5e8ef2d28655..157bb6954ccb 100644 --- a/src/battle_controller_safari.c +++ b/src/battle_controller_safari.c @@ -147,7 +147,7 @@ static void (*const sSafariBufferCommands[CONTROLLER_CMDS_COUNT])(void) = [CONTROLLER_TERMINATOR_NOP] = SafariCmdEnd }; -static void SpriteCB_Null4(void) +static void UNUSED SpriteCB_Null4(void) { } @@ -307,7 +307,7 @@ static void SafariBufferExecCompleted(void) } } -static void CompleteOnFinishedStatusAnimation(void) +static void UNUSED CompleteOnFinishedStatusAnimation(void) { if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive) SafariBufferExecCompleted(); diff --git a/src/battle_controller_wally.c b/src/battle_controller_wally.c index 5b94f2dd2641..ce357319a59e 100644 --- a/src/battle_controller_wally.c +++ b/src/battle_controller_wally.c @@ -161,7 +161,7 @@ static void (*const sWallyBufferCommands[CONTROLLER_CMDS_COUNT])(void) = [CONTROLLER_TERMINATOR_NOP] = WallyCmdEnd }; -static void SpriteCB_Null7(void) +static void UNUSED SpriteCB_Null7(void) { } @@ -417,7 +417,7 @@ static void WallyBufferExecCompleted(void) } } -static void CompleteOnFinishedStatusAnimation(void) +static void UNUSED CompleteOnFinishedStatusAnimation(void) { if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive) WallyBufferExecCompleted(); diff --git a/src/battle_controllers.c b/src/battle_controllers.c index b93e65fdc09d..2ba5d4329d85 100644 --- a/src/battle_controllers.c +++ b/src/battle_controllers.c @@ -905,8 +905,7 @@ void BtlController_EmitGetMonData(u8 bufferId, u8 requestId, u8 monToCheck) PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 4); } -// Unused -static void BtlController_EmitGetRawMonData(u8 bufferId, u8 monId, u8 bytes) +static void UNUSED BtlController_EmitGetRawMonData(u8 bufferId, u8 monId, u8 bytes) { sBattleBuffersTransferData[0] = CONTROLLER_GETRAWMONDATA; sBattleBuffersTransferData[1] = monId; @@ -927,8 +926,7 @@ void BtlController_EmitSetMonData(u8 bufferId, u8 requestId, u8 monToCheck, u8 b PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 3 + bytes); } -// Unused -static void BtlController_EmitSetRawMonData(u8 bufferId, u8 monId, u8 bytes, void *data) +static void UNUSED BtlController_EmitSetRawMonData(u8 bufferId, u8 monId, u8 bytes, void *data) { s32 i; @@ -1001,8 +999,7 @@ void BtlController_EmitFaintAnimation(u8 bufferId) PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 4); } -// Unused -static void BtlController_EmitPaletteFade(u8 bufferId) +static void UNUSED BtlController_EmitPaletteFade(u8 bufferId) { sBattleBuffersTransferData[0] = CONTROLLER_PALETTEFADE; sBattleBuffersTransferData[1] = CONTROLLER_PALETTEFADE; @@ -1011,8 +1008,7 @@ static void BtlController_EmitPaletteFade(u8 bufferId) PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 4); } -// Unused -static void BtlController_EmitSuccessBallThrowAnim(u8 bufferId) +static void UNUSED BtlController_EmitSuccessBallThrowAnim(u8 bufferId) { sBattleBuffersTransferData[0] = CONTROLLER_SUCCESSBALLTHROWANIM; sBattleBuffersTransferData[1] = CONTROLLER_SUCCESSBALLTHROWANIM; @@ -1028,8 +1024,7 @@ void BtlController_EmitBallThrowAnim(u8 bufferId, u8 caseId) PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 2); } -// Unused -static void BtlController_EmitPause(u8 bufferId, u8 toWait, void *data) +static void UNUSED BtlController_EmitPause(u8 bufferId, u8 toWait, void *data) { s32 i; @@ -1188,8 +1183,7 @@ void BtlController_EmitChoosePokemon(u8 bufferId, u8 caseId, u8 slotId, u8 abili PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 8); // Only 7 bytes were written. } -// Unused -static void BtlController_EmitCmd23(u8 bufferId) +static void UNUSED BtlController_EmitCmd23(u8 bufferId) { sBattleBuffersTransferData[0] = CONTROLLER_23; sBattleBuffersTransferData[1] = CONTROLLER_23; @@ -1243,8 +1237,7 @@ void BtlController_EmitStatusAnimation(u8 bufferId, bool8 status2, u32 status) PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 6); } -// Unused -static void BtlController_EmitStatusXor(u8 bufferId, u8 b) +static void UNUSED BtlController_EmitStatusXor(u8 bufferId, u8 b) { sBattleBuffersTransferData[0] = CONTROLLER_STATUSXOR; sBattleBuffersTransferData[1] = b; @@ -1264,8 +1257,7 @@ void BtlController_EmitDataTransfer(u8 bufferId, u16 size, void *data) PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, size + 4); } -// Unused -static void BtlController_EmitDMA3Transfer(u8 bufferId, void *dst, u16 size, void *data) +static void UNUSED BtlController_EmitDMA3Transfer(u8 bufferId, void *dst, u16 size, void *data) { s32 i; @@ -1281,8 +1273,7 @@ static void BtlController_EmitDMA3Transfer(u8 bufferId, void *dst, u16 size, voi PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, size + 7); } -// Unused -static void BtlController_EmitPlayBGM(u8 bufferId, u16 songId, void *data) +static void UNUSED BtlController_EmitPlayBGM(u8 bufferId, u16 songId, void *data) { s32 i; @@ -1297,8 +1288,7 @@ static void BtlController_EmitPlayBGM(u8 bufferId, u16 songId, void *data) PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, songId + 3); } -// Unused -static void BtlController_EmitCmd32(u8 bufferId, u16 size, void *data) +static void UNUSED BtlController_EmitCmd32(u8 bufferId, u16 size, void *data) { s32 i; @@ -1348,8 +1338,7 @@ void BtlController_EmitOneReturnValue_Duplicate(u8 bufferId, u16 ret) PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 4); } -// Unused -static void BtlController_EmitClearUnkVar(u8 bufferId) +static void UNUSED BtlController_EmitClearUnkVar(u8 bufferId) { sBattleBuffersTransferData[0] = CONTROLLER_CLEARUNKVAR; sBattleBuffersTransferData[1] = CONTROLLER_CLEARUNKVAR; @@ -1358,16 +1347,14 @@ static void BtlController_EmitClearUnkVar(u8 bufferId) PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 4); } -// Unused -static void BtlController_EmitSetUnkVar(u8 bufferId, u8 b) +static void UNUSED BtlController_EmitSetUnkVar(u8 bufferId, u8 b) { sBattleBuffersTransferData[0] = CONTROLLER_SETUNKVAR; sBattleBuffersTransferData[1] = b; PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 2); } -// Unused -static void BtlController_EmitClearUnkFlag(u8 bufferId) +static void UNUSED BtlController_EmitClearUnkFlag(u8 bufferId) { sBattleBuffersTransferData[0] = CONTROLLER_CLEARUNKFLAG; sBattleBuffersTransferData[1] = CONTROLLER_CLEARUNKFLAG; @@ -1376,8 +1363,7 @@ static void BtlController_EmitClearUnkFlag(u8 bufferId) PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 4); } -// Unused -static void BtlController_EmitToggleUnkFlag(u8 bufferId) +static void UNUSED BtlController_EmitToggleUnkFlag(u8 bufferId) { sBattleBuffersTransferData[0] = CONTROLLER_TOGGLEUNKFLAG; sBattleBuffersTransferData[1] = CONTROLLER_TOGGLEUNKFLAG; diff --git a/src/battle_dome.c b/src/battle_dome.c index 6ecb254baa3f..8364515e591e 100644 --- a/src/battle_dome.c +++ b/src/battle_dome.c @@ -1667,13 +1667,13 @@ static const u8 sTourneyTreePokeballCoords[DOME_TOURNAMENT_TRAINERS_COUNT + DOME {.tile = LINE_V_L, .y = 9, .x = 17}, \ {.tile = LINE_V_L, .y = 10, .x = 17}, \ {.tile = LINE_V_L_HALF_LOGO, .y = 11, .x = 17}, - + #define LINESECTION_SEMIFINAL_BOTTOM_RIGHT \ {.tile = LINE_V_L_LOGO4, .y = 14, .x = 17}, \ {.tile = LINE_V_L_LOGO3, .y = 13, .x = 17}, \ {.tile = LINE_V_L_LOGO2, .y = 12, .x = 17}, \ {.tile = LINE_V_L_LOGO1, .y = 11, .x = 17}, - + #define LINESECTION_FINAL_LEFT \ {.tile = LINE_H_LOGO1, .y = 11, .x = 13}, \ {.tile = LINE_H_LOGO2, .y = 11, .x = 14}, diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c index d98809be461a..d4326860a92e 100644 --- a/src/battle_gfx_sfx_util.c +++ b/src/battle_gfx_sfx_util.c @@ -378,7 +378,7 @@ void SpriteCB_WaitForBattlerBallReleaseAnim(struct Sprite *sprite) } } -static void UnusedDoBattleSpriteAffineAnim(struct Sprite *sprite, bool8 pointless) +static void UNUSED UnusedDoBattleSpriteAffineAnim(struct Sprite *sprite, bool8 pointless) { sprite->animPaused = TRUE; sprite->callback = SpriteCallbackDummy; @@ -690,8 +690,7 @@ void BattleLoadPlayerMonSpriteGfx(struct Pokemon *mon, u8 battlerId) } } -// Unused -static void BattleGfxSfxDummy1(void) +static void UNUSED BattleGfxSfxDummy1(void) { } diff --git a/src/battle_interface.c b/src/battle_interface.c index f9a7be58ea45..a417be4a72c1 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -841,8 +841,7 @@ static void Debug_DrawNumber(s16 number, u16 *dest, bool8 unk) } } -// Unused -static void Debug_DrawNumberPair(s16 number1, s16 number2, u16 *dest) +static void UNUSED Debug_DrawNumberPair(s16 number1, s16 number2, u16 *dest) { dest[4] = 0x1E; Debug_DrawNumber(number2, dest, FALSE); @@ -2459,9 +2458,8 @@ static u8 CalcBarFilledPixels(s32 maxValue, s32 oldValue, s32 receivedValue, s32 return filledPixels; } -// Unused // These two functions seem as if they were made for testing the health bar. -static s16 Debug_TestHealthBar(struct TestingBar *barInfo, s32 *currValue, u16 *dest, s32 unused) +static s16 UNUSED Debug_TestHealthBar(struct TestingBar *barInfo, s32 *currValue, u16 *dest, s32 unused) { s16 ret, var; diff --git a/src/battle_intro.c b/src/battle_intro.c index 3cdc879a86a0..5df697e3ae98 100644 --- a/src/battle_intro.c +++ b/src/battle_intro.c @@ -602,7 +602,7 @@ void DrawBattlerOnBg(int bgId, u8 x, u8 y, u8 battlerPosition, u8 paletteId, u8 LoadBgTilemap(bgId, tilemap, BG_SCREEN_SIZE, 0); } -static void DrawBattlerOnBgDMA(u8 x, u8 y, u8 battlerPosition, u8 arg3, u8 paletteId, u16 arg5, u8 arg6, u8 arg7) +static void UNUSED DrawBattlerOnBgDMA(u8 x, u8 y, u8 battlerPosition, u8 arg3, u8 paletteId, u16 arg5, u8 arg6, u8 arg7) { int i, j, offset; diff --git a/src/battle_main.c b/src/battle_main.c index e1c6a514a7f5..b5c6cbbf078b 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -2073,8 +2073,7 @@ static u8 CreateNPCTrainerParty(struct Pokemon *party, u16 trainerNum, bool8 fir return gTrainers[trainerNum].partySize; } -// Unused -static void HBlankCB_Battle(void) +static void UNUSED HBlankCB_Battle(void) { if (REG_VCOUNT < DISPLAY_HEIGHT && REG_VCOUNT >= 111) SetGpuReg(REG_OFFSET_BG0CNT, BGCNT_SCREENBASE(24) | BGCNT_TXT256x512); @@ -2710,8 +2709,7 @@ void SpriteCallbackDummy_2(struct Sprite *sprite) #define sNumFlickers data[3] #define sDelay data[4] -// Unused -static void SpriteCB_InitFlicker(struct Sprite *sprite) +static void UNUSED SpriteCB_InitFlicker(struct Sprite *sprite) { sprite->sNumFlickers = 6; sprite->sDelay = 1; @@ -2866,8 +2864,7 @@ static void SpriteCB_BattleSpriteSlideLeft(struct Sprite *sprite) } } -// Unused -static void SetIdleSpriteCallback(struct Sprite *sprite) +static void UNUSED SetIdleSpriteCallback(struct Sprite *sprite) { sprite->callback = SpriteCB_Idle; } @@ -3689,8 +3686,7 @@ static void BattleIntroRecordMonsToDex(void) } } -// Unused -static void BattleIntroSkipRecordMonsToDex(void) +static void UNUSED BattleIntroSkipRecordMonsToDex(void) { if (gBattleControllerExecFlags == 0) gBattleMainFunc = BattleIntroPrintPlayerSendsOut; @@ -3793,8 +3789,7 @@ static void BattleIntroPlayer1SendsOutMonAnimation(void) gBattleMainFunc = TryDoEventsBeforeFirstTurn; } -// Unused -static void BattleIntroSwitchInPlayerMons(void) +static void UNUSED BattleIntroSwitchInPlayerMons(void) { if (gBattleControllerExecFlags == 0) { diff --git a/src/battle_pike.c b/src/battle_pike.c index acc9eaee4e08..750562120179 100644 --- a/src/battle_pike.c +++ b/src/battle_pike.c @@ -1097,8 +1097,7 @@ static u16 GetNPCRoomGraphicsId(void) return sNPCTable[sNpcId].graphicsId; } -// Unused -static u8 GetInWildMonRoom(void) +static bool8 UNUSED GetInWildMonRoom(void) { return sInWildMonRoom; } diff --git a/src/battle_pyramid.c b/src/battle_pyramid.c index e51f804981b2..b4bb3caccaa6 100644 --- a/src/battle_pyramid.c +++ b/src/battle_pyramid.c @@ -1479,8 +1479,7 @@ u8 GetTrainerEncounterMusicIdInBattlePyramid(u16 trainerId) return TRAINER_ENCOUNTER_MUSIC_MALE; } -// Unused -static void BattlePyramidRetireChallenge(void) +static void UNUSED BattlePyramidRetireChallenge(void) { ScriptContext_SetupScript(BattlePyramid_Retire); } diff --git a/src/battle_pyramid_bag.c b/src/battle_pyramid_bag.c index d580cf680072..bf9a7704b10d 100644 --- a/src/battle_pyramid_bag.c +++ b/src/battle_pyramid_bag.c @@ -174,12 +174,12 @@ enum { static const struct MenuAction sMenuActions[] = { - [ACTION_USE_FIELD] = { gMenuText_Use, BagAction_UseOnField }, - [ACTION_TOSS] = { gMenuText_Toss, BagAction_Toss }, - [ACTION_GIVE] = { gMenuText_Give, BagAction_Give }, - [ACTION_CANCEL] = { gText_Cancel2, BagAction_Cancel }, - [ACTION_USE_BATTLE] = { gMenuText_Use, BagAction_UseInBattle }, - [ACTION_DUMMY] = { gText_EmptyString2, NULL }, + [ACTION_USE_FIELD] = { gMenuText_Use, {BagAction_UseOnField} }, + [ACTION_TOSS] = { gMenuText_Toss, {BagAction_Toss} }, + [ACTION_GIVE] = { gMenuText_Give, {BagAction_Give} }, + [ACTION_CANCEL] = { gText_Cancel2, {BagAction_Cancel} }, + [ACTION_USE_BATTLE] = { gMenuText_Use, {BagAction_UseInBattle} }, + [ACTION_DUMMY] = { gText_EmptyString2, {NULL} }, }; static const u8 sMenuActionIds_Field[] = {ACTION_USE_FIELD, ACTION_GIVE, ACTION_TOSS, ACTION_CANCEL}; @@ -382,8 +382,8 @@ void CB2_PyramidBagMenuFromStartMenu(void) GoToBattlePyramidBagMenu(PYRAMIDBAG_LOC_FIELD, CB2_ReturnToFieldWithOpenMenu); } -// Unused, CB2_BagMenuFromBattle is used instead -static void OpenBattlePyramidBagInBattle(void) +// CB2_BagMenuFromBattle is used instead +static void UNUSED OpenBattlePyramidBagInBattle(void) { GoToBattlePyramidBagMenu(PYRAMIDBAG_LOC_BATTLE, CB2_SetUpReshowBattleScreenAfterMenu2); } @@ -1468,8 +1468,7 @@ static void DrawTossNumberWindow(u8 windowId) ScheduleBgCopyTilemapToVram(1); } -// Unused -static u8 GetMenuActionWindowId(u8 windowArrayId) +static u8 UNUSED GetMenuActionWindowId(u8 windowArrayId) { return gPyramidBagMenu->windowIds[windowArrayId]; } diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 7246a11d16ee..9d2c2cb71557 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1650,7 +1650,7 @@ static inline void ApplyRandomDmgMultiplier(void) } } -static void Unused_ApplyRandomDmgMultiplier(void) +static void UNUSED Unused_ApplyRandomDmgMultiplier(void) { ApplyRandomDmgMultiplier(); } diff --git a/src/battle_setup.c b/src/battle_setup.c index fc1586a5f294..a9cfc48ffb44 100644 --- a/src/battle_setup.c +++ b/src/battle_setup.c @@ -1248,7 +1248,7 @@ static void SetBattledTrainersFlags(void) FlagSet(GetTrainerAFlag()); } -static void SetBattledTrainerFlag(void) +static void UNUSED SetBattledTrainerFlag(void) { FlagSet(GetTrainerAFlag()); } diff --git a/src/battle_tent.c b/src/battle_tent.c index f0f7363f31af..b7a9daecba4c 100644 --- a/src/battle_tent.c +++ b/src/battle_tent.c @@ -313,7 +313,6 @@ static void GenerateInitialRentalMons(void) monSetId = Random() % NUM_SLATEPORT_TENT_MONS; for (j = firstMonId; j < firstMonId + i; j++) { - u16 monId = monIds[j]; if (monIds[j] == monSetId) break; if (species[j] == gFacilityTrainerMons[monSetId].species) diff --git a/src/battle_tower.c b/src/battle_tower.c index 3cf7ea0a8e47..15509a7dcf6c 100644 --- a/src/battle_tower.c +++ b/src/battle_tower.c @@ -1129,8 +1129,7 @@ u16 GetRandomScaledFrontierTrainerId(u8 challengeNum, u8 battleNum) return trainerId; } -// Unused -static void GetRandomScaledFrontierTrainerIdRange(u8 challengeNum, u8 battleNum, u16 *trainerIdPtr, u8 *rangePtr) +static void UNUSED GetRandomScaledFrontierTrainerIdRange(u8 challengeNum, u8 battleNum, u16 *trainerIdPtr, u8 *rangePtr) { u16 trainerId, range; @@ -1756,7 +1755,7 @@ static void FillTrainerParty(u16 trainerId, u8 firstMonId, u8 monCount) } // Probably an early draft before the 'CreateApprenticeMon' was written. -static void Unused_CreateApprenticeMons(u16 trainerId, u8 firstMonId) +static void UNUSED Unused_CreateApprenticeMons(u16 trainerId, u8 firstMonId) { s32 i, j; u8 friendship = MAX_FRIENDSHIP; @@ -1832,12 +1831,14 @@ static void FillFactoryFrontierTrainerParty(u16 trainerId, u8 firstMonId) if (trainerId < FRONTIER_TRAINERS_COUNT) { - u8 lvlMode = gSaveBlock2Ptr->frontier.lvlMode; - u8 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE); // By mistake Battle Tower's Level 50 challenge number is used to determine the IVs for Battle Factory. #ifdef BUGFIX + u8 lvlMode = gSaveBlock2Ptr->frontier.lvlMode; + u8 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE); u8 challengeNum = gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode] / FRONTIER_STAGES_PER_CHALLENGE; #else + u8 UNUSED lvlMode = gSaveBlock2Ptr->frontier.lvlMode; + u8 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE); u8 challengeNum = gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][FRONTIER_LVL_50] / FRONTIER_STAGES_PER_CHALLENGE; #endif if (gSaveBlock2Ptr->frontier.curChallengeBattleNum < FRONTIER_STAGES_PER_CHALLENGE - 1) @@ -2278,7 +2279,7 @@ static void LoadMultiPartnerCandidatesData(void) u32 lvlMode, battleMode; s32 challengeNum; u32 species1, species2; - u32 level; + u32 UNUSED level; struct ObjectEventTemplate *objEventTemplates; objEventTemplates = gSaveBlock1Ptr->objectEventTemplates; @@ -2461,7 +2462,7 @@ static void ShowPartnerCandidateMessage(void) { s32 i, j, partnerId; s32 monId; - s32 level = SetFacilityPtrsGetLevel(); + s32 UNUSED level = SetFacilityPtrsGetLevel(); u16 winStreak = GetCurrentFacilityWinStreak(); s32 challengeNum = winStreak / FRONTIER_STAGES_PER_CHALLENGE; s32 k = gSpecialVar_LastTalked - 2; @@ -2823,7 +2824,7 @@ static void AwardBattleTowerRibbons(void) // This is a leftover debugging function that is used to populate the E-Reader // trainer with the player's current data. -static void FillEReaderTrainerWithPlayerData(void) +static void UNUSED FillEReaderTrainerWithPlayerData(void) { struct BattleTowerEReaderTrainer *ereaderTrainer = &gSaveBlock2Ptr->frontier.ereaderTrainer; s32 i, j; diff --git a/src/battle_transition.c b/src/battle_transition.c index 2e87b9c1d77e..11f9cddf4bb5 100644 --- a/src/battle_transition.c +++ b/src/battle_transition.c @@ -779,7 +779,7 @@ static const TransitionStateFunc sTransitionIntroFuncs[] = static const struct SpriteFrameImage sSpriteImage_Pokeball[] = { - sPokeball_Gfx, sizeof(sPokeball_Gfx) + {sPokeball_Gfx, sizeof(sPokeball_Gfx)} }; static const union AnimCmd sSpriteAnim_Pokeball[] = @@ -841,12 +841,12 @@ static const struct OamData sOam_UnusedBrendanLass = static const struct SpriteFrameImage sImageTable_UnusedBrendan[] = { - sUnusedBrendan_Gfx, sizeof(sUnusedBrendan_Gfx) + {sUnusedBrendan_Gfx, sizeof(sUnusedBrendan_Gfx)} }; static const struct SpriteFrameImage sImageTable_UnusedLass[] = { - sUnusedLass_Gfx, sizeof(sUnusedLass_Gfx) + {sUnusedLass_Gfx, sizeof(sUnusedLass_Gfx)} }; static const union AnimCmd sSpriteAnim_UnusedBrendanLass[] = @@ -1017,8 +1017,7 @@ static void CB2_TestBattleTransition(void) UpdatePaletteFade(); } -// Unused -static void TestBattleTransition(u8 transitionId) +static void UNUSED TestBattleTransition(u8 transitionId) { sTestingTransitionId = transitionId; SetMainCallback2(CB2_TestBattleTransition); diff --git a/src/battle_util.c b/src/battle_util.c index f71c825c1bb3..50c560bccf3c 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -827,8 +827,7 @@ void PressurePPLoseOnUsingPerishSong(u8 attacker) } } -// Unused -static void MarkAllBattlersForControllerExec(void) +static void UNUSED MarkAllBattlersForControllerExec(void) { int i; @@ -3243,8 +3242,8 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) int i = 0; u8 effect = ITEM_NO_EFFECT; u8 changedPP = 0; - u8 battlerHoldEffect, atkHoldEffect, defHoldEffect; - u8 battlerHoldEffectParam, atkHoldEffectParam, defHoldEffectParam; + u8 battlerHoldEffect, atkHoldEffect, UNUSED defHoldEffect; + u8 battlerHoldEffectParam, atkHoldEffectParam, UNUSED defHoldEffectParam; u16 atkItem, defItem; gLastUsedItem = gBattleMons[battlerId].item; diff --git a/src/berry_blender.c b/src/berry_blender.c index b882fc12d970..97262a4e2fd3 100644 --- a/src/berry_blender.c +++ b/src/berry_blender.c @@ -2377,8 +2377,7 @@ static void Debug_SetMaxRPMStage(s16 value) sDebug_MaxRPMStage = value; } -// Unused -static s16 Debug_GetMaxRPMStage(void) +static s16 UNUSED Debug_GetMaxRPMStage(void) { return sDebug_MaxRPMStage; } @@ -2388,8 +2387,7 @@ static void Debug_SetGameTimeStage(s16 value) sDebug_GameTimeStage = value; } -// Unued -static s16 Debug_GetGameTimeStage(void) +static s16 UNUSED Debug_GetGameTimeStage(void) { return sDebug_GameTimeStage; } @@ -2501,8 +2499,7 @@ static void CalculatePokeblock(struct BlenderBerry *berries, struct Pokeblock *p flavors[i] = sPokeblockFlavors[i]; } -// Unused -static void Debug_CalculatePokeblock(struct BlenderBerry* berries, struct Pokeblock* pokeblock, u8 numPlayers, u8 *flavors, u16 maxRPM) +static void UNUSED Debug_CalculatePokeblock(struct BlenderBerry* berries, struct Pokeblock* pokeblock, u8 numPlayers, u8 *flavors, u16 maxRPM) { CalculatePokeblock(berries, pokeblock, numPlayers, flavors, maxRPM); } @@ -3471,7 +3468,7 @@ static bool8 PrintBlendingResults(void) struct Pokeblock pokeblock; u8 flavors[FLAVOR_COUNT + 1]; u8 text[40]; - u16 berryIds[4]; // unused + u16 UNUSED berryIds[4]; switch (sBerryBlender->mainState) { @@ -3866,6 +3863,9 @@ static void Blender_AddTextPrinter(u8 windowId, const u8 *string, u8 x, u8 y, s3 { case 0: case 3: +#ifdef UBFIX + default: +#endif txtColor[0] = TEXT_COLOR_WHITE; txtColor[1] = TEXT_COLOR_DARK_GRAY; txtColor[2] = TEXT_COLOR_LIGHT_GRAY; diff --git a/src/berry_crush.c b/src/berry_crush.c index c0a75b199471..4e789f27a457 100755 --- a/src/berry_crush.c +++ b/src/berry_crush.c @@ -1062,7 +1062,7 @@ static void BerryCrush_SetVBlankCB(void) SetVBlankCallback(VBlankCB); } -static void BerryCrush_InitVBlankCB(void) +static void UNUSED BerryCrush_InitVBlankCB(void) { SetVBlankCallback(NULL); } diff --git a/src/berry_fix_graphics.c b/src/berry_fix_graphics.c index d766c3966253..80510a4ce173 100644 --- a/src/berry_fix_graphics.c +++ b/src/berry_fix_graphics.c @@ -34,8 +34,8 @@ static const struct { } }; -// Unused. See berry_fix_program.c -static void LoadBerryFixGraphics(u32 idx) +// See berry_fix_program.c +static void UNUSED LoadBerryFixGraphics(u32 idx) { REG_DISPCNT = 0; REG_BG0HOFS = 0; diff --git a/src/berry_powder.c b/src/berry_powder.c index 7066f9d95c1b..4a9fa421d3fa 100755 --- a/src/berry_powder.c +++ b/src/berry_powder.c @@ -15,8 +15,7 @@ static EWRAM_DATA u8 sBerryPowderVendorWindowId = 0; -// Unused -static const struct BgTemplate sBerryPowderBgTemplates[] = +static const struct BgTemplate UNUSED sBerryPowderBgTemplates[] = { { .bg = 0, @@ -57,10 +56,9 @@ static const struct BgTemplate sBerryPowderBgTemplates[] = }; // ? Part of the BG templates? -static const u32 sUnknown[] = {0xFF, 0x00}; +static const u32 UNUSED sUnknown[] = {0xFF, 0x00}; -// Unused -static const struct WindowTemplate sBerryPowderWindowTemplates[] = +static const struct WindowTemplate UNUSED sBerryPowderWindowTemplates[] = { { .bg = 0, @@ -177,7 +175,7 @@ bool8 GiveBerryPowder(u32 amountToAdd) } } -static bool8 TakeBerryPowder_(u32 cost) +static bool8 UNUSED TakeBerryPowder_(u32 cost) { u32 *powder = &gSaveBlock2Ptr->berryCrush.berryPowderAmount; if (!HasEnoughBerryPowder_(cost)) diff --git a/src/braille_puzzles.c b/src/braille_puzzles.c index 49f73dd6b733..7863f3cc116c 100644 --- a/src/braille_puzzles.c +++ b/src/braille_puzzles.c @@ -256,7 +256,7 @@ static void DoBrailleRegisteelEffect(void) } // theory: another commented out DoBrailleWait and Task_BrailleWait. -static void DoBrailleWait(void) +static void UNUSED DoBrailleWait(void) { } diff --git a/src/cable_club.c b/src/cable_club.c index b12a50920f31..5305326589d3 100644 --- a/src/cable_club.c +++ b/src/cable_club.c @@ -195,8 +195,7 @@ static bool32 CheckSioErrored(u8 taskId) return FALSE; } -// Unused -static void Task_DelayedBlockRequest(u8 taskId) +static void UNUSED Task_DelayedBlockRequest(u8 taskId) { gTasks[taskId].data[0]++; if (gTasks[taskId].data[0] == 10) @@ -1166,14 +1165,13 @@ void PlayerEnteredTradeSeat(void) CreateTask_EnterCableClubSeat(Task_StartWiredTrade); } -// Unused -static void CreateTask_StartWiredTrade(void) +static void UNUSED CreateTask_StartWiredTrade(void) { CreateTask(Task_StartWiredTrade, 80); } -// Unused, implemented in Ruby/Sapphire -void Script_StartWiredTrade(void) +// Implemented in Ruby/Sapphire +void UNUSED Script_StartWiredTrade(void) { // CreateTask_StartWiredTrade(); // ScriptContext_Stop(); @@ -1189,10 +1187,9 @@ void ColosseumPlayerSpotTriggered(void) CreateTask_EnterCableClubSeat(Task_StartWiredCableClubBattle); } -// Unused -static void CreateTask_EnterCableClubSeatNoFollowup(void) +static UNUSED void CreateTask_EnterCableClubSeatNoFollowup(void) { - u8 taskId = CreateTask(Task_EnterCableClubSeat, 80); + u8 UNUSED taskId = CreateTask(Task_EnterCableClubSeat, 80); ScriptContext_Stop(); } @@ -1262,8 +1259,7 @@ static void Task_WaitExitToScript(u8 taskId) } } -// Unused -static void ExitLinkToScript(u8 taskId) +static void UNUSED ExitLinkToScript(u8 taskId) { SetCloseLinkCallback(); gTasks[taskId].func = Task_WaitExitToScript; diff --git a/src/contest.c b/src/contest.c index 09c07536f1cf..e183c2bd7400 100644 --- a/src/contest.c +++ b/src/contest.c @@ -3251,8 +3251,7 @@ static void DrawMoveEffectSymbol(u16 move, u8 contestant) } } -// Unused -static void DrawMoveEffectSymbols(void) +static void UNUSED DrawMoveEffectSymbols(void) { s32 i; @@ -4221,8 +4220,7 @@ static void SpriteCB_EndBlinkContestantBox(struct Sprite *sprite) ResetBlendForContestantBoxBlink(); } -// Unused. -static void ContestDebugTogglePointTotal(void) +static void UNUSED ContestDebugTogglePointTotal(void) { if(eContestDebugMode == CONTEST_DEBUG_MODE_PRINT_POINT_TOTAL) eContestDebugMode = CONTEST_DEBUG_MODE_OFF; @@ -4876,15 +4874,13 @@ static void Task_ShowAndUpdateApplauseMeter(u8 taskId) } } -// Unused. -static void HideApplauseMeterNoAnim(void) +static void UNUSED HideApplauseMeterNoAnim(void) { gSprites[eContest.applauseMeterSpriteId].x2 = 0; gSprites[eContest.applauseMeterSpriteId].invisible = FALSE; } -// Unused. -static void ShowApplauseMeterNoAnim(void) +static void UNUSED ShowApplauseMeterNoAnim(void) { gSprites[eContest.applauseMeterSpriteId].invisible = TRUE; } diff --git a/src/credits.c b/src/credits.c index b412b29e27bd..69a4ebbbf3c4 100644 --- a/src/credits.c +++ b/src/credits.c @@ -80,7 +80,7 @@ struct CreditsEntry const u8 *text; }; -static EWRAM_DATA s16 sUnkVar = 0; // Never read, only set to 0 +static EWRAM_DATA s16 UNUSED sUnkVar = 0; // Never read, only set to 0 static EWRAM_DATA u16 sSavedTaskId = 0; EWRAM_DATA bool8 gHasHallOfFameRecords = 0; static EWRAM_DATA bool8 sUsedSpeedUp = 0; // Never read diff --git a/src/data.c b/src/data.c index 350927f86d94..bde609be1dd3 100644 --- a/src/data.c +++ b/src/data.c @@ -16,100 +16,100 @@ static const u32 sMinigameDigitsThin_Gfx[] = INCBIN_U32("graphics/link/minigame_ const struct SpriteFrameImage gBattlerPicTable_PlayerLeft[] = { - BATTLER_OFFSET(0), MON_PIC_SIZE, - BATTLER_OFFSET(1), MON_PIC_SIZE, - BATTLER_OFFSET(2), MON_PIC_SIZE, - BATTLER_OFFSET(3), MON_PIC_SIZE, + {BATTLER_OFFSET(0), MON_PIC_SIZE}, + {BATTLER_OFFSET(1), MON_PIC_SIZE}, + {BATTLER_OFFSET(2), MON_PIC_SIZE}, + {BATTLER_OFFSET(3), MON_PIC_SIZE}, }; const struct SpriteFrameImage gBattlerPicTable_OpponentLeft[] = { - BATTLER_OFFSET(4), MON_PIC_SIZE, - BATTLER_OFFSET(5), MON_PIC_SIZE, - BATTLER_OFFSET(6), MON_PIC_SIZE, - BATTLER_OFFSET(7), MON_PIC_SIZE, + {BATTLER_OFFSET(4), MON_PIC_SIZE}, + {BATTLER_OFFSET(5), MON_PIC_SIZE}, + {BATTLER_OFFSET(6), MON_PIC_SIZE}, + {BATTLER_OFFSET(7), MON_PIC_SIZE}, }; const struct SpriteFrameImage gBattlerPicTable_PlayerRight[] = { - BATTLER_OFFSET(8), MON_PIC_SIZE, - BATTLER_OFFSET(9), MON_PIC_SIZE, - BATTLER_OFFSET(10), MON_PIC_SIZE, - BATTLER_OFFSET(11), MON_PIC_SIZE, + {BATTLER_OFFSET(8), MON_PIC_SIZE}, + {BATTLER_OFFSET(9), MON_PIC_SIZE}, + {BATTLER_OFFSET(10), MON_PIC_SIZE}, + {BATTLER_OFFSET(11), MON_PIC_SIZE}, }; const struct SpriteFrameImage gBattlerPicTable_OpponentRight[] = { - BATTLER_OFFSET(12), MON_PIC_SIZE, - BATTLER_OFFSET(13), MON_PIC_SIZE, - BATTLER_OFFSET(14), MON_PIC_SIZE, - BATTLER_OFFSET(15), MON_PIC_SIZE, + {BATTLER_OFFSET(12), MON_PIC_SIZE}, + {BATTLER_OFFSET(13), MON_PIC_SIZE}, + {BATTLER_OFFSET(14), MON_PIC_SIZE}, + {BATTLER_OFFSET(15), MON_PIC_SIZE}, }; const struct SpriteFrameImage gTrainerBackPicTable_Brendan[] = { - gTrainerBackPic_Brendan + TRAINER_PIC_SIZE * 0, TRAINER_PIC_SIZE, - gTrainerBackPic_Brendan + TRAINER_PIC_SIZE * 1, TRAINER_PIC_SIZE, - gTrainerBackPic_Brendan + TRAINER_PIC_SIZE * 2, TRAINER_PIC_SIZE, - gTrainerBackPic_Brendan + TRAINER_PIC_SIZE * 3, TRAINER_PIC_SIZE, + {gTrainerBackPic_Brendan + TRAINER_PIC_SIZE * 0, TRAINER_PIC_SIZE}, + {gTrainerBackPic_Brendan + TRAINER_PIC_SIZE * 1, TRAINER_PIC_SIZE}, + {gTrainerBackPic_Brendan + TRAINER_PIC_SIZE * 2, TRAINER_PIC_SIZE}, + {gTrainerBackPic_Brendan + TRAINER_PIC_SIZE * 3, TRAINER_PIC_SIZE}, }; const struct SpriteFrameImage gTrainerBackPicTable_May[] = { - gTrainerBackPic_May + TRAINER_PIC_SIZE * 0, TRAINER_PIC_SIZE, - gTrainerBackPic_May + TRAINER_PIC_SIZE * 1, TRAINER_PIC_SIZE, - gTrainerBackPic_May + TRAINER_PIC_SIZE * 2, TRAINER_PIC_SIZE, - gTrainerBackPic_May + TRAINER_PIC_SIZE * 3, TRAINER_PIC_SIZE, + {gTrainerBackPic_May + TRAINER_PIC_SIZE * 0, TRAINER_PIC_SIZE}, + {gTrainerBackPic_May + TRAINER_PIC_SIZE * 1, TRAINER_PIC_SIZE}, + {gTrainerBackPic_May + TRAINER_PIC_SIZE * 2, TRAINER_PIC_SIZE}, + {gTrainerBackPic_May + TRAINER_PIC_SIZE * 3, TRAINER_PIC_SIZE}, }; const struct SpriteFrameImage gTrainerBackPicTable_Red[] = { - gTrainerBackPic_Red + TRAINER_PIC_SIZE * 0, TRAINER_PIC_SIZE, - gTrainerBackPic_Red + TRAINER_PIC_SIZE * 1, TRAINER_PIC_SIZE, - gTrainerBackPic_Red + TRAINER_PIC_SIZE * 2, TRAINER_PIC_SIZE, - gTrainerBackPic_Red + TRAINER_PIC_SIZE * 3, TRAINER_PIC_SIZE, - gTrainerBackPic_Red + TRAINER_PIC_SIZE * 4, TRAINER_PIC_SIZE, + {gTrainerBackPic_Red + TRAINER_PIC_SIZE * 0, TRAINER_PIC_SIZE}, + {gTrainerBackPic_Red + TRAINER_PIC_SIZE * 1, TRAINER_PIC_SIZE}, + {gTrainerBackPic_Red + TRAINER_PIC_SIZE * 2, TRAINER_PIC_SIZE}, + {gTrainerBackPic_Red + TRAINER_PIC_SIZE * 3, TRAINER_PIC_SIZE}, + {gTrainerBackPic_Red + TRAINER_PIC_SIZE * 4, TRAINER_PIC_SIZE}, }; const struct SpriteFrameImage gTrainerBackPicTable_Leaf[] = { - gTrainerBackPic_Leaf + TRAINER_PIC_SIZE * 0, TRAINER_PIC_SIZE, - gTrainerBackPic_Leaf + TRAINER_PIC_SIZE * 1, TRAINER_PIC_SIZE, - gTrainerBackPic_Leaf + TRAINER_PIC_SIZE * 2, TRAINER_PIC_SIZE, - gTrainerBackPic_Leaf + TRAINER_PIC_SIZE * 3, TRAINER_PIC_SIZE, - gTrainerBackPic_Leaf + TRAINER_PIC_SIZE * 4, TRAINER_PIC_SIZE, + {gTrainerBackPic_Leaf + TRAINER_PIC_SIZE * 0, TRAINER_PIC_SIZE}, + {gTrainerBackPic_Leaf + TRAINER_PIC_SIZE * 1, TRAINER_PIC_SIZE}, + {gTrainerBackPic_Leaf + TRAINER_PIC_SIZE * 2, TRAINER_PIC_SIZE}, + {gTrainerBackPic_Leaf + TRAINER_PIC_SIZE * 3, TRAINER_PIC_SIZE}, + {gTrainerBackPic_Leaf + TRAINER_PIC_SIZE * 4, TRAINER_PIC_SIZE}, }; const struct SpriteFrameImage gTrainerBackPicTable_RubySapphireBrendan[] = { - gTrainerBackPic_RubySapphireBrendan + TRAINER_PIC_SIZE * 0, TRAINER_PIC_SIZE, - gTrainerBackPic_RubySapphireBrendan + TRAINER_PIC_SIZE * 1, TRAINER_PIC_SIZE, - gTrainerBackPic_RubySapphireBrendan + TRAINER_PIC_SIZE * 2, TRAINER_PIC_SIZE, - gTrainerBackPic_RubySapphireBrendan + TRAINER_PIC_SIZE * 3, TRAINER_PIC_SIZE, + {gTrainerBackPic_RubySapphireBrendan + TRAINER_PIC_SIZE * 0, TRAINER_PIC_SIZE}, + {gTrainerBackPic_RubySapphireBrendan + TRAINER_PIC_SIZE * 1, TRAINER_PIC_SIZE}, + {gTrainerBackPic_RubySapphireBrendan + TRAINER_PIC_SIZE * 2, TRAINER_PIC_SIZE}, + {gTrainerBackPic_RubySapphireBrendan + TRAINER_PIC_SIZE * 3, TRAINER_PIC_SIZE}, }; const struct SpriteFrameImage gTrainerBackPicTable_RubySapphireMay[] = { - gTrainerBackPic_RubySapphireMay + TRAINER_PIC_SIZE * 0, TRAINER_PIC_SIZE, - gTrainerBackPic_RubySapphireMay + TRAINER_PIC_SIZE * 1, TRAINER_PIC_SIZE, - gTrainerBackPic_RubySapphireMay + TRAINER_PIC_SIZE * 2, TRAINER_PIC_SIZE, - gTrainerBackPic_RubySapphireMay + TRAINER_PIC_SIZE * 3, TRAINER_PIC_SIZE, + {gTrainerBackPic_RubySapphireMay + TRAINER_PIC_SIZE * 0, TRAINER_PIC_SIZE}, + {gTrainerBackPic_RubySapphireMay + TRAINER_PIC_SIZE * 1, TRAINER_PIC_SIZE}, + {gTrainerBackPic_RubySapphireMay + TRAINER_PIC_SIZE * 2, TRAINER_PIC_SIZE}, + {gTrainerBackPic_RubySapphireMay + TRAINER_PIC_SIZE * 3, TRAINER_PIC_SIZE}, }; const struct SpriteFrameImage gTrainerBackPicTable_Wally[] = { - gTrainerBackPic_Wally + TRAINER_PIC_SIZE * 0, TRAINER_PIC_SIZE, - gTrainerBackPic_Wally + TRAINER_PIC_SIZE * 1, TRAINER_PIC_SIZE, - gTrainerBackPic_Wally + TRAINER_PIC_SIZE * 2, TRAINER_PIC_SIZE, - gTrainerBackPic_Wally + TRAINER_PIC_SIZE * 3, TRAINER_PIC_SIZE, + {gTrainerBackPic_Wally + TRAINER_PIC_SIZE * 0, TRAINER_PIC_SIZE}, + {gTrainerBackPic_Wally + TRAINER_PIC_SIZE * 1, TRAINER_PIC_SIZE}, + {gTrainerBackPic_Wally + TRAINER_PIC_SIZE * 2, TRAINER_PIC_SIZE}, + {gTrainerBackPic_Wally + TRAINER_PIC_SIZE * 3, TRAINER_PIC_SIZE}, }; const struct SpriteFrameImage gTrainerBackPicTable_Steven[] = { - gTrainerBackPic_Steven + TRAINER_PIC_SIZE * 0, TRAINER_PIC_SIZE, - gTrainerBackPic_Steven + TRAINER_PIC_SIZE * 1, TRAINER_PIC_SIZE, - gTrainerBackPic_Steven + TRAINER_PIC_SIZE * 2, TRAINER_PIC_SIZE, - gTrainerBackPic_Steven + TRAINER_PIC_SIZE * 3, TRAINER_PIC_SIZE, + {gTrainerBackPic_Steven + TRAINER_PIC_SIZE * 0, TRAINER_PIC_SIZE}, + {gTrainerBackPic_Steven + TRAINER_PIC_SIZE * 1, TRAINER_PIC_SIZE}, + {gTrainerBackPic_Steven + TRAINER_PIC_SIZE * 2, TRAINER_PIC_SIZE}, + {gTrainerBackPic_Steven + TRAINER_PIC_SIZE * 3, TRAINER_PIC_SIZE}, }; static const union AnimCmd sAnim_GeneralFrame0[] = diff --git a/src/data/credits.h b/src/data/credits.h index 3ae2b1d3bea2..3b92ae26f78f 100644 --- a/src/data/credits.h +++ b/src/data/credits.h @@ -221,565 +221,565 @@ static const u8 sCreditsText_MotoyasuTojima[] = _("Motoyasu Toji static const u8 sCreditsText_NicolaPrattBarlow[] = _("Nicola Pratt-Barlow"); static const u8 sCreditsText_ShellieDow[] = _("Shellie Dow"); static const u8 sCreditsText_ErikJohnson[] = _("Erik Johnson"); -static const struct CreditsEntry sCreditsEntry_EmptyString[] = { 0, FALSE, sCreditsText_EmptyString}; -static const struct CreditsEntry sCreditsEntry_PkmnEmeraldVersion[] = { 7, TRUE, sCreditsText_PkmnEmeraldVersion}; -static const struct CreditsEntry sCreditsEntry_Credits[] = {11, TRUE, sCreditsText_Credits}; -static const struct CreditsEntry sCreditsEntry_ExecutiveDirector[] = { 8, TRUE, sCreditsText_ExecutiveDirector}; -static const struct CreditsEntry sCreditsEntry_Director[] = {12, TRUE, sCreditsText_Director}; -static const struct CreditsEntry sCreditsEntry_ArtDirector[] = {10, TRUE, sCreditsText_ArtDirector}; -static const struct CreditsEntry sCreditsEntry_BattleDirector[] = {10, TRUE, sCreditsText_BattleDirector}; -static const struct CreditsEntry sCreditsEntry_MainProgrammer[] = {10, TRUE, sCreditsText_MainProgrammer}; -static const struct CreditsEntry sCreditsEntry_BattleSystemPgrms[] = { 8, TRUE, sCreditsText_BattleSystemPgrms}; -static const struct CreditsEntry sCreditsEntry_FieldSystemPgrms[] = { 7, TRUE, sCreditsText_FieldSystemPgrms}; -static const struct CreditsEntry sCreditsEntry_Programmers[] = {12, TRUE, sCreditsText_Programmers}; -static const struct CreditsEntry sCreditsEntry_MainGraphicDesigner[] = { 7, TRUE, sCreditsText_MainGraphicDesigner}; -static const struct CreditsEntry sCreditsEntry_GraphicDesigners[] = { 9, TRUE, sCreditsText_GraphicDesigners}; -static const struct CreditsEntry sCreditsEntry_PkmnDesigners[] = {10, TRUE, sCreditsText_PkmnDesigners}; -static const struct CreditsEntry sCreditsEntry_MusicComposition[] = {13, TRUE, sCreditsText_MusicComposition}; -static const struct CreditsEntry sCreditsEntry_SoundEffectsAndPkmnVoices[] = { 4, TRUE, sCreditsText_SoundEffectsAndPkmnVoices}; -static const struct CreditsEntry sCreditsEntry_GameDesigners[] = {11, TRUE, sCreditsText_GameDesigners}; -static const struct CreditsEntry sCreditsEntry_ScenarioPlot[] = {11, TRUE, sCreditsText_ScenarioPlot}; -static const struct CreditsEntry sCreditsEntry_Scenario[] = {13, TRUE, sCreditsText_Scenario}; -static const struct CreditsEntry sCreditsEntry_ScriptDesigners[] = {10, TRUE, sCreditsText_ScriptDesigners}; -static const struct CreditsEntry sCreditsEntry_MapDesigners[] = {11, TRUE, sCreditsText_MapDesigners}; -static const struct CreditsEntry sCreditsEntry_MapDataDesigners[] = { 9, TRUE, sCreditsText_MapDataDesigners}; -static const struct CreditsEntry sCreditsEntry_ParametricDesigners[] = { 9, TRUE, sCreditsText_ParametricDesigners}; -static const struct CreditsEntry sCreditsEntry_PokedexText[] = {11, TRUE, sCreditsText_PokedexText}; -static const struct CreditsEntry sCreditsEntry_EnvAndToolPgrms[] = { 6, TRUE, sCreditsText_EnvAndToolPgrms}; -static const struct CreditsEntry sCreditsEntry_NCLProductTesting[] = {11, TRUE, sCreditsText_NCLProductTesting}; -static const struct CreditsEntry sCreditsEntry_SpecialThanks[] = {10, TRUE, sCreditsText_SpecialThanks}; -static const struct CreditsEntry sCreditsEntry_Coordinators[] = {11, TRUE, sCreditsText_Coordinators}; -static const struct CreditsEntry sCreditsEntry_Producers[] = {11, TRUE, sCreditsText_Producers}; -static const struct CreditsEntry sCreditsEntry_ExecProducers[] = { 7, TRUE, sCreditsText_ExecProducers}; -static const struct CreditsEntry sCreditsEntry_InfoSupervisors[] = {10, TRUE, sCreditsText_InfoSupervisors}; -static const struct CreditsEntry sCreditsEntry_TaskManagers[] = { 8, TRUE, sCreditsText_TaskManagers}; -static const struct CreditsEntry sCreditsEntry_BrailleCodeCheck[] = {10, TRUE, sCreditsText_BrailleCodeCheck}; -static const struct CreditsEntry sCreditsEntry_WorldDirector[] = {10, TRUE, sCreditsText_WorldDirector}; -static const struct CreditsEntry sCreditsEntry_BattleFrontierData[] = { 8, TRUE, sCreditsText_BattleFrontierData}; -static const struct CreditsEntry sCreditsEntry_SupportProgrammers[] = {10, TRUE, sCreditsText_SupportProgrammers}; -static const struct CreditsEntry sCreditsEntry_Artwork[] = {12, TRUE, sCreditsText_Artwork}; -static const struct CreditsEntry sCreditsEntry_LeadProgrammer[] = {10, TRUE, sCreditsText_LeadProgrammer}; -static const struct CreditsEntry sCreditsEntry_LeadGraphicArtist[] = { 9, TRUE, sCreditsText_LeadGraphicArtist}; -static const struct CreditsEntry sCreditsEntry_SatoshiTajiri[] = {11, FALSE, sCreditsText_SatoshiTajiri}; -static const struct CreditsEntry sCreditsEntry_JunichiMasuda[] = {11, FALSE, sCreditsText_JunichiMasuda}; -static const struct CreditsEntry sCreditsEntry_KenSugimori[] = {11, FALSE, sCreditsText_KenSugimori}; -static const struct CreditsEntry sCreditsEntry_ShigekiMorimoto[] = {11, FALSE, sCreditsText_ShigekiMorimoto}; -static const struct CreditsEntry sCreditsEntry_TetsuyaWatanabe[] = {11, FALSE, sCreditsText_TetsuyaWatanabe}; -static const struct CreditsEntry sCreditsEntry_HisashiSogabe[] = {11, FALSE, sCreditsText_HisashiSogabe}; -static const struct CreditsEntry sCreditsEntry_SosukeTamada[] = {11, FALSE, sCreditsText_SosukeTamada}; -static const struct CreditsEntry sCreditsEntry_AkitoMori[] = {11, FALSE, sCreditsText_AkitoMori}; -static const struct CreditsEntry sCreditsEntry_KeitaKagaya[] = {11, FALSE, sCreditsText_KeitaKagaya}; -static const struct CreditsEntry sCreditsEntry_YoshinoriMatsuda[] = {11, FALSE, sCreditsText_YoshinoriMatsuda}; -static const struct CreditsEntry sCreditsEntry_HiroyukiNakamura[] = {11, FALSE, sCreditsText_HiroyukiNakamura}; -static const struct CreditsEntry sCreditsEntry_MasaoTaya[] = {11, FALSE, sCreditsText_MasaoTaya}; -static const struct CreditsEntry sCreditsEntry_SatoshiNohara[] = {11, FALSE, sCreditsText_SatoshiNohara}; -static const struct CreditsEntry sCreditsEntry_TomomichiOhta[] = {11, FALSE, sCreditsText_TomomichiOhta}; -static const struct CreditsEntry sCreditsEntry_MiyukiIwasawa[] = {11, FALSE, sCreditsText_MiyukiIwasawa}; -static const struct CreditsEntry sCreditsEntry_TakenoriOhta[] = {11, FALSE, sCreditsText_TakenoriOhta}; -static const struct CreditsEntry sCreditsEntry_HironobuYoshida[] = {11, FALSE, sCreditsText_HironobuYoshida}; -static const struct CreditsEntry sCreditsEntry_MotofumiFujiwara[] = {11, FALSE, sCreditsText_MotofumiFujiwara}; -static const struct CreditsEntry sCreditsEntry_SatoshiOhta[] = {11, FALSE, sCreditsText_SatoshiOhta}; -static const struct CreditsEntry sCreditsEntry_AsukaIwashita[] = {11, FALSE, sCreditsText_AsukaIwashita}; -static const struct CreditsEntry sCreditsEntry_AimiTomita[] = {11, FALSE, sCreditsText_AimiTomita}; -static const struct CreditsEntry sCreditsEntry_TakaoUnno[] = {11, FALSE, sCreditsText_TakaoUnno}; -static const struct CreditsEntry sCreditsEntry_KanakoEo[] = {11, FALSE, sCreditsText_KanakoEo}; -static const struct CreditsEntry sCreditsEntry_JunOkutani[] = {11, FALSE, sCreditsText_JunOkutani}; -static const struct CreditsEntry sCreditsEntry_AtsukoNishida[] = {11, FALSE, sCreditsText_AtsukoNishida}; -static const struct CreditsEntry sCreditsEntry_MuneoSaito[] = {11, FALSE, sCreditsText_MuneoSaito}; -static const struct CreditsEntry sCreditsEntry_RenaYoshikawa[] = {11, FALSE, sCreditsText_RenaYoshikawa}; -static const struct CreditsEntry sCreditsEntry_GoIchinose[] = {11, FALSE, sCreditsText_GoIchinose}; -static const struct CreditsEntry sCreditsEntry_MorikazuAoki[] = {11, FALSE, sCreditsText_MorikazuAoki}; -static const struct CreditsEntry sCreditsEntry_KojiNishino[] = {11, FALSE, sCreditsText_KojiNishino}; -static const struct CreditsEntry sCreditsEntry_KenjiMatsushima[] = {11, FALSE, sCreditsText_KenjiMatsushima}; -static const struct CreditsEntry sCreditsEntry_TetsujiOhta[] = {11, FALSE, sCreditsText_TetsujiOhta}; -static const struct CreditsEntry sCreditsEntry_HitomiSato[] = {11, FALSE, sCreditsText_HitomiSato}; -static const struct CreditsEntry sCreditsEntry_TakeshiKawachimaru[] = {11, FALSE, sCreditsText_TakeshiKawachimaru}; -static const struct CreditsEntry sCreditsEntry_TeruyukiShimoyamada[] = {11, FALSE, sCreditsText_TeruyukiShimoyamada}; -static const struct CreditsEntry sCreditsEntry_ShigeruOhmori[] = {11, FALSE, sCreditsText_ShigeruOhmori}; -static const struct CreditsEntry sCreditsEntry_TadashiTakahashi[] = {11, FALSE, sCreditsText_TadashiTakahashi}; -static const struct CreditsEntry sCreditsEntry_ToshinobuMatsumiya[] = {11, FALSE, sCreditsText_ToshinobuMatsumiya}; -static const struct CreditsEntry sCreditsEntry_AkihitoTomisawa[] = {11, FALSE, sCreditsText_AkihitoTomisawa}; -static const struct CreditsEntry sCreditsEntry_HirokiEnomoto[] = {11, FALSE, sCreditsText_HirokiEnomoto}; -static const struct CreditsEntry sCreditsEntry_KazuyukiTerada[] = {11, FALSE, sCreditsText_KazuyukiTerada}; -static const struct CreditsEntry sCreditsEntry_YuriSakurai[] = {11, FALSE, sCreditsText_YuriSakurai}; -static const struct CreditsEntry sCreditsEntry_HiromiSagawa[] = {11, FALSE, sCreditsText_HiromiSagawa}; -static const struct CreditsEntry sCreditsEntry_KenjiTominaga[] = {11, FALSE, sCreditsText_KenjiTominaga}; -static const struct CreditsEntry sCreditsEntry_YoshioTajiri[] = {11, FALSE, sCreditsText_YoshioTajiri}; -static const struct CreditsEntry sCreditsEntry_TeikoSasaki[] = {11, FALSE, sCreditsText_TeikoSasaki}; -static const struct CreditsEntry sCreditsEntry_SachikoHamano[] = {11, FALSE, sCreditsText_SachikoHamano}; -static const struct CreditsEntry sCreditsEntry_ChieMatsumiya[] = {11, FALSE, sCreditsText_ChieMatsumiya}; -static const struct CreditsEntry sCreditsEntry_AkikoShinozaki[] = {11, FALSE, sCreditsText_AkikoShinozaki}; -static const struct CreditsEntry sCreditsEntry_AstukoFujii[] = {11, FALSE, sCreditsText_AstukoFujii}; -static const struct CreditsEntry sCreditsEntry_NozomuSaito[] = {11, FALSE, sCreditsText_NozomuSaito}; -static const struct CreditsEntry sCreditsEntry_KenkichiToyama[] = {11, FALSE, sCreditsText_KenkichiToyama}; -static const struct CreditsEntry sCreditsEntry_SuguruNakatsui[] = {11, FALSE, sCreditsText_SuguruNakatsui}; -static const struct CreditsEntry sCreditsEntry_YumiFunasaka[] = {11, FALSE, sCreditsText_YumiFunasaka}; -static const struct CreditsEntry sCreditsEntry_NaokoYanase[] = {11, FALSE, sCreditsText_NaokoYanase}; -static const struct CreditsEntry sCreditsEntry_NCLSuperMarioClub[] = {11, FALSE, sCreditsText_NCLSuperMarioClub}; -static const struct CreditsEntry sCreditsEntry_AtsushiTada[] = {11, FALSE, sCreditsText_AtsushiTada}; -static const struct CreditsEntry sCreditsEntry_TakahiroOhnishi[] = {11, FALSE, sCreditsText_TakahiroOhnishi}; -static const struct CreditsEntry sCreditsEntry_NorihideOkamura[] = {11, FALSE, sCreditsText_NorihideOkamura}; -static const struct CreditsEntry sCreditsEntry_HiroNakamura[] = {11, FALSE, sCreditsText_HiroNakamura}; -static const struct CreditsEntry sCreditsEntry_HiroyukiUesugi[] = {11, FALSE, sCreditsText_HiroyukiUesugi}; -static const struct CreditsEntry sCreditsEntry_TerukiMurakawa[] = {11, FALSE, sCreditsText_TerukiMurakawa}; -static const struct CreditsEntry sCreditsEntry_AkiraKinashi[] = {11, FALSE, sCreditsText_AkiraKinashi}; -static const struct CreditsEntry sCreditsEntry_MichikoTakizawa[] = {11, FALSE, sCreditsText_MichikoTakizawa}; -static const struct CreditsEntry sCreditsEntry_MakikoTakada[] = {11, FALSE, sCreditsText_MakikoTakada}; -static const struct CreditsEntry sCreditsEntry_TakanaoKondo[] = {11, FALSE, sCreditsText_TakanaoKondo}; -static const struct CreditsEntry sCreditsEntry_AiMashima[] = {11, FALSE, sCreditsText_AiMashima}; -static const struct CreditsEntry sCreditsEntry_GakujiNomoto[] = {11, FALSE, sCreditsText_GakujiNomoto}; -static const struct CreditsEntry sCreditsEntry_TakehiroIzushi[] = {11, FALSE, sCreditsText_TakehiroIzushi}; -static const struct CreditsEntry sCreditsEntry_HitoshiYamagami[] = {11, FALSE, sCreditsText_HitoshiYamagami}; -static const struct CreditsEntry sCreditsEntry_KyokoWatanabe[] = {11, FALSE, sCreditsText_KyokoWatanabe}; -static const struct CreditsEntry sCreditsEntry_TakaoNakano[] = {11, FALSE, sCreditsText_TakaoNakano}; -static const struct CreditsEntry sCreditsEntry_HiroyukiJinnai[] = {11, FALSE, sCreditsText_HiroyukiJinnai}; -static const struct CreditsEntry sCreditsEntry_HiroakiTsuru[] = {11, FALSE, sCreditsText_HiroakiTsuru}; -static const struct CreditsEntry sCreditsEntry_TsunekazIshihara[] = {11, FALSE, sCreditsText_TsunekazIshihara}; -static const struct CreditsEntry sCreditsEntry_SatoruIwata[] = {11, FALSE, sCreditsText_SatoruIwata}; -static const struct CreditsEntry sCreditsEntry_KazuyaSuyama[] = {11, FALSE, sCreditsText_KazuyaSuyama}; -static const struct CreditsEntry sCreditsEntry_SatoshiMitsuhara[] = {11, FALSE, sCreditsText_SatoshiMitsuhara}; -static const struct CreditsEntry sCreditsEntry_JapanBrailleLibrary[] = { 9, FALSE, sCreditsText_JapanBrailleLibrary}; -static const struct CreditsEntry sCreditsEntry_TomotakaKomura[] = {11, FALSE, sCreditsText_TomotakaKomura}; -static const struct CreditsEntry sCreditsEntry_MikikoOhhashi[] = {11, FALSE, sCreditsText_MikikoOhhashi}; -static const struct CreditsEntry sCreditsEntry_DaisukeHoshino[] = {11, FALSE, sCreditsText_DaisukeHoshino}; -static const struct CreditsEntry sCreditsEntry_KenjiroIto[] = {11, FALSE, sCreditsText_KenjiroIto}; -static const struct CreditsEntry sCreditsEntry_RuiKawaguchi[] = {11, FALSE, sCreditsText_RuiKawaguchi}; -static const struct CreditsEntry sCreditsEntry_ShunsukeKohori[] = {11, FALSE, sCreditsText_ShunsukeKohori}; -static const struct CreditsEntry sCreditsEntry_SachikoNakamichi[] = {11, FALSE, sCreditsText_SachikoNakamichi}; -static const struct CreditsEntry sCreditsEntry_FujikoNomura[] = {11, FALSE, sCreditsText_FujikoNomura}; -static const struct CreditsEntry sCreditsEntry_KazukiYoshihara[] = {11, FALSE, sCreditsText_KazukiYoshihara}; -static const struct CreditsEntry sCreditsEntry_RetsujiNomoto[] = {11, FALSE, sCreditsText_RetsujiNomoto}; -static const struct CreditsEntry sCreditsEntry_AzusaTajima[] = {11, FALSE, sCreditsText_AzusaTajima}; -static const struct CreditsEntry sCreditsEntry_ShusakuEgami[] = {11, FALSE, sCreditsText_ShusakuEgami}; -static const struct CreditsEntry sCreditsEntry_PackageAndManual[] = { 0, TRUE, sCreditsText_PackageAndManual}; -static const struct CreditsEntry sCreditsEntry_EnglishVersion[] = { 0, TRUE, sCreditsText_EnglishVersion}; -static const struct CreditsEntry sCreditsEntry_Translator[] = { 0, TRUE, sCreditsText_Translator}; -static const struct CreditsEntry sCreditsEntry_TextEditor[] = { 0, TRUE, sCreditsText_TextEditor}; -static const struct CreditsEntry sCreditsEntry_NCLCoordinator[] = { 0, TRUE, sCreditsText_NCLCoordinator}; -static const struct CreditsEntry sCreditsEntry_GraphicDesigner[] = { 0, TRUE, sCreditsText_GraphicDesigner}; -static const struct CreditsEntry sCreditsEntry_NOAProductTesting[] = { 0, TRUE, sCreditsText_NOAProductTesting}; -static const struct CreditsEntry sCreditsEntry_HideyukiNakajima[] = { 0, FALSE, sCreditsText_HideyukiNakajima}; -static const struct CreditsEntry sCreditsEntry_HidenoriSaeki[] = { 0, FALSE, sCreditsText_HidenoriSaeki}; -static const struct CreditsEntry sCreditsEntry_YokoWatanabe[] = { 0, FALSE, sCreditsText_YokoWatanabe}; -static const struct CreditsEntry sCreditsEntry_SakaeKimura[] = { 0, FALSE, sCreditsText_SakaeKimura}; -static const struct CreditsEntry sCreditsEntry_ChiakiShinkai[] = { 0, FALSE, sCreditsText_ChiakiShinkai}; -static const struct CreditsEntry sCreditsEntry_SethMcMahill[] = { 0, FALSE, sCreditsText_SethMcMahill}; -static const struct CreditsEntry sCreditsEntry_NobOgasawara[] = { 0, FALSE, sCreditsText_NobOgasawara}; -static const struct CreditsEntry sCreditsEntry_TeresaLillygren[] = { 0, FALSE, sCreditsText_TeresaLillygren}; -static const struct CreditsEntry sCreditsEntry_KimikoNakamichi[] = { 0, FALSE, sCreditsText_KimikoNakamichi}; -static const struct CreditsEntry sCreditsEntry_SouichiYamamoto[] = { 0, FALSE, sCreditsText_SouichiYamamoto}; -static const struct CreditsEntry sCreditsEntry_YuichiroIto[] = { 0, FALSE, sCreditsText_YuichiroIto}; -static const struct CreditsEntry sCreditsEntry_ThomasHertzog[] = { 0, FALSE, sCreditsText_ThomasHertzog}; -static const struct CreditsEntry sCreditsEntry_MikaKurosawa[] = { 0, FALSE, sCreditsText_MikaKurosawa}; -static const struct CreditsEntry sCreditsEntry_NationalFederationBlind[] = { 0, FALSE, sCreditsText_NationalFederationBlind}; -static const struct CreditsEntry sCreditsEntry_PatriciaAMaurer[] = { 0, FALSE, sCreditsText_PatriciaAMaurer}; -static const struct CreditsEntry sCreditsEntry_EuropeanBlindUnion[] = { 0, FALSE, sCreditsText_EuropeanBlindUnion}; -static const struct CreditsEntry sCreditsEntry_AustralianBrailleAuthority[] = { 0, FALSE, sCreditsText_AustralianBrailleAuthority}; -static const struct CreditsEntry sCreditsEntry_RoyalNewZealandFederationBlind[] = { 0, FALSE, sCreditsText_RoyalNewZealandFederationBlind}; -static const struct CreditsEntry sCreditsEntry_MotoyasuTojima[] = { 0, FALSE, sCreditsText_MotoyasuTojima}; -static const struct CreditsEntry sCreditsEntry_NicolaPrattBarlow[] = { 0, FALSE, sCreditsText_NicolaPrattBarlow}; -static const struct CreditsEntry sCreditsEntry_ShellieDow[] = { 0, FALSE, sCreditsText_ShellieDow}; -static const struct CreditsEntry sCreditsEntry_ErikJohnson[] = { 0, FALSE, sCreditsText_ErikJohnson}; +static const struct CreditsEntry sCreditsEntry_EmptyString = { 0, FALSE, sCreditsText_EmptyString}; +static const struct CreditsEntry sCreditsEntry_PkmnEmeraldVersion = { 7, TRUE, sCreditsText_PkmnEmeraldVersion}; +static const struct CreditsEntry sCreditsEntry_Credits = {11, TRUE, sCreditsText_Credits}; +static const struct CreditsEntry sCreditsEntry_ExecutiveDirector = { 8, TRUE, sCreditsText_ExecutiveDirector}; +static const struct CreditsEntry sCreditsEntry_Director = {12, TRUE, sCreditsText_Director}; +static const struct CreditsEntry sCreditsEntry_ArtDirector = {10, TRUE, sCreditsText_ArtDirector}; +static const struct CreditsEntry sCreditsEntry_BattleDirector = {10, TRUE, sCreditsText_BattleDirector}; +static const struct CreditsEntry sCreditsEntry_MainProgrammer = {10, TRUE, sCreditsText_MainProgrammer}; +static const struct CreditsEntry sCreditsEntry_BattleSystemPgrms = { 8, TRUE, sCreditsText_BattleSystemPgrms}; +static const struct CreditsEntry sCreditsEntry_FieldSystemPgrms = { 7, TRUE, sCreditsText_FieldSystemPgrms}; +static const struct CreditsEntry sCreditsEntry_Programmers = {12, TRUE, sCreditsText_Programmers}; +static const struct CreditsEntry sCreditsEntry_MainGraphicDesigner = { 7, TRUE, sCreditsText_MainGraphicDesigner}; +static const struct CreditsEntry sCreditsEntry_GraphicDesigners = { 9, TRUE, sCreditsText_GraphicDesigners}; +static const struct CreditsEntry sCreditsEntry_PkmnDesigners = {10, TRUE, sCreditsText_PkmnDesigners}; +static const struct CreditsEntry sCreditsEntry_MusicComposition = {13, TRUE, sCreditsText_MusicComposition}; +static const struct CreditsEntry sCreditsEntry_SoundEffectsAndPkmnVoices = { 4, TRUE, sCreditsText_SoundEffectsAndPkmnVoices}; +static const struct CreditsEntry sCreditsEntry_GameDesigners = {11, TRUE, sCreditsText_GameDesigners}; +static const struct CreditsEntry sCreditsEntry_ScenarioPlot = {11, TRUE, sCreditsText_ScenarioPlot}; +static const struct CreditsEntry sCreditsEntry_Scenario = {13, TRUE, sCreditsText_Scenario}; +static const struct CreditsEntry sCreditsEntry_ScriptDesigners = {10, TRUE, sCreditsText_ScriptDesigners}; +static const struct CreditsEntry sCreditsEntry_MapDesigners = {11, TRUE, sCreditsText_MapDesigners}; +static const struct CreditsEntry sCreditsEntry_MapDataDesigners = { 9, TRUE, sCreditsText_MapDataDesigners}; +static const struct CreditsEntry sCreditsEntry_ParametricDesigners = { 9, TRUE, sCreditsText_ParametricDesigners}; +static const struct CreditsEntry sCreditsEntry_PokedexText = {11, TRUE, sCreditsText_PokedexText}; +static const struct CreditsEntry sCreditsEntry_EnvAndToolPgrms = { 6, TRUE, sCreditsText_EnvAndToolPgrms}; +static const struct CreditsEntry sCreditsEntry_NCLProductTesting = {11, TRUE, sCreditsText_NCLProductTesting}; +static const struct CreditsEntry sCreditsEntry_SpecialThanks = {10, TRUE, sCreditsText_SpecialThanks}; +static const struct CreditsEntry sCreditsEntry_Coordinators = {11, TRUE, sCreditsText_Coordinators}; +static const struct CreditsEntry sCreditsEntry_Producers = {11, TRUE, sCreditsText_Producers}; +static const struct CreditsEntry sCreditsEntry_ExecProducers = { 7, TRUE, sCreditsText_ExecProducers}; +static const struct CreditsEntry sCreditsEntry_InfoSupervisors = {10, TRUE, sCreditsText_InfoSupervisors}; +static const struct CreditsEntry sCreditsEntry_TaskManagers = { 8, TRUE, sCreditsText_TaskManagers}; +static const struct CreditsEntry sCreditsEntry_BrailleCodeCheck = {10, TRUE, sCreditsText_BrailleCodeCheck}; +static const struct CreditsEntry sCreditsEntry_WorldDirector = {10, TRUE, sCreditsText_WorldDirector}; +static const struct CreditsEntry sCreditsEntry_BattleFrontierData = { 8, TRUE, sCreditsText_BattleFrontierData}; +static const struct CreditsEntry sCreditsEntry_SupportProgrammers = {10, TRUE, sCreditsText_SupportProgrammers}; +static const struct CreditsEntry sCreditsEntry_Artwork = {12, TRUE, sCreditsText_Artwork}; +static const struct CreditsEntry sCreditsEntry_LeadProgrammer = {10, TRUE, sCreditsText_LeadProgrammer}; +static const struct CreditsEntry sCreditsEntry_LeadGraphicArtist = { 9, TRUE, sCreditsText_LeadGraphicArtist}; +static const struct CreditsEntry sCreditsEntry_SatoshiTajiri = {11, FALSE, sCreditsText_SatoshiTajiri}; +static const struct CreditsEntry sCreditsEntry_JunichiMasuda = {11, FALSE, sCreditsText_JunichiMasuda}; +static const struct CreditsEntry sCreditsEntry_KenSugimori = {11, FALSE, sCreditsText_KenSugimori}; +static const struct CreditsEntry sCreditsEntry_ShigekiMorimoto = {11, FALSE, sCreditsText_ShigekiMorimoto}; +static const struct CreditsEntry sCreditsEntry_TetsuyaWatanabe = {11, FALSE, sCreditsText_TetsuyaWatanabe}; +static const struct CreditsEntry sCreditsEntry_HisashiSogabe = {11, FALSE, sCreditsText_HisashiSogabe}; +static const struct CreditsEntry sCreditsEntry_SosukeTamada = {11, FALSE, sCreditsText_SosukeTamada}; +static const struct CreditsEntry sCreditsEntry_AkitoMori = {11, FALSE, sCreditsText_AkitoMori}; +static const struct CreditsEntry sCreditsEntry_KeitaKagaya = {11, FALSE, sCreditsText_KeitaKagaya}; +static const struct CreditsEntry sCreditsEntry_YoshinoriMatsuda = {11, FALSE, sCreditsText_YoshinoriMatsuda}; +static const struct CreditsEntry sCreditsEntry_HiroyukiNakamura = {11, FALSE, sCreditsText_HiroyukiNakamura}; +static const struct CreditsEntry sCreditsEntry_MasaoTaya = {11, FALSE, sCreditsText_MasaoTaya}; +static const struct CreditsEntry sCreditsEntry_SatoshiNohara = {11, FALSE, sCreditsText_SatoshiNohara}; +static const struct CreditsEntry sCreditsEntry_TomomichiOhta = {11, FALSE, sCreditsText_TomomichiOhta}; +static const struct CreditsEntry sCreditsEntry_MiyukiIwasawa = {11, FALSE, sCreditsText_MiyukiIwasawa}; +static const struct CreditsEntry sCreditsEntry_TakenoriOhta = {11, FALSE, sCreditsText_TakenoriOhta}; +static const struct CreditsEntry sCreditsEntry_HironobuYoshida = {11, FALSE, sCreditsText_HironobuYoshida}; +static const struct CreditsEntry sCreditsEntry_MotofumiFujiwara = {11, FALSE, sCreditsText_MotofumiFujiwara}; +static const struct CreditsEntry sCreditsEntry_SatoshiOhta = {11, FALSE, sCreditsText_SatoshiOhta}; +static const struct CreditsEntry sCreditsEntry_AsukaIwashita = {11, FALSE, sCreditsText_AsukaIwashita}; +static const struct CreditsEntry sCreditsEntry_AimiTomita = {11, FALSE, sCreditsText_AimiTomita}; +static const struct CreditsEntry sCreditsEntry_TakaoUnno = {11, FALSE, sCreditsText_TakaoUnno}; +static const struct CreditsEntry sCreditsEntry_KanakoEo = {11, FALSE, sCreditsText_KanakoEo}; +static const struct CreditsEntry sCreditsEntry_JunOkutani = {11, FALSE, sCreditsText_JunOkutani}; +static const struct CreditsEntry sCreditsEntry_AtsukoNishida = {11, FALSE, sCreditsText_AtsukoNishida}; +static const struct CreditsEntry sCreditsEntry_MuneoSaito = {11, FALSE, sCreditsText_MuneoSaito}; +static const struct CreditsEntry sCreditsEntry_RenaYoshikawa = {11, FALSE, sCreditsText_RenaYoshikawa}; +static const struct CreditsEntry sCreditsEntry_GoIchinose = {11, FALSE, sCreditsText_GoIchinose}; +static const struct CreditsEntry sCreditsEntry_MorikazuAoki = {11, FALSE, sCreditsText_MorikazuAoki}; +static const struct CreditsEntry sCreditsEntry_KojiNishino = {11, FALSE, sCreditsText_KojiNishino}; +static const struct CreditsEntry sCreditsEntry_KenjiMatsushima = {11, FALSE, sCreditsText_KenjiMatsushima}; +static const struct CreditsEntry sCreditsEntry_TetsujiOhta = {11, FALSE, sCreditsText_TetsujiOhta}; +static const struct CreditsEntry sCreditsEntry_HitomiSato = {11, FALSE, sCreditsText_HitomiSato}; +static const struct CreditsEntry sCreditsEntry_TakeshiKawachimaru = {11, FALSE, sCreditsText_TakeshiKawachimaru}; +static const struct CreditsEntry sCreditsEntry_TeruyukiShimoyamada = {11, FALSE, sCreditsText_TeruyukiShimoyamada}; +static const struct CreditsEntry sCreditsEntry_ShigeruOhmori = {11, FALSE, sCreditsText_ShigeruOhmori}; +static const struct CreditsEntry sCreditsEntry_TadashiTakahashi = {11, FALSE, sCreditsText_TadashiTakahashi}; +static const struct CreditsEntry sCreditsEntry_ToshinobuMatsumiya = {11, FALSE, sCreditsText_ToshinobuMatsumiya}; +static const struct CreditsEntry sCreditsEntry_AkihitoTomisawa = {11, FALSE, sCreditsText_AkihitoTomisawa}; +static const struct CreditsEntry sCreditsEntry_HirokiEnomoto = {11, FALSE, sCreditsText_HirokiEnomoto}; +static const struct CreditsEntry sCreditsEntry_KazuyukiTerada = {11, FALSE, sCreditsText_KazuyukiTerada}; +static const struct CreditsEntry sCreditsEntry_YuriSakurai = {11, FALSE, sCreditsText_YuriSakurai}; +static const struct CreditsEntry sCreditsEntry_HiromiSagawa = {11, FALSE, sCreditsText_HiromiSagawa}; +static const struct CreditsEntry sCreditsEntry_KenjiTominaga = {11, FALSE, sCreditsText_KenjiTominaga}; +static const struct CreditsEntry sCreditsEntry_YoshioTajiri = {11, FALSE, sCreditsText_YoshioTajiri}; +static const struct CreditsEntry sCreditsEntry_TeikoSasaki = {11, FALSE, sCreditsText_TeikoSasaki}; +static const struct CreditsEntry sCreditsEntry_SachikoHamano = {11, FALSE, sCreditsText_SachikoHamano}; +static const struct CreditsEntry sCreditsEntry_ChieMatsumiya = {11, FALSE, sCreditsText_ChieMatsumiya}; +static const struct CreditsEntry sCreditsEntry_AkikoShinozaki = {11, FALSE, sCreditsText_AkikoShinozaki}; +static const struct CreditsEntry sCreditsEntry_AstukoFujii = {11, FALSE, sCreditsText_AstukoFujii}; +static const struct CreditsEntry sCreditsEntry_NozomuSaito = {11, FALSE, sCreditsText_NozomuSaito}; +static const struct CreditsEntry sCreditsEntry_KenkichiToyama = {11, FALSE, sCreditsText_KenkichiToyama}; +static const struct CreditsEntry sCreditsEntry_SuguruNakatsui = {11, FALSE, sCreditsText_SuguruNakatsui}; +static const struct CreditsEntry sCreditsEntry_YumiFunasaka = {11, FALSE, sCreditsText_YumiFunasaka}; +static const struct CreditsEntry sCreditsEntry_NaokoYanase = {11, FALSE, sCreditsText_NaokoYanase}; +static const struct CreditsEntry sCreditsEntry_NCLSuperMarioClub = {11, FALSE, sCreditsText_NCLSuperMarioClub}; +static const struct CreditsEntry sCreditsEntry_AtsushiTada = {11, FALSE, sCreditsText_AtsushiTada}; +static const struct CreditsEntry sCreditsEntry_TakahiroOhnishi = {11, FALSE, sCreditsText_TakahiroOhnishi}; +static const struct CreditsEntry sCreditsEntry_NorihideOkamura = {11, FALSE, sCreditsText_NorihideOkamura}; +static const struct CreditsEntry sCreditsEntry_HiroNakamura = {11, FALSE, sCreditsText_HiroNakamura}; +static const struct CreditsEntry sCreditsEntry_HiroyukiUesugi = {11, FALSE, sCreditsText_HiroyukiUesugi}; +static const struct CreditsEntry sCreditsEntry_TerukiMurakawa = {11, FALSE, sCreditsText_TerukiMurakawa}; +static const struct CreditsEntry sCreditsEntry_AkiraKinashi = {11, FALSE, sCreditsText_AkiraKinashi}; +static const struct CreditsEntry sCreditsEntry_MichikoTakizawa = {11, FALSE, sCreditsText_MichikoTakizawa}; +static const struct CreditsEntry sCreditsEntry_MakikoTakada = {11, FALSE, sCreditsText_MakikoTakada}; +static const struct CreditsEntry sCreditsEntry_TakanaoKondo = {11, FALSE, sCreditsText_TakanaoKondo}; +static const struct CreditsEntry sCreditsEntry_AiMashima = {11, FALSE, sCreditsText_AiMashima}; +static const struct CreditsEntry sCreditsEntry_GakujiNomoto = {11, FALSE, sCreditsText_GakujiNomoto}; +static const struct CreditsEntry sCreditsEntry_TakehiroIzushi = {11, FALSE, sCreditsText_TakehiroIzushi}; +static const struct CreditsEntry sCreditsEntry_HitoshiYamagami = {11, FALSE, sCreditsText_HitoshiYamagami}; +static const struct CreditsEntry sCreditsEntry_KyokoWatanabe = {11, FALSE, sCreditsText_KyokoWatanabe}; +static const struct CreditsEntry sCreditsEntry_TakaoNakano = {11, FALSE, sCreditsText_TakaoNakano}; +static const struct CreditsEntry sCreditsEntry_HiroyukiJinnai = {11, FALSE, sCreditsText_HiroyukiJinnai}; +static const struct CreditsEntry sCreditsEntry_HiroakiTsuru = {11, FALSE, sCreditsText_HiroakiTsuru}; +static const struct CreditsEntry sCreditsEntry_TsunekazIshihara = {11, FALSE, sCreditsText_TsunekazIshihara}; +static const struct CreditsEntry sCreditsEntry_SatoruIwata = {11, FALSE, sCreditsText_SatoruIwata}; +static const struct CreditsEntry sCreditsEntry_KazuyaSuyama = {11, FALSE, sCreditsText_KazuyaSuyama}; +static const struct CreditsEntry sCreditsEntry_SatoshiMitsuhara = {11, FALSE, sCreditsText_SatoshiMitsuhara}; +static const struct CreditsEntry sCreditsEntry_JapanBrailleLibrary = { 9, FALSE, sCreditsText_JapanBrailleLibrary}; +static const struct CreditsEntry sCreditsEntry_TomotakaKomura = {11, FALSE, sCreditsText_TomotakaKomura}; +static const struct CreditsEntry sCreditsEntry_MikikoOhhashi = {11, FALSE, sCreditsText_MikikoOhhashi}; +static const struct CreditsEntry sCreditsEntry_DaisukeHoshino = {11, FALSE, sCreditsText_DaisukeHoshino}; +static const struct CreditsEntry sCreditsEntry_KenjiroIto = {11, FALSE, sCreditsText_KenjiroIto}; +static const struct CreditsEntry sCreditsEntry_RuiKawaguchi = {11, FALSE, sCreditsText_RuiKawaguchi}; +static const struct CreditsEntry sCreditsEntry_ShunsukeKohori = {11, FALSE, sCreditsText_ShunsukeKohori}; +static const struct CreditsEntry sCreditsEntry_SachikoNakamichi = {11, FALSE, sCreditsText_SachikoNakamichi}; +static const struct CreditsEntry sCreditsEntry_FujikoNomura = {11, FALSE, sCreditsText_FujikoNomura}; +static const struct CreditsEntry sCreditsEntry_KazukiYoshihara = {11, FALSE, sCreditsText_KazukiYoshihara}; +static const struct CreditsEntry sCreditsEntry_RetsujiNomoto = {11, FALSE, sCreditsText_RetsujiNomoto}; +static const struct CreditsEntry sCreditsEntry_AzusaTajima = {11, FALSE, sCreditsText_AzusaTajima}; +static const struct CreditsEntry sCreditsEntry_ShusakuEgami = {11, FALSE, sCreditsText_ShusakuEgami}; +static const struct CreditsEntry sCreditsEntry_PackageAndManual = { 0, TRUE, sCreditsText_PackageAndManual}; +static const struct CreditsEntry sCreditsEntry_EnglishVersion = { 0, TRUE, sCreditsText_EnglishVersion}; +static const struct CreditsEntry sCreditsEntry_Translator = { 0, TRUE, sCreditsText_Translator}; +static const struct CreditsEntry sCreditsEntry_TextEditor = { 0, TRUE, sCreditsText_TextEditor}; +static const struct CreditsEntry sCreditsEntry_NCLCoordinator = { 0, TRUE, sCreditsText_NCLCoordinator}; +static const struct CreditsEntry sCreditsEntry_GraphicDesigner = { 0, TRUE, sCreditsText_GraphicDesigner}; +static const struct CreditsEntry sCreditsEntry_NOAProductTesting = { 0, TRUE, sCreditsText_NOAProductTesting}; +static const struct CreditsEntry sCreditsEntry_HideyukiNakajima = { 0, FALSE, sCreditsText_HideyukiNakajima}; +static const struct CreditsEntry sCreditsEntry_HidenoriSaeki = { 0, FALSE, sCreditsText_HidenoriSaeki}; +static const struct CreditsEntry sCreditsEntry_YokoWatanabe = { 0, FALSE, sCreditsText_YokoWatanabe}; +static const struct CreditsEntry sCreditsEntry_SakaeKimura = { 0, FALSE, sCreditsText_SakaeKimura}; +static const struct CreditsEntry sCreditsEntry_ChiakiShinkai = { 0, FALSE, sCreditsText_ChiakiShinkai}; +static const struct CreditsEntry sCreditsEntry_SethMcMahill = { 0, FALSE, sCreditsText_SethMcMahill}; +static const struct CreditsEntry sCreditsEntry_NobOgasawara = { 0, FALSE, sCreditsText_NobOgasawara}; +static const struct CreditsEntry sCreditsEntry_TeresaLillygren = { 0, FALSE, sCreditsText_TeresaLillygren}; +static const struct CreditsEntry sCreditsEntry_KimikoNakamichi = { 0, FALSE, sCreditsText_KimikoNakamichi}; +static const struct CreditsEntry sCreditsEntry_SouichiYamamoto = { 0, FALSE, sCreditsText_SouichiYamamoto}; +static const struct CreditsEntry sCreditsEntry_YuichiroIto = { 0, FALSE, sCreditsText_YuichiroIto}; +static const struct CreditsEntry sCreditsEntry_ThomasHertzog = { 0, FALSE, sCreditsText_ThomasHertzog}; +static const struct CreditsEntry sCreditsEntry_MikaKurosawa = { 0, FALSE, sCreditsText_MikaKurosawa}; +static const struct CreditsEntry sCreditsEntry_NationalFederationBlind = { 0, FALSE, sCreditsText_NationalFederationBlind}; +static const struct CreditsEntry sCreditsEntry_PatriciaAMaurer = { 0, FALSE, sCreditsText_PatriciaAMaurer}; +static const struct CreditsEntry sCreditsEntry_EuropeanBlindUnion = { 0, FALSE, sCreditsText_EuropeanBlindUnion}; +static const struct CreditsEntry sCreditsEntry_AustralianBrailleAuthority = { 0, FALSE, sCreditsText_AustralianBrailleAuthority}; +static const struct CreditsEntry sCreditsEntry_RoyalNewZealandFederationBlind = { 0, FALSE, sCreditsText_RoyalNewZealandFederationBlind}; +static const struct CreditsEntry sCreditsEntry_MotoyasuTojima = { 0, FALSE, sCreditsText_MotoyasuTojima}; +static const struct CreditsEntry sCreditsEntry_NicolaPrattBarlow = { 0, FALSE, sCreditsText_NicolaPrattBarlow}; +static const struct CreditsEntry sCreditsEntry_ShellieDow = { 0, FALSE, sCreditsText_ShellieDow}; +static const struct CreditsEntry sCreditsEntry_ErikJohnson = { 0, FALSE, sCreditsText_ErikJohnson}; -#define _ sCreditsEntry_EmptyString +#define _ &sCreditsEntry_EmptyString static const struct CreditsEntry *const sCreditsEntryPointerTable[PAGE_COUNT][ENTRIES_PER_PAGE] = { [PAGE_TITLE] = { _, - sCreditsEntry_PkmnEmeraldVersion, - sCreditsEntry_Credits, + &sCreditsEntry_PkmnEmeraldVersion, + &sCreditsEntry_Credits, _, _ }, [PAGE_DIRECTOR] = { _, - sCreditsEntry_Director, - sCreditsEntry_ShigekiMorimoto, + &sCreditsEntry_Director, + &sCreditsEntry_ShigekiMorimoto, _, _, }, [PAGE_ART_DIRECTOR] = { _, - sCreditsEntry_ArtDirector, - sCreditsEntry_KenSugimori, + &sCreditsEntry_ArtDirector, + &sCreditsEntry_KenSugimori, _, _, }, [PAGE_WORLD_DIRECTOR] = { _, - sCreditsEntry_WorldDirector, - sCreditsEntry_JunichiMasuda, + &sCreditsEntry_WorldDirector, + &sCreditsEntry_JunichiMasuda, _, _, }, [PAGE_LEAD_PROGRAMMER] = { - sCreditsEntry_LeadProgrammer, - sCreditsEntry_HisashiSogabe, - sCreditsEntry_LeadGraphicArtist, - sCreditsEntry_MotofumiFujiwara, + &sCreditsEntry_LeadProgrammer, + &sCreditsEntry_HisashiSogabe, + &sCreditsEntry_LeadGraphicArtist, + &sCreditsEntry_MotofumiFujiwara, _, }, [PAGE_PROGRAMMERS_1] = { - sCreditsEntry_Programmers, - sCreditsEntry_HisashiSogabe, - sCreditsEntry_TomomichiOhta, - sCreditsEntry_NozomuSaito, - sCreditsEntry_EmptyString, + &sCreditsEntry_Programmers, + &sCreditsEntry_HisashiSogabe, + &sCreditsEntry_TomomichiOhta, + &sCreditsEntry_NozomuSaito, + _, }, [PAGE_PROGRAMMERS_2] = { - sCreditsEntry_Programmers, - sCreditsEntry_AkitoMori, - sCreditsEntry_HiroyukiNakamura, - sCreditsEntry_MasaoTaya, + &sCreditsEntry_Programmers, + &sCreditsEntry_AkitoMori, + &sCreditsEntry_HiroyukiNakamura, + &sCreditsEntry_MasaoTaya, _, }, [PAGE_PROGRAMMERS_3] = { - sCreditsEntry_Programmers, - sCreditsEntry_SatoshiNohara, - sCreditsEntry_MiyukiIwasawa, - sCreditsEntry_YoshinoriMatsuda, - sCreditsEntry_KeitaKagaya, + &sCreditsEntry_Programmers, + &sCreditsEntry_SatoshiNohara, + &sCreditsEntry_MiyukiIwasawa, + &sCreditsEntry_YoshinoriMatsuda, + &sCreditsEntry_KeitaKagaya, }, [PAGE_PROGRAMMERS_4] = { - sCreditsEntry_Programmers, - sCreditsEntry_TetsuyaWatanabe, - sCreditsEntry_SosukeTamada, - sCreditsEntry_TakenoriOhta, + &sCreditsEntry_Programmers, + &sCreditsEntry_TetsuyaWatanabe, + &sCreditsEntry_SosukeTamada, + &sCreditsEntry_TakenoriOhta, _, }, [PAGE_GRAPHIC_DESIGNERS_1] = { _, - sCreditsEntry_GraphicDesigners, - sCreditsEntry_MotofumiFujiwara, - sCreditsEntry_SatoshiOhta, + &sCreditsEntry_GraphicDesigners, + &sCreditsEntry_MotofumiFujiwara, + &sCreditsEntry_SatoshiOhta, _, }, [PAGE_GRAPHIC_DESIGNERS_2] = { - sCreditsEntry_GraphicDesigners, - sCreditsEntry_KenkichiToyama, - sCreditsEntry_AsukaIwashita, - sCreditsEntry_TakaoUnno, + &sCreditsEntry_GraphicDesigners, + &sCreditsEntry_KenkichiToyama, + &sCreditsEntry_AsukaIwashita, + &sCreditsEntry_TakaoUnno, _, }, [PAGE_GRAPHIC_DESIGNERS_3] = { - sCreditsEntry_GraphicDesigners, - sCreditsEntry_KenSugimori, - sCreditsEntry_HironobuYoshida, - sCreditsEntry_AimiTomita, - sCreditsEntry_KanakoEo, + &sCreditsEntry_GraphicDesigners, + &sCreditsEntry_KenSugimori, + &sCreditsEntry_HironobuYoshida, + &sCreditsEntry_AimiTomita, + &sCreditsEntry_KanakoEo, }, [PAGE_MUSIC_COMPOSITION] = { - sCreditsEntry_MusicComposition, - sCreditsEntry_GoIchinose, - sCreditsEntry_JunichiMasuda, - sCreditsEntry_MorikazuAoki, - sCreditsEntry_HitomiSato, + &sCreditsEntry_MusicComposition, + &sCreditsEntry_GoIchinose, + &sCreditsEntry_JunichiMasuda, + &sCreditsEntry_MorikazuAoki, + &sCreditsEntry_HitomiSato, }, [PAGE_SOUND_EFFECTS] = { _, - sCreditsEntry_SoundEffectsAndPkmnVoices, - sCreditsEntry_GoIchinose, - sCreditsEntry_MorikazuAoki, + &sCreditsEntry_SoundEffectsAndPkmnVoices, + &sCreditsEntry_GoIchinose, + &sCreditsEntry_MorikazuAoki, _, }, [PAGE_GAME_DESIGNERS_1] = { - sCreditsEntry_GameDesigners, - sCreditsEntry_ShigekiMorimoto, - sCreditsEntry_TeruyukiShimoyamada, - sCreditsEntry_TakeshiKawachimaru, - sCreditsEntry_AkihitoTomisawa, + &sCreditsEntry_GameDesigners, + &sCreditsEntry_ShigekiMorimoto, + &sCreditsEntry_TeruyukiShimoyamada, + &sCreditsEntry_TakeshiKawachimaru, + &sCreditsEntry_AkihitoTomisawa, }, [PAGE_GAME_DESIGNERS_2] = { - sCreditsEntry_GameDesigners, - sCreditsEntry_SuguruNakatsui, - sCreditsEntry_TetsujiOhta, - sCreditsEntry_HitomiSato, - sCreditsEntry_KenjiMatsushima, + &sCreditsEntry_GameDesigners, + &sCreditsEntry_SuguruNakatsui, + &sCreditsEntry_TetsujiOhta, + &sCreditsEntry_HitomiSato, + &sCreditsEntry_KenjiMatsushima, }, [PAGE_GAME_DESIGNERS_3] = { - sCreditsEntry_GameDesigners, - sCreditsEntry_JunichiMasuda, - sCreditsEntry_KojiNishino, - sCreditsEntry_ShigeruOhmori, - sCreditsEntry_TadashiTakahashi, + &sCreditsEntry_GameDesigners, + &sCreditsEntry_JunichiMasuda, + &sCreditsEntry_KojiNishino, + &sCreditsEntry_ShigeruOhmori, + &sCreditsEntry_TadashiTakahashi, }, [PAGE_SCENARIO_PLOT] = { - sCreditsEntry_ScenarioPlot, - sCreditsEntry_AkihitoTomisawa, - sCreditsEntry_JunichiMasuda, - sCreditsEntry_KojiNishino, + &sCreditsEntry_ScenarioPlot, + &sCreditsEntry_AkihitoTomisawa, + &sCreditsEntry_JunichiMasuda, + &sCreditsEntry_KojiNishino, _, }, [PAGE_SCENARIO] = { - sCreditsEntry_Scenario, - sCreditsEntry_AkihitoTomisawa, - sCreditsEntry_HitomiSato, - sCreditsEntry_ToshinobuMatsumiya, + &sCreditsEntry_Scenario, + &sCreditsEntry_AkihitoTomisawa, + &sCreditsEntry_HitomiSato, + &sCreditsEntry_ToshinobuMatsumiya, _, }, [PAGE_SCRIPT_DESIGNERS] = { - sCreditsEntry_ScriptDesigners, - sCreditsEntry_TomomichiOhta, - sCreditsEntry_SatoshiNohara, + &sCreditsEntry_ScriptDesigners, + &sCreditsEntry_TomomichiOhta, + &sCreditsEntry_SatoshiNohara, _, _, }, [PAGE_MAP_DESIGNERS] = { - sCreditsEntry_MapDesigners, - sCreditsEntry_SuguruNakatsui, - sCreditsEntry_TeruyukiShimoyamada, - sCreditsEntry_ShigeruOhmori, - sCreditsEntry_TetsujiOhta, + &sCreditsEntry_MapDesigners, + &sCreditsEntry_SuguruNakatsui, + &sCreditsEntry_TeruyukiShimoyamada, + &sCreditsEntry_ShigeruOhmori, + &sCreditsEntry_TetsujiOhta, }, [PAGE_BATTLE_FRONTIER_DATA] = { _, - sCreditsEntry_BattleFrontierData, - sCreditsEntry_TetsujiOhta, + &sCreditsEntry_BattleFrontierData, + &sCreditsEntry_TetsujiOhta, _, _, }, [PAGE_PARAMETRIC_DESIGNERS] = { - sCreditsEntry_ParametricDesigners, - sCreditsEntry_TeruyukiShimoyamada, - sCreditsEntry_ShigekiMorimoto, - sCreditsEntry_TetsujiOhta, - sCreditsEntry_KojiNishino, + &sCreditsEntry_ParametricDesigners, + &sCreditsEntry_TeruyukiShimoyamada, + &sCreditsEntry_ShigekiMorimoto, + &sCreditsEntry_TetsujiOhta, + &sCreditsEntry_KojiNishino, }, [PAGE_POKEDEX_TEXT] = { _, - sCreditsEntry_PokedexText, - sCreditsEntry_KenjiMatsushima, + &sCreditsEntry_PokedexText, + &sCreditsEntry_KenjiMatsushima, _, _, }, [PAGE_ENVIRONMENT_AND_TOOL_PROGRAMS_1] = { - sCreditsEntry_EnvAndToolPgrms, - sCreditsEntry_HisashiSogabe, - sCreditsEntry_SosukeTamada, - sCreditsEntry_HiroyukiNakamura, - sCreditsEntry_AkitoMori, + &sCreditsEntry_EnvAndToolPgrms, + &sCreditsEntry_HisashiSogabe, + &sCreditsEntry_SosukeTamada, + &sCreditsEntry_HiroyukiNakamura, + &sCreditsEntry_AkitoMori, }, [PAGE_PKMN_DESIGNERS_1] = { - sCreditsEntry_PkmnDesigners, - sCreditsEntry_KenSugimori, - sCreditsEntry_MotofumiFujiwara, - sCreditsEntry_ShigekiMorimoto, + &sCreditsEntry_PkmnDesigners, + &sCreditsEntry_KenSugimori, + &sCreditsEntry_MotofumiFujiwara, + &sCreditsEntry_ShigekiMorimoto, _, }, [PAGE_PKMN_DESIGNERS_2] = { - sCreditsEntry_PkmnDesigners, - sCreditsEntry_HironobuYoshida, - sCreditsEntry_SatoshiOhta, - sCreditsEntry_AsukaIwashita, + &sCreditsEntry_PkmnDesigners, + &sCreditsEntry_HironobuYoshida, + &sCreditsEntry_SatoshiOhta, + &sCreditsEntry_AsukaIwashita, _, }, [PAGE_PKMN_DESIGNERS_3] = { - sCreditsEntry_PkmnDesigners, - sCreditsEntry_TakaoUnno, - sCreditsEntry_KanakoEo, - sCreditsEntry_AimiTomita, + &sCreditsEntry_PkmnDesigners, + &sCreditsEntry_TakaoUnno, + &sCreditsEntry_KanakoEo, + &sCreditsEntry_AimiTomita, _, }, [PAGE_PKMN_DESIGNERS_4] = { - sCreditsEntry_PkmnDesigners, - sCreditsEntry_AtsukoNishida, - sCreditsEntry_MuneoSaito, - sCreditsEntry_RenaYoshikawa, - sCreditsEntry_JunOkutani, + &sCreditsEntry_PkmnDesigners, + &sCreditsEntry_AtsukoNishida, + &sCreditsEntry_MuneoSaito, + &sCreditsEntry_RenaYoshikawa, + &sCreditsEntry_JunOkutani, }, [PAGE_SUPPORT_PROGRAMMERS] = { _, - sCreditsEntry_SupportProgrammers, - sCreditsEntry_SatoshiMitsuhara, - sCreditsEntry_DaisukeHoshino, + &sCreditsEntry_SupportProgrammers, + &sCreditsEntry_SatoshiMitsuhara, + &sCreditsEntry_DaisukeHoshino, _, }, [PAGE_NCL_PRODUCT_TESTING] = { _, - sCreditsEntry_NCLProductTesting, - sCreditsEntry_NCLSuperMarioClub, + &sCreditsEntry_NCLProductTesting, + &sCreditsEntry_NCLSuperMarioClub, _, _, }, [PAGE_PACKAGE_AND_MANUAL] = { _, - sCreditsEntry_PackageAndManual, - sCreditsEntry_KenSugimori, + &sCreditsEntry_PackageAndManual, + &sCreditsEntry_KenSugimori, _, _, }, [PAGE_SPECIAL_THANKS_1] = { _, - sCreditsEntry_SpecialThanks, - sCreditsEntry_KenjiTominaga, - sCreditsEntry_HirokiEnomoto, + &sCreditsEntry_SpecialThanks, + &sCreditsEntry_KenjiTominaga, + &sCreditsEntry_HirokiEnomoto, _, }, [PAGE_SPECIAL_THANKS_2] = { - sCreditsEntry_SpecialThanks, - sCreditsEntry_KazuyaSuyama, - sCreditsEntry_KenjiroIto, - sCreditsEntry_MichikoTakizawa, - sCreditsEntry_MakikoTakada, + &sCreditsEntry_SpecialThanks, + &sCreditsEntry_KazuyaSuyama, + &sCreditsEntry_KenjiroIto, + &sCreditsEntry_MichikoTakizawa, + &sCreditsEntry_MakikoTakada, }, [PAGE_SPECIAL_THANKS_3] = { - sCreditsEntry_SpecialThanks, - sCreditsEntry_MikikoOhhashi, - sCreditsEntry_TakanaoKondo, - sCreditsEntry_RuiKawaguchi, + &sCreditsEntry_SpecialThanks, + &sCreditsEntry_MikikoOhhashi, + &sCreditsEntry_TakanaoKondo, + &sCreditsEntry_RuiKawaguchi, _, }, [PAGE_SPECIAL_THANKS_4] = { - sCreditsEntry_SpecialThanks, - sCreditsEntry_TakahiroOhnishi, - sCreditsEntry_NorihideOkamura, - sCreditsEntry_ShunsukeKohori, + &sCreditsEntry_SpecialThanks, + &sCreditsEntry_TakahiroOhnishi, + &sCreditsEntry_NorihideOkamura, + &sCreditsEntry_ShunsukeKohori, _, }, [PAGE_INFORMATION_SUPERVISORS] = { - sCreditsEntry_InfoSupervisors, - sCreditsEntry_KazuyukiTerada, - sCreditsEntry_YuriSakurai, - sCreditsEntry_YumiFunasaka, - sCreditsEntry_NaokoYanase, + &sCreditsEntry_InfoSupervisors, + &sCreditsEntry_KazuyukiTerada, + &sCreditsEntry_YuriSakurai, + &sCreditsEntry_YumiFunasaka, + &sCreditsEntry_NaokoYanase, }, [PAGE_ARTWORK_1] = { _, - sCreditsEntry_Artwork, - sCreditsEntry_SachikoNakamichi, - sCreditsEntry_FujikoNomura, + &sCreditsEntry_Artwork, + &sCreditsEntry_SachikoNakamichi, + &sCreditsEntry_FujikoNomura, _, }, [PAGE_ARTWORK_2] = { _, - sCreditsEntry_Artwork, - sCreditsEntry_HideyukiNakajima, - sCreditsEntry_HidenoriSaeki, + &sCreditsEntry_Artwork, + &sCreditsEntry_HideyukiNakajima, + &sCreditsEntry_HidenoriSaeki, _, }, [PAGE_ARTWORK_3] = { - sCreditsEntry_Artwork, - sCreditsEntry_YokoWatanabe, - sCreditsEntry_SakaeKimura, - sCreditsEntry_ChiakiShinkai, + &sCreditsEntry_Artwork, + &sCreditsEntry_YokoWatanabe, + &sCreditsEntry_SakaeKimura, + &sCreditsEntry_ChiakiShinkai, _, }, [PAGE_COORDINATORS] = { - sCreditsEntry_Coordinators, - sCreditsEntry_KazukiYoshihara, - sCreditsEntry_AkiraKinashi, - sCreditsEntry_RetsujiNomoto, + &sCreditsEntry_Coordinators, + &sCreditsEntry_KazukiYoshihara, + &sCreditsEntry_AkiraKinashi, + &sCreditsEntry_RetsujiNomoto, _, }, [PAGE_ENGLISH_VERSION] = { _, - sCreditsEntry_EnglishVersion, - sCreditsEntry_HiroNakamura, - sCreditsEntry_SethMcMahill, + &sCreditsEntry_EnglishVersion, + &sCreditsEntry_HiroNakamura, + &sCreditsEntry_SethMcMahill, _, }, [PAGE_TRANSLATOR] = { _, - sCreditsEntry_Translator, - sCreditsEntry_NobOgasawara, + &sCreditsEntry_Translator, + &sCreditsEntry_NobOgasawara, _, _, }, [PAGE_TEXT_EDITOR] = { _, - sCreditsEntry_TextEditor, - sCreditsEntry_TeresaLillygren, + &sCreditsEntry_TextEditor, + &sCreditsEntry_TeresaLillygren, _, _, }, [PAGE_NCL_COORDINATOR] = { _, - sCreditsEntry_NCLCoordinator, - sCreditsEntry_KimikoNakamichi, + &sCreditsEntry_NCLCoordinator, + &sCreditsEntry_KimikoNakamichi, _, _, }, [PAGE_PROGRAMMERS_5] = { - sCreditsEntry_Programmers, - sCreditsEntry_TerukiMurakawa, - sCreditsEntry_SouichiYamamoto, - sCreditsEntry_YuichiroIto, - sCreditsEntry_AkiraKinashi, + &sCreditsEntry_Programmers, + &sCreditsEntry_TerukiMurakawa, + &sCreditsEntry_SouichiYamamoto, + &sCreditsEntry_YuichiroIto, + &sCreditsEntry_AkiraKinashi, }, [PAGE_GRAPHIC_DESIGNER] = { _, - sCreditsEntry_GraphicDesigner, - sCreditsEntry_AkiraKinashi, + &sCreditsEntry_GraphicDesigner, + &sCreditsEntry_AkiraKinashi, _, _, }, [PAGE_ENVIRONMENT_AND_TOOL_PROGRAMS_2] = { - sCreditsEntry_EnvAndToolPgrms, - sCreditsEntry_TerukiMurakawa, - sCreditsEntry_SouichiYamamoto, - sCreditsEntry_KimikoNakamichi, + &sCreditsEntry_EnvAndToolPgrms, + &sCreditsEntry_TerukiMurakawa, + &sCreditsEntry_SouichiYamamoto, + &sCreditsEntry_KimikoNakamichi, _, }, [PAGE_NOA_TESTING] = { - sCreditsEntry_NOAProductTesting, - sCreditsEntry_ThomasHertzog, - sCreditsEntry_ErikJohnson, - sCreditsEntry_MikaKurosawa, + &sCreditsEntry_NOAProductTesting, + &sCreditsEntry_ThomasHertzog, + &sCreditsEntry_ErikJohnson, + &sCreditsEntry_MikaKurosawa, _, }, [PAGE_BRAILLE_CODE_CHECK_1] = { - sCreditsEntry_BrailleCodeCheck, - sCreditsEntry_NationalFederationBlind, - sCreditsEntry_PatriciaAMaurer, - sCreditsEntry_JapanBrailleLibrary, - sCreditsEntry_EuropeanBlindUnion, + &sCreditsEntry_BrailleCodeCheck, + &sCreditsEntry_NationalFederationBlind, + &sCreditsEntry_PatriciaAMaurer, + &sCreditsEntry_JapanBrailleLibrary, + &sCreditsEntry_EuropeanBlindUnion, }, [PAGE_BRAILLE_CODE_CHECK_2] = { _, - sCreditsEntry_BrailleCodeCheck, - sCreditsEntry_AustralianBrailleAuthority, - sCreditsEntry_RoyalNewZealandFederationBlind, + &sCreditsEntry_BrailleCodeCheck, + &sCreditsEntry_AustralianBrailleAuthority, + &sCreditsEntry_RoyalNewZealandFederationBlind, _, }, [PAGE_SPECIAL_THANKS_5] = { - sCreditsEntry_SpecialThanks, - sCreditsEntry_HiroyukiUesugi, - sCreditsEntry_MotoyasuTojima, - sCreditsEntry_NicolaPrattBarlow, - sCreditsEntry_ShellieDow, + &sCreditsEntry_SpecialThanks, + &sCreditsEntry_HiroyukiUesugi, + &sCreditsEntry_MotoyasuTojima, + &sCreditsEntry_NicolaPrattBarlow, + &sCreditsEntry_ShellieDow, }, [PAGE_TASK_MANAGERS] = { _, - sCreditsEntry_TaskManagers, - sCreditsEntry_AzusaTajima, - sCreditsEntry_ShusakuEgami, + &sCreditsEntry_TaskManagers, + &sCreditsEntry_AzusaTajima, + &sCreditsEntry_ShusakuEgami, _, }, [PAGE_PRODUCERS] = { - sCreditsEntry_Producers, - sCreditsEntry_HiroyukiJinnai, - sCreditsEntry_HitoshiYamagami, - sCreditsEntry_GakujiNomoto, - sCreditsEntry_HiroakiTsuru, + &sCreditsEntry_Producers, + &sCreditsEntry_HiroyukiJinnai, + &sCreditsEntry_HitoshiYamagami, + &sCreditsEntry_GakujiNomoto, + &sCreditsEntry_HiroakiTsuru, }, [PAGE_EXECUTIVE_DIRECTOR] = { _, - sCreditsEntry_ExecutiveDirector, - sCreditsEntry_SatoshiTajiri, + &sCreditsEntry_ExecutiveDirector, + &sCreditsEntry_SatoshiTajiri, _, _, }, [PAGE_EXECUTIVE_PRODUCERS_1] = { _, - sCreditsEntry_ExecProducers, - sCreditsEntry_SatoruIwata, + &sCreditsEntry_ExecProducers, + &sCreditsEntry_SatoruIwata, _, _, }, [PAGE_EXECUTIVE_PRODUCERS_2] = { _, - sCreditsEntry_ExecProducers, - sCreditsEntry_TsunekazIshihara, + &sCreditsEntry_ExecProducers, + &sCreditsEntry_TsunekazIshihara, _, _, }, diff --git a/src/data/pointillism_points.h b/src/data/pointillism_points.h index 708f5c02e646..9d19d13140e6 100644 --- a/src/data/pointillism_points.h +++ b/src/data/pointillism_points.h @@ -2,7 +2,7 @@ #define GET_POINT_COLOR_TYPE(bits) (((bits) >> 1) & 3) #define GET_POINT_DELTA(bits) (((bits) >> 3) & 7) -#define PT(x, y, delta, colorType, offsetDownLeft) x, y, (delta << 3) | (colorType << 1) | offsetDownLeft +#define PT(x, y, delta, colorType, offsetDownLeft) {x, y, (delta << 3) | (colorType << 1) | offsetDownLeft} static const u8 sPointillismPoints[][3] = { PT( 0, 29, 3, 2, FALSE), diff --git a/src/data/trade.h b/src/data/trade.h index ef7e9231de5e..ba49f4b8743c 100644 --- a/src/data/trade.h +++ b/src/data/trade.h @@ -372,8 +372,8 @@ static const u8 *const sActionTexts[] = static const struct MenuAction sSelectTradeMonActions[] = { - {sText_Summary2, Task_DrawSelectionSummary}, - {sText_Trade2, Task_DrawSelectionTrade} + {sText_Summary2, {Task_DrawSelectionSummary}}, + {sText_Trade2, {Task_DrawSelectionTrade}} }; static const u8 *const sMessages[] = diff --git a/src/daycare.c b/src/daycare.c index 48f642baa47b..d618db78ec2b 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -331,7 +331,7 @@ void GetDaycareCost(void) gSpecialVar_0x8005 = GetDaycareCostForMon(&gSaveBlock1Ptr->daycare, gSpecialVar_0x8004); } -static void Debug_AddDaycareSteps(u16 numSteps) +static void UNUSED Debug_AddDaycareSteps(u16 numSteps) { gSaveBlock1Ptr->daycare.mons[0].steps += numSteps; gSaveBlock1Ptr->daycare.mons[1].steps += numSteps; @@ -364,7 +364,7 @@ static void ClearDaycareMon(struct DaycareMon *daycareMon) ClearDaycareMonMail(&daycareMon->mail); } -static void ClearAllDaycareData(struct DayCare *daycare) +static void UNUSED ClearAllDaycareData(struct DayCare *daycare) { u8 i; @@ -498,8 +498,7 @@ void TriggerPendingDaycareEgg(void) _TriggerPendingDaycareEgg(&gSaveBlock1Ptr->daycare); } -// Unused -static void TriggerPendingDaycareMaleEgg(void) +static void UNUSED TriggerPendingDaycareMaleEgg(void) { _TriggerPendingDaycareMaleEgg(&gSaveBlock1Ptr->daycare); } @@ -986,7 +985,7 @@ u8 GetDaycareState(void) return DAYCARE_NO_MONS; } -static u8 GetDaycarePokemonCount(void) +static u8 UNUSED GetDaycarePokemonCount(void) { u8 ret = CountPokemonInDaycare(&gSaveBlock1Ptr->daycare); if (ret) @@ -1142,7 +1141,7 @@ static u8 *AppendMonGenderSymbol(u8 *name, struct BoxPokemon *boxMon) return AppendGenderSymbol(name, GetBoxMonGender(boxMon)); } -static void GetDaycareLevelMenuText(struct DayCare *daycare, u8 *dest) +static void UNUSED GetDaycareLevelMenuText(struct DayCare *daycare, u8 *dest) { u8 monNames[DAYCARE_MON_COUNT][POKEMON_NAME_BUFFER_SIZE]; u8 i; @@ -1161,7 +1160,7 @@ static void GetDaycareLevelMenuText(struct DayCare *daycare, u8 *dest) StringAppend(dest, gText_Exit4); } -static void GetDaycareLevelMenuLevelText(struct DayCare *daycare, u8 *dest) +static void UNUSED GetDaycareLevelMenuLevelText(struct DayCare *daycare, u8 *dest) { u8 i; u8 level; diff --git a/src/decompress.c b/src/decompress.c index c16c2cdb311c..8452f340ed38 100644 --- a/src/decompress.c +++ b/src/decompress.c @@ -113,7 +113,7 @@ void Unused_LZDecompressWramIndirect(const void **src, void *dest) LZ77UnCompWram(*src, dest); } -static void StitchObjectsOn8x8Canvas(s32 object_size, s32 object_count, u8 *src_tiles, u8 *dest_tiles) +static void UNUSED StitchObjectsOn8x8Canvas(s32 object_size, s32 object_count, u8 *src_tiles, u8 *dest_tiles) { /* This function appears to emulate behaviour found in the GB(C) versions regarding how the Pokemon images diff --git a/src/decoration.c b/src/decoration.c index 688018b2db17..f4fae6cc5e97 100644 --- a/src/decoration.c +++ b/src/decoration.c @@ -113,7 +113,7 @@ EWRAM_DATA static u16 sDecorationsCursorPos = 0; EWRAM_DATA static u16 sDecorationsScrollOffset = 0; EWRAM_DATA u8 gCurDecorationIndex = 0; EWRAM_DATA static u8 sCurDecorationCategory = DECORCAT_DESK; -EWRAM_DATA static u32 sFiller[2] = {}; +EWRAM_DATA static u32 UNUSED sFiller[2] = {}; EWRAM_DATA static struct DecorationPCContext sDecorationContext = {}; EWRAM_DATA static u8 sDecorMenuWindowIds[WINDOW_COUNT] = {}; EWRAM_DATA static struct DecorationItemsMenu *sDecorationItemsMenu = NULL; diff --git a/src/dodrio_berry_picking.c b/src/dodrio_berry_picking.c index 1ba82c6d21a1..1b4500002c71 100644 --- a/src/dodrio_berry_picking.c +++ b/src/dodrio_berry_picking.c @@ -2834,9 +2834,8 @@ static void GetScoreResults(struct DodrioGame_ScoreResults *dst, u8 playerId) *dst = sGame->scoreResults[playerId]; } -// Unused // Returns where the specified player's score ranks, 0 being first (highest score) -static u8 GetScoreRanking(u8 playerId) +static u8 UNUSED GetScoreRanking(u8 playerId) { u8 i, ranking = 0; u8 numPlayers = sGame->numPlayers; @@ -3068,12 +3067,12 @@ static const u8 *const sDebug_PlayerNames[] = sText_Digits }; -static void Debug_UpdateNumPlayers(void) +static void UNUSED Debug_UpdateNumPlayers(void) { sGame->numPlayers = GetLinkPlayerCount(); } -static void Debug_SetPlayerNamesAndResults(void) +static void UNUSED Debug_SetPlayerNamesAndResults(void) { u8 i, playerId; @@ -4253,8 +4252,7 @@ static void SetBerryAnim(u16 id, u8 animNum) StartSpriteAnim(&gSprites[*sBerrySpriteIds[id]], animNum); } -// Unused -static void UnusedSetSpritePos(u8 spriteId) +static void UNUSED UnusedSetSpritePos(u8 spriteId) { gSprites[spriteId].x = 20 * spriteId + 50; gSprites[spriteId].y = 50; @@ -4486,8 +4484,7 @@ static void InitGameGfx(struct DodrioGame_Gfx *ptr) SetGfxFunc(LoadGfx); } -// Unused -static void FreeAllWindowBuffers_(void) +static void UNUSED FreeAllWindowBuffers_(void) { FreeAllWindowBuffers(); } diff --git a/src/easy_chat.c b/src/easy_chat.c index 5c910dced1ae..93fdafd80bc0 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -2758,7 +2758,7 @@ static void GetEasyChatConfirmDeletionText(const u8 **str1, const u8 **str2) *str2 = gText_BeDeletedThatOkay; } -static void GetKeyboardCursorColAndRow(u8 *column, u8 *row) +static void GetKeyboardCursorColAndRow(s8 *column, s8 *row) { *column = sEasyChatScreen->keyboardColumn; *row = sEasyChatScreen->keyboardRow; @@ -2774,7 +2774,7 @@ static u8 GetKeyboardScrollOffset(void) return sEasyChatScreen->keyboardScrollOffset; } -static void GetWordSelectColAndRow(u8 *column, u8 *row) +static void GetWordSelectColAndRow(s8 *column, s8 *row) { *column = sEasyChatScreen->wordSelectColumn; *row = sEasyChatScreen->wordSelectRow; @@ -2790,7 +2790,7 @@ static u8 GetWordSelectLastRow(void) return sEasyChatScreen->wordSelectLastRow; } -static u8 UnusedDummy(void) +static u8 UNUSED UnusedDummy(void) { return FALSE; } @@ -5264,7 +5264,7 @@ u8 *ConvertEasyChatWordsToString(u8 *dest, const u16 *src, u16 columns, u16 rows return dest; } -static u8 *UnusedConvertEasyChatWordsToString(u8 *dest, const u16 *src, u16 columns, u16 rows) +static u8 UNUSED *UnusedConvertEasyChatWordsToString(u8 *dest, const u16 *src, u16 columns, u16 rows) { u16 i, j, k; u16 numColumns; @@ -5503,8 +5503,7 @@ u16 UnlockRandomTrendySaying(void) return EC_EMPTY_WORD; } -// Unused -static u16 GetRandomUnlockedTrendySaying(void) +static u16 UNUSED GetRandomUnlockedTrendySaying(void) { u16 i; u16 n = GetNumTrendySayingsUnlocked(); @@ -5650,8 +5649,7 @@ static u8 GetUnlockedEasyChatGroupId(u8 index) return sWordData->unlockedGroupIds[index]; } -// Unused -static u8 *BufferEasyChatWordGroupName(u8 *dest, u8 groupId, u16 totalChars) +static u8 UNUSED *BufferEasyChatWordGroupName(u8 *dest, u8 groupId, u16 totalChars) { u16 i; u8 *str = StringCopy(dest, sEasyChatGroupNamePointers[groupId]); diff --git a/src/egg_hatch.c b/src/egg_hatch.c index e9d287cf7210..abf1aff841eb 100644 --- a/src/egg_hatch.c +++ b/src/egg_hatch.c @@ -781,7 +781,7 @@ static void SpriteCB_Egg_Shake3(struct Sprite *sprite) { if (++sprite->sTimer > 38) { - u16 species; + u16 UNUSED species; sprite->callback = SpriteCB_Egg_WaitHatch; sprite->sTimer = 0; species = GetMonData(&gPlayerParty[sEggHatchData->eggPartyId], MON_DATA_SPECIES); diff --git a/src/event_object_movement.c b/src/event_object_movement.c index d4b89fbae1dc..411b826a53d9 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -2007,8 +2007,7 @@ static void LoadObjectEventPalette(u16 paletteTag) LoadSpritePaletteIfTagExists(&sObjectEventSpritePalettes[i]); } -// Unused -static void LoadObjectEventPaletteSet(u16 *paletteTags) +static void UNUSED LoadObjectEventPaletteSet(u16 *paletteTags) { u8 i; @@ -2090,8 +2089,7 @@ static void _PatchObjectPalette(u16 tag, u8 slot) PatchObjectPalette(tag, slot); } -// Unused -static void IncrementObjectEventCoords(struct ObjectEvent *objectEvent, s16 x, s16 y) +static void UNUSED IncrementObjectEventCoords(struct ObjectEvent *objectEvent, s16 x, s16 y) { objectEvent->previousCoords.x = objectEvent->currentCoords.x; objectEvent->previousCoords.y = objectEvent->currentCoords.y; @@ -2290,8 +2288,7 @@ void CameraObjectSetFollowedSpriteId(u8 spriteId) } } -// Unused -static u8 CameraObjectGetFollowedSpriteId(void) +static u8 UNUSED CameraObjectGetFollowedSpriteId(void) { struct Sprite *camera; @@ -2388,8 +2385,7 @@ static u16 GetObjectEventFlagIdByObjectEventId(u8 objectEventId) return GetObjectEventFlagIdByLocalIdAndMap(gObjectEvents[objectEventId].localId, gObjectEvents[objectEventId].mapNum, gObjectEvents[objectEventId].mapGroup); } -// Unused -static u8 GetObjectTrainerTypeByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup) +static u8 UNUSED GetObjectTrainerTypeByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup) { u8 objectEventId; @@ -2399,8 +2395,7 @@ static u8 GetObjectTrainerTypeByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup return gObjectEvents[objectEventId].trainerType; } -// Unused -static u8 GetObjectTrainerTypeByObjectEventId(u8 objectEventId) +static u8 UNUSED GetObjectTrainerTypeByObjectEventId(u8 objectEventId) { return gObjectEvents[objectEventId].trainerType; } @@ -4763,8 +4758,7 @@ void MoveCoords(u8 direction, s16 *x, s16 *y) *y += sDirectionToVectors[direction].y; } -// Unused -static void MoveCoordsInMapCoordIncrement(u8 direction, s16 *x, s16 *y) +static void UNUSED MoveCoordsInMapCoordIncrement(u8 direction, s16 *x, s16 *y) { *x += sDirectionToVectors[direction].x << 4; *y += sDirectionToVectors[direction].y << 4; @@ -7908,10 +7902,10 @@ static void DoTracksGroundEffect_BikeTireTracks(struct ObjectEvent *objEvent, st // each byte in that row is for the next direction of the bike in the order // of down, up, left, right. static const u8 bikeTireTracks_Transitions[4][4] = { - 1, 2, 7, 8, - 1, 2, 6, 5, - 5, 8, 3, 4, - 6, 7, 3, 4, + {1, 2, 7, 8}, + {1, 2, 6, 5}, + {5, 8, 3, 4}, + {6, 7, 3, 4}, }; if (objEvent->currentCoords.x != objEvent->previousCoords.x || objEvent->currentCoords.y != objEvent->previousCoords.y) @@ -8580,8 +8574,7 @@ static void SpriteCB_VirtualObject(struct Sprite *sprite) UpdateObjectEventSpriteInvisibility(sprite, sprite->sInvisible); } -// Unused -static void DestroyVirtualObjects(void) +static void UNUSED DestroyVirtualObjects(void) { int i; diff --git a/src/evolution_scene.c b/src/evolution_scene.c index dc198626164c..133afe3b0dd2 100644 --- a/src/evolution_scene.c +++ b/src/evolution_scene.c @@ -1634,8 +1634,7 @@ static void StartBgAnimation(bool8 isLink) CreateBgAnimTask(isLink); } -// Unused -static void PauseBgPaletteAnim(void) +static void UNUSED PauseBgPaletteAnim(void) { u8 taskId = FindTaskIdByFunc(Task_UpdateBgPalette); diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c index 3a0c97e8cf65..09d6ae7838a0 100644 --- a/src/field_control_avatar.c +++ b/src/field_control_avatar.c @@ -606,8 +606,7 @@ static bool8 TryStartStepCountScript(u16 metatileBehavior) return FALSE; } -// Unused -static void ClearFriendshipStepCounter(void) +static void UNUSED ClearFriendshipStepCounter(void) { VarSet(VAR_FRIENDSHIP_STEP_COUNTER, 0); } diff --git a/src/field_door.c b/src/field_door.c index 756d0dabf1d2..255233ec2346 100644 --- a/src/field_door.c +++ b/src/field_door.c @@ -408,7 +408,7 @@ static bool32 AnimateDoorFrame(struct DoorGraphics *gfx, struct DoorAnimFrame *f static void Task_AnimateDoor(u8 taskId) { - u16 *data = gTasks[taskId].data; + u16 *data = (u16*) gTasks[taskId].data; struct DoorAnimFrame *frames = (struct DoorAnimFrame *)(tFramesHi << 16 | tFramesLo); struct DoorGraphics *gfx = (struct DoorGraphics *)(tGfxHi << 16 | tGfxLo); @@ -502,8 +502,8 @@ static s8 GetDoorSoundType(const struct DoorGraphics *gfx, u32 x, u32 y) return gfx->sound; } -// Unused. Debug? Same as FieldAnimateDoorOpen but doesnt return or check if metatile is actually a door -static void Debug_FieldAnimateDoorOpen(u32 x, u32 y) +// Debug? Same as FieldAnimateDoorOpen but doesnt return or check if metatile is actually a door +static void UNUSED Debug_FieldAnimateDoorOpen(u32 x, u32 y) { StartDoorOpenAnimation(sDoorAnimGraphicsTable, x, y); } diff --git a/src/field_effect.c b/src/field_effect.c index 8d6b6342d1fa..86f1ca97d2e0 100644 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -900,8 +900,7 @@ u8 CreateTrainerSprite(u8 trainerSpriteID, s16 x, s16 y, u8 subpriority, u8 *buf return CreateSprite(&spriteTemplate, x, y, subpriority); } -// Unused -static void LoadTrainerGfx_TrainerCard(u8 gender, u16 palOffset, u8 *dest) +static void UNUSED LoadTrainerGfx_TrainerCard(u8 gender, u16 palOffset, u8 *dest) { LZDecompressVram(gTrainerFrontPicTable[gender].data, dest); LoadCompressedPalette(gTrainerFrontPicPaletteTable[gender].data, palOffset, PLTT_SIZE_4BPP); @@ -2610,7 +2609,7 @@ static void FieldMoveShowMonOutdoorsEffect_Init(struct Task *task) { task->data[11] = REG_WININ; task->data[12] = REG_WINOUT; - StoreWordInTwoHalfwords(&task->data[13], (u32)gMain.vblankCallback); + StoreWordInTwoHalfwords((u16*) &task->data[13], (u32)gMain.vblankCallback); task->tWinHoriz = WIN_RANGE(DISPLAY_WIDTH, DISPLAY_WIDTH + 1); task->tWinVert = WIN_RANGE(DISPLAY_HEIGHT / 2, DISPLAY_HEIGHT / 2 + 1); task->tWinIn = WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR; diff --git a/src/field_effect_helpers.c b/src/field_effect_helpers.c index 9421aaf27aca..386c3c76b27b 100755 --- a/src/field_effect_helpers.c +++ b/src/field_effect_helpers.c @@ -1658,7 +1658,7 @@ static void UpdateGrassFieldEffectSubpriority(struct Sprite *sprite, u8 elevatio { u8 i; s16 var, xhi, lyhi, yhi, ylo; - const struct ObjectEventGraphicsInfo *graphicsInfo; // Unused Variable + const struct ObjectEventGraphicsInfo UNUSED *graphicsInfo; struct Sprite *linkedSprite; SetObjectSubpriorityByElevation(elevation, sprite, subpriority); diff --git a/src/field_message_box.c b/src/field_message_box.c index 64734cc2092e..55124e7dfc0d 100755 --- a/src/field_message_box.c +++ b/src/field_message_box.c @@ -97,8 +97,7 @@ bool8 ShowFieldAutoScrollMessage(const u8 *str) return TRUE; } -// Unused -static bool8 ForceShowFieldAutoScrollMessage(const u8 *str) +static bool8 UNUSED ForceShowFieldAutoScrollMessage(const u8 *str) { sFieldMessageBoxMode = FIELD_MESSAGE_BOX_AUTO_SCROLL; ExpandStringAndStartDrawFieldMessage(str, TRUE); @@ -148,8 +147,7 @@ bool8 IsFieldMessageBoxHidden(void) return FALSE; } -// Unused -static void ReplaceFieldMessageWithFrame(void) +static void UNUSED ReplaceFieldMessageWithFrame(void) { DestroyTask_DrawFieldMessage(); DrawStdWindowFrame(0, TRUE); diff --git a/src/field_specials.c b/src/field_specials.c index fc4d23bef1b4..7d20d3571d0c 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -1011,7 +1011,7 @@ static void PCTurnOnEffect(struct Task *task) if (task->tTimer == 6) { task->tTimer = 0; - + // Get where the PC should be, depending on where the player is looking. playerDirection = GetPlayerFacingDirection(); switch (playerDirection) @@ -1033,7 +1033,7 @@ static void PCTurnOnEffect(struct Task *task) // Update map PCTurnOnEffect_SetMetatile(task->tIsScreenOn, dx, dy); DrawWholeMapView(); - + // Screen flickers 5 times. Odd number and starting with the // screen off means the animation ends with the screen on. task->tIsScreenOn ^= 1; diff --git a/src/field_tasks.c b/src/field_tasks.c index 8683301f2651..a9d11b2d70b0 100644 --- a/src/field_tasks.c +++ b/src/field_tasks.c @@ -172,7 +172,7 @@ static void Task_RunTimeBasedEvents(u8 taskId) if (!ArePlayerFieldControlsLocked()) { RunTimeBasedEvents(data); - UpdateAmbientCry(&tAmbientCryState, &tAmbientCryDelay); + UpdateAmbientCry(&tAmbientCryState, (u16*) &tAmbientCryDelay); } } diff --git a/src/field_weather.c b/src/field_weather.c index bcc6a1c44004..5ca907525029 100644 --- a/src/field_weather.c +++ b/src/field_weather.c @@ -855,8 +855,7 @@ void ApplyWeatherColorMapToPal(u8 paletteIndex) ApplyColorMap(paletteIndex, 1, gWeatherPtr->colorMapIndex); } -// Unused -static bool8 IsFirstFrameOfWeatherFadeIn(void) +static bool8 UNUSED IsFirstFrameOfWeatherFadeIn(void) { if (gWeatherPtr->palProcessingState == WEATHER_PAL_STATE_SCREEN_FADING_IN) return gWeatherPtr->fadeInFirstFrame; @@ -997,8 +996,8 @@ bool8 Weather_UpdateBlend(void) return FALSE; } -// Unused. Uses the same numbering scheme as the coord events -static void SetFieldWeather(u8 weather) +// Uses the same numbering scheme as the coord events +static void UNUSED SetFieldWeather(u8 weather) { switch (weather) { diff --git a/src/field_weather_effect.c b/src/field_weather_effect.c index 05eae421e0e0..de0b90c48006 100644 --- a/src/field_weather_effect.c +++ b/src/field_weather_effect.c @@ -2434,8 +2434,7 @@ static void UpdateBubbleSprite(struct Sprite *sprite) //------------------------------------------------------------------------------ -// Unused function. -static void UnusedSetCurrentAbnormalWeather(u32 weather, u32 unknown) +static void UNUSED UnusedSetCurrentAbnormalWeather(u32 weather, u32 unknown) { sCurrentAbnormalWeather = weather; sUnusedWeatherRelated = unknown; diff --git a/src/fieldmap.c b/src/fieldmap.c index 9534255c7879..97b5b7811366 100644 --- a/src/fieldmap.c +++ b/src/fieldmap.c @@ -29,7 +29,7 @@ EWRAM_DATA static u16 ALIGNED(4) sBackupMapData[MAX_MAP_DATA_SIZE] = {0}; EWRAM_DATA struct MapHeader gMapHeader = {0}; EWRAM_DATA struct Camera gCamera = {0}; EWRAM_DATA static struct ConnectionFlags sMapConnectionFlags = {0}; -EWRAM_DATA static u32 sFiller = 0; // without this, the next file won't align properly +EWRAM_DATA static u32 UNUSED sFiller = 0; // without this, the next file won't align properly struct BackupMapLayout gBackupMapLayout; @@ -48,6 +48,7 @@ static const struct MapConnection *GetIncomingConnection(u8 direction, int x, in static bool8 IsPosInIncomingConnectingMap(u8 direction, int x, int y, const struct MapConnection *connection); static bool8 IsCoordInIncomingConnectingMap(int coord, int srcMax, int destMax, int offset); + #define GetBorderBlockAt(x, y)({ \ u16 block; \ int i; \ @@ -799,8 +800,7 @@ void GetCameraFocusCoords(u16 *x, u16 *y) *y = gSaveBlock1Ptr->pos.y + MAP_OFFSET; } -// Unused -static void SetCameraCoords(u16 x, u16 y) +static void UNUSED SetCameraCoords(u16 x, u16 y) { gSaveBlock1Ptr->pos.x = x; gSaveBlock1Ptr->pos.y = y; @@ -866,7 +866,7 @@ static void ApplyGlobalTintToPaletteEntries(u16 offset, u16 size) } -static void ApplyGlobalTintToPaletteSlot(u8 slot, u8 count) +static void UNUSED ApplyGlobalTintToPaletteSlot(u8 slot, u8 count) { } diff --git a/src/fldeff_escalator.c b/src/fldeff_escalator.c index 0dc98c319c2a..eabbd535497b 100644 --- a/src/fldeff_escalator.c +++ b/src/fldeff_escalator.c @@ -14,43 +14,43 @@ static void Task_DrawEscalator(u8 taskId); #define ESCALATOR_STAGES 3 #define LAST_ESCALATOR_STAGE (ESCALATOR_STAGES - 1) -static const u16 sEscalatorMetatiles_1F_0[ESCALATOR_STAGES] = { +static const s16 sEscalatorMetatiles_1F_0[ESCALATOR_STAGES] = { METATILE_PokemonCenter_Escalator1F_Tile0_Frame2, METATILE_PokemonCenter_Escalator1F_Tile0_Frame1, METATILE_PokemonCenter_Escalator1F_Tile0_Frame0 }; -static const u16 sEscalatorMetatiles_1F_1[ESCALATOR_STAGES] = { +static const s16 sEscalatorMetatiles_1F_1[ESCALATOR_STAGES] = { METATILE_PokemonCenter_Escalator1F_Tile1_Frame2, METATILE_PokemonCenter_Escalator1F_Tile1_Frame1, METATILE_PokemonCenter_Escalator1F_Tile1_Frame0 }; -static const u16 sEscalatorMetatiles_1F_2[ESCALATOR_STAGES] = { +static const s16 sEscalatorMetatiles_1F_2[ESCALATOR_STAGES] = { METATILE_PokemonCenter_Escalator1F_Tile2_Frame2, METATILE_PokemonCenter_Escalator1F_Tile2_Frame1, METATILE_PokemonCenter_Escalator1F_Tile2_Frame0 }; -static const u16 sEscalatorMetatiles_1F_3[ESCALATOR_STAGES] = { +static const s16 sEscalatorMetatiles_1F_3[ESCALATOR_STAGES] = { METATILE_PokemonCenter_Escalator1F_Tile3_Frame2, METATILE_PokemonCenter_Escalator1F_Tile3_Frame1, METATILE_PokemonCenter_Escalator1F_Tile3_Frame0 }; -static const u16 sEscalatorMetatiles_2F_0[ESCALATOR_STAGES] = { +static const s16 sEscalatorMetatiles_2F_0[ESCALATOR_STAGES] = { METATILE_PokemonCenter_Escalator2F_Tile0_Frame0, METATILE_PokemonCenter_Escalator2F_Tile0_Frame1, METATILE_PokemonCenter_Escalator2F_Tile0_Frame2 }; -static const u16 sEscalatorMetatiles_2F_1[ESCALATOR_STAGES] = { +static const s16 sEscalatorMetatiles_2F_1[ESCALATOR_STAGES] = { METATILE_PokemonCenter_Escalator2F_Tile1_Frame0, METATILE_PokemonCenter_Escalator2F_Tile1_Frame1, METATILE_PokemonCenter_Escalator2F_Tile1_Frame2 }; -static const u16 sEscalatorMetatiles_2F_2[ESCALATOR_STAGES] = { +static const s16 sEscalatorMetatiles_2F_2[ESCALATOR_STAGES] = { METATILE_PokemonCenter_Escalator2F_Tile2_Frame0, METATILE_PokemonCenter_Escalator2F_Tile2_Frame1, METATILE_PokemonCenter_Escalator2F_Tile2_Frame2 diff --git a/src/graphics.c b/src/graphics.c index 7c327c4451f9..17ea237df28a 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1515,7 +1515,7 @@ const u16 gTitleScreenPressStartPal[] = INCBIN_U16("graphics/title_screen/p const u32 gTitleScreenPressStartGfx[] = INCBIN_U32("graphics/title_screen/press_start.4bpp.lz"); const u32 gTitleScreenPokemonLogoTilemap[] = INCBIN_U32("graphics/title_screen/pokemon_logo.bin.lz"); -const u16 gFrontierPassBg_Pal[][16] = INCBIN_U16("graphics/frontier_pass/bg.gbapal"); +const u16 gFrontierPassBg_Pal[] = INCBIN_U16("graphics/frontier_pass/bg.gbapal"); // 8 x 16 const u32 gFrontierPassBg_Gfx[] = INCBIN_U32("graphics/frontier_pass/bg.4bpp.lz"); const u32 gFrontierPassMapAndCard_Gfx[] = INCBIN_U32("graphics/frontier_pass/map_and_card.8bpp.lz"); const u32 gFrontierPassBg_Tilemap[] = INCBIN_U32("graphics/frontier_pass/bg.bin.lz"); diff --git a/src/intro.c b/src/intro.c index 6a6a58ddd5d4..195374bba0c9 100644 --- a/src/intro.c +++ b/src/intro.c @@ -169,7 +169,7 @@ extern const struct SpriteTemplate gAncientPowerRockSpriteTemplate[]; #define TIMER_START_LEGENDARIES 43 static EWRAM_DATA u16 sIntroCharacterGender = 0; -static EWRAM_DATA u16 sUnusedVar = 0; +static EWRAM_DATA u16 UNUSED sUnusedVar = 0; static EWRAM_DATA u16 sFlygonYOffset = 0; u32 gIntroFrameCounter; @@ -178,7 +178,7 @@ struct GcmbStruct gMultibootProgramStruct; static const u16 sIntroDrops_Pal[] = INCBIN_U16("graphics/intro/scene_1/drops.gbapal"); static const u16 sIntroLogo_Pal[] = INCBIN_U16("graphics/intro/scene_1/logo.gbapal"); static const u32 sIntroDropsLogo_Gfx[] = INCBIN_U32("graphics/intro/scene_1/drops_logo.4bpp.lz"); -static const u16 sIntro1Bg_Pal[16][16] = INCBIN_U16("graphics/intro/scene_1/bg.gbapal"); +static const u16 sIntro1Bg_Pal[] = INCBIN_U16("graphics/intro/scene_1/bg.gbapal"); // 16 x 16 static const u32 sIntro1Bg0_Tilemap[] = INCBIN_U32("graphics/intro/scene_1/bg0_map.bin.lz"); static const u32 sIntro1Bg1_Tilemap[] = INCBIN_U32("graphics/intro/scene_1/bg1_map.bin.lz"); static const u32 sIntro1Bg2_Tilemap[] = INCBIN_U32("graphics/intro/scene_1/bg2_map.bin.lz"); diff --git a/src/intro_credits_graphics.c b/src/intro_credits_graphics.c index 05b5a3a0507a..c4b059fdd78b 100644 --- a/src/intro_credits_graphics.c +++ b/src/intro_credits_graphics.c @@ -1148,7 +1148,7 @@ static void SpriteCB_FlygonRightHalf(struct Sprite *sprite) } // In RS these were for Latios/Latias. In Emerald both are replaced with Flygon and now only 1 is used -static u8 CreateIntroFlygonSprite_Unused(s16 x, s16 y) +static u8 UNUSED CreateIntroFlygonSprite_Unused(s16 x, s16 y) { u8 leftSpriteId = CreateSprite(&sSpriteTemplate_FlygonLatios, x - 32, y, 5); u8 rightSpriteId = CreateSprite(&sSpriteTemplate_FlygonLatios, x + 32, y, 6); diff --git a/src/item_menu.c b/src/item_menu.c index 223f028d020c..f0abfcf62a34 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -109,7 +109,7 @@ struct ListBuffer1 { }; struct ListBuffer2 { - s8 name[MAX_POCKET_ITEMS][ITEM_NAME_LENGTH + 10]; + u8 name[MAX_POCKET_ITEMS][ITEM_NAME_LENGTH + 10]; }; struct TempWallyBag { @@ -138,7 +138,7 @@ static void PrepareTMHMMoveWindow(void); static bool8 IsWallysBag(void); static void Task_WallyTutorialBagMenu(u8); static void Task_BagMenu_HandleInput(u8); -static void GetItemName(s8 *, u16); +static void GetItemName(u8 *, u16); static void PrintItemDescription(int); static void BagMenu_PrintCursorAtPos(u8, u8); static void BagMenu_Print(u8, u8, const u8 *, u8, u8, u8, u8, u8, u8); @@ -265,21 +265,21 @@ static const struct ListMenuTemplate sItemListMenu = }; static const struct MenuAction sItemMenuActions[] = { - [ACTION_USE] = {gMenuText_Use, ItemMenu_UseOutOfBattle}, - [ACTION_TOSS] = {gMenuText_Toss, ItemMenu_Toss}, - [ACTION_REGISTER] = {gMenuText_Register, ItemMenu_Register}, - [ACTION_GIVE] = {gMenuText_Give, ItemMenu_Give}, - [ACTION_CANCEL] = {gText_Cancel2, ItemMenu_Cancel}, - [ACTION_BATTLE_USE] = {gMenuText_Use, ItemMenu_UseInBattle}, - [ACTION_CHECK] = {gMenuText_Check, ItemMenu_UseOutOfBattle}, - [ACTION_WALK] = {gMenuText_Walk, ItemMenu_UseOutOfBattle}, - [ACTION_DESELECT] = {gMenuText_Deselect, ItemMenu_Register}, - [ACTION_CHECK_TAG] = {gMenuText_CheckTag, ItemMenu_CheckTag}, - [ACTION_CONFIRM] = {gMenuText_Confirm, Task_FadeAndCloseBagMenu}, - [ACTION_SHOW] = {gMenuText_Show, ItemMenu_Show}, - [ACTION_GIVE_FAVOR_LADY] = {gMenuText_Give2, ItemMenu_GiveFavorLady}, - [ACTION_CONFIRM_QUIZ_LADY] = {gMenuText_Confirm, ItemMenu_ConfirmQuizLady}, - [ACTION_DUMMY] = {gText_EmptyString2, NULL} + [ACTION_USE] = {gMenuText_Use, {ItemMenu_UseOutOfBattle}}, + [ACTION_TOSS] = {gMenuText_Toss, {ItemMenu_Toss}}, + [ACTION_REGISTER] = {gMenuText_Register, {ItemMenu_Register}}, + [ACTION_GIVE] = {gMenuText_Give, {ItemMenu_Give}}, + [ACTION_CANCEL] = {gText_Cancel2, {ItemMenu_Cancel}}, + [ACTION_BATTLE_USE] = {gMenuText_Use, {ItemMenu_UseInBattle}}, + [ACTION_CHECK] = {gMenuText_Check, {ItemMenu_UseOutOfBattle}}, + [ACTION_WALK] = {gMenuText_Walk, {ItemMenu_UseOutOfBattle}}, + [ACTION_DESELECT] = {gMenuText_Deselect, {ItemMenu_Register}}, + [ACTION_CHECK_TAG] = {gMenuText_CheckTag, {ItemMenu_CheckTag}}, + [ACTION_CONFIRM] = {gMenuText_Confirm, {Task_FadeAndCloseBagMenu}}, + [ACTION_SHOW] = {gMenuText_Show, {ItemMenu_Show}}, + [ACTION_GIVE_FAVOR_LADY] = {gMenuText_Give2, {ItemMenu_GiveFavorLady}}, + [ACTION_CONFIRM_QUIZ_LADY] = {gMenuText_Confirm, {ItemMenu_ConfirmQuizLady}}, + [ACTION_DUMMY] = {gText_EmptyString2, {NULL}} }; // these are all 2D arrays with a width of 2 but are represented as 1D arrays @@ -894,7 +894,7 @@ static void LoadBagItemListBuffers(u8 pocketId) gMultiuseListMenuTemplate.maxShowed = gBagMenu->numShownItems[pocketId]; } -static void GetItemName(s8 *dest, u16 itemId) +static void GetItemName(u8 *dest, u16 itemId) { switch (gBagPosition.pocket) { @@ -2466,8 +2466,7 @@ static void BagMenu_Print(u8 windowId, u8 fontId, const u8 *str, u8 left, u8 top AddTextPrinterParameterized4(windowId, fontId, left, top, letterSpacing, lineSpacing, sFontColorTable[colorIndex], speed, str); } -// Unused -static u8 BagMenu_GetWindowId(u8 windowType) +static u8 UNUSED BagMenu_GetWindowId(u8 windowType) { return gBagMenu->windowIds[windowType]; } diff --git a/src/item_use.c b/src/item_use.c index 9737ca7d87e4..60338e437a0e 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -724,7 +724,7 @@ static void ItemUseOnFieldCB_WailmerPailBerry(u8 taskId) static bool8 TryToWaterSudowoodo(void) { - u16 x, y; + s16 x, y; u8 elevation; u8 objId; GetXYCoordsOneStepInFrontOfPlayer(&x, &y); diff --git a/src/librfu_rfu.c b/src/librfu_rfu.c index da37b8fc112d..20d11352a160 100644 --- a/src/librfu_rfu.c +++ b/src/librfu_rfu.c @@ -1400,7 +1400,11 @@ static u16 rfu_STC_setSendData_org(u8 ni_or_uni, u8 bmSendSlot, u8 subFrameSize, { u8 bm_slot_id, sendSlotFlag; u8 frameSize; +#ifdef UBFIX + u8 *llFrameSize_p = NULL; +#else u8 *llFrameSize_p; +#endif u8 sending; u8 i; u16 imeBak; diff --git a/src/link.c b/src/link.c index c51abc952604..f784a36c679a 100644 --- a/src/link.c +++ b/src/link.c @@ -278,8 +278,7 @@ static void InitLinkTestBG(u8 paletteNum, u8 bgNum, u8 screenBaseBlock, u8 charB SetGpuReg(REG_OFFSET_BG0VOFS + bgNum * 4, 0); } -// Unused -static void LoadLinkTestBgGfx(u8 paletteNum, u8 bgNum, u8 screenBaseBlock, u8 charBaseBlock) +static void UNUSED LoadLinkTestBgGfx(u8 paletteNum, u8 bgNum, u8 screenBaseBlock, u8 charBaseBlock) { LoadPalette(sLinkTestDigitsPal, BG_PLTT_ID(paletteNum), PLTT_SIZE_4BPP); DmaCopy16(3, sLinkTestDigitsGfx, (u16 *)BG_CHAR_ADDR(charBaseBlock), sizeof sLinkTestDigitsGfx); @@ -289,8 +288,7 @@ static void LoadLinkTestBgGfx(u8 paletteNum, u8 bgNum, u8 screenBaseBlock, u8 ch SetGpuReg(sBGControlRegs[bgNum], BGCNT_SCREENBASE(screenBaseBlock) | BGCNT_CHARBASE(charBaseBlock)); } -// Unused -static void LinkTestScreen(void) +static void UNUSED LinkTestScreen(void) { int i; @@ -779,8 +777,7 @@ u32 LinkDummy_Return2(void) return 2; } -// Unused -static bool32 IsFullLinkGroupWithNoRS(void) +static bool32 UNUSED IsFullLinkGroupWithNoRS(void) { if (GetLinkPlayerCount() != MAX_LINK_PLAYERS || AreAnyLinkPlayersUsingVersions(VERSION_RUBY, VERSION_SAPPHIRE) < 0) { @@ -1012,14 +1009,12 @@ void SetBerryBlenderLinkCallback(void) gLinkCallback = LinkCB_BerryBlenderSendHeldKeys; } -// Unused -static u32 GetBerryBlenderKeySendAttempts(void) +static u32 UNUSED GetBerryBlenderKeySendAttempts(void) { return gBerryBlenderKeySendAttempts; } -// Unused -static void SendBerryBlenderNoSpaceForPokeblocks(void) +static void UNUSED SendBerryBlenderNoSpaceForPokeblocks(void) { BuildSendCmd(LINKCMD_BLENDER_NO_PBLOCK_SPACE); } @@ -1165,7 +1160,7 @@ static void LinkTest_PrintHex(u32 num, u8 x, u8 y, u8 length) } } -static void LinkTest_PrintInt(int num, u8 x, u8 y, u8 length) +static void UNUSED LinkTest_PrintInt(int num, u8 x, u8 y, u8 length) { char buff[16]; int negX; @@ -1297,8 +1292,7 @@ u8 GetSavedPlayerCount(void) return gSavedLinkPlayerCount; } -// Unused -static u8 GetSavedMultiplayerId(void) +static u8 UNUSED GetSavedMultiplayerId(void) { return gSavedMultiplayerId; } @@ -1335,13 +1329,13 @@ bool8 DoesLinkPlayerCountMatchSaved(void) void ClearSavedLinkPlayers(void) { - int i; // The CpuSet loop below is incorrectly writing to NULL // instead of sSavedLinkPlayers. // Additionally it's using the wrong array size. #ifdef UBFIX memset(sSavedLinkPlayers, 0, sizeof(sSavedLinkPlayers)); #else + int i; for (i = 0; i < MAX_LINK_PLAYERS; i++) CpuSet(&sSavedLinkPlayers[i], NULL, sizeof(struct LinkPlayer)); #endif @@ -1382,8 +1376,7 @@ bool8 IsLinkMaster(void) return EXTRACT_MASTER(gLinkStatus); } -// Unused -static u8 GetDummy2(void) +static u8 UNUSED GetDummy2(void) { return sDummy2; } diff --git a/src/link_rfu_2.c b/src/link_rfu_2.c index 6c84ffefe008..9979097a49a9 100644 --- a/src/link_rfu_2.c +++ b/src/link_rfu_2.c @@ -699,8 +699,7 @@ void StopUnionRoomLinkManager(void) gRfu.state = RFUSTATE_UR_STOP_MANAGER; } -// Unused -static void ReadySendDataForSlots(u8 slots) +static void UNUSED ReadySendDataForSlots(u8 slots) { u8 i; @@ -2146,7 +2145,7 @@ void RfuSetErrorParams(u32 errorInfo) } } -static void ResetErrorState(void) +static void UNUSED ResetErrorState(void) { gRfu.errorState = RFU_ERROR_STATE_NONE; } @@ -2560,8 +2559,7 @@ static void VBlank_RfuIdle(void) TransferPlttBuffer(); } -// Unused -static void Debug_RfuIdle(void) +static void UNUSED Debug_RfuIdle(void) { s32 i; @@ -2934,7 +2932,7 @@ static void Debug_PrintEmpty(void) Debug_PrintString(sASCII_30Spaces, 0, i); } -static void Debug_PrintStatus(void) +static void UNUSED Debug_PrintStatus(void) { s32 i, j; Debug_PrintNum(GetBlockReceivedStatus(), 28, 19, 2); @@ -2990,7 +2988,7 @@ static void Debug_PrintStatus(void) } } -static u32 GetRfuSendQueueLength(void) +static u32 UNUSED GetRfuSendQueueLength(void) { return gRfu.sendQueue.count; } diff --git a/src/link_rfu_3.c b/src/link_rfu_3.c index 6eee8435c929..8a9c28f1b049 100644 --- a/src/link_rfu_3.c +++ b/src/link_rfu_3.c @@ -342,7 +342,7 @@ void RfuSendQueue_Reset(struct RfuSendQueue *queue) queue->full = FALSE; } -static void RfuUnusedQueue_Reset(struct RfuUnusedQueue *queue) +static void UNUSED RfuUnusedQueue_Reset(struct RfuUnusedQueue *queue) { s32 i; s32 j; @@ -514,7 +514,7 @@ bool8 RfuBackupQueue_Dequeue(struct RfuBackupQueue *queue, u8 *src) return TRUE; } -static void RfuUnusedQueue_Enqueue(struct RfuUnusedQueue *queue, u8 *data) +static void UNUSED RfuUnusedQueue_Enqueue(struct RfuUnusedQueue *queue, u8 *data) { s32 i; @@ -533,7 +533,7 @@ static void RfuUnusedQueue_Enqueue(struct RfuUnusedQueue *queue, u8 *data) } } -static bool8 RfuUnusedQueue_Dequeue(struct RfuUnusedQueue *queue, u8 *dest) +static bool8 UNUSED RfuUnusedQueue_Dequeue(struct RfuUnusedQueue *queue, u8 *dest) { s32 i; @@ -549,11 +549,10 @@ static bool8 RfuUnusedQueue_Dequeue(struct RfuUnusedQueue *queue, u8 *dest) return TRUE; } -// Unused // Populates an array with a sequence of numbers (which numbers depends on the mode) // and sets the final element to the total of the other elements #define SEQ_ARRAY_MAX_SIZE 200 -static void PopulateArrayWithSequence(u8 *arr, u8 mode) +static void UNUSED PopulateArrayWithSequence(u8 *arr, u8 mode) { s32 i; u8 rval; @@ -607,7 +606,7 @@ static void PopulateArrayWithSequence(u8 *arr, u8 mode) // File boundary here maybe? -static void PkmnStrToASCII(u8 *asciiStr, const u8 *pkmnStr) +static void UNUSED PkmnStrToASCII(u8 *asciiStr, const u8 *pkmnStr) { s32 i; @@ -616,7 +615,7 @@ static void PkmnStrToASCII(u8 *asciiStr, const u8 *pkmnStr) asciiStr[i] = 0; } -static void ASCIIToPkmnStr(u8 *pkmnStr, const u8 *asciiStr) +static void UNUSED ASCIIToPkmnStr(u8 *pkmnStr, const u8 *asciiStr) { s32 i; diff --git a/src/m4a_tables.c b/src/m4a_tables.c index 9a4ea32e69e7..12e6893902bf 100644 --- a/src/m4a_tables.c +++ b/src/m4a_tables.c @@ -261,10 +261,9 @@ const struct PokemonCrySong gPokemonCrySongTemplate = 0, // block count 255, // priority 0, // reverb - (struct ToneData *)&voicegroup000, - NULL, - NULL, - 0, + (struct ToneData *)&voicegroup000, // tone + {NULL, NULL}, // part + 0, // gap TUNE, // part 0 C_V, // TUNE value GOTO, diff --git a/src/mail_data.c b/src/mail_data.c index 99cf1f9edd62..ed152faf2ced 100644 --- a/src/mail_data.c +++ b/src/mail_data.c @@ -129,7 +129,7 @@ u8 GiveMailToMon(struct Pokemon *mon, struct Mail *mail) return mailId; } -static bool32 DummyMailFunc(void) +static bool32 UNUSED DummyMailFunc(void) { return FALSE; } diff --git a/src/main.c b/src/main.c index 99d2610bb3ee..5f12a2996e44 100644 --- a/src/main.c +++ b/src/main.c @@ -76,7 +76,9 @@ static EWRAM_DATA u16 sTrainerId = 0; static void UpdateLinkAndCallCallbacks(void); static void InitMainCallbacks(void); static void CallCallbacks(void); +#ifdef BUGFIX static void SeedRngWithRtc(void); +#endif static void ReadKeys(void); void InitIntrHandlers(void); static void WaitForVBlank(void); diff --git a/src/main_menu.c b/src/main_menu.c index ddbcda5fd299..6a6ee9955730 100644 --- a/src/main_menu.c +++ b/src/main_menu.c @@ -454,8 +454,8 @@ static const union AffineAnimCmd *const sSpriteAffineAnimTable_PlayerShrink[] = }; static const struct MenuAction sMenuActions_Gender[] = { - {gText_BirchBoy, NULL}, - {gText_BirchGirl, NULL} + {gText_BirchBoy, {NULL}}, + {gText_BirchGirl, {NULL}} }; static const u8 *const sMalePresetNames[] = { diff --git a/src/map_name_popup.c b/src/map_name_popup.c index 93a282583372..796eb28afac9 100644 --- a/src/map_name_popup.c +++ b/src/map_name_popup.c @@ -198,8 +198,7 @@ static const u8 * const sBattlePyramid_MapHeaderStrings[FRONTIER_STAGES_PER_CHAL sText_Pyramid, }; -// Unused -static bool8 StartMenu_ShowMapNamePopup(void) +static bool8 UNUSED StartMenu_ShowMapNamePopup(void) { HideStartMenu(); ShowMapNamePopup(); diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c index 36b29ed73be0..287419f90143 100644 --- a/src/mauville_old_man.c +++ b/src/mauville_old_man.c @@ -740,8 +740,7 @@ void SanitizeMauvilleOldManForRuby(union OldMan * oldMan) } } -// Unused -static void SetMauvilleOldManLanguage(union OldMan * oldMan, u32 language1, u32 language2, u32 language3) +static void UNUSED SetMauvilleOldManLanguage(union OldMan * oldMan, u32 language1, u32 language2, u32 language3) { s32 i; diff --git a/src/menu.c b/src/menu.c index ad3381de9b3d..dd43e310dc8c 100644 --- a/src/menu.c +++ b/src/menu.c @@ -442,14 +442,12 @@ void Menu_LoadStdPalAt(u16 offset) LoadPalette(gStandardMenuPalette, offset, STD_WINDOW_PALETTE_SIZE); } -// Unused -static const u16 *Menu_GetStdPal(void) +static UNUSED const u16* Menu_GetStdPal(void) { return gStandardMenuPalette; } -// Unused -static u16 Menu_GetStdPalColor(u8 colorNum) +static u16 UNUSED Menu_GetStdPalColor(u8 colorNum) { if (colorNum > 15) colorNum = 0; @@ -510,14 +508,12 @@ void RemoveStartMenuWindow(void) } } -// Unused -static u16 GetDialogFrameBaseTileNum(void) +static u16 UNUSED GetDialogFrameBaseTileNum(void) { return DLG_WINDOW_BASE_TILE_NUM; } -// Unused -static u16 GetStandardFrameBaseTileNum(void) +static u16 UNUSED GetStandardFrameBaseTileNum(void) { return STD_WINDOW_BASE_TILE_NUM; } @@ -567,8 +563,7 @@ void DrawDialogFrameWithCustomTileAndPalette(u8 windowId, bool8 copyToVram, u16 CopyWindowToVram(windowId, COPYWIN_FULL); } -// Never used. -static void DrawDialogFrameWithCustomTile(u8 windowId, bool8 copyToVram, u16 tileNum) +static void UNUSED DrawDialogFrameWithCustomTile(u8 windowId, bool8 copyToVram, u16 tileNum) { sTileNum = tileNum; sPaletteNum = GetWindowAttribute(windowId, WINDOW_PALETTE_NUM); @@ -877,15 +872,13 @@ void HofPCTopBar_PrintPair(const u8 *string, const u8 *string2, bool8 noBg, u8 l } } -// Unused -static void HofPCTopBar_CopyToVram(void) +static void UNUSED HofPCTopBar_CopyToVram(void) { if (sHofPCTopBarWindowId != WINDOW_NONE) CopyWindowToVram(sHofPCTopBarWindowId, COPYWIN_FULL); } -// Unused -static void HofPCTopBar_Clear(void) +static void UNUSED HofPCTopBar_Clear(void) { if (sHofPCTopBarWindowId != WINDOW_NONE) { @@ -936,8 +929,7 @@ u8 InitMenuNormal(u8 windowId, u8 fontId, u8 left, u8 top, u8 cursorHeight, u8 n return InitMenu(windowId, fontId, left, top, cursorHeight, numChoices, initialCursorPos, FALSE); } -// Unused -static u8 InitMenuDefaultCursorHeight(u8 windowId, u8 fontId, u8 left, u8 top, u8 numChoices, u8 initialCursorPos) +static u8 UNUSED InitMenuDefaultCursorHeight(u8 windowId, u8 fontId, u8 left, u8 top, u8 numChoices, u8 initialCursorPos) { u8 cursorHeight = GetMenuCursorDimensionByFont(fontId, 1); return InitMenuNormal(windowId, fontId, left, top, cursorHeight, numChoices, initialCursorPos); @@ -1114,8 +1106,7 @@ void PrintMenuActionTextsAtPos(u8 windowId, u8 fontId, u8 left, u8 top, u8 lineH CopyWindowToVram(windowId, COPYWIN_GFX); } -// Unused -static void PrintMenuActionTextsWithSpacing(u8 windowId, u8 fontId, u8 left, u8 top, u8 lineHeight, u8 itemCount, const struct MenuAction *menuActions, u8 letterSpacing, u8 lineSpacing) +static void UNUSED PrintMenuActionTextsWithSpacing(u8 windowId, u8 fontId, u8 left, u8 top, u8 lineHeight, u8 itemCount, const struct MenuAction *menuActions, u8 letterSpacing, u8 lineSpacing) { u8 i; for (i = 0; i < itemCount; i++) @@ -1123,8 +1114,7 @@ static void PrintMenuActionTextsWithSpacing(u8 windowId, u8 fontId, u8 left, u8 CopyWindowToVram(windowId, COPYWIN_GFX); } -// Unused -static void PrintMenuActionTextsAtTop(u8 windowId, u8 fontId, u8 lineHeight, u8 itemCount, const struct MenuAction *menuActions) +static void UNUSED PrintMenuActionTextsAtTop(u8 windowId, u8 fontId, u8 lineHeight, u8 itemCount, const struct MenuAction *menuActions) { PrintMenuActionTextsAtPos(windowId, fontId, GetFontAttribute(fontId, FONTATTR_MAX_LETTER_WIDTH), 1, lineHeight, itemCount, menuActions); } @@ -1156,8 +1146,7 @@ void PrintMenuActionTexts(u8 windowId, u8 fontId, u8 left, u8 top, u8 letterSpac CopyWindowToVram(windowId, COPYWIN_GFX); } -// Unused -static void PrintMenuActionTextsAtTopById(u8 windowId, u8 fontId, u8 lineHeight, u8 itemCount, const struct MenuAction *menuActions, const u8 *actionIds) +static void UNUSED PrintMenuActionTextsAtTopById(u8 windowId, u8 fontId, u8 lineHeight, u8 itemCount, const struct MenuAction *menuActions, const u8 *actionIds) { PrintMenuActionTexts(windowId, fontId, GetFontAttribute(fontId, FONTATTR_MAX_LETTER_WIDTH), 1, GetFontAttribute(fontId, FONTATTR_LETTER_SPACING), lineHeight, itemCount, menuActions, actionIds); } @@ -1214,7 +1203,7 @@ static void CreateYesNoMenuAtPos(const struct WindowTemplate *window, u8 fontId, InitMenuNormal(sYesNoWindowId, fontId, left, top, GetFontAttribute(fontId, FONTATTR_MAX_LETTER_HEIGHT), 2, initialCursorPos); } -static void CreateYesNoMenuInTopLeft(const struct WindowTemplate *window, u8 fontId, u16 baseTileNum, u8 paletteNum) +static void UNUSED CreateYesNoMenuInTopLeft(const struct WindowTemplate *window, u8 fontId, u16 baseTileNum, u8 paletteNum) { CreateYesNoMenuAtPos(window, fontId, 0, 1, baseTileNum, paletteNum, 0); } @@ -1245,8 +1234,7 @@ static void PrintMenuActionGridText(u8 windowId, u8 fontId, u8 left, u8 top, u8 CopyWindowToVram(windowId, COPYWIN_GFX); } -// Unused -static void PrintMenuActionGridTextAtTop(u8 windowId, u8 fontId, u8 width, u8 height, u8 columns, u8 rows, const struct MenuAction *menuActions) +static void UNUSED PrintMenuActionGridTextAtTop(u8 windowId, u8 fontId, u8 width, u8 height, u8 columns, u8 rows, const struct MenuAction *menuActions) { PrintMenuActionGridText(windowId, fontId, GetFontAttribute(fontId, FONTATTR_MAX_LETTER_WIDTH), 0, width, height, columns, rows, menuActions); } @@ -1282,8 +1270,7 @@ void PrintMenuActionGrid(u8 windowId, u8 fontId, u8 left, u8 top, u8 optionWidth CopyWindowToVram(windowId, COPYWIN_GFX); } -// Unused -static void PrintMenuActionGrid_TopLeft(u8 windowId, u8 fontId, u8 optionWidth, u8 unused, u8 horizontalCount, u8 verticalCount, const struct MenuAction *menuActions, const u8 *actionIds) +static void UNUSED PrintMenuActionGrid_TopLeft(u8 windowId, u8 fontId, u8 optionWidth, u8 unused, u8 horizontalCount, u8 verticalCount, const struct MenuAction *menuActions, const u8 *actionIds) { PrintMenuActionGrid(windowId, fontId, GetFontAttribute(fontId, FONTATTR_MAX_LETTER_WIDTH), 0, optionWidth, horizontalCount, verticalCount, menuActions, actionIds); } @@ -1315,8 +1302,7 @@ static u8 InitMenuGrid(u8 windowId, u8 fontId, u8 left, u8 top, u8 optionWidth, return sMenu.cursorPos; } -// Unused -static u8 InitMenuGridDefaultCursorHeight(u8 windowId, u8 fontId, u8 left, u8 top, u8 width, u8 columns, u8 rows, u8 cursorPos) +static u8 UNUSED InitMenuGridDefaultCursorHeight(u8 windowId, u8 fontId, u8 left, u8 top, u8 width, u8 columns, u8 rows, u8 cursorPos) { u8 cursorHeight = GetMenuCursorDimensionByFont(fontId, 1); u8 numChoices = columns * rows; @@ -1408,8 +1394,7 @@ u8 ChangeGridMenuCursorPosition(s8 deltaX, s8 deltaY) } } -// Unused -static s8 Menu_ProcessGridInput_NoSoundLimit(void) +static s8 UNUSED Menu_ProcessGridInput_NoSoundLimit(void) { if (JOY_NEW(A_BUTTON)) { @@ -1489,8 +1474,7 @@ s8 Menu_ProcessGridInput(void) return MENU_NOTHING_CHOSEN; } -// Unused -static s8 Menu_ProcessGridInputRepeat_NoSoundLimit(void) +static s8 UNUSED Menu_ProcessGridInputRepeat_NoSoundLimit(void) { if (JOY_NEW(A_BUTTON)) { @@ -1529,8 +1513,7 @@ static s8 Menu_ProcessGridInputRepeat_NoSoundLimit(void) return MENU_NOTHING_CHOSEN; } -// Unused -static s8 Menu_ProcessGridInputRepeat(void) +static s8 UNUSED Menu_ProcessGridInputRepeat(void) { u8 oldPos = sMenu.cursorPos; @@ -1674,8 +1657,7 @@ void PrintMenuGridTable(u8 windowId, u8 optionWidth, u8 columns, u8 rows, const CopyWindowToVram(windowId, COPYWIN_GFX); } -// Unused -static void PrintMenuActionGridTextNoSpacing(u8 windowId, u8 optionWidth, u8 columns, u8 rows, const struct MenuAction *menuActions, const u8 *actionIds) +static void UNUSED PrintMenuActionGridTextNoSpacing(u8 windowId, u8 optionWidth, u8 columns, u8 rows, const struct MenuAction *menuActions, const u8 *actionIds) { u8 i; u8 j; @@ -2007,7 +1989,7 @@ void PrintPlayerNameOnWindow(u8 windowId, const u8 *src, u16 x, u16 y) AddTextPrinterParameterized(windowId, 1, gStringVar4, x, y, TEXT_SKIP_DRAW, 0); } -static void UnusedBlitBitmapRect(const struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 srcY, u16 dstX, u16 dstY, u16 width, u16 height) +static void UNUSED UnusedBlitBitmapRect(const struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 srcY, u16 dstX, u16 dstY, u16 width, u16 height) { int loopSrcY, loopDstY, loopSrcX, loopDstX, xEnd, yEnd, multiplierSrcY, multiplierDstY; const u8 *pixelsSrc; @@ -2082,14 +2064,12 @@ static void UnusedBlitBitmapRect(const struct Bitmap *src, struct Bitmap *dst, u } } -// Unused -static void LoadMonIconPalAtOffset(u8 palOffset, u16 speciesId) +static void UNUSED LoadMonIconPalAtOffset(u8 palOffset, u16 speciesId) { LoadPalette(GetValidMonIconPalettePtr(speciesId), palOffset, PLTT_SIZE_4BPP); } -// Unused -static void DrawMonIconAtPos(u8 windowId, u16 speciesId, u32 personality, u16 x, u16 y) +static void UNUSED DrawMonIconAtPos(u8 windowId, u16 speciesId, u32 personality, u16 x, u16 y) { BlitBitmapToWindow(windowId, GetMonIconPtr(speciesId, personality, 1), x, y, 32, 32); } diff --git a/src/menu_specialized.c b/src/menu_specialized.c index 15fdafbeb238..e749f599de76 100644 --- a/src/menu_specialized.c +++ b/src/menu_specialized.c @@ -236,8 +236,7 @@ void MailboxMenu_RemoveWindow(u8 windowIdx) sMailboxWindowIds[windowIdx] = WINDOW_NONE; } -// Unused -static u8 MailboxMenu_GetWindowId(u8 windowIdx) +static u8 UNUSED MailboxMenu_GetWindowId(u8 windowIdx) { return sMailboxWindowIds[windowIdx]; } diff --git a/src/mini_printf.c b/src/mini_printf.c index d96a9379a147..69500157c67c 100644 --- a/src/mini_printf.c +++ b/src/mini_printf.c @@ -97,7 +97,7 @@ static s32 _putsAscii(char *s, s32 len, void *buf) if (!buf) return len; - + b = buf; p0 = b->buffer; @@ -120,7 +120,7 @@ static s32 _putsEncoded(char *s, s32 len, void *buf) if (!buf) return len; - + b = buf; p0 = b->buffer; diff --git a/src/minigame_countdown.c b/src/minigame_countdown.c index b4d3b6558bc7..617922e5aa1d 100644 --- a/src/minigame_countdown.c +++ b/src/minigame_countdown.c @@ -158,8 +158,7 @@ static const TaskFunc sStaticCountdownFuncs[][4] = #define sId data[4] // Never read #define sNumberSpriteId data[5] // Never read -// Unused -static u32 CreateStaticCountdownTask(u8 funcSetId, u8 taskPriority) +static u32 UNUSED CreateStaticCountdownTask(u8 funcSetId, u8 taskPriority) { u8 taskId = CreateTask(Task_StaticCountdown, taskPriority); struct Task *task = &gTasks[taskId]; @@ -170,7 +169,7 @@ static u32 CreateStaticCountdownTask(u8 funcSetId, u8 taskPriority) return taskId; } -static bool32 StartStaticCountdown(void) +static bool32 UNUSED StartStaticCountdown(void) { u8 taskId = FindTaskIdByFunc(Task_StaticCountdown); if (taskId == TASK_NONE) @@ -180,7 +179,7 @@ static bool32 StartStaticCountdown(void) return TRUE; } -static bool32 IsStaticCountdownRunning(void) +static bool32 UNUSED IsStaticCountdownRunning(void) { return FuncIsActiveTask(Task_StaticCountdown); } diff --git a/src/mirage_tower.c b/src/mirage_tower.c index 9b48ee24b72b..b1e2e5003b0f 100644 --- a/src/mirage_tower.c +++ b/src/mirage_tower.c @@ -431,7 +431,7 @@ void DoMirageTowerCeilingCrumble(void) static void WaitCeilingCrumble(u8 taskId) { - u16 *data = gTasks[taskId].data; + u16 *data = (u16*)gTasks[taskId].data; data[1]++; // Either wait 1000 frames, or until all 16 crumble sprites and the one screen-shake task are completed. if (data[1] == 1000 || data[0] == 17) diff --git a/src/mystery_gift_menu.c b/src/mystery_gift_menu.c index c44b7a2620d9..78e4a4571524 100644 --- a/src/mystery_gift_menu.c +++ b/src/mystery_gift_menu.c @@ -597,8 +597,7 @@ static void ShowDownArrow(void) DrawDownArrow(WIN_MSG, DOWN_ARROW_X, DOWN_ARROW_Y, 1, TRUE, &sDownArrowCounterAndYCoordIdx[0], &sDownArrowCounterAndYCoordIdx[1]); } -// Unused -static bool32 HideDownArrowAndWaitButton(u8 * textState) +static bool32 UNUSED HideDownArrowAndWaitButton(u8 * textState) { switch (*textState) { @@ -722,7 +721,7 @@ s8 DoMysteryGiftYesNo(u8 * textState, u16 * windowId, bool8 yesNoBoxPlacement, c // Handle the "Receive/Send/Toss" menu that appears when selecting Wonder Card/News static s32 HandleGiftSelectMenu(u8 * textState, u16 * windowId, bool32 cannotToss, bool32 cannotSend) { - struct WindowTemplate windowTemplate; + struct WindowTemplate UNUSED windowTemplate; s32 input; switch (*textState) diff --git a/src/naming_screen.c b/src/naming_screen.c index 6acb29ffbf84..d8ae7ccd4d91 100644 --- a/src/naming_screen.c +++ b/src/naming_screen.c @@ -2058,23 +2058,23 @@ static bool8 IsWideLetter(u8 character) return FALSE; } -// Debug? Unused, and arguments aren't sensible for non-player screens. -static void Debug_NamingScreenPlayer(void) +// Debug? Arguments aren't sensible for non-player screens. +static void UNUSED Debug_NamingScreenPlayer(void) { DoNamingScreen(NAMING_SCREEN_PLAYER, gSaveBlock2Ptr->playerName, gSaveBlock2Ptr->playerGender, 0, 0, CB2_ReturnToFieldWithOpenMenu); } -static void Debug_NamingScreenBox(void) +static void UNUSED Debug_NamingScreenBox(void) { DoNamingScreen(NAMING_SCREEN_BOX, gSaveBlock2Ptr->playerName, gSaveBlock2Ptr->playerGender, 0, 0, CB2_ReturnToFieldWithOpenMenu); } -static void Debug_NamingScreenCaughtMon(void) +static void UNUSED Debug_NamingScreenCaughtMon(void) { DoNamingScreen(NAMING_SCREEN_CAUGHT_MON, gSaveBlock2Ptr->playerName, gSaveBlock2Ptr->playerGender, 0, 0, CB2_ReturnToFieldWithOpenMenu); } -static void Debug_NamingScreenNickname(void) +static void UNUSED Debug_NamingScreenNickname(void) { DoNamingScreen(NAMING_SCREEN_NICKNAME, gSaveBlock2Ptr->playerName, gSaveBlock2Ptr->playerGender, 0, 0, CB2_ReturnToFieldWithOpenMenu); } diff --git a/src/overworld.c b/src/overworld.c index 3d46fc50056d..e9245ce0a05c 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -134,14 +134,11 @@ static void CreateLinkPlayerSprite(u8, u8); static void GetLinkPlayerCoords(u8, u16 *, u16 *); static u8 GetLinkPlayerFacingDirection(u8); static u8 GetLinkPlayerElevation(u8); -static s32 GetLinkPlayerObjectStepTimer(u8); static u8 GetLinkPlayerIdAt(s16, s16); static void SetPlayerFacingDirection(u8, u8); static void ZeroObjectEvent(struct ObjectEvent *); static void SpawnLinkPlayerObjectEvent(u8, s16, s16, u8); static void InitLinkPlayerObjectEventPos(struct ObjectEvent *, s16, s16); -static void SetLinkPlayerObjectRange(u8, u8); -static void DestroyLinkPlayerObject(u8); static u8 GetSpriteForLinkedPlayer(u8); static void RunTerminateLinkScript(void); static u32 GetLinkSendQueueLength(void); @@ -1004,8 +1001,8 @@ void SetObjectEventLoadFlag(u8 flag) sObjectEventLoadFlag = flag; } -// Unused, sObjectEventLoadFlag is read directly -static u8 GetObjectEventLoadFlag(void) +// sObjectEventLoadFlag is read directly +static u8 UNUSED GetObjectEventLoadFlag(void) { return sObjectEventLoadFlag; } @@ -2165,7 +2162,7 @@ static void InitObjectEventsLink(void) static void InitObjectEventsLocal(void) { - s16 x, y; + u16 x, y; struct InitialPlayerAvatarState *player; gTotalCameraPixelOffsetX = 0; @@ -2661,8 +2658,7 @@ u32 GetCableClubPartnersReady(void) return CABLE_SEAT_WAITING; } -// Unused -static bool32 IsAnyPlayerExitingCableClub(void) +static bool32 UNUSED IsAnyPlayerExitingCableClub(void) { return IsAnyPlayerInLinkState(PLAYER_LINK_STATE_EXITING_ROOM); } @@ -2970,7 +2966,7 @@ static void InitLinkPlayerObjectEventPos(struct ObjectEvent *objEvent, s16 x, s1 ObjectEventUpdateElevation(objEvent); } -static void SetLinkPlayerObjectRange(u8 linkPlayerId, u8 dir) +static void UNUSED SetLinkPlayerObjectRange(u8 linkPlayerId, u8 dir) { if (gLinkPlayerObjectEvents[linkPlayerId].active) { @@ -2980,7 +2976,7 @@ static void SetLinkPlayerObjectRange(u8 linkPlayerId, u8 dir) } } -static void DestroyLinkPlayerObject(u8 linkPlayerId) +static void UNUSED DestroyLinkPlayerObject(u8 linkPlayerId) { struct LinkPlayerObjectEvent *linkPlayerObjEvent = &gLinkPlayerObjectEvents[linkPlayerId]; u8 objEventId = linkPlayerObjEvent->objEventId; @@ -3021,7 +3017,7 @@ static u8 GetLinkPlayerElevation(u8 linkPlayerId) return objEvent->currentElevation; } -static s32 GetLinkPlayerObjectStepTimer(u8 linkPlayerId) +static s32 UNUSED GetLinkPlayerObjectStepTimer(u8 linkPlayerId) { u8 objEventId = gLinkPlayerObjectEvents[linkPlayerId].objEventId; struct ObjectEvent *objEvent = &gObjectEvents[objEventId]; diff --git a/src/palette.c b/src/palette.c index e3606646274b..f19ac07cf630 100644 --- a/src/palette.c +++ b/src/palette.c @@ -201,15 +201,13 @@ bool8 BeginNormalPaletteFade(u32 selectedPalettes, s8 delay, u8 startY, u8 targe } } -// Unused -static bool8 BeginPlttFade(u32 selectedPalettes, u8 delay, u8 startY, u8 targetY, u16 blendColor) +static bool8 UNUSED BeginPlttFade(u32 selectedPalettes, u8 delay, u8 startY, u8 targetY, u16 blendColor) { ReadPlttIntoBuffers(); return BeginNormalPaletteFade(selectedPalettes, delay, startY, targetY, blendColor); } -// Unused -static void PaletteStruct_Run(u8 a1, u32 *unkFlags) +static void UNUSED PaletteStruct_Run(u8 a1, u32 *unkFlags) { u8 i; @@ -382,14 +380,14 @@ void ResetPaletteFadeControl(void) gPaletteFade.deltaY = 2; } -static void PaletteStruct_SetUnusedFlag(u16 id) +static void UNUSED PaletteStruct_SetUnusedFlag(u16 id) { u8 paletteNum = PaletteStruct_GetPalNum(id); if (paletteNum != NUM_PALETTE_STRUCTS) sPaletteStructs[paletteNum].flag = TRUE; } -static void PaletteStruct_ClearUnusedFlag(u16 id) +static void UNUSED PaletteStruct_ClearUnusedFlag(u16 id) { u8 paletteNum = PaletteStruct_GetPalNum(id); if (paletteNum != NUM_PALETTE_STRUCTS) @@ -982,8 +980,7 @@ void BlendPalettesGradually(u32 selectedPalettes, s8 delay, u8 coeff, u8 coeffTa gTasks[taskId].func(taskId); } -// Unused -static bool32 IsBlendPalettesGraduallyTaskActive(u8 id) +static bool32 UNUSED IsBlendPalettesGraduallyTaskActive(u8 id) { int i; @@ -996,8 +993,7 @@ static bool32 IsBlendPalettesGraduallyTaskActive(u8 id) return FALSE; } -// Unused -static void DestroyBlendPalettesGraduallyTask(void) +static void UNUSED DestroyBlendPalettesGraduallyTask(void) { u8 taskId; diff --git a/src/palette_util.c b/src/palette_util.c index 08239c3363bd..d24321d58053 100755 --- a/src/palette_util.c +++ b/src/palette_util.c @@ -39,8 +39,7 @@ u8 RouletteFlash_Add(struct RouletteFlashUtil *flash, u8 id, const struct Roulet return id; } -// Unused -static u8 RouletteFlash_Remove(struct RouletteFlashUtil *flash, u8 id) +static u8 UNUSED RouletteFlash_Remove(struct RouletteFlashUtil *flash, u8 id) { if (id >= ARRAY_COUNT(flash->palettes)) return 0xFF; @@ -470,7 +469,7 @@ void SetTilemapRect(u16 *dest, u16 *src, u8 left, u8 top, u8 width, u8 height) } } -static void FillTilemapRect_Unused(void *dest, u16 value, u8 left, u8 top, u8 width, u8 height) +static void UNUSED FillTilemapRect_Unused(void *dest, u16 value, u8 left, u8 top, u8 width, u8 height) { u8 i, j; u8 x, y; @@ -486,7 +485,7 @@ static void FillTilemapRect_Unused(void *dest, u16 value, u8 left, u8 top, u8 wi } } -static void SetTilemapRect_Unused(void *dest, const u16 *src, u8 left, u8 top, u8 width, u8 height) +static void UNUSED SetTilemapRect_Unused(void *dest, const u16 *src, u8 left, u8 top, u8 width, u8 height) { u8 i, j; u8 x, y; diff --git a/src/party_menu.c b/src/party_menu.c index f72814cbbf46..9b076755c844 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -1937,7 +1937,7 @@ u8 GetMonAilment(struct Pokemon *mon) static void SetPartyMonsAllowedInMinigame(void) { - u16 *ptr; + s16 *ptr; if (gPartyMenu.menuType == PARTY_MENU_TYPE_MINIGAME) { @@ -4154,9 +4154,9 @@ static void PartyMenuStartSpriteAnim(u8 spriteId, u8 animNum) StartSpriteAnim(&gSprites[spriteId], animNum); } -// Unused. Might explain the large blank section in gPartyMenuPokeballSmall_Gfx +// Might explain the large blank section in gPartyMenuPokeballSmall_Gfx // At the very least this is how the unused anim cmds for sSpriteAnimTable_MenuPokeballSmall were meant to be accessed -static void SpriteCB_BounceConfirmCancelButton(u8 spriteId, u8 spriteId2, u8 animNum) +static void UNUSED SpriteCB_BounceConfirmCancelButton(u8 spriteId, u8 spriteId2, u8 animNum) { if (animNum == 0) { @@ -6095,8 +6095,7 @@ static void UpdatePartyToFieldOrder(void) Free(partyBuffer); } -// Unused -static void SwitchAliveMonIntoLeadSlot(void) +static void UNUSED SwitchAliveMonIntoLeadSlot(void) { u8 i; struct Pokemon *mon; @@ -6198,8 +6197,7 @@ void ChooseMonForDaycare(void) InitPartyMenu(PARTY_MENU_TYPE_DAYCARE, PARTY_LAYOUT_SINGLE, PARTY_ACTION_CHOOSE_MON, FALSE, PARTY_MSG_CHOOSE_MON_2, Task_HandleChooseMonInput, BufferMonSelection); } -// Unused -static void ChoosePartyMonByMenuType(u8 menuType) +static void UNUSED ChoosePartyMonByMenuType(u8 menuType) { gFieldCallback2 = CB2_FadeFromPartyMenu; InitPartyMenu(menuType, PARTY_LAYOUT_SINGLE, PARTY_ACTION_CHOOSE_AND_CLOSE, FALSE, PARTY_MSG_CHOOSE_MON, Task_HandleChooseMonInput, CB2_ReturnToField); diff --git a/src/player_pc.c b/src/player_pc.c index f53e08f5323e..7dc2616e7109 100644 --- a/src/player_pc.c +++ b/src/player_pc.c @@ -191,10 +191,10 @@ static const u8 *const sItemStorage_OptionDescriptions[] = static const struct MenuAction sPlayerPCMenuActions[] = { - [MENU_ITEMSTORAGE] = { gText_ItemStorage, PlayerPC_ItemStorage }, - [MENU_MAILBOX] = { gText_Mailbox, PlayerPC_Mailbox }, - [MENU_DECORATION] = { gText_Decoration, PlayerPC_Decoration }, - [MENU_TURNOFF] = { gText_TurnOff, PlayerPC_TurnOff } + [MENU_ITEMSTORAGE] = { gText_ItemStorage, {PlayerPC_ItemStorage} }, + [MENU_MAILBOX] = { gText_Mailbox, {PlayerPC_Mailbox} }, + [MENU_DECORATION] = { gText_Decoration, {PlayerPC_Decoration} }, + [MENU_TURNOFF] = { gText_TurnOff, {PlayerPC_TurnOff} } }; static const u8 sBedroomPC_OptionOrder[] = @@ -216,10 +216,10 @@ static const u8 sPlayerPC_OptionOrder[] = static const struct MenuAction sItemStorage_MenuActions[] = { - [MENU_WITHDRAW] = { gText_WithdrawItem, ItemStorage_Withdraw }, - [MENU_DEPOSIT] = { gText_DepositItem, ItemStorage_Deposit }, - [MENU_TOSS] = { gText_TossItem, ItemStorage_Toss }, - [MENU_EXIT] = { gText_Cancel, ItemStorage_Exit } + [MENU_WITHDRAW] = { gText_WithdrawItem, {ItemStorage_Withdraw} }, + [MENU_DEPOSIT] = { gText_DepositItem, {ItemStorage_Deposit} }, + [MENU_TOSS] = { gText_TossItem, {ItemStorage_Toss} }, + [MENU_EXIT] = { gText_Cancel, {ItemStorage_Exit} } }; static const struct ItemSlot sNewGamePCItems[] = @@ -230,10 +230,10 @@ static const struct ItemSlot sNewGamePCItems[] = const struct MenuAction gMailboxMailOptions[] = { - { gText_Read, Mailbox_DoMailRead }, - { gText_MoveToBag, Mailbox_MoveToBag }, - { gText_Give2, Mailbox_Give }, - { gText_Cancel2, Mailbox_Cancel } + { gText_Read, {Mailbox_DoMailRead} }, + { gText_MoveToBag, {Mailbox_MoveToBag} }, + { gText_Give2, {Mailbox_Give} }, + { gText_Cancel2, {Mailbox_Cancel} } }; static const struct WindowTemplate sWindowTemplates_MainMenus[] = diff --git a/src/pokeball.c b/src/pokeball.c index 22d973381ee2..bdc2b703695b 100644 --- a/src/pokeball.c +++ b/src/pokeball.c @@ -1228,7 +1228,7 @@ static void SpriteCB_TradePokeballEnd(struct Sprite *sprite) #undef sTimer // Unreferenced here and in RS, but used in FRLG, possibly by mistake. -static void DestroySpriteAndFreeResources_Ball(struct Sprite *sprite) +static void UNUSED DestroySpriteAndFreeResources_Ball(struct Sprite *sprite) { DestroySpriteAndFreeResources(sprite); } diff --git a/src/pokeblock.c b/src/pokeblock.c index e490f372c469..e01e821f7e1d 100644 --- a/src/pokeblock.c +++ b/src/pokeblock.c @@ -215,12 +215,12 @@ const u8 *const gPokeblockNames[] = static const struct MenuAction sPokeblockMenuActions[] = { - [PKBL_USE_ON_FIELD] = {gMenuText_Use, PokeblockAction_UseOnField}, - [PKBL_TOSS] = {gMenuText_Toss, PokeblockAction_Toss}, - [PKBL_CANCEL] = {gText_Cancel2, PokeblockAction_Cancel}, - [PKBL_USE_IN_BATTLE] = {gMenuText_Use, PokeblockAction_UseInBattle}, - [PKBL_USE_ON_FEEDER] = {gMenuText_Use, PokeblockAction_UseOnPokeblockFeeder}, - [PKBL_GIVE_TO_LADY] = {gMenuText_Give2, PokeblockAction_GiveToContestLady}, + [PKBL_USE_ON_FIELD] = {gMenuText_Use, {PokeblockAction_UseOnField}}, + [PKBL_TOSS] = {gMenuText_Toss, {PokeblockAction_Toss}}, + [PKBL_CANCEL] = {gText_Cancel2, {PokeblockAction_Cancel}}, + [PKBL_USE_IN_BATTLE] = {gMenuText_Use, {PokeblockAction_UseInBattle}}, + [PKBL_USE_ON_FEEDER] = {gMenuText_Use, {PokeblockAction_UseOnPokeblockFeeder}}, + [PKBL_GIVE_TO_LADY] = {gMenuText_Give2, {PokeblockAction_GiveToContestLady}}, }; static const u8 sActionsOnField[] = {PKBL_USE_ON_FIELD, PKBL_TOSS, PKBL_CANCEL}; diff --git a/src/pokedex.c b/src/pokedex.c index 3f5ab22431f2..bd824aa567c3 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -4480,7 +4480,7 @@ static void PrintInfoSubMenuText(u8 windowId, const u8 *str, u8 left, u8 top) AddTextPrinterParameterized4(windowId, FONT_NORMAL, left, top, 0, 0, color, TEXT_SKIP_DRAW, str); } -static void UnusedPrintNum(u8 windowId, u16 num, u8 left, u8 top) +static void UNUSED UnusedPrintNum(u8 windowId, u16 num, u8 left, u8 top) { u8 str[4]; @@ -4514,7 +4514,7 @@ static u8 PrintCryScreenSpeciesName(u8 windowId, u16 num, u8 left, u8 top) return i; } -static void UnusedPrintMonName(u8 windowId, const u8 *name, u8 left, u8 top) +static void UNUSED UnusedPrintMonName(u8 windowId, const u8 *name, u8 left, u8 top) { u8 str[POKEMON_NAME_LENGTH + 1]; u8 i; @@ -4535,7 +4535,7 @@ static void UnusedPrintMonName(u8 windowId, const u8 *name, u8 left, u8 top) } // Unused in the English version, used to print height/weight in versions which use metric system. -static void PrintDecimalNum(u8 windowId, u16 num, u8 left, u8 top) +static void UNUSED PrintDecimalNum(u8 windowId, u16 num, u8 left, u8 top) { u8 str[6]; bool8 outputted = FALSE; @@ -4606,8 +4606,8 @@ static void DrawFootprint(u8 windowId, u16 dexNum) CopyToWindowPixelBuffer(windowId, footprint4bpp, sizeof(footprint4bpp), 0); } -// Unused Ruby/Sapphire function. -static void RS_DrawFootprint(u16 offset, u16 tileNum) +// Ruby/Sapphire function. +static void UNUSED RS_DrawFootprint(u16 offset, u16 tileNum) { *(u16 *)(VRAM + offset * 0x800 + 0x232) = 0xF000 + tileNum + 0; *(u16 *)(VRAM + offset * 0x800 + 0x234) = 0xF000 + tileNum + 1; diff --git a/src/pokemon.c b/src/pokemon.c index 7bc9f3bee317..ba0f77a2ddf6 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -5755,7 +5755,7 @@ u16 SpeciesToCryId(u16 species) // Same as DrawSpindaSpots but attempts to discern for itself whether or // not it's the front pic. -static void DrawSpindaSpotsUnused(u16 species, u32 personality, u8 *dest) +static void UNUSED DrawSpindaSpotsUnused(u16 species, u32 personality, u8 *dest) { if (species == SPECIES_SPINDA && dest != gMonSpritesGfxPtr->sprites.ptr[B_POSITION_PLAYER_LEFT] @@ -6838,9 +6838,9 @@ void BattleAnimateBackSprite(struct Sprite *sprite, u16 species) } } -// Unused, identical to GetOpposingLinkMultiBattlerId but for the player +// Identical to GetOpposingLinkMultiBattlerId but for the player // "rightSide" from that team's perspective, i.e. B_POSITION_*_RIGHT -static u8 GetOwnOpposingLinkMultiBattlerId(bool8 rightSide) +static u8 UNUSED GetOwnOpposingLinkMultiBattlerId(bool8 rightSide) { s32 i; s32 battlerId = 0; diff --git a/src/pokemon_animation.c b/src/pokemon_animation.c index 6afbd20b7dd8..25c7778f8b15 100644 --- a/src/pokemon_animation.c +++ b/src/pokemon_animation.c @@ -846,13 +846,13 @@ static const u8 sBackAnimNatureModTable[NUM_NATURES] = static const union AffineAnimCmd sMonAffineAnim_0[] = { AFFINEANIMCMD_FRAME(256, 256, 0, 0), - AFFINEANIMCMDTYPE_END + {AFFINEANIMCMDTYPE_END} }; static const union AffineAnimCmd sMonAffineAnim_1[] = { AFFINEANIMCMD_FRAME(-256, 256, 0, 0), - AFFINEANIMCMDTYPE_END + {AFFINEANIMCMDTYPE_END} }; static const union AffineAnimCmd *const sMonAffineAnims[] = diff --git a/src/pokemon_jump.c b/src/pokemon_jump.c index 4461d8ad2ab9..d744ff66505b 100755 --- a/src/pokemon_jump.c +++ b/src/pokemon_jump.c @@ -3968,7 +3968,7 @@ struct UnusedPacket // Data packet that's never sent // No function to read it either -static void SendPacket_Unused(u32 data) +static void UNUSED SendPacket_Unused(u32 data) { struct UnusedPacket packet; packet.id = PACKET_UNUSED; diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index 9db0d77c6cd9..574e6ba51e91 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -1370,8 +1370,7 @@ void DrawTextWindowAndBufferTiles(const u8 *string, void *dst, u8 zero1, u8 zero RemoveWindow(windowId); } -// Unused -static void UnusedDrawTextWindow(const u8 *string, void *dst, u16 offset, u8 bgColor, u8 fgColor, u8 shadowColor) +static void UNUSED UnusedDrawTextWindow(const u8 *string, void *dst, u16 offset, u8 bgColor, u8 fgColor, u8 shadowColor) { u32 tilesSize; u8 windowId; @@ -1486,8 +1485,7 @@ u8 *StringCopyAndFillWithSpaces(u8 *dst, const u8 *src, u16 n) return str; } -// Unused -static void UnusedWriteRectCpu(u16 *dest, u16 dest_left, u16 dest_top, const u16 *src, u16 src_left, u16 src_top, u16 dest_width, u16 dest_height, u16 src_width) +static void UNUSED UnusedWriteRectCpu(u16 *dest, u16 dest_left, u16 dest_top, const u16 *src, u16 src_left, u16 src_top, u16 dest_width, u16 dest_height, u16 src_width) { u16 i; @@ -1502,8 +1500,7 @@ static void UnusedWriteRectCpu(u16 *dest, u16 dest_left, u16 dest_top, const u16 } } -// Unused -static void UnusedWriteRectDma(u16 *dest, u16 dest_left, u16 dest_top, u16 width, u16 height) +static void UNUSED UnusedWriteRectDma(u16 *dest, u16 dest_left, u16 dest_top, u16 width, u16 height) { u16 i; @@ -1697,8 +1694,7 @@ static void CB2_ExitPokeStorage(void) SetMainCallback2(CB2_ReturnToField); } -// Unused -static s16 StorageSystemGetNextMonIndex(struct BoxPokemon *box, s8 startIdx, u8 stopIdx, u8 mode) +static s16 UNUSED StorageSystemGetNextMonIndex(struct BoxPokemon *box, s8 startIdx, u8 stopIdx, u8 mode) { s16 i; s16 direction; @@ -7893,8 +7889,7 @@ static void StartCursorAnim(u8 animNum) StartSpriteAnim(sStorage->cursorSprite, animNum); } -// Unused -static u8 GetMovingMonOriginalBoxId(void) +static u8 UNUSED GetMovingMonOriginalBoxId(void) { return sMovingMonOrigBoxId; } @@ -9392,14 +9387,14 @@ static void SpriteCB_ItemIcon_HideParty(struct Sprite *sprite) //------------------------------------------------------------------------------ -// Unused, leftover from FRLG -static void BackupPokemonStorage(void/*struct PokemonStorage * dest*/) +// Leftover from FRLG +static void UNUSED BackupPokemonStorage(void/*struct PokemonStorage * dest*/) { //*dest = *gPokemonStoragePtr; } -// Unused, leftover from FRLG -static void RestorePokemonStorage(void/*struct PokemonStorage * src*/) +// Leftover from FRLG +static void UNUSED RestorePokemonStorage(void/*struct PokemonStorage * src*/) { //*gPokemonStoragePtr = *src; } @@ -9791,8 +9786,7 @@ static void TilemapUtil_Free(void) Free(sTilemapUtil); } -// Unused -static void TilemapUtil_UpdateAll(void) +static void UNUSED TilemapUtil_UpdateAll(void) { s32 i; @@ -9856,8 +9850,7 @@ static void TilemapUtil_SetMap(u8 id, u8 bg, const void *tilemap, u16 width, u16 sTilemapUtil[id].active = TRUE; } -// Unused -static void TilemapUtil_SetSavedMap(u8 id, const void *tilemap) +static void UNUSED TilemapUtil_SetSavedMap(u8 id, const void *tilemap) { if (id >= sNumTilemapUtilIds) return; @@ -10007,8 +10000,7 @@ static void UnkUtil_Run(void) } } -// Unused -static bool8 UnkUtil_CpuAdd(u8 *dest, u16 dLeft, u16 dTop, const u8 *src, u16 sLeft, u16 sTop, u16 width, u16 height, u16 unkArg) +static bool8 UNUSED UnkUtil_CpuAdd(u8 *dest, u16 dLeft, u16 dTop, const u8 *src, u16 sLeft, u16 sTop, u16 width, u16 height, u16 unkArg) { struct UnkUtilData *data; @@ -10038,8 +10030,7 @@ static void UnkUtil_CpuRun(struct UnkUtilData *data) } } -// Unused -static bool8 UnkUtil_DmaAdd(void *dest, u16 dLeft, u16 dTop, u16 width, u16 height) +static bool8 UNUSED UnkUtil_DmaAdd(void *dest, u16 dLeft, u16 dTop, u16 width, u16 height) { struct UnkUtilData *data; diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index 7b306016cebe..454541112492 100644 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -702,8 +702,10 @@ static const u8 sTextColors[][3] = {0, 7, 8} }; -static const u8 sAButton_Gfx[] = INCBIN_U8("graphics/summary_screen/a_button.4bpp"); -static const u8 sBButton_Gfx[] = INCBIN_U8("graphics/summary_screen/b_button.4bpp"); +static const u8 sButtons_Gfx[][4 * TILE_SIZE_4BPP] = { + INCBIN_U8("graphics/summary_screen/a_button.4bpp"), + INCBIN_U8("graphics/summary_screen/b_button.4bpp"), +}; static void (*const sTextPrinterFunctions[])(void) = { @@ -2790,8 +2792,13 @@ static void PrintGenderSymbol(struct Pokemon *mon, u16 species) static void PrintAOrBButtonIcon(u8 windowId, bool8 bButton, u32 x) { - // sBButton_Gfx - sizeof(sBButton_Gfx) = sAButton_Gfx - BlitBitmapToWindow(windowId, (bButton) ? sBButton_Gfx : sBButton_Gfx - sizeof(sBButton_Gfx), x, 0, 16, 16); + const u8 *button; + if (!bButton) + button = sButtons_Gfx[0]; + else + button = sButtons_Gfx[1]; + + BlitBitmapToWindow(windowId, button, x, 0, 16, 16); } static void PrintPageNamesAndStats(void) @@ -3984,8 +3991,7 @@ static void SummaryScreen_DestroyAnimDelayTask(void) } } -// unused -static bool32 IsMonAnimationFinished(void) +static bool32 UNUSED IsMonAnimationFinished(void) { if (gSprites[sMonSummaryScreen->spriteIds[SPRITE_ARR_ID_MON]].callback == SpriteCallbackDummy) return FALSE; diff --git a/src/pokenav_conditions_gfx.c b/src/pokenav_conditions_gfx.c index 9f4b2db61254..26d8e99e0686 100644 --- a/src/pokenav_conditions_gfx.c +++ b/src/pokenav_conditions_gfx.c @@ -548,7 +548,7 @@ static u32 LoopedTask_CloseMonMarkingsWindow(s32 state) return LT_FINISH; } -static u8 *UnusedPrintNumberString(u8 *dst, u16 num) +static u8 UNUSED *UnusedPrintNumberString(u8 *dst, u16 num) { u8 *txtPtr = ConvertIntToDecimalStringN(dst, num, STR_CONV_MODE_RIGHT_ALIGN, 4); txtPtr = StringCopy(txtPtr, gText_Number2); diff --git a/src/pokenav_match_call_list.c b/src/pokenav_match_call_list.c index b00c76b48af9..8d1a73f55718 100755 --- a/src/pokenav_match_call_list.c +++ b/src/pokenav_match_call_list.c @@ -278,22 +278,19 @@ int GetNumberRegistered(void) return state->numRegistered; } -// Unused -static int GetNumSpecialTrainers(void) +static int UNUSED GetNumSpecialTrainers(void) { struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); return state->numSpecialTrainers; } -// Unused -static int GetNumNormalTrainers(void) +static int UNUSED GetNumNormalTrainers(void) { struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); return state->numRegistered - state->numSpecialTrainers; } -// Unused -static int GetNormalTrainerHeaderId(int index) +static int UNUSED GetNormalTrainerHeaderId(int index) { struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); index += state->numSpecialTrainers; @@ -468,8 +465,7 @@ int GetIndexDeltaOfNextCheckPageUp(int index) return 0; } -// Unused -static bool32 HasRematchEntry(void) +static bool32 UNUSED HasRematchEntry(void) { int i; diff --git a/src/pokenav_ribbons_list.c b/src/pokenav_ribbons_list.c index 344b44f00914..05eded624045 100644 --- a/src/pokenav_ribbons_list.c +++ b/src/pokenav_ribbons_list.c @@ -227,8 +227,7 @@ static s32 GetRibbonsMonListCount(void) return list->monList->listCount; } -//unused -static s32 GetMonRibbonSelectedMonData(void) +static s32 UNUSED GetMonRibbonSelectedMonData(void) { struct Pokenav_RibbonsMonList * list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); s32 idx = PokenavList_GetSelectedIndex(); @@ -343,8 +342,7 @@ static void InsertMonListItem(struct Pokenav_RibbonsMonList *list, struct Pokena list->monList->listCount++; } -// Unused -static bool32 PlayerHasRibbonsMon(void) +static bool32 UNUSED PlayerHasRibbonsMon(void) { s32 i, j; diff --git a/src/rayquaza_scene.c b/src/rayquaza_scene.c index cacadf5280bb..3264b22bdf08 100644 --- a/src/rayquaza_scene.c +++ b/src/rayquaza_scene.c @@ -1638,7 +1638,7 @@ static void Task_DuoFightAnim(u8 taskId) static void Task_DuoFight_AnimateClouds(u8 taskId) { s16 i; - u16 *data = gTasks[taskId].data; + u16 *data = (u16*)gTasks[taskId].data; for (i = 24; i < 92; i++) { diff --git a/src/recorded_battle.c b/src/recorded_battle.c index 33228255d21e..42866c723b73 100644 --- a/src/recorded_battle.c +++ b/src/recorded_battle.c @@ -222,8 +222,7 @@ u8 RecordedBattle_GetBattlerAction(u8 battlerId) } } -// Unused -static u8 GetRecordedBattleMode(void) +static u8 UNUSED GetRecordedBattleMode(void) { return sRecordMode; } diff --git a/src/region_map.c b/src/region_map.c index 7d5fe93654f6..21c6314d30a2 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -1434,14 +1434,12 @@ static void FreeRegionMapCursorSprite(void) } } -// Unused -static void SetUnkCursorSpriteData(void) +static void UNUSED SetUnkCursorSpriteData(void) { sRegionMap->cursorSprite->data[3] = TRUE; } -// Unused -static void ClearUnkCursorSpriteData(void) +static void UNUSED ClearUnkCursorSpriteData(void) { sRegionMap->cursorSprite->data[3] = FALSE; } diff --git a/src/roulette.c b/src/roulette.c index d311ad094081..44dac2db6caf 100644 --- a/src/roulette.c +++ b/src/roulette.c @@ -3556,8 +3556,7 @@ static void CreateGridSprites(void) } } -// Unused -static void DestroyGridSprites(void) +static void UNUSED DestroyGridSprites(void) { u8 i; for (i = 0; i < NUM_ROULETTE_SLOTS; i++) @@ -4353,7 +4352,7 @@ static void CreateShroomishSprite(struct Sprite *ball) {116, 44}, {116, 112} }; - struct Roulette *roulette; + struct Roulette UNUSED *roulette; t = ball->data[7] - 2; roulette = sRoulette; // Unnecessary, needed to match diff --git a/src/scrcmd.c b/src/scrcmd.c index bf4ec38f448b..147a11b86962 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -76,12 +76,12 @@ void * const gNullScriptPtr = NULL; static const u8 sScriptConditionTable[6][3] = { // < = > - 1, 0, 0, // < - 0, 1, 0, // = - 0, 0, 1, // > - 1, 1, 0, // <= - 0, 1, 1, // >= - 1, 0, 1, // != + {1, 0, 0}, // < + {0, 1, 0}, // = + {0, 0, 1}, // > + {1, 1, 0}, // <= + {0, 1, 1}, // >= + {1, 0, 1}, // != }; static u8 * const sScriptStringVars[] = diff --git a/src/script_menu.c b/src/script_menu.c index 6633332f3fbc..e923f4031ac6 100644 --- a/src/script_menu.c +++ b/src/script_menu.c @@ -64,8 +64,7 @@ bool8 ScriptMenu_MultichoiceWithDefault(u8 left, u8 top, u8 multichoiceId, bool8 } } -// Unused -static u16 GetLengthWithExpandedPlayerName(const u8 *str) +static u16 UNUSED GetLengthWithExpandedPlayerName(const u8 *str) { u16 length = 0; diff --git a/src/slot_machine.c b/src/slot_machine.c index 20386a2528b5..5ae0f9f1d522 100644 --- a/src/slot_machine.c +++ b/src/slot_machine.c @@ -5813,8 +5813,8 @@ static const struct SpriteFrameImage sImageTable_ReelTimeNumbers[] = { gSlotMachineReelTimeNumber5, 0x80 }, }; -static const struct SpriteFrameImage sImageTable_ReelTimeShadow[] = { gSlotMachineReelTimeShadow, 0x200 }; -static const struct SpriteFrameImage sImageTable_ReelTimeNumberGap[] = { gSlotMachineReelTimeNumberGap_Gfx, 0x40 }; +static const struct SpriteFrameImage sImageTable_ReelTimeShadow[] = { {gSlotMachineReelTimeShadow, 0x200} }; +static const struct SpriteFrameImage sImageTable_ReelTimeNumberGap[] = { {gSlotMachineReelTimeNumberGap_Gfx, 0x40} }; static const struct SpriteFrameImage sImageTable_ReelTimeBolt[] = { @@ -5822,7 +5822,7 @@ static const struct SpriteFrameImage sImageTable_ReelTimeBolt[] = { gSlotMachineReelTimeBolt1, 0x100 }, }; -static const struct SpriteFrameImage sImageTable_ReelTimePikachuAura[] = { gSlotMachineReelTimePikaAura, 0x400 }; +static const struct SpriteFrameImage sImageTable_ReelTimePikachuAura[] = { {gSlotMachineReelTimePikaAura, 0x400} }; static const struct SpriteFrameImage sImageTable_ReelTimeExplosion[] = { @@ -5830,9 +5830,9 @@ static const struct SpriteFrameImage sImageTable_ReelTimeExplosion[] = { gSlotMachineReelTimeExplosion1, 0x200 }, }; -static const struct SpriteFrameImage sImageTable_ReelTimeDuck[] = { gSlotMachineReelTimeDuck, 0x20}; -static const struct SpriteFrameImage sImageTable_ReelTimeSmoke[] = { gSlotMachineReelTimeSmoke, 0x80}; -static const struct SpriteFrameImage sImageTable_PikaPowerBolt[] = { gSlotMachinePikaPowerBolt, 0x20}; +static const struct SpriteFrameImage sImageTable_ReelTimeDuck[] = { {gSlotMachineReelTimeDuck, 0x20} }; +static const struct SpriteFrameImage sImageTable_ReelTimeSmoke[] = { {gSlotMachineReelTimeSmoke, 0x80} }; +static const struct SpriteFrameImage sImageTable_PikaPowerBolt[] = { {gSlotMachinePikaPowerBolt, 0x20} }; static const union AnimCmd sAnim_SingleFrame[] = { @@ -6485,7 +6485,7 @@ static const struct Subsprite sSubsprites_ReelBackground[] = static const struct SubspriteTable sSubspriteTable_ReelBackground[] = { - ARRAY_COUNT(sSubsprites_ReelBackground), sSubsprites_ReelBackground + {ARRAY_COUNT(sSubsprites_ReelBackground), sSubsprites_ReelBackground} }; /* v-- Origin on 3 @@ -6547,7 +6547,7 @@ static const struct Subsprite sSubsprites_ReelTimeMachineAntennae[] = static const struct SubspriteTable sSubspriteTable_ReelTimeMachineAntennae[] = { - ARRAY_COUNT(sSubsprites_ReelTimeMachineAntennae), sSubsprites_ReelTimeMachineAntennae + {ARRAY_COUNT(sSubsprites_ReelTimeMachineAntennae), sSubsprites_ReelTimeMachineAntennae} }; /* @@ -6587,7 +6587,7 @@ static const struct Subsprite sSubsprites_ReelTimeMachine[] = static const struct SubspriteTable sSubspriteTable_ReelTimeMachine[] = { - ARRAY_COUNT(sSubsprites_ReelTimeMachine), sSubsprites_ReelTimeMachine + {ARRAY_COUNT(sSubsprites_ReelTimeMachine), sSubsprites_ReelTimeMachine} }; /* @@ -6644,7 +6644,7 @@ static const struct Subsprite sSubsprites_BrokenReelTimeMachine[] = static const struct SubspriteTable sSubspriteTable_BrokenReelTimeMachine[] = { - ARRAY_COUNT(sSubsprites_BrokenReelTimeMachine), sSubsprites_BrokenReelTimeMachine + {ARRAY_COUNT(sSubsprites_BrokenReelTimeMachine), sSubsprites_BrokenReelTimeMachine} }; /* v-- Origin on 3 @@ -6689,7 +6689,7 @@ static const struct Subsprite sSubsprites_ReelTimeShadow[] = static const struct SubspriteTable sSubspriteTable_ReelTimeShadow[] = { - ARRAY_COUNT(sSubsprites_ReelTimeShadow), sSubsprites_ReelTimeShadow + {ARRAY_COUNT(sSubsprites_ReelTimeShadow), sSubsprites_ReelTimeShadow} }; /* @@ -6727,7 +6727,7 @@ static const struct Subsprite sSubsprites_ReelTimeNumberGap[] = static const struct SubspriteTable sSubspriteTable_ReelTimeNumberGap[] = { - ARRAY_COUNT(sSubsprites_ReelTimeNumberGap), sSubsprites_ReelTimeNumberGap + {ARRAY_COUNT(sSubsprites_ReelTimeNumberGap), sSubsprites_ReelTimeNumberGap} }; /* @@ -6784,7 +6784,7 @@ static const struct Subsprite sSubsprites_DigitalDisplay_Reel[] = static const struct SubspriteTable sSubspriteTable_DigitalDisplay_Reel[] = { - ARRAY_COUNT(sSubsprites_DigitalDisplay_Reel), sSubsprites_DigitalDisplay_Reel + {ARRAY_COUNT(sSubsprites_DigitalDisplay_Reel), sSubsprites_DigitalDisplay_Reel} }; /* v-- Origin on 3 @@ -6829,7 +6829,7 @@ static const struct Subsprite sSubsprites_DigitalDisplay_Time[] = static const struct SubspriteTable sSubspriteTable_DigitalDisplay_Time[] = { - ARRAY_COUNT(sSubsprites_DigitalDisplay_Time), sSubsprites_DigitalDisplay_Time + {ARRAY_COUNT(sSubsprites_DigitalDisplay_Time), sSubsprites_DigitalDisplay_Time} }; /* v-- Origin on 3 @@ -6874,7 +6874,7 @@ static const struct Subsprite sSubsprites_DigitalDisplay_Insert[] = static const struct SubspriteTable sSubspriteTable_DigitalDisplay_Insert[] = { - ARRAY_COUNT(sSubsprites_DigitalDisplay_Insert), sSubsprites_DigitalDisplay_Insert + {ARRAY_COUNT(sSubsprites_DigitalDisplay_Insert), sSubsprites_DigitalDisplay_Insert} }; /* v-- Origin on 3 @@ -6919,7 +6919,7 @@ static const struct Subsprite sSubsprites_DigitalDisplay_Unused1[] = static const struct SubspriteTable sSubspriteTable_DigitalDisplay_Unused1[] = { - ARRAY_COUNT(sSubsprites_DigitalDisplay_Unused1), sSubsprites_DigitalDisplay_Unused1 + {ARRAY_COUNT(sSubsprites_DigitalDisplay_Unused1), sSubsprites_DigitalDisplay_Unused1} }; /* v-- Origin on 3 @@ -6981,7 +6981,7 @@ static const struct Subsprite sSubsprites_DigitalDisplay_Win[] = static const struct SubspriteTable sSubspriteTable_DigitalDisplay_Win[] = { - ARRAY_COUNT(sSubsprites_DigitalDisplay_Win), sSubsprites_DigitalDisplay_Win + {ARRAY_COUNT(sSubsprites_DigitalDisplay_Win), sSubsprites_DigitalDisplay_Win} }; static const struct Subsprite sSubsprites_DigitalDisplay_Smoke[] = @@ -7010,12 +7010,12 @@ static const struct Subsprite sSubsprites_DigitalDisplay_Unused2[] = static const struct SubspriteTable sSubspriteTable_DigitalDisplay_Smoke[] = { - ARRAY_COUNT(sSubsprites_DigitalDisplay_Smoke), sSubsprites_DigitalDisplay_Smoke + {ARRAY_COUNT(sSubsprites_DigitalDisplay_Smoke), sSubsprites_DigitalDisplay_Smoke} }; static const struct SubspriteTable sSubspriteTable_DigitalDisplay_Unused2[] = { - ARRAY_COUNT(sSubsprites_DigitalDisplay_Unused2), sSubsprites_DigitalDisplay_Unused2 + {ARRAY_COUNT(sSubsprites_DigitalDisplay_Unused2), sSubsprites_DigitalDisplay_Unused2} }; /* @@ -7128,7 +7128,7 @@ static const struct Subsprite sSubsprites_DigitalDisplay_Pokeball[] = static const struct SubspriteTable sSubspriteTable_DigitalDisplay_Pokeball[] = { - ARRAY_COUNT(sSubsprites_DigitalDisplay_Pokeball), sSubsprites_DigitalDisplay_Pokeball + {ARRAY_COUNT(sSubsprites_DigitalDisplay_Pokeball), sSubsprites_DigitalDisplay_Pokeball} }; /* @@ -7166,7 +7166,7 @@ static const struct Subsprite sSubsprites_DigitalDisplay_DPad[] = static const struct SubspriteTable sSubspriteTable_DigitalDisplay_DPad[] = { - ARRAY_COUNT(sSubsprites_DigitalDisplay_DPad), sSubsprites_DigitalDisplay_DPad + {ARRAY_COUNT(sSubsprites_DigitalDisplay_DPad), sSubsprites_DigitalDisplay_DPad} }; /* @@ -7195,7 +7195,7 @@ static const struct Subsprite sSubsprites_DigitalDisplay_StopS[] = static const struct SubspriteTable sSubspriteTable_DigitalDisplay_StopS[] = { - ARRAY_COUNT(sSubsprites_DigitalDisplay_StopS), sSubsprites_DigitalDisplay_StopS + {ARRAY_COUNT(sSubsprites_DigitalDisplay_StopS), sSubsprites_DigitalDisplay_StopS} }; /* @@ -7224,7 +7224,7 @@ static const struct Subsprite sSubsprites_DigitalDisplay_StopT[] = static const struct SubspriteTable sSubspriteTable_DigitalDisplay_StopT[] = { - ARRAY_COUNT(sSubsprites_DigitalDisplay_StopT), sSubsprites_DigitalDisplay_StopT + {ARRAY_COUNT(sSubsprites_DigitalDisplay_StopT), sSubsprites_DigitalDisplay_StopT} }; /* @@ -7253,7 +7253,7 @@ static const struct Subsprite sSubsprites_DigitalDisplay_StopO[] = static const struct SubspriteTable sSubspriteTable_DigitalDisplay_StopO[] = { - ARRAY_COUNT(sSubsprites_DigitalDisplay_StopO), sSubsprites_DigitalDisplay_StopO + {ARRAY_COUNT(sSubsprites_DigitalDisplay_StopO), sSubsprites_DigitalDisplay_StopO} }; /* @@ -7282,7 +7282,7 @@ static const struct Subsprite sSubsprites_DigitalDisplay_StopP[] = static const struct SubspriteTable sSubspriteTable_DigitalDisplay_StopP[] = { - ARRAY_COUNT(sSubsprites_DigitalDisplay_StopP), sSubsprites_DigitalDisplay_StopP + {ARRAY_COUNT(sSubsprites_DigitalDisplay_StopP), sSubsprites_DigitalDisplay_StopP} }; /* @@ -7311,7 +7311,7 @@ static const struct Subsprite sSubsprites_DigitalDisplay_BonusB[] = static const struct SubspriteTable sSubspriteTable_DigitalDisplay_BonusB[] = { - ARRAY_COUNT(sSubsprites_DigitalDisplay_BonusB), sSubsprites_DigitalDisplay_BonusB + {ARRAY_COUNT(sSubsprites_DigitalDisplay_BonusB), sSubsprites_DigitalDisplay_BonusB} }; /* @@ -7340,7 +7340,7 @@ static const struct Subsprite sSubsprites_DigitalDisplay_BonusO[] = static const struct SubspriteTable sSubspriteTable_DigitalDisplay_BonusO[] = { - ARRAY_COUNT(sSubsprites_DigitalDisplay_BonusO), sSubsprites_DigitalDisplay_BonusO + {ARRAY_COUNT(sSubsprites_DigitalDisplay_BonusO), sSubsprites_DigitalDisplay_BonusO} }; /* @@ -7369,7 +7369,7 @@ static const struct Subsprite sSubsprites_DigitalDisplay_BonusN[] = static const struct SubspriteTable sSubspriteTable_DigitalDisplay_BonusN[] = { - ARRAY_COUNT(sSubsprites_DigitalDisplay_BonusN), sSubsprites_DigitalDisplay_BonusN + {ARRAY_COUNT(sSubsprites_DigitalDisplay_BonusN), sSubsprites_DigitalDisplay_BonusN} }; /* @@ -7398,7 +7398,7 @@ static const struct Subsprite sSubsprites_DigitalDisplay_BonusU[] = static const struct SubspriteTable sSubspriteTable_DigitalDisplay_BonusU[] = { - ARRAY_COUNT(sSubsprites_DigitalDisplay_BonusU), sSubsprites_DigitalDisplay_BonusU + {ARRAY_COUNT(sSubsprites_DigitalDisplay_BonusU), sSubsprites_DigitalDisplay_BonusU} }; /* @@ -7427,7 +7427,7 @@ static const struct Subsprite sSubsprites_DigitalDisplay_BonusS[] = static const struct SubspriteTable sSubspriteTable_DigitalDisplay_BonusS[] = { - ARRAY_COUNT(sSubsprites_DigitalDisplay_BonusS), sSubsprites_DigitalDisplay_BonusS + {ARRAY_COUNT(sSubsprites_DigitalDisplay_BonusS), sSubsprites_DigitalDisplay_BonusS} }; /* @@ -7490,7 +7490,7 @@ static const struct Subsprite sSubsprites_DigitalDisplay_BigB[] = static const struct SubspriteTable sSubspriteTable_DigitalDisplay_BigB[] = { - ARRAY_COUNT(sSubsprites_DigitalDisplay_BigB), sSubsprites_DigitalDisplay_BigB + {ARRAY_COUNT(sSubsprites_DigitalDisplay_BigB), sSubsprites_DigitalDisplay_BigB} }; /* @@ -7528,7 +7528,7 @@ static const struct Subsprite sSubsprites_DigitalDisplay_BigI[] = static const struct SubspriteTable sSubspriteTable_DigitalDisplay_BigI[] = { - ARRAY_COUNT(sSubsprites_DigitalDisplay_BigI), sSubsprites_DigitalDisplay_BigI + {ARRAY_COUNT(sSubsprites_DigitalDisplay_BigI), sSubsprites_DigitalDisplay_BigI} }; /* @@ -7591,7 +7591,7 @@ static const struct Subsprite sSubsprites_DigitalDisplay_BigG[] = static const struct SubspriteTable sSubspriteTable_DigitalDisplay_BigG[] = { - ARRAY_COUNT(sSubsprites_DigitalDisplay_BigG), sSubsprites_DigitalDisplay_BigG + {ARRAY_COUNT(sSubsprites_DigitalDisplay_BigG), sSubsprites_DigitalDisplay_BigG} }; /* @@ -7654,7 +7654,7 @@ static const struct Subsprite sSubsprites_DigitalDisplay_RegR[] = static const struct SubspriteTable sSubspriteTable_DigitalDisplay_RegR[] = { - ARRAY_COUNT(sSubsprites_DigitalDisplay_RegR), sSubsprites_DigitalDisplay_RegR + {ARRAY_COUNT(sSubsprites_DigitalDisplay_RegR), sSubsprites_DigitalDisplay_RegR} }; /* @@ -7692,7 +7692,7 @@ static const struct Subsprite sSubsprites_DigitalDisplay_RegE[] = static const struct SubspriteTable sSubspriteTable_DigitalDisplay_RegE[] = { - ARRAY_COUNT(sSubsprites_DigitalDisplay_RegE), sSubsprites_DigitalDisplay_RegE + {ARRAY_COUNT(sSubsprites_DigitalDisplay_RegE), sSubsprites_DigitalDisplay_RegE} }; /* @@ -7755,7 +7755,7 @@ static const struct Subsprite sSubsprites_DigitalDisplay_RegG[] = static const struct SubspriteTable sSubspriteTable_DigitalDisplay_RegG[] = { - ARRAY_COUNT(sSubsprites_DigitalDisplay_RegG), sSubsprites_DigitalDisplay_RegG + {ARRAY_COUNT(sSubsprites_DigitalDisplay_RegG), sSubsprites_DigitalDisplay_RegG} }; static const struct SpriteTemplate *const sSpriteTemplates_DigitalDisplay[NUM_DIG_DISPLAY_SPRITES] = diff --git a/src/sound.c b/src/sound.c index 15ebee831232..bef3658ecd24 100644 --- a/src/sound.c +++ b/src/sound.c @@ -156,8 +156,7 @@ void FadeOutAndFadeInNewMapMusic(u16 songNum, u8 fadeOutSpeed, u8 fadeInSpeed) sMapMusicFadeInSpeed = fadeInSpeed; } -// Unused -static void FadeInNewMapMusic(u16 songNum, u8 speed) +static void UNUSED FadeInNewMapMusic(u16 songNum, u8 speed) { FadeInNewBGM(songNum, speed); sCurrentMapMusic = songNum; diff --git a/src/start_menu.c b/src/start_menu.c index e39a5438ee00..2faff8c63d77 100644 --- a/src/start_menu.c +++ b/src/start_menu.c @@ -83,7 +83,7 @@ EWRAM_DATA static u8 sBattlePyramidFloorWindowId = 0; EWRAM_DATA static u8 sStartMenuCursorPos = 0; EWRAM_DATA static u8 sNumStartMenuActions = 0; EWRAM_DATA static u8 sCurrentStartMenuActions[9] = {0}; -EWRAM_DATA static u8 sInitStartMenuData[2] = {0}; +EWRAM_DATA static s8 sInitStartMenuData[2] = {0}; EWRAM_DATA static u8 (*sSaveDialogCallback)(void) = NULL; EWRAM_DATA static u8 sSaveDialogTimer = 0; diff --git a/src/trade.c b/src/trade.c index 28e8f89d1c5b..037ea4101a39 100644 --- a/src/trade.c +++ b/src/trade.c @@ -1900,7 +1900,7 @@ static void DrawSelectedMonScreen(u8 whichParty) StoreSpriteCallbackInData6(&gSprites[sTradeMenu->partySpriteIds[selectedMonParty][partyIdx]], SpriteCB_MonIcon); sTradeMenu->drawSelectedMonState[whichParty]++; Trade_MoveSelectedMonToTarget(&gSprites[sTradeMenu->partySpriteIds[selectedMonParty][partyIdx]]); - + CopyToBgTilemapBufferRect_ChangePalette(1, sTradePartyBoxTilemap, whichParty * 15, 0, 15, 17, 0); CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(0); @@ -3093,7 +3093,7 @@ static void UpdatePokedexForReceivedMon(u8 partyIdx) // Functionally nop after commented code static void TryEnableNationalDexFromLinkPartner(void) { - u8 mpId = GetMultiplayerId(); + u8 UNUSED mpId = GetMultiplayerId(); // Originally in Ruby but commented out /*if (gLinkPlayers[mpId ^ 1].lp_field_2 == 0x8000) EnableNationalPokedex();*/ diff --git a/src/trainer_hill.c b/src/trainer_hill.c index 3fbec613ad4b..cca1a3e984c9 100644 --- a/src/trainer_hill.c +++ b/src/trainer_hill.c @@ -571,7 +571,7 @@ static void IsTrainerHillChallengeActive(void) gSpecialVar_Result = TRUE; } -static void TrainerHillDummy_Unused(void) +static void UNUSED TrainerHillDummy_Unused(void) { } @@ -769,8 +769,7 @@ u8 GetCurrentTrainerHillMapId(void) return mapId; } -// Unused -static bool32 OnTrainerHillRoof(void) +static bool32 UNUSED OnTrainerHillRoof(void) { bool32 onRoof; diff --git a/src/trainer_pokemon_sprites.c b/src/trainer_pokemon_sprites.c index 3d7823cf3e60..b6e2b63c3556 100644 --- a/src/trainer_pokemon_sprites.c +++ b/src/trainer_pokemon_sprites.c @@ -337,8 +337,7 @@ u16 FreeAndDestroyMonPicSprite(u16 spriteId) return FreeAndDestroyPicSpriteInternal(spriteId); } -// Unused -static u16 LoadMonPicInWindow(u16 species, u32 otId, u32 personality, bool8 isFrontPic, u8 paletteSlot, u8 windowId) +static u16 UNUSED LoadMonPicInWindow(u16 species, u32 otId, u32 personality, bool8 isFrontPic, u8 paletteSlot, u8 windowId) { return LoadPicSpriteInWindow(species, otId, personality, isFrontPic, paletteSlot, windowId, FALSE); } @@ -359,8 +358,7 @@ u16 FreeAndDestroyTrainerPicSprite(u16 spriteId) return FreeAndDestroyPicSpriteInternal(spriteId); } -// Unused -static u16 LoadTrainerPicInWindow(u16 species, bool8 isFrontPic, u8 paletteSlot, u8 windowId) +static u16 UNUSED LoadTrainerPicInWindow(u16 species, bool8 isFrontPic, u8 paletteSlot, u8 windowId) { return LoadPicSpriteInWindow(species, 0, 0, isFrontPic, paletteSlot, windowId, TRUE); } diff --git a/src/trainer_see.c b/src/trainer_see.c index dd4acc7f36b1..88f9215f7703 100644 --- a/src/trainer_see.c +++ b/src/trainer_see.c @@ -627,7 +627,7 @@ static void Task_SetBuriedTrainerMovement(u8 taskId) struct Task *task = &gTasks[taskId]; struct ObjectEvent *objEvent; - LoadWordFromTwoHalfwords(&task->tObjEvent, (u32 *)&objEvent); + LoadWordFromTwoHalfwords((u16*) &task->tObjEvent, (u32 *)&objEvent); if (!task->data[7]) { ObjectEventClearHeldMovement(objEvent); @@ -649,7 +649,7 @@ static void Task_SetBuriedTrainerMovement(u8 taskId) // Called when a buried Trainer has the reveal_trainer movement applied, from direct interaction void SetBuriedTrainerMovement(struct ObjectEvent *objEvent) { - StoreWordInTwoHalfwords(&gTasks[CreateTask(Task_SetBuriedTrainerMovement, 0)].tObjEvent, (u32)objEvent); + StoreWordInTwoHalfwords((u16*) &gTasks[CreateTask(Task_SetBuriedTrainerMovement, 0)].tObjEvent, (u32)objEvent); } void DoTrainerApproach(void) diff --git a/src/tv.c b/src/tv.c index 1246faff2526..ef493c10ce5d 100644 --- a/src/tv.c +++ b/src/tv.c @@ -3961,8 +3961,7 @@ else \ (langptr) = langfix; \ } -// Unused -static void TranslateShowNames(TVShow *show, u32 language) +static void UNUSED TranslateShowNames(TVShow *show, u32 language) { int i; TVShow **shows; diff --git a/src/union_room.c b/src/union_room.c index 9160fc16ae41..1b29863183cd 100644 --- a/src/union_room.c +++ b/src/union_room.c @@ -1043,8 +1043,8 @@ static void Task_TryJoinLinkGroup(u8 taskId) id = ListMenu_ProcessInput(data->listTaskId); if (JOY_NEW(A_BUTTON) && id != LIST_NOTHING_CHOSEN) { - // this unused variable along with the assignment is needed to match - u32 activity = data->playerList->players[id].rfu.data.activity; + // Needed to match + u32 UNUSED activity = data->playerList->players[id].rfu.data.activity; if (data->playerList->players[id].groupScheduledAnim == UNION_ROOM_SPAWN_IN && !data->playerList->players[id].rfu.data.startedActivity) { @@ -2149,8 +2149,8 @@ static void Task_CardOrNewsWithFriend(u8 taskId) id = ListMenu_ProcessInput(data->listTaskId); if (JOY_NEW(A_BUTTON) && id != LIST_NOTHING_CHOSEN) { - // this unused variable along with the assignment is needed to match - u32 activity = data->playerList->players[id].rfu.data.activity; + // Needed to match + u32 UNUSED activity = data->playerList->players[id].rfu.data.activity; if (data->playerList->players[id].groupScheduledAnim == UNION_ROOM_SPAWN_IN && !data->playerList->players[id].rfu.data.startedActivity) { diff --git a/src/union_room_chat.c b/src/union_room_chat.c index 253e025689b7..993e36de524a 100644 --- a/src/union_room_chat.c +++ b/src/union_room_chat.c @@ -744,11 +744,11 @@ static const struct MessageWindowInfo sDisplayStdMessages[] = { static const u8 sText_Ellipsis[] = _("…"); static const struct MenuAction sKeyboardPageTitleTexts[UNION_ROOM_KB_PAGE_COUNT + 1] = { - [UNION_ROOM_KB_PAGE_UPPER] = {gText_Upper, NULL}, - [UNION_ROOM_KB_PAGE_LOWER] = {gText_Lower, NULL}, - [UNION_ROOM_KB_PAGE_EMOJI] = {gText_Symbols, NULL}, - [UNION_ROOM_KB_PAGE_REGISTER] = {gText_Register2, NULL}, - [UNION_ROOM_KB_PAGE_COUNT] = {gText_Exit2, NULL}, + [UNION_ROOM_KB_PAGE_UPPER] = {gText_Upper, {NULL}}, + [UNION_ROOM_KB_PAGE_LOWER] = {gText_Lower, {NULL}}, + [UNION_ROOM_KB_PAGE_EMOJI] = {gText_Symbols, {NULL}}, + [UNION_ROOM_KB_PAGE_REGISTER] = {gText_Register2, {NULL}}, + [UNION_ROOM_KB_PAGE_COUNT] = {gText_Exit2, {NULL}}, }; static const u16 sUnionRoomChatInterfacePal[] = INCBIN_U16("graphics/union_room_chat/interface.gbapal"); diff --git a/src/use_pokeblock.c b/src/use_pokeblock.c index 06df5d0a3349..1defb73ea943 100644 --- a/src/use_pokeblock.c +++ b/src/use_pokeblock.c @@ -1108,8 +1108,7 @@ static u8 GetSelectionIdFromPartyId(u8 partyId) return partyId - numEggs; } -// Unused -static u8 GetPartyIdFromSelectionId_(u8 selectionId) +static u8 UNUSED GetPartyIdFromSelectionId_(u8 selectionId) { return GetPartyIdFromSelectionId(selectionId); } From 927e4b60719f8f5ef5a85218316d1abeb38fced3 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Wed, 20 Sep 2023 19:04:50 -0300 Subject: [PATCH 22/48] Renamed time amounts --- include/siirtc.h | 6 +++--- src/pokemon.c | 2 +- src/rtc.c | 20 ++++++++++---------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/siirtc.h b/include/siirtc.h index 24573e4429f6..ad13fc62f37b 100644 --- a/include/siirtc.h +++ b/include/siirtc.h @@ -9,9 +9,9 @@ #define SIIRTCINFO_24HOUR 0x40 // 0: 12-hour mode, 1: 24-hour mode #define SIIRTCINFO_POWER 0x80 // power on or power failure occurred -#define DAY_HOURS 24 -#define HOUR_MINUTES 60 -#define MINUTE_SECONDS 60 +#define HOURS_PER_DAY 24 +#define MINUTES_PER_HOUR 60 +#define SECONDS_PER_MINUTE 60 enum { diff --git a/src/pokemon.c b/src/pokemon.c index fe93c14c192c..7eab3ccf684b 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -49,7 +49,7 @@ #include "constants/union_room.h" #define DAY_EVO_HOUR_BEGIN 12 -#define DAY_EVO_HOUR_END DAY_HOURS +#define DAY_EVO_HOUR_END HOURS_PER_DAY #define NIGHT_EVO_HOUR_BEGIN 0 #define NIGHT_EVO_HOUR_END 12 diff --git a/src/rtc.c b/src/rtc.c index a4920025cf93..b79f62a3c468 100644 --- a/src/rtc.c +++ b/src/rtc.c @@ -192,17 +192,17 @@ u16 RtcCheckInfo(struct SiiRtcInfo *rtc) value = ConvertBcdToBinary(rtc->hour); - if (value > DAY_HOURS) + if (value > HOURS_PER_DAY) errorFlags |= RTC_ERR_INVALID_HOUR; value = ConvertBcdToBinary(rtc->minute); - if (value > HOUR_MINUTES) + if (value > MINUTES_PER_HOUR) errorFlags |= RTC_ERR_INVALID_MINUTE; value = ConvertBcdToBinary(rtc->second); - if (value > MINUTE_SECONDS) + if (value > SECONDS_PER_MINUTE) errorFlags |= RTC_ERR_INVALID_SECOND; return errorFlags; @@ -270,19 +270,19 @@ void RtcCalcTimeDifference(struct SiiRtcInfo *rtc, struct Time *result, struct T if (result->seconds < 0) { - result->seconds += MINUTE_SECONDS; + result->seconds += SECONDS_PER_MINUTE; --result->minutes; } if (result->minutes < 0) { - result->minutes += HOUR_MINUTES; + result->minutes += MINUTES_PER_HOUR; --result->hours; } if (result->hours < 0) { - result->hours += DAY_HOURS; + result->hours += HOURS_PER_DAY; --result->days; } } @@ -317,19 +317,19 @@ void CalcTimeDifference(struct Time *result, struct Time *t1, struct Time *t2) if (result->seconds < 0) { - result->seconds += MINUTE_SECONDS; + result->seconds += SECONDS_PER_MINUTE; --result->minutes; } if (result->minutes < 0) { - result->minutes += HOUR_MINUTES; + result->minutes += MINUTES_PER_HOUR; --result->hours; } if (result->hours < 0) { - result->hours += DAY_HOURS; + result->hours += HOURS_PER_DAY; --result->days; } } @@ -337,7 +337,7 @@ void CalcTimeDifference(struct Time *result, struct Time *t1, struct Time *t2) u32 RtcGetMinuteCount(void) { RtcGetInfo(&sRtc); - return (DAY_HOURS * HOUR_MINUTES) * RtcGetDayCount(&sRtc) + HOUR_MINUTES * sRtc.hour + sRtc.minute; + return (HOURS_PER_DAY * MINUTES_PER_HOUR) * RtcGetDayCount(&sRtc) + MINUTES_PER_HOUR * sRtc.hour + sRtc.minute; } u32 RtcGetLocalDayCount(void) From a56eb4f53fe1ee1021f762af8b199988ed2b00b2 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Fri, 22 Sep 2023 11:19:00 -0300 Subject: [PATCH 23/48] Review changes. --- src/battle_anim_effects_1.c | 2 +- src/fieldmap.c | 1 - src/m4a_tables.c | 56 ++++++++++++++++++------------------- 3 files changed, 29 insertions(+), 30 deletions(-) diff --git a/src/battle_anim_effects_1.c b/src/battle_anim_effects_1.c index 0368adcf800d..3a558969b55d 100644 --- a/src/battle_anim_effects_1.c +++ b/src/battle_anim_effects_1.c @@ -4734,7 +4734,7 @@ static void AnimFalseSwipeSlice(struct Sprite *sprite) static void AnimFalseSwipePositionedSlice(struct Sprite *sprite) { - sprite->x = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2) + 0xFFD0 + gBattleAnimArgs[0]; + sprite->x = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2) - 48 + gBattleAnimArgs[0]; sprite->y = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET); StartSpriteAnim(sprite, 1); sprite->data[0] = 0; diff --git a/src/fieldmap.c b/src/fieldmap.c index 97b5b7811366..d9c4fa371a29 100644 --- a/src/fieldmap.c +++ b/src/fieldmap.c @@ -48,7 +48,6 @@ static const struct MapConnection *GetIncomingConnection(u8 direction, int x, in static bool8 IsPosInIncomingConnectingMap(u8 direction, int x, int y, const struct MapConnection *connection); static bool8 IsCoordInIncomingConnectingMap(int coord, int srcMax, int destMax, int offset); - #define GetBorderBlockAt(x, y)({ \ u16 block; \ int i; \ diff --git a/src/m4a_tables.c b/src/m4a_tables.c index 12e6893902bf..4d012cea2820 100644 --- a/src/m4a_tables.c +++ b/src/m4a_tables.c @@ -257,34 +257,34 @@ const u8 gClockTable[] = const struct PokemonCrySong gPokemonCrySongTemplate = { - 1, // track count - 0, // block count - 255, // priority - 0, // reverb - (struct ToneData *)&voicegroup000, // tone - {NULL, NULL}, // part - 0, // gap - TUNE, // part 0 - C_V, // TUNE value - GOTO, - 0, // GOTO target address - TUNE, // part 1 - C_V + 16, // TUNE value - {VOICE, 0}, // part 0 jumps here with GOTO - VOL, - 127, // volume - {XCMD, 0x0D}, - 0, // unk value - {XCMD, xRELE}, - 0, // release - PAN, - C_V, // PAN value - TIE, - 60, // TIE key (default is Cn3) - 127, // TIE velocity - {XCMD, 0x0C}, - 60, // unk value - {EOT, FINE} // end + .trackCount = 1, + .blockCount = 0, + .priority = 255, + .reverb = 0, + .tone = (struct ToneData *)&voicegroup000, + .part = {NULL, NULL}, + .gap = 0, + .part0 = TUNE, + .tuneValue = C_V, + .gotoCmd = GOTO, + .gotoTarget = 0, + .part1 = TUNE, + .tuneValue2 = C_V + 16, + .cont = {VOICE, 0}, // part0 jumps here with gotoCmd + .volCmd = VOL, + .volumeValue = 127, + .unkCmd0D = {XCMD, 0x0D}, + .unkCmd0DParam = 0, + .xreleCmd = {XCMD, xRELE}, + .releaseValue = 0, + .panCmd = PAN, + .panValue = C_V, + .tieCmd = TIE, + .tieKeyValue = 60, // default is Cn3 + .tieVelocityValue = 127, + .unkCmd0C = {XCMD, 0x0C}, + .unkCmd0CParam = 60, + .end = {EOT, FINE} }; const XcmdFunc gXcmdTable[] = From 03a1e7779b9fe10784f9e14b56abdf4f99789458 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Fri, 22 Sep 2023 11:23:27 -0300 Subject: [PATCH 24/48] Null dereferencing fix --- src/librfu_rfu.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/librfu_rfu.c b/src/librfu_rfu.c index 20d11352a160..fa8137f408f5 100644 --- a/src/librfu_rfu.c +++ b/src/librfu_rfu.c @@ -1430,7 +1430,11 @@ static u16 rfu_STC_setSendData_org(u8 ni_or_uni, u8 bmSendSlot, u8 subFrameSize, else if (gRfuLinkStatus->parentChild == MODE_CHILD) llFrameSize_p = &gRfuLinkStatus->remainLLFrameSizeChild[bm_slot_id]; frameSize = llsf_struct[gRfuLinkStatus->parentChild].frameSize; +#if UBFIX + if (llFrameSize_p && (subFrameSize > *llFrameSize_p || subFrameSize <= frameSize)) +#else if (subFrameSize > *llFrameSize_p || subFrameSize <= frameSize) +#endif return ERR_SUBFRAME_SIZE; imeBak = REG_IME; REG_IME = 0; @@ -1468,7 +1472,10 @@ static u16 rfu_STC_setSendData_org(u8 ni_or_uni, u8 bmSendSlot, u8 subFrameSize, } while (0); } gRfuLinkStatus->sendSlotNIFlag |= bmSendSlot; - *llFrameSize_p -= subFrameSize; +#if UBFIX + if (llFrameSize_p) +#endif + *llFrameSize_p -= subFrameSize; slotStatus_NI->send.state = SLOT_STATE_SEND_START; } else if (ni_or_uni & 0x10) @@ -1477,7 +1484,10 @@ static u16 rfu_STC_setSendData_org(u8 ni_or_uni, u8 bmSendSlot, u8 subFrameSize, slotStatus_UNI->send.bmSlot = bmSendSlot; slotStatus_UNI->send.src = src; slotStatus_UNI->send.payloadSize = subFrameSize - frameSize; - *llFrameSize_p -= subFrameSize; +#if UBFIX + if (llFrameSize_p) +#endif + *llFrameSize_p -= subFrameSize; slotStatus_UNI->send.state = SLOT_STATE_SEND_UNI; gRfuLinkStatus->sendSlotUNIFlag |= bmSendSlot; } From aff709a3cb847b31bcbd26b3b7ad8bbb8152d00d Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Fri, 22 Sep 2023 14:17:23 -0300 Subject: [PATCH 25/48] Fixed dumb mistake --- src/librfu_rfu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/librfu_rfu.c b/src/librfu_rfu.c index fa8137f408f5..37d99c4b46ef 100644 --- a/src/librfu_rfu.c +++ b/src/librfu_rfu.c @@ -1430,7 +1430,7 @@ static u16 rfu_STC_setSendData_org(u8 ni_or_uni, u8 bmSendSlot, u8 subFrameSize, else if (gRfuLinkStatus->parentChild == MODE_CHILD) llFrameSize_p = &gRfuLinkStatus->remainLLFrameSizeChild[bm_slot_id]; frameSize = llsf_struct[gRfuLinkStatus->parentChild].frameSize; -#if UBFIX +#ifdef UBFIX if (llFrameSize_p && (subFrameSize > *llFrameSize_p || subFrameSize <= frameSize)) #else if (subFrameSize > *llFrameSize_p || subFrameSize <= frameSize) @@ -1472,7 +1472,7 @@ static u16 rfu_STC_setSendData_org(u8 ni_or_uni, u8 bmSendSlot, u8 subFrameSize, } while (0); } gRfuLinkStatus->sendSlotNIFlag |= bmSendSlot; -#if UBFIX +#ifdef UBFIX if (llFrameSize_p) #endif *llFrameSize_p -= subFrameSize; @@ -1484,7 +1484,7 @@ static u16 rfu_STC_setSendData_org(u8 ni_or_uni, u8 bmSendSlot, u8 subFrameSize, slotStatus_UNI->send.bmSlot = bmSendSlot; slotStatus_UNI->send.src = src; slotStatus_UNI->send.payloadSize = subFrameSize - frameSize; -#if UBFIX +#ifdef UBFIX if (llFrameSize_p) #endif *llFrameSize_p -= subFrameSize; From 6eb6282c89387f4636fd7725f555623d3f3c5ec7 Mon Sep 17 00:00:00 2001 From: Kurausukun Date: Sat, 23 Sep 2023 17:06:12 -0400 Subject: [PATCH 26/48] add missing constant usage in m4a_1 --- src/m4a_1.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m4a_1.s b/src/m4a_1.s index 3f15788061d0..20f9197a8dd3 100644 --- a/src/m4a_1.s +++ b/src/m4a_1.s @@ -1395,7 +1395,7 @@ _081DD9F6: cmp r6, 0 beq _081DDA14 ldrb r0, [r4, o_CgbChannel_modify] - movs r1, 0x1 + movs r1, CGB_CHANNEL_MO_VOL orrs r0, r1 strb r0, [r4, o_CgbChannel_modify] _081DDA14: From cc30dc06d520314e87e5c6d9392f3a88628e4f65 Mon Sep 17 00:00:00 2001 From: kittenchilly Date: Tue, 26 Sep 2023 16:25:15 -0500 Subject: [PATCH 27/48] Add friendship evo threshold constant --- src/pokemon.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/pokemon.c b/src/pokemon.c index 7eab3ccf684b..be8a08341cf3 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -48,11 +48,13 @@ #include "constants/trainers.h" #include "constants/union_room.h" -#define DAY_EVO_HOUR_BEGIN 12 -#define DAY_EVO_HOUR_END HOURS_PER_DAY +#define DAY_EVO_HOUR_BEGIN 12 +#define DAY_EVO_HOUR_END HOURS_PER_DAY -#define NIGHT_EVO_HOUR_BEGIN 0 -#define NIGHT_EVO_HOUR_END 12 +#define NIGHT_EVO_HOUR_BEGIN 0 +#define NIGHT_EVO_HOUR_END 12 + +#define FRIENDSHIP_EVO_THRESHOLD 220 struct SpeciesItem { @@ -5499,17 +5501,17 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 mode, u16 evolutionItem) switch (gEvolutionTable[species][i].method) { case EVO_FRIENDSHIP: - if (friendship >= 220) + if (friendship >= FRIENDSHIP_EVO_THRESHOLD) targetSpecies = gEvolutionTable[species][i].targetSpecies; break; case EVO_FRIENDSHIP_DAY: RtcCalcLocalTime(); - if (gLocalTime.hours >= DAY_EVO_HOUR_BEGIN && gLocalTime.hours < DAY_EVO_HOUR_END && friendship >= 220) + if (gLocalTime.hours >= DAY_EVO_HOUR_BEGIN && gLocalTime.hours < DAY_EVO_HOUR_END && friendship >= FRIENDSHIP_EVO_THRESHOLD) targetSpecies = gEvolutionTable[species][i].targetSpecies; break; case EVO_FRIENDSHIP_NIGHT: RtcCalcLocalTime(); - if (gLocalTime.hours >= NIGHT_EVO_HOUR_BEGIN && gLocalTime.hours < NIGHT_EVO_HOUR_END && friendship >= 220) + if (gLocalTime.hours >= NIGHT_EVO_HOUR_BEGIN && gLocalTime.hours < NIGHT_EVO_HOUR_END && friendship >= FRIENDSHIP_EVO_THRESHOLD) targetSpecies = gEvolutionTable[species][i].targetSpecies; break; case EVO_LEVEL: From b724cfc578757c08fe0cde8bf9dcadd2fa141827 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sat, 30 Sep 2023 18:22:38 -0300 Subject: [PATCH 28/48] Review comment --- src/librfu_rfu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librfu_rfu.c b/src/librfu_rfu.c index 37d99c4b46ef..828d6450bc1b 100644 --- a/src/librfu_rfu.c +++ b/src/librfu_rfu.c @@ -1431,7 +1431,7 @@ static u16 rfu_STC_setSendData_org(u8 ni_or_uni, u8 bmSendSlot, u8 subFrameSize, llFrameSize_p = &gRfuLinkStatus->remainLLFrameSizeChild[bm_slot_id]; frameSize = llsf_struct[gRfuLinkStatus->parentChild].frameSize; #ifdef UBFIX - if (llFrameSize_p && (subFrameSize > *llFrameSize_p || subFrameSize <= frameSize)) + if ((llFrameSize_p && subFrameSize > *llFrameSize_p) || subFrameSize <= frameSize) #else if (subFrameSize > *llFrameSize_p || subFrameSize <= frameSize) #endif From 3a8a82d385daf325341fb350075d2604b4814385 Mon Sep 17 00:00:00 2001 From: kaboissonneault Date: Wed, 4 Oct 2023 09:18:02 -0400 Subject: [PATCH 29/48] Fixed out-of-bounds access in GetFactoryMonFixedIV when generating player rentals in round 8 (if player has 15+ swaps) and in round 9 --- src/battle_factory.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/battle_factory.c b/src/battle_factory.c index 5905b4191700..46d34efd7d29 100644 --- a/src/battle_factory.c +++ b/src/battle_factory.c @@ -741,7 +741,14 @@ u8 GetFactoryMonFixedIV(u8 challengeNum, bool8 isLastBattle) u8 ivSet; bool8 useHigherIV = isLastBattle ? TRUE : FALSE; +// The Factory has an out-of-bounds access when generating the rental draft for round 9 (challengeNum==8), +// or the "elevated" rentals from round 8 (challengeNum+1==8) +// This happens to land on a number higher than 31, which is interpreted as "random IVs" +#ifdef BUGFIX + if (challengeNum > 7) +#else if (challengeNum > 8) +#endif ivSet = 7; else ivSet = challengeNum; From 0a183c2027649e0042e066b0890f68088d1e0546 Mon Sep 17 00:00:00 2001 From: kaboissonneault Date: Thu, 5 Oct 2023 08:26:34 -0400 Subject: [PATCH 30/48] Changed sFixedIVTable access from hardcoded index limits to ARRAY_COUNT --- src/battle_factory.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/battle_factory.c b/src/battle_factory.c index 46d34efd7d29..3606d88e6afc 100644 --- a/src/battle_factory.c +++ b/src/battle_factory.c @@ -745,11 +745,11 @@ u8 GetFactoryMonFixedIV(u8 challengeNum, bool8 isLastBattle) // or the "elevated" rentals from round 8 (challengeNum+1==8) // This happens to land on a number higher than 31, which is interpreted as "random IVs" #ifdef BUGFIX - if (challengeNum > 7) + if (challengeNum >= ARRAY_COUNT(sFixedIVTable)) #else - if (challengeNum > 8) + if (challengeNum > ARRAY_COUNT(sFixedIVTable)) #endif - ivSet = 7; + ivSet = ARRAY_COUNT(sFixedIVTable) - 1; else ivSet = challengeNum; From 6f71fbe521ebe7ff1d3490ec3851ad28e9284ec0 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sun, 17 Sep 2023 17:11:55 -0400 Subject: [PATCH 31/48] Add some missing trainer hill constant usage --- src/event_object_movement.c | 4 ++-- src/trainer_hill.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 411b826a53d9..29dcf4d27c6b 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -1324,7 +1324,7 @@ u8 Unref_TryInitLocalObjectEvent(u8 localId) if (InBattlePyramid()) objectEventCount = GetNumBattlePyramidObjectEvents(); else if (InTrainerHill()) - objectEventCount = 2; + objectEventCount = HILL_TRAINERS_PER_FLOOR; else objectEventCount = gMapHeader.events->objectEventCount; @@ -1640,7 +1640,7 @@ void TrySpawnObjectEvents(s16 cameraX, s16 cameraY) if (InBattlePyramid()) objectCount = GetNumBattlePyramidObjectEvents(); else if (InTrainerHill()) - objectCount = 2; + objectCount = HILL_TRAINERS_PER_FLOOR; else objectCount = gMapHeader.events->objectEventCount; diff --git a/src/trainer_hill.c b/src/trainer_hill.c index cca1a3e984c9..018b9f14ba58 100644 --- a/src/trainer_hill.c +++ b/src/trainer_hill.c @@ -650,7 +650,7 @@ void LoadTrainerHillObjectEventTemplates(void) eventTemplates[i].localId = i + 1; eventTemplates[i].graphicsId = FacilityClassToGraphicsId(sHillData->floors[floorId].trainers[i].facilityClass); eventTemplates[i].x = sHillData->floors[floorId].map.trainerCoords[i] & 0xF; - eventTemplates[i].y = ((sHillData->floors[floorId].map.trainerCoords[i] >> 4) & 0xF) + 5; + eventTemplates[i].y = ((sHillData->floors[floorId].map.trainerCoords[i] >> 4) & 0xF) + HILL_FLOOR_HEIGHT_MARGIN; bits = i << 2; eventTemplates[i].movementType = ((sHillData->floors[floorId].map.trainerDirections >> bits) & 0xF) + MOVEMENT_TYPE_FACE_UP; eventTemplates[i].trainerRange_berryTreeId = (sHillData->floors[floorId].map.trainerRanges >> bits) & 0xF; From 054d0f98526e97d644062af3f26557cf32a62f05 Mon Sep 17 00:00:00 2001 From: Thomas Winwood Date: Sat, 7 Oct 2023 17:52:57 +0100 Subject: [PATCH 32/48] Remove fakematch in NewGameInitPCItems --- src/player_pc.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/player_pc.c b/src/player_pc.c index 7dc2616e7109..009aa7810f79 100644 --- a/src/player_pc.c +++ b/src/player_pc.c @@ -222,7 +222,7 @@ static const struct MenuAction sItemStorage_MenuActions[] = [MENU_EXIT] = { gText_Cancel, {ItemStorage_Exit} } }; -static const struct ItemSlot sNewGamePCItems[] = +static const u16 sNewGamePCItems[][2] = { { ITEM_POTION, 1 }, { ITEM_NONE, 0 } @@ -355,16 +355,20 @@ static const struct WindowTemplate sWindowTemplates_ItemStorage[ITEMPC_WIN_COUNT static const u8 sSwapArrowTextColors[] = {TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GRAY, TEXT_COLOR_DARK_GRAY}; -// Macro below is likely a fakematch, equivalent to sNewGamePCItems[i].quantity -#define GET_QUANTITY(i) ((u16)((u16 *)sNewGamePCItems + 1)[i * 2]) void NewGameInitPCItems(void) { u8 i = 0; ClearItemSlots(gSaveBlock1Ptr->pcItems, PC_ITEMS_COUNT); - for(; sNewGamePCItems[i].itemId != ITEM_NONE && GET_QUANTITY(i) && - AddPCItem(sNewGamePCItems[i].itemId, GET_QUANTITY(i)) == TRUE; i++); + + while (TRUE) + { + if (sNewGamePCItems[i][0] == ITEM_NONE || sNewGamePCItems[i][1] == 0) + break; + if (AddPCItem(sNewGamePCItems[i][0], sNewGamePCItems[i][1]) != TRUE) + break; + i++; + } } -#undef GET_QUANTITY void BedroomPC(void) { From 0e84c7deb302560913decb24673e1e991d52b5a9 Mon Sep 17 00:00:00 2001 From: marlux895 <141656905+marlux895@users.noreply.github.com> Date: Sat, 7 Oct 2023 23:23:52 +0200 Subject: [PATCH 33/48] corrected comment, tough to smart --- src/menu_specialized.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/menu_specialized.c b/src/menu_specialized.c index e749f599de76..20ddce1f44e7 100644 --- a/src/menu_specialized.c +++ b/src/menu_specialized.c @@ -587,7 +587,7 @@ static void ConditionGraph_CalcRightHalf(struct ConditionGraph *graph) // No need for conditional, positions on the Beauty line are always above the Cute line ConditionGraph_CalcLine(graph, graph->scanlineRight[0], &graph->curPositions[GRAPH_BEAUTY], &graph->curPositions[GRAPH_CUTE], TRUE, NULL); - // Calculate Cute -> Tough line (includes left scanline because this crosses the halfway point) + // Calculate Cute -> Smart line (includes left scanline because this crosses the halfway point) i = (graph->curPositions[GRAPH_CUTE].y <= graph->curPositions[GRAPH_SMART].y); ConditionGraph_CalcLine(graph, graph->scanlineRight[0], &graph->curPositions[GRAPH_CUTE], &graph->curPositions[GRAPH_SMART], i, graph->scanlineLeft[0]); From a5c2ac5e49207fea321dff74003bca81ee1a55f0 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Thu, 19 Oct 2023 23:37:04 -0400 Subject: [PATCH 34/48] Use BUGFIX in assembly files --- data/battle_ai_scripts.s | 23 +++++++++-------- data/contest_ai_scripts.s | 25 ++++++++++--------- data/event_scripts.s | 1 + .../scripts.inc | 10 ++++---- .../MossdeepCity_SpaceCenter_1F/scripts.inc | 6 ++--- data/scripts/trainer_hill.inc | 4 +-- 6 files changed, 36 insertions(+), 33 deletions(-) diff --git a/data/battle_ai_scripts.s b/data/battle_ai_scripts.s index c296702a6453..a43c88950289 100644 --- a/data/battle_ai_scripts.s +++ b/data/battle_ai_scripts.s @@ -1,3 +1,4 @@ +#include "config.h" #include "constants/battle.h" #include "constants/battle_ai.h" #include "constants/abilities.h" @@ -1926,19 +1927,19 @@ AI_CV_Protect_End: @ BUG: Foresight is only encouraged if the user is Ghost type or @ has high evasion, but should check target instead AI_CV_Foresight: -.ifdef BUGFIX +#ifdef BUGFIX get_target_type1 if_equal TYPE_GHOST, AI_CV_Foresight2 get_target_type2 if_equal TYPE_GHOST, AI_CV_Foresight2 if_stat_level_more_than AI_TARGET, STAT_EVASION, 8, AI_CV_Foresight3 -.else +#else get_user_type1 if_equal TYPE_GHOST, AI_CV_Foresight2 get_user_type2 if_equal TYPE_GHOST, AI_CV_Foresight2 if_stat_level_more_than AI_USER, STAT_EVASION, 8, AI_CV_Foresight3 -.endif +#endif score -2 goto AI_CV_Foresight_End @@ -2183,13 +2184,13 @@ AI_CV_SemiInvulnerable2: if_status2 AI_TARGET, STATUS2_CURSED, AI_CV_SemiInvulnerable_TryEncourage if_status3 AI_TARGET, STATUS3_LEECHSEED, AI_CV_SemiInvulnerable_TryEncourage get_weather -.ifdef BUGFIX +#ifdef BUGFIX if_equal AI_WEATHER_HAIL, AI_CV_SemiInvulnerable_CheckIceType if_equal AI_WEATHER_SANDSTORM, AI_CV_SemiInvulnerable_CheckSandstormTypes -.else +#else if_equal AI_WEATHER_HAIL, AI_CV_SemiInvulnerable_CheckSandstormTypes if_equal AI_WEATHER_SANDSTORM, AI_CV_SemiInvulnerable_CheckIceType -.endif +#endif goto AI_CV_SemiInvulnerable5 AI_CV_SemiInvulnerable_CheckSandstormTypes: @@ -2254,11 +2255,11 @@ AI_CV_Hail_End: @ BUG: Facade score is increased if the target is statused, but should be if the user is AI_CV_Facade: -.ifdef BUGFIX +#ifdef BUGFIX if_not_status AI_USER, STATUS1_POISON | STATUS1_BURN | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON, AI_CV_Facade_End -.else +#else if_not_status AI_TARGET, STATUS1_POISON | STATUS1_BURN | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON, AI_CV_Facade_End -.endif +#endif score +1 AI_CV_Facade_End: end @@ -3176,9 +3177,9 @@ AI_HPAware_DiscouragedEffectsWhenTargetLowHP: AI_TrySunnyDayStart: if_target_is_ally AI_TryOnAlly if_not_effect EFFECT_SUNNY_DAY, AI_TrySunnyDayStart_End -.ifndef BUGFIX @ funcResult has not been set in this script yet, below call is nonsense +#ifndef BUGFIX @ funcResult has not been set in this script yet, below call is nonsense if_equal FALSE, AI_TrySunnyDayStart_End -.endif +#endif is_first_turn_for AI_USER if_equal FALSE, AI_TrySunnyDayStart_End score +5 diff --git a/data/contest_ai_scripts.s b/data/contest_ai_scripts.s index ecd3103ae2ec..affaf31d6dde 100644 --- a/data/contest_ai_scripts.s +++ b/data/contest_ai_scripts.s @@ -1,3 +1,4 @@ +#include "config.h" #include "constants/global.h" #include "constants/contest.h" .include "asm/macros.inc" @@ -435,11 +436,11 @@ AI_CGM_BetterWhenAudienceExcited: AI_CGM_BetterWhenAudienceExcited_1stUp: @ BUG: Should be if_appeal_num_eq 0 @ 1st up on 1st appeal excitement will always be 0 -.ifdef BUGFIX +#ifdef BUGFIX if_appeal_num_eq 0, AI_CGM_BetterWhenAudienceExcited_1stAppeal -.else +#else if_appeal_num_not_eq 0, AI_CGM_BetterWhenAudienceExcited_1stAppeal -.endif +#endif if_excitement_eq 4, AI_CGM_BetterWhenAudienceExcited_1AwayFromMax if_excitement_eq 3, AI_CGM_BetterWhenAudienceExcited_2AwayFromMax end @@ -546,11 +547,11 @@ AI_CGM_TargetMonWithJudgesAttention: end AI_CGM_TargetMonWithJudgesAttention_CheckMon1: if_cannot_participate MON_1, AI_CGM_TargetMonWithJudgesAttention_CheckMon2 -.ifdef BUGFIX +#ifdef BUGFIX if_not_used_combo_starter MON_1, AI_CGM_TargetMonWithJudgesAttention_CheckMon2 -.else +#else if_used_combo_starter MON_1, AI_CGM_TargetMonWithJudgesAttention_CheckMon2 -.endif +#endif if_random_less_than 125, AI_CGM_TargetMonWithJudgesAttention_CheckMon2 score +2 if_not_completed_combo MON_1, AI_CGM_TargetMonWithJudgesAttention_CheckMon2 @@ -559,11 +560,11 @@ AI_CGM_TargetMonWithJudgesAttention_CheckMon1: AI_CGM_TargetMonWithJudgesAttention_CheckMon2: if_user_order_eq MON_2, AI_CGM_End if_cannot_participate MON_2, AI_CGM_TargetMonWithJudgesAttention_CheckMon3 -.ifdef BUGFIX +#ifdef BUGFIX if_not_used_combo_starter MON_2, AI_CGM_TargetMonWithJudgesAttention_CheckMon3 -.else +#else if_used_combo_starter MON_2, AI_CGM_TargetMonWithJudgesAttention_CheckMon3 -.endif +#endif if_random_less_than 125, AI_CGM_TargetMonWithJudgesAttention_CheckMon3 score +2 if_not_completed_combo MON_2, AI_CGM_TargetMonWithJudgesAttention_CheckMon3 @@ -572,11 +573,11 @@ AI_CGM_TargetMonWithJudgesAttention_CheckMon2: AI_CGM_TargetMonWithJudgesAttention_CheckMon3: if_user_order_eq MON_3, AI_CGM_End if_cannot_participate MON_3, AI_CGM_End -.ifdef BUGFIX +#ifdef BUGFIX if_not_used_combo_starter MON_3, AI_CGM_End -.else +#else if_used_combo_starter MON_3, AI_CGM_End -.endif +#endif if_random_less_than 125, AI_CGM_End score +2 if_not_completed_combo MON_3, AI_CGM_End diff --git a/data/event_scripts.s b/data/event_scripts.s index 1f3db6aa2b0b..e8fb9dcbd18c 100644 --- a/data/event_scripts.s +++ b/data/event_scripts.s @@ -1,3 +1,4 @@ +#include "config.h" #include "constants/global.h" #include "constants/apprentice.h" #include "constants/battle.h" diff --git a/data/maps/BattleFrontier_BattleTowerLobby/scripts.inc b/data/maps/BattleFrontier_BattleTowerLobby/scripts.inc index 6162d0ada684..a216055b5b72 100644 --- a/data/maps/BattleFrontier_BattleTowerLobby/scripts.inc +++ b/data/maps/BattleFrontier_BattleTowerLobby/scripts.inc @@ -415,18 +415,18 @@ BattleFrontier_BattleTowerLobby_EventScript_SaveBeforeLinkMultisChallenge:: @ to the flash, but not data in PokemonStorage. The SaveGame script that follows asks the player to do a full save, @ which they can opt out of. As a result the player can save their party and quit without having saved the PC. @ This allows players to clone pokemon and their held items by withdrawing them (or erase them by despositing). -.ifndef BUGFIX +#ifndef BUGFIX tower_save 0 -.endif +#endif call Common_EventScript_SaveGame setvar VAR_TEMP_CHALLENGE_STATUS, 255 goto_if_eq VAR_RESULT, 0, BattleFrontier_BattleTowerLobby_EventScript_CancelChallengeSaveFailed @ GAME_STAT_ENTERED_BATTLE_TOWER should not be incremented here, for two reasons: @ 1. It is incremented again in BattleFrontier_BattleTowerLobby_EventScript_CableLinkSuccessful or BattleFrontier_BattleTowerLobby_EventScript_WirelessLinkSuccessful -@ 2. If the player tries to save, but fails, the counter will still be incremented even if the player never enters the tower. -.ifndef BUGFIX +@ 2. If the player tries to connect, but fails, the counter will still be incremented even if the player never enters the tower. +#ifndef BUGFIX incrementgamestat GAME_STAT_ENTERED_BATTLE_TOWER -.endif +#endif specialvar VAR_RESULT, IsWirelessAdapterConnected goto_if_eq VAR_RESULT, TRUE, BattleFrontier_BattleTowerLobby_EventScript_TryWirelessLink goto BattleFrontier_BattleTowerLobby_EventScript_TryCableLink diff --git a/data/maps/MossdeepCity_SpaceCenter_1F/scripts.inc b/data/maps/MossdeepCity_SpaceCenter_1F/scripts.inc index 263b07105679..e17af3572452 100644 --- a/data/maps/MossdeepCity_SpaceCenter_1F/scripts.inc +++ b/data/maps/MossdeepCity_SpaceCenter_1F/scripts.inc @@ -229,11 +229,11 @@ MossdeepCity_SpaceCenter_1F_EventScript_Grunt2:: copyobjectxytoperm LOCALID_STAIR_GRUNT switch VAR_FACING case DIR_WEST, MossdeepCity_SpaceCenter_1F_EventScript_MoveGruntFromStairsWest - #ifdef BUGFIX +#ifdef BUGFIX case DIR_EAST, MossdeepCity_SpaceCenter_1F_EventScript_MoveGruntFromStairsEast - #else +#else case DIR_WEST, MossdeepCity_SpaceCenter_1F_EventScript_MoveGruntFromStairsEast - #endif +#endif applymovement LOCALID_STAIR_GRUNT, MossdeepCity_SpaceCenter_1F_Movement_MoveGruntFromStairs waitmovement 0 setvar VAR_MOSSDEEP_SPACE_CENTER_STAIR_GUARD_STATE, 2 diff --git a/data/scripts/trainer_hill.inc b/data/scripts/trainer_hill.inc index b7f815351449..04bbe05e5ad4 100644 --- a/data/scripts/trainer_hill.inc +++ b/data/scripts/trainer_hill.inc @@ -13,9 +13,9 @@ TrainerHill_OnWarp: TrainerHill_1F_EventScript_DummyOnWarp:: setvar VAR_TEMP_3, 1 -.ifdef BUGFIX +#ifdef BUGFIX end @ Missing end. By chance, the next byte (0x02 of VAR_TEMP_2) is also the id for the end cmd -.endif +#endif TrainerHill_OnFrame: map_script_2 VAR_TEMP_2, 0, TrainerHill_1F_EventScript_DummyWarpToEntranceCounter From ffdc2456cbf00954c965d4d9a256cd452226b0d8 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Fri, 20 Oct 2023 12:46:28 -0400 Subject: [PATCH 35/48] Document datahpupdate --- data/battle_scripts_1.s | 4 +- include/battle.h | 15 +++++--- include/constants/battle.h | 2 +- src/battle_main.c | 4 +- src/battle_script_commands.c | 73 +++++++++++++++++++++++------------- src/battle_util.c | 24 ++++++------ 6 files changed, 72 insertions(+), 50 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index e7f592aacbef..0c0dc72831d6 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -3208,7 +3208,7 @@ BattleScript_DamagingWeatherLoop:: jumpifword CMP_EQUAL, gBattleMoveDamage, 0, BattleScript_DamagingWeatherLoopIncrement printfromtable gSandStormHailDmgStringIds waitmessage B_WAIT_TIME_LONG - orword gHitMarker, HITMARKER_SKIP_DMG_TRACK | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE | HITMARKER_GRUDGE + orword gHitMarker, HITMARKER_IGNORE_BIDE | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE | HITMARKER_GRUDGE effectivenesssound hitanimation BS_ATTACKER healthbarupdate BS_ATTACKER @@ -3220,7 +3220,7 @@ BattleScript_DamagingWeatherLoopIncrement:: addbyte gBattleCommunication, 1 jumpifbytenotequal gBattleCommunication, gBattlersCount, BattleScript_DamagingWeatherLoop BattleScript_DamagingWeatherContinuesEnd:: - bicword gHitMarker, HITMARKER_SKIP_DMG_TRACK | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE | HITMARKER_GRUDGE + bicword gHitMarker, HITMARKER_IGNORE_BIDE | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE | HITMARKER_GRUDGE end2 BattleScript_SandStormHailEnds:: diff --git a/include/battle.h b/include/battle.h index bb0e42fb837e..f4c5bd997e20 100644 --- a/include/battle.h +++ b/include/battle.h @@ -54,6 +54,9 @@ #define BATTLE_BUFFER_LINK_SIZE 0x1000 +// Special indicator value for shellBellDmg in SpecialStatus +#define IGNORE_SHELL_BELL 0xFFFF + struct ResourceFlags { u32 flags[MAX_BATTLERS_COUNT]; @@ -133,7 +136,7 @@ struct SpecialStatus u32 ppNotAffectedByPressure:1; u32 faintedHasReplacement:1; u32 focusBanded:1; - s32 dmg; + s32 shellBellDmg; s32 physicalDmg; s32 specialDmg; u8 physicalBattlerId; @@ -445,9 +448,9 @@ struct BattleStruct // The assert below is to ensure palaceFlags is large enough to store these flags without overlap. STATIC_ASSERT(sizeof(((struct BattleStruct *)0)->palaceFlags) * 8 >= MAX_BATTLERS_COUNT + MAX_MON_MOVES, PalaceFlagsTooSmall) -#define F_DYNAMIC_TYPE_1 (1 << 6) -#define F_DYNAMIC_TYPE_2 (1 << 7) -#define DYNAMIC_TYPE_MASK (F_DYNAMIC_TYPE_1 - 1) +#define DYNAMIC_TYPE_MASK ((1 << 6) - 1) +#define F_DYNAMIC_TYPE_IGNORE_PHYSICALITY (1 << 6) // If set, the dynamic type's physicality won't be used for certain move effects. +#define F_DYNAMIC_TYPE_UNREAD (1 << 7) // Set for Hidden Power and Weather Ball but never apparently checked. #define GET_MOVE_TYPE(move, typeArg) \ { \ @@ -647,7 +650,7 @@ extern u16 gChosenMove; extern u16 gCalledMove; extern s32 gBattleMoveDamage; extern s32 gHpDealt; -extern s32 gTakenDmg[MAX_BATTLERS_COUNT]; +extern s32 gBideDmg[MAX_BATTLERS_COUNT]; extern u16 gLastUsedItem; extern u8 gLastUsedAbility; extern u8 gBattlerAttacker; @@ -673,7 +676,7 @@ extern u8 gLastHitBy[MAX_BATTLERS_COUNT]; extern u16 gChosenMoveByBattler[MAX_BATTLERS_COUNT]; extern u8 gMoveResultFlags; extern u32 gHitMarker; -extern u8 gTakenDmgByBattler[MAX_BATTLERS_COUNT]; +extern u8 gBideTarget[MAX_BATTLERS_COUNT]; extern u8 gUnusedFirstBattleVar2; extern u16 gSideStatuses[NUM_BATTLE_SIDES]; extern struct SideTimer gSideTimers[NUM_BATTLE_SIDES]; diff --git a/include/constants/battle.h b/include/constants/battle.h index ac83feb3a056..c4c1bc5e6825 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -168,7 +168,7 @@ // Not really sure what a "hitmarker" is. #define HITMARKER_WAKE_UP_CLEAR (1 << 4) // Cleared when waking up. Never set or checked. -#define HITMARKER_SKIP_DMG_TRACK (1 << 5) +#define HITMARKER_IGNORE_BIDE (1 << 5) #define HITMARKER_DESTINYBOND (1 << 6) #define HITMARKER_NO_ANIMATIONS (1 << 7) #define HITMARKER_IGNORE_SUBSTITUTE (1 << 8) diff --git a/src/battle_main.c b/src/battle_main.c index b5c6cbbf078b..c19089deb043 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -170,7 +170,7 @@ EWRAM_DATA u16 gChosenMove = 0; EWRAM_DATA u16 gCalledMove = 0; EWRAM_DATA s32 gBattleMoveDamage = 0; EWRAM_DATA s32 gHpDealt = 0; -EWRAM_DATA s32 gTakenDmg[MAX_BATTLERS_COUNT] = {0}; +EWRAM_DATA s32 gBideDmg[MAX_BATTLERS_COUNT] = {0}; EWRAM_DATA u16 gLastUsedItem = 0; EWRAM_DATA u8 gLastUsedAbility = 0; EWRAM_DATA u8 gBattlerAttacker = 0; @@ -197,7 +197,7 @@ EWRAM_DATA u16 gChosenMoveByBattler[MAX_BATTLERS_COUNT] = {0}; EWRAM_DATA u8 gMoveResultFlags = 0; EWRAM_DATA u32 gHitMarker = 0; EWRAM_DATA static u8 sUnusedBattlersArray[MAX_BATTLERS_COUNT] = {0}; -EWRAM_DATA u8 gTakenDmgByBattler[MAX_BATTLERS_COUNT] = {0}; +EWRAM_DATA u8 gBideTarget[MAX_BATTLERS_COUNT] = {0}; EWRAM_DATA u8 gUnusedFirstBattleVar2 = 0; // Never read EWRAM_DATA u16 gSideStatuses[NUM_BATTLE_SIDES] = {0}; EWRAM_DATA struct SideTimer gSideTimers[NUM_BATTLE_SIDES] = {0}; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 9d2c2cb71557..fd87e94e2a0e 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1836,6 +1836,7 @@ static void Cmd_healthbarupdate(void) gBattlescriptCurrInstr += 2; } +// Update the active battler's HP and various HP trackers (Substitute, Bide, etc.) static void Cmd_datahpupdate(void) { u32 moveType; @@ -1843,9 +1844,13 @@ static void Cmd_datahpupdate(void) if (gBattleControllerExecFlags) return; + // moveType will be used later to record for Counter/Mirror Coat whether this was physical or special damage. + // For moves with a dynamic type that have F_DYNAMIC_TYPE_IGNORE_PHYSICALITY set (in vanilla, just Hidden Power) this will ignore + // the dynamic type and use the move's base type instead, meaning (as a Normal type) Hidden Power will only ever trigger Counter. + // It also means that Hidden Power Fire is unable to defrost targets. if (gBattleStruct->dynamicMoveType == 0) moveType = gBattleMoves[gCurrentMove].type; - else if (!(gBattleStruct->dynamicMoveType & F_DYNAMIC_TYPE_1)) + else if (!(gBattleStruct->dynamicMoveType & F_DYNAMIC_TYPE_IGNORE_PHYSICALITY)) moveType = gBattleStruct->dynamicMoveType & DYNAMIC_TYPE_MASK; else moveType = gBattleMoves[gCurrentMove].type; @@ -1855,23 +1860,26 @@ static void Cmd_datahpupdate(void) gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); if (gBattleMons[gActiveBattler].status2 & STATUS2_SUBSTITUTE && gDisableStructs[gActiveBattler].substituteHP && !(gHitMarker & HITMARKER_IGNORE_SUBSTITUTE)) { + // Target has an active Substitute, deal damage to that instead. if (gDisableStructs[gActiveBattler].substituteHP >= gBattleMoveDamage) { - if (gSpecialStatuses[gActiveBattler].dmg == 0) - gSpecialStatuses[gActiveBattler].dmg = gBattleMoveDamage; + if (gSpecialStatuses[gActiveBattler].shellBellDmg == 0) + gSpecialStatuses[gActiveBattler].shellBellDmg = gBattleMoveDamage; gDisableStructs[gActiveBattler].substituteHP -= gBattleMoveDamage; gHpDealt = gBattleMoveDamage; } else { - if (gSpecialStatuses[gActiveBattler].dmg == 0) - gSpecialStatuses[gActiveBattler].dmg = gDisableStructs[gActiveBattler].substituteHP; + // Substitute has less HP than the damage dealt, set its HP to 0. + if (gSpecialStatuses[gActiveBattler].shellBellDmg == 0) + gSpecialStatuses[gActiveBattler].shellBellDmg = gDisableStructs[gActiveBattler].substituteHP; gHpDealt = gDisableStructs[gActiveBattler].substituteHP; gDisableStructs[gActiveBattler].substituteHP = 0; } - // check substitute fading + if (gDisableStructs[gActiveBattler].substituteHP == 0) { + // Substitute fades gBattlescriptCurrInstr += 2; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_SubstituteFade; @@ -1881,28 +1889,30 @@ static void Cmd_datahpupdate(void) else { gHitMarker &= ~HITMARKER_IGNORE_SUBSTITUTE; - if (gBattleMoveDamage < 0) // hp goes up + if (gBattleMoveDamage < 0) { - gBattleMons[gActiveBattler].hp -= gBattleMoveDamage; + // Negative damage is HP gain + gBattleMons[gActiveBattler].hp += -gBattleMoveDamage; if (gBattleMons[gActiveBattler].hp > gBattleMons[gActiveBattler].maxHP) gBattleMons[gActiveBattler].hp = gBattleMons[gActiveBattler].maxHP; - } - else // hp goes down + else { - if (gHitMarker & HITMARKER_SKIP_DMG_TRACK) + if (gHitMarker & HITMARKER_IGNORE_BIDE) { - gHitMarker &= ~HITMARKER_SKIP_DMG_TRACK; + gHitMarker &= ~HITMARKER_IGNORE_BIDE; } else { - gTakenDmg[gActiveBattler] += gBattleMoveDamage; + // Record damage/attacker for Bide + gBideDmg[gActiveBattler] += gBattleMoveDamage; if (gBattlescriptCurrInstr[1] == BS_TARGET) - gTakenDmgByBattler[gActiveBattler] = gBattlerAttacker; + gBideTarget[gActiveBattler] = gBattlerAttacker; else - gTakenDmgByBattler[gActiveBattler] = gBattlerTarget; + gBideTarget[gActiveBattler] = gBattlerTarget; } + // Deal damage to the battler if (gBattleMons[gActiveBattler].hp > gBattleMoveDamage) { gBattleMons[gActiveBattler].hp -= gBattleMoveDamage; @@ -1914,11 +1924,16 @@ static void Cmd_datahpupdate(void) gBattleMons[gActiveBattler].hp = 0; } - if (!gSpecialStatuses[gActiveBattler].dmg && !(gHitMarker & HITMARKER_PASSIVE_DAMAGE)) - gSpecialStatuses[gActiveBattler].dmg = gHpDealt; + // Record damage for Shell Bell + if (gSpecialStatuses[gActiveBattler].shellBellDmg == 0 && !(gHitMarker & HITMARKER_PASSIVE_DAMAGE)) + gSpecialStatuses[gActiveBattler].shellBellDmg = gHpDealt; + // Note: While physicalDmg/specialDmg below are only distinguished between for Counter/Mirror Coat, they are + // used in combination as general damage trackers for other purposes. specialDmg is additionally used + // to help determine if a fire move should defrost the target. if (IS_TYPE_PHYSICAL(moveType) && !(gHitMarker & HITMARKER_PASSIVE_DAMAGE) && gCurrentMove != MOVE_PAIN_SPLIT) { + // Record physical damage/attacker for Counter gProtectStructs[gActiveBattler].physicalDmg = gHpDealt; gSpecialStatuses[gActiveBattler].physicalDmg = gHpDealt; if (gBattlescriptCurrInstr[1] == BS_TARGET) @@ -1934,6 +1949,7 @@ static void Cmd_datahpupdate(void) } else if (!IS_TYPE_PHYSICAL(moveType) && !(gHitMarker & HITMARKER_PASSIVE_DAMAGE)) { + // Record special damage/attacker for Mirror Coat gProtectStructs[gActiveBattler].specialDmg = gHpDealt; gSpecialStatuses[gActiveBattler].specialDmg = gHpDealt; if (gBattlescriptCurrInstr[1] == BS_TARGET) @@ -1949,15 +1965,18 @@ static void Cmd_datahpupdate(void) } } gHitMarker &= ~HITMARKER_PASSIVE_DAMAGE; + + // Send updated HP BtlController_EmitSetMonData(BUFFER_A, REQUEST_HP_BATTLE, 0, sizeof(gBattleMons[gActiveBattler].hp), &gBattleMons[gActiveBattler].hp); MarkBattlerForControllerExec(gActiveBattler); } } else { + // MOVE_RESULT_NO_EFFECT was set gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); - if (gSpecialStatuses[gActiveBattler].dmg == 0) - gSpecialStatuses[gActiveBattler].dmg = 0xFFFF; + if (gSpecialStatuses[gActiveBattler].shellBellDmg == 0) + gSpecialStatuses[gActiveBattler].shellBellDmg = IGNORE_SHELL_BELL; } gBattlescriptCurrInstr += 2; } @@ -7092,7 +7111,7 @@ static void Cmd_setbide(void) { gBattleMons[gBattlerAttacker].status2 |= STATUS2_MULTIPLETURNS; gLockedMoves[gBattlerAttacker] = gCurrentMove; - gTakenDmg[gBattlerAttacker] = 0; + gBideDmg[gBattlerAttacker] = 0; gBattleMons[gBattlerAttacker].status2 |= STATUS2_BIDE_TURN(2); gBattlescriptCurrInstr++; @@ -7984,7 +8003,7 @@ static void Cmd_painsplitdmgcalc(void) storeLoc[3] = (painSplitHp & 0xFF000000) >> 24; gBattleMoveDamage = gBattleMons[gBattlerAttacker].hp - hpDiff; - gSpecialStatuses[gBattlerTarget].dmg = 0xFFFF; + gSpecialStatuses[gBattlerTarget].shellBellDmg = IGNORE_SHELL_BELL; gBattlescriptCurrInstr += 5; } @@ -8822,7 +8841,7 @@ static void Cmd_hiddenpowercalc(void) gBattleStruct->dynamicMoveType = ((NUMBER_OF_MON_TYPES - 3) * typeBits) / 63 + 1; if (gBattleStruct->dynamicMoveType >= TYPE_MYSTERY) gBattleStruct->dynamicMoveType++; - gBattleStruct->dynamicMoveType |= F_DYNAMIC_TYPE_1 | F_DYNAMIC_TYPE_2; + gBattleStruct->dynamicMoveType |= F_DYNAMIC_TYPE_IGNORE_PHYSICALITY | F_DYNAMIC_TYPE_UNREAD; gBattlescriptCurrInstr++; } @@ -9699,15 +9718,15 @@ static void Cmd_setweatherballtype(void) if (gBattleWeather & B_WEATHER_ANY) gBattleScripting.dmgMultiplier = 2; if (gBattleWeather & B_WEATHER_RAIN) - *(&gBattleStruct->dynamicMoveType) = TYPE_WATER | F_DYNAMIC_TYPE_2; + *(&gBattleStruct->dynamicMoveType) = TYPE_WATER | F_DYNAMIC_TYPE_UNREAD; else if (gBattleWeather & B_WEATHER_SANDSTORM) - *(&gBattleStruct->dynamicMoveType) = TYPE_ROCK | F_DYNAMIC_TYPE_2; + *(&gBattleStruct->dynamicMoveType) = TYPE_ROCK | F_DYNAMIC_TYPE_UNREAD; else if (gBattleWeather & B_WEATHER_SUN) - *(&gBattleStruct->dynamicMoveType) = TYPE_FIRE | F_DYNAMIC_TYPE_2; + *(&gBattleStruct->dynamicMoveType) = TYPE_FIRE | F_DYNAMIC_TYPE_UNREAD; else if (gBattleWeather & B_WEATHER_HAIL) - *(&gBattleStruct->dynamicMoveType) = TYPE_ICE | F_DYNAMIC_TYPE_2; + *(&gBattleStruct->dynamicMoveType) = TYPE_ICE | F_DYNAMIC_TYPE_UNREAD; else - *(&gBattleStruct->dynamicMoveType) = TYPE_NORMAL | F_DYNAMIC_TYPE_2; + *(&gBattleStruct->dynamicMoveType) = TYPE_NORMAL | F_DYNAMIC_TYPE_UNREAD; } gBattlescriptCurrInstr++; diff --git a/src/battle_util.c b/src/battle_util.c index 50c560bccf3c..5a2b6392f09b 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -1448,7 +1448,7 @@ u8 DoBattlerEndTurnEffects(void) { u8 effect = 0; - gHitMarker |= (HITMARKER_GRUDGE | HITMARKER_SKIP_DMG_TRACK); + gHitMarker |= (HITMARKER_GRUDGE | HITMARKER_IGNORE_BIDE); while (gBattleStruct->turnEffectsBattlerId < gBattlersCount && gBattleStruct->turnEffectsTracker <= ENDTURN_BATTLER_COUNT) { gActiveBattler = gBattlerAttacker = gBattlerByTurnOrder[gBattleStruct->turnEffectsBattlerId]; @@ -1761,13 +1761,13 @@ u8 DoBattlerEndTurnEffects(void) return effect; } } - gHitMarker &= ~(HITMARKER_GRUDGE | HITMARKER_SKIP_DMG_TRACK); + gHitMarker &= ~(HITMARKER_GRUDGE | HITMARKER_IGNORE_BIDE); return 0; } bool8 HandleWishPerishSongOnTurnEnd(void) { - gHitMarker |= (HITMARKER_GRUDGE | HITMARKER_SKIP_DMG_TRACK); + gHitMarker |= (HITMARKER_GRUDGE | HITMARKER_IGNORE_BIDE); switch (gBattleStruct->wishPerishSongState) { @@ -1796,7 +1796,7 @@ bool8 HandleWishPerishSongOnTurnEnd(void) gBattlerTarget = gActiveBattler; gBattlerAttacker = gWishFutureKnock.futureSightAttacker[gActiveBattler]; gBattleMoveDamage = gWishFutureKnock.futureSightDmg[gActiveBattler]; - gSpecialStatuses[gBattlerTarget].dmg = 0xFFFF; + gSpecialStatuses[gBattlerTarget].shellBellDmg = IGNORE_SHELL_BELL; BattleScriptExecute(BattleScript_MonTookFutureAttack); if (gWishFutureKnock.futureSightCounter[gActiveBattler] == 0 @@ -1867,7 +1867,7 @@ bool8 HandleWishPerishSongOnTurnEnd(void) break; } - gHitMarker &= ~(HITMARKER_GRUDGE | HITMARKER_SKIP_DMG_TRACK); + gHitMarker &= ~(HITMARKER_GRUDGE | HITMARKER_IGNORE_BIDE); return FALSE; } @@ -2212,11 +2212,11 @@ u8 AtkCanceller_UnableToUseMove(void) { // This is removed in FRLG and Emerald for some reason //gBattleMons[gBattlerAttacker].status2 &= ~STATUS2_MULTIPLETURNS; - if (gTakenDmg[gBattlerAttacker]) + if (gBideDmg[gBattlerAttacker]) { gCurrentMove = MOVE_BIDE; - *bideDmg = gTakenDmg[gBattlerAttacker] * 2; - gBattlerTarget = gTakenDmgByBattler[gBattlerAttacker]; + *bideDmg = gBideDmg[gBattlerAttacker] * 2; + gBattlerTarget = gBideTarget[gBattlerAttacker]; if (gAbsentBattlerFlags & gBitTable[gBattlerTarget]) gBattlerTarget = GetMoveTarget(MOVE_BIDE, MOVE_TARGET_SELECTED + 1); gBattlescriptCurrInstr = BattleScript_BideAttack; @@ -3769,8 +3769,8 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) break; case HOLD_EFFECT_SHELL_BELL: if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) - && gSpecialStatuses[gBattlerTarget].dmg != 0 - && gSpecialStatuses[gBattlerTarget].dmg != 0xFFFF + && gSpecialStatuses[gBattlerTarget].shellBellDmg != 0 + && gSpecialStatuses[gBattlerTarget].shellBellDmg != IGNORE_SHELL_BELL && gBattlerAttacker != gBattlerTarget && gBattleMons[gBattlerAttacker].hp != gBattleMons[gBattlerAttacker].maxHP && gBattleMons[gBattlerAttacker].hp != 0) @@ -3778,10 +3778,10 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) gLastUsedItem = atkItem; gPotentialItemEffectBattler = gBattlerAttacker; gBattleScripting.battler = gBattlerAttacker; - gBattleMoveDamage = (gSpecialStatuses[gBattlerTarget].dmg / atkHoldEffectParam) * -1; + gBattleMoveDamage = (gSpecialStatuses[gBattlerTarget].shellBellDmg / atkHoldEffectParam) * -1; if (gBattleMoveDamage == 0) gBattleMoveDamage = -1; - gSpecialStatuses[gBattlerTarget].dmg = 0; + gSpecialStatuses[gBattlerTarget].shellBellDmg = 0; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_ItemHealHP_Ret; effect++; From 5712777dc23aa9b64e9b246b2b1a946de38fb639 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Fri, 20 Oct 2023 12:57:36 -0400 Subject: [PATCH 36/48] Correct dynamic type flag name --- include/battle.h | 2 +- src/battle_script_commands.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/battle.h b/include/battle.h index f4c5bd997e20..68beaf219fbe 100644 --- a/include/battle.h +++ b/include/battle.h @@ -450,7 +450,7 @@ STATIC_ASSERT(sizeof(((struct BattleStruct *)0)->palaceFlags) * 8 >= MAX_BATTLER #define DYNAMIC_TYPE_MASK ((1 << 6) - 1) #define F_DYNAMIC_TYPE_IGNORE_PHYSICALITY (1 << 6) // If set, the dynamic type's physicality won't be used for certain move effects. -#define F_DYNAMIC_TYPE_UNREAD (1 << 7) // Set for Hidden Power and Weather Ball but never apparently checked. +#define F_DYNAMIC_TYPE_SET (1 << 7) // Set for all dynamic types to distinguish a dynamic type of Normal (0) from no dynamic type. #define GET_MOVE_TYPE(move, typeArg) \ { \ diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index fd87e94e2a0e..96ae0e68a376 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8841,7 +8841,7 @@ static void Cmd_hiddenpowercalc(void) gBattleStruct->dynamicMoveType = ((NUMBER_OF_MON_TYPES - 3) * typeBits) / 63 + 1; if (gBattleStruct->dynamicMoveType >= TYPE_MYSTERY) gBattleStruct->dynamicMoveType++; - gBattleStruct->dynamicMoveType |= F_DYNAMIC_TYPE_IGNORE_PHYSICALITY | F_DYNAMIC_TYPE_UNREAD; + gBattleStruct->dynamicMoveType |= F_DYNAMIC_TYPE_IGNORE_PHYSICALITY | F_DYNAMIC_TYPE_SET; gBattlescriptCurrInstr++; } @@ -9718,15 +9718,15 @@ static void Cmd_setweatherballtype(void) if (gBattleWeather & B_WEATHER_ANY) gBattleScripting.dmgMultiplier = 2; if (gBattleWeather & B_WEATHER_RAIN) - *(&gBattleStruct->dynamicMoveType) = TYPE_WATER | F_DYNAMIC_TYPE_UNREAD; + *(&gBattleStruct->dynamicMoveType) = TYPE_WATER | F_DYNAMIC_TYPE_SET; else if (gBattleWeather & B_WEATHER_SANDSTORM) - *(&gBattleStruct->dynamicMoveType) = TYPE_ROCK | F_DYNAMIC_TYPE_UNREAD; + *(&gBattleStruct->dynamicMoveType) = TYPE_ROCK | F_DYNAMIC_TYPE_SET; else if (gBattleWeather & B_WEATHER_SUN) - *(&gBattleStruct->dynamicMoveType) = TYPE_FIRE | F_DYNAMIC_TYPE_UNREAD; + *(&gBattleStruct->dynamicMoveType) = TYPE_FIRE | F_DYNAMIC_TYPE_SET; else if (gBattleWeather & B_WEATHER_HAIL) - *(&gBattleStruct->dynamicMoveType) = TYPE_ICE | F_DYNAMIC_TYPE_UNREAD; + *(&gBattleStruct->dynamicMoveType) = TYPE_ICE | F_DYNAMIC_TYPE_SET; else - *(&gBattleStruct->dynamicMoveType) = TYPE_NORMAL | F_DYNAMIC_TYPE_UNREAD; + *(&gBattleStruct->dynamicMoveType) = TYPE_NORMAL | F_DYNAMIC_TYPE_SET; } gBattlescriptCurrInstr++; From 333523e5f7b0a8c3c40ffedc8d7234a0eb14eb88 Mon Sep 17 00:00:00 2001 From: kittenchilly Date: Mon, 23 Oct 2023 13:24:38 -0500 Subject: [PATCH 37/48] Remove all leading whitespace --- INSTALL.md | 6 +++--- src/battle_factory.c | 2 +- src/easy_chat.c | 4 ++-- src/event_object_movement.c | 2 +- src/mini_printf.c | 12 ++++++------ src/rom_header_gf.c | 4 ++-- src/trade.c | 2 +- tools/aif2pcm/main.c | 14 +++++++------- tools/gbagfx/font.c | 6 +++--- tools/preproc/c_file.cpp | 4 ++-- tools/preproc/charmap.cpp | 2 +- tools/scaninc/source_file.cpp | 4 ++-- 12 files changed, 31 insertions(+), 31 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index a76d0acc75c2..920e03c71366 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -150,9 +150,9 @@ Note that in msys2, Copy is Ctrl+Insert and Paste is Shift+Insert.
Notes... - > Note 1: While not shown, msys uses forward slashes `/` instead of backwards slashes `\` as the directory separator. - > Note 2: If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "Downloads/My Downloads"`. - > Note 3: Windows path names are case-insensitive so adhering to capitalization isn’t needed. + > Note 1: While not shown, msys uses forward slashes `/` instead of backwards slashes `\` as the directory separator. + > Note 2: If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "Downloads/My Downloads"`. + > Note 3: Windows path names are case-insensitive so adhering to capitalization isn’t needed. > Note 4: If libpng was saved elsewhere, you will need to specify the full path to where libpng was downloaded, e.g. `cd c:/devkitpro/msys2` if it was saved there.
diff --git a/src/battle_factory.c b/src/battle_factory.c index 3606d88e6afc..0f4ed9816d1f 100644 --- a/src/battle_factory.c +++ b/src/battle_factory.c @@ -741,7 +741,7 @@ u8 GetFactoryMonFixedIV(u8 challengeNum, bool8 isLastBattle) u8 ivSet; bool8 useHigherIV = isLastBattle ? TRUE : FALSE; -// The Factory has an out-of-bounds access when generating the rental draft for round 9 (challengeNum==8), +// The Factory has an out-of-bounds access when generating the rental draft for round 9 (challengeNum==8), // or the "elevated" rentals from round 8 (challengeNum+1==8) // This happens to land on a number higher than 31, which is interpreted as "random IVs" #ifdef BUGFIX diff --git a/src/easy_chat.c b/src/easy_chat.c index 93fdafd80bc0..8e93ca310e89 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -230,7 +230,7 @@ enum { PALTAG_TRIANGLE_CURSOR, PALTAG_RECTANGLE_CURSOR, PALTAG_MISC_UI, - PALTAG_RS_INTERVIEW_FRAME, + PALTAG_RS_INTERVIEW_FRAME, }; enum { @@ -240,7 +240,7 @@ enum { GFXTAG_START_SELECT_BUTTONS, GFXTAG_MODE_WINDOW, GFXTAG_RS_INTERVIEW_FRAME, - GFXTAG_BUTTON_WINDOW, + GFXTAG_BUTTON_WINDOW, }; diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 29dcf4d27c6b..a181ea9f2188 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -498,7 +498,7 @@ static const struct SpritePalette sObjectEventSpritePalettes[] = { {gObjectEventPal_RubySapphireBrendan, OBJ_EVENT_PAL_TAG_RS_BRENDAN}, {gObjectEventPal_RubySapphireMay, OBJ_EVENT_PAL_TAG_RS_MAY}, #ifdef BUGFIX - {NULL, OBJ_EVENT_PAL_TAG_NONE}, + {NULL, OBJ_EVENT_PAL_TAG_NONE}, #else {}, // BUG: FindObjectEventPaletteIndexByTag looks for OBJ_EVENT_PAL_TAG_NONE and not 0x0. // If it's looking for a tag that isn't in this table, the game locks in an infinite loop. diff --git a/src/mini_printf.c b/src/mini_printf.c index 69500157c67c..9fb4ecfac9e5 100644 --- a/src/mini_printf.c +++ b/src/mini_printf.c @@ -41,7 +41,7 @@ #ifndef NDEBUG -struct mini_buff +struct mini_buff { char *buffer, *pbuffer; u32 buffer_len; @@ -95,7 +95,7 @@ static s32 _putsAscii(char *s, s32 len, void *buf) s32 i; struct mini_buff *b; - if (!buf) + if (!buf) return len; b = buf; @@ -118,7 +118,7 @@ static s32 _putsEncoded(char *s, s32 len, void *buf) s32 i; struct mini_buff *b; - if (!buf) + if (!buf) return len; b = buf; @@ -159,7 +159,7 @@ static s32 mini_itoa(s32 value, u32 radix, s32 uppercase, bool32 unsig, char *bu } /* This builds the string back to front ... */ - do + do { s32 digit = value % radix; *(pbuffer++) = (digit < 10 ? '0' + digit : (uppercase ? 'A' : 'a') + digit - 10); @@ -243,7 +243,7 @@ s32 mini_vpprintf(void* buf, const char *fmt, va_list va) { len = 1; len = _putsAscii(&ch, len, buf); - } else + } else { char pad_char = ' '; s32 pad_to = 0; @@ -270,7 +270,7 @@ s32 mini_vpprintf(void* buf, const char *fmt, va_list va) ch=*(fmt++); } - switch (ch) + switch (ch) { case 0: goto end; diff --git a/src/rom_header_gf.c b/src/rom_header_gf.c index 465c0cf41098..36ff3401d39a 100644 --- a/src/rom_header_gf.c +++ b/src/rom_header_gf.c @@ -9,8 +9,8 @@ // The purpose of this struct is for outside applications to be // able to access parts of the ROM or its save file, like a public API. // In vanilla, it was used by Colosseum and XD to access pokemon graphics. -// -// If this struct is rearranged in any way, it defeats the purpose of +// +// If this struct is rearranged in any way, it defeats the purpose of // having it at all. Applications like PKHex or streaming HUDs may find // these values useful, so there's some potential benefit to keeping it. // If there's a compilation problem below, just comment out the assignment diff --git a/src/trade.c b/src/trade.c index 037ea4101a39..5728a6ee51fc 100644 --- a/src/trade.c +++ b/src/trade.c @@ -1285,7 +1285,7 @@ static void Leader_HandleCommunication(void) if (sTradeMenu->playerSelectStatus == STATUS_READY && sTradeMenu->partnerSelectStatus == STATUS_READY) { - // Both players have selected a pokemon to trade + // Both players have selected a pokemon to trade sTradeMenu->callbackId = CB_SET_SELECTED_MONS; sTradeMenu->linkData[0] = LINKCMD_SET_MONS_TO_TRADE; sTradeMenu->linkData[1] = sTradeMenu->cursorPosition; diff --git a/tools/aif2pcm/main.c b/tools/aif2pcm/main.c index 720db1acaeb8..0824b92da8c3 100644 --- a/tools/aif2pcm/main.c +++ b/tools/aif2pcm/main.c @@ -238,7 +238,7 @@ void read_aif(struct Bytes *aif, AifData *aif_data) { FATAL_ERROR("More than one MARK Chunk in file!\n"); } - + markers = calloc(num_markers, sizeof(struct Marker)); // Read each marker. @@ -289,7 +289,7 @@ void read_aif(struct Bytes *aif, AifData *aif_data) // Skip NoLooping sustain loop. pos += 4; } - + // Skip release loop, we don't need it. pos += 6; } @@ -303,7 +303,7 @@ void read_aif(struct Bytes *aif, AifData *aif_data) { uint8_t *sample_data = (uint8_t *)malloc(num_samples * sizeof(uint8_t)); memcpy(sample_data, &aif->data[pos], num_samples); - + aif_data->samples8 = sample_data; aif_data->real_num_samples = num_samples; } @@ -316,7 +316,7 @@ void read_aif(struct Bytes *aif, AifData *aif_data) { sample_data_swapped[i] = __builtin_bswap16(sample_data[i]); } - + aif_data->samples16 = sample_data_swapped; aif_data->real_num_samples = num_samples; free(sample_data); @@ -329,12 +329,12 @@ void read_aif(struct Bytes *aif, AifData *aif_data) pos += chunk_size; } } - + if (markers) { // Resolve loop points. struct Marker *cur_marker = markers; - + // Grab loop start point. for (int i = 0; i < num_markers; i++, cur_marker++) { @@ -573,7 +573,7 @@ void aif2pcm(const char *aif_filename, const char *pcm_filename, bool compress) struct Bytes *aif = read_bytearray(aif_filename); AifData aif_data = {0}; read_aif(aif, &aif_data); - + // Convert 16-bit to 8-bit if necessary if (aif_data.sample_size == 16) { diff --git a/tools/gbagfx/font.c b/tools/gbagfx/font.c index 0dd6fbc3ee01..1251b5c6473a 100644 --- a/tools/gbagfx/font.c +++ b/tools/gbagfx/font.c @@ -26,7 +26,7 @@ static void ConvertFromLatinFont(unsigned char *src, unsigned char *dest, unsign unsigned int pixelsX = (column * 16) + ((glyphTile & 1) * 8); for (unsigned int i = 0; i < 8; i++) { - unsigned int pixelsY = (row * 16) + ((glyphTile >> 1) * 8) + i; + unsigned int pixelsY = (row * 16) + ((glyphTile >> 1) * 8) + i; unsigned int destPixelsOffset = (pixelsY * 64) + (pixelsX / 4); dest[destPixelsOffset] = src[srcPixelsOffset + 1]; @@ -75,7 +75,7 @@ static void ConvertFromHalfwidthJapaneseFont(unsigned char *src, unsigned char * for (unsigned int i = 0; i < 8; i++) { unsigned int pixelsY = (row * 16) + (glyphTile * 8) + i; unsigned int destPixelsOffset = (pixelsY * 32) + (pixelsX / 4); - + dest[destPixelsOffset] = src[srcPixelsOffset + 1]; dest[destPixelsOffset + 1] = src[srcPixelsOffset]; @@ -233,7 +233,7 @@ void ReadHalfwidthJapaneseFont(char *path, struct Image *image) FATAL_ERROR("The file size (%d) is not a multiple of %d.\n", fileSize, glyphSize); int numGlyphs = fileSize / glyphSize; - + if (numGlyphs % 16 != 0) FATAL_ERROR("The number of glyphs (%d) is not a multiple of 16.\n", numGlyphs); diff --git a/tools/preproc/c_file.cpp b/tools/preproc/c_file.cpp index 17a08cc9f71d..508c6287313a 100644 --- a/tools/preproc/c_file.cpp +++ b/tools/preproc/c_file.cpp @@ -383,7 +383,7 @@ void CFile::TryConvertIncbin() if (m_buffer[m_pos] == '\\') RaiseError("unexpected escape in path string"); - + m_pos++; } @@ -418,7 +418,7 @@ void CFile::TryConvertIncbin() m_pos++; } - + if (m_buffer[m_pos] != ')') RaiseError("expected ')'"); diff --git a/tools/preproc/charmap.cpp b/tools/preproc/charmap.cpp index a7bedfe26f8e..a0c631026c97 100644 --- a/tools/preproc/charmap.cpp +++ b/tools/preproc/charmap.cpp @@ -119,7 +119,7 @@ Lhs CharmapReader::ReadLhs() break; } } - + if (m_buffer[m_pos] == '\'') { m_pos++; diff --git a/tools/scaninc/source_file.cpp b/tools/scaninc/source_file.cpp index df31282f80a4..9d188eb738c3 100644 --- a/tools/scaninc/source_file.cpp +++ b/tools/scaninc/source_file.cpp @@ -41,7 +41,7 @@ SourceFileType GetFileType(std::string& path) return SourceFileType::Inc; else FATAL_ERROR("Unrecognized extension \"%s\"\n", extension.c_str()); - + // Unreachable return SourceFileType::Cpp; } @@ -84,7 +84,7 @@ SourceFile::SourceFile(std::string path) else incbins.insert(outputPath); } - + new (&m_source_file.asm_wrapper) SourceFile::InnerUnion::AsmWrapper{incbins, includes}; } } From 25d6f8ba74997a8694a7dbf150a86a402934702d Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Thu, 26 Oct 2023 09:25:50 -0300 Subject: [PATCH 38/48] Fix mini_printf encoded string -Werror=pointer-sign warning --- src/mini_printf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mini_printf.c b/src/mini_printf.c index 69500157c67c..65b350e08b7b 100644 --- a/src/mini_printf.c +++ b/src/mini_printf.c @@ -328,7 +328,7 @@ s32 mini_vpprintf(void* buf, const char *fmt, va_list va) break; case 'S' : // preproc encoded string handler ptr = va_arg(va, char*); - len = StringLength(ptr); + len = StringLength((u8*)ptr); if (pad_to > 0) { len = mini_pad(ptr, len, pad_char, pad_to, bf); From f472d768ddddb46cfcf94e5b1efd7d840bef37e0 Mon Sep 17 00:00:00 2001 From: Bassoonian Date: Sat, 28 Oct 2023 16:32:55 +0200 Subject: [PATCH 39/48] Rename Undiscovered to No Eggs Discovered --- include/constants/pokemon.h | 36 ++++++++--------- src/data/pokemon/species_info.h | 70 ++++++++++++++++----------------- src/daycare.c | 2 +- 3 files changed, 54 insertions(+), 54 deletions(-) diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index e515378d4c23..6265c027aa5b 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -24,24 +24,24 @@ #define NUMBER_OF_MON_TYPES 18 // Pokemon egg groups -#define EGG_GROUP_NONE 0 -#define EGG_GROUP_MONSTER 1 -#define EGG_GROUP_WATER_1 2 -#define EGG_GROUP_BUG 3 -#define EGG_GROUP_FLYING 4 -#define EGG_GROUP_FIELD 5 -#define EGG_GROUP_FAIRY 6 -#define EGG_GROUP_GRASS 7 -#define EGG_GROUP_HUMAN_LIKE 8 -#define EGG_GROUP_WATER_3 9 -#define EGG_GROUP_MINERAL 10 -#define EGG_GROUP_AMORPHOUS 11 -#define EGG_GROUP_WATER_2 12 -#define EGG_GROUP_DITTO 13 -#define EGG_GROUP_DRAGON 14 -#define EGG_GROUP_UNDISCOVERED 15 - -#define EGG_GROUPS_PER_MON 2 +#define EGG_GROUP_NONE 0 +#define EGG_GROUP_MONSTER 1 +#define EGG_GROUP_WATER_1 2 +#define EGG_GROUP_BUG 3 +#define EGG_GROUP_FLYING 4 +#define EGG_GROUP_FIELD 5 +#define EGG_GROUP_FAIRY 6 +#define EGG_GROUP_GRASS 7 +#define EGG_GROUP_HUMAN_LIKE 8 +#define EGG_GROUP_WATER_3 9 +#define EGG_GROUP_MINERAL 10 +#define EGG_GROUP_AMORPHOUS 11 +#define EGG_GROUP_WATER_2 12 +#define EGG_GROUP_DITTO 13 +#define EGG_GROUP_DRAGON 14 +#define EGG_GROUP_NO_EGGS_DISCOVERED 15 + +#define EGG_GROUPS_PER_MON 2 // Pokemon natures #define NATURE_HARDY 0 diff --git a/src/data/pokemon/species_info.h b/src/data/pokemon/species_info.h index 2ef0629b52e0..afd671a4c0bf 100644 --- a/src/data/pokemon/species_info.h +++ b/src/data/pokemon/species_info.h @@ -25,7 +25,7 @@ .eggCycles = 120, \ .friendship = 0, \ .growthRate = GROWTH_MEDIUM_FAST, \ - .eggGroups = { EGG_GROUP_UNDISCOVERED, EGG_GROUP_UNDISCOVERED, }, \ + .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED, }, \ .abilities = {ABILITY_NONE, ABILITY_NONE}, \ .safariZoneFleeRate = 0, \ .bodyColor = BODY_COLOR_BLACK, \ @@ -929,7 +929,7 @@ const struct SpeciesInfo gSpeciesInfo[] = .eggCycles = 20, .friendship = STANDARD_FRIENDSHIP, .growthRate = GROWTH_MEDIUM_SLOW, - .eggGroups = { EGG_GROUP_UNDISCOVERED, EGG_GROUP_UNDISCOVERED }, + .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED }, .abilities = {ABILITY_POISON_POINT, ABILITY_NONE}, .safariZoneFleeRate = 0, .bodyColor = BODY_COLOR_BLUE, @@ -959,7 +959,7 @@ const struct SpeciesInfo gSpeciesInfo[] = .eggCycles = 20, .friendship = STANDARD_FRIENDSHIP, .growthRate = GROWTH_MEDIUM_SLOW, - .eggGroups = { EGG_GROUP_UNDISCOVERED, EGG_GROUP_UNDISCOVERED }, + .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED }, .abilities = {ABILITY_POISON_POINT, ABILITY_NONE}, .safariZoneFleeRate = 0, .bodyColor = BODY_COLOR_BLUE, @@ -4349,7 +4349,7 @@ const struct SpeciesInfo gSpeciesInfo[] = .eggCycles = 80, .friendship = 35, .growthRate = GROWTH_SLOW, - .eggGroups = { EGG_GROUP_UNDISCOVERED, EGG_GROUP_UNDISCOVERED }, + .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED }, .abilities = {ABILITY_PRESSURE, ABILITY_NONE}, .safariZoneFleeRate = 0, .bodyColor = BODY_COLOR_BLUE, @@ -4379,7 +4379,7 @@ const struct SpeciesInfo gSpeciesInfo[] = .eggCycles = 80, .friendship = 35, .growthRate = GROWTH_SLOW, - .eggGroups = { EGG_GROUP_UNDISCOVERED, EGG_GROUP_UNDISCOVERED }, + .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED }, .abilities = {ABILITY_PRESSURE, ABILITY_NONE}, .safariZoneFleeRate = 0, .bodyColor = BODY_COLOR_YELLOW, @@ -4409,7 +4409,7 @@ const struct SpeciesInfo gSpeciesInfo[] = .eggCycles = 80, .friendship = 35, .growthRate = GROWTH_SLOW, - .eggGroups = { EGG_GROUP_UNDISCOVERED, EGG_GROUP_UNDISCOVERED }, + .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED }, .abilities = {ABILITY_PRESSURE, ABILITY_NONE}, .safariZoneFleeRate = 0, .bodyColor = BODY_COLOR_YELLOW, @@ -4529,7 +4529,7 @@ const struct SpeciesInfo gSpeciesInfo[] = .eggCycles = 120, .friendship = 0, .growthRate = GROWTH_SLOW, - .eggGroups = { EGG_GROUP_UNDISCOVERED, EGG_GROUP_UNDISCOVERED }, + .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED }, .abilities = {ABILITY_PRESSURE, ABILITY_NONE}, .safariZoneFleeRate = 0, .bodyColor = BODY_COLOR_PURPLE, @@ -4559,7 +4559,7 @@ const struct SpeciesInfo gSpeciesInfo[] = .eggCycles = 120, .friendship = 100, .growthRate = GROWTH_MEDIUM_SLOW, - .eggGroups = { EGG_GROUP_UNDISCOVERED, EGG_GROUP_UNDISCOVERED }, + .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED }, .abilities = {ABILITY_SYNCHRONIZE, ABILITY_NONE}, .safariZoneFleeRate = 0, .bodyColor = BODY_COLOR_PINK, @@ -5189,7 +5189,7 @@ const struct SpeciesInfo gSpeciesInfo[] = .eggCycles = 10, .friendship = STANDARD_FRIENDSHIP, .growthRate = GROWTH_MEDIUM_FAST, - .eggGroups = { EGG_GROUP_UNDISCOVERED, EGG_GROUP_UNDISCOVERED }, + .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED }, .abilities = {ABILITY_STATIC, ABILITY_NONE}, .safariZoneFleeRate = 0, .bodyColor = BODY_COLOR_YELLOW, @@ -5219,7 +5219,7 @@ const struct SpeciesInfo gSpeciesInfo[] = .eggCycles = 10, .friendship = 140, .growthRate = GROWTH_FAST, - .eggGroups = { EGG_GROUP_UNDISCOVERED, EGG_GROUP_UNDISCOVERED }, + .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED }, .abilities = {ABILITY_CUTE_CHARM, ABILITY_NONE}, .safariZoneFleeRate = 0, .bodyColor = BODY_COLOR_PINK, @@ -5249,7 +5249,7 @@ const struct SpeciesInfo gSpeciesInfo[] = .eggCycles = 10, .friendship = STANDARD_FRIENDSHIP, .growthRate = GROWTH_FAST, - .eggGroups = { EGG_GROUP_UNDISCOVERED, EGG_GROUP_UNDISCOVERED }, + .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED }, .abilities = {ABILITY_CUTE_CHARM, ABILITY_NONE}, .safariZoneFleeRate = 0, .bodyColor = BODY_COLOR_PINK, @@ -5279,7 +5279,7 @@ const struct SpeciesInfo gSpeciesInfo[] = .eggCycles = 10, .friendship = STANDARD_FRIENDSHIP, .growthRate = GROWTH_FAST, - .eggGroups = { EGG_GROUP_UNDISCOVERED, EGG_GROUP_UNDISCOVERED }, + .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED }, .abilities = {ABILITY_HUSTLE, ABILITY_SERENE_GRACE}, .safariZoneFleeRate = 0, .bodyColor = BODY_COLOR_WHITE, @@ -6059,7 +6059,7 @@ const struct SpeciesInfo gSpeciesInfo[] = .eggCycles = 40, .friendship = STANDARD_FRIENDSHIP, .growthRate = GROWTH_MEDIUM_FAST, - .eggGroups = { EGG_GROUP_UNDISCOVERED, EGG_GROUP_UNDISCOVERED }, + .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED }, .abilities = {ABILITY_LEVITATE, ABILITY_NONE}, .safariZoneFleeRate = 0, .bodyColor = BODY_COLOR_BLACK, @@ -7109,7 +7109,7 @@ const struct SpeciesInfo gSpeciesInfo[] = .eggCycles = 25, .friendship = STANDARD_FRIENDSHIP, .growthRate = GROWTH_MEDIUM_FAST, - .eggGroups = { EGG_GROUP_UNDISCOVERED, EGG_GROUP_UNDISCOVERED }, + .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED }, .abilities = {ABILITY_GUTS, ABILITY_NONE}, .safariZoneFleeRate = 0, .bodyColor = BODY_COLOR_PURPLE, @@ -7169,7 +7169,7 @@ const struct SpeciesInfo gSpeciesInfo[] = .eggCycles = 25, .friendship = STANDARD_FRIENDSHIP, .growthRate = GROWTH_MEDIUM_FAST, - .eggGroups = { EGG_GROUP_UNDISCOVERED, EGG_GROUP_UNDISCOVERED }, + .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED }, .abilities = {ABILITY_OBLIVIOUS, ABILITY_NONE}, .safariZoneFleeRate = 0, .bodyColor = BODY_COLOR_PINK, @@ -7199,7 +7199,7 @@ const struct SpeciesInfo gSpeciesInfo[] = .eggCycles = 25, .friendship = STANDARD_FRIENDSHIP, .growthRate = GROWTH_MEDIUM_FAST, - .eggGroups = { EGG_GROUP_UNDISCOVERED, EGG_GROUP_UNDISCOVERED }, + .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED }, .abilities = {ABILITY_STATIC, ABILITY_NONE}, .safariZoneFleeRate = 0, .bodyColor = BODY_COLOR_YELLOW, @@ -7229,7 +7229,7 @@ const struct SpeciesInfo gSpeciesInfo[] = .eggCycles = 25, .friendship = STANDARD_FRIENDSHIP, .growthRate = GROWTH_MEDIUM_FAST, - .eggGroups = { EGG_GROUP_UNDISCOVERED, EGG_GROUP_UNDISCOVERED }, + .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED }, .abilities = {ABILITY_FLAME_BODY, ABILITY_NONE}, .safariZoneFleeRate = 0, .bodyColor = BODY_COLOR_RED, @@ -7319,7 +7319,7 @@ const struct SpeciesInfo gSpeciesInfo[] = .eggCycles = 80, .friendship = 35, .growthRate = GROWTH_SLOW, - .eggGroups = { EGG_GROUP_UNDISCOVERED, EGG_GROUP_UNDISCOVERED }, + .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED }, .abilities = {ABILITY_PRESSURE, ABILITY_NONE}, .safariZoneFleeRate = 0, .bodyColor = BODY_COLOR_YELLOW, @@ -7349,7 +7349,7 @@ const struct SpeciesInfo gSpeciesInfo[] = .eggCycles = 80, .friendship = 35, .growthRate = GROWTH_SLOW, - .eggGroups = { EGG_GROUP_UNDISCOVERED, EGG_GROUP_UNDISCOVERED }, + .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED }, .abilities = {ABILITY_PRESSURE, ABILITY_NONE}, .safariZoneFleeRate = 0, .bodyColor = BODY_COLOR_BROWN, @@ -7379,7 +7379,7 @@ const struct SpeciesInfo gSpeciesInfo[] = .eggCycles = 80, .friendship = 35, .growthRate = GROWTH_SLOW, - .eggGroups = { EGG_GROUP_UNDISCOVERED, EGG_GROUP_UNDISCOVERED }, + .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED }, .abilities = {ABILITY_PRESSURE, ABILITY_NONE}, .safariZoneFleeRate = 0, .bodyColor = BODY_COLOR_BLUE, @@ -7499,7 +7499,7 @@ const struct SpeciesInfo gSpeciesInfo[] = .eggCycles = 120, .friendship = 0, .growthRate = GROWTH_SLOW, - .eggGroups = { EGG_GROUP_UNDISCOVERED, EGG_GROUP_UNDISCOVERED }, + .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED }, .abilities = {ABILITY_PRESSURE, ABILITY_NONE}, .safariZoneFleeRate = 0, .bodyColor = BODY_COLOR_WHITE, @@ -7529,7 +7529,7 @@ const struct SpeciesInfo gSpeciesInfo[] = .eggCycles = 120, .friendship = 0, .growthRate = GROWTH_SLOW, - .eggGroups = { EGG_GROUP_UNDISCOVERED, EGG_GROUP_UNDISCOVERED }, + .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED }, .abilities = {ABILITY_PRESSURE, ABILITY_NONE}, .safariZoneFleeRate = 0, .bodyColor = BODY_COLOR_RED, @@ -7559,7 +7559,7 @@ const struct SpeciesInfo gSpeciesInfo[] = .eggCycles = 120, .friendship = 100, .growthRate = GROWTH_MEDIUM_SLOW, - .eggGroups = { EGG_GROUP_UNDISCOVERED, EGG_GROUP_UNDISCOVERED }, + .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED }, .abilities = {ABILITY_NATURAL_CURE, ABILITY_NONE}, .safariZoneFleeRate = 0, .bodyColor = BODY_COLOR_GREEN, @@ -9829,7 +9829,7 @@ const struct SpeciesInfo gSpeciesInfo[] = .eggCycles = 10, .friendship = STANDARD_FRIENDSHIP, .growthRate = GROWTH_FAST, - .eggGroups = { EGG_GROUP_UNDISCOVERED, EGG_GROUP_UNDISCOVERED }, + .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED }, .abilities = {ABILITY_THICK_FAT, ABILITY_HUGE_POWER}, .safariZoneFleeRate = 0, .bodyColor = BODY_COLOR_BLUE, @@ -10129,7 +10129,7 @@ const struct SpeciesInfo gSpeciesInfo[] = .eggCycles = 20, .friendship = STANDARD_FRIENDSHIP, .growthRate = GROWTH_MEDIUM_FAST, - .eggGroups = { EGG_GROUP_UNDISCOVERED, EGG_GROUP_UNDISCOVERED }, + .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED }, .abilities = {ABILITY_SHADOW_TAG, ABILITY_NONE}, .safariZoneFleeRate = 0, .bodyColor = BODY_COLOR_BLUE, @@ -11359,7 +11359,7 @@ const struct SpeciesInfo gSpeciesInfo[] = .eggCycles = 80, .friendship = 35, .growthRate = GROWTH_SLOW, - .eggGroups = { EGG_GROUP_UNDISCOVERED, EGG_GROUP_UNDISCOVERED }, + .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED }, .abilities = {ABILITY_CLEAR_BODY, ABILITY_NONE}, .safariZoneFleeRate = 0, .bodyColor = BODY_COLOR_BROWN, @@ -11389,7 +11389,7 @@ const struct SpeciesInfo gSpeciesInfo[] = .eggCycles = 80, .friendship = 35, .growthRate = GROWTH_SLOW, - .eggGroups = { EGG_GROUP_UNDISCOVERED, EGG_GROUP_UNDISCOVERED }, + .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED }, .abilities = {ABILITY_CLEAR_BODY, ABILITY_NONE}, .safariZoneFleeRate = 0, .bodyColor = BODY_COLOR_BLUE, @@ -11419,7 +11419,7 @@ const struct SpeciesInfo gSpeciesInfo[] = .eggCycles = 80, .friendship = 35, .growthRate = GROWTH_SLOW, - .eggGroups = { EGG_GROUP_UNDISCOVERED, EGG_GROUP_UNDISCOVERED }, + .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED }, .abilities = {ABILITY_CLEAR_BODY, ABILITY_NONE}, .safariZoneFleeRate = 0, .bodyColor = BODY_COLOR_GRAY, @@ -11449,7 +11449,7 @@ const struct SpeciesInfo gSpeciesInfo[] = .eggCycles = 120, .friendship = 0, .growthRate = GROWTH_SLOW, - .eggGroups = { EGG_GROUP_UNDISCOVERED, EGG_GROUP_UNDISCOVERED }, + .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED }, .abilities = {ABILITY_DRIZZLE, ABILITY_NONE}, .safariZoneFleeRate = 0, .bodyColor = BODY_COLOR_BLUE, @@ -11479,7 +11479,7 @@ const struct SpeciesInfo gSpeciesInfo[] = .eggCycles = 120, .friendship = 0, .growthRate = GROWTH_SLOW, - .eggGroups = { EGG_GROUP_UNDISCOVERED, EGG_GROUP_UNDISCOVERED }, + .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED }, .abilities = {ABILITY_DROUGHT, ABILITY_NONE}, .safariZoneFleeRate = 0, .bodyColor = BODY_COLOR_RED, @@ -11509,7 +11509,7 @@ const struct SpeciesInfo gSpeciesInfo[] = .eggCycles = 120, .friendship = 0, .growthRate = GROWTH_SLOW, - .eggGroups = { EGG_GROUP_UNDISCOVERED, EGG_GROUP_UNDISCOVERED }, + .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED }, .abilities = {ABILITY_AIR_LOCK, ABILITY_NONE}, .safariZoneFleeRate = 0, .bodyColor = BODY_COLOR_GREEN, @@ -11539,7 +11539,7 @@ const struct SpeciesInfo gSpeciesInfo[] = .eggCycles = 120, .friendship = 90, .growthRate = GROWTH_SLOW, - .eggGroups = { EGG_GROUP_UNDISCOVERED, EGG_GROUP_UNDISCOVERED }, + .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED }, .abilities = {ABILITY_LEVITATE, ABILITY_NONE}, .safariZoneFleeRate = 0, .bodyColor = BODY_COLOR_RED, @@ -11569,7 +11569,7 @@ const struct SpeciesInfo gSpeciesInfo[] = .eggCycles = 120, .friendship = 90, .growthRate = GROWTH_SLOW, - .eggGroups = { EGG_GROUP_UNDISCOVERED, EGG_GROUP_UNDISCOVERED }, + .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED }, .abilities = {ABILITY_LEVITATE, ABILITY_NONE}, .safariZoneFleeRate = 0, .bodyColor = BODY_COLOR_BLUE, @@ -11599,7 +11599,7 @@ const struct SpeciesInfo gSpeciesInfo[] = .eggCycles = 120, .friendship = 100, .growthRate = GROWTH_SLOW, - .eggGroups = { EGG_GROUP_UNDISCOVERED, EGG_GROUP_UNDISCOVERED }, + .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED }, .abilities = {ABILITY_SERENE_GRACE, ABILITY_NONE}, .safariZoneFleeRate = 0, .bodyColor = BODY_COLOR_YELLOW, @@ -11629,7 +11629,7 @@ const struct SpeciesInfo gSpeciesInfo[] = .eggCycles = 120, .friendship = 0, .growthRate = GROWTH_SLOW, - .eggGroups = { EGG_GROUP_UNDISCOVERED, EGG_GROUP_UNDISCOVERED }, + .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED }, .abilities = {ABILITY_PRESSURE, ABILITY_NONE}, .safariZoneFleeRate = 0, .bodyColor = BODY_COLOR_RED, diff --git a/src/daycare.c b/src/daycare.c index d618db78ec2b..d62bd589d0d9 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -1033,7 +1033,7 @@ static u8 GetDaycareCompatibilityScore(struct DayCare *daycare) } // check unbreedable egg group - if (eggGroups[0][0] == EGG_GROUP_UNDISCOVERED || eggGroups[1][0] == EGG_GROUP_UNDISCOVERED) + if (eggGroups[0][0] == EGG_GROUP_NO_EGGS_DISCOVERED || eggGroups[1][0] == EGG_GROUP_NO_EGGS_DISCOVERED) return PARENTS_INCOMPATIBLE; // two Ditto can't breed if (eggGroups[0][0] == EGG_GROUP_DITTO && eggGroups[1][0] == EGG_GROUP_DITTO) From cd9ef3a5662a1d6800e44ff09b5e1f059a27add7 Mon Sep 17 00:00:00 2001 From: Bassoonian Date: Sat, 28 Oct 2023 16:34:11 +0200 Subject: [PATCH 40/48] Formatting fix --- src/data/pokemon/species_info.h | 54 ++++++++++++++++----------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/data/pokemon/species_info.h b/src/data/pokemon/species_info.h index afd671a4c0bf..fbd3bcba2a20 100644 --- a/src/data/pokemon/species_info.h +++ b/src/data/pokemon/species_info.h @@ -2,34 +2,34 @@ // 255 (MON_GENDERLESS) is reserved for genderless Pokémon. #define PERCENT_FEMALE(percent) min(254, ((percent * 255) / 100)) -#define OLD_UNOWN_SPECIES_INFO \ - { \ - .baseHP = 50, \ - .baseAttack = 150, \ - .baseDefense = 50, \ - .baseSpeed = 150, \ - .baseSpAttack = 150, \ - .baseSpDefense = 50, \ - .types = { TYPE_NORMAL, TYPE_NORMAL}, \ - .catchRate = 3, \ - .expYield = 1, \ - .evYield_HP = 2, \ - .evYield_Attack = 2, \ - .evYield_Defense = 2, \ - .evYield_Speed = 2, \ - .evYield_SpAttack = 2, \ - .evYield_SpDefense = 2, \ - .itemCommon = ITEM_NONE, \ - .itemRare = ITEM_NONE, \ - .genderRatio = MON_GENDERLESS, \ - .eggCycles = 120, \ - .friendship = 0, \ - .growthRate = GROWTH_MEDIUM_FAST, \ +#define OLD_UNOWN_SPECIES_INFO \ + { \ + .baseHP = 50, \ + .baseAttack = 150, \ + .baseDefense = 50, \ + .baseSpeed = 150, \ + .baseSpAttack = 150, \ + .baseSpDefense = 50, \ + .types = { TYPE_NORMAL, TYPE_NORMAL}, \ + .catchRate = 3, \ + .expYield = 1, \ + .evYield_HP = 2, \ + .evYield_Attack = 2, \ + .evYield_Defense = 2, \ + .evYield_Speed = 2, \ + .evYield_SpAttack = 2, \ + .evYield_SpDefense = 2, \ + .itemCommon = ITEM_NONE, \ + .itemRare = ITEM_NONE, \ + .genderRatio = MON_GENDERLESS, \ + .eggCycles = 120, \ + .friendship = 0, \ + .growthRate = GROWTH_MEDIUM_FAST, \ .eggGroups = { EGG_GROUP_NO_EGGS_DISCOVERED, EGG_GROUP_NO_EGGS_DISCOVERED, }, \ - .abilities = {ABILITY_NONE, ABILITY_NONE}, \ - .safariZoneFleeRate = 0, \ - .bodyColor = BODY_COLOR_BLACK, \ - .noFlip = FALSE, \ + .abilities = {ABILITY_NONE, ABILITY_NONE}, \ + .safariZoneFleeRate = 0, \ + .bodyColor = BODY_COLOR_BLACK, \ + .noFlip = FALSE, \ } const struct SpeciesInfo gSpeciesInfo[] = From d44b2a972d2b9fd1da64dacc4fd2b2224fb294a4 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Tue, 31 Oct 2023 04:36:46 -0300 Subject: [PATCH 41/48] =?UTF-8?q?Renamed=20SendMonToPC=20to=20CopyMonToPC?= =?UTF-8?q?=20instead=20"SendMonToPC"=20implies=20that=20the=20Pok=C3=A9mo?= =?UTF-8?q?n=20affected=20is=20actually=20sent=20over=20to=20the=20PC,=20b?= =?UTF-8?q?ut=20in=20reality=20the=20function=20simply=20copies=20the=20da?= =?UTF-8?q?ta=20of=20the=20Pok=C3=A9mon=20and=20then=20pastes=20it=20in=20?= =?UTF-8?q?the=20first=20available=20slot=20of=20the=20Pok=C3=A9mon=20Stor?= =?UTF-8?q?age=20System.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pokemon.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pokemon.c b/src/pokemon.c index 3925d77fe3a9..d3a570e72fcc 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -70,7 +70,7 @@ static void Task_PlayMapChosenOrBattleBGM(u8 taskId); static bool8 ShouldGetStatBadgeBoost(u16 flagId, u8 battlerId); static u16 GiveMoveToBoxMon(struct BoxPokemon *boxMon, u16 move); static bool8 ShouldSkipFriendshipChange(void); -static u8 SendMonToPC(struct Pokemon *mon); +static u8 CopyMonToPC(struct Pokemon *mon); EWRAM_DATA static u8 sLearningMoveTableID = 0; EWRAM_DATA u8 gPlayerPartyCount = 0; @@ -4405,14 +4405,14 @@ u8 GiveMonToPlayer(struct Pokemon *mon) } if (i >= PARTY_SIZE) - return SendMonToPC(mon); + return CopyMonToPC(mon); CopyMon(&gPlayerParty[i], mon, sizeof(*mon)); gPlayerPartyCount = i + 1; return MON_GIVEN_TO_PARTY; } -static u8 SendMonToPC(struct Pokemon *mon) +static u8 CopyMonToPC(struct Pokemon *mon) { s32 boxNo, boxPos; From 3122d744f535194e4e9747a6c0be8e457764f98b Mon Sep 17 00:00:00 2001 From: kaboissonneault Date: Thu, 2 Nov 2023 09:48:13 -0400 Subject: [PATCH 42/48] Added BUGFIX for "dual non-immunity" glitch. In certain AI script commands, the call to TypeCalc does not assign effectiveness flags properly, resulting in the check for immunity always failing --- src/battle_ai_script_commands.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c index 9a63031dd2bd..8bb76705ec44 100644 --- a/src/battle_ai_script_commands.c +++ b/src/battle_ai_script_commands.c @@ -1484,7 +1484,13 @@ static void Cmd_get_highest_type_effectiveness(void) if (gCurrentMove != MOVE_NONE) { + // TypeCalc does not assign to gMoveResultFlags, Cmd_TypeCalc does + // This makes the check for gMoveResultFlags below always fail +#ifdef BUGFIX + gMoveResultFlags = TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget); +#else TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget); +#endif if (gBattleMoveDamage == 120) // Super effective STAB. gBattleMoveDamage = AI_EFFECTIVENESS_x2; @@ -1519,7 +1525,16 @@ static void Cmd_if_type_effectiveness(void) gBattleMoveDamage = AI_EFFECTIVENESS_x1; gCurrentMove = AI_THINKING_STRUCT->moveConsidered; + // TypeCalc does not assign to gMoveResultFlags, Cmd_TypeCalc does + // This makes the check for gMoveResultFlags below always fail + // This is how you get the "dual non-immunity" glitch, where AI + // will use ineffective moves on immune pokémon if the second type + // has a non-neutral, non-immune effectiveness +#ifdef BUGFIX + gMoveResultFlags = TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget); +#else TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget); +#endif if (gBattleMoveDamage == 120) // Super effective STAB. gBattleMoveDamage = AI_EFFECTIVENESS_x2; From 5ddf3e2ee514cfd9250e68772c8a19ee2e8fb21d Mon Sep 17 00:00:00 2001 From: kaboissonneault Date: Thu, 2 Nov 2023 11:17:57 -0400 Subject: [PATCH 43/48] Fixed casing in comment on "dual non-immunity" glitch --- src/battle_ai_script_commands.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c index 8bb76705ec44..d8a9760ff209 100644 --- a/src/battle_ai_script_commands.c +++ b/src/battle_ai_script_commands.c @@ -1484,7 +1484,7 @@ static void Cmd_get_highest_type_effectiveness(void) if (gCurrentMove != MOVE_NONE) { - // TypeCalc does not assign to gMoveResultFlags, Cmd_TypeCalc does + // TypeCalc does not assign to gMoveResultFlags, Cmd_typecalc does // This makes the check for gMoveResultFlags below always fail #ifdef BUGFIX gMoveResultFlags = TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget); @@ -1525,7 +1525,7 @@ static void Cmd_if_type_effectiveness(void) gBattleMoveDamage = AI_EFFECTIVENESS_x1; gCurrentMove = AI_THINKING_STRUCT->moveConsidered; - // TypeCalc does not assign to gMoveResultFlags, Cmd_TypeCalc does + // TypeCalc does not assign to gMoveResultFlags, Cmd_typecalc does // This makes the check for gMoveResultFlags below always fail // This is how you get the "dual non-immunity" glitch, where AI // will use ineffective moves on immune pokémon if the second type From a093e402d554816595d606eb8a575a0f701a69fd Mon Sep 17 00:00:00 2001 From: quocmanh94 Date: Fri, 3 Nov 2023 12:50:47 +0700 Subject: [PATCH 44/48] Delete the redundant files generated after running build --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 7476a9dc312d..5c073b36ca18 100644 --- a/Makefile +++ b/Makefile @@ -236,8 +236,7 @@ clean-tools: @$(foreach tooldir,$(TOOLDIRS),$(MAKE) clean -C $(tooldir);) mostlyclean: tidynonmodern tidymodern - rm -f $(SAMPLE_SUBDIR)/*.bin - rm -f $(CRY_SUBDIR)/*.bin + find sound -iname '*.bin' -exec rm {} + rm -f $(MID_SUBDIR)/*.s find . \( -iname '*.1bpp' -o -iname '*.4bpp' -o -iname '*.8bpp' -o -iname '*.gbapal' -o -iname '*.lz' -o -iname '*.rl' -o -iname '*.latfont' -o -iname '*.hwjpnfont' -o -iname '*.fwjpnfont' \) -exec rm {} + rm -f $(DATA_ASM_SUBDIR)/layouts/layouts.inc $(DATA_ASM_SUBDIR)/layouts/layouts_table.inc From 81f397360e391507534b154e4f976c2b99c09731 Mon Sep 17 00:00:00 2001 From: Icedude907 <34080011+Icedude907@users.noreply.github.com> Date: Sun, 12 Nov 2023 14:28:11 +1300 Subject: [PATCH 45/48] Moved files - spinda spots, jp fonts, redyellowgreen_frame.bin --- ..._female_font.png => japanese_frlg_female.png} | Bin ...frlg_male_font.png => japanese_frlg_male.png} | Bin .../spinda/spots}/spot_0.png | Bin .../spinda/spots}/spot_1.png | Bin .../spinda/spots}/spot_2.png | Bin .../spinda/spots}/spot_3.png | Bin graphics/unused/.gitignore | 1 + graphics/unused/redyellowgreen_frame.bin | Bin 8192 -> 0 bytes graphics_file_rules.mk | 6 +++--- src/pokemon.c | 8 ++++---- 10 files changed, 8 insertions(+), 7 deletions(-) rename graphics/fonts/{japanese_frlg_female_font.png => japanese_frlg_female.png} (100%) rename graphics/fonts/{japanese_frlg_male_font.png => japanese_frlg_male.png} (100%) rename graphics/{spinda_spots => pokemon/spinda/spots}/spot_0.png (100%) rename graphics/{spinda_spots => pokemon/spinda/spots}/spot_1.png (100%) rename graphics/{spinda_spots => pokemon/spinda/spots}/spot_2.png (100%) rename graphics/{spinda_spots => pokemon/spinda/spots}/spot_3.png (100%) create mode 100644 graphics/unused/.gitignore delete mode 100644 graphics/unused/redyellowgreen_frame.bin diff --git a/graphics/fonts/japanese_frlg_female_font.png b/graphics/fonts/japanese_frlg_female.png similarity index 100% rename from graphics/fonts/japanese_frlg_female_font.png rename to graphics/fonts/japanese_frlg_female.png diff --git a/graphics/fonts/japanese_frlg_male_font.png b/graphics/fonts/japanese_frlg_male.png similarity index 100% rename from graphics/fonts/japanese_frlg_male_font.png rename to graphics/fonts/japanese_frlg_male.png diff --git a/graphics/spinda_spots/spot_0.png b/graphics/pokemon/spinda/spots/spot_0.png similarity index 100% rename from graphics/spinda_spots/spot_0.png rename to graphics/pokemon/spinda/spots/spot_0.png diff --git a/graphics/spinda_spots/spot_1.png b/graphics/pokemon/spinda/spots/spot_1.png similarity index 100% rename from graphics/spinda_spots/spot_1.png rename to graphics/pokemon/spinda/spots/spot_1.png diff --git a/graphics/spinda_spots/spot_2.png b/graphics/pokemon/spinda/spots/spot_2.png similarity index 100% rename from graphics/spinda_spots/spot_2.png rename to graphics/pokemon/spinda/spots/spot_2.png diff --git a/graphics/spinda_spots/spot_3.png b/graphics/pokemon/spinda/spots/spot_3.png similarity index 100% rename from graphics/spinda_spots/spot_3.png rename to graphics/pokemon/spinda/spots/spot_3.png diff --git a/graphics/unused/.gitignore b/graphics/unused/.gitignore new file mode 100644 index 000000000000..b929a6cae784 --- /dev/null +++ b/graphics/unused/.gitignore @@ -0,0 +1 @@ +redyellowgreen_frame.bin \ No newline at end of file diff --git a/graphics/unused/redyellowgreen_frame.bin b/graphics/unused/redyellowgreen_frame.bin deleted file mode 100644 index 6852998fb85d057fa16a892b867f0343b6764ec7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8192 zcmeI!+X{m)5CqV9D7fD5|NpC{Hc%{3u4D}*?zg_@9F)gu3!3ct5E`l3oKZj+Ni*e z*{PlGf6B{`3;g%`S!{J`qyJBO|M=|B;PapAPd{#Ilz;>zAOQ(TKmrnwz)c0-iL^Nf diff --git a/graphics_file_rules.mk b/graphics_file_rules.mk index 090620ebe895..92cc3338dc7d 100644 --- a/graphics_file_rules.mk +++ b/graphics_file_rules.mk @@ -21,7 +21,7 @@ JPCONTESTGFXDIR := graphics/contest/japanese POKEDEXGFXDIR := graphics/pokedex STARTERGFXDIR := graphics/starter_choose NAMINGGFXDIR := graphics/naming_screen -SPINDAGFXDIR := graphics/spinda_spots +SPINDAGFXDIR := graphics/pokemon/spinda/spots types := normal fight flying poison ground rock bug ghost steel mystery fire water grass electric psychic ice dragon dark contest_types := cool beauty cute smart tough @@ -290,10 +290,10 @@ $(FONTGFXDIR)/short.fwjpnfont: $(FONTGFXDIR)/japanese_short.png $(FONTGFXDIR)/braille.fwjpnfont: $(FONTGFXDIR)/braille.png $(GFX) $< $@ -$(FONTGFXDIR)/frlg_male.fwjpnfont: $(FONTGFXDIR)/japanese_frlg_male_font.png +$(FONTGFXDIR)/frlg_male.fwjpnfont: $(FONTGFXDIR)/japanese_frlg_male.png $(GFX) $< $@ -$(FONTGFXDIR)/frlg_female.fwjpnfont: $(FONTGFXDIR)/japanese_frlg_female_font.png +$(FONTGFXDIR)/frlg_female.fwjpnfont: $(FONTGFXDIR)/japanese_frlg_female.png $(GFX) $< $@ diff --git a/src/pokemon.c b/src/pokemon.c index d3a570e72fcc..6ee052fda576 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -1354,10 +1354,10 @@ static const u16 sHoennToNationalOrder[NUM_SPECIES - 1] = const struct SpindaSpot gSpindaSpotGraphics[] = { - {.x = 16, .y = 7, .image = INCBIN_U16("graphics/spinda_spots/spot_0.1bpp")}, - {.x = 40, .y = 8, .image = INCBIN_U16("graphics/spinda_spots/spot_1.1bpp")}, - {.x = 22, .y = 25, .image = INCBIN_U16("graphics/spinda_spots/spot_2.1bpp")}, - {.x = 34, .y = 26, .image = INCBIN_U16("graphics/spinda_spots/spot_3.1bpp")} + {.x = 16, .y = 7, .image = INCBIN_U16("graphics/pokemon/spinda/spots/spot_0.1bpp")}, + {.x = 40, .y = 8, .image = INCBIN_U16("graphics/pokemon/spinda/spots/spot_1.1bpp")}, + {.x = 22, .y = 25, .image = INCBIN_U16("graphics/pokemon/spinda/spots/spot_2.1bpp")}, + {.x = 34, .y = 26, .image = INCBIN_U16("graphics/pokemon/spinda/spots/spot_3.1bpp")} }; #include "data/pokemon/item_effects.h" From a0bf504bc1364e15d7c60e1d8a043e6044376770 Mon Sep 17 00:00:00 2001 From: Icedude907 <34080011+Icedude907@users.noreply.github.com> Date: Sun, 12 Nov 2023 15:19:50 +1300 Subject: [PATCH 46/48] Linkerscript now tracks RAM/ROM usage --- .gitignore | 1 - Makefile | 9 ++-- gflib/malloc.c | 3 ++ gflib/malloc.h | 3 +- ld_script.txt => ld_script.ld | 50 +++++++++---------- ld_script_modern.txt => ld_script_modern.ld | 55 ++++++++++----------- 6 files changed, 61 insertions(+), 60 deletions(-) rename ld_script.txt => ld_script.ld (99%) rename ld_script_modern.txt => ld_script_modern.ld (83%) diff --git a/.gitignore b/.gitignore index 082430d794e2..9fa431e14320 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,6 @@ sound/**/*.bin sound/songs/midi/*.s tools/agbcc *.map -*.ld *.bat *.dump *.sa* diff --git a/Makefile b/Makefile index 5c073b36ca18..50953be79cd7 100644 --- a/Makefile +++ b/Makefile @@ -119,8 +119,6 @@ ifneq ($(MODERN),1) CPPFLAGS += -I tools/agbcc/include -I tools/agbcc -nostdinc -undef endif -LDFLAGS = -Map ../../$(MAP) - SHA1 := $(shell { command -v sha1sum || command -v shasum; } 2>/dev/null) -c GFX := tools/gbagfx/gbagfx$(EXE) AIF := tools/aif2pcm/aif2pcm$(EXE) @@ -406,19 +404,20 @@ $(OBJ_DIR)/sym_ewram.ld: sym_ewram.txt $(RAMSCRGEN) ewram_data $< ENGLISH > $@ ifeq ($(MODERN),0) -LD_SCRIPT := ld_script.txt +LD_SCRIPT := ld_script.ld LD_SCRIPT_DEPS := $(OBJ_DIR)/sym_bss.ld $(OBJ_DIR)/sym_common.ld $(OBJ_DIR)/sym_ewram.ld else -LD_SCRIPT := ld_script_modern.txt +LD_SCRIPT := ld_script_modern.ld LD_SCRIPT_DEPS := endif $(OBJ_DIR)/ld_script.ld: $(LD_SCRIPT) $(LD_SCRIPT_DEPS) cd $(OBJ_DIR) && sed "s#tools/#../../tools/#g" ../../$(LD_SCRIPT) > ld_script.ld +LDFLAGS = -Map ../../$(MAP) $(ELF): $(OBJ_DIR)/ld_script.ld $(OBJS) libagbsyscall @echo "cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ld_script.ld -o ../../$@ " - @cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ld_script.ld -o ../../$@ $(OBJS_REL) $(LIB) + @cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ld_script.ld --print-memory-usage -o ../../$@ $(OBJS_REL) $(LIB) | cat $(FIX) $@ -t"$(TITLE)" -c$(GAME_CODE) -m$(MAKER_CODE) -r$(REVISION) --silent $(ROM): $(ELF) diff --git a/gflib/malloc.c b/gflib/malloc.c index d0b94976358f..7229c20e8bd3 100644 --- a/gflib/malloc.c +++ b/gflib/malloc.c @@ -1,8 +1,11 @@ #include "global.h" +#include "malloc.h" static void *sHeapStart; static u32 sHeapSize; +__attribute__((section("__EWRAM_HEAP"))) u8 gHeap[HEAP_SIZE] = {0}; + #define MALLOC_SYSTEM_ID 0xA3A3 struct MemBlock { diff --git a/gflib/malloc.h b/gflib/malloc.h index 851db83a62e5..2792ff1cb721 100644 --- a/gflib/malloc.h +++ b/gflib/malloc.h @@ -1,7 +1,6 @@ #ifndef GUARD_ALLOC_H #define GUARD_ALLOC_H -#define HEAP_SIZE 0x1C000 #define FREE_AND_SET_NULL(ptr) \ { \ @@ -11,6 +10,8 @@ #define TRY_FREE_AND_SET_NULL(ptr) if (ptr != NULL) FREE_AND_SET_NULL(ptr) +// 122 KB. Max size of the heap without running into other data +#define HEAP_SIZE 0x1C000 extern u8 gHeap[]; void *Alloc(u32 size); diff --git a/ld_script.txt b/ld_script.ld similarity index 99% rename from ld_script.txt rename to ld_script.ld index 4be596524004..ee0556d5a098 100644 --- a/ld_script.txt +++ b/ld_script.ld @@ -3,6 +3,13 @@ ENTRY(Start) gNumMusicPlayers = 4; gMaxLines = 0; +MEMORY +{ + EWRAM (rwx) : ORIGIN = 0x2000000, LENGTH = 256K + IWRAM (rwx) : ORIGIN = 0x3000000, LENGTH = 32K + ROM (rx) : ORIGIN = 0x8000000, LENGTH = 16M +} + /* Modify the following load addresses as needed to make more room. Alternately, delete both the declarations below and their references further down to get rid of the gaps. */ @@ -10,28 +17,22 @@ __anim_mon_load_address = 0x8b00000; __gfx_load_address = 0x8c00000; SECTIONS { - . = 0x2000000; - ewram (NOLOAD) : + ewram 0x2000000 (NOLOAD) : ALIGN(4) { - gHeap = .; - - . = 0x1C000; + *(__EWRAM_HEAP); INCLUDE "sym_ewram.ld" - src/*.o(ewram_data); - gflib/*.o(ewram_data); + src/*.o(ewram_data); /**/ + gflib/*.o(ewram_data); /**/ *libc.a:impure.o(.data); *libc.a:locale.o(.data); *libc.a:mallocr.o(.data); - . = 0x40000; - } - - . = 0x3000000; + } > EWRAM - iwram (NOLOAD) : + iwram 0x3000000 (NOLOAD) : ALIGN(4) { /* .bss starts at 0x3000000 */ @@ -46,10 +47,9 @@ SECTIONS { /* COMMON starts at 0x30022A8 */ INCLUDE "sym_common.ld" *libc.a:sbrkr.o(COMMON); - end = .; - . = 0x8000; - } + } > IWRAM + /* BEGIN ROM DATA */ . = 0x8000000; .text : @@ -343,7 +343,7 @@ SECTIONS { src/gym_leader_rematch.o(.text); src/battle_transition_frontier.o(.text); src/international_string_util.o(.text); - } =0 + } > ROM =0 script_data : ALIGN(4) @@ -356,7 +356,7 @@ SECTIONS { data/battle_ai_scripts.o(script_data); data/contest_ai_scripts.o(script_data); data/mystery_event_script_cmd_table.o(script_data); - } =0 + } > ROM =0 lib_text : ALIGN(4) @@ -440,7 +440,7 @@ SECTIONS { *libc.a:libcfunc.o(.text); *libc.a:lseekr.o(.text); *libc.a:readr.o(.text); - } =0 + } > ROM =0 .rodata : ALIGN(4) @@ -705,7 +705,7 @@ SECTIONS { data/mystery_gift.o(.rodata); src/m4a_tables.o(.rodata); data/sound_data.o(.rodata); - } =0 + } > ROM =0 song_data : ALIGN(4) @@ -1240,7 +1240,7 @@ SECTIONS { sound/songs/midi/ph_nurse_blend.o(.rodata); sound/songs/midi/ph_nurse_held.o(.rodata); sound/songs/midi/ph_nurse_solo.o(.rodata); - } =0 + } > ROM =0 lib_rodata : SUBALIGN(4) @@ -1293,7 +1293,7 @@ SECTIONS { *libc.a:lseekr.o(.rodata); *libc.a:readr.o(.rodata); src/libisagbprn.o(.rodata); - } =0 + } > ROM =0 multiboot_data : ALIGN(4) @@ -1301,19 +1301,19 @@ SECTIONS { data/multiboot_ereader.o(.rodata); data/multiboot_berry_glitch_fix.o(.rodata); data/multiboot_pokemon_colosseum.o(.rodata); - } =0 + } > ROM =0 anim_mon_front_pic_data __anim_mon_load_address : ALIGN(4) { src/anim_mon_front_pics.o(.rodata); - } =0 + } > ROM =0 gfx_data __gfx_load_address : ALIGN(4) { src/graphics.o(.rodata); - } =0 + } > ROM =0 extra : ALIGN(4) @@ -1323,7 +1323,7 @@ SECTIONS { src/*.o(.rodata); gflib/*.o(.rodata); data/*.o(.rodata); - } = 0 + } > ROM = 0 /* DWARF debug sections. Symbols in the DWARF debugging sections are relative to the beginning diff --git a/ld_script_modern.txt b/ld_script_modern.ld similarity index 83% rename from ld_script_modern.txt rename to ld_script_modern.ld index 549d040e1ebd..05b2b815ffd8 100644 --- a/ld_script_modern.txt +++ b/ld_script_modern.ld @@ -3,28 +3,28 @@ ENTRY(Start) gNumMusicPlayers = 4; gMaxLines = 0; +/* Memory Spaces */ +MEMORY +{ + EWRAM (rwx) : ORIGIN = 0x2000000, LENGTH = 256K + IWRAM (rwx) : ORIGIN = 0x3000000, LENGTH = 32K + ROM (rx) : ORIGIN = 0x8000000, LENGTH = 16M +} + SECTIONS { - . = 0x2000000; - ewram (NOLOAD) : + ewram 0x2000000 (NOLOAD) : ALIGN(4) { - gHeap = .; - - . = 0x1C000; - - src/*.o(ewram_data); - gflib/*.o(ewram_data); + *(__EWRAM_HEAP); - . = 0x40000; -} - - . = 0x3000000; + src/*.o(ewram_data); /**/ + gflib/*.o(ewram_data); /**/ + } > EWRAM - iwram (NOLOAD) : + iwram 0x3000000 (NOLOAD) : ALIGN(4) { - /* .bss starts at 0x3000000 */ src/*.o(.bss); gflib/*.o(.bss); data/*.o(.bss); @@ -35,14 +35,13 @@ SECTIONS { src/m4a.o(.bss.code); /* COMMON starts at 0x30022A8 */ - src/*.o(COMMON); - gflib/*.o(COMMON); - *libc.a:*.o(COMMON); + src/*.o(COMMON); /**/ + gflib/*.o(COMMON); /**/ + *libc.a:*.o(COMMON); *libnosys.a:*.o(COMMON); - end = .; - . = 0x8000; - } + } > IWRAM + /* BEGIN ROM DATA */ . = 0x8000000; .text : @@ -55,13 +54,13 @@ SECTIONS { gflib/*.o(.text*); src/*.o(.text*); asm/*.o(.text*); - } =0 + } > ROM =0 script_data : ALIGN(4) { data/*.o(script_data); - } =0 + } > ROM =0 lib_text : ALIGN(4) @@ -82,7 +81,7 @@ SECTIONS { *libc.a:*.o(.text*); *libnosys.a:*.o(.text*); src/libisagbprn.o(.text); - } =0 + } > ROM =0 .rodata : ALIGN(4) @@ -90,13 +89,13 @@ SECTIONS { src/*.o(.rodata*); gflib/*.o(.rodata*); data/*.o(.rodata*); - } =0 + } > ROM =0 song_data : ALIGN(4) { sound/songs/*.o(.rodata); - } =0 + } > ROM =0 lib_rodata : SUBALIGN(4) @@ -121,19 +120,19 @@ SECTIONS { data/multiboot_ereader.o(.rodata); data/multiboot_berry_glitch_fix.o(.rodata); data/multiboot_pokemon_colosseum.o(.rodata); - } =0 + } > ROM =0 anim_mon_front_pic_data : ALIGN(4) { src/anim_mon_front_pics.o(.rodata); - } =0 + } > ROM =0 gfx_data : ALIGN(4) { src/graphics.o(.rodata); - } =0 + } > ROM =0 /* DWARF debug sections. Symbols in the DWARF debugging sections are relative to the beginning From 190e77e9c886174e0edaecbe8bb44365e55bfebd Mon Sep 17 00:00:00 2001 From: SnorlaxMonster Date: Sat, 18 Nov 2023 12:53:00 +1100 Subject: [PATCH 47/48] Rename HITMARKER_IGNORE_SAFEGUARD Rename HITMARKER_IGNORE_SAFEGUARD to HITMARKER_STATUS_ABILITY_EFFECT. This flag is used exclusively by status-inflicting Abilities, and has 3 main functions: - Whether the effect bypasses Shield Dust - Whether the effect bypasses Safeguard - Which text string to display when the status condition is inflicted (i.e. whether it was inflicted by a move or Ability) I believe this new name better represents what the flag actually does. This name was structured to parallel HITMARKER_SYNCHRONISE_EFFECT. --- include/constants/battle.h | 2 +- src/battle_script_commands.c | 30 +++++++++++++++--------------- src/battle_util.c | 16 ++++++++-------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/include/constants/battle.h b/include/constants/battle.h index c4c1bc5e6825..50c93083f835 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -176,7 +176,7 @@ #define HITMARKER_ATTACKSTRING_PRINTED (1 << 10) #define HITMARKER_NO_PPDEDUCT (1 << 11) #define HITMARKER_SWAP_ATTACKER_TARGET (1 << 12) -#define HITMARKER_IGNORE_SAFEGUARD (1 << 13) +#define HITMARKER_STATUS_ABILITY_EFFECT (1 << 13) #define HITMARKER_SYNCHRONISE_EFFECT (1 << 14) #define HITMARKER_RUN (1 << 15) #define HITMARKER_IGNORE_ON_AIR (1 << 16) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 96ae0e68a376..2bc8e73f43b2 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -2246,11 +2246,11 @@ void SetMoveEffect(bool8 primary, u8 certain) gBattleScripting.battler = gBattlerAttacker; } - if (gBattleMons[gEffectBattler].ability == ABILITY_SHIELD_DUST && !(gHitMarker & HITMARKER_IGNORE_SAFEGUARD) + if (gBattleMons[gEffectBattler].ability == ABILITY_SHIELD_DUST && !(gHitMarker & HITMARKER_STATUS_ABILITY_EFFECT) && !primary && gBattleCommunication[MOVE_EFFECT_BYTE] <= 9) INCREMENT_RESET_RETURN - if (gSideStatuses[GET_BATTLER_SIDE(gEffectBattler)] & SIDE_STATUS_SAFEGUARD && !(gHitMarker & HITMARKER_IGNORE_SAFEGUARD) + if (gSideStatuses[GET_BATTLER_SIDE(gEffectBattler)] & SIDE_STATUS_SAFEGUARD && !(gHitMarker & HITMARKER_STATUS_ABILITY_EFFECT) && !primary && gBattleCommunication[MOVE_EFFECT_BYTE] <= 7) INCREMENT_RESET_RETURN @@ -2300,10 +2300,10 @@ void SetMoveEffect(bool8 primary, u8 certain) BattleScriptPush(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = BattleScript_PSNPrevention; - if (gHitMarker & HITMARKER_IGNORE_SAFEGUARD) + if (gHitMarker & HITMARKER_STATUS_ABILITY_EFFECT) { gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_ABILITY_PREVENTS_ABILITY_STATUS; - gHitMarker &= ~HITMARKER_IGNORE_SAFEGUARD; + gHitMarker &= ~HITMARKER_STATUS_ABILITY_EFFECT; } else { @@ -2312,7 +2312,7 @@ void SetMoveEffect(bool8 primary, u8 certain) RESET_RETURN } if ((IS_BATTLER_OF_TYPE(gEffectBattler, TYPE_POISON) || IS_BATTLER_OF_TYPE(gEffectBattler, TYPE_STEEL)) - && (gHitMarker & HITMARKER_IGNORE_SAFEGUARD) + && (gHitMarker & HITMARKER_STATUS_ABILITY_EFFECT) && (primary == TRUE || certain == MOVE_EFFECT_CERTAIN)) { BattleScriptPush(gBattlescriptCurrInstr + 1); @@ -2341,10 +2341,10 @@ void SetMoveEffect(bool8 primary, u8 certain) BattleScriptPush(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = BattleScript_BRNPrevention; - if (gHitMarker & HITMARKER_IGNORE_SAFEGUARD) + if (gHitMarker & HITMARKER_STATUS_ABILITY_EFFECT) { gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_ABILITY_PREVENTS_ABILITY_STATUS; - gHitMarker &= ~HITMARKER_IGNORE_SAFEGUARD; + gHitMarker &= ~HITMARKER_STATUS_ABILITY_EFFECT; } else { @@ -2353,7 +2353,7 @@ void SetMoveEffect(bool8 primary, u8 certain) RESET_RETURN } if (IS_BATTLER_OF_TYPE(gEffectBattler, TYPE_FIRE) - && (gHitMarker & HITMARKER_IGNORE_SAFEGUARD) + && (gHitMarker & HITMARKER_STATUS_ABILITY_EFFECT) && (primary == TRUE || certain == MOVE_EFFECT_CERTAIN)) { BattleScriptPush(gBattlescriptCurrInstr + 1); @@ -2397,10 +2397,10 @@ void SetMoveEffect(bool8 primary, u8 certain) BattleScriptPush(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = BattleScript_PRLZPrevention; - if (gHitMarker & HITMARKER_IGNORE_SAFEGUARD) + if (gHitMarker & HITMARKER_STATUS_ABILITY_EFFECT) { gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_ABILITY_PREVENTS_ABILITY_STATUS; - gHitMarker &= ~HITMARKER_IGNORE_SAFEGUARD; + gHitMarker &= ~HITMARKER_STATUS_ABILITY_EFFECT; } else { @@ -2425,10 +2425,10 @@ void SetMoveEffect(bool8 primary, u8 certain) BattleScriptPush(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = BattleScript_PSNPrevention; - if (gHitMarker & HITMARKER_IGNORE_SAFEGUARD) + if (gHitMarker & HITMARKER_STATUS_ABILITY_EFFECT) { gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_ABILITY_PREVENTS_ABILITY_STATUS; - gHitMarker &= ~HITMARKER_IGNORE_SAFEGUARD; + gHitMarker &= ~HITMARKER_STATUS_ABILITY_EFFECT; } else { @@ -2437,7 +2437,7 @@ void SetMoveEffect(bool8 primary, u8 certain) RESET_RETURN } if ((IS_BATTLER_OF_TYPE(gEffectBattler, TYPE_POISON) || IS_BATTLER_OF_TYPE(gEffectBattler, TYPE_STEEL)) - && (gHitMarker & HITMARKER_IGNORE_SAFEGUARD) + && (gHitMarker & HITMARKER_STATUS_ABILITY_EFFECT) && (primary == TRUE || certain == MOVE_EFFECT_CERTAIN)) { BattleScriptPush(gBattlescriptCurrInstr + 1); @@ -2480,10 +2480,10 @@ void SetMoveEffect(bool8 primary, u8 certain) BtlController_EmitSetMonData(BUFFER_A, REQUEST_STATUS_BATTLE, 0, sizeof(gBattleMons[gEffectBattler].status1), &gBattleMons[gEffectBattler].status1); MarkBattlerForControllerExec(gActiveBattler); - if (gHitMarker & HITMARKER_IGNORE_SAFEGUARD) + if (gHitMarker & HITMARKER_STATUS_ABILITY_EFFECT) { gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_STATUSED_BY_ABILITY; - gHitMarker &= ~HITMARKER_IGNORE_SAFEGUARD; + gHitMarker &= ~HITMARKER_STATUS_ABILITY_EFFECT; } else { diff --git a/src/battle_util.c b/src/battle_util.c index 5a2b6392f09b..735d1ba8106b 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -649,7 +649,7 @@ void HandleAction_NothingIsFainted(void) gCurrentTurnActionNumber++; gCurrentActionFuncId = gActionsByTurnOrder[gCurrentTurnActionNumber]; gHitMarker &= ~(HITMARKER_DESTINYBOND | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_ATTACKSTRING_PRINTED - | HITMARKER_NO_PPDEDUCT | HITMARKER_IGNORE_SAFEGUARD | HITMARKER_IGNORE_ON_AIR + | HITMARKER_NO_PPDEDUCT | HITMARKER_STATUS_ABILITY_EFFECT | HITMARKER_IGNORE_ON_AIR | HITMARKER_IGNORE_UNDERGROUND | HITMARKER_IGNORE_UNDERWATER | HITMARKER_PASSIVE_DAMAGE | HITMARKER_OBEYS | HITMARKER_WAKE_UP_CLEAR | HITMARKER_SYNCHRONISE_EFFECT | HITMARKER_CHARGING | HITMARKER_NEVER_SET); @@ -662,7 +662,7 @@ void HandleAction_ActionFinished(void) gCurrentActionFuncId = gActionsByTurnOrder[gCurrentTurnActionNumber]; SpecialStatusesClear(); gHitMarker &= ~(HITMARKER_DESTINYBOND | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_ATTACKSTRING_PRINTED - | HITMARKER_NO_PPDEDUCT | HITMARKER_IGNORE_SAFEGUARD | HITMARKER_IGNORE_ON_AIR + | HITMARKER_NO_PPDEDUCT | HITMARKER_STATUS_ABILITY_EFFECT | HITMARKER_IGNORE_ON_AIR | HITMARKER_IGNORE_UNDERGROUND | HITMARKER_IGNORE_UNDERWATER | HITMARKER_PASSIVE_DAMAGE | HITMARKER_OBEYS | HITMARKER_WAKE_UP_CLEAR | HITMARKER_SYNCHRONISE_EFFECT | HITMARKER_CHARGING | HITMARKER_NEVER_SET); @@ -2782,7 +2782,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA gBattleCommunication[MOVE_EFFECT_BYTE] += MOVE_EFFECT_AFFECTS_USER; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_ApplySecondaryEffect; - gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; + gHitMarker |= HITMARKER_STATUS_ABILITY_EFFECT; effect++; } break; @@ -2797,7 +2797,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA gBattleCommunication[MOVE_EFFECT_BYTE] = MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_POISON; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_ApplySecondaryEffect; - gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; + gHitMarker |= HITMARKER_STATUS_ABILITY_EFFECT; effect++; } break; @@ -2812,7 +2812,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA gBattleCommunication[MOVE_EFFECT_BYTE] = MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_PARALYSIS; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_ApplySecondaryEffect; - gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; + gHitMarker |= HITMARKER_STATUS_ABILITY_EFFECT; effect++; } break; @@ -2827,7 +2827,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA gBattleCommunication[MOVE_EFFECT_BYTE] = MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_BURN; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_ApplySecondaryEffect; - gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; + gHitMarker |= HITMARKER_STATUS_ABILITY_EFFECT; effect++; } break; @@ -2963,7 +2963,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA gBattleScripting.battler = gBattlerTarget; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_SynchronizeActivates; - gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; + gHitMarker |= HITMARKER_STATUS_ABILITY_EFFECT; effect++; } break; @@ -2979,7 +2979,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA gBattleScripting.battler = gBattlerAttacker; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_SynchronizeActivates; - gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; + gHitMarker |= HITMARKER_STATUS_ABILITY_EFFECT; effect++; } break; From e5ac2a103ee301bbac1db281136b047192287362 Mon Sep 17 00:00:00 2001 From: Icedude907 <34080011+Icedude907@users.noreply.github.com> Date: Fri, 24 Nov 2023 10:13:50 +1300 Subject: [PATCH 48/48] Incorporate review changes --- gflib/malloc.c | 2 +- gflib/malloc.h | 3 +-- ld_script.ld | 8 +++----- ld_script_modern.ld | 17 ++++++----------- sym_ewram.txt | 1 + 5 files changed, 12 insertions(+), 19 deletions(-) diff --git a/gflib/malloc.c b/gflib/malloc.c index 7229c20e8bd3..f54c751a4c45 100644 --- a/gflib/malloc.c +++ b/gflib/malloc.c @@ -4,7 +4,7 @@ static void *sHeapStart; static u32 sHeapSize; -__attribute__((section("__EWRAM_HEAP"))) u8 gHeap[HEAP_SIZE] = {0}; +EWRAM_DATA u8 gHeap[HEAP_SIZE] = {0}; #define MALLOC_SYSTEM_ID 0xA3A3 diff --git a/gflib/malloc.h b/gflib/malloc.h index 2792ff1cb721..72e1a5e1d38d 100644 --- a/gflib/malloc.h +++ b/gflib/malloc.h @@ -10,9 +10,8 @@ #define TRY_FREE_AND_SET_NULL(ptr) if (ptr != NULL) FREE_AND_SET_NULL(ptr) -// 122 KB. Max size of the heap without running into other data #define HEAP_SIZE 0x1C000 -extern u8 gHeap[]; +extern u8 gHeap[HEAP_SIZE]; void *Alloc(u32 size); void *AllocZeroed(u32 size); diff --git a/ld_script.ld b/ld_script.ld index ee0556d5a098..c4abf075f8ae 100644 --- a/ld_script.ld +++ b/ld_script.ld @@ -7,7 +7,7 @@ MEMORY { EWRAM (rwx) : ORIGIN = 0x2000000, LENGTH = 256K IWRAM (rwx) : ORIGIN = 0x3000000, LENGTH = 32K - ROM (rx) : ORIGIN = 0x8000000, LENGTH = 16M + ROM (rx) : ORIGIN = 0x8000000, LENGTH = 32M } /* Modify the following load addresses as needed to make more room. Alternately, delete both the @@ -21,11 +21,9 @@ SECTIONS { ewram 0x2000000 (NOLOAD) : ALIGN(4) { - *(__EWRAM_HEAP); - INCLUDE "sym_ewram.ld" - src/*.o(ewram_data); /**/ - gflib/*.o(ewram_data); /**/ + src/*.o(ewram_data); + gflib/*.o(ewram_data); *libc.a:impure.o(.data); *libc.a:locale.o(.data); diff --git a/ld_script_modern.ld b/ld_script_modern.ld index 05b2b815ffd8..4ccbfbaa0f75 100644 --- a/ld_script_modern.ld +++ b/ld_script_modern.ld @@ -3,12 +3,11 @@ ENTRY(Start) gNumMusicPlayers = 4; gMaxLines = 0; -/* Memory Spaces */ MEMORY { EWRAM (rwx) : ORIGIN = 0x2000000, LENGTH = 256K IWRAM (rwx) : ORIGIN = 0x3000000, LENGTH = 32K - ROM (rx) : ORIGIN = 0x8000000, LENGTH = 16M + ROM (rx) : ORIGIN = 0x8000000, LENGTH = 32M } SECTIONS { @@ -16,10 +15,8 @@ SECTIONS { ewram 0x2000000 (NOLOAD) : ALIGN(4) { - *(__EWRAM_HEAP); - - src/*.o(ewram_data); /**/ - gflib/*.o(ewram_data); /**/ + src/*.o(ewram_data); + gflib/*.o(ewram_data); } > EWRAM iwram 0x3000000 (NOLOAD) : @@ -31,13 +28,11 @@ SECTIONS { *libc.a:*.o(.bss*); *libnosys.a:*.o(.bss*); - /* .bss.code starts at 0x3001AA8 */ src/m4a.o(.bss.code); - /* COMMON starts at 0x30022A8 */ - src/*.o(COMMON); /**/ - gflib/*.o(COMMON); /**/ - *libc.a:*.o(COMMON); + src/*.o(COMMON); + gflib/*.o(COMMON); + *libc.a:*.o(COMMON); *libnosys.a:*.o(COMMON); } > IWRAM diff --git a/sym_ewram.txt b/sym_ewram.txt index 414b7a3b235c..31c507ee9bf4 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -1,3 +1,4 @@ + .include "gflib/malloc.o" .include "src/decompress.o" .include "src/main.o" .include "gflib/window.o"