optimized gfx2.vertical_line for highres 4c mode

This commit is contained in:
Irmen de Jong 2021-04-28 00:29:21 +02:00
parent 3bf335e0a0
commit a5961cbeab
2 changed files with 62 additions and 64 deletions

View File

@ -292,15 +292,15 @@ _done
} }
sub vertical_line(uword x, uword y, uword height, ubyte color) { sub vertical_line(uword x, uword y, uword height, ubyte color) {
position(x,y)
when active_mode { when active_mode {
1, 5 -> { 1, 5 -> {
; monochrome, either resolution ; monochrome, either resolution
; note for the 1 bpp modes we can't use vera's auto increment mode because we have to 'or' the pixel data in place. ; note for the 1 bpp modes we can't use vera's auto increment mode because we have to 'or' the pixel data in place.
; TODO use TWO vera adress pointers simultaneously one for reading, one for writing, so auto-increment IS possible ; TODO use TWO vera adress pointers simultaneously one for reading, one for writing, so auto-increment IS possible
position(x,y)
cx16.VERA_ADDR_H &= %00000111 ; no auto advance cx16.VERA_ADDR_H &= %00000111 ; no auto advance
cx16.r15 = gfx2.plot.bits[x as ubyte & 7] ; bitmask cx16.r15 = gfx2.plot.bits[x as ubyte & 7] ; bitmask
if active_mode>=5 if active_mode==5
cx16.r14 = 640/8 cx16.r14 = 640/8
else else
cx16.r14 = 320/8 cx16.r14 = 320/8
@ -385,6 +385,7 @@ _done
4 -> { 4 -> {
; lores 256c ; lores 256c
; set vera auto-increment to 320 pixel increment (=next line) ; set vera auto-increment to 320 pixel increment (=next line)
position(x,y)
cx16.VERA_ADDR_H = cx16.VERA_ADDR_H & %00000111 | (14<<4) cx16.VERA_ADDR_H = cx16.VERA_ADDR_H & %00000111 | (14<<4)
%asm {{ %asm {{
ldy height ldy height
@ -398,31 +399,23 @@ _done
} }
6 -> { 6 -> {
; highres 4c ; highres 4c
; note for this mode we can't use vera's auto increment mode because we have to 'or' the pixel data in place. ; use TWO vera adress pointers simultaneously one for reading, one for writing, so auto-increment is possible
; TODO use TWO vera adress pointers simultaneously one for reading, one for writing, so auto-increment IS possible if height==0
cx16.VERA_ADDR_H &= %00000111 ; no auto advance return
; TODO also mostly usable for lores 4c? position2(x,y,true)
void addr_mul_24_for_highres_4c(y, x) ; 24 bits result is in r0 and r1L (highest byte) cx16.VERA_CTRL = 0
cx16.VERA_ADDR_H = cx16.VERA_ADDR_H & %00000111 | (13<<4) ; 160 increment = 1 line in 640 px 4c mode
; TODO optimize this vertical line loop in pure assembly cx16.VERA_CTRL = 1
cx16.VERA_ADDR_H = cx16.VERA_ADDR_H & %00000111 | (13<<4) ; 160 increment = 1 line in 640 px 4c mode
color &= 3 color &= 3
color <<= gfx2.plot.shift4c[lsb(x) & 3] color <<= gfx2.plot.shift4c[lsb(x) & 3]
ubyte mask = gfx2.plot.mask4c[lsb(x) & 3] ubyte mask = gfx2.plot.mask4c[lsb(x) & 3]
repeat height { repeat height {
ubyte value = cx16.vpeek(lsb(cx16.r1), cx16.r0) & mask | color
cx16.vpoke(lsb(cx16.r1), cx16.r0, value)
%asm {{ %asm {{
; 24 bits add 160 (640/4) lda cx16.VERA_DATA0
clc and mask
lda cx16.r0 ora color
adc #640/4 sta cx16.VERA_DATA1
sta cx16.r0
lda cx16.r0+1
adc #0
sta cx16.r0+1
bcc +
inc cx16.r1
+
}} }}
} }
} }
@ -680,6 +673,20 @@ _done
} }
} }
sub position2(uword @zp x, uword y, ubyte also_port_1) {
position(x, y)
if also_port_1 {
when active_mode {
1, 5 -> cx16.vaddr(0, cx16.r0, 1, 1)
; TODO modes 2, 3
4, 6 -> {
ubyte bank = lsb(cx16.r1)
cx16.vaddr(bank, cx16.r0, 1, 1)
}
}
}
}
inline asmsub next_pixel(ubyte color @A) { inline asmsub next_pixel(ubyte color @A) {
; -- sets the next pixel byte to the graphics chip. ; -- sets the next pixel byte to the graphics chip.
; for 8 bpp screens this will plot 1 pixel. ; for 8 bpp screens this will plot 1 pixel.
@ -765,7 +772,7 @@ _done
1, 5 -> { 1, 5 -> {
; monochrome mode, either resolution ; monochrome mode, either resolution
cx16.r2 = 40 cx16.r2 = 40
if active_mode>=5 if active_mode==5
cx16.r2 = 80 cx16.r2 = 80
while @(sctextptr) { while @(sctextptr) {
chardataptr = charset_addr + (@(sctextptr) as uword)*8 chardataptr = charset_addr + (@(sctextptr) as uword)*8

View File

@ -1,50 +1,41 @@
%import textio %import conv
%zeropage basicsafe %import gfx2
main { main {
sub start() { sub start() {
ubyte uu gfx2.screen_mode(6) ; high res 4 colors
cx16.rambank(1) gfx2.text_charset(3)
sys.memcopy(&banked.double, $a000, 100) gfx2.text(10, 10, 1, @"Hello!")
cx16.rambank(0)
txt.nl()
uword ww c64.SETTIM(0,0,0)
uu = 99
txt.print_ub(uu)
txt.nl()
callfar($01, $a000, &uu)
txt.print_ub(uu)
uu = '\n' repeat 1 {
callrom($00, $ffd2, &uu) uword xx
uu = 'a' ; gfx2.monochrome_stipple(true)
callrom($00, $ffd2, &uu) ; for xx in 0 to 639 {
uu = '!' ; gfx2.vertical_line(xx, 20, 220, 1)
callrom($00, $ffd2, &uu) ; }
uu = '\n' ; gfx2.monochrome_stipple(false)
callrom($00, $ffd2, &uu) for xx in 0 to 639 {
gfx2.vertical_line(xx, 20, 450, 1)
}
for xx in 0 to 639 {
gfx2.vertical_line(xx, 20, 450, 2)
}
for xx in 0 to 639 {
gfx2.vertical_line(xx, 20, 450, 3)
}
for xx in 0 to 639 {
gfx2.vertical_line(xx, 20, 450, 0)
}
}
; cx16.rombank(0) uword time = c64.RDTIM16()
; %asm{{ conv.str_uw(time)
; lda #13 gfx2.text(100, 10, 1, conv.string_out)
; jsr $ffd2
; lda #'a' repeat {
; jsr $ffd2 }
; lda #13
; jsr $ffd2
; }}
; cx16.rombank(4)
}
}
banked {
asmsub double(ubyte number @A) -> ubyte @A {
%asm {{
asl a
rts
}}
} }
} }