Skip to content

Commit 203188e

Browse files
committed
vdp: printable ASCII
1 parent 387f8f0 commit 203188e

File tree

1 file changed

+143
-13
lines changed

1 file changed

+143
-13
lines changed

vdp.s

Lines changed: 143 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ VDP_REGISTER_BITS = $80
88
VDP_NAME_TABLE_BASE = $0000
99
VDP_PATTERN_TABLE_BASE = $0800
1010

11+
; zero page addresses
12+
VDP_PATTERN_INIT = $30
13+
VDP_PATTERN_INIT_HI = $31
14+
1115
.macro vdp_write_vram
1216
lda #<(\1)
1317
sta VDP_REG
@@ -47,29 +51,39 @@ vdp_initialize_pattern_table:
4751
pha
4852
phx
4953
vdp_write_vram VDP_PATTERN_TABLE_BASE
50-
ldx #0
54+
lda #<vdp_patterns
55+
sta VDP_PATTERN_INIT
56+
lda #>vdp_patterns
57+
sta VDP_PATTERN_INIT_HI
5158
vdp_pattern_table_loop:
52-
lda vdp_hex_digits,x
59+
lda (VDP_PATTERN_INIT)
5360
sta VDP_VRAM
54-
inx
55-
cpx #(vdp_end_hex_digits - vdp_hex_digits)
61+
62+
lda VDP_PATTERN_INIT
63+
clc
64+
adc #1
65+
sta VDP_PATTERN_INIT
66+
lda #0
67+
adc VDP_PATTERN_INIT_HI
68+
sta VDP_PATTERN_INIT_HI
69+
cmp #>vdp_end_patterns
5670
bne vdp_pattern_table_loop
71+
lda VDP_PATTERN_INIT
72+
cmp #<vdp_end_patterns
73+
bne vdp_pattern_table_loop
74+
5775
plx
5876
pla
5977
rts
6078

6179
vdp_initialize_name_table:
62-
; initialize to "0123456789ABCDEF"
6380
pha
64-
phx
6581
vdp_write_vram VDP_NAME_TABLE_BASE
6682
lda #0
6783
vdp_name_table_loop:
6884
sta VDP_VRAM
69-
ina
70-
cmp #$10
71-
bne vdp_name_table_loop
72-
plx
85+
inc
86+
bne vdp_name_table_loop ; will be true after $FF
7387
pla
7488
rts
7589

@@ -91,10 +105,62 @@ vdp_register_3: .byte $00 ; Color table base (currently unused)
91105
vdp_register_4: .byte $01 ; Pattern table base / $800. $01 = $0800
92106
vdp_register_5: .byte $00 ; Sprite attribute table base (currently unused)
93107
vdp_register_6: .byte $00 ; Sprite pattern generator (currently unused)
94-
vdp_register_7: .byte $B4 ; FG/BG. 4=>Dark blue, B=>Light yellow
108+
vdp_register_7: .byte $1E ; FG/BG. 1=>Black, E=>Gray
95109
vdp_end_register_inits:
96110

