shithub: pokered

Download patch

ref: f702fc7840e30f00c840ce619a1ea15d763438de
parent: bc6f0bc08a73a4afafc24d5349d56108d3971e2a
author: dannye <corrnondacqb@yahoo.com>
date: Fri Jul 3 20:44:12 EDT 2015

Start using text predef macros
also sprite direction constants

--- a/data/hidden_objects.asm
+++ b/data/hidden_objects.asm
@@ -233,10 +233,10 @@
 ViridianMartHiddenObjects: ; 46ba0 (11:6ba0)
 	db $FF
 ViridianSchoolHiddenObjects: ; 46ba1 (11:6ba1)
-	db $04,$03,$20 ; ViridianSchoolNotebook
+	db $04,$03,(ViridianSchoolNotebook_id - TextPredefs) / 2 + 1
 	db Bank(PrintNotebookText)
 	dw PrintNotebookText
-	db $00,$03,$21 ; ViridianSchoolBlackboard
+	db $00,$03,(ViridianSchoolBlackboard_id - TextPredefs) / 2 + 1
 	db BANK(PrintBlackboardLinkCableText)
 	dw PrintBlackboardLinkCableText
 	db $FF
@@ -743,13 +743,13 @@
 	dw PrintMagazinesText
 	db $FF
 CeladonMansion5HiddenObjects: ; 46fd5 (11:6fd5)
-	db $00,$03,$34 ; LinkCableHelp
+	db $00,$03,(LinkCableHelp_id - TextPredefs) / 2 + 1
 	db BANK(PrintBlackboardLinkCableText)
 	dw PrintBlackboardLinkCableText
-	db $00,$04,$34 ; LinkCableHelp
+	db $00,$04,(LinkCableHelp_id - TextPredefs) / 2 + 1
 	db BANK(PrintBlackboardLinkCableText)
 	dw PrintBlackboardLinkCableText
-	db $04,$03,$35 ; TMNotebook
+	db $04,$03,(TMNotebook_id - TextPredefs) / 2 + 1
 	db Bank(PrintNotebookText)
 	dw PrintNotebookText
 	db $FF
--- a/engine/game_corner_slots.asm
+++ b/engine/game_corner_slots.asm
@@ -27,13 +27,13 @@
 	call PromptUserToPlaySlots
 	ret
 .printOutOfOrder
-	ld a, $28
+	tx_pre_id GameCornerOutOfOrderText
 	jr .printText
 .printOutToLunch
-	ld a, $29
+	tx_pre_id GameCornerOutToLunchText
 	jr .printText
 .printSomeonesKeys
-	ld a, $2a
+	tx_pre_id GameCornerSomeonesKeysText
 .printText
 	push af
 	call EnableAutoTextBoxDrawing
--- a/engine/game_corner_slots2.asm
+++ b/engine/game_corner_slots2.asm
@@ -6,13 +6,13 @@
 	predef IsItemInBag_  ; IsItemInBag_
 	ld a, b
 	and a
-	ld b, $33 ; GameCornerCoinCaseText
+	ld b, (GameCornerCoinCaseText_id - TextPredefs) / 2 + 1
 	jr z, .printCoinCaseRequired
 	ld hl, wPlayerCoins
 	ld a, [hli]
 	or [hl]
 	jr nz, .done ; able to play
-	ld b, $32 ; GameCornerNoCoinsText
+	ld b, (GameCornerNoCoinsText_id - TextPredefs) / 2 + 1
 .printCoinCaseRequired
 	call EnableAutoTextBoxDrawing
 	ld a, b
--- a/engine/hidden_object_functions14.asm
+++ b/engine/hidden_object_functions14.asm
@@ -66,8 +66,7 @@
 
 PrintFightingDojoText2: ; 52a08 (14:6a08)
 	call EnableAutoTextBoxDrawing
-	ld a, $37
-	jp PrintPredefTextID
+	tx_pre_jump FightingDojoText_52a10
 
 FightingDojoText_52a10: ; 52a10 (14:6a10)
 	TX_FAR _FightingDojoText_52a10
@@ -75,8 +74,7 @@
 
 PrintFightingDojoText3: ; 52a15 (14:6a15)
 	call EnableAutoTextBoxDrawing
-	ld a, $38
-	jp PrintPredefTextID
+	tx_pre_jump FightingDojoText_52a1d
 
 FightingDojoText_52a1d: ; 52a1d (14:6a1d)
 	TX_FAR _FightingDojoText_52a1d
@@ -84,8 +82,7 @@
 
 PrintFightingDojoText: ; 52a22 (14:6a22)
 	call EnableAutoTextBoxDrawing
-	ld a, $36
-	jp PrintPredefTextID
+	tx_pre_jump FightingDojoText
 
 FightingDojoText: ; 52a2a (14:6a2a)
 	TX_FAR _FightingDojoText
@@ -93,11 +90,10 @@
 
 PrintIndigoPlateauHQText: ; 52a2f (14:6a2f)
 	ld a, [wSpriteStateData1 + 9]
-	cp $4
+	cp SPRITE_FACING_UP
 	ret nz
 	call EnableAutoTextBoxDrawing
-	ld a, $27
-	jp PrintPredefTextID
+	tx_pre_jump IndigoPlateauHQText
 
 IndigoPlateauHQText: ; 52a3d (14:6a3d)
 	TX_FAR _IndigoPlateauHQText
--- a/engine/hidden_object_functions17.asm
+++ b/engine/hidden_object_functions17.asm
@@ -1,7 +1,6 @@
 PrintRedsNESText: ; 5db79 (17:5b79)
 	call EnableAutoTextBoxDrawing
-	ld a, $4 ; RedBedroomSNESText
-	jp PrintPredefTextID
+	tx_pre_jump RedBedroomSNESText
 
 RedBedroomSNESText: ; 5db81 (17:5b81)
 	TX_FAR _RedBedroomSNESText
