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 28, 2024
1 parent ef89e35 commit 4c59cfe
Show file tree
Hide file tree
Showing 30 changed files with 71 additions and 73 deletions.
4 changes: 2 additions & 2 deletions 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
; wStatusFlags5
const_def
const BIT_GAME_TIMER_COUNTING ; 0
const BIT_DEBUG_MODE ; 1
Expand All @@ -94,7 +94,7 @@ DEF NUM_BADGES EQU const_value
const BIT_ALWAYS_ON_BIKE ; 5
const BIT_ESCAPE_WARP ; 6

; wStatusFlags7
; wStatusFlags6
const_def
const BIT_TEST_BATTLE ; 0
const BIT_NO_MAP_MUSIC ; 1
Expand Down
14 changes: 7 additions & 7 deletions engine/battle/core.asm
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ TrainerBattleVictory:
cp RIVAL3 ; final battle against rival
jr nz, .notrival
ld b, MUSIC_DEFEATED_GYM_LEADER
ld hl, wStatusFlags7
ld hl, wStatusFlags6
set BIT_NO_MAP_MUSIC, [hl]
.notrival
ld a, [wLinkState]
Expand Down Expand Up @@ -1157,9 +1157,9 @@ HandlePlayerBlackOut:
ld hl, LinkBattleLostText
.noLinkBattle
call PrintText
ld a, [wStatusFlags6]
ld a, [wStatusFlags5]
res BIT_ALWAYS_ON_BIKE, a
ld [wStatusFlags6], a
ld [wStatusFlags5], a
call ClearScreen
scf
ret
Expand Down Expand Up @@ -2558,7 +2558,7 @@ MoveSelectionMenu:
cp LINK_STATE_BATTLING
jr z, .matchedkeyspicked
; Disable left, right, and START buttons in regular battles.
ld a, [wStatusFlags7]
ld a, [wStatusFlags6]
bit BIT_TEST_BATTLE, a
ld b, D_UP | D_DOWN | A_BUTTON | B_BUTTON | SELECT
jr z, .matchedkeyspicked
Expand Down Expand Up @@ -2587,7 +2587,7 @@ SelectMenuItem:
jr .select
.battleselect
; Hide move swap cursor in TestBattle.
ld a, [wStatusFlags7]
ld a, [wStatusFlags6]
bit BIT_TEST_BATTLE, a
; This causes PrintMenuItem to not run in TestBattle.
; MoveSelectionMenu still draws part of its window, an issue
Expand Down Expand Up @@ -6092,7 +6092,7 @@ GetCurrentMove:
.player
ld de, wPlayerMoveNum
; Apply InitBattleVariables to TestBattle.
ld a, [wStatusFlags7]
ld a, [wStatusFlags6]
bit BIT_TEST_BATTLE, a
ld a, [wTestBattlePlayerSelectedMove]
jr nz, .selected
Expand Down Expand Up @@ -6776,7 +6776,7 @@ InitOpponent:
jr InitBattleCommon

DetermineWildOpponent:
ld a, [wStatusFlags6]
ld a, [wStatusFlags5]
bit BIT_DEBUG_MODE, a
jr z, .notDebugMode
ldh a, [hJoyHeld]
Expand Down
4 changes: 2 additions & 2 deletions 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, wStatusFlags5
set BIT_DEBUG_MODE, [hl]
jp StartNewGameDebug

Expand All @@ -80,7 +80,7 @@ TestBattle: ; unreferenced except in _DEBUG
ld a, 1 << BIT_EARTHBADGE
ld [wObtainedBadges], a

ld hl, wStatusFlags7
ld hl, wStatusFlags6
set BIT_TEST_BATTLE, [hl]

; wNumBagItems and wBagItems are not initialized here,
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, wStatusFlags5
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, wStatusFlags5
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, wStatusFlags5
set BIT_FLY_WARP, [hl]
assert wStatusFlags6 + 1 == wStatusFlags7
assert wStatusFlags5 + 1 == wStatusFlags6
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, wStatusFlags5
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, wStatusFlags5
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, wStatusFlags5
; 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, wStatusFlags5
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, [wStatusFlags5]
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, wStatusFlags5
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, [wStatusFlags5]
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, [wStatusFlags5]
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 [wStatusFlags5], 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, [wStatusFlags5]
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, wStatusFlags5
ld [hli], a
ld [hli], a ; wStatusFlags7
ld [hl], a ; wElite4Flags
assert wStatusFlags5 + 1 == wStatusFlags6
ld [hli], a
assert wStatusFlags6 + 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/auto_movement.asm
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ PalletMovementScript_OakMoveLeft:
ld a, $3
ld [wNPCMovementScriptFunctionNum], a
.done
ld hl, wStatusFlags7
ld hl, wStatusFlags6
set BIT_NO_MAP_MUSIC, [hl]
ld a, SELECT | START | D_RIGHT | D_LEFT | D_UP | D_DOWN
ld [wJoyIgnore], 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, [wStatusFlags5]
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, wStatusFlags5
set BIT_DUNGEON_WARP, [hl]
ret

Expand Down
6 changes: 3 additions & 3 deletions engine/overworld/player_animations.asm
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ EnterMapAnim::
call Delay3
push hl
call GBFadeInFromWhite
ld hl, wStatusFlags7
ld hl, wStatusFlags6
bit BIT_USED_FLY, [hl]
res BIT_USED_FLY, [hl]
jr nz, .flyAnimation
ld a, SFX_TELEPORT_ENTER_1
call PlaySound
ld hl, wStatusFlags6
ld hl, wStatusFlags5
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, [wStatusFlags5]
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, wStatusFlags5
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, wStatusFlags5
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, wStatusFlags5
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, wStatusFlags5
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, [wStatusFlags5]
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, wStatusFlags5
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, [wStatusFlags5]
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, [wStatusFlags5]
bit BIT_DEBUG_MODE, a
ret z
ldh a, [hJoyHeld]
Expand Down
Loading

0 comments on commit 4c59cfe

Please sign in to comment.