mirror of
https://github.com/irmen/prog8.git
synced 2024-10-18 01:24:51 +00:00
optimize cx16 textio.setcc()/setcc2()
This commit is contained in:
parent
62b32b2211
commit
1d342cc6af
@ -195,7 +195,7 @@ sub iso_off() {
|
|||||||
|
|
||||||
|
|
||||||
asmsub scroll_left() clobbers(A, Y) {
|
asmsub scroll_left() clobbers(A, Y) {
|
||||||
; ---- scroll the whole screen 1 character to the left TODO optimize this more?
|
; ---- scroll the whole screen 1 character to the left
|
||||||
; contents of the rightmost column are unchanged, you should clear/refill this yourself
|
; contents of the rightmost column are unchanged, you should clear/refill this yourself
|
||||||
%asm {{
|
%asm {{
|
||||||
phx
|
phx
|
||||||
@ -241,7 +241,7 @@ _lx ldx #0 ; modified
|
|||||||
}
|
}
|
||||||
|
|
||||||
asmsub scroll_right() clobbers(A) {
|
asmsub scroll_right() clobbers(A) {
|
||||||
; ---- scroll the whole screen 1 character to the right TODO optimize this more?
|
; ---- scroll the whole screen 1 character to the right
|
||||||
; contents of the leftmost column are unchanged, you should clear/refill this yourself
|
; contents of the leftmost column are unchanged, you should clear/refill this yourself
|
||||||
%asm {{
|
%asm {{
|
||||||
phx
|
phx
|
||||||
@ -295,7 +295,7 @@ _lx ldx #0 ; modified
|
|||||||
}
|
}
|
||||||
|
|
||||||
asmsub scroll_up() clobbers(A, Y) {
|
asmsub scroll_up() clobbers(A, Y) {
|
||||||
; ---- scroll the whole screen 1 character up TODO optimize this more?
|
; ---- scroll the whole screen 1 character up
|
||||||
; contents of the bottom row are unchanged, you should refill/clear this yourself
|
; contents of the bottom row are unchanged, you should refill/clear this yourself
|
||||||
%asm {{
|
%asm {{
|
||||||
phx
|
phx
|
||||||
@ -345,7 +345,7 @@ _nextline
|
|||||||
}
|
}
|
||||||
|
|
||||||
asmsub scroll_down() clobbers(A, Y) {
|
asmsub scroll_down() clobbers(A, Y) {
|
||||||
; ---- scroll the whole screen 1 character down TODO optimize this more?
|
; ---- scroll the whole screen 1 character down
|
||||||
; contents of the top row are unchanged, you should refill/clear this yourself
|
; contents of the top row are unchanged, you should refill/clear this yourself
|
||||||
%asm {{
|
%asm {{
|
||||||
phx
|
phx
|
||||||
@ -635,7 +635,7 @@ asmsub setchr (ubyte col @X, ubyte row @Y, ubyte character @A) clobbers(A) {
|
|||||||
asl a
|
asl a
|
||||||
sta cx16.VERA_ADDR_L
|
sta cx16.VERA_ADDR_L
|
||||||
tya
|
tya
|
||||||
clc
|
; clc
|
||||||
adc #>VERA_TEXTMATRIX_ADDR
|
adc #>VERA_TEXTMATRIX_ADDR
|
||||||
sta cx16.VERA_ADDR_M
|
sta cx16.VERA_ADDR_M
|
||||||
pla
|
pla
|
||||||
@ -655,7 +655,7 @@ asmsub getchr (ubyte col @A, ubyte row @Y) -> ubyte @ A {
|
|||||||
pla
|
pla
|
||||||
sta cx16.VERA_ADDR_L
|
sta cx16.VERA_ADDR_L
|
||||||
tya
|
tya
|
||||||
clc
|
; clc
|
||||||
adc #>VERA_TEXTMATRIX_ADDR
|
adc #>VERA_TEXTMATRIX_ADDR
|
||||||
sta cx16.VERA_ADDR_M
|
sta cx16.VERA_ADDR_M
|
||||||
lda cx16.VERA_DATA0
|
lda cx16.VERA_DATA0
|
||||||
@ -677,7 +677,7 @@ asmsub setclr (ubyte col @X, ubyte row @Y, ubyte color @A) clobbers(A) {
|
|||||||
ina
|
ina
|
||||||
sta cx16.VERA_ADDR_L
|
sta cx16.VERA_ADDR_L
|
||||||
tya
|
tya
|
||||||
clc
|
; clc
|
||||||
adc #>VERA_TEXTMATRIX_ADDR
|
adc #>VERA_TEXTMATRIX_ADDR
|
||||||
sta cx16.VERA_ADDR_M
|
sta cx16.VERA_ADDR_M
|
||||||
pla
|
pla
|
||||||
@ -698,7 +698,7 @@ asmsub getclr (ubyte col @A, ubyte row @Y) -> ubyte @ A {
|
|||||||
pla
|
pla
|
||||||
sta cx16.VERA_ADDR_L
|
sta cx16.VERA_ADDR_L
|
||||||
tya
|
tya
|
||||||
clc
|
; clc
|
||||||
adc #>VERA_TEXTMATRIX_ADDR
|
adc #>VERA_TEXTMATRIX_ADDR
|
||||||
sta cx16.VERA_ADDR_M
|
sta cx16.VERA_ADDR_M
|
||||||
lda cx16.VERA_DATA0
|
lda cx16.VERA_DATA0
|
||||||
@ -707,36 +707,29 @@ asmsub getclr (ubyte col @A, ubyte row @Y) -> ubyte @ A {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub setcc (ubyte column, ubyte row, ubyte char, ubyte charcolor) {
|
sub setcc (ubyte column, ubyte row, ubyte char, ubyte charcolor) {
|
||||||
; ---- set char+color at the given position on the screen TODO optimize this better
|
; ---- set char+color at the given position on the screen
|
||||||
; note: color handling is the same as on the C64: it only sets the foreground color.
|
; note: color handling is the same as on the C64: it only sets the foreground color and leaves the background color as is.
|
||||||
; use setcc2 if you want Cx-16 specific feature of setting both Bg+Fg colors.
|
; Use setcc2 if you want Cx-16 specific feature of setting both Bg+Fg colors (is faster as well).
|
||||||
%asm {{
|
%asm {{
|
||||||
phx
|
phx
|
||||||
lda column
|
lda column
|
||||||
asl a
|
asl a
|
||||||
tax
|
tax
|
||||||
ldy row
|
ldy row
|
||||||
lda charcolor
|
|
||||||
and #$0f
|
|
||||||
sta P8ZP_SCRATCH_B1
|
|
||||||
stz cx16.VERA_CTRL
|
stz cx16.VERA_CTRL
|
||||||
lda #VERA_TEXTMATRIX_BANK
|
lda #VERA_TEXTMATRIX_BANK
|
||||||
sta cx16.VERA_ADDR_H
|
sta cx16.VERA_ADDR_H
|
||||||
stx cx16.VERA_ADDR_L
|
stx cx16.VERA_ADDR_L
|
||||||
tya
|
tya
|
||||||
clc
|
;clc
|
||||||
adc #>VERA_TEXTMATRIX_ADDR
|
adc #>VERA_TEXTMATRIX_ADDR
|
||||||
sta cx16.VERA_ADDR_M
|
sta cx16.VERA_ADDR_M
|
||||||
lda char
|
lda char
|
||||||
sta cx16.VERA_DATA0
|
sta cx16.VERA_DATA0
|
||||||
inx
|
inc cx16.VERA_ADDR_L
|
||||||
lda #VERA_TEXTMATRIX_BANK
|
lda charcolor
|
||||||
sta cx16.VERA_ADDR_H
|
and #$0f
|
||||||
stx cx16.VERA_ADDR_L
|
sta P8ZP_SCRATCH_B1
|
||||||
tya
|
|
||||||
clc
|
|
||||||
adc #>VERA_TEXTMATRIX_ADDR
|
|
||||||
sta cx16.VERA_ADDR_M
|
|
||||||
lda cx16.VERA_DATA0
|
lda cx16.VERA_DATA0
|
||||||
and #$f0
|
and #$f0
|
||||||
ora P8ZP_SCRATCH_B1
|
ora P8ZP_SCRATCH_B1
|
||||||
@ -747,9 +740,9 @@ sub setcc (ubyte column, ubyte row, ubyte char, ubyte charcolor) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub setcc2 (ubyte column, ubyte row, ubyte char, ubyte colors) {
|
sub setcc2 (ubyte column, ubyte row, ubyte char, ubyte colors) {
|
||||||
; ---- set char+color at the given position on the screen TODO optimize this
|
; ---- set char+color at the given position on the screen
|
||||||
; note: on the CommanderX16 this allows you to set both Fg and Bg colors;
|
; note: on the CommanderX16 this allows you to set both Fg and Bg colors;
|
||||||
; use the high nybble in A to set the Bg color!
|
; use the high nybble in A to set the Bg color! Is a bit faster than setcc() too.
|
||||||
%asm {{
|
%asm {{
|
||||||
phx
|
phx
|
||||||
lda column
|
lda column
|
||||||
@ -761,19 +754,12 @@ sub setcc2 (ubyte column, ubyte row, ubyte char, ubyte colors) {
|
|||||||
sta cx16.VERA_ADDR_H
|
sta cx16.VERA_ADDR_H
|
||||||
stx cx16.VERA_ADDR_L
|
stx cx16.VERA_ADDR_L
|
||||||
tya
|
tya
|
||||||
clc
|
; clc
|
||||||
adc #>VERA_TEXTMATRIX_ADDR
|
adc #>VERA_TEXTMATRIX_ADDR
|
||||||
sta cx16.VERA_ADDR_M
|
sta cx16.VERA_ADDR_M
|
||||||
lda char
|
lda char
|
||||||
sta cx16.VERA_DATA0
|
sta cx16.VERA_DATA0
|
||||||
inx
|
inc cx16.VERA_ADDR_L
|
||||||
lda #VERA_TEXTMATRIX_BANK
|
|
||||||
sta cx16.VERA_ADDR_H
|
|
||||||
stx cx16.VERA_ADDR_L
|
|
||||||
tya
|
|
||||||
clc
|
|
||||||
adc #>VERA_TEXTMATRIX_ADDR
|
|
||||||
sta cx16.VERA_ADDR_M
|
|
||||||
lda colors
|
lda colors
|
||||||
sta cx16.VERA_DATA0
|
sta cx16.VERA_DATA0
|
||||||
plx
|
plx
|
||||||
|
@ -3,7 +3,6 @@ TODO
|
|||||||
|
|
||||||
For next release
|
For next release
|
||||||
^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^
|
||||||
- cx16 textio: optimize the 4 scroll routines and setcc/setcc2.
|
|
||||||
- vm: implement all operators in the virtualmachine
|
- vm: implement all operators in the virtualmachine
|
||||||
- vm: codegen: more optimal code for loops ending on 0 (BNZ?)
|
- vm: codegen: more optimal code for loops ending on 0 (BNZ?)
|
||||||
- pipe operator: allow non-unary function calls in the pipe that specify the other argument(s) in the calls.
|
- pipe operator: allow non-unary function calls in the pipe that specify the other argument(s) in the calls.
|
||||||
|
@ -9,9 +9,24 @@ main {
|
|||||||
ubyte global = 42
|
ubyte global = 42
|
||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
txt.print_ub(global)
|
uword begin = c64.RDTIM16()
|
||||||
global++
|
|
||||||
rol2(global)
|
ubyte shift
|
||||||
|
repeat 60 {
|
||||||
|
ubyte yy
|
||||||
|
for yy in 0 to 59 {
|
||||||
|
ubyte xx
|
||||||
|
for xx in 0 to 79 {
|
||||||
|
ubyte color = yy+xx+shift
|
||||||
|
txt.setcc2(xx,yy,81,color) ; 356
|
||||||
|
}
|
||||||
|
}
|
||||||
|
shift++
|
||||||
|
}
|
||||||
|
|
||||||
|
uword duration = c64.RDTIM16()-begin
|
||||||
|
txt.print_uw(duration)
|
||||||
|
txt.print(" \n")
|
||||||
|
|
||||||
; a "pixelshader":
|
; a "pixelshader":
|
||||||
; syscall1(8, 0) ; enable lo res creen
|
; syscall1(8, 0) ; enable lo res creen
|
||||||
|
Loading…
Reference in New Issue
Block a user