@@ -9,19 +8,17 @@
 
 OpenRedsPC: ; 5db86 (17:5b86)
 	call EnableAutoTextBoxDrawing
-	ld a, $3
-	jp PrintPredefTextID
+	tx_pre_jump RedBedroomPCText
 
-RedBedroomPC: ; 5db8e (17:5b8e)
+RedBedroomPCText: ; 5db8e (17:5b8e)
 	db $fc ; FuncTX_ItemStoragePC
 
 Route15GateLeftBinoculars: ; 5db8f (17:5b8f)
 	ld a, [wSpriteStateData1 + 9]
-	cp $4 ; i
+	cp SPRITE_FACING_UP
 	ret nz
 	call EnableAutoTextBoxDrawing
-	ld a, $a ; text id Route15UpstairsBinocularsText
-	call PrintPredefTextID
+	tx_pre Route15UpstairsBinocularsText
 	ld a, ARTICUNO
 	ld [wcf91], a
 	call PlayCry
@@ -36,8 +33,7 @@
 	ld [wcf91], a
 	call DisplayMonFrontSpriteInBox
 	call EnableAutoTextBoxDrawing
-	ld a, $9
-	call PrintPredefTextID
+	tx_pre AerodactylFossilText
 	ret
 
 AerodactylFossilText: ; 5dbbe (17:5bbe)
@@ -49,8 +45,7 @@
 	ld [wcf91], a
 	call DisplayMonFrontSpriteInBox
 	call EnableAutoTextBoxDrawing
-	ld a, $b
-	call PrintPredefTextID
+	tx_pre KabutopsFossilText
 	ret
 
 KabutopsFossilText: ; 5dbd4 (17:5bd4)
@@ -307,8 +302,7 @@
 
 PrintTrashText: ; 5ddef (17:5def)
 	call EnableAutoTextBoxDrawing
-	ld a, $26
-	jp PrintPredefTextID
+	tx_pre_jump VermilionGymTrashText
 
 VermilionGymTrashText: ; 5ddf7 (17:5df7)
 	TX_FAR _VermilionGymTrashText
@@ -324,8 +318,7 @@
 	bit 0, a
 	jr z, .ok
 
-	ld a, $26 ; DisplayTextID $26 = VermilionGymTrashText (nothing in the trash)
-	jp PrintPredefTextID
+	tx_pre_jump VermilionGymTrashText
 
 .ok
 	bit 1, a
@@ -337,7 +330,7 @@
 	cp b
 	jr z, .openFirstLock
 
-	ld a, $26 ; DisplayTextID $26 = VermilionGymTrashText (nothing in the trash)
+	tx_pre_id VermilionGymTrashText
 	jr .done
 
 .openFirstLock
@@ -375,7 +368,7 @@
 	and $f
 	ld [wd744], a
 
-	ld a, $3b ; DisplayTextID $3b = VermilionGymTrashSuccesText1 (first lock opened!)
+	tx_pre_id VermilionGymTrashSuccesText1
 	jr .done
 
 .trySecondLock
@@ -393,7 +386,7 @@
 	and $e
 	ld [wd743], a
 
-	ld a, $3e ; DisplayTextID $3e = VermilionGymTrashFailText (locks reset!)
+	tx_pre_id VermilionGymTrashFailText
 	jr .done
 
 .openSecondLock
@@ -403,7 +396,7 @@
 	ld hl, wd126
 	set 6, [hl]
 
-	ld a, $3d ; DisplayTextID $3d = VermilionGymTrashSuccesText3 (2nd lock opened!)
+	tx_pre_id VermilionGymTrashSuccesText3
 
 .done
 	jp PrintPredefTextID
--- a/engine/hidden_object_functions18.asm
+++ b/engine/hidden_object_functions18.asm
@@ -1,31 +1,31 @@
 GymStatues: ; 62419 (18:6419)
-; if in a gym and have the corresponding badge, a = $D and jp PrintPredefTextID
-; if in a gym and don’t have the corresponding badge, a = $C and jp PrintPredefTextID
+; 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, [wSpriteStateData1 + 9]
-	cp $4
+	cp SPRITE_FACING_UP
 	ret nz
 	ld hl, .BadgeFlags
 	ld a, [W_CURMAP]
 	ld b, a
-.asm_62429
+.loop
 	ld a, [hli]
 	cp $ff
 	ret z
 	cp b
-	jr z, .asm_62433
+	jr z, .match
 	inc hl
-	jr .asm_62429
-.asm_62433
+	jr .loop
+.match
 	ld b, [hl]
 	ld a, [wd72a]
 	and b
 	cp b
-	ld a, $d
-	jr z, .asm_6243f
-	ld a, $c
-.asm_6243f
+	tx_pre_id GymStatueText2
+	jr z, .haveBadge
+	tx_pre_id GymStatueText1
+.haveBadge
 	jp PrintPredefTextID
 
 .BadgeFlags: ; 62442 (18:6442)
@@ -49,41 +49,53 @@
 
 PrintBenchGuyText: ; 6245d (18:645d)
 	call EnableAutoTextBoxDrawing
-	ld hl, PokeCenterMapIDList
+	ld hl, BenchGuyTextPointers
 	ld a, [W_CURMAP]
 	ld b, a
-.asm_62467
+.loop
 	ld a, [hli]
 	cp $ff
 	ret z
 	cp b
-	jr z, .asm_62472
+	jr z, .match
 	inc hl
 	inc hl
-	jr .asm_62467
-.asm_62472
+	jr .loop
+.match
 	ld a, [hli]
 	ld b, a
 	ld a, [wSpriteStateData1 + 9]
 	cp b
-	jr nz, .asm_62467
+	jr nz, .loop ; player isn't facing left at the bench guy
 	ld a, [hl]
 	jp PrintPredefTextID
 
-; format: db map id, 08, text id of PredefTextIDPointerTable
-PokeCenterMapIDList: ; 6247e (18:647e)
-	db VIRIDIAN_POKECENTER,$08,$0F
-	db PEWTER_POKECENTER,$08,$10
-	db CERULEAN_POKECENTER,$08,$11
-	db LAVENDER_POKECENTER,$08,$12
-	db VERMILION_POKECENTER,$08,$13
-	db CELADON_POKECENTER,$08,$14
-	db CELADON_HOTEL,$08,$15
-	db FUCHSIA_POKECENTER,$08,$16
-	db CINNABAR_POKECENTER,$08,$17
-	db SAFFRON_POKECENTER,$08,$18
-	db MT_MOON_POKECENTER,$08,$19
-	db ROCK_TUNNEL_POKECENTER,$08,$1A
+; format: db map id, player sprite facing direction, text id of PredefTextIDPointerTable
+BenchGuyTextPointers: ; 6247e (18:647e)
+	db VIRIDIAN_POKECENTER,   SPRITE_FACING_LEFT
+	db (ViridianCityPokecenterBenchGuyText_id   - TextPredefs) / 2 + 1
+	db PEWTER_POKECENTER,     SPRITE_FACING_LEFT
+	db (PewterCityPokecenterBenchGuyText_id     - TextPredefs) / 2 + 1
+	db CERULEAN_POKECENTER,   SPRITE_FACING_LEFT
+	db (CeruleanCityPokecenterBenchGuyText_id   - TextPredefs) / 2 + 1
+	db LAVENDER_POKECENTER,   SPRITE_FACING_LEFT
+	db (LavenderCityPokecenterBenchGuyText_id   - TextPredefs) / 2 + 1
+	db VERMILION_POKECENTER,  SPRITE_FACING_LEFT
+	db (VermilionCityPokecenterBenchGuyText_id  - TextPredefs) / 2 + 1
+	db CELADON_POKECENTER,    SPRITE_FACING_LEFT
+	db (CeladonCityPokecenterBenchGuyText_id    - TextPredefs) / 2 + 1
+	db CELADON_HOTEL,         SPRITE_FACING_LEFT
+	db (CeladonCityHotelText_id                 - TextPredefs) / 2 + 1
+	db FUCHSIA_POKECENTER,    SPRITE_FACING_LEFT
+	db (FuchsiaCityPokecenterBenchGuyText_id    - TextPredefs) / 2 + 1
+	db CINNABAR_POKECENTER,   SPRITE_FACING_LEFT
+	db (CinnabarIslandPokecenterBenchGuyText_id - TextPredefs) / 2 + 1
+	db SAFFRON_POKECENTER,    SPRITE_FACING_LEFT
+	db (SaffronCityPokecenterBenchGuyText_id    - TextPredefs) / 2 + 1
+	db MT_MOON_POKECENTER,    SPRITE_FACING_LEFT
+	db (MtMoonPokecenterBenchGuyText_id         - TextPredefs) / 2 + 1
+	db ROCK_TUNNEL_POKECENTER,SPRITE_FACING_LEFT
+	db (RockTunnelPokecenterBenchGuyText_id     - TextPredefs) / 2 + 1
 	db $FF
 
 ViridianCityPokecenterBenchGuyText: ; 624a3 (18:64a3)
@@ -163,13 +175,12 @@
 
 	ret
 
-TerminatorText_62508: ; 62508 (18:6508)
+UnusedPredefText: ; 62508 (18:6508)
 	db "@"
 
 PrintBookcaseText: ; 6509 (18:6509)
 	call EnableAutoTextBoxDrawing
-	ld a, $e ; BookcaseText
-	jp PrintPredefTextID
+	tx_pre_jump BookcaseText
 
 BookcaseText: ; 62511 (18:6511)
 	TX_FAR _BookcaseText
@@ -177,13 +188,12 @@
 
 OpenPokemonCenterPC: ; 62516 (18:6516)
 	ld a, [wSpriteStateData1 + 9]
-	cp $4 ; check to see if player is facing up
+	cp SPRITE_FACING_UP ; check to see if player is facing up
 	ret nz
 	call EnableAutoTextBoxDrawing
 	ld a, $1
 	ld [wAutoTextBoxDrawingControl], a
-	ld a, $1f ; PredefText1f
-	jp PrintPredefTextID
+	tx_pre_jump PokemonCenterPCText
 
-PredefText1f: ; 62529 (18:6529)
+PokemonCenterPCText: ; 62529 (18:6529)
 	db $F9 ; FuncTX_PokemonCenterPC
--- a/engine/hidden_object_functions3.asm
+++ b/engine/hidden_object_functions3.asm
@@ -40,23 +40,40 @@
 
 ; format: db tileset id, bookshelf tile id, text id
 BookshelfTileIDs: ; fb8b (3:7b8b)
-	db PLATEAU,      $30, $3A
-	db HOUSE,        $3D, $3F
-	db HOUSE,        $1E, $40
-	db MANSION,      $32, $40
-	db REDS_HOUSE_1, $32, $40
-	db LAB,          $28, $40
-	db LOBBY,        $16, $41
-	db GYM,          $1D, $40
-	db DOJO,         $1D, $40
-	db GATE,         $22, $40
-	db MART,         $54, $42
-	db MART,         $55, $42
-	db POKECENTER,   $54, $42
-	db POKECENTER,   $55, $42
-	db LOBBY,        $50, $42
-	db LOBBY,        $52, $42
-	db SHIP,         $36, $40
+	db PLATEAU,      $30
+	db (IndigoPlateauStatues_id   - TextPredefs) / 2 + 1
+	db HOUSE,        $3D
+	db (TownMapText_id   - TextPredefs) / 2 + 1
+	db HOUSE,        $1E
+	db (BookOrSculptureText_id   - TextPredefs) / 2 + 1
+	db MANSION,      $32
+	db (BookOrSculptureText_id   - TextPredefs) / 2 + 1
+	db REDS_HOUSE_1, $32
+	db (BookOrSculptureText_id   - TextPredefs) / 2 + 1
+	db LAB,          $28
+	db (BookOrSculptureText_id   - TextPredefs) / 2 + 1
+	db LOBBY,        $16
+	db (ElevatorText_id   - TextPredefs) / 2 + 1
+	db GYM,          $1D
+	db (BookOrSculptureText_id   - TextPredefs) / 2 + 1
+	db DOJO,         $1D
+	db (BookOrSculptureText_id   - TextPredefs) / 2 + 1
+	db GATE,         $22
+	db (BookOrSculptureText_id   - TextPredefs) / 2 + 1
+	db MART,         $54
+	db (PokemonStuffText_id   - TextPredefs) / 2 + 1
+	db MART,         $55
+	db (PokemonStuffText_id   - TextPredefs) / 2 + 1
+	db POKECENTER,   $54
+	db (PokemonStuffText_id   - TextPredefs) / 2 + 1
+	db POKECENTER,   $55
+	db (PokemonStuffText_id   - TextPredefs) / 2 + 1
+	db LOBBY,        $50
+	db (PokemonStuffText_id   - TextPredefs) / 2 + 1
+	db LOBBY,        $52
+	db (PokemonStuffText_id   - TextPredefs) / 2 + 1
+	db SHIP,         $36
+	db (BookOrSculptureText_id   - TextPredefs) / 2 + 1
 	db $FF
 
 IndigoPlateauStatues: ; fbbf (3:7bbf)
