mirror of
https://github.com/irmen/prog8.git
synced 2024-09-08 10:55:08 +00:00
optimized cx16 txt screen functions to use VERA autoincrement
This commit is contained in:
parent
ca9588380a
commit
ba3dce0b4c
@ -16,11 +16,8 @@ const ubyte DEFAULT_WIDTH = 40
|
|||||||
const ubyte DEFAULT_HEIGHT = 25
|
const ubyte DEFAULT_HEIGHT = 25
|
||||||
|
|
||||||
|
|
||||||
asmsub clear_screen() {
|
sub clear_screen() {
|
||||||
%asm {{
|
clear_screenchars(' ')
|
||||||
lda #' '
|
|
||||||
jmp clear_screenchars
|
|
||||||
}}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
asmsub fill_screen (ubyte char @ A, ubyte charcolor @ Y) clobbers(A) {
|
asmsub fill_screen (ubyte char @ A, ubyte charcolor @ Y) clobbers(A) {
|
||||||
|
@ -16,74 +16,78 @@ const ubyte DEFAULT_HEIGHT = 60
|
|||||||
|
|
||||||
|
|
||||||
sub clear_screen() {
|
sub clear_screen() {
|
||||||
c64.CHROUT(147) ; clear screen (spaces)
|
clear_screenchars(' ')
|
||||||
}
|
}
|
||||||
|
|
||||||
asmsub fill_screen (ubyte char @ A, ubyte txtcolor @ Y) clobbers(A) {
|
asmsub fill_screen (ubyte char @ A, ubyte txtcolor @ Y) clobbers(A) {
|
||||||
; ---- fill the character screen with the given fill character and character color.
|
; ---- 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 {{
|
%asm {{
|
||||||
sta P8ZP_SCRATCH_W1 ; fillchar
|
sty _ly+1
|
||||||
sty P8ZP_SCRATCH_W1+1 ; textcolor
|
|
||||||
phx
|
phx
|
||||||
|
pha
|
||||||
jsr c64.SCREEN ; get dimensions in X/Y
|
jsr c64.SCREEN ; get dimensions in X/Y
|
||||||
dex
|
|
||||||
dey
|
|
||||||
txa
|
txa
|
||||||
asl a
|
lsr a
|
||||||
adc #1
|
lsr a
|
||||||
sta P8ZP_SCRATCH_B1
|
sta _lx+1
|
||||||
- ldx P8ZP_SCRATCH_B1
|
lda #%00010000
|
||||||
- stz cx16.VERA_ADDR_H
|
sta cx16.VERA_ADDR_H ; enable auto increment by 1, bank 0.
|
||||||
stx cx16.VERA_ADDR_L
|
stz cx16.VERA_ADDR_L ; start at (0,0)
|
||||||
sty cx16.VERA_ADDR_M
|
stz cx16.VERA_ADDR_M
|
||||||
lda cx16.VERA_DATA0
|
pla
|
||||||
and #$f0
|
_lx ldx #0 ; modified
|
||||||
ora P8ZP_SCRATCH_W1+1
|
phy
|
||||||
|
_ly ldy #1 ; modified
|
||||||
|
- sta cx16.VERA_DATA0
|
||||||
|
sty cx16.VERA_DATA0
|
||||||
sta cx16.VERA_DATA0
|
sta cx16.VERA_DATA0
|
||||||
dex
|
sty cx16.VERA_DATA0
|
||||||
stz cx16.VERA_ADDR_H
|
|
||||||
stx cx16.VERA_ADDR_L
|
|
||||||
sty cx16.VERA_ADDR_M
|
|
||||||
lda P8ZP_SCRATCH_W1
|
|
||||||
sta cx16.VERA_DATA0
|
sta cx16.VERA_DATA0
|
||||||
|
sty cx16.VERA_DATA0
|
||||||
|
sta cx16.VERA_DATA0
|
||||||
|
sty cx16.VERA_DATA0
|
||||||
dex
|
dex
|
||||||
cpx #255
|
|
||||||
bne -
|
bne -
|
||||||
|
ply
|
||||||
dey
|
dey
|
||||||
bpl --
|
beq +
|
||||||
plx
|
stz cx16.VERA_ADDR_L
|
||||||
|
inc cx16.VERA_ADDR_M ; next line
|
||||||
|
bra _lx
|
||||||
|
+ plx
|
||||||
rts
|
rts
|
||||||
}}
|
}}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
asmsub clear_screenchars (ubyte char @ A) clobbers(Y) {
|
asmsub clear_screenchars (ubyte char @ A) clobbers(Y) {
|
||||||
; ---- clear the character screen with the given fill character (leaves colors)
|
; ---- clear the character screen with the given fill character (leaves colors)
|
||||||
; (assumes screen matrix is at the default address)
|
; (assumes screen matrix is at the default address)
|
||||||
; TODO this can be done more efficiently with the VERA auto increment mode?
|
|
||||||
%asm {{
|
%asm {{
|
||||||
phx
|
phx
|
||||||
pha
|
pha
|
||||||
jsr c64.SCREEN ; get dimensions in X/Y
|
jsr c64.SCREEN ; get dimensions in X/Y
|
||||||
dex
|
|
||||||
dey
|
|
||||||
txa
|
txa
|
||||||
asl a
|
lsr a
|
||||||
sta _mod+1
|
lsr a
|
||||||
|
sta _lx+1
|
||||||
|
lda #%00100000
|
||||||
|
sta cx16.VERA_ADDR_H ; enable auto increment by 2, bank 0.
|
||||||
|
stz cx16.VERA_ADDR_L ; start at (0,0)
|
||||||
|
stz cx16.VERA_ADDR_M
|
||||||
pla
|
pla
|
||||||
_mod ldx #0 ; modified
|
_lx ldx #0 ; modified
|
||||||
- stz cx16.VERA_ADDR_H
|
- sta cx16.VERA_DATA0
|
||||||
stx cx16.VERA_ADDR_L
|
sta cx16.VERA_DATA0
|
||||||
sty cx16.VERA_ADDR_M
|
sta cx16.VERA_DATA0
|
||||||
sta cx16.VERA_DATA0
|
sta cx16.VERA_DATA0
|
||||||
dex
|
dex
|
||||||
dex
|
|
||||||
cpx #-2
|
|
||||||
bne -
|
bne -
|
||||||
dey
|
dey
|
||||||
bpl _mod
|
beq +
|
||||||
plx
|
stz cx16.VERA_ADDR_L
|
||||||
|
inc cx16.VERA_ADDR_M ; next line
|
||||||
|
bra _lx
|
||||||
|
+ plx
|
||||||
rts
|
rts
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -91,30 +95,34 @@ _mod ldx #0 ; modified
|
|||||||
asmsub clear_screencolors (ubyte scrcolor @ A) clobbers(Y) {
|
asmsub clear_screencolors (ubyte scrcolor @ A) clobbers(Y) {
|
||||||
; ---- clear the character screen colors with the given color (leaves characters).
|
; ---- clear the character screen colors with the given color (leaves characters).
|
||||||
; (assumes color matrix is at the default address)
|
; (assumes color matrix is at the default address)
|
||||||
; TODO this can be done more efficiently with the VERA auto increment mode?
|
|
||||||
%asm {{
|
%asm {{
|
||||||
phx
|
phx
|
||||||
pha
|
sta _la+1
|
||||||
jsr c64.SCREEN ; get dimensions in X/Y
|
jsr c64.SCREEN ; get dimensions in X/Y
|
||||||
dex
|
|
||||||
dey
|
|
||||||
txa
|
txa
|
||||||
asl a
|
lsr a
|
||||||
ina
|
lsr a
|
||||||
sta _mod+1
|
sta _lx+1
|
||||||
pla
|
lda #%00100000
|
||||||
_mod ldx #0 ; modified
|
sta cx16.VERA_ADDR_H ; enable auto increment by 2, bank 0.
|
||||||
- stz cx16.VERA_ADDR_H
|
lda #1
|
||||||
stx cx16.VERA_ADDR_L
|
sta cx16.VERA_ADDR_L ; start at (1,0)
|
||||||
sty cx16.VERA_ADDR_M
|
stz cx16.VERA_ADDR_M
|
||||||
|
_lx ldx #0 ; modified
|
||||||
|
_la lda #0 ; modified
|
||||||
|
- sta cx16.VERA_DATA0
|
||||||
|
sta cx16.VERA_DATA0
|
||||||
|
sta cx16.VERA_DATA0
|
||||||
sta cx16.VERA_DATA0
|
sta cx16.VERA_DATA0
|
||||||
dex
|
dex
|
||||||
dex
|
|
||||||
cpx #-1
|
|
||||||
bne -
|
bne -
|
||||||
dey
|
dey
|
||||||
bpl _mod
|
beq +
|
||||||
plx
|
lda #1
|
||||||
|
sta cx16.VERA_ADDR_L
|
||||||
|
inc cx16.VERA_ADDR_M ; next line
|
||||||
|
bra _lx
|
||||||
|
+ plx
|
||||||
rts
|
rts
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
%import syslib
|
%import syslib
|
||||||
; %import graphics
|
; %import graphics
|
||||||
%import textio
|
%import textio
|
||||||
%import floats
|
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
|
|
||||||
|
|
||||||
@ -9,7 +8,17 @@ main {
|
|||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
|
|
||||||
txt.clear_screenchars('*')
|
; 40 x 25
|
||||||
|
; 80 x 60
|
||||||
|
txt.fill_screen('*', 8)
|
||||||
|
|
||||||
|
txt.clear_screen()
|
||||||
|
|
||||||
|
txt.print_ub(txt.width())
|
||||||
|
txt.chrout('\n')
|
||||||
|
txt.print_ub(txt.height())
|
||||||
|
txt.chrout('\n')
|
||||||
|
|
||||||
ubyte i
|
ubyte i
|
||||||
repeat {
|
repeat {
|
||||||
txt.clear_screencolors(i)
|
txt.clear_screencolors(i)
|
||||||
|
Loading…
Reference in New Issue
Block a user