ref: cc8c36ee149b287b7a1cabb85abb4bf42873a3b2
parent: 01fe51df0ca5c6e2f99df9f34d308ff98516478d
author: PikalaxALT <PikalaxALT@gmail.com>
date: Fri Nov 13 13:59:49 EST 2015
Creation of constants for OBJECT_09 indices
--- a/constants/sprite_constants.asm
+++ b/constants/sprite_constants.asm
@@ -266,3 +266,31 @@
const SPRITEMOVEFN_1B
MAX_OUTDOOR_SPRITES EQU 23
+
+ const_def
+ const OBJECT_09_VALUE_00
+ const OBJECT_09_VALUE_01
+ const OBJECT_09_VALUE_02
+ const OBJECT_09_VALUE_03
+ const OBJECT_09_VALUE_04
+ const OBJECT_09_VALUE_05
+ const OBJECT_09_VALUE_06
+ const OBJECT_09_VALUE_07
+ const OBJECT_09_VALUE_08
+ const OBJECT_09_VALUE_09
+ const OBJECT_09_VALUE_0A
+ const OBJECT_09_VALUE_0B
+ const OBJECT_09_VALUE_0C
+ const OBJECT_09_VALUE_0D
+ const OBJECT_09_VALUE_0E
+ const OBJECT_09_VALUE_0F
+ const OBJECT_09_VALUE_10
+ const OBJECT_09_VALUE_11
+ const OBJECT_09_VALUE_12
+ const OBJECT_09_VALUE_13
+ const OBJECT_09_VALUE_14
+ const OBJECT_09_VALUE_15
+ const OBJECT_09_VALUE_16
+ const OBJECT_09_VALUE_17
+ const OBJECT_09_VALUE_18
+ const OBJECT_09_VALUE_19
--- a/engine/events.asm
+++ b/engine/events.asm
@@ -24,13 +24,13 @@
; 966cb
-ClearAllScriptFlags3: ; 966cb
+DisableEvents: ; 966cb
xor a
ld [ScriptFlags3], a
ret
; 966d0
-SetAll_ScriptFlags3:: ; 966d0
+EnableEvents:: ; 966d0
ld a, $ff
ld [ScriptFlags3], a
ret
@@ -42,73 +42,73 @@
ret
; 966dc
-ResetBit2_ScriptFlags3: ; 966dc
+DisableWarpsConnxns: ; 966dc
ld hl, ScriptFlags3
res 2, [hl]
ret
; 966e2
-ResetBit1_ScriptFlags3: ; 966e2
+DisableCoordEvents: ; 966e2
ld hl, ScriptFlags3
res 1, [hl]
ret
; 966e8
-ResetBit0_ScriptFlags3: ; 966e8
+DisableStepCount: ; 966e8
ld hl, ScriptFlags3
res 0, [hl]
ret
; 966ee
-ResetBit4_ScriptFlags3: ; 966ee
+DisableWildEncounters: ; 966ee
ld hl, ScriptFlags3
res 4, [hl]
ret
; 966f4
-SetBit2_ScriptFlags3: ; 966f4
+EnableWarpsConnxns: ; 966f4
ld hl, ScriptFlags3
set 2, [hl]
ret
; 966fa
-SetBit1_ScriptFlags3: ; 966fa
+EnableCoordEvents: ; 966fa
ld hl, ScriptFlags3
set 1, [hl]
ret
; 96700
-SetBit0_ScriptFlags3: ; 96700
+EnableStepCount: ; 96700
ld hl, ScriptFlags3
set 0, [hl]
ret
; 96706
-SetBit4_ScriptFlags3: ; 96706
+EnableWildEncounters: ; 96706
ld hl, ScriptFlags3
set 4, [hl]
ret
; 9670c
-CheckBit2_ScriptFlags3: ; 9670c
+CheckWarpConnxnScriptFlag: ; 9670c
ld hl, ScriptFlags3
bit 2, [hl]
ret
; 96712
-CheckBit1_ScriptFlags3: ; 96712
+CheckCoordEventScriptFlag: ; 96712
ld hl, ScriptFlags3
bit 1, [hl]
ret
; 96718
-CheckBit0_ScriptFlags3: ; 96718
+CheckStepCountScriptFlag: ; 96718
ld hl, ScriptFlags3
bit 0, [hl]
ret
; 9671e
-CheckBit4_ScriptFlags3: ; 9671e
+CheckWildEncountersScriptFlag: ; 9671e
ld hl, ScriptFlags3
bit 4, [hl]
ret
@@ -135,13 +135,13 @@
ld [wd454], a
call SetUpFiveStepWildEncounterCooldown
callba RunMapSetupScript
- call ClearAllScriptFlags3
+ call DisableEvents
ld a, [hMapEntryMethod]
cp MAPSETUP_CONNECTION
- jr nz, .dontset
- call SetAll_ScriptFlags3
-.dontset
+ jr nz, .dont_enable
+ call EnableEvents
+.dont_enable
ld a, [hMapEntryMethod]
cp MAPSETUP_RELOADMAP
@@ -197,7 +197,7 @@
.events ; 967a1
call PlayerEvents
- call ClearAllScriptFlags3
+ call DisableEvents
callba ScriptEvents
ret
; 967ae
@@ -238,7 +238,7 @@
; 967d1
Function967d1: ; 967d1
- callba Function576a
+ callba Function576a ; engine/map_objects.asm
callba Functiond497
call Function96812
ret
@@ -259,7 +259,7 @@
jr z, .noevents
bit 4, a
jr nz, .noevents
- call SetAll_ScriptFlags3
+ call EnableEvents
.events
ld a, 0 ; events
@@ -355,8 +355,8 @@
CheckTileEvent: ; 96874
; Check for warps, tile triggers or wild battles.
- call CheckBit2_ScriptFlags3
- jr z, .bit2
+ call CheckWarpConnxnScriptFlag
+ jr z, .connections_disabled
callba CheckMovingOffEdgeOfMap
jr c, .map_connection
@@ -364,22 +364,22 @@
call CheckWarpTile
jr c, .warp_tile
-.bit2
- call CheckBit1_ScriptFlags3
- jr z, .bit1
+.connections_disabled
+ call CheckCoordEventScriptFlag
+ jr z, .coord_events_disabled
call CheckCurrentMapXYTriggers
- jr c, .movement
+ jr c, .coord_event
-.bit1
- call CheckBit0_ScriptFlags3
- jr z, .bit0
+.coord_events_disabled
+ call CheckStepCountScriptFlag
+ jr z, .step_count_disabled
call CountStep
ret c
-.bit0
- call CheckBit4_ScriptFlags3
+.step_count_disabled
+ call CheckWildEncountersScriptFlag
jr z, .ok
call RandomEncounter
@@ -408,8 +408,8 @@
scf
ret
-.movement
- ld hl, MovementAnimation
+.coord_event
+ ld hl, EngineBuffer5
ld a, [hli]
ld h, [hl]
ld l, a
@@ -552,7 +552,7 @@
jr nz, .NoAction
; Can't perform button actions while sliding on ice.
- callba Function80404
+ callba CheckStandingOnIce
jr c, .NoAction
call CheckAPressOW
@@ -1077,12 +1077,12 @@
dba SeenByTrainerScript ; 1
dba TalkToTrainerScript ; 2
dba FindItemInBallScript ; 3
- dba UnknownScript_0x96c4d ; 4
+ dba EdgeWarpScript ; 4
dba WarpToNewMapScript ; 5
dba FallIntoMapScript ; 6
dba Script_OverworldWhiteout ; 7
dba HatchEggScript ; 8
- dba UnknownScript_0x96c4f ; 9
+ dba ChangeDirectionScript ; 9
dba Invalid_0x96c2d ; 10
; 96c2d
@@ -1124,13 +1124,13 @@
end
; 96c4d
-UnknownScript_0x96c4d: ; 4
+EdgeWarpScript: ; 4
reloadandreturn MAPSETUP_CONNECTION
; 96c4f
-UnknownScript_0x96c4f: ; 9
- deactivatefacing $3
- callasm SetBit4_ScriptFlags3
+ChangeDirectionScript: ; 9
+ deactivatefacing 3
+ callasm EnableWildEncounters
end
; 96c56
--- a/engine/map_objects.asm
+++ b/engine/map_objects.asm
@@ -2,45 +2,45 @@
INCLUDE "engine/facings.asm"
SpriteMovementData:: ; 4273
- ; function, facing, ?, ?, ?, ?
- db SPRITEMOVEFN_00, DOWN, $01, $02, $00, $00 ; 00
- db SPRITEMOVEFN_STANDING, DOWN, $01, $0c, $00, $00 ; 01
- db SPRITEMOVEFN_RANDOM_WALK_XY, DOWN, $01, $00, $00, $00 ; 02
- db SPRITEMOVEFN_SLOW_RANDOM_SPIN, DOWN, $01, $00, $00, $00 ; 03
- db SPRITEMOVEFN_RANDOM_WALK_Y, DOWN, $01, $00, $00, $00 ; 04
- db SPRITEMOVEFN_RANDOM_WALK_X, DOWN, $01, $00, $00, $00 ; 05
- db SPRITEMOVEFN_STANDING, DOWN, $01, $00, $00, $00 ; 06
- db SPRITEMOVEFN_STANDING, UP, $01, $00, $00, $00 ; 07
- db SPRITEMOVEFN_STANDING, LEFT, $01, $00, $00, $00 ; 08
- db SPRITEMOVEFN_STANDING, RIGHT, $01, $00, $00, $00 ; 09
- db SPRITEMOVEFN_FAST_RANDOM_SPIN, DOWN, $01, $00, $00, $00 ; 0a
- db SPRITEMOVEFN_OBEY_DPAD, DOWN, $01, $02, $00, $00 ; 0b
- db SPRITEMOVEFN_08, DOWN, $01, $00, $00, $00 ; 0c
- db SPRITEMOVEFN_09, DOWN, $01, $00, $00, $00 ; 0d
- db SPRITEMOVEFN_0A, DOWN, $01, $00, $00, $00 ; 0e
- db SPRITEMOVEFN_0B, DOWN, $01, $00, $00, $00 ; 0f
- db SPRITEMOVEFN_0C, DOWN, $01, $00, $00, $00 ; 10
- db SPRITEMOVEFN_0D, DOWN, $01, $00, $00, $00 ; 11
- db SPRITEMOVEFN_0E, DOWN, $01, $00, $00, $00 ; 12
- db SPRITEMOVEFN_FOLLOW, DOWN, $01, $02, $00, $00 ; 13
- db SPRITEMOVEFN_SCRIPTED, DOWN, $01, $02, $00, $00 ; 14
- db SPRITEMOVEFN_BIG_SNORLAX, DOWN, $09, $2e, $01, $c0 ; 15
- db SPRITEMOVEFN_BOUNCE, DOWN, $0a, $2e, $00, $00 ; 16
- db SPRITEMOVEFN_STANDING, DOWN, $01, $0c, $00, $00 ; 17
- db SPRITEMOVEFN_STANDING, DOWN, $01, $2e, $10, $00 ; 18
- db SPRITEMOVEFN_STRENGTH, DOWN, $01, $2e, $00, $40 ; 19
- db SPRITEMOVEFN_FOLLOWNOTEXACT, DOWN, $01, $02, $00, $00 ; 1a
- db SPRITEMOVEFN_13, DOWN, $00, $8e, $01, $00 ; 1b
- db SPRITEMOVEFN_14, DOWN, $08, $8e, $02, $00 ; 1c
- db SPRITEMOVEFN_17, DOWN, $00, $82, $00, $00 ; 1d
+ ; function, facing, ?, ?, ?, ?
+ db SPRITEMOVEFN_00, DOWN, $01, $02, $00, $00 ; 00
+ db SPRITEMOVEFN_STANDING, DOWN, $01, $0c, $00, $00 ; 01
+ db SPRITEMOVEFN_RANDOM_WALK_XY, DOWN, $01, $00, $00, $00 ; 02
+ db SPRITEMOVEFN_SLOW_RANDOM_SPIN, DOWN, $01, $00, $00, $00 ; 03
+ db SPRITEMOVEFN_RANDOM_WALK_Y, DOWN, $01, $00, $00, $00 ; 04
+ db SPRITEMOVEFN_RANDOM_WALK_X, DOWN, $01, $00, $00, $00 ; 05
+ db SPRITEMOVEFN_STANDING, DOWN, $01, $00, $00, $00 ; 06
+ db SPRITEMOVEFN_STANDING, UP, $01, $00, $00, $00 ; 07
+ db SPRITEMOVEFN_STANDING, LEFT, $01, $00, $00, $00 ; 08
+ db SPRITEMOVEFN_STANDING, RIGHT, $01, $00, $00, $00 ; 09
+ db SPRITEMOVEFN_FAST_RANDOM_SPIN, DOWN, $01, $00, $00, $00 ; 0a
+ db SPRITEMOVEFN_OBEY_DPAD, DOWN, $01, $02, $00, $00 ; 0b
+ db SPRITEMOVEFN_08, DOWN, $01, $00, $00, $00 ; 0c
+ db SPRITEMOVEFN_09, DOWN, $01, $00, $00, $00 ; 0d
+ db SPRITEMOVEFN_0A, DOWN, $01, $00, $00, $00 ; 0e
+ db SPRITEMOVEFN_0B, DOWN, $01, $00, $00, $00 ; 0f
+ db SPRITEMOVEFN_0C, DOWN, $01, $00, $00, $00 ; 10
+ db SPRITEMOVEFN_0D, DOWN, $01, $00, $00, $00 ; 11
+ db SPRITEMOVEFN_0E, DOWN, $01, $00, $00, $00 ; 12
+ db SPRITEMOVEFN_FOLLOW, DOWN, $01, $02, $00, $00 ; 13
+ db SPRITEMOVEFN_SCRIPTED, DOWN, $01, $02, $00, $00 ; 14
+ db SPRITEMOVEFN_BIG_SNORLAX, DOWN, $09, $2e, $01, $c0 ; 15
+ db SPRITEMOVEFN_BOUNCE, DOWN, $0a, $2e, $00, $00 ; 16
+ db SPRITEMOVEFN_STANDING, DOWN, $01, $0c, $00, $00 ; 17
+ db SPRITEMOVEFN_STANDING, DOWN, $01, $2e, $10, $00 ; 18
+ db SPRITEMOVEFN_STRENGTH, DOWN, $01, $2e, $00, $40 ; 19
+ db SPRITEMOVEFN_FOLLOWNOTEXACT, DOWN, $01, $02, $00, $00 ; 1a
+ db SPRITEMOVEFN_13, DOWN, $00, $8e, $01, $00 ; 1b
+ db SPRITEMOVEFN_14, DOWN, $08, $8e, $02, $00 ; 1c
+ db SPRITEMOVEFN_17, DOWN, $00, $82, $00, $00 ; 1d
db SPRITEMOVEFN_SPIN_COUNTERCLOCKWISE, LEFT, $01, $00, $00, $00 ; 1e
- db SPRITEMOVEFN_SPIN_CLOCKWISE, RIGHT, $01, $00, $00, $00 ; 1f
- db SPRITEMOVEFN_STRENGTH, DOWN, $0c, $2e, $01, $c0 ; 20
- db SPRITEMOVEFN_STRENGTH, DOWN, $0d, $2e, $01, $c0 ; 21
- db SPRITEMOVEFN_1A, DOWN, $0e, $8e, $01, $00 ; 22
- db SPRITEMOVEFN_1B, DOWN, $0f, $8e, $02, $00 ; 23
- db SPRITEMOVEFN_RANDOM_WALK_XY, DOWN, $01, $00, $00, $20 ; 24
- db SPRITEMOVEFN_00, DOWN, $01, $00, $00, $00 ; 25
+ db SPRITEMOVEFN_SPIN_CLOCKWISE, RIGHT, $01, $00, $00, $00 ; 1f
+ db SPRITEMOVEFN_STRENGTH, DOWN, $0c, $2e, $01, $c0 ; 20
+ db SPRITEMOVEFN_STRENGTH, DOWN, $0d, $2e, $01, $c0 ; 21
+ db SPRITEMOVEFN_1A, DOWN, $0e, $8e, $01, $00 ; 22
+ db SPRITEMOVEFN_1B, DOWN, $0f, $8e, $02, $00 ; 23
+ db SPRITEMOVEFN_RANDOM_WALK_XY, DOWN, $01, $00, $00, $20 ; 24
+ db SPRITEMOVEFN_00, DOWN, $01, $00, $00, $00 ; 25
; 4357
@@ -156,11 +156,13 @@
ld a, [hl]
and a
jr z, .zero
+
ld hl, OBJECT_FLAGS2
add hl, bc
bit 5, [hl]
jr nz, .bit5
- cp 1
+
+ cp OBJECT_09_VALUE_01
jr z, .one
jr .ok
@@ -178,7 +180,7 @@
ld a, [hl]
and a
ret z
- cp 1
+ cp OBJECT_09_VALUE_01
ret z
.ok
@@ -892,6 +894,7 @@
; 47a8
JumptoObjectStructField28: ; 47a8
+; anonymous jumptable
ld hl, OBJECT_28
add hl, bc
ld a, [hl]
@@ -931,7 +934,7 @@
call Function467b
ld hl, OBJECT_09
add hl, bc
- ld [hl], 1
+ ld [hl], OBJECT_09_VALUE_01
ret
; 47dd
@@ -1037,7 +1040,7 @@
ld [hl], 1
ld hl, OBJECT_09
add hl, bc
- ld [hl], 5
+ ld [hl], OBJECT_09_VALUE_05
ret
; 487c
@@ -1121,7 +1124,7 @@
call Function463f
ld hl, OBJECT_09
add hl, bc
- ld [hl], $f
+ ld [hl], OBJECT_09_VALUE_0F
ret
.ok2
@@ -1223,7 +1226,7 @@
ld [hl], 9
ld hl, OBJECT_09
add hl, bc
- ld [hl], 4
+ ld [hl], OBJECT_09_VALUE_04
ret
; 496e
@@ -1237,7 +1240,7 @@
ld [hl], 10
ld hl, OBJECT_09
add hl, bc
- ld [hl], 4
+ ld [hl], OBJECT_09_VALUE_04
ret
; 4984
@@ -1274,7 +1277,7 @@
ld [hl], a
ld hl, OBJECT_09
add hl, bc
- ld [hl], 3
+ ld [hl], OBJECT_09_VALUE_03
call IncrementObjectStructField27
ret
; 49b8
@@ -1351,7 +1354,7 @@
ld [hl], 0
ld hl, OBJECT_09
add hl, bc
- ld [hl], $13
+ ld [hl], OBJECT_09_VALUE_13
ret
; 4a21
@@ -1372,7 +1375,7 @@
ld [hl], 0
ld hl, OBJECT_09
add hl, bc
- ld [hl], $13
+ ld [hl], OBJECT_09_VALUE_13
ret
; 4a46
@@ -1411,7 +1414,7 @@
ld [hl], e
ld hl, OBJECT_09
add hl, bc
- ld [hl], $13
+ ld [hl], OBJECT_09_VALUE_13
ret
; 4a81
@@ -1438,7 +1441,7 @@
ld [hl], a
ld hl, OBJECT_09
add hl, bc
- ld [hl], $13
+ ld [hl], OBJECT_09_VALUE_13
ret
; 4aa8
@@ -1476,7 +1479,7 @@
ld [hl], a
ld hl, OBJECT_09
add hl, bc
- ld [hl], $15
+ ld [hl], OBJECT_09_VALUE_15
ret
; 4ade
@@ -1512,13 +1515,13 @@
jr z, .load_6
ld hl, OBJECT_09
add hl, bc
- ld [hl], 7
+ ld [hl], OBJECT_09_VALUE_07
ret
.load_6
ld hl, OBJECT_09
add hl, bc
- ld [hl], 6
+ ld [hl], OBJECT_09_VALUE_06
ret
Function4b17: ; 4b17
@@ -1553,37 +1556,38 @@
ld [hl], 1
ld hl, OBJECT_09
add hl, bc
- ld [hl], 3
+ ld [hl], OBJECT_09_VALUE_03
ret
; 4b45
Pointers4b45: ; 4b45
- dw Function47bc
- dw Function47dd
- dw Function4e2b
- dw Function4ddd
- dw Function4e21
- dw Function4e0c
- dw Function4e56
- dw Function4e47
- dw Function4b86
- dw Function4bbf
- dw Function4e83
- dw Function4dff
- dw Function4c18
- dw Function4c89
- dw Function4d14
- dw Function4ecd
- dw Function4d7e
- dw Function4daf
- dw Function4dc8
- dw Function4f04
- dw Function4f33
- dw Function4f33
- dw Function4f77
- dw Function4f7a
- dw Function4df0
- dw Function4f83
+; These pointers use OBJECT_09. See constants/sprite_constants.asm
+ dw Function47bc ; 00
+ dw Function47dd ; 01
+ dw Function4e2b ; 02
+ dw Function4ddd ; 03
+ dw Function4e21 ; 04
+ dw Function4e0c ; 05
+ dw Function4e56 ; 06
+ dw Function4e47 ; 07
+ dw Function4b86 ; 08
+ dw Function4bbf ; 09
+ dw Function4e83 ; 0a
+ dw Function4dff ; 0b
+ dw Function4c18 ; 0c
+ dw Function4c89 ; 0d
+ dw Function4d14 ; 0e
+ dw Function4ecd ; 0f
+ dw Function4d7e ; 10
+ dw Function4daf ; 11
+ dw Function4dc8 ; 12
+ dw Function4f04 ; 13
+ dw Function4f33 ; 14
+ dw Function4f33 ; 15
+ dw Function4f77 ; 16
+ dw Function4f7a ; 17
+ dw Function4df0 ; 18
+ dw Function4f83 ; 19
; 4b79
Function4b79: ; 4b79
@@ -1593,7 +1597,7 @@
ret nz
ld hl, OBJECT_09
add hl, bc
- ld [hl], 1
+ ld [hl], OBJECT_09_VALUE_01
ret
; 4b86
@@ -1629,7 +1633,7 @@
call Function4600
ld hl, OBJECT_09
add hl, bc
- ld [hl], 1
+ ld [hl], OBJECT_09_VALUE_01
ret
; 4bbf
@@ -1686,7 +1690,7 @@
call Function4600
ld hl, OBJECT_09
add hl, bc
- ld [hl], 1
+ ld [hl], OBJECT_09_VALUE_01
ret
; 4c18
@@ -1762,7 +1766,7 @@
ld [hl], 0
ld hl, OBJECT_09
add hl, bc
- ld [hl], 1
+ ld [hl], OBJECT_09_VALUE_01
ret
; 4c89
@@ -1861,7 +1865,7 @@
ld [hl], 0
ld hl, OBJECT_09
add hl, bc
- ld [hl], 1
+ ld [hl], OBJECT_09_VALUE_01
ret
; 4d14
@@ -1934,7 +1938,7 @@
ld [hl], 0
ld hl, OBJECT_09
add hl, bc
- ld [hl], 1
+ ld [hl], OBJECT_09_VALUE_01
ret
; 4d7e
@@ -1970,7 +1974,7 @@
ld [hl], 0
ld hl, OBJECT_09
add hl, bc
- ld [hl], 1
+ ld [hl], OBJECT_09_VALUE_01
ret
; 4daf
@@ -2021,7 +2025,7 @@
ret nz
ld hl, OBJECT_09
add hl, bc
- ld [hl], 1
+ ld [hl], OBJECT_09_VALUE_01
ret
; 4df0
@@ -2043,7 +2047,7 @@
ret nz
ld hl, OBJECT_09
add hl, bc
- ld [hl], 1
+ ld [hl], OBJECT_09_VALUE_01
ret
; 4e0c
@@ -2055,7 +2059,7 @@
Function4e13: ; 4e13
call RestoreDefaultMovement
- call Function1a47
+ call GetInitialFacing
ld hl, OBJECT_FACING
add hl, bc
ld [hl], a
@@ -2084,7 +2088,7 @@
ld [hl], STANDING
ld hl, OBJECT_09
add hl, bc
- ld [hl], 1
+ ld [hl], OBJECT_09_VALUE_01
ret
; 4e47
@@ -2126,7 +2130,7 @@
ld [hl], STANDING
ld hl, OBJECT_09
add hl, bc
- ld [hl], 1
+ ld [hl], OBJECT_09_VALUE_01
ret
; 4e83
@@ -2183,7 +2187,7 @@
ret nz
ld hl, OBJECT_09
add hl, bc
- ld [hl], 1
+ ld [hl], OBJECT_09_VALUE_01
ret
; 4ecd
@@ -2215,7 +2219,7 @@
ld [hl], STANDING
ld hl, OBJECT_09
add hl, bc
- ld [hl], 1
+ ld [hl], OBJECT_09_VALUE_01
ret
; 4f04
@@ -2347,7 +2351,7 @@
ld [hl], 0
ld hl, OBJECT_09
add hl, bc
- ld [hl], 1
+ ld [hl], OBJECT_09_VALUE_01
ret
; 4fb2
@@ -2404,7 +2408,7 @@
; 5000
Function5000: ; unscripted?
-; copy [wc3de] to [wc2df]
+; copy [wc2de] to [wc2df]
ld a, [wc2de]
ld hl, wc2df
ld [hl], a
@@ -3188,7 +3192,7 @@
ld [hl], SPRITEMOVEDATA_FOLLOWING
ld hl, OBJECT_09
add hl, bc
- ld [hl], 0
+ ld [hl], OBJECT_09_VALUE_00
ld a, [hObjectStructIndexBuffer]
ld [wObjectFollow_Follower], a
ret
@@ -3328,7 +3332,7 @@
ld hl, OBJECT_09
add hl, bc
- ld [hl], 0
+ ld [hl], OBJECT_09_VALUE_00
ret
; 5903
@@ -3347,7 +3351,7 @@
ld hl, OBJECT_09
add hl, bc
- ld [hl], 0
+ ld [hl], OBJECT_09_VALUE_00
ret
.standing_movefns
--- a/engine/mart.asm
+++ b/engine/mart.asm
@@ -29,7 +29,7 @@
ld a, 0
ld [EngineBuffer1], a
xor a
- ld [MovementAnimation], a
+ ld [EngineBuffer5], a
call StandardMart
ret
; 15a6e
@@ -129,7 +129,7 @@
ld bc, 16
call ByteFill
xor a
- ld [MovementAnimation], a
+ ld [EngineBuffer5], a
ld [wBargainShopFlags], a
ld [FacingDirection], a
ret
@@ -157,10 +157,10 @@
StandardMart: ; 15b47
.loop
- ld a, [MovementAnimation]
+ ld a, [EngineBuffer5]
ld hl, .MartFunctions
rst JumpTable
- ld [MovementAnimation], a
+ ld [EngineBuffer5], a
cp $ff
jr nz, .loop
ret
--- a/engine/movement.asm
+++ b/engine/movement.asm
@@ -79,7 +79,7 @@
dw Movement_teleport_to ; 4d
dw Movement_skyfall ; 4e
dw Movement_step_wait5 ; 4f
- dw Movement_50 ; 50
+ dw Movement_step_bump ; 50
dw Movement_fish_got_bite ; 51
dw Movement_fish_cast_rod ; 52
dw Movement_hide_emote ; 53
@@ -95,7 +95,7 @@
Movement_teleport_from: ; 5129
ld hl, OBJECT_09
add hl, bc
- ld [hl], $c
+ ld [hl], OBJECT_09_VALUE_0C
ret
; 5130
@@ -102,7 +102,7 @@
Movement_teleport_to: ; 5130
ld hl, OBJECT_09
add hl, bc
- ld [hl], $d
+ ld [hl], OBJECT_09_VALUE_0D
ret
; 5137
@@ -109,7 +109,7 @@
Movement_skyfall: ; 5137
ld hl, OBJECT_09
add hl, bc
- ld [hl], $e
+ ld [hl], OBJECT_09_VALUE_0E
ret
; 513e
@@ -116,7 +116,7 @@
Movement_59: ; 513e
ld hl, OBJECT_09
add hl, bc
- ld [hl], $19
+ ld [hl], OBJECT_09_VALUE_19
ret
; 5145
@@ -136,7 +136,7 @@
ld [hl], a
ld hl, OBJECT_09
add hl, bc
- ld [hl], $3
+ ld [hl], OBJECT_09_VALUE_03
ld hl, OBJECT_DIRECTION_WALKING
add hl, bc
ld [hl], STANDING
@@ -159,7 +159,7 @@
ld [hl], STANDING
ld hl, OBJECT_09
add hl, bc
- ld [hl], $12
+ ld [hl], OBJECT_09_VALUE_12
ret
; 5189
@@ -169,7 +169,7 @@
ld [hl], $6
ld hl, OBJECT_09
add hl, bc
- ld [hl], $10
+ ld [hl], OBJECT_09_VALUE_10
ret
; 5196
@@ -183,7 +183,7 @@
ld [hl], $1
ld hl, OBJECT_09
add hl, bc
- ld [hl], $11
+ ld [hl], OBJECT_09_VALUE_11
ret
; 51ab
@@ -193,7 +193,7 @@
ld [hl], $6
ld hl, OBJECT_09
add hl, bc
- ld [hl], $1
+ ld [hl], OBJECT_09_VALUE_01
ret
; 51b8
@@ -219,7 +219,7 @@
ld hl, OBJECT_09
add hl, bc
- ld [hl], $1
+ ld [hl], OBJECT_09_VALUE_01
ret
; 51db
@@ -240,7 +240,7 @@
ld hl, OBJECT_09
add hl, bc
- ld [hl], $3
+ ld [hl], OBJECT_09_VALUE_03
ld hl, VramState
res 7, [hl]
@@ -268,7 +268,7 @@
ld hl, OBJECT_09
add hl, bc
- ld [hl], $4
+ ld [hl], OBJECT_09_VALUE_04
ld hl, VramState
res 7, [hl]
@@ -276,36 +276,36 @@
; 5222
Movement_step_sleep_1: ; 5222
- ld a, $1
- jr Function5247
+ ld a, 1
+ jr Movement_step_sleep_common
Movement_step_sleep_2: ; 5226
- ld a, $2
- jr Function5247
+ ld a, 2
+ jr Movement_step_sleep_common
Movement_step_sleep_3: ; 522a
- ld a, $3
- jr Function5247
+ ld a, 3
+ jr Movement_step_sleep_common
Movement_step_sleep_4: ; 522e
- ld a, $4
- jr Function5247
+ ld a, 4
+ jr Movement_step_sleep_common
Movement_step_sleep_5: ; 5232
- ld a, $5
- jr Function5247
+ ld a, 5
+ jr Movement_step_sleep_common
Movement_step_sleep_6: ; 5236
- ld a, $6
- jr Function5247
+ ld a, 6
+ jr Movement_step_sleep_common
Movement_step_sleep_7: ; 523a
- ld a, $7
- jr Function5247
+ ld a, 7
+ jr Movement_step_sleep_common
Movement_step_sleep_8: ; 523e
- ld a, $8
- jr Function5247
+ ld a, 8
+ jr Movement_step_sleep_common
Movement_step_sleep: ; 5242
; parameters:
@@ -312,9 +312,9 @@
; duration (DecimalParam)
call GetMovementByte
- jr Function5247
+ jr Movement_step_sleep_common
-Function5247: ; 5247
+Movement_step_sleep_common: ; 5247
ld hl, OBJECT_STEP_DURATION
add hl, bc
ld [hl], a
@@ -321,7 +321,7 @@
ld hl, OBJECT_09
add hl, bc
- ld [hl], $3
+ ld [hl], OBJECT_09_VALUE_03
ld hl, OBJECT_11
add hl, bc
@@ -333,7 +333,7 @@
ret
; 525f
-Movement_50: ; 525f
+Movement_step_bump: ; 525f
ld a, $1
ld hl, OBJECT_STEP_DURATION
add hl, bc
@@ -340,7 +340,7 @@
ld [hl], a
ld hl, OBJECT_09
add hl, bc
- ld [hl], $b
+ ld [hl], OBJECT_09_VALUE_0B
ld hl, OBJECT_11
add hl, bc
ld [hl], $3
@@ -357,7 +357,7 @@
ld [hl], a
ld hl, OBJECT_09
add hl, bc
- ld [hl], $3
+ ld [hl], OBJECT_09_VALUE_03
ld hl, OBJECT_11
add hl, bc
ld [hl], $b
@@ -726,7 +726,7 @@
ld [hl], $2
ld hl, OBJECT_09
add hl, bc
- ld [hl], $a
+ ld [hl], OBJECT_09_VALUE_0A
ret
; 5412
@@ -756,13 +756,13 @@
ld hl, OBJECT_09
add hl, bc
- ld [hl], $2
+ ld [hl], OBJECT_09_VALUE_02
ret
.asm_543f
ld hl, OBJECT_09
add hl, bc
- ld [hl], $6
+ ld [hl], OBJECT_09_VALUE_06
ret
; 5446
@@ -778,13 +778,13 @@
jr z, .asm_5461
ld hl, OBJECT_09
add hl, bc
- ld [hl], $2
+ ld [hl], OBJECT_09_VALUE_02
ret
.asm_5461
ld hl, OBJECT_09
add hl, bc
- ld [hl], $6
+ ld [hl], OBJECT_09_VALUE_06
ret
; 5468
@@ -801,13 +801,13 @@
jr z, .asm_5483
ld hl, OBJECT_09
add hl, bc
- ld [hl], $2
+ ld [hl], OBJECT_09_VALUE_02
ret
.asm_5483
ld hl, OBJECT_09
add hl, bc
- ld [hl], $6
+ ld [hl], OBJECT_09_VALUE_06
ret
; 548a
@@ -830,12 +830,12 @@
jr z, .asm_54b1
ld hl, OBJECT_09
add hl, bc
- ld [hl], $8
+ ld [hl], OBJECT_09_VALUE_08
ret
.asm_54b1
ld hl, OBJECT_09
add hl, bc
- ld [hl], $9
+ ld [hl], OBJECT_09_VALUE_09
ret
; 54b8
--- a/engine/scripting.asm
+++ b/engine/scripting.asm
@@ -2987,12 +2987,12 @@
call WarpCheck
ret nc
- callba SetAll_ScriptFlags3
+ callba EnableEvents
ret
; 0x97b01
-Function97b01: ; 0x97b01
- callba SetAll_ScriptFlags3
+Script_enableevents: ; unreferenced
+ callba EnableEvents
ret
; 0x97b08
--- a/engine/sprites.asm
+++ b/engine/sprites.asm
@@ -75,7 +75,7 @@
; 8cfa8
Function8cfa8: ; 8cfa8 (23:4fa8)
- ld hl, wc314
+ ld hl, wSpriteAnimationStructs
ld e, 10
.loop
--- a/home/map_objects.asm
+++ b/home/map_objects.asm
@@ -508,7 +508,7 @@
ret
; 1a47
-Function1a47:: ; 1a47
+GetInitialFacing:: ; 1a47
push bc
push de
ld e, a
--- a/macros/movement.asm
+++ b/macros/movement.asm
@@ -388,7 +388,10 @@
db movement_step_wait5 ; $4f
endm
-__enum__ = $51
+ enum movement_step_bump
+step_bump: macro
+ db movement_step_bump ; $50
+ endm
enum movement_fish_got_bite
fish_got_bite: macro
--- a/main.asm
+++ b/main.asm
@@ -2369,7 +2369,7 @@
ld bc, ObjectStructs ; redundant
ld a, 0
ld [hMapObjectIndexBuffer], a
- call Function7041
+ call IsNPCAtCoord
ret nc
ld hl, OBJECT_DIRECTION_WALKING
add hl, bc
@@ -2392,7 +2392,7 @@
ld hl, OBJECT_MAP_Y
add hl, bc
ld e, [hl]
- jr Function7041
+ jr IsNPCAtCoord
; 7015
Function7015: ; unreferenced
@@ -2399,7 +2399,7 @@
ld a, [hMapObjectIndexBuffer]
call GetObjectStruct
call Function7021
- call Function7041
+ call IsNPCAtCoord
ret
Function7021: ; 7021
@@ -2432,7 +2432,7 @@
ret
; 7041
-Function7041: ; 7041
+IsNPCAtCoord: ; 7041
ld bc, ObjectStructs
xor a
.loop
@@ -2439,14 +2439,17 @@
ld [hObjectStructIndexBuffer], a
call GetObjectSprite
jr z, .next
+
ld hl, OBJECT_FLAGS1
add hl, bc
bit 7, [hl]
jr nz, .next
+
ld hl, OBJECT_PALETTE
add hl, bc
bit 7, [hl]
jr z, .got
+
call Function7171
jr nc, .ok
jr .ok2
@@ -3631,7 +3634,7 @@
ld hl, OBJECT_09
add hl, de
- ld [hl], $0
+ ld [hl], OBJECT_09_VALUE_00
ld hl, OBJECT_FACING_STEP
add hl, de
@@ -3882,7 +3885,7 @@
ld [hl], SPRITEMOVEDATA_FOLLOWNOTEXACT
ld hl, OBJECT_09
add hl, de
- ld [hl], $0
+ ld [hl], OBJECT_09_VALUE_00
ret
; 8417
@@ -33993,7 +33996,7 @@
DoPlayerMovement:: ; 80000
call GetMovementInput
- ld a, $3e ; standing
+ ld a, movement_step_sleep_1
ld [MovementAnimation], a
xor a
ld [wd041], a
@@ -34039,7 +34042,7 @@
cp PLAYER_BIKE
jr z, .Normal
cp PLAYER_SLIP
- jr z, .Board
+ jr z, .Ice
.Normal
call CheckForcedMovementInput
@@ -34067,7 +34070,7 @@
ret c
jr .NotMoving
-.Board
+.Ice
call CheckForcedMovementInput
call GetMovementAction
call CheckTileMovement
@@ -34095,7 +34098,7 @@
jr z, .Standing
; Walking into an edge warp won't bump.
- ld a, [wd041]
+ ld a, [EngineBuffer4]
and a
jr nz, .CantMove
call PlayBump
@@ -34268,13 +34271,13 @@
jr z, TrySurfStep
call CheckLandPermissions
- jr c, .asm_801be
+ jr c, .bump
call IsNPCInFront
and a
- jr z, .asm_801be
+ jr z, .bump
cp 2
- jr z, .asm_801be
+ jr z, .bump
ld a, [PlayerStandingTile]
call CheckIceTile
@@ -34282,7 +34285,7 @@
; Downhill riding is slower when not moving down.
call CheckRiding
- jr nz, .asm_801ae
+ jr nz, .walk
ld hl, BikeFlags
bit 2, [hl] ; downhill
@@ -34303,7 +34306,7 @@
scf
ret
-.asm_801ae
+.walk
ld a, STEP_WALK
call DoStep
scf
@@ -34319,7 +34322,7 @@
xor a
ret
-.asm_801be
+.bump
xor a
ret
; 801c0
@@ -34417,13 +34420,13 @@
add hl, de
ld a, [PlayerStandingTile]
cp [hl]
- jr nz, .asm_80259
+ jr nz, .nope
ld a, 1
ld [wd041], a
ld a, [WalkingDirection]
cp STANDING
- jr z, .asm_80259
+ jr z, .nope
ld e, a
ld a, [PlayerDirection]
@@ -34431,9 +34434,9 @@
rrca
and 3
cp e
- jr nz, .asm_80259
- call WarpCheck ; CheckFallPit?
- jr nc, .asm_80259
+ jr nz, .nope
+ call WarpCheck
+ jr nc, .nope
call StandInPlace
scf
@@ -34440,7 +34443,7 @@
ld a, 1
ret
-.asm_80259
+.nope
xor a
ret
@@ -34488,21 +34491,45 @@
dw .WalkInPlace
.Slow
- db $08, $09, $0a, $0b
+ slow_step_down
+ slow_step_up
+ slow_step_left
+ slow_step_right
.Walk
- db $0c, $0d, $0e, $0f
+ step_down
+ step_up
+ step_left
+ step_right
.Bike
- db $10, $11, $12, $13
+ big_step_down
+ big_step_up
+ big_step_left
+ big_step_right
.Ledge
- db $30, $31, $32, $33
+ jump_step_down
+ jump_step_up
+ jump_step_left
+ jump_step_right
.Ice
- db $1c, $1d, $1e, $1f
+ fast_slide_step_down
+ fast_slide_step_up
+ fast_slide_step_left
+ fast_slide_step_right
.BackwardsLedge
- db $31, $30, $33, $32
+ jump_step_up
+ jump_step_down
+ jump_step_right
+ jump_step_left
.Turn
- db $04, $05, $06, $07
+ half_step_down
+ half_step_up
+ half_step_left
+ half_step_right
.WalkInPlace
- db $80, $81, $82, $83
+ db $80 + movement_turn_head_down
+ db $80 + movement_turn_head_up
+ db $80 + movement_turn_head_left
+ db $80 + movement_turn_head_right
; 802b3
@@ -34509,7 +34536,7 @@
StandInPlace: ; 802b3
ld a, 0
ld [wd04e], a
- ld a, $3e ; standing
+ ld a, movement_step_sleep_1
ld [MovementAnimation], a
xor a
ret
@@ -34519,7 +34546,7 @@
WalkInPlace: ; 802bf
ld a, 0
ld [wd04e], a
- ld a, $50 ; walking
+ ld a, movement_step_bump
ld [MovementAnimation], a
xor a
ret
@@ -34529,7 +34556,7 @@
CheckForcedMovementInput: ; 802cb
; When sliding on ice, input is forced to remain in the same direction.
- call Function80404
+ call CheckStandingOnIce
ret nc
ld a, [wd04e]
@@ -34542,7 +34569,7 @@
ld hl, .data_802e8
add hl, de
ld a, [CurInput]
- and A_BUTTON | B_BUTTON | SELECT | START
+ and BUTTONS
or [hl]
ld [CurInput], a
ret
@@ -34613,33 +34640,39 @@
IsNPCInFront: ; 80341
-
+; 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
ld a, 0
ld [hMapObjectIndexBuffer], a
+; Load the next X coordinate into d
ld a, [PlayerMapX]
ld d, a
ld a, [WalkingX]
add d
ld d, a
+; Load the next Y coordinate into e
ld a, [PlayerMapY]
ld e, a
ld a, [WalkingY]
add e
ld e, a
+; Find an object struct with coordinates equal to d,e
ld bc, ObjectStructs ; redundant
- callba Function7041
- jr nc, .asm_80369
+ callba IsNPCAtCoord
+ jr nc, .nope
call Function8036f
- jr c, .asm_8036c
+ jr c, .no_bump
+; .bump
xor a
ret
-.asm_80369
+.nope
ld a, 1
ret
-.asm_8036c
+.no_bump
ld a, 2
ret
; 8036f
@@ -34648,27 +34681,27 @@
Function8036f: ; 8036f
ld hl, BikeFlags
- bit 0, [hl]
- jr z, .asm_8039c
+ bit 0, [hl] ; using strength
+ jr z, .nope
- ld hl, $7
+ ld hl, OBJECT_DIRECTION_WALKING
add hl, bc
ld a, [hl]
- cp $ff
- jr nz, .asm_8039c
+ cp STANDING
+ jr nz, .nope
- ld hl, $6
+ ld hl, OBJECT_PALETTE
add hl, bc
bit 6, [hl]
- jr z, .asm_8039c
+ jr z, .nope
- ld hl, $5
+ ld hl, OBJECT_FLAGS2
add hl, bc
set 2, [hl]
ld a, [WalkingDirection]
ld d, a
- ld hl, $20
+ ld hl, OBJECT_32
add hl, bc
ld a, [hl]
and $fc
@@ -34678,7 +34711,7 @@
scf
ret
-.asm_8039c
+.nope
xor a
ret
; 8039e
@@ -34799,24 +34832,24 @@
; 80404
-Function80404:: ; 80404
+CheckStandingOnIce:: ; 80404
ld a, [wd04e]
cp 0
- jr z, .asm_80420
+ jr z, .nope
cp $f0
- jr z, .asm_80420
+ jr z, .nope
ld a, [PlayerStandingTile]
call CheckIceTile
- jr nc, .asm_8041e
+ jr nc, .yep
ld a, [PlayerState]
cp PLAYER_SLIP
- jr nz, .asm_80420
+ jr nz, .nope
-.asm_8041e
+.yep
scf
ret
-.asm_80420
+.nope
and a
ret
; 80422
@@ -34824,7 +34857,7 @@
Function80422:: ; 80422
ld hl, wc2de
- ld a, $3e ; standing
+ ld a, movement_step_sleep_1
cp [hl]
ret z
ld [hl], a
--- a/misc/mobile_5c.asm
+++ b/misc/mobile_5c.asm
@@ -1960,7 +1960,7 @@
ld de, wMapPals
ld bc, $40
call CopyBytes
- ld hl, MovementAnimation
+ ld hl, EngineBuffer5
ld a, $ff
ld [hli], a
ld a, $7f
--- a/wram.asm
+++ b/wram.asm
@@ -319,7 +319,8 @@
ds 1
wc2de:: ds 1
-wc2df:: ds 3
+wc2df:: ds 1
+ ds 2
wMovementPerson:: ds 1
wMovementDataPointer:: ds 3 ; dba
wc2e6:: ds 4
@@ -1568,6 +1569,7 @@
wTempTrainerEventFlagHi::
MovementAnimation:: ; d042
+EngineBuffer5::
ds 1
wTempTrainerClass::
@@ -2089,6 +2091,11 @@
ScriptFlags2:: ; d435
ds 1
ScriptFlags3:: ; d436
+; bit 0: count steps
+; bit 1: xy triggers
+; bit 2: warps and connections
+; bit 4: wild encounters
+; bit 5: unknown
ds 1
ScriptMode:: ; d437
@@ -2198,7 +2205,7 @@
wd4d1:: ds 1
ds 4
-ObjectStructs::
+ObjectStructs:: ; d4d6
object_struct: MACRO
\1Struct::
\1Sprite:: ds 1