From 70ee2026ffb68ad75e26569e0cab0f7b09523ae3 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Mon, 2 Oct 2023 00:12:48 +0200 Subject: [PATCH] fix gfx2 screen fill broken when using verafx --- compiler/res/prog8lib/cx16/gfx2.p8 | 1 + compiler/res/prog8lib/cx16/verafx.p8 | 14 +++++++++++++- docs/source/todo.rst | 2 +- examples/test.p8 | 9 +++++++-- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/compiler/res/prog8lib/cx16/gfx2.p8 b/compiler/res/prog8lib/cx16/gfx2.p8 index 616ad42f0..f3c4023ed 100644 --- a/compiler/res/prog8lib/cx16/gfx2.p8 +++ b/compiler/res/prog8lib/cx16/gfx2.p8 @@ -32,6 +32,7 @@ gfx2 { bool monochrome_dont_stipple_flag = false ; set to false to enable stippling mode in monochrome displaymodes sub screen_mode(ubyte mode) { + cx16.VERA_CTRL=0 when mode { 1 -> { ; lores monochrome diff --git a/compiler/res/prog8lib/cx16/verafx.p8 b/compiler/res/prog8lib/cx16/verafx.p8 index e15cee9fe..274c7408f 100644 --- a/compiler/res/prog8lib/cx16/verafx.p8 +++ b/compiler/res/prog8lib/cx16/verafx.p8 @@ -6,6 +6,17 @@ verafx { %option no_symbol_prefixing + sub fill(ubyte vbank, uword vaddr, ubyte data, uword numlongs) { + ; TODO use vera fx cache write + cx16.vaddr(vbank, vaddr, 0, true) + repeat numlongs { + cx16.VERA_DATA0 = data + cx16.VERA_DATA0 = data + cx16.VERA_DATA0 = data + cx16.VERA_DATA0 = data + } + } + ; unsigned multiplication just passes the values as signed to muls ; if you do this yourself in your call to muls, it will save a few instructions. sub mult(uword value1, uword value2) -> uword { @@ -46,9 +57,10 @@ verafx { stz cx16.VERA_DATA0 ; multiply and write out result lda #%00010001 ; $01 with Increment 1 sta cx16.VERA_ADDR_H ; so we can read out the result - stz cx16.VERA_FX_CTRL ; Cache write disable lda cx16.VERA_DATA0 ldy cx16.VERA_DATA0 + stz cx16.VERA_FX_CTRL ; Cache write disable + stz cx16.VERA_CTRL ; reset DCSEL rts ; we skip the upper 16 bits of the result: ; lda cx16.VERA_DATA0 diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 7842d0c34..ff09bc848 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -1,7 +1,6 @@ TODO ==== -- add a compiler switch to replace all calls to the math word mul routine on the X16 by the verafx call instead. Search TODO("vera fx mul") - [on branch: shortcircuit] investigate McCarthy evaluation again? this may also reduce code size perhaps for things like if a>4 or a<2 .... - [on branch: ir-less-branch-opcodes] IR: reduce the number of branch instructions such as BEQ, BEQR, etc (gradually), replace with CMP(I) + status branch instruction - IR: reduce amount of CMP/CMPI after instructions that set the status bits correctly (LOADs? INC? etc), but only after setting the status bits is verified! @@ -20,6 +19,7 @@ Future Things and Ideas ^^^^^^^^^^^^^^^^^^^^^^^ Compiler: +- Currently "320*240/8/8" gives integer overflow, so: allow constant integer subexpressions to contain out of range integers (>65535 etc) as long as the final constant value is within byte/word range. - allow 'chained' array indexing for expressions: value = ptrarray[0][0] - allow 'chained' array indexing for assign targets: ptrarray[0][0] = 42 this is just evaluating the lhs as a uword pointer expression diff --git a/examples/test.p8 b/examples/test.p8 index 4c7d36a69..89efde817 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -1,7 +1,7 @@ -%import diskio +%import gfx2 %import textio ;%import math -;%import verafx +%import verafx %zeropage basicsafe %option no_sysinit @@ -36,6 +36,11 @@ main { txt.print_w(w1) txt.nl() + gfx2.screen_mode(1) + verafx.fill(0, 0, %10101010, 1200) ; should fill top half of the screen + verafx.fill(0, 4800, %11111111, 1200) ; should fill bottom half of the screen + + ; txt.print_uw(math.mul16_last_upper()) ; txt.nl() ; uword value1=5678