summaryrefslogtreecommitdiff
path: root/engine/overworld
diff options
context:
space:
mode:
Diffstat (limited to 'engine/overworld')
-rw-r--r--engine/overworld/decorations.asm295
-rw-r--r--engine/overworld/events.asm240
-rw-r--r--engine/overworld/events_2.asm103
-rw-r--r--engine/overworld/init_map.asm8
-rw-r--r--engine/overworld/load_map_part.asm2
-rw-r--r--engine/overworld/map_object_action.asm64
-rw-r--r--engine/overworld/map_objects.asm356
-rw-r--r--engine/overworld/map_objects_2.asm6
-rw-r--r--engine/overworld/map_setup.asm47
-rw-r--r--engine/overworld/movement.asm277
-rw-r--r--engine/overworld/npc_movement.asm46
-rw-r--r--engine/overworld/overworld.asm79
-rw-r--r--engine/overworld/player_movement.asm68
-rw-r--r--engine/overworld/player_object.asm64
-rw-r--r--engine/overworld/player_step.asm34
-rw-r--r--engine/overworld/select_menu.asm33
-rw-r--r--engine/overworld/spawn_points.asm6
-rw-r--r--engine/overworld/tile_events.asm27
-rw-r--r--engine/overworld/time.asm115
-rw-r--r--engine/overworld/variables.asm32
-rw-r--r--engine/overworld/warp_connection.asm31
-rw-r--r--engine/overworld/wildmons.asm87
22 files changed, 709 insertions, 1311 deletions
diff --git a/engine/overworld/decorations.asm b/engine/overworld/decorations.asm
index 33d0ca0cd..0ed34e318 100644
--- a/engine/overworld/decorations.asm
+++ b/engine/overworld/decorations.asm
@@ -1,4 +1,4 @@
-InitDecorations: ; 26751 (9:6751)
+InitDecorations:
ld a, DECO_FEATHERY_BED
ld [wDecoBed], a
ld a, DECO_TOWN_MAP
@@ -51,7 +51,7 @@ _PlayerDecorationMenu: ; 0x2675c
dw .pointers
; 0x267aa
-.pointers ; 267aa
+.pointers
dw DecoBedMenu, .bed
dw DecoCarpetMenu, .carpet
dw DecoPlantMenu, .plant
@@ -69,9 +69,8 @@ _PlayerDecorationMenu: ; 0x2675c
.ornament db "ORNAMENT@"
.big_doll db "BIG DOLL@"
.exit db "EXIT@"
-; 26806
-.FindCategoriesWithOwnedDecos: ; 26806
+.FindCategoriesWithOwnedDecos:
xor a
ld [wWhichIndexSet], a
call .ClearStringBuffer2
@@ -84,7 +83,7 @@ _PlayerDecorationMenu: ; 0x2675c
call CopyBytes
ret
-.ClearStringBuffer2: ; 26822 (9:6822)
+.ClearStringBuffer2:
ld hl, wStringBuffer2
xor a
ld [hli], a
@@ -93,7 +92,7 @@ _PlayerDecorationMenu: ; 0x2675c
call ByteFill
ret
-.AppendToStringBuffer2: ; 26830 (9:6830)
+.AppendToStringBuffer2:
ld hl, wStringBuffer2
inc [hl]
ld e, [hl]
@@ -102,7 +101,7 @@ _PlayerDecorationMenu: ; 0x2675c
ld [hl], a
ret
-.FindOwndDecos: ; 2683a (9:683a)
+.FindOwndDecos:
ld hl, .dw
.loop
ld a, [hli]
@@ -124,9 +123,8 @@ _PlayerDecorationMenu: ; 0x2675c
jr .loop
.done
ret
-; 26855 (9:6855)
-.dw ; 26855
+.dw
dwb FindOwnedBeds, 0 ; bed
dwb FindOwnedCarpets, 1 ; carpet
dwb FindOwnedPlants, 2 ; plant
@@ -135,9 +133,8 @@ _PlayerDecorationMenu: ; 0x2675c
dwb FindOwnedOrnaments, 5 ; ornament
dwb FindOwnedBigDolls, 6 ; big doll
dw 0 ; end
-; 2686c
-Deco_FillTempWithMinusOne: ; 2686c
+Deco_FillTempWithMinusOne:
xor a
ld hl, wd002
ld [hli], a
@@ -145,9 +142,8 @@ Deco_FillTempWithMinusOne: ; 2686c
ld bc, $10
call ByteFill
ret
-; 2687a
-CheckAllDecorationFlags: ; 2687a
+CheckAllDecorationFlags:
.loop
ld a, [hli]
cp -1
@@ -166,9 +162,8 @@ CheckAllDecorationFlags: ; 2687a
.done
ret
-; 26891
-AppendDecoIndex: ; 26891
+AppendDecoIndex:
ld hl, wd002
inc [hl]
ld e, [hl]
@@ -176,9 +171,8 @@ AppendDecoIndex: ; 26891
add hl, de
ld [hl], a
ret
-; 2689b
-FindOwnedDecosInCategory: ; 2689b
+FindOwnedDecosInCategory:
push bc
push hl
call Deco_FillTempWithMinusOne
@@ -195,126 +189,108 @@ FindOwnedDecosInCategory: ; 2689b
call AppendDecoIndex
scf
ret
-; 268b5
-DecoBedMenu: ; 268b5
+DecoBedMenu:
call FindOwnedBeds
call PopulateDecoCategoryMenu
xor a
ret
-; 268bd
-FindOwnedBeds: ; 268bd
+FindOwnedBeds:
ld hl, .beds
ld c, BEDS
jp FindOwnedDecosInCategory
-; 268c5
-.beds ; 268c5
+.beds
db DECO_FEATHERY_BED ; 2
db DECO_PINK_BED ; 3
db DECO_POLKADOT_BED ; 4
db DECO_PIKACHU_BED ; 5
db -1
-; 268ca
-DecoCarpetMenu: ; 268ca
+DecoCarpetMenu:
call FindOwnedCarpets
call PopulateDecoCategoryMenu
xor a
ret
-; 268d2
-FindOwnedCarpets: ; 268d2
+FindOwnedCarpets:
ld hl, .carpets
ld c, CARPETS
jp FindOwnedDecosInCategory
-; 268da
-.carpets ; 268da
+.carpets
db DECO_RED_CARPET ; 7
db DECO_BLUE_CARPET ; 8
db DECO_YELLOW_CARPET ; 9
db DECO_GREEN_CARPET ; a
db -1
-; 268df
-DecoPlantMenu: ; 268df
+DecoPlantMenu:
call FindOwnedPlants
call PopulateDecoCategoryMenu
xor a
ret
-; 268e7
-FindOwnedPlants: ; 268e7
+FindOwnedPlants:
ld hl, .plants
ld c, PLANTS
jp FindOwnedDecosInCategory
-; 268ef
-.plants ; 268ef
+.plants
db DECO_MAGNAPLANT ; c
db DECO_TROPICPLANT ; d
db DECO_JUMBOPLANT ; e
db -1
-; 268f3
-DecoPosterMenu: ; 268f3
+DecoPosterMenu:
call FindOwnedPosters
call PopulateDecoCategoryMenu
xor a
ret
-; 268fb
-FindOwnedPosters: ; 268fb
+FindOwnedPosters:
ld hl, .posters
ld c, POSTERS
jp FindOwnedDecosInCategory
-; 26903
-.posters ; 26903
+.posters
db DECO_TOWN_MAP ; 10
db DECO_PIKACHU_POSTER ; 11
db DECO_CLEFAIRY_POSTER ; 12
db DECO_JIGGLYPUFF_POSTER ; 13
db -1
-; 26908
-DecoConsoleMenu: ; 26908
+DecoConsoleMenu:
call FindOwnedConsoles
call PopulateDecoCategoryMenu
xor a
ret
-; 26910
-FindOwnedConsoles: ; 26910
+FindOwnedConsoles:
ld hl, .consoles
ld c, CONSOLES
jp FindOwnedDecosInCategory
-; 26918
-.consoles ; 26918
+.consoles
db DECO_FAMICOM ; 15
db DECO_SNES ; 16
db DECO_N64 ; 17
db DECO_VIRTUAL_BOY ; 18
db -1
-; 2691d
-DecoOrnamentMenu: ; 2691d
+DecoOrnamentMenu:
call FindOwnedOrnaments
call PopulateDecoCategoryMenu
xor a
ret
-; 26925
-FindOwnedOrnaments: ; 26925
+FindOwnedOrnaments:
ld hl, .ornaments
ld c, DOLLS
jp FindOwnedDecosInCategory
-; 2692d
-.ornaments ; 2692d
+.ornaments
db DECO_PIKACHU_DOLL ; 1e
db DECO_SURF_PIKACHU_DOLL ; 1f
db DECO_CLEFAIRY_DOLL ; 20
@@ -339,34 +315,29 @@ FindOwnedOrnaments: ; 26925
db DECO_GOLD_TROPHY_DOLL ; 33
db DECO_SILVER_TROPHY_DOLL ; 34
db -1
-; 26945
-DecoBigDollMenu: ; 26945
+DecoBigDollMenu:
call FindOwnedBigDolls
call PopulateDecoCategoryMenu
xor a
ret
-; 2694d
-FindOwnedBigDolls: ; 2694d
+FindOwnedBigDolls:
ld hl, .big_dolls
ld c, BIG_DOLLS
jp FindOwnedDecosInCategory
-; 26955
-.big_dolls ; 26955
+.big_dolls
db DECO_BIG_SNORLAX_DOLL ; 1a
db DECO_BIG_ONIX_DOLL ; 1b
db DECO_BIG_LAPRAS_DOLL ; 1c
db -1
-; 26959
-DecoExitMenu: ; 26959
+DecoExitMenu:
scf
ret
-; 2695b
-PopulateDecoCategoryMenu: ; 2695b
+PopulateDecoCategoryMenu:
ld a, [wd002]
and a
jr z, .empty
@@ -413,7 +384,6 @@ PopulateDecoCategoryMenu: ; 2695b
ld hl, .Text_nothing_to_choose
call MenuTextBoxBackup
ret
-; 269b0
.Text_nothing_to_choose: ; 0x269b0
; There's nothing to choose.
@@ -451,26 +421,23 @@ PopulateDecoCategoryMenu: ; 2695b
dba DecorationMenuFunction
dbw 0, 0
dbw 0, 0
-; 269dd
-GetDecorationData: ; 269dd
+GetDecorationData:
ld hl, DecorationAttributes
ld bc, 6
call AddNTimes
ret
-; 269e7
-GetDecorationName: ; 269e7
+GetDecorationName:
push hl
call GetDecorationData
call GetDecoName
pop hl
call CopyName2
ret
-; 269f3
-DecorationMenuFunction: ; 269f3
+DecorationMenuFunction:
ld a, [wMenuSelection]
push de
call GetDecorationData
@@ -478,9 +445,8 @@ DecorationMenuFunction: ; 269f3
pop hl
call PlaceString
ret
-; 26a02
-DoDecorationAction2: ; 26a02
+DoDecorationAction2:
ld a, [wMenuSelection]
call GetDecorationData
ld de, 2 ; function 2
@@ -489,9 +455,8 @@ DoDecorationAction2: ; 26a02
ld hl, .DecoActions
rst JumpTable
ret
-; 26a12
-.DecoActions: ; 26a12
+.DecoActions:
dw DecoAction_nothing
dw DecoAction_setupbed
dw DecoAction_putawaybed
@@ -507,10 +472,9 @@ DoDecorationAction2: ; 26a02
dw DecoAction_putawaybigdoll
dw DecoAction_setupornament
dw DecoAction_putawayornament
-; 26a30
-GetDecorationFlag: ; 26a30
+GetDecorationFlag:
call GetDecorationData
ld de, 3 ; event flag
add hl, de
@@ -518,17 +482,15 @@ GetDecorationFlag: ; 26a30
ld d, [hl]
ld e, a
ret
-; 26a3b
-DecorationFlagAction: ; 26a3b
+DecorationFlagAction:
push bc
call GetDecorationFlag
pop bc
call EventFlagAction
ret
-; 26a44
-GetDecorationSprite: ; 26a44
+GetDecorationSprite:
ld a, c
call GetDecorationData
ld de, 5 ; sprite
@@ -536,13 +498,12 @@ GetDecorationSprite: ; 26a44
ld a, [hl]
ld c, a
ret
-; 26a4f
INCLUDE "data/decorations/attributes.asm"
INCLUDE "data/decorations/names.asm"
-GetDecoName: ; 26c72
+GetDecoName:
ld a, [hli]
ld e, [hl]
ld bc, wStringBuffer2
@@ -551,9 +512,8 @@ GetDecoName: ; 26c72
rst JumpTable
pop de
ret
-; 26c7e
-.NameFunctions: ; 26c7e
+.NameFunctions:
dw .invalid
dw .plant
dw .bed
@@ -561,40 +521,38 @@ GetDecoName: ; 26c72
dw .poster
dw .doll
dw .bigdoll
-; 26c8c
-.invalid ; 26c8c
+.invalid
ret
-; 26c8d
-.plant ; 26c8d
+.plant
ld a, e
jr .getdeconame
-.bed ; 26c90
+.bed
call .plant
ld a, _BED
jr .getdeconame
-.carpet ; 26c97
+.carpet
call .plant
ld a, _CARPET
jr .getdeconame
-.poster ; 26c9e
+.poster
ld a, e
call .getpokename
ld a, _POSTER
jr .getdeconame
-.doll ; 26ca6
+.doll
ld a, e
call .getpokename
ld a, _DOLL
jr .getdeconame
-.bigdoll ; 26cae
+.bigdoll
push de
ld a, BIG_
call .getdeconame
@@ -602,25 +560,25 @@ GetDecoName: ; 26c72
ld a, e
jr .getpokename
-.unused ; 26cb8
+.unused
push de
call .getdeconame
pop de
ld a, e
jr .getdeconame
-.getpokename ; 26cc0
+.getpokename
push bc
ld [wd265], a
call GetPokemonName
pop bc
jr .copy
-.getdeconame ; 26cca
+.getdeconame
call ._getdeconame
jr .copy
-._getdeconame ; 26ccf
+._getdeconame
push bc
ld hl, DecorationNames
call GetNthString
@@ -629,7 +587,7 @@ GetDecoName: ; 26c72
pop bc
ret
-.copy ; 26cda
+.copy
ld h, b
ld l, c
call CopyName2
@@ -637,74 +595,60 @@ GetDecoName: ; 26c72
ld b, h
ld c, l
ret
-; 26ce3
-DecoAction_nothing: ; 26ce3
+DecoAction_nothing:
scf
ret
-; 26ce5
-DecoAction_setupbed: ; 26ce5
+DecoAction_setupbed:
ld hl, wDecoBed
jp DecoAction_TrySetItUp
-; 26ceb
-DecoAction_putawaybed: ; 26ceb
+DecoAction_putawaybed:
ld hl, wDecoBed
jp DecoAction_TryPutItAway
-; 26cf1
-DecoAction_setupcarpet: ; 26cf1
+DecoAction_setupcarpet:
ld hl, wDecoCarpet
jp DecoAction_TrySetItUp
-; 26cf7
-DecoAction_putawaycarpet: ; 26cf7
+DecoAction_putawaycarpet:
ld hl, wDecoCarpet
jp DecoAction_TryPutItAway
-; 26cfd
-DecoAction_setupplant: ; 26cfd
+DecoAction_setupplant:
ld hl, wDecoPlant
jp DecoAction_TrySetItUp
-; 26d03
-DecoAction_putawayplant: ; 26d03
+DecoAction_putawayplant:
ld hl, wDecoPlant
jp DecoAction_TryPutItAway
-; 26d09
-DecoAction_setupposter: ; 26d09
+DecoAction_setupposter:
ld hl, wDecoPoster
jp DecoAction_TrySetItUp
-; 26d0f
-DecoAction_putawayposter: ; 26d0f
+DecoAction_putawayposter:
ld hl, wDecoPoster
jp DecoAction_TryPutItAway
-; 26d15
-DecoAction_setupconsole: ; 26d15
+DecoAction_setupconsole:
ld hl, wDecoConsole
jp DecoAction_TrySetItUp
-; 26d1b
-DecoAction_putawayconsole: ; 26d1b
+DecoAction_putawayconsole:
ld hl, wDecoConsole
jp DecoAction_TryPutItAway
-; 26d21
-DecoAction_setupbigdoll: ; 26d21
+DecoAction_setupbigdoll:
ld hl, wDecoBigDoll
jp DecoAction_TrySetItUp
-; 26d27
-DecoAction_putawaybigdoll: ; 26d27
+DecoAction_putawaybigdoll:
ld hl, wDecoBigDoll
jp DecoAction_TryPutItAway
-; 26d2d
-DecoAction_TrySetItUp: ; 26d2d
+DecoAction_TrySetItUp:
ld a, [hl]
ld [wBuffer1], a
push hl
@@ -722,9 +666,8 @@ DecoAction_TrySetItUp: ; 26d2d
pop hl
xor a
ret
-; 26d46
-DecoAction_SetItUp: ; 26d46
+DecoAction_SetItUp:
; See if there's anything of the same type already out
ld a, [wBuffer1]
and a
@@ -760,9 +703,8 @@ DecoAction_SetItUp: ; 26d46
call MenuTextBoxBackup
scf
ret
-; 26d86
-DecoAction_TryPutItAway: ; 26d86
+DecoAction_TryPutItAway:
; If there is no item of that type already set, there is nothing to put away.
ld a, [hl]
ld [wBuffer1], a
@@ -788,9 +730,8 @@ DecoAction_TryPutItAway: ; 26d86
call MenuTextBoxBackup
xor a
ret
-; 26db3
-DecoAction_setupornament: ; 26db3
+DecoAction_setupornament:
ld hl, UnknownText_0x26e41
call DecoAction_AskWhichSide
jr c, .cancel
@@ -804,7 +745,7 @@ DecoAction_setupornament: ; 26db3
xor a
ret
-DecoAction_putawayornament: ; 26dc9
+DecoAction_putawayornament:
ld hl, DecoText_WhichSide
call DecoAction_AskWhichSide
jr nc, .incave
@@ -814,7 +755,7 @@ DecoAction_putawayornament: ; 26dc9
.incave
call DecoAction_PutItAway_Ornament
-DecoAction_FinishUp_Ornament: ; 26dd6
+DecoAction_FinishUp_Ornament:
call QueryWhichSide
ld a, [wSelectedDecoration]
ld [hl], a
@@ -822,9 +763,8 @@ DecoAction_FinishUp_Ornament: ; 26dd6
ld [de], a
xor a
ret
-; 26de3
-DecoAction_SetItUp_Ornament: ; 26de3
+DecoAction_SetItUp_Ornament:
ld a, [wSelectedDecoration]
and a
jr z, .nothingthere
@@ -863,9 +803,8 @@ DecoAction_SetItUp_Ornament: ; 26de3
call MenuTextBoxBackup
scf
ret
-; 26e33
-.getwhichside ; 26e33
+.getwhichside
ld a, [wMenuSelection]
ld b, a
ld a, [wOtherDecoration]
@@ -874,7 +813,6 @@ DecoAction_SetItUp_Ornament: ; 26de3
xor a
ld [wOtherDecoration], a
ret
-; 26e41
UnknownText_0x26e41: ; 0x26e41
; Which side do you want to put it on?
@@ -882,7 +820,7 @@ UnknownText_0x26e41: ; 0x26e41
db "@"
; 0x26e46
-DecoAction_PutItAway_Ornament: ; 26e46
+DecoAction_PutItAway_Ornament:
ld a, [wSelectedDecoration]
and a
jr z, .nothingthere
@@ -902,7 +840,6 @@ DecoAction_PutItAway_Ornament: ; 26e46
call MenuTextBoxBackup
xor a
ret
-; 26e6b
DecoText_WhichSide: ; 0x26e6b
; Which side do you want to put away?
@@ -910,7 +847,7 @@ DecoText_WhichSide: ; 0x26e6b
db "@"
; 0x26e70
-DecoAction_AskWhichSide: ; 26e70
+DecoAction_AskWhichSide:
call MenuTextBox
ld hl, MenuHeader_0x26eab
call GetMenu2
@@ -932,9 +869,8 @@ DecoAction_AskWhichSide: ; 26e70
.nope
scf
ret
-; 26e9a
-QueryWhichSide: ; 26e9a
+QueryWhichSide:
ld hl, wDecoRightOrnament
ld de, wDecoLeftOrnament
ld a, [wBuffer2]
@@ -945,7 +881,6 @@ QueryWhichSide: ; 26e9a
ld l, e
pop de
ret
-; 26eab
MenuHeader_0x26eab: ; 0x26eab
db MENU_BACKUP_TILES ; flags
@@ -992,21 +927,19 @@ DecoText_AlreadySetUp: ; 0x26ee5
db "@"
; 0x26eea
-GetDecorationName_c_de: ; 26eea
+GetDecorationName_c_de:
ld a, c
ld h, d
ld l, e
call GetDecorationName
ret
-; 26ef1
-DecorationFlagAction_c: ; 26ef1
+DecorationFlagAction_c:
ld a, c
jp DecorationFlagAction
-; 26ef5
-GetDecorationName_c: ; 26ef5 (9:6ef5)
+GetDecorationName_c:
ld a, c
call GetDecorationID
ld hl, wStringBuffer1
@@ -1016,15 +949,14 @@ GetDecorationName_c: ; 26ef5 (9:6ef5)
ret
-SetSpecificDecorationFlag: ; 26f02
+SetSpecificDecorationFlag:
ld a, c
call GetDecorationID
ld b, SET_FLAG
call DecorationFlagAction
ret
-; 26f0c
-GetDecorationID: ; 26f0c
+GetDecorationID:
push hl
push de
ld e, a
@@ -1035,9 +967,8 @@ GetDecorationID: ; 26f0c
pop de
pop hl
ret
-; 26f19
-SetAllDecorationFlags: ; 26f19
+SetAllDecorationFlags:
ld hl, DecorationIDs
.loop
ld a, [hli]
@@ -1051,27 +982,24 @@ SetAllDecorationFlags: ; 26f19
.done
ret
-; 26f2b
INCLUDE "data/decorations/decorations.asm"
-DescribeDecoration:: ; 26f59
+DescribeDecoration::
ld a, b
ld hl, .JumpTable
rst JumpTable
ret
-; 26f5f
-.JumpTable: ; 26f5f
+.JumpTable:
; entries correspond to DECODESC_* constants
dw DecorationDesc_Poster
dw DecorationDesc_LeftOrnament
dw DecorationDesc_RightOrnament
dw DecorationDesc_GiantOrnament
dw DecorationDesc_Console
-; 26f69
-DecorationDesc_Poster: ; 26f69
+DecorationDesc_Poster:
ld a, [wDecoPoster]
ld hl, DecorationDesc_PosterPointers
ld de, 3
@@ -1088,15 +1016,13 @@ DecorationDesc_Poster: ; 26f69
ld d, [hl]
ld e, a
ret
-; 26f84
-DecorationDesc_PosterPointers: ; 26f84
+DecorationDesc_PosterPointers:
dbw DECO_TOWN_MAP, DecorationDesc_TownMapPoster
dbw DECO_PIKACHU_POSTER, DecorationDesc_PikachuPoster
dbw DECO_CLEFAIRY_POSTER, DecorationDesc_ClefairyPoster
dbw DECO_JIGGLYPUFF_POSTER, DecorationDesc_JigglypuffPoster
db -1
-; 26f91
DecorationDesc_TownMapPoster: ; 0x26f91
opentext
@@ -1143,34 +1069,31 @@ DecorationDesc_JigglypuffPoster: ; 0x26fb0
db "@"
; 0x26fb8
-DecorationDesc_NullPoster: ; 26fb8
+DecorationDesc_NullPoster:
end
-; 26fb9
-DecorationDesc_LeftOrnament: ; 26fb9
+DecorationDesc_LeftOrnament:
ld a, [wDecoLeftOrnament]
jr DecorationDesc_OrnamentOrConsole
-DecorationDesc_RightOrnament: ; 26fbe
+DecorationDesc_RightOrnament:
ld a, [wDecoRightOrnament]
jr DecorationDesc_OrnamentOrConsole
-DecorationDesc_Console: ; 26fc3
+DecorationDesc_Console:
ld a, [wDecoConsole]
jr DecorationDesc_OrnamentOrConsole
-DecorationDesc_OrnamentOrConsole: ; 26fc8
+DecorationDesc_OrnamentOrConsole:
ld c, a
ld de, wStringBuffer3
call GetDecorationName_c_de
ld b, BANK(.OrnamentConsoleScript)
ld de, .OrnamentConsoleScript
ret
-; 26fd5
-.OrnamentConsoleScript: ; 26fd5
+.OrnamentConsoleScript:
jumptext .OrnamentConsoleText
-; 26fd8
.OrnamentConsoleText: ; 0x26fd8
; It's an adorable @ .
@@ -1178,15 +1101,13 @@ DecorationDesc_OrnamentOrConsole: ; 26fc8
db "@"
; 0x26fdd
-DecorationDesc_GiantOrnament: ; 26fdd
+DecorationDesc_GiantOrnament:
ld b, BANK(.BigDollScript)
ld de, .BigDollScript
ret
-; 26fe3
-.BigDollScript: ; 26fe3
+.BigDollScript:
jumptext .BigDollText
-; 26fe6
.BigDollText: ; 0x26fe6
; A giant doll! It's fluffy and cuddly.
@@ -1194,7 +1115,7 @@ DecorationDesc_GiantOrnament: ; 26fdd
db "@"
; 0x26feb
-ToggleMaptileDecorations: ; 26feb
+ToggleMaptileDecorations:
lb de, 0, 4
ld a, [wDecoBed]
call SetDecorationTile
@@ -1223,9 +1144,8 @@ ToggleMaptileDecorations: ; 26feb
dec a
ld [hl], a
ret
-; 27027
-SetPosterVisibility: ; 27027
+SetPosterVisibility:
ld b, SET_FLAG
ld a, [wDecoPoster]
and a
@@ -1235,9 +1155,8 @@ SetPosterVisibility: ; 27027
.ok
ld de, EVENT_PLAYERS_ROOM_POSTER
jp EventFlagAction
-; 27037
-SetDecorationTile: ; 27037
+SetDecorationTile:
push af
call PadCoords_de
pop af
@@ -1246,9 +1165,8 @@ SetDecorationTile: ; 27037
call _GetDecorationSprite
ld [hl], a
ret
-; 27043
-ToggleDecorationsVisibility: ; 27043
+ToggleDecorationsVisibility:
ld de, EVENT_PLAYERS_HOUSE_2F_CONSOLE
ld hl, wVariableSprites + SPRITE_CONSOLE - SPRITE_VARS
ld a, [wDecoConsole]
@@ -1266,9 +1184,8 @@ ToggleDecorationsVisibility: ; 27043
ld a, [wDecoBigDoll]
call ToggleDecorationVisibility
ret
-; 27074
-ToggleDecorationVisibility: ; 27074
+ToggleDecorationVisibility:
and a
jr z, .hide
call _GetDecorationSprite
@@ -1279,9 +1196,8 @@ ToggleDecorationVisibility: ; 27074
.hide
ld b, SET_FLAG
jp EventFlagAction
-; 27085
-_GetDecorationSprite: ; 27085
+_GetDecorationSprite:
ld c, a
push de
push hl
@@ -1290,9 +1206,8 @@ _GetDecorationSprite: ; 27085
pop de
ld a, c
ret
-; 27092
-PadCoords_de: ; 27092
+PadCoords_de:
ld a, d
add 4
ld d, a
diff --git a/engine/overworld/events.asm b/engine/overworld/events.asm
index cc2c8c574..daa7b8414 100644
--- a/engine/overworld/events.asm
+++ b/engine/overworld/events.asm
@@ -3,7 +3,7 @@ INCLUDE "constants.asm"
SECTION "Events", ROMX
-OverworldLoop:: ; 966b0
+OverworldLoop::
xor a
ld [wMapStatus], a
.loop
@@ -21,99 +21,83 @@ OverworldLoop:: ; 966b0
dw EnterMap
dw HandleMap
dw .done
-; 966cb
-DisableEvents: ; 966cb
+DisableEvents:
xor a
ld [wScriptFlags3], a
ret
-; 966d0
-EnableEvents:: ; 966d0
+EnableEvents::
ld a, $ff
ld [wScriptFlags3], a
ret
-; 966d6
-CheckBit5_ScriptFlags3: ; 966d6
+CheckBit5_ScriptFlags3:
ld hl, wScriptFlags3
bit 5, [hl]
ret
-; 966dc
-DisableWarpsConnxns: ; 966dc
+DisableWarpsConnxns:
ld hl, wScriptFlags3
res 2, [hl]
ret
-; 966e2
-DisableCoordEvents: ; 966e2
+DisableCoordEvents:
ld hl, wScriptFlags3
res 1, [hl]
ret
-; 966e8
-DisableStepCount: ; 966e8
+DisableStepCount:
ld hl, wScriptFlags3
res 0, [hl]
ret
-; 966ee
-DisableWildEncounters: ; 966ee
+DisableWildEncounters:
ld hl, wScriptFlags3
res 4, [hl]
ret
-; 966f4
-EnableWarpsConnxns: ; 966f4
+EnableWarpsConnxns:
ld hl, wScriptFlags3
set 2, [hl]
ret
-; 966fa
-EnableCoordEvents: ; 966fa
+EnableCoordEvents:
ld hl, wScriptFlags3
set 1, [hl]
ret
-; 96700
-EnableStepCount: ; 96700
+EnableStepCount:
ld hl, wScriptFlags3
set 0, [hl]
ret
-; 96706
-EnableWildEncounters: ; 96706
+EnableWildEncounters:
ld hl, wScriptFlags3
set 4, [hl]
ret
-; 9670c
-CheckWarpConnxnScriptFlag: ; 9670c
+CheckWarpConnxnScriptFlag:
ld hl, wScriptFlags3
bit 2, [hl]
ret
-; 96712
-CheckCoordEventScriptFlag: ; 96712
+CheckCoordEventScriptFlag:
ld hl, wScriptFlags3
bit 1, [hl]
ret
-; 96718
-CheckStepCountScriptFlag: ; 96718
+CheckStepCountScriptFlag:
ld hl, wScriptFlags3
bit 0, [hl]
ret
-; 9671e
-CheckWildEncountersScriptFlag: ; 9671e
+CheckWildEncountersScriptFlag:
ld hl, wScriptFlags3
bit 4, [hl]
ret
-; 96724
-StartMap: ; 96724
+StartMap:
xor a
ld [wScriptVar], a
xor a
@@ -123,7 +107,7 @@ StartMap: ; 96724
call ByteFill
farcall InitCallReceiveDelay
call ClearJoypad
-EnterMap: ; 9673e
+EnterMap:
xor a
ld [wXYComparePointer], a
ld [wXYComparePointer + 1], a
@@ -149,15 +133,13 @@ EnterMap: ; 9673e
ld a, 2 ; HandleMap
ld [wMapStatus], a
ret
-; 9676d
-UnusedWait30Frames: ; 9676d
+UnusedWait30Frames:
ld c, 30
call DelayFrames
ret
-; 96773
-HandleMap: ; 96773
+HandleMap:
call ResetOverworldDelay
call HandleMapTimeAndJoypad
farcall HandleCmdQueue ; no need to farcall
@@ -173,9 +155,8 @@ HandleMap: ; 96773
call HandleMapBackground
call CheckPlayerState
ret
-; 96795
-MapEvents: ; 96795
+MapEvents:
ld a, [wMapEventStatus]
ld hl, .jumps
rst JumpTable
@@ -184,39 +165,33 @@ MapEvents: ; 96795
.jumps
dw .events
dw .no_events
-; 967a1
-.events ; 967a1
+.events
call PlayerEvents
call DisableEvents
farcall ScriptEvents
ret
-; 967ae
-.no_events ; 967ae
+.no_events
ret
-; 967af
-MaxOverworldDelay: ; 967af
+MaxOverworldDelay:
db 2
-; 967b0
-ResetOverworldDelay: ; 967b0
+ResetOverworldDelay:
ld a, [MaxOverworldDelay]
ld [wOverworldDelay], a
ret
-; 967b7
-NextOverworldFrame: ; 967b7
+NextOverworldFrame:
ld a, [wOverworldDelay]
and a
ret z
ld c, a
call DelayFrames
ret
-; 967c1
-HandleMapTimeAndJoypad: ; 967c1
+HandleMapTimeAndJoypad:
ld a, [wMapEventStatus]
cp 1 ; no events
ret z
@@ -225,23 +200,20 @@ HandleMapTimeAndJoypad: ; 967c1
call GetJoypad
call TimeOfDayPals
ret
-; 967d1
-HandleMapObjects: ; 967d1
+HandleMapObjects:
farcall HandleNPCStep ; engine/map_objects.asm
farcall _HandlePlayerStep
call _CheckObjectEnteringVisibleRange
ret
-; 967e1
-HandleMapBackground: ; 967e1
+HandleMapBackground:
farcall _UpdateSprites
farcall ScrollScreen
farcall PlaceMapNameSign
ret
-; 967f4
-CheckPlayerState: ; 967f4
+CheckPlayerState:
ld a, [wPlayerStepFlags]
bit 5, a ; in the middle of step
jr z, .events
@@ -259,17 +231,15 @@ CheckPlayerState: ; 967f4
ld a, 1 ; no events
ld [wMapEventStatus], a
ret
-; 96812
-_CheckObjectEnteringVisibleRange: ; 96812
+_CheckObjectEnteringVisibleRange:
ld hl, wPlayerStepFlags
bit 6, [hl]
ret z
farcall CheckObjectEnteringVisibleRange
ret
-; 9681f
-PlayerEvents: ; 9681f
+PlayerEvents:
xor a
; If there's already a player event, don't interrupt it.
ld a, [wScriptRunning]
@@ -318,9 +288,8 @@ PlayerEvents: ; 9681f
.ok2
scf
ret
-; 96867
-CheckTrainerBattle3: ; 96867
+CheckTrainerBattle3:
nop
nop
call CheckTrainerBattle2
@@ -333,9 +302,8 @@ CheckTrainerBattle3: ; 96867
.nope
xor a
ret
-; 96874
-CheckTileEvent: ; 96874
+CheckTileEvent:
; Check for warps, coord events, or wild battles.
call CheckWarpConnxnScriptFlag
@@ -399,9 +367,8 @@ CheckTileEvent: ; 96874
call GetMapScriptsBank
call CallScript
ret
-; 968c7
-CheckWildEncounterCooldown:: ; 968c7
+CheckWildEncounterCooldown::
ld hl, wWildEncounterCooldown
ld a, [hl]
and a
@@ -410,35 +377,30 @@ CheckWildEncounterCooldown:: ; 968c7
ret z
scf
ret
-; 968d1
-SetUpFiveStepWildEncounterCooldown: ; 968d1
+SetUpFiveStepWildEncounterCooldown:
ld a, 5
ld [wWildEncounterCooldown], a
ret
-; 968d7
-ret_968d7: ; 968d7
+ret_968d7:
ret
-;968d8
-SetMinTwoStepWildEncounterCooldown: ; 968d8
+SetMinTwoStepWildEncounterCooldown:
ld a, [wWildEncounterCooldown]
cp 2
ret nc
ld a, 2
ld [wWildEncounterCooldown], a
ret
-; 968e4
-Dummy_CheckScriptFlags3Bit5: ; 968e4
+Dummy_CheckScriptFlags3Bit5:
call CheckBit5_ScriptFlags3
ret z
call ret_2f3e
ret
-; 968ec
-RunSceneScript: ; 968ec
+RunSceneScript:
ld a, [wCurrMapSceneScriptCount]
and a
jr z, .nope
@@ -485,9 +447,8 @@ endr
.nope
xor a
ret
-; 9693a
-CheckTimeEvents: ; 9693a
+CheckTimeEvents:
ld a, [wLinkMode]
and a
jr nz, .nothing
@@ -517,15 +478,13 @@ CheckTimeEvents: ; 9693a
call CallScript
scf
ret
-; 96970
-.unused ; 96970
+.unused
ld a, 8
scf
ret
-; 96974
-OWPlayerInput: ; 96974
+OWPlayerInput:
call PlayerMovement
ret c
@@ -552,9 +511,8 @@ OWPlayerInput: ; 96974
pop af
scf
ret
-; 96999
-CheckAPressOW: ; 96999
+CheckAPressOW:
ld a, [hJoyPressed]
and A_BUTTON
ret z
@@ -566,17 +524,15 @@ CheckAPressOW: ; 96999
ret c
xor a
ret
-; 969ac
-PlayTalkObject: ; 969ac
+PlayTalkObject:
push de
ld de, SFX_READ_TEXT_2
call PlaySFX
pop de
ret
-; 969b5
-TryObjectEvent: ; 969b5
+TryObjectEvent:
farcall CheckFacingObject
jr c, .IsObject
xor a
@@ -627,9 +583,8 @@ TryObjectEvent: ; 969b5
dbw OBJECTTYPE_5, .five
dbw OBJECTTYPE_6, .six
db -1
-; 96a04
-.script ; 96a04
+.script
ld hl, MAPOBJECT_SCRIPT_POINTER
add hl, bc
ld a, [hli]
@@ -638,9 +593,8 @@ TryObjectEvent: ; 969b5
call GetMapScriptsBank
call CallScript
ret
-; 96a12
-.itemball ; 96a12
+.itemball
ld hl, MAPOBJECT_SCRIPT_POINTER
add hl, bc
ld a, [hli]
@@ -653,36 +607,30 @@ TryObjectEvent: ; 969b5
ld a, PLAYEREVENT_ITEMBALL
scf
ret
-; 96a29
-.trainer ; 96a29
+.trainer
call TalkToTrainer
ld a, PLAYEREVENT_TALKTOTRAINER
scf
ret
-; 96a30
-.three ; 96a30
+.three
xor a
ret
-; 96a32
-.four ; 96a32
+.four
xor a
ret
-; 96a34
-.five ; 96a34
+.five
xor a
ret
-; 96a36
-.six ; 96a36
+.six
xor a
ret
-; 96a38
-TryBGEvent: ; 96a38
+TryBGEvent:
call CheckFacingBGEvent
jr c, .is_bg_event
xor a
@@ -704,7 +652,6 @@ TryBGEvent: ; 96a38
dw .ifnotset
dw .itemifset
dw .copy
-; 96a59
.up
ld b, OW_UP
@@ -784,9 +731,8 @@ TryBGEvent: ; 96a38
.dontread
xor a
ret
-; 96ad8
-CheckBGEventFlag: ; 96ad8
+CheckBGEventFlag:
ld hl, wEngineBuffer4
ld a, [hli]
ld h, [hl]
@@ -802,16 +748,14 @@ CheckBGEventFlag: ; 96ad8
and a
pop hl
ret
-; 96af0
-PlayerMovement: ; 96af0
+PlayerMovement:
farcall DoPlayerMovement
ld a, c
ld hl, .pointers
rst JumpTable
ld a, c
ret
-; 96afd
.pointers
dw .zero
@@ -824,34 +768,30 @@ PlayerMovement: ; 96af0
dw .seven
.zero
-.four ; 96b0d
+.four
xor a
ld c, a
ret
-; 96b10
-.seven ; 96b10
+.seven
call ret_968d7 ; mobile
xor a
ld c, a
ret
-; 96b16
-.one ; 96b16
+.one
ld a, 5
ld c, a
scf
ret
-; 96b1b
-.two ; 96b1b
+.two
ld a, 9
ld c, a
scf
ret
-; 96b20
-.three ; 96b20
+.three
; force the player to move in some direction
ld a, BANK(Script_ForcedMovement)
ld hl, Script_ForcedMovement
@@ -860,17 +800,15 @@ PlayerMovement: ; 96af0
ld c, a
scf
ret
-; 96b2b
.five
-.six ; 96b2b
+.six
ld a, -1
ld c, a
and a
ret
-; 96b30
-CheckMenuOW: ; 96b30
+CheckMenuOW:
xor a
ld [hMenuReturn], a
ld [hMenuReturn + 1], a
@@ -899,36 +837,30 @@ CheckMenuOW: ; 96b30
call CallScript
scf
ret
-; 96b58
-StartMenuScript: ; 96b58
+StartMenuScript:
callasm StartMenu
jump StartMenuCallback
-; 96b5f
-SelectMenuScript: ; 96b5f
+SelectMenuScript:
callasm SelectMenu
jump SelectMenuCallback
-; 96b66
StartMenuCallback:
-SelectMenuCallback: ; 96b66
+SelectMenuCallback:
copybytetovar hMenuReturn
ifequal HMENURETURN_SCRIPT, .Script
ifequal HMENURETURN_ASM, .Asm
end
-; 96b72
-.Script: ; 96b72
+.Script:
ptjump wQueuedScriptBank
-; 96b75
-.Asm: ; 96b75
+.Asm:
ptcallasm wQueuedScriptBank
end
-; 96b79
-CountStep: ; 96b79
+CountStep:
; Don't count steps in link communication rooms.
ld a, [wLinkMode]
and a
@@ -993,16 +925,14 @@ CountStep: ; 96b79
ld a, 8
scf
ret
-; 96bd3
; unused
-.unreferenced ; 96bd3
+.unreferenced
ld a, 7
scf
ret
-; 96bd7
-DoRepelStep: ; 96bd7
+DoRepelStep:
ld a, [wRepelEffect]
and a
ret z
@@ -1016,9 +946,8 @@ DoRepelStep: ; 96bd7
call CallScript
scf
ret
-; 96beb
-DoPlayerEvent: ; 96beb
+DoPlayerEvent:
ld a, [wScriptRunning]
and a
ret z
@@ -1042,9 +971,8 @@ DoPlayerEvent: ; 96beb
ld a, [hl]
ld [wScriptPos + 1], a
ret
-; 96c0c
-PlayerEventScriptPointers: ; 96c0c
+PlayerEventScriptPointers:
dba Invalid_0x96c2d ; 0
dba SeenByTrainerScript ; 1
dba TalkToTrainerScript ; 2
@@ -1056,55 +984,45 @@ PlayerEventScriptPointers: ; 96c0c
dba HatchEggScript ; 8
dba ChangeDirectionScript ; 9
dba Invalid_0x96c2d ; 10
-; 96c2d
-Invalid_0x96c2d: ; 96c2d
+Invalid_0x96c2d:
end
-; 96c2e
; unused
end
-; 96c2f
-HatchEggScript: ; 96c2f
+HatchEggScript:
callasm OverworldHatchEgg
end
-; 96c34
-WarpToNewMapScript: ; 96c34
+WarpToNewMapScript:
warpsound
newloadmap MAPSETUP_DOOR
end
-; 96c38
-FallIntoMapScript: ; 96c38
+FallIntoMapScript:
newloadmap MAPSETUP_FALL
playsound SFX_KINESIS
applymovement PLAYER, MovementData_0x96c48
playsound SFX_STRENGTH
scall LandAfterPitfallScript
end
-; 96c48
-MovementData_0x96c48: ; 96c48
+MovementData_0x96c48:
skyfall
step_end
-; 96c4a
-LandAfterPitfallScript: ; 96c4a
+LandAfterPitfallScript:
earthquake 16
end
-; 96c4d
EdgeWarpScript: ; 4
reloadandreturn MAPSETUP_CONNECTION
-; 96c4f
ChangeDirectionScript: ; 9
deactivatefacing 3
callasm EnableWildEncounters
end
-; 96c56
INCLUDE "engine/overworld/scripting.asm"
diff --git a/engine/overworld/events_2.asm b/engine/overworld/events_2.asm
index 6e106541a..b7376d48d 100644
--- a/engine/overworld/events_2.asm
+++ b/engine/overworld/events_2.asm
@@ -1,14 +1,13 @@
; More overworld event handling.
-WarpToSpawnPoint:: ; 97c28
+WarpToSpawnPoint::
ld hl, wStatusFlags2
res STATUSFLAGS2_SAFARI_GAME_F, [hl]
res STATUSFLAGS2_BUG_CONTEST_TIMER_F, [hl]
ret
-; 97c30
-RunMemScript:: ; 97c30
+RunMemScript::
; If there is no script here, we don't need to be here.
ld a, [wMapReentryScriptQueueFlag]
and a
@@ -29,9 +28,8 @@ RunMemScript:: ; 97c30
call ByteFill
pop af
ret
-; 97c4f
-LoadScriptBDE:: ; 97c4f
+LoadScriptBDE::
; If there's already a script here, don't overwrite.
ld hl, wMapReentryScriptQueueFlag
ld a, [hl]
@@ -48,9 +46,8 @@ LoadScriptBDE:: ; 97c4f
ld [hl], d
scf
ret
-; 97c5f
-TryTileCollisionEvent:: ; 97c5f
+TryTileCollisionEvent::
call GetFacingTileCoord
ld [wEngineBuffer1], a
ld c, a
@@ -98,10 +95,9 @@ TryTileCollisionEvent:: ; 97c5f
ld a, $ff
scf
ret
-; 97cc0
-RandomEncounter:: ; 97cc0
+RandomEncounter::
; Random encounter
call CheckWildEncounterCooldown
@@ -139,16 +135,14 @@ RandomEncounter:: ; 97cc0
call CallScript
scf
ret
-; 97cf9
-WildBattleScript: ; 97cf9
+WildBattleScript:
randomwildmon
startbattle
reloadmapafterbattle
end
-; 97cfd
-CanUseSweetScent:: ; 97cfd
+CanUseSweetScent::
ld hl, wStatusFlags
bit STATUSFLAGS_NO_WILD_ENCOUNTERS_F, [hl]
jr nz, .no
@@ -170,17 +164,15 @@ CanUseSweetScent:: ; 97cfd
.no
and a
ret
-; 97d23
-_TryWildEncounter_BugContest: ; 97d23
+_TryWildEncounter_BugContest:
call TryWildEncounter_BugContest
ret nc
call ChooseWildEncounter_BugContest
farcall CheckRepelEffect
ret
-; 97d31
-ChooseWildEncounter_BugContest:: ; 97d31
+ChooseWildEncounter_BugContest::
; Pick a random mon out of ContestMons.
.loop
@@ -232,9 +224,8 @@ ChooseWildEncounter_BugContest:: ; 97d31
xor a
ret
-; 97d64
-TryWildEncounter_BugContest: ; 97d64
+TryWildEncounter_BugContest:
ld a, [wPlayerStandingTile]
call CheckSuperTallGrassTile
ld b, 40 percent
@@ -251,13 +242,12 @@ TryWildEncounter_BugContest: ; 97d64
ld a, 1
and a
ret
-; 97d87
INCLUDE "data/wild/bug_contest_mons.asm"
-DoBikeStep:: ; 97db3
+DoBikeStep::
nop
nop
; If the bike shop owner doesn't have our number, or
@@ -322,9 +312,8 @@ DoBikeStep:: ; 97db3
.NoCall:
xor a
ret
-; 97df9
-ClearCmdQueue:: ; 97df9
+ClearCmdQueue::
ld hl, wCmdQueue
ld de, 6
ld c, 4
@@ -335,9 +324,8 @@ ClearCmdQueue:: ; 97df9
dec c
jr nz, .loop
ret
-; 97e08
-HandleCmdQueue:: ; 97e08
+HandleCmdQueue::
ld hl, wCmdQueue
xor a
.loop
@@ -359,18 +347,16 @@ HandleCmdQueue:: ; 97e08
cp CMDQUEUE_CAPACITY
jr nz, .loop
ret
-; 97e25
-Unreferenced_GetNthCmdQueueEntry: ; 97e25
+Unreferenced_GetNthCmdQueueEntry:
ld hl, wCmdQueue
ld bc, CMDQUEUE_ENTRY_SIZE
call AddNTimes
ld b, h
ld c, l
ret
-; 97e31
-WriteCmdQueue:: ; 97e31
+WriteCmdQueue::
push bc
push de
call .GetNextEmptyEntry
@@ -385,9 +371,8 @@ WriteCmdQueue:: ; 97e31
xor a
ld [hl], a
ret
-; 97e45
-.GetNextEmptyEntry: ; 97e45
+.GetNextEmptyEntry:
ld hl, wCmdQueue
ld de, CMDQUEUE_ENTRY_SIZE
ld c, CMDQUEUE_CAPACITY
@@ -406,9 +391,8 @@ WriteCmdQueue:: ; 97e31
sub c
and a
ret
-; 97e5c
-DelCmdQueue:: ; 97e5c
+DelCmdQueue::
ld hl, wCmdQueue
ld de, CMDQUEUE_ENTRY_SIZE
ld c, CMDQUEUE_CAPACITY
@@ -427,16 +411,14 @@ DelCmdQueue:: ; 97e5c
ld [hl], a
scf
ret
-; 97e72
-_DelCmdQueue: ; 97e72
+_DelCmdQueue:
ld hl, CMDQUEUE_TYPE
add hl, bc
ld [hl], 0
ret
-; 97e79
-HandleQueuedCommand: ; 97e79
+HandleQueuedCommand:
ld hl, CMDQUEUE_TYPE
add hl, bc
ld a, [hl]
@@ -459,62 +441,54 @@ HandleQueuedCommand: ; 97e79
pop af
rst FarCall
ret
-; 97e94
-.Jumptable: ; 97e94
+.Jumptable:
dba CmdQueue_Null
dba CmdQueue_Null2
dba CmdQueue_StoneTable
dba CmdQueue_Type3
dba CmdQueue_Type4
-; 97ea3
-CmdQueueAnonymousJumptable: ; 97ea3
+CmdQueueAnonymousJumptable:
ld hl, CMDQUEUE_05
add hl, bc
ld a, [hl]
pop hl
rst JumpTable
ret
-; 97eab
-CmdQueueAnonJT_Increment: ; 97eab
+CmdQueueAnonJT_Increment:
ld hl, CMDQUEUE_05
add hl, bc
inc [hl]
ret
-; 97eb1
-CmdQueueAnonJT_Decrement: ; 97eb1
+CmdQueueAnonJT_Decrement:
ld hl, CMDQUEUE_05
add hl, bc
dec [hl]
ret
-; 97eb7
-CmdQueue_Null: ; 97eb7
+CmdQueue_Null:
ret
-; 97eb8
-CmdQueue_Null2: ; 97eb8
+CmdQueue_Null2:
call ret_2f3e
ret
-; 97ebc
-CmdQueue_Type4: ; 97ebc
+CmdQueue_Type4:
call CmdQueueAnonymousJumptable
; anonymous dw
dw .zero
dw .one
-; 97ec3
-.zero ; 97ec3
+.zero
ld a, [hSCY]
ld hl, 4
add hl, bc
ld [hl], a
call CmdQueueAnonJT_Increment
-.one ; 97ecd
+.one
ld hl, 1
add hl, bc
ld a, [hl]
@@ -545,21 +519,19 @@ CmdQueue_Type4: ; 97ebc
ld [hSCY], a
call _DelCmdQueue
ret
-; 97ef9
-CmdQueue_Type3: ; 97ef9
+CmdQueue_Type3:
call CmdQueueAnonymousJumptable
; anonymous dw
dw .zero
dw .one
dw .two
-; 97f02
-.zero ; 97f02
+.zero
call .IsPlayerFacingDown
jr z, .PlayerNotFacingDown
call CmdQueueAnonJT_Increment
-.one ; 97f0a
+.one
call .IsPlayerFacingDown
jr z, .PlayerNotFacingDown
call CmdQueueAnonJT_Increment
@@ -569,9 +541,8 @@ CmdQueue_Type3: ; 97ef9
ld a, [hl]
ld [wd173], a
ret
-; 97f1b
-.two ; 97f1b
+.two
call .IsPlayerFacingDown
jr z, .PlayerNotFacingDown
call CmdQueueAnonJT_Decrement
@@ -581,27 +552,24 @@ CmdQueue_Type3: ; 97ef9
ld a, [hl]
ld [wd173], a
ret
-; 97f2c
-.PlayerNotFacingDown: ; 97f2c
+.PlayerNotFacingDown:
ld a, $7f
ld [wd173], a
ld hl, 5
add hl, bc
ld [hl], 0
ret
-; 97f38
-.IsPlayerFacingDown: ; 97f38
+.IsPlayerFacingDown:
push bc
ld bc, wPlayerStruct
call GetSpriteDirection
and a
pop bc
ret
-; 97f42
-CmdQueue_StoneTable: ; 97f42
+CmdQueue_StoneTable:
ld de, wPlayerStruct
ld a, NUM_OBJECT_STRUCTS
.loop
@@ -647,4 +615,3 @@ CmdQueue_StoneTable: ; 97f42
.fall_down_hole
pop af
ret
-; 97f7e
diff --git a/engine/overworld/init_map.asm b/engine/overworld/init_map.asm
index 2eb4998a6..ba1e74295 100644
--- a/engine/overworld/init_map.asm
+++ b/engine/overworld/init_map.asm
@@ -1,4 +1,4 @@
-ReanchorBGMap_NoOAMUpdate:: ; 6454
+ReanchorBGMap_NoOAMUpdate::
call DelayFrame
ld a, [hOAMUpdate]
push af
@@ -50,13 +50,13 @@ ReanchorBGMap_NoOAMUpdate:: ; 6454
call ApplyBGMapAnchorToObjects
ret
-.LoadBGMapAddrIntoHRAM: ; 64b9
+.LoadBGMapAddrIntoHRAM:
ld [hBGMapAddress + 1], a
xor a
ld [hBGMapAddress], a
ret
-LoadFonts_NoOAMUpdate:: ; 64bf
+LoadFonts_NoOAMUpdate::
ld a, [hOAMUpdate]
push af
ld a, $1
@@ -76,7 +76,7 @@ LoadFonts_NoOAMUpdate:: ; 64bf
call LoadStandardFont
ret
-HDMATransfer_FillBGMap0WithBlack: ; 64db
+HDMATransfer_FillBGMap0WithBlack:
ld a, [rSVBK]
push af
ld a, BANK(wDecompressScratch)
diff --git a/engine/overworld/load_map_part.asm b/engine/overworld/load_map_part.asm
index 9eeef7259..da1436406 100644
--- a/engine/overworld/load_map_part.asm
+++ b/engine/overworld/load_map_part.asm
@@ -1,4 +1,4 @@
-_LoadMapPart:: ; 4d15b
+_LoadMapPart::
ld hl, wSurroundingTiles
ld a, [wMetatileStandingY]
and a
diff --git a/engine/overworld/map_object_action.asm b/engine/overworld/map_object_action.asm
index 8c897d25a..613e3b099 100644
--- a/engine/overworld/map_object_action.asm
+++ b/engine/overworld/map_object_action.asm
@@ -1,4 +1,4 @@
-ObjectActionPairPointers: ; 445f
+ObjectActionPairPointers:
; entries correspond to OBJECT_ACTION_* constants
dw SetFacingStanding, SetFacingStanding
dw SetFacingStandAction, SetFacingCurrent
@@ -17,34 +17,30 @@ ObjectActionPairPointers: ; 445f
dw SetFacingBoulderDust, SetFacingStanding
dw SetFacingGrassShake, SetFacingStanding
dw SetFacingSkyfall, SetFacingCurrent
-; 44a3
-SetFacingStanding: ; 44a3
+SetFacingStanding:
ld hl, OBJECT_FACING_STEP
add hl, bc
ld [hl], STANDING
ret
-; 44aa
-SetFacingCurrent: ; 44aa
+SetFacingCurrent:
call GetSpriteDirection
or FACING_STEP_DOWN_0 ; useless
ld hl, OBJECT_FACING_STEP
add hl, bc
ld [hl], a
ret
-; 44b5
-SetFacingStandAction: ; 44b5
+SetFacingStandAction:
ld hl, OBJECT_FACING_STEP
add hl, bc
ld a, [hl]
and 1
jr nz, SetFacingStepAction
jp SetFacingCurrent
-; 44c1
-SetFacingStepAction: ; 44c1
+SetFacingStepAction:
ld hl, OBJECT_FLAGS1
add hl, bc
bit SLIDING_F, [hl]
@@ -69,9 +65,8 @@ SetFacingStepAction: ; 44c1
add hl, bc
ld [hl], a
ret
-; 44e4
-SetFacingSkyfall: ; 44e4
+SetFacingSkyfall:
ld hl, OBJECT_FLAGS1
add hl, bc
bit SLIDING_F, [hl]
@@ -96,9 +91,8 @@ SetFacingSkyfall: ; 44e4
add hl, bc
ld [hl], a
ret
-; 4508
-SetFacingBumpAction: ; 4508
+SetFacingBumpAction:
ld hl, OBJECT_FLAGS1
add hl, bc
bit SLIDING_F, [hl]
@@ -122,9 +116,8 @@ SetFacingBumpAction: ; 4508
add hl, bc
ld [hl], a
ret
-; 4529
-SetFacingCounterclockwiseSpin: ; 4529
+SetFacingCounterclockwiseSpin:
call CounterclockwiseSpinAction
ld hl, OBJECT_FACING
add hl, bc
@@ -134,14 +127,12 @@ SetFacingCounterclockwiseSpin: ; 4529
add hl, bc
ld [hl], a
ret
-; 4539
-SetFacingCounterclockwiseSpin2: ; 4539
+SetFacingCounterclockwiseSpin2:
call CounterclockwiseSpinAction
jp SetFacingStanding
-; 453f
-CounterclockwiseSpinAction: ; 453f
+CounterclockwiseSpinAction:
; Here, OBJECT_STEP_FRAME consists of two 2-bit components,
; using only bits 0,1 and 4,5.
; bits 0,1 is a timer (4 overworld frames)
@@ -179,13 +170,11 @@ CounterclockwiseSpinAction: ; 453f
add hl, bc
ld [hl], a
ret
-; 456a
-.Directions: ; 456a
+.Directions:
db OW_DOWN, OW_RIGHT, OW_UP, OW_LEFT
-; 456e
-SetFacingFish: ; 456e
+SetFacingFish:
call GetSpriteDirection
rrca
rrca
@@ -194,30 +183,26 @@ SetFacingFish: ; 456e
add hl, bc
ld [hl], a
ret
-; 457b
-SetFacingShadow: ; 457b
+SetFacingShadow:
ld hl, OBJECT_FACING_STEP
add hl, bc
ld [hl], FACING_SHADOW
ret
-; 4582
SetFacingEmote: ; 4582 emote
ld hl, OBJECT_FACING_STEP
add hl, bc
ld [hl], FACING_EMOTE
ret
-; 4589
-SetFacingBigDollSym: ; 4589
+SetFacingBigDollSym:
ld hl, OBJECT_FACING_STEP
add hl, bc
ld [hl], FACING_BIG_DOLL_SYM
ret
-; 4590
-SetFacingBounce: ; 4590
+SetFacingBounce:
ld hl, OBJECT_STEP_FRAME
add hl, bc
ld a, [hl]
@@ -230,16 +215,14 @@ SetFacingBounce: ; 4590
add hl, bc
ld [hl], FACING_STEP_UP_0
ret
-; 45a4
-SetFacingFreezeBounce: ; 45a4
+SetFacingFreezeBounce:
ld hl, OBJECT_FACING_STEP
add hl, bc
ld [hl], FACING_STEP_DOWN_0
ret
-; 45ab
-SetFacingWeirdTree: ; 45ab
+SetFacingWeirdTree:
ld hl, OBJECT_STEP_FRAME
add hl, bc
ld a, [hl]
@@ -253,16 +236,14 @@ SetFacingWeirdTree: ; 45ab
add hl, bc
ld [hl], a
ret
-; 45be
-SetFacingBigDollAsym: ; 45be
+SetFacingBigDollAsym:
ld hl, OBJECT_FACING_STEP
add hl, bc
ld [hl], FACING_BIG_DOLL_ASYM
ret
-; 45c5
-SetFacingBigDoll: ; 45c5
+SetFacingBigDoll:
ld a, [wVariableSprites + SPRITE_BIG_DOLL - SPRITE_VARS]
ld d, FACING_BIG_DOLL_SYM ; symmetric
cp SPRITE_BIG_SNORLAX
@@ -276,9 +257,8 @@ SetFacingBigDoll: ; 45c5
add hl, bc
ld [hl], d
ret
-; 45da
-SetFacingBoulderDust: ; 45da
+SetFacingBoulderDust:
ld hl, OBJECT_STEP_FRAME
add hl, bc
inc [hl]
@@ -293,9 +273,8 @@ SetFacingBoulderDust: ; 45da
.ok
ld [hl], a
ret
-; 45ed
-SetFacingGrassShake: ; 45ed
+SetFacingGrassShake:
ld hl, OBJECT_STEP_FRAME
add hl, bc
inc [hl]
@@ -310,4 +289,3 @@ SetFacingGrassShake: ; 45ed
.ok
ld [hl], a
ret
-; 4600
diff --git a/engine/overworld/map_objects.asm b/engine/overworld/map_objects.asm
index 7ed1d5f5f..0846f01b1 100644
--- a/engine/overworld/map_objects.asm
+++ b/engine/overworld/map_objects.asm
@@ -3,8 +3,7 @@ INCLUDE "data/sprites/facings.asm"
INCLUDE "data/sprites/map_objects.asm"
-; 4357
-DeleteMapObject:: ; 4357
+DeleteMapObject::
push bc
ld hl, OBJECT_MAP_OBJECT_INDEX
add hl, bc
@@ -27,9 +26,8 @@ DeleteMapObject:: ; 4357
.ok
pop bc
ret
-; 437b
-Function437b: ; 437b
+Function437b:
call .CheckObjectStillVisible
ret c
call .HandleStepType
@@ -156,9 +154,8 @@ Function437b: ; 437b
jr nz, asm_4448
ld de, ObjectActionPairPointers ; use first column
jr _HandleObjectAction
-; 4440
-Function4440: ; 4440
+Function4440:
ld hl, OBJECT_FLAGS1
add hl, bc
bit INVISIBLE_F, [hl]
@@ -166,7 +163,6 @@ Function4440: ; 4440
asm_4448:
ld de, ObjectActionPairPointers + 2 ; use second column
jr _HandleObjectAction
-; 444d
_HandleObjectAction:
; call [4 * wObjectStructs[ObjInd, OBJECT_ACTION] + de]
@@ -183,11 +179,10 @@ _HandleObjectAction:
ld l, a
call _hl_
ret
-; 445f
INCLUDE "engine/overworld/map_object_action.asm"
-CopyNextCoordsTileToStandingCoordsTile: ; 4600
+CopyNextCoordsTileToStandingCoordsTile:
ld hl, OBJECT_NEXT_MAP_X
add hl, bc
ld a, [hl]
@@ -212,9 +207,8 @@ CopyNextCoordsTileToStandingCoordsTile: ; 4600
ld a, [hl]
call UselessAndA
ret
-; 462a
-Function462a: ; 462a
+Function462a:
ld hl, OBJECT_MAP_X
add hl, bc
ld a, [hl]
@@ -228,9 +222,8 @@ Function462a: ; 462a
add hl, bc
ld [hl], a
ret
-; 463f
-UpdateTallGrassFlags: ; 463f
+UpdateTallGrassFlags:
ld hl, OBJECT_FLAGS2
add hl, bc
bit OVERHEAD_F, [hl]
@@ -250,9 +243,8 @@ UpdateTallGrassFlags: ; 463f
ld a, [hl]
call UselessAndA
ret
-; 4661
-SetTallGrassFlags: ; 4661
+SetTallGrassFlags:
call CheckSuperTallGrassTile
jr z, .set
call CheckGrassTile
@@ -268,14 +260,12 @@ SetTallGrassFlags: ; 4661
add hl, bc
res OVERHEAD_F, [hl]
ret
-; 4679
-UselessAndA: ; 4679
+UselessAndA:
and a
ret
-; 467b
-EndSpriteMovement: ; 467b
+EndSpriteMovement:
xor a
ld hl, OBJECT_STEP_FRAME
add hl, bc
@@ -290,9 +280,8 @@ EndSpriteMovement: ; 467b
add hl, bc
ld [hl], STANDING
ret
-; 4690
-InitStep: ; 4690
+InitStep:
ld hl, OBJECT_DIRECTION_WALKING
add hl, bc
ld [hl], a
@@ -306,7 +295,7 @@ InitStep: ; 4690
ld hl, OBJECT_FACING
add hl, bc
ld [hl], a
-GetNextTile: ; 46a6
+GetNextTile:
call GetStepVector
ld hl, OBJECT_STEP_DURATION
add hl, bc
@@ -336,9 +325,8 @@ GetNextTile: ; 46a6
add hl, bc
ld [hl], a
ret
-; 46d7
-AddStepVector: ; 46d7
+AddStepVector:
call GetStepVector
ld hl, OBJECT_SPRITE_X
add hl, bc
@@ -351,9 +339,8 @@ AddStepVector: ; 46d7
add e
ld [hl], a
ret
-; 46e9
-GetStepVector: ; 46e9
+GetStepVector:
; Return (x, y, duration, speed) in (d, e, a, h).
ld hl, OBJECT_DIRECTION_WALKING
add hl, bc
@@ -372,9 +359,8 @@ GetStepVector: ; 46e9
ld a, [hli]
ld h, [hl]
ret
-; 4700
-StepVectors: ; 4700
+StepVectors:
; x, y, duration, speed
; slow
db 0, 1, 16, 1
@@ -391,18 +377,16 @@ StepVectors: ; 4700
db 0, -4, 4, 4
db -4, 0, 4, 4
db 4, 0, 4, 4
-; 4730
-GetStepVectorSign: ; 4730
+GetStepVectorSign:
add a
ret z ; 0 or 128
ld a, 1
ret nc ; 1 - 127
ld a, -1
ret ; 129 - 255
-; 4738
-UpdatePlayerStep: ; 4738
+UpdatePlayerStep:
ld hl, OBJECT_DIRECTION_WALKING
add hl, bc
ld a, [hl]
@@ -418,9 +402,8 @@ UpdatePlayerStep: ; 4738
ld hl, wPlayerStepFlags
set 5, [hl]
ret
-; 4759
-Unreferenced_Function4759: ; 4759
+Unreferenced_Function4759:
push bc
ld e, a
ld d, 0
@@ -432,9 +415,8 @@ Unreferenced_Function4759: ; 4759
ld a, [hl]
pop bc
ret
-; 4769
-RestoreDefaultMovement: ; 4769
+RestoreDefaultMovement:
ld hl, OBJECT_MAP_OBJECT_INDEX
add hl, bc
ld a, [hl]
@@ -451,76 +433,66 @@ RestoreDefaultMovement: ; 4769
.ok
ld a, SPRITEMOVEFN_STANDING
ret
-; 4780
-ClearObjectMovementByteIndex: ; 4780
+ClearObjectMovementByteIndex:
ld hl, OBJECT_MOVEMENT_BYTE_INDEX
add hl, bc
ld [hl], 0
ret
-; 4787
-IncrementObjectMovementByteIndex: ; 4787
+IncrementObjectMovementByteIndex:
ld hl, OBJECT_MOVEMENT_BYTE_INDEX
add hl, bc
inc [hl]
ret
-; 478d
-DecrementObjectMovementByteIndex: ; 478d
+DecrementObjectMovementByteIndex:
ld hl, OBJECT_MOVEMENT_BYTE_INDEX
add hl, bc
dec [hl]
ret
-; 4793
-MovementAnonymousJumptable: ; 4793
+MovementAnonymousJumptable:
ld hl, OBJECT_MOVEMENT_BYTE_INDEX
add hl, bc
ld a, [hl]
pop hl
rst JumpTable
ret
-; 479b
-ClearObjectStructField1c: ; 479b
+ClearObjectStructField1c:
ld hl, OBJECT_1C
add hl, bc
ld [hl], 0
ret
-; 47a2
-IncrementObjectStructField1c: ; 47a2
+IncrementObjectStructField1c:
ld hl, OBJECT_1C
add hl, bc
inc [hl]
ret
-; 47a8
-Field1cAnonymousJumptable: ; 47a8
+Field1cAnonymousJumptable:
ld hl, OBJECT_1C
add hl, bc
ld a, [hl]
pop hl
rst JumpTable
ret
-; 47b0
-GetValueObjectStructField1c: ; 47b0
+GetValueObjectStructField1c:
ld hl, OBJECT_1C
add hl, bc
ld a, [hl]
ret
-; 47b6
-SetValueObjectStructField1c: ; 47b6
+SetValueObjectStructField1c:
ld hl, OBJECT_1C
add hl, bc
ld [hl], a
ret
-; 47bc
-ObjectMovementReset: ; 47bc
+ObjectMovementReset:
ld hl, OBJECT_NEXT_MAP_X
add hl, bc
ld d, [hl]
@@ -539,9 +511,8 @@ ObjectMovementReset: ; 47bc
add hl, bc
ld [hl], STEP_TYPE_SLEEP
ret
-; 47dd
-MapObjectMovementPattern: ; 47dd
+MapObjectMovementPattern:
call ClearObjectStructField1c
call GetSpriteMovementFunction
ld a, [hl]
@@ -549,7 +520,7 @@ MapObjectMovementPattern: ; 47dd
rst JumpTable
ret
-.Pointers: ; 47e9
+.Pointers:
; entries correspond to SPRITEMOVEFN_* constants
dw .Null_00 ; 00
dw .RandomWalkY ; 01
@@ -848,7 +819,7 @@ MapObjectMovementPattern: ; 47dd
call .MovementSpinNextFacing
jr .MovementSpinCounterclockwise
-.DirectionData_Counterclockwise: ; 49c0
+.DirectionData_Counterclockwise:
db OW_RIGHT, OW_LEFT, OW_DOWN, OW_UP
.MovementSpinTurnRight:
@@ -856,7 +827,7 @@ MapObjectMovementPattern: ; 47dd
call .MovementSpinNextFacing
jr .MovementSpinClockwise
-.DirectionData_Clockwise: ; 49cc
+.DirectionData_Clockwise:
db OW_LEFT, OW_RIGHT, OW_UP, OW_DOWN
.MovementSpinNextFacing:
@@ -969,7 +940,7 @@ MapObjectMovementPattern: ; 47dd
ld [hl], STEP_TYPE_TRACKING_OBJECT
ret
-.data_4a81 ; 4a81
+.data_4a81
; x, y
db 0, -4
db 0, 8
@@ -1073,18 +1044,17 @@ MapObjectMovementPattern: ; 47dd
.NewDuration:
call EndSpriteMovement
call Function462a
-RandomStepDuration_Slow: ; 4b1d
+RandomStepDuration_Slow:
call Random
ld a, [hRandomAdd]
and %01111111
jr SetRandomStepDuration
-; 4b26
-RandomStepDuration_Fast: ; 4b26
+RandomStepDuration_Fast:
call Random
ld a, [hRandomAdd]
and %00011111
-SetRandomStepDuration: ; 4b2d
+SetRandomStepDuration:
ld hl, OBJECT_STEP_DURATION
add hl, bc
ld [hl], a
@@ -1098,9 +1068,8 @@ SetRandomStepDuration: ; 4b2d
add hl, bc
ld [hl], STEP_TYPE_03
ret
-; 4b45
-StepTypesJumptable: ; 4b45
+StepTypesJumptable:
; entries correspond to STEP_TYPE_* constants
dw ObjectMovementReset ; 00
dw MapObjectMovementPattern ; 01
@@ -1128,9 +1097,8 @@ StepTypesJumptable: ; 4b45
dw StepType17 ; 17
dw StepType18 ; 18
dw SkyfallTop ; 19
-; 4b79
-WaitStep_InPlace: ; 4b79
+WaitStep_InPlace:
ld hl, OBJECT_STEP_DURATION
add hl, bc
dec [hl]
@@ -1139,9 +1107,8 @@ WaitStep_InPlace: ; 4b79
add hl, bc
ld [hl], STEP_TYPE_SLEEP
ret
-; 4b86
-NPCJump: ; 4b86
+NPCJump:
call Field1cAnonymousJumptable
; anonymous dw
dw .Jump
@@ -1174,9 +1141,8 @@ NPCJump: ; 4b86
add hl, bc
ld [hl], STEP_TYPE_SLEEP
ret
-; 4bbf
-PlayerJump: ; 4bbf
+PlayerJump:
call Field1cAnonymousJumptable
; anonymous dw
dw .initjump
@@ -1224,16 +1190,14 @@ PlayerJump: ; 4bbf
add hl, bc
ld [hl], STEP_TYPE_SLEEP
ret
-; 4c18
-TeleportFrom: ; 4c18
+TeleportFrom:
call Field1cAnonymousJumptable
; anonymous dw
dw .InitSpin
dw .DoSpin
dw .InitSpinRise
dw .DoSpinRise
-; 4c23
.InitSpin:
ld hl, OBJECT_STEP_FRAME
@@ -1294,9 +1258,8 @@ TeleportFrom: ; 4c18
add hl, bc
ld [hl], STEP_TYPE_SLEEP
ret
-; 4c89
-TeleportTo: ; 4c89
+TeleportTo:
call Field1cAnonymousJumptable
; anonymous dw
dw .InitWait
@@ -1306,7 +1269,6 @@ TeleportTo: ; 4c89
dw .InitFinalSpin
dw .DoFinalSpin
dw .FinishStep
-; 4c9a
.InitWait:
ld hl, OBJECT_ACTION
@@ -1317,7 +1279,6 @@ TeleportTo: ; 4c89
ld [hl], 16
call IncrementObjectStructField1c
ret
-; 4caa
.DoWait:
ld hl, OBJECT_STEP_DURATION
@@ -1337,7 +1298,6 @@ TeleportTo: ; 4c89
ld [hl], 16
call IncrementObjectStructField1c
ret
-; 4cc9
.DoDescent:
ld hl, OBJECT_ACTION
@@ -1365,7 +1325,6 @@ TeleportTo: ; 4c89
ld [hl], 16
call IncrementObjectStructField1c
ret
-; 4cf5
.DoFinalSpin:
ld hl, OBJECT_ACTION
@@ -1386,16 +1345,14 @@ TeleportTo: ; 4c89
add hl, bc
ld [hl], STEP_TYPE_SLEEP
ret
-; 4d14
-Skyfall: ; 4d14
+Skyfall:
call Field1cAnonymousJumptable
; anonymous dw
dw .Init
dw .Step
dw .Fall
dw .Finish
-; 4d1f
.Init:
ld hl, OBJECT_ACTION
@@ -1451,14 +1408,12 @@ Skyfall: ; 4d14
add hl, bc
ld [hl], STEP_TYPE_SLEEP
ret
-; 4d7e
-GotBiteStep: ; 4d7e
+GotBiteStep:
call Field1cAnonymousJumptable
; anonymous dw
dw .Init
dw .Run
-; 4d85
.Init:
ld hl, OBJECT_STEP_DURATION
@@ -1485,12 +1440,10 @@ GotBiteStep: ; 4d7e
add hl, bc
ld [hl], STEP_TYPE_SLEEP
ret
-; 4daf
-RockSmashStep: ; 4daf
+RockSmashStep:
call .Step
jp WaitStep_InPlace
-; 4db5
.Step:
ld hl, OBJECT_STEP_DURATION
@@ -1505,9 +1458,8 @@ RockSmashStep: ; 4daf
add hl, bc
ld [hl], a
ret
-; 4dc8
-ReturnDigStep: ; 4dc8
+ReturnDigStep:
ld hl, OBJECT_STEP_DURATION
add hl, bc
ld a, [hl]
@@ -1520,9 +1472,8 @@ ReturnDigStep: ; 4dc8
add hl, bc
ld [hl], a
jp WaitStep_InPlace
-; 4ddd
-StepType03: ; 4ddd
+StepType03:
ld hl, OBJECT_DIRECTION_WALKING
add hl, bc
ld [hl], STANDING
@@ -1534,9 +1485,8 @@ StepType03: ; 4ddd
add hl, bc
ld [hl], STEP_TYPE_SLEEP
ret
-; 4df0
-StepType18: ; 4df0
+StepType18:
ld hl, OBJECT_DIRECTION_WALKING
add hl, bc
ld [hl], STANDING
@@ -1545,9 +1495,8 @@ StepType18: ; 4df0
dec [hl]
ret nz
jp DeleteMapObject
-; 4dff
-StepTypeBump: ; 4dff
+StepTypeBump:
ld hl, OBJECT_STEP_DURATION
add hl, bc
dec [hl]
@@ -1556,9 +1505,8 @@ StepTypeBump: ; 4dff
add hl, bc
ld [hl], STEP_TYPE_SLEEP
ret
-; 4e0c
-StepType05: ; 4e0c
+StepType05:
call Field1cAnonymousJumptable
; anonymous dw
dw .Reset
@@ -1571,15 +1519,14 @@ StepType05: ; 4e0c
add hl, bc
ld [hl], a
call IncrementObjectStructField1c
-StepType04: ; 4e21
+StepType04:
call Stubbed_Function4fb2
ld hl, OBJECT_DIRECTION_WALKING
add hl, bc
ld [hl], STANDING
ret
-; 4e2b
-NPCStep: ; 4e2b
+NPCStep:
call Stubbed_Function4fb2
call AddStepVector
ld hl, OBJECT_STEP_DURATION
@@ -1594,9 +1541,8 @@ NPCStep: ; 4e2b
add hl, bc
ld [hl], STEP_TYPE_SLEEP
ret
-; 4e47
-StepType07: ; 4e47
+StepType07:
call AddStepVector
ld hl, OBJECT_STEP_DURATION
add hl, bc
@@ -1604,9 +1550,8 @@ StepType07: ; 4e47
ret nz
call CopyNextCoordsTileToStandingCoordsTile
jp RandomStepDuration_Slow
-; 4e56
-PlayerStep: ; 4e56
+PlayerStep:
; AnimateStep?
call Field1cAnonymousJumptable
; anonymous dw
@@ -1633,9 +1578,8 @@ PlayerStep: ; 4e56
add hl, bc
ld [hl], STEP_TYPE_SLEEP
ret
-; 4e83
-PlayerOrNPCTurnStep: ; 4e83
+PlayerOrNPCTurnStep:
call Field1cAnonymousJumptable
; anonymous dw
dw .init1
@@ -1681,9 +1625,8 @@ PlayerOrNPCTurnStep: ; 4e83
add hl, bc
ld [hl], STEP_TYPE_SLEEP
ret
-; 4ecd
-StepType0f: ; 4ecd
+StepType0f:
call AddStepVector
ld hl, OBJECT_STEP_DURATION
add hl, bc
@@ -1713,9 +1656,8 @@ StepType0f: ; 4ecd
add hl, bc
ld [hl], STEP_TYPE_SLEEP
ret
-; 4f04
-StepTypeTrackingObject: ; 4f04
+StepTypeTrackingObject:
ld hl, OBJECT_1D
add hl, bc
ld e, [hl]
@@ -1747,10 +1689,9 @@ StepTypeTrackingObject: ; 4f04
ret nz
.nope
jp DeleteMapObject
-; 4f33
-StepType14: ; 4f33
-StepType15: ; 4f33
+StepType14:
+StepType15:
call Field1cAnonymousJumptable
; anonymous dw
dw .Init
@@ -1797,21 +1738,18 @@ StepType15: ; 4f33
cpl
inc a
ret
-; 4f77
-StepType16: ; 4f77
+StepType16:
call Field1cAnonymousJumptable ; ????
-; 4f7a
-StepType17: ; 4f7a
+StepType17:
call Field1cAnonymousJumptable
; anonymous dw
dw .null
dw .null
dw .null
.null
-; 4f83
-SkyfallTop: ; 4f83
+SkyfallTop:
call Field1cAnonymousJumptable
; anonymous dw
dw .Init
@@ -1841,7 +1779,6 @@ SkyfallTop: ; 4f83
add hl, bc
ld [hl], STEP_TYPE_SLEEP
ret
-; 4fb2
Stubbed_Function4fb2:
ret
@@ -1862,10 +1799,9 @@ Stubbed_Function4fb2:
ld [hl], a
ret
-.y ; 4fcd
+.y
db 0, -1, -2, -3, -4, -3, -2, -1
-; 4fd5
-UpdateJumpPosition: ; 4fd5
+UpdateJumpPosition:
call GetStepVector
ld a, h
ld hl, OBJECT_1F
@@ -1884,10 +1820,9 @@ UpdateJumpPosition: ; 4fd5
ld [hl], a
ret
-.y ; 4ff0
+.y
db -4, -6, -8, -10, -11, -12, -12, -12
db -11, -10, -9, -8, -6, -4, 0, 0
-; 5000
Function5000: ; unscripted?
; copy [wPlayerNextMovement] to [wPlayerMovement]
ld a, [wPlayerNextMovement]
@@ -1899,15 +1834,13 @@ Function5000: ; unscripted?
; recover the previous value of [wPlayerNextMovement]
ld a, [hl]
ret
-; 500e
GetMovementByte:
ld hl, wMovementDataPointer
call _GetMovementByte
ret
-; 5015
-Function5015: ; 5015
+Function5015:
ld hl, OBJECT_MOVEMENT_BYTE_INDEX
add hl, bc
ld e, [hl]
@@ -1920,9 +1853,8 @@ Function5015: ; 5015
add hl, de
ld a, [hl]
ret
-; 5026
-Function5026: ; 5026
+Function5026:
ld hl, OBJECT_MOVEMENT_BYTE_INDEX
add hl, bc
ld e, [hl]
@@ -1935,19 +1867,16 @@ Function5026: ; 5026
add hl, de
ld a, [hl]
ret
-; 5037
-_GetMovementObject: ; 5037
+_GetMovementObject:
ld hl, GetMovementObject
jp HandleMovementData
-; 503d
-GetMovementObject: ; 503d
+GetMovementObject:
ld a, [wMovementObject]
ret
-; 5041
-HandleMovementData: ; 5041
+HandleMovementData:
call .StorePointer
.loop
xor a
@@ -1965,35 +1894,30 @@ HandleMovementData: ; 5041
ld a, h
ld [wMovementPointer + 1], a
ret
-; 505e
-JumpMovementPointer: ; 505e
+JumpMovementPointer:
ld hl, wMovementPointer
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
-; 5065
-ContinueReadingMovement: ; 5065
+ContinueReadingMovement:
ld a, 1
ld [wMovementByteWasControlSwitch], a
ret
-; 506b
-DoMovementFunction: ; 506b
+DoMovementFunction:
push af
call ApplyMovementToFollower
pop af
ld hl, MovementPointers
rst JumpTable
ret
-; 5075
INCLUDE "engine/overworld/movement.asm"
-; 54b8
-ApplyMovementToFollower: ; 54b8
+ApplyMovementToFollower:
ld e, a
ld a, [wObjectFollow_Follower]
cp -1
@@ -2024,9 +1948,8 @@ ApplyMovementToFollower: ; 54b8
pop af
ld [hl], a
ret
-; 54e6
-GetFollowerNextMovementByte: ; 54e6
+GetFollowerNextMovementByte:
ld hl, wFollowerMovementQueueLength
ld a, [hl]
and a
@@ -2075,9 +1998,8 @@ GetFollowerNextMovementByte: ; 54e6
ld a, movement_step_end
scf
ret
-; 5529
-SpawnShadow: ; 5529
+SpawnShadow:
push bc
ld de, .ShadowObject
call CopyTempObjectData
@@ -2088,9 +2010,8 @@ SpawnShadow: ; 5529
.ShadowObject:
; vtile, palette, movement
db $00, PAL_OW_SILVER, SPRITEMOVEDATA_SHADOW
-; 5538
-SpawnStrengthBoulderDust: ; 5538
+SpawnStrengthBoulderDust:
push bc
ld de, .BoulderDustObject
call CopyTempObjectData
@@ -2100,9 +2021,8 @@ SpawnStrengthBoulderDust: ; 5538
.BoulderDustObject:
db $00, PAL_OW_SILVER, SPRITEMOVEDATA_BOULDERDUST
-; 5547
-SpawnEmote: ; 5547
+SpawnEmote:
push bc
ld de, .EmoteObject
call CopyTempObjectData
@@ -2112,9 +2032,8 @@ SpawnEmote: ; 5547
.EmoteObject:
db $00, PAL_OW_SILVER, SPRITEMOVEDATA_EMOTE
-; 5556
-ShakeGrass: ; 5556
+ShakeGrass:
push bc
ld de, .GrassObject
call CopyTempObjectData
@@ -2124,9 +2043,8 @@ ShakeGrass: ; 5556
.GrassObject
db $00, PAL_OW_TREE, SPRITEMOVEDATA_GRASS
-; 5565
-ShakeScreen: ; 5565
+ShakeScreen:
push bc
push af
ld de, .ScreenShakeObject
@@ -2139,9 +2057,8 @@ ShakeScreen: ; 5565
.ScreenShakeObject:
db $00, PAL_OW_SILVER, SPRITEMOVEDATA_SCREENSHAKE
-; 5579
-DespawnEmote: ; 5579
+DespawnEmote:
push bc
ld a, [hMapObjectIndexBuffer]
ld c, a
@@ -2177,18 +2094,16 @@ DespawnEmote: ; 5579
dec a
jr nz, .loop
ret
-; 55ac
-InitTempObject: ; 55ac
+InitTempObject:
call FindFirstEmptyObjectStruct
ret nc
ld d, h
ld e, l
farcall CopyTempObjectToObjectStruct
ret
-; 55b9
-CopyTempObjectData: ; 55b9
+CopyTempObjectData:
; load into wTempObjectCopy:
; -1, -1, [de], [de + 1], [de + 2], [hMapObjectIndexBuffer], [NextMapX], [NextMapY], -1
; This spawns the object at the same place as whichever object is loaded into bc.
@@ -2221,9 +2136,8 @@ CopyTempObjectData: ; 55b9
inc hl
ld [hl], -1
ret
-; 55e0
-Function55e0:: ; 55e0
+Function55e0::
ld a, [wVramState]
bit 0, a
ret z
@@ -2244,7 +2158,6 @@ Function55e0:: ; 55e0
cp NUM_OBJECT_STRUCTS
jr nz, .loop
ret
-; 5602
Function5602: ; 5602, called at battle start
call Function5645 ; clear sprites
@@ -2260,17 +2173,15 @@ Function5602: ; 5602, called at battle start
.ok
call _UpdateSprites
ret
-; 561d
-Function561d: ; 561d
+Function561d:
call Function5645 ; clear sprites
ld a, PLAYER
call Function5629 ; respawn player
call _UpdateSprites
ret
-; 5629
-Function5629: ; 5629
+Function5629:
cp NUM_OBJECTS
ret nc
call GetMapObject
@@ -2286,9 +2197,8 @@ Function5629: ; 5629
ret z
call Function5673
ret
-; 5645
-Function5645: ; 5645
+Function5645:
xor a
ld bc, wObjectStructs
.loop
@@ -2303,9 +2213,8 @@ Function5645: ; 5645
cp NUM_OBJECT_STRUCTS
jr nz, .loop
ret
-; 565c
-Function565c: ; 565c
+Function565c:
push bc
call Function56cd
pop bc
@@ -2316,25 +2225,22 @@ Function565c: ; 565c
farcall Function4440
xor a
ret
-; 5673
-Function5673: ; 5673
+Function5673:
call Function56a3
jr c, SetFacing_Standing
farcall Function4440 ; no need to farcall
xor a
ret
-; 5680
-SetFacing_Standing: ; 5680
+SetFacing_Standing:
ld hl, OBJECT_FACING_STEP
add hl, bc
ld [hl], STANDING
scf
ret
-; 5688
-Function5688: ; 5688
+Function5688:
push bc
ld hl, OBJECT_NEXT_MAP_X
add hl, bc
@@ -2349,9 +2255,8 @@ Function5688: ; 5688
ld [hl], a
farcall UpdateTallGrassFlags ; no need to farcall
ret
-; 56a3
-Function56a3: ; 56a3
+Function56a3:
ld hl, OBJECT_NEXT_MAP_X
add hl, bc
ld d, [hl]
@@ -2382,9 +2287,8 @@ Function56a3: ; 56a3
.nope
scf
ret
-; 56cd
-Function56cd: ; 56cd
+Function56cd:
ld a, [wPlayerBGMapOffsetX]
ld d, a
ld hl, OBJECT_SPRITE_X_OFFSET
@@ -2492,9 +2396,8 @@ Function56cd: ; 56cd
.nope
scf
ret
-; 576a
-HandleNPCStep:: ; 576a
+HandleNPCStep::
call .ResetStepVector
call .DoStepsForAllObjects
ret
@@ -2526,9 +2429,8 @@ HandleNPCStep:: ; 576a
cp NUM_OBJECT_STRUCTS
jr nz, .loop
ret
-; 579d
-RefreshPlayerSprite: ; 579d
+RefreshPlayerSprite:
ld a, movement_step_sleep
ld [wPlayerNextMovement], a
ld [wPlayerMovement], a
@@ -2540,9 +2442,8 @@ RefreshPlayerSprite: ; 579d
call c, SpawnInFacingDown
call .SpawnInCustomFacing
ret
-; 57bc
-.TryResetPlayerAction: ; 57bc
+.TryResetPlayerAction:
ld hl, wPlayerSpriteSetupFlags
bit PLAYERSPRITESETUP_RESET_ACTION_F, [hl]
jr nz, .ok
@@ -2552,9 +2453,8 @@ RefreshPlayerSprite: ; 579d
ld a, OBJECT_ACTION_00
ld [wPlayerAction], a
ret
-; 57ca
-.SpawnInCustomFacing: ; 57ca
+.SpawnInCustomFacing:
ld hl, wPlayerSpriteSetupFlags
bit PLAYERSPRITESETUP_CUSTOM_FACING_F, [hl]
ret z
@@ -2563,17 +2463,15 @@ RefreshPlayerSprite: ; 579d
add a
add a
jr ContinueSpawnFacing
-; 57d9
-SpawnInFacingDown: ; 57d9
+SpawnInFacingDown:
ld a, 0
-ContinueSpawnFacing: ; 57db
+ContinueSpawnFacing:
ld bc, wPlayerStruct
call SetSpriteDirection
ret
-; 57e2
-_SetPlayerPalette: ; 57e2
+_SetPlayerPalette:
ld a, d
and 1 << 7
ret z
@@ -2595,9 +2493,8 @@ _SetPlayerPalette: ; 57e2
or d
ld [hl], a
ret
-; 5803
-StartFollow:: ; 5803
+StartFollow::
push bc
ld a, b
call SetLeaderIfVisible
@@ -2607,29 +2504,25 @@ StartFollow:: ; 5803
call SetFollowerIfVisible
farcall QueueFollowerFirstStep
ret
-; 5815
-SetLeaderIfVisible: ; 5815
+SetLeaderIfVisible:
call CheckObjectVisibility
ret c
ld a, [hObjectStructIndexBuffer]
ld [wObjectFollow_Leader], a
ret
-; 581f
-StopFollow:: ; 581f
+StopFollow::
call ResetLeader
call ResetFollower
ret
-; 5826
-ResetLeader: ; 5826
+ResetLeader:
ld a, -1
ld [wObjectFollow_Leader], a
ret
-; 582c
-SetFollowerIfVisible: ; 582c
+SetFollowerIfVisible:
push af
call ResetFollower
pop af
@@ -2644,9 +2537,8 @@ SetFollowerIfVisible: ; 582c
ld a, [hObjectStructIndexBuffer]
ld [wObjectFollow_Follower], a
ret
-; 5847
-ResetFollower: ; 5847
+ResetFollower:
ld a, [wObjectFollow_Follower]
cp -1
ret z
@@ -2655,9 +2547,8 @@ ResetFollower: ; 5847
ld a, -1
ld [wObjectFollow_Follower], a
ret
-; 585c
-SetFlagsForMovement_1:: ; 585c
+SetFlagsForMovement_1::
ld a, c
call CheckObjectVisibility
ret c
@@ -2669,9 +2560,8 @@ SetFlagsForMovement_1:: ; 585c
res 5, [hl]
xor a
ret
-; 586e
-Function586e: ; 586e
+Function586e:
call CheckObjectVisibility
ret c
ld hl, OBJECT_FLAGS2
@@ -2679,9 +2569,8 @@ Function586e: ; 586e
set 5, [hl]
xor a
ret
-; 587a
-Function587a: ; 587a
+Function587a:
ld bc, wObjectStructs
xor a
.loop
@@ -2701,9 +2590,8 @@ Function587a: ; 587a
cp NUM_OBJECT_STRUCTS
jr nz, .loop
ret
-; 5897
-_SetFlagsForMovement_2:: ; 5897
+_SetFlagsForMovement_2::
ld a, [wObjectFollow_Leader]
cp -1
ret z
@@ -2723,9 +2611,8 @@ _SetFlagsForMovement_2:: ; 5897
add hl, bc
res 5, [hl]
ret
-; 58b9
-Function58b9:: ; 58b9
+Function58b9::
push bc
ld bc, wObjectStructs
xor a
@@ -2747,18 +2634,16 @@ Function58b9:: ; 58b9
jr nz, .loop
pop bc
ret
-; 58d8
-Function58d8: ; 58d8
+Function58d8:
call CheckObjectVisibility
ret c
ld hl, OBJECT_FLAGS2
add hl, bc
res 5, [hl]
ret
-; 58e3
-Function58e3: ; 58e3
+Function58e3:
ld hl, OBJECT_MAP_OBJECT_INDEX
add hl, bc
ld a, [hl]
@@ -2777,9 +2662,8 @@ Function58e3: ; 58e3
add hl, bc
ld [hl], STEP_TYPE_00
ret
-; 5903
-Function5903: ; 5903
+Function5903:
call GetSpriteDirection
rrca
rrca
@@ -2801,9 +2685,8 @@ Function5903: ; 5903
db SPRITEMOVEDATA_STANDING_UP
db SPRITEMOVEDATA_STANDING_LEFT
db SPRITEMOVEDATA_STANDING_RIGHT
-; 5920
-_UpdateSprites:: ; 5920
+_UpdateSprites::
ld a, [wVramState]
bit 0, a
ret z
@@ -2840,9 +2723,8 @@ _UpdateSprites:: ; 5920
cp l
jr nz, .loop
ret
-; 5958
-ApplyBGMapAnchorToObjects: ; 5958
+ApplyBGMapAnchorToObjects:
push hl
push de
push bc
@@ -2881,14 +2763,13 @@ ApplyBGMapAnchorToObjects: ; 5958
pop de
pop hl
ret
-; 5991
PRIORITY_LOW EQU $10
PRIORITY_NORM EQU $20
PRIORITY_HIGH EQU $30
-InitSprites: ; 5991
+InitSprites:
call .DeterminePriorities
ld c, PRIORITY_HIGH
call .InitSpritesByPriority
@@ -3107,7 +2988,7 @@ InitSprites: ; 5991
ld b, [hl]
ret
-.Addresses: ; 5ace
+.Addresses:
dw wPlayerStruct
dw wObject1Struct
dw wObject2Struct
@@ -3121,4 +3002,3 @@ InitSprites: ; 5991
dw wObject10Struct
dw wObject11Struct
dw wObject12Struct
-; 5ae8
diff --git a/engine/overworld/map_objects_2.asm b/engine/overworld/map_objects_2.asm
index 038e2b49b..f055e0fd9 100644
--- a/engine/overworld/map_objects_2.asm
+++ b/engine/overworld/map_objects_2.asm
@@ -1,4 +1,4 @@
-LoadObjectMasks: ; 2454f
+LoadObjectMasks:
ld hl, wObjectMasks
xor a
ld bc, NUM_OBJECTS
@@ -29,7 +29,7 @@ LoadObjectMasks: ; 2454f
jr nz, .loop
ret
-CheckObjectFlag: ; 2457d (9:457d)
+CheckObjectFlag:
ld hl, MAPOBJECT_SPRITE
add hl, bc
ld a, [hl]
@@ -62,7 +62,7 @@ CheckObjectFlag: ; 2457d (9:457d)
scf
ret
-GetObjectTimeMask: ; 245a7 (9:45a7)
+GetObjectTimeMask:
call CheckObjectTime
ld a, -1
ret c
diff --git a/engine/overworld/map_setup.asm b/engine/overworld/map_setup.asm
index 268574de0..6cdccba71 100644
--- a/engine/overworld/map_setup.asm
+++ b/engine/overworld/map_setup.asm
@@ -1,4 +1,4 @@
-RunMapSetupScript:: ; 15363
+RunMapSetupScript::
ld a, [hMapEntryMethod]
and $f
dec a
@@ -12,11 +12,10 @@ RunMapSetupScript:: ; 15363
ld l, a
call ReadMapSetupScript
ret
-; 15377
INCLUDE "data/maps/setup_scripts.asm"
-ReadMapSetupScript: ; 1541d
+ReadMapSetupScript:
.loop
ld a, [hli]
cp -1
@@ -58,9 +57,8 @@ ReadMapSetupScript: ; 1541d
pop hl
jr .loop
-; 15440
-MapSetupCommands: ; 15440
+MapSetupCommands:
; entries correspond to command indexes in constants/map_setup_constants.asm
dba EnableLCD ; 00
dba DisableLCD ; 01
@@ -108,51 +106,44 @@ MapSetupCommands: ; 15440
dba RetainOldPalettes ; 2b
dba DontScrollText ; 2c
dba ReturnFromMapSetupScript ; 2d
-; 154ca
-DontScrollText: ; 154ca
+DontScrollText:
xor a
ld [wDisableTextAcceleration], a
ret
-; 154cf
-ActivateMapAnims: ; 154cf
+ActivateMapAnims:
ld a, $1
ld [hMapAnims], a
ret
-; 154d3
-SuspendMapAnims: ; 154d3
+SuspendMapAnims:
xor a
ld [hMapAnims], a
ret
-; 154d7
-LoadObjectsRunCallback_02: ; 154d7
+LoadObjectsRunCallback_02:
ld a, MAPCALLBACK_OBJECTS
call RunMapCallback
farcall LoadObjectMasks
farcall InitializeVisibleSprites
ret
-; 154ea (5:54ea)
; unused
ret
-; 154eb
-DelayClearingOldSprites: ; 154eb
+DelayClearingOldSprites:
ld hl, wPlayerSpriteSetupFlags
set PLAYERSPRITESETUP_RESET_ACTION_F, [hl]
ret
-; 154f1
-DelayLoadingNewSprites: ; 154f1
+DelayLoadingNewSprites:
ld hl, wPlayerSpriteSetupFlags
set PLAYERSPRITESETUP_SKIP_RELOAD_GFX_F, [hl]
ret
-CheckReplaceKrisSprite: ; 154f7
+CheckReplaceKrisSprite:
nop
call .CheckBiking
jr c, .ok
@@ -166,7 +157,7 @@ CheckReplaceKrisSprite: ; 154f7
call ReplaceKrisSprite
ret
-.CheckBiking: ; 1550c (5:550c)
+.CheckBiking:
and a
ld hl, wBikeFlags
bit BIKEFLAGS_ALWAYS_ON_BIKE_F, [hl]
@@ -176,7 +167,7 @@ CheckReplaceKrisSprite: ; 154f7
scf
ret
-.CheckSurfing2: ; 1551a (5:551a)
+.CheckSurfing2:
ld a, [wPlayerState]
cp PLAYER_NORMAL
jr z, .nope
@@ -208,7 +199,7 @@ CheckReplaceKrisSprite: ; 154f7
and a
ret
-.CheckSurfing: ; 1554e (5:554e)
+.CheckSurfing:
call CheckOnWater
jr nz, .ret_nc
ld a, [wPlayerState]
@@ -224,19 +215,17 @@ CheckReplaceKrisSprite: ; 154f7
.ret_nc
and a
ret
-; 15567
-FadeOldMapMusic: ; 15567
+FadeOldMapMusic:
ld a, 6
call SkipMusic
ret
-; 1556d
-RetainOldPalettes: ; 1556d
+RetainOldPalettes:
farcall _UpdateTimePals
ret
-RotatePalettesRightMapAndMusic: ; 15574
+RotatePalettesRightMapAndMusic:
ld e, 0
ld a, [wMusicFadeID]
ld d, 0
@@ -245,9 +234,8 @@ RotatePalettesRightMapAndMusic: ; 15574
ld [wMusicFade], a
call RotateThreePalettesRight
ret
-; 15587
-ForceMapMusic: ; 15587
+ForceMapMusic:
ld a, [wPlayerState]
cp PLAYER_BIKE
jr nz, .notbiking
@@ -257,4 +245,3 @@ ForceMapMusic: ; 15587
.notbiking
call TryRestartMapMusic
ret
-; 1559a
diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm
index fcb8d55fb..fac0b4ae8 100644
--- a/engine/overworld/movement.asm
+++ b/engine/overworld/movement.asm
@@ -1,4 +1,4 @@
-MovementPointers: ; 5075
+MovementPointers:
; entries correspond to macros/scripts/movement.asm enumeration
dw Movement_turn_head_down ; 00
dw Movement_turn_head_up ; 01
@@ -90,38 +90,33 @@ MovementPointers: ; 5075
dw Movement_rock_smash ; 57
dw Movement_return_dig ; 58
dw Movement_skyfall_top ; 59
-; 5129
-Movement_teleport_from: ; 5129
+Movement_teleport_from:
ld hl, OBJECT_STEP_TYPE
add hl, bc
ld [hl], STEP_TYPE_TELEPORT_FROM
ret
-; 5130
-Movement_teleport_to: ; 5130
+Movement_teleport_to:
ld hl, OBJECT_STEP_TYPE
add hl, bc
ld [hl], STEP_TYPE_TELEPORT_TO
ret
-; 5137
-Movement_skyfall: ; 5137
+Movement_skyfall:
ld hl, OBJECT_STEP_TYPE
add hl, bc
ld [hl], STEP_TYPE_SKYFALL
ret
-; 513e
-Movement_skyfall_top: ; 513e
+Movement_skyfall_top:
ld hl, OBJECT_STEP_TYPE
add hl, bc
ld [hl], STEP_TYPE_SKYFALL_TOP
ret
-; 5145
-Movement_step_dig: ; 5145
+Movement_step_dig:
call GetSpriteDirection
rlca
rlca
@@ -142,9 +137,8 @@ Movement_step_dig: ; 5145
add hl, bc
ld [hl], STANDING
ret
-; 516a
-Movement_return_dig: ; 516a
+Movement_return_dig:
call GetSpriteDirection
rlca
rlca
@@ -162,9 +156,8 @@ Movement_return_dig: ; 516a
add hl, bc
ld [hl], STEP_TYPE_RETURN_DIG
ret
-; 5189
-Movement_fish_got_bite: ; 5189
+Movement_fish_got_bite:
ld hl, OBJECT_ACTION
add hl, bc
ld [hl], OBJECT_ACTION_FISHING
@@ -172,9 +165,8 @@ Movement_fish_got_bite: ; 5189
add hl, bc
ld [hl], STEP_TYPE_GOT_BITE
ret
-; 5196
-Movement_rock_smash: ; 5196
+Movement_rock_smash:
call JumpMovementPointer
ld hl, OBJECT_STEP_DURATION
add hl, bc
@@ -186,9 +178,8 @@ Movement_rock_smash: ; 5196
add hl, bc
ld [hl], STEP_TYPE_ROCK_SMASH
ret
-; 51ab
-Movement_fish_cast_rod: ; 51ab
+Movement_fish_cast_rod:
ld hl, OBJECT_ACTION
add hl, bc
ld [hl], OBJECT_ACTION_FISHING
@@ -196,16 +187,14 @@ Movement_fish_cast_rod: ; 51ab
add hl, bc
ld [hl], STEP_TYPE_SLEEP
ret
-; 51b8
-Movement_step_loop: ; 51b8
+Movement_step_loop:
ld hl, OBJECT_MOVEMENT_BYTE_INDEX
add hl, bc
ld [hl], $0
jp ContinueReadingMovement
-; 51c1
-Movement_step_end: ; 51c1
+Movement_step_end:
call RestoreDefaultMovement
ld hl, OBJECT_MOVEMENTTYPE
add hl, bc
@@ -222,9 +211,8 @@ Movement_step_end: ; 51c1
add hl, bc
ld [hl], STEP_TYPE_SLEEP
ret
-; 51db
-Movement_48: ; 51db
+Movement_48:
call RestoreDefaultMovement
ld hl, OBJECT_MOVEMENTTYPE
add hl, bc
@@ -246,9 +234,8 @@ Movement_48: ; 51db
ld hl, wVramState
res 7, [hl]
ret
-; 51fd
-Movement_remove_object: ; 51fd
+Movement_remove_object:
call DeleteMapObject
ld hl, wObjectFollow_Leader
ld a, [hMapObjectIndexBuffer]
@@ -260,9 +247,8 @@ Movement_remove_object: ; 51fd
ld hl, wVramState
res 7, [hl]
ret
-; 5210
-Movement_4b: ; 5210
+Movement_4b:
ld hl, OBJECT_ACTION
add hl, bc
ld [hl], OBJECT_ACTION_STAND
@@ -274,48 +260,47 @@ Movement_4b: ; 5210
ld hl, wVramState
res 7, [hl]
ret
-; 5222
-Movement_step_sleep_1: ; 5222
+Movement_step_sleep_1:
ld a, 1
jr Movement_step_sleep_common
-Movement_step_sleep_2: ; 5226
+Movement_step_sleep_2:
ld a, 2
jr Movement_step_sleep_common
-Movement_step_sleep_3: ; 522a
+Movement_step_sleep_3:
ld a, 3
jr Movement_step_sleep_common
-Movement_step_sleep_4: ; 522e
+Movement_step_sleep_4:
ld a, 4
jr Movement_step_sleep_common
-Movement_step_sleep_5: ; 5232
+Movement_step_sleep_5:
ld a, 5
jr Movement_step_sleep_common
-Movement_step_sleep_6: ; 5236
+Movement_step_sleep_6:
ld a, 6
jr Movement_step_sleep_common
-Movement_step_sleep_7: ; 523a
+Movement_step_sleep_7:
ld a, 7
jr Movement_step_sleep_common
-Movement_step_sleep_8: ; 523e
+Movement_step_sleep_8:
ld a, 8
jr Movement_step_sleep_common
-Movement_step_sleep: ; 5242
+Movement_step_sleep:
; parameters:
; duration (DecimalParam)
call JumpMovementPointer
jr Movement_step_sleep_common
-Movement_step_sleep_common: ; 5247
+Movement_step_sleep_common:
ld hl, OBJECT_STEP_DURATION
add hl, bc
ld [hl], a
@@ -332,9 +317,8 @@ Movement_step_sleep_common: ; 5247
add hl, bc
ld [hl], STANDING
ret
-; 525f
-Movement_step_bump: ; 525f
+Movement_step_bump:
ld a, 1
ld hl, OBJECT_STEP_DURATION
add hl, bc
@@ -352,9 +336,8 @@ Movement_step_bump: ; 525f
add hl, bc
ld [hl], STANDING
ret
-; 5279
-Movement_tree_shake: ; 5279
+Movement_tree_shake:
ld a, 24
ld hl, OBJECT_STEP_DURATION
add hl, bc
@@ -372,86 +355,76 @@ Movement_tree_shake: ; 5279
add hl, bc
ld [hl], STANDING
ret
-; 5293
-Movement_remove_sliding: ; 5293
+Movement_remove_sliding:
ld hl, OBJECT_FLAGS1
add hl, bc
res SLIDING_F, [hl]
jp ContinueReadingMovement
-; 529c
-Movement_set_sliding: ; 529c
+Movement_set_sliding:
ld hl, OBJECT_FLAGS1
add hl, bc
set SLIDING_F, [hl]
jp ContinueReadingMovement
-; 52a5
-Movement_remove_fixed_facing: ; 52a5
+Movement_remove_fixed_facing:
ld hl, OBJECT_FLAGS1
add hl, bc
res FIXED_FACING_F, [hl]
jp ContinueReadingMovement
-; 52ae
-Movement_fix_facing: ; 52ae
+Movement_fix_facing:
ld hl, OBJECT_FLAGS1
add hl, bc
set FIXED_FACING_F, [hl]
jp ContinueReadingMovement
-; 52b7
-Movement_show_object: ; 52b7
+Movement_show_object:
ld hl, OBJECT_FLAGS1
add hl, bc
res INVISIBLE_F, [hl]
jp ContinueReadingMovement
-; 52c0
-Movement_hide_object: ; 52c0
+Movement_hide_object:
ld hl, OBJECT_FLAGS1
add hl, bc
set INVISIBLE_F, [hl]
jp ContinueReadingMovement
-; 52c9
-Movement_hide_emote: ; 52c9
+Movement_hide_emote:
call DespawnEmote
jp ContinueReadingMovement
-; 52cf
-Movement_show_emote: ; 52cf
+Movement_show_emote:
call SpawnEmote
jp ContinueReadingMovement
-; 52d5
-Movement_step_shake: ; 52d5
+Movement_step_shake:
; parameters:
; displacement (DecimalParam)
call JumpMovementPointer
call ShakeScreen
jp ContinueReadingMovement
-; 52de
-Movement_turn_head_down: ; 52de
+Movement_turn_head_down:
ld a, OW_DOWN
jr TurnHead
-Movement_turn_head_up: ; 52e2
+Movement_turn_head_up:
ld a, OW_UP
jr TurnHead
-Movement_turn_head_left: ; 52e6
+Movement_turn_head_left:
ld a, OW_LEFT
jr TurnHead
-Movement_turn_head_right: ; 52ea
+Movement_turn_head_right:
ld a, OW_RIGHT
jr TurnHead
-TurnHead: ; 52ee
+TurnHead:
ld hl, OBJECT_FACING
add hl, bc
ld [hl], a
@@ -464,269 +437,220 @@ TurnHead: ; 52ee
add hl, bc
ld [hl], STANDING
ret
-; 5300
-Movement_slow_step_down: ; 5300
+Movement_slow_step_down:
ld a, STEP_SLOW << 2 | DOWN
jp NormalStep
-; 5305
-Movement_slow_step_up: ; 5305
+Movement_slow_step_up:
ld a, STEP_SLOW << 2 | UP
jp NormalStep
-; 530a
-Movement_slow_step_left: ; 530a
+Movement_slow_step_left:
ld a, STEP_SLOW << 2 | LEFT
jp NormalStep
-; 530f
-Movement_slow_step_right: ; 530f
+Movement_slow_step_right:
ld a, STEP_SLOW << 2 | RIGHT
jp NormalStep
-; 5314
-Movement_step_down: ; 5314
+Movement_step_down:
ld a, STEP_WALK << 2 | DOWN
jp NormalStep
-; 5319
-Movement_step_up: ; 5319
+Movement_step_up:
ld a, STEP_WALK << 2 | UP
jp NormalStep
-; 531e
-Movement_step_left: ; 531e
+Movement_step_left:
ld a, STEP_WALK << 2 | LEFT
jp NormalStep
-; 5323
-Movement_step_right: ; 5323
+Movement_step_right:
ld a, STEP_WALK << 2 | RIGHT
jp NormalStep
-; 5328
-Movement_big_step_down: ; 5328
+Movement_big_step_down:
ld a, STEP_BIKE << 2 | DOWN
jp NormalStep
-; 532d
-Movement_big_step_up: ; 532d
+Movement_big_step_up:
ld a, STEP_BIKE << 2 | UP
jp NormalStep
-; 5332
-Movement_big_step_left: ; 5332
+Movement_big_step_left:
ld a, STEP_BIKE << 2 | LEFT
jp NormalStep
-; 5337
-Movement_big_step_right: ; 5337
+Movement_big_step_right:
ld a, STEP_BIKE << 2 | RIGHT
jp NormalStep
-; 533c
-Movement_turn_away_down: ; 533c
+Movement_turn_away_down:
ld a, STEP_SLOW << 2 | DOWN
jp TurningStep
-; 5341
-Movement_turn_away_up: ; 5341
+Movement_turn_away_up:
ld a, STEP_SLOW << 2 | UP
jp TurningStep
-; 5346
-Movement_turn_away_left: ; 5346
+Movement_turn_away_left:
ld a, STEP_SLOW << 2 | LEFT
jp TurningStep
-; 534b
-Movement_turn_away_right: ; 534b
+Movement_turn_away_right:
ld a, STEP_SLOW << 2 | RIGHT
jp TurningStep
-; 5350
-Movement_turn_in_down: ; 5350
+Movement_turn_in_down:
ld a, STEP_WALK << 2 | DOWN
jp TurningStep
-; 5355
-Movement_turn_in_up: ; 5355
+Movement_turn_in_up:
ld a, STEP_WALK << 2 | UP
jp TurningStep
-; 535a
-Movement_turn_in_left: ; 535a
+Movement_turn_in_left:
ld a, STEP_WALK << 2 | LEFT
jp TurningStep
-; 535f
-Movement_turn_in_right: ; 535f
+Movement_turn_in_right:
ld a, STEP_WALK << 2 | RIGHT
jp TurningStep
-; 5364
-Movement_turn_waterfall_down: ; 5364
+Movement_turn_waterfall_down:
ld a, STEP_BIKE << 2 | DOWN
jp TurningStep
-; 5369
-Movement_turn_waterfall_up: ; 5369
+Movement_turn_waterfall_up:
ld a, STEP_BIKE << 2 | UP
jp TurningStep
-; 536e
-Movement_turn_waterfall_left: ; 536e
+Movement_turn_waterfall_left:
ld a, STEP_BIKE << 2 | LEFT
jp TurningStep
-; 5373
-Movement_turn_waterfall_right: ; 5373
+Movement_turn_waterfall_right:
ld a, STEP_BIKE << 2 | RIGHT
jp TurningStep
-; 5378
-Movement_slow_slide_step_down: ; 5378
+Movement_slow_slide_step_down:
ld a, STEP_SLOW << 2 | DOWN
jp SlideStep
-; 537d
-Movement_slow_slide_step_up: ; 537d
+Movement_slow_slide_step_up:
ld a, STEP_SLOW << 2 | UP
jp SlideStep
-; 5382
-Movement_slow_slide_step_left: ; 5382
+Movement_slow_slide_step_left:
ld a, STEP_SLOW << 2 | LEFT
jp SlideStep
-; 5387
-Movement_slow_slide_step_right: ; 5387
+Movement_slow_slide_step_right:
ld a, STEP_SLOW << 2 | RIGHT
jp SlideStep
-; 538c
-Movement_slide_step_down: ; 538c
+Movement_slide_step_down:
ld a, STEP_WALK << 2 | DOWN
jp SlideStep
-; 5391
-Movement_slide_step_up: ; 5391
+Movement_slide_step_up:
ld a, STEP_WALK << 2 | UP
jp SlideStep
-; 5396
-Movement_slide_step_left: ; 5396
+Movement_slide_step_left:
ld a, STEP_WALK << 2 | LEFT
jp SlideStep
-; 539b
-Movement_slide_step_right: ; 539b
+Movement_slide_step_right:
ld a, STEP_WALK << 2 | RIGHT
jp SlideStep
-; 53a0
-Movement_fast_slide_step_down: ; 53a0
+Movement_fast_slide_step_down:
ld a, STEP_BIKE << 2 | DOWN
jp SlideStep
-; 53a5
-Movement_fast_slide_step_up: ; 53a5
+Movement_fast_slide_step_up:
ld a, STEP_BIKE << 2 | UP
jp SlideStep
-; 53aa
-Movement_fast_slide_step_left: ; 53aa
+Movement_fast_slide_step_left:
ld a, STEP_BIKE << 2 | LEFT
jp SlideStep
-; 53af
-Movement_fast_slide_step_right: ; 53af
+Movement_fast_slide_step_right:
ld a, STEP_BIKE << 2 | RIGHT
jp SlideStep
-; 53b4
-Movement_slow_jump_step_down: ; 53b4
+Movement_slow_jump_step_down:
ld a, STEP_SLOW << 2 | DOWN
jp JumpStep
-; 53b9
-Movement_slow_jump_step_up: ; 53b9
+Movement_slow_jump_step_up:
ld a, STEP_SLOW << 2 | UP
jp JumpStep
-; 53be
-Movement_slow_jump_step_left: ; 53be
+Movement_slow_jump_step_left:
ld a, STEP_SLOW << 2 | LEFT
jp JumpStep
-; 53c3
-Movement_slow_jump_step_right: ; 53c3
+Movement_slow_jump_step_right:
ld a, STEP_SLOW << 2 | RIGHT
jp JumpStep
-; 53c8
-Movement_jump_step_down: ; 53c8
+Movement_jump_step_down:
ld a, STEP_WALK << 2 | DOWN
jp JumpStep
-; 53cd
-Movement_jump_step_up: ; 53cd
+Movement_jump_step_up:
ld a, STEP_WALK << 2 | UP
jp JumpStep
-; 53d2
-Movement_jump_step_left: ; 53d2
+Movement_jump_step_left:
ld a, STEP_WALK << 2 | LEFT
jp JumpStep
-; 53d7
-Movement_jump_step_right: ; 53d7
+Movement_jump_step_right:
ld a, STEP_WALK << 2 | RIGHT
jp JumpStep
-; 53dc
-Movement_fast_jump_step_down: ; 53dc
+Movement_fast_jump_step_down:
ld a, STEP_BIKE << 2 | DOWN
jp JumpStep
-; 53e1
-Movement_fast_jump_step_up: ; 53e1
+Movement_fast_jump_step_up:
ld a, STEP_BIKE << 2 | UP
jp JumpStep
-; 53e6
-Movement_fast_jump_step_left: ; 53e6
+Movement_fast_jump_step_left:
ld a, STEP_BIKE << 2 | LEFT
jp JumpStep
-; 53eb
-Movement_fast_jump_step_right: ; 53eb
+Movement_fast_jump_step_right:
ld a, STEP_BIKE << 2 | RIGHT
jp JumpStep
-; 53f0
-Movement_turn_step_down: ; 53f0
+Movement_turn_step_down:
ld a, OW_DOWN
jr TurnStep
-Movement_turn_step_up: ; 53f4
+Movement_turn_step_up:
ld a, OW_UP
jr TurnStep
-Movement_turn_step_left: ; 53f8
+Movement_turn_step_left:
ld a, OW_LEFT
jr TurnStep
-Movement_turn_step_right: ; 53fc
+Movement_turn_step_right:
ld a, OW_RIGHT
jr TurnStep
-TurnStep: ; 5400
+TurnStep:
ld hl, OBJECT_1D ; new facing
add hl, bc
ld [hl], a
@@ -739,9 +663,8 @@ TurnStep: ; 5400
add hl, bc
ld [hl], STEP_TYPE_HALF_STEP
ret
-; 5412
-NormalStep: ; 5412
+NormalStep:
call InitStep
call UpdateTallGrassFlags
ld hl, OBJECT_ACTION
@@ -776,9 +699,8 @@ NormalStep: ; 5412
add hl, bc
ld [hl], STEP_TYPE_PLAYER_WALK
ret
-; 5446
-TurningStep: ; 5446
+TurningStep:
call InitStep
call UpdateTallGrassFlags
@@ -801,10 +723,9 @@ TurningStep: ; 5446
add hl, bc
ld [hl], STEP_TYPE_PLAYER_WALK
ret
-; 5468
-SlideStep: ; 5468
+SlideStep:
call InitStep
call UpdateTallGrassFlags
@@ -827,10 +748,9 @@ SlideStep: ; 5468
add hl, bc
ld [hl], STEP_TYPE_PLAYER_WALK
ret
-; 548a
-JumpStep: ; 548a
+JumpStep:
call InitStep
ld hl, OBJECT_1F
add hl, bc
@@ -861,4 +781,3 @@ JumpStep: ; 548a
add hl, bc
ld [hl], STEP_TYPE_PLAYER_JUMP
ret
-; 54b8
diff --git a/engine/overworld/npc_movement.asm b/engine/overworld/npc_movement.asm
index 40ced1a5f..07881a788 100644
--- a/engine/overworld/npc_movement.asm
+++ b/engine/overworld/npc_movement.asm
@@ -1,4 +1,4 @@
-CanObjectMoveInDirection: ; 6ec1
+CanObjectMoveInDirection:
ld hl, OBJECT_PALETTE
add hl, bc
@@ -57,10 +57,9 @@ CanObjectMoveInDirection: ; 6ec1
.move_anywhere
and a
ret
-; 6f07
-WillObjectBumpIntoWater: ; 6f07
+WillObjectBumpIntoWater:
call Function6f5f
ret c
ld hl, OBJECT_NEXT_MAP_X
@@ -82,9 +81,8 @@ WillObjectBumpIntoWater: ; 6f07
jr z, WillObjectBumpIntoTile
scf
ret
-; 6f2c
-WillObjectBumpIntoLand: ; 6f2c
+WillObjectBumpIntoLand:
call Function6f5f
ret c
ld hl, OBJECT_NEXT_TILE
@@ -95,9 +93,8 @@ WillObjectBumpIntoLand: ; 6f2c
jr z, WillObjectBumpIntoTile
scf
ret
-; 6f3e
-WillObjectBumpIntoTile: ; 6f3e
+WillObjectBumpIntoTile:
ld hl, OBJECT_NEXT_TILE
add hl, bc
ld a, [hl]
@@ -117,13 +114,11 @@ WillObjectBumpIntoTile: ; 6f3e
ret z
scf
ret
-; 6f5b
.data_6f5b
db DOWN_MASK, UP_MASK, RIGHT_MASK, LEFT_MASK
-; 6f5f
-Function6f5f: ; 6f5f
+Function6f5f:
ld hl, OBJECT_STANDING_TILE
add hl, bc
ld a, [hl]
@@ -142,13 +137,11 @@ Function6f5f: ; 6f5f
ret z
scf
ret
-; 6f7b
.data_6f7b
db UP_MASK, DOWN_MASK, LEFT_MASK, RIGHT_MASK
-; 6f7f
-Function6f7f: ; 6f7f
+Function6f7f:
ld d, a
and $f0
cp $b0
@@ -168,14 +161,12 @@ Function6f7f: ; 6f7f
ld a, [hl]
scf
ret
-; 6f99
.data_6f99
db 8, 4, 1, 2
db 10, 6, 9, 5
-; 6fa1
-Function6fa1: ; 6fa1
+Function6fa1:
ld hl, OBJECT_DIRECTION_WALKING
add hl, bc
ld a, [hl]
@@ -224,11 +215,10 @@ Function6fa1: ; 6fa1
.not_land
scf
ret
-; 6fd9
-CheckFacingObject:: ; 6fd9
+CheckFacingObject::
call GetFacingTileCoord
@@ -267,10 +257,9 @@ CheckFacingObject:: ; 6fd9
.standing
scf
ret
-; 7009
-WillObjectBumpIntoSomeoneElse: ; 7009
+WillObjectBumpIntoSomeoneElse:
ld hl, OBJECT_NEXT_MAP_X
add hl, bc
ld d, [hl]
@@ -278,7 +267,6 @@ WillObjectBumpIntoSomeoneElse: ; 7009
add hl, bc
ld e, [hl]
jr IsNPCAtCoord
-; 7015
Unreferenced_Function7015:
ld a, [hMapObjectIndexBuffer]
@@ -287,7 +275,7 @@ Unreferenced_Function7015:
call IsNPCAtCoord
ret
-.CheckWillBeFacingNPC: ; 7021
+.CheckWillBeFacingNPC:
ld hl, OBJECT_NEXT_MAP_X
add hl, bc
ld d, [hl]
@@ -315,9 +303,8 @@ Unreferenced_Function7015:
.left
dec d
ret
-; 7041
-IsNPCAtCoord: ; 7041
+IsNPCAtCoord:
ld bc, wObjectStructs
xor a
.loop
@@ -390,9 +377,8 @@ IsNPCAtCoord: ; 7041
.setcarry
scf
ret
-; 70a4
-HasObjectReachedMovementLimit: ; 70a4
+HasObjectReachedMovementLimit:
ld hl, OBJECT_RADIUS
add hl, bc
ld a, [hl]
@@ -450,9 +436,8 @@ HasObjectReachedMovementLimit: ; 70a4
.yes
scf
ret
-; 70ed
-IsObjectMovingOffEdgeOfScreen: ; 70ed
+IsObjectMovingOffEdgeOfScreen:
ld hl, OBJECT_NEXT_MAP_X
add hl, bc
ld a, [wXCoord]
@@ -481,7 +466,6 @@ IsObjectMovingOffEdgeOfScreen: ; 70ed
.yes
scf
ret
-; 7113
Unreferenced_Function7113:
ld a, [wPlayerStandingMapX]
@@ -547,10 +531,9 @@ Unreferenced_Function7113:
.yes
scf
ret
-; 7171
-Function7171: ; 7171
+Function7171:
ld hl, OBJECT_NEXT_MAP_X
add hl, bc
ld a, d
@@ -571,4 +554,3 @@ Function7171: ; 7171
.nope
and a
ret
-; 718d
diff --git a/engine/overworld/overworld.asm b/engine/overworld/overworld.asm
index 381c2d89f..35a792921 100644
--- a/engine/overworld/overworld.asm
+++ b/engine/overworld/overworld.asm
@@ -1,13 +1,12 @@
-GetEmote2bpp: ; 1412a
+GetEmote2bpp:
ld a, $1
ld [rVBK], a
call Get2bpp
xor a
ld [rVBK], a
ret
-; 14135
-_ReplaceKrisSprite:: ; 14135
+_ReplaceKrisSprite::
call GetPlayerSprite
ld a, [wUsedSprites]
ld [hUsedSpriteIndex], a
@@ -15,7 +14,6 @@ _ReplaceKrisSprite:: ; 14135
ld [hUsedSpriteTile], a
call GetUsedSprite
ret
-; 14146
Function14146: ; mobile
ld hl, wSpriteFlags
@@ -27,7 +25,6 @@ Function14146: ; mobile
pop af
ld [wSpriteFlags], a
ret
-; 14157
Function14157: ; mobile
ld hl, wSpriteFlags
@@ -39,15 +36,13 @@ Function14157: ; mobile
pop af
ld [wSpriteFlags], a
ret
-; 14168
-RefreshSprites:: ; 14168
+RefreshSprites::
call .Refresh
call LoadUsedSpritesGFX
ret
-; 1416f
-.Refresh: ; 1416f
+.Refresh:
xor a
ld bc, wUsedSpritesEnd - wUsedSprites
ld hl, wUsedSprites
@@ -56,9 +51,8 @@ RefreshSprites:: ; 14168
call AddMapSprites
call LoadAndSortSprites
ret
-; 14183
-GetPlayerSprite: ; 14183
+GetPlayerSprite:
; Get Chris or Kris's sprite.
ld hl, ChrisStateSprites
ld a, [wPlayerSpriteSetupFlags]
@@ -98,7 +92,7 @@ GetPlayerSprite: ; 14183
INCLUDE "data/sprites/player_sprites.asm"
-AddMapSprites: ; 141c9
+AddMapSprites:
call GetMapEnvironment
call CheckOutdoorMap
jr z, .outdoor
@@ -108,10 +102,9 @@ AddMapSprites: ; 141c9
.outdoor
call AddOutdoorSprites
ret
-; 141d9
-AddIndoorSprites: ; 141d9
+AddIndoorSprites:
ld hl, wMap1ObjectSprite
ld a, 1
.loop
@@ -125,10 +118,9 @@ AddIndoorSprites: ; 141d9
cp NUM_OBJECTS
jr nz, .loop
ret
-; 141ee
-AddOutdoorSprites: ; 141ee
+AddOutdoorSprites:
ld a, [wMapGroup]
dec a
ld c, a
@@ -148,18 +140,16 @@ AddOutdoorSprites: ; 141ee
dec c
jr nz, .loop
ret
-; 14209
-LoadUsedSpritesGFX: ; 14209
+LoadUsedSpritesGFX:
ld a, MAPCALLBACK_SPRITES
call RunMapCallback
call GetUsedSprites
call .LoadMiscTiles
ret
-; 14215
-.LoadMiscTiles: ; 14215
+.LoadMiscTiles:
ld a, [wSpriteFlags]
bit 6, a
ret nz
@@ -174,18 +164,16 @@ LoadUsedSpritesGFX: ; 14209
.outdoor
farcall LoadEmote
ret
-; 14236
-SafeGetSprite: ; 14236
+SafeGetSprite:
push hl
call GetSprite
pop hl
ret
-; 1423c
-GetSprite: ; 1423c
+GetSprite:
call GetMonSprite
ret c
@@ -211,10 +199,9 @@ GetSprite: ; 1423c
ld l, [hl]
ld h, a
ret
-; 14259
-GetMonSprite: ; 14259
+GetMonSprite:
; Return carry if a monster sprite was loaded.
cp SPRITE_POKEMON
@@ -275,10 +262,9 @@ GetMonSprite: ; 14259
ld h, 0
and a
ret
-; 142a7
-_DoesSpriteHaveFacings:: ; 142a7
+_DoesSpriteHaveFacings::
; Checks to see whether we can apply a facing to a sprite.
; Returns carry unless the sprite is a Pokemon or a Still Sprite.
cp SPRITE_POKEMON
@@ -303,10 +289,9 @@ _DoesSpriteHaveFacings:: ; 142a7
.only_down
and a
ret
-; 142c4
-_GetSpritePalette:: ; 142c4
+_GetSpritePalette::
ld a, c
call GetMonSprite
jr c, .is_pokemon
@@ -324,18 +309,16 @@ _GetSpritePalette:: ; 142c4
xor a
ld c, a
ret
-; 142db
-LoadAndSortSprites: ; 142db
+LoadAndSortSprites:
call LoadSpriteGFX
call SortUsedSprites
call ArrangeUsedSprites
ret
-; 142e5
-AddSpriteGFX: ; 142e5
+AddSpriteGFX:
; Add any new sprite ids to a list of graphics to be loaded.
; Return carry if the list is full.
@@ -372,10 +355,9 @@ AddSpriteGFX: ; 142e5
pop hl
and a
ret
-; 14306
-LoadSpriteGFX: ; 14306
+LoadSpriteGFX:
; Bug: b is not preserved, so it's useless as a next count.
; Uncomment the lines below to fix.
@@ -401,10 +383,9 @@ LoadSpriteGFX: ; 14306
; pop bc
ld a, l
ret
-; 1431e
-SortUsedSprites: ; 1431e
+SortUsedSprites:
; Bubble-sort sprites by type.
; Run backwards through wUsedSprites to find the last one.
@@ -473,10 +454,9 @@ SortUsedSprites: ; 1431e
.quit
ret
-; 14355
-ArrangeUsedSprites: ; 14355
+ArrangeUsedSprites:
; Get the length of each sprite and space them out in VRAM.
; Crystal introduces a second table in VRAM bank 0.
@@ -533,10 +513,9 @@ ArrangeUsedSprites: ; 14355
.quit
ret
-; 14386
-GetSpriteLength: ; 14386
+GetSpriteLength:
; Return the length of sprite type a in tiles.
cp WALKING_SPRITE
@@ -556,10 +535,9 @@ GetSpriteLength: ; 14386
.OneDirection:
ld a, 4
ret
-; 1439b
-GetUsedSprites: ; 1439b
+GetUsedSprites:
ld hl, wUsedSprites
ld c, SPRITE_GFX_LIST_CAPACITY
@@ -594,9 +572,8 @@ GetUsedSprites: ; 1439b
.done
ret
-; 143c8
-GetUsedSprite: ; 143c8
+GetUsedSprite:
ld a, [hUsedSpriteIndex]
call SafeGetSprite
ld a, [hUsedSpriteTile]
@@ -639,9 +616,8 @@ endr
.done
ret
-; 14406
-.GetTileAddr: ; 14406
+.GetTileAddr:
; Return the address of tile (a) in (hl).
and $7f
ld l, a
@@ -656,9 +632,8 @@ endr
adc HIGH(vTiles0)
ld h, a
ret
-; 14418
-.CopyToVram: ; 14418
+.CopyToVram:
ld a, [rVBK]
push af
ld a, [wSpriteFlags]
@@ -673,9 +648,8 @@ endr
pop af
ld [rVBK], a
ret
-; 1442f
-LoadEmote:: ; 1442f
+LoadEmote::
; Get the address of the pointer to emote c.
ld a, c
ld bc, 6 ; sizeof(emote)
@@ -703,7 +677,6 @@ LoadEmote:: ; 1442f
ret z
call GetEmote2bpp
ret
-; 1444d
INCLUDE "data/sprites/emotes.asm"
diff --git a/engine/overworld/player_movement.asm b/engine/overworld/player_movement.asm
index f8bbe4952..0a2674341 100644
--- a/engine/overworld/player_movement.asm
+++ b/engine/overworld/player_movement.asm
@@ -1,4 +1,4 @@
-DoPlayerMovement:: ; 80000
+DoPlayerMovement::
call .GetDPad
ld a, movement_step_sleep
@@ -30,7 +30,6 @@ DoPlayerMovement:: ; 80000
or D_DOWN
ld [wCurInput], a
ret
-; 8002d
.TranslateIntoMovement:
ld a, [wPlayerState]
@@ -112,9 +111,8 @@ DoPlayerMovement:: ; 80000
call .StandInPlace
xor a
ret
-; 800b7
-.CheckTile: ; 800b7
+.CheckTile:
; Tiles such as waterfalls and warps move the player
; in a given direction, overriding input.
@@ -227,9 +225,8 @@ DoPlayerMovement:: ; 80000
ld a, 5
scf
ret
-; 80147
-.CheckTurning: ; 80147
+.CheckTurning:
; If the player is turning, change direction first. This also lets
; the player change facing without moving by tapping a direction.
@@ -257,9 +254,8 @@ DoPlayerMovement:: ; 80000
.not_turning
xor a
ret
-; 8016b
-.TryStep: ; 8016b
+.TryStep:
; Surfing actually calls .TrySurf directly instead of passing through here.
ld a, [wPlayerState]
@@ -323,9 +319,8 @@ DoPlayerMovement:: ; 80000
.bump
xor a
ret
-; 801c0
-.TrySurf: ; 801c0
+.TrySurf:
call .CheckSurfPerms
ld [wd040], a
@@ -359,9 +354,8 @@ DoPlayerMovement:: ; 80000
.surf_bump
xor a
ret
-; 801f3
-.TryJump: ; 801f3
+.TryJump:
ld a, [wPlayerStandingTile]
ld e, a
and $f0
@@ -399,9 +393,8 @@ DoPlayerMovement:: ; 80000
db FACE_DOWN | FACE_LEFT ; COLL_HOP_DOWN_LEFT
db FACE_UP | FACE_RIGHT ; COLL_HOP_UP_RIGHT
db FACE_UP | FACE_LEFT ; COLL_HOP_UP_LEFT
-; 80226
-.CheckWarp: ; 80226
+.CheckWarp:
; Bug: Since no case is made for STANDING here, it will check
; [.edgewarps + $ff]. This resolves to $3e at $8035a.
@@ -450,7 +443,6 @@ DoPlayerMovement:: ; 80000
db COLL_WARP_CARPET_UP
db COLL_WARP_CARPET_LEFT
db COLL_WARP_CARPET_RIGHT
-; 8025f
.DoStep:
ld e, a
@@ -529,27 +521,24 @@ DoPlayerMovement:: ; 80000
db $80 + UP
db $80 + LEFT
db $80 + RIGHT
-; 802b3
-.StandInPlace: ; 802b3
+.StandInPlace:
ld a, 0
ld [wPlayerTurningDirection], a
ld a, movement_step_sleep
ld [wMovementAnimation], a
xor a
ret
-; 802bf
-._WalkInPlace: ; 802bf
+._WalkInPlace:
ld a, 0
ld [wPlayerTurningDirection], a
ld a, movement_step_bump
ld [wMovementAnimation], a
xor a
ret
-; 802cb
-.CheckForced: ; 802cb
+.CheckForced:
; When sliding on ice, input is forced to remain in the same direction.
call CheckStandingOnIce
@@ -572,9 +561,8 @@ DoPlayerMovement:: ; 80000
.forced_dpad
db D_DOWN, D_UP, D_LEFT, D_RIGHT
-; 802ec
-.GetAction: ; 802ec
+.GetAction:
; Poll player input and update movement info.
ld hl, .table
@@ -631,9 +619,8 @@ DoPlayerMovement:: ; 80000
dw wTileUp
db DOWN, FACE_DOWN, 0, 1
dw wTileDown
-; 80341
-.CheckNPC: ; 80341
+.CheckNPC:
; Returns 0 if there is an NPC in front that you can't move
; Returns 1 if there is no NPC in front
; Returns 2 if there is a movable NPC in front
@@ -668,9 +655,8 @@ DoPlayerMovement:: ; 80000
.no_bump
ld a, 2
ret
-; 8036f
-.CheckStrengthBoulder: ; 8036f
+.CheckStrengthBoulder:
ld hl, wBikeFlags
bit BIKEFLAGS_STRENGTH_ACTIVE_F, [hl]
@@ -706,9 +692,8 @@ DoPlayerMovement:: ; 80000
.not_boulder
xor a
ret
-; 8039e
-.CheckLandPerms: ; 8039e
+.CheckLandPerms:
; Return 0 if walking onto land and tile permissions allow it.
; Otherwise, return carry.
@@ -728,9 +713,8 @@ DoPlayerMovement:: ; 80000
.NotWalkable:
scf
ret
-; 803b4
-.CheckSurfPerms: ; 803b4
+.CheckSurfPerms:
; Return 0 if moving in water, or 1 if moving onto land.
; Otherwise, return carry.
@@ -750,17 +734,15 @@ DoPlayerMovement:: ; 80000
.NotSurfable:
scf
ret
-; 803ca
-.BikeCheck: ; 803ca
+.BikeCheck:
ld a, [wPlayerState]
cp PLAYER_BIKE
ret z
cp PLAYER_SKATE
ret
-; 803d3
-.CheckWalkable: ; 803d3
+.CheckWalkable:
; Return 0 if tile a is land. Otherwise, return carry.
call GetTileCollision
@@ -768,9 +750,8 @@ DoPlayerMovement:: ; 80000
ret z
scf
ret
-; 803da
-.CheckSurfable: ; 803da
+.CheckSurfable:
; Return 0 if tile a is water, or 1 if land.
; Otherwise, return carry.
@@ -796,27 +777,24 @@ DoPlayerMovement:: ; 80000
.Neither:
scf
ret
-; 803ee
-.BumpSound: ; 803ee
+.BumpSound:
call CheckSFX
ret c
ld de, SFX_BUMP
call PlaySFX
ret
-; 803f9
-.GetOutOfWater: ; 803f9
+.GetOutOfWater:
push bc
ld a, PLAYER_NORMAL
ld [wPlayerState], a
call ReplaceKrisSprite ; UpdateSprites
pop bc
ret
-; 80404
-CheckStandingOnIce:: ; 80404
+CheckStandingOnIce::
ld a, [wPlayerTurningDirection]
cp 0
jr z, .not_ice
@@ -836,9 +814,8 @@ CheckStandingOnIce:: ; 80404
.not_ice
and a
ret
-; 80422
-StopPlayerForEvent:: ; 80422
+StopPlayerForEvent::
ld hl, wPlayerNextMovement
ld a, movement_step_sleep
cp [hl]
@@ -848,4 +825,3 @@ StopPlayerForEvent:: ; 80422
ld a, 0
ld [wPlayerTurningDirection], a
ret
-; 80430
diff --git a/engine/overworld/player_object.asm b/engine/overworld/player_object.asm
index 7d287dedb..08a990f4b 100644
--- a/engine/overworld/player_object.asm
+++ b/engine/overworld/player_object.asm
@@ -1,4 +1,4 @@
-BlankScreen: ; 8000
+BlankScreen:
call DisableSpriteUpdates
xor a
ld [hBGMapMode], a
@@ -16,7 +16,7 @@ BlankScreen: ; 8000
call SetPalettes
ret
-SpawnPlayer: ; 8029
+SpawnPlayer:
ld a, -1
ld [wObjectFollow_Leader], a
ld [wObjectFollow_Follower], a
@@ -51,13 +51,13 @@ SpawnPlayer: ; 8029
ld [wCenteredObject], a
ret
-PlayerObjectTemplate: ; 8071
+PlayerObjectTemplate:
; A dummy map object used to initialize the player object.
; Shorter than the actual amount copied by two bytes.
; Said bytes seem to be unused.
object_event -4, -4, SPRITE_CHRIS, SPRITEMOVEDATA_PLAYER, 15, 15, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, 0, -1
-CopyDECoordsToMapObject:: ; 807e
+CopyDECoordsToMapObject::
push de
ld a, b
call GetMapObject
@@ -70,7 +70,7 @@ CopyDECoordsToMapObject:: ; 807e
ld [hl], e
ret
-PlayerSpawn_ConvertCoords: ; 808f
+PlayerSpawn_ConvertCoords:
push bc
ld a, [wXCoord]
add 4
@@ -82,7 +82,7 @@ PlayerSpawn_ConvertCoords: ; 808f
call CopyDECoordsToMapObject
ret
-WriteObjectXY:: ; 80a1
+WriteObjectXY::
ld a, b
call CheckObjectVisibility
ret c
@@ -99,7 +99,7 @@ WriteObjectXY:: ; 80a1
and a
ret
-RefreshPlayerCoords: ; 80b8
+RefreshPlayerCoords:
ld a, [wXCoord]
add 4
ld d, a
@@ -127,7 +127,7 @@ RefreshPlayerCoords: ; 80b8
ret nz ; wtf
ret
-CopyObjectStruct:: ; 80e7
+CopyObjectStruct::
call CheckObjectMask
and a
ret nz ; masked
@@ -161,12 +161,12 @@ CopyObjectStruct:: ; 80e7
set 5, [hl]
ret
-CopyMapObjectToObjectStruct: ; 8116
+CopyMapObjectToObjectStruct:
call .CopyMapObjectToTempObject
call CopyTempObjectToObjectStruct
ret
-.CopyMapObjectToTempObject: ; 811d
+.CopyMapObjectToTempObject:
ld a, [hObjectStructIndexBuffer]
ld hl, MAPOBJECT_OBJECT_STRUCT_ID
add hl, bc
@@ -223,7 +223,7 @@ CopyMapObjectToObjectStruct: ; 8116
ld [wTempObjectCopyRadius], a
ret
-InitializeVisibleSprites: ; 8177
+InitializeVisibleSprites:
ld bc, wMapObjects + OBJECT_LENGTH
ld a, 1
.loop
@@ -281,10 +281,10 @@ InitializeVisibleSprites: ; 8177
jr nz, .loop
ret
-.ret ; 81c9
+.ret
ret
-CheckObjectEnteringVisibleRange:: ; 81ca
+CheckObjectEnteringVisibleRange::
nop
ld a, [wPlayerStepDirection]
cp STANDING
@@ -293,21 +293,21 @@ CheckObjectEnteringVisibleRange:: ; 81ca
rst JumpTable
ret
-.dw ; 81d6
+.dw
dw .Down
dw .Up
dw .Left
dw .Right
-.Up: ; 81de
+.Up:
ld a, [wYCoord]
sub 1
jr .Vertical
-.Down: ; 81e5
+.Down:
ld a, [wYCoord]
add 9
-.Vertical: ; 81ea
+.Vertical:
ld d, a
ld a, [wXCoord]
ld e, a
@@ -355,15 +355,15 @@ CheckObjectEnteringVisibleRange:: ; 81ca
jr nz, .loop_v
ret
-.Left: ; 8232
+.Left:
ld a, [wXCoord]
sub 1
jr .Horizontal
-.Right: ; 8239
+.Right:
ld a, [wXCoord]
add 10
-.Horizontal: ; 823e
+.Horizontal:
ld e, a
ld a, [wYCoord]
ld d, a
@@ -411,7 +411,7 @@ CheckObjectEnteringVisibleRange:: ; 81ca
jr nz, .loop_h
ret
-CopyTempObjectToObjectStruct: ; 8286
+CopyTempObjectToObjectStruct:
ld a, [wTempObjectCopyMapObjectIndex]
ld hl, OBJECT_MAP_OBJECT_INDEX
add hl, de
@@ -461,7 +461,7 @@ CopyTempObjectToObjectStruct: ; 8286
and a
ret
-.InitYCoord: ; 82d5
+.InitYCoord:
ld hl, OBJECT_INIT_Y
add hl, de
ld [hl], a
@@ -481,7 +481,7 @@ CopyTempObjectToObjectStruct: ; 8286
ld [hl], a
ret
-.InitXCoord: ; 82f1
+.InitXCoord:
ld hl, OBJECT_INIT_X
add hl, de
ld [hl], a
@@ -499,7 +499,7 @@ CopyTempObjectToObjectStruct: ; 8286
ld [hl], a
ret
-.InitRadius: ; 830d
+.InitRadius:
ld h, a
inc a
and $f
@@ -513,7 +513,7 @@ CopyTempObjectToObjectStruct: ; 8286
ld [hl], a
ret
-TrainerWalkToPlayer: ; 831e
+TrainerWalkToPlayer:
ld a, [hLastTalked]
call InitMovementBuffer
ld a, movement_step_sleep
@@ -533,7 +533,7 @@ TrainerWalkToPlayer: ; 831e
call AppendToMovementBuffer
ret
-.GetPathToPlayer: ; 8341
+.GetPathToPlayer:
push de
push bc
; get player object struct, load to de
@@ -577,7 +577,7 @@ TrainerWalkToPlayer: ; 831e
call ComputePathToWalkToPlayer
ret
-SurfStartStep: ; 8379
+SurfStartStep:
call InitMovementBuffer
call .GetMovementData
call AppendToMovementBuffer
@@ -585,7 +585,7 @@ SurfStartStep: ; 8379
call AppendToMovementBuffer
ret
-.GetMovementData: ; 8388
+.GetMovementData:
ld a, [wPlayerDirection]
srl a
srl a
@@ -603,7 +603,7 @@ SurfStartStep: ; 8379
slow_step LEFT
slow_step RIGHT
-FollowNotExact:: ; 839e
+FollowNotExact::
push bc
ld a, c
call CheckObjectVisibility
@@ -690,7 +690,7 @@ FollowNotExact:: ; 839e
ld [hl], STEP_TYPE_00
ret
-GetRelativeFacing:: ; 8417
+GetRelativeFacing::
; Determines which way map object e would have to turn to face map object d. Returns carry if it's impossible for whatever reason.
ld a, d
call GetMapObject
@@ -715,7 +715,7 @@ GetRelativeFacing:: ; 8417
scf
ret
-.GetFacing_e_relativeto_d: ; 8439
+.GetFacing_e_relativeto_d:
; Determines which way object e would have to turn to face object d. Returns carry if it's impossible.
; load the coordinates of object d into bc
ld a, d
@@ -796,7 +796,7 @@ GetRelativeFacing:: ; 8417
scf
ret
-QueueFollowerFirstStep: ; 848a
+QueueFollowerFirstStep:
call .QueueFirstStep
jr c, .same
ld [wFollowMovementQueue], a
diff --git a/engine/overworld/player_step.asm b/engine/overworld/player_step.asm
index 675c6553b..eba149b57 100644
--- a/engine/overworld/player_step.asm
+++ b/engine/overworld/player_step.asm
@@ -1,4 +1,4 @@
-_HandlePlayerStep:: ; d497 (3:5497)
+_HandlePlayerStep::
ld a, [wPlayerStepFlags]
and a
ret z
@@ -34,7 +34,7 @@ _HandlePlayerStep:: ; d497 (3:5497)
ld [wPlayerBGMapOffsetY], a
ret
-ScrollScreen:: ; d4d2 (3:54d2)
+ScrollScreen::
ld a, [wPlayerStepVectorX]
ld d, a
ld a, [wPlayerStepVectorY]
@@ -47,7 +47,7 @@ ScrollScreen:: ; d4d2 (3:54d2)
ld [hSCY], a
ret
-HandlePlayerStep: ; d4e5 (3:54e5)
+HandlePlayerStep:
ld hl, wHandlePlayerStep
ld a, [hl]
and a
@@ -58,7 +58,7 @@ HandlePlayerStep: ; d4e5 (3:54e5)
rst JumpTable
ret
-.Jumptable: ; d4f2 (3:54f2)
+.Jumptable:
dw GetMovementPermissions
dw BufferScreen
dw .mobile
@@ -72,17 +72,17 @@ HandlePlayerStep: ; d4e5 (3:54e5)
dw .fail1
dw .fail1
-.fail1 ; d508 (3:5508)
+.fail1
ret
-.mobile ; d509 (3:5509)
+.mobile
farcall StubbedTrainerRankings_StepCount
ret
-.fail2 ; d510 (3:5510)
+.fail2
ret
-UpdatePlayerCoords: ; d511 (3:5511)
+UpdatePlayerCoords:
ld a, [wPlayerStepDirection]
and a
jr nz, .check_step_down
@@ -111,7 +111,7 @@ UpdatePlayerCoords: ; d511 (3:5511)
inc [hl]
ret
-UpdateOverworldMap: ; d536 (3:5536)
+UpdateOverworldMap:
ld a, [wPlayerStepDirection]
and a
jr z, .step_down
@@ -147,7 +147,7 @@ UpdateOverworldMap: ; d536 (3:5536)
call ScrollMapLeft
ret
-.ScrollOverworldMapDown: ; d571 (3:5571)
+.ScrollOverworldMapDown:
ld a, [wBGMapAnchor]
add 2 * BG_MAP_WIDTH
ld [wBGMapAnchor], a
@@ -168,7 +168,7 @@ UpdateOverworldMap: ; d536 (3:5536)
.done_down
ret
-.Add6ToOverworldMapAnchor: ; d595 (3:5595)
+.Add6ToOverworldMapAnchor:
ld hl, wOverworldMapAnchor
ld a, [wMapWidth]
add 6
@@ -178,7 +178,7 @@ UpdateOverworldMap: ; d536 (3:5536)
inc [hl]
ret
-.ScrollOverworldMapUp: ; d5a2 (3:55a2)
+.ScrollOverworldMapUp:
ld a, [wBGMapAnchor]
sub 2 * BG_MAP_WIDTH
ld [wBGMapAnchor], a
@@ -199,7 +199,7 @@ UpdateOverworldMap: ; d536 (3:5536)
.done_up
ret
-.Sub6FromOverworldMapAnchor: ; d5c6 (3:55c6)
+.Sub6FromOverworldMapAnchor:
ld hl, wOverworldMapAnchor
ld a, [wMapWidth]
add 6
@@ -211,7 +211,7 @@ UpdateOverworldMap: ; d536 (3:5536)
dec [hl]
ret
-.ScrollOverworldMapLeft: ; d5d5 (3:55d5)
+.ScrollOverworldMapLeft:
ld a, [wBGMapAnchor]
ld e, a
and $e0
@@ -231,7 +231,7 @@ UpdateOverworldMap: ; d536 (3:5536)
.done_left
ret
-.DecrementwOverworldMapAnchor: ; d5f4 (3:55f4)
+.DecrementwOverworldMapAnchor:
ld hl, wOverworldMapAnchor
ld a, [hl]
sub 1
@@ -240,7 +240,7 @@ UpdateOverworldMap: ; d536 (3:5536)
dec [hl]
ret
-.ScrollOverworldMapRight: ; d5fe (3:55fe)
+.ScrollOverworldMapRight:
ld a, [wBGMapAnchor]
ld e, a
and $e0
@@ -260,7 +260,7 @@ UpdateOverworldMap: ; d536 (3:5536)
.done_right
ret
-.IncrementwOverworldMapAnchor: ; d61d (3:561d)
+.IncrementwOverworldMapAnchor:
ld hl, wOverworldMapAnchor
ld a, [hl]
add 1
diff --git a/engine/overworld/select_menu.asm b/engine/overworld/select_menu.asm
index 9898afda2..069d74f2d 100644
--- a/engine/overworld/select_menu.asm
+++ b/engine/overworld/select_menu.asm
@@ -1,4 +1,4 @@
-SelectMenu:: ; 13327
+SelectMenu::
call CheckRegisteredItem
jr c, .NotRegistered
@@ -11,16 +11,14 @@ SelectMenu:: ; 13327
call MapTextbox
call WaitButton
jp CloseText
-; 13340
-ItemMayBeRegisteredText: ; 13340
+ItemMayBeRegisteredText:
text_jump UnknownText_0x1c1cf3
db "@"
-; 13345
-CheckRegisteredItem: ; 13345
+CheckRegisteredItem:
ld a, [wWhichRegisteredItem]
and a
@@ -86,10 +84,9 @@ CheckRegisteredItem: ; 13345
ld [wRegisteredItem], a
scf
ret
-; 133a6
-.CheckRegisteredNo: ; 133a6
+.CheckRegisteredNo:
ld a, [wWhichRegisteredItem]
and REGISTERED_NUMBER
dec a
@@ -102,10 +99,9 @@ CheckRegisteredItem: ; 13345
.NotEnoughItems:
scf
ret
-; 133b6
-.IsSameItem: ; 133b6
+.IsSameItem:
ld a, [wRegisteredItem]
cp [hl]
jr nz, .NotSameItem
@@ -116,10 +112,9 @@ CheckRegisteredItem: ; 13345
.NotSameItem:
scf
ret
-; 133c3
-UseRegisteredItem: ; 133c3
+UseRegisteredItem:
farcall CheckItemMenu
ld a, [wItemAttributeParamBuffer]
@@ -136,25 +131,22 @@ UseRegisteredItem: ; 133c3
dw .Current
dw .Party
dw .Overworld
-; 133df
-.NoFunction: ; 133df
+.NoFunction:
call OpenText
call CantUseItem
call CloseText
and a
ret
-; 133ea
-.Current: ; 133ea
+.Current:
call OpenText
call DoItemEffect
call CloseText
and a
ret
-; 133f5
-.Party: ; 133f5
+.Party:
call RefreshScreen
call FadeToMenu
call DoItemEffect
@@ -162,9 +154,8 @@ UseRegisteredItem: ; 133c3
call CloseText
and a
ret
-; 13406
-.Overworld: ; 13406
+.Overworld:
call RefreshScreen
ld a, 1
ld [wUsingItemWithSelect], a
@@ -178,9 +169,8 @@ UseRegisteredItem: ; 133c3
ld a, HMENURETURN_SCRIPT
ld [hMenuReturn], a
ret
-; 13422
-.CantUse: ; 13422
+.CantUse:
call RefreshScreen
._cantuse
@@ -188,4 +178,3 @@ UseRegisteredItem: ; 133c3
call CloseText
and a
ret
-; 1342d
diff --git a/engine/overworld/spawn_points.asm b/engine/overworld/spawn_points.asm
index 1a3d12441..2c673d6b1 100644
--- a/engine/overworld/spawn_points.asm
+++ b/engine/overworld/spawn_points.asm
@@ -1,7 +1,7 @@
INCLUDE "data/maps/spawn_points.asm"
-LoadSpawnPoint: ; 1531f
+LoadSpawnPoint:
; loads the spawn point in wDefaultSpawnpoint
push hl
push de
@@ -26,10 +26,9 @@ LoadSpawnPoint: ; 1531f
pop de
pop hl
ret
-; 15344
-IsSpawnPoint: ; 15344
+IsSpawnPoint:
; Checks if the map loaded in de is a spawn point. Returns carry if it's a spawn point.
ld hl, SpawnPoints
ld c, 0
@@ -59,4 +58,3 @@ IsSpawnPoint: ; 15344
.yes
scf
ret
-; 15363
diff --git a/engine/overworld/tile_events.asm b/engine/overworld/tile_events.asm
index 705c0e427..bb566c997 100644
--- a/engine/overworld/tile_events.asm
+++ b/engine/overworld/tile_events.asm
@@ -1,4 +1,4 @@
-CheckWarpCollision:: ; 1499a
+CheckWarpCollision::
; Is this tile a warp?
ld a, [wPlayerStandingTile]
cp COLL_PIT
@@ -14,9 +14,8 @@ CheckWarpCollision:: ; 1499a
.warp
scf
ret
-; 149af
-CheckDirectionalWarp:: ; 149af
+CheckDirectionalWarp::
; If this is a directional warp, clear carry (press the designated button to warp).
; Else, set carry (immediate warp).
ld a, [wPlayerStandingTile]
@@ -34,17 +33,15 @@ CheckDirectionalWarp:: ; 149af
.directional
xor a
ret
-; 149c6
-CheckWarpFacingDown: ; 149c6
+CheckWarpFacingDown:
ld de, 1
ld hl, .blocks
ld a, [wPlayerStandingTile]
call IsInArray
ret
-; 149d3
-.blocks ; 149d3
+.blocks
db COLL_DOOR
db COLL_DOOR_79
db COLL_STAIRCASE
@@ -55,17 +52,15 @@ CheckWarpFacingDown: ; 149c6
db COLL_DOOR_75
db COLL_DOOR_7D
db -1
-; 149dd
-CheckGrassCollision:: ; 149dd
+CheckGrassCollision::
ld a, [wPlayerStandingTile]
ld hl, .blocks
ld de, 1
call IsInArray
ret
-; 149ea
-.blocks ; 149ea
+.blocks
db COLL_CUT_08
db COLL_TALL_GRASS
db COLL_LONG_GRASS
@@ -77,17 +72,15 @@ CheckGrassCollision:: ; 149dd
db COLL_GRASS_4B
db COLL_GRASS_4C
db -1
-; 149f5
-CheckCutCollision: ; 149f5
+CheckCutCollision:
ld a, c
ld hl, .blocks
ld de, 1
call IsInArray
ret
-; 14a00
-.blocks ; 14a00
+.blocks
db COLL_CUT_TREE
db COLL_CUT_TREE_1A
db COLL_TALL_GRASS_10
@@ -95,9 +88,8 @@ CheckCutCollision: ; 149f5
db COLL_LONG_GRASS
db COLL_LONG_GRASS_1C
db -1
-; 14a07
-GetWarpSFX:: ; 14a07
+GetWarpSFX::
ld a, [wPlayerStandingTile]
ld de, SFX_ENTER_DOOR
cp COLL_DOOR
@@ -107,4 +99,3 @@ GetWarpSFX:: ; 14a07
ret z
ld de, SFX_EXIT_BUILDING
ret
-; 14a1a
diff --git a/engine/overworld/time.asm b/engine/overworld/time.asm
index 0f83447cc..136adb221 100644
--- a/engine/overworld/time.asm
+++ b/engine/overworld/time.asm
@@ -1,21 +1,19 @@
-_InitializeStartDay: ; 113d6
+_InitializeStartDay:
call InitializeStartDay
ret
-; 113da
-ClearDailyTimers: ; 113da
+ClearDailyTimers:
xor a
ld [wLuckyNumberDayBuffer], a
ld [wUnusedTwoDayTimer], a
ld [wDailyResetTimer], a
ret
-; 113e5
-InitCallReceiveDelay:: ; 113e5
+InitCallReceiveDelay::
xor a
ld [wTimeCyclesSinceLastCall], a
-NextCallReceiveDelay: ; 113e9
+NextCallReceiveDelay:
ld a, [wTimeCyclesSinceLastCall]
cp 3
jr c, .okay
@@ -28,13 +26,11 @@ NextCallReceiveDelay: ; 113e9
add hl, de
ld a, [hl]
jp RestartReceiveCallDelay
-; 113fd
.ReceiveCallDelays:
db 20, 10, 5, 3
-; 11401
-CheckReceiveCallTimer: ; 11401
+CheckReceiveCallTimer:
call CheckReceiveCallDelay ; check timer
ret nc
ld hl, wTimeCyclesSinceLastCall
@@ -47,12 +43,11 @@ CheckReceiveCallTimer: ; 11401
call NextCallReceiveDelay ; restart timer
scf
ret
-; 11413
-InitOneDayCountdown: ; 11413
+InitOneDayCountdown:
ld a, 1
-InitNDaysCountdown: ; 11415
+InitNDaysCountdown:
ld [hl], a
push hl
call UpdateTime
@@ -60,9 +55,8 @@ InitNDaysCountdown: ; 11415
inc hl
call CopyDayToHL
ret
-; 11420
-CheckDayDependentEventHL: ; 11420
+CheckDayDependentEventHL:
inc hl
push hl
call CalcDaysSince
@@ -71,32 +65,28 @@ CheckDayDependentEventHL: ; 11420
dec hl
call UpdateTimeRemaining
ret
-; 1142e
-RestartReceiveCallDelay: ; 1142e
+RestartReceiveCallDelay:
ld hl, wReceiveCallDelay_MinsRemaining
ld [hl], a
call UpdateTime
ld hl, wReceiveCallDelay_StartTime
call CopyDayHourMinToHL
ret
-; 1143c
-CheckReceiveCallDelay: ; 1143c
+CheckReceiveCallDelay:
ld hl, wReceiveCallDelay_StartTime
call CalcMinsHoursDaysSince
call GetMinutesSinceIfLessThan60
ld hl, wReceiveCallDelay_MinsRemaining
call UpdateTimeRemaining
ret
-; 1144c
-RestartDailyResetTimer: ; 1144c
+RestartDailyResetTimer:
ld hl, wDailyResetTimer
jp InitOneDayCountdown
-; 11452
-CheckDailyResetTimer:: ; 11452
+CheckDailyResetTimer::
ld hl, wDailyResetTimer
call CheckDayDependentEventHL
ret nc
@@ -128,18 +118,16 @@ endr
call SampleKenjiBreakCountdown
.DontRestartKenjiBreakCountdown:
jr RestartDailyResetTimer
-; 11485
-SampleKenjiBreakCountdown: ; 11485
+SampleKenjiBreakCountdown:
; Generate a random number between 3 and 6
call Random
and %11
add 3
ld [wKenjiBreakTimer], a
ret
-; 11490
-StartBugContestTimer: ; 11490
+StartBugContestTimer:
ld a, BUG_CONTEST_MINUTES
ld [wBugContestMinsRemaining], a
ld a, BUG_CONTEST_SECONDS
@@ -148,10 +136,9 @@ StartBugContestTimer: ; 11490
ld hl, wBugContestStartTime
call CopyDayHourMinSecToHL
ret
-; 114a4
-CheckBugContestTimer:: ; 114a4 (4:54a4)
+CheckBugContestTimer::
ld hl, wBugContestStartTime
call CalcSecsMinsHoursDaysSince
ld a, [wDaysSince]
@@ -186,14 +173,13 @@ CheckBugContestTimer:: ; 114a4 (4:54a4)
ret
-InitializeStartDay: ; 114dd
+InitializeStartDay:
call UpdateTime
ld hl, wTimerEventStartDay
call CopyDayToHL
ret
-; 114e7
-CheckPokerusTick:: ; 114e7
+CheckPokerusTick::
ld hl, wTimerEventStartDay
call CalcDaysSince
call GetDaysSince
@@ -204,9 +190,8 @@ CheckPokerusTick:: ; 114e7
.done
xor a
ret
-; 114fc
-SetUnusedTwoDayTimer: ; 114fc
+SetUnusedTwoDayTimer:
ld a, 2
ld hl, wUnusedTwoDayTimer
ld [hl], a
@@ -214,22 +199,19 @@ SetUnusedTwoDayTimer: ; 114fc
ld hl, wUnusedTwoDayTimerStartDate
call CopyDayToHL
ret
-; 1150c
-CheckUnusedTwoDayTimer: ; 1150c
+CheckUnusedTwoDayTimer:
ld hl, wUnusedTwoDayTimerStartDate
call CalcDaysSince
call GetDaysSince
ld hl, wUnusedTwoDayTimer
call UpdateTimeRemaining
ret
-; 1151c
; unused
ld hl, wDailyFlags
set DAILYFLAGS_FISH_SWARM_F, [hl]
ret
-; 11522
; unused
and a
@@ -238,15 +220,13 @@ CheckUnusedTwoDayTimer: ; 1150c
ret nz
scf
ret
-; 1152b
-RestartLuckyNumberCountdown: ; 1152b
+RestartLuckyNumberCountdown:
call .GetDaysUntilNextFriday
ld hl, wLuckyNumberDayBuffer
jp InitNDaysCountdown
-; 11534
-.GetDaysUntilNextFriday: ; 11534
+.GetDaysUntilNextFriday:
call GetWeekday
ld c, a
ld a, FRIDAY
@@ -259,14 +239,12 @@ RestartLuckyNumberCountdown: ; 1152b
.earlier
ret
-; 11542
-_CheckLuckyNumberShowFlag: ; 11542
+_CheckLuckyNumberShowFlag:
ld hl, wLuckyNumberDayBuffer
jp CheckDayDependentEventHL
-; 11548
-DoMysteryGiftIfDayHasPassed: ; 11548
+DoMysteryGiftIfDayHasPassed:
ld a, BANK(sMysteryGiftTimer)
call GetSRAMBank
ld hl, sMysteryGiftTimer
@@ -294,9 +272,8 @@ DoMysteryGiftIfDayHasPassed: ; 11548
ld [sMysteryGiftTimer + 1], a
call CloseSRAM
ret
-; 11586
-UpdateTimeRemaining: ; 11586
+UpdateTimeRemaining:
; If the amount of time elapsed exceeds the capacity of its
; unit, skip this part.
cp -1
@@ -318,9 +295,8 @@ UpdateTimeRemaining: ; 11586
ld [hl], a
scf
ret
-; 11599
-GetSecondsSinceIfLessThan60: ; 11599
+GetSecondsSinceIfLessThan60:
ld a, [wDaysSince]
and a
jr nz, GetTimeElapsed_ExceedsUnitLimit
@@ -331,9 +307,8 @@ GetSecondsSinceIfLessThan60: ; 11599
jr nz, GetTimeElapsed_ExceedsUnitLimit
ld a, [wSecondsSince]
ret
-; 115ae
-GetMinutesSinceIfLessThan60: ; 115ae
+GetMinutesSinceIfLessThan60:
ld a, [wDaysSince]
and a
jr nz, GetTimeElapsed_ExceedsUnitLimit
@@ -342,45 +317,38 @@ GetMinutesSinceIfLessThan60: ; 115ae
jr nz, GetTimeElapsed_ExceedsUnitLimit
ld a, [wMinutesSince]
ret
-; 115be
-GetHoursSinceIfLessThan24: ; 115be
+GetHoursSinceIfLessThan24:
ld a, [wDaysSince]
and a
jr nz, GetTimeElapsed_ExceedsUnitLimit
ld a, [wHoursSince]
ret
-; 115c8
-GetDaysSince: ; 115c8
+GetDaysSince:
ld a, [wDaysSince]
ret
-; 115cc
-GetTimeElapsed_ExceedsUnitLimit: ; 115cc
+GetTimeElapsed_ExceedsUnitLimit:
ld a, -1
ret
-; 115cf
-CalcDaysSince: ; 115cf
+CalcDaysSince:
xor a
jr _CalcDaysSince
-; 115d2
-CalcHoursDaysSince: ; 115d2
+CalcHoursDaysSince:
inc hl
xor a
jr _CalcHoursDaysSince
-; 115d6
-CalcMinsHoursDaysSince: ; 115d6
+CalcMinsHoursDaysSince:
inc hl
inc hl
xor a
jr _CalcMinsHoursDaysSince
-; 115db
-CalcSecsMinsHoursDaysSince: ; 115db
+CalcSecsMinsHoursDaysSince:
inc hl
inc hl
inc hl
@@ -394,7 +362,7 @@ CalcSecsMinsHoursDaysSince: ; 115db
dec hl
ld [wSecondsSince], a ; seconds since
-_CalcMinsHoursDaysSince: ; 115eb
+_CalcMinsHoursDaysSince:
ld a, [hMinutes]
ld c, a
sbc [hl]
@@ -405,7 +373,7 @@ _CalcMinsHoursDaysSince: ; 115eb
dec hl
ld [wMinutesSince], a ; minutes since
-_CalcHoursDaysSince: ; 115f8
+_CalcHoursDaysSince:
ld a, [hHours]
ld c, a
sbc [hl]
@@ -426,9 +394,8 @@ _CalcDaysSince:
ld [hl], c ; current days
ld [wDaysSince], a ; days since
ret
-; 11613
-CopyDayHourMinSecToHL: ; 11613
+CopyDayHourMinSecToHL:
ld a, [wCurDay]
ld [hli], a
ld a, [hHours]
@@ -438,23 +405,20 @@ CopyDayHourMinSecToHL: ; 11613
ld a, [hSeconds]
ld [hli], a
ret
-; 11621
-CopyDayToHL: ; 11621
+CopyDayToHL:
ld a, [wCurDay]
ld [hl], a
ret
-; 11626
-CopyDayHourToHL: ; 11626
+CopyDayHourToHL:
ld a, [wCurDay]
ld [hli], a
ld a, [hHours]
ld [hli], a
ret
-; 1162e
-CopyDayHourMinToHL: ; 1162e
+CopyDayHourMinToHL:
ld a, [wCurDay]
ld [hli], a
ld a, [hHours]
@@ -462,4 +426,3 @@ CopyDayHourMinToHL: ; 1162e
ld a, [hMinutes]
ld [hli], a
ret
-; 11639
diff --git a/engine/overworld/variables.asm b/engine/overworld/variables.asm
index 3adf6df33..9b5e3846c 100644
--- a/engine/overworld/variables.asm
+++ b/engine/overworld/variables.asm
@@ -1,4 +1,4 @@
-_GetVarAction:: ; 80648 (20:4648)
+_GetVarAction::
ld a, c
cp NUM_VARS
jr c, .valid
@@ -28,13 +28,12 @@ _GetVarAction:: ; 80648 (20:4648)
call _de_
ret
-.loadstringbuffer2 ; 8066c (20:466c)
+.loadstringbuffer2
ld de, wStringBuffer2
ld [de], a
ret
-; 80671 (20:4671)
-.VarActionTable: ; 80671
+.VarActionTable:
; entries correspond to VAR_* constants
; RETVAR_STRBUF2: copy [de] to wStringBuffer2
; RETVAR_ADDR_DE: return address in de
@@ -67,51 +66,45 @@ _GetVarAction:: ; 80648 (20:4648)
dwb wBuenasPassword, RETVAR_ADDR_DE
dwb wKenjiBreakTimer, RETVAR_STRBUF2
dwb NULL, RETVAR_STRBUF2
-; 806c5
-.CountCaughtMons: ; 806c5
+.CountCaughtMons:
; Caught mons.
ld hl, wPokedexCaught
ld b, wEndPokedexCaught - wPokedexCaught
call CountSetBits
ld a, [wd265]
jp .loadstringbuffer2
-; 806d3
-.CountSeenMons: ; 806d3
+.CountSeenMons:
; Seen mons.
ld hl, wPokedexSeen
ld b, wEndPokedexSeen - wPokedexSeen
call CountSetBits
ld a, [wd265]
jp .loadstringbuffer2
-; 806e1
-.CountBadges: ; 806e1
+.CountBadges:
; Number of owned badges.
ld hl, wBadges
ld b, 2
call CountSetBits
ld a, [wd265]
jp .loadstringbuffer2
-; 806ef
-.PlayerFacing: ; 806ef
+.PlayerFacing:
; The direction the player is facing.
ld a, [wPlayerDirection]
and $c
rrca
rrca
jp .loadstringbuffer2
-; 806f9
-.DayOfWeek: ; 806f9
+.DayOfWeek:
; The day of the week.
call GetWeekday
jp .loadstringbuffer2
-; 806ff
-.UnownCaught: ; 806ff
+.UnownCaught:
; Number of unique Unown caught.
call .count
ld a, b
@@ -129,9 +122,8 @@ _GetVarAction:: ; 80648 (20:4648)
cp NUM_UNOWN
jr c, .loop
ret
-; 80715
-.BoxFreeSpace: ; 80715
+.BoxFreeSpace:
; Remaining slots in the current box.
ld a, BANK(sBoxCount)
call GetSRAMBank
@@ -142,10 +134,8 @@ _GetVarAction:: ; 80648 (20:4648)
call CloseSRAM
ld a, b
jp .loadstringbuffer2
-; 80728
-.BattleResult: ; 80728
+.BattleResult:
ld a, [wBattleResult]
and $ff ^ BATTLERESULT_BITMASK
jp .loadstringbuffer2
-; 80730
diff --git a/engine/overworld/warp_connection.asm b/engine/overworld/warp_connection.asm
index 2f5e488cc..0ab9a6c2d 100644
--- a/engine/overworld/warp_connection.asm
+++ b/engine/overworld/warp_connection.asm
@@ -1,5 +1,5 @@
-HandleNewMap: ; 1045b0
+HandleNewMap:
call Clearwc7e8
call ResetMapBufferEventFlags
call ResetFlashIfOutOfCave
@@ -7,7 +7,7 @@ HandleNewMap: ; 1045b0
call ResetBikeFlags
ld a, MAPCALLBACK_NEWMAP
call RunMapCallback
-InitCommandQueue: ; 1045c4
+InitCommandQueue:
farcall ClearCmdQueue
ld a, MAPCALLBACK_CMDQUEUE
call RunMapCallback
@@ -16,7 +16,7 @@ InitCommandQueue: ; 1045c4
ret
-EnterMapConnection: ; 1045d6
+EnterMapConnection:
; Return carry if a connection has been entered.
ld a, [wPlayerStepDirection]
and a
@@ -150,9 +150,8 @@ EnterMapConnection: ; 1045d6
.done
scf
ret
-; 1046c6
-LoadWarpData: ; 1046c6
+LoadWarpData:
call .SaveDigWarp
call .SetSpawn
ld a, [wNextWarp]
@@ -163,7 +162,7 @@ LoadWarpData: ; 1046c6
ld [wMapNumber], a
ret
-.SaveDigWarp: ; 1046df (41:46df)
+.SaveDigWarp:
call GetMapEnvironment
call CheckOutdoorMap
ret nz
@@ -195,7 +194,7 @@ LoadWarpData: ; 1046c6
ld [wDigMapNumber], a
ret
-.SetSpawn: ; 104718 (41:4718)
+.SetSpawn:
call GetMapEnvironment
call CheckOutdoorMap
ret nz
@@ -227,7 +226,7 @@ LoadWarpData: ; 1046c6
ld [wLastSpawnMapNumber], a
ret
-LoadMapTimeOfDay: ; 104750
+LoadMapTimeOfDay:
ld hl, wVramState
res 6, [hl]
ld a, $1
@@ -239,7 +238,7 @@ LoadMapTimeOfDay: ; 104750
call .PushAttrMap
ret
-.ClearBGMap: ; 104770 (41:4770)
+.ClearBGMap:
ld a, HIGH(vBGMap0)
ld [wBGMapAnchor + 1], a
xor a ; LOW(vBGMap0)
@@ -267,7 +266,7 @@ LoadMapTimeOfDay: ; 104750
call ByteFill
ret
-.PushAttrMap: ; 1047a3 (41:47a3)
+.PushAttrMap:
decoord 0, 0
call .copy
ld a, [hCGB]
@@ -298,7 +297,7 @@ LoadMapTimeOfDay: ; 104750
ld [rVBK], a
ret
-LoadGraphics: ; 1047cf
+LoadGraphics:
call LoadTileset
call LoadTilesetGFX
xor a
@@ -310,12 +309,11 @@ LoadGraphics: ; 1047cf
farcall LoadOverworldFont
ret
-LoadMapPalettes: ; 1047eb
+LoadMapPalettes:
ld b, SCGB_MAPPALS
jp GetSGBLayout
-; 1047f0
-RefreshMapSprites: ; 1047f0
+RefreshMapSprites:
call ClearSprites
farcall ReturnFromMapSetupScript
call GetMovementPermissions
@@ -333,7 +331,7 @@ RefreshMapSprites: ; 1047f0
ld [wPlayerSpriteSetupFlags], a
ret
-CheckMovingOffEdgeOfMap:: ; 104820 (41:4820)
+CheckMovingOffEdgeOfMap::
ld a, [wPlayerStepDirection]
cp STANDING
ret z
@@ -391,7 +389,7 @@ CheckMovingOffEdgeOfMap:: ; 104820 (41:4820)
ret
-GetCoordOfUpperLeftCorner:: ; 10486d
+GetCoordOfUpperLeftCorner::
ld hl, wOverworldMapBlocks
ld a, [wXCoord]
bit 0, a
@@ -436,4 +434,3 @@ GetCoordOfUpperLeftCorner:: ; 10486d
and $1
ld [wMetatileStandingX], a
ret
-; 1048ba
diff --git a/engine/overworld/wildmons.asm b/engine/overworld/wildmons.asm
index 20375ba6c..e28a18f89 100644
--- a/engine/overworld/wildmons.asm
+++ b/engine/overworld/wildmons.asm
@@ -1,4 +1,4 @@
-LoadWildMonData: ; 29ff8
+LoadWildMonData:
call _GrassWildmonLookup
jr c, .copy
ld hl, wMornEncounterRate
@@ -25,7 +25,7 @@ LoadWildMonData: ; 29ff8
ld [wWaterEncounterRate], a
ret
-FindNest: ; 2a01f
+FindNest:
; Parameters:
; e: 0 = Johto, 1 = Kanto
; wNamedObjectIndexBuffer: species
@@ -51,9 +51,8 @@ FindNest: ; 2a01f
call .FindGrass
ld hl, KantoWaterWildMons
jp .FindWater
-; 2a052
-.FindGrass: ; 2a052
+.FindGrass:
ld a, [hl]
cp -1
ret z
@@ -76,9 +75,8 @@ FindNest: ; 2a01f
ld bc, GRASS_WILDDATA_LENGTH
add hl, bc
jr .FindGrass
-; 2a06e
-.FindWater: ; 2a06e
+.FindWater:
ld a, [hl]
cp -1
ret z
@@ -99,9 +97,8 @@ FindNest: ; 2a01f
ld bc, 3 * 3
add hl, bc
jr .FindWater
-; 2a088
-.SearchMapForMon: ; 2a088
+.SearchMapForMon:
inc hl
.ScanMapLoop:
push af
@@ -119,9 +116,8 @@ FindNest: ; 2a01f
.found
pop af
jp .AppendNest
-; 2a09c
-.AppendNest: ; 2a09c
+.AppendNest:
push de
call GetWorldMapLocation
ld c, a
@@ -144,9 +140,8 @@ FindNest: ; 2a01f
pop de
and a
ret
-; 2a0b7
-.RoamMon1: ; 2a0b7
+.RoamMon1:
ld a, [wRoamMon1Species]
ld b, a
ld a, [wNamedObjectIndexBuffer]
@@ -161,9 +156,8 @@ FindNest: ; 2a01f
ld [de], a
inc de
ret
-; 2a0cf
-.RoamMon2: ; 2a0cf
+.RoamMon2:
ld a, [wRoamMon2Species]
ld b, a
ld a, [wNamedObjectIndexBuffer]
@@ -178,9 +172,8 @@ FindNest: ; 2a01f
ld [de], a
inc de
ret
-; 2a0e7
-TryWildEncounter:: ; 2a0e7
+TryWildEncounter::
; Try to trigger a wild encounter.
call .EncounterRate
jr nc, .no_battle
@@ -198,18 +191,16 @@ TryWildEncounter:: ; 2a0e7
ld a, 1
and a
ret
-; 2a103
-.EncounterRate: ; 2a103
+.EncounterRate:
call GetMapEncounterRate
call ApplyMusicEffectOnEncounterRate
call ApplyCleanseTagEffectOnEncounterRate
call Random
cp b
ret
-; 2a111
-GetMapEncounterRate: ; 2a111
+GetMapEncounterRate:
ld hl, wMornEncounterRate
call CheckOnWater
ld a, wWaterEncounterRate - wMornEncounterRate
@@ -221,9 +212,8 @@ GetMapEncounterRate: ; 2a111
add hl, bc
ld b, [hl]
ret
-; 2a124
-ApplyMusicEffectOnEncounterRate:: ; 2a124
+ApplyMusicEffectOnEncounterRate::
; Pokemon March and Ruins of Alph signal double encounter rate.
; Pokemon Lullaby halves encounter rate.
ld a, [wMapMusic]
@@ -239,9 +229,8 @@ ApplyMusicEffectOnEncounterRate:: ; 2a124
.double
sla b
ret
-; 2a138
-ApplyCleanseTagEffectOnEncounterRate:: ; 2a138
+ApplyCleanseTagEffectOnEncounterRate::
; Cleanse Tag halves encounter rate.
ld hl, wPartyMon1Item
ld de, PARTYMON_STRUCT_LENGTH
@@ -259,9 +248,8 @@ ApplyCleanseTagEffectOnEncounterRate:: ; 2a138
.cleansetag
srl b
ret
-; 2a14f
-ChooseWildEncounter: ; 2a14f
+ChooseWildEncounter:
call LoadWildMonDataPointer
jp nc, .nowildbattle
call CheckEncounterRoamMon
@@ -355,11 +343,10 @@ ChooseWildEncounter: ; 2a14f
.startwildbattle
xor a
ret
-; 2a1cb
INCLUDE "data/wild/probabilities.asm"
-CheckRepelEffect:: ; 2a1df
+CheckRepelEffect::
; If there is no active Repel, there's no need to be here.
ld a, [wRepelEffect]
and a
@@ -389,13 +376,12 @@ endr
.encounter
scf
ret
-; 2a200
-LoadWildMonDataPointer: ; 2a200
+LoadWildMonDataPointer:
call CheckOnWater
jr z, _WaterWildmonLookup
-_GrassWildmonLookup: ; 2a205
+_GrassWildmonLookup:
ld hl, SwarmGrassWildMons
ld bc, GRASS_WILDDATA_LENGTH
call _SwarmWildmonCheck
@@ -406,7 +392,7 @@ _GrassWildmonLookup: ; 2a205
ld bc, GRASS_WILDDATA_LENGTH
jr _NormalWildmonOK
-_WaterWildmonLookup: ; 2a21d
+_WaterWildmonLookup:
ld hl, SwarmWaterWildMons
ld bc, WATER_WILDDATA_LENGTH
call _SwarmWildmonCheck
@@ -467,17 +453,15 @@ _NoSwarmWildmon:
_NormalWildmonOK:
call CopyCurrMapDE
jr LookUpWildmonsForMapDE
-; 2a27f
-CopyCurrMapDE: ; 2a27f
+CopyCurrMapDE:
ld a, [wMapGroup]
ld d, a
ld a, [wMapNumber]
ld e, a
ret
-; 2a288
-LookUpWildmonsForMapDE: ; 2a288
+LookUpWildmonsForMapDE:
.loop
push hl
ld a, [hl]
@@ -505,10 +489,9 @@ LookUpWildmonsForMapDE: ; 2a288
pop hl
scf
ret
-; 2a2a0
-InitRoamMons: ; 2a2a0
+InitRoamMons:
; initialize wRoamMon structs
; species
@@ -540,10 +523,9 @@ InitRoamMons: ; 2a2a0
ld [wRoamMon2HP], a
ret
-; 2a2ce
-CheckEncounterRoamMon: ; 2a2ce
+CheckEncounterRoamMon:
push hl
; Don't trigger an encounter if we're on water.
call CheckOnWater
@@ -589,10 +571,9 @@ CheckEncounterRoamMon: ; 2a2ce
pop hl
and a
ret
-; 2a30d
-UpdateRoamMons: ; 2a30d
+UpdateRoamMons:
ld a, [wRoamMon1MapGroup]
cp GROUP_N_A
jr z, .SkipRaikou
@@ -633,10 +614,9 @@ UpdateRoamMons: ; 2a30d
.Finished:
jp _BackUpMapIndices
-; 2a355
-.Update: ; 2a355
+.Update:
ld hl, RoamMaps
.loop
; Are we at the end of the table?
@@ -693,7 +673,7 @@ UpdateRoamMons: ; 2a30d
ld c, [hl]
ret
-JumpRoamMons: ; 2a394
+JumpRoamMons:
ld a, [wRoamMon1MapGroup]
cp GROUP_N_A
jr z, .SkipRaikou
@@ -726,7 +706,7 @@ JumpRoamMons: ; 2a394
.Finished:
jp _BackUpMapIndices
-JumpRoamMon: ; 2a3cd
+JumpRoamMon:
.loop
ld hl, RoamMaps
.innerloop1 ; This loop happens to be unnecessary.
@@ -760,9 +740,8 @@ JumpRoamMon: ; 2a3cd
ld b, a
ld c, [hl]
ret
-; 2a3f6
-_BackUpMapIndices: ; 2a3f6
+_BackUpMapIndices:
ld a, [wRoamMons_CurrentMapNumber]
ld [wRoamMons_LastMapNumber], a
ld a, [wRoamMons_CurrentMapGroup]
@@ -772,13 +751,12 @@ _BackUpMapIndices: ; 2a3f6
ld a, [wMapGroup]
ld [wRoamMons_CurrentMapGroup], a
ret
-; 2a40f
INCLUDE "data/wild/roammon_maps.asm"
-ValidateTempWildMonSpecies: ; 2a4a0
+ValidateTempWildMonSpecies:
; Due to a development oversight, this function is called with the wild Pokemon's level, not its species, in a.
and a
jr z, .nowildmon ; = 0
@@ -790,11 +768,10 @@ ValidateTempWildMonSpecies: ; 2a4a0
.nowildmon
scf
ret
-; 2a4ab
; Finds a rare wild Pokemon in the route of the trainer calling, then checks if it's been Seen already.
; The trainer will then tell you about the Pokemon if you haven't seen it.
-RandomUnseenWildMon: ; 2a4ab
+RandomUnseenWildMon:
farcall GetCallerLocation
ld d, b
ld e, c
@@ -867,7 +844,7 @@ RandomUnseenWildMon: ; 2a4ab
db "@"
; 0x2a51f
-RandomPhoneWildMon: ; 2a51f
+RandomPhoneWildMon:
farcall GetCallerLocation
ld d, b
ld e, c
@@ -905,9 +882,8 @@ RandomPhoneWildMon: ; 2a51f
ld de, wStringBuffer4
ld bc, MON_NAME_LENGTH
jp CopyBytes
-; 2a567
-RandomPhoneMon: ; 2a567
+RandomPhoneMon:
; Get a random monster owned by the trainer who's calling.
farcall GetCallerLocation
ld hl, TrainerGroups
@@ -989,7 +965,6 @@ RandomPhoneMon: ; 2a567
ld de, wStringBuffer4
ld bc, MON_NAME_LENGTH
jp CopyBytes
-; 2a5e9
INCLUDE "data/wild/johto_grass.asm"