--- a/engine/hidden_object_functions7.asm
+++ b/engine/hidden_object_functions7.asm
@@ -1,7 +1,6 @@
 PrintNewBikeText: ; 1e94b (7:694b)
 	call EnableAutoTextBoxDrawing
-	ld a, $39
-	jp PrintPredefTextID
+	tx_pre_jump NewBicycleText
 
 NewBicycleText: ; 1e953 (7:6953)
 	TX_FAR _NewBicycleText
@@ -9,8 +8,7 @@
 
 DisplayOakLabLeftPoster: ; 1e958 (7:6958)
 	call EnableAutoTextBoxDrawing
-	ld a, $05 ; PushStartText
-	jp PrintPredefTextID
+	tx_pre_jump PushStartText
 
 PushStartText: ; 1e960 (7:6960)
 	TX_FAR _PushStartText
@@ -23,10 +21,10 @@
 	call CountSetBits
 	ld a, [wd11e]
 	cp $2
-	ld a, $6 ; SaveOptionText
-	jr c, .asm_1e97b
-	ld a, $7 ; StrengthsAndWeaknessesText
-.asm_1e97b
+	tx_pre_id SaveOptionText
+	jr c, .ownThreeOrMoreMon
+	tx_pre_id StrengthsAndWeaknessesText
+.ownThreeOrMoreMon
 	jp PrintPredefTextID
 
 SaveOptionText: ; 1e97e (7:697e)
@@ -120,11 +118,10 @@
 
 PrintCinnabarQuiz: ; 1ea17 (7:6a17)
 	ld a, [wSpriteStateData1 + 9]
-	cp $4
+	cp SPRITE_FACING_UP
 	ret nz
 	call EnableAutoTextBoxDrawing
-	ld a, $31
-	jp PrintPredefTextID
+	tx_pre_jump CinnabarGymQuiz
 
 CinnabarGymQuiz: ; 1ea25 (7:6a25)
 	TX_ASM
@@ -309,8 +306,7 @@
 
 PrintMagazinesText: ; 1eb60 (7:6b60)
 	call EnableAutoTextBoxDrawing
-	ld a, $30
-	call PrintPredefTextID
+	tx_pre MagazinesText
 	ret
 
 MagazinesText: ; 1eb69 (7:6b69)
@@ -320,7 +316,7 @@
 BillsHousePC: ; 1eb6e (7:6b6e)
 	call EnableAutoTextBoxDrawing
 	ld a, [wSpriteStateData1 + 9]
-	cp $4
+	cp SPRITE_FACING_UP
 	ret nz
 	ld a, [wd7f2]
 	bit 7, a
@@ -330,13 +326,11 @@
 	bit 6, a
 	jr nz, .asm_1eb8b
 .asm_1eb86
-	ld a, $2d
-	jp PrintPredefTextID
+	tx_pre_jump BillsHouseMonitorText
 .asm_1eb8b
 	ld a, $1
 	ld [wDoNotWaitForButtonPressAfterDisplayingText], a
-	ld a, $2e
-	call PrintPredefTextID
+	tx_pre BillsHouseInitiatedText
 	ld c, 32
 	call DelayFrames
 	ld a, (SFX_02_3c - SFX_Headers_02) / 3
@@ -364,8 +358,7 @@
 .asm_1ebd2
 	ld a, $1
 	ld [wDoNotWaitForButtonPressAfterDisplayingText], a
-	ld a, $2f
-	call PrintPredefTextID
+	tx_pre BillsHousePokemonList
 	ret
 
 BillsHouseMonitorText: ; 1ebdd (7:6bdd)
@@ -459,11 +452,10 @@
 
 DisplayOakLabEmailText: ; 1ecaf (7:6caf)
 	ld a, [wSpriteStateData1 + 9]
-	cp $4
+	cp SPRITE_FACING_UP
 	ret nz
 	call EnableAutoTextBoxDrawing
-	ld a, $8 ; OakLabEmailText
-	jp PrintPredefTextID
+	tx_pre_jump OakLabEmailText
 
 OakLabEmailText: ; 1ecbd (7:6cbd)
 	TX_FAR _OakLabEmailText
--- a/engine/menu/bills_pc.asm
+++ b/engine/menu/bills_pc.asm
@@ -523,8 +523,7 @@
 .asm_2183a
 	ld [wLinkState], a
 	call EnableAutoTextBoxDrawing
-	ld a, $22 ; JustAMomentText
-	jp PrintPredefTextID
+	tx_pre_jump JustAMomentText
 
 CableClubRightGameboy:: ; 5845 (8:5845)
 	ld a, [hSerialConnectionStatus]
@@ -541,8 +540,7 @@
 .asm_2185a
 	ld [wLinkState], a
 	call EnableAutoTextBoxDrawing
