Skip to content

Commit

Permalink
Shift status flags
Browse files Browse the repository at this point in the history
  • Loading branch information
Rangi42 committed Jun 26, 2024
1 parent ef89e35 commit 0fe542b
Show file tree
Hide file tree
Showing 25 changed files with 50 additions and 52 deletions.
2 changes: 1 addition & 1 deletion constants/ram_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ DEF NUM_BADGES EQU const_value
const BIT_NO_TEXT_DELAY ; 6
const BIT_SCRIPTED_MOVEMENT_STATE ; 7

; wStatusFlags6
; wWarpFlags
const_def
const BIT_GAME_TIMER_COUNTING ; 0
const BIT_DEBUG_MODE ; 1
Expand Down
6 changes: 3 additions & 3 deletions engine/battle/core.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1157,9 +1157,9 @@ HandlePlayerBlackOut:
ld hl, LinkBattleLostText
.noLinkBattle
call PrintText
ld a, [wStatusFlags6]
ld a, [wWarpFlags]
res BIT_ALWAYS_ON_BIKE, a
ld [wStatusFlags6], a
ld [wWarpFlags], a
call ClearScreen
scf
ret
Expand Down Expand Up @@ -6776,7 +6776,7 @@ InitOpponent:
jr InitBattleCommon

DetermineWildOpponent:
ld a, [wStatusFlags6]
ld a, [wWarpFlags]
bit BIT_DEBUG_MODE, a
jr z, .notDebugMode
ldh a, [hJoyHeld]
Expand Down
2 changes: 1 addition & 1 deletion engine/debug/debug_menu.asm
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ IF DEF(_DEBUG)
jp z, TestBattle

; DEBUG
ld hl, wStatusFlags6
ld hl, wWarpFlags
set BIT_DEBUG_MODE, [hl]
jp StartNewGameDebug

Expand Down
2 changes: 1 addition & 1 deletion engine/events/black_out.asm
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ ResetStatusAndHalveMoneyOnBlackout::
ld [wPlayerMoney + 2], a

.lostmoney
ld hl, wStatusFlags6
ld hl, wWarpFlags
set BIT_FLY_OR_DUNGEON_WARP, [hl]
res BIT_FLY_WARP, [hl]
set BIT_ESCAPE_WARP, [hl]
Expand Down
2 changes: 1 addition & 1 deletion engine/items/item_effects.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,7 @@ ItemUseEscapeRope:
jr z, .notUsable
cp b
jr nz, .loop
ld hl, wStatusFlags6
ld hl, wWarpFlags
set BIT_FLY_WARP, [hl]
set BIT_ESCAPE_WARP, [hl]
ld hl, wStatusFlags4
Expand Down
4 changes: 2 additions & 2 deletions engine/items/town_map.asm
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,9 @@ LoadTownMap_Fly::
call PlaySound
ld a, [hl]
ld [wDestinationMap], a
ld hl, wStatusFlags6
ld hl, wWarpFlags
set BIT_FLY_WARP, [hl]
assert wStatusFlags6 + 1 == wStatusFlags7
assert wWarpFlags + 1 == wStatusFlags7
inc hl
set BIT_USED_FLY, [hl]
.pressedB
Expand Down
8 changes: 4 additions & 4 deletions engine/menus/main_menu.asm
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ MainMenu:
jp nz, SpecialEnterMap
xor a
ld [wDestinationMap], a
ld hl, wStatusFlags6
ld hl, wWarpFlags
set BIT_FLY_OR_DUNGEON_WARP, [hl]
call PrepareForSpecialWarp
jp SpecialEnterMap
Expand Down Expand Up @@ -272,7 +272,7 @@ LinkMenu:
call PrintText
ld c, 50
call DelayFrames
ld hl, wStatusFlags6
ld hl, wWarpFlags
res BIT_DEBUG_MODE, [hl]
ld a, [wDefaultMap]
ld [wDestinationMap], a
Expand Down Expand Up @@ -312,7 +312,7 @@ LinkCanceledText:
text_end

