-
Notifications
You must be signed in to change notification settings - Fork 1
/
apple2_rc6502_visuals.inc
282 lines (277 loc) · 5.42 KB
/
apple2_rc6502_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
.proc print_board
ldy #0
ldx #0
stx TMP
@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 #8
sta TEMP
jmp @draw
: ; cell is covered
lda #0
sta TEMP
jmp @draw
@check_mine:
lda board, X
and #MINE_PLACED
cmp #MINE_PLACED
bne :+
; mine is here
lda #16 ; '*' char
sta TEMP
jmp @draw
: lda board,X
and #NEIGHBOURS
cmp #0
bne :+
; no neighbouring mines
lda #24; ' ' char
sta TEMP
jmp @draw
; number for neighbouring mines
: asl
asl
asl
clc
adc #(24)
sta TEMP
@draw: tya
pha
txa
pha
tya
asl
tay
jsr draw_whole_symbol
pla
tax
pla
tay
iny
cpy width
bne @continue
; we are at the end of the row, move the counters
ldy TMP
iny
iny
sty TMP
ldy #0
@continue:
inx
cpx size
beq :+
jmp @loop
: rts
.endproc
.PROC print_verticals
; Y stores the position in current row
; X stores the current index into the board
ldy #0
ldx #0
iny
sty TMP
ldy #0
@loop: tya
pha
lda intersections,X
tay
lda @char_table,y
sta TEMP
pla
tay
tya
pha
asl
tay
txa
pha
jsr draw_whole_symbol
pla
tax
pla
tay
iny
cpy width
bne :+
; we are at the end of the row
ldy TMP
iny
iny
sty TMP
ldy #0
: inx
cpx size_m1
bcs :+
jmp @loop
: rts
@char_table:
; blank ;tl ;tr ;tw ;bl ;lc ;lr ;BR ;br ;rl :rc :BL ;bw ;TR ;TL ;CL
.byte 0, (8*30), 0, (8*30), (8*31), 24, (8*31), 24, 0, (8*30), 0, (8*30), (8*31), 24, (8*31), 24
.ENDPROC
.PROC print_horizontals
; Y stores the position in current row
; X stores the current index into the board
ldy #0
ldx #0
sty TMP
@loop: tya
pha
lda intersections,X
tay
lda @char_table,y
sta TEMP
pla
tay
tya
pha
asl
tay
txa
pha
iny
jsr draw_whole_symbol
pla
tax
pla
tay
iny
cpy width_m1 ; M1 (-1) because we don't print the right edge
bne :+
; we are at the end of the row
inx
ldy TMP
iny
iny
sty TMP
ldy #0
: inx
cpx size
bcs :+
jmp @loop
: rts
@char_table:
; blank ;tl ;tr;tw ;bl ;lc ;lr ;BR ;br ;rl :rc :BL ;bw ;TR ;TL ;CL
.byte (8*29), (96+8),96 ,24 ,(8*29) ,(96+8),96 ,24 ,(8*29) ,(96+8),96, 24, (8*29), (96+8), 96,24
.ENDPROC
.PROC print_intersections
; Y stores the position in current row
; X stores the current index into the board
ldy #0
ldx #0
iny
sty TMP
ldy #0
@loop: tya
pha
lda intersections,X
tay
lda @char_table,y
sta TEMP
pla
tay
tya
pha
asl
tay
txa
pha
iny
jsr draw_whole_symbol
pla
tax
pla
tay
iny
cpy width_m1 ; M1 (-1) because we don't print the right edge
bne :+
; we are at the end of the row
inx
ldy TMP
iny
iny
sty TMP
ldy #0
: inx
cpx size_m1
bcs :+
jmp @loop
: rts
@char_table:
; blank ;tl ;tr ;tw ;bl ;lc ;lr;BR ;br ;rl :rc :BL ;bw ;TR ;TL ;CL
.byte (8*29), (96+32) ,(96+32+8) ,112 ,(96+32+16) ,(96+8),(96+32+32+24+16) ,(96+32+32),(96+32+24) ,(96+32+32+24+8),96, (96+32+32+8), 120, (96+32+32+16), (96+32+32+24), 24
.ENDPROC
.PROC print_hud
ldy flags
ldx #(MAX_HEIGHT*2)
@loop:
cpx #0
beq @done
lda #24
cpy #0
beq :+
dey
lda #(96+64+24+24+8)
cpy #0
beq :+
dey
lda #(96+64+24+24)
: sta TEMP
tya
pha
ldy #(MAX_WIDTH*2-1)
dex
stx TMP
jsr draw_whole_symbol
ldx TMP
pla
tay
jmp @loop
@done:
rts
.ENDPROC
.proc clear_cursor
lda CURSOR_ON
cmp #0
bne :+
rts
: jmp flash_cursor
.endproc
.proc position_cursor_sprite
lda #$0
sta CURSOR_ON
lda #1
sta CURSOR_ENABLED
jmp flash_cursor
.endproc
.proc flash_cursor
lda CURSOR_ENABLED
cmp #0
beq :+
lda CURSOR_ON
eor #$FF
sta CURSOR_ON
lda cursor_col
asl
tay
lda cursor_row
asl
tax
stx TMP
jmp draw_whole_cursor
: rts
.endproc
.PROC print_menu
jsr print_static_hud
jsr print_title
jsr print_hud
jsr print_board_size
rts
.ENDPROC