-	ld a, $22 ; JustAMomentText
-	jp PrintPredefTextID
+	tx_pre_jump JustAMomentText
 
 JustAMomentText:: ; 21865 (8:5865)
 	TX_FAR _JustAMomentText
@@ -552,9 +550,8 @@
 	cp SPRITE_FACING_UP
 	ret nz
 	call EnableAutoTextBoxDrawing
-	ld a, $23
-	jp PrintPredefTextID
+	tx_pre_jump OpenBillsPCText
 
-PredefText23:: ; 21878 (8:5878)
+OpenBillsPCText:: ; 21878 (8:5878)
 	db $FD ; FuncTX_BillsPC
 
--- a/engine/overworld/card_key.asm
+++ b/engine/overworld/card_key.asm
@@ -27,7 +27,7 @@
 	jr z, .noCardKey
 	call GetCoordsInFrontOfPlayer
 	push de
-	ld a, $1
+	tx_pre_id CardKeySuccessText
 	ld [H_DOWNARROWBLINKCNT2], a
 	call PrintPredefTextID
 	pop de
@@ -54,7 +54,7 @@
 	ld a, (SFX_1f_57 - SFX_Headers_1f) / 3
 	jp PlaySound
 .noCardKey
-	ld a, $2
+	tx_pre_id CardKeyFailText
 	ld [H_DOWNARROWBLINKCNT2], a
 	jp PrintPredefTextID
 
--- a/engine/overworld/cut.asm
+++ b/engine/overworld/cut.asm
@@ -185,26 +185,26 @@
 	add hl, bc
 	ld a, [wSpriteStateData1 + 9]
 	and a
-	jr z, .asm_f0c7
-	cp $4
-	jr z, .asm_f0cf
-	cp $8
-	jr z, .asm_f0d7
+	jr z, .down
+	cp SPRITE_FACING_UP
+	jr z, .up
+	cp SPRITE_FACING_LEFT
+	jr z, .left
 	ld a, [W_XBLOCKCOORD]
 	and a
 	jr z, .asm_f0e0
 	jr .asm_f0ec
-.asm_f0c7
+.down
 	ld a, [W_YBLOCKCOORD]
 	and a
 	jr z, .asm_f0e0
 	jr .asm_f0df
-.asm_f0cf
+.up
 	ld a, [W_YBLOCKCOORD]
 	and a
 	jr z, .asm_f0e1
 	jr .asm_f0e0
-.asm_f0d7
+.left
 	ld a, [W_XBLOCKCOORD]
 	and a
 	jr z, .asm_f0e6
--- a/engine/overworld/hidden_items.asm
+++ b/engine/overworld/hidden_items.asm
@@ -16,8 +16,7 @@
 	ld a, [wWhichTrade] ; item ID
 	ld [wd11e], a
 	call GetItemName
-	ld a, $24
-	jp PrintPredefTextID
+	tx_pre_jump FoundHiddenItemText
 
 INCLUDE "data/hidden_item_coords.asm"
 
@@ -112,10 +111,10 @@
 	ld a, [wPlayerCoins + 1]
 	cp $99
 	jr nz, .RoomInCoinCase
-	ld a, $2c
+	tx_pre_id DroppedHiddenCoinsText
 	jr .done
 .RoomInCoinCase
-	ld a, $2b
+	tx_pre_id FoundHiddenCoinsText
 .done
 	jp PrintPredefTextID
 
--- a/engine/overworld/movement.asm
+++ b/engine/overworld/movement.asm
@@ -27,34 +27,34 @@
 	jr nz, .asm_4e90
 	ld a, [wd528]
 	bit 2, a
-	jr z, .asm_4e65
-	xor a
-	jr .asm_4e86
-.asm_4e65
+	jr z, .notDown
+	xor a ; ld a, SPRITE_FACING_DOWN
+	jr .done
+.notDown
 	bit 3, a
-	jr z, .asm_4e6d
-	ld a, $4
-	jr .asm_4e86
-.asm_4e6d
+	jr z, .notUp
+	ld a, SPRITE_FACING_UP
+	jr .done
+.notUp
 	bit 1, a
-	jr z, .asm_4e75
-	ld a, $8
-	jr .asm_4e86
-.asm_4e75
+	jr z, .notLeft
+	ld a, SPRITE_FACING_LEFT
+	jr .done
+.notLeft
 	bit 0, a
-	jr z, .asm_4e7d
-	ld a, $c
-	jr .asm_4e86
-.asm_4e7d
+	jr z, .notRight
+	ld a, SPRITE_FACING_RIGHT
+	jr .done
+.notRight
 	xor a
 	ld [wSpriteStateData1 + 7], a
 	ld [wSpriteStateData1 + 8], a
 	jr .asm_4eab
-.asm_4e86
+.done
 	ld [wSpriteStateData1 + 9], a
 	ld a, [wFontLoaded]
 	bit 0, a
-	jr nz, .asm_4e7d
+	jr nz, .notRight
 .asm_4e90
 	ld a, [wd736]
 	bit 7, a
--- a/home.asm
+++ b/home.asm
@@ -4679,7 +4679,7 @@
 TextPredefs::
 	add_tx_pre CardKeySuccessText                   ; 01
 	add_tx_pre CardKeyFailText                      ; 02
-	add_tx_pre RedBedroomPC                         ; 03
+	add_tx_pre RedBedroomPCText                     ; 03
 	add_tx_pre RedBedroomSNESText                   ; 04
 	add_tx_pre PushStartText                        ; 05
 	add_tx_pre SaveOptionText                       ; 06
@@ -4703,17 +4703,17 @@
 	add_tx_pre SaffronCityPokecenterBenchGuyText    ; 18
 	add_tx_pre MtMoonPokecenterBenchGuyText         ; 19
 	add_tx_pre RockTunnelPokecenterBenchGuyText     ; 1A
