summaryrefslogtreecommitdiff
path: root/engine/overworld
diff options
context:
space:
mode:
authorRangi <remy.oukaour+rangi42@gmail.com>2020-07-03 22:11:35 -0400
committerRangi <remy.oukaour+rangi42@gmail.com>2020-07-03 22:22:09 -0400
commit6ef36800b0dcb86100a7c716172015667e60dc99 (patch)
tree7e381171a7f42cadb6e619c839bfc4d3eb88e7d1 /engine/overworld
parent35deb771130a9012ee4494b1db097761f2fe2919 (diff)
Replace raw hex values with HRAM constants
To do: turn constants into labels and use ldh
Diffstat (limited to 'engine/overworld')
-rwxr-xr-xengine/overworld/hidden_objects.asm14
-rw-r--r--engine/overworld/missable_objects.asm2
-rw-r--r--engine/overworld/movement.asm4
-rw-r--r--engine/overworld/player_state.asm32
-rw-r--r--engine/overworld/sprite_collisions.asm40
-rw-r--r--engine/overworld/tilesets.asm2
-rwxr-xr-xengine/overworld/trainer_sight.asm16
-rw-r--r--engine/overworld/update_map.asm14
8 files changed, 62 insertions, 62 deletions
diff --git a/engine/overworld/hidden_objects.asm b/engine/overworld/hidden_objects.asm
index 5887660e..a19694e0 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 [$ffee], else stores $ff
+; if a hidden object was found, stores $00 in [hFoundHiddenObject], else stores $ff
CheckForHiddenObject::
- ld hl, $ffeb
+ ld hl, hFoundHiddenObjectOrBookshelf
xor a
- ld [hli], a
- ld [hli], a
- ld [hli], a
- ld [hl], a
+ ld [hli], a ; [hFoundHiddenObjectOrBookshelf]
+ ld [hli], a ; [hSavedMapTextPtr]
+ ld [hli], a ; [hSavedMapTextPtr + 1]
+ ld [hl], a ; [hFoundHiddenObject]
ld de, $0
ld hl, HiddenObjectMaps
.hiddenMapLoop
@@ -81,7 +81,7 @@ CheckForHiddenObject::
ret
.noMatch
ld a, $ff
- ld [$ffee], a
+ ld [hFoundHiddenObject], a
ret
; checks if the coordinates in front of the player's sprite match Y in b and X in c
diff --git a/engine/overworld/missable_objects.asm b/engine/overworld/missable_objects.asm
index 6d365715..a89fcb54 100644
--- a/engine/overworld/missable_objects.asm
+++ b/engine/overworld/missable_objects.asm
@@ -120,7 +120,7 @@ IsObjectHidden:
.notHidden
xor a
.hidden
- ld [$ffe5], a
+ ld [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 432ae5ca..6c354779 100644
--- a/engine/overworld/movement.asm
+++ b/engine/overworld/movement.asm
@@ -475,7 +475,7 @@ 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
@@ -564,7 +564,7 @@ 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, [hCurrentSpriteOffset]
diff --git a/engine/overworld/player_state.asm b/engine/overworld/player_state.asm
index 69b9201f..ea24fdc1 100644
--- a/engine/overworld/player_state.asm
+++ b/engine/overworld/player_state.asm
@@ -297,7 +297,7 @@ _GetTileAndCoordsInFrontOfPlayer:
GetTileTwoStepsInFrontOfPlayer:
xor a
- ld [$ffdb], a
+ ld [hPlayerFacing], a
ld hl, wYCoord
ld a, [hli]
ld d, a
@@ -306,7 +306,7 @@ GetTileTwoStepsInFrontOfPlayer:
and a ; cp SPRITE_FACING_DOWN
jr nz, .notFacingDown
; facing down
- ld hl, $ffdb
+ ld hl, hPlayerFacing
set 0, [hl]
aCoord 8, 13
inc d
@@ -315,7 +315,7 @@ GetTileTwoStepsInFrontOfPlayer:
cp SPRITE_FACING_UP
jr nz, .notFacingUp
; facing up
- ld hl, $ffdb
+ ld hl, hPlayerFacing
set 1, [hl]
aCoord 8, 5
dec d
@@ -324,7 +324,7 @@ GetTileTwoStepsInFrontOfPlayer:
cp SPRITE_FACING_LEFT
jr nz, .notFacingLeft
; facing left
- ld hl, $ffdb
+ ld hl, hPlayerFacing
set 2, [hl]
aCoord 4, 9
dec e
@@ -333,7 +333,7 @@ GetTileTwoStepsInFrontOfPlayer:
cp SPRITE_FACING_RIGHT
jr nz, .storeTile
; facing right
- ld hl, $ffdb
+ ld hl, hPlayerFacing
set 3, [hl]
aCoord 12, 9
inc e
@@ -378,33 +378,33 @@ CheckForBoulderCollisionWithSprites:
ld hl, wSpriteStateData2 + $14
add hl, de
ld a, [hli] ; map Y position
- ld [$ffdc], a
+ ld [hPlayerYCoord], a
ld a, [hl] ; map X position
- ld [$ffdd], a
+ ld [hPlayerXCoord], a
ld a, [wNumSprites]
ld c, a
ld de, $f
ld hl, wSpriteStateData2 + $14
- ld a, [$ffdb]
+ ld a, [hPlayerFacing]
and $3 ; facing up or down?
jr z, .pushingHorizontallyLoop
.pushingVerticallyLoop
inc hl
- ld a, [$ffdd]
+ ld a, [hPlayerXCoord]
cp [hl]
jr nz, .nextSprite1 ; if X coordinates don't match
dec hl
ld a, [hli]
ld b, a
- ld a, [$ffdb]
+ ld a, [hPlayerFacing]
rrca
jr c, .pushingDown
; pushing up
- ld a, [$ffdc]
+ ld a, [hPlayerYCoord]
dec a
jr .compareYCoords
.pushingDown
- ld a, [$ffdc]
+ ld a, [hPlayerYCoord]
inc a
.compareYCoords
cp b
@@ -417,19 +417,19 @@ CheckForBoulderCollisionWithSprites:
.pushingHorizontallyLoop
ld a, [hli]
ld b, a
- ld a, [$ffdc]
+ ld a, [hPlayerYCoord]
cp b
jr nz, .nextSprite2
ld b, [hl]
- ld a, [$ffdb]
+ ld a, [hPlayerFacing]
bit 2, a
jr nz, .pushingLeft
; pushing right
- ld a, [$ffdd]
+ ld a, [hPlayerXCoord]
inc a
jr .compareXCoords
.pushingLeft
- ld a, [$ffdd]
+ ld a, [hPlayerXCoord]
dec a
.compareXCoords
cp b
diff --git a/engine/overworld/sprite_collisions.asm b/engine/overworld/sprite_collisions.asm
index 43d1759c..c5ff8ebb 100644
--- a/engine/overworld/sprite_collisions.asm
+++ b/engine/overworld/sprite_collisions.asm
@@ -31,7 +31,7 @@ _UpdateSprites::
UpdateNonPlayerSprite:
dec a
swap a
- ld [$ff93], a ; $10 * sprite#
+ ld [hTilePlayerStandingOn], a ; $10 * sprite#
ld a, [wNPCMovementScriptSpriteOffset] ; some sprite offset?
ld b, a
ld a, [hCurrentSpriteOffset]
@@ -79,7 +79,7 @@ DetectCollisionBetweenSprites:
and $f0
or c
- ld [$ff90], a ; store Y coordinate adjusted for direction of movement
+ ld [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 [$ff91], a ; store X coordinate adjusted for direction of movement
+ ld [hFF91], a ; store X coordinate adjusted for direction of movement
ld a, l
add 7
@@ -102,15 +102,15 @@ DetectCollisionBetweenSprites:
ld [hld], a ; zero [$c1id] XXX what's [$c1id] for?
ld [hld], a ; zero [$c1ic] (directions in which collisions occurred)
- ld a, [$ff91]
+ ld a, [hFF91]
ld [hld], a ; [$c1ib] = adjusted X coordinate
- ld a, [$ff90]
+ ld a, [hFF90]
ld [hl], a ; [$c1ia] = adjusted Y coordinate
xor a ; zero the loop counter
.loop
- ld [$ff8f], a ; store loop counter
+ ld [hFF8F], a ; store loop counter
swap a
ld e, a
ld a, [hCurrentSpriteOffset]
@@ -154,7 +154,7 @@ DetectCollisionBetweenSprites:
cpl
inc a
.noCarry1
- ld [$ff90], a ; store the distance between the two sprites' adjusted Y values
+ ld [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, [$ff90] ; a = distance between adjusted Y coordinates
+ ld a, [hFF90] ; a = distance between adjusted Y coordinates
sub b
- ld [$ff92], a ; store distance adjusted using sprite i's direction
+ ld [hFF92], a ; store distance adjusted using sprite i's direction
ld a, b
- ld [$ff90], a ; store 7 or 9 depending on sprite i's delta Y
+ ld [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, [$ff92] ; a = distance adjusted using sprite i's direction
+ ld 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 [$ff91], a ; store the distance between the two sprites' adjusted X values
+ ld [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, [$ff91] ; a = distance between adjusted X coordinates
+ ld a, [hFF91] ; a = distance between adjusted X coordinates
sub b
- ld [$ff92], a ; store distance adjusted using sprite i's direction
+ ld [hFF92], a ; store distance adjusted using sprite i's direction
ld a, b
- ld [$ff91], a ; store 7 or 9 depending on sprite i's delta X
+ ld [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, [$ff92] ; a = distance adjusted using sprite i's direction
+ ld 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, [$ff91] ; a = 7 or 9 depending on sprite i's delta X
+ ld a, [hFF91] ; a = 7 or 9 depending on sprite i's delta X
ld b, a
- ld a, [$ff90] ; a = 7 or 9 depending on sprite i's delta Y
+ ld 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, [$ff8f] ; a = loop counter
+ ld a, [hFF8F] ; a = loop counter
ld de, SpriteCollisionBitTable
add a
add e
@@ -311,7 +311,7 @@ DetectCollisionBetweenSprites:
ld [hl], a
.next
- ld a, [$ff8f] ; a = loop counter
+ ld 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 d6b8221c..88147233 100644
--- a/engine/overworld/tilesets.asm
+++ b/engine/overworld/tilesets.asm
@@ -25,7 +25,7 @@ LoadTilesetHeader:
ld a, [hl]
ld [hTilesetType], a
xor a
- ld [$ffd8], a
+ ld [hMovingBGTilesCounter1], a
pop hl
ld a, [wCurMapTileset]
push hl
diff --git a/engine/overworld/trainer_sight.asm b/engine/overworld/trainer_sight.asm
index f0ea7266..81978c35 100755
--- a/engine/overworld/trainer_sight.asm
+++ b/engine/overworld/trainer_sight.asm
@@ -5,16 +5,16 @@ _GetSpritePosition1::
ld [hSpriteIndex], a
call GetSpriteDataPointer
ld a, [hli] ; c1x4 (screen Y pos)
- ld [$ffeb], a
+ ld [hSpriteScreenYCoord], a
inc hl
ld a, [hl] ; c1x6 (screen X pos)
- ld [$ffec], a
+ ld [hSpriteScreenXCoord], a
ld de, (wSpriteStateData2 + $4) - (wSpriteStateData1 + $6)
add hl, de
ld a, [hli] ; c2x4 (map Y pos)
- ld [$ffed], a
+ ld [hSpriteMapYCoord], a
ld a, [hl] ; c2x5 (map X pos)
- ld [$ffee], a
+ ld [hSpriteMapXCoord], a
ret
_GetSpritePosition2::
@@ -42,16 +42,16 @@ _SetSpritePosition1::
ld a, [wSpriteIndex]
ld [hSpriteIndex], a
call GetSpriteDataPointer
- ld a, [$ffeb] ; c1x4 (screen Y pos)
+ ld a, [hSpriteScreenYCoord] ; c1x4 (screen Y pos)
ld [hli], a
inc hl
- ld a, [$ffec] ; c1x6 (screen X pos)
+ ld a, [hSpriteScreenXCoord] ; c1x6 (screen X pos)
ld [hl], a
ld de, (wSpriteStateData2 + $4) - (wSpriteStateData1 + $6)
add hl, de
- ld a, [$ffed] ; c2x4 (map Y pos)
+ ld a, [hSpriteMapYCoord] ; c2x4 (map Y pos)
ld [hli], a
- ld a, [$ffee] ; c2x5 (map X pos)
+ ld a, [hSpriteMapXCoord] ; c2x5 (map X pos)
ld [hl], a
ret
diff --git a/engine/overworld/update_map.asm b/engine/overworld/update_map.asm
index c494065c..92ae2b10 100644
--- a/engine/overworld/update_map.asm
+++ b/engine/overworld/update_map.asm
@@ -63,7 +63,7 @@ RedrawMapView:
ld a, [hli]
ld h, [hl]
ld l, a
- ld de, -2 * 32
+ ld de, -2 * BG_MAP_WIDTH
add hl, de
ld a, h
and $3
@@ -73,23 +73,23 @@ RedrawMapView:
ld a, h
ld [wBuffer + 1], a ; this copy of the address is not used
ld a, 2
- ld [$ffbe], a
- ld c, 9 ; number of rows of 2x2 tiles (this covers the whole screen)
+ ld [hRedrawMapViewRowOffset], a
+ ld c, SCREEN_HEIGHT / 2 ; number of rows of 2x2 tiles (this covers the whole screen)
.redrawRowLoop
push bc
push hl
push hl
ld hl, wTileMap - 2 * SCREEN_WIDTH
ld de, SCREEN_WIDTH
- ld a, [$ffbe]
+ ld a, [hRedrawMapViewRowOffset]
.calcWRAMAddrLoop
add hl, de
dec a
jr nz, .calcWRAMAddrLoop
call CopyToRedrawRowOrColumnSrcTiles
pop hl
- ld de, $20
- ld a, [$ffbe]
+ ld de, BG_MAP_WIDTH
+ ld a, [hRedrawMapViewRowOffset]
ld c, a
.calcVRAMAddrLoop
add hl, de
@@ -104,7 +104,7 @@ RedrawMapView:
ld a, REDRAW_ROW
ld [hRedrawRowOrColumnMode], a
call DelayFrame
- ld hl, $ffbe
+ ld hl, hRedrawMapViewRowOffset
inc [hl]
inc [hl]
pop hl