updates to make c16txtio more complete

This commit is contained in:
Irmen de Jong 2020-09-19 23:00:47 +02:00
parent 2deb18beb2
commit ce9a90f626
2 changed files with 87 additions and 29 deletions

View File

@ -18,6 +18,7 @@ sub clear_screen() {
asmsub fill_screen (ubyte char @ A, ubyte txtcolor @ Y) clobbers(A) {
; ---- fill the character screen with the given fill character and character color.
; TODO this can be done more efficiently with the VERA auto increment mode?
%asm {{
sta P8ZP_SCRATCH_W1 ; fillchar
sty P8ZP_SCRATCH_W1+1 ; textcolor
@ -57,6 +58,7 @@ asmsub fill_screen (ubyte char @ A, ubyte txtcolor @ Y) clobbers(A) {
asmsub clear_screenchars (ubyte char @ A) clobbers(Y) {
; ---- clear the character screen with the given fill character (leaves colors)
; (assumes screen matrix is at the default address)
; TODO this can be done more efficiently with the VERA auto increment mode?
%asm {{
pha
phx
@ -103,6 +105,8 @@ sub uppercase() {
cx16.screen_set_charset(2, 0) ; uppercase charset
}
; TODO implement the "missing" txtio scroll subroutines: scroll_left_full, (also right, up, down)
romsub $FFD2 = chrout(ubyte char @ A) ; for consistency. You can also use c64.CHROUT directly ofcourse.
asmsub print (str text @ AY) clobbers(A,Y) {
@ -328,7 +332,61 @@ asmsub input_chars (uword buffer @ AY) clobbers(A) -> ubyte @ Y {
}}
}
; TODO implement the "missing" txtio subroutines: getchr, setclr, getclr, scroll_left_full, (also right, up, down)
asmsub setchr (ubyte col @X, ubyte row @Y, ubyte character @A) clobbers(A) {
; ---- sets the character in the screen matrix at the given position
%asm {{
pha
txa
asl a
stz cx16.VERA_ADDR_H
sta cx16.VERA_ADDR_L
sty cx16.VERA_ADDR_M
pla
sta cx16.VERA_DATA0
rts
}}
}
asmsub getchr (ubyte col @A, ubyte row @Y) -> ubyte @ A {
; ---- get the character in the screen matrix at the given location
%asm {{
asl a
stz cx16.VERA_ADDR_H
sta cx16.VERA_ADDR_L
sty cx16.VERA_ADDR_M
lda cx16.VERA_DATA0
rts
}}
}
asmsub setclr (ubyte col @X, ubyte row @Y, ubyte color @A) clobbers(A) {
; ---- set the color in A on the screen matrix at the given position
%asm {{
pha
txa
asl a
ina
stz cx16.VERA_ADDR_H
sta cx16.VERA_ADDR_L
sty cx16.VERA_ADDR_M
pla
sta cx16.VERA_DATA0
rts
}}
}
asmsub getclr (ubyte col @A, ubyte row @Y) -> ubyte @ A {
; ---- get the color in the screen color matrix at the given location
%asm {{
asl a
ina
stz cx16.VERA_ADDR_H
sta cx16.VERA_ADDR_L
sty cx16.VERA_ADDR_M
lda cx16.VERA_DATA0
rts
}}
}
sub setcc (ubyte column, ubyte row, ubyte char, ubyte charcolor) {
; ---- set char+color at the given position on the screen

View File

@ -21,35 +21,35 @@ main {
txt.setchr(7, 6, '+')
txt.setchr(7, 7, '+')
; txt.setclr(5, 5, 1)
; txt.setclr(6, 5, 2)
; txt.setclr(7, 5, 3)
; txt.setclr(7, 6, 4)
; txt.setclr(7, 7, 5)
;
txt.setclr(5, 5, 1)
txt.setclr(6, 5, 2)
txt.setclr(7, 5, 3)
txt.setclr(7, 6, 4)
txt.setclr(7, 7, 5)
txt.plot(15,10)
txt.chrout('!')
;
; txt.print_ub(txt.getchr(4,5))
; txt.chrout(',')
; txt.print_ub(txt.getchr(5,5))
; txt.chrout(',')
; txt.print_ub(txt.getchr(6,5))
; txt.chrout(',')
; txt.print_ub(txt.getchr(7,5))
; txt.chrout(',')
; txt.print_ub(txt.getchr(8,5))
; txt.chrout('\n')
; txt.print_ub(txt.getclr(4,5))
; txt.chrout(',')
; txt.print_ub(txt.getclr(5,5))
; txt.chrout(',')
; txt.print_ub(txt.getclr(6,5))
; txt.chrout(',')
; txt.print_ub(txt.getclr(7,5))
; txt.chrout(',')
; txt.print_ub(txt.getclr(8,5))
; txt.chrout('\n')
txt.print_ub(txt.getchr(4,5))
txt.chrout(',')
txt.print_ub(txt.getchr(5,5))
txt.chrout(',')
txt.print_ub(txt.getchr(6,5))
txt.chrout(',')
txt.print_ub(txt.getchr(7,5))
txt.chrout(',')
txt.print_ub(txt.getchr(8,5))
txt.chrout('\n')
txt.print_ub(txt.getclr(4,5))
txt.chrout(',')
txt.print_ub(txt.getclr(5,5))
txt.chrout(',')
txt.print_ub(txt.getclr(6,5))
txt.chrout(',')
txt.print_ub(txt.getclr(7,5))
txt.chrout(',')
txt.print_ub(txt.getclr(8,5))
txt.chrout('\n')
}
}