Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Identify wCurrentMapScriptFlags bits #467

Merged
merged 2 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions constants/ram_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ DEF BIT_TEXT_PREDEF EQU 0
; wFontLoaded
DEF BIT_FONT_LOADED EQU 0

; wCurrentMapScriptFlags
const_def 5
const BIT_CUR_MAP_LOADED_1 ; 5
const BIT_CUR_MAP_LOADED_2 ; 6
const BIT_CUR_MAP_USED_ELEVATOR ; 7

; wOptions
DEF TEXT_DELAY_MASK EQU %111
const_def 6
Expand Down
2 changes: 1 addition & 1 deletion engine/events/card_key.asm
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ PrintCardKeyText:
ld [wNewTileBlockID], a
predef ReplaceTileBlock
ld hl, wCurrentMapScriptFlags
set 5, [hl]
set BIT_CUR_MAP_LOADED_1, [hl]
ld a, SFX_GO_INSIDE
jp PlaySound
.noCardKey
Expand Down
2 changes: 1 addition & 1 deletion engine/events/elevator.asm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ DisplayElevatorFloorMenu:
ld [wListScrollOffset], a
ret c
ld hl, wCurrentMapScriptFlags
set 7, [hl]
set BIT_CUR_MAP_USED_ELEVATOR, [hl]
ld hl, wElevatorWarpMaps
ld a, [wWhichPokemon]
add a
Expand Down
2 changes: 1 addition & 1 deletion engine/events/hidden_objects/cinnabar_gym_quiz.asm
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ CinnabarGymQuiz_AskQuestion:
cp c
jr nz, .wrongAnswer
ld hl, wCurrentMapScriptFlags
set 5, [hl]
set BIT_CUR_MAP_LOADED_1, [hl]
ldh a, [hGymGateIndex]
ldh [hBackupGymGateIndex], a
ld hl, CinnabarGymQuizCorrectText
Expand Down
2 changes: 1 addition & 1 deletion engine/events/hidden_objects/vermilion_gym_trash.asm
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ GymTrashScript:
; Completed the trash can puzzle.
SetEvent EVENT_2ND_LOCK_OPENED
ld hl, wCurrentMapScriptFlags
set 6, [hl]
set BIT_CUR_MAP_LOADED_2, [hl]

tx_pre_id VermilionGymTrashSuccessText3

Expand Down
2 changes: 1 addition & 1 deletion engine/menus/main_menu.asm
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ MainMenu:
.choseContinue
call DisplayContinueGameInfo
ld hl, wCurrentMapScriptFlags
set 5, [hl]
set BIT_CUR_MAP_LOADED_1, [hl]
.inputLoop
xor a
ldh [hJoyPressed], a
Expand Down
8 changes: 4 additions & 4 deletions home/overworld.asm
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ EnterMap::
res BIT_NO_NPC_FACE_PLAYER, [hl]
call UpdateSprites
ld hl, wCurrentMapScriptFlags
set 5, [hl]
set 6, [hl]
set BIT_CUR_MAP_LOADED_1, [hl]
set BIT_CUR_MAP_LOADED_2, [hl]
xor a
ld [wJoyIgnore], a

Expand Down Expand Up @@ -329,8 +329,8 @@ OverworldLoopLessDelay::
ld hl, wStatusFlags7
res BIT_TRAINER_BATTLE, [hl]
ld hl, wCurrentMapScriptFlags
set 5, [hl]
set 6, [hl]
set BIT_CUR_MAP_LOADED_1, [hl]
set BIT_CUR_MAP_LOADED_2, [hl]
xor a
ldh [hJoyHeld], a
ld a, [wCurMap]
Expand Down
4 changes: 2 additions & 2 deletions home/trainers.asm
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ StartTrainerBattle::

EndTrainerBattle::
ld hl, wCurrentMapScriptFlags
set 5, [hl]
set 6, [hl]
set BIT_CUR_MAP_LOADED_1, [hl]
set BIT_CUR_MAP_LOADED_2, [hl]
ld hl, wStatusFlags3
res BIT_PRINT_END_BATTLE_TEXT, [hl]
ld hl, wMiscFlags
Expand Down
5 changes: 4 additions & 1 deletion ram/wram.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1593,7 +1593,10 @@ wIsKeyItem:: db

wTextBoxID:: db

wCurrentMapScriptFlags:: db ; not exactly sure what this is used for, but it seems to be used as a multipurpose temp flag value
; bit 5: set when maps first load; can be reset to re-run a script
; bit 6: set when maps first load; can be reset to re-run a script (used less often than bit 5)
; bit 7: set when using an elevator map's menu; triggers the shaking animation
wCurrentMapScriptFlags:: db

