2018-06-24 07:09:41 -07:00
|
|
|
ObjectActionPairPointers:
|
2021-03-03 19:22:41 -08:00
|
|
|
; entries correspond to OBJECT_ACTION_* constants (see constants/map_object_constants.asm)
|
|
|
|
table_width 2 + 2, ObjectActionPairPointers
|
2021-03-22 13:41:17 -07:00
|
|
|
; normal action, frozen action
|
2017-12-08 21:50:59 -08:00
|
|
|
dw SetFacingStanding, SetFacingStanding
|
|
|
|
dw SetFacingStandAction, SetFacingCurrent
|
|
|
|
dw SetFacingStepAction, SetFacingCurrent
|
|
|
|
dw SetFacingBumpAction, SetFacingCurrent
|
|
|
|
dw SetFacingCounterclockwiseSpin, SetFacingCurrent
|
|
|
|
dw SetFacingCounterclockwiseSpin2, SetFacingStanding
|
|
|
|
dw SetFacingFish, SetFacingFish
|
|
|
|
dw SetFacingShadow, SetFacingStanding
|
|
|
|
dw SetFacingEmote, SetFacingEmote
|
|
|
|
dw SetFacingBigDollSym, SetFacingBigDollSym
|
|
|
|
dw SetFacingBounce, SetFacingFreezeBounce
|
|
|
|
dw SetFacingWeirdTree, SetFacingCurrent
|
|
|
|
dw SetFacingBigDollAsym, SetFacingBigDollAsym
|
|
|
|
dw SetFacingBigDoll, SetFacingBigDoll
|
|
|
|
dw SetFacingBoulderDust, SetFacingStanding
|
|
|
|
dw SetFacingGrassShake, SetFacingStanding
|
|
|
|
dw SetFacingSkyfall, SetFacingCurrent
|
2021-03-03 19:22:41 -08:00
|
|
|
assert_table_length NUM_OBJECT_ACTIONS
|
2015-12-29 10:15:58 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SetFacingStanding:
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_FACING
|
2015-12-29 10:15:58 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], STANDING
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SetFacingCurrent:
|
2015-12-29 10:15:58 -08:00
|
|
|
call GetSpriteDirection
|
2016-09-27 07:10:13 -07:00
|
|
|
or FACING_STEP_DOWN_0 ; useless
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_FACING
|
2015-12-29 10:15:58 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SetFacingStandAction:
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_FACING
|
2015-12-29 10:15:58 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
and 1
|
2016-09-27 06:37:10 -07:00
|
|
|
jr nz, SetFacingStepAction
|
2015-12-29 10:15:58 -08:00
|
|
|
jp SetFacingCurrent
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SetFacingStepAction:
|
2015-12-29 10:15:58 -08:00
|
|
|
ld hl, OBJECT_FLAGS1
|
|
|
|
add hl, bc
|
2018-05-23 10:15:07 -07:00
|
|
|
bit SLIDING_F, [hl]
|
2015-12-29 10:15:58 -08:00
|
|
|
jp nz, SetFacingCurrent
|
|
|
|
|
|
|
|
ld hl, OBJECT_STEP_FRAME
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
inc a
|
|
|
|
and %00001111
|
|
|
|
ld [hl], a
|
|
|
|
|
|
|
|
rrca
|
|
|
|
rrca
|
2018-05-23 10:15:07 -07:00
|
|
|
maskbits NUM_DIRECTIONS
|
2015-12-29 10:15:58 -08:00
|
|
|
ld d, a
|
|
|
|
|
|
|
|
call GetSpriteDirection
|
2016-09-27 07:10:13 -07:00
|
|
|
or FACING_STEP_DOWN_0 ; useless
|
2015-12-29 10:15:58 -08:00
|
|
|
or d
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_FACING
|
2015-12-29 10:15:58 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SetFacingSkyfall:
|
2015-12-29 10:15:58 -08:00
|
|
|
ld hl, OBJECT_FLAGS1
|
|
|
|
add hl, bc
|
2018-05-23 10:15:07 -07:00
|
|
|
bit SLIDING_F, [hl]
|
2015-12-29 10:15:58 -08:00
|
|
|
jp nz, SetFacingCurrent
|
|
|
|
|
|
|
|
ld hl, OBJECT_STEP_FRAME
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
add 2
|
|
|
|
and %00001111
|
|
|
|
ld [hl], a
|
|
|
|
|
|
|
|
rrca
|
|
|
|
rrca
|
2018-05-23 10:15:07 -07:00
|
|
|
maskbits NUM_DIRECTIONS
|
2015-12-29 10:15:58 -08:00
|
|
|
ld d, a
|
|
|
|
|
|
|
|
call GetSpriteDirection
|
2016-09-27 07:10:13 -07:00
|
|
|
or FACING_STEP_DOWN_0 ; useless
|
2015-12-29 10:15:58 -08:00
|
|
|
or d
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_FACING
|
2015-12-29 10:15:58 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SetFacingBumpAction:
|
2015-12-29 10:15:58 -08:00
|
|
|
ld hl, OBJECT_FLAGS1
|
|
|
|
add hl, bc
|
2018-05-23 10:15:07 -07:00
|
|
|
bit SLIDING_F, [hl]
|
2015-12-29 10:15:58 -08:00
|
|
|
jp nz, SetFacingCurrent
|
|
|
|
|
|
|
|
ld hl, OBJECT_STEP_FRAME
|
|
|
|
add hl, bc
|
|
|
|
inc [hl]
|
|
|
|
|
|
|
|
ld a, [hl]
|
|
|
|
rrca
|
|
|
|
rrca
|
|
|
|
rrca
|
2018-05-23 10:15:07 -07:00
|
|
|
maskbits NUM_DIRECTIONS
|
2015-12-29 10:15:58 -08:00
|
|
|
ld d, a
|
|
|
|
|
|
|
|
call GetSpriteDirection
|
2016-09-27 07:10:13 -07:00
|
|
|
or FACING_STEP_DOWN_0 ; useless
|
2015-12-29 10:15:58 -08:00
|
|
|
or d
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_FACING
|
2015-12-29 10:15:58 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SetFacingCounterclockwiseSpin:
|
2016-09-27 06:37:10 -07:00
|
|
|
call CounterclockwiseSpinAction
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_DIRECTION
|
2015-12-29 10:15:58 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2016-09-27 07:10:13 -07:00
|
|
|
or FACING_STEP_DOWN_0 ; useless
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_FACING
|
2015-12-29 10:15:58 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SetFacingCounterclockwiseSpin2:
|
2016-09-27 06:37:10 -07:00
|
|
|
call CounterclockwiseSpinAction
|
2015-12-29 10:15:58 -08:00
|
|
|
jp SetFacingStanding
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CounterclockwiseSpinAction:
|
2016-09-27 06:37:10 -07:00
|
|
|
; Here, OBJECT_STEP_FRAME consists of two 2-bit components,
|
|
|
|
; using only bits 0,1 and 4,5.
|
|
|
|
; bits 0,1 is a timer (4 overworld frames)
|
|
|
|
; bits 4,5 determines the facing - the direction is counterclockwise.
|
2015-12-29 10:15:58 -08:00
|
|
|
ld hl, OBJECT_STEP_FRAME
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
and %11110000
|
|
|
|
ld e, a
|
|
|
|
|
|
|
|
ld a, [hl]
|
|
|
|
inc a
|
|
|
|
and %00001111
|
|
|
|
ld d, a
|
|
|
|
cp 4
|
|
|
|
jr c, .ok
|
|
|
|
|
|
|
|
ld d, 0
|
|
|
|
ld a, e
|
|
|
|
add $10
|
|
|
|
and %00110000
|
|
|
|
ld e, a
|
|
|
|
|
|
|
|
.ok
|
|
|
|
ld a, d
|
|
|
|
or e
|
|
|
|
ld [hl], a
|
|
|
|
|
|
|
|
swap e
|
|
|
|
ld d, 0
|
2020-10-22 14:41:48 -07:00
|
|
|
ld hl, .facings
|
2015-12-29 10:15:58 -08:00
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_DIRECTION
|
2015-12-29 10:15:58 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2020-10-22 14:41:48 -07:00
|
|
|
.facings:
|
|
|
|
db OW_DOWN
|
|
|
|
db OW_RIGHT
|
|
|
|
db OW_UP
|
|
|
|
db OW_LEFT
|
2015-12-29 10:15:58 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SetFacingFish:
|
2015-12-29 10:15:58 -08:00
|
|
|
call GetSpriteDirection
|
|
|
|
rrca
|
|
|
|
rrca
|
2016-09-27 06:37:10 -07:00
|
|
|
add FACING_FISH_DOWN
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_FACING
|
2015-12-29 10:15:58 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SetFacingShadow:
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_FACING
|
2015-12-29 10:15:58 -08:00
|
|
|
add hl, bc
|
2016-09-27 07:10:13 -07:00
|
|
|
ld [hl], FACING_SHADOW
|
2015-12-29 10:15:58 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 18:39:23 -07:00
|
|
|
SetFacingEmote:
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_FACING
|
2015-12-29 10:15:58 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], FACING_EMOTE
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SetFacingBigDollSym:
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_FACING
|
2015-12-29 10:15:58 -08:00
|
|
|
add hl, bc
|
2016-09-27 07:10:13 -07:00
|
|
|
ld [hl], FACING_BIG_DOLL_SYM
|
2015-12-29 10:15:58 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SetFacingBounce:
|
2015-12-29 10:15:58 -08:00
|
|
|
ld hl, OBJECT_STEP_FRAME
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
inc a
|
|
|
|
and %00001111
|
|
|
|
ld [hl], a
|
|
|
|
and %00001000
|
2016-09-27 07:10:13 -07:00
|
|
|
jr z, SetFacingFreezeBounce
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_FACING
|
2015-12-29 10:15:58 -08:00
|
|
|
add hl, bc
|
2016-09-27 06:37:10 -07:00
|
|
|
ld [hl], FACING_STEP_UP_0
|
2015-12-29 10:15:58 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SetFacingFreezeBounce:
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_FACING
|
2015-12-29 10:15:58 -08:00
|
|
|
add hl, bc
|
2016-09-27 07:10:13 -07:00
|
|
|
ld [hl], FACING_STEP_DOWN_0
|
2015-12-29 10:15:58 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SetFacingWeirdTree:
|
2015-12-29 10:15:58 -08:00
|
|
|
ld hl, OBJECT_STEP_FRAME
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
inc a
|
|
|
|
ld [hl], a
|
2018-05-23 10:15:07 -07:00
|
|
|
maskbits NUM_DIRECTIONS, 2
|
2015-12-29 10:15:58 -08:00
|
|
|
rrca
|
|
|
|
rrca
|
2016-09-27 07:10:13 -07:00
|
|
|
add FACING_WEIRD_TREE_0
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_FACING
|
2015-12-29 10:15:58 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SetFacingBigDollAsym:
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_FACING
|
2015-12-29 10:15:58 -08:00
|
|
|
add hl, bc
|
2016-09-27 07:10:13 -07:00
|
|
|
ld [hl], FACING_BIG_DOLL_ASYM
|
2015-12-29 10:15:58 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SetFacingBigDoll:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wVariableSprites + SPRITE_BIG_DOLL - SPRITE_VARS]
|
2016-09-27 07:10:13 -07:00
|
|
|
ld d, FACING_BIG_DOLL_SYM ; symmetric
|
2015-12-29 10:15:58 -08:00
|
|
|
cp SPRITE_BIG_SNORLAX
|
|
|
|
jr z, .ok
|
|
|
|
cp SPRITE_BIG_LAPRAS
|
|
|
|
jr z, .ok
|
2016-09-27 07:10:13 -07:00
|
|
|
ld d, FACING_BIG_DOLL_ASYM ; asymmetric
|
2015-12-29 10:15:58 -08:00
|
|
|
|
|
|
|
.ok
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_FACING
|
2015-12-29 10:15:58 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], d
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SetFacingBoulderDust:
|
2015-12-29 10:15:58 -08:00
|
|
|
ld hl, OBJECT_STEP_FRAME
|
|
|
|
add hl, bc
|
|
|
|
inc [hl]
|
|
|
|
ld a, [hl]
|
|
|
|
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_FACING
|
2015-12-29 10:15:58 -08:00
|
|
|
add hl, bc
|
|
|
|
and 2
|
2016-09-27 07:10:13 -07:00
|
|
|
ld a, FACING_BOULDER_DUST_1
|
2015-12-29 10:15:58 -08:00
|
|
|
jr z, .ok
|
2020-10-26 19:24:38 -07:00
|
|
|
inc a
|
|
|
|
assert FACING_BOULDER_DUST_1 + 1 == FACING_BOULDER_DUST_2
|
2015-12-29 10:15:58 -08:00
|
|
|
.ok
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SetFacingGrassShake:
|
2015-12-29 10:15:58 -08:00
|
|
|
ld hl, OBJECT_STEP_FRAME
|
|
|
|
add hl, bc
|
|
|
|
inc [hl]
|
|
|
|
ld a, [hl]
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_FACING
|
2015-12-29 10:15:58 -08:00
|
|
|
add hl, bc
|
|
|
|
and 4
|
2016-09-27 06:37:10 -07:00
|
|
|
ld a, FACING_GRASS_1
|
2015-12-29 10:15:58 -08:00
|
|
|
jr z, .ok
|
2016-09-27 06:37:10 -07:00
|
|
|
inc a ; FACING_GRASS_2
|
2015-12-29 10:15:58 -08:00
|
|
|
|
|
|
|
.ok
|
|
|
|
ld [hl], a
|
|
|
|
ret
|