ref: dcc7f3bc9f41f2d5e0f7448b4688c1058da0040b
parent: 5ce58a048cecba5435d74b14652c58004d3f95b1
author: YamaArashi <shadow962@live.com>
date: Tue Jul 21 10:21:14 EDT 2015
named more constants
--- a/constants/event_constants.asm
+++ b/constants/event_constants.asm
@@ -3,7 +3,7 @@
const EVENT_FOLLOWED_OAK_INTO_LAB ; 000, (D747, bit 0)
const EVENT_001 ; 001, (D747, bit 1)
const EVENT_002 ; 002, (D747, bit 2)
- const EVENT_003 ; 003, (D747, bit 3)
+ const EVENT_HALL_OF_FAME_DEX_RATING ; 003, (D747, bit 3)
const EVENT_004 ; 004, (D747, bit 4)
const EVENT_005 ; 005, (D747, bit 5)
const EVENT_PALLET_AFTER_GETTING_POKEBALLS ; 006, (D747, bit 6)
@@ -666,13 +666,13 @@
const EVENT_297 ; 297, (D799, bit 7)
const EVENT_GOT_TM38 ; 298, (D79A, bit 0)
const EVENT_BEAT_BLAINE ; 299, (D79A, bit 1)
- const EVENT_29A ; 29A, (D79A, bit 2)
- const EVENT_29B ; 29B, (D79A, bit 3)
- const EVENT_29C ; 29C, (D79A, bit 4)
- const EVENT_29D ; 29D, (D79A, bit 5)
- const EVENT_29E ; 29E, (D79A, bit 6)
- const EVENT_29F ; 29F, (D79A, bit 7)
- const EVENT_2A0 ; 2A0, (D79B, bit 0)
+ const EVENT_BEAT_CINNABAR_GYM_TRAINER_0 ; 29A, (D79A, bit 2)
+ const EVENT_BEAT_CINNABAR_GYM_TRAINER_1 ; 29B, (D79A, bit 3)
+ const EVENT_BEAT_CINNABAR_GYM_TRAINER_2 ; 29C, (D79A, bit 4)
+ const EVENT_BEAT_CINNABAR_GYM_TRAINER_3 ; 29D, (D79A, bit 5)
+ const EVENT_BEAT_CINNABAR_GYM_TRAINER_4 ; 29E, (D79A, bit 6)
+ const EVENT_BEAT_CINNABAR_GYM_TRAINER_5 ; 29F, (D79A, bit 7)
+ const EVENT_BEAT_CINNABAR_GYM_TRAINER_6 ; 2A0, (D79B, bit 0)
const EVENT_2A1 ; 2A1, (D79B, bit 1)
const EVENT_2A2 ; 2A2, (D79B, bit 2)
const EVENT_2A3 ; 2A3, (D79B, bit 3)
@@ -680,13 +680,13 @@
const EVENT_2A5 ; 2A5, (D79B, bit 5)
const EVENT_2A6 ; 2A6, (D79B, bit 6)
const EVENT_2A7 ; 2A7, (D79B, bit 7)
- const EVENT_2A8 ; 2A8, (D79C, bit 0)
- const EVENT_2A9 ; 2A9, (D79C, bit 1)
- const EVENT_2AA ; 2AA, (D79C, bit 2)
- const EVENT_2AB ; 2AB, (D79C, bit 3)
- const EVENT_2AC ; 2AC, (D79C, bit 4)
- const EVENT_2AD ; 2AD, (D79C, bit 5)
- const EVENT_2AE ; 2AE, (D79C, bit 6)
+ const EVENT_CINNABAR_GYM_GATE0_UNLOCKED ; 2A8, (D79C, bit 0) doesn't exist, but the bit is set
+ const EVENT_CINNABAR_GYM_GATE1_UNLOCKED ; 2A9, (D79C, bit 1)
+ const EVENT_CINNABAR_GYM_GATE2_UNLOCKED ; 2AA, (D79C, bit 2)
+ const EVENT_CINNABAR_GYM_GATE3_UNLOCKED ; 2AB, (D79C, bit 3)
+ const EVENT_CINNABAR_GYM_GATE4_UNLOCKED ; 2AC, (D79C, bit 4)
+ const EVENT_CINNABAR_GYM_GATE5_UNLOCKED ; 2AD, (D79C, bit 5)
+ const EVENT_CINNABAR_GYM_GATE6_UNLOCKED ; 2AE, (D79C, bit 6)
const EVENT_2AF ; 2AF, (D79C, bit 7)
const EVENT_2B0 ; 2B0, (D79D, bit 0)
const EVENT_2B1 ; 2B1, (D79D, bit 1)
@@ -2272,7 +2272,7 @@
const EVENT_8DD ; 8DD, (D862, bit 5)
const EVENT_8DE ; 8DE, (D862, bit 6)
const EVENT_8DF ; 8DF, (D862, bit 7)
- const EVENT_ELITE4_EVENTS_START ; 8E0, (D863, bit 0)
+ const ELITE4_EVENTS_START ; 8E0, (D863, bit 0)
const EVENT_BEAT_LORELEIS_ROOM_TRAINER_0 ; 8E1, (D863, bit 1)
const EVENT_8E2 ; 8E2, (D863, bit 2)
const EVENT_8E3 ; 8E3, (D863, bit 3)
@@ -2311,7 +2311,7 @@
const EVENT_904 ; 904, (D867, bit 4)
const EVENT_905 ; 905, (D867, bit 5)
const EVENT_906 ; 906, (D867, bit 6)
- const EVENT_907 ; 907, (D867, bit 7)
+ const ELITE4_CHAMPION_EVENTS_END ; 907, (D867, bit 7)
const EVENT_908 ; 908, (D868, bit 0)
const EVENT_909 ; 909, (D868, bit 1)
const EVENT_90A ; 90A, (D868, bit 2)
--- a/engine/hall_of_fame.asm
+++ b/engine/hall_of_fame.asm
@@ -207,7 +207,7 @@
predef_jump CopyTileIDsFromList
HoFDisplayPlayerStats: ; 70377 (1c:4377)
- SetEvent EVENT_003
+ SetEvent EVENT_HALL_OF_FAME_DEX_RATING
predef DisplayDexRating
coord hl, 0, 4
ld b, $6
--- a/engine/hidden_object_functions7.asm
+++ b/engine/hidden_object_functions7.asm
@@ -188,8 +188,8 @@
TX_FAR _CinnabarQuizQuestionsText6
db "@"
-CinnabarGymQuiz_1ea8a: ; 1ea8a (7:6a8a)
- EventFlagAddress hl, EVENT_2A8
+CinnabarGymGateFlagAction: ; 1ea8a (7:6a8a)
+ EventFlagAddress hl, EVENT_CINNABAR_GYM_GATE0_UNLOCKED
predef_jump FlagActionPredef
CinnabarGymQuiz_1ea92: ; 1ea92 (7:6a92)
@@ -206,11 +206,11 @@
ld hl, CinnabarGymQuizCorrectText
call PrintText
ld a, [$ffe0]
- AdjustEventBit EVENT_2A8, 0
+ AdjustEventBit EVENT_CINNABAR_GYM_GATE0_UNLOCKED, 0
ld c, a
ld b, FLAG_SET
- call CinnabarGymQuiz_1ea8a
- jp CinnabarGymQuiz_1eb0a
+ call CinnabarGymGateFlagAction
+ jp UpdateCinnabarGymGateTileBlocks_
.asm_1eab8
call WaitForSoundToFinish
ld a, SFX_DENIED
@@ -220,10 +220,10 @@
call PrintText
ld a, [$ffdb]
add $2
- AdjustEventBit EVENT_29A, 2
+ AdjustEventBit EVENT_BEAT_CINNABAR_GYM_TRAINER_0, 2
ld c, a
ld b, FLAG_TEST
- EventFlagAddress hl, EVENT_29A
+ EventFlagAddress hl, EVENT_BEAT_CINNABAR_GYM_TRAINER_0
predef FlagActionPredef
ld a, c
and a
@@ -240,10 +240,10 @@
TX_ASM
ld a, [$ffe0]
- AdjustEventBit EVENT_2A8, 0
+ AdjustEventBit EVENT_CINNABAR_GYM_GATE0_UNLOCKED, 0
ld c, a
ld b, FLAG_TEST
- call CinnabarGymQuiz_1ea8a
+ call CinnabarGymGateFlagAction
ld a, c
and a
jp nz, TextScriptEnd
@@ -257,15 +257,17 @@
TX_FAR _CinnabarGymQuizIncorrectText
db "@"
-CinnabarGymQuiz_1eb0a: ; 1eb0a (7:6b0a)
- ld a, $6
+UpdateCinnabarGymGateTileBlocks_: ; 1eb0a (7:6b0a)
+; Update the overworld map with open floor blocks or locked gate blocks
+; depending on event flags.
+ ld a, 6
ld [$ffdb], a
-.asm_1eb0e
+.loop
ld a, [$ffdb]
dec a
add a
add a
- ld d, $0
+ ld d, 0
ld e, a
ld hl, CinnabarGymGateCoords
add hl, de
@@ -278,24 +280,24 @@
push bc
ld a, [$ffdb]
ld [$ffe0], a
- AdjustEventBit EVENT_2A8, 0
+ AdjustEventBit EVENT_CINNABAR_GYM_GATE0_UNLOCKED, 0
ld c, a
ld b, FLAG_TEST
- call CinnabarGymQuiz_1ea8a
+ call CinnabarGymGateFlagAction
ld a, c
and a
- jr nz, .asm_1eb36
+ jr nz, .unlocked
ld a, [wd12f]
- jr .asm_1eb38
-.asm_1eb36
+ jr .next
+.unlocked
ld a, $e
-.asm_1eb38
+.next
pop bc
ld [wd09f], a
predef ReplaceTileBlock
ld hl, $ffdb
dec [hl]
- jr nz, .asm_1eb0e
+ jr nz, .loop
ret
CinnabarGymGateCoords: ; 1eb48 (7:6b48)
--- a/engine/pokedex_rating.asm
+++ b/engine/pokedex_rating.asm
@@ -23,7 +23,7 @@
ld a, [hli]
ld h, [hl]
ld l, a ; load text pointer into hl
- CheckAndResetEventA EVENT_003
+ CheckAndResetEventA EVENT_HALL_OF_FAME_DEX_RATING
jr nz, .label3
push hl
ld hl, PokedexRatingText_441cc
--- a/home.asm
+++ b/home.asm
@@ -4590,8 +4590,8 @@
INCLUDE "home/predef.asm"
-Func_3ead:: ; 3ead (0:3ead)
- jpba CinnabarGymQuiz_1eb0a
+UpdateCinnabarGymGateTileBlocks:: ; 3ead (0:3ead)
+ jpba UpdateCinnabarGymGateTileBlocks_
CheckForHiddenObjectOrBookshelfOrCardKeyDoor:: ; 3eb5 (0:3eb5)
ld a, [H_LOADEDROMBANK]
--- a/scripts/cinnabargym.asm
+++ b/scripts/cinnabargym.asm
@@ -14,7 +14,7 @@
pop hl
bit 5, [hl]
res 5, [hl]
- call nz, Func_3ead
+ call nz, UpdateCinnabarGymGateTileBlocks
ResetEvent EVENT_2A7
ret
CinnabarGymScript_75772: ; 75772 (1d:5772)
@@ -88,7 +88,7 @@
ld [hSpriteIndexOrTextID], a
jp DisplayTextID
-CinnabarGymScript_757f1: ; 757f1 (1d:57f1)
+CinnabarGymFlagAction: ; 757f1 (1d:57f1)
predef_jump FlagActionPredef
CinnabarGymScript2: ; 757f6 (1d:57f6)
@@ -97,11 +97,11 @@
jp z, CinnabarGymScript_75792
ld a, [wTrainerHeaderFlagBit]
ld [$ffdb], a
- AdjustEventBit EVENT_29A, 2
+ AdjustEventBit EVENT_BEAT_CINNABAR_GYM_TRAINER_0, 2
ld c, a
ld b, FLAG_TEST
- EventFlagAddress hl, EVENT_29A
- call CinnabarGymScript_757f1
+ EventFlagAddress hl, EVENT_BEAT_CINNABAR_GYM_TRAINER_0
+ call CinnabarGymFlagAction
ld a, c
and a
jr nz, .asm_7581b
@@ -112,19 +112,19 @@
.asm_7581b
ld a, [wTrainerHeaderFlagBit]
ld [$ffdb], a
- AdjustEventBit EVENT_29A, 2
+ AdjustEventBit EVENT_BEAT_CINNABAR_GYM_TRAINER_0, 2
ld c, a
ld b, FLAG_SET
- EventFlagAddress hl, EVENT_29A
- call CinnabarGymScript_757f1
+ EventFlagAddress hl, EVENT_BEAT_CINNABAR_GYM_TRAINER_0
+ call CinnabarGymFlagAction
ld a, [wTrainerHeaderFlagBit]
sub $2
- AdjustEventBit EVENT_2A8, 0
+ AdjustEventBit EVENT_CINNABAR_GYM_GATE0_UNLOCKED, 0
ld c, a
ld b, FLAG_SET
- EventFlagAddress hl, EVENT_2A8
- call CinnabarGymScript_757f1
- call Func_3ead
+ EventFlagAddress hl, EVENT_CINNABAR_GYM_GATE0_UNLOCKED
+ call CinnabarGymFlagAction
+ call UpdateCinnabarGymGateTileBlocks
xor a
ld [wJoyIgnore], a
ld [wda38], a
@@ -163,7 +163,7 @@
set 6, [hl]
; deactivate gym trainers
- SetEventRange EVENT_29A, EVENT_2A0
+ SetEventRange EVENT_BEAT_CINNABAR_GYM_TRAINER_0, EVENT_BEAT_CINNABAR_GYM_TRAINER_6
ld hl, wd126
set 5, [hl]
@@ -258,7 +258,7 @@
CinnabarGymText2: ; 75939 (1d:5939)
TX_ASM
call CinnabarGymScript_757a0
- CheckEvent EVENT_29A
+ CheckEvent EVENT_BEAT_CINNABAR_GYM_TRAINER_0
jr nz, .asm_46bb4
ld hl, CinnabarGymText_7595f
call PrintText
@@ -286,7 +286,7 @@
CinnabarGymText3: ; 7596e (1d:596e)
TX_ASM
call CinnabarGymScript_757a0
- CheckEvent EVENT_29B
+ CheckEvent EVENT_BEAT_CINNABAR_GYM_TRAINER_1
jr nz, .asm_4b406
ld hl, CinnabarGymText_75994
call PrintText
@@ -314,7 +314,7 @@
CinnabarGymText4: ; 759a3 (1d:59a3)
TX_ASM
call CinnabarGymScript_757a0
- CheckEvent EVENT_29C
+ CheckEvent EVENT_BEAT_CINNABAR_GYM_TRAINER_2
jr nz, .asm_c0673
ld hl, CinnabarGymText_759c9
call PrintText
@@ -342,7 +342,7 @@
CinnabarGymText5: ; 759d8 (1d:59d8)
TX_ASM
call CinnabarGymScript_757a0
- CheckEvent EVENT_29D
+ CheckEvent EVENT_BEAT_CINNABAR_GYM_TRAINER_3
jr nz, .asm_5cfd7
ld hl, CinnabarGymText_759fe
call PrintText
@@ -370,7 +370,7 @@
CinnabarGymText6: ; 75a0d (1d:5a0d)
TX_ASM
call CinnabarGymScript_757a0
- CheckEvent EVENT_29E
+ CheckEvent EVENT_BEAT_CINNABAR_GYM_TRAINER_4
jr nz, .asm_776b4
ld hl, CinnabarGymText_75a33
call PrintText
@@ -398,7 +398,7 @@
CinnabarGymText7: ; 75a42 (1d:5a42)
TX_ASM
call CinnabarGymScript_757a0
- CheckEvent EVENT_29F
+ CheckEvent EVENT_BEAT_CINNABAR_GYM_TRAINER_5
jr nz, .asm_2f755
ld hl, CinnabarGymText_75a68
call PrintText
@@ -426,7 +426,7 @@
CinnabarGymText8: ; 75a77 (1d:5a77)
TX_ASM
call CinnabarGymScript_757a0
- CheckEvent EVENT_2A0
+ CheckEvent EVENT_BEAT_CINNABAR_GYM_TRAINER_6
jr nz, .asm_d87be
ld hl, CinnabarGymText_75a9d
call PrintText
--- a/scripts/halloffameroom.asm
+++ b/scripts/halloffameroom.asm
@@ -40,7 +40,7 @@
ld [W_LANCECURSCRIPT], a
ld [W_HALLOFFAMEROOMCURSCRIPT], a
; Elite 4 events
- ResetEventRange EVENT_ELITE4_EVENTS_START, EVENT_907, 1
+ ResetEventRange ELITE4_EVENTS_START, ELITE4_CHAMPION_EVENTS_END, 1
xor a
ld [W_HALLOFFAMEROOMCURSCRIPT], a
ld a, PALLET_TOWN
--- a/scripts/indigoplateaulobby.asm
+++ b/scripts/indigoplateaulobby.asm
@@ -6,12 +6,12 @@
res 6, [hl]
ret z
ResetEvent EVENT_VICTORY_ROAD_1_BOULDER_ON_SWITCH
- ld hl, wd734
+ ld hl, wBeatLorelei
bit 1, [hl]
res 1, [hl]
ret z
; Elite 4 events
- ResetEventRange EVENT_ELITE4_EVENTS_START, EVENT_LANCES_ROOM_LOCK_DOOR
+ ResetEventRange ELITE4_EVENTS_START, EVENT_LANCES_ROOM_LOCK_DOOR
ret
IndigoPlateauLobbyTextPointers: ; 19c7f (6:5c7f)
--- a/scripts/lorelei.asm
+++ b/scripts/lorelei.asm
@@ -13,7 +13,7 @@
bit 5, [hl]
res 5, [hl]
ret z
- ld hl, wd734
+ ld hl, wBeatLorelei
set 1, [hl]
CheckEvent EVENT_BEAT_LORELEIS_ROOM_TRAINER_0
jr z, .asm_761a9
--- a/wram.asm
+++ b/wram.asm
@@ -2547,7 +2547,10 @@
; bit 7: used fly out of battle
ds 1
-wd734:: ds 2 ; flag for indigo plateau and lorelei (not sure what it's for)
+wBeatLorelei:: ; d734
+; bit 1: set when you beat Lorelei and reset in Indigo Plateau lobby
+; the game uses this to tell when Elite 4 events need to be reset
+ ds 2
wd736:: ; d736
; bit 0: check if the player is standing on a door and make him walk down a step if so