aboutsummaryrefslogtreecommitdiff
path: root/entity/actions.gbasm
blob: 70327669a4b08218f09fe6fb7832ff9b045f3411 (plain)
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
Entities_Actions:
	LD A, $mem_moving_animation_step
	CP $05
	JR NZ, =.Action_Functions
	CALL =Reset_Entities_Collision_Map

	.Action_Functions:
	LD HL, $mem_entities_list
	CALL =Entity_Action
	CALL =Entity_Action
	CALL =Entity_Action
	CALL =Entity_Action
	CALL =Entity_Action
	CALL =Entity_Action
	CALL =Entity_Action
	CALL =Entity_Action
	CALL =Entity_Action
	CALL =Entity_Action
	CALL =Entity_Action
	CALL =Entity_Action
	CALL =Entity_Action
	CALL =Entity_Action
	CALL =Entity_Action
	CALL =Entity_Action
	RET

Entity_Action:
	LD A, (HL+)
	CP $00
	JR Z, =.skip

	INC HL
	INC HL
	INC HL

	LD E, (HL)
	PUSH HL

	LD A, L
	AND $f0
	LD L, A

	LD BC, =Turn_Jump_table
	LD A, E

	.JUMP_TABLE

	POP HL

	.skip:
	LD A, L
	AND $f0
	ADD $10
	LD L, A
	RET

Update_Animation_Steps:
	LD A, $mem_blinking_animation_counter
	DEC A
	CP $ff
	JR Z, =.Skip_blinking_update
	LD $mem_blinking_animation_counter, A
	.Skip_blinking_update:

	LD A, $mem_map_loading_flags
	BIT 3, A
	JR Z, =.update_mode

	LD A, $mem_moving_animation_step
	INC A
	AND $0f
	LD $mem_moving_animation_step, A

	CP $00
	JR NZ, =.end

	LD A, $mem_map_loading_flags
	RES 3, A
	SET 1, A
	LD $mem_map_loading_flags, A

	.update_mode:

	; We need to make sure that the mode doesn't change to a mode with objects update while a dialogue box refresh is currently being done
	LD A, $mem_current_mode
	BIT 7, A
	JR Z, =.set_current_mode
	LD A, $mem_display_flag
	AND 0b00010100
	CP $00
	JR NZ, =.end

	.set_current_mode:
	LD A, $mem_requested_mode
	LD $mem_current_mode, A

	.end:
	LD A, $mem_bunny_health
	CP $00
	JR Z =.Dead_mode

	RET

	.Dead_mode:

	LD A, $20
	LD $mem_bunny_direction, A

	LD A, $enum_dead_mode
	LD $mem_current_mode, A

	.CLOSE_DIALOGUE

	RET

Turn_Jump_table:
	; 00
	RET
	NOP
	NOP
	NOP

	; 01
	JP =Move_Bunny
	NOP

	; 02
	JP =Fox_Turn
	NOP

	; 03
	JP =Cat_Turn
	NOP

	; 04
	JP =Penguin_Turn
	NOP

Interaction_Jump_table:
	; 00
	RET
	NOP
	NOP
	NOP

	; 01
	JP =Enemy_Interaction
	NOP

	; 02
	JP =Open_Dialogue
	NOP

Open_Dialogue:
	LD A, L
	AND $f0
	LD L, A

	INC HL

	LD A, $mem_bunny_x
	CP (HL)
	JR Z, =.Vertical_check

	.Horizontal_check:
		INC A
		CP (HL)
		JR Z, =.Left
		.Right:
			INC HL
			INC HL
			LD (HL), $enum_direction_right
			JR =.Check_end
		.Left:
			INC HL
			INC HL
			LD (HL), $enum_direction_left
			JR =.Check_end
	.Vertical_check:
		INC HL
		LD A, $mem_bunny_y
		INC A
		CP (HL)
		JR Z, =.Up
		.Down:
			INC HL
			LD (HL), $enum_direction_down
			JR =.Check_end
		.Up:
			INC HL
			LD (HL), $enum_direction_up
			JR =.Check_end
	.Check_end:

	LD HL, $dialogue_first_line
	LD BC, =Bunny_Prefix
	CALL =Print_str

	LD HL, $dialogue_third_line
	LD BC, =Text_1
	CALL =Print_str

	LD A, $07
	LD $mem_display_flag, A

	LD A, $mem_bunny_direction
	AND $0f
	LD $mem_bunny_direction, A

	LD A, $enum_dungeon_dialogue_mode
	LD $mem_requested_mode, A
	RET

Enemy_Interaction:
	LD A, L
	AND $f0
	ADD $06
	LD L, A
	LD A, (HL)
	DEC A
	DAA
	LD (HL+), A

	SET 3, (HL)
	LD A, $24
	LD $mem_blinking_animation_counter, A

	RET