Skip to content

Commit

Permalink
vdp: printable ASCII
Browse files Browse the repository at this point in the history
  • Loading branch information
InPermutation committed Oct 4, 2020
1 parent 387f8f0 commit 203188e
Showing 1 changed file with 143 additions and 13 deletions.
156 changes: 143 additions & 13 deletions vdp.s
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ VDP_REGISTER_BITS = $80
VDP_NAME_TABLE_BASE = $0000
VDP_PATTERN_TABLE_BASE = $0800

; zero page addresses
VDP_PATTERN_INIT = $30
VDP_PATTERN_INIT_HI = $31

.macro vdp_write_vram
lda #<(\1)
sta VDP_REG
Expand Down Expand Up @@ -47,29 +51,39 @@ vdp_initialize_pattern_table:
pha
phx
vdp_write_vram VDP_PATTERN_TABLE_BASE
ldx #0
lda #<vdp_patterns
sta VDP_PATTERN_INIT
lda #>vdp_patterns
sta VDP_PATTERN_INIT_HI
vdp_pattern_table_loop:
lda vdp_hex_digits,x
lda (VDP_PATTERN_INIT)
sta VDP_VRAM
inx
cpx #(vdp_end_hex_digits - vdp_hex_digits)

lda VDP_PATTERN_INIT
clc
adc #1
sta VDP_PATTERN_INIT
lda #0
adc VDP_PATTERN_INIT_HI
sta VDP_PATTERN_INIT_HI
cmp #>vdp_end_patterns
bne vdp_pattern_table_loop
lda VDP_PATTERN_INIT
cmp #<vdp_end_patterns
bne vdp_pattern_table_loop

plx
pla
rts

vdp_initialize_name_table:
; initialize to "0123456789ABCDEF"
pha
phx
vdp_write_vram VDP_NAME_TABLE_BASE
lda #0
vdp_name_table_loop:
sta VDP_VRAM
ina
cmp #$10
bne vdp_name_table_loop
plx
inc
bne vdp_name_table_loop ; will be true after $FF
pla
rts

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

