diff --git a/compiler/res/prog8lib/cx16/verafx.p8 b/compiler/res/prog8lib/cx16/verafx.p8 index ae5039a93..9fd771ba3 100644 --- a/compiler/res/prog8lib/cx16/verafx.p8 +++ b/compiler/res/prog8lib/cx16/verafx.p8 @@ -6,6 +6,21 @@ verafx { %option no_symbol_prefixing + sub available() -> bool { + ; returns true if Vera FX is available (Vera V0.3.1 or later), false if not. + cx16.r1L = 0 + cx16.r0L = cx16.VERA_CTRL + cx16.VERA_CTRL = $7e + if cx16.VERA_DC_VER0 == $56 { + ; Vera version number is valid. + ; Vera fx is available on Vera version 0.3.1 and later, + ; so no need to even check VERA_DC_VER1, which contains 0 (or higher) + cx16.r1L = mkword(cx16.VERA_DC_VER2, cx16.VERA_DC_VER3) >= $0301 + } + cx16.VERA_CTRL = cx16.r0L + return cx16.r1L + } + sub clear(ubyte vbank, uword vaddr, ubyte data, uword amountof32bits) { ; use cached 4-byte write to quickly clear a portion of the video memory to a given byte value ; this routine is around 3 times faster as gfx2.clear_screen() diff --git a/compiler/res/prog8lib/virtual/math.p8 b/compiler/res/prog8lib/virtual/math.p8 index bd9088037..1e58632bb 100644 --- a/compiler/res/prog8lib/virtual/math.p8 +++ b/compiler/res/prog8lib/virtual/math.p8 @@ -2,9 +2,6 @@ math { - ; TODO: the VM doesn't yet store the full 32 bits result of a 16*16 multiplication, so there is NO mul16_last_upper() routine here at this time. - - sub sin8u(ubyte angle) -> ubyte { ubyte[256] sintab = [$80, $83, $86, $89, $8c, $8f, $92, $95, $98, $9b, $9e, $a2, $a5, $a7, $aa, $ad, $b0, $b3, $b6, $b9, $bc, $be, $c1, $c4, $c6, $c9, $cb, $ce, $d0, $d3, $d5, $d7, $da, $dc, $de, $e0, diff --git a/docs/source/libraries.rst b/docs/source/libraries.rst index a4425489f..cb59bb839 100644 --- a/docs/source/libraries.rst +++ b/docs/source/libraries.rst @@ -521,15 +521,18 @@ Available for the Cx16 target. Experimental routines that use the new Vera FX logic (hopefully coming in the Vera in new X16 boards, the emulators already support it). +``available`` + Returns true if Vera FX is available, false if not (that would be an older Vera chip) + ``mult`` , ``muls`` - For now, the hardware 16*16 multiplier is exposed via ``mult`` and ``muls`` routines (unsigned and signed respectively). + The hardware 16*16 multiplier is exposed via ``mult`` and ``muls`` routines (unsigned and signed respectively). They are about 4 to 5 times faster as the default 6502 cpu routine for word multiplication. But they depend on some Vera manipulation and 4 bytes in vram just below the PSG registers for storage. Note: there is a block level %option "verafxmuls" that automatically replaces all word multiplications in that block by calls to verafx.muls/mult, but be careful with it because it may interfere with other Vera operations or IRQs. ``clear`` - There's also a ``clear`` routine here to very quickly clear a piece of vram to a given byte value (it writes 4 bytes at a time). + Very quickly clear a piece of vram to a given byte value (it writes 4 bytes at a time). The routine is around 3 times faster as a regular unrolled loop to clear vram. ``transparency``