summaryrefslogtreecommitdiff
path: root/engine/overworld
diff options
context:
space:
mode:
Diffstat (limited to 'engine/overworld')
-rwxr-xr-xengine/overworld/auto_movement.asm4
-rw-r--r--engine/overworld/clear_variables.asm2
-rwxr-xr-xengine/overworld/cut.asm2
-rwxr-xr-xengine/overworld/doors.asm2
-rwxr-xr-xengine/overworld/elevator.asm4
-rwxr-xr-xengine/overworld/healing_machine.asm4
-rwxr-xr-xengine/overworld/hidden_objects.asm16
-rwxr-xr-xengine/overworld/ledges.asm2
-rwxr-xr-xengine/overworld/map_sprites.asm7
-rw-r--r--engine/overworld/missable_objects.asm16
-rw-r--r--engine/overworld/movement.asm88
-rwxr-xr-xengine/overworld/player_animations.asm2
-rw-r--r--engine/overworld/player_state.asm38
-rw-r--r--engine/overworld/push_boulder.asm2
-rw-r--r--engine/overworld/special_warps.asm2
-rw-r--r--engine/overworld/sprite_collisions.asm52
-rw-r--r--engine/overworld/tilesets.asm6
-rwxr-xr-xengine/overworld/trainer_sight.asm28
-rwxr-xr-xengine/overworld/turn_sprite.asm6
-rw-r--r--engine/overworld/update_map.asm20
-rw-r--r--engine/overworld/wild_mons.asm8
21 files changed, 156 insertions, 155 deletions
diff --git a/engine/overworld/auto_movement.asm b/engine/overworld/auto_movement.asm
index e478c9ad..421e3180 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 [H_SPRITEINDEX], a
+ ld [hSpriteIndex], a
ld de, wNPCMovementDirections2
call MoveSprite
ld a, $1
@@ -282,7 +282,7 @@ FreezeEnemyTrainerSprite::
jr .loop
.notRival
ld a, [wSpriteIndex]
- ld [H_SPRITEINDEX], a
+ ld [hSpriteIndex], a
jp SetSpriteMovementBytesToFF
RivalIDs:
diff --git a/engine/overworld/clear_variables.asm b/engine/overworld/clear_variables.asm
index 32dc85cd..b5a1f4a0 100644
--- a/engine/overworld/clear_variables.asm
+++ b/engine/overworld/clear_variables.asm
@@ -3,7 +3,7 @@ ClearVariablesOnEnterMap::
ld [hWY], a
ld [rWY], a
xor a
- ld [H_AUTOBGTRANSFERENABLED], a
+ ld [hAutoBGTransferEnabled], a
ld [wStepCounter], a
ld [wLoneAttackNo], a
ld [hJoyPressed], a
diff --git a/engine/overworld/cut.asm b/engine/overworld/cut.asm
index f61ca65f..c75fbbb6 100755
--- a/engine/overworld/cut.asm
+++ b/engine/overworld/cut.asm
@@ -248,4 +248,4 @@ ReplaceTreeTileBlock:
ld [hl], a
ret
-INCLUDE "data/cut_tree_blocks.asm"
+INCLUDE "data/tilesets/cut_tree_blocks.asm"
diff --git a/engine/overworld/doors.asm b/engine/overworld/doors.asm
index 1339430a..ed893773 100755
--- a/engine/overworld/doors.asm
+++ b/engine/overworld/doors.asm
@@ -25,4 +25,4 @@ IsPlayerStandingOnDoorTile:
and a
ret
-INCLUDE "data/door_tile_ids.asm"
+INCLUDE "data/tilesets/door_tile_ids.asm"
diff --git a/engine/overworld/elevator.asm b/engine/overworld/elevator.asm
index d36e2f2c..05ca08c9 100755
--- a/engine/overworld/elevator.asm
+++ b/engine/overworld/elevator.asm
@@ -4,7 +4,7 @@ ShakeElevator::
ld de, SCREEN_HEIGHT * $20
call ShakeElevatorRedrawRow
call Delay3
- ld a, $ff
+ ld a, SFX_STOP_ALL_MUSIC
call PlaySound
ld a, [hSCY]
ld d, a
@@ -27,7 +27,7 @@ ShakeElevator::
jr nz, .shakeLoop
ld a, d
ld [hSCY], a
- ld a, $ff
+ ld a, SFX_STOP_ALL_MUSIC
call PlaySound
ld c, BANK(SFX_Safari_Zone_PA)
ld a, SFX_SAFARI_ZONE_PA
diff --git a/engine/overworld/healing_machine.asm b/engine/overworld/healing_machine.asm
index 510f963b..836af44d 100755
--- a/engine/overworld/healing_machine.asm
+++ b/engine/overworld/healing_machine.asm
@@ -17,7 +17,7 @@ AnimateHealingMachine:
call CopyHealingMachineOAM
ld a, 4
ld [wAudioFadeOutControl], a
- ld a, $ff
+ ld a, SFX_STOP_ALL_MUSIC
ld [wNewSoundID], a
call PlaySound
.waitLoop
@@ -38,7 +38,7 @@ AnimateHealingMachine:
cp BANK(Audio3_UpdateMusic)
ld [wAudioSavedROMBank], a
jr nz, .next
- ld a, $ff
+ ld a, SFX_STOP_ALL_MUSIC
ld [wNewSoundID], a
call PlaySound
ld a, BANK(Music_PkmnHealed)
diff --git a/engine/overworld/hidden_objects.asm b/engine/overworld/hidden_objects.asm
index c93f2e1b..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
@@ -130,4 +130,4 @@ CheckIfCoordsInFrontOfPlayerMatch:
ld [hCoordsInFrontOfPlayerMatch], a
ret
-INCLUDE "data/hidden_objects.asm"
+INCLUDE "data/events/hidden_objects.asm"
diff --git a/engine/overworld/ledges.asm b/engine/overworld/ledges.asm
index 290c8c80..c56914f6 100755
--- a/engine/overworld/ledges.asm
+++ b/engine/overworld/ledges.asm
@@ -54,7 +54,7 @@ HandleLedges::
call PlaySound
ret
-INCLUDE "data/ledge_tiles.asm"
+INCLUDE "data/tilesets/ledge_tiles.asm"
LoadHoppingShadowOAM:
ld hl, vChars1 + $7f0
diff --git a/engine/overworld/map_sprites.asm b/engine/overworld/map_sprites.asm
index 19e25435..904e9b04 100755
--- a/engine/overworld/map_sprites.asm
+++ b/engine/overworld/map_sprites.asm
@@ -133,8 +133,7 @@ LoadMapSpriteTilePatterns:
jr nc, .fourTileSpriteVRAMAddr
ld d, a
dec d
-; Equivalent to multiplying $C0 (number of bytes in 12 tiles) times the VRAM
-; slot and adding the result to $8000 (the VRAM base address).
+; vSprites += [hVRAMSlot] * $C0 (the number of bytes in 12 tiles)
.calculateVRAMAddrLoop
add hl, bc
dec d
@@ -437,4 +436,6 @@ GetSplitMapSpriteSetID:
ld a, $01
ret
-INCLUDE "data/sprite_sets.asm"
+INCLUDE "data/maps/sprite_sets.asm"
+
+INCLUDE "data/sprites/sprites.asm"
diff --git a/engine/overworld/missable_objects.asm b/engine/overworld/missable_objects.asm
index 7d6de545..a89fcb54 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 [H_DIVIDEND], a
+ ld [hDividend], a
ld a, l
- ld [H_DIVIDEND+1], a
+ ld [hDividend+1], a
xor a
- ld [H_DIVIDEND+2], a
- ld [H_DIVIDEND+3], a
+ ld [hDividend+2], a
+ ld [hDividend+3], a
ld a, $3
- ld [H_DIVISOR], a
+ ld [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, [H_DIVIDEND+3]
+ ld 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, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
swap a
ld b, a
ld hl, wMissableObjectList
@@ -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 f272f497..6c354779 100644
--- a/engine/overworld/movement.asm
+++ b/engine/overworld/movement.asm
@@ -63,7 +63,7 @@ UpdatePlayerSprite:
ld a, [wd736]
bit 7, a ; is the player sprite spinning due to a spin tile?
jr nz, .skipSpriteAnim
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
add $7
ld l, a
ld a, [hl]
@@ -103,7 +103,7 @@ UpdatePlayerSprite:
UnusedReadSpriteDataFunction:
push bc
push af
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
ld c, a
pop af
add c
@@ -112,7 +112,7 @@ UnusedReadSpriteDataFunction:
ret
UpdateNPCSprite:
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
swap a
dec a
add a
@@ -122,7 +122,7 @@ UpdateNPCSprite:
ld a, [hl] ; read movement byte 2
ld [wCurSpriteMovement2], a
ld h, $c1
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
ld l, a
inc l
ld a, [hl] ; c1x1
@@ -131,7 +131,7 @@ UpdateNPCSprite:
call CheckSpriteAvailability
ret c ; if sprite is invisible, on tile >=MAP_TILESET_SIZE, in grass or player is currently walking
ld h, $c1
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
ld l, a
inc l
ld a, [hl] ; c1x1
@@ -151,7 +151,7 @@ UpdateNPCSprite:
ret nz ; don't do anything yet if player is currently moving (redundant, already tested in CheckSpriteAvailability)
call InitializeSpriteScreenPosition
ld h, $c2
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
add $6
ld l, a
ld a, [hl] ; c2x6: movement byte 1
@@ -264,11 +264,11 @@ ChangeFacingDirection:
TryWalking:
push hl
ld h, $c1
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
add $9
ld l, a
ld [hl], c ; c1x9 (update facing direction)
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
add $3
ld l, a
ld [hl], d ; c1x3 (update Y movement delta)
@@ -282,7 +282,7 @@ TryWalking:
pop de
ret c ; cannot walk there (reinitialization of delay values already done)
ld h, $c2
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
add $4
ld l, a
ld a, [hl] ; c2x4: Y position
@@ -291,7 +291,7 @@ TryWalking:
ld a, [hl] ; c2x5: X position
add e
ld [hl], a ; update X position
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
ld l, a
ld [hl], $10 ; c2x0=16: walk animation counter
dec h
@@ -301,7 +301,7 @@ TryWalking:
; update the walking animation parameters for a sprite that is currently walking
UpdateSpriteInWalkingAnimation:
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
add $7
ld l, a
ld a, [hl] ; c1x7 (counter until next walk animation frame)
@@ -317,7 +317,7 @@ UpdateSpriteInWalkingAnimation:
and $3
ld [hl], a ; advance to next animation frame every 4 ticks (16 ticks total for one step)
.noNextAnimationFrame
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
add $3
ld l, a
ld a, [hli] ; c1x3 (movement Y delta)
@@ -330,7 +330,7 @@ UpdateSpriteInWalkingAnimation:
ld a, [hl] ; c1x6 (screen X position)
add b
ld [hl], a ; update screen X position
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
ld l, a
inc h
ld a, [hl] ; c2x0 (walk animation counter)
@@ -343,7 +343,7 @@ UpdateSpriteInWalkingAnimation:
ld a, [hl] ; c2x6 (movement byte 1)
cp $fe
jr nc, .initNextMovementCounter ; values $fe and $ff
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
inc a
ld l, a
dec h
@@ -351,14 +351,14 @@ UpdateSpriteInWalkingAnimation:
ret
.initNextMovementCounter
call Random
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
add $8
ld l, a
ld a, [hRandomAdd]
and $7f
ld [hl], a ; c2x8: set next movement delay to a random value in [0,$7f]
dec h ; note that value 0 actually makes the delay $100 (bug?)
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
inc a
ld l, a
ld [hl], $2 ; c1x1 = 2 (movement status)
@@ -375,7 +375,7 @@ UpdateSpriteInWalkingAnimation:
; update delay value (c2x8) for sprites in the delayed state (c1x1)
UpdateSpriteMovementDelay:
ld h, $c2
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
add $6
ld l, a
ld a, [hl] ; c2x6: movement byte 1
@@ -390,13 +390,13 @@ UpdateSpriteMovementDelay:
jr nz, notYetMoving
.moving
dec h
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
inc a
ld l, a
ld [hl], $1 ; c1x1 = 1 (mark as ready to move)
notYetMoving:
ld h, wSpriteStateData1 / $100
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
add $8
ld l, a
ld [hl], $0 ; c1x8 = 0 (walk animation frame)
@@ -429,7 +429,7 @@ MakeNPCFacePlayer:
.notFacingRight
ld c, SPRITE_FACING_LEFT
.facingDirectionDetermined
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
add $9
ld l, a
ld [hl], c ; c1x9: set facing direction
@@ -440,7 +440,7 @@ InitializeSpriteStatus:
inc l
ld [hl], $ff ; $c1x2: set sprite image to $ff (invisible/off screen)
inc h
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
add $2
ld l, a
ld a, $8
@@ -451,7 +451,7 @@ InitializeSpriteStatus:
; calculates the sprite's screen position form its map position and the player position
InitializeSpriteScreenPosition:
ld h, wSpriteStateData2 / $100
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
add $4
ld l, a
ld a, [wYCoord]
@@ -475,17 +475,17 @@ InitializeSpriteScreenPosition:
; tests if sprite is off screen or otherwise unable to do anything
CheckSpriteAvailability:
predef IsObjectHidden
- ld a, [$ffe5]
+ ld a, [hIsHiddenMissableObject]
and a
jp nz, .spriteInvisible
ld h, wSpriteStateData2 / $100
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
add $6
ld l, a
ld a, [hl] ; c2x6: movement byte 1
cp $fe
jr c, .skipXVisibilityTest ; movement byte 1 < $fe (i.e. the sprite's movement is scripted)
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
add $4
ld l, a
ld b, [hl] ; c2x4: Y pos (+4)
@@ -527,7 +527,7 @@ CheckSpriteAvailability:
jr c, .spriteVisible ; standing on tile with ID >=MAP_TILESET_SIZE (top right tile)
.spriteInvisible
ld h, wSpriteStateData1 / $100
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
add $2
ld l, a
ld [hl], $ff ; c1x2
@@ -540,7 +540,7 @@ CheckSpriteAvailability:
jr nz, .done ; if player is currently walking, we're done
call UpdateSpriteImage
inc h
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
add $7
ld l, a
ld a, [wGrassTile]
@@ -556,7 +556,7 @@ CheckSpriteAvailability:
UpdateSpriteImage:
ld h, $c1
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
add $8
ld l, a
ld a, [hli] ; c1x8: walk animation frame
@@ -564,10 +564,10 @@ UpdateSpriteImage:
ld a, [hl] ; c1x9: facing direction
add b
ld b, a
- ld a, [$ff93] ; current sprite offset
+ ld a, [hTilePlayerStandingOn]
add b
ld b, a
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
add $2
ld l, a
ld [hl], b ; c1x2: sprite to display
@@ -581,7 +581,7 @@ UpdateSpriteImage:
; set carry on failure, clears carry on success
CanWalkOntoTile:
ld h, wSpriteStateData2 / $100
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
add $6
ld l, a
ld a, [hl] ; c2x6 (movement byte 1)
@@ -602,14 +602,14 @@ CanWalkOntoTile:
cp c
jr nz, .tilePassableLoop
ld h, $c2
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
add $6
ld l, a
ld a, [hl] ; $c2x6 (movement byte 1)
inc a
jr z, .impassable ; if $ff, no movement allowed (however, changing direction is)
ld h, wSpriteStateData1 / $100
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
add $4
ld l, a
ld a, [hli] ; c1x4 (screen Y pos)
@@ -628,14 +628,14 @@ CanWalkOntoTile:
pop bc
pop de
ld h, wSpriteStateData1 / $100
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
add $c
ld l, a
ld a, [hl] ; c1xc (directions in which sprite collision would occur)
and b ; check against chosen direction (1,2,4 or 8)
jr nz, .impassable ; collision between sprites, don't go there
ld h, wSpriteStateData2 / $100
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
add $2
ld l, a
ld a, [hli] ; c2x2 (sprite Y displacement, initialized at $8, keep track of where a sprite did go)
@@ -666,7 +666,7 @@ CanWalkOntoTile:
ret
.impassable
ld h, $c1
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
inc a
ld l, a
ld [hl], $2 ; c1x1 = 2 (set movement status to delayed)
@@ -677,7 +677,7 @@ CanWalkOntoTile:
inc l
ld [hl], a ; c1x5 = 0 (clear X movement delta)
inc h
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
add $8
ld l, a
call Random
@@ -692,7 +692,7 @@ CanWalkOntoTile:
; hl: output pointer
GetTileSpriteStandsOn:
ld h, wSpriteStateData1 / $100
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
add $4
ld l, a
ld a, [hli] ; c1x4: screen Y position
@@ -784,7 +784,7 @@ DoScriptedNPCMovement:
ld a, [hl]
add b
ld [hl], a
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
add $9
ld l, a
ld a, c
@@ -817,7 +817,7 @@ GetSpriteScreenXPointer:
GetSpriteScreenXYPointerCommon:
ld hl, wSpriteStateData1
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
add l
add b
ld l, a
@@ -825,7 +825,7 @@ GetSpriteScreenXYPointerCommon:
AnimScriptedNPCMovement:
ld hl, wSpriteStateData2
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
add $e
ld l, a
ld a, [hl] ; VRAM slot
@@ -833,7 +833,7 @@ AnimScriptedNPCMovement:
swap a
ld b, a
ld hl, wSpriteStateData1
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
add $9
ld l, a
ld a, [hl] ; facing direction
@@ -852,7 +852,7 @@ AnimScriptedNPCMovement:
ld [hSpriteVRAMSlotAndFacing], a
call AdvanceScriptedNPCAnimFrameCounter
ld hl, wSpriteStateData1
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
add $2
ld l, a
ld a, [hSpriteVRAMSlotAndFacing]
@@ -863,7 +863,7 @@ AnimScriptedNPCMovement:
ret
AdvanceScriptedNPCAnimFrameCounter:
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
add $7
ld l, a
ld a, [hl] ; intra-animation frame counter
diff --git a/engine/overworld/player_animations.asm b/engine/overworld/player_animations.asm
index 0ac4f3b2..a3f6e051 100755
--- a/engine/overworld/player_animations.asm
+++ b/engine/overworld/player_animations.asm
@@ -373,7 +373,7 @@ IsPlayerStandingOnWarpPadOrHole::
ld [wStandingOnWarpPadOrHole], a
ret
-INCLUDE "data/warp_pad_hole_tile_ids.asm"
+INCLUDE "data/tilesets/warp_pad_hole_tile_ids.asm"
FishingAnim:
ld c, 10
diff --git a/engine/overworld/player_state.asm b/engine/overworld/player_state.asm
index 23da664c..ea24fdc1 100644
--- a/engine/overworld/player_state.asm
+++ b/engine/overworld/player_state.asm
@@ -82,7 +82,7 @@ CheckForceBikeOrSurf::
ld [wWalkBikeSurfStateCopy], a
jp ForceBikeOrSurf
-INCLUDE "data/force_bike_surf.asm"
+INCLUDE "data/maps/force_bike_surf.asm"
IsPlayerFacingEdgeOfMap::
push hl
@@ -176,7 +176,7 @@ IsWarpTileInFrontOfPlayer::
pop hl
ret
-INCLUDE "data/warp_carpet_tile_ids.asm"
+INCLUDE "data/tilesets/warp_carpet_tile_ids.asm"
IsSSAnneBowWarpTileInFrontOfPlayer:
ld a, [wTileInFrontOfPlayer]
@@ -215,7 +215,7 @@ IsPlayerStandingOnDoorTileOrWarpTile::
pop hl
ret
-INCLUDE "data/warp_tile_ids.asm"
+INCLUDE "data/tilesets/warp_tile_ids.asm"
PrintSafariZoneSteps::
ld a, [wCurMap]
@@ -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/push_boulder.asm b/engine/overworld/push_boulder.asm
index c45554f1..e4dd91cf 100644
--- a/engine/overworld/push_boulder.asm
+++ b/engine/overworld/push_boulder.asm
@@ -92,7 +92,7 @@ DoBoulderDustAnimation::
call ResetBoulderPushFlags
set 7, [hl]
ld a, [wBoulderSpriteIndex]
- ld [H_SPRITEINDEX], a
+ ld [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 eee85402..042146f9 100644
--- a/engine/overworld/special_warps.asm
+++ b/engine/overworld/special_warps.asm
@@ -146,4 +146,4 @@ LoadSpecialWarpData:
ld [wDestinationWarpID], a
ret
-INCLUDE "data/special_warps.asm"
+INCLUDE "data/maps/special_warps.asm"
diff --git a/engine/overworld/sprite_collisions.asm b/engine/overworld/sprite_collisions.asm
index 0e6b2d06..c5ff8ebb 100644
--- a/engine/overworld/sprite_collisions.asm
+++ b/engine/overworld/sprite_collisions.asm
@@ -6,7 +6,7 @@ _UpdateSprites::
ld l, a
sub $e
ld c, a
- ld [H_CURRENTSPRITEOFFSET], a
+ ld [hCurrentSpriteOffset], a
ld a, [hl]
and a
jr z, .skipSprite ; tests $c2Xe
@@ -31,17 +31,17 @@ _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, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
cp b
jr nz, .unequal
jp DoScriptedNPCMovement
.unequal
jp UpdateNPCSprite
-; This detects if the current sprite (whose offset is at H_CURRENTSPRITEOFFSET)
+; This detects if the current sprite (whose offset is at hCurrentSpriteOffset)
; is going to collide with another sprite by looping over the other sprites.
; The current sprite's offset will be labelled with i (e.g. $c1i0).
; The loop sprite's offset will labelled with j (e.g. $c1j0).
@@ -54,7 +54,7 @@ DetectCollisionBetweenSprites:
nop
ld h, wSpriteStateData1 / $100
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
add wSpriteStateData1 % $100
ld l, a
@@ -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,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, [$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, [H_CURRENTSPRITEOFFSET]
+ ld 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, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
add 10
ld l, a
@@ -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 6e33974f..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
@@ -55,6 +55,6 @@ LoadTilesetHeader:
.done
ret
-INCLUDE "data/dungeon_tilesets.asm"
+INCLUDE "data/tilesets/dungeon_tilesets.asm"
-INCLUDE "data/tileset_headers.asm"
+INCLUDE "data/tilesets/tileset_headers.asm"
diff --git a/engine/overworld/trainer_sight.asm b/engine/overworld/trainer_sight.asm
index 5a68b627..81978c35 100755
--- a/engine/overworld/trainer_sight.asm
+++ b/engine/overworld/trainer_sight.asm
@@ -2,26 +2,26 @@ _GetSpritePosition1::
ld hl, wSpriteStateData1
ld de, $4
ld a, [wSpriteIndex]
- ld [H_SPRITEINDEX], a
+ 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::
ld hl, wSpriteStateData1
ld de, $4
ld a, [wSpriteIndex]
- ld [H_SPRITEINDEX], a
+ ld [hSpriteIndex], a
call GetSpriteDataPointer
ld a, [hli] ; c1x4 (screen Y pos)
ld [wSavedSpriteScreenY], a
@@ -40,18 +40,18 @@ _SetSpritePosition1::
ld hl, wSpriteStateData1
ld de, $4
ld a, [wSpriteIndex]
- ld [H_SPRITEINDEX], a
+ 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
@@ -59,7 +59,7 @@ _SetSpritePosition2::
ld hl, wSpriteStateData1
ld de, 4
ld a, [wSpriteIndex]
- ld [H_SPRITEINDEX], a
+ ld [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 [H_SPRITEINDEX], a
+ ld [hSpriteIndex], a
jp MoveSprite_
; input: de = offset within sprite entry
@@ -152,7 +152,7 @@ TrainerWalkUpToPlayer::
GetSpriteDataPointer:
push de
add hl, de
- ld a, [H_SPRITEINDEX]
+ ld 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 c7f7712b..bef26537 100755
--- a/engine/overworld/turn_sprite.asm
+++ b/engine/overworld/turn_sprite.asm
@@ -1,12 +1,12 @@
UpdateSpriteFacingOffsetAndDelayMovement::
ld h, $c2
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld a, [hCurrentSpriteOffset]
add $8
ld l, a
ld a, $7f ; maximum movement delay
ld [hl], a ; c2x8 (movement delay)
dec h
- ld a, [H_CURRENTSPRITEOFFSET]
+ ld 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, [H_CURRENTSPRITEOFFSET]
+ ld 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 8577b9e7..92ae2b10 100644
--- a/engine/overworld/update_map.asm
+++ b/engine/overworld/update_map.asm
@@ -50,12 +50,12 @@ RedrawMapView:
ld a, [wIsInBattle]
inc a
ret z
- ld a, [H_AUTOBGTRANSFERENABLED]
+ ld a, [hAutoBGTransferEnabled]
push af
ld a, [hTilesetType]
push af
xor a
- ld [H_AUTOBGTRANSFERENABLED], a
+ ld [hAutoBGTransferEnabled], a
ld [hTilesetType], a ; no flower/water BG tile animations
call LoadCurrentMapView
call RunDefaultPaletteCommand
@@ -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
@@ -114,7 +114,7 @@ RedrawMapView:
pop af
ld [hTilesetType], a
pop af
- ld [H_AUTOBGTRANSFERENABLED], a
+ ld [hAutoBGTransferEnabled], a
ret
CompareHLWithBC:
diff --git a/engine/overworld/wild_mons.asm b/engine/overworld/wild_mons.asm
index df4d3121..2593e0ec 100644
--- a/engine/overworld/wild_mons.asm
+++ b/engine/overworld/wild_mons.asm
@@ -16,10 +16,10 @@ LoadWildData::
jr z, .NoGrassData ; if no grass data, skip to surfing data
push hl
ld de, wGrassMons ; otherwise, load grass data
- ld bc, $0014
+ ld bc, $14
call CopyData
pop hl
- ld bc, $0014
+ ld bc, $14
add hl, bc
.NoGrassData
ld a, [hli]
@@ -27,7 +27,7 @@ LoadWildData::
and a
ret z ; if no water data, we're done
ld de, wWaterMons ; otherwise, load surfing data
- ld bc, $0014
+ ld bc, $14
jp CopyData
-INCLUDE "data/wild_mons.asm"
+INCLUDE "data/wild/grass_water.asm"