wCurEnemyLevel:: db

Expand Down
4 changes: 2 additions & 2 deletions scripts/AgathasRoom.asm
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ AgathasRoom_Script:
AgathaShowOrHideExitBlock:
; Blocks or clears the exit to the next room.
ld hl, wCurrentMapScriptFlags
bit 5, [hl]
res 5, [hl]
bit BIT_CUR_MAP_LOADED_1, [hl]
res BIT_CUR_MAP_LOADED_1, [hl]
ret z
CheckEvent EVENT_BEAT_AGATHAS_ROOM_TRAINER_0
jr z, .blockExitToNextRoom
Expand Down
4 changes: 2 additions & 2 deletions scripts/BrunosRoom.asm
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ BrunosRoom_Script:
BrunoShowOrHideExitBlock:
; Blocks or clears the exit to the next room.
ld hl, wCurrentMapScriptFlags
bit 5, [hl]
res 5, [hl]
bit BIT_CUR_MAP_LOADED_1, [hl]
res BIT_CUR_MAP_LOADED_1, [hl]
ret z
CheckEvent EVENT_BEAT_BRUNOS_ROOM_TRAINER_0
jr z, .blockExitToNextRoom
Expand Down
4 changes: 2 additions & 2 deletions scripts/CeladonGym.asm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CeladonGym_Script:
ld hl, wCurrentMapScriptFlags
bit 6, [hl]
res 6, [hl]
bit BIT_CUR_MAP_LOADED_2, [hl]
res BIT_CUR_MAP_LOADED_2, [hl]
call nz, .LoadNames
call EnableAutoTextBoxDrawing
ld hl, CeladonGymTrainerHeaders
Expand Down
8 changes: 4 additions & 4 deletions scripts/CeladonMartElevator.asm
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
CeladonMartElevator_Script:
ld hl, wCurrentMapScriptFlags
bit 5, [hl]
res 5, [hl]
bit BIT_CUR_MAP_LOADED_1, [hl]
res BIT_CUR_MAP_LOADED_1, [hl]
push hl
call nz, CeladonMartElevatorStoreWarpEntriesScript
pop hl
bit 7, [hl]
res 7, [hl]
bit BIT_CUR_MAP_USED_ELEVATOR, [hl]
res BIT_CUR_MAP_USED_ELEVATOR, [hl]
call nz, CeladonMartElevatorShakeScript
xor a
ld [wAutoTextBoxDrawingControl], a
Expand Down
4 changes: 2 additions & 2 deletions scripts/CeruleanGym.asm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CeruleanGym_Script:
ld hl, wCurrentMapScriptFlags
bit 6, [hl]
res 6, [hl]
bit BIT_CUR_MAP_LOADED_2, [hl]
res BIT_CUR_MAP_LOADED_2, [hl]
call nz, .LoadNames
call EnableAutoTextBoxDrawing
ld hl, CeruleanGymTrainerHeaders
Expand Down
10 changes: 5 additions & 5 deletions scripts/CinnabarGym.asm
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ CinnabarGym_Script:

CinnabarGymSetMapAndTiles:
ld hl, wCurrentMapScriptFlags
bit 6, [hl]
res 6, [hl]
bit BIT_CUR_MAP_LOADED_2, [hl]
res BIT_CUR_MAP_LOADED_2, [hl]
push hl
call nz, .LoadNames
pop hl
bit 5, [hl]
res 5, [hl]
bit BIT_CUR_MAP_LOADED_1, [hl]
res BIT_CUR_MAP_LOADED_1, [hl]
call nz, UpdateCinnabarGymGateTileBlocks
ResetEvent EVENT_2A7
ret
Expand Down Expand Up @@ -170,7 +170,7 @@ CinnabarGymReceiveTM38:
SetEventRange EVENT_BEAT_CINNABAR_GYM_TRAINER_0, EVENT_BEAT_CINNABAR_GYM_TRAINER_6

ld hl, wCurrentMapScriptFlags
set 5, [hl]
set BIT_CUR_MAP_LOADED_1, [hl]

jp CinnabarGymResetScripts

