1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
TryPushingBoulder::
ld a, [wd728]
bit 0, a ; using Strength?
ret z
ld a, [wFlags_0xcd60]
bit 1, a ; has boulder dust animation from previous push played yet?
ret nz
xor a
ldh [hSpriteIndexOrTextID], a
call IsSpriteInFrontOfPlayer
ldh a, [hSpriteIndexOrTextID]
ld [wBoulderSpriteIndex], a
and a
jp z, ResetBoulderPushFlags
ld hl, wSpritePlayerStateData1MovementStatus
ld d, $0
ldh a, [hSpriteIndexOrTextID]
swap a
ld e, a
add hl, de
res 7, [hl]
call GetSpriteMovementByte2Pointer
ld a, [hl]
cp BOULDER_MOVEMENT_BYTE_2
jp nz, ResetBoulderPushFlags
ld hl, wFlags_0xcd60
bit 6, [hl]
set 6, [hl] ; indicate that the player has tried pushing
ret z ; the player must try pushing twice before the boulder will move
ldh a, [hJoyHeld]
and D_RIGHT | D_LEFT | D_UP | D_DOWN
ret z
predef CheckForCollisionWhenPushingBoulder
ld a, [wTileInFrontOfBoulderAndBoulderCollisionResult]
and a ; was there a collision?
jp nz, ResetBoulderPushFlags
ldh a, [hJoyHeld]
ld b, a
ld a, [wSpritePlayerStateData1FacingDirection]
cp SPRITE_FACING_UP
jr z, .pushBoulderUp
cp SPRITE_FACING_LEFT
jr z, .pushBoulderLeft
cp SPRITE_FACING_RIGHT
jr z, .pushBoulderRight
.pushBoulderDown
bit 7, b
ret z
ld de, PushBoulderDownMovementData
jr .done
.pushBoulderUp
bit 6, b
ret z
ld de, PushBoulderUpMovementData
jr .done
.pushBoulderLeft
bit 5, b
ret z
ld de, PushBoulderLeftMovementData
jr .done
.pushBoulderRight
bit 4, b
ret z
ld de, PushBoulderRightMovementData
.done
call MoveSprite
ld a, SFX_PUSH_BOULDER
call PlaySound
ld hl, wFlags_0xcd60
set 1, [hl]
ret
PushBoulderUpMovementData:
db NPC_MOVEMENT_UP
db -1 ; end
PushBoulderDownMovementData:
db NPC_MOVEMENT_DOWN
db -1 ; end
PushBoulderLeftMovementData:
db NPC_MOVEMENT_LEFT
db -1 ; end
PushBoulderRightMovementData:
db NPC_MOVEMENT_RIGHT
db -1 ; end
DoBoulderDustAnimation::
ld a, [wd730]
bit 0, a
ret nz
callfar AnimateBoulderDust
call DiscardButtonPresses
ld [wJoyIgnore], a
call ResetBoulderPushFlags
set 7, [hl]
ld a, [wBoulderSpriteIndex]
ldh [hSpriteIndex], a
call GetSpriteMovementByte2Pointer
ld [hl], $10
ld a, SFX_CUT
jp PlaySound
ResetBoulderPushFlags:
ld hl, wFlags_0xcd60
res 1, [hl]
res 6, [hl]
ret
|