-	add_tx_pre UnusedBenchGuyText1                  ; 1B
-	add_tx_pre UnusedBenchGuyText2                  ; 1C
-	add_tx_pre UnusedBenchGuyText3                  ; 1D
-	add_tx_pre TerminatorText_62508                 ; 1E
-	add_tx_pre PredefText1f                         ; 1F
+	add_tx_pre UnusedBenchGuyText1                  ; 1B XXX unused
+	add_tx_pre UnusedBenchGuyText2                  ; 1C XXX unused
+	add_tx_pre UnusedBenchGuyText3                  ; 1D XXX unused
+	add_tx_pre UnusedPredefText                     ; 1E XXX unused
+	add_tx_pre PokemonCenterPCText                  ; 1F
 	add_tx_pre ViridianSchoolNotebook               ; 20
 	add_tx_pre ViridianSchoolBlackboard             ; 21
 	add_tx_pre JustAMomentText                      ; 22
-	add_tx_pre PredefText23                         ; 23
+	add_tx_pre OpenBillsPCText                      ; 23
 	add_tx_pre FoundHiddenItemText                  ; 24
-	add_tx_pre HiddenItemBagFullText                ; 25
+	add_tx_pre HiddenItemBagFullText                ; 25 XXX unused
 	add_tx_pre VermilionGymTrashText                ; 26
 	add_tx_pre IndigoPlateauHQText                  ; 27
 	add_tx_pre GameCornerOutOfOrderText             ; 28
@@ -4736,7 +4736,7 @@
 	add_tx_pre NewBicycleText                       ; 39
 	add_tx_pre IndigoPlateauStatues                 ; 3A
 	add_tx_pre VermilionGymTrashSuccesText1         ; 3B
-	add_tx_pre VermilionGymTrashSuccesText2         ; 3C
+	add_tx_pre VermilionGymTrashSuccesText2         ; 3C XXX unused
 	add_tx_pre VermilionGymTrashSuccesText3         ; 3D
 	add_tx_pre VermilionGymTrashFailText            ; 3E
 	add_tx_pre TownMapText                          ; 3F
--- a/home/overworld.asm
+++ b/home/overworld.asm
@@ -1120,7 +1120,7 @@
 	ld bc,$3c40 ; Y and X position of player sprite
 	ld a,[wSpriteStateData1 + 9] ; direction the player is facing
 .checkIfPlayerFacingUp
-	cp a,$04
+	cp SPRITE_FACING_UP
 	jr nz,.checkIfPlayerFacingDown
 ; facing up
 	ld a,b
@@ -1129,7 +1129,7 @@
 	ld a,$08
 	jr .doneCheckingDirection
 .checkIfPlayerFacingDown
-	cp a,$00
+	cp SPRITE_FACING_DOWN
 	jr nz,.checkIfPlayerFacingRight
 ; facing down
 	ld a,b
@@ -1138,7 +1138,7 @@
 	ld a,$04
 	jr .doneCheckingDirection
 .checkIfPlayerFacingRight
-	cp a,$0c
+	cp SPRITE_FACING_RIGHT
 	jr nz,.playerFacingLeft
 ; facing right
 	ld a,c
--- a/macros.asm
+++ b/macros.asm
@@ -226,7 +226,7 @@
 ENDM
 
 tx_pre_id: MACRO
-	ld a, (\1_id - TextPredefs) / 2
+	ld a, (\1_id - TextPredefs) / 2 + 1
 ENDM
 
 tx_pre: MACRO
--- a/main.asm
+++ b/main.asm
@@ -2339,7 +2339,7 @@
 	ld a, [W_XCOORD]
 	ld e, a
 	ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
-	and a
+	and a ; cp SPRITE_FACING_DOWN
 	jr nz, .notFacingDown
 ; facing down
 	aCoord 8, 11
@@ -2378,7 +2378,7 @@
 	ld d, a
 	ld e, [hl]
 	ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
-	and a
+	and a ; cp SPRITE_FACING_DOWN
 	jr nz, .notFacingDown
 ; facing down
 	ld hl, $ffdb
--- a/scripts/battlecenterm.asm
+++ b/scripts/battlecenterm.asm
@@ -19,7 +19,7 @@
 	ld [hli], a
 	ld a, $a
 	ld [hl], a
-	ld a, $8
+	ld a, SPRITE_FACING_LEFT
 	ld [wSpriteStateData1 + $19], a
 	ld a, [$ffaa]
 	cp $2
@@ -26,7 +26,7 @@
 	ret z
 	ld a, $7
 	ld [wSpriteStateData2 + $15], a
-	ld a, $c
+	ld a, SPRITE_FACING_RIGHT
 	ld [wSpriteStateData1 + $19], a
 	ret
 
--- a/scripts/billshouse.asm
+++ b/scripts/billshouse.asm
@@ -17,11 +17,11 @@
 
 BillsHouseScript1: ; 1e783 (7:6783)
 	ld a, [wSpriteStateData1 + 9]
-	and a
+	and a ; cp SPRITE_FACING_DOWN
 	ld de, MovementData_1e79c
-	jr nz, .asm_1e78f
+	jr nz, .notDown
 	ld de, MovementData_1e7a0
-.asm_1e78f
+.notDown
 	ld a, $1
 	ld [$ff8c], a
 	call MoveSprite
@@ -32,6 +32,7 @@
 MovementData_1e79c: ; 1e79c (7:679c)
 	db $40,$40,$40,$FF
 
+; make Bill walk around the player
 MovementData_1e7a0: ; 1e7a0 (7:67a0)
 	db $C0,$40,$40,$80,$40,$FF
 
--- a/scripts/copycatshouse2f.asm
+++ b/scripts/copycatshouse2f.asm
@@ -85,11 +85,11 @@
 CopycatsHouse2FText7: ; 5cd03 (17:4d03)
 	TX_ASM
 	ld a, [wSpriteStateData1 + 9]
-	cp $4
+	cp SPRITE_FACING_UP
 	ld hl, CopycatsHouse2FText_5cd1c