StartNewGame:
ld hl, wStatusFlags6
ld hl, wWarpFlags
; Ensure debug mode is not used when starting a regular new game.
; Debug mode persists in saved games for both debug and non-debug builds, and is
; only reset here by the main menu.
Expand All @@ -330,7 +330,7 @@ SpecialEnterMap::
ldh [hJoyHeld], a
ldh [hJoy5], a
ld [wCableClubDestinationMap], a
ld hl, wStatusFlags6
ld hl, wWarpFlags
set BIT_GAME_TIMER_COUNTING, [hl]
call ResetPlayerSpriteData
ld c, 20
Expand Down
6 changes: 3 additions & 3 deletions engine/menus/start_sub_menus.asm
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ StartMenu_Pokemon::
jp .loop
.canFly
call ChooseFlyDestination
ld a, [wStatusFlags6]
ld a, [wWarpFlags]
bit BIT_FLY_WARP, a
jp nz, .goBackToMap
call LoadFontTilePatterns
Expand Down Expand Up @@ -214,7 +214,7 @@ StartMenu_Pokemon::
.canTeleport
ld hl, .warpToLastPokemonCenterText
call PrintText
ld hl, wStatusFlags6
ld hl, wWarpFlags
set BIT_FLY_WARP, [hl]
set BIT_ESCAPE_WARP, [hl]
ld hl, wStatusFlags4
Expand Down Expand Up @@ -371,7 +371,7 @@ StartMenu_Item::
ld a, [wcf91]
cp BICYCLE
jr nz, .notBicycle2
ld a, [wStatusFlags6]
ld a, [wWarpFlags]
bit BIT_ALWAYS_ON_BIKE, a
jr z, .useItem_closeMenu
ld hl, CannotGetOffHereText
Expand Down
6 changes: 3 additions & 3 deletions engine/movie/oak_speech/oak_speech.asm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ PrepareOakSpeech:
; which causes CheckForceBikeOrSurf to not return.
; To fix this in debug builds, reset bit 5 here or in StartNewGame.
; In non-debug builds, the instructions can be removed.
ld a, [wStatusFlags6]
ld a, [wWarpFlags]
push af
ld hl, wPlayerName
ld bc, wBoxDataEnd - wPlayerName
Expand All @@ -19,7 +19,7 @@ PrepareOakSpeech:
xor a
call FillMemory
pop af
ld [wStatusFlags6], a
ld [wWarpFlags], a
pop af
ld [wOptions], a
pop af
Expand Down Expand Up @@ -61,7 +61,7 @@ OakSpeech:
call PrepareForSpecialWarp
xor a
ldh [hTileAnimations], a
ld a, [wStatusFlags6]
ld a, [wWarpFlags]
bit BIT_DEBUG_MODE, a
jp nz, .skipSpeech
ld de, ProfOakPic
Expand Down
8 changes: 5 additions & 3 deletions engine/movie/title.asm
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ PrepareTitleScreen::
xor a
ldh [hWY], a
ld [wLetterPrintingDelayFlags], a
ld hl, wStatusFlags6
ld hl, wWarpFlags
ld [hli], a
ld [hli], a ; wStatusFlags7
ld [hl], a ; wElite4Flags
assert wWarpFlags + 1 == wStatusFlags7
ld [hli], a
assert wStatusFlags7 + 1 == wElite4Flags
ld [hl], a
ld a, BANK(Music_TitleScreen)
ld [wAudioROMBank], a
ld [wAudioSavedROMBank], a
Expand Down
2 changes: 1 addition & 1 deletion engine/overworld/field_move_messages.asm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ IsSurfingAllowed:
; Seafoam Islands before the current has been slowed with boulders.
ld hl, wStatusFlags
set BIT_SURF_ALLOWED, [hl]
ld a, [wStatusFlags6]
ld a, [wWarpFlags]
bit BIT_ALWAYS_ON_BIKE, a
jr nz, .forcedToRideBike
ld a, [wCurMap]
Expand Down
2 changes: 1 addition & 1 deletion engine/overworld/hidden_objects.asm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ IsPlayerOnDungeonWarp::
ld [wWhichDungeonWarp], a
ld hl, wStatusFlags3
set BIT_ON_DUNGEON_WARP, [hl]
ld hl, wStatusFlags6
ld hl, wWarpFlags
set BIT_DUNGEON_WARP, [hl]
ret

Expand Down
4 changes: 2 additions & 2 deletions engine/overworld/player_animations.asm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ EnterMapAnim::
jr nz, .flyAnimation
ld a, SFX_TELEPORT_ENTER_1
call PlaySound
ld hl, wStatusFlags6
ld hl, wWarpFlags
bit BIT_DUNGEON_WARP, [hl]
res BIT_DUNGEON_WARP, [hl]
pop hl
Expand Down Expand Up @@ -122,7 +122,7 @@ _LeaveMapAnim::
.playerNotStandingOnWarpPadOrHole
ld a, $4
call StopMusic
ld a, [wStatusFlags6]
ld a, [wWarpFlags]
bit BIT_ESCAPE_WARP, a
jr z, .flyAnimation
; if going to the last used pokemon center
Expand Down
4 changes: 2 additions & 2 deletions engine/overworld/player_state.asm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ IsPlayerStandingOnWarp::
ret

