-
Notifications
You must be signed in to change notification settings - Fork 1
/
vic20_visuals.inc
727 lines (699 loc) · 13.2 KB
/
vic20_visuals.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
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
FLAG_TILE = 89
COVERED_TILE = 91
SPACE_TILE = 80
MINE_TILE = 90
OFFSET = 80
SPACE_COL = 3
BLOCK_COL = 7
TITLE_COL = 7
BLOCK_HI_COL = 5
BLOCK_LO_COL = 5
FLAG_COL = 7
MINE_COL = 1
WONMSG_COL = 7
LOSTMSG_COL = 2
STATIC_HUD_COL = 1
PRESSRET_COL = 3
SIDE_FLAGS_COL = 1
CLOCK_COL = 1
BSIZE_OFF_COL = 2
BSIZE_ON_COL = 7
MENU_BODY_COL = 1
MENU_HL_COL = 7
BYLINE_COL = 3
TITLE_BOX_COL = 1
MENU_BOX_COL = 1
BACKDROP_COL = 2
.PROC won_screen
jsr conclude_music
lda #0
sta CURSOR_ENABLED
jsr stop_clock
ldx #0
ldy #0
lda #<(VRAM + $01A6 + 44)
sta PTR
lda #>(VRAM + $01A6 + 44)
sta PTR+1
lda #<(CRAM + $01A6 + 44)
sta PTR2
lda #>(CRAM + $01A6 + 44)
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, 25, 15, 21, $20, 23,9,14,33, $20, 62, 0
.ENDPROC
.PROC lost_screen
lda #0
sta CURSOR_ENABLED
jsr conclude_music
jsr stop_clock
jsr reveal_mines
jsr print_board
jsr print_intersections
ldx #0
ldy #0
lda #<(VRAM + $01A6 + 44)
sta PTR
lda #>(VRAM + $0100 + 44)
sta PTR+1
lda #<(CRAM + $01A6 + 44)
sta PTR2
lda #>(CRAM + $0100 + 44)
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, 25, 15, 21, $20, 12,15,19,5,$20, 62, 0
.ENDPROC
.PROC press_return
ldx #0
ldy #0
lda #<(VRAM + $01A6 + 44 +28)
sta PTR
lda #>(VRAM + $01A6 + 44 + 28)
sta PTR+1
lda #<(CRAM + $01A6 + 44 + 28)
sta PTR2
lda #>(CRAM + $01A6 + 44 + 28)
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 + $01CD + 22
sta CRAM + $01CD + 22 + 1
sta CRAM + $01CD + 22 + 2
sta CRAM + $01CD + 22 + 3
sta CRAM + $01CD + 22 + 4
sta CRAM + $01CD + 22 + 5
lda #58
sta VRAM + $01CD+22+3
lda #$20
sta VRAM + $01CD+22
sta VRAM + $01CD+22+1
sta VRAM + $01CD+22+2
sta VRAM + $01CD+22+4
ldx #0
: cpx #22
beq :+
lda #61 ; top border
sta VRAM + $01CD, x
lda #STATIC_HUD_COL
sta CRAM + $01CD, x
inx
jmp :-
: jmp print_hud
.ENDPROC
.PROC print_hud
ldx flags
cpx #44
bcc :+
ldx #44
: ldy #0
lda #227
sta PTR
lda #>(VRAM + $0100)
sta PTR+1
lda #227
sta PTR2
lda #>(CRAM + $0100)
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 #22
bcs :+
dec PTR+1
: sta PTR
lda PTR2
sec
sbc #22
bcs :+
dec PTR2+1
: sta PTR2
jmp @loop
@done:
lda #$20
sta (PTR),Y
rts
.ENDPROC
.PROC print_menu_title
lda #25+22
sta PTR
lda #>VRAM
sta PTR+1
lda #25+22
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 #MAX_WIDTH
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 #245
sta PTR
lda #>(VRAM+$0000)
sta PTR+1
lda #245
sta PTR2
lda #>(CRAM+$0000)
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
.data
left_color: .byte 11
right_color: .byte 10
.code
.ENDPROC
.PROC print_menu_body
lda #24+22+22+22+22+22+1+22
sta PTR
lda #>VRAM
sta PTR+1
lda #24+22+22+22+22+22+1+22
sta PTR2
lda #>CRAM
sta PTR2+1
ldy #0
@loop: lda @menu_body, y
cmp #0
beq @ret
cmp #$FF
beq @continue
sta (PTR), y
cmp #27
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, 28, 58, $20, 4, 9, 6, 6, 9, 3, 21, 12, 20, 25, $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
.byte $FF, $FF, $FF, $20, 27, 58, $20, 2, 15, 1, 18, 4, $20, 19, 9, 26, 5, $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
.byte $FF, $FF, $FF, $20, $20, 8, 1, 12, 6, $20, $20, $20, 6, 21, 12, 12, $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
.byte $FF, $FF, $FF, $20, 29, 30, $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 #<(VRAM + $01E4)
sta PTR
lda #>(VRAM + $01E4)
sta PTR+1
lda #<(CRAM + $01E4)
sta PTR2
lda #>(CRAM + $01E4)
sta PTR2+1
ldy #0
: lda byline, y
cmp #0
beq :+
sta (PTR), y
lda color
sta (PTR2), y
iny
jmp :-
: rts
byline: .byte 13, 1, 4, 5, $20, 2, 25, $20, 12, 9, 1, 13, $20, 15, 39, 3, 15, 14, 14, 15, 18, $20, 0
.data
color: .byte BYLINE_COL
.code
.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 #24
sta PTR
lda #>VRAM
sta PTR+1
lda #24
sta PTR2
lda #>CRAM
sta PTR2+1
lda #TITLE_BOX_COL
jsr draw_box
ldx #8
ldy #14
lda #24+22+22+22+22
sta PTR
lda #>VRAM
sta PTR+1
lda #24+22+22+22+22
sta PTR2
lda #>CRAM
sta PTR2+1
lda #MENU_BOX_COL
jsr draw_box
jsr print_menu_title
jsr print_static_hud
lda #BYLINE_COL
sta print_byline::color
jsr print_byline
jsr print_menu_body
jsr print_board_size
rts
.ENDPROC
.PROC draw_halfwidth_backdrop
ldx #19
ldy #8
lda #10
sta PTR
lda #>VRAM
sta PTR+1
lda #10
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 #22
bcc :+
inc PTR+1
: sta PTR
lda PTR2
clc
adc #22
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
.PROC print_intersections
; PTR stores the current row in video ram
; PTR2 stores the current row in color ram
; Y stores the position in current row
; X stores the current index into the board
lda #<(VRAM + 22)
sta PTR
lda #>(VRAM + 22)
sta PTR+1
lda #<(CRAM + 22)
sta PTR2
lda #>(CRAM + 22)
sta PTR2+1
ldy #0
ldx #0
@loop: tya
pha
lda intersections,X
tay
clc
and #$0F
adc #64
sta TEMP
lda @color_table,y
sta TEMP2
pla
tay
tya
pha
;asl
tay
lda TEMP
sta (PTR),Y
lda TEMP2
sta (PTR2),Y
pla
tay
iny
cpy width
bne @next_col
; we are at the end of the row
ldy #0
lda PTR2
clc
adc #44
sta PTR2
bcc :+
inc PTR2+1
:
lda PTR
clc
adc #44
sta PTR
bcc @next_col
inc PTR+1
@next_col:
inx
cpx size_m1
bcs :+
jmp @loop
: rts
@color_table: .byte BLOCK_LO_COL , BLOCK_HI_COL , BLOCK_LO_COL , BLOCK_HI_COL , BLOCK_LO_COL , BLOCK_LO_COL , BLOCK_HI_COL , BLOCK_HI_COL , BLOCK_LO_COL , BLOCK_HI_COL , BLOCK_LO_COL , BLOCK_HI_COL , BLOCK_LO_COL , BLOCK_HI_COL , BLOCK_LO_COL , BLOCK_LO_COL
.ENDPROC
.PROC print_board
lda #<VRAM
; PTR stores the current row in video ram
; PTR2 stores the current row in color ram
; Y stores the position in current row
; X stores the current index into the board
sta PTR
lda #>VRAM
sta PTR+1
lda #<CRAM
sta PTR2
lda #>CRAM
sta PTR2+1
ldy #0
ldx #0
@loop: lda board,x
and #UNCOVERED
cmp #UNCOVERED
beq @check_mine
;it's covered, is there a flag?
lda board, x
and #FLAG_PLACED
cmp #FLAG_PLACED
bne :+
; cell is flag
lda #FLAG_COL
sta TEMP2
lda #FLAG_TILE
sta TEMP
jmp @draw
: ; cell is covered
lda #BLOCK_COL
sta TEMP2
lda #COVERED_TILE
sta TEMP
jmp @draw
@check_mine:
lda board, X
and #MINE_PLACED
cmp #MINE_PLACED
bne :+
; mine is here
lda #MINE_COL ;red
sta TEMP2
lda #MINE_TILE
sta TEMP
jmp @draw
: lda board,X
and #NEIGHBOURS
cmp #0
bne :+
; no neighbouring mines
lda #BLOCK_HI_COL
sta TEMP2
lda #SPACE_TILE
sta TEMP
jmp @draw
; number for neighbouring mines
: pha
clc
adc #OFFSET
sta TEMP
pla
sta TEMP2
txa
pha
ldx TEMP2
lda @colors,X
sta TEMP2
pla
tax
@draw: lda intersections, X
and #TOP_RIGHT
cmp #TOP_RIGHT
beq :+
lda TEMP
clc
adc #12
sta TEMP
: tya
pha
;asl
tay
lda TEMP
sta (PTR),Y
lda TEMP2
sta (PTR2),Y
pla
tay
iny
cpy width
bne @continue
; we are at the end of the row, move the pointers.
ldy #0
lda PTR2
clc
adc #44
sta PTR2
bcc :+
inc PTR2+1
: lda PTR
clc
adc #44
sta PTR
bcc @continue
inc PTR+1
@continue:
inx
cpx size
beq :+
jmp @loop
: rts
@colors: .byte $0,$3,$5,$7,$1,$1,$1
.ENDPROC