diff --git a/compiler/res/prog8lib/cx16/gfx2.p8 b/compiler/res/prog8lib/cx16/gfx2.p8 index 46cf47276..0c259672d 100644 --- a/compiler/res/prog8lib/cx16/gfx2.p8 +++ b/compiler/res/prog8lib/cx16/gfx2.p8 @@ -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 diff --git a/compiler/res/prog8lib/cx16/monogfx.p8 b/compiler/res/prog8lib/cx16/monogfx.p8 index c97f1a4fa..4e5e4d12e 100644 --- a/compiler/res/prog8lib/cx16/monogfx.p8 +++ b/compiler/res/prog8lib/cx16/monogfx.p8 @@ -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 diff --git a/examples/cx16/testgfx2.p8 b/examples/cx16/testgfx2.p8 index 2e405693a..50f8ba2ba 100644 --- a/examples/cx16/testgfx2.p8 +++ b/examples/cx16/testgfx2.p8 @@ -78,7 +78,8 @@ main { } sys.wait(60) - gfx2.clear_screen() + gfx2.clear_screen(2) + gfx2.clear_screen(0) ubyte radius diff --git a/examples/cx16/testmonogfx.p8 b/examples/cx16/testmonogfx.p8 index 4c00f7833..00fa408c9 100644 --- a/examples/cx16/testmonogfx.p8 +++ b/examples/cx16/testmonogfx.p8 @@ -189,7 +189,8 @@ main { } sys.wait(60) - monogfx.clear_screen() + monogfx.clear_screen(1) + monogfx.clear_screen(0) ubyte radius