CheckForceBikeOrSurf::
ld hl, wStatusFlags6
ld hl, wWarpFlags
bit BIT_ALWAYS_ON_BIKE, [hl]
ret nz
ld hl, ForcedBikeOrSurfMaps
Expand Down Expand Up @@ -64,7 +64,7 @@ CheckForceBikeOrSurf::
ld a, SCRIPT_SEAFOAMISLANDSB4F_MOVE_OBJECT
ld [wSeafoamIslandsB4FCurScript], a
jr z, .forceSurfing
ld hl, wStatusFlags6
ld hl, wWarpFlags
set BIT_ALWAYS_ON_BIKE, [hl]
ld a, $1
ld [wWalkBikeSurfState], a
Expand Down
8 changes: 4 additions & 4 deletions engine/overworld/special_warps.asm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PrepareForSpecialWarp::
call LoadSpecialWarpData
predef LoadTilesetHeader
ld hl, wStatusFlags6
ld hl, wWarpFlags
bit BIT_FLY_OR_DUNGEON_WARP, [hl]
res BIT_FLY_OR_DUNGEON_WARP, [hl]
jr z, .debugNewGameWarp
Expand All @@ -22,7 +22,7 @@ PrepareForSpecialWarp::
jr nz, .next2
ld a, b
.next2
ld hl, wStatusFlags6
ld hl, wWarpFlags
bit BIT_DUNGEON_WARP, [hl]
ret nz
ld [wLastMap], a
Expand All @@ -48,7 +48,7 @@ LoadSpecialWarpData:
ld hl, ColosseumFriendWarp
jr .copyWarpData
.notColosseum
ld a, [wStatusFlags6]
ld a, [wWarpFlags]
bit BIT_DEBUG_MODE, a
; warp to wLastMap (PALLET_TOWN) for StartNewGameDebug
jr nz, .notNewGameWarp
Expand All @@ -70,7 +70,7 @@ LoadSpecialWarpData:
jr .done
.notNewGameWarp
ld a, [wLastMap] ; this value is overwritten before it's ever read
ld hl, wStatusFlags6
ld hl, wWarpFlags
bit BIT_DUNGEON_WARP, [hl]
jr nz, .usedDungeonWarp
bit BIT_ESCAPE_WARP, [hl]
Expand Down
2 changes: 1 addition & 1 deletion engine/play_time.asm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
TrackPlayTime::
call CountDownIgnoreInputBitReset
ld a, [wStatusFlags6]
ld a, [wWarpFlags]
bit BIT_GAME_TIMER_COUNTING, a
ret z
ld a, [wPlayTimeMaxed]
Expand Down
2 changes: 1 addition & 1 deletion home/npc_movement.asm
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ DebugPressedOrHeldB:: ; dummy except in _DEBUG
; This is used to skip Trainer battles, the
; Safari Game step counter, and some NPC scripts.
IF DEF(_DEBUG)
ld a, [wStatusFlags6]
ld a, [wWarpFlags]
bit BIT_DEBUG_MODE, a
ret z
ldh a, [hJoyHeld]
Expand Down
10 changes: 5 additions & 5 deletions home/overworld.asm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ EnterMap::
res BIT_BATTLE_OVER_OR_BLACKOUT, [hl]
call z, ResetUsingStrengthOutOfBattleBit
call nz, MapEntryAfterBattle
ld hl, wStatusFlags6
ld hl, wWarpFlags
ld a, [hl]
and (1 << BIT_FLY_WARP) | (1 << BIT_DUNGEON_WARP)
jr z, .didNotEnterUsingFlyWarpOrDungeonWarp
Expand Down Expand Up @@ -58,7 +58,7 @@ OverworldLoopLessDelay::
bit BIT_WARP_FROM_CUR_SCRIPT, [hl]
res BIT_WARP_FROM_CUR_SCRIPT, [hl]
jp nz, WarpFound2
ld a, [wStatusFlags6]
ld a, [wWarpFlags]
and (1 << BIT_FLY_WARP) | (1 << BIT_DUNGEON_WARP)
jp nz, HandleFlyWarpOrDungeonWarp
ld a, [wCurOpponent]
Expand Down Expand Up @@ -516,7 +516,7 @@ WarpFound2::
dec a ; is the player on a warp pad?
jr nz, .notWarpPad
; if the player is on a warp pad
ld hl, wStatusFlags6
ld hl, wWarpFlags
set BIT_FLY_WARP, [hl]
call LeaveMapAnim
jr .skipMapChangeSound
Expand Down Expand Up @@ -788,7 +788,7 @@ HandleFlyWarpOrDungeonWarp::
ld [wWalkBikeSurfState], a
ld [wIsInBattle], a
ld [wMapPalOffset], a
ld hl, wStatusFlags6
ld hl, wWarpFlags
set BIT_FLY_OR_DUNGEON_WARP, [hl]
res BIT_ALWAYS_ON_BIKE, [hl]
call LeaveMapAnim
Expand Down Expand Up @@ -2342,7 +2342,7 @@ LoadMapData::
ld b, SET_PAL_OVERWORLD
call RunPaletteCommand
call LoadPlayerSpriteGraphics
ld a, [wStatusFlags6]
ld a, [wWarpFlags]
and (1 << BIT_FLY_WARP) | (1 << BIT_DUNGEON_WARP)
jr nz, .restoreRomBank
ld a, [wStatusFlags7]
Expand Down
6 changes: 3 additions & 3 deletions home/text_script.asm
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ CloseTextDisplay::
call InitMapSprites ; reload sprite tile pattern data (since it was partially overwritten by text tile patterns)
ld hl, wFontLoaded
res 0, [hl]
ld a, [wStatusFlags6]
ld a, [wWarpFlags]
bit BIT_FLY_WARP, a
call z, LoadPlayerSpriteGraphics
call LoadCurrentMapView
Expand Down Expand Up @@ -196,9 +196,9 @@ PokemonFaintedText::
DisplayPlayerBlackedOutText::
ld hl, PlayerBlackedOutText
call PrintText
ld a, [wStatusFlags6]
ld a, [wWarpFlags]
res BIT_ALWAYS_ON_BIKE, a
ld [wStatusFlags6], a
ld [wWarpFlags], a
jp HoldTextDisplayOpen

