summaryrefslogtreecommitdiff
path: root/engine/map_objects.asm
diff options
context:
space:
mode:
Diffstat (limited to 'engine/map_objects.asm')
-rw-r--r--engine/map_objects.asm117
1 files changed, 66 insertions, 51 deletions
diff --git a/engine/map_objects.asm b/engine/map_objects.asm
index d5fa84642..c37e6d2cf 100644
--- a/engine/map_objects.asm
+++ b/engine/map_objects.asm
@@ -1,9 +1,8 @@
+INCLUDE "data/facings.asm"
-INCLUDE "engine/facings.asm"
-
-SpriteMovementData:: ; 4273
INCLUDE "data/map_objects.asm"
+
; 4357
DeleteMapObject:: ; 4357
push bc
@@ -155,8 +154,8 @@ Function437b: ; 437b
jr nz, SetFacingStanding
bit 5, [hl]
jr nz, asm_4448
- ld de, Pointers445f ; use first column
- jr asm_444d
+ ld de, ObjectActionPairPointers ; use first column
+ jr _HandleObjectAction
; 4440
Function4440: ; 4440
@@ -164,13 +163,28 @@ Function4440: ; 4440
add hl, bc
bit INVISIBLE, [hl]
jr nz, SetFacingStanding
-asm_4448 ; use second column
- ld de, Pointers445f + 2
- jr asm_444d
+asm_4448
+ ld de, ObjectActionPairPointers + 2 ; use second column
+ jr _HandleObjectAction
; 444d
-asm_444d
+_HandleObjectAction
; call [4 * ObjectStructs[ObjInd, OBJECT_ACTION] + de]
+ ld hl, OBJECT_ACTION
+ add hl, bc
+ ld a, [hl]
+ ld l, a
+ ld h, 0
+ add hl, hl
+ add hl, hl
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ call _hl_
+ ret
+; 445f
+
INCLUDE "engine/map_object_action.asm"
CopyNextCoordsTileToStandingCoordsTile: ; 4600
@@ -535,6 +549,7 @@ MapObjectMovementPattern: ; 47dd
ret
.Pointers: ; 47e9
+; entries correspond to SPRITEMOVEFN_* constants
dw .Null_00 ; 00
dw .RandomWalkY ; 01
dw .RandomWalkX ; 02
@@ -616,7 +631,7 @@ MapObjectMovementPattern: ; 47dd
call EndSpriteMovement
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_STAND
+ ld [hl], OBJECT_ACTION_STAND
ld hl, OBJECT_STEP_TYPE
add hl, bc
ld [hl], STEP_TYPE_05
@@ -635,20 +650,20 @@ MapObjectMovementPattern: ; 47dd
jp HandleMovementData
.Movement0a:
- jp _GetMovementPerson
+ jp _GetMovementObject
.Movement0b:
- jp _GetMovementPerson
+ jp _GetMovementObject
.Movement0c:
- jp _GetMovementPerson
+ jp _GetMovementObject
.Movement0d:
ld hl, Function5000
jp HandleMovementData
.Movement0e:
- jp _GetMovementPerson
+ jp _GetMovementObject
.Follow:
ld hl, GetFollowerNextMovementByte
@@ -766,7 +781,7 @@ MapObjectMovementPattern: ; 47dd
ld [hl], STANDING
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_STAND
+ ld [hl], OBJECT_ACTION_STAND
ret
.MovementBigStanding:
@@ -776,7 +791,7 @@ MapObjectMovementPattern: ; 47dd
ld [hl], STANDING
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_BIG_SNORLAX
+ ld [hl], OBJECT_ACTION_BIG_SNORLAX
ld hl, OBJECT_STEP_TYPE
add hl, bc
ld [hl], STEP_TYPE_04
@@ -789,7 +804,7 @@ MapObjectMovementPattern: ; 47dd
ld [hl], STANDING
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_BOUNCE
+ ld [hl], OBJECT_ACTION_BOUNCE
ld hl, OBJECT_STEP_TYPE
add hl, bc
ld [hl], STEP_TYPE_04
@@ -813,7 +828,7 @@ MapObjectMovementPattern: ; 47dd
.MovementSpinRepeat:
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_STAND
+ ld [hl], OBJECT_ACTION_STAND
ld hl, OBJECT_RANGE
add hl, bc
ld a, [hl]
@@ -864,7 +879,7 @@ MapObjectMovementPattern: ; 47dd
call ._MovementShadow_Grass_Emote_BoulderDust
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_SHADOW
+ ld [hl], OBJECT_ACTION_SHADOW
ld hl, OBJECT_STEP_DURATION
add hl, de
ld a, [hl]
@@ -901,7 +916,7 @@ MapObjectMovementPattern: ; 47dd
call ._MovementShadow_Grass_Emote_BoulderDust
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_EMOTE
+ ld [hl], OBJECT_ACTION_EMOTE
ld hl, OBJECT_STEP_DURATION
add hl, bc
ld [hl], 0
@@ -921,7 +936,7 @@ MapObjectMovementPattern: ; 47dd
call ._MovementShadow_Grass_Emote_BoulderDust
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_BOULDER_DUST
+ ld [hl], OBJECT_ACTION_BOULDER_DUST
ld hl, OBJECT_STEP_DURATION
add hl, de
ld a, [hl]
@@ -965,7 +980,7 @@ MapObjectMovementPattern: ; 47dd
call ._MovementShadow_Grass_Emote_BoulderDust
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_GRASS_SHAKE
+ ld [hl], OBJECT_ACTION_GRASS_SHAKE
ld hl, OBJECT_STEP_DURATION
add hl, de
ld a, [hl]
@@ -998,7 +1013,7 @@ MapObjectMovementPattern: ; 47dd
call EndSpriteMovement
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_00
+ ld [hl], OBJECT_ACTION_00
ld hl, OBJECT_RANGE
add hl, bc
ld a, [hl]
@@ -1038,7 +1053,7 @@ MapObjectMovementPattern: ; 47dd
call UpdateTallGrassFlags
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_STEP
+ ld [hl], OBJECT_ACTION_STEP
ld hl, wCenteredObject
ld a, [hMapObjectIndexBuffer]
cp [hl]
@@ -1077,7 +1092,7 @@ SetRandomStepDuration: ; 4b2d
ld [hl], STANDING
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_STAND
+ ld [hl], OBJECT_ACTION_STAND
ld hl, OBJECT_STEP_TYPE
add hl, bc
ld [hl], STEP_TYPE_03
@@ -1085,7 +1100,7 @@ SetRandomStepDuration: ; 4b2d
; 4b45
StepTypesJumptable: ; 4b45
-; These pointers use OBJECT_STEP_TYPE. See constants/sprite_constants.asm
+; entries correspond to STEP_TYPE_* constants
dw ObjectMovementReset ; 00
dw MapObjectMovementPattern ; unused
dw NPCStep ; 02 npc walk
@@ -1230,7 +1245,7 @@ TeleportFrom: ; 4c18
.DoSpin:
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_SPIN
+ ld [hl], OBJECT_ACTION_SPIN
ld hl, OBJECT_STEP_DURATION
add hl, bc
dec [hl]
@@ -1255,7 +1270,7 @@ TeleportFrom: ; 4c18
.DoSpinRise:
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_SPIN
+ ld [hl], OBJECT_ACTION_SPIN
ld hl, OBJECT_31
add hl, bc
inc [hl]
@@ -1295,7 +1310,7 @@ TeleportTo: ; 4c89
.InitWait:
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_00
+ ld [hl], OBJECT_ACTION_00
ld hl, OBJECT_STEP_DURATION
add hl, bc
ld [hl], 16
@@ -1326,7 +1341,7 @@ TeleportTo: ; 4c89
.DoDescent:
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_SPIN
+ ld [hl], OBJECT_ACTION_SPIN
ld hl, OBJECT_31
add hl, bc
inc [hl]
@@ -1354,7 +1369,7 @@ TeleportTo: ; 4c89
.DoFinalSpin:
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_SPIN
+ ld [hl], OBJECT_ACTION_SPIN
ld hl, OBJECT_STEP_DURATION
add hl, bc
dec [hl]
@@ -1384,7 +1399,7 @@ Skyfall: ; 4d14
.Init:
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_00
+ ld [hl], OBJECT_ACTION_00
ld hl, OBJECT_STEP_DURATION
add hl, bc
ld [hl], 16
@@ -1396,7 +1411,7 @@ Skyfall: ; 4d14
ret nz
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_STEP
+ ld [hl], OBJECT_ACTION_STEP
ld hl, OBJECT_STEP_FRAME
add hl, bc
ld [hl], 0
@@ -1481,9 +1496,9 @@ RockSmashStep: ; 4daf
add hl, bc
ld a, [hl]
and %00000001
- ld a, PERSON_ACTION_STAND
+ ld a, OBJECT_ACTION_STAND
jr z, .yes
- ld a, PERSON_ACTION_00
+ ld a, OBJECT_ACTION_00
.yes
ld hl, OBJECT_ACTION
add hl, bc
@@ -1496,9 +1511,9 @@ ReturnDigStep: ; 4dc8
add hl, bc
ld a, [hl]
and %00000001
- ld a, PERSON_ACTION_SPIN
+ ld a, OBJECT_ACTION_SPIN
jr z, .yes
- ld a, PERSON_ACTION_SPIN_FLICKER
+ ld a, OBJECT_ACTION_SPIN_FLICKER
.yes
ld hl, OBJECT_ACTION
add hl, bc
@@ -1684,7 +1699,7 @@ StepType0f: ; 4ecd
add hl, bc
ld a, [hl]
ld b, a
- callba CopyDECoordsToMapObject
+ farcall CopyDECoordsToMapObject
pop bc
ld hl, OBJECT_FLAGS2
add hl, bc
@@ -1804,7 +1819,7 @@ SkyfallTop: ; 4f83
.Init:
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_SKYFALL
+ ld [hl], OBJECT_ACTION_SKYFALL
ld hl, OBJECT_STEP_DURATION
add hl, bc
ld [hl], 16
@@ -1920,13 +1935,13 @@ Function5026: ; 5026
ret
; 5037
-_GetMovementPerson: ; 5037
- ld hl, GetMovementPerson
+_GetMovementObject: ; 5037
+ ld hl, GetMovementObject
jp HandleMovementData
; 503d
-GetMovementPerson: ; 503d
- ld a, [wMovementPerson]
+GetMovementObject: ; 503d
+ ld a, [wMovementObject]
ret
; 5041
@@ -2162,7 +2177,7 @@ InitTempObject: ; 55ac
ret nc
ld d, h
ld e, l
- callba CopyTempObjectToObjectStruct
+ farcall CopyTempObjectToObjectStruct
ret
; 55b9
@@ -2291,7 +2306,7 @@ Function565c: ; 565c
call Function56a3
jr c, SetFacing_Standing
call Function5688
- callba Function4440
+ farcall Function4440
xor a
ret
; 5673
@@ -2299,7 +2314,7 @@ Function565c: ; 565c
Function5673: ; 5673
call Function56a3
jr c, SetFacing_Standing
- callba Function4440 ; no need to farcall
+ farcall Function4440 ; no need to farcall
xor a
ret
; 5680
@@ -2325,7 +2340,7 @@ Function5688: ; 5688
ld hl, OBJECT_NEXT_TILE
add hl, bc
ld [hl], a
- callba UpdateTallGrassFlags ; no need to farcall
+ farcall UpdateTallGrassFlags ; no need to farcall
ret
; 56a3
@@ -2512,7 +2527,7 @@ RefreshPlayerSprite: ; 579d
ld [wPlayerTurningDirection], a
ld [PlayerObjectStepFrame], a
call .TryResetPlayerAction
- callba CheckWarpFacingDown
+ farcall CheckWarpFacingDown
call c, SpawnInFacingDown
call .SpawnInCustomFacing
ret
@@ -2525,7 +2540,7 @@ RefreshPlayerSprite: ; 579d
ret
.ok
- ld a, PERSON_ACTION_00
+ ld a, OBJECT_ACTION_00
ld [PlayerAction], a
ret
; 57ca
@@ -2581,7 +2596,7 @@ StartFollow:: ; 5803
ret c
ld a, c
call SetFollowerIfVisible
- callba QueueFollowerFirstStep
+ farcall QueueFollowerFirstStep
ret
; 5815
@@ -2627,7 +2642,7 @@ ResetFollower: ; 5847
cp -1
ret z
call GetObjectStruct
- callba Function58e3 ; no need to bankswitch
+ farcall Function58e3 ; no need to bankswitch
ld a, -1
ld [wObjectFollow_Follower], a
ret