-
Notifications
You must be signed in to change notification settings - Fork 1
/
my_c64.inc
376 lines (351 loc) · 7.57 KB
/
my_c64.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
VRAM = $0400
CRAM = $d800
MAX_HEIGHT=12
MAX_WIDTH=20
SPACE_COL = 0
BLOCK_COL = 8
TITLE_COL = 7
BLOCK_HI_COL = 10
BLOCK_LO_COL = 9
FLAG_COL = 1
MINE_COL = 2
WONMSG_COL = 7
LOSTMSG_COL = 7
STATIC_HUD_COL = 1
PRESSRET_COL = 8
SIDE_FLAGS_COL = 1
CLOCK_COL = 1
BSIZE_OFF_COL = 11
BSIZE_ON_COL = 10
MENU_BODY_COL = 1
MENU_HL_COL = 7
BYLINE_COL = 11
TITLE_BOX_COL = 7
MENU_BOX_COL = 1
BACKDROP_COL = 11
SPACE_COL_BG = 0
BLOCK_COL_BG = %01000000
BLOCK_LO_COL_BG = %10000000
BLOCK_HI_COL_BG = %11000000
CURSOR_LEFT_MARGIN = 16
CURSOR_TOP_MARGIN = 42
PTR2 = $FB
PTR = $FD
TEMP2 = $4A
BoardScreen = $0400
KEY_RIGHT = $1d
KEY_RIGHT2 = $44 ;D
KEY_LEFT = $9d
KEY_LEFT2 = $41 ; A
KEY_UP = $91
KEY_UP2 = $57 ; W
KEY_DOWN = $11
KEY_DOWN2 = $53 ; S
KEY_FLAG = $0d
KEY_DIG = $20
KEY_FW = $1d
KEY_HW = $9d
KEY_EASIER = $11
KEY_HARDER = $91
KEY_START = $0d
.MACRO start_irq
.ENDMACRO
.MACRO ack_irq
jmp $ea31
.ENDMACRO
.MACRO CLEAR_CURSOR
.ENDMACRO
.macro GETIN
jsr $FFE4 ; GETIN kernal function
.endmacro
.PROC init
lda #0
sta VIC_BORDERCOLOR
lda VIC_VIDEO_ADR
ora #$0e ; set chars location to $3800 for displaying the custom font
sta VIC_VIDEO_ADR
lda VIC_CTRL1 ; mode register
ora #%01000000 ; extended color mode
sta VIC_CTRL1
lda #SPACE_COL
sta VIC_BG_COLOR0
lda #BLOCK_COL
sta VIC_BG_COLOR1
lda #BLOCK_LO_COL
sta VIC_BG_COLOR2
lda #BLOCK_HI_COL
sta VIC_BG_COLOR3
lda #$10
sta VIC_SPR_MCOLOR
lda #0
sta VIC_SPR_BG_PRIO
lda #7
sta VIC_SPR0_COLOR
lda #CURSOR_LEFT_MARGIN
sta VIC_SPR0_X
lda #CURSOR_TOP_MARGIN
sta VIC_SPR0_Y
lda #$80
sta $07f8 ; sprite pointer 1
.ENDPROC
.MACRO show_cursor
lda #$01
sta VIC_SPR_ENA
.ENDMACRO
.MACRO hide_cursor
lda #$00
sta VIC_SPR_ENA
.ENDMACRO
.MACRO SILENCE
lda #0
sta SID_Ctl3
.ENDMACRO
.PROC setup_timer
; sei
; lda #%01010010
; sta $dc0f
lda #$FF
sta $dc04
lda #$44
sta $dc05
lda #$ff
sta $dc06
sta $dc07
lda #<clock
sta $0314
lda #>clock
sta $0315
lda #%00010001
sta $dc0e
; cli
rts
.ENDPROC
.PROC setup_sound
; volume
lda #%00001111
sta SID_Amp
; sound effects control
lda #%01000111
sta SID_AD1
; sound effects frequency
lda #$8
sta SID_S1Hi
lda #$8
sta SID_PB1Hi
rts
.ENDPROC
.PROC dig_sound
lda #0
sta SID_Ctl1
lda #%10000001
sta SID_Ctl1
rts
.ENDPROC
.PROC bass_note
lda #0
sta SID_Ctl2
txa
asl
tax
inx
lda @bass_table,x
sta SID_S2Lo ; frequency
dex
lda @bass_table,x
sta SID_S2Hi
lda #$8
sta SID_PB2Lo ; pulse width
sta SID_PB2Hi
lda #%00100001 ; control register
sta SID_Ctl2
lda #%00000111 ; attack decay
sta SID_AD2
lda #%00001111 ; sustain release
sta SID_SUR2
rts
@bass_table:
.byte $04, $54 ; C
.byte $04, $DC ; D
.byte $05, $26 ; Eflat
.ENDPROC
.PROC treble_note
lda #0
sta SID_Ctl3
;sta SID_C
txa
asl
tax
inx
lda @treble_table,x
sta SID_S3Lo ; frequency
dex
lda @treble_table,x
sta SID_S3Hi
lda #$8
sta SID_PB3Lo ; pulse width
sta SID_PB3Hi
lda #%00010001 ; control register
sta SID_Ctl3
lda #%01000111 ; attack decay
sta SID_AD3
lda #%00011111 ; sustain release
sta SID_SUR3
rts
@treble_table:
.byte $11, $50 ; C
.byte $13, $6F ; D
.byte $14, $96 ; Eflat
.byte $18, $7C ; fsharp
.byte $19, $F0 ; G
.byte $1D, $1E ; A
.ENDPROC
.PROC position_cursor_sprite
lda #0
sta TEMP
lda cursor_col
asl
bcc :+
inc TEMP
: clc
asl
bcc :+
inc TEMP
: clc
asl
bcc :+
inc TEMP
: clc
asl
bcc :+
inc TEMP
: clc
adc #CURSOR_LEFT_MARGIN
bcc :+
inc TEMP
: sta VIC_SPR0_X
lda TEMP
sta VIC_SPR_HI_X
lda cursor_row
asl
asl
asl
asl
adc #CURSOR_TOP_MARGIN
sta VIC_SPR0_Y
lda cursor_col
cmp width_m1
beq :++
lda cursor
cmp size_m1
bcs :+
lda #$80
sta $07f8
rts
: lda #$82
sta $07f8
rts
: lda cursor
cmp size_m1
bcs :+
lda #$81
sta $07f8
rts
: lda #$83
sta $07f8
rts
.endproc
.segment "CURSORS"
cursor_data:
.byte %00000000, %00000000, %00000000
.byte %00000000, %00000000, %00000000
.byte %00000000, %00000000, %00000000
.byte %00000000, %00000000, %00000000
.byte %00001111, %11111111, %11110000
.byte %00001000, %00000000, %00010000
.byte %00001011, %11111111, %11010000
.byte %00001011, %11111111, %11010000
.byte %00001011, %00000000, %11010000
.byte %00001011, %00000000, %11010000
.byte %00001011, %00000000, %11010000
.byte %00001011, %00000000, %11010000
.byte %00001011, %00000000, %11010000
.byte %00001011, %00000000, %11010000
.byte %00001011, %00000000, %11010000
.byte %00001011, %00000000, %11010000
.byte %00001011, %11111111, %11010000
.byte %00001011, %11111111, %11010000
.byte %00001000, %00000000, %00010000
.byte %00001111, %11111111, %11110000
.byte %00000000, %00000000, %00000000
.byte $FE
cursor_right_edge:
.byte %00000000, %00000000, %00000000
.byte %00000000, %00000000, %00000000
.byte %00000000, %00000000, %00000000
.byte %00000000, %00000000, %00000000
.byte %00001111, %11111111, %00000000
.byte %00001000, %00000000, %00000000
.byte %00001011, %11111111, %00000000
.byte %00001011, %11111111, %00000000
.byte %00001011, %00000000, %00000000
.byte %00001011, %00000000, %00000000
.byte %00001011, %00000000, %00000000
.byte %00001011, %00000000, %00000000
.byte %00001011, %00000000, %00000000
.byte %00001011, %00000000, %00000000
.byte %00001011, %00000000, %00000000
.byte %00001011, %00000000, %00000000
.byte %00001011, %11111111, %00000000
.byte %00001011, %11111111, %00000000
.byte %00001000, %00000000, %00000000
.byte %00001111, %11111111, %00000000
.byte %00000000, %00000000, %00000000
.byte $FE
cursor_bottom_edge:
.byte %00000000, %00000000, %00000000
.byte %00000000, %00000000, %00000000
.byte %00000000, %00000000, %00000000
.byte %00000000, %00000000, %00000000
.byte %00001111, %11111111, %11110000
.byte %00001000, %00000000, %00010000
.byte %00001011, %11111111, %11010000
.byte %00001011, %11111111, %11010000
.byte %00001011, %00000000, %11010000
.byte %00001011, %00000000, %11010000
.byte %00001011, %00000000, %11010000
.byte %00001011, %00000000, %11010000
.byte %00001011, %00000000, %11010000
.byte %00001011, %00000000, %11010000
.byte %00001011, %00000000, %11010000
.byte %00001011, %00000000, %11010000
.byte %00000000, %00000000, %00000000
.byte %00000000, %00000000, %00000000
.byte %00000000, %00000000, %00000000
.byte %00000000, %00000000, %00000000
.byte %00000000, %00000000, %00000000
.byte $FE
cursor_bottom_right_edge:
.byte %00000000, %00000000, %00000000
.byte %00000000, %00000000, %00000000
.byte %00000000, %00000000, %00000000
.byte %00000000, %00000000, %00000000
.byte %00001111, %11111111, %00000000
.byte %00001000, %00000000, %00000000
.byte %00001011, %11111111, %00000000
.byte %00001011, %11111111, %00000000
.byte %00001011, %00000000, %00000000
.byte %00001011, %00000000, %00000000
.byte %00001011, %00000000, %00000000
.byte %00001011, %00000000, %00000000
.byte %00001011, %00000000, %00000000
.byte %00001011, %00000000, %00000000
.byte %00001011, %00000000, %00000000
.byte %00001011, %00000000, %00000000
.byte %00000000, %00000000, %00000000
.byte %00000000, %00000000, %00000000
.byte %00000000, %00000000, %00000000
.byte %00000000, %00000000, %00000000
.byte %00000000, %00000000, %00000000
.byte $FE
.segment "CHARS"
.incbin "chars_hires-charset.bin",0,512