2018-01-10 15:10:01 -08:00
|
|
|
INCLUDE "data/sprites/facings.asm"
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2018-01-10 15:10:01 -08:00
|
|
|
INCLUDE "data/sprites/map_objects.asm"
|
2015-11-15 21:52:53 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
DeleteMapObject::
|
2015-02-11 14:13:22 -08:00
|
|
|
push bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_MAP_OBJECT_INDEX
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
push af
|
|
|
|
ld h, b
|
|
|
|
ld l, c
|
2019-11-03 09:25:59 -08:00
|
|
|
ld bc, OBJECT_LENGTH
|
2015-02-11 14:13:22 -08:00
|
|
|
xor a
|
|
|
|
call ByteFill
|
|
|
|
pop af
|
2015-07-15 12:48:44 -07:00
|
|
|
cp -1
|
|
|
|
jr z, .ok
|
2015-02-11 14:13:22 -08:00
|
|
|
bit 7, a
|
2015-07-15 12:48:44 -07:00
|
|
|
jr nz, .ok
|
2015-02-11 14:13:22 -08:00
|
|
|
call GetMapObject
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_SPRITE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], -1
|
|
|
|
.ok
|
2015-02-11 14:13:22 -08:00
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
|
2020-10-05 13:15:57 -07:00
|
|
|
HandleObjectStep:
|
2020-10-22 14:41:48 -07:00
|
|
|
call CheckObjectStillVisible
|
2015-02-11 14:13:22 -08:00
|
|
|
ret c
|
2020-10-22 14:41:48 -07:00
|
|
|
call HandleStepType
|
|
|
|
call HandleObjectAction
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
CheckObjectStillVisible:
|
2015-10-29 20:32:11 -07:00
|
|
|
ld hl, OBJECT_FLAGS2
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2019-01-24 18:41:14 -08:00
|
|
|
res OBJ_FLAGS2_6, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wXCoord]
|
2015-02-11 14:13:22 -08:00
|
|
|
ld e, a
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MAP_X
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-07-15 12:48:44 -07:00
|
|
|
add 1
|
2015-02-11 14:13:22 -08:00
|
|
|
sub e
|
2015-07-15 12:48:44 -07:00
|
|
|
jr c, .ok
|
|
|
|
cp MAPOBJECT_SCREEN_WIDTH
|
|
|
|
jr nc, .ok
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wYCoord]
|
2015-02-11 14:13:22 -08:00
|
|
|
ld e, a
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MAP_Y
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-07-15 12:48:44 -07:00
|
|
|
add 1
|
2015-02-11 14:13:22 -08:00
|
|
|
sub e
|
2015-07-15 12:48:44 -07:00
|
|
|
jr c, .ok
|
|
|
|
cp MAPOBJECT_SCREEN_HEIGHT
|
|
|
|
jr nc, .ok
|
|
|
|
jr .yes
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
.ok
|
2015-10-29 20:32:11 -07:00
|
|
|
ld hl, OBJECT_FLAGS2
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2019-01-24 18:41:14 -08:00
|
|
|
set OBJ_FLAGS2_6, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wXCoord]
|
2015-02-11 14:13:22 -08:00
|
|
|
ld e, a
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_INIT_X
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-07-15 12:48:44 -07:00
|
|
|
add 1
|
2015-02-11 14:13:22 -08:00
|
|
|
sub e
|
2015-07-15 12:48:44 -07:00
|
|
|
jr c, .ok2
|
|
|
|
cp MAPOBJECT_SCREEN_WIDTH
|
|
|
|
jr nc, .ok2
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wYCoord]
|
2015-02-11 14:13:22 -08:00
|
|
|
ld e, a
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_INIT_Y
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-07-15 12:48:44 -07:00
|
|
|
add 1
|
2015-02-11 14:13:22 -08:00
|
|
|
sub e
|
2015-07-15 12:48:44 -07:00
|
|
|
jr c, .ok2
|
|
|
|
cp MAPOBJECT_SCREEN_HEIGHT
|
|
|
|
jr nc, .ok2
|
|
|
|
.yes
|
2015-02-11 14:13:22 -08:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
.ok2
|
2015-10-29 20:32:11 -07:00
|
|
|
ld hl, OBJECT_FLAGS1
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2018-05-23 19:01:21 -07:00
|
|
|
bit WONT_DELETE_F, [hl]
|
2015-07-15 12:48:44 -07:00
|
|
|
jr nz, .yes2
|
2015-12-17 12:14:51 -08:00
|
|
|
call DeleteMapObject
|
2015-02-11 14:13:22 -08:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
.yes2
|
2015-10-29 20:32:11 -07:00
|
|
|
ld hl, OBJECT_FLAGS2
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2019-01-24 18:41:14 -08:00
|
|
|
set OBJ_FLAGS2_6, [hl]
|
2015-02-11 14:13:22 -08:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
HandleStepType:
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_STEP_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
and a
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .zero
|
2015-10-29 20:32:11 -07:00
|
|
|
ld hl, OBJECT_FLAGS2
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2020-10-22 18:25:40 -07:00
|
|
|
bit FROZEN_F, [hl]
|
|
|
|
jr nz, .frozen
|
2020-10-22 14:41:48 -07:00
|
|
|
cp STEP_TYPE_FROM_MOVEMENT
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .one
|
2015-12-29 10:15:58 -08:00
|
|
|
jr .ok3
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
.zero
|
2020-10-22 14:41:48 -07:00
|
|
|
call StepFunction_Reset
|
2015-10-29 20:32:11 -07:00
|
|
|
ld hl, OBJECT_FLAGS2
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2020-10-22 18:25:40 -07:00
|
|
|
bit FROZEN_F, [hl]
|
|
|
|
jr nz, .frozen
|
2015-07-15 12:48:44 -07:00
|
|
|
.one
|
2020-10-22 14:41:48 -07:00
|
|
|
call StepFunction_FromMovement
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_STEP_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
and a
|
|
|
|
ret z
|
2020-10-22 14:41:48 -07:00
|
|
|
cp STEP_TYPE_FROM_MOVEMENT
|
2015-02-11 14:13:22 -08:00
|
|
|
ret z
|
2015-12-29 10:15:58 -08:00
|
|
|
.ok3
|
2016-05-08 11:11:24 -07:00
|
|
|
ld hl, StepTypesJumptable
|
2015-02-11 14:13:22 -08:00
|
|
|
rst JumpTable
|
|
|
|
ret
|
|
|
|
|
2020-10-22 18:25:40 -07:00
|
|
|
.frozen
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
HandleObjectAction:
|
2015-10-29 20:32:11 -07:00
|
|
|
ld hl, OBJECT_FLAGS1
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2018-05-23 10:15:07 -07:00
|
|
|
bit INVISIBLE_F, [hl]
|
2015-11-15 11:59:38 -08:00
|
|
|
jr nz, SetFacingStanding
|
2015-10-29 20:32:11 -07:00
|
|
|
ld hl, OBJECT_FLAGS2
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2019-01-24 18:41:14 -08:00
|
|
|
bit OBJ_FLAGS2_6, [hl]
|
2015-11-15 11:59:38 -08:00
|
|
|
jr nz, SetFacingStanding
|
2020-10-22 18:25:40 -07:00
|
|
|
bit FROZEN_F, [hl]
|
2020-10-22 14:41:48 -07:00
|
|
|
jr nz, _CallFrozenObjectAction
|
|
|
|
; use first column (normal)
|
|
|
|
ld de, ObjectActionPairPointers
|
|
|
|
jr CallObjectAction
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
HandleFrozenObjectAction:
|
2015-10-29 20:32:11 -07:00
|
|
|
ld hl, OBJECT_FLAGS1
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2018-05-23 10:15:07 -07:00
|
|
|
bit INVISIBLE_F, [hl]
|
2015-11-15 11:59:38 -08:00
|
|
|
jr nz, SetFacingStanding
|
2020-10-22 14:41:48 -07:00
|
|
|
_CallFrozenObjectAction:
|
2020-10-22 18:25:40 -07:00
|
|
|
; use second column (frozen)
|
2020-10-22 14:41:48 -07:00
|
|
|
ld de, ObjectActionPairPointers + 2
|
|
|
|
jr CallObjectAction ; pointless
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
CallObjectAction:
|
2017-12-08 21:50:59 -08:00
|
|
|
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
|
|
|
|
|
2018-03-13 05:07:16 -07:00
|
|
|
INCLUDE "engine/overworld/map_object_action.asm"
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2022-09-12 06:15:44 -07:00
|
|
|
CopyCoordsTileToLastCoordsTile:
|
|
|
|
ld hl, OBJECT_MAP_X
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_LAST_MAP_X
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MAP_Y
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_LAST_MAP_Y
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
2024-02-10 15:25:25 -08:00
|
|
|
ld hl, OBJECT_TILE_COLLISION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_LAST_TILE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
2015-11-15 11:59:38 -08:00
|
|
|
call SetTallGrassFlags
|
2024-02-10 15:25:25 -08:00
|
|
|
ld hl, OBJECT_TILE_COLLISION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-11-15 11:59:38 -08:00
|
|
|
call UselessAndA
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2022-09-12 06:15:44 -07:00
|
|
|
CopyLastCoordsToCoords:
|
|
|
|
ld hl, OBJECT_LAST_MAP_X
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MAP_X
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_LAST_MAP_Y
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MAP_Y
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
UpdateTallGrassFlags:
|
2015-10-29 20:32:11 -07:00
|
|
|
ld hl, OBJECT_FLAGS2
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2018-05-23 10:15:07 -07:00
|
|
|
bit OVERHEAD_F, [hl]
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .ok
|
2024-02-10 15:25:25 -08:00
|
|
|
ld hl, OBJECT_TILE_COLLISION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-11-15 11:59:38 -08:00
|
|
|
call SetTallGrassFlags
|
2015-07-15 12:48:44 -07:00
|
|
|
.ok
|
2024-02-10 15:25:25 -08:00
|
|
|
ld hl, OBJECT_TILE_COLLISION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-11-15 11:59:38 -08:00
|
|
|
call UselessAndA
|
|
|
|
ret c ; never happens
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_LAST_TILE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-11-15 11:59:38 -08:00
|
|
|
call UselessAndA
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SetTallGrassFlags:
|
2015-07-23 00:41:52 -07:00
|
|
|
call CheckSuperTallGrassTile
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .set
|
2015-11-15 11:59:38 -08:00
|
|
|
call CheckGrassTile
|
2015-07-15 12:48:44 -07:00
|
|
|
jr c, .reset
|
|
|
|
.set
|
2015-10-29 20:32:11 -07:00
|
|
|
ld hl, OBJECT_FLAGS2
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2018-05-23 10:15:07 -07:00
|
|
|
set OVERHEAD_F, [hl]
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
.reset
|
2015-10-29 20:32:11 -07:00
|
|
|
ld hl, OBJECT_FLAGS2
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2018-05-23 10:15:07 -07:00
|
|
|
res OVERHEAD_F, [hl]
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
UselessAndA:
|
2015-02-11 14:13:22 -08:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
EndSpriteMovement:
|
2015-02-11 14:13:22 -08:00
|
|
|
xor a
|
2015-11-15 18:28:15 -08:00
|
|
|
ld hl, OBJECT_STEP_FRAME
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MOVEMENT_INDEX
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hli], a
|
2022-09-12 06:15:44 -07:00
|
|
|
ld [hli], a ; OBJECT_STEP_INDEX
|
2020-10-22 14:41:48 -07:00
|
|
|
ld [hli], a ; OBJECT_1D
|
|
|
|
ld [hl], a ; OBJECT_1E
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_WALKING
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], STANDING
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
InitStep:
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_WALKING
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
2015-10-29 20:32:11 -07:00
|
|
|
ld hl, OBJECT_FLAGS1
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2018-05-23 10:15:07 -07:00
|
|
|
bit FIXED_FACING_F, [hl]
|
2015-11-15 11:59:38 -08:00
|
|
|
jr nz, GetNextTile
|
2015-02-11 14:13:22 -08:00
|
|
|
add a
|
2015-12-26 18:59:03 -08:00
|
|
|
add a
|
2015-07-15 12:48:44 -07:00
|
|
|
and %00001100
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_DIRECTION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
2020-10-22 14:41:48 -07:00
|
|
|
; fallthrough
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetNextTile:
|
2015-02-11 14:13:22 -08:00
|
|
|
call GetStepVector
|
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
ld a, d
|
2015-11-14 11:41:47 -08:00
|
|
|
call GetStepVectorSign
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_LAST_MAP_X
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
add [hl]
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MAP_X
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
ld d, a
|
|
|
|
ld a, e
|
2015-11-14 11:41:47 -08:00
|
|
|
call GetStepVectorSign
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_LAST_MAP_Y
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
add [hl]
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MAP_Y
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
ld e, a
|
|
|
|
push bc
|
2024-02-10 15:25:25 -08:00
|
|
|
call GetCoordTileCollision
|
2015-02-11 14:13:22 -08:00
|
|
|
pop bc
|
2024-02-10 15:25:25 -08:00
|
|
|
ld hl, OBJECT_TILE_COLLISION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AddStepVector:
|
2015-02-11 14:13:22 -08:00
|
|
|
call GetStepVector
|
|
|
|
ld hl, OBJECT_SPRITE_X
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
add d
|
|
|
|
ld [hl], a
|
|
|
|
ld hl, OBJECT_SPRITE_Y
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
add e
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetStepVector:
|
2015-02-11 14:13:22 -08:00
|
|
|
; Return (x, y, duration, speed) in (d, e, a, h).
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_WALKING
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-07-15 12:48:44 -07:00
|
|
|
and %00001111
|
2015-02-11 14:13:22 -08:00
|
|
|
add a
|
2015-12-26 18:59:03 -08:00
|
|
|
add a
|
2015-02-11 14:13:22 -08:00
|
|
|
ld l, a
|
|
|
|
ld h, 0
|
|
|
|
ld de, StepVectors
|
|
|
|
add hl, de
|
|
|
|
ld d, [hl]
|
|
|
|
inc hl
|
|
|
|
ld e, [hl]
|
|
|
|
inc hl
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
StepVectors:
|
2015-02-11 14:13:22 -08:00
|
|
|
; x, y, duration, speed
|
|
|
|
; slow
|
|
|
|
db 0, 1, 16, 1
|
|
|
|
db 0, -1, 16, 1
|
|
|
|
db -1, 0, 16, 1
|
|
|
|
db 1, 0, 16, 1
|
|
|
|
; normal
|
|
|
|
db 0, 2, 8, 2
|
|
|
|
db 0, -2, 8, 2
|
|
|
|
db -2, 0, 8, 2
|
|
|
|
db 2, 0, 8, 2
|
|
|
|
; fast
|
|
|
|
db 0, 4, 4, 4
|
|
|
|
db 0, -4, 4, 4
|
|
|
|
db -4, 0, 4, 4
|
|
|
|
db 4, 0, 4, 4
|
2018-01-10 22:45:27 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetStepVectorSign:
|
2015-02-11 14:13:22 -08:00
|
|
|
add a
|
2020-10-22 14:41:48 -07:00
|
|
|
ret z ; 0 or 128 (-128)
|
2015-02-11 14:13:22 -08:00
|
|
|
ld a, 1
|
2020-10-22 14:41:48 -07:00
|
|
|
ret nc ; +1 to +127
|
2015-02-11 14:13:22 -08:00
|
|
|
ld a, -1
|
2020-10-22 14:41:48 -07:00
|
|
|
ret ; -127 to -1
|
2018-01-10 22:45:27 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
UpdatePlayerStep:
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_WALKING
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-07-15 12:48:44 -07:00
|
|
|
and %00000011
|
2015-11-14 20:02:38 -08:00
|
|
|
ld [wPlayerStepDirection], a
|
2015-11-14 11:41:47 -08:00
|
|
|
call AddStepVector
|
2015-11-14 20:02:38 -08:00
|
|
|
ld a, [wPlayerStepVectorX]
|
2015-02-11 14:13:22 -08:00
|
|
|
add d
|
2015-11-14 20:02:38 -08:00
|
|
|
ld [wPlayerStepVectorX], a
|
|
|
|
ld a, [wPlayerStepVectorY]
|
2015-02-11 14:13:22 -08:00
|
|
|
add e
|
2015-11-14 20:02:38 -08:00
|
|
|
ld [wPlayerStepVectorY], a
|
|
|
|
ld hl, wPlayerStepFlags
|
2019-01-24 18:41:14 -08:00
|
|
|
set PLAYERSTEP_CONTINUE_F, [hl]
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
GetMapObjectField: ; unreferenced
|
2015-02-11 14:13:22 -08:00
|
|
|
push bc
|
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_MAP_OBJECT_INDEX
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
call GetMapObject
|
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
RestoreDefaultMovement:
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_MAP_OBJECT_INDEX
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-07-15 12:48:44 -07:00
|
|
|
cp -1
|
|
|
|
jr z, .ok
|
2015-02-11 14:13:22 -08:00
|
|
|
push bc
|
|
|
|
call GetMapObject
|
2015-07-29 15:22:23 -07:00
|
|
|
ld hl, MAPOBJECT_MOVEMENT
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
.ok
|
2019-08-21 05:43:21 -07:00
|
|
|
ld a, SPRITEMOVEDATA_STANDING_DOWN
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2022-09-12 06:15:44 -07:00
|
|
|
ObjectMovement_ZeroAnonJumptableIndex: ; unreferenced
|
|
|
|
ld hl, OBJECT_MOVEMENT_INDEX
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], 0
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2022-09-12 06:15:44 -07:00
|
|
|
ObjectMovement_IncAnonJumptableIndex:
|
|
|
|
ld hl, OBJECT_MOVEMENT_INDEX
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2022-09-12 06:15:44 -07:00
|
|
|
ObjectMovement_DecAnonJumptableIndex:
|
|
|
|
ld hl, OBJECT_MOVEMENT_INDEX
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
2022-09-12 06:15:44 -07:00
|
|
|
ObjectMovement_AnonJumptable:
|
|
|
|
ld hl, OBJECT_MOVEMENT_INDEX
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
pop hl
|
|
|
|
rst JumpTable
|
|
|
|
ret
|
|
|
|
|
2022-09-12 06:15:44 -07:00
|
|
|
ObjectStep_ZeroAnonJumptableIndex:
|
|
|
|
ld hl, OBJECT_STEP_INDEX
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], 0
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2022-09-12 06:15:44 -07:00
|
|
|
ObjectStep_IncAnonJumptableIndex:
|
|
|
|
ld hl, OBJECT_STEP_INDEX
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2022-09-12 06:15:44 -07:00
|
|
|
ObjectStep_AnonJumptable:
|
|
|
|
ld hl, OBJECT_STEP_INDEX
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
pop hl
|
|
|
|
rst JumpTable
|
|
|
|
ret
|
|
|
|
|
2022-09-12 06:15:44 -07:00
|
|
|
ObjectStep_GetAnonJumptableIndex: ; unreferenced
|
|
|
|
ld hl, OBJECT_STEP_INDEX
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
ret
|
|
|
|
|
2022-09-12 06:15:44 -07:00
|
|
|
ObjectStep_SetAnonJumptableIndex: ; unreferenced
|
|
|
|
ld hl, OBJECT_STEP_INDEX
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
StepFunction_Reset:
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MAP_X
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld d, [hl]
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MAP_Y
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld e, [hl]
|
|
|
|
push bc
|
2024-02-10 15:25:25 -08:00
|
|
|
call GetCoordTileCollision
|
2015-02-11 14:13:22 -08:00
|
|
|
pop bc
|
2024-02-10 15:25:25 -08:00
|
|
|
ld hl, OBJECT_TILE_COLLISION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
2022-09-12 06:15:44 -07:00
|
|
|
call CopyCoordsTileToLastCoordsTile
|
2015-12-17 12:14:51 -08:00
|
|
|
call EndSpriteMovement
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_STEP_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2020-10-22 14:41:48 -07:00
|
|
|
ld [hl], STEP_TYPE_FROM_MOVEMENT
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
StepFunction_FromMovement:
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_ZeroAnonJumptableIndex
|
2015-11-06 13:42:38 -08:00
|
|
|
call GetSpriteMovementFunction
|
2015-02-11 14:13:22 -08:00
|
|
|
ld a, [hl]
|
|
|
|
ld hl, .Pointers
|
|
|
|
rst JumpTable
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.Pointers:
|
2021-03-03 19:22:41 -08:00
|
|
|
; entries correspond to SPRITEMOVEFN_* constants (see constants/map_object_constants.asm)
|
|
|
|
table_width 2, StepFunction_FromMovement.Pointers
|
2020-10-22 07:54:53 -07:00
|
|
|
dw MovementFunction_Null ; 00
|
|
|
|
dw MovementFunction_RandomWalkY ; 01
|
|
|
|
dw MovementFunction_RandomWalkX ; 02
|
|
|
|
dw MovementFunction_RandomWalkXY ; 03
|
|
|
|
dw MovementFunction_RandomSpinSlow ; 04
|
|
|
|
dw MovementFunction_RandomSpinFast ; 05
|
|
|
|
dw MovementFunction_Standing ; 06
|
|
|
|
dw MovementFunction_ObeyDPad ; 07
|
2020-10-22 14:41:48 -07:00
|
|
|
dw MovementFunction_Indexed1 ; 08
|
|
|
|
dw MovementFunction_Indexed2 ; 09
|
2020-10-22 07:54:53 -07:00
|
|
|
dw MovementFunction_0a ; 0a
|
|
|
|
dw MovementFunction_0b ; 0b
|
|
|
|
dw MovementFunction_0c ; 0c
|
|
|
|
dw MovementFunction_0d ; 0d
|
|
|
|
dw MovementFunction_0e ; 0e
|
|
|
|
dw MovementFunction_Follow ; 0f
|
|
|
|
dw MovementFunction_Script ; 10
|
|
|
|
dw MovementFunction_Strength ; 11
|
|
|
|
dw MovementFunction_FollowNotExact ; 12
|
|
|
|
dw MovementFunction_Shadow ; 13
|
|
|
|
dw MovementFunction_Emote ; 14
|
|
|
|
dw MovementFunction_BigStanding ; 15
|
|
|
|
dw MovementFunction_Bouncing ; 16
|
|
|
|
dw MovementFunction_ScreenShake ; 17
|
|
|
|
dw MovementFunction_SpinClockwise ; 18
|
|
|
|
dw MovementFunction_SpinCounterclockwise ; 19
|
|
|
|
dw MovementFunction_BoulderDust ; 1a
|
|
|
|
dw MovementFunction_ShakingGrass ; 1b
|
2021-03-03 19:22:41 -08:00
|
|
|
assert_table_length NUM_SPRITEMOVEFN
|
2020-10-22 07:54:53 -07:00
|
|
|
|
|
|
|
MovementFunction_Null:
|
|
|
|
ret
|
|
|
|
|
|
|
|
MovementFunction_RandomWalkY:
|
2015-02-11 14:13:22 -08:00
|
|
|
call Random
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hRandomAdd]
|
2015-07-15 12:48:44 -07:00
|
|
|
and %00000001
|
2020-10-22 07:54:53 -07:00
|
|
|
jp _RandomWalkContinue
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
MovementFunction_RandomWalkX:
|
2015-02-11 14:13:22 -08:00
|
|
|
call Random
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hRandomAdd]
|
2015-07-15 12:48:44 -07:00
|
|
|
and %00000001
|
|
|
|
or %00000010
|
2020-10-22 07:54:53 -07:00
|
|
|
jp _RandomWalkContinue
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
MovementFunction_RandomWalkXY:
|
2015-02-11 14:13:22 -08:00
|
|
|
call Random
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hRandomAdd]
|
2015-07-15 12:48:44 -07:00
|
|
|
and %00000011
|
2020-10-22 07:54:53 -07:00
|
|
|
jp _RandomWalkContinue
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
MovementFunction_RandomSpinSlow:
|
2015-02-11 14:13:22 -08:00
|
|
|
call Random
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hRandomAdd]
|
2015-07-15 12:48:44 -07:00
|
|
|
and %00001100
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_DIRECTION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
2015-11-14 11:41:47 -08:00
|
|
|
jp RandomStepDuration_Slow
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
MovementFunction_RandomSpinFast:
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_DIRECTION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-07-15 12:48:44 -07:00
|
|
|
and %00001100
|
2015-02-11 14:13:22 -08:00
|
|
|
ld d, a
|
|
|
|
call Random
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hRandomAdd]
|
2015-07-15 12:48:44 -07:00
|
|
|
and %00001100
|
2015-02-11 14:13:22 -08:00
|
|
|
cp d
|
2015-07-15 12:48:44 -07:00
|
|
|
jr nz, .keep
|
|
|
|
xor %00001100
|
|
|
|
.keep
|
2015-02-11 14:13:22 -08:00
|
|
|
ld [hl], a
|
2015-11-14 11:41:47 -08:00
|
|
|
jp RandomStepDuration_Fast
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
MovementFunction_Standing:
|
2022-09-12 06:15:44 -07:00
|
|
|
call CopyLastCoordsToCoords
|
2015-12-17 12:14:51 -08:00
|
|
|
call EndSpriteMovement
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_ACTION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2017-12-24 10:46:34 -08:00
|
|
|
ld [hl], OBJECT_ACTION_STAND
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_STEP_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2020-10-22 14:41:48 -07:00
|
|
|
ld [hl], STEP_TYPE_RESTORE
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
MovementFunction_ObeyDPad:
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, GetPlayerNextMovementIndex
|
2015-11-11 20:38:57 -08:00
|
|
|
jp HandleMovementData
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
MovementFunction_Indexed1:
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, GetIndexedMovementIndex1
|
2015-11-11 20:38:57 -08:00
|
|
|
jp HandleMovementData
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
MovementFunction_Indexed2:
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, GetIndexedMovementIndex2
|
2015-11-11 20:38:57 -08:00
|
|
|
jp HandleMovementData
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
MovementFunction_0a:
|
2017-12-24 10:46:34 -08:00
|
|
|
jp _GetMovementObject
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
MovementFunction_0b:
|
2017-12-24 10:46:34 -08:00
|
|
|
jp _GetMovementObject
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
MovementFunction_0c:
|
2017-12-24 10:46:34 -08:00
|
|
|
jp _GetMovementObject
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
MovementFunction_0d:
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, GetPlayerNextMovementIndex
|
2015-11-11 20:38:57 -08:00
|
|
|
jp HandleMovementData
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
MovementFunction_0e:
|
2017-12-24 10:46:34 -08:00
|
|
|
jp _GetMovementObject
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
MovementFunction_Follow:
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, GetFollowerNextMovementIndex
|
2015-11-11 20:38:57 -08:00
|
|
|
jp HandleMovementData
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
MovementFunction_Script:
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, GetMovementIndex
|
2015-11-11 20:38:57 -08:00
|
|
|
jp HandleMovementData
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
MovementFunction_Strength:
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectMovement_AnonJumptable
|
2020-10-22 07:54:53 -07:00
|
|
|
.anon_dw
|
|
|
|
dw .start
|
|
|
|
dw .stop
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
.start:
|
2024-02-10 15:25:25 -08:00
|
|
|
ld hl, OBJECT_TILE_COLLISION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
call CheckPitTile
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .on_pit
|
2015-10-29 20:32:11 -07:00
|
|
|
ld hl, OBJECT_FLAGS2
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2019-01-24 18:41:14 -08:00
|
|
|
bit OBJ_FLAGS2_2, [hl]
|
|
|
|
res OBJ_FLAGS2_2, [hl]
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .ok
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_RANGE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-07-15 12:48:44 -07:00
|
|
|
and %00000011
|
|
|
|
or 0
|
2015-12-17 12:14:51 -08:00
|
|
|
call InitStep
|
2018-05-24 09:36:35 -07:00
|
|
|
call CanObjectMoveInDirection
|
2015-07-15 12:48:44 -07:00
|
|
|
jr c, .ok2
|
2015-02-11 14:13:22 -08:00
|
|
|
ld de, SFX_STRENGTH
|
|
|
|
call PlaySFX
|
2015-11-14 11:41:47 -08:00
|
|
|
call SpawnStrengthBoulderDust
|
2015-12-17 12:14:51 -08:00
|
|
|
call UpdateTallGrassFlags
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_STEP_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2020-10-22 14:41:48 -07:00
|
|
|
ld [hl], STEP_TYPE_STRENGTH_BOULDER
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
.ok2
|
2022-09-12 06:15:44 -07:00
|
|
|
call CopyLastCoordsToCoords
|
2015-07-15 12:48:44 -07:00
|
|
|
.ok
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_WALKING
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], STANDING
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
.on_pit
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectMovement_IncAnonJumptableIndex
|
2020-10-22 07:54:53 -07:00
|
|
|
.stop:
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_WALKING
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], STANDING
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
MovementFunction_FollowNotExact:
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MAP_X
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld d, [hl]
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MAP_Y
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld e, [hl]
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_RANGE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
push bc
|
2015-07-15 12:48:44 -07:00
|
|
|
call GetObjectStruct
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_WALKING
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-07-15 12:48:44 -07:00
|
|
|
cp STANDING
|
|
|
|
jr z, .standing
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_LAST_MAP_X
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
cp d
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .equal
|
|
|
|
jr c, .less
|
|
|
|
ld a, 3
|
|
|
|
jr .done
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
.less
|
|
|
|
ld a, 2
|
|
|
|
jr .done
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
.equal
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_LAST_MAP_Y
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
cp e
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .standing
|
|
|
|
jr c, .less2
|
|
|
|
ld a, 0
|
|
|
|
jr .done
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
.less2
|
|
|
|
ld a, 1
|
|
|
|
.done
|
2015-02-11 14:13:22 -08:00
|
|
|
ld d, a
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_WALKING
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-07-15 12:48:44 -07:00
|
|
|
and %00001100
|
2015-02-11 14:13:22 -08:00
|
|
|
or d
|
|
|
|
pop bc
|
2015-10-29 20:32:11 -07:00
|
|
|
jp NormalStep
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
.standing
|
2015-02-11 14:13:22 -08:00
|
|
|
pop bc
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_WALKING
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], STANDING
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_ACTION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2017-12-24 10:46:34 -08:00
|
|
|
ld [hl], OBJECT_ACTION_STAND
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
MovementFunction_BigStanding:
|
2015-12-17 12:14:51 -08:00
|
|
|
call EndSpriteMovement
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_WALKING
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], STANDING
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_ACTION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2018-01-30 19:34:05 -08:00
|
|
|
ld [hl], OBJECT_ACTION_BIG_DOLL_SYM
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_STEP_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2020-10-22 14:41:48 -07:00
|
|
|
ld [hl], STEP_TYPE_STANDING
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
MovementFunction_Bouncing:
|
2015-12-17 12:14:51 -08:00
|
|
|
call EndSpriteMovement
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_WALKING
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], STANDING
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_ACTION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2017-12-24 10:46:34 -08:00
|
|
|
ld [hl], OBJECT_ACTION_BOUNCE
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_STEP_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2020-10-22 14:41:48 -07:00
|
|
|
ld [hl], STEP_TYPE_STANDING
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
MovementFunction_SpinCounterclockwise:
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectMovement_AnonJumptable
|
2020-10-22 07:54:53 -07:00
|
|
|
.anon_dw
|
|
|
|
dw _MovementSpinInit
|
|
|
|
dw _MovementSpinRepeat
|
|
|
|
dw _MovementSpinTurnLeft
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
MovementFunction_SpinClockwise:
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectMovement_AnonJumptable
|
2020-10-22 07:54:53 -07:00
|
|
|
.anon_dw
|
|
|
|
dw _MovementSpinInit
|
|
|
|
dw _MovementSpinRepeat
|
|
|
|
dw _MovementSpinTurnRight
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
_MovementSpinInit:
|
2015-12-17 12:14:51 -08:00
|
|
|
call EndSpriteMovement
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectMovement_IncAnonJumptableIndex
|
2020-10-22 14:41:48 -07:00
|
|
|
; fallthrough
|
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
_MovementSpinRepeat:
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_ACTION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2017-12-24 10:46:34 -08:00
|
|
|
ld [hl], OBJECT_ACTION_STAND
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_RANGE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-11-14 20:02:38 -08:00
|
|
|
ld a, $10
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_STEP_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2020-10-22 14:41:48 -07:00
|
|
|
ld [hl], STEP_TYPE_SLEEP
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectMovement_IncAnonJumptableIndex
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
_MovementSpinTurnLeft:
|
|
|
|
ld de, .facings_counterclockwise
|
|
|
|
call _MovementSpinNextFacing
|
|
|
|
jr MovementFunction_SpinCounterclockwise
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
.facings_counterclockwise:
|
|
|
|
db OW_RIGHT
|
|
|
|
db OW_LEFT
|
|
|
|
db OW_DOWN
|
|
|
|
db OW_UP
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
_MovementSpinTurnRight:
|
|
|
|
ld de, .facings_clockwise
|
|
|
|
call _MovementSpinNextFacing
|
|
|
|
jr MovementFunction_SpinClockwise
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
.facings_clockwise:
|
|
|
|
db OW_LEFT
|
|
|
|
db OW_RIGHT
|
|
|
|
db OW_UP
|
|
|
|
db OW_DOWN
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
_MovementSpinNextFacing:
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_DIRECTION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-07-15 12:48:44 -07:00
|
|
|
and %00001100
|
2015-02-11 14:13:22 -08:00
|
|
|
rrca
|
|
|
|
rrca
|
|
|
|
push hl
|
|
|
|
ld l, a
|
2015-07-15 12:48:44 -07:00
|
|
|
ld h, 0
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
pop hl
|
|
|
|
ld [hl], a
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectMovement_DecAnonJumptableIndex
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
MovementFunction_Shadow:
|
|
|
|
call InitMovementField1dField1e
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_ACTION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2017-12-24 10:46:34 -08:00
|
|
|
ld [hl], OBJECT_ACTION_SHADOW
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
inc a
|
|
|
|
add a
|
2015-07-15 12:48:44 -07:00
|
|
|
add 0
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_WALKING
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
2018-01-16 14:27:50 -08:00
|
|
|
maskbits NUM_DIRECTIONS
|
2023-07-26 17:50:16 -07:00
|
|
|
ld d, 1 * TILE_WIDTH + 6
|
2015-07-15 12:48:44 -07:00
|
|
|
cp DOWN
|
2020-10-22 07:54:53 -07:00
|
|
|
jr z, .ok
|
2015-07-15 12:48:44 -07:00
|
|
|
cp UP
|
2020-10-22 07:54:53 -07:00
|
|
|
jr z, .ok
|
2023-07-26 17:50:16 -07:00
|
|
|
ld d, 1 * TILE_WIDTH + 4
|
2020-10-22 07:54:53 -07:00
|
|
|
.ok
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_SPRITE_Y_OFFSET
|
|
|
|
add hl, bc
|
|
|
|
ld [hl], d
|
|
|
|
ld hl, OBJECT_SPRITE_X_OFFSET
|
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], 0
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_STEP_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2015-12-17 12:14:51 -08:00
|
|
|
ld [hl], STEP_TYPE_TRACKING_OBJECT
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
MovementFunction_Emote:
|
2015-12-17 12:14:51 -08:00
|
|
|
call EndSpriteMovement
|
2020-10-22 07:54:53 -07:00
|
|
|
call InitMovementField1dField1e
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_ACTION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2017-12-24 10:46:34 -08:00
|
|
|
ld [hl], OBJECT_ACTION_EMOTE
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], 0
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_SPRITE_Y_OFFSET
|
|
|
|
add hl, bc
|
2023-07-26 17:50:16 -07:00
|
|
|
ld [hl], -2 * TILE_WIDTH
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_SPRITE_X_OFFSET
|
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], 0
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_STEP_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2015-12-17 12:14:51 -08:00
|
|
|
ld [hl], STEP_TYPE_TRACKING_OBJECT
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
MovementFunction_BoulderDust:
|
2015-12-17 12:14:51 -08:00
|
|
|
call EndSpriteMovement
|
2020-10-22 07:54:53 -07:00
|
|
|
call InitMovementField1dField1e
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_ACTION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2017-12-24 10:46:34 -08:00
|
|
|
ld [hl], OBJECT_ACTION_BOULDER_DUST
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
inc a
|
|
|
|
add a
|
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_WALKING
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
2015-07-15 12:48:44 -07:00
|
|
|
and %00000011
|
2015-02-11 14:13:22 -08:00
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
2020-10-22 07:54:53 -07:00
|
|
|
ld hl, .dust_coords
|
2015-12-29 10:15:58 -08:00
|
|
|
add hl, de
|
|
|
|
add hl, de
|
2015-02-11 14:13:22 -08:00
|
|
|
ld d, [hl]
|
|
|
|
inc hl
|
|
|
|
ld e, [hl]
|
|
|
|
ld hl, OBJECT_SPRITE_X_OFFSET
|
|
|
|
add hl, bc
|
|
|
|
ld [hl], d
|
|
|
|
ld hl, OBJECT_SPRITE_Y_OFFSET
|
|
|
|
add hl, bc
|
|
|
|
ld [hl], e
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_STEP_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2015-12-17 12:14:51 -08:00
|
|
|
ld [hl], STEP_TYPE_TRACKING_OBJECT
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
.dust_coords:
|
2015-02-11 14:13:22 -08:00
|
|
|
; x, y
|
|
|
|
db 0, -4
|
|
|
|
db 0, 8
|
|
|
|
db 6, 2
|
|
|
|
db -6, 2
|
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
MovementFunction_ShakingGrass:
|
2015-12-17 12:14:51 -08:00
|
|
|
call EndSpriteMovement
|
2020-10-22 07:54:53 -07:00
|
|
|
call InitMovementField1dField1e
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_ACTION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2017-12-24 10:46:34 -08:00
|
|
|
ld [hl], OBJECT_ACTION_GRASS_SHAKE
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
2015-07-15 12:48:44 -07:00
|
|
|
add -1
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_STEP_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2015-12-17 12:14:51 -08:00
|
|
|
ld [hl], STEP_TYPE_TRACKING_OBJECT
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
InitMovementField1dField1e:
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_RANGE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
push bc
|
2015-07-15 12:48:44 -07:00
|
|
|
call GetObjectStruct
|
2015-02-11 14:13:22 -08:00
|
|
|
ld d, b
|
|
|
|
ld e, c
|
|
|
|
pop bc
|
2017-12-29 07:19:51 -08:00
|
|
|
ld hl, OBJECT_1D
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], e
|
2022-09-12 06:15:44 -07:00
|
|
|
inc hl ; OBJECT_1E
|
2015-02-11 14:13:22 -08:00
|
|
|
ld [hl], d
|
|
|
|
ret
|
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
MovementFunction_ScreenShake:
|
2015-12-17 12:14:51 -08:00
|
|
|
call EndSpriteMovement
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_ACTION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2017-12-24 10:46:34 -08:00
|
|
|
ld [hl], OBJECT_ACTION_00
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_RANGE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2020-10-22 07:54:53 -07:00
|
|
|
call .GetDurationAndField1e
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
|
|
|
ld [hl], e
|
2017-12-29 07:19:51 -08:00
|
|
|
ld hl, OBJECT_1E
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_STEP_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2020-10-22 14:41:48 -07:00
|
|
|
ld [hl], STEP_TYPE_SCREENSHAKE
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
.GetDurationAndField1e:
|
2015-02-11 14:13:22 -08:00
|
|
|
ld d, a
|
2015-07-15 12:48:44 -07:00
|
|
|
and %00111111
|
2015-02-11 14:13:22 -08:00
|
|
|
ld e, a
|
|
|
|
ld a, d
|
|
|
|
rlca
|
|
|
|
rlca
|
2015-07-15 12:48:44 -07:00
|
|
|
and %00000011
|
2015-02-11 14:13:22 -08:00
|
|
|
ld d, a
|
|
|
|
inc d
|
2015-07-15 12:48:44 -07:00
|
|
|
ld a, 1
|
|
|
|
.loop
|
2015-02-11 14:13:22 -08:00
|
|
|
dec d
|
|
|
|
ret z
|
|
|
|
add a
|
2015-07-15 12:48:44 -07:00
|
|
|
jr .loop
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
_RandomWalkContinue:
|
2015-12-17 12:14:51 -08:00
|
|
|
call InitStep
|
2020-10-22 14:41:48 -07:00
|
|
|
call CanObjectMoveInDirection
|
2020-10-22 07:54:53 -07:00
|
|
|
jr c, .new_duration
|
2015-12-17 12:14:51 -08:00
|
|
|
call UpdateTallGrassFlags
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_ACTION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2017-12-24 10:46:34 -08:00
|
|
|
ld [hl], OBJECT_ACTION_STEP
|
2015-11-16 08:53:26 -08:00
|
|
|
ld hl, wCenteredObject
|
2020-12-23 13:54:28 -08:00
|
|
|
ldh a, [hMapObjectIndex]
|
2015-02-11 14:13:22 -08:00
|
|
|
cp [hl]
|
2020-10-22 07:54:53 -07:00
|
|
|
jr z, .centered
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_STEP_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2020-10-22 14:41:48 -07:00
|
|
|
ld [hl], STEP_TYPE_CONTINUE_WALK
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
.centered
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_STEP_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2015-11-16 08:53:26 -08:00
|
|
|
ld [hl], STEP_TYPE_PLAYER_WALK
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 07:54:53 -07:00
|
|
|
.new_duration:
|
2015-12-17 12:14:51 -08:00
|
|
|
call EndSpriteMovement
|
2022-09-12 06:15:44 -07:00
|
|
|
call CopyLastCoordsToCoords
|
2020-10-22 07:54:53 -07:00
|
|
|
; fallthrough
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
RandomStepDuration_Slow:
|
2015-02-11 14:13:22 -08:00
|
|
|
call Random
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hRandomAdd]
|
2015-07-15 12:48:44 -07:00
|
|
|
and %01111111
|
2020-10-22 14:41:48 -07:00
|
|
|
jr _SetRandomStepDuration
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
RandomStepDuration_Fast:
|
2015-02-11 14:13:22 -08:00
|
|
|
call Random
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hRandomAdd]
|
2015-07-15 12:48:44 -07:00
|
|
|
and %00011111
|
2020-10-22 14:41:48 -07:00
|
|
|
_SetRandomStepDuration:
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_WALKING
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], STANDING
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_ACTION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2017-12-24 10:46:34 -08:00
|
|
|
ld [hl], OBJECT_ACTION_STAND
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_STEP_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2020-10-22 14:41:48 -07:00
|
|
|
ld [hl], STEP_TYPE_SLEEP
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
StepTypesJumptable:
|
2021-03-03 19:22:41 -08:00
|
|
|
; entries correspond to STEP_TYPE_* constants (see constants/map_object_constants.asm)
|
|
|
|
table_width 2, StepTypesJumptable
|
2020-10-22 14:41:48 -07:00
|
|
|
dw StepFunction_Reset ; 00
|
|
|
|
dw StepFunction_FromMovement ; 01
|
|
|
|
dw StepFunction_NPCWalk ; 02
|
|
|
|
dw StepFunction_Sleep ; 03
|
|
|
|
dw StepFunction_Standing ; 04
|
|
|
|
dw StepFunction_Restore ; 05
|
|
|
|
dw StepFunction_PlayerWalk ; 06
|
|
|
|
dw StepFunction_ContinueWalk ; 07
|
|
|
|
dw StepFunction_NPCJump ; 08
|
|
|
|
dw StepFunction_PlayerJump ; 09
|
|
|
|
dw StepFunction_Turn ; 0a
|
|
|
|
dw StepFunction_Bump ; 0b
|
|
|
|
dw StepFunction_TeleportFrom ; 0c
|
|
|
|
dw StepFunction_TeleportTo ; 0d
|
|
|
|
dw StepFunction_Skyfall ; 0e
|
|
|
|
dw StepFunction_StrengthBoulder ; 0f
|
|
|
|
dw StepFunction_GotBite ; 10
|
|
|
|
dw StepFunction_RockSmash ; 11
|
|
|
|
dw StepFunction_DigTo ; 12
|
|
|
|
dw StepFunction_TrackingObject ; 13
|
|
|
|
dw StepFunction_14 ; 14
|
|
|
|
dw StepFunction_ScreenShake ; 15
|
|
|
|
dw StepFunction_16 ; 16
|
|
|
|
dw StepFunction_17 ; 17
|
|
|
|
dw StepFunction_Delete ; 18
|
|
|
|
dw StepFunction_SkyfallTop ; 19
|
2021-03-03 19:22:41 -08:00
|
|
|
assert_table_length NUM_STEP_TYPES
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
WaitStep_InPlace:
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
|
|
|
dec [hl]
|
|
|
|
ret nz
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_STEP_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2020-10-22 14:41:48 -07:00
|
|
|
ld [hl], STEP_TYPE_FROM_MOVEMENT
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
StepFunction_NPCJump:
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_AnonJumptable
|
2020-10-22 07:54:53 -07:00
|
|
|
.anon_dw
|
2015-12-29 10:15:58 -08:00
|
|
|
dw .Jump
|
|
|
|
dw .Land
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Jump:
|
2015-11-14 11:41:47 -08:00
|
|
|
call AddStepVector
|
2015-02-11 14:13:22 -08:00
|
|
|
call UpdateJumpPosition
|
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
|
|
|
dec [hl]
|
|
|
|
ret nz
|
2022-09-12 06:15:44 -07:00
|
|
|
call CopyCoordsTileToLastCoordsTile
|
2015-11-15 11:59:38 -08:00
|
|
|
call GetNextTile
|
2015-10-29 20:32:11 -07:00
|
|
|
ld hl, OBJECT_FLAGS2
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2019-01-24 18:41:14 -08:00
|
|
|
res OVERHEAD_F, [hl]
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_IncAnonJumptableIndex
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Land:
|
2015-11-14 11:41:47 -08:00
|
|
|
call AddStepVector
|
2015-02-11 14:13:22 -08:00
|
|
|
call UpdateJumpPosition
|
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
|
|
|
dec [hl]
|
|
|
|
ret nz
|
2022-09-12 06:15:44 -07:00
|
|
|
call CopyCoordsTileToLastCoordsTile
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_STEP_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2020-10-22 14:41:48 -07:00
|
|
|
ld [hl], STEP_TYPE_FROM_MOVEMENT
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
StepFunction_PlayerJump:
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_AnonJumptable
|
2020-10-22 07:54:53 -07:00
|
|
|
.anon_dw
|
2015-12-17 12:14:51 -08:00
|
|
|
dw .initjump
|
|
|
|
dw .stepjump
|
|
|
|
dw .initland
|
|
|
|
dw .stepland
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2015-12-29 10:15:58 -08:00
|
|
|
.initjump
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, wPlayerStepFlags
|
2019-01-24 18:41:14 -08:00
|
|
|
set PLAYERSTEP_START_F, [hl]
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_IncAnonJumptableIndex
|
2015-12-29 10:15:58 -08:00
|
|
|
.stepjump
|
2015-02-11 14:13:22 -08:00
|
|
|
call UpdateJumpPosition
|
2015-12-17 12:14:51 -08:00
|
|
|
call UpdatePlayerStep
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
|
|
|
dec [hl]
|
|
|
|
ret nz
|
2022-09-12 06:15:44 -07:00
|
|
|
call CopyCoordsTileToLastCoordsTile
|
2015-10-29 20:32:11 -07:00
|
|
|
ld hl, OBJECT_FLAGS2
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2019-01-24 18:41:14 -08:00
|
|
|
res OVERHEAD_F, [hl]
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, wPlayerStepFlags
|
2019-01-24 18:41:14 -08:00
|
|
|
set PLAYERSTEP_STOP_F, [hl]
|
|
|
|
set PLAYERSTEP_MIDAIR_F, [hl]
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_IncAnonJumptableIndex
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2015-12-29 10:15:58 -08:00
|
|
|
.initland
|
2015-11-15 11:59:38 -08:00
|
|
|
call GetNextTile
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, wPlayerStepFlags
|
2019-01-24 18:41:14 -08:00
|
|
|
set PLAYERSTEP_START_F, [hl]
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_IncAnonJumptableIndex
|
2015-12-29 10:15:58 -08:00
|
|
|
.stepland
|
2015-02-11 14:13:22 -08:00
|
|
|
call UpdateJumpPosition
|
2015-12-17 12:14:51 -08:00
|
|
|
call UpdatePlayerStep
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
|
|
|
dec [hl]
|
|
|
|
ret nz
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, wPlayerStepFlags
|
2019-01-24 18:41:14 -08:00
|
|
|
set PLAYERSTEP_STOP_F, [hl]
|
2022-09-12 06:15:44 -07:00
|
|
|
call CopyCoordsTileToLastCoordsTile
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_STEP_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2020-10-22 14:41:48 -07:00
|
|
|
ld [hl], STEP_TYPE_FROM_MOVEMENT
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
StepFunction_TeleportFrom:
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_AnonJumptable
|
2020-10-22 07:54:53 -07:00
|
|
|
.anon_dw
|
2015-12-29 10:15:58 -08:00
|
|
|
dw .InitSpin
|
|
|
|
dw .DoSpin
|
|
|
|
dw .InitSpinRise
|
|
|
|
dw .DoSpinRise
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.InitSpin:
|
2015-11-15 18:28:15 -08:00
|
|
|
ld hl, OBJECT_STEP_FRAME
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], 0
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
2015-12-29 10:15:58 -08:00
|
|
|
ld [hl], 16
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_IncAnonJumptableIndex
|
2016-04-10 11:42:14 -07:00
|
|
|
.DoSpin:
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_ACTION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2017-12-24 10:46:34 -08:00
|
|
|
ld [hl], OBJECT_ACTION_SPIN
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
|
|
|
dec [hl]
|
|
|
|
ret nz
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_IncAnonJumptableIndex
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.InitSpinRise:
|
2015-11-15 18:28:15 -08:00
|
|
|
ld hl, OBJECT_STEP_FRAME
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], 0
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_JUMP_HEIGHT
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], $10
|
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
2015-12-29 10:15:58 -08:00
|
|
|
ld [hl], 16
|
2015-10-29 20:32:11 -07:00
|
|
|
ld hl, OBJECT_FLAGS2
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2019-01-24 18:41:14 -08:00
|
|
|
res OVERHEAD_F, [hl]
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_IncAnonJumptableIndex
|
2016-04-10 11:42:14 -07:00
|
|
|
.DoSpinRise:
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_ACTION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2017-12-24 10:46:34 -08:00
|
|
|
ld [hl], OBJECT_ACTION_SPIN
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_JUMP_HEIGHT
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
inc [hl]
|
|
|
|
ld a, [hl]
|
|
|
|
ld d, $60
|
|
|
|
call Sine
|
|
|
|
ld a, h
|
|
|
|
sub $60
|
|
|
|
ld hl, OBJECT_SPRITE_Y_OFFSET
|
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
|
|
|
dec [hl]
|
|
|
|
ret nz
|
2015-11-15 18:28:15 -08:00
|
|
|
ld hl, OBJECT_STEP_FRAME
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], 0
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_STEP_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2020-10-22 14:41:48 -07:00
|
|
|
ld [hl], STEP_TYPE_FROM_MOVEMENT
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
StepFunction_TeleportTo:
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_AnonJumptable
|
2020-10-22 07:54:53 -07:00
|
|
|
.anon_dw
|
2015-12-29 10:15:58 -08:00
|
|
|
dw .InitWait
|
|
|
|
dw .DoWait
|
|
|
|
dw .InitDescent
|
|
|
|
dw .DoDescent
|
|
|
|
dw .InitFinalSpin
|
|
|
|
dw .DoFinalSpin
|
|
|
|
dw .FinishStep
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.InitWait:
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_ACTION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2017-12-24 10:46:34 -08:00
|
|
|
ld [hl], OBJECT_ACTION_00
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
2015-12-29 10:15:58 -08:00
|
|
|
ld [hl], 16
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_IncAnonJumptableIndex
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.DoWait:
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
|
|
|
dec [hl]
|
|
|
|
ret nz
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_IncAnonJumptableIndex
|
2016-04-10 11:42:14 -07:00
|
|
|
.InitDescent:
|
2015-11-15 18:28:15 -08:00
|
|
|
ld hl, OBJECT_STEP_FRAME
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], 0
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_JUMP_HEIGHT
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], 0
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
2015-12-29 10:15:58 -08:00
|
|
|
ld [hl], 16
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_IncAnonJumptableIndex
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.DoDescent:
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_ACTION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2017-12-24 10:46:34 -08:00
|
|
|
ld [hl], OBJECT_ACTION_SPIN
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_JUMP_HEIGHT
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
inc [hl]
|
|
|
|
ld a, [hl]
|
|
|
|
ld d, $60
|
|
|
|
call Sine
|
|
|
|
ld a, h
|
|
|
|
sub $60
|
|
|
|
ld hl, OBJECT_SPRITE_Y_OFFSET
|
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
|
|
|
dec [hl]
|
|
|
|
ret nz
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_IncAnonJumptableIndex
|
2016-04-10 11:42:14 -07:00
|
|
|
.InitFinalSpin:
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
2015-12-29 10:15:58 -08:00
|
|
|
ld [hl], 16
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_IncAnonJumptableIndex
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.DoFinalSpin:
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_ACTION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2017-12-24 10:46:34 -08:00
|
|
|
ld [hl], OBJECT_ACTION_SPIN
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
|
|
|
dec [hl]
|
|
|
|
ret nz
|
2016-04-10 11:42:14 -07:00
|
|
|
.FinishStep:
|
2015-11-15 18:28:15 -08:00
|
|
|
ld hl, OBJECT_STEP_FRAME
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], 0
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_SPRITE_Y_OFFSET
|
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], 0
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_STEP_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2020-10-22 14:41:48 -07:00
|
|
|
ld [hl], STEP_TYPE_FROM_MOVEMENT
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
StepFunction_Skyfall:
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_AnonJumptable
|
2020-10-22 07:54:53 -07:00
|
|
|
.anon_dw
|
2015-12-29 10:15:58 -08:00
|
|
|
dw .Init
|
|
|
|
dw .Step
|
|
|
|
dw .Fall
|
|
|
|
dw .Finish
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Init:
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_ACTION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2017-12-24 10:46:34 -08:00
|
|
|
ld [hl], OBJECT_ACTION_00
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
2015-12-29 10:15:58 -08:00
|
|
|
ld [hl], 16
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_IncAnonJumptableIndex
|
2016-04-10 11:42:14 -07:00
|
|
|
.Step:
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
|
|
|
dec [hl]
|
|
|
|
ret nz
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_ACTION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2017-12-24 10:46:34 -08:00
|
|
|
ld [hl], OBJECT_ACTION_STEP
|
2015-11-15 18:28:15 -08:00
|
|
|
ld hl, OBJECT_STEP_FRAME
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], 0
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_JUMP_HEIGHT
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], 0
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
2015-12-29 10:15:58 -08:00
|
|
|
ld [hl], 16
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_IncAnonJumptableIndex
|
2016-04-10 11:42:14 -07:00
|
|
|
.Fall:
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_JUMP_HEIGHT
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
inc [hl]
|
|
|
|
ld a, [hl]
|
|
|
|
ld d, $60
|
|
|
|
call Sine
|
|
|
|
ld a, h
|
|
|
|
sub $60
|
|
|
|
ld hl, OBJECT_SPRITE_Y_OFFSET
|
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
|
|
|
dec [hl]
|
|
|
|
ret nz
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_IncAnonJumptableIndex
|
2016-04-10 11:42:14 -07:00
|
|
|
.Finish:
|
2015-11-15 18:28:15 -08:00
|
|
|
ld hl, OBJECT_STEP_FRAME
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], 0
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_SPRITE_Y_OFFSET
|
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], 0
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_STEP_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2020-10-22 14:41:48 -07:00
|
|
|
ld [hl], STEP_TYPE_FROM_MOVEMENT
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
StepFunction_GotBite:
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_AnonJumptable
|
2020-10-22 07:54:53 -07:00
|
|
|
.anon_dw
|
2015-12-29 10:15:58 -08:00
|
|
|
dw .Init
|
|
|
|
dw .Run
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Init:
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], 8
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_SPRITE_Y_OFFSET
|
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], 0
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_IncAnonJumptableIndex
|
2016-04-10 11:42:14 -07:00
|
|
|
.Run:
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_SPRITE_Y_OFFSET
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
xor 1
|
|
|
|
ld [hl], a
|
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
|
|
|
dec [hl]
|
|
|
|
ret nz
|
|
|
|
ld hl, OBJECT_SPRITE_Y_OFFSET
|
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], 0
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_STEP_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2020-10-22 14:41:48 -07:00
|
|
|
ld [hl], STEP_TYPE_FROM_MOVEMENT
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
StepFunction_RockSmash:
|
2015-12-29 10:15:58 -08:00
|
|
|
call .Step
|
|
|
|
jp WaitStep_InPlace
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Step:
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-07-15 12:48:44 -07:00
|
|
|
and %00000001
|
2017-12-24 10:46:34 -08:00
|
|
|
ld a, OBJECT_ACTION_STAND
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .yes
|
2017-12-24 10:46:34 -08:00
|
|
|
ld a, OBJECT_ACTION_00
|
2015-07-15 12:48:44 -07:00
|
|
|
.yes
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_ACTION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
StepFunction_DigTo:
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-07-15 12:48:44 -07:00
|
|
|
and %00000001
|
2017-12-24 10:46:34 -08:00
|
|
|
ld a, OBJECT_ACTION_SPIN
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .yes
|
2017-12-24 10:46:34 -08:00
|
|
|
ld a, OBJECT_ACTION_SPIN_FLICKER
|
2015-07-15 12:48:44 -07:00
|
|
|
.yes
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_ACTION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
2015-12-29 10:15:58 -08:00
|
|
|
jp WaitStep_InPlace
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
StepFunction_Sleep:
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_WALKING
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], STANDING
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
|
|
|
dec [hl]
|
|
|
|
ret nz
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_STEP_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2020-10-22 14:41:48 -07:00
|
|
|
ld [hl], STEP_TYPE_FROM_MOVEMENT
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
StepFunction_Delete:
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_WALKING
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], STANDING
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
|
|
|
dec [hl]
|
|
|
|
ret nz
|
2015-12-17 12:14:51 -08:00
|
|
|
jp DeleteMapObject
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
StepFunction_Bump:
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
|
|
|
dec [hl]
|
|
|
|
ret nz
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_STEP_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2020-10-22 14:41:48 -07:00
|
|
|
ld [hl], STEP_TYPE_FROM_MOVEMENT
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
StepFunction_Restore:
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_AnonJumptable
|
2020-10-22 07:54:53 -07:00
|
|
|
.anon_dw
|
2015-12-29 10:15:58 -08:00
|
|
|
dw .Reset
|
2020-10-22 14:41:48 -07:00
|
|
|
dw StepFunction_Standing
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Reset:
|
2015-11-02 08:15:32 -08:00
|
|
|
call RestoreDefaultMovement
|
2015-11-13 15:59:49 -08:00
|
|
|
call GetInitialFacing
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_DIRECTION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_IncAnonJumptableIndex
|
2020-10-22 14:41:48 -07:00
|
|
|
; fallthrough
|
|
|
|
|
|
|
|
StepFunction_Standing:
|
|
|
|
call Stubbed_UpdateYOffset
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_WALKING
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], STANDING
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
StepFunction_NPCWalk:
|
|
|
|
call Stubbed_UpdateYOffset
|
2015-11-14 11:41:47 -08:00
|
|
|
call AddStepVector
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
|
|
|
dec [hl]
|
|
|
|
ret nz
|
2022-09-12 06:15:44 -07:00
|
|
|
call CopyCoordsTileToLastCoordsTile
|
|
|
|
ld hl, OBJECT_WALKING
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], STANDING
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_STEP_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2020-10-22 14:41:48 -07:00
|
|
|
ld [hl], STEP_TYPE_FROM_MOVEMENT
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
StepFunction_ContinueWalk:
|
2015-11-14 11:41:47 -08:00
|
|
|
call AddStepVector
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
|
|
|
dec [hl]
|
|
|
|
ret nz
|
2022-09-12 06:15:44 -07:00
|
|
|
call CopyCoordsTileToLastCoordsTile
|
2015-11-14 11:41:47 -08:00
|
|
|
jp RandomStepDuration_Slow
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
StepFunction_PlayerWalk:
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_AnonJumptable
|
2020-10-22 07:54:53 -07:00
|
|
|
.anon_dw
|
2015-12-17 12:14:51 -08:00
|
|
|
dw .init
|
|
|
|
dw .step
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2015-12-29 10:15:58 -08:00
|
|
|
.init
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, wPlayerStepFlags
|
2019-01-24 18:41:14 -08:00
|
|
|
set PLAYERSTEP_START_F, [hl]
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_IncAnonJumptableIndex
|
2015-12-29 10:15:58 -08:00
|
|
|
.step
|
2015-12-17 12:14:51 -08:00
|
|
|
call UpdatePlayerStep
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
|
|
|
dec [hl]
|
|
|
|
ret nz
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, wPlayerStepFlags
|
2019-01-24 18:41:14 -08:00
|
|
|
set PLAYERSTEP_STOP_F, [hl]
|
2022-09-12 06:15:44 -07:00
|
|
|
call CopyCoordsTileToLastCoordsTile
|
|
|
|
ld hl, OBJECT_WALKING
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], STANDING
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_STEP_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2020-10-22 14:41:48 -07:00
|
|
|
ld [hl], STEP_TYPE_FROM_MOVEMENT
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
StepFunction_Turn:
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_AnonJumptable
|
2020-10-22 07:54:53 -07:00
|
|
|
.anon_dw
|
2015-12-17 12:14:51 -08:00
|
|
|
dw .init1
|
|
|
|
dw .step1
|
|
|
|
dw .init2
|
|
|
|
dw .step2
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2015-12-29 10:15:58 -08:00
|
|
|
.init1
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_WALKING
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], STANDING
|
2015-11-15 18:28:15 -08:00
|
|
|
ld hl, OBJECT_STEP_FRAME
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2023-10-28 09:57:18 -07:00
|
|
|
ld [hl], 4
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
2023-10-28 09:57:18 -07:00
|
|
|
ld [hl], 1
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_IncAnonJumptableIndex
|
2015-12-29 10:15:58 -08:00
|
|
|
.step1
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
|
|
|
dec [hl]
|
|
|
|
ret nz
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_IncAnonJumptableIndex
|
2015-12-29 10:15:58 -08:00
|
|
|
.init2
|
2017-12-29 07:19:51 -08:00
|
|
|
ld hl, OBJECT_1D ; new facing
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_DIRECTION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
2023-10-28 09:57:18 -07:00
|
|
|
ld [hl], 3
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_IncAnonJumptableIndex
|
2015-12-29 10:15:58 -08:00
|
|
|
.step2
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
|
|
|
dec [hl]
|
|
|
|
ret nz
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_STEP_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2020-10-22 14:41:48 -07:00
|
|
|
ld [hl], STEP_TYPE_FROM_MOVEMENT
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
StepFunction_StrengthBoulder:
|
2015-11-14 11:41:47 -08:00
|
|
|
call AddStepVector
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
|
|
|
dec [hl]
|
|
|
|
ret nz
|
|
|
|
push bc
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MAP_X
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld d, [hl]
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MAP_Y
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld e, [hl]
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_MAP_OBJECT_INDEX
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
ld b, a
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall CopyDECoordsToMapObject
|
2015-02-11 14:13:22 -08:00
|
|
|
pop bc
|
2015-10-29 20:32:11 -07:00
|
|
|
ld hl, OBJECT_FLAGS2
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2019-01-24 18:41:14 -08:00
|
|
|
res OBJ_FLAGS2_2, [hl]
|
2022-09-12 06:15:44 -07:00
|
|
|
call CopyCoordsTileToLastCoordsTile
|
|
|
|
ld hl, OBJECT_WALKING
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], STANDING
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_STEP_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2020-10-22 14:41:48 -07:00
|
|
|
ld [hl], STEP_TYPE_FROM_MOVEMENT
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
StepFunction_TrackingObject:
|
2017-12-29 07:19:51 -08:00
|
|
|
ld hl, OBJECT_1D
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld e, [hl]
|
|
|
|
inc hl
|
|
|
|
ld d, [hl]
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_SPRITE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
and a
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .nope
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_SPRITE_X
|
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
ld hl, OBJECT_SPRITE_X
|
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
ld hl, OBJECT_SPRITE_Y
|
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
ld hl, OBJECT_SPRITE_Y
|
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
dec [hl]
|
|
|
|
ret nz
|
2015-07-15 12:48:44 -07:00
|
|
|
.nope
|
2015-12-17 12:14:51 -08:00
|
|
|
jp DeleteMapObject
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
StepFunction_14:
|
|
|
|
StepFunction_ScreenShake:
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_AnonJumptable
|
2020-10-22 07:54:53 -07:00
|
|
|
.anon_dw
|
2015-12-29 10:15:58 -08:00
|
|
|
dw .Init
|
|
|
|
dw .Run
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Init:
|
2015-02-11 14:13:22 -08:00
|
|
|
xor a
|
2017-12-29 07:19:51 -08:00
|
|
|
ld hl, OBJECT_1D
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_IncAnonJumptableIndex
|
2016-04-10 11:42:14 -07:00
|
|
|
.Run:
|
2017-12-29 07:19:51 -08:00
|
|
|
ld hl, OBJECT_1D
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld d, [hl]
|
2015-11-14 20:02:38 -08:00
|
|
|
ld a, [wPlayerStepVectorY]
|
2015-02-11 14:13:22 -08:00
|
|
|
sub d
|
2015-11-14 20:02:38 -08:00
|
|
|
ld [wPlayerStepVectorY], a
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
|
|
|
dec [hl]
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .ok
|
2015-02-11 14:13:22 -08:00
|
|
|
ld a, [hl]
|
2015-12-29 10:15:58 -08:00
|
|
|
call .GetSign
|
2017-12-29 07:19:51 -08:00
|
|
|
ld hl, OBJECT_1D
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
ld d, a
|
2015-11-14 20:02:38 -08:00
|
|
|
ld a, [wPlayerStepVectorY]
|
2015-02-11 14:13:22 -08:00
|
|
|
add d
|
2015-11-14 20:02:38 -08:00
|
|
|
ld [wPlayerStepVectorY], a
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
.ok
|
2015-12-17 12:14:51 -08:00
|
|
|
call DeleteMapObject
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.GetSign:
|
2017-12-29 07:19:51 -08:00
|
|
|
ld hl, OBJECT_1E
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
and 1
|
|
|
|
ld a, [hl]
|
|
|
|
ret z
|
|
|
|
cpl
|
|
|
|
inc a
|
|
|
|
ret
|
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
StepFunction_16:
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_AnonJumptable
|
2020-11-17 08:09:02 -08:00
|
|
|
; jumptable was dummied out here
|
2020-10-22 14:41:48 -07:00
|
|
|
|
|
|
|
StepFunction_17:
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_AnonJumptable
|
2020-10-22 07:54:53 -07:00
|
|
|
.anon_dw
|
2015-12-29 10:15:58 -08:00
|
|
|
dw .null
|
|
|
|
dw .null
|
|
|
|
dw .null
|
|
|
|
.null
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
StepFunction_SkyfallTop:
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_AnonJumptable
|
2020-10-22 14:41:48 -07:00
|
|
|
.anon_dw
|
2015-12-29 10:15:58 -08:00
|
|
|
dw .Init
|
|
|
|
dw .Run
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Init:
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_ACTION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2017-12-24 10:46:34 -08:00
|
|
|
ld [hl], OBJECT_ACTION_SKYFALL
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
2015-11-14 20:02:38 -08:00
|
|
|
ld [hl], 16
|
2022-09-12 06:15:44 -07:00
|
|
|
call ObjectStep_IncAnonJumptableIndex
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2015-12-29 10:15:58 -08:00
|
|
|
.Run:
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
|
|
|
dec [hl]
|
|
|
|
ret nz
|
|
|
|
ld hl, OBJECT_SPRITE_Y_OFFSET
|
|
|
|
add hl, bc
|
|
|
|
ld [hl], $60
|
2015-11-15 18:28:15 -08:00
|
|
|
ld hl, OBJECT_STEP_FRAME
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], 0
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_STEP_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2020-10-22 14:41:48 -07:00
|
|
|
ld [hl], STEP_TYPE_FROM_MOVEMENT
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
Stubbed_UpdateYOffset:
|
|
|
|
; dummied out
|
2018-01-02 11:00:14 -08:00
|
|
|
ret
|
2017-12-29 07:19:51 -08:00
|
|
|
ld hl, OBJECT_1D
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
inc [hl]
|
|
|
|
ld a, [hl]
|
|
|
|
srl a
|
|
|
|
srl a
|
2015-07-15 12:48:44 -07:00
|
|
|
and %00000111
|
2015-02-11 14:13:22 -08:00
|
|
|
ld l, a
|
|
|
|
ld h, 0
|
2020-10-22 14:41:48 -07:00
|
|
|
ld de, .y_offsets
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
ld hl, OBJECT_SPRITE_Y_OFFSET
|
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
.y_offsets:
|
2015-02-11 14:13:22 -08:00
|
|
|
db 0, -1, -2, -3, -4, -3, -2, -1
|
2020-10-22 07:54:53 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
UpdateJumpPosition:
|
2015-02-11 14:13:22 -08:00
|
|
|
call GetStepVector
|
|
|
|
ld a, h
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_JUMP_HEIGHT
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld e, [hl]
|
|
|
|
add e
|
|
|
|
ld [hl], a
|
|
|
|
nop
|
|
|
|
srl e
|
|
|
|
ld d, 0
|
2020-10-22 14:41:48 -07:00
|
|
|
ld hl, .y_offsets
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
ld hl, OBJECT_SPRITE_Y_OFFSET
|
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
.y_offsets:
|
2015-02-11 14:13:22 -08:00
|
|
|
db -4, -6, -8, -10, -11, -12, -12, -12
|
|
|
|
db -11, -10, -9, -8, -6, -4, 0, 0
|
2018-12-09 15:13:37 -08:00
|
|
|
|
2022-09-12 06:15:44 -07:00
|
|
|
GetPlayerNextMovementIndex:
|
2015-12-29 10:15:58 -08:00
|
|
|
; copy [wPlayerNextMovement] to [wPlayerMovement]
|
|
|
|
ld a, [wPlayerNextMovement]
|
|
|
|
ld hl, wPlayerMovement
|
2015-02-11 14:13:22 -08:00
|
|
|
ld [hl], a
|
2016-05-14 09:28:00 -07:00
|
|
|
; load [wPlayerNextMovement] with movement_step_sleep
|
|
|
|
ld a, movement_step_sleep
|
2015-12-29 10:15:58 -08:00
|
|
|
ld [wPlayerNextMovement], a
|
|
|
|
; recover the previous value of [wPlayerNextMovement]
|
2015-02-11 14:13:22 -08:00
|
|
|
ld a, [hl]
|
|
|
|
ret
|
|
|
|
|
2022-09-12 06:15:44 -07:00
|
|
|
GetMovementIndex:
|
2019-04-19 08:35:27 -07:00
|
|
|
ld hl, wMovementDataBank
|
2022-09-12 06:15:44 -07:00
|
|
|
call _GetMovementIndex
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2022-09-12 06:15:44 -07:00
|
|
|
GetIndexedMovementIndex1:
|
|
|
|
ld hl, OBJECT_MOVEMENT_INDEX
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld e, [hl]
|
|
|
|
inc [hl]
|
|
|
|
ld d, 0
|
2020-06-17 19:12:04 -07:00
|
|
|
ld hl, wMovementObject
|
2015-02-11 14:13:22 -08:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
ret
|
|
|
|
|
2022-09-12 06:15:44 -07:00
|
|
|
GetIndexedMovementIndex2:
|
|
|
|
ld hl, OBJECT_MOVEMENT_INDEX
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld e, [hl]
|
|
|
|
inc [hl]
|
|
|
|
ld d, 0
|
2020-10-22 18:25:40 -07:00
|
|
|
ld hl, wIndexedMovement2Pointer
|
2015-02-11 14:13:22 -08:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
_GetMovementObject:
|
2017-12-24 10:46:34 -08:00
|
|
|
ld hl, GetMovementObject
|
2015-11-11 20:38:57 -08:00
|
|
|
jp HandleMovementData
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetMovementObject:
|
2017-12-24 10:46:34 -08:00
|
|
|
ld a, [wMovementObject]
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
HandleMovementData:
|
2015-12-29 10:15:58 -08:00
|
|
|
call .StorePointer
|
2015-07-15 12:48:44 -07:00
|
|
|
.loop
|
2015-02-11 14:13:22 -08:00
|
|
|
xor a
|
2022-09-12 06:15:44 -07:00
|
|
|
ld [wContinueReadingMovement], a
|
2015-12-29 10:15:58 -08:00
|
|
|
call JumpMovementPointer
|
2015-07-18 20:45:39 -07:00
|
|
|
call DoMovementFunction
|
2022-09-12 06:15:44 -07:00
|
|
|
ld a, [wContinueReadingMovement]
|
2015-02-11 14:13:22 -08:00
|
|
|
and a
|
2015-07-15 12:48:44 -07:00
|
|
|
jr nz, .loop
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.StorePointer:
|
2015-02-11 14:13:22 -08:00
|
|
|
ld a, l
|
2015-11-02 08:15:32 -08:00
|
|
|
ld [wMovementPointer], a
|
2015-02-11 14:13:22 -08:00
|
|
|
ld a, h
|
2015-11-02 08:15:32 -08:00
|
|
|
ld [wMovementPointer + 1], a
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
JumpMovementPointer:
|
2015-11-02 08:15:32 -08:00
|
|
|
ld hl, wMovementPointer
|
2015-02-11 14:13:22 -08:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2017-06-09 14:01:10 -07:00
|
|
|
jp hl
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ContinueReadingMovement:
|
2022-09-12 06:15:44 -07:00
|
|
|
ld a, TRUE
|
|
|
|
ld [wContinueReadingMovement], a
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
DoMovementFunction:
|
2015-02-11 14:13:22 -08:00
|
|
|
push af
|
2015-11-02 08:15:32 -08:00
|
|
|
call ApplyMovementToFollower
|
2015-02-11 14:13:22 -08:00
|
|
|
pop af
|
|
|
|
ld hl, MovementPointers
|
|
|
|
rst JumpTable
|
|
|
|
ret
|
|
|
|
|
2018-03-13 05:07:16 -07:00
|
|
|
INCLUDE "engine/overworld/movement.asm"
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ApplyMovementToFollower:
|
2015-02-11 14:13:22 -08:00
|
|
|
ld e, a
|
2015-11-02 08:15:32 -08:00
|
|
|
ld a, [wObjectFollow_Follower]
|
2015-07-15 12:48:44 -07:00
|
|
|
cp -1
|
2015-02-11 14:13:22 -08:00
|
|
|
ret z
|
2015-11-02 08:15:32 -08:00
|
|
|
ld a, [wObjectFollow_Leader]
|
2015-02-11 14:13:22 -08:00
|
|
|
ld d, a
|
2020-12-23 13:54:28 -08:00
|
|
|
ldh a, [hMapObjectIndex]
|
2015-02-11 14:13:22 -08:00
|
|
|
cp d
|
|
|
|
ret nz
|
|
|
|
ld a, e
|
2016-05-14 09:28:00 -07:00
|
|
|
cp movement_step_sleep
|
2015-02-11 14:13:22 -08:00
|
|
|
ret z
|
2015-12-29 10:15:58 -08:00
|
|
|
cp movement_step_end
|
2015-02-11 14:13:22 -08:00
|
|
|
ret z
|
2015-12-29 10:15:58 -08:00
|
|
|
cp movement_step_4b
|
2015-02-11 14:13:22 -08:00
|
|
|
ret z
|
2015-12-29 10:15:58 -08:00
|
|
|
cp movement_step_bump
|
2015-02-11 14:13:22 -08:00
|
|
|
ret z
|
2016-05-14 10:46:14 -07:00
|
|
|
cp movement_slow_step
|
2015-02-11 14:13:22 -08:00
|
|
|
ret c
|
|
|
|
push af
|
2015-12-29 10:15:58 -08:00
|
|
|
ld hl, wFollowerMovementQueueLength
|
2015-02-11 14:13:22 -08:00
|
|
|
inc [hl]
|
|
|
|
ld e, [hl]
|
|
|
|
ld d, 0
|
2015-12-29 10:15:58 -08:00
|
|
|
ld hl, wFollowMovementQueue
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, de
|
|
|
|
pop af
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2022-09-12 06:15:44 -07:00
|
|
|
GetFollowerNextMovementIndex:
|
2015-12-29 10:15:58 -08:00
|
|
|
ld hl, wFollowerMovementQueueLength
|
2015-02-11 14:13:22 -08:00
|
|
|
ld a, [hl]
|
|
|
|
and a
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .done
|
|
|
|
cp -1
|
|
|
|
jr z, .done
|
2015-02-11 14:13:22 -08:00
|
|
|
dec [hl]
|
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
2015-12-29 10:15:58 -08:00
|
|
|
ld hl, wFollowMovementQueue
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, de
|
|
|
|
inc e
|
2015-07-15 12:48:44 -07:00
|
|
|
ld a, -1
|
|
|
|
.loop
|
2015-02-11 14:13:22 -08:00
|
|
|
ld d, [hl]
|
|
|
|
ld [hld], a
|
|
|
|
ld a, d
|
|
|
|
dec e
|
2015-07-15 12:48:44 -07:00
|
|
|
jr nz, .loop
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
.done
|
2015-12-29 10:15:58 -08:00
|
|
|
call .CancelFollowIfLeaderMissing
|
2015-02-11 14:13:22 -08:00
|
|
|
ret c
|
2016-05-14 09:28:00 -07:00
|
|
|
ld a, movement_step_sleep
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.CancelFollowIfLeaderMissing:
|
2015-11-02 08:15:32 -08:00
|
|
|
ld a, [wObjectFollow_Leader]
|
2015-07-15 12:48:44 -07:00
|
|
|
cp -1
|
|
|
|
jr z, .nope
|
2015-02-11 14:13:22 -08:00
|
|
|
push bc
|
2015-07-15 12:48:44 -07:00
|
|
|
call GetObjectStruct
|
|
|
|
ld hl, OBJECT_SPRITE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
pop bc
|
|
|
|
and a
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .nope
|
2015-02-11 14:13:22 -08:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
.nope
|
2015-12-29 10:15:58 -08:00
|
|
|
ld a, -1
|
2015-11-02 08:15:32 -08:00
|
|
|
ld [wObjectFollow_Follower], a
|
2015-11-11 20:38:57 -08:00
|
|
|
ld a, movement_step_end
|
2015-02-11 14:13:22 -08:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SpawnShadow:
|
2015-02-11 14:13:22 -08:00
|
|
|
push bc
|
2015-11-14 11:41:47 -08:00
|
|
|
ld de, .ShadowObject
|
|
|
|
call CopyTempObjectData
|
|
|
|
call InitTempObject
|
2015-02-11 14:13:22 -08:00
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.ShadowObject:
|
2015-11-14 11:41:47 -08:00
|
|
|
; vtile, palette, movement
|
2023-11-05 02:07:32 -08:00
|
|
|
db $00, PAL_OW_GREY, SPRITEMOVEDATA_SHADOW
|
2018-01-18 12:58:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SpawnStrengthBoulderDust:
|
2015-02-11 14:13:22 -08:00
|
|
|
push bc
|
2015-11-14 11:41:47 -08:00
|
|
|
ld de, .BoulderDustObject
|
|
|
|
call CopyTempObjectData
|
|
|
|
call InitTempObject
|
2015-02-11 14:13:22 -08:00
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.BoulderDustObject:
|
2020-10-22 14:41:48 -07:00
|
|
|
; vtile, palette, movement
|
2023-11-05 02:07:32 -08:00
|
|
|
db $00, PAL_OW_GREY, SPRITEMOVEDATA_BOULDERDUST
|
2018-01-18 12:58:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SpawnEmote:
|
2015-02-11 14:13:22 -08:00
|
|
|
push bc
|
2015-11-14 11:41:47 -08:00
|
|
|
ld de, .EmoteObject
|
|
|
|
call CopyTempObjectData
|
|
|
|
call InitTempObject
|
2015-02-11 14:13:22 -08:00
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.EmoteObject:
|
2020-10-22 14:41:48 -07:00
|
|
|
; vtile, palette, movement
|
2023-11-05 02:07:32 -08:00
|
|
|
db $00, PAL_OW_GREY, SPRITEMOVEDATA_EMOTE
|
2018-01-18 12:58:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ShakeGrass:
|
2015-02-11 14:13:22 -08:00
|
|
|
push bc
|
2018-06-01 00:04:36 -07:00
|
|
|
ld de, .GrassObject
|
2015-11-14 11:41:47 -08:00
|
|
|
call CopyTempObjectData
|
|
|
|
call InitTempObject
|
2015-02-11 14:13:22 -08:00
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
.GrassObject:
|
|
|
|
; vtile, palette, movement
|
2015-11-14 11:41:47 -08:00
|
|
|
db $00, PAL_OW_TREE, SPRITEMOVEDATA_GRASS
|
2018-01-18 12:58:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ShakeScreen:
|
2015-02-11 14:13:22 -08:00
|
|
|
push bc
|
|
|
|
push af
|
2015-11-14 11:41:47 -08:00
|
|
|
ld de, .ScreenShakeObject
|
|
|
|
call CopyTempObjectData
|
2015-02-11 14:13:22 -08:00
|
|
|
pop af
|
2015-11-14 11:41:47 -08:00
|
|
|
ld [wTempObjectCopyRange], a
|
|
|
|
call InitTempObject
|
2015-02-11 14:13:22 -08:00
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.ScreenShakeObject:
|
2020-10-22 14:41:48 -07:00
|
|
|
; vtile, palette, movement
|
2023-11-05 02:07:32 -08:00
|
|
|
db $00, PAL_OW_GREY, SPRITEMOVEDATA_SCREENSHAKE
|
2018-06-01 00:04:36 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
DespawnEmote:
|
2015-02-11 14:13:22 -08:00
|
|
|
push bc
|
2020-12-23 13:54:28 -08:00
|
|
|
ldh a, [hMapObjectIndex]
|
2015-02-11 14:13:22 -08:00
|
|
|
ld c, a
|
2015-11-14 11:41:47 -08:00
|
|
|
call .DeleteEmote
|
2015-02-11 14:13:22 -08:00
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.DeleteEmote:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wObjectStructs
|
2015-07-26 00:11:33 -07:00
|
|
|
ld a, NUM_OBJECT_STRUCTS
|
2015-07-15 12:48:44 -07:00
|
|
|
.loop
|
2015-02-11 14:13:22 -08:00
|
|
|
push af
|
2015-10-29 20:32:11 -07:00
|
|
|
ld hl, OBJECT_FLAGS1
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, de
|
2018-05-23 10:15:07 -07:00
|
|
|
bit EMOTE_OBJECT_F, [hl]
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .next
|
|
|
|
ld hl, OBJECT_SPRITE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
and a
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .next
|
2015-02-11 14:13:22 -08:00
|
|
|
push bc
|
|
|
|
xor a
|
2019-11-03 09:25:59 -08:00
|
|
|
ld bc, OBJECT_LENGTH
|
2015-02-11 14:13:22 -08:00
|
|
|
call ByteFill
|
|
|
|
pop bc
|
2015-07-15 12:48:44 -07:00
|
|
|
.next
|
2019-11-03 09:25:59 -08:00
|
|
|
ld hl, OBJECT_LENGTH
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, de
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
pop af
|
|
|
|
dec a
|
2015-07-15 12:48:44 -07:00
|
|
|
jr nz, .loop
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
InitTempObject:
|
2015-10-31 18:05:02 -07:00
|
|
|
call FindFirstEmptyObjectStruct
|
2015-02-11 14:13:22 -08:00
|
|
|
ret nc
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall CopyTempObjectToObjectStruct
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CopyTempObjectData:
|
2015-11-14 11:41:47 -08:00
|
|
|
; load into wTempObjectCopy:
|
2020-12-23 13:54:28 -08:00
|
|
|
; -1, -1, [de], [de + 1], [de + 2], [hMapObjectIndex], [NextMapX], [NextMapY], -1
|
2015-11-14 11:41:47 -08:00
|
|
|
; This spawns the object at the same place as whichever object is loaded into bc.
|
|
|
|
ld hl, wTempObjectCopyMapObjectIndex
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], -1
|
2015-02-11 14:13:22 -08:00
|
|
|
inc hl
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], -1
|
2015-02-11 14:13:22 -08:00
|
|
|
inc hl
|
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
ld [hli], a
|
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
ld [hli], a
|
|
|
|
ld a, [de]
|
|
|
|
ld [hli], a
|
2020-12-23 13:54:28 -08:00
|
|
|
ldh a, [hMapObjectIndex]
|
2015-02-11 14:13:22 -08:00
|
|
|
ld [hli], a
|
|
|
|
push hl
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MAP_X
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld d, [hl]
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MAP_Y
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld e, [hl]
|
|
|
|
pop hl
|
|
|
|
ld [hl], d
|
|
|
|
inc hl
|
|
|
|
ld [hl], e
|
|
|
|
inc hl
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], -1
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 18:25:40 -07:00
|
|
|
UpdateAllObjectsFrozen::
|
2024-02-10 15:34:46 -08:00
|
|
|
ld a, [wStateFlags]
|
2015-02-11 14:13:22 -08:00
|
|
|
bit 0, a
|
|
|
|
ret z
|
2018-01-23 14:39:09 -08:00
|
|
|
ld bc, wObjectStructs
|
2015-02-11 14:13:22 -08:00
|
|
|
xor a
|
2015-07-15 12:48:44 -07:00
|
|
|
.loop
|
2020-12-23 13:54:28 -08:00
|
|
|
ldh [hMapObjectIndex], a
|
2016-05-04 19:34:09 -07:00
|
|
|
call DoesObjectHaveASprite
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .ok
|
2020-10-22 18:25:40 -07:00
|
|
|
call UpdateObjectFrozen
|
2015-07-15 12:48:44 -07:00
|
|
|
.ok
|
2019-11-03 09:25:59 -08:00
|
|
|
ld hl, OBJECT_LENGTH
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld b, h
|
|
|
|
ld c, l
|
2020-12-23 13:54:28 -08:00
|
|
|
ldh a, [hMapObjectIndex]
|
2015-02-11 14:13:22 -08:00
|
|
|
inc a
|
2015-07-15 12:48:44 -07:00
|
|
|
cp NUM_OBJECT_STRUCTS
|
|
|
|
jr nz, .loop
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 18:25:40 -07:00
|
|
|
RespawnPlayerAndOpponent:
|
2018-06-24 18:39:23 -07:00
|
|
|
; called at battle start
|
2020-10-22 18:25:40 -07:00
|
|
|
call HideAllObjects
|
2015-11-16 08:53:26 -08:00
|
|
|
ld a, PLAYER
|
2020-10-22 18:25:40 -07:00
|
|
|
call RespawnObject
|
2015-11-25 07:16:29 -08:00
|
|
|
ld a, [wBattleScriptFlags]
|
2015-02-11 14:13:22 -08:00
|
|
|
bit 7, a
|
2020-10-22 18:25:40 -07:00
|
|
|
jr z, .skip_opponent
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hLastTalked]
|
2015-02-11 14:13:22 -08:00
|
|
|
and a
|
2020-10-22 18:25:40 -07:00
|
|
|
jr z, .skip_opponent
|
|
|
|
call RespawnObject
|
|
|
|
.skip_opponent
|
2023-10-21 09:46:56 -07:00
|
|
|
call _UpdateActiveSprites
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 18:25:40 -07:00
|
|
|
RespawnPlayer:
|
|
|
|
call HideAllObjects
|
2015-11-16 08:53:26 -08:00
|
|
|
ld a, PLAYER
|
2020-10-22 18:25:40 -07:00
|
|
|
call RespawnObject
|
2023-10-21 09:46:56 -07:00
|
|
|
call _UpdateActiveSprites
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 18:25:40 -07:00
|
|
|
RespawnObject:
|
2015-07-26 00:11:33 -07:00
|
|
|
cp NUM_OBJECTS
|
2015-02-11 14:13:22 -08:00
|
|
|
ret nc
|
|
|
|
call GetMapObject
|
2015-07-18 12:46:38 -07:00
|
|
|
ld hl, MAPOBJECT_OBJECT_STRUCT_ID
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-07-19 01:58:31 -07:00
|
|
|
cp -1
|
2015-02-11 14:13:22 -08:00
|
|
|
ret z
|
2015-07-26 00:11:33 -07:00
|
|
|
cp NUM_OBJECT_STRUCTS
|
2015-02-11 14:13:22 -08:00
|
|
|
ret nc
|
2015-07-15 12:48:44 -07:00
|
|
|
call GetObjectStruct
|
2016-05-04 19:34:09 -07:00
|
|
|
call DoesObjectHaveASprite
|
2015-02-11 14:13:22 -08:00
|
|
|
ret z
|
2020-10-22 18:25:40 -07:00
|
|
|
call UpdateRespawnedObjectFrozen
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 18:25:40 -07:00
|
|
|
HideAllObjects:
|
2015-02-11 14:13:22 -08:00
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld bc, wObjectStructs
|
2015-07-15 12:48:44 -07:00
|
|
|
.loop
|
2020-12-23 13:54:28 -08:00
|
|
|
ldh [hMapObjectIndex], a
|
2015-11-16 08:53:26 -08:00
|
|
|
call SetFacing_Standing
|
2019-11-03 09:25:59 -08:00
|
|
|
ld hl, OBJECT_LENGTH
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld b, h
|
|
|
|
ld c, l
|
2020-12-23 13:54:28 -08:00
|
|
|
ldh a, [hMapObjectIndex]
|
2015-02-11 14:13:22 -08:00
|
|
|
inc a
|
2015-07-15 12:48:44 -07:00
|
|
|
cp NUM_OBJECT_STRUCTS
|
|
|
|
jr nz, .loop
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 18:25:40 -07:00
|
|
|
UpdateObjectFrozen:
|
2015-02-11 14:13:22 -08:00
|
|
|
push bc
|
2020-10-22 18:25:40 -07:00
|
|
|
call CheckObjectCoveredByTextbox
|
2015-02-11 14:13:22 -08:00
|
|
|
pop bc
|
2015-11-16 08:53:26 -08:00
|
|
|
jr c, SetFacing_Standing
|
2020-10-22 18:25:40 -07:00
|
|
|
call CheckObjectOnScreen
|
2015-11-16 08:53:26 -08:00
|
|
|
jr c, SetFacing_Standing
|
2022-09-12 06:15:44 -07:00
|
|
|
call UpdateObjectTile
|
2023-08-31 09:41:05 -07:00
|
|
|
call HandleFrozenObjectAction
|
2015-02-11 14:13:22 -08:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2020-10-22 18:25:40 -07:00
|
|
|
UpdateRespawnedObjectFrozen:
|
|
|
|
call CheckObjectOnScreen
|
2015-11-16 08:53:26 -08:00
|
|
|
jr c, SetFacing_Standing
|
2023-08-31 09:41:05 -07:00
|
|
|
call HandleFrozenObjectAction
|
2015-02-11 14:13:22 -08:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SetFacing_Standing:
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_FACING
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], STANDING
|
2015-02-11 14:13:22 -08:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2022-09-12 06:15:44 -07:00
|
|
|
UpdateObjectTile:
|
2015-02-11 14:13:22 -08:00
|
|
|
push bc
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MAP_X
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld d, [hl]
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MAP_Y
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld e, [hl]
|
2024-02-10 15:25:25 -08:00
|
|
|
call GetCoordTileCollision
|
2015-02-11 14:13:22 -08:00
|
|
|
pop bc
|
2024-02-10 15:25:25 -08:00
|
|
|
ld hl, OBJECT_TILE_COLLISION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
2023-08-31 09:41:05 -07:00
|
|
|
call UpdateTallGrassFlags
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 18:25:40 -07:00
|
|
|
CheckObjectOnScreen:
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MAP_X
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld d, [hl]
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MAP_Y
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld e, [hl]
|
|
|
|
inc d
|
|
|
|
inc e
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wXCoord]
|
2015-02-11 14:13:22 -08:00
|
|
|
cp d
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .equal_x
|
|
|
|
jr nc, .nope
|
2018-01-18 12:58:55 -08:00
|
|
|
add MAPOBJECT_SCREEN_WIDTH - 1
|
2015-02-11 14:13:22 -08:00
|
|
|
cp d
|
2015-07-15 12:48:44 -07:00
|
|
|
jr c, .nope
|
|
|
|
.equal_x
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wYCoord]
|
2015-02-11 14:13:22 -08:00
|
|
|
cp e
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .equal_y
|
|
|
|
jr nc, .nope
|
2018-01-18 12:58:55 -08:00
|
|
|
add MAPOBJECT_SCREEN_HEIGHT - 1
|
2015-02-11 14:13:22 -08:00
|
|
|
cp e
|
2015-07-15 12:48:44 -07:00
|
|
|
jr c, .nope
|
|
|
|
.equal_y
|
2015-02-11 14:13:22 -08:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
.nope
|
2015-02-11 14:13:22 -08:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2020-10-22 18:25:40 -07:00
|
|
|
CheckObjectCoveredByTextbox:
|
|
|
|
; Check whether the object fits in the screen width.
|
2016-05-04 19:34:09 -07:00
|
|
|
ld a, [wPlayerBGMapOffsetX]
|
2015-02-11 14:13:22 -08:00
|
|
|
ld d, a
|
|
|
|
ld hl, OBJECT_SPRITE_X_OFFSET
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
ld hl, OBJECT_SPRITE_X
|
|
|
|
add hl, bc
|
|
|
|
add [hl]
|
|
|
|
add d
|
|
|
|
cp $f0
|
2015-07-15 12:48:44 -07:00
|
|
|
jr nc, .ok1
|
2020-10-22 18:25:40 -07:00
|
|
|
cp SCREEN_WIDTH_PX
|
2023-08-31 09:41:05 -07:00
|
|
|
jp nc, .disappear
|
2015-07-15 12:48:44 -07:00
|
|
|
.ok1
|
2020-10-22 18:25:40 -07:00
|
|
|
; Account for objects currently moving left/right.
|
2015-07-15 12:48:44 -07:00
|
|
|
and %00000111
|
|
|
|
ld d, 2
|
2020-10-22 18:25:40 -07:00
|
|
|
cp TILE_WIDTH / 2
|
2015-07-15 12:48:44 -07:00
|
|
|
jr c, .ok2
|
|
|
|
ld d, 3
|
|
|
|
.ok2
|
2020-10-22 18:25:40 -07:00
|
|
|
; Convert pixels to tiles.
|
2015-02-11 14:13:22 -08:00
|
|
|
ld a, [hl]
|
|
|
|
srl a
|
|
|
|
srl a
|
|
|
|
srl a
|
2015-11-09 20:01:45 -08:00
|
|
|
cp SCREEN_WIDTH
|
2015-07-15 12:48:44 -07:00
|
|
|
jr c, .ok3
|
2018-01-18 12:58:55 -08:00
|
|
|
sub BG_MAP_WIDTH
|
2015-07-15 12:48:44 -07:00
|
|
|
.ok3
|
2020-04-18 14:31:51 -07:00
|
|
|
ldh [hCurSpriteXCoord], a
|
2020-10-22 18:25:40 -07:00
|
|
|
|
|
|
|
; Check whether the object fits in the screen height.
|
2016-05-04 19:34:09 -07:00
|
|
|
ld a, [wPlayerBGMapOffsetY]
|
2015-02-11 14:13:22 -08:00
|
|
|
ld e, a
|
|
|
|
ld hl, OBJECT_SPRITE_Y_OFFSET
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
ld hl, OBJECT_SPRITE_Y
|
|
|
|
add hl, bc
|
|
|
|
add [hl]
|
|
|
|
add e
|
|
|
|
cp $f0
|
2015-07-15 12:48:44 -07:00
|
|
|
jr nc, .ok4
|
2020-10-22 18:25:40 -07:00
|
|
|
cp SCREEN_HEIGHT_PX
|
2023-08-31 09:41:05 -07:00
|
|
|
jr nc, .disappear
|
2015-07-15 12:48:44 -07:00
|
|
|
.ok4
|
2020-10-22 18:25:40 -07:00
|
|
|
; Account for objects currently moving up/down.
|
2015-07-15 12:48:44 -07:00
|
|
|
and %00000111
|
|
|
|
ld e, 2
|
2020-10-22 18:25:40 -07:00
|
|
|
cp TILE_WIDTH / 2
|
2015-07-15 12:48:44 -07:00
|
|
|
jr c, .ok5
|
|
|
|
ld e, 3
|
|
|
|
.ok5
|
2020-10-22 18:25:40 -07:00
|
|
|
; Convert pixels to tiles.
|
2015-02-11 14:13:22 -08:00
|
|
|
ld a, [hl]
|
|
|
|
srl a
|
|
|
|
srl a
|
|
|
|
srl a
|
2018-01-18 12:58:55 -08:00
|
|
|
cp SCREEN_HEIGHT
|
2015-07-15 12:48:44 -07:00
|
|
|
jr c, .ok6
|
2018-01-18 12:58:55 -08:00
|
|
|
sub BG_MAP_HEIGHT
|
2015-07-15 12:48:44 -07:00
|
|
|
.ok6
|
2020-04-18 14:31:51 -07:00
|
|
|
ldh [hCurSpriteYCoord], a
|
2020-10-22 18:25:40 -07:00
|
|
|
|
|
|
|
; Account for big objects that are twice as wide and high.
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_PALETTE
|
|
|
|
add hl, bc
|
2018-05-23 16:06:04 -07:00
|
|
|
bit BIG_OBJECT_F, [hl]
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .ok7
|
2015-02-11 14:13:22 -08:00
|
|
|
ld a, d
|
2015-07-15 12:48:44 -07:00
|
|
|
add 2
|
2015-02-11 14:13:22 -08:00
|
|
|
ld d, a
|
|
|
|
ld a, e
|
2015-07-15 12:48:44 -07:00
|
|
|
add 2
|
2015-02-11 14:13:22 -08:00
|
|
|
ld e, a
|
2015-07-15 12:48:44 -07:00
|
|
|
.ok7
|
2015-02-11 14:13:22 -08:00
|
|
|
ld a, d
|
2020-04-18 14:31:51 -07:00
|
|
|
ldh [hCurSpriteXPixel], a
|
2020-10-22 18:25:40 -07:00
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
.loop
|
2020-04-18 14:31:51 -07:00
|
|
|
ldh a, [hCurSpriteXPixel]
|
2015-02-11 14:13:22 -08:00
|
|
|
ld d, a
|
2020-04-18 14:31:51 -07:00
|
|
|
ldh a, [hCurSpriteYCoord]
|
2015-02-11 14:13:22 -08:00
|
|
|
add e
|
|
|
|
dec a
|
|
|
|
ld b, a
|
2015-07-15 12:48:44 -07:00
|
|
|
.next
|
2020-04-18 14:31:51 -07:00
|
|
|
ldh a, [hCurSpriteXCoord]
|
2015-02-11 14:13:22 -08:00
|
|
|
add d
|
|
|
|
dec a
|
|
|
|
ld c, a
|
|
|
|
push bc
|
2023-10-31 08:02:37 -07:00
|
|
|
call ScrollAwareCoord2Tile
|
2015-02-11 14:13:22 -08:00
|
|
|
pop bc
|
2023-08-31 09:41:05 -07:00
|
|
|
; NPCs disappear if standing on tiles FIRST_REGULAR_TEXT_CHAR or above,
|
2018-01-18 15:34:20 -08:00
|
|
|
; since those IDs are for text characters and textbox frames.
|
2023-08-31 09:41:05 -07:00
|
|
|
; - if 1bpp text, a single textbox tile overlapping with the sprite makes it disappear.
|
|
|
|
; - if 2bpp text, sprite only disappears if ALL overlapping tiles are textbox tiles.
|
2015-02-11 14:13:22 -08:00
|
|
|
ld a, [hl]
|
2018-01-18 15:34:20 -08:00
|
|
|
cp FIRST_REGULAR_TEXT_CHAR
|
2023-08-31 09:41:05 -07:00
|
|
|
jr c, .object_not_in_textbox
|
|
|
|
|
|
|
|
;.object_in_textbox
|
2023-09-30 15:10:44 -07:00
|
|
|
ld a, [wText2bpp]
|
|
|
|
and a
|
2023-08-31 09:41:05 -07:00
|
|
|
jr z, .disappear
|
|
|
|
jr .ok8
|
|
|
|
|
|
|
|
.object_not_in_textbox
|
2023-09-30 15:10:44 -07:00
|
|
|
ld a, [wText2bpp]
|
|
|
|
and a
|
2023-08-31 09:41:05 -07:00
|
|
|
jr nz, .not_disappear
|
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
.ok8
|
2015-02-11 14:13:22 -08:00
|
|
|
dec d
|
2015-07-15 12:48:44 -07:00
|
|
|
jr nz, .next
|
|
|
|
.ok9
|
2023-08-31 09:41:05 -07:00
|
|
|
; while sprites are centered to tiles in the X axis exactly on top of two adjacent horizonal tiles,
|
|
|
|
; in the Y axis they occupy 4-8-4 pixels of adjacent vertical tiles instead.
|
|
|
|
; this is why we loop here one more time (thrice for regular-sized sprites) than horizontally.
|
2015-02-11 14:13:22 -08:00
|
|
|
dec e
|
2023-08-31 09:41:05 -07:00
|
|
|
ld a, e
|
|
|
|
cp $ff
|
2015-07-15 12:48:44 -07:00
|
|
|
jr nz, .loop
|
2020-10-22 18:25:40 -07:00
|
|
|
|
2023-08-31 09:41:05 -07:00
|
|
|
; if we managed make it here without returning early, there are only two options:
|
|
|
|
; - if 1bpp text, the sprite is wholly outside of a textbox
|
|
|
|
; - if 2bpp text, the sprite is wholly inside a textbox
|
2023-09-30 15:10:44 -07:00
|
|
|
ld a, [wText2bpp]
|
|
|
|
and a
|
2023-08-31 09:41:05 -07:00
|
|
|
jr z, .not_disappear
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2023-08-31 09:41:05 -07:00
|
|
|
.disappear
|
2015-02-11 14:13:22 -08:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2023-08-31 09:41:05 -07:00
|
|
|
.not_disappear
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
HandleNPCStep::
|
2020-10-22 18:25:40 -07:00
|
|
|
call ResetStepVector
|
|
|
|
call DoStepsForAllObjects
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 18:25:40 -07:00
|
|
|
ResetStepVector:
|
2015-02-11 14:13:22 -08:00
|
|
|
xor a
|
2015-11-14 20:02:38 -08:00
|
|
|
ld [wPlayerStepVectorX], a
|
|
|
|
ld [wPlayerStepVectorY], a
|
|
|
|
ld [wPlayerStepFlags], a
|
2019-01-24 18:41:14 -08:00
|
|
|
ld a, STANDING
|
2015-11-14 20:02:38 -08:00
|
|
|
ld [wPlayerStepDirection], a
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 18:25:40 -07:00
|
|
|
DoStepsForAllObjects:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld bc, wObjectStructs
|
2015-02-11 14:13:22 -08:00
|
|
|
xor a
|
2015-07-15 12:48:44 -07:00
|
|
|
.loop
|
2020-12-23 13:54:28 -08:00
|
|
|
ldh [hMapObjectIndex], a
|
2016-05-04 19:34:09 -07:00
|
|
|
call DoesObjectHaveASprite
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .next
|
2020-10-05 13:15:57 -07:00
|
|
|
call HandleObjectStep
|
2015-07-15 12:48:44 -07:00
|
|
|
.next
|
2019-11-03 09:25:59 -08:00
|
|
|
ld hl, OBJECT_LENGTH
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld b, h
|
|
|
|
ld c, l
|
2020-12-23 13:54:28 -08:00
|
|
|
ldh a, [hMapObjectIndex]
|
2015-02-11 14:13:22 -08:00
|
|
|
inc a
|
2015-07-15 12:48:44 -07:00
|
|
|
cp NUM_OBJECT_STRUCTS
|
|
|
|
jr nz, .loop
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
RefreshPlayerSprite:
|
2016-05-14 09:28:00 -07:00
|
|
|
ld a, movement_step_sleep
|
2015-12-29 10:15:58 -08:00
|
|
|
ld [wPlayerNextMovement], a
|
|
|
|
ld [wPlayerMovement], a
|
2015-02-11 14:13:22 -08:00
|
|
|
xor a
|
2016-05-14 10:46:14 -07:00
|
|
|
ld [wPlayerTurningDirection], a
|
2022-09-12 06:15:44 -07:00
|
|
|
ld [wPlayerStepFrame], a
|
2020-10-22 18:25:40 -07:00
|
|
|
call TryResetPlayerAction
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall CheckWarpFacingDown
|
2015-07-20 00:51:52 -07:00
|
|
|
call c, SpawnInFacingDown
|
2020-10-22 18:25:40 -07:00
|
|
|
call SpawnInCustomFacing
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 18:25:40 -07:00
|
|
|
TryResetPlayerAction:
|
2015-10-24 07:34:19 -07:00
|
|
|
ld hl, wPlayerSpriteSetupFlags
|
2018-01-22 11:34:55 -08:00
|
|
|
bit PLAYERSPRITESETUP_RESET_ACTION_F, [hl]
|
2015-07-15 12:48:44 -07:00
|
|
|
jr nz, .ok
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
.ok
|
2017-12-24 10:46:34 -08:00
|
|
|
ld a, OBJECT_ACTION_00
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wPlayerAction], a
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 18:25:40 -07:00
|
|
|
SpawnInCustomFacing:
|
2015-10-24 07:34:19 -07:00
|
|
|
ld hl, wPlayerSpriteSetupFlags
|
2018-01-22 11:34:55 -08:00
|
|
|
bit PLAYERSPRITESETUP_CUSTOM_FACING_F, [hl]
|
2015-02-11 14:13:22 -08:00
|
|
|
ret z
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [wPlayerSpriteSetupFlags]
|
2018-01-22 11:34:55 -08:00
|
|
|
and PLAYERSPRITESETUP_FACING_MASK
|
2015-02-11 14:13:22 -08:00
|
|
|
add a
|
2015-12-26 18:59:03 -08:00
|
|
|
add a
|
2020-10-22 18:25:40 -07:00
|
|
|
jr _ContinueSpawnFacing
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SpawnInFacingDown:
|
2019-08-21 05:43:21 -07:00
|
|
|
ld a, DOWN
|
2020-10-22 18:25:40 -07:00
|
|
|
_ContinueSpawnFacing:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld bc, wPlayerStruct
|
2015-07-15 12:48:44 -07:00
|
|
|
call SetSpriteDirection
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
_SetPlayerPalette:
|
2015-02-11 14:13:22 -08:00
|
|
|
ld a, d
|
2018-05-23 19:13:46 -07:00
|
|
|
and 1 << 7
|
2015-02-11 14:13:22 -08:00
|
|
|
ret z
|
2015-11-02 11:37:02 -08:00
|
|
|
ld bc, 0 ; debug?
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_DIRECTION
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
or d
|
|
|
|
ld [hl], a
|
|
|
|
ld a, d
|
|
|
|
swap a
|
2018-05-23 19:13:46 -07:00
|
|
|
and PALETTE_MASK
|
2015-02-11 14:13:22 -08:00
|
|
|
ld d, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld bc, wPlayerStruct
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_PALETTE
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2021-11-23 17:37:18 -08:00
|
|
|
and ~PALETTE_MASK
|
2015-02-11 14:13:22 -08:00
|
|
|
or d
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
StartFollow::
|
2015-02-11 14:13:22 -08:00
|
|
|
push bc
|
|
|
|
ld a, b
|
2015-11-02 08:15:32 -08:00
|
|
|
call SetLeaderIfVisible
|
2015-02-11 14:13:22 -08:00
|
|
|
pop bc
|
|
|
|
ret c
|
|
|
|
ld a, c
|
2015-11-02 08:15:32 -08:00
|
|
|
call SetFollowerIfVisible
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall QueueFollowerFirstStep
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SetLeaderIfVisible:
|
2015-11-02 08:15:32 -08:00
|
|
|
call CheckObjectVisibility
|
2015-02-11 14:13:22 -08:00
|
|
|
ret c
|
2020-12-23 13:54:28 -08:00
|
|
|
ldh a, [hObjectStructIndex]
|
2015-11-02 08:15:32 -08:00
|
|
|
ld [wObjectFollow_Leader], a
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
StopFollow::
|
2015-11-02 08:15:32 -08:00
|
|
|
call ResetLeader
|
|
|
|
call ResetFollower
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ResetLeader:
|
2015-07-15 12:48:44 -07:00
|
|
|
ld a, -1
|
2015-11-02 08:15:32 -08:00
|
|
|
ld [wObjectFollow_Leader], a
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SetFollowerIfVisible:
|
2015-02-11 14:13:22 -08:00
|
|
|
push af
|
2015-11-02 08:15:32 -08:00
|
|
|
call ResetFollower
|
2015-02-11 14:13:22 -08:00
|
|
|
pop af
|
2015-11-02 08:15:32 -08:00
|
|
|
call CheckObjectVisibility
|
2015-02-11 14:13:22 -08:00
|
|
|
ret c
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MOVEMENT_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2015-11-06 13:42:38 -08:00
|
|
|
ld [hl], SPRITEMOVEDATA_FOLLOWING
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_STEP_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2020-10-22 14:41:48 -07:00
|
|
|
ld [hl], STEP_TYPE_RESET
|
2020-12-23 13:54:28 -08:00
|
|
|
ldh a, [hObjectStructIndex]
|
2015-11-02 08:15:32 -08:00
|
|
|
ld [wObjectFollow_Follower], a
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ResetFollower:
|
2015-11-02 08:15:32 -08:00
|
|
|
ld a, [wObjectFollow_Follower]
|
2015-07-15 12:48:44 -07:00
|
|
|
cp -1
|
2015-02-11 14:13:22 -08:00
|
|
|
ret z
|
2015-07-15 12:48:44 -07:00
|
|
|
call GetObjectStruct
|
2023-08-31 09:41:05 -07:00
|
|
|
call ResetObject
|
2015-07-15 12:48:44 -07:00
|
|
|
ld a, -1
|
2015-11-02 08:15:32 -08:00
|
|
|
ld [wObjectFollow_Follower], a
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 18:25:40 -07:00
|
|
|
FreezeAllOtherObjects::
|
2015-02-11 14:13:22 -08:00
|
|
|
ld a, c
|
2015-11-02 08:15:32 -08:00
|
|
|
call CheckObjectVisibility
|
2015-02-11 14:13:22 -08:00
|
|
|
ret c
|
|
|
|
push bc
|
2020-10-22 18:25:40 -07:00
|
|
|
call FreezeAllObjects
|
2015-02-11 14:13:22 -08:00
|
|
|
pop bc
|
2015-10-29 20:32:11 -07:00
|
|
|
ld hl, OBJECT_FLAGS2
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2020-10-22 18:25:40 -07:00
|
|
|
res FROZEN_F, [hl]
|
2015-02-11 14:13:22 -08:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2020-10-22 18:25:40 -07:00
|
|
|
FreezeObject: ; unreferenced
|
2015-11-02 08:15:32 -08:00
|
|
|
call CheckObjectVisibility
|
2015-02-11 14:13:22 -08:00
|
|
|
ret c
|
2015-10-29 20:32:11 -07:00
|
|
|
ld hl, OBJECT_FLAGS2
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2020-10-22 18:25:40 -07:00
|
|
|
set FROZEN_F, [hl]
|
2015-02-11 14:13:22 -08:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2020-10-22 18:25:40 -07:00
|
|
|
FreezeAllObjects:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld bc, wObjectStructs
|
2015-02-11 14:13:22 -08:00
|
|
|
xor a
|
2015-07-15 12:48:44 -07:00
|
|
|
.loop
|
2015-02-11 14:13:22 -08:00
|
|
|
push af
|
2016-05-04 19:34:09 -07:00
|
|
|
call DoesObjectHaveASprite
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .next
|
2015-10-29 20:32:11 -07:00
|
|
|
ld hl, OBJECT_FLAGS2
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2020-10-22 18:25:40 -07:00
|
|
|
set FROZEN_F, [hl]
|
2015-07-15 12:48:44 -07:00
|
|
|
.next
|
2019-11-03 09:25:59 -08:00
|
|
|
ld hl, OBJECT_LENGTH
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld b, h
|
|
|
|
ld c, l
|
|
|
|
pop af
|
|
|
|
inc a
|
2015-07-15 12:48:44 -07:00
|
|
|
cp NUM_OBJECT_STRUCTS
|
|
|
|
jr nz, .loop
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 18:25:40 -07:00
|
|
|
_UnfreezeFollowerObject::
|
2015-11-02 08:15:32 -08:00
|
|
|
ld a, [wObjectFollow_Leader]
|
2015-07-15 12:48:44 -07:00
|
|
|
cp -1
|
2015-02-11 14:13:22 -08:00
|
|
|
ret z
|
|
|
|
push bc
|
2015-07-15 12:48:44 -07:00
|
|
|
call GetObjectStruct
|
|
|
|
ld hl, OBJECT_MAP_OBJECT_INDEX
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
pop bc
|
|
|
|
cp c
|
|
|
|
ret nz
|
2015-11-02 08:15:32 -08:00
|
|
|
ld a, [wObjectFollow_Follower]
|
2015-07-15 12:48:44 -07:00
|
|
|
cp -1
|
2015-02-11 14:13:22 -08:00
|
|
|
ret z
|
2015-07-15 12:48:44 -07:00
|
|
|
call GetObjectStruct
|
2015-10-29 20:32:11 -07:00
|
|
|
ld hl, OBJECT_FLAGS2
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2020-10-22 18:25:40 -07:00
|
|
|
res FROZEN_F, [hl]
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 18:25:40 -07:00
|
|
|
UnfreezeAllObjects::
|
2015-02-11 14:13:22 -08:00
|
|
|
push bc
|
2018-01-23 14:39:09 -08:00
|
|
|
ld bc, wObjectStructs
|
2015-02-11 14:13:22 -08:00
|
|
|
xor a
|
2015-07-15 12:48:44 -07:00
|
|
|
.loop
|
2015-02-11 14:13:22 -08:00
|
|
|
push af
|
2016-05-04 19:34:09 -07:00
|
|
|
call DoesObjectHaveASprite
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .next
|
2015-10-29 20:32:11 -07:00
|
|
|
ld hl, OBJECT_FLAGS2
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2020-10-22 18:25:40 -07:00
|
|
|
res FROZEN_F, [hl]
|
2015-07-15 12:48:44 -07:00
|
|
|
.next
|
2019-11-03 09:25:59 -08:00
|
|
|
ld hl, OBJECT_LENGTH
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld b, h
|
|
|
|
ld c, l
|
|
|
|
pop af
|
|
|
|
inc a
|
2015-07-15 12:48:44 -07:00
|
|
|
cp NUM_OBJECT_STRUCTS
|
|
|
|
jr nz, .loop
|
2015-02-11 14:13:22 -08:00
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
|
2020-10-22 18:25:40 -07:00
|
|
|
UnfreezeObject: ; unreferenced
|
2015-11-02 08:15:32 -08:00
|
|
|
call CheckObjectVisibility
|
2015-02-11 14:13:22 -08:00
|
|
|
ret c
|
2015-10-29 20:32:11 -07:00
|
|
|
ld hl, OBJECT_FLAGS2
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2020-10-22 18:25:40 -07:00
|
|
|
res FROZEN_F, [hl]
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 18:25:40 -07:00
|
|
|
ResetObject:
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_MAP_OBJECT_INDEX
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-07-15 12:48:44 -07:00
|
|
|
cp -1
|
2022-07-09 14:12:02 -07:00
|
|
|
jp z, .set_standing
|
2015-02-11 14:13:22 -08:00
|
|
|
push bc
|
|
|
|
call GetMapObject
|
2015-07-29 15:22:23 -07:00
|
|
|
ld hl, MAPOBJECT_MOVEMENT
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
pop bc
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MOVEMENT_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_STEP_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2020-10-22 14:41:48 -07:00
|
|
|
ld [hl], STEP_TYPE_RESET
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 18:25:40 -07:00
|
|
|
.set_standing:
|
2015-02-11 14:13:22 -08:00
|
|
|
call GetSpriteDirection
|
|
|
|
rrca
|
|
|
|
rrca
|
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
2015-10-31 18:05:02 -07:00
|
|
|
ld hl, .standing_movefns
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MOVEMENT_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_STEP_TYPE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2020-10-22 14:41:48 -07:00
|
|
|
ld [hl], STEP_TYPE_RESET
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
.standing_movefns:
|
2015-10-31 18:05:02 -07:00
|
|
|
db SPRITEMOVEDATA_STANDING_DOWN
|
|
|
|
db SPRITEMOVEDATA_STANDING_UP
|
|
|
|
db SPRITEMOVEDATA_STANDING_LEFT
|
|
|
|
db SPRITEMOVEDATA_STANDING_RIGHT
|
2018-01-10 10:47:57 -08:00
|
|
|
|
2023-12-28 10:53:34 -08:00
|
|
|
; Used to make the last talked object remain hidden.
|
|
|
|
; This is done by setting its event flag to special value ALWAYS_HIDDEN.
|
|
|
|
; Otherwise when data is read from wMapObjectsBackups after entering the map,
|
|
|
|
; it would appear by default even if it had been made disappear.
|
|
|
|
SetObjectToRemainHidden:
|
|
|
|
ldh a, [hLastTalked]
|
|
|
|
call GetMapObject
|
|
|
|
ld hl, MAPOBJECT_EVENT_FLAG
|
|
|
|
add hl, bc
|
|
|
|
ld de, ALWAYS_HIDDEN
|
|
|
|
ld [hl], e
|
|
|
|
inc hl
|
|
|
|
ld [hl], d
|
|
|
|
ret
|
|
|
|
|
2023-10-21 09:46:56 -07:00
|
|
|
_UpdateActiveSpritesAfterOffset::
|
2024-02-10 15:34:46 -08:00
|
|
|
ld a, [wStateFlags]
|
2023-09-26 11:09:13 -07:00
|
|
|
bit 0, a
|
|
|
|
ret z
|
2023-10-21 09:46:56 -07:00
|
|
|
jr _UpdateActiveSprites.go
|
2023-09-26 11:09:13 -07:00
|
|
|
|
2023-10-21 09:46:56 -07:00
|
|
|
_UpdateActiveSprites::
|
2024-02-10 15:34:46 -08:00
|
|
|
ld a, [wStateFlags]
|
2015-02-11 14:13:22 -08:00
|
|
|
bit 0, a
|
|
|
|
ret z
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hUsedSpriteIndex], a
|
2023-09-26 11:09:13 -07:00
|
|
|
.go
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hOAMUpdate]
|
2015-02-11 14:13:22 -08:00
|
|
|
push af
|
2015-07-15 12:48:44 -07:00
|
|
|
ld a, 1
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hOAMUpdate], a
|
2015-11-15 18:28:15 -08:00
|
|
|
call InitSprites
|
|
|
|
call .fill
|
2015-02-11 14:13:22 -08:00
|
|
|
pop af
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hOAMUpdate], a
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2015-12-29 10:15:58 -08:00
|
|
|
.fill
|
2024-02-10 15:34:46 -08:00
|
|
|
ld a, [wStateFlags]
|
2015-02-11 14:13:22 -08:00
|
|
|
bit 1, a
|
2021-03-24 07:24:52 -07:00
|
|
|
ld b, NUM_SPRITE_OAM_STRUCTS * SPRITEOAMSTRUCT_LENGTH
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .ok
|
2021-03-24 07:24:52 -07:00
|
|
|
ld b, (NUM_SPRITE_OAM_STRUCTS - 12) * SPRITEOAMSTRUCT_LENGTH
|
2015-07-15 12:48:44 -07:00
|
|
|
.ok
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hUsedSpriteIndex]
|
2015-02-11 14:13:22 -08:00
|
|
|
cp b
|
|
|
|
ret nc
|
|
|
|
ld l, a
|
2022-07-09 14:18:22 -07:00
|
|
|
ld h, HIGH(wShadowOAM)
|
2018-01-10 10:47:57 -08:00
|
|
|
ld de, SPRITEOAMSTRUCT_LENGTH
|
2015-02-11 14:13:22 -08:00
|
|
|
ld a, b
|
2018-01-10 10:47:57 -08:00
|
|
|
ld c, SCREEN_HEIGHT_PX + 2 * TILE_WIDTH
|
2015-07-15 12:48:44 -07:00
|
|
|
.loop
|
2018-01-10 10:47:57 -08:00
|
|
|
ld [hl], c ; y
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, de
|
|
|
|
cp l
|
2015-07-15 12:48:44 -07:00
|
|
|
jr nz, .loop
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ApplyBGMapAnchorToObjects:
|
2015-02-11 14:13:22 -08:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2016-05-04 19:34:09 -07:00
|
|
|
ld a, [wPlayerBGMapOffsetX]
|
2015-02-11 14:13:22 -08:00
|
|
|
ld d, a
|
2016-05-04 19:34:09 -07:00
|
|
|
ld a, [wPlayerBGMapOffsetY]
|
2015-02-11 14:13:22 -08:00
|
|
|
ld e, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld bc, wObjectStructs
|
2015-07-15 12:48:44 -07:00
|
|
|
ld a, NUM_OBJECT_STRUCTS
|
|
|
|
.loop
|
2015-02-11 14:13:22 -08:00
|
|
|
push af
|
2016-05-04 19:34:09 -07:00
|
|
|
call DoesObjectHaveASprite
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .skip
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_SPRITE_X
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
add d
|
|
|
|
ld [hl], a
|
|
|
|
ld hl, OBJECT_SPRITE_Y
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
add e
|
|
|
|
ld [hl], a
|
2015-07-15 12:48:44 -07:00
|
|
|
.skip
|
2019-11-03 09:25:59 -08:00
|
|
|
ld hl, OBJECT_LENGTH
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld b, h
|
|
|
|
ld c, l
|
|
|
|
pop af
|
|
|
|
dec a
|
2015-07-15 12:48:44 -07:00
|
|
|
jr nz, .loop
|
2015-02-11 14:13:22 -08:00
|
|
|
xor a
|
2016-05-04 19:34:09 -07:00
|
|
|
ld [wPlayerBGMapOffsetX], a
|
|
|
|
ld [wPlayerBGMapOffsetY], a
|
2015-02-11 14:13:22 -08:00
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2022-06-06 14:25:42 -07:00
|
|
|
DEF PRIORITY_LOW EQU $10
|
|
|
|
DEF PRIORITY_NORM EQU $20
|
|
|
|
DEF PRIORITY_HIGH EQU $30
|
2018-01-18 12:58:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
InitSprites:
|
2023-08-17 04:51:29 -07:00
|
|
|
call InitSecondarySprites
|
2015-11-15 18:28:15 -08:00
|
|
|
call .DeterminePriorities
|
|
|
|
ld c, PRIORITY_HIGH
|
|
|
|
call .InitSpritesByPriority
|
|
|
|
ld c, PRIORITY_NORM
|
|
|
|
call .InitSpritesByPriority
|
|
|
|
ld c, PRIORITY_LOW
|
|
|
|
call .InitSpritesByPriority
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.DeterminePriorities:
|
2015-02-11 14:13:22 -08:00
|
|
|
xor a
|
2020-06-15 20:28:24 -07:00
|
|
|
ld hl, wObjectPriorities
|
2015-11-15 18:28:15 -08:00
|
|
|
ld bc, NUM_OBJECT_STRUCTS
|
2015-02-11 14:13:22 -08:00
|
|
|
call ByteFill
|
|
|
|
ld d, 0
|
2018-01-23 14:39:09 -08:00
|
|
|
ld bc, wObjectStructs
|
2020-06-15 20:28:24 -07:00
|
|
|
ld hl, wObjectPriorities
|
2015-02-11 14:13:22 -08:00
|
|
|
.loop
|
|
|
|
push hl
|
2016-05-04 19:34:09 -07:00
|
|
|
call DoesObjectHaveASprite
|
2015-02-11 14:13:22 -08:00
|
|
|
jr z, .skip
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_FACING
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-11-15 18:28:15 -08:00
|
|
|
cp STANDING
|
2015-02-11 14:13:22 -08:00
|
|
|
jr z, .skip
|
|
|
|
; Define the sprite priority.
|
2015-11-15 18:28:15 -08:00
|
|
|
ld e, PRIORITY_LOW
|
2015-10-29 20:32:11 -07:00
|
|
|
ld hl, OBJECT_FLAGS2
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
2018-05-23 10:15:07 -07:00
|
|
|
bit LOW_PRIORITY_F, [hl]
|
2015-02-11 14:13:22 -08:00
|
|
|
jr nz, .add
|
2015-11-15 18:28:15 -08:00
|
|
|
ld e, PRIORITY_NORM
|
2018-05-23 10:15:07 -07:00
|
|
|
bit HIGH_PRIORITY_F, [hl]
|
2015-02-11 14:13:22 -08:00
|
|
|
jr z, .add
|
2015-11-15 18:28:15 -08:00
|
|
|
ld e, PRIORITY_HIGH
|
2015-02-11 14:13:22 -08:00
|
|
|
jr .add
|
|
|
|
|
|
|
|
.skip
|
2019-11-03 09:25:59 -08:00
|
|
|
ld hl, OBJECT_LENGTH
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld b, h
|
|
|
|
ld c, l
|
|
|
|
pop hl
|
|
|
|
jr .next
|
|
|
|
|
|
|
|
.add
|
2019-11-03 09:25:59 -08:00
|
|
|
ld hl, OBJECT_LENGTH
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld b, h
|
|
|
|
ld c, l
|
|
|
|
pop hl
|
|
|
|
ld a, d
|
|
|
|
or e
|
|
|
|
ld [hli], a
|
|
|
|
.next
|
|
|
|
inc d
|
|
|
|
ld a, d
|
2015-07-15 12:48:44 -07:00
|
|
|
cp NUM_OBJECT_STRUCTS
|
2015-02-11 14:13:22 -08:00
|
|
|
jr nz, .loop
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.InitSpritesByPriority:
|
2020-06-15 20:28:24 -07:00
|
|
|
ld hl, wObjectPriorities
|
2015-11-15 18:28:15 -08:00
|
|
|
.next_sprite
|
2015-02-11 14:13:22 -08:00
|
|
|
ld a, [hli]
|
|
|
|
ld d, a
|
2015-11-11 20:38:57 -08:00
|
|
|
and $f0
|
2015-02-11 14:13:22 -08:00
|
|
|
ret z
|
|
|
|
cp c
|
2015-11-15 18:28:15 -08:00
|
|
|
jr nz, .next_sprite
|
2015-02-11 14:13:22 -08:00
|
|
|
push bc
|
|
|
|
push hl
|
|
|
|
ld a, d
|
2015-11-11 20:38:57 -08:00
|
|
|
and $f
|
|
|
|
call .GetObjectStructPointer
|
2015-11-15 18:28:15 -08:00
|
|
|
call .InitSprite
|
2015-02-11 14:13:22 -08:00
|
|
|
pop hl
|
|
|
|
pop bc
|
2015-11-15 18:28:15 -08:00
|
|
|
jr .next_sprite
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.InitSprite:
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_SPRITE_TILE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2021-11-23 17:37:18 -08:00
|
|
|
and ~(1 << 7)
|
2020-04-18 14:31:51 -07:00
|
|
|
ldh [hCurSpriteTile], a
|
2015-02-11 14:13:22 -08:00
|
|
|
xor a
|
|
|
|
bit 7, [hl]
|
2020-10-26 12:45:57 -07:00
|
|
|
jr nz, .not_vram1
|
2018-05-23 17:44:32 -07:00
|
|
|
or VRAM_BANK_1
|
2020-10-26 12:45:57 -07:00
|
|
|
.not_vram1
|
2015-10-29 20:32:11 -07:00
|
|
|
ld hl, OBJECT_FLAGS2
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld e, [hl]
|
2019-01-24 18:41:14 -08:00
|
|
|
bit OBJ_FLAGS2_7, e
|
2020-10-26 12:45:57 -07:00
|
|
|
jr z, .not_priority
|
2018-05-23 17:44:32 -07:00
|
|
|
or PRIORITY
|
2020-10-26 12:45:57 -07:00
|
|
|
.not_priority
|
2018-05-23 17:44:32 -07:00
|
|
|
bit USE_OBP1_F, e
|
2020-10-26 12:45:57 -07:00
|
|
|
jr z, .not_obp_num
|
2018-05-23 17:44:32 -07:00
|
|
|
or OBP_NUM
|
2020-10-26 12:45:57 -07:00
|
|
|
.not_obp_num
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_PALETTE
|
|
|
|
add hl, bc
|
|
|
|
ld d, a
|
|
|
|
ld a, [hl]
|
2018-05-23 17:44:32 -07:00
|
|
|
and PALETTE_MASK
|
2015-02-11 14:13:22 -08:00
|
|
|
or d
|
|
|
|
ld d, a
|
|
|
|
xor a
|
2018-05-23 17:44:32 -07:00
|
|
|
bit OVERHEAD_F, e
|
2020-10-26 12:45:57 -07:00
|
|
|
jr z, .not_overhead
|
2018-05-23 17:44:32 -07:00
|
|
|
or PRIORITY
|
2020-10-26 12:45:57 -07:00
|
|
|
.not_overhead
|
2020-04-18 14:31:51 -07:00
|
|
|
ldh [hCurSpriteOAMFlags], a
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_SPRITE_X
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
ld hl, OBJECT_SPRITE_X_OFFSET
|
|
|
|
add hl, bc
|
|
|
|
add [hl]
|
|
|
|
add 8
|
|
|
|
ld e, a
|
2016-05-04 19:34:09 -07:00
|
|
|
ld a, [wPlayerBGMapOffsetX]
|
2015-02-11 14:13:22 -08:00
|
|
|
add e
|
2020-04-18 14:31:51 -07:00
|
|
|
ldh [hCurSpriteXPixel], a
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_SPRITE_Y
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
ld hl, OBJECT_SPRITE_Y_OFFSET
|
|
|
|
add hl, bc
|
|
|
|
add [hl]
|
|
|
|
add 12
|
|
|
|
ld e, a
|
2016-05-04 19:34:09 -07:00
|
|
|
ld a, [wPlayerBGMapOffsetY]
|
2015-02-11 14:13:22 -08:00
|
|
|
add e
|
2020-04-18 14:31:51 -07:00
|
|
|
ldh [hCurSpriteYPixel], a
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_FACING
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-11-14 11:41:47 -08:00
|
|
|
cp STANDING
|
2015-02-11 14:13:22 -08:00
|
|
|
jp z, .done
|
|
|
|
cp NUM_FACINGS
|
|
|
|
jp nc, .done
|
|
|
|
ld l, a
|
|
|
|
ld h, 0
|
|
|
|
add hl, hl
|
|
|
|
ld bc, Facings
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hUsedSpriteIndex]
|
2015-02-11 14:13:22 -08:00
|
|
|
ld c, a
|
2022-07-09 14:18:22 -07:00
|
|
|
ld b, HIGH(wShadowOAM)
|
2015-02-11 14:13:22 -08:00
|
|
|
ld a, [hli]
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hUsedSpriteTile], a
|
2015-02-11 14:13:22 -08:00
|
|
|
add c
|
2022-07-09 14:18:22 -07:00
|
|
|
cp LOW(wShadowOAMEnd)
|
2015-02-11 14:13:22 -08:00
|
|
|
jr nc, .full
|
|
|
|
.addsprite
|
2020-04-18 14:31:51 -07:00
|
|
|
ldh a, [hCurSpriteYPixel]
|
2015-02-11 14:13:22 -08:00
|
|
|
add [hl]
|
|
|
|
inc hl
|
2018-01-10 10:47:57 -08:00
|
|
|
ld [bc], a ; y
|
2015-02-11 14:13:22 -08:00
|
|
|
inc c
|
2020-04-18 14:31:51 -07:00
|
|
|
ldh a, [hCurSpriteXPixel]
|
2015-02-11 14:13:22 -08:00
|
|
|
add [hl]
|
|
|
|
inc hl
|
2018-01-10 10:47:57 -08:00
|
|
|
ld [bc], a ; x
|
2015-02-11 14:13:22 -08:00
|
|
|
inc c
|
|
|
|
ld e, [hl]
|
|
|
|
inc hl
|
2020-04-18 14:31:51 -07:00
|
|
|
ldh a, [hCurSpriteTile]
|
2018-05-23 19:01:21 -07:00
|
|
|
bit ABSOLUTE_TILE_ID_F, e
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .nope1
|
2015-02-11 14:13:22 -08:00
|
|
|
xor a
|
2015-07-15 12:48:44 -07:00
|
|
|
.nope1
|
2015-02-11 14:13:22 -08:00
|
|
|
add [hl]
|
|
|
|
inc hl
|
2018-01-10 10:47:57 -08:00
|
|
|
ld [bc], a ; tile id
|
2015-02-11 14:13:22 -08:00
|
|
|
inc c
|
|
|
|
ld a, e
|
2018-05-23 19:01:21 -07:00
|
|
|
bit RELATIVE_ATTRIBUTES_F, a
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .nope2
|
2020-04-18 14:31:51 -07:00
|
|
|
ldh a, [hCurSpriteOAMFlags]
|
2015-02-11 14:13:22 -08:00
|
|
|
or e
|
2015-07-15 12:48:44 -07:00
|
|
|
.nope2
|
2018-01-18 12:58:55 -08:00
|
|
|
and OBP_NUM | X_FLIP | Y_FLIP | PRIORITY
|
2015-02-11 14:13:22 -08:00
|
|
|
or d
|
2018-01-10 10:47:57 -08:00
|
|
|
ld [bc], a ; attributes
|
2015-02-11 14:13:22 -08:00
|
|
|
inc c
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hUsedSpriteTile]
|
2015-02-11 14:13:22 -08:00
|
|
|
dec a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hUsedSpriteTile], a
|
2015-02-11 14:13:22 -08:00
|
|
|
jr nz, .addsprite
|
|
|
|
ld a, c
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hUsedSpriteIndex], a
|
2015-02-11 14:13:22 -08:00
|
|
|
.done
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.full
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.GetObjectStructPointer:
|
2015-02-11 14:13:22 -08:00
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
|
|
|
ld hl, .Addresses
|
2015-12-29 10:15:58 -08:00
|
|
|
add hl, bc
|
|
|
|
add hl, bc
|
2015-02-11 14:13:22 -08:00
|
|
|
ld c, [hl]
|
|
|
|
inc hl
|
|
|
|
ld b, [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.Addresses:
|
2018-01-23 14:39:09 -08:00
|
|
|
dw wPlayerStruct
|
|
|
|
dw wObject1Struct
|
|
|
|
dw wObject2Struct
|
|
|
|
dw wObject3Struct
|
|
|
|
dw wObject4Struct
|
|
|
|
dw wObject5Struct
|
|
|
|
dw wObject6Struct
|
|
|
|
dw wObject7Struct
|
|
|
|
dw wObject8Struct
|
|
|
|
dw wObject9Struct
|
|
|
|
dw wObject10Struct
|
|
|
|
dw wObject11Struct
|
|
|
|
dw wObject12Struct
|
2023-08-17 04:51:29 -07:00
|
|
|
|
2023-10-14 10:28:35 -07:00
|
|
|
_UpdateSecondarySprites::
|
2023-10-21 09:46:56 -07:00
|
|
|
; this is a shorter _UpdateActiveSprites for when only secondary sprites
|
|
|
|
; have changed since the last sprites update, but NOT expanded or shrinked,
|
|
|
|
; which would require to displace primary (NPC) sprites in OAM.
|
2023-09-30 04:30:30 -07:00
|
|
|
; if it is detected that the size of secondary sprites has increased in the end,
|
2023-10-21 09:46:56 -07:00
|
|
|
; fall back to calling _UpdateActiveSprites to avoid corruption.
|
2024-02-10 15:34:46 -08:00
|
|
|
ld a, [wStateFlags]
|
2023-09-30 04:30:30 -07:00
|
|
|
bit 0, a
|
|
|
|
ret z
|
|
|
|
ld a, [hUsedSpriteIndex]
|
|
|
|
push af
|
|
|
|
|
|
|
|
xor a
|
|
|
|
ldh [hUsedSpriteIndex], a
|
|
|
|
.go
|
|
|
|
ldh a, [hOAMUpdate]
|
|
|
|
push af
|
|
|
|
ld a, 1
|
|
|
|
ldh [hOAMUpdate], a
|
|
|
|
call InitSecondarySprites
|
|
|
|
pop af
|
|
|
|
ldh [hOAMUpdate], a
|
|
|
|
|
|
|
|
ldh a, [hUsedSpriteIndex]
|
|
|
|
ld c, a
|
|
|
|
pop af
|
|
|
|
cp c
|
|
|
|
ret nc
|
2023-10-21 09:46:56 -07:00
|
|
|
jp _UpdateActiveSprites
|
2023-09-30 04:30:30 -07:00
|
|
|
|
2023-08-17 04:51:29 -07:00
|
|
|
InitSecondarySprites:
|
|
|
|
ld a, [wDisplaySecondarySprites]
|
|
|
|
bit SECONDARYSPRITES_BOARD_MENU_F, a
|
2023-09-25 12:57:47 -07:00
|
|
|
call nz, InitBoardMenuSprites
|
|
|
|
bit SECONDARYSPRITES_DIE_ROLL_F, a
|
2023-10-24 11:36:23 -07:00
|
|
|
call nz, InitDieRollSprites
|
2023-09-27 10:25:47 -07:00
|
|
|
bit SECONDARYSPRITES_SPACES_LEFT_F, a
|
|
|
|
call nz, InitSpacesLeftNumberSprites
|
2023-12-23 05:44:36 -08:00
|
|
|
bit SECONDARYSPRITES_BRANCH_SPACE_F, a
|
2023-10-24 11:36:23 -07:00
|
|
|
call nz, InitBranchArrowsSprites
|
2023-11-04 05:04:25 -07:00
|
|
|
bit SECONDARYSPRITES_VIEW_MAP_MODE_F, a
|
|
|
|
call nz, InitViewMapModeSprites
|
2023-12-23 05:44:36 -08:00
|
|
|
bit SECONDARYSPRITES_TALKER_EVENT_F, a
|
|
|
|
call nz, InitTalkerEventSprites
|
2023-12-26 12:04:20 -08:00
|
|
|
bit SECONDARYSPRITES_GAIN_OR_LOSE_COINS_F, a
|
|
|
|
call nz, InitGainOrLoseCoinsSprites
|
2023-08-17 04:51:29 -07:00
|
|
|
ret
|
|
|
|
|
2023-09-25 12:57:47 -07:00
|
|
|
InitBoardMenuSprites:
|
2023-08-17 04:51:29 -07:00
|
|
|
push af
|
|
|
|
|
|
|
|
ld hl, BoardMenuOAM
|
|
|
|
ld a, [wBoardMenuCursorPosition]
|
2023-09-23 02:50:25 -07:00
|
|
|
ld bc, BOARD_MENU_ITEM_SIZE * SPRITEOAMSTRUCT_LENGTH
|
2023-08-17 04:51:29 -07:00
|
|
|
call AddNTimes
|
2023-09-23 02:50:25 -07:00
|
|
|
; find the beginning of free space in OAM, and assure there's space for a BOARD_MENU_ITEM_SIZE object
|
2023-08-17 04:51:29 -07:00
|
|
|
ldh a, [hUsedSpriteIndex]
|
2023-09-23 02:50:25 -07:00
|
|
|
cp (NUM_SPRITE_OAM_STRUCTS * SPRITEOAMSTRUCT_LENGTH) - (BOARD_MENU_ITEM_SIZE * SPRITEOAMSTRUCT_LENGTH) + 1
|
2023-08-17 04:51:29 -07:00
|
|
|
jr nc, .oam_full
|
2023-09-23 02:50:25 -07:00
|
|
|
; copy the sprite data (BOARD_MENU_ITEM_SIZE objects) of that item to the available space in OAM
|
2023-08-17 04:51:29 -07:00
|
|
|
ld e, a
|
|
|
|
ld d, HIGH(wShadowOAM)
|
2023-09-23 02:50:25 -07:00
|
|
|
ld bc, BOARD_MENU_ITEM_SIZE * SPRITEOAMSTRUCT_LENGTH
|
2023-08-17 04:51:29 -07:00
|
|
|
call CopyBytes
|
|
|
|
|
|
|
|
ldh a, [hUsedSpriteIndex]
|
2023-09-23 02:50:25 -07:00
|
|
|
add (BOARD_MENU_ITEM_SIZE * SPRITEOAMSTRUCT_LENGTH)
|
2023-08-17 04:51:29 -07:00
|
|
|
ldh [hUsedSpriteIndex], a
|
|
|
|
|
|
|
|
.oam_full
|
|
|
|
pop af
|
|
|
|
ret
|
|
|
|
|
2023-10-24 11:36:23 -07:00
|
|
|
InitDieRollSprites:
|
2023-09-25 12:57:47 -07:00
|
|
|
push af
|
|
|
|
|
|
|
|
ld a, [wDieRoll]
|
2023-10-14 10:28:35 -07:00
|
|
|
and a
|
|
|
|
jr z, .zero_or_oam_full
|
2023-09-25 12:57:47 -07:00
|
|
|
dec a
|
2023-10-14 10:28:35 -07:00
|
|
|
ld hl, DieRollOAM
|
2023-09-25 12:57:47 -07:00
|
|
|
ld bc, DIE_SIZE * SPRITEOAMSTRUCT_LENGTH
|
|
|
|
call AddNTimes
|
|
|
|
; find the beginning of free space in OAM, and assure there's space for a DIE_SIZE object
|
|
|
|
ldh a, [hUsedSpriteIndex]
|
|
|
|
cp (NUM_SPRITE_OAM_STRUCTS * SPRITEOAMSTRUCT_LENGTH) - (DIE_SIZE * SPRITEOAMSTRUCT_LENGTH) + 1
|
2023-10-14 10:28:35 -07:00
|
|
|
jr nc, .zero_or_oam_full
|
2023-09-25 12:57:47 -07:00
|
|
|
; copy the sprite data (DIE_SIZE objects) of that item to the available space in OAM
|
|
|
|
ld e, a
|
|
|
|
ld d, HIGH(wShadowOAM)
|
|
|
|
ld bc, DIE_SIZE * SPRITEOAMSTRUCT_LENGTH
|
|
|
|
call CopyBytes
|
|
|
|
|
|
|
|
ldh a, [hUsedSpriteIndex]
|
|
|
|
add (DIE_SIZE * SPRITEOAMSTRUCT_LENGTH)
|
|
|
|
ldh [hUsedSpriteIndex], a
|
|
|
|
|
2023-10-14 10:28:35 -07:00
|
|
|
.zero_or_oam_full
|
2023-09-25 12:57:47 -07:00
|
|
|
pop af
|
|
|
|
ret
|
|
|
|
|
2023-09-27 10:25:47 -07:00
|
|
|
InitSpacesLeftNumberSprites:
|
|
|
|
push af
|
|
|
|
|
|
|
|
ld hl, SpacesLeftNumberOAM
|
|
|
|
ld a, [wSpacesLeft]
|
|
|
|
dec a
|
|
|
|
ld bc, DIE_NUMBER_SIZE * SPRITEOAMSTRUCT_LENGTH
|
|
|
|
call AddNTimes
|
|
|
|
; find the beginning of free space in OAM, and assure there's space for a DIE_NUMBER_SIZE object
|
|
|
|
ldh a, [hUsedSpriteIndex]
|
|
|
|
cp (NUM_SPRITE_OAM_STRUCTS * SPRITEOAMSTRUCT_LENGTH) - (DIE_NUMBER_SIZE * SPRITEOAMSTRUCT_LENGTH) + 1
|
|
|
|
jr nc, .oam_full
|
|
|
|
; copy the sprite data (DIE_NUMBER_SIZE objects) of that item to the available space in OAM
|
|
|
|
ld e, a
|
|
|
|
ld d, HIGH(wShadowOAM)
|
|
|
|
ld bc, DIE_NUMBER_SIZE * SPRITEOAMSTRUCT_LENGTH
|
|
|
|
call CopyBytes
|
|
|
|
|
|
|
|
ldh a, [hUsedSpriteIndex]
|
|
|
|
add (DIE_NUMBER_SIZE * SPRITEOAMSTRUCT_LENGTH)
|
|
|
|
ldh [hUsedSpriteIndex], a
|
|
|
|
|
|
|
|
.oam_full
|
|
|
|
pop af
|
|
|
|
ret
|
|
|
|
|
2023-10-24 11:36:23 -07:00
|
|
|
InitBranchArrowsSprites:
|
|
|
|
push af
|
|
|
|
|
2023-12-23 05:44:36 -08:00
|
|
|
;; arrows
|
2023-10-24 11:36:23 -07:00
|
|
|
; find the beginning of free space in OAM, and assure there's space for 4 objects
|
|
|
|
ldh a, [hUsedSpriteIndex]
|
|
|
|
cp (NUM_SPRITE_OAM_STRUCTS * SPRITEOAMSTRUCT_LENGTH) - (NUM_DIRECTIONS * SPRITEOAMSTRUCT_LENGTH) + 1
|
|
|
|
jr nc, .oam_full
|
|
|
|
|
|
|
|
ld hl, BranchArrowsOAM
|
|
|
|
ld de, wTempSpaceBranchStruct
|
|
|
|
ld c, NUM_DIRECTIONS
|
|
|
|
.loop
|
|
|
|
ld a, [de]
|
2023-10-29 04:03:23 -07:00
|
|
|
cp BRANCH_DIRECTION_INVALID
|
|
|
|
jr z, .next1 ; skip this arrow if this direction is not valid
|
|
|
|
cp BRANCH_DIRECTION_UNAVAILABLE
|
2023-11-05 02:07:32 -08:00
|
|
|
ld b, PAL_OW_GREY ; draw grey arrow if this direction is unavailable
|
2024-03-09 07:40:21 -08:00
|
|
|
jr z, .got_pal
|
|
|
|
call GetSecondarySpritesPal
|
|
|
|
ld b, a
|
2023-10-24 11:36:23 -07:00
|
|
|
|
2024-03-09 07:40:21 -08:00
|
|
|
.got_pal
|
2023-10-24 11:36:23 -07:00
|
|
|
; draw this arrow and advance hUsedSpriteIndex
|
|
|
|
; preserve loop variables d, e, c
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
ldh a, [hUsedSpriteIndex]
|
|
|
|
ld e, a
|
|
|
|
ld d, HIGH(wShadowOAM)
|
2023-10-29 04:03:23 -07:00
|
|
|
; copy all bytes minus the attributes one. the palette matches the
|
2023-11-05 02:07:32 -08:00
|
|
|
; player's color palette, or is PAL_OW_GREY if direction is unavailable
|
2023-10-29 04:03:23 -07:00
|
|
|
push bc
|
2023-10-24 11:36:23 -07:00
|
|
|
ld bc, SPRITEOAMSTRUCT_LENGTH - 1
|
|
|
|
call CopyBytes
|
2023-10-29 04:03:23 -07:00
|
|
|
pop bc
|
|
|
|
ld a, b ; palette
|
2023-10-24 11:36:23 -07:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld a, e
|
|
|
|
ldh [hUsedSpriteIndex], a
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
jr .next2
|
|
|
|
|
|
|
|
.next1
|
|
|
|
inc hl ;
|
|
|
|
inc hl ;
|
|
|
|
inc hl ;
|
|
|
|
|
|
|
|
.next2
|
|
|
|
inc hl ; next object in BranchArrowsOAM
|
|
|
|
inc de
|
|
|
|
dec c
|
|
|
|
jr nz, .loop
|
|
|
|
|
2023-12-23 05:44:36 -08:00
|
|
|
;; legend
|
|
|
|
; find the beginning of free space in OAM, and assure there's space for 8 objects
|
|
|
|
ldh a, [hUsedSpriteIndex]
|
|
|
|
cp (NUM_SPRITE_OAM_STRUCTS * SPRITEOAMSTRUCT_LENGTH) - (8 * SPRITEOAMSTRUCT_LENGTH) + 1
|
|
|
|
jr nc, .oam_full
|
|
|
|
; copy the sprite data of the legend to the available space in OAM.
|
|
|
|
; the palette byte overrides that data as it matches the player's color palette.
|
|
|
|
ld e, a
|
|
|
|
ld d, HIGH(wShadowOAM)
|
2024-03-09 07:40:21 -08:00
|
|
|
call GetSecondarySpritesPal
|
2023-12-23 05:44:36 -08:00
|
|
|
ld b, a
|
|
|
|
ld c, 8 ; number of objects
|
|
|
|
ld hl, BranchLegendOAM
|
|
|
|
.loop2
|
|
|
|
push bc
|
|
|
|
ld bc, SPRITEOAMSTRUCT_LENGTH - 1
|
|
|
|
call CopyBytes
|
|
|
|
pop bc
|
|
|
|
ld a, b ; palette
|
|
|
|
ld [de], a
|
|
|
|
inc hl
|
|
|
|
inc de
|
|
|
|
dec c
|
|
|
|
jr nz, .loop2
|
|
|
|
|
|
|
|
ldh a, [hUsedSpriteIndex]
|
|
|
|
add (8 * SPRITEOAMSTRUCT_LENGTH)
|
|
|
|
ldh [hUsedSpriteIndex], a
|
|
|
|
|
2023-10-24 11:36:23 -07:00
|
|
|
.oam_full
|
|
|
|
pop af
|
|
|
|
ret
|
|
|
|
|
2023-11-04 05:04:25 -07:00
|
|
|
InitViewMapModeSprites:
|
|
|
|
push af
|
|
|
|
|
2023-12-23 05:44:36 -08:00
|
|
|
;; arrows
|
2023-11-04 05:04:25 -07:00
|
|
|
; find the beginning of free space in OAM, and assure there's space for 4 objects
|
|
|
|
ldh a, [hUsedSpriteIndex]
|
|
|
|
cp (NUM_SPRITE_OAM_STRUCTS * SPRITEOAMSTRUCT_LENGTH) - (NUM_DIRECTIONS * SPRITEOAMSTRUCT_LENGTH) + 1
|
|
|
|
jr nc, .oam_full
|
|
|
|
|
|
|
|
ld hl, ViewMapModeArrowsOAM
|
|
|
|
ld de, wTileDown
|
|
|
|
ld c, NUM_DIRECTIONS
|
|
|
|
|
|
|
|
.loop
|
|
|
|
ld a, [de]
|
|
|
|
cp $ff
|
|
|
|
jr z, .next1 ; skip this arrow if this direction is not valid
|
2024-03-09 07:40:21 -08:00
|
|
|
call GetSecondarySpritesPal
|
2023-11-04 05:04:25 -07:00
|
|
|
ld b, a
|
|
|
|
; draw this arrow and advance hUsedSpriteIndex
|
|
|
|
; preserve loop variables d, e, c
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
ldh a, [hUsedSpriteIndex]
|
|
|
|
ld e, a
|
|
|
|
ld d, HIGH(wShadowOAM)
|
|
|
|
; copy all bytes minus the attributes one.
|
|
|
|
; the palette matches the player's color palette.
|
|
|
|
push bc
|
|
|
|
ld bc, SPRITEOAMSTRUCT_LENGTH - 1
|
|
|
|
call CopyBytes
|
|
|
|
pop bc
|
|
|
|
ld a, b ; palette
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld a, e
|
|
|
|
ldh [hUsedSpriteIndex], a
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
jr .next2
|
|
|
|
|
|
|
|
.next1
|
|
|
|
inc hl ;
|
|
|
|
inc hl ;
|
|
|
|
inc hl ;
|
|
|
|
|
|
|
|
.next2
|
|
|
|
inc hl ; next object in ViewMapModeArrowsOAM
|
|
|
|
inc de
|
|
|
|
dec c
|
|
|
|
jr nz, .loop
|
|
|
|
|
2023-12-23 05:44:36 -08:00
|
|
|
;; legend
|
|
|
|
; find the beginning of free space in OAM, and assure there's space for 8 objects
|
|
|
|
ldh a, [hUsedSpriteIndex]
|
|
|
|
cp (NUM_SPRITE_OAM_STRUCTS * SPRITEOAMSTRUCT_LENGTH) - (8 * SPRITEOAMSTRUCT_LENGTH) + 1
|
|
|
|
jr nc, .oam_full
|
|
|
|
; copy the sprite data of the legend to the available space in OAM.
|
|
|
|
; the palette byte overrides that data as it matches the player's color palette.
|
|
|
|
ld e, a
|
|
|
|
ld d, HIGH(wShadowOAM)
|
2024-03-09 07:40:21 -08:00
|
|
|
call GetSecondarySpritesPal
|
2023-12-23 05:44:36 -08:00
|
|
|
ld b, a
|
|
|
|
ld c, 8 ; number of objects
|
|
|
|
ld hl, ViewMapModeLegendOAM
|
|
|
|
.loop2
|
|
|
|
push bc
|
|
|
|
ld bc, SPRITEOAMSTRUCT_LENGTH - 1
|
|
|
|
call CopyBytes
|
|
|
|
pop bc
|
|
|
|
ld a, b ; palette
|
|
|
|
ld [de], a
|
|
|
|
inc hl
|
|
|
|
inc de
|
|
|
|
dec c
|
|
|
|
jr nz, .loop2
|
|
|
|
|
|
|
|
ldh a, [hUsedSpriteIndex]
|
|
|
|
add (8 * SPRITEOAMSTRUCT_LENGTH)
|
|
|
|
ldh [hUsedSpriteIndex], a
|
|
|
|
|
|
|
|
.oam_full
|
|
|
|
pop af
|
|
|
|
ret
|
|
|
|
|
|
|
|
InitTalkerEventSprites:
|
2023-12-26 12:04:20 -08:00
|
|
|
push af
|
|
|
|
|
2023-12-23 05:44:36 -08:00
|
|
|
; find the beginning of free space in OAM, and assure there's space for 8 objects
|
|
|
|
ldh a, [hUsedSpriteIndex]
|
|
|
|
cp (NUM_SPRITE_OAM_STRUCTS * SPRITEOAMSTRUCT_LENGTH) - (8 * SPRITEOAMSTRUCT_LENGTH) + 1
|
|
|
|
jr nc, .oam_full
|
|
|
|
; copy the sprite data of the legend to the available space in OAM.
|
|
|
|
; the palette byte overrides that data as it matches the player's color palette.
|
|
|
|
ld e, a
|
|
|
|
ld d, HIGH(wShadowOAM)
|
2024-03-09 07:40:21 -08:00
|
|
|
call GetSecondarySpritesPal
|
2023-12-23 05:44:36 -08:00
|
|
|
ld b, a
|
|
|
|
ld c, 8 ; number of objects
|
|
|
|
ld hl, TalkerEventLegendOAM
|
|
|
|
.loop2
|
|
|
|
push bc
|
|
|
|
ld bc, SPRITEOAMSTRUCT_LENGTH - 1
|
|
|
|
call CopyBytes
|
|
|
|
pop bc
|
|
|
|
ld a, b ; palette
|
|
|
|
ld [de], a
|
|
|
|
inc hl
|
|
|
|
inc de
|
|
|
|
dec c
|
|
|
|
jr nz, .loop2
|
|
|
|
|
|
|
|
ldh a, [hUsedSpriteIndex]
|
|
|
|
add (8 * SPRITEOAMSTRUCT_LENGTH)
|
|
|
|
ldh [hUsedSpriteIndex], a
|
|
|
|
|
2023-11-04 05:04:25 -07:00
|
|
|
.oam_full
|
|
|
|
pop af
|
|
|
|
ret
|
|
|
|
|
2023-12-26 12:04:20 -08:00
|
|
|
InitGainOrLoseCoinsSprites:
|
|
|
|
push af
|
|
|
|
|
|
|
|
; print string at wStringBuffer1 as OAM
|
|
|
|
; get string length
|
|
|
|
ld hl, wStringBuffer1
|
|
|
|
ld c, 0
|
|
|
|
.get_length_loop
|
|
|
|
ld a, [hli]
|
|
|
|
cp "@"
|
|
|
|
jr z, .got_length
|
|
|
|
inc c
|
|
|
|
ld a, c
|
|
|
|
cp $2 + MAX_DELTA_COINS_DIGITS + 1
|
|
|
|
jr nz, .get_length_loop
|
|
|
|
|
|
|
|
.got_length
|
|
|
|
ld e, c
|
|
|
|
; find the beginning of free space in OAM, and assure there's space for c objects
|
|
|
|
ld a, (NUM_SPRITE_OAM_STRUCTS * SPRITEOAMSTRUCT_LENGTH) + 1
|
|
|
|
sla c ;
|
|
|
|
sla c ; c *= SPRITEOAMSTRUCT_LENGTH
|
|
|
|
sub c
|
|
|
|
ld b, a ; b = (NUM_SPRITE_OAM_STRUCTS * SPRITEOAMSTRUCT_LENGTH) - (c * SPRITEOAMSTRUCT_LENGTH) + 1
|
|
|
|
ldh a, [hUsedSpriteIndex]
|
|
|
|
cp b
|
|
|
|
jr nc, .oam_full
|
|
|
|
|
|
|
|
; align OAM in the X axis according to the string length (e)
|
|
|
|
ld a, 10 * TILE_WIDTH
|
|
|
|
ld c, TILE_WIDTH / 2
|
|
|
|
.x_coord_loop
|
|
|
|
sub c
|
|
|
|
dec e
|
|
|
|
jr nz, .x_coord_loop
|
|
|
|
; b = SPRITEOAMSTRUCT_XCOORD
|
|
|
|
ld b, a
|
|
|
|
; c = SPRITEOAMSTRUCT_YCOORD
|
|
|
|
ld c, 8 * TILE_WIDTH
|
|
|
|
; de = address within wShadowOAM
|
|
|
|
ld a, [hUsedSpriteIndex]
|
|
|
|
ld e, a
|
|
|
|
ld d, HIGH(wShadowOAM)
|
|
|
|
ld hl, wStringBuffer1
|
|
|
|
.print_oam_loop
|
|
|
|
ld a, c
|
|
|
|
ld [de], a ; SPRITEOAMSTRUCT_YCOORD
|
|
|
|
inc de
|
|
|
|
ld a, b
|
|
|
|
ld [de], a ; SPRITEOAMSTRUCT_XCOORD
|
|
|
|
inc de
|
|
|
|
add 1 * TILE_WIDTH
|
|
|
|
ld b, a
|
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a ; SPRITEOAMSTRUCT_TILE_ID
|
|
|
|
inc de
|
|
|
|
ld a, PAL_OW_MISC
|
|
|
|
ld [de], a ; SPRITEOAMSTRUCT_ATTRIBUTES
|
|
|
|
inc de
|
|
|
|
ld a, [hl]
|
|
|
|
cp "@"
|
|
|
|
jr nz, .print_oam_loop
|
|
|
|
|
|
|
|
ld a, e
|
|
|
|
ld [hUsedSpriteIndex], a
|
|
|
|
|
|
|
|
.oam_full
|
|
|
|
pop af
|
|
|
|
ret
|
|
|
|
|
2024-03-09 07:40:21 -08:00
|
|
|
GetSecondarySpritesPal:
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
ld a, [wPlayerCharacter]
|
|
|
|
ld e, PLAYERDATA_OW_PAL
|
|
|
|
call GetPlayerField
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2023-08-17 04:51:29 -07:00
|
|
|
INCLUDE "data/sprites/secondary_sprites.asm"
|