Specify the ldh instruction, don't turn ld into ldh

This commit is contained in:
Rangi 2020-07-06 19:03:05 -04:00
parent c480632d54
commit 772fcc7588
219 changed files with 2556 additions and 2556 deletions

View file

@ -14,7 +14,7 @@ UpdatePlayerSprite:
; the maximum number for map tiles
.checkIfTextBoxInFrontOfSprite
aCoord 8, 9
ld [hTilePlayerStandingOn], a
ldh [hTilePlayerStandingOn], a
cp MAP_TILESET_SIZE
jr c, .lowerLeftTileIsMapTile
.disableSprite
@ -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, [hCurrentSpriteOffset]
ldh a, [hCurrentSpriteOffset]
add $7
ld l, a
ld a, [hl]
@ -89,7 +89,7 @@ UpdatePlayerSprite:
; lower priority than the background so that it's partially obscured by the
; grass. Only the lower half of the sprite is permitted to have the priority
; bit set by later logic.
ld a, [hTilePlayerStandingOn]
ldh a, [hTilePlayerStandingOn]
ld c, a
ld a, [wGrassTile]
cp c
@ -103,7 +103,7 @@ UpdatePlayerSprite:
UnusedReadSpriteDataFunction:
push bc
push af
ld a, [hCurrentSpriteOffset]
ldh a, [hCurrentSpriteOffset]
ld c, a
pop af
add c
@ -112,7 +112,7 @@ UnusedReadSpriteDataFunction:
ret
UpdateNPCSprite:
ld a, [hCurrentSpriteOffset]
ldh 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, [hCurrentSpriteOffset]
ldh 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, [hCurrentSpriteOffset]
ldh 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, [hCurrentSpriteOffset]
ldh 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, [hCurrentSpriteOffset]
ldh a, [hCurrentSpriteOffset]
add $9
ld l, a
ld [hl], c ; c1x9 (update facing direction)
ld a, [hCurrentSpriteOffset]
ldh 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, [hCurrentSpriteOffset]
ldh 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, [hCurrentSpriteOffset]
ldh 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, [hCurrentSpriteOffset]
ldh 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, [hCurrentSpriteOffset]
ldh 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, [hCurrentSpriteOffset]
ldh 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, [hCurrentSpriteOffset]
ldh a, [hCurrentSpriteOffset]
inc a
ld l, a
dec h
@ -351,14 +351,14 @@ UpdateSpriteInWalkingAnimation:
ret
.initNextMovementCounter
call Random
ld a, [hCurrentSpriteOffset]
ldh a, [hCurrentSpriteOffset]
add $8
ld l, a
ld a, [hRandomAdd]
ldh 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, [hCurrentSpriteOffset]
ldh 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, [hCurrentSpriteOffset]
ldh 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, [hCurrentSpriteOffset]
ldh a, [hCurrentSpriteOffset]
inc a
ld l, a
ld [hl], $1 ; c1x1 = 1 (mark as ready to move)
notYetMoving:
ld h, wSpriteStateData1 / $100
ld a, [hCurrentSpriteOffset]
ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData1AnimFrameCounter - wSpritePlayerStateData1
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, [hCurrentSpriteOffset]
ldh 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, [hCurrentSpriteOffset]
ldh 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, [hCurrentSpriteOffset]
ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData2MapY - wSpritePlayerStateData2
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, [hIsHiddenMissableObject]
ldh a, [hIsHiddenMissableObject]
and a
jp nz, .spriteInvisible
ld h, wSpriteStateData2 / $100
ld a, [hCurrentSpriteOffset]
ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData2MovementByte1 - wSpritePlayerStateData2
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, [hCurrentSpriteOffset]
ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData2MapY - wSpritePlayerStateData2
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, [hCurrentSpriteOffset]
ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData1ImageIndex - wSpritePlayerStateData1
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, [hCurrentSpriteOffset]
ldh a, [hCurrentSpriteOffset]
add $7
ld l, a
ld a, [wGrassTile]
@ -556,7 +556,7 @@ CheckSpriteAvailability:
UpdateSpriteImage:
ld h, $c1
ld a, [hCurrentSpriteOffset]
ldh 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, [hTilePlayerStandingOn]
ldh a, [hTilePlayerStandingOn]
add b
ld b, a
ld a, [hCurrentSpriteOffset]
ldh 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, [hCurrentSpriteOffset]
ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData2MovementByte1 - wSpritePlayerStateData2
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, [hCurrentSpriteOffset]
ldh 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, [hCurrentSpriteOffset]
ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData1YPixels - wSpritePlayerStateData1
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, [hCurrentSpriteOffset]
ldh 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, [hCurrentSpriteOffset]
ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData2YDisplacement - wSpritePlayerStateData2
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, wSpriteStateData1 / $100
ld a, [hCurrentSpriteOffset]
ldh a, [hCurrentSpriteOffset]
inc a
ld l, a
ld [hl], $2 ; c1x1 = 2 (set movement status to delayed)
@ -677,11 +677,11 @@ CanWalkOntoTile:
inc l
ld [hl], a ; c1x5 = 0 (clear X movement delta)
inc h
ld a, [hCurrentSpriteOffset]
ldh a, [hCurrentSpriteOffset]
add $8
ld l, a
call Random
ld a, [hRandomAdd]
ldh a, [hRandomAdd]
and $7f
ld [hl], a ; c2x8: set next movement delay to a random value in [0,$7f] (again with delay $100 if value is 0)
scf ; set carry (marking failure to walk)
@ -692,7 +692,7 @@ CanWalkOntoTile:
; hl: output pointer
GetTileSpriteStandsOn:
ld h, wSpriteStateData1 / $100
ld a, [hCurrentSpriteOffset]
ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData1YPixels - wSpritePlayerStateData1
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, [hCurrentSpriteOffset]
ldh a, [hCurrentSpriteOffset]
add $9
ld l, a
ld a, c
@ -817,7 +817,7 @@ GetSpriteScreenXPointer:
GetSpriteScreenXYPointerCommon:
ld hl, wSpriteStateData1
ld a, [hCurrentSpriteOffset]
ldh a, [hCurrentSpriteOffset]
add l
add b
ld l, a
@ -825,7 +825,7 @@ GetSpriteScreenXYPointerCommon:
AnimScriptedNPCMovement:
ld hl, wSpriteStateData2
ld a, [hCurrentSpriteOffset]
ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData2ImageBaseOffset - wSpritePlayerStateData2
ld l, a
ld a, [hl] ; VRAM slot
@ -833,7 +833,7 @@ AnimScriptedNPCMovement:
swap a
ld b, a
ld hl, wSpriteStateData1
ld a, [hCurrentSpriteOffset]
ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData1FacingDirection - wSpritePlayerStateData1
ld l, a
ld a, [hl] ; facing direction
@ -849,21 +849,21 @@ AnimScriptedNPCMovement:
.anim
add b
ld b, a
ld [hSpriteVRAMSlotAndFacing], a
ldh [hSpriteVRAMSlotAndFacing], a
call AdvanceScriptedNPCAnimFrameCounter
ld hl, wSpriteStateData1
ld a, [hCurrentSpriteOffset]
ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData1ImageIndex - wSpritePlayerStateData1
ld l, a
ld a, [hSpriteVRAMSlotAndFacing]
ldh a, [hSpriteVRAMSlotAndFacing]
ld b, a
ld a, [hSpriteAnimFrameCounter]
ldh a, [hSpriteAnimFrameCounter]
add b
ld [hl], a
ret
AdvanceScriptedNPCAnimFrameCounter:
ld a, [hCurrentSpriteOffset]
ldh a, [hCurrentSpriteOffset]
add $7
ld l, a
ld a, [hl] ; intra-animation frame counter
@ -878,5 +878,5 @@ AdvanceScriptedNPCAnimFrameCounter:
inc a
and $3
ld [hl], a
ld [hSpriteAnimFrameCounter], a
ldh [hSpriteAnimFrameCounter], a
ret