-
Notifications
You must be signed in to change notification settings - Fork 806
/
sleep_talk.asm
141 lines (128 loc) · 1.84 KB
/
sleep_talk.asm
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
BattleCommand_SleepTalk:
call ClearLastMove
ld a, [wAttackMissed]
and a
jr nz, .fail
ldh a, [hBattleTurn]
and a
ld hl, wBattleMonMoves + 1
ld a, [wDisabledMove]
ld d, a
jr z, .got_moves
ld hl, wEnemyMonMoves + 1
ld a, [wEnemyDisabledMove]
ld d, a
.got_moves
ld a, BATTLE_VARS_STATUS
call GetBattleVar
and SLP_MASK
jr z, .fail
ld a, [hl]
and a
jr z, .fail
call .safely_check_has_usable_move
jr c, .fail
dec hl
.sample_move
push hl
call BattleRandom
maskbits NUM_MOVES
ld c, a
ld b, 0
add hl, bc
ld a, [hl]
pop hl
and a
jr z, .sample_move
ld e, a
ld a, BATTLE_VARS_MOVE_ANIM
call GetBattleVar
cp e
jr z, .sample_move
ld a, e
cp d
jr z, .sample_move
call .check_two_turn_move
jr z, .sample_move
ld a, BATTLE_VARS_MOVE
call GetBattleVarAddr
ld a, e
ld [hl], a
call CheckUserIsCharging
jr nz, .charging
ld a, [wBattleAnimParam]
push af
call BattleCommand_LowerSub
pop af
ld [wBattleAnimParam], a
.charging
call LoadMoveAnim
call UpdateMoveData
jp ResetTurn
.fail
call AnimateFailedMove
jp TryPrintButItFailed
.safely_check_has_usable_move
push hl
push de
push bc
call .check_has_usable_move
pop bc
pop de
pop hl
ret
.check_has_usable_move
ldh a, [hBattleTurn]
and a
ld a, [wDisabledMove]
jr z, .got_move_2
ld a, [wEnemyDisabledMove]
.got_move_2
ld b, a
ld a, BATTLE_VARS_MOVE
call GetBattleVar
ld c, a
dec hl
ld d, NUM_MOVES
.loop2
ld a, [hl]
and a
jr z, .carry
cp c
jr z, .nope
cp b
jr z, .nope
call .check_two_turn_move
jr nz, .no_carry
.nope
inc hl
dec d
jr nz, .loop2
.carry
scf
ret
.no_carry
and a
ret
.check_two_turn_move
push hl
push de
push bc
ld b, a
callfar GetMoveEffect
ld a, b
pop bc
pop de
pop hl
cp EFFECT_SKULL_BASH
ret z
cp EFFECT_RAZOR_WIND
ret z
cp EFFECT_SKY_ATTACK
ret z
cp EFFECT_SOLARBEAM
ret z
cp EFFECT_FLY
ret z
cp EFFECT_BIDE
ret