gfx2.clear_screen and monogfx.clear_screen() now have color parameter to clear the screen with

this is much faster than filling a rectangle of the full screen size with a color.
This commit is contained in:
Irmen de Jong 2023-10-05 21:00:39 +02:00
parent ee81da14d6
commit 433832b329
4 changed files with 41 additions and 30 deletions

View File

@ -70,21 +70,23 @@ gfx2 {
active_mode = mode
if bpp
clear_screen()
clear_screen(0)
}
sub clear_screen() {
sub clear_screen(ubyte color) {
position(0, 0)
when active_mode {
1 -> {
; lores 256c
repeat 240/2
cs_innerloop640()
cs_innerloop640(color)
}
2 -> {
; highres 4c
ubyte[] colors = [%00000000, %01010101, %10101010, %11111111]
color = colors[color&3]
repeat 480/4
cs_innerloop640()
cs_innerloop640(color)
}
}
position(0, 0)
@ -104,6 +106,8 @@ gfx2 {
}
sub fillrect(uword xx, uword yy, uword rwidth, uword rheight, ubyte color) {
; Draw a filled rectangle of the given size and color.
; To fill the whole screen, use clear_screen(color) instead - it is much faster.
if rwidth==0
return
repeat rheight {
@ -784,17 +788,17 @@ skip:
}
}
asmsub cs_innerloop640() clobbers(Y) {
asmsub cs_innerloop640(ubyte color @A) clobbers(Y) {
%asm {{
ldy #80
- stz cx16.VERA_DATA0
stz cx16.VERA_DATA0
stz cx16.VERA_DATA0
stz cx16.VERA_DATA0
stz cx16.VERA_DATA0
stz cx16.VERA_DATA0
stz cx16.VERA_DATA0
stz cx16.VERA_DATA0
- sta cx16.VERA_DATA0
sta cx16.VERA_DATA0
sta cx16.VERA_DATA0
sta cx16.VERA_DATA0
sta cx16.VERA_DATA0
sta cx16.VERA_DATA0
sta cx16.VERA_DATA0
sta cx16.VERA_DATA0
dey
bne -
rts

View File

@ -26,7 +26,7 @@ monogfx {
cx16.VERA_L1_TILEBASE = 0
width = 320
height = 240
clear_screen()
clear_screen(0)
}
sub hires() {
@ -40,7 +40,7 @@ monogfx {
cx16.VERA_L1_TILEBASE = %00000001
width = 640
height = 480
clear_screen()
clear_screen(0)
}
sub textmode() {
@ -50,17 +50,17 @@ monogfx {
cx16.VERA_DC_VIDEO = (cx16.VERA_DC_VIDEO & %11111000) | cx16.r15L
}
sub clear_screen() {
sub clear_screen(ubyte color) {
stipple(false)
position(0, 0)
when width {
320 -> {
repeat 240/2/8
cs_innerloop640()
cs_innerloop640(color)
}
640 -> {
repeat 480/8
cs_innerloop640()
cs_innerloop640(color)
}
}
position(0, 0)
@ -84,6 +84,8 @@ monogfx {
}
sub fillrect(uword xx, uword yy, uword rwidth, uword rheight, bool draw) {
; Draw a filled rectangle of the given size and color.
; To fill the whole screen, use clear_screen(color) instead - it is much faster.
if rwidth==0
return
repeat rheight {
@ -765,17 +767,20 @@ skip:
}
}
asmsub cs_innerloop640() clobbers(Y) {
asmsub cs_innerloop640(ubyte color @A) clobbers(Y) {
%asm {{
ldy #80
- stz cx16.VERA_DATA0
stz cx16.VERA_DATA0
stz cx16.VERA_DATA0
stz cx16.VERA_DATA0
stz cx16.VERA_DATA0
stz cx16.VERA_DATA0
stz cx16.VERA_DATA0
stz cx16.VERA_DATA0
cmp #0
beq +
lda #255
+ ldy #80
- sta cx16.VERA_DATA0
sta cx16.VERA_DATA0
sta cx16.VERA_DATA0
sta cx16.VERA_DATA0
sta cx16.VERA_DATA0
sta cx16.VERA_DATA0
sta cx16.VERA_DATA0
sta cx16.VERA_DATA0
dey
bne -
rts

View File

@ -78,7 +78,8 @@ main {
}
sys.wait(60)
gfx2.clear_screen()
gfx2.clear_screen(2)
gfx2.clear_screen(0)
ubyte radius

View File

@ -189,7 +189,8 @@ main {
}
sys.wait(60)
monogfx.clear_screen()
monogfx.clear_screen(1)
monogfx.clear_screen(0)
ubyte radius