-	jr nz, .asm_399a4
+	jr nz, .notUp
 	ld hl, CopycatsHouse2FText_5cd17
-.asm_399a4
+.notUp
 	call PrintText
 	jp TextScriptEnd
 
--- a/scripts/mansion1.asm
+++ b/scripts/mansion1.asm
@@ -48,7 +48,7 @@
 
 Mansion1Script_Switches: ; 44316 (11:4316)
 	ld a, [wSpriteStateData1 + 9]
-	cp $4
+	cp SPRITE_FACING_UP
 	ret nz
 	xor a
 	ld [hJoyHeld], a
--- a/scripts/mansion2.asm
+++ b/scripts/mansion2.asm
@@ -44,7 +44,7 @@
 
 Mansion2Script_Switches: ; 52037 (14:6037)
 	ld a, [wSpriteStateData1 + 9]
-	cp $4
+	cp SPRITE_FACING_UP
 	ret nz
 	xor a
 	ld [hJoyHeld], a
--- a/scripts/mansion3.asm
+++ b/scripts/mansion3.asm
@@ -75,7 +75,7 @@
 
 Mansion3Script_Switches: ; 5227a (14:627a)
 	ld a, [wSpriteStateData1 + 9]
-	cp $4
+	cp SPRITE_FACING_UP
 	ret nz
 	xor a
 	ld [hJoyHeld], a
--- a/scripts/mansion4.asm
+++ b/scripts/mansion4.asm
@@ -46,7 +46,7 @@
 
 Mansion4Script_Switches: ; 52420 (14:6420)
 	ld a, [wSpriteStateData1 + 9]
-	cp $4
+	cp SPRITE_FACING_UP
 	ret nz
 	xor a
 	ld [hJoyHeld], a
--- a/scripts/oakslab.asm
+++ b/scripts/oakslab.asm
@@ -454,6 +454,7 @@
 	ld a, $12
 	ld [W_OAKSLABCURSCRIPT], a
 	jr .done
+; make the player keep facing the rival as he walks away
 .asm_1ce8c
 	ld a, [wcf0f]
 	cp $5
@@ -461,17 +462,17 @@
 	ld a, [W_XCOORD]
 	cp $4
 	jr nz, .asm_1cea1
-	ld a, $c
+	ld a, SPRITE_FACING_RIGHT
 	ld [wSpriteStateData1 + 9], a
 	jr .done
 .asm_1cea1
-	ld a, $8
+	ld a, SPRITE_FACING_LEFT
 	ld [wSpriteStateData1 + 9], a
 	jr .done
 .asm_1cea8
 	cp $4
 	ret nz
-	xor a
+	xor a ; ld a, SPRITE_FACING_DOWN
 	ld [wSpriteStateData1 + 9], a
 .done
 	ret
--- a/scripts/pallettown.asm
+++ b/scripts/pallettown.asm
@@ -97,7 +97,7 @@
 	ld a,[wd730]
 	bit 0,a
 	ret nz
-	xor a
+	xor a ; ld a, SPRITE_FACING_DOWN
 	ld [wSpriteStateData1 + 9],a
 	ld a,1
 	ld [wcf0d],a
--- a/scripts/pokemontower7.asm
+++ b/scripts/pokemontower7.asm
@@ -69,7 +69,7 @@
 	ld a, HS_POKEMONTOWER_7_MR_FUJI
 	ld [wcc4d], a
 	predef HideObject
-	ld a, $4
+	ld a, SPRITE_FACING_UP
 	ld [wSpriteStateData1 + 9], a
 	ld a, LAVENDER_HOUSE_1
 	ld [H_DOWNARROWBLINKCNT1], a
--- a/scripts/redshouse1f.asm
+++ b/scripts/redshouse1f.asm
@@ -52,11 +52,11 @@
 RedsHouse1FText2: ; 0x481c6 TV
 	TX_ASM
 	ld a,[wSpriteStateData1 + 9]
-	cp 4
+	cp SPRITE_FACING_UP
 	ld hl,TVWrongSideText
-	jr nz,.done ; if player is not facing up
+	jr nz,.notUp
 	ld hl,StandByMeText
-.done
+.notUp
 	call PrintText
 	jp TextScriptEnd
 
--- a/scripts/route11gateupstairs.asm
+++ b/scripts/route11gateupstairs.asm
@@ -50,8 +50,8 @@
 Route11GateUpstairsText3: ; 494a8 (12:54a8)
 	TX_ASM
 	ld a, [wSpriteStateData1 + 9]
-	cp $4
-	jp nz, Route12GateUpstairsScript_495c9
+	cp SPRITE_FACING_UP
+	jp nz, GateUpstairsScript_PrintIfFacingUp
 	ld a, [wd7d8]
 	bit 7, a ; fought snorlax?
 	ld hl, BinocularsSnorlaxText
@@ -72,7 +72,7 @@
 Route11GateUpstairsText4: ; 494ce (12:54ce)
 	TX_ASM
 	ld hl, Route11GateUpstairsText_494d5
-	jp Route12GateUpstairsScript_495c9
+	jp GateUpstairsScript_PrintIfFacingUp
 
 Route11GateUpstairsText_494d5: ; 494d5 (12:54d5)
 	TX_FAR _Route11GateUpstairsText_494d5
--- a/scripts/route12gateupstairs.asm
+++ b/scripts/route12gateupstairs.asm
@@ -50,7 +50,7 @@
 Route12GateUpstairsText2: ; 495b1 (12:55b1)
 	TX_ASM
 	ld hl, Route12GateUpstairsText_495b8
-	jp Route12GateUpstairsScript_495c9
+	jp GateUpstairsScript_PrintIfFacingUp
 
 Route12GateUpstairsText_495b8: ; 495b8 (12:55b8)
 	TX_FAR _Route12GateUpstairsText_495b8
@@ -59,21 +59,21 @@
 Route12GateUpstairsText3: ; 495bd (12:55bd)
 	TX_ASM
 	ld hl, Route12GateUpstairsText_495c4
