From a1e4e9c50f055d5d1d41a5e0fc8973de1c1dcd7d Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Wed, 28 Apr 2021 02:22:21 +0200 Subject: [PATCH] optimized gfx2.plot() for lores-256c --- compiler/res/prog8lib/cx16/gfx2.p8 | 17 ++++++++++++----- examples/test.p8 | 4 ++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/compiler/res/prog8lib/cx16/gfx2.p8 b/compiler/res/prog8lib/cx16/gfx2.p8 index 0ef8a4173..1ed8fcc87 100644 --- a/compiler/res/prog8lib/cx16/gfx2.p8 +++ b/compiler/res/prog8lib/cx16/gfx2.p8 @@ -588,12 +588,19 @@ _done ; TODO mode 2,3 4 -> { ; lores 256c - ; TODO get rid of all the vpoke calls to optimize all plot() ? void addr_mul_24_for_lores_256c(y, x) ; 24 bits result is in r0 and r1L (highest byte) - cx16.vpoke(lsb(cx16.r1), cx16.r0, color) - ; activate vera auto-increment mode so next_pixel() can be used after this - cx16.VERA_ADDR_H = cx16.VERA_ADDR_H & %00000111 | %00010000 - cx16.r0L = cx16.VERA_DATA0 ; advance 1 + %asm {{ + stz cx16.VERA_CTRL + lda cx16.r1 + ora #%00010000 ; enable auto-increment so next_pixel() can be used after this + sta cx16.VERA_ADDR_H + lda cx16.r0+1 + sta cx16.VERA_ADDR_M + lda cx16.r0 + sta cx16.VERA_ADDR_L + lda color + sta cx16.VERA_DATA0 + }} } 5 -> { ; highres monochrome diff --git a/examples/test.p8 b/examples/test.p8 index 6fb8d1d3d..95831503c 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -5,7 +5,7 @@ main { sub start() { - gfx2.screen_mode(1) ; lo res + gfx2.screen_mode(4) ; lo res 256c gfx2.text_charset(3) gfx2.text(10, 10, 1, @"Hello!") @@ -14,7 +14,7 @@ main { ubyte yy uword rw - ;413 jiffies (lores mono) / 480 jiffies (highres mono) / 368 jiffies (lores 256c) / 442 jiffies (lores 4c) + ;480 jiffies (highres mono) / 442 jiffies (lores 4c) repeat 50000 { rw = rndw() yy = (lsb(rw) & 127) + 20