vdp_hex_digits:
.align 8
vdp_patterns:
; line drawing
.byte $00,$00,$00,$FF,$FF,$00,$00,$00 ; lr
.byte $18,$18,$18,$18,$18,$18,$18,$18 ; ud
.byte $00,$00,$00,$F8,$F8,$18,$18,$18 ; ld
.byte $00,$00,$00,$1F,$1F,$18,$18,$18 ; rd
.byte $18,$18,$18,$F8,$F8,$00,$00,$00 ; lu
.byte $18,$18,$18,$1F,$1F,$00,$00,$00 ; ur
.byte $18,$18,$18,$FF,$FF,$18,$18,$18 ; lurd
; <nonsense for debug>
.byte $07,$07,$07,$07,$07,$07,$07,$00 ; 07
.byte $08,$08,$08,$08,$08,$08,$08,$00 ; 08
.byte $09,$09,$09,$09,$09,$09,$09,$00 ; 09
.byte $0A,$0A,$0A,$0A,$0A,$0A,$0A,$00 ; 0A
.byte $0B,$0B,$0B,$0B,$0B,$0B,$0B,$00 ; 0B
.byte $0C,$0C,$0C,$0C,$0C,$0C,$0C,$00 ; 0C
.byte $0D,$0D,$0D,$0D,$0D,$0D,$0D,$00 ; 0D
.byte $0E,$0E,$0E,$0E,$0E,$0E,$0E,$00 ; 0E
.byte $0F,$0F,$0F,$0F,$0F,$0F,$0F,$00 ; 0F
.byte $10,$10,$10,$10,$10,$10,$10,$00 ; 10
.byte $11,$11,$11,$11,$11,$11,$11,$00 ; 11
.byte $12,$12,$12,$12,$12,$12,$12,$00 ; 12
.byte $13,$13,$13,$13,$13,$13,$13,$00 ; 13
.byte $14,$14,$14,$14,$14,$14,$14,$00 ; 14
.byte $15,$15,$15,$15,$15,$15,$15,$00 ; 15
.byte $16,$16,$16,$16,$16,$16,$16,$00 ; 16
.byte $17,$17,$17,$17,$17,$17,$17,$00 ; 17
.byte $18,$18,$18,$18,$18,$18,$18,$00 ; 18
.byte $19,$19,$19,$19,$19,$19,$19,$00 ; 19
.byte $1A,$1A,$1A,$1A,$1A,$1A,$1A,$00 ; 1A
.byte $1B,$1B,$1B,$1B,$1B,$1B,$1B,$00 ; 1B
.byte $1C,$1C,$1C,$1C,$1C,$1C,$1C,$00 ; 1C
.byte $1D,$1D,$1D,$1D,$1D,$1D,$1D,$00 ; 1D
.byte $1E,$1E,$1E,$1E,$1E,$1E,$1E,$00 ; 1E
.byte $1F,$1F,$1F,$1F,$1F,$1F,$1F,$00 ; 1F
; </nonsense>
.byte $00,$00,$00,$00,$00,$00,$00,$00 ; ' '
.byte $20,$20,$20,$00,$20,$20,$00,$00 ; !
.byte $50,$50,$50,$00,$00,$00,$00,$00 ; "
.byte $50,$50,$F8,$50,$F8,$50,$50,$00 ; #
.byte $20,$78,$A0,$70,$28,$F0,$20,$00 ; $
.byte $C0,$C8,$10,$20,$40,$98,$18,$00 ; %
.byte $40,$A0,$A0,$40,$A8,$90,$68,$00 ; &
.byte $20,$20,$40,$00,$00,$00,$00,$00 ; '
.byte $20,$40,$80,$80,$80,$40,$20,$00 ; (
.byte $20,$10,$08,$08,$08,$10,$20,$00 ; )
.byte $20,$A8,$70,$20,$70,$A8,$20,$00 ; *
.byte $00,$20,$20,$F8,$20,$20,$00,$00 ; +
.byte $00,$00,$00,$00,$20,$20,$40,$00 ; ,
.byte $00,$00,$00,$F8,$00,$00,$00,$00 ; -
.byte $00,$00,$00,$00,$20,$20,$00,$00 ; .
.byte $00,$08,$10,$20,$40,$80,$00,$00 ; /
.byte $70,$88,$98,$A8,$C8,$88,$70,$00 ; 0
.byte $20,$60,$20,$20,$20,$20,$70,$00 ; 1
.byte $70,$88,$08,$30,$40,$80,$F8,$00 ; 2
Expand All @@ -105,10 +171,74 @@ vdp_hex_digits:
.byte $F8,$08,$10,$20,$40,$40,$40,$00 ; 7
.byte $70,$88,$88,$70,$88,$88,$70,$00 ; 8
.byte $70,$88,$88,$78,$08,$10,$E0,$00 ; 9
.byte $00,$00,$20,$00,$20,$00,$00,$00 ; :
.byte $00,$00,$20,$00,$20,$20,$40,$00 ; ;
.byte $10,$20,$40,$80,$40,$20,$10,$00 ; <
.byte $00,$00,$F8,$00,$F8,$00,$00,$00 ; =
.byte $40,$20,$10,$08,$10,$20,$40,$00 ; >
.byte $70,$88,$10,$20,$20,$00,$20,$00 ; ?
.byte $70,$88,$A8,$B8,$B0,$80,$78,$00 ; @
.byte $20,$50,$88,$88,$F8,$88,$88,$00 ; A
.byte $F0,$88,$88,$F0,$88,$88,$F0,$00 ; B
.byte $70,$88,$80,$80,$80,$88,$70,$00 ; C
.byte $F0,$88,$88,$88,$88,$88,$F0,$00 ; D
.byte $F8,$80,$80,$F0,$80,$80,$F8,$00 ; E
.byte $F8,$80,$80,$F0,$80,$80,$80,$00 ; F
vdp_end_hex_digits:
.byte $78,$80,$80,$80,$98,$88,$78,$00 ; G
.byte $88,$88,$88,$F8,$88,$88,$88,$00 ; H
.byte $70,$20,$20,$20,$20,$20,$70,$00 ; I
.byte $08,$08,$08,$08,$08,$88,$70,$00 ; J
.byte $88,$90,$A0,$C0,$A0,$90,$88,$00 ; K
.byte $80,$80,$80,$80,$80,$80,$F8,$00 ; L
.byte $88,$D8,$A8,$A8,$88,$88,$88,$00 ; M
.byte $88,$88,$C8,$A8,$98,$88,$88,$00 ; N
.byte $70,$88,$88,$88,$88,$88,$70,$00 ; O
.byte $F0,$88,$88,$F0,$80,$80,$80,$00 ; P
.byte $70,$88,$88,$88,$A8,$90,$68,$00 ; Q
.byte $F0,$88,$88,$F0,$A0,$90,$88,$00 ; R
.byte $70,$88,$80,$70,$08,$88,$70,$00 ; S
.byte $F8,$20,$20,$20,$20,$20,$20,$00 ; T
.byte $88,$88,$88,$88,$88,$88,$70,$00 ; U
.byte $88,$88,$88,$88,$50,$50,$20,$00 ; V
.byte $88,$88,$88,$A8,$A8,$D8,$88,$00 ; W
.byte $88,$88,$50,$20,$50,$88,$88,$00 ; X
.byte $88,$88,$50,$20,$20,$20,$20,$00 ; Y
.byte $F8,$08,$10,$20,$40,$80,$F8,$00 ; Z
.byte $F8,$C0,$C0,$C0,$C0,$C0,$F8,$00 ; [
.byte $00,$80,$40,$20,$10,$08,$00,$00 ; \
.byte $F8,$18,$18,$18,$18,$18,$F8,$00 ; ]
.byte $00,$00,$20,$50,$88,$00,$00,$00 ; ^
.byte $00,$00,$00,$00,$00,$00,$F8,$00 ; _
.byte $40,$20,$10,$00,$00,$00,$00,$00 ; `
.byte $00,$00,$70,$88,$88,$98,$68,$00 ; a
.byte $80,$80,$F0,$88,$88,$88,$F0,$00 ; b
.byte $00,$00,$78,$80,$80,$80,$78,$00 ; c
.byte $08,$08,$78,$88,$88,$88,$78,$00 ; d
.byte $00,$00,$70,$88,$F8,$80,$78,$00 ; e
.byte $30,$40,$E0,$40,$40,$40,$40,$00 ; f
.byte $00,$00,$70,$88,$F8,$08,$F0,$00 ; g
.byte $80,$80,$F0,$88,$88,$88,$88,$00 ; h
.byte $00,$40,$00,$40,$40,$40,$40,$00 ; i
.byte $00,$20,$00,$20,$20,$A0,$60,$00 ; j
.byte $00,$80,$80,$A0,$C0,$A0,$90,$00 ; k
.byte $C0,$40,$40,$40,$40,$40,$60,$00 ; l
.byte $00,$00,$D8,$A8,$A8,$A8,$A8,$00 ; m
.byte $00,$00,$F0,$88,$88,$88,$88,$00 ; n
.byte $00,$00,$70,$88,$88,$88,$70,$00 ; o
.byte $00,$00,$70,$88,$F0,$80,$80,$00 ; p
.byte $00,$00,$F0,$88,$78,$08,$08,$00 ; q
.byte $00,$00,$70,$88,$80,$80,$80,$00 ; r
.byte $00,$00,$78,$80,$70,$08,$F0,$00 ; s
.byte $40,$40,$F0,$40,$40,$40,$30,$00 ; t
.byte $00,$00,$88,$88,$88,$88,$78,$00 ; u
.byte $00,$00,$88,$88,$90,$A0,$40,$00 ; v
.byte $00,$00,$88,$88,$88,$A8,$D8,$00 ; w
.byte $00,$00,$88,$50,$20,$50,$88,$00 ; x
.byte $00,$00,$88,$88,$78,$08,$F0,$00 ; y
.byte $00,$00,$F8,$10,$20,$40,$F8,$00 ; z
.byte $38,$40,$20,$C0,$20,$40,$38,$00 ; {
.byte $40,$40,$40,$00,$40,$40,$40,$00 ; |
.byte $E0,$10,$20,$18,$20,$10,$E0,$00 ; }
.byte $40,$A8,$10,$00,$00,$00,$00,$00 ; ~
.byte $A8,$50,$A8,$50,$A8,$50,$A8,$00 ; checkerboard
vdp_end_patterns:

0 comments on commit 203188e

Please sign in to comment.