diff options
| author | Rangi <35663410+Rangi42@users.noreply.github.com> | 2026-01-07 22:05:37 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-07 22:05:37 -0500 |
| commit | 0e49aef88ef94b9d3e80d89e4eb718e9425045df (patch) | |
| tree | c63433287b9e2aceda14ff977cc06875cd0735d3 /engine/events/hidden_events | |
| parent | Use macros to enforce "missable/hide/show object" constraints, and rename the... (diff) | |
| download | pokeyellow-0e49aef88ef94b9d3e80d89e4eb718e9425045df.tar.gz pokeyellow-0e49aef88ef94b9d3e80d89e4eb718e9425045df.tar.xz pokeyellow-0e49aef88ef94b9d3e80d89e4eb718e9425045df.zip | |
Use macros to enforce "hidden object" constraints, and rename them to "hidden events" (#559)
Diffstat (limited to 'engine/events/hidden_events')
25 files changed, 1323 insertions, 0 deletions
diff --git a/engine/events/hidden_events/bench_guys.asm b/engine/events/hidden_events/bench_guys.asm new file mode 100644 index 00000000..e5a2a724 --- /dev/null +++ b/engine/events/hidden_events/bench_guys.asm @@ -0,0 +1,107 @@ +PrintBenchGuyText: + call EnableAutoTextBoxDrawing + ld hl, BenchGuyTextPointers + ld a, [wCurMap] + ld b, a +.loop + ld a, [hli] + cp -1 + ret z + cp b + jr z, .match + inc hl + inc hl + jr .loop +.match + ld a, [hli] + ld b, a + ld a, [wSpritePlayerStateData1FacingDirection] + cp b + + ; bug: an 'inc hl' instruction is needed before looping back. When trying to + ; talk to a bench guy from above, this Sprite Facing test will fail, and the + ; next loop iteration will be misaligned within BenchGuyTextPointers table. + ; As a result, the routine will miss the terminator byte, and continue to + ; process data beyond the table boundary. + ; It seems that it will only return after starting to read data from VRAM + ; (According to Pan Docs, during PPU mode 3, reads return garbage value, + ; usually $FF). + jr nz, .loop ; player isn't facing the bench guy + ld a, [hl] + jp PrintPredefTextID + +INCLUDE "data/events/bench_guys.asm" + +ViridianCityPokecenterBenchGuyText:: + text_far _ViridianCityPokecenterGuyText + text_end + +PewterCityPokecenterBenchGuyText:: + text_far _PewterCityPokecenterGuyText + text_end + +CeruleanCityPokecenterBenchGuyText:: + text_far _CeruleanPokecenterGuyText + text_end + +LavenderCityPokecenterBenchGuyText:: + text_far _LavenderPokecenterGuyText + text_end + +MtMoonPokecenterBenchGuyText:: + text_far _MtMoonPokecenterBenchGuyText + text_end + +RockTunnelPokecenterBenchGuyText:: + text_far _RockTunnelPokecenterGuyText + text_end + +UnusedBenchGuyText1:: + text_far _UnusedBenchGuyText1 + text_end + +UnusedBenchGuyText2:: + text_far _UnusedBenchGuyText2 + text_end + +UnusedBenchGuyText3:: + text_far _UnusedBenchGuyText3 + text_end + +VermilionCityPokecenterBenchGuyText:: + text_far _VermilionPokecenterGuyText + text_end + +CeladonCityPokecenterBenchGuyText:: + text_far _CeladonCityPokecenterGuyText + text_end + +FuchsiaCityPokecenterBenchGuyText:: + text_far _FuchsiaCityPokecenterGuyText + text_end + +CinnabarIslandPokecenterBenchGuyText:: + text_far _CinnabarPokecenterGuyText + text_end + +SaffronCityPokecenterBenchGuyText:: + text_asm + CheckEvent EVENT_BEAT_SILPH_CO_GIOVANNI + ld hl, SaffronCityPokecenterBenchGuyText2 + jr nz, .printText + ld hl, SaffronCityPokecenterBenchGuyText1 +.printText + call PrintText + jp TextScriptEnd + +SaffronCityPokecenterBenchGuyText1: + text_far _SaffronCityPokecenterGuyText1 + text_end + +SaffronCityPokecenterBenchGuyText2: + text_far _SaffronCityPokecenterGuyText2 + text_end + +CeladonCityHotelText:: + text_far _CeladonCityHotelText + text_end diff --git a/engine/events/hidden_events/bills_house_pc.asm b/engine/events/hidden_events/bills_house_pc.asm new file mode 100644 index 00000000..3972e20c --- /dev/null +++ b/engine/events/hidden_events/bills_house_pc.asm @@ -0,0 +1,134 @@ +BillsHousePC: + call EnableAutoTextBoxDrawing + ld a, [wSpritePlayerStateData1FacingDirection] + cp SPRITE_FACING_UP + ret nz + CheckEvent EVENT_LEFT_BILLS_HOUSE_AFTER_HELPING + jr nz, .displayBillsHousePokemonList + CheckEventReuseA EVENT_USED_CELL_SEPARATOR_ON_BILL + jr nz, .displayBillsHouseMonitorText + CheckEventReuseA EVENT_BILL_SAID_USE_CELL_SEPARATOR + jr nz, .doCellSeparator +.displayBillsHouseMonitorText + tx_pre_jump BillsHouseMonitorText +.doCellSeparator + ld a, $1 + ld [wDoNotWaitForButtonPressAfterDisplayingText], a + tx_pre BillsHouseInitiatedText + ld c, 32 + call DelayFrames + ld a, SFX_TINK + call PlaySound + call WaitForSoundToFinish + ld c, 80 + call DelayFrames + ld a, SFX_SHRINK + call PlaySound + call WaitForSoundToFinish + ld c, 48 + call DelayFrames + ld a, SFX_TINK + call PlaySound + call WaitForSoundToFinish + ld c, 32 + call DelayFrames + ld a, SFX_GET_ITEM_1 + call PlaySound + call WaitForSoundToFinish + call PlayDefaultMusic + SetEvent EVENT_USED_CELL_SEPARATOR_ON_BILL + ret +.displayBillsHousePokemonList + ld a, $1 + ld [wDoNotWaitForButtonPressAfterDisplayingText], a + tx_pre BillsHousePokemonList + ret + +BillsHouseMonitorText:: + text_far _BillsHouseMonitorText + text_end + +BillsHouseInitiatedText:: + text_far _BillsHouseInitiatedText + text_promptbutton + text_asm + ld a, SFX_STOP_ALL_MUSIC + ld [wNewSoundID], a + call PlaySound + ld c, 16 + call DelayFrames + ld a, SFX_SWITCH + call PlaySound + call WaitForSoundToFinish + ld c, 60 + call DelayFrames + jp TextScriptEnd + +BillsHousePokemonList:: + text_asm + call SaveScreenTilesToBuffer1 + ld hl, BillsHousePokemonListText1 + call PrintText + xor a + ld [wMenuItemOffset], a ; not used + ld [wCurrentMenuItem], a + ld [wLastMenuItem], a + ld a, PAD_A | PAD_B + ld [wMenuWatchedKeys], a + ld a, 4 + ld [wMaxMenuItem], a + ld a, 2 + ld [wTopMenuItemY], a + ld a, 1 + ld [wTopMenuItemX], a +.billsPokemonLoop + ld hl, wStatusFlags5 + set BIT_NO_TEXT_DELAY, [hl] + hlcoord 0, 0 + ld b, 10 + ld c, 9 + call TextBoxBorder + hlcoord 2, 2 + ld de, BillsMonListText + call PlaceString + ld hl, BillsHousePokemonListText2 + call PrintText + call SaveScreenTilesToBuffer2 + call HandleMenuInput + bit B_PAD_B, a + jr nz, .cancel + ld a, [wCurrentMenuItem] + add EEVEE + cp EEVEE + jr z, .displayPokedex + cp FLAREON + jr z, .displayPokedex + cp JOLTEON + jr z, .displayPokedex + cp VAPOREON + jr z, .displayPokedex + jr .cancel +.displayPokedex + call DisplayPokedex + call LoadScreenTilesFromBuffer2 + jr .billsPokemonLoop +.cancel + ld hl, wStatusFlags5 + res BIT_NO_TEXT_DELAY, [hl] + call LoadScreenTilesFromBuffer2 + jp TextScriptEnd + +BillsHousePokemonListText1: + text_far _BillsHousePokemonListText1 + text_end + +BillsMonListText: + db "EEVEE" + next "FLAREON" + next "JOLTEON" + next "VAPOREON" + next "CANCEL@" + +BillsHousePokemonListText2: + text_far _BillsHousePokemonListText2 + text_end diff --git a/engine/events/hidden_events/blues_room.asm b/engine/events/hidden_events/blues_room.asm new file mode 100644 index 00000000..bcbad556 --- /dev/null +++ b/engine/events/hidden_events/blues_room.asm @@ -0,0 +1,13 @@ + + ret ; unused + +UnusedPredefText:: + db "@" + +PrintBookcaseText: + call EnableAutoTextBoxDrawing + tx_pre_jump BookcaseText + +BookcaseText:: + text_far _BookcaseText + text_end diff --git a/engine/events/hidden_events/book_or_sculpture.asm b/engine/events/hidden_events/book_or_sculpture.asm new file mode 100644 index 00000000..e04f4047 --- /dev/null +++ b/engine/events/hidden_events/book_or_sculpture.asm @@ -0,0 +1,21 @@ +BookOrSculptureText:: + text_asm + ld hl, PokemonBooksText + ld a, [wCurMapTileset] + cp MANSION ; Celadon Mansion tileset + jr nz, .ok + lda_coord 8, 6 + cp $38 + jr nz, .ok + ld hl, DiglettSculptureText +.ok + call PrintText + jp TextScriptEnd + +PokemonBooksText: + text_far _PokemonBooksText + text_end + +DiglettSculptureText: + text_far _DiglettSculptureText + text_end diff --git a/engine/events/hidden_events/bookshelves.asm b/engine/events/hidden_events/bookshelves.asm new file mode 100644 index 00000000..813cfc49 --- /dev/null +++ b/engine/events/hidden_events/bookshelves.asm @@ -0,0 +1,39 @@ +; prints text for bookshelves in buildings without sign events +PrintBookshelfText:: + ld a, [wSpritePlayerStateData1FacingDirection] + cp SPRITE_FACING_UP + jr nz, .noMatch +; facing up + ld a, [wCurMapTileset] + ld b, a + lda_coord 8, 7 + ld c, a + ld hl, BookshelfTileIDs +.loop + ld a, [hli] + cp $ff + jr z, .noMatch + cp b + jr nz, .nextBookshelfEntry1 + ld a, [hli] + cp c + jr nz, .nextBookshelfEntry2 + ld a, [hl] + push af + call EnableAutoTextBoxDrawing + pop af + call PrintPredefTextID + xor a + ldh [hInteractedWithBookshelf], a + ret +.nextBookshelfEntry1 + inc hl +.nextBookshelfEntry2 + inc hl + jr .loop +.noMatch + ld a, $ff + ldh [hInteractedWithBookshelf], a + farjp PrintCardKeyText + +INCLUDE "data/tilesets/bookshelf_tile_ids.asm" diff --git a/engine/events/hidden_events/cinnabar_gym_quiz.asm b/engine/events/hidden_events/cinnabar_gym_quiz.asm new file mode 100644 index 00000000..9762c214 --- /dev/null +++ b/engine/events/hidden_events/cinnabar_gym_quiz.asm @@ -0,0 +1,200 @@ +PrintCinnabarQuiz: + ld a, [wSpritePlayerStateData1FacingDirection] + cp SPRITE_FACING_UP + ret nz + call EnableAutoTextBoxDrawing + tx_pre_jump CinnabarGymQuiz + +CinnabarGymQuiz:: + text_asm + xor a + ld [wOpponentAfterWrongAnswer], a + ld a, [wHiddenEventFunctionArgument] + push af + and $f + ldh [hGymGateIndex], a + pop af + and $f0 + swap a + ldh [hGymGateAnswer], a + ld hl, CinnabarGymQuizIntroText + call PrintText + ldh a, [hGymGateIndex] + dec a + add a + ld d, 0 + ld e, a + ld hl, CinnabarQuizQuestions + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + call PrintText + ld a, 1 + ld [wDoNotWaitForButtonPressAfterDisplayingText], a + call CinnabarGymQuiz_AskQuestion + jp TextScriptEnd + +CinnabarGymQuizIntroText: + text_far _CinnabarGymQuizIntroText + text_end + +CinnabarQuizQuestions: + dw CinnabarQuizQuestionsText1 + dw CinnabarQuizQuestionsText2 + dw CinnabarQuizQuestionsText3 + dw CinnabarQuizQuestionsText4 + dw CinnabarQuizQuestionsText5 + dw CinnabarQuizQuestionsText6 + +CinnabarQuizQuestionsText1: + text_far _CinnabarQuizQuestionsText1 + text_end + +CinnabarQuizQuestionsText2: + text_far _CinnabarQuizQuestionsText2 + text_end + +CinnabarQuizQuestionsText3: + text_far _CinnabarQuizQuestionsText3 + text_end + +CinnabarQuizQuestionsText4: + text_far _CinnabarQuizQuestionsText4 + text_end + +CinnabarQuizQuestionsText5: + text_far _CinnabarQuizQuestionsText5 + text_end + +CinnabarQuizQuestionsText6: + text_far _CinnabarQuizQuestionsText6 + text_end + +CinnabarGymGateFlagAction: + EventFlagAddress hl, EVENT_CINNABAR_GYM_GATE0_UNLOCKED + predef_jump FlagActionPredef + +CinnabarGymQuiz_AskQuestion: + call YesNoChoice + ldh a, [hGymGateAnswer] + ld c, a + ld a, [wCurrentMenuItem] + cp c + jr nz, .wrongAnswer + ld hl, wCurrentMapScriptFlags + set BIT_CUR_MAP_LOADED_1, [hl] + ldh a, [hGymGateIndex] + ldh [hBackupGymGateIndex], a + ld hl, CinnabarGymQuizCorrectText + call PrintText + ldh a, [hBackupGymGateIndex] + AdjustEventBit EVENT_CINNABAR_GYM_GATE0_UNLOCKED, 0 + ld c, a + ld b, FLAG_SET + call CinnabarGymGateFlagAction + jp UpdateCinnabarGymGateTileBlocks_ +.wrongAnswer + call WaitForSoundToFinish + ld a, SFX_DENIED + call PlaySound + call WaitForSoundToFinish + ld hl, CinnabarGymQuizIncorrectText + call PrintText + ldh a, [hGymGateIndex] + add $2 + AdjustEventBit EVENT_BEAT_CINNABAR_GYM_TRAINER_0, 2 + ld c, a + ld b, FLAG_TEST + EventFlagAddress hl, EVENT_BEAT_CINNABAR_GYM_TRAINER_0 + predef FlagActionPredef + ld a, c + and a + ret nz + ldh a, [hGymGateIndex] + add $2 + ld [wOpponentAfterWrongAnswer], a + ret + +CinnabarGymQuizCorrectText: + sound_get_item_1 + text_far _CinnabarGymQuizCorrectText + text_promptbutton + text_asm + + ldh a, [hBackupGymGateIndex] + AdjustEventBit EVENT_CINNABAR_GYM_GATE0_UNLOCKED, 0 + ld c, a + ld b, FLAG_TEST + call CinnabarGymGateFlagAction + ld a, c + and a + jp nz, TextScriptEnd + call WaitForSoundToFinish + ld a, SFX_GO_INSIDE + call PlaySound + call WaitForSoundToFinish + jp TextScriptEnd + +CinnabarGymQuizIncorrectText: + text_far _CinnabarGymQuizIncorrectText + text_end + +UpdateCinnabarGymGateTileBlocks_:: +; Update the overworld map with open floor blocks or locked gate blocks +; depending on event flags. + ld a, 6 + ldh [hGymGateIndex], a +.loop + ldh a, [hGymGateIndex] + dec a + add a + add a + ld d, 0 + ld e, a + ld hl, CinnabarGymGateCoords + add hl, de + ld a, [hli] + ld b, [hl] + ld c, a + inc hl + ld a, [hl] + ld [wGymGateTileBlock], a + push bc + ldh a, [hGymGateIndex] + ldh [hBackupGymGateIndex], a + AdjustEventBit EVENT_CINNABAR_GYM_GATE0_UNLOCKED, 0 + ld c, a + ld b, FLAG_TEST + call CinnabarGymGateFlagAction + ld a, c + and a + jr nz, .unlocked + ld a, [wGymGateTileBlock] + jr .next +.unlocked + ld a, $e +.next + pop bc + ld [wNewTileBlockID], a + predef ReplaceTileBlock + ld hl, hGymGateIndex + dec [hl] + jr nz, .loop + ret + +MACRO gym_gate_coord + db \1, \2, \3, 0 +ENDM + +DEF HORIZONTAL_GATE_BLOCK EQU $54 +DEF VERTICAL_GATE_BLOCK EQU $5f + +CinnabarGymGateCoords: + ; x coord, y coord, block id + gym_gate_coord 9, 3, HORIZONTAL_GATE_BLOCK + gym_gate_coord 6, 3, HORIZONTAL_GATE_BLOCK + gym_gate_coord 6, 6, HORIZONTAL_GATE_BLOCK + gym_gate_coord 3, 8, VERTICAL_GATE_BLOCK + gym_gate_coord 2, 6, HORIZONTAL_GATE_BLOCK + gym_gate_coord 2, 3, HORIZONTAL_GATE_BLOCK diff --git a/engine/events/hidden_events/elevator.asm b/engine/events/hidden_events/elevator.asm new file mode 100644 index 00000000..ab0f731f --- /dev/null +++ b/engine/events/hidden_events/elevator.asm @@ -0,0 +1,3 @@ +ElevatorText:: + text_far _ElevatorText + text_end diff --git a/engine/events/hidden_events/fighting_dojo.asm b/engine/events/hidden_events/fighting_dojo.asm new file mode 100644 index 00000000..b4f89985 --- /dev/null +++ b/engine/events/hidden_events/fighting_dojo.asm @@ -0,0 +1,23 @@ +PrintFightingDojoText2: + call EnableAutoTextBoxDrawing + tx_pre_jump EnemiesOnEverySideText + +EnemiesOnEverySideText:: + text_far _EnemiesOnEverySideText + text_end + +PrintFightingDojoText3: + call EnableAutoTextBoxDrawing + tx_pre_jump WhatGoesAroundComesAroundText + +WhatGoesAroundComesAroundText:: + text_far _WhatGoesAroundComesAroundText + text_end + +PrintFightingDojoText: + call EnableAutoTextBoxDrawing + tx_pre_jump FightingDojoText + +FightingDojoText:: + text_far _FightingDojoText + text_end diff --git a/engine/events/hidden_events/gym_statues.asm b/engine/events/hidden_events/gym_statues.asm new file mode 100644 index 00000000..1c7eb970 --- /dev/null +++ b/engine/events/hidden_events/gym_statues.asm @@ -0,0 +1,39 @@ +GymStatues: +; if in a gym and have the corresponding badge, a = GymStatueText2_id and jp PrintPredefTextID +; if in a gym and don't have the corresponding badge, a = GymStatueText1_id and jp PrintPredefTextID +; else ret + call EnableAutoTextBoxDrawing + ld a, [wSpritePlayerStateData1FacingDirection] + cp SPRITE_FACING_UP + ret nz + ld hl, MapBadgeFlags + ld a, [wCurMap] + ld b, a +.loop + ld a, [hli] + cp $ff + ret z + cp b + jr z, .match + inc hl + jr .loop +.match + ld b, [hl] + ld a, [wBeatGymFlags] + and b + cp b + tx_pre_id GymStatueText2 + jr z, .haveBadge + tx_pre_id GymStatueText1 +.haveBadge + jp PrintPredefTextID + +INCLUDE "data/maps/badge_maps.asm" + +GymStatueText1:: + text_far _GymStatueText1 + text_end + +GymStatueText2:: + text_far _GymStatueText2 + text_end diff --git a/engine/events/hidden_events/indigo_plateau_hq.asm b/engine/events/hidden_events/indigo_plateau_hq.asm new file mode 100644 index 00000000..e8fd0220 --- /dev/null +++ b/engine/events/hidden_events/indigo_plateau_hq.asm @@ -0,0 +1,10 @@ +PrintIndigoPlateauHQText: + ld a, [wSpritePlayerStateData1FacingDirection] + cp SPRITE_FACING_UP + ret nz + call EnableAutoTextBoxDrawing + tx_pre_jump IndigoPlateauHQText + +IndigoPlateauHQText:: + text_far _IndigoPlateauHQText + text_end diff --git a/engine/events/hidden_events/indigo_plateau_statues.asm b/engine/events/hidden_events/indigo_plateau_statues.asm new file mode 100644 index 00000000..f78a5a72 --- /dev/null +++ b/engine/events/hidden_events/indigo_plateau_statues.asm @@ -0,0 +1,24 @@ +IndigoPlateauStatues:: + text_asm + ld hl, IndigoPlateauStatuesText1 + call PrintText + ld a, [wXCoord] + bit 0, a ; even or odd? + ld hl, IndigoPlateauStatuesText2 + jr nz, .ok + ld hl, IndigoPlateauStatuesText3 +.ok + call PrintText + jp TextScriptEnd + +IndigoPlateauStatuesText1: + text_far _IndigoPlateauStatuesText1 + text_end + +IndigoPlateauStatuesText2: + text_far _IndigoPlateauStatuesText2 + text_end + +IndigoPlateauStatuesText3: + text_far _IndigoPlateauStatuesText3 + text_end diff --git a/engine/events/hidden_events/magazines.asm b/engine/events/hidden_events/magazines.asm new file mode 100644 index 00000000..b58636ff --- /dev/null +++ b/engine/events/hidden_events/magazines.asm @@ -0,0 +1,8 @@ +PrintMagazinesText: + call EnableAutoTextBoxDrawing + tx_pre MagazinesText + ret + +MagazinesText:: + text_far _MagazinesText + text_end diff --git a/engine/events/hidden_events/museum_fossils.asm b/engine/events/hidden_events/museum_fossils.asm new file mode 100644 index 00000000..df74293f --- /dev/null +++ b/engine/events/hidden_events/museum_fossils.asm @@ -0,0 +1,51 @@ +AerodactylFossil: + ld a, FOSSIL_AERODACTYL + ld [wCurPartySpecies], a + call DisplayMonFrontSpriteInBox + call EnableAutoTextBoxDrawing + tx_pre AerodactylFossilText + ret + +AerodactylFossilText:: + text_far _AerodactylFossilText + text_end + +KabutopsFossil: + ld a, FOSSIL_KABUTOPS + ld [wCurPartySpecies], a + call DisplayMonFrontSpriteInBox + call EnableAutoTextBoxDrawing + tx_pre KabutopsFossilText + ret + +KabutopsFossilText:: + text_far _KabutopsFossilText + text_end + +DisplayMonFrontSpriteInBox: +; Displays a pokemon's front sprite in a pop-up window. + ld a, 1 + ldh [hAutoBGTransferEnabled], a + call Delay3 + xor a + ldh [hWY], a + call SaveScreenTilesToBuffer1 + ld a, MON_SPRITE_POPUP + ld [wTextBoxID], a + call DisplayTextBoxID + call UpdateSprites + ld a, [wCurPartySpecies] + ld [wCurSpecies], a + call GetMonHeader + ld de, vChars1 tile $31 + call LoadMonFrontSprite + ld a, $80 + ldh [hStartTileID], a + hlcoord 10, 11 + predef AnimateSendingOutMon + call WaitForTextScrollButtonPress + call LoadScreenTilesFromBuffer1 + call Delay3 + ld a, $90 + ldh [hWY], a + ret diff --git a/engine/events/hidden_events/new_bike.asm b/engine/events/hidden_events/new_bike.asm new file mode 100644 index 00000000..5bce5937 --- /dev/null +++ b/engine/events/hidden_events/new_bike.asm @@ -0,0 +1,7 @@ +PrintNewBikeText: + call EnableAutoTextBoxDrawing + tx_pre_jump NewBicycleText + +NewBicycleText:: + text_far _NewBicycleText + text_end diff --git a/engine/events/hidden_events/oaks_lab_email.asm b/engine/events/hidden_events/oaks_lab_email.asm new file mode 100644 index 00000000..b66babe0 --- /dev/null +++ b/engine/events/hidden_events/oaks_lab_email.asm @@ -0,0 +1,10 @@ +DisplayOakLabEmailText: + ld a, [wSpritePlayerStateData1FacingDirection] + cp SPRITE_FACING_UP + ret nz + call EnableAutoTextBoxDrawing + tx_pre_jump OakLabEmailText + +OakLabEmailText:: + text_far _OakLabEmailText + text_end diff --git a/engine/events/hidden_events/oaks_lab_posters.asm b/engine/events/hidden_events/oaks_lab_posters.asm new file mode 100644 index 00000000..502cf951 --- /dev/null +++ b/engine/events/hidden_events/oaks_lab_posters.asm @@ -0,0 +1,29 @@ +DisplayOakLabLeftPoster: + call EnableAutoTextBoxDrawing + tx_pre_jump PushStartText + +PushStartText:: + text_far _PushStartText + text_end + +DisplayOakLabRightPoster: + call EnableAutoTextBoxDrawing + ld hl, wPokedexOwned + ld b, wPokedexOwnedEnd - wPokedexOwned + call CountSetBits + ld a, [wNumSetBits] + cp 2 + tx_pre_id SaveOptionText + jr c, .ownLessThanTwo + ; own two or more mon + tx_pre_id StrengthsAndWeaknessesText +.ownLessThanTwo + jp PrintPredefTextID + +SaveOptionText:: + text_far _SaveOptionText + text_end + +StrengthsAndWeaknessesText:: + text_far _StrengthsAndWeaknessesText + text_end diff --git a/engine/events/hidden_events/pokecenter_pc.asm b/engine/events/hidden_events/pokecenter_pc.asm new file mode 100644 index 00000000..59867d1a --- /dev/null +++ b/engine/events/hidden_events/pokecenter_pc.asm @@ -0,0 +1,11 @@ +OpenPokemonCenterPC: + ld a, [wSpritePlayerStateData1FacingDirection] + cp SPRITE_FACING_UP + ret nz + call EnableAutoTextBoxDrawing + ld a, 1 << BIT_NO_AUTO_TEXT_BOX + ld [wAutoTextBoxDrawingControl], a + tx_pre_jump PokemonCenterPCText + +PokemonCenterPCText:: + script_pokecenter_pc diff --git a/engine/events/hidden_events/pokemon_stuff.asm b/engine/events/hidden_events/pokemon_stuff.asm new file mode 100644 index 00000000..267a191a --- /dev/null +++ b/engine/events/hidden_events/pokemon_stuff.asm @@ -0,0 +1,3 @@ +PokemonStuffText:: + text_far _PokemonStuffText + text_end diff --git a/engine/events/hidden_events/reds_room.asm b/engine/events/hidden_events/reds_room.asm new file mode 100644 index 00000000..7b8d51a0 --- /dev/null +++ b/engine/events/hidden_events/reds_room.asm @@ -0,0 +1,14 @@ +PrintRedSNESText: + call EnableAutoTextBoxDrawing + tx_pre_jump RedBedroomSNESText + +RedBedroomSNESText:: + text_far _RedBedroomSNESText + text_end + +OpenRedsPC: + call EnableAutoTextBoxDrawing + tx_pre_jump RedBedroomPCText + +RedBedroomPCText:: + script_players_pc diff --git a/engine/events/hidden_events/route_15_binoculars.asm b/engine/events/hidden_events/route_15_binoculars.asm new file mode 100644 index 00000000..733ab73e --- /dev/null +++ b/engine/events/hidden_events/route_15_binoculars.asm @@ -0,0 +1,14 @@ +Route15GateLeftBinoculars: + ld a, [wSpritePlayerStateData1FacingDirection] + cp SPRITE_FACING_UP + ret nz + call EnableAutoTextBoxDrawing + tx_pre Route15UpstairsBinocularsText + ld a, ARTICUNO + ld [wCurPartySpecies], a + call PlayCry + jp DisplayMonFrontSpriteInBox + +Route15UpstairsBinocularsText:: + text_far _Route15UpstairsBinocularsText + text_end diff --git a/engine/events/hidden_events/safari_game.asm b/engine/events/hidden_events/safari_game.asm new file mode 100644 index 00000000..fc014ce0 --- /dev/null +++ b/engine/events/hidden_events/safari_game.asm @@ -0,0 +1,83 @@ +SafariZoneCheck:: + CheckEventHL EVENT_IN_SAFARI_ZONE ; if we are not in the Safari Zone, + jr z, SafariZoneGameStillGoing ; don't bother printing game over text + ld a, [wNumSafariBalls] + and a + jr z, SafariZoneGameOver + jr SafariZoneGameStillGoing + +SafariZoneCheckSteps:: +IF DEF(_DEBUG) + call DebugPressedOrHeldB + ret nz +ENDC + ld a, [wSafariSteps] + ld b, a + ld a, [wSafariSteps + 1] + ld c, a + or b + jr z, SafariZoneGameOver + dec bc + ld a, b + ld [wSafariSteps], a + ld a, c + ld [wSafariSteps + 1], a +SafariZoneGameStillGoing: + xor a + ld [wSafariZoneGameOver], a + ret + +SafariZoneGameOver: + call EnableAutoTextBoxDrawing + xor a + ld [wAudioFadeOutControl], a + dec a ; SFX_STOP_ALL_MUSIC + call PlaySound + ld c, BANK(SFX_Safari_Zone_PA) + ld a, SFX_SAFARI_ZONE_PA + call PlayMusic +.waitForMusicToPlay + ld a, [wChannelSoundIDs + CHAN5] + cp SFX_SAFARI_ZONE_PA + jr nz, .waitForMusicToPlay + ld a, TEXT_SAFARI_GAME_OVER + ldh [hTextID], a + call DisplayTextID + xor a + ld [wPlayerMovingDirection], a + ld a, SAFARI_ZONE_GATE + ldh [hWarpDestinationMap], a + ld a, $3 + ld [wDestinationWarpID], a + ld a, SCRIPT_SAFARIZONEGATE_LEAVING_SAFARI + ld [wSafariZoneGateCurScript], a + SetEvent EVENT_SAFARI_GAME_OVER + ld a, 1 + ld [wSafariZoneGameOver], a + ret + +PrintSafariGameOverText:: + xor a + ld [wJoyIgnore], a + ld hl, SafariGameOverText + jp PrintText + +SafariGameOverText: + text_asm + ld a, [wNumSafariBalls] + and a + jr z, .noMoreSafariBalls + ld hl, TimesUpText + call PrintText +.noMoreSafariBalls + ld hl, GameOverText + call PrintText + jp TextScriptEnd + +TimesUpText: + text_far _TimesUpText + text_end + +GameOverText: + text_far _GameOverText + text_end diff --git a/engine/events/hidden_events/school_blackboard.asm b/engine/events/hidden_events/school_blackboard.asm new file mode 100644 index 00000000..71e24ed0 --- /dev/null +++ b/engine/events/hidden_events/school_blackboard.asm @@ -0,0 +1,224 @@ +PrintBlackboardLinkCableText: + call EnableAutoTextBoxDrawing + ld a, $1 + ld [wDoNotWaitForButtonPressAfterDisplayingText], a + ld a, [wHiddenEventFunctionArgument] + call PrintPredefTextID + ret + +LinkCableHelp:: + text_asm + call SaveScreenTilesToBuffer1 + ld hl, LinkCableHelpText1 + call PrintText + xor a + ld [wMenuItemOffset], a ; not used + ld [wCurrentMenuItem], a + ld [wLastMenuItem], a + ld a, PAD_A | PAD_B + ld [wMenuWatchedKeys], a + ld a, 3 + ld [wMaxMenuItem], a + ld a, 2 + ld [wTopMenuItemY], a + ld a, 1 + ld [wTopMenuItemX], a +.linkHelpLoop + ld hl, wStatusFlags5 + set BIT_NO_TEXT_DELAY, [hl] + hlcoord 0, 0 + ld b, 8 + ld c, 13 + call TextBoxBorder + hlcoord 2, 2 + ld de, HowToLinkText + call PlaceString + ld hl, LinkCableHelpText2 + call PrintText + call HandleMenuInput + bit B_PAD_B, a + jr nz, .exit + ld a, [wCurrentMenuItem] + cp 3 ; pressed a on "STOP READING" + jr z, .exit + ld hl, wStatusFlags5 + res BIT_NO_TEXT_DELAY, [hl] + ld hl, LinkCableInfoTexts + add a + ld d, 0 + ld e, a + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + call PrintText + jp .linkHelpLoop +.exit + ld hl, wStatusFlags5 + res BIT_NO_TEXT_DELAY, [hl] + call LoadScreenTilesFromBuffer1 + jp TextScriptEnd + +LinkCableHelpText1: + text_far _LinkCableHelpText1 + text_end + +LinkCableHelpText2: + text_far _LinkCableHelpText2 + text_end + +HowToLinkText: + db "HOW TO LINK" + next "COLOSSEUM" + next "TRADE CENTER" + next "STOP READING@" + +LinkCableInfoTexts: + dw LinkCableInfoText1 + dw LinkCableInfoText2 + dw LinkCableInfoText3 + +LinkCableInfoText1: + text_far _LinkCableInfoText1 + text_end + +LinkCableInfoText2: + text_far _LinkCableInfoText2 + text_end + +LinkCableInfoText3: + text_far _LinkCableInfoText3 + text_end + +ViridianSchoolBlackboard:: + text_asm + call SaveScreenTilesToBuffer1 + ld hl, ViridianSchoolBlackboardText1 + call PrintText + xor a + ld [wMenuItemOffset], a + ld [wCurrentMenuItem], a + ld [wLastMenuItem], a + ld a, PAD_LEFT | PAD_RIGHT | PAD_A | PAD_B + ld [wMenuWatchedKeys], a + ld a, 2 + ld [wMaxMenuItem], a + ld a, 2 + ld [wTopMenuItemY], a + ld a, 1 + ld [wTopMenuItemX], a +.blackboardLoop + ld hl, wStatusFlags5 + set BIT_NO_TEXT_DELAY, [hl] + hlcoord 0, 0 + lb bc, 6, 10 + call TextBoxBorder + hlcoord 1, 2 + ld de, StatusAilmentText1 + call PlaceString + hlcoord 6, 2 + ld de, StatusAilmentText2 + call PlaceString + ld hl, ViridianSchoolBlackboardText2 + call PrintText + call HandleMenuInput ; pressing up and down is handled in here + bit B_PAD_B, a ; pressed b + jr nz, .exitBlackboard + bit B_PAD_RIGHT, a + jr z, .didNotPressRight + ; move cursor to right column + ld a, 2 + ld [wMaxMenuItem], a + ld a, 2 + ld [wTopMenuItemY], a + ld a, 6 + ld [wTopMenuItemX], a + ld a, 3 ; in the the right column, use an offset to prevent overlap + ld [wMenuItemOffset], a + jr .blackboardLoop +.didNotPressRight + bit B_PAD_LEFT, a + jr z, .didNotPressLeftOrRight + ; move cursor to left column + ld a, 2 + ld [wMaxMenuItem], a + ld a, 2 + ld [wTopMenuItemY], a + ld a, 1 + ld [wTopMenuItemX], a + xor a + ld [wMenuItemOffset], a + jr .blackboardLoop +.didNotPressLeftOrRight + ld a, [wCurrentMenuItem] + ld b, a + ld a, [wMenuItemOffset] + add b + cp 5 ; cursor is pointing to "QUIT" + jr z, .exitBlackboard + ; we must have pressed a on a status condition + ; so print the text + ld hl, wStatusFlags5 + res BIT_NO_TEXT_DELAY, [hl] + ld hl, ViridianBlackboardStatusPointers + add a + ld d, 0 + ld e, a + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + call PrintText + jp .blackboardLoop +.exitBlackboard + ld hl, wStatusFlags5 + res BIT_NO_TEXT_DELAY, [hl] + call LoadScreenTilesFromBuffer1 + jp TextScriptEnd + +ViridianSchoolBlackboardText1: + text_far _ViridianSchoolBlackboardText1 + text_end + +ViridianSchoolBlackboardText2: + text_far _ViridianSchoolBlackboardText2 + text_end + +StatusAilmentText1: + db " SLP" + next " PSN" + next " PAR@" + +StatusAilmentText2: + db " BRN" + next " FRZ" + next " QUIT@" + + db "@" ; unused + +ViridianBlackboardStatusPointers: + dw ViridianBlackboardSleepText + dw ViridianBlackboardPoisonText + dw ViridianBlackboardPrlzText + dw ViridianBlackboardBurnText + dw ViridianBlackboardFrozenText + +ViridianBlackboardSleepText: + text_far _ViridianBlackboardSleepText + text_end + +ViridianBlackboardPoisonText: + text_far _ViridianBlackboardPoisonText + text_end + +ViridianBlackboardPrlzText: + text_far _ViridianBlackboardPrlzText + text_end + +ViridianBlackboardBurnText: + text_far _ViridianBlackboardBurnText + text_end + +ViridianBlackboardFrozenText: + text_far _ViridianBlackboardFrozenText + text_end diff --git a/engine/events/hidden_events/school_notebooks.asm b/engine/events/hidden_events/school_notebooks.asm new file mode 100644 index 00000000..2387c089 --- /dev/null +++ b/engine/events/hidden_events/school_notebooks.asm @@ -0,0 +1,65 @@ +PrintNotebookText: + call EnableAutoTextBoxDrawing + ld a, $1 + ld [wDoNotWaitForButtonPressAfterDisplayingText], a + ld a, [wHiddenEventFunctionArgument] + jp PrintPredefTextID + +TMNotebook:: + text_far TMNotebookText + text_waitbutton + text_end + +ViridianSchoolNotebook:: + text_asm + ld hl, ViridianSchoolNotebookText1 + call PrintText + call TurnPageSchoolNotebook + jr nz, .doneReading + ld hl, ViridianSchoolNotebookText2 + call PrintText + call TurnPageSchoolNotebook + jr nz, .doneReading + ld hl, ViridianSchoolNotebookText3 + call PrintText + call TurnPageSchoolNotebook + jr nz, .doneReading + ld hl, ViridianSchoolNotebookText4 + call PrintText + ld hl, ViridianSchoolNotebookText5 + call PrintText +.doneReading + jp TextScriptEnd + +TurnPageSchoolNotebook: + ld hl, TurnPageText + call PrintText + call YesNoChoice + ld a, [wCurrentMenuItem] + and a + ret + +TurnPageText: + text_far _TurnPageText + text_end + +ViridianSchoolNotebookText5: + text_far _ViridianSchoolNotebookText5 + text_waitbutton + text_end + +ViridianSchoolNotebookText1: + text_far _ViridianSchoolNotebookText1 + text_end + +ViridianSchoolNotebookText2: + text_far _ViridianSchoolNotebookText2 + text_end + +ViridianSchoolNotebookText3: + text_far _ViridianSchoolNotebookText3 + text_end + +ViridianSchoolNotebookText4: + text_far _ViridianSchoolNotebookText4 + text_end diff --git a/engine/events/hidden_events/town_map.asm b/engine/events/hidden_events/town_map.asm new file mode 100644 index 00000000..11f7cbc7 --- /dev/null +++ b/engine/events/hidden_events/town_map.asm @@ -0,0 +1,22 @@ +TownMapText:: + text_far _TownMapText + text_promptbutton + text_asm + ld a, $1 + ld [wDoNotWaitForButtonPressAfterDisplayingText], a + ld hl, wStatusFlags5 + set BIT_NO_TEXT_DELAY, [hl] + call GBPalWhiteOutWithDelay3 + xor a + ldh [hWY], a + inc a + ldh [hAutoBGTransferEnabled], a + call LoadFontTilePatterns + farcall DisplayTownMap + ld hl, wStatusFlags5 + res BIT_NO_TEXT_DELAY, [hl] + ld de, TextScriptEnd + push de + ldh a, [hLoadedROMBank] + push af + jp CloseTextDisplay diff --git a/engine/events/hidden_events/vermilion_gym_trash.asm b/engine/events/hidden_events/vermilion_gym_trash.asm new file mode 100644 index 00000000..40e200d6 --- /dev/null +++ b/engine/events/hidden_events/vermilion_gym_trash.asm @@ -0,0 +1,169 @@ +PrintTrashText: + call EnableAutoTextBoxDrawing + tx_pre_jump VermilionGymTrashText + +VermilionGymTrashText:: + text_far _VermilionGymTrashText + text_end + +GymTrashScript: + call EnableAutoTextBoxDrawing + ld a, [wHiddenEventFunctionArgument] + ld [wGymTrashCanIndex], a + +; Don't do the trash can puzzle if it's already been done. + CheckEvent EVENT_2ND_LOCK_OPENED + jr z, .ok + + tx_pre_jump VermilionGymTrashText + +.ok + CheckEventReuseA EVENT_1ST_LOCK_OPENED + jr nz, .trySecondLock + + ld a, [wFirstLockTrashCanIndex] + ld b, a + ld a, [wGymTrashCanIndex] + cp b + jr z, .openFirstLock + + tx_pre_id VermilionGymTrashText + jr .done + +.openFirstLock +; Next can is trying for the second switch. + SetEvent EVENT_1ST_LOCK_OPENED + + ld hl, GymTrashCans + ld a, [wGymTrashCanIndex] + ; * 5 + ld b, a + add a + add a + add b + + ld d, 0 + ld e, a + add hl, de + ld a, [hli] + +; Bug: This code should calculate a value in the range [0, 3], +; but if the mask and random number don't have any 1 bits in common, then +; the result of the AND will be 0. When 1 is subtracted from that, the value +; will become $ff. This will result in 255 being added to hl, which will cause +; hl to point to one of the zero bytes that pad the end of the ROM bank. +; Trash can 0 was intended to be able to have the second lock only when the +; first lock was in trash can 1 or 3. However, due to this bug, trash can 0 can +; have the second lock regardless of which trash can had the first lock. + + ldh [hGymTrashCanRandNumMask], a + push hl + call Random + swap a + ld b, a + ldh a, [hGymTrashCanRandNumMask] + and b + dec a + pop hl + + ld d, 0 + ld e, a + add hl, de + ld a, [hl] + and $f + ld [wSecondLockTrashCanIndex], a + + tx_pre_id VermilionGymTrashSuccessText1 + jr .done + +.trySecondLock + ld a, [wSecondLockTrashCanIndex] + ld b, a + ld a, [wGymTrashCanIndex] + cp b + jr z, .openSecondLock + +; Reset the cans. + ResetEvent EVENT_1ST_LOCK_OPENED + call Random + + and $e + ld [wFirstLockTrashCanIndex], a + + tx_pre_id VermilionGymTrashFailText + jr .done + +.openSecondLock +; Completed the trash can puzzle. + SetEvent EVENT_2ND_LOCK_OPENED + ld hl, wCurrentMapScriptFlags + set BIT_CUR_MAP_LOADED_2, [hl] + + tx_pre_id VermilionGymTrashSuccessText3 + +.done + jp PrintPredefTextID + +GymTrashCans: +; byte 0: mask for random number +; bytes 1-4: indices of the trash cans that can have the second lock +; (but see the comment above explaining a bug regarding this) +; Note that the mask is simply the number of valid trash can indices that +; follow. The remaining bytes are filled with 0 to pad the length of each entry +; to 5 bytes. + db 2, 1, 3, 0, 0 ; 0 + db 3, 0, 2, 4, 0 ; 1 + db 2, 1, 5, 0, 0 ; 2 + db 3, 0, 4, 6, 0 ; 3 + db 4, 1, 3, 5, 7 ; 4 + db 3, 2, 4, 8, 0 ; 5 + db 3, 3, 7, 9, 0 ; 6 + db 4, 4, 6, 8, 10 ; 7 + db 3, 5, 7, 11, 0 ; 8 + db 3, 6, 10, 12, 0 ; 9 + db 4, 7, 9, 11, 13 ; 10 + db 3, 8, 10, 14, 0 ; 11 + db 2, 9, 13, 0, 0 ; 12 + db 3, 10, 12, 14, 0 ; 13 + db 2, 11, 13, 0, 0 ; 14 + +VermilionGymTrashSuccessText1:: + text_far _VermilionGymTrashSuccessText1 + text_asm + call WaitForSoundToFinish + ld a, SFX_SWITCH + call PlaySound + call WaitForSoundToFinish + jp TextScriptEnd + +; unused +VermilionGymTrashSuccessText2:: + text_far _VermilionGymTrashSuccessText2 + text_end + +; unused +VermilionGymTrashSuccessPlaySfx: + text_asm + call WaitForSoundToFinish + ld a, SFX_SWITCH + call PlaySound + call WaitForSoundToFinish + jp TextScriptEnd + +VermilionGymTrashSuccessText3:: + text_far _VermilionGymTrashSuccessText3 + text_asm + call WaitForSoundToFinish + ld a, SFX_GO_INSIDE + call PlaySound + call WaitForSoundToFinish + jp TextScriptEnd + +VermilionGymTrashFailText:: + text_far _VermilionGymTrashFailText + text_asm + call WaitForSoundToFinish + ld a, SFX_DENIED + call PlaySound + call WaitForSoundToFinish + jp TextScriptEnd |
