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
|
2015-07-15 12:48:44 -07:00
|
|
|
ld bc, OBJECT_STRUCT_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
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Function437b:
|
2015-12-17 12:14:51 -08:00
|
|
|
call .CheckObjectStillVisible
|
2015-02-11 14:13:22 -08:00
|
|
|
ret c
|
2015-12-29 10:15:58 -08:00
|
|
|
call .HandleStepType
|
|
|
|
call .HandleObjectAction
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -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
|
|
|
|
res 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_NEXT_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
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_NEXT_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
|
|
|
|
set 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
|
|
|
|
set 6, [hl]
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -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
|
|
|
|
bit 5, [hl]
|
2015-10-31 18:05:02 -07:00
|
|
|
jr nz, .bit5
|
2015-12-17 12:14:51 -08:00
|
|
|
cp STEP_TYPE_SLEEP
|
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
|
2015-12-17 12:14:51 -08:00
|
|
|
call ObjectMovementReset
|
2015-10-29 20:32:11 -07:00
|
|
|
ld hl, OBJECT_FLAGS2
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
bit 5, [hl]
|
2015-10-31 18:05:02 -07:00
|
|
|
jr nz, .bit5
|
2015-07-15 12:48:44 -07:00
|
|
|
.one
|
2015-12-17 12:14:51 -08:00
|
|
|
call MapObjectMovementPattern
|
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
|
2015-12-17 12:14:51 -08:00
|
|
|
cp STEP_TYPE_SLEEP
|
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
|
|
|
|
|
2015-10-31 18:05:02 -07:00
|
|
|
.bit5
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -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
|
|
|
|
bit 6, [hl]
|
2015-11-15 11:59:38 -08:00
|
|
|
jr nz, SetFacingStanding
|
2015-02-11 14:13:22 -08:00
|
|
|
bit 5, [hl]
|
2015-12-29 10:15:58 -08:00
|
|
|
jr nz, asm_4448
|
2017-12-24 10:46:34 -08:00
|
|
|
ld de, ObjectActionPairPointers ; use first column
|
2017-12-08 21:50:59 -08:00
|
|
|
jr _HandleObjectAction
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Function4440:
|
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
|
2018-05-05 00:19:04 -07:00
|
|
|
asm_4448:
|
2017-12-24 10:46:34 -08:00
|
|
|
ld de, ObjectActionPairPointers + 2 ; use second column
|
2017-12-08 21:50:59 -08:00
|
|
|
jr _HandleObjectAction
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2018-05-05 00:19:04 -07:00
|
|
|
_HandleObjectAction:
|
2018-01-23 14:39:09 -08:00
|
|
|
; call [4 * wObjectStructs[ObjInd, OBJECT_ACTION] + de]
|
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
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CopyNextCoordsTileToStandingCoordsTile:
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_NEXT_MAP_X
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_MAP_X
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_NEXT_MAP_Y
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_MAP_Y
|
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_NEXT_TILE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_STANDING_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
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_NEXT_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
|
|
|
Function462a:
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_MAP_X
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_NEXT_MAP_X
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_MAP_Y
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_NEXT_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
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_NEXT_TILE
|
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
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_NEXT_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
|
|
|
|
ret c ; never happens
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_STANDING_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
|
2015-11-11 20:38:57 -08:00
|
|
|
ld hl, OBJECT_MOVEMENT_BYTE_INDEX
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hli], a
|
2016-05-10 09:31:49 -07:00
|
|
|
ld [hli], a
|
|
|
|
ld [hli], a
|
2017-12-29 07:19:51 -08:00
|
|
|
ld [hl], a ; OBJECT_1E
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_DIRECTION_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:
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_DIRECTION_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
|
|
|
|
ld hl, OBJECT_FACING
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
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
|
|
|
|
ld hl, OBJECT_MAP_X
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
add [hl]
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_NEXT_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
|
|
|
|
ld hl, OBJECT_MAP_Y
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
add [hl]
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_NEXT_MAP_Y
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
ld e, a
|
|
|
|
push bc
|
2015-11-12 21:49:27 -08:00
|
|
|
call GetCoordTile
|
2015-02-11 14:13:22 -08:00
|
|
|
pop bc
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_NEXT_TILE
|
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).
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_DIRECTION_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
|
2015-11-14 11:41:47 -08:00
|
|
|
ret z ; 0 or 128
|
2015-02-11 14:13:22 -08:00
|
|
|
ld a, 1
|
2015-11-14 11:41:47 -08:00
|
|
|
ret nc ; 1 - 127
|
2015-02-11 14:13:22 -08:00
|
|
|
ld a, -1
|
2015-11-14 11:41:47 -08:00
|
|
|
ret ; 129 - 255
|
2018-01-10 22:45:27 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
UpdatePlayerStep:
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_DIRECTION_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
|
2015-02-11 14:13:22 -08:00
|
|
|
set 5, [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Unreferenced_Function4759:
|
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
|
2015-12-29 10:15:58 -08:00
|
|
|
ld a, SPRITEMOVEFN_STANDING
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ClearObjectMovementByteIndex:
|
2015-11-11 20:38:57 -08:00
|
|
|
ld hl, OBJECT_MOVEMENT_BYTE_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
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
IncrementObjectMovementByteIndex:
|
2015-11-11 20:38:57 -08:00
|
|
|
ld hl, OBJECT_MOVEMENT_BYTE_INDEX
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
DecrementObjectMovementByteIndex:
|
2015-11-11 20:38:57 -08:00
|
|
|
ld hl, OBJECT_MOVEMENT_BYTE_INDEX
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
MovementAnonymousJumptable:
|
2015-11-11 20:38:57 -08:00
|
|
|
ld hl, OBJECT_MOVEMENT_BYTE_INDEX
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
pop hl
|
|
|
|
rst JumpTable
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ClearObjectStructField1c:
|
2017-12-29 07:19:51 -08:00
|
|
|
ld hl, OBJECT_1C
|
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
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
IncrementObjectStructField1c:
|
2017-12-29 07:19:51 -08:00
|
|
|
ld hl, OBJECT_1C
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Field1cAnonymousJumptable:
|
2017-12-29 07:19:51 -08:00
|
|
|
ld hl, OBJECT_1C
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
pop hl
|
|
|
|
rst JumpTable
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetValueObjectStructField1c:
|
2017-12-29 07:19:51 -08:00
|
|
|
ld hl, OBJECT_1C
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SetValueObjectStructField1c:
|
2017-12-29 07:19:51 -08:00
|
|
|
ld hl, OBJECT_1C
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ObjectMovementReset:
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_NEXT_MAP_X
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld d, [hl]
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_NEXT_MAP_Y
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld e, [hl]
|
|
|
|
push bc
|
2015-11-12 21:49:27 -08:00
|
|
|
call GetCoordTile
|
2015-02-11 14:13:22 -08:00
|
|
|
pop bc
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_NEXT_TILE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
2015-12-17 12:14:51 -08:00
|
|
|
call CopyNextCoordsTileToStandingCoordsTile
|
|
|
|
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
|
2015-12-17 12:14:51 -08:00
|
|
|
ld [hl], STEP_TYPE_SLEEP
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
MapObjectMovementPattern:
|
2017-12-29 07:19:51 -08:00
|
|
|
call ClearObjectStructField1c
|
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:
|
2017-12-08 21:50:59 -08:00
|
|
|
; entries correspond to SPRITEMOVEFN_* constants
|
2015-12-26 18:59:03 -08:00
|
|
|
dw .Null_00 ; 00
|
|
|
|
dw .RandomWalkY ; 01
|
|
|
|
dw .RandomWalkX ; 02
|
|
|
|
dw .RandomWalkXY ; 03
|
|
|
|
dw .RandomSpin1 ; 04
|
|
|
|
dw .RandomSpin2 ; 05
|
|
|
|
dw .Standing ; 06
|
|
|
|
dw .ObeyDPad ; 07
|
|
|
|
dw .Movement08 ; 08
|
|
|
|
dw .Movement09 ; 09
|
|
|
|
dw .Movement0a ; 0a
|
|
|
|
dw .Movement0b ; 0b
|
|
|
|
dw .Movement0c ; 0c
|
|
|
|
dw .Movement0d ; 0d
|
|
|
|
dw .Movement0e ; 0e
|
|
|
|
dw .Follow ; 0f
|
|
|
|
dw .Script ; 10
|
|
|
|
dw .Strength ; 11
|
|
|
|
dw .FollowNotExact ; 12
|
|
|
|
dw .MovementShadow ; 13
|
|
|
|
dw .MovementEmote ; 14
|
|
|
|
dw .MovementBigStanding ; 15
|
|
|
|
dw .MovementBouncing ; 16
|
|
|
|
dw .MovementScreenShake ; 17
|
|
|
|
dw .MovementSpinClockwise ; 18
|
|
|
|
dw .MovementSpinCounterclockwise ; 19
|
|
|
|
dw .MovementBoulderDust ; 1a
|
|
|
|
dw .MovementShakingGrass ; 1b
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Null_00:
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.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
|
2015-11-06 13:42:38 -08:00
|
|
|
jp .RandomWalkContinue
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.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
|
2015-11-06 13:42:38 -08:00
|
|
|
jp .RandomWalkContinue
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.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
|
2015-11-06 13:42:38 -08:00
|
|
|
jp .RandomWalkContinue
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.RandomSpin1:
|
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
|
|
|
|
ld hl, OBJECT_FACING
|
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
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.RandomSpin2:
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_FACING
|
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
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Standing:
|
2015-02-11 14:13:22 -08:00
|
|
|
call Function462a
|
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
|
2015-11-14 20:02:38 -08:00
|
|
|
ld [hl], STEP_TYPE_05
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.ObeyDPad:
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, Function5000
|
2015-11-11 20:38:57 -08:00
|
|
|
jp HandleMovementData
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Movement08:
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, Function5015
|
2015-11-11 20:38:57 -08:00
|
|
|
jp HandleMovementData
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Movement09:
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, Function5026
|
2015-11-11 20:38:57 -08:00
|
|
|
jp HandleMovementData
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Movement0a:
|
2017-12-24 10:46:34 -08:00
|
|
|
jp _GetMovementObject
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Movement0b:
|
2017-12-24 10:46:34 -08:00
|
|
|
jp _GetMovementObject
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Movement0c:
|
2017-12-24 10:46:34 -08:00
|
|
|
jp _GetMovementObject
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Movement0d:
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, Function5000
|
2015-11-11 20:38:57 -08:00
|
|
|
jp HandleMovementData
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Movement0e:
|
2017-12-24 10:46:34 -08:00
|
|
|
jp _GetMovementObject
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Follow:
|
2015-12-29 10:15:58 -08:00
|
|
|
ld hl, GetFollowerNextMovementByte
|
2015-11-11 20:38:57 -08:00
|
|
|
jp HandleMovementData
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Script:
|
2015-12-29 10:15:58 -08:00
|
|
|
ld hl, GetMovementByte
|
2015-11-11 20:38:57 -08:00
|
|
|
jp HandleMovementData
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Strength:
|
2015-11-15 11:59:38 -08:00
|
|
|
call MovementAnonymousJumptable
|
2015-11-06 13:42:38 -08:00
|
|
|
dw .Strength_Start
|
|
|
|
dw .Strength_Stop
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Strength_Start:
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_NEXT_TILE
|
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
|
|
|
|
bit 2, [hl]
|
|
|
|
res 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
|
2015-11-14 20:02:38 -08:00
|
|
|
ld [hl], STEP_TYPE_0F
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
.ok2
|
2015-02-11 14:13:22 -08:00
|
|
|
call Function462a
|
2015-07-15 12:48:44 -07:00
|
|
|
.ok
|
|
|
|
ld hl, OBJECT_DIRECTION_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
|
2015-11-14 11:41:47 -08:00
|
|
|
call IncrementObjectMovementByteIndex
|
2016-04-10 11:42:14 -07:00
|
|
|
.Strength_Stop:
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_DIRECTION_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
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.FollowNotExact:
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_NEXT_MAP_X
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld d, [hl]
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_NEXT_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
|
|
|
|
ld hl, OBJECT_DIRECTION_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
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_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
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_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
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_DIRECTION_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
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_DIRECTION_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
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.MovementBigStanding:
|
2015-12-17 12:14:51 -08:00
|
|
|
call EndSpriteMovement
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_DIRECTION_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
|
2015-11-14 20:02:38 -08:00
|
|
|
ld [hl], STEP_TYPE_04
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.MovementBouncing:
|
2015-12-17 12:14:51 -08:00
|
|
|
call EndSpriteMovement
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_DIRECTION_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
|
2015-11-14 20:02:38 -08:00
|
|
|
ld [hl], STEP_TYPE_04
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.MovementSpinCounterclockwise:
|
2015-11-15 11:59:38 -08:00
|
|
|
call MovementAnonymousJumptable
|
2015-11-06 13:42:38 -08:00
|
|
|
dw .MovementSpinInit
|
|
|
|
dw .MovementSpinRepeat
|
|
|
|
dw .MovementSpinTurnLeft
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.MovementSpinClockwise:
|
2015-11-15 11:59:38 -08:00
|
|
|
call MovementAnonymousJumptable
|
2015-11-06 13:42:38 -08:00
|
|
|
dw .MovementSpinInit
|
|
|
|
dw .MovementSpinRepeat
|
|
|
|
dw .MovementSpinTurnRight
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.MovementSpinInit:
|
2015-12-17 12:14:51 -08:00
|
|
|
call EndSpriteMovement
|
2015-11-14 11:41:47 -08:00
|
|
|
call IncrementObjectMovementByteIndex
|
2016-04-10 11:42:14 -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
|
2015-11-14 20:02:38 -08:00
|
|
|
ld [hl], STEP_TYPE_03
|
2015-11-14 11:41:47 -08:00
|
|
|
call IncrementObjectMovementByteIndex
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.MovementSpinTurnLeft:
|
2015-11-06 13:42:38 -08:00
|
|
|
ld de, .DirectionData_Counterclockwise
|
|
|
|
call .MovementSpinNextFacing
|
|
|
|
jr .MovementSpinCounterclockwise
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.DirectionData_Counterclockwise:
|
2015-11-15 11:59:38 -08:00
|
|
|
db OW_RIGHT, OW_LEFT, OW_DOWN, OW_UP
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.MovementSpinTurnRight:
|
2015-11-06 13:42:38 -08:00
|
|
|
ld de, .DirectionData_Clockwise
|
|
|
|
call .MovementSpinNextFacing
|
|
|
|
jr .MovementSpinClockwise
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.DirectionData_Clockwise:
|
2015-11-15 11:59:38 -08:00
|
|
|
db OW_LEFT, OW_RIGHT, OW_UP, OW_DOWN
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.MovementSpinNextFacing:
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_FACING
|
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
|
2015-11-14 11:41:47 -08:00
|
|
|
call DecrementObjectMovementByteIndex
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.MovementShadow:
|
2015-11-15 18:28:15 -08:00
|
|
|
call ._MovementShadow_Grass_Emote_BoulderDust
|
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
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_DIRECTION_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
|
2015-12-17 12:14:51 -08:00
|
|
|
ld d, 1 * 8 + 6
|
2015-07-15 12:48:44 -07:00
|
|
|
cp DOWN
|
2015-11-06 13:42:38 -08:00
|
|
|
jr z, .ok_13
|
2015-07-15 12:48:44 -07:00
|
|
|
cp UP
|
2015-11-06 13:42:38 -08:00
|
|
|
jr z, .ok_13
|
2015-12-17 12:14:51 -08:00
|
|
|
ld d, 1 * 8 + 4
|
2015-11-06 13:42:38 -08:00
|
|
|
.ok_13
|
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
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.MovementEmote:
|
2015-12-17 12:14:51 -08:00
|
|
|
call EndSpriteMovement
|
2015-11-15 18:28:15 -08:00
|
|
|
call ._MovementShadow_Grass_Emote_BoulderDust
|
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
|
2015-12-17 12:14:51 -08:00
|
|
|
ld [hl], -2 * 8
|
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
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.MovementBoulderDust:
|
2015-12-17 12:14:51 -08:00
|
|
|
call EndSpriteMovement
|
2015-11-15 18:28:15 -08:00
|
|
|
call ._MovementShadow_Grass_Emote_BoulderDust
|
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
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_DIRECTION_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
|
|
|
|
ld hl, .data_4a81
|
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
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.data_4a81
|
2015-02-11 14:13:22 -08:00
|
|
|
; x, y
|
|
|
|
db 0, -4
|
|
|
|
db 0, 8
|
|
|
|
db 6, 2
|
|
|
|
db -6, 2
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.MovementShakingGrass:
|
2015-12-17 12:14:51 -08:00
|
|
|
call EndSpriteMovement
|
2015-11-15 18:28:15 -08:00
|
|
|
call ._MovementShadow_Grass_Emote_BoulderDust
|
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
|
|
|
|
|
2016-04-10 12:11:37 -07:00
|
|
|
._MovementShadow_Grass_Emote_BoulderDust:
|
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
|
|
|
|
inc hl
|
|
|
|
ld [hl], d
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.MovementScreenShake:
|
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]
|
2015-11-14 20:02:38 -08:00
|
|
|
call ._MovementScreenShake
|
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
|
2015-11-14 20:02:38 -08:00
|
|
|
ld [hl], STEP_TYPE_15
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2016-04-10 12:11:37 -07:00
|
|
|
._MovementScreenShake:
|
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
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.RandomWalkContinue:
|
2015-12-17 12:14:51 -08:00
|
|
|
call InitStep
|
2018-05-24 09:36:35 -07:00
|
|
|
call CanObjectMoveInDirection ; check whether the object can move in that direction
|
2015-11-15 11:59:38 -08:00
|
|
|
jr c, .NewDuration
|
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
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hMapObjectIndexBuffer]
|
2015-02-11 14:13:22 -08:00
|
|
|
cp [hl]
|
2015-11-06 13:42:38 -08:00
|
|
|
jr z, .load_6
|
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-14 20:02:38 -08:00
|
|
|
ld [hl], STEP_TYPE_07
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2015-11-06 13:42:38 -08:00
|
|
|
.load_6
|
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
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.NewDuration:
|
2015-12-17 12:14:51 -08:00
|
|
|
call EndSpriteMovement
|
2015-02-11 14:13:22 -08:00
|
|
|
call Function462a
|
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
|
2015-11-14 11:41:47 -08: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
|
2018-06-24 07:09:41 -07:00
|
|
|
SetRandomStepDuration:
|
2015-02-11 14:13:22 -08:00
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_DIRECTION_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
|
2015-11-14 20:02:38 -08:00
|
|
|
ld [hl], STEP_TYPE_03
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
StepTypesJumptable:
|
2017-12-08 21:50:59 -08:00
|
|
|
; entries correspond to STEP_TYPE_* constants
|
2015-12-26 18:59:03 -08:00
|
|
|
dw ObjectMovementReset ; 00
|
2018-01-30 19:34:05 -08:00
|
|
|
dw MapObjectMovementPattern ; 01
|
|
|
|
dw NPCStep ; 02
|
2015-12-29 10:15:58 -08:00
|
|
|
dw StepType03 ; 03
|
|
|
|
dw StepType04 ; 04
|
|
|
|
dw StepType05 ; 05
|
2018-01-30 19:34:05 -08:00
|
|
|
dw PlayerStep ; 06
|
2015-12-29 10:15:58 -08:00
|
|
|
dw StepType07 ; 07
|
2018-01-30 19:34:05 -08:00
|
|
|
dw NPCJump ; 08
|
|
|
|
dw PlayerJump ; 09
|
|
|
|
dw PlayerOrNPCTurnStep ; 0a
|
2015-12-29 10:15:58 -08:00
|
|
|
dw StepTypeBump ; 0b
|
2018-01-30 19:34:05 -08:00
|
|
|
dw TeleportFrom ; 0c
|
|
|
|
dw TeleportTo ; 0d
|
|
|
|
dw Skyfall ; 0e
|
2015-12-29 10:15:58 -08:00
|
|
|
dw StepType0f ; 0f
|
2015-12-26 18:59:03 -08:00
|
|
|
dw GotBiteStep ; 10
|
|
|
|
dw RockSmashStep ; 11
|
|
|
|
dw ReturnDigStep ; 12
|
2015-12-29 10:15:58 -08:00
|
|
|
dw StepTypeTrackingObject ; 13
|
|
|
|
dw StepType14 ; 14
|
|
|
|
dw StepType15 ; 15
|
|
|
|
dw StepType16 ; 16
|
|
|
|
dw StepType17 ; 17
|
|
|
|
dw StepType18 ; 18
|
2015-12-26 18:59:03 -08:00
|
|
|
dw SkyfallTop ; 19
|
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
|
2015-12-17 12:14:51 -08:00
|
|
|
ld [hl], STEP_TYPE_SLEEP
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
NPCJump:
|
2017-12-29 07:19:51 -08:00
|
|
|
call Field1cAnonymousJumptable
|
2015-12-26 18:59:03 -08:00
|
|
|
; anonymous 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
|
2015-12-17 12:14:51 -08:00
|
|
|
call CopyNextCoordsTileToStandingCoordsTile
|
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
|
|
|
|
res 3, [hl]
|
2017-12-29 07:19:51 -08:00
|
|
|
call IncrementObjectStructField1c
|
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
|
2015-12-17 12:14:51 -08:00
|
|
|
call CopyNextCoordsTileToStandingCoordsTile
|
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_SLEEP
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
PlayerJump:
|
2017-12-29 07:19:51 -08:00
|
|
|
call Field1cAnonymousJumptable
|
2015-12-26 18:59:03 -08:00
|
|
|
; anonymous 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
|
2015-02-11 14:13:22 -08:00
|
|
|
set 7, [hl]
|
2017-12-29 07:19:51 -08:00
|
|
|
call IncrementObjectStructField1c
|
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
|
2015-12-17 12:14:51 -08:00
|
|
|
call CopyNextCoordsTileToStandingCoordsTile
|
2015-10-29 20:32:11 -07:00
|
|
|
ld hl, OBJECT_FLAGS2
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
res 3, [hl]
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, wPlayerStepFlags
|
2015-02-11 14:13:22 -08:00
|
|
|
set 6, [hl]
|
|
|
|
set 4, [hl]
|
2017-12-29 07:19:51 -08:00
|
|
|
call IncrementObjectStructField1c
|
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
|
2015-02-11 14:13:22 -08:00
|
|
|
set 7, [hl]
|
2017-12-29 07:19:51 -08:00
|
|
|
call IncrementObjectStructField1c
|
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
|
2015-02-11 14:13:22 -08:00
|
|
|
set 6, [hl]
|
2015-12-17 12:14:51 -08:00
|
|
|
call CopyNextCoordsTileToStandingCoordsTile
|
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_SLEEP
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
TeleportFrom:
|
2017-12-29 07:19:51 -08:00
|
|
|
call Field1cAnonymousJumptable
|
2015-12-26 18:59:03 -08:00
|
|
|
; anonymous 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
|
2017-12-29 07:19:51 -08:00
|
|
|
call IncrementObjectStructField1c
|
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
|
2017-12-29 07:19:51 -08:00
|
|
|
call IncrementObjectStructField1c
|
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
|
2017-12-29 07:19:51 -08:00
|
|
|
ld hl, OBJECT_1F
|
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
|
|
|
|
res 3, [hl]
|
2017-12-29 07:19:51 -08:00
|
|
|
call IncrementObjectStructField1c
|
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
|
2017-12-29 07:19:51 -08:00
|
|
|
ld hl, OBJECT_1F
|
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
|
2015-12-17 12:14:51 -08:00
|
|
|
ld [hl], STEP_TYPE_SLEEP
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
TeleportTo:
|
2017-12-29 07:19:51 -08:00
|
|
|
call Field1cAnonymousJumptable
|
2015-12-26 18:59:03 -08:00
|
|
|
; anonymous 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
|
2017-12-29 07:19:51 -08:00
|
|
|
call IncrementObjectStructField1c
|
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
|
2017-12-29 07:19:51 -08:00
|
|
|
call IncrementObjectStructField1c
|
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
|
2017-12-29 07:19:51 -08:00
|
|
|
ld hl, OBJECT_1F
|
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
|
2017-12-29 07:19:51 -08:00
|
|
|
call IncrementObjectStructField1c
|
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
|
2017-12-29 07:19:51 -08:00
|
|
|
ld hl, OBJECT_1F
|
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
|
2017-12-29 07:19:51 -08:00
|
|
|
call IncrementObjectStructField1c
|
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
|
2017-12-29 07:19:51 -08:00
|
|
|
call IncrementObjectStructField1c
|
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
|
2015-12-17 12:14:51 -08:00
|
|
|
ld [hl], STEP_TYPE_SLEEP
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Skyfall:
|
2017-12-29 07:19:51 -08:00
|
|
|
call Field1cAnonymousJumptable
|
2015-12-26 18:59:03 -08:00
|
|
|
; anonymous 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
|
2017-12-29 07:19:51 -08:00
|
|
|
call IncrementObjectStructField1c
|
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
|
2017-12-29 07:19:51 -08:00
|
|
|
ld hl, OBJECT_1F
|
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
|
2017-12-29 07:19:51 -08:00
|
|
|
call IncrementObjectStructField1c
|
2016-04-10 11:42:14 -07:00
|
|
|
.Fall:
|
2017-12-29 07:19:51 -08:00
|
|
|
ld hl, OBJECT_1F
|
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
|
2017-12-29 07:19:51 -08:00
|
|
|
call IncrementObjectStructField1c
|
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
|
2015-12-17 12:14:51 -08:00
|
|
|
ld [hl], STEP_TYPE_SLEEP
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GotBiteStep:
|
2017-12-29 07:19:51 -08:00
|
|
|
call Field1cAnonymousJumptable
|
2015-12-26 18:59:03 -08:00
|
|
|
; anonymous 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
|
2017-12-29 07:19:51 -08:00
|
|
|
call IncrementObjectStructField1c
|
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
|
2015-12-17 12:14:51 -08:00
|
|
|
ld [hl], STEP_TYPE_SLEEP
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
RockSmashStep:
|
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
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ReturnDigStep:
|
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
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
StepType03:
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_DIRECTION_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
|
2015-12-17 12:14:51 -08:00
|
|
|
ld [hl], STEP_TYPE_SLEEP
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
StepType18:
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_DIRECTION_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
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
StepTypeBump:
|
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
|
2015-12-17 12:14:51 -08:00
|
|
|
ld [hl], STEP_TYPE_SLEEP
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
StepType05:
|
2017-12-29 07:19:51 -08:00
|
|
|
call Field1cAnonymousJumptable
|
2015-12-26 18:59:03 -08:00
|
|
|
; anonymous dw
|
2015-12-29 10:15:58 -08:00
|
|
|
dw .Reset
|
|
|
|
dw StepType04
|
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
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_FACING
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
2017-12-29 07:19:51 -08:00
|
|
|
call IncrementObjectStructField1c
|
2018-06-24 07:09:41 -07:00
|
|
|
StepType04:
|
2018-01-02 11:00:14 -08:00
|
|
|
call Stubbed_Function4fb2
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_DIRECTION_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
|
|
|
NPCStep:
|
2018-01-02 11:00:14 -08:00
|
|
|
call Stubbed_Function4fb2
|
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
|
2015-12-17 12:14:51 -08:00
|
|
|
call CopyNextCoordsTileToStandingCoordsTile
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_DIRECTION_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
|
2015-12-17 12:14:51 -08:00
|
|
|
ld [hl], STEP_TYPE_SLEEP
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
StepType07:
|
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
|
2015-12-17 12:14:51 -08:00
|
|
|
call CopyNextCoordsTileToStandingCoordsTile
|
2015-11-14 11:41:47 -08:00
|
|
|
jp RandomStepDuration_Slow
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
PlayerStep:
|
2015-02-11 14:13:22 -08:00
|
|
|
; AnimateStep?
|
2017-12-29 07:19:51 -08:00
|
|
|
call Field1cAnonymousJumptable
|
2015-12-26 18:59:03 -08:00
|
|
|
; anonymous 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
|
2015-02-11 14:13:22 -08:00
|
|
|
set 7, [hl]
|
2017-12-29 07:19:51 -08:00
|
|
|
call IncrementObjectStructField1c
|
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
|
2015-02-11 14:13:22 -08:00
|
|
|
set 6, [hl]
|
2015-12-17 12:14:51 -08:00
|
|
|
call CopyNextCoordsTileToStandingCoordsTile
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_DIRECTION_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
|
2015-12-17 12:14:51 -08:00
|
|
|
ld [hl], STEP_TYPE_SLEEP
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
PlayerOrNPCTurnStep:
|
2017-12-29 07:19:51 -08:00
|
|
|
call Field1cAnonymousJumptable
|
2015-12-26 18:59:03 -08:00
|
|
|
; anonymous 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
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_DIRECTION_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]
|
2015-07-15 12:48:44 -07:00
|
|
|
ld [hl], 2
|
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], 2
|
2017-12-29 07:19:51 -08:00
|
|
|
call IncrementObjectStructField1c
|
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
|
2017-12-29 07:19:51 -08:00
|
|
|
call IncrementObjectStructField1c
|
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]
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_FACING
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
ld hl, OBJECT_STEP_DURATION
|
|
|
|
add hl, bc
|
2015-12-17 12:14:51 -08:00
|
|
|
ld [hl], 2
|
2017-12-29 07:19:51 -08:00
|
|
|
call IncrementObjectStructField1c
|
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
|
2015-12-17 12:14:51 -08:00
|
|
|
ld [hl], STEP_TYPE_SLEEP
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
StepType0f:
|
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
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_NEXT_MAP_X
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld d, [hl]
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_NEXT_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
|
|
|
|
res 2, [hl]
|
2015-12-17 12:14:51 -08:00
|
|
|
call CopyNextCoordsTileToStandingCoordsTile
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_DIRECTION_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
|
2015-12-17 12:14:51 -08:00
|
|
|
ld [hl], STEP_TYPE_SLEEP
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
StepTypeTrackingObject:
|
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
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
StepType14:
|
|
|
|
StepType15:
|
2017-12-29 07:19:51 -08:00
|
|
|
call Field1cAnonymousJumptable
|
2015-12-26 18:59:03 -08:00
|
|
|
; anonymous 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
|
2017-12-29 07:19:51 -08:00
|
|
|
call IncrementObjectStructField1c
|
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
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
StepType16:
|
2017-12-29 07:19:51 -08:00
|
|
|
call Field1cAnonymousJumptable ; ????
|
2018-06-24 07:09:41 -07:00
|
|
|
StepType17:
|
2017-12-29 07:19:51 -08:00
|
|
|
call Field1cAnonymousJumptable
|
2015-12-26 18:59:03 -08:00
|
|
|
; anonymous dw
|
2015-12-29 10:15:58 -08:00
|
|
|
dw .null
|
|
|
|
dw .null
|
|
|
|
dw .null
|
|
|
|
.null
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SkyfallTop:
|
2017-12-29 07:19:51 -08:00
|
|
|
call Field1cAnonymousJumptable
|
2015-12-26 18:59:03 -08:00
|
|
|
; anonymous 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
|
2017-12-29 07:19:51 -08:00
|
|
|
call IncrementObjectStructField1c
|
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
|
2015-12-17 12:14:51 -08:00
|
|
|
ld [hl], STEP_TYPE_SLEEP
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-01-02 11:00:14 -08:00
|
|
|
Stubbed_Function4fb2:
|
|
|
|
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
|
|
|
|
ld de, .y
|
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
ld hl, OBJECT_SPRITE_Y_OFFSET
|
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.y
|
2015-02-11 14:13:22 -08:00
|
|
|
db 0, -1, -2, -3, -4, -3, -2, -1
|
2018-06-24 07:09:41 -07:00
|
|
|
UpdateJumpPosition:
|
2015-02-11 14:13:22 -08:00
|
|
|
call GetStepVector
|
|
|
|
ld a, h
|
2017-12-29 07:19:51 -08:00
|
|
|
ld hl, OBJECT_1F
|
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
|
|
|
|
ld hl, .y
|
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
ld hl, OBJECT_SPRITE_Y_OFFSET
|
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.y
|
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
|
2015-11-02 08:15:32 -08:00
|
|
|
Function5000: ; unscripted?
|
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
|
|
|
|
|
2015-12-29 10:15:58 -08:00
|
|
|
GetMovementByte:
|
2015-11-02 08:15:32 -08:00
|
|
|
ld hl, wMovementDataPointer
|
2015-12-29 10:15:58 -08:00
|
|
|
call _GetMovementByte
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Function5015:
|
2015-11-11 20:38:57 -08:00
|
|
|
ld hl, OBJECT_MOVEMENT_BYTE_INDEX
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld e, [hl]
|
|
|
|
inc [hl]
|
|
|
|
ld d, 0
|
2015-12-29 10:15:58 -08:00
|
|
|
ld hl, wc2e2
|
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
|
|
|
Function5026:
|
2015-11-11 20:38:57 -08:00
|
|
|
ld hl, OBJECT_MOVEMENT_BYTE_INDEX
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld e, [hl]
|
|
|
|
inc [hl]
|
|
|
|
ld d, 0
|
|
|
|
ld hl, wc2e6
|
|
|
|
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
|
2015-12-29 10:15:58 -08:00
|
|
|
ld [wMovementByteWasControlSwitch], a
|
|
|
|
call JumpMovementPointer
|
2015-07-18 20:45:39 -07:00
|
|
|
call DoMovementFunction
|
2015-12-29 10:15:58 -08:00
|
|
|
ld a, [wMovementByteWasControlSwitch]
|
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:
|
2015-07-15 12:48:44 -07:00
|
|
|
ld a, 1
|
2015-12-29 10:15:58 -08:00
|
|
|
ld [wMovementByteWasControlSwitch], 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
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hMapObjectIndexBuffer]
|
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
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetFollowerNextMovementByte:
|
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
|
|
|
|
db $00, PAL_OW_SILVER, 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:
|
2015-11-14 11:41:47 -08:00
|
|
|
db $00, PAL_OW_SILVER, 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:
|
2015-11-14 11:41:47 -08:00
|
|
|
db $00, PAL_OW_SILVER, 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
|
|
|
|
|
2018-06-01 00:04:36 -07:00
|
|
|
.GrassObject
|
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:
|
2015-11-14 11:41:47 -08:00
|
|
|
db $00, PAL_OW_SILVER, 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
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hMapObjectIndexBuffer]
|
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
|
2015-07-15 12:48:44 -07:00
|
|
|
ld bc, OBJECT_STRUCT_LENGTH
|
2015-02-11 14:13:22 -08:00
|
|
|
call ByteFill
|
|
|
|
pop bc
|
2015-07-15 12:48:44 -07:00
|
|
|
.next
|
|
|
|
ld hl, OBJECT_STRUCT_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:
|
|
|
|
; -1, -1, [de], [de + 1], [de + 2], [hMapObjectIndexBuffer], [NextMapX], [NextMapY], -1
|
|
|
|
; This spawns the object at the same place as whichever object is loaded into bc.
|
|
|
|
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
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hMapObjectIndexBuffer]
|
2015-02-11 14:13:22 -08:00
|
|
|
ld [hli], a
|
|
|
|
push hl
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_NEXT_MAP_X
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld d, [hl]
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_NEXT_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
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Function55e0::
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wVramState]
|
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
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMapObjectIndexBuffer], a
|
2016-05-04 19:34:09 -07:00
|
|
|
call DoesObjectHaveASprite
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .ok
|
2015-02-11 14:13:22 -08:00
|
|
|
call Function565c
|
2015-07-15 12:48:44 -07:00
|
|
|
.ok
|
|
|
|
ld hl, OBJECT_STRUCT_LENGTH
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld b, h
|
|
|
|
ld c, l
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hMapObjectIndexBuffer]
|
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 18:39:23 -07:00
|
|
|
Function5602:
|
|
|
|
; called at battle start
|
2015-11-16 08:53:26 -08:00
|
|
|
call Function5645 ; clear sprites
|
|
|
|
ld a, PLAYER
|
|
|
|
call Function5629 ; respawn player
|
2015-11-25 07:16:29 -08:00
|
|
|
ld a, [wBattleScriptFlags]
|
2015-02-11 14:13:22 -08:00
|
|
|
bit 7, a
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .ok
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hLastTalked]
|
2015-02-11 14:13:22 -08:00
|
|
|
and a
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .ok
|
2015-11-16 08:53:26 -08:00
|
|
|
call Function5629 ; respawn opponent
|
2015-07-15 12:48:44 -07:00
|
|
|
.ok
|
2015-11-15 18:28:15 -08:00
|
|
|
call _UpdateSprites
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Function561d:
|
2015-11-16 08:53:26 -08:00
|
|
|
call Function5645 ; clear sprites
|
|
|
|
ld a, PLAYER
|
|
|
|
call Function5629 ; respawn player
|
2015-11-15 18:28:15 -08:00
|
|
|
call _UpdateSprites
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Function5629:
|
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
|
|
|
|
call Function5673
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Function5645:
|
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
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMapObjectIndexBuffer], a
|
2015-11-16 08:53:26 -08:00
|
|
|
call SetFacing_Standing
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_STRUCT_LENGTH
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld b, h
|
|
|
|
ld c, l
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hMapObjectIndexBuffer]
|
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
|
|
|
Function565c:
|
2015-02-11 14:13:22 -08:00
|
|
|
push bc
|
|
|
|
call Function56cd
|
|
|
|
pop bc
|
2015-11-16 08:53:26 -08:00
|
|
|
jr c, SetFacing_Standing
|
2015-02-11 14:13:22 -08:00
|
|
|
call Function56a3
|
2015-11-16 08:53:26 -08:00
|
|
|
jr c, SetFacing_Standing
|
2015-02-11 14:13:22 -08:00
|
|
|
call Function5688
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall Function4440
|
2015-02-11 14:13:22 -08:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Function5673:
|
2015-02-11 14:13:22 -08:00
|
|
|
call Function56a3
|
2015-11-16 08:53:26 -08:00
|
|
|
jr c, SetFacing_Standing
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall Function4440 ; no need to farcall
|
2015-02-11 14:13:22 -08:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SetFacing_Standing:
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_FACING_STEP
|
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
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Function5688:
|
2015-02-11 14:13:22 -08:00
|
|
|
push bc
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_NEXT_MAP_X
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld d, [hl]
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_NEXT_MAP_Y
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld e, [hl]
|
2015-11-12 21:49:27 -08:00
|
|
|
call GetCoordTile
|
2015-02-11 14:13:22 -08:00
|
|
|
pop bc
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, OBJECT_NEXT_TILE
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall UpdateTallGrassFlags ; no need to farcall
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Function56a3:
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_NEXT_MAP_X
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld d, [hl]
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_NEXT_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
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Function56cd:
|
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
|
2015-02-11 14:13:22 -08:00
|
|
|
cp $a0
|
2015-07-15 12:48:44 -07:00
|
|
|
jp nc, .nope
|
|
|
|
.ok1
|
|
|
|
and %00000111
|
|
|
|
ld d, 2
|
|
|
|
cp 4
|
|
|
|
jr c, .ok2
|
|
|
|
ld d, 3
|
|
|
|
.ok2
|
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
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hUsedSpriteIndex], a
|
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
|
2015-02-11 14:13:22 -08:00
|
|
|
cp $90
|
2015-07-15 12:48:44 -07:00
|
|
|
jr nc, .nope
|
|
|
|
.ok4
|
|
|
|
and %00000111
|
|
|
|
ld e, 2
|
|
|
|
cp 4
|
|
|
|
jr c, .ok5
|
|
|
|
ld e, 3
|
|
|
|
.ok5
|
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
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hUsedSpriteTile], a
|
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
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hFFBF], a
|
2015-07-15 12:48:44 -07:00
|
|
|
.loop
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hFFBF]
|
2015-02-11 14:13:22 -08:00
|
|
|
ld d, a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hUsedSpriteTile]
|
2015-02-11 14:13:22 -08:00
|
|
|
add e
|
|
|
|
dec a
|
2018-01-18 12:58:55 -08:00
|
|
|
cp SCREEN_HEIGHT
|
2015-07-15 12:48:44 -07:00
|
|
|
jr nc, .ok9
|
2015-02-11 14:13:22 -08:00
|
|
|
ld b, a
|
2015-07-15 12:48:44 -07:00
|
|
|
.next
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hUsedSpriteIndex]
|
2015-02-11 14:13:22 -08:00
|
|
|
add d
|
|
|
|
dec a
|
2018-01-18 12:58:55 -08:00
|
|
|
cp SCREEN_WIDTH
|
2015-07-15 12:48:44 -07:00
|
|
|
jr nc, .ok8
|
2015-02-11 14:13:22 -08:00
|
|
|
ld c, a
|
|
|
|
push bc
|
2015-11-10 13:53:37 -08:00
|
|
|
call Coord2Tile
|
2015-02-11 14:13:22 -08:00
|
|
|
pop bc
|
2018-01-18 15:34:20 -08:00
|
|
|
; NPCs disappear if standing on tile $60-$7f (or $e0-$ff),
|
|
|
|
; since those IDs are for text characters and textbox frames.
|
2015-02-11 14:13:22 -08:00
|
|
|
ld a, [hl]
|
2018-01-18 15:34:20 -08:00
|
|
|
cp FIRST_REGULAR_TEXT_CHAR
|
2015-07-15 12:48:44 -07:00
|
|
|
jr nc, .nope
|
|
|
|
.ok8
|
2015-02-11 14:13:22 -08:00
|
|
|
dec d
|
2015-07-15 12:48:44 -07:00
|
|
|
jr nz, .next
|
|
|
|
.ok9
|
2015-02-11 14:13:22 -08:00
|
|
|
dec e
|
2015-07-15 12:48:44 -07:00
|
|
|
jr nz, .loop
|
2015-02-11 14:13:22 -08:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
.nope
|
2015-02-11 14:13:22 -08:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
HandleNPCStep::
|
2015-12-17 12:14:51 -08:00
|
|
|
call .ResetStepVector
|
2016-01-04 05:43:55 -08:00
|
|
|
call .DoStepsForAllObjects
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -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
|
2015-07-15 12:48:44 -07:00
|
|
|
ld a, -1
|
2015-11-14 20:02:38 -08:00
|
|
|
ld [wPlayerStepDirection], a
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -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
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMapObjectIndexBuffer], a
|
2016-05-04 19:34:09 -07:00
|
|
|
call DoesObjectHaveASprite
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .next
|
2015-02-11 14:13:22 -08:00
|
|
|
call Function437b
|
2015-07-15 12:48:44 -07:00
|
|
|
.next
|
|
|
|
ld hl, OBJECT_STRUCT_LENGTH
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld b, h
|
|
|
|
ld c, l
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hMapObjectIndexBuffer]
|
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
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wPlayerObjectStepFrame], a
|
2016-01-04 05:43:55 -08:00
|
|
|
call .TryResetPlayerAction
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall CheckWarpFacingDown
|
2015-07-20 00:51:52 -07:00
|
|
|
call c, SpawnInFacingDown
|
2016-01-04 05:43:55 -08:00
|
|
|
call .SpawnInCustomFacing
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -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
|
|
|
|
|
2018-06-24 07:09:41 -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
|
2015-11-15 18:28:15 -08:00
|
|
|
jr ContinueSpawnFacing
|
2015-02-11 14:13:22 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SpawnInFacingDown:
|
2015-07-15 12:48:44 -07:00
|
|
|
ld a, 0
|
2018-06-24 07:09:41 -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?
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_FACING
|
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]
|
2018-05-23 19:13:46 -07:00
|
|
|
and $ff ^ 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
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hObjectStructIndexBuffer]
|
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
|
2015-11-02 08:15:32 -08:00
|
|
|
ld hl, OBJECT_MOVEMENTTYPE
|
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
|
2015-11-14 20:02:38 -08:00
|
|
|
ld [hl], STEP_TYPE_00
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hObjectStructIndexBuffer]
|
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
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall Function58e3 ; no need to bankswitch
|
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
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SetFlagsForMovement_1::
|
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
|
|
|
|
call Function587a
|
|
|
|
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
|
|
|
|
res 5, [hl]
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Function586e:
|
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
|
|
|
|
set 5, [hl]
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Function587a:
|
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
|
|
|
|
set 5, [hl]
|
2015-07-15 12:48:44 -07:00
|
|
|
.next
|
|
|
|
ld hl, OBJECT_STRUCT_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
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
_SetFlagsForMovement_2::
|
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
|
|
|
|
res 5, [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Function58b9::
|
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
|
|
|
|
res 5, [hl]
|
2015-07-15 12:48:44 -07:00
|
|
|
.next
|
|
|
|
ld hl, OBJECT_STRUCT_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
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Function58d8:
|
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
|
|
|
|
res 5, [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Function58e3:
|
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
|
2015-11-11 20:38:57 -08:00
|
|
|
jp z, Function5903 ; a jr would have been appropriate here
|
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
|
2015-11-02 08:15:32 -08:00
|
|
|
ld hl, OBJECT_MOVEMENTTYPE
|
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
|
2015-11-14 20:02:38 -08:00
|
|
|
ld [hl], STEP_TYPE_00
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Function5903:
|
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]
|
2015-11-02 08:15:32 -08:00
|
|
|
ld hl, OBJECT_MOVEMENTTYPE
|
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
|
2015-11-14 20:02:38 -08:00
|
|
|
ld [hl], STEP_TYPE_00
|
2015-02-11 14:13:22 -08:00
|
|
|
ret
|
|
|
|
|
2015-10-31 18:05:02 -07:00
|
|
|
.standing_movefns
|
|
|
|
db SPRITEMOVEDATA_STANDING_DOWN
|
|
|
|
db SPRITEMOVEDATA_STANDING_UP
|
|
|
|
db SPRITEMOVEDATA_STANDING_LEFT
|
|
|
|
db SPRITEMOVEDATA_STANDING_RIGHT
|
2018-01-10 10:47:57 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
_UpdateSprites::
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wVramState]
|
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
|
|
|
|
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
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wVramState]
|
2015-02-11 14:13:22 -08:00
|
|
|
bit 1, a
|
2018-01-30 11:55:20 -08:00
|
|
|
ld b, LOW(wVirtualOAMEnd)
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .ok
|
2018-01-10 10:47:57 -08:00
|
|
|
ld b, 28 * 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
|
2018-01-23 13:45:34 -08:00
|
|
|
ld h, HIGH(wVirtualOAM)
|
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
|
|
|
|
ld hl, OBJECT_STRUCT_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
|
|
|
|
|
2015-11-15 18:28:15 -08:00
|
|
|
PRIORITY_LOW EQU $10
|
|
|
|
PRIORITY_NORM EQU $20
|
|
|
|
PRIORITY_HIGH EQU $30
|
2018-01-18 12:58:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
InitSprites:
|
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
|
2015-12-29 10:15:58 -08:00
|
|
|
ld hl, wMovementPointer
|
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
|
2015-12-29 10:15:58 -08:00
|
|
|
ld hl, wMovementPointer
|
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
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_FACING_STEP
|
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
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_STRUCT_LENGTH
|
2015-02-11 14:13:22 -08:00
|
|
|
add hl, bc
|
|
|
|
ld b, h
|
|
|
|
ld c, l
|
|
|
|
pop hl
|
|
|
|
jr .next
|
|
|
|
|
|
|
|
.add
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_STRUCT_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:
|
2015-11-02 08:15:32 -08:00
|
|
|
ld hl, wMovementPointer
|
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]
|
2018-05-23 17:44:32 -07:00
|
|
|
and $ff ^ (1 << 7)
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hFFC1], a
|
2015-02-11 14:13:22 -08:00
|
|
|
xor a
|
|
|
|
bit 7, [hl]
|
2015-07-15 12:48:44 -07:00
|
|
|
jr nz, .skip1
|
2018-05-23 17:44:32 -07:00
|
|
|
or VRAM_BANK_1
|
2015-07-15 12:48:44 -07:00
|
|
|
.skip1
|
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]
|
|
|
|
bit 7, e
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .skip2
|
2018-05-23 17:44:32 -07:00
|
|
|
or PRIORITY
|
2015-07-15 12:48:44 -07:00
|
|
|
.skip2
|
2018-05-23 17:44:32 -07:00
|
|
|
bit USE_OBP1_F, e
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .skip3
|
2018-05-23 17:44:32 -07:00
|
|
|
or OBP_NUM
|
2015-07-15 12:48:44 -07:00
|
|
|
.skip3
|
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
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .skip4
|
2018-05-23 17:44:32 -07:00
|
|
|
or PRIORITY
|
2015-07-15 12:48:44 -07:00
|
|
|
.skip4
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hFFC2], 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
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hFFBF], 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
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hFFC0], a
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, OBJECT_FACING_STEP
|
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
|
2018-01-23 13:45:34 -08:00
|
|
|
ld b, HIGH(wVirtualOAM)
|
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
|
2018-01-30 11:55:20 -08:00
|
|
|
cp LOW(wVirtualOAMEnd)
|
2015-02-11 14:13:22 -08:00
|
|
|
jr nc, .full
|
|
|
|
.addsprite
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hFFC0]
|
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
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hFFBF]
|
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
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hFFC1]
|
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
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hFFC2]
|
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
|