aboutsummaryrefslogtreecommitdiffstats
path: root/engine/overworld/advance_player_sprite.asm
diff options
context:
space:
mode:
authordannye <33dannye@gmail.com>2020-11-04 00:06:44 -0600
committerdannye <33dannye@gmail.com>2020-11-04 00:06:44 -0600
commit5647ca687b92954dcf37a6ea6bfbc9a341c32de4 (patch)
treedde1937a1bfdb3a835f4155e1c2eb8f1aaf86f63 /engine/overworld/advance_player_sprite.asm
parentMerge pull request #55 from Deokishisu/patch-1 (diff)
downloadpokeyellow-5647ca687b92954dcf37a6ea6bfbc9a341c32de4.tar.gz
pokeyellow-5647ca687b92954dcf37a6ea6bfbc9a341c32de4.tar.xz
pokeyellow-5647ca687b92954dcf37a6ea6bfbc9a341c32de4.zip
Sync with pokered
Diffstat (limited to 'engine/overworld/advance_player_sprite.asm')
-rw-r--r--engine/overworld/advance_player_sprite.asm247
1 files changed, 125 insertions, 122 deletions
diff --git a/engine/overworld/advance_player_sprite.asm b/engine/overworld/advance_player_sprite.asm
index 6b4a0cbb..4ebdac84 100644
--- a/engine/overworld/advance_player_sprite.asm
+++ b/engine/overworld/advance_player_sprite.asm
@@ -1,241 +1,244 @@
_AdvancePlayerSprite::
- ld a,[wSpriteStateData1 + 3] ; delta Y
- ld b,a
- ld a,[wSpriteStateData1 + 5] ; delta X
- ld c,a
- ld hl,wWalkCounter ; walking animation counter
+ ld a, [wSpritePlayerStateData1YStepVector]
+ ld b, a
+ ld a, [wSpritePlayerStateData1XStepVector]
+ ld c, a
+ ld hl, wWalkCounter ; walking animation counter
dec [hl]
- jr nz,.afterUpdateMapCoords
+ jr nz, .afterUpdateMapCoords
; if it's the end of the animation, update the player's map coordinates
ld hl, wPikachuOverworldStateFlags
res 5, [hl]
- ld a,[wYCoord]
+ ld a, [wYCoord]
add b
- ld [wYCoord],a
- ld a,[wXCoord]
+ ld [wYCoord], a
+ ld a, [wXCoord]
add c
- ld [wXCoord],a
+ ld [wXCoord], a
.afterUpdateMapCoords
- ld a,[wWalkCounter] ; walking animation counter
- cp a,$07
- jp nz,.scrollBackgroundAndSprites
+ ld a, [wWalkCounter] ; walking animation counter
+ cp $07
+ jp nz, .scrollBackgroundAndSprites
; if this is the first iteration of the animation
- ld a,c
- cp a,$01
- jr nz,.checkIfMovingWest
+ ld a, c
+ cp $01
+ jr nz, .checkIfMovingWest
; moving east
- ld a,[wMapViewVRAMPointer]
- ld e,a
+ ld a, [wMapViewVRAMPointer]
+ ld e, a
and $e0
- ld d,a
- ld a,e
+ ld d, a
+ ld a, e
add $02
and $1f
or d
- ld [wMapViewVRAMPointer],a
+ ld [wMapViewVRAMPointer], a
jr .adjustXCoordWithinBlock
.checkIfMovingWest
- cp a,$ff
- jr nz,.checkIfMovingSouth
+ cp $ff
+ jr nz, .checkIfMovingSouth
; moving west
- ld a,[wMapViewVRAMPointer]
- ld e,a
- and a,$e0
- ld d,a
- ld a,e
+ ld a, [wMapViewVRAMPointer]
+ ld e, a
+ and $e0
+ ld d, a
+ ld a, e
sub $02
and $1f
or d
- ld [wMapViewVRAMPointer],a
+ ld [wMapViewVRAMPointer], a
jr .adjustXCoordWithinBlock
.checkIfMovingSouth
- ld a,b
- cp a,$01
- jr nz,.checkIfMovingNorth
+ ld a, b
+ cp $01
+ jr nz, .checkIfMovingNorth
; moving south
- ld a,[wMapViewVRAMPointer]
+ ld a, [wMapViewVRAMPointer]
add $40
- ld [wMapViewVRAMPointer],a
- jr nc,.adjustXCoordWithinBlock
- ld a,[wMapViewVRAMPointer + 1]
+ ld [wMapViewVRAMPointer], a
+ jr nc, .adjustXCoordWithinBlock
+ ld a, [wMapViewVRAMPointer + 1]
inc a
and $03
or $98
- ld [wMapViewVRAMPointer + 1],a
+ ld [wMapViewVRAMPointer + 1], a
jr .adjustXCoordWithinBlock
.checkIfMovingNorth
- cp a,$ff
- jr nz,.adjustXCoordWithinBlock
+ cp $ff
+ jr nz, .adjustXCoordWithinBlock
; moving north
- ld a,[wMapViewVRAMPointer]
+ ld a, [wMapViewVRAMPointer]
sub $40
- ld [wMapViewVRAMPointer],a
- jr nc,.adjustXCoordWithinBlock
- ld a,[wMapViewVRAMPointer + 1]
+ ld [wMapViewVRAMPointer], a
+ jr nc, .adjustXCoordWithinBlock
+ ld a, [wMapViewVRAMPointer + 1]
dec a
and $03
or $98
- ld [wMapViewVRAMPointer + 1],a
+ ld [wMapViewVRAMPointer + 1], a
.adjustXCoordWithinBlock
- ld a,c
+ ld a, c
and a
- jr z,.pointlessJump ; mistake?
+ jr z, .pointlessJump ; mistake?
.pointlessJump
- ld hl,wXBlockCoord
- ld a,[hl]
+ ld hl, wXBlockCoord
+ ld a, [hl]
add c
- ld [hl],a
+ ld [hl], a
cp $02
- jr nz,.checkForMoveToWestBlock
+ jr nz, .checkForMoveToWestBlock
; moved into the tile block to the east
xor a
- ld [hl],a
- ld hl,wXOffsetSinceLastSpecialWarp
+ ld [hl], a
+ ld hl, wXOffsetSinceLastSpecialWarp
inc [hl]
- ld de,wCurrentTileBlockMapViewPointer
+ ld de, wCurrentTileBlockMapViewPointer
call MoveTileBlockMapPointerEast
jr .updateMapView
.checkForMoveToWestBlock
- cp a,$ff
- jr nz,.adjustYCoordWithinBlock
+ cp $ff
+ jr nz, .adjustYCoordWithinBlock
; moved into the tile block to the west
- ld a,$1
- ld [hl],a
- ld hl,wXOffsetSinceLastSpecialWarp
+ ld a, $01
+ ld [hl], a
+ ld hl, wXOffsetSinceLastSpecialWarp
dec [hl]
- ld de,wCurrentTileBlockMapViewPointer
+ ld de, wCurrentTileBlockMapViewPointer
call MoveTileBlockMapPointerWest
jr .updateMapView
.adjustYCoordWithinBlock
- ld hl,wYBlockCoord
- ld a,[hl]
+ ld hl, wYBlockCoord
+ ld a, [hl]
add b
- ld [hl],a
- cp $2
- jr nz,.checkForMoveToNorthBlock
+ ld [hl], a
+ cp $02
+ jr nz, .checkForMoveToNorthBlock
; moved into the tile block to the south
xor a
- ld [hl],a
- ld hl,wYOffsetSinceLastSpecialWarp
+ ld [hl], a
+ ld hl, wYOffsetSinceLastSpecialWarp
inc [hl]
- ld de,wCurrentTileBlockMapViewPointer
- ld a,[wCurMapWidth]
+ ld de, wCurrentTileBlockMapViewPointer
+ ld a, [wCurMapWidth]
call MoveTileBlockMapPointerSouth
jr .updateMapView
.checkForMoveToNorthBlock
- cp a,$ff
- jr nz,.updateMapView
+ cp $ff
+ jr nz, .updateMapView
; moved into the tile block to the north
- ld a,$1
- ld [hl],a
- ld hl,wYOffsetSinceLastSpecialWarp
+ ld a, $01
+ ld [hl], a
+ ld hl, wYOffsetSinceLastSpecialWarp
dec [hl]
- ld de,wCurrentTileBlockMapViewPointer
- ld a,[wCurMapWidth]
+ ld de, wCurrentTileBlockMapViewPointer
+ ld a, [wCurMapWidth]
call MoveTileBlockMapPointerNorth
.updateMapView
call LoadCurrentMapView
- ld a,[wSpriteStateData1 + 3] ; delta Y
- cp $1
- jr nz,.checkIfMovingNorth2
+ ld a, [wSpritePlayerStateData1YStepVector]
+ cp $01
+ jr nz, .checkIfMovingNorth2
; if moving south
call ScheduleSouthRowRedraw
jr .scrollBackgroundAndSprites
.checkIfMovingNorth2
cp $ff
- jr nz,.checkIfMovingEast2
+ jr nz, .checkIfMovingEast2
; if moving north
call ScheduleNorthRowRedraw
jr .scrollBackgroundAndSprites
.checkIfMovingEast2
- ld a,[wSpriteStateData1 + 5] ; delta X
- cp $1
- jr nz,.checkIfMovingWest2
+ ld a, [wSpritePlayerStateData1XStepVector]
+ cp $01
+ jr nz, .checkIfMovingWest2
; if moving east
call ScheduleEastColumnRedraw
jr .scrollBackgroundAndSprites
.checkIfMovingWest2
cp $ff
- jr nz,.scrollBackgroundAndSprites
+ jr nz, .scrollBackgroundAndSprites
; if moving west
call ScheduleWestColumnRedraw
.scrollBackgroundAndSprites
- ld a,[wSpriteStateData1 + 3] ; delta Y
+ ld a, [wSpritePlayerStateData1YStepVector]
add a
- ld b,a
- ld a,[wSpriteStateData1 + 5] ; delta X
+ ld b, a
+ ld a, [wSpritePlayerStateData1XStepVector]
add a
- ld c,a
+ ld c, a
; shift all the sprites in the direction opposite of the player's motion
; so that the player appears to move relative to them
- ld hl,wSpriteStateData1 + $14
- ld e,15
+ ld hl, wSprite01StateData1YPixels
+ ld e, 15
.spriteShiftLoop
- ld a,[hl]
+ ld a, [hl]
sub b
- ld [hli],a
+ ld [hli], a
inc l
- ld a,[hl]
+ ld a, [hl]
sub c
- ld [hl],a
- ld a,$0e
+ ld [hl], a
+ ld a, $0e
add l
- ld l,a
+ ld l, a
dec e
- jr nz,.spriteShiftLoop
+ jr nz, .spriteShiftLoop
.done
- ld a,[hSCY]
+ ldh a, [hSCY]
add b
- ld [hSCY],a ; update background scroll Y
- ld a,[hSCX]
+ ldh [hSCY], a ; update background scroll Y
+ ldh a, [hSCX]
add c
- ld [hSCX],a ; update background scroll X
+ ldh [hSCX], a ; update background scroll X
ret
+; the following four functions are used to move the pointer to the upper left
+; corner of the tile block map in the direction of motion
+
MoveTileBlockMapPointerEast::
- ld a,[de]
- add $1
- ld [de],a
+ ld a, [de]
+ add $01
+ ld [de], a
ret nc
inc de
- ld a,[de]
+ ld a, [de]
inc a
- ld [de],a
+ ld [de], a
ret
MoveTileBlockMapPointerWest::
- ld a,[de]
- sub $1
- ld [de],a
+ ld a, [de]
+ sub $01
+ ld [de], a
ret nc
inc de
- ld a,[de]
+ ld a, [de]
dec a
- ld [de],a
+ ld [de], a
ret
MoveTileBlockMapPointerSouth::
- add $6
- ld b,a
- ld a,[de]
+ add MAP_BORDER * 2
+ ld b, a
+ ld a, [de]
add b
- ld [de],a
+ ld [de], a
ret nc
inc de
- ld a,[de]
+ ld a, [de]
inc a
- ld [de],a
+ ld [de], a
ret
MoveTileBlockMapPointerNorth::
- add $6
- ld b,a
- ld a,[de]
+ add MAP_BORDER * 2
+ ld b, a
+ ld a, [de]
sub b
- ld [de],a
+ ld [de], a
ret nc
inc de
- ld a,[de]
+ ld a, [de]
dec a
- ld [de],a
+ ld [de], a
ret