From f9f5a7f1b031308aef91f14060426d9183bc11be Mon Sep 17 00:00:00 2001 From: Llinos Evans <36418502+PlagueVonKarma@users.noreply.github.com> Date: Thu, 6 Jul 2023 16:02:58 +0100 Subject: [PATCH 1/6] Groundwork The script currently doesn't work how I want it to, and I don't know why. --- data/maps/objects/IndigoPlateauLobby.asm | 3 +- data/maps/objects/RedsHouse2F.asm | 5 +- scripts/HallOfFame.asm | 126 ++++++++++++++++++++++- 3 files changed, 128 insertions(+), 6 deletions(-) diff --git a/data/maps/objects/IndigoPlateauLobby.asm b/data/maps/objects/IndigoPlateauLobby.asm index 9dd054a2..f8babc40 100644 --- a/data/maps/objects/IndigoPlateauLobby.asm +++ b/data/maps/objects/IndigoPlateauLobby.asm @@ -4,7 +4,8 @@ IndigoPlateauLobby_Object: def_warp_events warp_event 7, 11, LAST_MAP, 1 warp_event 8, 11, LAST_MAP, 2 - warp_event 8, 0, LORELEIS_ROOM, 1 + warp_event 8, 0, HALL_OF_FAME, 1 ; test post-game setup + ;warp_event 8, 0, LORELEIS_ROOM, 1 def_bg_events diff --git a/data/maps/objects/RedsHouse2F.asm b/data/maps/objects/RedsHouse2F.asm index 8ecb2e0d..aa3c0051 100644 --- a/data/maps/objects/RedsHouse2F.asm +++ b/data/maps/objects/RedsHouse2F.asm @@ -4,12 +4,13 @@ RedsHouse2F_Object: def_warp_events warp_event 7, 1, REDS_HOUSE_1F, 3 ;warp_event 5, 1, SILPH_GAUNTLET_7F, 1 ; - Test Chief - ;warp_event 5, 1, SILPH_CO_11F, 1 ; - Test Omega & Giovanni + ;warp_event 5, 1, SILPH_CO_11F, 1 ; - Test J&J, Omega, & Giovanni ;warp_event 5, 1, ROCKET_HIDEOUT_B4F, 2 ; - Test Giovanni 1 ;warp_event 5, 1, MT_MOON_SQUARE, 1 ; - Test Shop, NPCs, and Crater - ;warp_event 5, 1, CELESTE_HILL, 2 ; - Test GMolt + ;warp_event 5, 1, CELESTE_HILL, 1 ; - Test GMolt ;warp_event 5, 1, INDIGO_PLATEAU_LOBBY, 1 ; easy league access warp_event 5, 1, GARNET_CAVERN_B1F, 1 ; Test GCuno + ;warp_event 5, 1, FARAWAY_ISLAND_INSIDE, 1 ; Test Mew def_bg_events diff --git a/scripts/HallOfFame.asm b/scripts/HallOfFame.asm index d89f95ec..79450ffa 100644 --- a/scripts/HallOfFame.asm +++ b/scripts/HallOfFame.asm @@ -96,6 +96,7 @@ HallofFameRoomScript1: ld [wJoyIgnore], a call PostGameSetup + call ResetLegendaryPokemon ld a, $2 ld [wHallOfFameCurScript], a @@ -113,9 +114,8 @@ HallofFameRoomText1: ; It replaces the Cerulean Cave Guard bit, adapting him into the whole ordeal. PostGameSetup: - SetEvent EVENT_POST_GAME_ATTAINED ld hl, ObjectsToHide -.loop1 +.loop1 ; Hides ld a, [hli] cp $ff jr z, .skip @@ -126,7 +126,7 @@ PostGameSetup: jr .loop1 .skip ld hl, ObjectsToShow -.loop2 +.loop2 ; Shows ld a, [hli] cp -1 ret z @@ -136,6 +136,105 @@ PostGameSetup: pop hl jr .loop2 +; Begin conditional shows for Legendary Pokemon. +; Here, we check if a Pokemon is owned, and if it is, we reset their events. +; It's really suboptimal and I think there is a way to make it better. +ResetLegendaryPokemon: + ld a, DEX_ARTICUNO ; Load dex number + ld [wd11e], a ; Store in wd11e (input for IsPokemonBitSet) + ld hl, wPokedexOwned ; Grab the owned thing while you're at it + call HoFIsPokemonBitSet ; Is it owned? + jr nz, .skipArticuno ; If owned, skip + ResetEvent EVENT_BEAT_ARTICUNO ; If not, reset the event... + ld a, HS_ARTICUNO + ld [wMissableObjectIndex], a + predef ShowObject ; And restore the hide/show. +.skipArticuno ; Rinse and repeat. + ld a, DEX_ZAPDOS + ld [wd11e], a + call HoFIsPokemonBitSet + jr z, .skipZapdos + ResetEvent EVENT_BEAT_ZAPDOS + ld a, HS_ZAPDOS + ld [wMissableObjectIndex], a + predef ShowObject +.skipZapdos + ld a, DEX_MOLTRES + ld [wd11e], a + call HoFIsPokemonBitSet + jr z, .skipMoltres + ResetEvent EVENT_BEAT_MOLTRES + ld a, HS_MOLTRES + ld [wMissableObjectIndex], a + predef ShowObject +.skipMoltres + ; Omega is special. + ; If Omega wasn't obtained, it'll be available somewhere else on Silph Co. 11F. + ; Commented out until we actually do this. +; ld a, DEX_OMEGA +; ld [wd11e], a +; call HoFIsPokemonBitSet +; jr nz, .skipOmega +; ResetEvent EVENT_BEAT_OMEGA_2 +; ld a, HS_OMEGA_2 +; ld [wMissableObjectIndex], a +; predef ShowObject +;.skipOmega + ; Mew's hints aren't until the post-game, but is available regardless. + ; So, we put this here. + ld a, DEX_MEW + ld [wd11e], a + call HoFIsPokemonBitSet + jr z, .skipMew + ResetEvent EVENT_BEAT_MEW + ld a, HS_MEW + ld [wMissableObjectIndex], a + predef ShowObject +.skipMew + ; If you haven't cleared the game yet, you've not met the Galarian Birds. + ; So we may as well skip processing all this. + CheckEvent EVENT_POST_GAME_ATTAINED + jp z, .skipGalarianBirdsAndMewtwo + ld a, DEX_ARTICUNO_G + ld [wd11e], a + call HoFIsPokemonBitSet + jr z, .skipArticunoG + ResetEvent EVENT_BEAT_ARTICUNO_G + ld a, HS_GARNET_ARTICUNO_G + ld [wMissableObjectIndex], a + predef ShowObject +.skipArticunoG + ld a, DEX_ZAPDOS_G + ld [wd11e], a + call HoFIsPokemonBitSet + jr z, .skipZapdosG + ResetEvent EVENT_BEAT_ZAPDOSG + ld a, HS_BRUNSWICK_ZAPDOS_G_2 + ld [wMissableObjectIndex], a + predef ShowObject +.skipZapdosG + ld a, DEX_MOLTRES_G + ld [wd11e], a + call HoFIsPokemonBitSet + jr z, .skipMoltresG + ResetEvent EVENT_BEAT_GALARIAN_MOLTRES + ld a, HS_MOLTRES_G + ld [wMissableObjectIndex], a + predef ShowObject +.skipMoltresG + ld a, DEX_MEWTWO + ld [wd11e], a + call HoFIsPokemonBitSet + jr z, .skipGalarianBirdsAndMewtwo + ResetEvent EVENT_BEAT_MEWTWO + ld a, HS_MEWTWO + ld [wMissableObjectIndex], a + predef ShowObject +.skipGalarianBirdsAndMewtwo + ; We set this last to save on processing earlier in the script. + SetEvent EVENT_POST_GAME_ATTAINED + ret + ObjectsToShow: db HS_ROUTE_1_OAK ; Oak post-game fight db -1 ; end @@ -146,3 +245,24 @@ ObjectsToHide: db HS_MT_MOON_CRATER_GUARD ; Mt. Moon Crater access db HS_CERULEAN_CAVE_GUY ; Cerulean Cave access db -1 ; end + +; Farcalling this caused weird issues so I'm just using a clone +; This is a function used in engine/menus/pokedex.asm to check if a Pokemon is in the dex. +; We use this to reset Legendary Pokemon after the Elite Four. +; tests if a pokemon's bit is set in the seen or owned pokemon bit fields +; INPUT: +; [wd11e] = pokedex number +; hl = address of bit field +; OUTPUT: +; 0 = Not Owned +; 1 = Owned +HoFIsPokemonBitSet: + ld hl, wPokedexOwned + ld a, [wd11e] + dec a + ld c, a + ld b, FLAG_TEST + predef FlagActionPredef + ld a, c + and a + ret From 0c4d3c87316e844f6d7e5864c738f43cc87f9fd4 Mon Sep 17 00:00:00 2001 From: Llinos Evans <36418502+PlagueVonKarma@users.noreply.github.com> Date: Sat, 8 Jul 2023 15:52:31 +0100 Subject: [PATCH 2/6] Optimise hide/show --- scripts/HallOfFame.asm | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/scripts/HallOfFame.asm b/scripts/HallOfFame.asm index 79450ffa..ed99903d 100644 --- a/scripts/HallOfFame.asm +++ b/scripts/HallOfFame.asm @@ -131,8 +131,7 @@ PostGameSetup: cp -1 ret z push hl - ld [wMissableObjectIndex], a - predef ShowObject + call ShowThis pop hl jr .loop2 @@ -147,8 +146,7 @@ ResetLegendaryPokemon: jr nz, .skipArticuno ; If owned, skip ResetEvent EVENT_BEAT_ARTICUNO ; If not, reset the event... ld a, HS_ARTICUNO - ld [wMissableObjectIndex], a - predef ShowObject ; And restore the hide/show. + call ShowThis ; And restore the hide/show. .skipArticuno ; Rinse and repeat. ld a, DEX_ZAPDOS ld [wd11e], a @@ -156,8 +154,7 @@ ResetLegendaryPokemon: jr z, .skipZapdos ResetEvent EVENT_BEAT_ZAPDOS ld a, HS_ZAPDOS - ld [wMissableObjectIndex], a - predef ShowObject + call ShowThis .skipZapdos ld a, DEX_MOLTRES ld [wd11e], a @@ -165,8 +162,7 @@ ResetLegendaryPokemon: jr z, .skipMoltres ResetEvent EVENT_BEAT_MOLTRES ld a, HS_MOLTRES - ld [wMissableObjectIndex], a - predef ShowObject + call ShowThis .skipMoltres ; Omega is special. ; If Omega wasn't obtained, it'll be available somewhere else on Silph Co. 11F. @@ -177,8 +173,7 @@ ResetLegendaryPokemon: ; jr nz, .skipOmega ; ResetEvent EVENT_BEAT_OMEGA_2 ; ld a, HS_OMEGA_2 -; ld [wMissableObjectIndex], a -; predef ShowObject +; call ShowThis ;.skipOmega ; Mew's hints aren't until the post-game, but is available regardless. ; So, we put this here. @@ -188,8 +183,7 @@ ResetLegendaryPokemon: jr z, .skipMew ResetEvent EVENT_BEAT_MEW ld a, HS_MEW - ld [wMissableObjectIndex], a - predef ShowObject + call ShowThis .skipMew ; If you haven't cleared the game yet, you've not met the Galarian Birds. ; So we may as well skip processing all this. @@ -201,8 +195,7 @@ ResetLegendaryPokemon: jr z, .skipArticunoG ResetEvent EVENT_BEAT_ARTICUNO_G ld a, HS_GARNET_ARTICUNO_G - ld [wMissableObjectIndex], a - predef ShowObject + call ShowThis .skipArticunoG ld a, DEX_ZAPDOS_G ld [wd11e], a @@ -210,8 +203,7 @@ ResetLegendaryPokemon: jr z, .skipZapdosG ResetEvent EVENT_BEAT_ZAPDOSG ld a, HS_BRUNSWICK_ZAPDOS_G_2 - ld [wMissableObjectIndex], a - predef ShowObject + call ShowThis .skipZapdosG ld a, DEX_MOLTRES_G ld [wd11e], a @@ -219,8 +211,7 @@ ResetLegendaryPokemon: jr z, .skipMoltresG ResetEvent EVENT_BEAT_GALARIAN_MOLTRES ld a, HS_MOLTRES_G - ld [wMissableObjectIndex], a - predef ShowObject + call ShowThis .skipMoltresG ld a, DEX_MEWTWO ld [wd11e], a @@ -228,13 +219,17 @@ ResetLegendaryPokemon: jr z, .skipGalarianBirdsAndMewtwo ResetEvent EVENT_BEAT_MEWTWO ld a, HS_MEWTWO - ld [wMissableObjectIndex], a - predef ShowObject + call ShowThis .skipGalarianBirdsAndMewtwo ; We set this last to save on processing earlier in the script. SetEvent EVENT_POST_GAME_ATTAINED ret - + +ShowThis: + ld [wMissableObjectIndex], a + predef ShowObject + ret + ObjectsToShow: db HS_ROUTE_1_OAK ; Oak post-game fight db -1 ; end From 2ca3ea175f5acec34a7ce3d55ce7b534e6a7f555 Mon Sep 17 00:00:00 2001 From: Llinos Evans <36418502+PlagueVonKarma@users.noreply.github.com> Date: Sat, 8 Jul 2023 15:54:06 +0100 Subject: [PATCH 3/6] extra optimisation --- scripts/HallOfFame.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/HallOfFame.asm b/scripts/HallOfFame.asm index ed99903d..9b4fd349 100644 --- a/scripts/HallOfFame.asm +++ b/scripts/HallOfFame.asm @@ -141,7 +141,6 @@ PostGameSetup: ResetLegendaryPokemon: ld a, DEX_ARTICUNO ; Load dex number ld [wd11e], a ; Store in wd11e (input for IsPokemonBitSet) - ld hl, wPokedexOwned ; Grab the owned thing while you're at it call HoFIsPokemonBitSet ; Is it owned? jr nz, .skipArticuno ; If owned, skip ResetEvent EVENT_BEAT_ARTICUNO ; If not, reset the event... @@ -244,6 +243,7 @@ ObjectsToHide: ; Farcalling this caused weird issues so I'm just using a clone ; This is a function used in engine/menus/pokedex.asm to check if a Pokemon is in the dex. ; We use this to reset Legendary Pokemon after the Elite Four. +; It does have the optimisation of loading wPokedexOwned for processing, anyway. ; tests if a pokemon's bit is set in the seen or owned pokemon bit fields ; INPUT: ; [wd11e] = pokedex number From 24a89f1fd7e3e59d429f25607d522c80f9a59e12 Mon Sep 17 00:00:00 2001 From: Llinos Evans <36418502+PlagueVonKarma@users.noreply.github.com> Date: Sat, 8 Jul 2023 15:54:53 +0100 Subject: [PATCH 4/6] this can be optimised too --- scripts/HallOfFame.asm | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/scripts/HallOfFame.asm b/scripts/HallOfFame.asm index 9b4fd349..cd817282 100644 --- a/scripts/HallOfFame.asm +++ b/scripts/HallOfFame.asm @@ -140,7 +140,6 @@ PostGameSetup: ; It's really suboptimal and I think there is a way to make it better. ResetLegendaryPokemon: ld a, DEX_ARTICUNO ; Load dex number - ld [wd11e], a ; Store in wd11e (input for IsPokemonBitSet) call HoFIsPokemonBitSet ; Is it owned? jr nz, .skipArticuno ; If owned, skip ResetEvent EVENT_BEAT_ARTICUNO ; If not, reset the event... @@ -148,7 +147,6 @@ ResetLegendaryPokemon: call ShowThis ; And restore the hide/show. .skipArticuno ; Rinse and repeat. ld a, DEX_ZAPDOS - ld [wd11e], a call HoFIsPokemonBitSet jr z, .skipZapdos ResetEvent EVENT_BEAT_ZAPDOS @@ -156,7 +154,6 @@ ResetLegendaryPokemon: call ShowThis .skipZapdos ld a, DEX_MOLTRES - ld [wd11e], a call HoFIsPokemonBitSet jr z, .skipMoltres ResetEvent EVENT_BEAT_MOLTRES @@ -177,7 +174,6 @@ ResetLegendaryPokemon: ; Mew's hints aren't until the post-game, but is available regardless. ; So, we put this here. ld a, DEX_MEW - ld [wd11e], a call HoFIsPokemonBitSet jr z, .skipMew ResetEvent EVENT_BEAT_MEW @@ -189,7 +185,6 @@ ResetLegendaryPokemon: CheckEvent EVENT_POST_GAME_ATTAINED jp z, .skipGalarianBirdsAndMewtwo ld a, DEX_ARTICUNO_G - ld [wd11e], a call HoFIsPokemonBitSet jr z, .skipArticunoG ResetEvent EVENT_BEAT_ARTICUNO_G @@ -197,7 +192,6 @@ ResetLegendaryPokemon: call ShowThis .skipArticunoG ld a, DEX_ZAPDOS_G - ld [wd11e], a call HoFIsPokemonBitSet jr z, .skipZapdosG ResetEvent EVENT_BEAT_ZAPDOSG @@ -205,7 +199,6 @@ ResetLegendaryPokemon: call ShowThis .skipZapdosG ld a, DEX_MOLTRES_G - ld [wd11e], a call HoFIsPokemonBitSet jr z, .skipMoltresG ResetEvent EVENT_BEAT_GALARIAN_MOLTRES @@ -213,7 +206,6 @@ ResetLegendaryPokemon: call ShowThis .skipMoltresG ld a, DEX_MEWTWO - ld [wd11e], a call HoFIsPokemonBitSet jr z, .skipGalarianBirdsAndMewtwo ResetEvent EVENT_BEAT_MEWTWO @@ -252,6 +244,7 @@ ObjectsToHide: ; 0 = Not Owned ; 1 = Owned HoFIsPokemonBitSet: + ld [wd11e], a ld hl, wPokedexOwned ld a, [wd11e] dec a From 2b1b29a0c77b3f0cb405793c5c743e7923b6a075 Mon Sep 17 00:00:00 2001 From: Llinos Evans <36418502+PlagueVonKarma@users.noreply.github.com> Date: Sat, 8 Jul 2023 16:02:27 +0100 Subject: [PATCH 5/6] Update HallOfFame.asm --- scripts/HallOfFame.asm | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/HallOfFame.asm b/scripts/HallOfFame.asm index cd817282..c3c32441 100644 --- a/scripts/HallOfFame.asm +++ b/scripts/HallOfFame.asm @@ -219,7 +219,6 @@ ResetLegendaryPokemon: ShowThis: ld [wMissableObjectIndex], a predef ShowObject - ret ObjectsToShow: db HS_ROUTE_1_OAK ; Oak post-game fight From f4eccdb77ea51cc873bc6503e74a6ec7033eab0c Mon Sep 17 00:00:00 2001 From: Llinos Evans <36418502+PlagueVonKarma@users.noreply.github.com> Date: Sat, 8 Jul 2023 16:03:50 +0100 Subject: [PATCH 6/6] Update IndigoPlateauLobby.asm --- data/maps/objects/IndigoPlateauLobby.asm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/maps/objects/IndigoPlateauLobby.asm b/data/maps/objects/IndigoPlateauLobby.asm index f8babc40..eae9fc66 100644 --- a/data/maps/objects/IndigoPlateauLobby.asm +++ b/data/maps/objects/IndigoPlateauLobby.asm @@ -4,8 +4,8 @@ IndigoPlateauLobby_Object: def_warp_events warp_event 7, 11, LAST_MAP, 1 warp_event 8, 11, LAST_MAP, 2 - warp_event 8, 0, HALL_OF_FAME, 1 ; test post-game setup - ;warp_event 8, 0, LORELEIS_ROOM, 1 + ;warp_event 8, 0, HALL_OF_FAME, 1 ; test post-game setup + warp_event 8, 0, LORELEIS_ROOM, 1 def_bg_events