Expand Down
2 changes: 1 addition & 1 deletion scripts/CinnabarIsland.asm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CinnabarIsland_Script:
call EnableAutoTextBoxDrawing
ld hl, wCurrentMapScriptFlags
set 5, [hl]
set BIT_CUR_MAP_LOADED_1, [hl]
ResetEvent EVENT_MANSION_SWITCH_ON
ResetEvent EVENT_LAB_STILL_REVIVING_FOSSIL
ld hl, CinnabarIsland_ScriptPointers
Expand Down
4 changes: 2 additions & 2 deletions scripts/FuchsiaGym.asm
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ FuchsiaGym_Script:

.LoadNames:
ld hl, wCurrentMapScriptFlags
bit 6, [hl]
res 6, [hl]
bit BIT_CUR_MAP_LOADED_2, [hl]
res BIT_CUR_MAP_LOADED_2, [hl]
ret z
ld hl, .CityName
ld de, .LeaderName
Expand Down
12 changes: 6 additions & 6 deletions scripts/GameCorner.asm
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ GameCorner_Script:

GameCornerSelectLuckySlotMachine:
ld hl, wCurrentMapScriptFlags
bit 6, [hl]
res 6, [hl]
bit BIT_CUR_MAP_LOADED_2, [hl]
res BIT_CUR_MAP_LOADED_2, [hl]
ret z
call Random
ldh a, [hRandomAdd]
Expand All @@ -25,8 +25,8 @@ GameCornerSelectLuckySlotMachine:

GameCornerSetRocketHideoutDoorTile:
ld hl, wCurrentMapScriptFlags
bit 5, [hl]
res 5, [hl]
bit BIT_CUR_MAP_LOADED_1, [hl]
res BIT_CUR_MAP_LOADED_1, [hl]
ret z
CheckEvent EVENT_FOUND_ROCKET_HIDEOUT
ret nz
Expand Down Expand Up @@ -111,8 +111,8 @@ GameCornerRocketExitScript:
ld [wMissableObjectIndex], a
predef HideObject
ld hl, wCurrentMapScriptFlags
set 5, [hl]
set 6, [hl]
set BIT_CUR_MAP_LOADED_1, [hl]
set BIT_CUR_MAP_LOADED_2, [hl]
ld a, SCRIPT_GAMECORNER_DEFAULT
ld [wGameCornerCurScript], a
ret
Expand Down
4 changes: 2 additions & 2 deletions scripts/IndigoPlateauLobby.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ IndigoPlateauLobby_Script:
call Serial_TryEstablishingExternallyClockedConnection
call EnableAutoTextBoxDrawing
ld hl, wCurrentMapScriptFlags
bit 6, [hl]
res 6, [hl]
bit BIT_CUR_MAP_LOADED_2, [hl]
res BIT_CUR_MAP_LOADED_2, [hl]
ret z
ResetEvent EVENT_VICTORY_ROAD_1_BOULDER_ON_SWITCH
; Reset Elite Four events if the player started challenging them before
Expand Down
6 changes: 3 additions & 3 deletions scripts/LancesRoom.asm
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ LancesRoom_Script:

LanceShowOrHideEntranceBlocks:
ld hl, wCurrentMapScriptFlags
bit 5, [hl]
res 5, [hl]
bit BIT_CUR_MAP_LOADED_1, [hl]
res BIT_CUR_MAP_LOADED_1, [hl]
ret z
CheckEvent EVENT_LANCES_ROOM_LOCK_DOOR
jr nz, .closeEntrance
Expand Down Expand Up @@ -71,7 +71,7 @@ LancesRoomDefaultScript:
CheckAndSetEvent EVENT_LANCES_ROOM_LOCK_DOOR
ret nz
ld hl, wCurrentMapScriptFlags
set 5, [hl]
set BIT_CUR_MAP_LOADED_1, [hl]
ld a, SFX_GO_INSIDE
call PlaySound
jp LanceShowOrHideEntranceBlocks
Expand Down
4 changes: 2 additions & 2 deletions scripts/LoreleisRoom.asm
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ LoreleisRoom_Script:
LoreleiShowOrHideExitBlock:
; Blocks or clears the exit to the next room.
ld hl, wCurrentMapScriptFlags
bit 5, [hl]
res 5, [hl]
bit BIT_CUR_MAP_LOADED_1, [hl]
res BIT_CUR_MAP_LOADED_1, [hl]
ret z
ld hl, wElite4Flags
set BIT_STARTED_ELITE_4, [hl]
Expand Down
4 changes: 2 additions & 2 deletions scripts/PewterGym.asm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PewterGym_Script:
ld hl, wCurrentMapScriptFlags
bit 6, [hl]
res 6, [hl]
bit BIT_CUR_MAP_LOADED_2, [hl]
res BIT_CUR_MAP_LOADED_2, [hl]
call nz, .LoadNames
call EnableAutoTextBoxDrawing
ld hl, PewterGymTrainerHeaders
Expand Down
6 changes: 3 additions & 3 deletions scripts/PokemonMansion1F.asm
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ PokemonMansion1F_Script:

