diff options
author | Rangi <remy.oukaour+rangi42@gmail.com> | 2020-07-06 19:03:05 -0400 |
---|---|---|
committer | Rangi <remy.oukaour+rangi42@gmail.com> | 2020-07-06 19:03:05 -0400 |
commit | 772fcc7588a4e1fbe146a02b429cf64282c81dcb (patch) | |
tree | f491fa1d38e37ab10534b3f18422e0149ad0deca /engine/overworld | |
parent | c480632d5494d04f7f5f0298a31877a2293b564e (diff) |
Specify the ldh instruction, don't turn ld into ldh
Diffstat (limited to 'engine/overworld')
-rwxr-xr-x | engine/overworld/auto_movement.asm | 6 | ||||
-rw-r--r-- | engine/overworld/clear_variables.asm | 12 | ||||
-rwxr-xr-x | engine/overworld/cut.asm | 8 | ||||
-rwxr-xr-x | engine/overworld/cut2.asm | 8 | ||||
-rwxr-xr-x | engine/overworld/dust_smoke.asm | 6 | ||||
-rwxr-xr-x | engine/overworld/elevator.asm | 6 | ||||
-rwxr-xr-x | engine/overworld/healing_machine.asm | 10 | ||||
-rwxr-xr-x | engine/overworld/hidden_objects.asm | 6 | ||||
-rwxr-xr-x | engine/overworld/ledges.asm | 2 | ||||
-rwxr-xr-x | engine/overworld/map_sprites.asm | 14 | ||||
-rw-r--r-- | engine/overworld/missable_objects.asm | 16 | ||||
-rw-r--r-- | engine/overworld/movement.asm | 104 | ||||
-rw-r--r-- | engine/overworld/pathfinding.asm | 60 | ||||
-rwxr-xr-x | engine/overworld/player_animations.asm | 6 | ||||
-rw-r--r-- | engine/overworld/player_state.asm | 26 | ||||
-rw-r--r-- | engine/overworld/push_boulder.asm | 12 | ||||
-rw-r--r-- | engine/overworld/special_warps.asm | 4 | ||||
-rw-r--r-- | engine/overworld/sprite_collisions.asm | 50 | ||||
-rw-r--r-- | engine/overworld/tilesets.asm | 6 | ||||
-rwxr-xr-x | engine/overworld/trainer_sight.asm | 28 | ||||
-rwxr-xr-x | engine/overworld/turn_sprite.asm | 6 | ||||
-rw-r--r-- | engine/overworld/update_map.asm | 24 |
22 files changed, 210 insertions, 210 deletions
diff --git a/engine/overworld/auto_movement.asm b/engine/overworld/auto_movement.asm index 5e70ab8c..9a717641 100755 --- a/engine/overworld/auto_movement.asm +++ b/engine/overworld/auto_movement.asm @@ -66,7 +66,7 @@ PalletMovementScript_OakMoveLeft: call FillMemory ld [hl], $ff ld a, [wSpriteIndex] - ld [hSpriteIndex], a + ldh [hSpriteIndex], a ld de, wNPCMovementDirections2 call MoveSprite ld a, $1 @@ -91,7 +91,7 @@ PalletMovementScript_PlayerMoveLeft: ret nz ; return if Oak is still moving ld a, [wNumStepsToTake] ld [wSimulatedJoypadStatesIndex], a - ld [hNPCMovementDirections2Index], a + ldh [hNPCMovementDirections2Index], a predef ConvertNPCMovementDirectionsToJoypadMasks call StartSimulatingJoypadStates ld a, $2 @@ -282,7 +282,7 @@ FreezeEnemyTrainerSprite:: jr .loop .notRival ld a, [wSpriteIndex] - ld [hSpriteIndex], a + ldh [hSpriteIndex], a jp SetSpriteMovementBytesToFF RivalIDs: diff --git a/engine/overworld/clear_variables.asm b/engine/overworld/clear_variables.asm index 9b735495..bbb7c986 100644 --- a/engine/overworld/clear_variables.asm +++ b/engine/overworld/clear_variables.asm @@ -1,14 +1,14 @@ ClearVariablesOnEnterMap:: ld a, SCREEN_HEIGHT_PX - ld [hWY], a - ld [rWY], a + ldh [hWY], a + ldh [rWY], a xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ld [wStepCounter], a ld [wLoneAttackNo], a - ld [hJoyPressed], a - ld [hJoyReleased], a - ld [hJoyHeld], a + ldh [hJoyPressed], a + ldh [hJoyReleased], a + ldh [hJoyHeld], a ld [wActionResultOrTookBattleTurn], a ld [wUnusedD5A3], a ld hl, wCardKeyDoorY diff --git a/engine/overworld/cut.asm b/engine/overworld/cut.asm index f99bf323..fc5fb578 100755 --- a/engine/overworld/cut.asm +++ b/engine/overworld/cut.asm @@ -38,14 +38,14 @@ UsedCut: call ClearSprites call RestoreScreenTilesAndReloadTilePatterns ld a, SCREEN_HEIGHT_PX - ld [hWY], a + ldh [hWY], a call Delay3 call LoadGBPal call LoadCurrentMapView call SaveScreenTilesToBuffer2 call Delay3 xor a - ld [hWY], a + ldh [hWY], a ld hl, UsedCutText call PrintText call LoadScreenTilesFromBuffer2 @@ -63,7 +63,7 @@ UsedCut: ld a, SFX_CUT call PlaySound ld a, $90 - ld [hWY], a + ldh [hWY], a call UpdateSprites jp RedrawMapView @@ -75,7 +75,7 @@ InitCutAnimOAM: xor a ld [wWhichAnimationOffsets], a ld a, %11100100 - ld [rOBP1], a + ldh [rOBP1], a ld a, [wCutTile] cp $52 jr z, .grass diff --git a/engine/overworld/cut2.asm b/engine/overworld/cut2.asm index f16fed66..3d4a5905 100755 --- a/engine/overworld/cut2.asm +++ b/engine/overworld/cut2.asm @@ -15,9 +15,9 @@ AnimCut: ld [wCoordAdjustmentAmount], a ld c, 2 call AdjustOAMBlockXPos2 - ld a, [rOBP1] + ldh a, [rOBP1] xor $64 - ld [rOBP1], a + ldh [rOBP1], a call DelayFrame pop bc dec c @@ -65,9 +65,9 @@ AnimCutGrass_UpdateOAMEntries: ld [wCoordAdjustmentAmount], a ld c, 1 call AdjustOAMBlockXPos2 - ld a, [rOBP1] + ldh a, [rOBP1] xor $64 - ld [rOBP1], a + ldh [rOBP1], a call DelayFrame pop bc dec c diff --git a/engine/overworld/dust_smoke.asm b/engine/overworld/dust_smoke.asm index 2dc6882e..3d87e25a 100755 --- a/engine/overworld/dust_smoke.asm +++ b/engine/overworld/dust_smoke.asm @@ -6,7 +6,7 @@ AnimateBoulderDust: ld a, $ff ld [wUpdateSpritesEnabled], a ld a, %11100100 - ld [rOBP1], a + ldh [rOBP1], a call LoadSmokeTileFourTimes callba WriteCutOrBoulderDustAnimationOAMBlock ld c, 8 ; number of steps in animation @@ -18,9 +18,9 @@ AnimateBoulderDust: ld c, 4 jp hl .returnAddress - ld a, [rOBP1] + ldh a, [rOBP1] xor %01100100 - ld [rOBP1], a + ldh [rOBP1], a call Delay3 pop bc dec c diff --git a/engine/overworld/elevator.asm b/engine/overworld/elevator.asm index 05ca08c9..7a6aca85 100755 --- a/engine/overworld/elevator.asm +++ b/engine/overworld/elevator.asm @@ -6,7 +6,7 @@ ShakeElevator:: call Delay3 ld a, SFX_STOP_ALL_MUSIC call PlaySound - ld a, [hSCY] + ldh a, [hSCY] ld d, a ld e, $1 ld b, 100 @@ -15,7 +15,7 @@ ShakeElevator:: xor $fe ld e, a add d - ld [hSCY], a + ldh [hSCY], a push bc ld c, BANK(SFX_Collision_1) ld a, SFX_COLLISION @@ -26,7 +26,7 @@ ShakeElevator:: dec b jr nz, .shakeLoop ld a, d - ld [hSCY], a + ldh [hSCY], a ld a, SFX_STOP_ALL_MUSIC call PlaySound ld c, BANK(SFX_Safari_Zone_PA) diff --git a/engine/overworld/healing_machine.asm b/engine/overworld/healing_machine.asm index a09a7590..062ef7ea 100755 --- a/engine/overworld/healing_machine.asm +++ b/engine/overworld/healing_machine.asm @@ -8,10 +8,10 @@ AnimateHealingMachine: push af ld [hl], $ff push hl - ld a, [rOBP1] + ldh a, [rOBP1] push af ld a, $e0 - ld [rOBP1], a + ldh [rOBP1], a ld hl, wOAMBuffer + $84 ld de, PokeCenterOAMData call CopyHealingMachineOAM @@ -56,7 +56,7 @@ AnimateHealingMachine: ld c, 32 call DelayFrames pop af - ld [rOBP1], a + ldh [rOBP1], a pop hl pop af ld [hl], a @@ -78,9 +78,9 @@ PokeCenterOAMData: FlashSprite8Times: ld b, 8 .loop - ld a, [rOBP1] + ldh a, [rOBP1] xor d - ld [rOBP1], a + ldh [rOBP1], a ld c, 10 call DelayFrames dec b diff --git a/engine/overworld/hidden_objects.asm b/engine/overworld/hidden_objects.asm index 5ce7f3cb..855328e7 100755 --- a/engine/overworld/hidden_objects.asm +++ b/engine/overworld/hidden_objects.asm @@ -58,7 +58,7 @@ CheckForHiddenObject:: ld [wHiddenObjectX], a ld c, a call CheckIfCoordsInFrontOfPlayerMatch - ld a, [hCoordsInFrontOfPlayerMatch] + ldh a, [hCoordsInFrontOfPlayerMatch] and a jr z, .foundMatchingObject inc hl @@ -81,7 +81,7 @@ CheckForHiddenObject:: ret .noMatch ld a, $ff - ld [hDidntFindAnyHiddenObject], a + ldh [hDidntFindAnyHiddenObject], a ret ; checks if the coordinates in front of the player's sprite match Y in b and X in c @@ -127,7 +127,7 @@ CheckIfCoordsInFrontOfPlayerMatch: .didNotMatch ld a, $ff .done - ld [hCoordsInFrontOfPlayerMatch], a + ldh [hCoordsInFrontOfPlayerMatch], a ret INCLUDE "data/events/hidden_objects.asm" diff --git a/engine/overworld/ledges.asm b/engine/overworld/ledges.asm index 0f135fb6..cba544f6 100755 --- a/engine/overworld/ledges.asm +++ b/engine/overworld/ledges.asm @@ -36,7 +36,7 @@ HandleLedges:: inc hl jr .loop .foundMatch - ld a, [hJoyHeld] + ldh a, [hJoyHeld] and e ret z ld a, $ff diff --git a/engine/overworld/map_sprites.asm b/engine/overworld/map_sprites.asm index 0de1befd..26a8f1bb 100755 --- a/engine/overworld/map_sprites.asm +++ b/engine/overworld/map_sprites.asm @@ -39,7 +39,7 @@ LoadMapSpriteTilePatterns: ld b, $10 ; number of sprite slots ld hl, wSpritePlayerStateData2PictureID xor a - ld [hFourTileSpriteCount], a + ldh [hFourTileSpriteCount], a .copyPictureIDLoop ; loop to copy picture ID from $C2XD to $C2XE ld a, [hli] ; $C2XD (sprite picture ID) ld [hld], a ; $C2XE @@ -98,14 +98,14 @@ LoadMapSpriteTilePatterns: cp SPRITE_BALL ; is it a 4-tile sprite? jr c, .notFourTileSprite pop af - ld a, [hFourTileSpriteCount] + ldh a, [hFourTileSpriteCount] add 11 jr .storeVRAMSlot .notFourTileSprite pop af .storeVRAMSlot ld [hl], a ; store VRAM slot at $C2XE - ld [hVRAMSlot], a ; used to determine if it's 4-tile sprite later + ldh [hVRAMSlot], a ; used to determine if it's 4-tile sprite later ld a, b ; a = current sprite picture ID dec a add a @@ -128,7 +128,7 @@ LoadMapSpriteTilePatterns: push bc ld hl, vNPCSprites ; VRAM base address ld bc, $c0 ; number of bytes per VRAM slot - ld a, [hVRAMSlot] + ldh a, [hVRAMSlot] cp 11 ; is it a 4-tile sprite? jr nc, .fourTileSpriteVRAMAddr ld d, a @@ -141,13 +141,13 @@ LoadMapSpriteTilePatterns: jr .loadStillTilePattern .fourTileSpriteVRAMAddr ld hl, vSprites + $7c0 ; address for second 4-tile sprite - ld a, [hFourTileSpriteCount] + ldh a, [hFourTileSpriteCount] and a jr nz, .loadStillTilePattern ; if it's the first 4-tile sprite ld hl, vSprites + $780 ; address for first 4-tile sprite inc a - ld [hFourTileSpriteCount], a + ldh [hFourTileSpriteCount], a .loadStillTilePattern pop bc pop de @@ -167,7 +167,7 @@ LoadMapSpriteTilePatterns: .skipFirstLoad pop de pop hl - ld a, [hVRAMSlot] + ldh a, [hVRAMSlot] cp 11 ; is it a 4-tile sprite? jr nc, .skipSecondLoad ; if so, there is no second block push de diff --git a/engine/overworld/missable_objects.asm b/engine/overworld/missable_objects.asm index 1ebe8064..fd2fe578 100644 --- a/engine/overworld/missable_objects.asm +++ b/engine/overworld/missable_objects.asm @@ -31,19 +31,19 @@ LoadMissableObjects: sub d ld h, a ld a, h - ld [hDividend], a + ldh [hDividend], a ld a, l - ld [hDividend+1], a + ldh [hDividend+1], a xor a - ld [hDividend+2], a - ld [hDividend+3], a + ldh [hDividend+2], a + ldh [hDividend+3], a ld a, $3 - ld [hDivisor], a + ldh [hDivisor], a ld b, $2 call Divide ; divide difference by 3, resulting in the global offset (number of missable items before ours) ld a, [wCurMap] ld b, a - ld a, [hDividend+3] + ldh a, [hDividend+3] ld c, a ; store global offset in c ld de, wMissableObjectList pop hl @@ -99,7 +99,7 @@ InitializeMissableObjectsFlags: ; tests if current sprite is a missable object that is hidden/has been removed IsObjectHidden: - ld a, [hCurrentSpriteOffset] + ldh a, [hCurrentSpriteOffset] swap a ld b, a ld hl, wMissableObjectList @@ -120,7 +120,7 @@ IsObjectHidden: .notHidden xor a .hidden - ld [hIsHiddenMissableObject], a + ldh [hIsHiddenMissableObject], a ret ; adds missable object (items, leg. pokemon, etc.) to the map diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm index d27ccb4b..ac7e1b46 100644 --- a/engine/overworld/movement.asm +++ b/engine/overworld/movement.asm @@ -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 diff --git a/engine/overworld/pathfinding.asm b/engine/overworld/pathfinding.asm index 7251759c..54cb86b9 100644 --- a/engine/overworld/pathfinding.asm +++ b/engine/overworld/pathfinding.asm @@ -8,29 +8,29 @@ FindPathToPlayer: ld hl, wNPCMovementDirections2 ld de, $0 .loop - ld a, [hFindPathYProgress] + ldh a, [hFindPathYProgress] ld b, a - ld a, [hNPCPlayerYDistance] ; Y distance in steps + ldh a, [hNPCPlayerYDistance] ; Y distance in steps call CalcDifference ld d, a and a jr nz, .asm_f8da - ld a, [hFindPathFlags] + ldh a, [hFindPathFlags] set 0, a ; current end of path matches the player's Y coordinate - ld [hFindPathFlags], a + ldh [hFindPathFlags], a .asm_f8da - ld a, [hFindPathXProgress] + ldh a, [hFindPathXProgress] ld b, a - ld a, [hNPCPlayerXDistance] ; X distance in steps + ldh a, [hNPCPlayerXDistance] ; X distance in steps call CalcDifference ld e, a and a jr nz, .asm_f8ec - ld a, [hFindPathFlags] + ldh a, [hFindPathFlags] set 1, a ; current end of path matches the player's X coordinate - ld [hFindPathFlags], a + ldh [hFindPathFlags], a .asm_f8ec - ld a, [hFindPathFlags] + ldh a, [hFindPathFlags] cp $3 ; has the end of the path reached the player's position? jr z, .done ; Compare whether the X distance between the player and the current of the path @@ -39,7 +39,7 @@ FindPathToPlayer: cp d jr c, .yDistanceGreater ; x distance is greater - ld a, [hNPCPlayerRelativePosFlags] + ldh a, [hNPCPlayerRelativePosFlags] bit 1, a jr nz, .playerIsLeftOfNPC ld d, NPC_MOVEMENT_RIGHT @@ -47,12 +47,12 @@ FindPathToPlayer: .playerIsLeftOfNPC ld d, NPC_MOVEMENT_LEFT .next1 - ld a, [hFindPathXProgress] + ldh a, [hFindPathXProgress] add 1 - ld [hFindPathXProgress], a + ldh [hFindPathXProgress], a jr .storeDirection .yDistanceGreater - ld a, [hNPCPlayerRelativePosFlags] + ldh a, [hNPCPlayerRelativePosFlags] bit 0, a jr nz, .playerIsAboveNPC ld d, NPC_MOVEMENT_DOWN @@ -60,15 +60,15 @@ FindPathToPlayer: .playerIsAboveNPC ld d, NPC_MOVEMENT_UP .next2 - ld a, [hFindPathYProgress] + ldh a, [hFindPathYProgress] add 1 - ld [hFindPathYProgress], a + ldh [hFindPathYProgress], a .storeDirection ld a, d ld [hli], a - ld a, [hFindPathNumSteps] + ldh a, [hFindPathNumSteps] inc a - ld [hFindPathNumSteps], a + ldh [hFindPathNumSteps], a jp .loop .done ld [hl], $ff @@ -76,13 +76,13 @@ FindPathToPlayer: CalcPositionOfPlayerRelativeToNPC: xor a - ld [hNPCPlayerRelativePosFlags], a + ldh [hNPCPlayerRelativePosFlags], a ld a, [wSpritePlayerStateData1YPixels] ld d, a ld a, [wSpritePlayerStateData1XPixels] ld e, a ld hl, wSpriteStateData1 - ld a, [hNPCSpriteOffset] + ldh a, [hNPCSpriteOffset] add l add wSpritePlayerStateData1YPixels - wSpritePlayerStateData1 ld l, a @@ -115,7 +115,7 @@ CalcPositionOfPlayerRelativeToNPC: ld [hli], a call DivideBytes ; divide Y absolute distance by 16 ld a, [hl] ; quotient - ld [hNPCPlayerYDistance], a + ldh [hNPCPlayerYDistance], a pop hl inc hl ld b, e @@ -136,23 +136,23 @@ CalcPositionOfPlayerRelativeToNPC: res 1, [hl] pop hl .divideXDistance - ld [hDividend2], a + ldh [hDividend2], a ld a, 16 - ld [hDivisor2], a + ldh [hDivisor2], a call DivideBytes ; divide X absolute distance by 16 - ld a, [hQuotient2] - ld [hNPCPlayerXDistance], a - ld a, [hNPCPlayerRelativePosPerspective] + ldh a, [hQuotient2] + ldh [hNPCPlayerXDistance], a + ldh a, [hNPCPlayerRelativePosPerspective] and a ret z - ld a, [hNPCPlayerRelativePosFlags] + ldh a, [hNPCPlayerRelativePosFlags] cpl and $3 - ld [hNPCPlayerRelativePosFlags], a + ldh [hNPCPlayerRelativePosFlags], a ret ConvertNPCMovementDirectionsToJoypadMasks: - ld a, [hNPCMovementDirections2Index] + ldh a, [hNPCMovementDirections2Index] ld [wNPCMovementDirections2Index], a dec a ld de, wSimulatedJoypadStatesEnd @@ -166,9 +166,9 @@ ConvertNPCMovementDirectionsToJoypadMasks: call ConvertNPCMovementDirectionToJoypadMask ld [de], a inc de - ld a, [hNPCMovementDirections2Index] + ldh a, [hNPCMovementDirections2Index] dec a - ld [hNPCMovementDirections2Index], a + ldh [hNPCMovementDirections2Index], a jr nz, .loop ret diff --git a/engine/overworld/player_animations.asm b/engine/overworld/player_animations.asm index cfd6cc8d..fec10daf 100755 --- a/engine/overworld/player_animations.asm +++ b/engine/overworld/player_animations.asm @@ -516,9 +516,9 @@ _HandleMidJump:: call UpdateSprites call Delay3 xor a - ld [hJoyHeld], a - ld [hJoyPressed], a - ld [hJoyReleased], a + ldh [hJoyHeld], a + ldh [hJoyPressed], a + ldh [hJoyReleased], a ld [wPlayerJumpingYScreenCoordsIndex], a ld hl, wd736 res 6, [hl] ; not jumping down a ledge any more diff --git a/engine/overworld/player_state.asm b/engine/overworld/player_state.asm index 9ff67df8..f2e74683 100644 --- a/engine/overworld/player_state.asm +++ b/engine/overworld/player_state.asm @@ -17,7 +17,7 @@ IsPlayerStandingOnWarp:: ld a, [hli] ; target warp ld [wDestinationWarpID], a ld a, [hl] ; target map - ld [hWarpDestinationMap], a + ldh [hWarpDestinationMap], a ld hl, wd736 set 2, [hl] ; standing on warp flag ret @@ -297,7 +297,7 @@ _GetTileAndCoordsInFrontOfPlayer: GetTileTwoStepsInFrontOfPlayer: xor a - ld [hPlayerFacing], a + ldh [hPlayerFacing], a ld hl, wYCoord ld a, [hli] ld d, a @@ -378,33 +378,33 @@ CheckForBoulderCollisionWithSprites: ld hl, wSprite01StateData2MapY add hl, de ld a, [hli] ; map Y position - ld [hPlayerYCoord], a + ldh [hPlayerYCoord], a ld a, [hl] ; map X position - ld [hPlayerXCoord], a + ldh [hPlayerXCoord], a ld a, [wNumSprites] ld c, a ld de, $f ld hl, wSprite01StateData2MapY - ld a, [hPlayerFacing] + ldh a, [hPlayerFacing] and $3 ; facing up or down? jr z, .pushingHorizontallyLoop .pushingVerticallyLoop inc hl - ld a, [hPlayerXCoord] + ldh a, [hPlayerXCoord] cp [hl] jr nz, .nextSprite1 ; if X coordinates don't match dec hl ld a, [hli] ld b, a - ld a, [hPlayerFacing] + ldh a, [hPlayerFacing] rrca jr c, .pushingDown ; pushing up - ld a, [hPlayerYCoord] + ldh a, [hPlayerYCoord] dec a jr .compareYCoords .pushingDown - ld a, [hPlayerYCoord] + ldh a, [hPlayerYCoord] inc a .compareYCoords cp b @@ -417,19 +417,19 @@ CheckForBoulderCollisionWithSprites: .pushingHorizontallyLoop ld a, [hli] ld b, a - ld a, [hPlayerYCoord] + ldh a, [hPlayerYCoord] cp b jr nz, .nextSprite2 ld b, [hl] - ld a, [hPlayerFacing] + ldh a, [hPlayerFacing] bit 2, a jr nz, .pushingLeft ; pushing right - ld a, [hPlayerXCoord] + ldh a, [hPlayerXCoord] inc a jr .compareXCoords .pushingLeft - ld a, [hPlayerXCoord] + ldh a, [hPlayerXCoord] dec a .compareXCoords cp b diff --git a/engine/overworld/push_boulder.asm b/engine/overworld/push_boulder.asm index da1c6dee..fb4d06aa 100644 --- a/engine/overworld/push_boulder.asm +++ b/engine/overworld/push_boulder.asm @@ -6,15 +6,15 @@ TryPushingBoulder:: bit 1, a ; has boulder dust animation from previous push played yet? ret nz xor a - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call IsSpriteInFrontOfPlayer - ld a, [hSpriteIndexOrTextID] + ldh a, [hSpriteIndexOrTextID] ld [wBoulderSpriteIndex], a and a jp z, ResetBoulderPushFlags ld hl, wSpritePlayerStateData1MovementStatus ld d, $0 - ld a, [hSpriteIndexOrTextID] + ldh a, [hSpriteIndexOrTextID] swap a ld e, a add hl, de @@ -27,14 +27,14 @@ TryPushingBoulder:: bit 6, [hl] set 6, [hl] ; indicate that the player has tried pushing ret z ; the player must try pushing twice before the boulder will move - ld a, [hJoyHeld] + ldh a, [hJoyHeld] and D_RIGHT | D_LEFT | D_UP | D_DOWN ret z predef CheckForCollisionWhenPushingBoulder ld a, [wTileInFrontOfBoulderAndBoulderCollisionResult] and a ; was there a collision? jp nz, ResetBoulderPushFlags - ld a, [hJoyHeld] + ldh a, [hJoyHeld] ld b, a ld a, [wSpritePlayerStateData1FacingDirection] cp SPRITE_FACING_UP @@ -92,7 +92,7 @@ DoBoulderDustAnimation:: call ResetBoulderPushFlags set 7, [hl] ld a, [wBoulderSpriteIndex] - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call GetSpriteMovementByte2Pointer ld [hl], $10 ld a, SFX_CUT diff --git a/engine/overworld/special_warps.asm b/engine/overworld/special_warps.asm index 042146f9..54471ee0 100644 --- a/engine/overworld/special_warps.asm +++ b/engine/overworld/special_warps.asm @@ -34,7 +34,7 @@ LoadSpecialWarpData: cp TRADE_CENTER jr nz, .notTradeCenter ld hl, TradeCenterSpec1 - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK ; which gameboy is clocking determines who is on the left and who is on the right jr z, .copyWarpData ld hl, TradeCenterSpec2 @@ -43,7 +43,7 @@ LoadSpecialWarpData: cp COLOSSEUM jr nz, .notColosseum ld hl, ColosseumSpec1 - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK jr z, .copyWarpData ld hl, ColosseumSpec2 diff --git a/engine/overworld/sprite_collisions.asm b/engine/overworld/sprite_collisions.asm index 48cd95b9..e6c415ab 100644 --- a/engine/overworld/sprite_collisions.asm +++ b/engine/overworld/sprite_collisions.asm @@ -6,7 +6,7 @@ _UpdateSprites:: ld l, a sub wSpritePlayerStateData2ImageBaseOffset - wSpritePlayerStateData2 ld c, a - ld [hCurrentSpriteOffset], a + ldh [hCurrentSpriteOffset], a ld a, [hl] and a jr z, .skipSprite ; tests $c2Xe @@ -31,10 +31,10 @@ _UpdateSprites:: UpdateNonPlayerSprite: dec a swap a - ld [hTilePlayerStandingOn], a ; $10 * sprite# + ldh [hTilePlayerStandingOn], a ; $10 * sprite# ld a, [wNPCMovementScriptSpriteOffset] ; some sprite offset? ld b, a - ld a, [hCurrentSpriteOffset] + ldh a, [hCurrentSpriteOffset] cp b jr nz, .unequal jp DoScriptedNPCMovement @@ -54,7 +54,7 @@ DetectCollisionBetweenSprites: nop ld h, wSpriteStateData1 / $100 - ld a, [hCurrentSpriteOffset] + ldh a, [hCurrentSpriteOffset] add wSpriteStateData1 % $100 ld l, a @@ -79,7 +79,7 @@ DetectCollisionBetweenSprites: and $f0 or c - ld [hFF90], a ; store Y coordinate adjusted for direction of movement + ldh [hFF90], a ; store Y coordinate adjusted for direction of movement ld a, [hli] ; a = [$c1i5] (delta X) (-1, 0, or 1) call SetSpriteCollisionValues @@ -92,7 +92,7 @@ DetectCollisionBetweenSprites: and $f0 or c - ld [hFF91], a ; store X coordinate adjusted for direction of movement + ldh [hFF91], a ; store X coordinate adjusted for direction of movement ld a, l add 7 @@ -102,18 +102,18 @@ DetectCollisionBetweenSprites: ld [hld], a ; zero [$c1id] XXX what's [$c1id] for? ld [hld], a ; zero [$c1ic] (directions in which collisions occurred) - ld a, [hFF91] + ldh a, [hFF91] ld [hld], a ; [$c1ib] = adjusted X coordinate - ld a, [hFF90] + ldh a, [hFF90] ld [hl], a ; [$c1ia] = adjusted Y coordinate xor a ; zero the loop counter .loop - ld [hFF8F], a ; store loop counter + ldh [hFF8F], a ; store loop counter swap a ld e, a - ld a, [hCurrentSpriteOffset] + ldh a, [hCurrentSpriteOffset] cp e ; does the loop sprite match the current sprite? jp z, .next ; go to the next sprite if they match @@ -128,7 +128,7 @@ DetectCollisionBetweenSprites: inc a jp z, .next ; go the next sprite if offscreen - ld a, [hCurrentSpriteOffset] + ldh a, [hCurrentSpriteOffset] add 10 ld l, a @@ -154,7 +154,7 @@ DetectCollisionBetweenSprites: cpl inc a .noCarry1 - ld [hFF90], a ; store the distance between the two sprites' adjusted Y values + ldh [hFF90], a ; store the distance between the two sprites' adjusted Y values ; Use the carry flag set by the above subtraction to determine which sprite's ; Y coordinate is larger. This information is used later to set [$c1ic], @@ -176,11 +176,11 @@ DetectCollisionBetweenSprites: ld b, 9 .next1 - ld a, [hFF90] ; a = distance between adjusted Y coordinates + ldh a, [hFF90] ; a = distance between adjusted Y coordinates sub b - ld [hFF92], a ; store distance adjusted using sprite i's direction + ldh [hFF92], a ; store distance adjusted using sprite i's direction ld a, b - ld [hFF90], a ; store 7 or 9 depending on sprite i's delta Y + ldh [hFF90], a ; store 7 or 9 depending on sprite i's delta Y jr c, .checkXDistance ; If sprite j's delta Y is 0, then b = 7, else b = 9. @@ -193,7 +193,7 @@ DetectCollisionBetweenSprites: ld b, 9 .next2 - ld a, [hFF92] ; a = distance adjusted using sprite i's direction + ldh a, [hFF92] ; a = distance adjusted using sprite i's direction sub b ; adjust distance using sprite j's direction jr z, .checkXDistance jr nc, .next ; go to next sprite if distance is still positive after both adjustments @@ -225,7 +225,7 @@ DetectCollisionBetweenSprites: cpl inc a .noCarry2 - ld [hFF91], a ; store the distance between the two sprites' adjusted X values + ldh [hFF91], a ; store the distance between the two sprites' adjusted X values ; Use the carry flag set by the above subtraction to determine which sprite's ; X coordinate is larger. This information is used later to set [$c1ic], @@ -247,11 +247,11 @@ DetectCollisionBetweenSprites: ld b, 9 .next3 - ld a, [hFF91] ; a = distance between adjusted X coordinates + ldh a, [hFF91] ; a = distance between adjusted X coordinates sub b - ld [hFF92], a ; store distance adjusted using sprite i's direction + ldh [hFF92], a ; store distance adjusted using sprite i's direction ld a, b - ld [hFF91], a ; store 7 or 9 depending on sprite i's delta X + ldh [hFF91], a ; store 7 or 9 depending on sprite i's delta X jr c, .collision ; If sprite j's delta X is 0, then b = 7, else b = 9. @@ -264,15 +264,15 @@ DetectCollisionBetweenSprites: ld b, 9 .next4 - ld a, [hFF92] ; a = distance adjusted using sprite i's direction + ldh a, [hFF92] ; a = distance adjusted using sprite i's direction sub b ; adjust distance using sprite j's direction jr z, .collision jr nc, .next ; go to next sprite if distance is still positive after both adjustments .collision - ld a, [hFF91] ; a = 7 or 9 depending on sprite i's delta X + ldh a, [hFF91] ; a = 7 or 9 depending on sprite i's delta X ld b, a - ld a, [hFF90] ; a = 7 or 9 depending on sprite i's delta Y + ldh a, [hFF90] ; a = 7 or 9 depending on sprite i's delta Y inc l ; If delta X isn't 0 and delta Y is 0, then b = %0011, else b = %1100. @@ -294,7 +294,7 @@ DetectCollisionBetweenSprites: ; set bit in [$c1ie] or [$c1if] to indicate which sprite the collision occurred with inc l inc l - ld a, [hFF8F] ; a = loop counter + ldh a, [hFF8F] ; a = loop counter ld de, SpriteCollisionBitTable add a add e @@ -311,7 +311,7 @@ DetectCollisionBetweenSprites: ld [hl], a .next - ld a, [hFF8F] ; a = loop counter + ldh a, [hFF8F] ; a = loop counter inc a cp $10 jp nz, .loop diff --git a/engine/overworld/tilesets.asm b/engine/overworld/tilesets.asm index 88147233..f40cbbc2 100644 --- a/engine/overworld/tilesets.asm +++ b/engine/overworld/tilesets.asm @@ -23,9 +23,9 @@ LoadTilesetHeader: dec c jr nz, .copyTilesetHeaderLoop ld a, [hl] - ld [hTilesetType], a + ldh [hTilesetType], a xor a - ld [hMovingBGTilesCounter1], a + ldh [hMovingBGTilesCounter1], a pop hl ld a, [wCurMapTileset] push hl @@ -38,7 +38,7 @@ LoadTilesetHeader: jr c, .asm_c797 ld a, [wCurMapTileset] ld b, a - ld a, [hPreviousTileset] + ldh a, [hPreviousTileset] cp b jr z, .done .asm_c797 diff --git a/engine/overworld/trainer_sight.asm b/engine/overworld/trainer_sight.asm index c12c064b..5046f5f6 100755 --- a/engine/overworld/trainer_sight.asm +++ b/engine/overworld/trainer_sight.asm @@ -2,26 +2,26 @@ _GetSpritePosition1:: ld hl, wSpriteStateData1 ld de, wSpritePlayerStateData1YPixels - wSpritePlayerStateData1 ld a, [wSpriteIndex] - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call GetSpriteDataPointer ld a, [hli] ; c1x4 (screen Y pos) - ld [hSpriteScreenYCoord], a + ldh [hSpriteScreenYCoord], a inc hl ld a, [hl] ; c1x6 (screen X pos) - ld [hSpriteScreenXCoord], a + ldh [hSpriteScreenXCoord], a ld de, wSpritePlayerStateData2MapY - wSpritePlayerStateData1XPixels add hl, de ld a, [hli] ; c2x4 (map Y pos) - ld [hSpriteMapYCoord], a + ldh [hSpriteMapYCoord], a ld a, [hl] ; c2x5 (map X pos) - ld [hSpriteMapXCoord], a + ldh [hSpriteMapXCoord], a ret _GetSpritePosition2:: ld hl, wSpriteStateData1 ld de, wSpritePlayerStateData1YPixels - wSpritePlayerStateData1 ld a, [wSpriteIndex] - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call GetSpriteDataPointer ld a, [hli] ; c1x4 (screen Y pos) ld [wSavedSpriteScreenY], a @@ -40,18 +40,18 @@ _SetSpritePosition1:: ld hl, wSpriteStateData1 ld de, wSpritePlayerStateData1YPixels - wSpritePlayerStateData1 ld a, [wSpriteIndex] - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call GetSpriteDataPointer - ld a, [hSpriteScreenYCoord] ; c1x4 (screen Y pos) + ldh a, [hSpriteScreenYCoord] ; c1x4 (screen Y pos) ld [hli], a inc hl - ld a, [hSpriteScreenXCoord] ; c1x6 (screen X pos) + ldh a, [hSpriteScreenXCoord] ; c1x6 (screen X pos) ld [hl], a ld de, wSpritePlayerStateData2MapY - wSpritePlayerStateData1XPixels add hl, de - ld a, [hSpriteMapYCoord] ; c2x4 (map Y pos) + ldh a, [hSpriteMapYCoord] ; c2x4 (map Y pos) ld [hli], a - ld a, [hSpriteMapXCoord] ; c2x5 (map X pos) + ldh a, [hSpriteMapXCoord] ; c2x5 (map X pos) ld [hl], a ret @@ -59,7 +59,7 @@ _SetSpritePosition2:: ld hl, wSpriteStateData1 ld de, wSpritePlayerStateData1YPixels - wSpritePlayerStateData1 ld a, [wSpriteIndex] - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call GetSpriteDataPointer ld a, [wSavedSpriteScreenY] ld [hli], a ; c1x4 (screen Y pos) @@ -144,7 +144,7 @@ TrainerWalkUpToPlayer:: call FillMemory ; write the necessary steps to reach player ld [hl], $ff ; write end of list sentinel ld a, [wSpriteIndex] - ld [hSpriteIndex], a + ldh [hSpriteIndex], a jp MoveSprite_ ; input: de = offset within sprite entry @@ -152,7 +152,7 @@ TrainerWalkUpToPlayer:: GetSpriteDataPointer: push de add hl, de - ld a, [hSpriteIndex] + ldh a, [hSpriteIndex] swap a ld d, $0 ld e, a diff --git a/engine/overworld/turn_sprite.asm b/engine/overworld/turn_sprite.asm index bef26537..4ff58239 100755 --- a/engine/overworld/turn_sprite.asm +++ b/engine/overworld/turn_sprite.asm @@ -1,12 +1,12 @@ UpdateSpriteFacingOffsetAndDelayMovement:: ld h, $c2 - ld a, [hCurrentSpriteOffset] + ldh a, [hCurrentSpriteOffset] add $8 ld l, a ld a, $7f ; maximum movement delay ld [hl], a ; c2x8 (movement delay) dec h - ld a, [hCurrentSpriteOffset] + ldh a, [hCurrentSpriteOffset] add $9 ld l, a ld a, [hld] ; c1x9 (facing direction) @@ -14,7 +14,7 @@ UpdateSpriteFacingOffsetAndDelayMovement:: xor a ld [hld], a ld [hl], a ; c1x8 (walk animation frame) - ld a, [hCurrentSpriteOffset] + ldh a, [hCurrentSpriteOffset] add $2 ld l, a ld a, [hl] ; c1x2 (facing and animation table offset) diff --git a/engine/overworld/update_map.asm b/engine/overworld/update_map.asm index 92ae2b10..53a5592d 100644 --- a/engine/overworld/update_map.asm +++ b/engine/overworld/update_map.asm @@ -50,13 +50,13 @@ RedrawMapView: ld a, [wIsInBattle] inc a ret z - ld a, [hAutoBGTransferEnabled] + ldh a, [hAutoBGTransferEnabled] push af - ld a, [hTilesetType] + ldh a, [hTilesetType] push af xor a - ld [hAutoBGTransferEnabled], a - ld [hTilesetType], a ; no flower/water BG tile animations + ldh [hAutoBGTransferEnabled], a + ldh [hTilesetType], a ; no flower/water BG tile animations call LoadCurrentMapView call RunDefaultPaletteCommand ld hl, wMapViewVRAMPointer @@ -73,7 +73,7 @@ RedrawMapView: ld a, h ld [wBuffer + 1], a ; this copy of the address is not used ld a, 2 - ld [hRedrawMapViewRowOffset], a + ldh [hRedrawMapViewRowOffset], a ld c, SCREEN_HEIGHT / 2 ; number of rows of 2x2 tiles (this covers the whole screen) .redrawRowLoop push bc @@ -81,7 +81,7 @@ RedrawMapView: push hl ld hl, wTileMap - 2 * SCREEN_WIDTH ld de, SCREEN_WIDTH - ld a, [hRedrawMapViewRowOffset] + ldh a, [hRedrawMapViewRowOffset] .calcWRAMAddrLoop add hl, de dec a @@ -89,7 +89,7 @@ RedrawMapView: call CopyToRedrawRowOrColumnSrcTiles pop hl ld de, BG_MAP_WIDTH - ld a, [hRedrawMapViewRowOffset] + ldh a, [hRedrawMapViewRowOffset] ld c, a .calcVRAMAddrLoop add hl, de @@ -98,11 +98,11 @@ RedrawMapView: or $98 dec c jr nz, .calcVRAMAddrLoop - ld [hRedrawRowOrColumnDest + 1], a + ldh [hRedrawRowOrColumnDest + 1], a ld a, l - ld [hRedrawRowOrColumnDest], a + ldh [hRedrawRowOrColumnDest], a ld a, REDRAW_ROW - ld [hRedrawRowOrColumnMode], a + ldh [hRedrawRowOrColumnMode], a call DelayFrame ld hl, hRedrawMapViewRowOffset inc [hl] @@ -112,9 +112,9 @@ RedrawMapView: dec c jr nz, .redrawRowLoop pop af - ld [hTilesetType], a + ldh [hTilesetType], a pop af - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ret CompareHLWithBC: |