aboutsummaryrefslogtreecommitdiff
path: root/gui.gbasm
blob: 2e8e8f6cab68b6445aefdfdb7a19d98851750a0d (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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
.MACRODEF CLOSE_DIALOGUE
	LD A, $04
	LD $mem_display_flag, A

	LD HL, $dialogue_first_line
	LD BC, $12
	CALL =bzero

	LD HL, $dialogue_third_line
	LD BC, $12
	CALL =bzero
.END

Copy_Dialogue_Buffer:
	LD A, $mem_current_focused_attack_ep_cost
	LD HL, $9c43
	CALL =Print_8bit_Thin

	LD A, $mem_display_flag
	BIT 2, A
	RET Z
	RES 2, A
	LD $mem_display_flag, A
	LD HL, $9cb4
	LD DE, $dialogue_first_line
	LD C, $12
	CALL =tilemap_memcpy

	; LD HL, $9cd4
	; LD DE, $dialogue_second_line
	; LD C, $12
	; CALL =tilemap_memcpy

	LD HL, $9cf4
	LD DE, $dialogue_third_line
	LD C, $12
	JP =tilemap_memcpy

Init_Menu:
	LD HL, $mem_bunny_attacks

	.MACRODEF SETUP_NEXT_ATTACK_MENU dialogue_buffer choice_routine ; Attack index pointer in (HL)
		PUSH HL

		; Getting Attack list pointer from index
		LD E, (HL)
		LD D, $00
		SLA E
		RL D
		SLA E
		RL D
		SLA E
		RL D

		LD HL, =Attack_List
		LD A, L
		ADD E
		LD L, A
		LD A, H
		ADC D
		LD H, A

		; Printing txt into dialogue buffer
		LD A, (HL+)
		LD B, A
		LD A, (HL+)
		LD C, A

		LD E, L
		LD D, H
		LD HL, $dialogue_buffer
		CALL =Print_str
		LD H, D
		LD L, E

		; Setting up choice routine
		LD A, (HL+)
		LD B, A
		LD A, (HL+)
		LD C, A

		LD D, H
		LD E, L
		LD HL, $choice_routine
		LD A, B
		LD (HL+), A
		LD A, C
		LD (HL), A

		POP HL
		INC HL
	.END

	.SETUP_NEXT_ATTACK_MENU $dialogue_menu_choice1, $dialogue_menu_choice1_routine
	.SETUP_NEXT_ATTACK_MENU $dialogue_menu_choice2, $dialogue_menu_choice2_routine
	.SETUP_NEXT_ATTACK_MENU $dialogue_menu_choice3, $dialogue_menu_choice3_routine
	.SETUP_NEXT_ATTACK_MENU $dialogue_menu_choice4, $dialogue_menu_choice4_routine
	RET

Nothing:
	RET

Exit_Menu:
	LD A, $enum_dungeon_mode
	LD $mem_requested_mode, A

	.CLOSE_DIALOGUE

	RET

Display_dialogue_cursor:
	LD A, $mem_current_mode
	CP $enum_dungeon_menu_mode
	RET NZ

	LD A, $mem_current_focused_attack_ep_cost
	LD B, A
	LD A, $mem_bunny_mana
	CP B
	LD H, $69
	JR NC, =.Skip_Disable_cursor_setting
	LD H, $6b
	.Skip_Disable_cursor_setting:

	LD A, $mem_menu_cursor_position
	LD BC, $0000
	LD DE, $0000

	CP $00
	JR NZ, =.choice1_false
	LD B, H
	.choice1_false:

	CP $01
	JR NZ, =.choice2_false
	LD C, H
	.choice2_false:

	CP $02
	JR NZ, =.choice3_false
	LD D, H
	.choice3_false:

	CP $03
	JR NZ, =.choice4_false
	LD E, H
	.choice4_false:

	LD A, B
	LD $dialogue_menu_choice1_cursor, A
	LD A, C
	LD $dialogue_menu_choice2_cursor, A
	LD A, D
	LD $dialogue_menu_choice3_cursor, A
	LD A, E
	LD $dialogue_menu_choice4_cursor, A
	RET

Move_dialogue_cursor:
	LD A, $mem_current_mode
	CP $enum_dungeon_menu_mode
	RET NZ

	LD A, $mem_last_button_direction
	LD B, A
	LD A, $mem_button_direction
	CP $00
	RET Z
	CP B
	RET Z

	DEC A
	BIT 1, A
	JR Z, =.Vertical_axis
	LD A, $mem_menu_cursor_position
	XOR $02
	LD $mem_menu_cursor_position, A
	JR =Reload_EP_Cost

	.Vertical_axis:
	LD A, $mem_menu_cursor_position
	XOR $01
	LD $mem_menu_cursor_position, A

Reload_EP_Cost:
	LD A, $mem_menu_cursor_position
	ADD low($mem_bunny_attacks)
	LD L, A
	LD A, high($mem_bunny_attacks)
	ADC $00
	LD H, A

	; Getting Attack list pointer from index
	LD E, (HL)
	LD D, $00
	SLA E
	RL D
	SLA E
	RL D
	SLA E
	RL D

	LD HL, =Attack_List
	LD A, L
	ADD E
	ADD $04
	LD L, A
	LD A, H
	ADC D
	LD H, A

	LD A, (HL)
	LD $mem_current_focused_attack_ep_cost, A

	RET

Check_dialogue_action:
	LD A, $mem_current_mode
	CP $enum_dungeon_menu_mode
	JR Z, =.Check_exit

	CP $enum_dungeon_dialogue_mode
	RET NZ

	.Check_exit:
	LD A, $mem_last_button_action
	LD B, A
	LD A, $mem_button_action
	CP B
	RET Z
	BIT 3, A
	JP NZ, =Exit_Menu
	BIT 0, A
	RET Z

	LD A, $mem_current_mode
	CP $enum_dungeon_menu_mode
	RET NZ

	LD HL, $dialogue_menu_choice1_routine

	LD A, $mem_menu_cursor_position
	SLA A
	ADD L
	LD L, A

	LD A, (HL+)
	LD D, A
	LD A, (HL+)
	LD E, A

	.CALL_DE
	RET

Check_Open_Menu_button:
	LD A, $mem_current_mode
	CP $enum_dungeon_mode
	RET NZ

	LD A, $mem_last_button_action
	AND $08
	LD B, A
	LD A, $mem_button_action
	AND $08
	CP B
	RET Z
	BIT 3, A
	RET Z

	CALL =Init_Menu

	LD A, $enum_dungeon_menu_mode
	LD $mem_requested_mode, A
	RET

Open_dialogue_on_dungeon_menu_mode:
	LD A, $mem_current_mode
	CP $enum_dungeon_menu_mode
	RET NZ
	LD A, $mem_requested_mode
	CP $enum_dungeon_menu_mode
	RET NZ

	LD A, $0d
	LD $mem_display_flag, A

	RET