-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnova_2023_1.s65
203 lines (175 loc) · 5.41 KB
/
nova_2023_1.s65
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
.include "submodules/beeb/include/beeb.s65"
.cpu '65c02'
; refinement of lovebyte_2023_2
DMAX_COLOUR_CHANGE_COUNTER_VALUE=10 ; must be 10!
MIN_MAX_COLOUR=16
MAX_MAX_COLOUR=22
;-------------------------------------------------------------------------
*=$1900+MIN_MAX_COLOUR-2
.word entry
.dsection code
;-------------------------------------------------------------------------
sn_freq_reg: .function ch
.cerror ch<0||ch>3,"invalid SN channel"
.endfunction $80|ch<<5
sn_atten_reg: .function ch
.cerror ch<0||ch>3,"invalid SN channel"
.endfunction $80|ch<<5|$10
sn_atten: .function ch,atten
.cerror ch<0||ch>3,"invalid SN channel"
.cerror atten<0||atten>15,"invalid SN attenuation"
.endfunction sn_atten_reg(ch)|atten
sn_freqh: .function freq
.cerror freq<0||freq>1023,"invalid SN frequency"
.endfunction freq>>4
sn_freql: .function ch,freq
.cerror freq<0||freq>1023,"invalid SN frequency"
.endfunction sn_freq_reg(ch)|freq&15
.section code
start:
init_prints:
.byte 22
dmax_colour_change_counter_initial:
.byte 10
init_prints_end:
entry:
ldx #0
copy_zp_loop:
.cerror (<start)!=MIN_MAX_COLOUR,"oops"
max_colour_initial=*+1;;;;;;<--note
lda start,x;;<--note
sta 0,x
cpx #init_prints_end-init_prints
bcs +
jsr oswrch
+
sei
stx system_via.ddra
inx
bne copy_zp_loop
.byte $4c ;JMP abs
.byte <zp_code_actual_start ;JMP abs LSB
.logical *-start
pixels:
.byte $00 ;also JMP abs MSB
.byte $20
.byte $30
.byte $12
.byte $03
.byte $23
.byte $33
.byte $19
.byte $0c
.byte $2c
.byte $3c
.byte $1e
.byte $0f
.byte $2f
.byte $3f
pixels_end:
; max_colour: .byte MIN_MAX_COLOUR
max_colour=max_colour_initial-start
dmax_colour_change_counter=dmax_colour_change_counter_initial-start
zp_code_actual_start:
; lda #sn_atten(1,1)
; jsr sn_write
; ; silence startup beep on tone 3
; lda #sn_atten(0,15)
; jsr sn_write
main_loop:
ldy #19
blocks_loop:
colour=*+1;;;;;;;;;;;;;;;;;<--note
ldx #0;;;;;<--note
inx
cpx max_colour
bcc got_colour
ldx #0
got_colour:
stx colour
lda #0
cpx #pixels_end-pixels
bcs fill
lda pixels,x
fill:
ldx #7
fill_loop:
dest=*+1;;;;;;;;;;;;;;;;;;;;;;<-- note
sta $3000,x;;;<-- note
dex
bpl fill_loop
lda #13
fe00_constant=*+1;;;;;;;;;;<--note
sta $fe00;;<--note
fe01_constant=*+1;;;;;;;;;;<--note
inc $fe01;;<--note
bne got_crtc
dec a
sta (fe00_constant)
lda (fe01_constant)
inc a
cmp #$10
bcc got_crtc_msb
lda #$06
got_crtc_msb:
sta (fe01_constant)
got_crtc:
clc
lda dest+0
adc #8
sta dest+0
bcc dest_updated
update_dmax_colour:
dec dmax_colour_change_counter
bne update_dest_msb
; C=1 - 0=+1, $fe=-1
lda max_colour
dmax_colour=*+1;;;;;;;;;<--note
adc #0;;<--note
cmp #MAX_MAX_COLOUR+1
bcc max_max_ok
max_max_breached:
ldx #MAX_MAX_COLOUR
bra toggle_dmax_colour
max_max_ok:
cmp #MIN_MAX_COLOUR
bcs min_max_ok
ldx #MIN_MAX_COLOUR
toggle_dmax_colour:
lda dmax_colour
eor #$fe
sta dmax_colour
txa
min_max_ok:
sta max_colour
lda #DMAX_COLOUR_CHANGE_COUNTER_VALUE
sta dmax_colour_change_counter
update_dest_msb:
inc dest+1
bpl dest_updated
lda #$30
sta dest+1
dest_updated:
dey
bne blocks_loop
lda #2
wait_vsync_loop:
via_ifr_constant=*+1;;;;;;;;;;;;;;;;<--note
bit system_via.ifr;;<--note
beq wait_vsync_loop
sta (via_ifr_constant)
; this will probably have to remain a jmp due to the
; distances involved :(
jmp main_loop
sn_write: .proc
sta system_via.ora_no_handshake
stz system_via.orb
ldx #8
jsr +
jsr +
stx system_via.orb
+
rts
.endproc
.endlogical
.endsection