97-
vdp_hex_digits:
111+
.align 8
112+
vdp_patterns:
113+
; line drawing
114+
.byte $00,$00,$00,$FF,$FF,$00,$00,$00 ; lr
115+
.byte $18,$18,$18,$18,$18,$18,$18,$18 ; ud
116+
.byte $00,$00,$00,$F8,$F8,$18,$18,$18 ; ld
117+
.byte $00,$00,$00,$1F,$1F,$18,$18,$18 ; rd
118+
.byte $18,$18,$18,$F8,$F8,$00,$00,$00 ; lu
119+
.byte $18,$18,$18,$1F,$1F,$00,$00,$00 ; ur
120+
.byte $18,$18,$18,$FF,$FF,$18,$18,$18 ; lurd
121+
; <nonsense for debug>
122+
.byte $07,$07,$07,$07,$07,$07,$07,$00 ; 07
123+
.byte $08,$08,$08,$08,$08,$08,$08,$00 ; 08
124+
.byte $09,$09,$09,$09,$09,$09,$09,$00 ; 09
125+
.byte $0A,$0A,$0A,$0A,$0A,$0A,$0A,$00 ; 0A
126+
.byte $0B,$0B,$0B,$0B,$0B,$0B,$0B,$00 ; 0B
127+
.byte $0C,$0C,$0C,$0C,$0C,$0C,$0C,$00 ; 0C
128+
.byte $0D,$0D,$0D,$0D,$0D,$0D,$0D,$00 ; 0D
129+
.byte $0E,$0E,$0E,$0E,$0E,$0E,$0E,$00 ; 0E
130+
.byte $0F,$0F,$0F,$0F,$0F,$0F,$0F,$00 ; 0F
131+
.byte $10,$10,$10,$10,$10,$10,$10,$00 ; 10
132+
.byte $11,$11,$11,$11,$11,$11,$11,$00 ; 11
133+
.byte $12,$12,$12,$12,$12,$12,$12,$00 ; 12
134+
.byte $13,$13,$13,$13,$13,$13,$13,$00 ; 13
135+
.byte $14,$14,$14,$14,$14,$14,$14,$00 ; 14
136+
.byte $15,$15,$15,$15,$15,$15,$15,$00 ; 15
137+
.byte $16,$16,$16,$16,$16,$16,$16,$00 ; 16
138+
.byte $17,$17,$17,$17,$17,$17,$17,$00 ; 17
139+
.byte $18,$18,$18,$18,$18,$18,$18,$00 ; 18
140+
.byte $19,$19,$19,$19,$19,$19,$19,$00 ; 19
141+
.byte $1A,$1A,$1A,$1A,$1A,$1A,$1A,$00 ; 1A
142+
.byte $1B,$1B,$1B,$1B,$1B,$1B,$1B,$00 ; 1B
143+
.byte $1C,$1C,$1C,$1C,$1C,$1C,$1C,$00 ; 1C
144+
.byte $1D,$1D,$1D,$1D,$1D,$1D,$1D,$00 ; 1D
145+
.byte $1E,$1E,$1E,$1E,$1E,$1E,$1E,$00 ; 1E
146+
.byte $1F,$1F,$1F,$1F,$1F,$1F,$1F,$00 ; 1F
147+
; </nonsense>
148+
.byte $00,$00,$00,$00,$00,$00,$00,$00 ; ' '
149+
.byte $20,$20,$20,$00,$20,$20,$00,$00 ; !
150+
.byte $50,$50,$50,$00,$00,$00,$00,$00 ; "
151+
.byte $50,$50,$F8,$50,$F8,$50,$50,$00 ; #
152+
.byte $20,$78,$A0,$70,$28,$F0,$20,$00 ; $
153+
.byte $C0,$C8,$10,$20,$40,$98,$18,$00 ; %
154+
.byte $40,$A0,$A0,$40,$A8,$90,$68,$00 ; &
155+
.byte $20,$20,$40,$00,$00,$00,$00,$00 ; '
156+
.byte $20,$40,$80,$80,$80,$40,$20,$00 ; (
157+
.byte $20,$10,$08,$08,$08,$10,$20,$00 ; )
158+
.byte $20,$A8,$70,$20,$70,$A8,$20,$00 ; *
159+
.byte $00,$20,$20,$F8,$20,$20,$00,$00 ; +
160+
.byte $00,$00,$00,$00,$20,$20,$40,$00 ; ,
161+
.byte $00,$00,$00,$F8,$00,$00,$00,$00 ; -
162+
.byte $00,$00,$00,$00,$20,$20,$00,$00 ; .
163+
.byte $00,$08,$10,$20,$40,$80,$00,$00 ; /
98164
.byte $70,$88,$98,$A8,$C8,$88,$70,$00 ; 0
99165
.byte $20,$60,$20,$20,$20,$20,$70,$00 ; 1
100166
.byte $70,$88,$08,$30,$40,$80,$F8,$00 ; 2
@@ -105,10 +171,74 @@ vdp_hex_digits:
105171
.byte $F8,$08,$10,$20,$40,$40,$40,$00 ; 7
106172
.byte $70,$88,$88,$70,$88,$88,$70,$00 ; 8
107173
.byte $70,$88,$88,$78,$08,$10,$E0,$00 ; 9
174+
.byte $00,$00,$20,$00,$20,$00,$00,$00 ; :
175+
.byte $00,$00,$20,$00,$20,$20,$40,$00 ; ;
176+
.byte $10,$20,$40,$80,$40,$20,$10,$00 ; <
177+
.byte $00,$00,$F8,$00,$F8,$00,$00,$00 ; =
178+
.byte $40,$20,$10,$08,$10,$20,$40,$00 ; >
179+
.byte $70,$88,$10,$20,$20,$00,$20,$00 ; ?
180+
.byte $70,$88,$A8,$B8,$B0,$80,$78,$00 ; @
108181
.byte $20,$50,$88,$88,$F8,$88,$88,$00 ; A
109182
.byte $F0,$88,$88,$F0,$88,$88,$F0,$00 ; B
110183
.byte $70,$88,$80,$80,$80,$88,$70,$00 ; C
111184
.byte $F0,$88,$88,$88,$88,$88,$F0,$00 ; D
112185
.byte $F8,$80,$80,$F0,$80,$80,$F8,$00 ; E
113186
.byte $F8,$80,$80,$F0,$80,$80,$80,$00 ; F
114-
vdp_end_hex_digits:
187+
.byte $78,$80,$80,$80,$98,$88,$78,$00 ; G
188+
.byte $88,$88,$88,$F8,$88,$88,$88,$00 ; H
189+
.byte $70,$20,$20,$20,$20,$20,$70,$00 ; I
190+
.byte $08,$08,$08,$08,$08,$88,$70,$00 ; J
191+
.byte $88,$90,$A0,$C0,$A0,$90,$88,$00 ; K
192+
.byte $80,$80,$80,$80,$80,$80,$F8,$00 ; L
193+
.byte $88,$D8,$A8,$A8,$88,$88,$88,$00 ; M
194+
.byte $88,$88,$C8,$A8,$98,$88,$88,$00 ; N
195+
.byte $70,$88,$88,$88,$88,$88,$70,$00 ; O
196+
.byte $F0,$88,$88,$F0,$80,$80,$80,$00 ; P
197+
.byte $70,$88,$88,$88,$A8,$90,$68,$00 ; Q
198+
.byte $F0,$88,$88,$F0,$A0,$90,$88,$00 ; R
199+
.byte $70,$88,$80,$70,$08,$88,$70,$00 ; S
200+
.byte $F8,$20,$20,$20,$20,$20,$20,$00 ; T
201+
.byte $88,$88,$88,$88,$88,$88,$70,$00 ; U
202+
.byte $88,$88,$88,$88,$50,$50,$20,$00 ; V
203+
.byte $88,$88,$88,$A8,$A8,$D8,$88,$00 ; W
204+
.byte $88,$88,$50,$20,$50,$88,$88,$00 ; X
205+
.byte $88,$88,$50,$20,$20,$20,$20,$00 ; Y
206+
.byte $F8,$08,$10,$20,$40,$80,$F8,$00 ; Z
207+
.byte $F8,$C0,$C0,$C0,$C0,$C0,$F8,$00 ; [
208+
.byte $00,$80,$40,$20,$10,$08,$00,$00 ; \
209+
.byte $F8,$18,$18,$18,$18,$18,$F8,$00 ; ]
210+
.byte $00,$00,$20,$50,$88,$00,$00,$00 ; ^
211+
.byte $00,$00,$00,$00,$00,$00,$F8,$00 ; _
212+
.byte $40,$20,$10,$00,$00,$00,$00,$00 ; `
213+
.byte $00,$00,$70,$88,$88,$98,$68,$00 ; a
214+
.byte $80,$80,$F0,$88,$88,$88,$F0,$00 ; b
215+
.byte $00,$00,$78,$80,$80,$80,$78,$00 ; c
216+
.byte $08,$08,$78,$88,$88,$88,$78,$00 ; d
217+
.byte $00,$00,$70,$88,$F8,$80,$78,$00 ; e
218+
.byte $30,$40,$E0,$40,$40,$40,$40,$00 ; f
219+
.byte $00,$00,$70,$88,$F8,$08,$F0,$00 ; g
220+
.byte $80,$80,$F0,$88,$88,$88,$88,$00 ; h
221+
.byte $00,$40,$00,$40,$40,$40,$40,$00 ; i
222+
.byte $00,$20,$00,$20,$20,$A0,$60,$00 ; j
223+
.byte $00,$80,$80,$A0,$C0,$A0,$90,$00 ; k
224+
.byte $C0,$40,$40,$40,$40,$40,$60,$00 ; l
225+
.byte $00,$00,$D8,$A8,$A8,$A8,$A8,$00 ; m
226+
.byte $00,$00,$F0,$88,$88,$88,$88,$00 ; n
227+
.byte $00,$00,$70,$88,$88,$88,$70,$00 ; o
228+
.byte $00,$00,$70,$88,$F0,$80,$80,$00 ; p
229+
.byte $00,$00,$F0,$88,$78,$08,$08,$00 ; q
230+
.byte $00,$00,$70,$88,$80,$80,$80,$00 ; r
231+
.byte $00,$00,$78,$80,$70,$08,$F0,$00 ; s
232+
.byte $40,$40,$F0,$40,$40,$40,$30,$00 ; t
233+
.byte $00,$00,$88,$88,$88,$88,$78,$00 ; u
234+
.byte $00,$00,$88,$88,$90,$A0,$40,$00 ; v
235+
.byte $00,$00,$88,$88,$88,$A8,$D8,$00 ; w
236+
.byte $00,$00,$88,$50,$20,$50,$88,$00 ; x
237+
.byte $00,$00,$88,$88,$78,$08,$F0,$00 ; y
238+
.byte $00,$00,$F8,$10,$20,$40,$F8,$00 ; z
239+
.byte $38,$40,$20,$C0,$20,$40,$38,$00 ; {
240+
.byte $40,$40,$40,$00,$40,$40,$40,$00 ; |
241+
.byte $E0,$10,$20,$18,$20,$10,$E0,$00 ; }
242+
.byte $40,$A8,$10,$00,$00,$00,$00,$00 ; ~
243+
.byte $A8,$50,$A8,$50,$A8,$50,$A8,$00 ; checkerboard
244+
vdp_end_patterns:

0 commit comments

Comments
 (0)