aboutsummaryrefslogtreecommitdiffstats
path: root/engine/events/hidden_objects
diff options
context:
space:
mode:
authordannye <33dannye@gmail.com>2020-11-04 00:06:44 -0600
committerdannye <33dannye@gmail.com>2020-11-04 00:06:44 -0600
commit5647ca687b92954dcf37a6ea6bfbc9a341c32de4 (patch)
treedde1937a1bfdb3a835f4155e1c2eb8f1aaf86f63 /engine/events/hidden_objects
parentMerge pull request #55 from Deokishisu/patch-1 (diff)
downloadpokeyellow-5647ca687b92954dcf37a6ea6bfbc9a341c32de4.tar.gz
pokeyellow-5647ca687b92954dcf37a6ea6bfbc9a341c32de4.tar.xz
pokeyellow-5647ca687b92954dcf37a6ea6bfbc9a341c32de4.zip
Sync with pokered
Diffstat (limited to 'engine/events/hidden_objects')
-rw-r--r--engine/events/hidden_objects/bench_guys.asm98
-rw-r--r--engine/events/hidden_objects/bills_house_pc.asm131
-rw-r--r--engine/events/hidden_objects/blues_room.asm13
-rw-r--r--engine/events/hidden_objects/book_or_sculpture.asm21
-rw-r--r--engine/events/hidden_objects/bookshelves.asm39
-rw-r--r--engine/events/hidden_objects/cinnabar_gym_quiz.asm246
-rw-r--r--engine/events/hidden_objects/elevator.asm3
-rw-r--r--engine/events/hidden_objects/fanclub_pictures.asm23
-rw-r--r--engine/events/hidden_objects/fighting_dojo.asm23
-rw-r--r--engine/events/hidden_objects/gym_statues.asm39
-rw-r--r--engine/events/hidden_objects/indigo_plateau_hq.asm10
-rw-r--r--engine/events/hidden_objects/indigo_plateau_statues.asm24
-rw-r--r--engine/events/hidden_objects/magazines.asm8
-rw-r--r--engine/events/hidden_objects/museum_fossils.asm23
-rw-r--r--engine/events/hidden_objects/museum_fossils2.asm28
-rw-r--r--engine/events/hidden_objects/new_bike.asm7
-rw-r--r--engine/events/hidden_objects/oaks_lab_email.asm11
-rw-r--r--engine/events/hidden_objects/oaks_lab_posters.asm29
-rw-r--r--engine/events/hidden_objects/pokecenter_pc.asm11
-rw-r--r--engine/events/hidden_objects/pokemon_stuff.asm3
-rw-r--r--engine/events/hidden_objects/reds_room.asm14
-rw-r--r--engine/events/hidden_objects/route_15_binoculars.asm17
-rw-r--r--engine/events/hidden_objects/safari_game.asm78
-rw-r--r--engine/events/hidden_objects/school_blackboard.asm223
-rw-r--r--engine/events/hidden_objects/school_notebooks.asm65
-rw-r--r--engine/events/hidden_objects/town_map.asm22
-rw-r--r--engine/events/hidden_objects/vermilion_gym_trash.asm134
27 files changed, 1343 insertions, 0 deletions
diff --git a/engine/events/hidden_objects/bench_guys.asm b/engine/events/hidden_objects/bench_guys.asm
new file mode 100644
index 00000000..b41434ad
--- /dev/null
+++ b/engine/events/hidden_objects/bench_guys.asm
@@ -0,0 +1,98 @@
+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
+ 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, .asm_624f2
+ ld hl, SaffronCityPokecenterBenchGuyText1
+.asm_624f2
+ 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_objects/bills_house_pc.asm b/engine/events/hidden_objects/bills_house_pc.asm
new file mode 100644
index 00000000..bdbaff7e
--- /dev/null
+++ b/engine/events/hidden_objects/bills_house_pc.asm
@@ -0,0 +1,131 @@
+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
+ call StopAllMusic
+ 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, A_BUTTON | B_BUTTON
+ ld [wMenuWatchedKeys], a
+ ld a, 4
+ ld [wMaxMenuItem], a
+ ld a, 2
+ ld [wTopMenuItemY], a
+ ld a, 1
+ ld [wTopMenuItemX], a
+.billsPokemonLoop
+ ld hl, wd730
+ set 6, [hl]
+ hlcoord 0, 0
+ lb bc, 10, 9
+ call TextBoxBorder
+ hlcoord 2, 2
+ ld de, BillsMonListText
+ call PlaceString
+ ld hl, BillsHousePokemonListText2
+ call PrintText
+ call SaveScreenTilesToBuffer2
+ call HandleMenuInput
+ bit 1, a ; pressed b
+ 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, wd730
+ res 6, [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_objects/blues_room.asm b/engine/events/hidden_objects/blues_room.asm
new file mode 100644
index 00000000..bcbad556
--- /dev/null
+++ b/engine/events/hidden_objects/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_objects/book_or_sculpture.asm b/engine/events/hidden_objects/book_or_sculpture.asm
new file mode 100644
index 00000000..e04f4047
--- /dev/null
+++ b/engine/events/hidden_objects/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_objects/bookshelves.asm b/engine/events/hidden_objects/bookshelves.asm
new file mode 100644
index 00000000..b58444af
--- /dev/null
+++ b/engine/events/hidden_objects/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 [hFFDB], a
+ ret
+.nextBookshelfEntry1
+ inc hl
+.nextBookshelfEntry2
+ inc hl
+ jr .loop
+.noMatch
+ ld a, $ff
+ ldh [hFFDB], a
+ farjp PrintCardKeyText
+
+INCLUDE "data/tilesets/bookshelf_tile_ids.asm"
diff --git a/engine/events/hidden_objects/cinnabar_gym_quiz.asm b/engine/events/hidden_objects/cinnabar_gym_quiz.asm
new file mode 100644
index 00000000..da550c76
--- /dev/null
+++ b/engine/events/hidden_objects/cinnabar_gym_quiz.asm
@@ -0,0 +1,246 @@
+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 hl, wd475
+ res 7, [hl]
+ ld a, [wHiddenObjectFunctionArgument]
+ push af
+ and $f
+ ldh [hGymGateIndex], a
+ pop af
+ and $f0
+ swap a
+ ldh [hGymGateAnswer], a
+ ldh a, [hGymGateIndex]
+ ld hl, CinnabarGymQuizIntroText
+ cp 1
+ jr z, .onFirstQuestion
+ ld hl, CinnabarGymQuizShortIntroText
+.onFirstQuestion
+ 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_1ea92
+ jp TextScriptEnd
+
+CinnabarGymQuizDummyIntroText:
+ text_far _CinnabarGymQuizDummyIntroText
+ text_end
+
+CinnabarGymQuizIntroText:
+ text_far _CinnabarGymQuizIntroText
+ text_end
+
+CinnabarGymQuizShortIntroText:
+ text_far _CinnabarGymQuizShortIntroText
+ 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
+
+CinnabarGymQuiz_1ea92:
+ call YesNoChoice
+ ldh a, [hGymGateAnswer]
+ ld c, a
+ ld a, [wCurrentMenuItem]
+ cp c
+ jr nz, .wrongAnswer
+ ld hl, wCurrentMapScriptFlags
+ set 5, [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
+ ld hl, wd475
+ set 7, [hl]
+ 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
+
+CinnabarGymGateFlagAction:
+ EventFlagAddress hl, EVENT_CINNABAR_GYM_GATE0_UNLOCKED
+ predef_jump FlagActionPredef
+
+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
+ call CinnabarGym_ReplaceTileBlock
+ ld hl, hGymGateIndex
+ dec [hl]
+ jr nz, .loop
+ callfar RedrawMapView
+ ret
+
+gym_gate_coord: MACRO
+ db \1, \2, \3, 0
+ENDM
+
+HORIZONTAL_GATE_BLOCK EQU $54
+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
+
+
+CinnabarGym_ReplaceTileBlock:
+; basically a copy of the first half of ReplaceTileBlock
+; before checking if it is necessary to redraw the map view
+ ld hl, wOverworldMap
+ ld a, [wCurMapWidth]
+ add $6
+ ld e, a
+ ld d, $0
+ add hl, de
+ add hl, de
+ add hl, de
+ ld e, $3
+ add hl, de
+ ld e, a
+ ld a, b
+ and a
+ jr z, .addX
+.addWidthYTimesLoop
+ add hl, de
+ dec b
+ jr nz, .addWidthYTimesLoop
+.addX
+ add hl, bc
+ ld a, [wNewTileBlockID]
+ ld [hl], a
+ ret
diff --git a/engine/events/hidden_objects/elevator.asm b/engine/events/hidden_objects/elevator.asm
new file mode 100644
index 00000000..ab0f731f
--- /dev/null
+++ b/engine/events/hidden_objects/elevator.asm
@@ -0,0 +1,3 @@
+ElevatorText::
+ text_far _ElevatorText
+ text_end
diff --git a/engine/events/hidden_objects/fanclub_pictures.asm b/engine/events/hidden_objects/fanclub_pictures.asm
new file mode 100644
index 00000000..30bc72c7
--- /dev/null
+++ b/engine/events/hidden_objects/fanclub_pictures.asm
@@ -0,0 +1,23 @@
+FanClubPicture1:
+ ld a, RAPIDASH
+ ld [wcf91], a
+ call DisplayMonFrontSpriteInBox
+ call EnableAutoTextBoxDrawing
+ tx_pre FanClubPicture1Text
+ ret
+
+FanClubPicture1Text::
+ text_far _FanClubPicture1Text
+ text_end
+
+FanClubPicture2:
+ ld a, FEAROW
+ ld [wcf91], a
+ call DisplayMonFrontSpriteInBox
+ call EnableAutoTextBoxDrawing
+ tx_pre FanClubPicture2Text
+ ret
+
+FanClubPicture2Text::
+ text_far _FanClubPicture2Text
+ text_end
diff --git a/engine/events/hidden_objects/fighting_dojo.asm b/engine/events/hidden_objects/fighting_dojo.asm
new file mode 100644
index 00000000..b4f89985
--- /dev/null
+++ b/engine/events/hidden_objects/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_objects/gym_statues.asm b/engine/events/hidden_objects/gym_statues.asm
new file mode 100644
index 00000000..1c7eb970
--- /dev/null
+++ b/engine/events/hidden_objects/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_objects/indigo_plateau_hq.asm b/engine/events/hidden_objects/indigo_plateau_hq.asm
new file mode 100644
index 00000000..e8fd0220
--- /dev/null
+++ b/engine/events/hidden_objects/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_objects/indigo_plateau_statues.asm b/engine/events/hidden_objects/indigo_plateau_statues.asm
new file mode 100644
index 00000000..23e94fcf
--- /dev/null
+++ b/engine/events/hidden_objects/indigo_plateau_statues.asm
@@ -0,0 +1,24 @@
+IndigoPlateauStatues::
+ text_asm
+ ld hl, IndigoPlateauStatuesText1
+ call PrintText
+ ld a, [wXCoord]
+ bit 0, a
+ 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_objects/magazines.asm b/engine/events/hidden_objects/magazines.asm
new file mode 100644
index 00000000..b58636ff
--- /dev/null
+++ b/engine/events/hidden_objects/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_objects/museum_fossils.asm b/engine/events/hidden_objects/museum_fossils.asm
new file mode 100644
index 00000000..539f2c3f
--- /dev/null
+++ b/engine/events/hidden_objects/museum_fossils.asm
@@ -0,0 +1,23 @@
+AerodactylFossil:
+ ld a, FOSSIL_AERODACTYL
+ ld [wcf91], a
+ call DisplayMonFrontSpriteInBox
+ call EnableAutoTextBoxDrawing
+ tx_pre AerodactylFossilText
+ ret
+
+AerodactylFossilText::
+ text_far _AerodactylFossilText
+ text_end
+
+KabutopsFossil:
+ ld a, FOSSIL_KABUTOPS
+ ld [wcf91], a
+ call DisplayMonFrontSpriteInBox
+ call EnableAutoTextBoxDrawing
+ tx_pre KabutopsFossilText
+ ret
+
+KabutopsFossilText::
+ text_far _KabutopsFossilText
+ text_end
diff --git a/engine/events/hidden_objects/museum_fossils2.asm b/engine/events/hidden_objects/museum_fossils2.asm
new file mode 100644
index 00000000..fce0f03a
--- /dev/null
+++ b/engine/events/hidden_objects/museum_fossils2.asm
@@ -0,0 +1,28 @@
+DisplayMonFrontSpriteInBox:
+; Displays a pokemon's front sprite in a pop-up window.
+; [wcf91] = pokemon internal id number
+ 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, [wcf91]
+ ld [wd0b5], a
+ call GetMonHeader
+ ld de, vChars1 + $310
+ 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_objects/new_bike.asm b/engine/events/hidden_objects/new_bike.asm
new file mode 100644
index 00000000..5bce5937
--- /dev/null
+++ b/engine/events/hidden_objects/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_objects/oaks_lab_email.asm b/engine/events/hidden_objects/oaks_lab_email.asm
new file mode 100644
index 00000000..bd4c66d7
--- /dev/null
+++ b/engine/events/hidden_objects/oaks_lab_email.asm
@@ -0,0 +1,11 @@
+DisplayOakLabEmailText:
+ ld a, [wSpritePlayerStateData1FacingDirection]
+ cp SPRITE_FACING_UP
+ ret nz
+ call EnableAutoTextBoxDrawing
+ tx_pre OakLabEmailText
+ ret
+
+OakLabEmailText::
+ text_far _OakLabEmailText
+ text_end
diff --git a/engine/events/hidden_objects/oaks_lab_posters.asm b/engine/events/hidden_objects/oaks_lab_posters.asm
new file mode 100644
index 00000000..502cf951
--- /dev/null
+++ b/engine/events/hidden_objects/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_objects/pokecenter_pc.asm b/engine/events/hidden_objects/pokecenter_pc.asm
new file mode 100644
index 00000000..f20f40ed
--- /dev/null
+++ b/engine/events/hidden_objects/pokecenter_pc.asm
@@ -0,0 +1,11 @@
+OpenPokemonCenterPC:
+ ld a, [wSpritePlayerStateData1FacingDirection]
+ cp SPRITE_FACING_UP
+ ret nz
+ call EnableAutoTextBoxDrawing
+ ld a, TRUE
+ ld [wAutoTextBoxDrawingControl], a
+ tx_pre_jump PokemonCenterPCText
+
+PokemonCenterPCText::
+ script_pokecenter_pc
diff --git a/engine/events/hidden_objects/pokemon_stuff.asm b/engine/events/hidden_objects/pokemon_stuff.asm
new file mode 100644
index 00000000..267a191a
--- /dev/null
+++ b/engine/events/hidden_objects/pokemon_stuff.asm
@@ -0,0 +1,3 @@
+PokemonStuffText::
+ text_far _PokemonStuffText
+ text_end
diff --git a/engine/events/hidden_objects/reds_room.asm b/engine/events/hidden_objects/reds_room.asm
new file mode 100644
index 00000000..7b8d51a0
--- /dev/null
+++ b/engine/events/hidden_objects/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_objects/route_15_binoculars.asm b/engine/events/hidden_objects/route_15_binoculars.asm
new file mode 100644
index 00000000..9734e833
--- /dev/null
+++ b/engine/events/hidden_objects/route_15_binoculars.asm
@@ -0,0 +1,17 @@
+Route15GateLeftBinoculars:
+ ld a, [wSpritePlayerStateData1FacingDirection]
+ cp SPRITE_FACING_UP
+ ret nz
+ call EnableAutoTextBoxDrawing
+ tx_pre Route15UpstairsBinocularsText
+ ld a, ARTICUNO
+ ld [wcf91], a
+ call PlayCry
+ call DisplayMonFrontSpriteInBox
+ xor a
+ ldh [hAutoBGTransferEnabled], a
+ ret
+
+Route15UpstairsBinocularsText::
+ text_far _Route15UpstairsBinocularsText
+ text_end
diff --git a/engine/events/hidden_objects/safari_game.asm b/engine/events/hidden_objects/safari_game.asm
new file mode 100644
index 00000000..5001a5d4
--- /dev/null
+++ b/engine/events/hidden_objects/safari_game.asm
@@ -0,0 +1,78 @@
+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::
+ 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
+ call StopAllMusic
+ ld c, BANK(SFX_Safari_Zone_PA)
+ ld a, SFX_SAFARI_ZONE_PA
+ call PlayMusic
+.waitForMusicToPlay
+ ld a, [wChannelSoundIDs + Ch5]
+ cp SFX_SAFARI_ZONE_PA
+ jr nz, .waitForMusicToPlay
+ ld a, TEXT_SAFARI_GAME_OVER
+ ldh [hSpriteIndexOrTextID], a
+ call DisplayTextID
+ xor a
+ ld [wPlayerMovingDirection], a
+ ld a, SAFARI_ZONE_GATE
+ ldh [hWarpDestinationMap], a
+ ld a, $3
+ ld [wDestinationWarpID], a
+ ld a, $5
+ 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_objects/school_blackboard.asm b/engine/events/hidden_objects/school_blackboard.asm
new file mode 100644
index 00000000..eb927292
--- /dev/null
+++ b/engine/events/hidden_objects/school_blackboard.asm
@@ -0,0 +1,223 @@
+PrintBlackboardLinkCableText:
+ call EnableAutoTextBoxDrawing
+ ld a, $1
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
+ ld a, [wHiddenObjectFunctionArgument]
+ 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, A_BUTTON | B_BUTTON
+ ld [wMenuWatchedKeys], a
+ ld a, 3
+ ld [wMaxMenuItem], a
+ ld a, 2
+ ld [wTopMenuItemY], a
+ ld a, 1
+ ld [wTopMenuItemX], a
+.linkHelpLoop
+ ld hl, wd730
+ set 6, [hl]
+ hlcoord 0, 0
+ lb bc, 8, 13
+ call TextBoxBorder
+ hlcoord 2, 2
+ ld de, HowToLinkText
+ call PlaceString
+ ld hl, LinkCableHelpText2
+ call PrintText
+ call HandleMenuInput
+ bit 1, a ; pressed b
+ jr nz, .exit
+ ld a, [wCurrentMenuItem]
+ cp 3 ; pressed a on "STOP READING"
+ jr z, .exit
+ ld hl, wd730
+ res 6, [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, wd730
+ res 6, [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, D_LEFT | D_RIGHT | A_BUTTON | B_BUTTON
+ ld [wMenuWatchedKeys], a
+ ld a, 2
+ ld [wMaxMenuItem], a
+ ld a, 2
+ ld [wTopMenuItemY], a
+ ld a, 1
+ ld [wTopMenuItemX], a
+.blackboardLoop
+ ld hl, wd730
+ set 6, [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 1, a ; pressed b
+ jr nz, .exitBlackboard
+ bit 4, a ; pressed right
+ 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 5, a ; pressed left
+ 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, wd730
+ res 6, [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, wd730
+ res 6, [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_objects/school_notebooks.asm b/engine/events/hidden_objects/school_notebooks.asm
new file mode 100644
index 00000000..96a44ab5
--- /dev/null
+++ b/engine/events/hidden_objects/school_notebooks.asm
@@ -0,0 +1,65 @@
+PrintNotebookText:
+ call EnableAutoTextBoxDrawing
+ ld a, $1
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
+ ld a, [wHiddenObjectFunctionArgument]
+ 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_objects/town_map.asm b/engine/events/hidden_objects/town_map.asm
new file mode 100644
index 00000000..4284214f
--- /dev/null
+++ b/engine/events/hidden_objects/town_map.asm
@@ -0,0 +1,22 @@
+TownMapText::
+ text_far _TownMapText
+ text_promptbutton
+ text_asm
+ ld a, $1
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
+ ld hl, wd730
+ set 6, [hl]
+ call GBPalWhiteOutWithDelay3
+ xor a
+ ldh [hWY], a
+ inc a
+ ldh [hAutoBGTransferEnabled], a
+ call LoadFontTilePatterns
+ farcall DisplayTownMap
+ ld hl, wd730
+ res 6, [hl]
+ ld de, TextScriptEnd
+ push de
+ ldh a, [hLoadedROMBank]
+ push af
+ jp CloseTextDisplay
diff --git a/engine/events/hidden_objects/vermilion_gym_trash.asm b/engine/events/hidden_objects/vermilion_gym_trash.asm
new file mode 100644
index 00000000..21dd3ee0
--- /dev/null
+++ b/engine/events/hidden_objects/vermilion_gym_trash.asm
@@ -0,0 +1,134 @@
+PrintTrashText:
+ call EnableAutoTextBoxDrawing
+ tx_pre_jump VermilionGymTrashText
+
+VermilionGymTrashText::
+ text_far _VermilionGymTrashText
+ text_end
+
+GymTrashScript:
+ call EnableAutoTextBoxDrawing
+ ld a, [wHiddenObjectFunctionArgument]
+ 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
+ callfar Yellow_SampleSecondTrashCan
+ tx_pre_id VermilionGymTrashSuccessText1
+ jr .done
+
+.trySecondLock
+ ld a, [wGymTrashCanIndex]
+ ld b, a
+ ld a, [wSecondLockTrashCanIndex]
+ cp b
+ jr z, .openSecondLock
+ ld a, [wSecondLockTrashCanIndex + 1]
+ 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 6, [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
+; Note that the mask is simply the number of valid trash can indices that
+; follow. The remaining bytes are filled with -1 to pad the length of each entry
+; to 5 bytes.
+; This is functionally replaced with GymTrashCans3a but was never removed from source.
+
+ db 2, 1, 3, -1, -1 ; 0
+ db 3, 0, 2, 4, -1 ; 1
+ db 2, 1, 5, -1, -1 ; 2
+ db 3, 0, 4, 6, -1 ; 3
+ db 4, 1, 3, 5, 7 ; 4
+ db 3, 2, 4, 8, -1 ; 5
+ db 3, 3, 7, 9, -1 ; 6
+ db 4, 4, 6, 8, 10 ; 7
+ db 3, 5, 7, 11, -1 ; 8
+ db 3, 6, 10, 12, -1 ; 9
+ db 4, 7, 9, 11, 13 ; 10
+ db 3, 8, 10, 14, -1 ; 11
+ db 2, 9, 13, -1, -1 ; 12
+ db 3, 10, 12, 14, -1 ; 13
+ db 2, 11, 13, -1, -1 ; 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
+VermilionGymTrashSuccesPlaySfx:
+ 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