aboutsummaryrefslogtreecommitdiffstats
path: root/engine/overworld/player_state.asm
diff options
context:
space:
mode:
authordannye <33dannye@gmail.com>2024-09-25 00:45:00 -0500
committerdannye <33dannye@gmail.com>2024-09-25 00:45:00 -0500
commita02a98ee7ada1a658e28698484058be2796dc0df (patch)
tree945986054565bd8b5212fc755415096050d1d3a8 /engine/overworld/player_state.asm
parentUse long option flags for rgbgfx, same as tools/gfx (diff)
parentUse `const_skip` (diff)
downloadpokeyellow-a02a98ee7ada1a658e28698484058be2796dc0df.tar.gz
pokeyellow-a02a98ee7ada1a658e28698484058be2796dc0df.tar.xz
pokeyellow-a02a98ee7ada1a658e28698484058be2796dc0df.zip
Merge branch 'master' of https://github.com/pret/pokered
Diffstat (limited to 'engine/overworld/player_state.asm')
-rw-r--r--engine/overworld/player_state.asm47
1 files changed, 27 insertions, 20 deletions
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]