PlayerBlackedOutText::
Expand Down
6 changes: 1 addition & 5 deletions ram/wram.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2063,14 +2063,10 @@ wStatusFlags2:: db
wCableClubDestinationMap::
wStatusFlags3:: db
wStatusFlags4:: db

ds 1

wStateFlags:: db

ds 1

wStatusFlags6:: db
wWarpFlags:: db
wStatusFlags7:: db
wElite4Flags:: db
ds 1
Expand Down
2 changes: 1 addition & 1 deletion scripts/PokemonMansion3F.asm
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ PokemonMansion3FDefaultScript:
ld [wWhichDungeonWarp], a
ld hl, wStatusFlags3
set BIT_ON_DUNGEON_WARP, [hl]
ld hl, wStatusFlags6
ld hl, wWarpFlags
set BIT_DUNGEON_WARP, [hl]
ret

Expand Down
2 changes: 1 addition & 1 deletion scripts/Route16Gate1F.asm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Route16Gate1F_Script:
ld hl, wStatusFlags6
ld hl, wWarpFlags
res BIT_ALWAYS_ON_BIKE, [hl]
call EnableAutoTextBoxDrawing
ld a, [wRoute16Gate1FCurScript]
Expand Down
2 changes: 1 addition & 1 deletion scripts/Route18Gate1F.asm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Route18Gate1F_Script:
ld hl, wStatusFlags6
ld hl, wWarpFlags
res BIT_ALWAYS_ON_BIKE, [hl]
call EnableAutoTextBoxDrawing
ld a, [wRoute18Gate1FCurScript]
Expand Down
2 changes: 1 addition & 1 deletion scripts/SeafoamIslandsB3F.asm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ SeafoamIslandsB3F_Script:
ld [wDungeonWarpDestinationMap], a
ld hl, Seafoam4HolesCoords
call IsPlayerOnDungeonWarp
ld a, [wStatusFlags6]
ld a, [wWarpFlags]
bit BIT_DUNGEON_WARP, a
ret nz
.runCurrentMapScript
Expand Down
Loading

0 comments on commit 0fe542b

Please sign in to comment.