-
Notifications
You must be signed in to change notification settings - Fork 1
/
c64_c16_common.inc
501 lines (486 loc) · 8.77 KB
/
c64_c16_common.inc
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
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
.PROC won_screen
jsr conclude_music
lda #0
.ifdef __PLUS4__
sta CURSOR_ENABLED
.endif
jsr stop_clock
ldx #0
ldy #0
lda #$A5
sta PTR
lda #>(VRAM + $0300)
sta PTR+1
lda #$A5
sta PTR2
lda #>(CRAM + $0300)
sta PTR2+1
@loop:
lda @won_message,X
cmp #0
beq @ret
;ora #SPACE_COL_BG
sta (PTR),Y
cmp #63
beq :+
cmp #62
beq :+
lda #WONMSG_COL
jmp :++
: lda #STATIC_HUD_COL
: sta (PTR2),Y
lda PTR
clc
adc #1
bcc :+
inc PTR+1
: sta PTR
lda PTR2
clc
adc #1
bcc :+
inc PTR2+1
: sta PTR2
inx
jmp @loop
@ret:
jmp press_return
@won_message: .byte 63, $20, $20, 25, 15, 21, $20, 23,9,14,33, $20, $20, 62, 0
.ENDPROC
.PROC lost_screen
lda #0
.ifdef __PLUS4__
sta CURSOR_ENABLED
.endif
jsr conclude_music
jsr stop_clock
jsr reveal_mines
jsr print_board
jsr print_intersections
jsr print_horizontals
jsr print_verticals
ldx #0
ldy #0
lda #$A5
sta PTR
lda #>(VRAM + $0300)
sta PTR+1
lda #$A5
sta PTR2
lda #>(CRAM + $0300)
sta PTR2+1
@loop:
lda @lost_message,X
cmp #0
beq @ret
;ora #SPACE_COL_BG
sta (PTR),Y
cmp #63
beq :+
cmp #62
beq :+
lda #LOSTMSG_COL
jmp :++
: lda #STATIC_HUD_COL
: sta (PTR2),Y
lda PTR
clc
adc #1
bcc :+
inc PTR+1
: sta PTR
lda PTR2
clc
adc #1
bcc :+
inc PTR2+1
: sta PTR2
inx
jmp @loop
@ret:
jmp press_return
@lost_message: .byte 63, $20, $20, 25, 15, 21, $20, 12,15,19,5,$20,$20, 62, 0
.ENDPROC
.PROC press_return
ldx #0
ldy #0
lda #$CE
sta PTR
lda #>(VRAM + $0300)
sta PTR+1
lda #$CE
sta PTR2
lda #>(CRAM + $0300)
sta PTR2+1
@loop:
lda pak_message,X
cmp #0
beq wait_for_return
;ora #SPACE_COL_BG
sta (PTR),Y
lda #PRESSRET_COL
sta (PTR2),Y
lda PTR
clc
adc #1
bcc :+
inc PTR+1
: sta PTR
lda PTR2
clc
adc #1
bcc :+
inc PTR2+1
: sta PTR2
inx
jmp @loop
wait_for_return:
jsr $FFE4; GETIN kernal
cmp #$0D
beq :+
jmp wait_for_return
: jmp main_menu
pak_message: .byte 16,18,5,19,19,$20,18,5,20,21,18,14,0
.ENDPROC
.PROC print_static_hud
lda #CLOCK_COL
sta CRAM + $03c0
sta CRAM + $03c1
sta CRAM + $03c2
sta CRAM + $03c3
sta CRAM + $03c4
lda #58
sta VRAM + $03c2
ldx #0
: cpx #40
beq :+
lda #61 ; top border
sta VRAM + $0398, x
lda #STATIC_HUD_COL
sta CRAM + $0398, x
inx
jmp :-
: jmp print_hud
.ENDPROC
.PROC print_hud
ldx flags
ldy #0
lda #$97
sta PTR
lda #>(VRAM + $0300)
sta PTR+1
lda #$97
sta PTR2
lda #>(CRAM + $0300)
sta PTR2+1
@loop:
cpx #0
beq @done
dex
lda #59
cpx #0
beq :+
dex
lda #60
: sta (PTR),Y
lda #SIDE_FLAGS_COL
sta (PTR2),Y
lda PTR
sec
sbc #40
bcs :+
dec PTR+1
: sta PTR
lda PTR2
sec
sbc #40
bcs :+
dec PTR2+1
: sta PTR2
jmp @loop
@done:
lda #$20
sta (PTR),Y
rts
.ENDPROC
.PROC print_menu_title
lda #92
sta PTR
lda #>VRAM
sta PTR+1
lda #92
sta PTR2
lda #>CRAM
sta PTR2+1
ldy #0
: lda @title, y
cmp #0
beq :+
sta (PTR), y
lda @color
sta (PTR2), y
iny
jmp :-
: rts
@title: .byte $20, 1, 18, 3, 8, 1, 5, 15, 12, 15, 7, 9, 19, 20, 0
@color: .byte TITLE_COL
.ENDPROC
.PROC print_board_size
lda width
cmp #20
bne @hw
lda #BSIZE_OFF_COL
sta left_color
lda #BSIZE_ON_COL
sta right_color
jmp @onwards
@hw:
lda #BSIZE_ON_COL
sta left_color
lda #BSIZE_OFF_COL
sta right_color
@onwards:
lda #156
sta PTR
lda #>(VRAM + $0100)
sta PTR+1
lda #156
sta PTR2
lda #>(CRAM + $0100)
sta PTR2+1
lda left_color
sta TEMP
ldy #0
: lda @string, y
cmp #0
beq :++
cmp #$FF
bne :+
lda right_color
sta TEMP
lda #$20
: sta (PTR), y
lda TEMP
sta (PTR2), y
iny
jmp :--
:
rts
@string: .byte $20, $20, 8, 1, 12, 6, $20, $FF, $20, 6, 21, 12, 12, 0
left_color: .byte 11
right_color: .byte 10
.ENDPROC
.PROC print_menu_body
lda #36
sta PTR
lda #>(VRAM + $0100)
sta PTR+1
lda #36
sta PTR2
lda #>(CRAM + $0100)
sta PTR2+1
ldy #0
@loop: lda @menu_body, y
cmp #0
beq @ret
cmp #$FF
beq @continue
sta (PTR), y
cmp #44
bcs @hl
lda @menu_body_color
jmp @nohl
@hl: lda @menu_hl_color
@nohl: sta (PTR2), y
@continue:
iny
jmp @loop
@ret:
rts
@menu_body:
.byte $20, 46, 58, $20, 4, 9, 6, 6, 9, 3, 21, 12, 20, 25, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
.byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $20, 47, 58, $20, 2, 15, 1, 18, 4, $20, 19, 9, 26, 5,$FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
.byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
.byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $20, $20, 8, 1, 12, 6, $20, $20, $20, 6, 21, 12, 12, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
.byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
.byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $20, 45, 44, $20, 19, 20, 1, 18, 20, $20, 7, 1, 13, 5, 0
@menu_body_color: .byte MENU_BODY_COL
@menu_hl_color: .byte MENU_HL_COL
.ENDPROC
.PROC print_byline
;MADE BY LIAM O'CONNOR IN 2020
lda #$C0
sta PTR
lda #>(VRAM + $0300)
sta PTR+1
lda #$C0
sta PTR2
lda #>(CRAM + $0300)
sta PTR2+1
ldy #0
: lda byline, y
cmp #0
beq :+
sta (PTR), y
lda color
sta (PTR2), y
iny
jmp :-
: rts
byline: .byte $20, $20, $20, $20, $20, 13, 1, 4, 5, $20, 2, 25, $20, 12, 9, 1, 13, $20, 15, 39, 3, 15, 14, 14, 15, 18, $20, 9, 14, $20, 50, 48, 50, 48, 0
color: .byte BYLINE_COL
.ENDPROC
.PROC hide_byline
lda print_byline::color
pha
lda #0
sta print_byline::color
jsr print_byline
pla
sta print_byline::color
rts
.ENDPROC
.PROC print_menu
ldx #1
ldy #14
lda #51
sta PTR
lda #>VRAM
sta PTR+1
lda #51
sta PTR2
lda #>CRAM
sta PTR2+1
lda #TITLE_BOX_COL
jsr draw_box
ldx #8
ldy #14
lda #211
sta PTR
lda #>VRAM
sta PTR+1
lda #211
sta PTR2
lda #>CRAM
sta PTR2+1
lda #MENU_BOX_COL
jsr draw_box
jsr print_menu_title
jsr print_static_hud
jsr print_byline
jsr print_menu_body
jsr print_board_size
rts
.ENDPROC
.PROC draw_halfwidth_backdrop
ldx #21
ldy #17
lda #19
sta PTR
lda #>VRAM
sta PTR+1
lda #19
sta PTR2
lda #>CRAM
sta PTR2+1
lda #BACKDROP_COL
jmp draw_box
.ENDPROC
; put rows in x and cols in y, color in a
; set PTR and PTR2 to locations to print in screen and color ram
; respectively
.PROC draw_box
pha ; color
iny
inx
iny
sty TEMP2 ; cols
; first, draw the top border
; top right:
sta (PTR2),y
lda #36
sta (PTR),y
dey
; top middle
: cpy #0
beq :+
pla
pha
sta (PTR2),y
lda #61
sta (PTR),y
dey
jmp :-
: ;top left
pla
pha
sta (PTR2),y
lda #35
sta (PTR), y
@row_loop:
dex
lda PTR
clc
adc #40
bcc :+
inc PTR+1
: sta PTR
lda PTR2
clc
adc #40
bcc :+
inc PTR2+1
: sta PTR2
ldy TEMP2
cpx #0
beq :+++
; middle right:
pla
pha
sta (PTR2),y
lda #62
sta (PTR),y
dey
; middle middle
: cpy #0
beq :+
pla
pha
sta (PTR2),y
lda #$20
sta (PTR),y
dey
jmp :-
: ;middle left
pla
pha
sta (PTR2),y
lda #63
sta (PTR), y
jmp @row_loop
: ldy TEMP2 ; bottom right
pla
pha
sta (PTR2),y
lda #38
sta (PTR),y
dey
; bottom middle
: cpy #0
beq :+
pla
pha
sta (PTR2),y
lda #61
sta (PTR),y
dey
jmp :-
: ;bottom left
pla
pha
sta (PTR2),y
lda #37
sta (PTR), y
pla
rts
.ENDPROC