-	jp Route12GateUpstairsScript_495c9
+	jp GateUpstairsScript_PrintIfFacingUp
 
 Route12GateUpstairsText_495c4: ; 495c4 (12:55c4)
 	TX_FAR _Route12GateUpstairsText_495c4
 	db "@"
 
-Route12GateUpstairsScript_495c9: ; 495c9 (12:55c9)
+GateUpstairsScript_PrintIfFacingUp: ; 495c9 (12:55c9)
 	ld a, [wSpriteStateData1 + 9]
-	cp $4
-	jr z, .asm_495d4
+	cp SPRITE_FACING_UP
+	jr z, .up
 	ld a, $1
-	jr .asm_495d8
-.asm_495d4
+	jr .done
+.up
 	call PrintText
 	xor a
-.asm_495d8
+.done
 	ld [wDoNotWaitForButtonPressAfterDisplayingText], a
 	jp TextScriptEnd
--- a/scripts/route15gateupstairs.asm
+++ b/scripts/route15gateupstairs.asm
@@ -39,7 +39,7 @@
 Route15GateUpstairsText2: ; 49691 (12:5691)
 	TX_ASM
 	ld hl, Route15GateUpstairsText_49698
-	jp Route12GateUpstairsScript_495c9
+	jp GateUpstairsScript_PrintIfFacingUp
 
 Route15GateUpstairsText_49698: ; 49698 (12:5698)
 	TX_FAR _Route15GateUpstairsText_49698
--- a/scripts/route16gateupstairs.asm
+++ b/scripts/route16gateupstairs.asm
@@ -30,7 +30,7 @@
 Route16GateUpstairsText3: ; 49834 (12:5834)
 	TX_ASM
 	ld hl, Route16GateUpstairsText_4983b
-	jp Route12GateUpstairsScript_495c9
+	jp GateUpstairsScript_PrintIfFacingUp
 
 Route16GateUpstairsText_4983b: ; 4983b (12:583b)
 	TX_FAR _Route16GateUpstairsText_4983b
@@ -39,7 +39,7 @@
 Route16GateUpstairsText4: ; 49840 (12:5840)
 	TX_ASM
 	ld hl, Route16GateUpstairsText_49847
-	jp Route12GateUpstairsScript_495c9
+	jp GateUpstairsScript_PrintIfFacingUp
 
 Route16GateUpstairsText_49847: ; 49847 (12:5847)
 	TX_FAR _Route16GateUpstairsText_49847
--- a/scripts/route18gateupstairs.asm
+++ b/scripts/route18gateupstairs.asm
@@ -16,7 +16,7 @@
 Route18GateUpstairsText2: ; 4998c (12:598c)
 	TX_ASM
 	ld hl, Route18GateUpstairsText_49993
-	jp Route12GateUpstairsScript_495c9
+	jp GateUpstairsScript_PrintIfFacingUp
 
 Route18GateUpstairsText_49993: ; 49993 (12:5993)
 	TX_FAR _Route18GateUpstairsText_49993
@@ -25,7 +25,7 @@
 Route18GateUpstairsText3: ; 49998 (12:5998)
 	TX_ASM
 	ld hl, Route18GateUpstairsText_4999f
-	jp Route12GateUpstairsScript_495c9
+	jp GateUpstairsScript_PrintIfFacingUp
 
 Route18GateUpstairsText_4999f: ; 4999f (12:599f)
 	TX_FAR _Route18GateUpstairsText_4999f
--- a/scripts/route22.asm
+++ b/scripts/route22.asm
@@ -148,13 +148,13 @@
 	cp $ff
 	jp z, Route22Script_50ece
 	ld a, [wSpriteStateData1 + 9]
-	and a
-	jr nz, .asm_50fc7
-	ld a, $4
-	jr .asm_50fc9
-.asm_50fc7
-	ld a, $c
-.asm_50fc9
+	and a ; cp SPRITE_FACING_DOWN
+	jr nz, .notDown
+	ld a, SPRITE_FACING_UP
+	jr .done
+.notDown
+	ld a, SPRITE_FACING_RIGHT
+.done
 	ld [$ff8d], a
 	ld a, $1
 	ld [$ff8c], a
--- a/scripts/safarizoneentrance.asm
+++ b/scripts/safarizoneentrance.asm
@@ -24,7 +24,7 @@
 	ld [wJoyIgnore], a
 	xor a
 	ld [hJoyHeld], a
-	ld a, $c
+	ld a, SPRITE_FACING_RIGHT
 	ld [wSpriteStateData1 + 9], a
 	ld a, [wWhichTrade]
 	cp $1
@@ -247,7 +247,7 @@
 .asm_7539c
 	ld hl, .SafariZoneEntranceText_753c0
 	call PrintText
-	ld a, $4
+	ld a, SPRITE_FACING_UP
 	ld [wSpriteStateData1 + 9], a
 	ld a, $40
 	ld c, $1
--- a/scripts/vermilioncity.asm
+++ b/scripts/vermilioncity.asm
@@ -40,7 +40,7 @@
 
 VermilionCityScript0: ; 197e6 (6:57e6)
 	ld a, [wSpriteStateData1 + 9]
-	and a
+	and a ; cp SPRITE_FACING_DOWN
 	ret nz
 	ld hl, CoordsData_19823
 	call ArePlayerCoordsInArray
@@ -54,7 +54,7 @@
 	ld a, [wd803]
 	bit 2, a
 	jr nz, .asm_19810
-	ld b, $3f
+	ld b, S_S__TICKET
 	predef IsItemInBag_
 	ld a, b
 	and a
@@ -162,7 +162,7 @@
 	bit 2, a
 	jr nz, .asm_198f6
 	ld a, [wSpriteStateData1 + 9]
-	cp $c
+	cp SPRITE_FACING_RIGHT
 	jr z, .asm_198c8
 	ld hl, VermilionCityCoords1
 	call ArePlayerCoordsInArray