Mansion1CheckReplaceSwitchDoorBlocks:
ld hl, wCurrentMapScriptFlags
bit 5, [hl]
res 5, [hl]
bit BIT_CUR_MAP_LOADED_1, [hl]
res BIT_CUR_MAP_LOADED_1, [hl]
ret z
CheckEvent EVENT_MANSION_SWITCH_ON
jr nz, .switchTurnedOn
Expand Down Expand Up @@ -103,7 +103,7 @@ PokemonMansion1FSwitchText:
ld a, $1
ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, wCurrentMapScriptFlags
set 5, [hl]
set BIT_CUR_MAP_LOADED_1, [hl]
ld hl, .PressedText
call PrintText
ld a, SFX_GO_INSIDE
Expand Down
6 changes: 3 additions & 3 deletions scripts/PokemonMansion2F.asm
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ PokemonMansion2F_Script:

Mansion2CheckReplaceSwitchDoorBlocks:
ld hl, wCurrentMapScriptFlags
bit 5, [hl]
res 5, [hl]
bit BIT_CUR_MAP_LOADED_1, [hl]
res BIT_CUR_MAP_LOADED_1, [hl]
ret z
CheckEvent EVENT_MANSION_SWITCH_ON
jr nz, .switchTurnedOn
Expand Down Expand Up @@ -108,7 +108,7 @@ PokemonMansion2FSwitchText:
ld a, $1
ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, wCurrentMapScriptFlags
set 5, [hl]
set BIT_CUR_MAP_LOADED_1, [hl]
ld hl, .PressedText
call PrintText
ld a, SFX_GO_INSIDE
Expand Down
4 changes: 2 additions & 2 deletions scripts/PokemonMansion3F.asm
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ PokemonMansion3F_Script:

Mansion3CheckReplaceSwitchDoorBlocks:
ld hl, wCurrentMapScriptFlags
bit 5, [hl]
res 5, [hl]
bit BIT_CUR_MAP_LOADED_1, [hl]
res BIT_CUR_MAP_LOADED_1, [hl]
ret z
CheckEvent EVENT_MANSION_SWITCH_ON
jr nz, .switchTurnedOn
Expand Down
4 changes: 2 additions & 2 deletions scripts/PokemonMansionB1F.asm
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ PokemonMansionB1F_Script:

MansionB1FCheckReplaceSwitchDoorBlocks:
ld hl, wCurrentMapScriptFlags
bit 5, [hl]
res 5, [hl]
bit BIT_CUR_MAP_LOADED_1, [hl]
res BIT_CUR_MAP_LOADED_1, [hl]
ret z
CheckEvent EVENT_MANSION_SWITCH_ON
jr nz, .switchTurnedOn
Expand Down
4 changes: 2 additions & 2 deletions scripts/RocketHideoutB1F.asm
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ RocketHideoutB1F_Script:

RocketHideoutB1FDoorCallbackScript:
ld hl, wCurrentMapScriptFlags
bit 5, [hl]
res 5, [hl]
bit BIT_CUR_MAP_LOADED_1, [hl]
res BIT_CUR_MAP_LOADED_1, [hl]
ret z
CheckEvent EVENT_677
jr nz, .door_open
Expand Down
6 changes: 3 additions & 3 deletions scripts/RocketHideoutB4F.asm
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ RocketHideoutB4F_Script:

RocketHideoutB4FDoorCallbackScript:
ld hl, wCurrentMapScriptFlags
bit 5, [hl]
res 5, [hl]
bit BIT_CUR_MAP_LOADED_1, [hl]
res BIT_CUR_MAP_LOADED_1, [hl]
ret z
CheckEvent EVENT_ROCKET_HIDEOUT_4_DOOR_UNLOCKED
jr nz, .door_already_unlocked
Expand Down Expand Up @@ -67,7 +67,7 @@ RocketHideoutB4FBeatGiovanniScript:
xor a
ld [wJoyIgnore], a
ld hl, wCurrentMapScriptFlags
set 5, [hl]
set BIT_CUR_MAP_LOADED_1, [hl]
ld a, SCRIPT_ROCKETHIDEOUTB4F_DEFAULT
ld [wRocketHideoutB4FCurScript], a
ld [wCurMapScript], a
Expand Down
Loading