summaryrefslogtreecommitdiff
path: root/engine/overworld
diff options
context:
space:
mode:
Diffstat (limited to 'engine/overworld')
-rw-r--r--engine/overworld/decorations.asm20
-rw-r--r--engine/overworld/events.asm29
-rw-r--r--engine/overworld/player_movement.asm37
-rw-r--r--engine/overworld/scripting.asm6
-rw-r--r--engine/overworld/time.asm14
-rw-r--r--engine/overworld/variables.asm6
6 files changed, 55 insertions, 57 deletions
diff --git a/engine/overworld/decorations.asm b/engine/overworld/decorations.asm
index 7ba177420..673d7f272 100644
--- a/engine/overworld/decorations.asm
+++ b/engine/overworld/decorations.asm
@@ -559,7 +559,7 @@ GetDecoName:
.getpokename
push bc
- ld [wd265], a
+ ld [wNamedObjectIndexBuffer], a
call GetPokemonName
pop bc
jr .copy
@@ -1085,17 +1085,18 @@ DecorationDesc_GiantOrnament:
db "@"
ToggleMaptileDecorations:
- lb de, 0, 4
+ ; tile coordinates work the same way as for changeblock
+ lb de, 0, 4 ; bed coordinates
ld a, [wDecoBed]
call SetDecorationTile
- lb de, 7, 4
+ lb de, 7, 4 ; plant coordinates
ld a, [wDecoPlant]
call SetDecorationTile
- lb de, 6, 0
+ lb de, 6, 0 ; poster coordinates
ld a, [wDecoPoster]
call SetDecorationTile
call SetPosterVisibility
- lb de, 0, 0
+ lb de, 0, 0 ; carpet top-left coordinates
call PadCoords_de
ld a, [wDecoCarpet]
and a
@@ -1103,15 +1104,15 @@ ToggleMaptileDecorations:
call _GetDecorationSprite
ld [hl], a
push af
- lb de, 0, 2
+ lb de, 0, 2 ; carpet bottom-left coordinates
call PadCoords_de
pop af
inc a
- ld [hli], a
+ ld [hli], a ; carpet bottom-left block
inc a
- ld [hli], a
+ ld [hli], a ; carpet bottom-middle block
dec a
- ld [hl], a
+ ld [hl], a ; carpet bottom-right block
ret
SetPosterVisibility:
@@ -1177,6 +1178,7 @@ _GetDecorationSprite:
ret
PadCoords_de:
+; adjusts coordinates, the same way as Script_changeblock
ld a, d
add 4
ld d, a
diff --git a/engine/overworld/events.asm b/engine/overworld/events.asm
index 707d31e66..063265e4d 100644
--- a/engine/overworld/events.asm
+++ b/engine/overworld/events.asm
@@ -972,17 +972,18 @@ DoPlayerEvent:
ret
PlayerEventScriptPointers:
- dba Invalid_0x96c2d ; 0
- dba SeenByTrainerScript ; 1
- dba TalkToTrainerScript ; 2
- dba FindItemInBallScript ; 3
- dba EdgeWarpScript ; 4
- dba WarpToNewMapScript ; 5
- dba FallIntoMapScript ; 6
- dba Script_OverworldWhiteout ; 7
- dba HatchEggScript ; 8
- dba ChangeDirectionScript ; 9
- dba Invalid_0x96c2d ; 10
+; entries correspond to PLAYEREVENT_* constants
+ dba Invalid_0x96c2d ; PLAYEREVENT_NONE
+ dba SeenByTrainerScript ; PLAYEREVENT_SEENBYTRAINER
+ dba TalkToTrainerScript ; PLAYEREVENT_TALKTOTRAINER
+ dba FindItemInBallScript ; PLAYEREVENT_ITEMBALL
+ dba EdgeWarpScript ; PLAYEREVENT_CONNECTION
+ dba WarpToNewMapScript ; PLAYEREVENT_WARP
+ dba FallIntoMapScript ; PLAYEREVENT_FALL
+ dba Script_OverworldWhiteout ; PLAYEREVENT_WHITEOUT
+ dba HatchEggScript ; PLAYEREVENT_HATCH
+ dba ChangeDirectionScript ; PLAYEREVENT_JOYCHANGEFACING
+ dba Invalid_0x96c2d ; (NUM_PLAYER_EVENTS)
Invalid_0x96c2d:
end
@@ -1336,8 +1337,8 @@ DoBikeStep::
ClearCmdQueue::
ld hl, wCmdQueue
- ld de, 6
- ld c, 4
+ ld de, CMDQUEUE_ENTRY_SIZE
+ ld c, CMDQUEUE_CAPACITY
xor a
.loop
ld [hl], a
@@ -1443,7 +1444,7 @@ HandleQueuedCommand:
ld hl, CMDQUEUE_TYPE
add hl, bc
ld a, [hl]
- cp 5
+ cp NUM_CMDQUEUE_TYPES
jr c, .okay
xor a
diff --git a/engine/overworld/player_movement.asm b/engine/overworld/player_movement.asm
index c70357f13..a4926e7e5 100644
--- a/engine/overworld/player_movement.asm
+++ b/engine/overworld/player_movement.asm
@@ -562,8 +562,8 @@ DoPlayerMovement::
.GetAction:
; Poll player input and update movement info.
- ld hl, .table
- ld de, .table2 - .table1
+ ld hl, .action_table
+ ld de, .action_table_1_end - .action_table_1
ld a, [wCurInput]
bit D_DOWN_F, a
jr nz, .d_down
@@ -597,25 +597,20 @@ DoPlayerMovement::
ld [wWalkingTile], a
ret
-.table
-; struct:
-; walk direction
-; facing
-; x movement
-; y movement
-; tile collision pointer
-.table1
- db STANDING, FACE_CURRENT, 0, 0
- dw wPlayerStandingTile
-.table2
- db RIGHT, FACE_RIGHT, 1, 0
- dw wTileRight
- db LEFT, FACE_LEFT, -1, 0
- dw wTileLeft
- db UP, FACE_UP, 0, -1
- dw wTileUp
- db DOWN, FACE_DOWN, 0, 1
- dw wTileDown
+player_action: MACRO
+; walk direction, facing, x movement, y movement, tile collision pointer
+ db \1, \2, \3, \4
+ dw \5
+ENDM
+
+.action_table:
+.action_table_1
+ player_action STANDING, FACE_CURRENT, 0, 0, wPlayerStandingTile
+.action_table_1_end
+ player_action RIGHT, FACE_RIGHT, 1, 0, wTileRight
+ player_action LEFT, FACE_LEFT, -1, 0, wTileLeft
+ player_action UP, FACE_UP, 0, -1, wTileUp
+ player_action DOWN, FACE_DOWN, 0, 1, wTileDown
.CheckNPC:
; Returns 0 if there is an NPC in front that you can't move
diff --git a/engine/overworld/scripting.asm b/engine/overworld/scripting.asm
index f8e702eb9..248ff9978 100644
--- a/engine/overworld/scripting.asm
+++ b/engine/overworld/scripting.asm
@@ -623,7 +623,7 @@ INCLUDE "data/items/pocket_names.asm"
CurItemName:
ld a, [wCurItem]
- ld [wd265], a
+ ld [wNamedObjectIndexBuffer], a
call GetItemName
ret
@@ -1863,7 +1863,7 @@ Script_pokenamemem:
jr nz, .gotit
ld a, [wScriptVar]
.gotit
- ld [wd265], a
+ ld [wNamedObjectIndexBuffer], a
call GetPokemonName
ld de, wStringBuffer1
@@ -1890,7 +1890,7 @@ Script_itemtotext:
jr nz, .ok
ld a, [wScriptVar]
.ok
- ld [wd265], a
+ ld [wNamedObjectIndexBuffer], a
call GetItemName
ld de, wStringBuffer1
jr ConvertMemToText
diff --git a/engine/overworld/time.asm b/engine/overworld/time.asm
index abb12d87d..74bd1b6d9 100644
--- a/engine/overworld/time.asm
+++ b/engine/overworld/time.asm
@@ -91,9 +91,9 @@ CheckDailyResetTimer::
call CheckDayDependentEventHL
ret nc
xor a
- ld hl, wDailyFlags
- ld [hli], a ; wDailyFlags
- ld [hli], a ; wWeeklyFlags
+ ld hl, wDailyFlags1
+ ld [hli], a ; wDailyFlags1
+ ld [hli], a ; wDailyFlags2
ld [hli], a ; wSwarmFlags
ld [hl], a ; wSwarmFlags + 1
ld hl, wDailyRematchFlags
@@ -207,14 +207,14 @@ CheckUnusedTwoDayTimer:
ret
; unused
- ld hl, wDailyFlags
- set DAILYFLAGS_FISH_SWARM_F, [hl]
+ ld hl, wDailyFlags1
+ set DAILYFLAGS1_FISH_SWARM_F, [hl]
ret
; unused
and a
- ld hl, wDailyFlags
- bit DAILYFLAGS_FISH_SWARM_F, [hl]
+ ld hl, wDailyFlags1
+ bit DAILYFLAGS1_FISH_SWARM_F, [hl]
ret nz
scf
ret
diff --git a/engine/overworld/variables.asm b/engine/overworld/variables.asm
index 9b5e3846c..da4b18812 100644
--- a/engine/overworld/variables.asm
+++ b/engine/overworld/variables.asm
@@ -72,7 +72,7 @@ _GetVarAction::
ld hl, wPokedexCaught
ld b, wEndPokedexCaught - wPokedexCaught
call CountSetBits
- ld a, [wd265]
+ ld a, [wNumSetBits]
jp .loadstringbuffer2
.CountSeenMons:
@@ -80,7 +80,7 @@ _GetVarAction::
ld hl, wPokedexSeen
ld b, wEndPokedexSeen - wPokedexSeen
call CountSetBits
- ld a, [wd265]
+ ld a, [wNumSetBits]
jp .loadstringbuffer2
.CountBadges:
@@ -88,7 +88,7 @@ _GetVarAction::
ld hl, wBadges
ld b, 2
call CountSetBits
- ld a, [wd265]
+ ld a, [wNumSetBits]
jp .loadstringbuffer2
.PlayerFacing: