From 5c3669e0cd49ccc210d7c57228820685fef11230 Mon Sep 17 00:00:00 2001 From: kiliwily <69381603+kiliwily@users.noreply.github.com> Date: Sat, 12 Sep 2020 18:43:20 +0200 Subject: [PATCH 01/12] Bug documenting --- docs/bugs_and_glitches.md | 18 ++++++++++++++++++ src/battle_util.c | 2 ++ src/metatile_behavior.c | 4 ++++ src/pokemon.c | 2 ++ 4 files changed, 26 insertions(+) diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md index e23379cfba..e7b40a089b 100644 --- a/docs/bugs_and_glitches.md +++ b/docs/bugs_and_glitches.md @@ -42,6 +42,24 @@ And edit `AgbMain`: ... ``` +**Altenate Fix:**Edit the following function in [src/title_screen.c](https://github.com/pret/pokeemerald/blob/master/src/title_screen.c): + +```diff +void CB2_InitTitleScreen(void) +{ + switch (gMain.state) + { + default: + case 0: + SetVBlankCallback(NULL); + + StartTimer1(); + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + SetGpuReg(REG_OFFSET_BLDY, 0); + ... +``` +That matches the code of FR/LG and does what GF originally wanted to do. + ## Scrolling through items in the bag causes the image to flicker **Fix:** Add the following function to [src/item_menu_icons.c](https://github.com/pret/pokeemerald/blob/master/src/item_menu_icons.c): diff --git a/src/battle_util.c b/src/battle_util.c index eb3907157a..0c2e31e070 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -527,6 +527,8 @@ void HandleAction_ThrowPokeblock(void) gBattleStruct->safariPkblThrowCounter++; if (gBattleStruct->safariEscapeFactor > 1) { + //BUG: The safariEscapeFactor is unintetionally able to become 0 (but it can not become negative!). This causes the pokeblock throw glitch. + //To fix that change the < in the if statement below to <=. if (gBattleStruct->safariEscapeFactor < sPkblToEscapeFactor[gBattleStruct->safariPkblThrowCounter][gBattleCommunication[MULTISTRING_CHOOSER]]) gBattleStruct->safariEscapeFactor = 1; else diff --git a/src/metatile_behavior.c b/src/metatile_behavior.c index dde4de3292..516a44a079 100644 --- a/src/metatile_behavior.c +++ b/src/metatile_behavior.c @@ -968,6 +968,10 @@ bool8 MetatileBehavior_IsDiveable(u8 metatileBehavior) bool8 MetatileBehavior_IsUnableToEmerge(u8 metatileBehavior) { + //BUG: The player is unintentionally able to emerge on water doors. + //Also the narrower underwater door in the underwater tileset has the wrong metatile behavior. This causes the dive glitch. + //To fix that add ||metatileBehavior == MB_WATER_DOOR to the if statement below and + //change the metatile behavior of the narrower water door with porymaps tilset editor. if (metatileBehavior == MB_NO_SURFACING || metatileBehavior == MB_SEAWEED_NO_SURFACING) return TRUE; diff --git a/src/pokemon.c b/src/pokemon.c index a0e655d1e6..f706e8ef80 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -2861,6 +2861,8 @@ void CalculateMonStats(struct Pokemon *mon) if (currentHP == 0 && oldMaxHP == 0) currentHP = newMaxHP; else if (currentHP != 0) + //BUG: currentHP is unintentionally able to become <= 0 after the instruction below. This causes the pomeg berry glitch. + //To fix this add another if statement after the instruction that desides what happens if currentHP <= 0. currentHP += newMaxHP - oldMaxHP; else return; From 3e95f837a6b3fdc606b24fc069f0b2994279ebac Mon Sep 17 00:00:00 2001 From: kiliwily <69381603+kiliwily@users.noreply.github.com> Date: Sat, 12 Sep 2020 18:44:39 +0200 Subject: [PATCH 02/12] Update bugs_and_glitches.md --- docs/bugs_and_glitches.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md index e7b40a089b..0f4a85cc0b 100644 --- a/docs/bugs_and_glitches.md +++ b/docs/bugs_and_glitches.md @@ -42,7 +42,7 @@ And edit `AgbMain`: ... ``` -**Altenate Fix:**Edit the following function in [src/title_screen.c](https://github.com/pret/pokeemerald/blob/master/src/title_screen.c): +**Altenate Fix:** Edit the following function in [src/title_screen.c](https://github.com/pret/pokeemerald/blob/master/src/title_screen.c): ```diff void CB2_InitTitleScreen(void) @@ -52,7 +52,7 @@ void CB2_InitTitleScreen(void) default: case 0: SetVBlankCallback(NULL); - + StartTimer1(); ++ StartTimer1(); SetGpuReg(REG_OFFSET_BLDCNT, 0); SetGpuReg(REG_OFFSET_BLDALPHA, 0); SetGpuReg(REG_OFFSET_BLDY, 0); From 84acc5c6db99d7b57b1619f89f56b5bf8f3fea35 Mon Sep 17 00:00:00 2001 From: kiliwily <69381603+kiliwily@users.noreply.github.com> Date: Sat, 12 Sep 2020 18:47:10 +0200 Subject: [PATCH 03/12] Update bugs_and_glitches.md --- docs/bugs_and_glitches.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md index 0f4a85cc0b..0da23af4b2 100644 --- a/docs/bugs_and_glitches.md +++ b/docs/bugs_and_glitches.md @@ -52,11 +52,11 @@ void CB2_InitTitleScreen(void) default: case 0: SetVBlankCallback(NULL); -+ StartTimer1(); - SetGpuReg(REG_OFFSET_BLDCNT, 0); ++ StartTimer1(); + SetGpuReg(REG_OFFSET_BLDCNT, 0); SetGpuReg(REG_OFFSET_BLDALPHA, 0); SetGpuReg(REG_OFFSET_BLDY, 0); - ... + ... ``` That matches the code of FR/LG and does what GF originally wanted to do. From 7377c2f192ab46479f9a0cc23edfd8c07f186d0c Mon Sep 17 00:00:00 2001 From: kiliwily <69381603+kiliwily@users.noreply.github.com> Date: Sat, 12 Sep 2020 18:48:57 +0200 Subject: [PATCH 04/12] Update bugs_and_glitches.md --- docs/bugs_and_glitches.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md index 0da23af4b2..f0e1005b8e 100644 --- a/docs/bugs_and_glitches.md +++ b/docs/bugs_and_glitches.md @@ -52,11 +52,11 @@ void CB2_InitTitleScreen(void) default: case 0: SetVBlankCallback(NULL); -+ StartTimer1(); - SetGpuReg(REG_OFFSET_BLDCNT, 0); ++ StartTimer1(); + SetGpuReg(REG_OFFSET_BLDCNT, 0); SetGpuReg(REG_OFFSET_BLDALPHA, 0); SetGpuReg(REG_OFFSET_BLDY, 0); - ... + ... ``` That matches the code of FR/LG and does what GF originally wanted to do. From 4c4c2ea41bf6841753002f2fd6f527a4fecc363d Mon Sep 17 00:00:00 2001 From: kiliwily <69381603+kiliwily@users.noreply.github.com> Date: Sat, 12 Sep 2020 18:49:55 +0200 Subject: [PATCH 05/12] Update bugs_and_glitches.md --- docs/bugs_and_glitches.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md index f0e1005b8e..9f80992d2b 100644 --- a/docs/bugs_and_glitches.md +++ b/docs/bugs_and_glitches.md @@ -52,8 +52,8 @@ void CB2_InitTitleScreen(void) default: case 0: SetVBlankCallback(NULL); -+ StartTimer1(); - SetGpuReg(REG_OFFSET_BLDCNT, 0); ++ StartTimer1(); + SetGpuReg(REG_OFFSET_BLDCNT, 0); SetGpuReg(REG_OFFSET_BLDALPHA, 0); SetGpuReg(REG_OFFSET_BLDY, 0); ... From f84702e50bc57549c76500f7394500baadd61501 Mon Sep 17 00:00:00 2001 From: kiliwily <69381603+kiliwily@users.noreply.github.com> Date: Sat, 12 Sep 2020 18:52:00 +0200 Subject: [PATCH 06/12] Update bugs_and_glitches.md --- docs/bugs_and_glitches.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md index 9f80992d2b..fc993e6784 100644 --- a/docs/bugs_and_glitches.md +++ b/docs/bugs_and_glitches.md @@ -47,15 +47,15 @@ And edit `AgbMain`: ```diff void CB2_InitTitleScreen(void) { - switch (gMain.state) - { - default: - case 0: - SetVBlankCallback(NULL); -+ StartTimer1(); - SetGpuReg(REG_OFFSET_BLDCNT, 0); - SetGpuReg(REG_OFFSET_BLDALPHA, 0); - SetGpuReg(REG_OFFSET_BLDY, 0); + switch (gMain.state) + { + default: + case 0: + SetVBlankCallback(NULL); ++ StartTimer1(); + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + SetGpuReg(REG_OFFSET_BLDY, 0); ... ``` That matches the code of FR/LG and does what GF originally wanted to do. From 50139aa00ce2bbc65641fb6f2a37b2ddbfcca9ab Mon Sep 17 00:00:00 2001 From: kiliwily <69381603+kiliwily@users.noreply.github.com> Date: Sat, 12 Sep 2020 18:53:09 +0200 Subject: [PATCH 07/12] Update bugs_and_glitches.md --- docs/bugs_and_glitches.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md index fc993e6784..b5f8a3276a 100644 --- a/docs/bugs_and_glitches.md +++ b/docs/bugs_and_glitches.md @@ -58,7 +58,7 @@ void CB2_InitTitleScreen(void) SetGpuReg(REG_OFFSET_BLDY, 0); ... ``` -That matches the code of FR/LG and does what GF originally wanted to do. +This matches with the code of FR/LG and does what GF originally wanted to do. ## Scrolling through items in the bag causes the image to flicker From f861b70fe74d064ab7f476ed5a3d0f2d3415c1a6 Mon Sep 17 00:00:00 2001 From: kiliwily <69381603+kiliwily@users.noreply.github.com> Date: Sat, 12 Sep 2020 18:53:59 +0200 Subject: [PATCH 08/12] Update bugs_and_glitches.md --- docs/bugs_and_glitches.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md index b5f8a3276a..fccdd5a2b2 100644 --- a/docs/bugs_and_glitches.md +++ b/docs/bugs_and_glitches.md @@ -42,7 +42,7 @@ And edit `AgbMain`: ... ``` -**Altenate Fix:** Edit the following function in [src/title_screen.c](https://github.com/pret/pokeemerald/blob/master/src/title_screen.c): +**Alternate Fix:** Edit the following function in [src/title_screen.c](https://github.com/pret/pokeemerald/blob/master/src/title_screen.c): ```diff void CB2_InitTitleScreen(void) From 9b4ded46c6b736a39bc15cf2e6325176ad50c8de Mon Sep 17 00:00:00 2001 From: kiliwily <69381603+kiliwily@users.noreply.github.com> Date: Sat, 12 Sep 2020 19:20:42 +0200 Subject: [PATCH 09/12] Update pokemon.c --- src/pokemon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pokemon.c b/src/pokemon.c index f706e8ef80..b6bec03293 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -2862,7 +2862,7 @@ void CalculateMonStats(struct Pokemon *mon) currentHP = newMaxHP; else if (currentHP != 0) //BUG: currentHP is unintentionally able to become <= 0 after the instruction below. This causes the pomeg berry glitch. - //To fix this add another if statement after the instruction that desides what happens if currentHP <= 0. + //To fix this add another if statement after the instruction that sets currentHP = 1 if currentHP <= 0. currentHP += newMaxHP - oldMaxHP; else return; From a130c2dc4adc114a5bf57383046077f2bf66e271 Mon Sep 17 00:00:00 2001 From: kiliwily <69381603+kiliwily@users.noreply.github.com> Date: Sat, 12 Sep 2020 20:02:27 +0200 Subject: [PATCH 10/12] Update bugs_and_glitches.md --- docs/bugs_and_glitches.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md index fccdd5a2b2..3d294f5cfd 100644 --- a/docs/bugs_and_glitches.md +++ b/docs/bugs_and_glitches.md @@ -42,6 +42,8 @@ And edit `AgbMain`: ... ``` +This restores the code of Ruby/Sapphire. + **Alternate Fix:** Edit the following function in [src/title_screen.c](https://github.com/pret/pokeemerald/blob/master/src/title_screen.c): ```diff From 56848fb891f55acdc98ee1b5956ffd2b1c8174eb Mon Sep 17 00:00:00 2001 From: kiliwily <69381603+kiliwily@users.noreply.github.com> Date: Sat, 19 Sep 2020 20:44:16 +0200 Subject: [PATCH 11/12] Update battle_util.c --- src/battle_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/battle_util.c b/src/battle_util.c index 0c2e31e070..31ed0b3fe7 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -527,8 +527,8 @@ void HandleAction_ThrowPokeblock(void) gBattleStruct->safariPkblThrowCounter++; if (gBattleStruct->safariEscapeFactor > 1) { - //BUG: The safariEscapeFactor is unintetionally able to become 0 (but it can not become negative!). This causes the pokeblock throw glitch. - //To fix that change the < in the if statement below to <=. + // BUG: The safariEscapeFactor is unintetionally able to become 0 (but it can not become negative!). This causes the pokeblock throw glitch. + // To fix that change the < in the if statement below to <=. if (gBattleStruct->safariEscapeFactor < sPkblToEscapeFactor[gBattleStruct->safariPkblThrowCounter][gBattleCommunication[MULTISTRING_CHOOSER]]) gBattleStruct->safariEscapeFactor = 1; else From f1366dfc694c78ac934e58a917a173f95c55df28 Mon Sep 17 00:00:00 2001 From: kiliwily <69381603+kiliwily@users.noreply.github.com> Date: Sat, 19 Sep 2020 20:46:26 +0200 Subject: [PATCH 12/12] Fix typos --- src/metatile_behavior.c | 8 ++++---- src/pokemon.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/metatile_behavior.c b/src/metatile_behavior.c index 516a44a079..51cc65c221 100644 --- a/src/metatile_behavior.c +++ b/src/metatile_behavior.c @@ -968,10 +968,10 @@ bool8 MetatileBehavior_IsDiveable(u8 metatileBehavior) bool8 MetatileBehavior_IsUnableToEmerge(u8 metatileBehavior) { - //BUG: The player is unintentionally able to emerge on water doors. - //Also the narrower underwater door in the underwater tileset has the wrong metatile behavior. This causes the dive glitch. - //To fix that add ||metatileBehavior == MB_WATER_DOOR to the if statement below and - //change the metatile behavior of the narrower water door with porymaps tilset editor. + // BUG: The player is unintentionally able to emerge on water doors. + // Also the narrower underwater door in the underwater tileset has the wrong metatile behavior. This causes the dive glitch. + // To fix that add || metatileBehavior == MB_WATER_DOOR to the if statement below and + // change the metatile behavior of the narrower water door with porymaps tileset editor. if (metatileBehavior == MB_NO_SURFACING || metatileBehavior == MB_SEAWEED_NO_SURFACING) return TRUE; diff --git a/src/pokemon.c b/src/pokemon.c index b6bec03293..30f0b0e73b 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -2861,8 +2861,8 @@ void CalculateMonStats(struct Pokemon *mon) if (currentHP == 0 && oldMaxHP == 0) currentHP = newMaxHP; else if (currentHP != 0) - //BUG: currentHP is unintentionally able to become <= 0 after the instruction below. This causes the pomeg berry glitch. - //To fix this add another if statement after the instruction that sets currentHP = 1 if currentHP <= 0. + // BUG: currentHP is unintentionally able to become <= 0 after the instruction below. This causes the pomeg berry glitch. + // To fix that set currentHP = 1 if currentHP <= 0. currentHP += newMaxHP - oldMaxHP; else return;