diff options
| author | dannye <33dannye@gmail.com> | 2024-09-25 00:45:00 -0500 |
|---|---|---|
| committer | dannye <33dannye@gmail.com> | 2024-09-25 00:45:00 -0500 |
| commit | a02a98ee7ada1a658e28698484058be2796dc0df (patch) | |
| tree | 945986054565bd8b5212fc755415096050d1d3a8 /engine/overworld | |
| parent | Use long option flags for rgbgfx, same as tools/gfx (diff) | |
| parent | Use `const_skip` (diff) | |
| download | pokeyellow-a02a98ee7ada1a658e28698484058be2796dc0df.tar.gz pokeyellow-a02a98ee7ada1a658e28698484058be2796dc0df.tar.xz pokeyellow-a02a98ee7ada1a658e28698484058be2796dc0df.zip | |
Merge branch 'master' of https://github.com/pret/pokered
Diffstat (limited to 'engine/overworld')
| -rw-r--r-- | engine/overworld/auto_movement.asm | 80 | ||||
| -rw-r--r-- | engine/overworld/clear_variables.asm | 2 | ||||
| -rw-r--r-- | engine/overworld/cut.asm | 8 | ||||
| -rw-r--r-- | engine/overworld/dungeon_warps.asm | 12 | ||||
| -rw-r--r-- | engine/overworld/emotion_bubbles.asm | 4 | ||||
| -rw-r--r-- | engine/overworld/field_move_messages.asm | 26 | ||||
| -rw-r--r-- | engine/overworld/ledges.asm | 8 | ||||
| -rw-r--r-- | engine/overworld/map_sprites.asm | 6 | ||||
| -rw-r--r-- | engine/overworld/movement.asm | 36 | ||||
| -rw-r--r-- | engine/overworld/pathfinding.asm | 26 | ||||
| -rw-r--r-- | engine/overworld/player_animations.asm | 30 | ||||
| -rw-r--r-- | engine/overworld/player_state.asm | 47 | ||||
| -rw-r--r-- | engine/overworld/push_boulder.asm | 46 | ||||
| -rw-r--r-- | engine/overworld/special_warps.asm | 32 | ||||
| -rw-r--r-- | engine/overworld/specific_script_flags.asm | 4 | ||||
| -rw-r--r-- | engine/overworld/spinners.asm | 2 | ||||
| -rw-r--r-- | engine/overworld/trainer_sight.asm | 4 |
17 files changed, 190 insertions, 183 deletions
diff --git a/engine/overworld/auto_movement.asm b/engine/overworld/auto_movement.asm index 39c1f380..8174b273 100644 --- a/engine/overworld/auto_movement.asm +++ b/engine/overworld/auto_movement.asm @@ -1,12 +1,12 @@ PlayerStepOutFromDoor:: - ld hl, wd730 - res 1, [hl] + ld hl, wStatusFlags5 ; should this be wMovementFlags? + res BIT_EXITING_DOOR, [hl] call IsPlayerStandingOnDoorTile jr nc, .notStandingOnDoor ld a, SELECT | START | D_RIGHT | D_LEFT | D_UP | D_DOWN ld [wJoyIgnore], a - ld hl, wd736 - set 1, [hl] + ld hl, wMovementFlags + set BIT_EXITING_DOOR, [hl] ld a, $1 ld [wSimulatedJoypadStatesIndex], a ld a, D_DOWN @@ -17,29 +17,29 @@ PlayerStepOutFromDoor:: ret .notStandingOnDoor xor a - ld [wUnusedCD3A], a + ld [wUnusedOverrideSimulatedJoypadStatesIndex], a ld [wSimulatedJoypadStatesIndex], a ld [wSimulatedJoypadStatesEnd], a - ld hl, wd736 - res 0, [hl] - res 1, [hl] - ld hl, wd730 - res 7, [hl] + ld hl, wMovementFlags + res BIT_STANDING_ON_DOOR, [hl] + res BIT_EXITING_DOOR, [hl] + ld hl, wStatusFlags5 + res BIT_SCRIPTED_MOVEMENT_STATE, [hl] ret _EndNPCMovementScript:: - ld hl, wd730 - res 7, [hl] - ld hl, wd72e - res 7, [hl] - ld hl, wd736 - res 0, [hl] - res 1, [hl] + ld hl, wStatusFlags5 + res BIT_SCRIPTED_MOVEMENT_STATE, [hl] + ld hl, wStatusFlags4 + res BIT_INIT_SCRIPTED_MOVEMENT, [hl] + ld hl, wMovementFlags + res BIT_STANDING_ON_DOOR, [hl] + res BIT_EXITING_DOOR, [hl] xor a ld [wNPCMovementScriptSpriteOffset], a ld [wNPCMovementScriptFunctionNum], a ld [wNPCMovementScriptPointerTableNum], a - ld [wUnusedCD3A], a + ld [wUnusedOverrideSimulatedJoypadStatesIndex], a ld [wSimulatedJoypadStatesIndex], a ld [wSimulatedJoypadStatesEnd], a ret @@ -83,15 +83,15 @@ PalletMovementScript_OakMoveLeft: ld c, a ld a, MUSIC_MUSEUM_GUY call PlayMusic - ld hl, wFlags_D733 - set 1, [hl] + ld hl, wStatusFlags7 + set BIT_NO_MAP_MUSIC, [hl] ld a, SELECT | START | D_RIGHT | D_LEFT | D_UP | D_DOWN ld [wJoyIgnore], a ret PalletMovementScript_PlayerMoveLeft: - ld a, [wd730] - bit 0, a ; is an NPC being moved by a script? + ld a, [wStatusFlags5] + bit BIT_SCRIPTED_NPC_MOVEMENT, a ret nz ; return if Oak is still moving ld a, [wNumStepsToTake] ld [wSimulatedJoypadStatesIndex], a @@ -123,10 +123,10 @@ PalletMovementScript_WalkToLab: ld hl, wNPCMovementDirections2 ld de, RLEList_ProfOakWalkToLab call DecodeRLEList - ld hl, wd72e - res 7, [hl] - ld hl, wd730 - set 7, [hl] + ld hl, wStatusFlags4 + res BIT_INIT_SCRIPTED_MOVEMENT, [hl] + ld hl, wStatusFlags5 + set BIT_SCRIPTED_MOVEMENT_STATE, [hl] ld a, $4 ld [wNPCMovementScriptFunctionNum], a ret @@ -156,10 +156,10 @@ PalletMovementScript_Done: ld a, HS_PALLET_TOWN_OAK ld [wMissableObjectIndex], a predef HideObject - ld hl, wd730 - res 7, [hl] - ld hl, wd72e - res 7, [hl] + ld hl, wStatusFlags5 + res BIT_SCRIPTED_MOVEMENT_STATE, [hl] + ld hl, wStatusFlags4 + res BIT_INIT_SCRIPTED_MOVEMENT, [hl] jp EndNPCMovementScript PewterMuseumGuyMovementScriptPointerTable:: @@ -186,8 +186,8 @@ PewterMovementScript_WalkToMuseum: ld hl, wNPCMovementDirections2 ld de, RLEList_PewterMuseumGuy call DecodeRLEList - ld hl, wd72e - res 7, [hl] + ld hl, wStatusFlags4 + res BIT_INIT_SCRIPTED_MOVEMENT, [hl] ld a, $1 ld [wNPCMovementScriptFunctionNum], a ret @@ -210,10 +210,10 @@ PewterMovementScript_Done: ld a, [wSimulatedJoypadStatesIndex] and a ret nz - ld hl, wd730 - res 7, [hl] - ld hl, wd72e - res 7, [hl] + ld hl, wStatusFlags5 + res BIT_SCRIPTED_MOVEMENT_STATE, [hl] + ld hl, wStatusFlags4 + res BIT_INIT_SCRIPTED_MOVEMENT, [hl] jp EndNPCMovementScript PewterGymGuyMovementScriptPointerTable:: @@ -241,10 +241,10 @@ PewterMovementScript_WalkToGym: ld hl, wNPCMovementDirections2 ld de, RLEList_PewterGymGuy call DecodeRLEList - ld hl, wd72e - res 7, [hl] - ld hl, wd730 - set 7, [hl] + ld hl, wStatusFlags4 + res BIT_INIT_SCRIPTED_MOVEMENT, [hl] + ld hl, wStatusFlags5 + set BIT_SCRIPTED_MOVEMENT_STATE, [hl] ld a, $1 ld [wNPCMovementScriptFunctionNum], a ret diff --git a/engine/overworld/clear_variables.asm b/engine/overworld/clear_variables.asm index bbb7c986..6bd44963 100644 --- a/engine/overworld/clear_variables.asm +++ b/engine/overworld/clear_variables.asm @@ -10,7 +10,7 @@ ClearVariablesOnEnterMap:: ldh [hJoyReleased], a ldh [hJoyHeld], a ld [wActionResultOrTookBattleTurn], a - ld [wUnusedD5A3], a + ld [wUnusedMapVariable], a ld hl, wCardKeyDoorY ld [hli], a ld [hl], a diff --git a/engine/overworld/cut.asm b/engine/overworld/cut.asm index 1373f5dd..8cc76104 100644 --- a/engine/overworld/cut.asm +++ b/engine/overworld/cut.asm @@ -32,8 +32,8 @@ UsedCut: ld a, [wWhichPokemon] ld hl, wPartyMonNicks call GetPartyMonName - ld hl, wd730 - set 6, [hl] + ld hl, wStatusFlags5 + set BIT_NO_TEXT_DELAY, [hl] call GBPalWhiteOutWithDelay3 call ClearSprites call RestoreScreenTilesAndReloadTilePatterns @@ -49,8 +49,8 @@ UsedCut: ld hl, UsedCutText call PrintText call LoadScreenTilesFromBuffer2 - ld hl, wd730 - res 6, [hl] + ld hl, wStatusFlags5 + res BIT_NO_TEXT_DELAY, [hl] ld a, $ff ld [wUpdateSpritesEnabled], a call InitCutAnimOAM diff --git a/engine/overworld/dungeon_warps.asm b/engine/overworld/dungeon_warps.asm index 7641c688..943c379d 100644 --- a/engine/overworld/dungeon_warps.asm +++ b/engine/overworld/dungeon_warps.asm @@ -1,15 +1,15 @@ IsPlayerOnDungeonWarp:: xor a ld [wWhichDungeonWarp], a - ld a, [wd72d] - bit 4, a + ld a, [wStatusFlags3] + bit BIT_ON_DUNGEON_WARP, a ret nz call ArePlayerCoordsInArray ret nc ld a, [wCoordIndex] ld [wWhichDungeonWarp], a - ld hl, wd72d - set 4, [hl] - ld hl, wd732 - set 4, [hl] + ld hl, wStatusFlags3 + set BIT_ON_DUNGEON_WARP, [hl] + ld hl, wStatusFlags6 + set BIT_DUNGEON_WARP, [hl] ret diff --git a/engine/overworld/emotion_bubbles.asm b/engine/overworld/emotion_bubbles.asm index 006bded3..61bbc4f5 100644 --- a/engine/overworld/emotion_bubbles.asm +++ b/engine/overworld/emotion_bubbles.asm @@ -18,8 +18,8 @@ EmotionBubble: push af ld a, $ff ld [wUpdateSpritesEnabled], a - ld a, [wd736] - bit 6, a ; are the last 4 OAM entries reserved for a shadow or fishing rod? + ld a, [wMovementFlags] + bit BIT_LEDGE_OR_FISHING, a ; are the last 4 OAM entries reserved for a shadow or fishing rod? ld hl, wShadowOAMSprite35Attributes ld de, wShadowOAMSprite39Attributes jr z, .next diff --git a/engine/overworld/field_move_messages.asm b/engine/overworld/field_move_messages.asm index d75ffc21..dadfb753 100644 --- a/engine/overworld/field_move_messages.asm +++ b/engine/overworld/field_move_messages.asm @@ -1,6 +1,6 @@ -PrintStrengthTxt: - ld hl, wd728 - set 0, [hl] +PrintStrengthText: + ld hl, wStatusFlags1 + set BIT_STRENGTH_ACTIVE, [hl] ld hl, UsedStrengthText call PrintText ld hl, CanMoveBouldersText @@ -9,7 +9,7 @@ PrintStrengthTxt: UsedStrengthText: text_far _UsedStrengthText text_asm - ld a, [wcf91] + ld a, [wCurPartySpecies] call PlayCry call Delay3 jp TextScriptEnd @@ -19,13 +19,13 @@ CanMoveBouldersText: text_end IsSurfingAllowed: -; Returns whether surfing is allowed in bit 1 of wd728. +; Returns whether surfing is allowed in BIT_SURF_ALLOWED of wStatusFlags1. ; Surfing isn't allowed on the Cycling Road or in the lowest level of the ; Seafoam Islands before the current has been slowed with boulders. - ld hl, wd728 - set 1, [hl] - ld a, [wd732] - bit 5, a + ld hl, wStatusFlags1 + set BIT_SURF_ALLOWED, [hl] + ld a, [wStatusFlags6] + bit BIT_ALWAYS_ON_BIKE, a jr nz, .forcedToRideBike ld a, [wCurMap] cp SEAFOAM_ISLANDS_B4F @@ -35,13 +35,13 @@ IsSurfingAllowed: ld hl, SeafoamIslandsB4FStairsCoords call ArePlayerCoordsInArray ret nc - ld hl, wd728 - res 1, [hl] + ld hl, wStatusFlags1 + res BIT_SURF_ALLOWED, [hl] ld hl, CurrentTooFastText jp PrintText .forcedToRideBike - ld hl, wd728 - res 1, [hl] + ld hl, wStatusFlags1 + res BIT_SURF_ALLOWED, [hl] ld hl, CyclingIsFunText jp PrintText diff --git a/engine/overworld/ledges.asm b/engine/overworld/ledges.asm index 96441838..c08d9eaf 100644 --- a/engine/overworld/ledges.asm +++ b/engine/overworld/ledges.asm @@ -1,6 +1,6 @@ HandleLedges:: - ld a, [wd736] - bit 6, a ; already jumping down ledge + ld a, [wMovementFlags] + bit BIT_LEDGE_OR_FISHING, a ret nz ld a, [wCurMapTileset] and a ; OVERWORLD @@ -41,8 +41,8 @@ HandleLedges:: ret z ld a, A_BUTTON | B_BUTTON | SELECT | START | D_RIGHT | D_LEFT | D_UP | D_DOWN ld [wJoyIgnore], a - ld hl, wd736 - set 6, [hl] ; jumping down ledge + ld hl, wMovementFlags + set BIT_LEDGE_OR_FISHING, [hl] call StartSimulatingJoypadStates ld a, e ld [wSimulatedJoypadStatesEnd], a diff --git a/engine/overworld/map_sprites.asm b/engine/overworld/map_sprites.asm index d1bc7832..5d25b6d0 100644 --- a/engine/overworld/map_sprites.asm +++ b/engine/overworld/map_sprites.asm @@ -27,7 +27,7 @@ InitOutsideMapSprites: ; if so, choose the appropriate one ld b, a ; b = spriteSetID ld a, [wFontLoaded] - bit 0, a ; reloading upper half of tile patterns after displaying text? + bit BIT_FONT_LOADED, a ; reloading upper half of tile patterns after displaying text? jr nz, .loadSpriteSet ; if so, forcibly reload the sprite set ld a, [wSpriteSetID] cp b ; has the sprite set ID changed? @@ -170,7 +170,7 @@ ReloadWalkingTilePatterns: LoadStillTilePattern: ld a, [wFontLoaded] - bit 0, a ; reloading upper half of tile patterns after displaying text? + bit BIT_FONT_LOADED, a ; reloading upper half of tile patterns after displaying text? ret nz ; if so, skip loading data into the lower half call ReadSpriteSheetData ret nc @@ -186,7 +186,7 @@ LoadWalkingTilePattern: ld d, h ld e, l call GetSpriteVRAMAddress - set 3, h ; add $80 tiles to hl + set 3, h ; add $800 ($80 tiles) to hl (1 << 3 == $8) call CopyVideoDataAlternate ret diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm index 48a6f3aa..c05837eb 100644 --- a/engine/overworld/movement.asm +++ b/engine/overworld/movement.asm @@ -57,7 +57,7 @@ UpdatePlayerSprite: .next ld [wSpritePlayerStateData1FacingDirection], a ; facing direction ld a, [wFontLoaded] - bit 0, a + bit BIT_FONT_LOADED, a jr z, .moving .notMoving ; zero the animation counters @@ -67,8 +67,8 @@ UpdatePlayerSprite: call Func_4e32 jr .skipSpriteAnim .moving - ld a, [wd736] - bit 7, a ; is the player sprite spinning due to a spin tile? + ld a, [wMovementFlags] + bit BIT_SPINNING, a jr nz, .skipSpriteAnim call Func_5274 call Func_4e32 @@ -120,11 +120,11 @@ UpdateNPCSprite: ld l, a inc l ld a, [hl] ; x#SPRITESTATEDATA1_MOVEMENTSTATUS - bit 7, a ; is the face player flag set? + bit BIT_FACE_PLAYER, a jp nz, MakeNPCFacePlayer ld b, a ld a, [wFontLoaded] - bit 0, a + bit BIT_FONT_LOADED, a jp nz, notYetMoving ld a, b cp $2 @@ -162,11 +162,11 @@ UpdateNPCSprite: jr nz, .next ; reached end of wNPCMovementDirections list ld [hl], a ; store $ff in movement byte 1, disabling scripted movement - ld hl, wd730 - res 0, [hl] + ld hl, wStatusFlags5 + res BIT_SCRIPTED_NPC_MOVEMENT, [hl] xor a ld [wSimulatedJoypadStatesIndex], a - ld [wUnusedCD3A], a + ld [wUnusedOverrideSimulatedJoypadStatesIndex], a ret .next cp WALK @@ -367,10 +367,10 @@ MakeNPCFacePlayer: ; Check if the behaviour of the NPC facing the player when spoken to is ; disabled. This is only done when rubbing the S.S. Anne captain's back. - ld a, [wd72d] - bit 5, a + ld a, [wStatusFlags3] + bit BIT_NO_NPC_FACE_PLAYER, a jr nz, notYetMoving - res 7, [hl] + res BIT_FACE_PLAYER, [hl] ld a, [wPlayerDirection] bit PLAYER_DIR_BIT_UP, a jr z, .notFacingDown @@ -610,7 +610,7 @@ CanWalkOntoTile: add SPRITESTATEDATA2_YDISPLACEMENT ld l, a ld a, [hli] ; x#SPRITESTATEDATA2_YDISPLACEMENT (initialized at $8, keep track of where a sprite did go) - bit 7, d ; check if going upwards (d=$ff) + bit 7, d ; check if going upwards (d == -1) jr nz, .upwards add d ; bug: these tests against $5 probably were supposed to prevent @@ -628,7 +628,7 @@ CanWalkOntoTile: .checkHorizontal ld d, a ld a, [hl] ; x#SPRITESTATEDATA2_XDISPLACEMENT (initialized at $8, keep track of where a sprite did go) - bit 7, e ; check if going left (e=$ff) + bit 7, e ; check if going left (e == -1) jr nz, .left add e cp $5 ; compare, but no conditional jump like in the vertical check above (bug?) @@ -710,12 +710,12 @@ DoScriptedNPCMovement: ; a few times in the game. It is used when the NPC and player must walk together ; in sync, such as when the player is following the NPC somewhere. An NPC can't ; be moved in sync with the player using the other method. - ld a, [wd730] - bit 7, a + ld a, [wStatusFlags5] + bit BIT_SCRIPTED_MOVEMENT_STATE, a ret z - ld hl, wd72e - bit 7, [hl] - set 7, [hl] + ld hl, wStatusFlags4 + bit BIT_INIT_SCRIPTED_MOVEMENT, [hl] + set BIT_INIT_SCRIPTED_MOVEMENT, [hl] jp z, InitScriptedNPCMovement ld hl, wNPCMovementDirections2 ld a, [wNPCMovementDirections2Index] diff --git a/engine/overworld/pathfinding.asm b/engine/overworld/pathfinding.asm index d067345e..58fa1da9 100644 --- a/engine/overworld/pathfinding.asm +++ b/engine/overworld/pathfinding.asm @@ -16,7 +16,7 @@ FindPathToPlayer: and a jr nz, .stillHasYProgress ldh a, [hFindPathFlags] - set 0, a ; current end of path matches the player's Y coordinate + set BIT_PATH_FOUND_Y, a ldh [hFindPathFlags], a .stillHasYProgress ldh a, [hFindPathXProgress] @@ -27,11 +27,11 @@ FindPathToPlayer: and a jr nz, .stillHasXProgress ldh a, [hFindPathFlags] - set 1, a ; current end of path matches the player's X coordinate + set BIT_PATH_FOUND_X, a ldh [hFindPathFlags], a .stillHasXProgress ldh a, [hFindPathFlags] - cp $3 ; has the end of the path reached the player's position? + cp (1 << BIT_PATH_FOUND_X) | (1 << BIT_PATH_FOUND_Y) jr z, .done ; Compare whether the X distance between the player and the current of the path ; is greater or if the Y distance is. Then, try to reduce whichever is greater. @@ -40,7 +40,7 @@ FindPathToPlayer: jr c, .yDistanceGreater ; x distance is greater ldh a, [hNPCPlayerRelativePosFlags] - bit 1, a + bit BIT_PLAYER_LOWER_X, a jr nz, .playerIsLeftOfNPC ld d, NPC_MOVEMENT_RIGHT jr .next1 @@ -53,7 +53,7 @@ FindPathToPlayer: jr .storeDirection .yDistanceGreater ldh a, [hNPCPlayerRelativePosFlags] - bit 0, a + bit BIT_PLAYER_LOWER_Y, a jr nz, .playerIsAboveNPC ld d, NPC_MOVEMENT_DOWN jr .next2 @@ -97,15 +97,15 @@ CalcPositionOfPlayerRelativeToNPC: .NPCNorthOfPlayer push hl ld hl, hNPCPlayerRelativePosFlags - bit 0, [hl] - set 0, [hl] + bit BIT_PLAYER_LOWER_Y, [hl] + set BIT_PLAYER_LOWER_Y, [hl] pop hl jr .divideYDistance .NPCSouthOfOrAlignedWithPlayer push hl ld hl, hNPCPlayerRelativePosFlags - bit 0, [hl] - res 0, [hl] + bit BIT_PLAYER_LOWER_Y, [hl] + res BIT_PLAYER_LOWER_Y, [hl] pop hl .divideYDistance push hl @@ -125,15 +125,15 @@ CalcPositionOfPlayerRelativeToNPC: .NPCWestOfPlayer push hl ld hl, hNPCPlayerRelativePosFlags - bit 1, [hl] - set 1, [hl] + bit BIT_PLAYER_LOWER_X, [hl] + set BIT_PLAYER_LOWER_X, [hl] pop hl jr .divideXDistance .NPCEastOfOrAlignedWithPlayer push hl ld hl, hNPCPlayerRelativePosFlags - bit 1, [hl] - res 1, [hl] + bit BIT_PLAYER_LOWER_X, [hl] + res BIT_PLAYER_LOWER_X, [hl] pop hl .divideXDistance ldh [hDividend2], a diff --git a/engine/overworld/player_animations.asm b/engine/overworld/player_animations.asm index 6f8a5c18..aed6954c 100644 --- a/engine/overworld/player_animations.asm +++ b/engine/overworld/player_animations.asm @@ -5,14 +5,14 @@ EnterMapAnim:: call Delay3 push hl call GBFadeInFromWhite - ld hl, wFlags_D733 - bit 7, [hl] ; used fly out of battle? - res 7, [hl] + ld hl, wStatusFlags7 + bit BIT_USED_FLY, [hl] + res BIT_USED_FLY, [hl] jr nz, .flyAnimation ld a, SFX_TELEPORT_ENTER_1 call PlaySound - ld hl, wd732 - bit 4, [hl] ; used dungeon warp? + ld hl, wStatusFlags6 + bit BIT_DUNGEON_WARP, [hl] pop hl jr nz, .dungeonWarpAnimation call PlayerSpinWhileMovingDown @@ -126,8 +126,8 @@ _LeaveMapAnim:: .playerNotStandingOnWarpPadOrHole ld a, $4 call StopMusic - ld a, [wd732] - bit 6, a ; is the last used pokemon center the destination? + ld a, [wStatusFlags6] + bit BIT_ESCAPE_WARP, a jr z, .flyAnimation ; if going to the last used pokemon center ld hl, wPlayerSpinInPlaceAnimFrameDelay @@ -384,8 +384,8 @@ INCLUDE "data/tilesets/warp_pad_hole_tile_ids.asm" FishingAnim: ld c, 10 call DelayFrames - ld hl, wd736 - set 6, [hl] ; reserve the last 4 OAM entries + ld hl, wMovementFlags + set BIT_LEDGE_OR_FISHING, [hl] ld hl, vNPCSprites ld de, RedSprite ld b, BANK(RedSprite) @@ -452,8 +452,8 @@ FishingAnim: .done call PrintText - ld hl, wd736 - res 6, [hl] ; unreserve the last 4 OAM entries + ld hl, wMovementFlags + res BIT_LEDGE_OR_FISHING, [hl] call LoadFontTilePatterns ret @@ -519,10 +519,10 @@ _HandleMidJump:: ldh [hJoyPressed], a ldh [hJoyReleased], a ld [wPlayerJumpingYScreenCoordsIndex], a - ld hl, wd736 - res 6, [hl] ; not jumping down a ledge any more - ld hl, wd730 - res 7, [hl] ; not simulating joypad states any more + ld hl, wMovementFlags + res BIT_LEDGE_OR_FISHING, [hl] + ld hl, wStatusFlags5 + res BIT_SCRIPTED_MOVEMENT_STATE, [hl] xor a ld [wJoyIgnore], a ret diff --git a/engine/overworld/player_state.asm b/engine/overworld/player_state.asm index 1cedcf7c..1da1b36d 100644 --- a/engine/overworld/player_state.asm +++ b/engine/overworld/player_state.asm @@ -1,4 +1,4 @@ -; only used for setting bit 2 of wd736 upon entering a new map +; only used for setting BIT_STANDING_ON_WARP of wMovementFlags upon entering a new map IsPlayerStandingOnWarp:: ld a, [wNumberOfWarps] and a @@ -18,8 +18,8 @@ IsPlayerStandingOnWarp:: ld [wDestinationWarpID], a ld a, [hl] ; target map ldh [hWarpDestinationMap], a - ld hl, wd736 - set 2, [hl] ; standing on warp flag + ld hl, wMovementFlags + set BIT_STANDING_ON_WARP, [hl] ret .nextWarp1 inc hl @@ -32,8 +32,8 @@ IsPlayerStandingOnWarp:: ret CheckForceBikeOrSurf:: - ld hl, wd732 - bit 5, [hl] + ld hl, wStatusFlags6 + bit BIT_ALWAYS_ON_BIKE, [hl] ret nz ld hl, ForcedBikeOrSurfMaps ld a, [wYCoord] @@ -45,14 +45,14 @@ CheckForceBikeOrSurf:: .loop ld a, [hli] cp $ff - ret z ;if we reach FF then it's not part of the list - cp d ;compare to current map + ret z ; if we reach FF then it's not part of the list + cp d ; compare to current map jr nz, .incorrectMap ld a, [hli] - cp b ;compare y-coord + cp b ; compare y-coord jr nz, .incorrectY ld a, [hli] - cp c ;compare x-coord + cp c ; compare x-coord jr nz, .loop ; incorrect x-coord, check next item ld a, [wCurMap] cp SEAFOAM_ISLANDS_B3F @@ -64,9 +64,8 @@ CheckForceBikeOrSurf:: ld a, SCRIPT_SEAFOAMISLANDSB4F_MOVE_OBJECT ld [wSeafoamIslandsB4FCurScript], a jr z, .forceSurfing - ;force bike riding - ld hl, wd732 - set 5, [hl] + ld hl, wStatusFlags6 + set BIT_ALWAYS_ON_BIKE, [hl] ld a, $1 ld [wWalkBikeSurfState], a ld [wWalkBikeSurfStateCopy], a @@ -209,8 +208,8 @@ IsPlayerStandingOnDoorTileOrWarpTile:: lda_coord 8, 9 call IsInArray jr nc, .done - ld hl, wd736 - res 2, [hl] + ld hl, wMovementFlags + res BIT_STANDING_ON_WARP, [hl] .done pop bc pop de @@ -296,6 +295,13 @@ _GetTileAndCoordsInFrontOfPlayer: ld [wTileInFrontOfPlayer], a ret +; hPlayerFacing + const_def + const BIT_FACING_DOWN ; 0 + const BIT_FACING_UP ; 1 + const BIT_FACING_LEFT ; 2 + const BIT_FACING_RIGHT ; 3 + GetTileTwoStepsInFrontOfPlayer: xor a ldh [hPlayerFacing], a @@ -308,7 +314,7 @@ GetTileTwoStepsInFrontOfPlayer: jr nz, .notFacingDown ; facing down ld hl, hPlayerFacing - set 0, [hl] + set BIT_FACING_DOWN, [hl] lda_coord 8, 13 inc d jr .storeTile @@ -317,7 +323,7 @@ GetTileTwoStepsInFrontOfPlayer: jr nz, .notFacingUp ; facing up ld hl, hPlayerFacing - set 1, [hl] + set BIT_FACING_UP, [hl] lda_coord 8, 5 dec d jr .storeTile @@ -326,7 +332,7 @@ GetTileTwoStepsInFrontOfPlayer: jr nz, .notFacingLeft ; facing left ld hl, hPlayerFacing - set 2, [hl] + set BIT_FACING_LEFT, [hl] lda_coord 4, 9 dec e jr .storeTile @@ -335,7 +341,7 @@ GetTileTwoStepsInFrontOfPlayer: jr nz, .storeTile ; facing right ld hl, hPlayerFacing - set 3, [hl] + set BIT_FACING_RIGHT, [hl] lda_coord 12, 9 inc e .storeTile @@ -379,7 +385,7 @@ CheckForBoulderCollisionWithSprites: ld de, $f ld hl, wSprite01StateData2MapY ldh a, [hPlayerFacing] - and $3 ; facing up or down? + and (1 << BIT_FACING_UP) | (1 << BIT_FACING_DOWN) jr z, .pushingHorizontallyLoop .pushingVerticallyLoop inc hl @@ -390,6 +396,7 @@ CheckForBoulderCollisionWithSprites: ld a, [hli] ld b, a ldh a, [hPlayerFacing] + assert BIT_FACING_DOWN == 0 rrca jr c, .pushingDown ; pushing up @@ -415,7 +422,7 @@ CheckForBoulderCollisionWithSprites: jr nz, .nextSprite2 ld b, [hl] ldh a, [hPlayerFacing] - bit 2, a + bit BIT_FACING_LEFT, a jr nz, .pushingLeft ; pushing right ldh a, [hPlayerXCoord] diff --git a/engine/overworld/push_boulder.asm b/engine/overworld/push_boulder.asm index 96c506c0..1773e818 100644 --- a/engine/overworld/push_boulder.asm +++ b/engine/overworld/push_boulder.asm @@ -1,31 +1,31 @@ TryPushingBoulder:: - ld a, [wd728] - bit 0, a ; using Strength? + ld a, [wStatusFlags1] + bit BIT_STRENGTH_ACTIVE, a ret z - ld a, [wFlags_0xcd60] - bit 1, a ; has boulder dust animation from previous push played yet? + ld a, [wMiscFlags] + bit BIT_BOULDER_DUST, a ret nz xor a - ldh [hSpriteIndexOrTextID], a + ldh [hSpriteIndex], a call IsSpriteInFrontOfPlayer - ldh a, [hSpriteIndexOrTextID] + ldh a, [hSpriteIndex] ld [wBoulderSpriteIndex], a and a jp z, ResetBoulderPushFlags ld hl, wSpritePlayerStateData1MovementStatus ld d, $0 - ldh a, [hSpriteIndexOrTextID] + ldh a, [hSpriteIndex] swap a ld e, a add hl, de - res 7, [hl] + res BIT_FACE_PLAYER, [hl] call GetSpriteMovementByte2Pointer ld a, [hl] cp BOULDER_MOVEMENT_BYTE_2 jp nz, ResetBoulderPushFlags - ld hl, wFlags_0xcd60 - bit 6, [hl] - set 6, [hl] ; indicate that the player has tried pushing + ld hl, wMiscFlags + bit BIT_TRIED_PUSH_BOULDER, [hl] + set BIT_TRIED_PUSH_BOULDER, [hl] ret z ; the player must try pushing twice before the boulder will move ldh a, [hJoyHeld] and D_RIGHT | D_LEFT | D_UP | D_DOWN @@ -44,30 +44,30 @@ TryPushingBoulder:: cp SPRITE_FACING_RIGHT jr z, .pushBoulderRight .pushBoulderDown - bit 7, b + bit BIT_D_DOWN, b ret z ld de, PushBoulderDownMovementData jr .done .pushBoulderUp - bit 6, b + bit BIT_D_UP, b ret z ld de, PushBoulderUpMovementData jr .done .pushBoulderLeft - bit 5, b + bit BIT_D_LEFT, b ret z ld de, PushBoulderLeftMovementData jr .done .pushBoulderRight - bit 4, b + bit BIT_D_RIGHT, b ret z ld de, PushBoulderRightMovementData .done call MoveSprite ld a, SFX_PUSH_BOULDER call PlaySound - ld hl, wFlags_0xcd60 - set 1, [hl] + ld hl, wMiscFlags + set BIT_BOULDER_DUST, [hl] ret PushBoulderUpMovementData: @@ -87,14 +87,14 @@ PushBoulderRightMovementData: db -1 ; end DoBoulderDustAnimation:: - ld a, [wd730] - bit 0, a + ld a, [wStatusFlags5] + bit BIT_SCRIPTED_NPC_MOVEMENT, a ret nz callfar AnimateBoulderDust call DiscardButtonPresses ld [wJoyIgnore], a call ResetBoulderPushFlags - set 7, [hl] ; [wFlags_0xcd60] + set BIT_PUSHED_BOULDER, [hl] ld a, [wBoulderSpriteIndex] ldh [hSpriteIndex], a call GetSpriteMovementByte2Pointer @@ -103,7 +103,7 @@ DoBoulderDustAnimation:: jp PlaySound ResetBoulderPushFlags: - ld hl, wFlags_0xcd60 - res 1, [hl] - res 6, [hl] + ld hl, wMiscFlags + res BIT_BOULDER_DUST, [hl] + res BIT_TRIED_PUSH_BOULDER, [hl] ret diff --git a/engine/overworld/special_warps.asm b/engine/overworld/special_warps.asm index 0cc2a474..b20d490e 100644 --- a/engine/overworld/special_warps.asm +++ b/engine/overworld/special_warps.asm @@ -1,9 +1,9 @@ PrepareForSpecialWarp:: call LoadSpecialWarpData predef LoadTilesetHeader - ld hl, wd732 - bit 2, [hl] ; dungeon warp or fly warp? - res 2, [hl] + ld hl, wStatusFlags6 + bit BIT_FLY_OR_DUNGEON_WARP, [hl] + res BIT_FLY_OR_DUNGEON_WARP, [hl] jr z, .debugNewGameWarp ld a, [wDestinationMap] jr .next @@ -17,19 +17,19 @@ PrepareForSpecialWarp:: ld a, PALLET_TOWN .next ld b, a - ld a, [wd72d] - and a + ld a, [wStatusFlags3] + and a ; ??? jr nz, .next2 ld a, b .next2 - ld hl, wd732 - bit 4, [hl] ; dungeon warp + ld hl, wStatusFlags6 + bit BIT_DUNGEON_WARP, [hl] ret nz ld [wLastMap], a ret LoadSpecialWarpData: - ld a, [wd72d] + ld a, [wCableClubDestinationMap] cp TRADE_CENTER jr nz, .notTradeCenter ld hl, TradeCenterPlayerWarp @@ -48,11 +48,11 @@ LoadSpecialWarpData: ld hl, ColosseumFriendWarp jr .copyWarpData .notColosseum - ld a, [wd732] + ld a, [wStatusFlags6] bit BIT_DEBUG_MODE, a ; warp to wLastMap (PALLET_TOWN) for StartNewGameDebug jr nz, .notNewGameWarp - bit 2, a + bit BIT_FLY_OR_DUNGEON_WARP, a jr nz, .notNewGameWarp ld hl, NewGameWarp .copyWarpData @@ -70,17 +70,17 @@ LoadSpecialWarpData: jr .done .notNewGameWarp ld a, [wLastMap] ; this value is overwritten before it's ever read - ld hl, wd732 - bit 4, [hl] ; dungeon warp + ld hl, wStatusFlags6 + bit BIT_DUNGEON_WARP, [hl] jr nz, .usedDungeonWarp - bit 6, [hl] ; blacked out - res 6, [hl] + bit BIT_ESCAPE_WARP, [hl] + res BIT_ESCAPE_WARP, [hl] jr z, .otherDestination ld a, [wLastBlackoutMap] jr .usedFlyWarp .usedDungeonWarp - ld hl, wd72d - res 4, [hl] + ld hl, wStatusFlags3 + res BIT_ON_DUNGEON_WARP, [hl] ld a, [wDungeonWarpDestinationMap] ld b, a ld [wCurMap], a diff --git a/engine/overworld/specific_script_flags.asm b/engine/overworld/specific_script_flags.asm index b59aa9d0..bd045145 100644 --- a/engine/overworld/specific_script_flags.asm +++ b/engine/overworld/specific_script_flags.asm @@ -14,12 +14,12 @@ SetMapSpecificScriptFlagsOnMapReload:: .vermilion_gym ld hl, wCurrentMapScriptFlags - set 6, [hl] + set BIT_CUR_MAP_LOADED_2, [hl] ret .in_list ld hl, wCurrentMapScriptFlags - set 5, [hl] + set BIT_CUR_MAP_LOADED_1, [hl] ret INCLUDE "data/maps/bit_5_maps.asm" diff --git a/engine/overworld/spinners.asm b/engine/overworld/spinners.asm index 98b478c4..261a939e 100644 --- a/engine/overworld/spinners.asm +++ b/engine/overworld/spinners.asm @@ -15,7 +15,7 @@ LoadSpinnerArrowTiles:: ld hl, GymSpinnerArrows .gotSpinnerArrows ld a, [wSimulatedJoypadStatesIndex] - bit 0, a + bit 0, a ; even or odd? jr nz, .alternateGraphics ld de, 6 * 4 add hl, de diff --git a/engine/overworld/trainer_sight.asm b/engine/overworld/trainer_sight.asm index 816dea7f..f32b558a 100644 --- a/engine/overworld/trainer_sight.asm +++ b/engine/overworld/trainer_sight.asm @@ -221,8 +221,8 @@ TrainerEngage: ld a, [wTrainerSpriteOffset] and a jr z, .noEngage - ld hl, wFlags_0xcd60 - set 0, [hl] + ld hl, wMiscFlags + set BIT_SEEN_BY_TRAINER, [hl] call EngageMapTrainer ld a, $ff .noEngage |
