-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1_menu.asm
423 lines (289 loc) · 6.11 KB
/
1_menu.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
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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
; /////////////////////////////////////////////////////////////////////////////
; Znake (ZX Spectrum 48K)
; -----------------------------------------------------------------------------
; 1_menu.asm
; -----------------------------------------------------------------------------
; Copyright (C) 2016, Chris Wyatt
; All rights reserved
; Distributed under the Apache 2 license (see LICENSE)
; /////////////////////////////////////////////////////////////////////////////
select_difficulty_draw:
ld b,6
select_difficulty_draw_next:
push hl
push de
push bc
call draw_char
pop bc
pop de
pop hl
inc d
djnz select_difficulty_draw_next
ret
select_difficulty:
ld hl,difficulties
ld de,DIFFICULTIES_ROW_LENGTH
or a ; Reset carry flag
sbc hl,de
select_difficulty_move_pointer:
add hl,de
djnz select_difficulty_move_pointer
push hl
pop ix
ld d,(ix + 3)
ld e,(ix + 2)
ld hl,0x81c0
call select_difficulty_draw
ret
control_select:
; Set border color to black
xor a ; a = 0
call $229B
; Clear screen
ld hl,0x4000
ld de,0x4001
ld bc,0x17ff
ld (hl),0
ldir
ld iy,draw_line
ld de,0x0b08
ld hl,str_title
call print
ld de,0x0a0a
ld hl,str_keyboard
call print
ld de,0x0a0b
ld hl,str_kempston
call print
control_select_check_key:
ld a,0xbf
in a,(0xfe)
bit 2,a
jr z,menu_start
bit 3,a
jr nz,control_select_check_key
enable_kempston:
ld hl,flags
set 1,(hl)
menu_start:
ld a,(23672)
ld (menu_last_direction_frame_count),a
; Clear screen
ld hl,0x4000
ld de,0x4001
ld bc,0x17ff
ld (hl),0
ldir
ld ix,difficulties
ld iy,draw_line_xor
; Push col/row and memory locations of graphics to stack, ready to draw
; later
; Push top border
ld b,12
; Location of border top
ld hl,0x8180
; Column/row
ld de,0x0a05
menu_push_top_border_next:
push hl
push de
inc d
djnz menu_push_top_border_next
; Push right border
ld b,11
; Location of border right
ld hl,0x8188
; Column/row
ld de,0x1606
menu_push_right_border_next:
push hl
push de
inc e
djnz menu_push_right_border_next
; Push bottom border
ld b,12
; Location of border bottom
ld hl,0x8190
; Column/row
ld de,0x0a11
menu_push_bottom_border_next:
push hl
push de
inc d
djnz menu_push_bottom_border_next
; Push left border
ld b,11
; Location of border left
ld hl,0x8198
; Column/row
ld de,0x0906
menu_push_left_border_next:
push hl
push de
inc e
djnz menu_push_left_border_next
; Push border corners
; Location of border top-right
ld hl,0x81a0
; Column/row
ld de,0x1605
push hl
push de
; Location of border bottom-right
ld hl,0x81a8
; Column/row
ld de,0x1611
push hl
push de
; Location of border bottom-left
ld hl,0x81b0
; Column/row
ld de,0x0911
push hl
push de
; Location of border top-left
ld hl,0x81b8
; Column/row
ld de,0x0905
push hl
push de
ld c,12 + 11 + 12 + 11 + 4
halt
menu_draw_border_char:
pop de
pop hl
call draw_char
dec c
jr nz,menu_draw_border_char
ld hl,str_title
ld de,0x0b02
call print
ld hl,str_credits
ld de,0x0415
call print
ld h,(ix + 1)
ld l,(ix)
ld d,(ix + 3)
ld e,(ix + 2)
call print
ld h,(ix + DIFFICULTIES_ROW_LENGTH + 1)
ld l,(ix + DIFFICULTIES_ROW_LENGTH)
ld d,(ix + DIFFICULTIES_ROW_LENGTH + 3)
ld e,(ix + DIFFICULTIES_ROW_LENGTH + 2)
call print
ld h,(ix + DIFFICULTIES_ROW_LENGTH * 2 + 1)
ld l,(ix + DIFFICULTIES_ROW_LENGTH * 2)
ld d,(ix + DIFFICULTIES_ROW_LENGTH * 2 + 3)
ld e,(ix + DIFFICULTIES_ROW_LENGTH * 2 + 2)
call print
ld h,(ix + DIFFICULTIES_ROW_LENGTH * 3 + 1)
ld l,(ix + DIFFICULTIES_ROW_LENGTH * 3)
ld d,(ix + DIFFICULTIES_ROW_LENGTH * 3 + 3)
ld e,(ix + DIFFICULTIES_ROW_LENGTH * 3 + 2)
call print
ld h,(ix + DIFFICULTIES_ROW_LENGTH * 4 + 1)
ld l,(ix + DIFFICULTIES_ROW_LENGTH * 4)
ld d,(ix + DIFFICULTIES_ROW_LENGTH * 4 + 3)
ld e,(ix + DIFFICULTIES_ROW_LENGTH * 4 + 2)
call print
ld a,(difficulty)
inc a
ld b,a
ld de,DIFFICULTIES_ROW_LENGTH
ld ix,difficulties - 5
select_difficulty_offset_increment:
add ix,de
djnz select_difficulty_offset_increment
ld hl,0x81c0
ld d,(ix + 1)
ld e,(ix)
call select_difficulty_draw
input_loop:
; Map Q, A, [ENTER] to Kempston bits: 000FUDLR
ld c,0x01
ld a,0xfb ; 7 R E W Q
in a,(0xfe)
cpl
and c
rlca
rlca
rlca
ld b,a
ld a,0xfd ; G F D S A
in a,(0xfe)
cpl
and c
rlca
rlca
or b
ld b,a
ld a,0xbf ; H J K L [ENTER]
in a,(0xfe)
cpl
and c
rrca
rrca
rrca
rrca
or b
ld b,a
ld hl,flags
bit 1,(hl)
jr z,input_loop_skip_kempston
in a,(0x1f)
and 0x1c
or b
ld b,a
input_loop_skip_kempston:
; Only capture up/down
and 0x0f
ld hl,menu_last_direction
cp (hl)
jr nz,menu_change_direction
; Same direction
bit 4,b
jr nz,init
ld a,(23672)
ld hl,menu_last_direction_frame_count
sub (hl)
sub 20
jr c,input_loop
menu_change_direction:
ld a,b
ld (menu_last_direction),a
ld a,(23672)
ld (menu_last_direction_frame_count),a
ld hl,difficulty
ld a,b
bit 3,a
jr nz,menu_kempston_joy_up
bit 2,a
jr nz,menu_kempston_joy_down
jr input_loop
menu_kempston_joy_up:
ld a,(hl)
dec a
jp p,unselect_current_difficulty
ld a,4
jp unselect_current_difficulty
menu_kempston_joy_down:
ld a,(hl)
inc a
cp 5
jr nz,unselect_current_difficulty
xor a
unselect_current_difficulty:
ld d,a
push de
ld b,(hl)
inc b
call select_difficulty
; Select new difficulty
pop af
; Store new difficulty
ld hl,difficulty
ld (hl),a
ld b,a
inc b
call select_difficulty
jp input_loop