diff options
author | Rangi <35663410+Rangi42@users.noreply.github.com> | 2020-07-04 16:19:15 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-04 16:19:15 -0400 |
commit | 2718c36065e7eb201a149938bcdd51987c4e56b6 (patch) | |
tree | 4a1c0294193a497e15ec8e6be59390eb1f84b5d3 /engine/overworld/movement.asm | |
parent | c85050497c1bd062e9cd40bf5b32fa3beca366cc (diff) | |
parent | 36f8cd1477b8ebe0537e99abd3ba53471a2e16c4 (diff) |
Merge pull request #257 from Rangi42/master
More reorganization
Diffstat (limited to 'engine/overworld/movement.asm')
-rw-r--r-- | engine/overworld/movement.asm | 88 |
1 files changed, 44 insertions, 44 deletions
diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm index f272f497..6c354779 100644 --- a/engine/overworld/movement.asm +++ b/engine/overworld/movement.asm @@ -63,7 +63,7 @@ UpdatePlayerSprite: ld a, [wd736] bit 7, a ; is the player sprite spinning due to a spin tile? jr nz, .skipSpriteAnim - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $7 ld l, a ld a, [hl] @@ -103,7 +103,7 @@ UpdatePlayerSprite: UnusedReadSpriteDataFunction: push bc push af - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] ld c, a pop af add c @@ -112,7 +112,7 @@ UnusedReadSpriteDataFunction: ret UpdateNPCSprite: - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] swap a dec a add a @@ -122,7 +122,7 @@ UpdateNPCSprite: ld a, [hl] ; read movement byte 2 ld [wCurSpriteMovement2], a ld h, $c1 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] ld l, a inc l ld a, [hl] ; c1x1 @@ -131,7 +131,7 @@ UpdateNPCSprite: call CheckSpriteAvailability ret c ; if sprite is invisible, on tile >=MAP_TILESET_SIZE, in grass or player is currently walking ld h, $c1 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] ld l, a inc l ld a, [hl] ; c1x1 @@ -151,7 +151,7 @@ UpdateNPCSprite: ret nz ; don't do anything yet if player is currently moving (redundant, already tested in CheckSpriteAvailability) call InitializeSpriteScreenPosition ld h, $c2 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $6 ld l, a ld a, [hl] ; c2x6: movement byte 1 @@ -264,11 +264,11 @@ ChangeFacingDirection: TryWalking: push hl ld h, $c1 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $9 ld l, a ld [hl], c ; c1x9 (update facing direction) - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $3 ld l, a ld [hl], d ; c1x3 (update Y movement delta) @@ -282,7 +282,7 @@ TryWalking: pop de ret c ; cannot walk there (reinitialization of delay values already done) ld h, $c2 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $4 ld l, a ld a, [hl] ; c2x4: Y position @@ -291,7 +291,7 @@ TryWalking: ld a, [hl] ; c2x5: X position add e ld [hl], a ; update X position - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] ld l, a ld [hl], $10 ; c2x0=16: walk animation counter dec h @@ -301,7 +301,7 @@ TryWalking: ; update the walking animation parameters for a sprite that is currently walking UpdateSpriteInWalkingAnimation: - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $7 ld l, a ld a, [hl] ; c1x7 (counter until next walk animation frame) @@ -317,7 +317,7 @@ UpdateSpriteInWalkingAnimation: and $3 ld [hl], a ; advance to next animation frame every 4 ticks (16 ticks total for one step) .noNextAnimationFrame - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $3 ld l, a ld a, [hli] ; c1x3 (movement Y delta) @@ -330,7 +330,7 @@ UpdateSpriteInWalkingAnimation: ld a, [hl] ; c1x6 (screen X position) add b ld [hl], a ; update screen X position - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] ld l, a inc h ld a, [hl] ; c2x0 (walk animation counter) @@ -343,7 +343,7 @@ UpdateSpriteInWalkingAnimation: ld a, [hl] ; c2x6 (movement byte 1) cp $fe jr nc, .initNextMovementCounter ; values $fe and $ff - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] inc a ld l, a dec h @@ -351,14 +351,14 @@ UpdateSpriteInWalkingAnimation: ret .initNextMovementCounter call Random - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $8 ld l, a ld a, [hRandomAdd] and $7f ld [hl], a ; c2x8: set next movement delay to a random value in [0,$7f] dec h ; note that value 0 actually makes the delay $100 (bug?) - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] inc a ld l, a ld [hl], $2 ; c1x1 = 2 (movement status) @@ -375,7 +375,7 @@ UpdateSpriteInWalkingAnimation: ; update delay value (c2x8) for sprites in the delayed state (c1x1) UpdateSpriteMovementDelay: ld h, $c2 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $6 ld l, a ld a, [hl] ; c2x6: movement byte 1 @@ -390,13 +390,13 @@ UpdateSpriteMovementDelay: jr nz, notYetMoving .moving dec h - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] inc a ld l, a ld [hl], $1 ; c1x1 = 1 (mark as ready to move) notYetMoving: ld h, wSpriteStateData1 / $100 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $8 ld l, a ld [hl], $0 ; c1x8 = 0 (walk animation frame) @@ -429,7 +429,7 @@ MakeNPCFacePlayer: .notFacingRight ld c, SPRITE_FACING_LEFT .facingDirectionDetermined - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $9 ld l, a ld [hl], c ; c1x9: set facing direction @@ -440,7 +440,7 @@ InitializeSpriteStatus: inc l ld [hl], $ff ; $c1x2: set sprite image to $ff (invisible/off screen) inc h - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $2 ld l, a ld a, $8 @@ -451,7 +451,7 @@ InitializeSpriteStatus: ; calculates the sprite's screen position form its map position and the player position InitializeSpriteScreenPosition: ld h, wSpriteStateData2 / $100 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $4 ld l, a ld a, [wYCoord] @@ -475,17 +475,17 @@ InitializeSpriteScreenPosition: ; tests if sprite is off screen or otherwise unable to do anything CheckSpriteAvailability: predef IsObjectHidden - ld a, [$ffe5] + ld a, [hIsHiddenMissableObject] and a jp nz, .spriteInvisible ld h, wSpriteStateData2 / $100 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $6 ld l, a ld a, [hl] ; c2x6: movement byte 1 cp $fe jr c, .skipXVisibilityTest ; movement byte 1 < $fe (i.e. the sprite's movement is scripted) - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $4 ld l, a ld b, [hl] ; c2x4: Y pos (+4) @@ -527,7 +527,7 @@ CheckSpriteAvailability: jr c, .spriteVisible ; standing on tile with ID >=MAP_TILESET_SIZE (top right tile) .spriteInvisible ld h, wSpriteStateData1 / $100 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $2 ld l, a ld [hl], $ff ; c1x2 @@ -540,7 +540,7 @@ CheckSpriteAvailability: jr nz, .done ; if player is currently walking, we're done call UpdateSpriteImage inc h - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $7 ld l, a ld a, [wGrassTile] @@ -556,7 +556,7 @@ CheckSpriteAvailability: UpdateSpriteImage: ld h, $c1 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $8 ld l, a ld a, [hli] ; c1x8: walk animation frame @@ -564,10 +564,10 @@ UpdateSpriteImage: ld a, [hl] ; c1x9: facing direction add b ld b, a - ld a, [$ff93] ; current sprite offset + ld a, [hTilePlayerStandingOn] add b ld b, a - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $2 ld l, a ld [hl], b ; c1x2: sprite to display @@ -581,7 +581,7 @@ UpdateSpriteImage: ; set carry on failure, clears carry on success CanWalkOntoTile: ld h, wSpriteStateData2 / $100 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $6 ld l, a ld a, [hl] ; c2x6 (movement byte 1) @@ -602,14 +602,14 @@ CanWalkOntoTile: cp c jr nz, .tilePassableLoop ld h, $c2 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $6 ld l, a ld a, [hl] ; $c2x6 (movement byte 1) inc a jr z, .impassable ; if $ff, no movement allowed (however, changing direction is) ld h, wSpriteStateData1 / $100 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $4 ld l, a ld a, [hli] ; c1x4 (screen Y pos) @@ -628,14 +628,14 @@ CanWalkOntoTile: pop bc pop de ld h, wSpriteStateData1 / $100 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $c ld l, a ld a, [hl] ; c1xc (directions in which sprite collision would occur) and b ; check against chosen direction (1,2,4 or 8) jr nz, .impassable ; collision between sprites, don't go there ld h, wSpriteStateData2 / $100 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $2 ld l, a ld a, [hli] ; c2x2 (sprite Y displacement, initialized at $8, keep track of where a sprite did go) @@ -666,7 +666,7 @@ CanWalkOntoTile: ret .impassable ld h, $c1 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] inc a ld l, a ld [hl], $2 ; c1x1 = 2 (set movement status to delayed) @@ -677,7 +677,7 @@ CanWalkOntoTile: inc l ld [hl], a ; c1x5 = 0 (clear X movement delta) inc h - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $8 ld l, a call Random @@ -692,7 +692,7 @@ CanWalkOntoTile: ; hl: output pointer GetTileSpriteStandsOn: ld h, wSpriteStateData1 / $100 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $4 ld l, a ld a, [hli] ; c1x4: screen Y position @@ -784,7 +784,7 @@ DoScriptedNPCMovement: ld a, [hl] add b ld [hl], a - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $9 ld l, a ld a, c @@ -817,7 +817,7 @@ GetSpriteScreenXPointer: GetSpriteScreenXYPointerCommon: ld hl, wSpriteStateData1 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add l add b ld l, a @@ -825,7 +825,7 @@ GetSpriteScreenXYPointerCommon: AnimScriptedNPCMovement: ld hl, wSpriteStateData2 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $e ld l, a ld a, [hl] ; VRAM slot @@ -833,7 +833,7 @@ AnimScriptedNPCMovement: swap a ld b, a ld hl, wSpriteStateData1 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $9 ld l, a ld a, [hl] ; facing direction @@ -852,7 +852,7 @@ AnimScriptedNPCMovement: ld [hSpriteVRAMSlotAndFacing], a call AdvanceScriptedNPCAnimFrameCounter ld hl, wSpriteStateData1 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $2 ld l, a ld a, [hSpriteVRAMSlotAndFacing] @@ -863,7 +863,7 @@ AnimScriptedNPCMovement: ret AdvanceScriptedNPCAnimFrameCounter: - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $7 ld l, a ld a, [hl] ; intra-animation frame counter |