-
Notifications
You must be signed in to change notification settings - Fork 1
/
my_vic20.inc
211 lines (195 loc) · 2.65 KB
/
my_vic20.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
MAX_HEIGHT=11
MAX_WIDTH=21
PTR2 = $D8
PTR = $DA
RNDL = $DC
RNDH = $DD
CURSOR_ENABLED = $DE
CURSOR_ON = $DF
;CURSOR_TMP = $E8
TEMP2 = $5C
BoardScreen = VRAM
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 $EABF
.ENDMACRO
.MACRO CLEAR_CURSOR
jsr clear_cursor
.ENDMACRO
.macro GETIN
inc RNDL
jsr $FFE4 ; GETIN kernal function
.endmacro
.PROC init
lda #$0
sta CURSOR_ENABLED
sta CURSOR_ON
jsr stop_clock
jsr stop_music
rts
.ENDPROC
VRAM = $1E00
CRAM = $9600
.proc clear_cursor
lda CURSOR_ON
cmp #0
bne :+
rts
: jmp flash_cursor
.endproc
.MACRO show_cursor
.ENDMACRO
.MACRO hide_cursor
.ENDMACRO
.proc flash_cursor
lda CURSOR_ENABLED
cmp #0
beq :+
lda CURSOR_ON
eor #$FF
sta CURSOR_ON
lda #>VRAM
sta PTR+1
lda cursor_col
clc
adc #<VRAM
bcc :+
inc PTR+1
:
sta PTR
ldx cursor_row
loop:
cpx #0
beq done
lda PTR
clc
adc #44
bcc :+
inc PTR+1
: sta PTR
dex
jmp loop
done:
ldx #0
lda (PTR,X)
cmp #104
bcs put_back
clc
adc #24
sta (PTR,X)
jmp :+
put_back:
sec
sbc #24
sta (PTR,X)
: rts
.endproc
.MACRO SILENCE
.ENDMACRO
.PROC setup_timer
; $9125:$9216 contain the timer count, not sure if it needs to be set
sei
lda #<clock
sta $0314
lda #>clock
sta $0315
cli
rts
.ENDPROC
.data
SOUND_TICKS: .byte 0
MUSIC_TICKS: .byte 0
.code
.PROC fade_sfx
lda SOUND_TICKS
cmp #0
beq done
dec SOUND_TICKS
lda SOUND_TICKS
cmp #0
beq stop
jmp done
stop:
lda #0
sta $900D
done:
lda MUSIC_TICKS
cmp #0
beq done2
dec MUSIC_TICKS
lda MUSIC_TICKS
cmp #0
beq stop2
jmp done2
stop2:
lda #0
sta $900C
sta $900A
done2:
rts
.endproc
.PROC setup_sound
lda $900E
ora #$0F
sta $900E
rts
.ENDPROC
.PROC dig_sound
lda #129
ora #%1100000
sta $900D
lda #$A
sta SOUND_TICKS
rts
.ENDPROC
.PROC bass_note
lda notes, X
ora #%1100000
sta $900A
lda #$8
sta MUSIC_TICKS
rts
notes:
.byte 225; C
.byte 228 ; D
.byte 229 ; Eflat
.ENDPROC
; x input
.PROC treble_note
lda notes, X
ora #%1100000
sta $900C
lda #$8
sta MUSIC_TICKS
rts
notes:
.byte 225; C
.byte 228 ; D
.byte 229 ; Eflat
.byte 233 ; fsharp
.byte 235 ; G
.byte 237 ; A
.ENDPROC
.PROC position_cursor_sprite
lda #$0
sta CURSOR_ON
lda #1
sta CURSOR_ENABLED
jmp flash_cursor
.ENDPROC