summaryrefslogtreecommitdiff
path: root/engine/overworld
diff options
context:
space:
mode:
Diffstat (limited to 'engine/overworld')
-rwxr-xr-xengine/overworld/auto_movement.asm6
-rw-r--r--engine/overworld/clear_variables.asm2
-rwxr-xr-xengine/overworld/cut.asm14
-rwxr-xr-xengine/overworld/dust_smoke.asm2
-rwxr-xr-xengine/overworld/emotion_bubbles.asm2
-rw-r--r--engine/overworld/field_move_messages.asm16
-rwxr-xr-xengine/overworld/hidden_objects.asm12
-rwxr-xr-xengine/overworld/ledges.asm2
-rwxr-xr-xengine/overworld/map_sprites.asm22
-rw-r--r--engine/overworld/missable_objects.asm14
-rw-r--r--engine/overworld/movement.asm50
-rw-r--r--engine/overworld/pathfinding.asm6
-rwxr-xr-xengine/overworld/player_animations.asm48
-rw-r--r--engine/overworld/player_state.asm12
-rw-r--r--engine/overworld/push_boulder.asm4
-rw-r--r--engine/overworld/sprite_collisions.asm6
-rwxr-xr-xengine/overworld/trainer_sight.asm28
17 files changed, 123 insertions, 123 deletions
diff --git a/engine/overworld/auto_movement.asm b/engine/overworld/auto_movement.asm
index 421e3180..5e70ab8c 100755
--- a/engine/overworld/auto_movement.asm
+++ b/engine/overworld/auto_movement.asm
@@ -12,7 +12,7 @@ PlayerStepOutFromDoor::
ld a, D_DOWN
ld [wSimulatedJoypadStatesEnd], a
xor a
- ld [wSpriteStateData1 + 2], a
+ ld [wSpritePlayerStateData1ImageIndex], a
call StartSimulatingJoypadStates
ret
.notStandingOnDoor
@@ -110,7 +110,7 @@ PalletMovementScript_WalkToLab:
swap a
ld [wNPCMovementScriptSpriteOffset], a
xor a
- ld [wSpriteStateData2 + $06], a
+ ld [wSpritePlayerStateData2MovementByte1], a
ld hl, wSimulatedJoypadStatesEnd
ld de, RLEList_PlayerWalkToLab
call DecodeRLEList
@@ -228,7 +228,7 @@ PewterMovementScript_WalkToGym:
swap a
ld [wNPCMovementScriptSpriteOffset], a
xor a
- ld [wSpriteStateData2 + $06], a
+ ld [wSpritePlayerStateData2MovementByte1], a
ld hl, wSimulatedJoypadStatesEnd
ld de, RLEList_PewterGymPlayer
call DecodeRLEList
diff --git a/engine/overworld/clear_variables.asm b/engine/overworld/clear_variables.asm
index b5a1f4a0..9b735495 100644
--- a/engine/overworld/clear_variables.asm
+++ b/engine/overworld/clear_variables.asm
@@ -1,5 +1,5 @@
ClearVariablesOnEnterMap::
- ld a, SCREEN_HEIGHT_PIXELS
+ ld a, SCREEN_HEIGHT_PX
ld [hWY], a
ld [rWY], a
xor a
diff --git a/engine/overworld/cut.asm b/engine/overworld/cut.asm
index c75fbbb6..f99bf323 100755
--- a/engine/overworld/cut.asm
+++ b/engine/overworld/cut.asm
@@ -22,8 +22,8 @@ UsedCut:
jp PrintText
.NothingToCutText
- TX_FAR _NothingToCutText
- db "@"
+ text_far _NothingToCutText
+ text_end
.canCut
ld [wCutTile], a
@@ -37,7 +37,7 @@ UsedCut:
call GBPalWhiteOutWithDelay3
call ClearSprites
call RestoreScreenTilesAndReloadTilePatterns
- ld a, SCREEN_HEIGHT_PIXELS
+ ld a, SCREEN_HEIGHT_PX
ld [hWY], a
call Delay3
call LoadGBPal
@@ -68,8 +68,8 @@ UsedCut:
jp RedrawMapView
UsedCutText:
- TX_FAR _UsedCutText
- db "@"
+ text_far _UsedCutText
+ text_end
InitCutAnimOAM:
xor a
@@ -127,7 +127,7 @@ CutOrBoulderDustAnimationTilesAndAttributes:
db $FE,$10,$FF,$10
GetCutOrBoulderDustAnimationOffsets:
- ld hl, wSpriteStateData1 + 4
+ ld hl, wSpritePlayerStateData1YPixels
ld a, [hli] ; player's sprite screen Y position
ld b, a
inc hl
@@ -187,7 +187,7 @@ ReplaceTreeTileBlock:
ld h, [hl]
ld l, a
add hl, bc
- ld a, [wSpriteStateData1 + 9] ; player sprite's facing direction
+ ld a, [wSpritePlayerStateData1FacingDirection]
and a
jr z, .down
cp SPRITE_FACING_UP
diff --git a/engine/overworld/dust_smoke.asm b/engine/overworld/dust_smoke.asm
index 6c26b712..2dc6882e 100755
--- a/engine/overworld/dust_smoke.asm
+++ b/engine/overworld/dust_smoke.asm
@@ -30,7 +30,7 @@ AnimateBoulderDust:
jp LoadPlayerSpriteGraphics
GetMoveBoulderDustFunctionPointer:
- ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
+ ld a, [wSpritePlayerStateData1FacingDirection]
ld hl, MoveBoulderDustFunctionPointerTable
ld c, a
ld b, $0
diff --git a/engine/overworld/emotion_bubbles.asm b/engine/overworld/emotion_bubbles.asm
index 20309fc1..1ac07b80 100755
--- a/engine/overworld/emotion_bubbles.asm
+++ b/engine/overworld/emotion_bubbles.asm
@@ -38,7 +38,7 @@ EmotionBubble:
jr nz, .loop
; get the screen coordinates of the sprite the bubble is to be displayed above
- ld hl, wSpriteStateData1 + 4
+ ld hl, wSpritePlayerStateData1YPixels
ld a, [wEmotionBubbleSpriteIndex]
swap a
ld c, a
diff --git a/engine/overworld/field_move_messages.asm b/engine/overworld/field_move_messages.asm
index b1506742..8e849e46 100644
--- a/engine/overworld/field_move_messages.asm
+++ b/engine/overworld/field_move_messages.asm
@@ -7,16 +7,16 @@ PrintStrengthTxt:
jp PrintText
UsedStrengthText:
- TX_FAR _UsedStrengthText
- TX_ASM
+ text_far _UsedStrengthText
+ text_asm
ld a, [wcf91]
call PlayCry
call Delay3
jp TextScriptEnd
CanMoveBouldersText:
- TX_FAR _CanMoveBouldersText
- db "@"
+ text_far _CanMoveBouldersText
+ text_end
IsSurfingAllowed:
; Returns whether surfing is allowed in bit 1 of wd728.
@@ -49,9 +49,9 @@ CoordsData_cdf7:
db $0B,$07,$FF
CurrentTooFastText:
- TX_FAR _CurrentTooFastText
- db "@"
+ text_far _CurrentTooFastText
+ text_end
CyclingIsFunText:
- TX_FAR _CyclingIsFunText
- db "@"
+ text_far _CyclingIsFunText
+ text_end
diff --git a/engine/overworld/hidden_objects.asm b/engine/overworld/hidden_objects.asm
index a19694e0..5ce7f3cb 100755
--- a/engine/overworld/hidden_objects.asm
+++ b/engine/overworld/hidden_objects.asm
@@ -14,14 +14,14 @@ IsPlayerOnDungeonWarp::
set 4, [hl]
ret
-; if a hidden object was found, stores $00 in [hFoundHiddenObject], else stores $ff
+; if a hidden object was found, stores $00 in [hDidntFindAnyHiddenObject], else stores $ff
CheckForHiddenObject::
- ld hl, hFoundHiddenObjectOrBookshelf
+ ld hl, hItemAlreadyFound
xor a
- ld [hli], a ; [hFoundHiddenObjectOrBookshelf]
+ ld [hli], a ; [hItemAlreadyFound]
ld [hli], a ; [hSavedMapTextPtr]
ld [hli], a ; [hSavedMapTextPtr + 1]
- ld [hl], a ; [hFoundHiddenObject]
+ ld [hl], a ; [hDidntFindAnyHiddenObject]
ld de, $0
ld hl, HiddenObjectMaps
.hiddenMapLoop
@@ -81,13 +81,13 @@ CheckForHiddenObject::
ret
.noMatch
ld a, $ff
- ld [hFoundHiddenObject], a
+ ld [hDidntFindAnyHiddenObject], a
ret
; checks if the coordinates in front of the player's sprite match Y in b and X in c
; [hCoordsInFrontOfPlayerMatch] = $00 if they match, $ff if they don't match
CheckIfCoordsInFrontOfPlayerMatch:
- ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
+ ld a, [wSpritePlayerStateData1FacingDirection]
cp SPRITE_FACING_UP
jr z, .facingUp
cp SPRITE_FACING_LEFT
diff --git a/engine/overworld/ledges.asm b/engine/overworld/ledges.asm
index c56914f6..0f135fb6 100755
--- a/engine/overworld/ledges.asm
+++ b/engine/overworld/ledges.asm
@@ -6,7 +6,7 @@ HandleLedges::
and a ; OVERWORLD
ret nz
predef GetTileAndCoordsInFrontOfPlayer
- ld a, [wSpriteStateData1 + 9]
+ ld a, [wSpritePlayerStateData1FacingDirection]
ld b, a
aCoord 8, 9
ld c, a
diff --git a/engine/overworld/map_sprites.asm b/engine/overworld/map_sprites.asm
index 904e9b04..0de1befd 100755
--- a/engine/overworld/map_sprites.asm
+++ b/engine/overworld/map_sprites.asm
@@ -12,8 +12,8 @@ InitMapSprites::
call InitOutsideMapSprites
ret c ; return if the map is an outside map (already handled by above call)
; if the map is an inside map (i.e. mapID >= $25)
- ld hl, wSpriteStateData1
- ld de, wSpriteStateData2 + $0d
+ ld hl, wSpritePlayerStateData1PictureID
+ ld de, wSpritePlayerStateData2PictureID
; Loop to copy picture ID's from $C1X0 to $C2XD for LoadMapSpriteTilePatterns.
.copyPictureIDLoop
ld a, [hl] ; $C1X0 (picture ID)
@@ -37,7 +37,7 @@ LoadMapSpriteTilePatterns:
.spritesExist
ld c, a ; c = [wNumSprites]
ld b, $10 ; number of sprite slots
- ld hl, wSpriteStateData2 + $0d
+ ld hl, wSpritePlayerStateData2PictureID
xor a
ld [hFourTileSpriteCount], a
.copyPictureIDLoop ; loop to copy picture ID from $C2XD to $C2XE
@@ -48,9 +48,9 @@ LoadMapSpriteTilePatterns:
ld l, a
dec b
jr nz, .copyPictureIDLoop
- ld hl, wSpriteStateData2 + $1e
+ ld hl, wSprite01StateData2ImageBaseOffset
.loadTilePatternLoop
- ld de, wSpriteStateData2 + $1d
+ ld de, wSprite01StateData2PictureID
; Check if the current picture ID has already had its tile patterns loaded.
; This done by looping through the previous sprite slots and seeing if any of
; their picture ID's match that of the current sprite slot.
@@ -70,7 +70,7 @@ LoadMapSpriteTilePatterns:
ld e, a
jr .checkIfAlreadyLoadedLoop
.notAlreadyLoaded
- ld de, wSpriteStateData2 + $0e
+ ld de, wSpritePlayerStateData2ImageBaseOffset
ld b, $01
; loop to find the highest tile pattern VRAM slot (among the first 10 slots) used by a previous sprite slot
; this is done in order to find the first free VRAM slot available
@@ -133,7 +133,7 @@ LoadMapSpriteTilePatterns:
jr nc, .fourTileSpriteVRAMAddr
ld d, a
dec d
-; vSprites += [hVRAMSlot] * $C0 (the number of bytes in 12 tiles)
+; hl = vSprites + [hVRAMSlot] * $C0 (the number of bytes in 12 tiles)
.calculateVRAMAddrLoop
add hl, bc
dec d
@@ -215,7 +215,7 @@ LoadMapSpriteTilePatterns:
ld l, a
dec c
jp nz, .loadTilePatternLoop
- ld hl, wSpriteStateData2 + $0d
+ ld hl, wSpritePlayerStateData2PictureID
ld b, $10
; the pictures ID's stored at $C2XD are no longer needed, so zero them
.zeroStoredPictureIDLoop
@@ -287,7 +287,7 @@ InitOutsideMapSprites:
jr nc, .noCarry2
inc d
.noCarry2
- ld hl, wSpriteStateData2 + $0d
+ ld hl, wSpritePlayerStateData2PictureID
ld a, SPRITE_RED
ld [hl], a
ld bc, wSpriteSet
@@ -323,7 +323,7 @@ InitOutsideMapSprites:
call LoadMapSpriteTilePatterns
pop af
ld [wNumSprites], a ; restore number of sprites
- ld hl, wSpriteStateData2 + $1e
+ ld hl, wSprite01StateData2ImageBaseOffset
ld b, $0f
; The VRAM tile pattern slots that LoadMapSpriteTilePatterns set are in the
; order of the map's sprite set, not the order of the actual sprites loaded
@@ -337,7 +337,7 @@ InitOutsideMapSprites:
dec b
jr nz, .zeroVRAMSlotsLoop
.skipLoadingSpriteSet
- ld hl, wSpriteStateData1 + $10
+ ld hl, wSprite01StateData1
; This loop stores the correct VRAM tile pattern slots according the sprite
; data from the map's header. Since the VRAM tile pattern slots are filled in
; the order of the sprite set, in order to find the VRAM tile pattern slot
diff --git a/engine/overworld/missable_objects.asm b/engine/overworld/missable_objects.asm
index a89fcb54..1ebe8064 100644
--- a/engine/overworld/missable_objects.asm
+++ b/engine/overworld/missable_objects.asm
@@ -20,7 +20,7 @@ MarkTownVisitedAndLoadMissableObjects::
LoadMissableObjects:
ld l, a
push hl
- ld de, MapHS00 ; calculate difference between out pointer and the base pointer
+ ld de, MissableObjects ; calculate difference between out pointer and the base pointer
ld a, l
sub e
jr nc, .asm_f13c
@@ -49,7 +49,7 @@ LoadMissableObjects:
pop hl
.writeMissableObjectsListLoop
ld a, [hli]
- cp $ff
+ cp -1
jr z, .done ; end of list
cp b
jr nz, .done ; not for current map anymore
@@ -63,7 +63,7 @@ LoadMissableObjects:
inc de
jr .writeMissableObjectsListLoop
.done
- ld a, $ff
+ ld a, -1
ld [de], a ; write sentinel
ret
@@ -72,17 +72,17 @@ InitializeMissableObjectsFlags:
ld bc, wMissableObjectFlagsEnd - wMissableObjectFlags
xor a
call FillMemory ; clear missable objects flags
- ld hl, MapHS00
+ ld hl, MissableObjects
xor a
ld [wMissableObjectCounter], a
.missableObjectsLoop
ld a, [hli]
- cp $ff ; end of list
+ cp -1 ; end of list
ret z
push hl
inc hl
ld a, [hl]
- cp Hide
+ cp HIDE
jr nz, .skip
ld hl, wMissableObjectFlags
ld a, [wMissableObjectCounter]
@@ -105,7 +105,7 @@ IsObjectHidden:
ld hl, wMissableObjectList
.loop
ld a, [hli]
- cp $ff
+ cp -1
jr z, .notHidden ; not missable -> not hidden
cp b
ld a, [hli]
diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm
index 6c354779..d27ccb4b 100644
--- a/engine/overworld/movement.asm
+++ b/engine/overworld/movement.asm
@@ -1,13 +1,13 @@
MAP_TILESET_SIZE EQU $60
UpdatePlayerSprite:
- ld a, [wSpriteStateData2]
+ ld a, [wSpritePlayerStateData2WalkAnimationCounter]
and a
jr z, .checkIfTextBoxInFrontOfSprite
cp $ff
jr z, .disableSprite
dec a
- ld [wSpriteStateData2], a
+ ld [wSpritePlayerStateData2WalkAnimationCounter], a
jr .disableSprite
; check if a text box is in front of the sprite by checking if the lower left
; background tile the sprite is standing on is greater than $5F, which is
@@ -19,7 +19,7 @@ UpdatePlayerSprite:
jr c, .lowerLeftTileIsMapTile
.disableSprite
ld a, $ff
- ld [wSpriteStateData1 + 2], a
+ ld [wSpritePlayerStateData1ImageIndex], a
ret
.lowerLeftTileIsMapTile
call DetectCollisionBetweenSprites
@@ -51,11 +51,11 @@ UpdatePlayerSprite:
.notMoving
; zero the animation counters
xor a
- ld [wSpriteStateData1 + 7], a
- ld [wSpriteStateData1 + 8], a
+ ld [wSpritePlayerStateData1IntraAnimFrameCounter], a
+ ld [wSpritePlayerStateData1AnimFrameCounter], a
jr .calcImageIndex
.next
- ld [wSpriteStateData1 + 9], a ; facing direction
+ ld [wSpritePlayerStateData1FacingDirection], a
ld a, [wFontLoaded]
bit 0, a
jr nz, .notMoving
@@ -79,11 +79,11 @@ UpdatePlayerSprite:
and $3
ld [hl], a
.calcImageIndex
- ld a, [wSpriteStateData1 + 8]
+ ld a, [wSpritePlayerStateData1AnimFrameCounter]
ld b, a
- ld a, [wSpriteStateData1 + 9]
+ ld a, [wSpritePlayerStateData1FacingDirection]
add b
- ld [wSpriteStateData1 + 2], a
+ ld [wSpritePlayerStateData1ImageIndex], a
.skipSpriteAnim
; If the player is standing on a grass tile, make the player's sprite have
; lower priority than the background so that it's partially obscured by the
@@ -97,7 +97,7 @@ UpdatePlayerSprite:
jr nz, .next2
ld a, $80
.next2
- ld [wSpriteStateData2 + 7], a
+ ld [wSpritePlayerStateData2GrassPriority], a
ret
UnusedReadSpriteDataFunction:
@@ -397,7 +397,7 @@ UpdateSpriteMovementDelay:
notYetMoving:
ld h, wSpriteStateData1 / $100
ld a, [hCurrentSpriteOffset]
- add $8
+ add wSpritePlayerStateData1AnimFrameCounter - wSpritePlayerStateData1
ld l, a
ld [hl], $0 ; c1x8 = 0 (walk animation frame)
jp UpdateSpriteImage
@@ -452,7 +452,7 @@ InitializeSpriteStatus:
InitializeSpriteScreenPosition:
ld h, wSpriteStateData2 / $100
ld a, [hCurrentSpriteOffset]
- add $4
+ add wSpritePlayerStateData2MapY - wSpritePlayerStateData2
ld l, a
ld a, [wYCoord]
ld b, a
@@ -480,13 +480,13 @@ CheckSpriteAvailability:
jp nz, .spriteInvisible
ld h, wSpriteStateData2 / $100
ld a, [hCurrentSpriteOffset]
- add $6
+ 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]
- add $4
+ add wSpritePlayerStateData2MapY - wSpritePlayerStateData2
ld l, a
ld b, [hl] ; c2x4: Y pos (+4)
ld a, [wYCoord]
@@ -528,7 +528,7 @@ CheckSpriteAvailability:
.spriteInvisible
ld h, wSpriteStateData1 / $100
ld a, [hCurrentSpriteOffset]
- add $2
+ add wSpritePlayerStateData1ImageIndex - wSpritePlayerStateData1
ld l, a
ld [hl], $ff ; c1x2
scf
@@ -582,7 +582,7 @@ UpdateSpriteImage:
CanWalkOntoTile:
ld h, wSpriteStateData2 / $100
ld a, [hCurrentSpriteOffset]
- add $6
+ add wSpritePlayerStateData2MovementByte1 - wSpritePlayerStateData2
ld l, a
ld a, [hl] ; c2x6 (movement byte 1)
cp $fe
@@ -610,7 +610,7 @@ CanWalkOntoTile:
jr z, .impassable ; if $ff, no movement allowed (however, changing direction is)
ld h, wSpriteStateData1 / $100
ld a, [hCurrentSpriteOffset]
- add $4
+ add wSpritePlayerStateData1YPixels - wSpritePlayerStateData1
ld l, a
ld a, [hli] ; c1x4 (screen Y pos)
add $4 ; align to blocks (Y pos is always 4 pixels off)
@@ -636,7 +636,7 @@ CanWalkOntoTile:
jr nz, .impassable ; collision between sprites, don't go there
ld h, wSpriteStateData2 / $100
ld a, [hCurrentSpriteOffset]
- add $2
+ add wSpritePlayerStateData2YDisplacement - wSpritePlayerStateData2
ld l, a
ld a, [hli] ; c2x2 (sprite Y displacement, initialized at $8, keep track of where a sprite did go)
bit 7, d ; check if going upwards (d=$ff)
@@ -665,7 +665,7 @@ CanWalkOntoTile:
and a ; clear carry (marking success)
ret
.impassable
- ld h, $c1
+ ld h, wSpriteStateData1 / $100
ld a, [hCurrentSpriteOffset]
inc a
ld l, a
@@ -693,7 +693,7 @@ CanWalkOntoTile:
GetTileSpriteStandsOn:
ld h, wSpriteStateData1 / $100
ld a, [hCurrentSpriteOffset]
- add $4
+ add wSpritePlayerStateData1YPixels - wSpritePlayerStateData1
ld l, a
ld a, [hli] ; c1x4: screen Y position
add $4 ; align to 2*2 tile blocks (Y position is always off 4 pixels to the top)
@@ -807,12 +807,12 @@ InitScriptedNPCMovement:
jp AnimScriptedNPCMovement
GetSpriteScreenYPointer:
- ld a, $4
+ ld a, wSpritePlayerStateData1YPixels - wSpritePlayerStateData1
ld b, a
jr GetSpriteScreenXYPointerCommon
GetSpriteScreenXPointer:
- ld a, $6
+ ld a, wSpritePlayerStateData1XPixels - wSpritePlayerStateData1
ld b, a
GetSpriteScreenXYPointerCommon:
@@ -826,7 +826,7 @@ GetSpriteScreenXYPointerCommon:
AnimScriptedNPCMovement:
ld hl, wSpriteStateData2
ld a, [hCurrentSpriteOffset]
- add $e
+ add wSpritePlayerStateData2ImageBaseOffset - wSpritePlayerStateData2
ld l, a
ld a, [hl] ; VRAM slot
dec a
@@ -834,7 +834,7 @@ AnimScriptedNPCMovement:
ld b, a
ld hl, wSpriteStateData1
ld a, [hCurrentSpriteOffset]
- add $9
+ add wSpritePlayerStateData1FacingDirection - wSpritePlayerStateData1
ld l, a
ld a, [hl] ; facing direction
cp SPRITE_FACING_DOWN
@@ -853,7 +853,7 @@ AnimScriptedNPCMovement:
call AdvanceScriptedNPCAnimFrameCounter
ld hl, wSpriteStateData1
ld a, [hCurrentSpriteOffset]
- add $2
+ add wSpritePlayerStateData1ImageIndex - wSpritePlayerStateData1
ld l, a
ld a, [hSpriteVRAMSlotAndFacing]
ld b, a
diff --git a/engine/overworld/pathfinding.asm b/engine/overworld/pathfinding.asm
index ba052d38..7251759c 100644
--- a/engine/overworld/pathfinding.asm
+++ b/engine/overworld/pathfinding.asm
@@ -77,14 +77,14 @@ FindPathToPlayer:
CalcPositionOfPlayerRelativeToNPC:
xor a
ld [hNPCPlayerRelativePosFlags], a
- ld a, [wSpriteStateData1 + 4] ; player's sprite screen Y position in pixels
+ ld a, [wSpritePlayerStateData1YPixels]
ld d, a
- ld a, [wSpriteStateData1 + 6] ; player's sprite screen X position in pixels
+ ld a, [wSpritePlayerStateData1XPixels]
ld e, a
ld hl, wSpriteStateData1
ld a, [hNPCSpriteOffset]
add l
- add $4
+ add wSpritePlayerStateData1YPixels - wSpritePlayerStateData1
ld l, a
jr nc, .noCarry
inc h
diff --git a/engine/overworld/player_animations.asm b/engine/overworld/player_animations.asm
index a3f6e051..cfd6cc8d 100755
--- a/engine/overworld/player_animations.asm
+++ b/engine/overworld/player_animations.asm
@@ -1,7 +1,7 @@
EnterMapAnim::
call InitFacingDirectionList
ld a, $ec
- ld [wSpriteStateData1 + 4], a ; player's sprite Y screen position
+ ld [wSpritePlayerStateData1YPixels], a
call Delay3
push hl
call GBFadeInFromWhite
@@ -227,19 +227,19 @@ DoFlyAnimation:
ld a, [wFlyAnimBirdSpriteImageIndex]
xor $1 ; make the bird flap its wings
ld [wFlyAnimBirdSpriteImageIndex], a
- ld [wSpriteStateData1 + 2], a
+ ld [wSpritePlayerStateData1ImageIndex], a
call Delay3
ld a, [wFlyAnimUsingCoordList]
cp $ff
jr z, .skipCopyingCoords ; if the bird is flapping its wings in place
- ld hl, wSpriteStateData1 + 4
+ ld hl, wSpritePlayerStateData1YPixels
ld a, [de]
inc de
- ld [hli], a
+ ld [hli], a ; y
inc hl
ld a, [de]
inc de
- ld [hl], a
+ ld [hl], a ; x
.skipCopyingCoords
ld a, [wFlyAnimCounter]
dec a
@@ -258,15 +258,15 @@ LoadBirdSpriteGraphics:
jp CopyVideoData
InitFacingDirectionList:
- ld a, [wSpriteStateData1 + 2] ; player's sprite facing direction (image index is locked to standing images)
+ ld a, [wSpritePlayerStateData1ImageIndex] ; (image index is locked to standing images)
ld [wSavedPlayerFacingDirection], a
- ld a, [wSpriteStateData1 + 4] ; player's sprite Y screen position
+ ld a, [wSpritePlayerStateData1YPixels]
ld [wSavedPlayerScreenY], a
ld hl, PlayerSpinningFacingOrder
ld de, wFacingDirectionList
ld bc, 4
call CopyData
- ld a, [wSpriteStateData1 + 2] ; player's sprite facing direction (image index is locked to standing images)
+ ld a, [wSpritePlayerStateData1ImageIndex] ; (image index is locked to standing images)
ld hl, wFacingDirectionList
; find the place in the list that matches the current facing direction
.loop
@@ -284,7 +284,7 @@ PlayerSpinningFacingOrder:
SpinPlayerSprite:
; copy the current value from the list into the sprite data and rotate the list
ld a, [hl]
- ld [wSpriteStateData1 + 2], a ; player's sprite facing direction (image index is locked to standing images)
+ ld [wSpritePlayerStateData1ImageIndex], a ; (image index is locked to standing images)
push hl
ld hl, wFacingDirectionList
ld de, wFacingDirectionList - 1
@@ -320,9 +320,9 @@ PlayerSpinWhileMovingUpOrDown:
call SpinPlayerSprite
ld a, [wPlayerSpinWhileMovingUpOrDownAnimDeltaY]
ld c, a
- ld a, [wSpriteStateData1 + 4] ; player's sprite Y screen position
+ ld a, [wSpritePlayerStateData1YPixels]
add c
- ld [wSpriteStateData1 + 4], a
+ ld [wSpritePlayerStateData1YPixels], a
ld c, a
ld a, [wPlayerSpinWhileMovingUpOrDownAnimMaxY]
cp c
@@ -334,9 +334,9 @@ PlayerSpinWhileMovingUpOrDown:
RestoreFacingDirectionAndYScreenPos:
ld a, [wSavedPlayerScreenY]
- ld [wSpriteStateData1 + 4], a
+ ld [wSpritePlayerStateData1YPixels], a
ld a, [wSavedPlayerFacingDirection]
- ld [wSpriteStateData1 + 2], a
+ ld [wSpritePlayerStateData1ImageIndex], a ; (image index is locked to standing images)
ret
; if SGB, 2 frames, else 3 frames
@@ -387,7 +387,7 @@ FishingAnim:
ld a, $4
ld hl, RedFishingTiles
call LoadAnimSpriteGfx
- ld a, [wSpriteStateData1 + 2]
+ ld a, [wSpritePlayerStateData1ImageIndex]
ld c, a
ld b, $0
ld hl, FishingRodOAM
@@ -410,7 +410,7 @@ FishingAnim:
; shake the player's sprite vertically
ld b, 10
.loop
- ld hl, wSpriteStateData1 + 4 ; player's sprite Y screen position
+ ld hl, wSpritePlayerStateData1YPixels
call .ShakePlayerSprite
ld hl, wOAMBuffer + $9c
call .ShakePlayerSprite
@@ -420,7 +420,7 @@ FishingAnim:
; If the player is facing up, hide the fishing rod so it doesn't overlap with
; the exclamation bubble that will be shown next.
- ld a, [wSpriteStateData1 + 2] ; player's sprite facing direction
+ ld a, [wSpritePlayerStateData1ImageIndex] ; (image index is locked to standing images)
cp SPRITE_FACING_UP
jr nz, .skipHidingFishingRod
ld a, $a0
@@ -434,7 +434,7 @@ FishingAnim:
predef EmotionBubble
; If the player is facing up, unhide the fishing rod.
- ld a, [wSpriteStateData1 + 2] ; player's sprite facing direction
+ ld a, [wSpritePlayerStateData1ImageIndex] ; (image index is locked to standing images)
cp SPRITE_FACING_UP
jr nz, .skipUnhidingFishingRod
ld a, $44
@@ -457,16 +457,16 @@ FishingAnim:
ret
NoNibbleText:
- TX_FAR _NoNibbleText
- db "@"
+ text_far _NoNibbleText
+ text_end
NothingHereText:
- TX_FAR _NothingHereText
- db "@"
+ text_far _NothingHereText
+ text_end
ItsABiteText:
- TX_FAR _ItsABiteText
- db "@"
+ text_far _ItsABiteText
+ text_end
FishingRodOAM:
; specifies how the fishing rod should be drawn on the screen
@@ -507,7 +507,7 @@ _HandleMidJump::
ld hl, PlayerJumpingYScreenCoords
add hl, bc
ld a, [hl]
- ld [wSpriteStateData1 + 4], a ; player's sprite y coordinate
+ ld [wSpritePlayerStateData1YPixels], a
ret
.finishedJump
ld a, [wWalkCounter]
diff --git a/engine/overworld/player_state.asm b/engine/overworld/player_state.asm
index ea24fdc1..9ff67df8 100644
--- a/engine/overworld/player_state.asm
+++ b/engine/overworld/player_state.asm
@@ -88,7 +88,7 @@ IsPlayerFacingEdgeOfMap::
push hl
push de
push bc
- ld a, [wSpriteStateData1 + 9] ; player sprite's facing direction
+ ld a, [wSpritePlayerStateData1FacingDirection]
srl a
ld c, a
ld b, $0
@@ -158,7 +158,7 @@ IsWarpTileInFrontOfPlayer::
ld a, [wCurMap]
cp SS_ANNE_BOW
jr z, IsSSAnneBowWarpTileInFrontOfPlayer
- ld a, [wSpriteStateData1 + 9] ; player sprite's facing direction
+ ld a, [wSpritePlayerStateData1FacingDirection]
srl a
ld c, a
ld b, 0
@@ -263,7 +263,7 @@ _GetTileAndCoordsInFrontOfPlayer:
ld d, a
ld a, [wXCoord]
ld e, a
- ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
+ ld a, [wSpritePlayerStateData1FacingDirection]
and a ; cp SPRITE_FACING_DOWN
jr nz, .notFacingDown
; facing down
@@ -302,7 +302,7 @@ GetTileTwoStepsInFrontOfPlayer:
ld a, [hli]
ld d, a
ld e, [hl]
- ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
+ ld a, [wSpritePlayerStateData1FacingDirection]
and a ; cp SPRITE_FACING_DOWN
jr nz, .notFacingDown
; facing down
@@ -375,7 +375,7 @@ CheckForBoulderCollisionWithSprites:
swap a
ld d, 0
ld e, a
- ld hl, wSpriteStateData2 + $14
+ ld hl, wSprite01StateData2MapY
add hl, de
ld a, [hli] ; map Y position
ld [hPlayerYCoord], a
@@ -384,7 +384,7 @@ CheckForBoulderCollisionWithSprites:
ld a, [wNumSprites]
ld c, a
ld de, $f
- ld hl, wSpriteStateData2 + $14
+ ld hl, wSprite01StateData2MapY
ld a, [hPlayerFacing]
and $3 ; facing up or down?
jr z, .pushingHorizontallyLoop
diff --git a/engine/overworld/push_boulder.asm b/engine/overworld/push_boulder.asm
index e4dd91cf..da1c6dee 100644
--- a/engine/overworld/push_boulder.asm
+++ b/engine/overworld/push_boulder.asm
@@ -12,7 +12,7 @@ TryPushingBoulder::
ld [wBoulderSpriteIndex], a
and a
jp z, ResetBoulderPushFlags
- ld hl, wSpriteStateData1 + 1
+ ld hl, wSpritePlayerStateData1MovementStatus
ld d, $0
ld a, [hSpriteIndexOrTextID]
swap a
@@ -36,7 +36,7 @@ TryPushingBoulder::
jp nz, ResetBoulderPushFlags
ld a, [hJoyHeld]
ld b, a
- ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
+ ld a, [wSpritePlayerStateData1FacingDirection]
cp SPRITE_FACING_UP
jr z, .pushBoulderUp
cp SPRITE_FACING_LEFT
diff --git a/engine/overworld/sprite_collisions.asm b/engine/overworld/sprite_collisions.asm
index c5ff8ebb..48cd95b9 100644
--- a/engine/overworld/sprite_collisions.asm
+++ b/engine/overworld/sprite_collisions.asm
@@ -1,10 +1,10 @@
_UpdateSprites::
ld h, $c1
inc h
- ld a, $e ; wSpriteStateData2 + $0e
+ ld a, wSpritePlayerStateData2ImageBaseOffset - wSpritePlayerStateData2
.spriteLoop
ld l, a
- sub $e
+ sub wSpritePlayerStateData2ImageBaseOffset - wSpritePlayerStateData2
ld c, a
ld [hCurrentSpriteOffset], a
ld a, [hl]
@@ -20,7 +20,7 @@ _UpdateSprites::
.skipSprite
ld a, l
add $10 ; move to next sprite
- cp $e ; test for overflow (back at $0e)
+ cp wSpritePlayerStateData2ImageBaseOffset - wSpritePlayerStateData2 ; test for overflow (back at beginning)
jr nz, .spriteLoop
ret
.updateCurrentSprite
diff --git a/engine/overworld/trainer_sight.asm b/engine/overworld/trainer_sight.asm
index 81978c35..c12c064b 100755
--- a/engine/overworld/trainer_sight.asm
+++ b/engine/overworld/trainer_sight.asm
@@ -1,6 +1,6 @@
_GetSpritePosition1::
ld hl, wSpriteStateData1
- ld de, $4
+ ld de, wSpritePlayerStateData1YPixels - wSpritePlayerStateData1
ld a, [wSpriteIndex]
ld [hSpriteIndex], a
call GetSpriteDataPointer
@@ -9,7 +9,7 @@ _GetSpritePosition1::
inc hl
ld a, [hl] ; c1x6 (screen X pos)
ld [hSpriteScreenXCoord], a
- ld de, (wSpriteStateData2 + $4) - (wSpriteStateData1 + $6)
+ ld de, wSpritePlayerStateData2MapY - wSpritePlayerStateData1XPixels
add hl, de
ld a, [hli] ; c2x4 (map Y pos)
ld [hSpriteMapYCoord], a
@@ -19,7 +19,7 @@ _GetSpritePosition1::
_GetSpritePosition2::
ld hl, wSpriteStateData1
- ld de, $4
+ ld de, wSpritePlayerStateData1YPixels - wSpritePlayerStateData1
ld a, [wSpriteIndex]
ld [hSpriteIndex], a
call GetSpriteDataPointer
@@ -28,7 +28,7 @@ _GetSpritePosition2::
inc hl
ld a, [hl] ; c1x6 (screen X pos)
ld [wSavedSpriteScreenX], a
- ld de, (wSpriteStateData2 + $4) - (wSpriteStateData1 + $6)
+ ld de, wSpritePlayerStateData2MapY - wSpritePlayerStateData1XPixels
add hl, de
ld a, [hli] ; c2x4 (map Y pos)
ld [wSavedSpriteMapY], a
@@ -38,7 +38,7 @@ _GetSpritePosition2::
_SetSpritePosition1::
ld hl, wSpriteStateData1
- ld de, $4
+ ld de, wSpritePlayerStateData1YPixels - wSpritePlayerStateData1
ld a, [wSpriteIndex]
ld [hSpriteIndex], a
call GetSpriteDataPointer
@@ -47,7 +47,7 @@ _SetSpritePosition1::
inc hl
ld a, [hSpriteScreenXCoord] ; c1x6 (screen X pos)
ld [hl], a
- ld de, (wSpriteStateData2 + $4) - (wSpriteStateData1 + $6)
+ ld de, wSpritePlayerStateData2MapY - wSpritePlayerStateData1XPixels
add hl, de
ld a, [hSpriteMapYCoord] ; c2x4 (map Y pos)
ld [hli], a
@@ -57,7 +57,7 @@ _SetSpritePosition1::
_SetSpritePosition2::
ld hl, wSpriteStateData1
- ld de, 4
+ ld de, wSpritePlayerStateData1YPixels - wSpritePlayerStateData1
ld a, [wSpriteIndex]
ld [hSpriteIndex], a
call GetSpriteDataPointer
@@ -66,7 +66,7 @@ _SetSpritePosition2::
inc hl
ld a, [wSavedSpriteScreenX]
ld [hl], a ; c1x6 (screen X pos)
- ld de, (wSpriteStateData2 + $4) - (wSpriteStateData1 + $6)
+ ld de, wSpritePlayerStateData2MapY - wSpritePlayerStateData1XPixels
add hl, de
ld a, [wSavedSpriteMapY]
ld [hli], a ; c2x4 (map Y pos)
@@ -165,7 +165,7 @@ TrainerEngage:
push hl
push de
ld a, [wTrainerSpriteOffset]
- add $2
+ add wSpritePlayerStateData1ImageIndex - wSpritePlayerStateData1
ld d, $0
ld e, a
ld hl, wSpriteStateData1
@@ -176,7 +176,7 @@ TrainerEngage:
jp .noEngage
.spriteOnScreen
ld a, [wTrainerSpriteOffset]
- add $9
+ add wSpritePlayerStateData1FacingDirection - wSpritePlayerStateData1
ld d, $0
ld e, a
ld hl, wSpriteStateData1
@@ -234,7 +234,7 @@ TrainerEngage:
; reads trainer's Y position to wTrainerScreenY and X position to wTrainerScreenX
ReadTrainerScreenPosition:
ld a, [wTrainerSpriteOffset]
- add $4
+ add wSpritePlayerStateData1YPixels - wSpritePlayerStateData1
ld d, $0
ld e, a
ld hl, wSpriteStateData1
@@ -242,7 +242,7 @@ ReadTrainerScreenPosition:
ld a, [hl] ; c1x4 (sprite Y pos)
ld [wTrainerScreenY], a
ld a, [wTrainerSpriteOffset]
- add $6
+ add wSpritePlayerStateData1XPixels - wSpritePlayerStateData1
ld d, $0
ld e, a
ld hl, wSpriteStateData1
@@ -295,7 +295,7 @@ CheckPlayerIsInFrontOfSprite:
cp POWER_PLANT
jp z, .engage ; bypass this for power plant to get voltorb fake items to work
ld a, [wTrainerSpriteOffset]
- add $4
+ add wSpritePlayerStateData1YPixels - wSpritePlayerStateData1
ld d, $0
ld e, a
ld hl, wSpriteStateData1
@@ -307,7 +307,7 @@ CheckPlayerIsInFrontOfSprite:
.notOnTopmostTile
ld [wTrainerScreenY], a
ld a, [wTrainerSpriteOffset]
- add $6
+ add wSpritePlayerStateData1XPixels - wSpritePlayerStateData1
ld d, $0
ld e, a
ld hl, wSpriteStateData1