diff --git a/compiler/res/prog8lib/cx16/gfx2.p8 b/compiler/res/prog8lib/cx16/gfx2.p8 index a3f73e71d..5b6bc684e 100644 --- a/compiler/res/prog8lib/cx16/gfx2.p8 +++ b/compiler/res/prog8lib/cx16/gfx2.p8 @@ -239,22 +239,27 @@ _done 6 -> { ; highres 4c ; TODO also mostly usable for lores 4c? - cx16.VERA_ADDR_H = (cx16.VERA_ADDR_H & %00000111) ; no auto advance color &=3 - color <<= gfx2.plot.shift4c[lsb(x) & 3] - ubyte mask = gfx2.plot.mask4c[lsb(x) & 3] + ubyte[4] colorbits + ubyte[4] masks + ubyte mask = %11111100 + ubyte ii + for ii in 3 downto 0 { + colorbits[ii] = color + masks[ii] = mask + color <<= 2 + mask <<=2 + } void addr_mul_24_for_highres_4c(y, x) ; 24 bits result is in r0 and r1L (highest byte) + cx16.VERA_ADDR_H = (cx16.VERA_ADDR_H & %00000111) ; no auto advance repeat length { ; TODO optimize the vera memory manipulation in pure assembly - ubyte cbits4 = cx16.vpeek(lsb(cx16.r1), cx16.r0) & mask | color + ubyte lower_x_bits = lsb(x) & 3 + ubyte cbits4 = cx16.vpeek(lsb(cx16.r1), cx16.r0) & masks[lower_x_bits] | colorbits[lower_x_bits] cx16.vpoke(lsb(cx16.r1), cx16.r0, cbits4) - x++ - if x & 3 == 0 + if lower_x_bits==%00000011 cx16.r0++ ; next x byte - ror2(color) - ror2(color) - ror2(mask) - ror2(mask) + x++ } } } @@ -635,6 +640,7 @@ _done ; -- sets the next pixel byte to the graphics chip. ; for 8 bpp screens this will plot 1 pixel. ; for 1 bpp screens it will plot 8 pixels at once (color = bit pattern). + ; for 2 bpp screens it will plot 4 pixels at once (color = bit pattern). %asm {{ sta cx16.VERA_DATA0 }} @@ -644,6 +650,7 @@ _done ; -- sets the next bunch of pixels from a prepared array of bytes. ; for 8 bpp screens this will plot 1 pixel per byte. ; for 1 bpp screens it will plot 8 pixels at once (colors are the bit patterns per byte). + ; for 2 bpp screens it will plot 4 pixels at once (colors are the bit patterns per byte). %asm {{ phx sta P8ZP_SCRATCH_W1 diff --git a/examples/cx16/amiga.p8 b/examples/cx16/amiga.p8 index e68f7d424..5ad9d5ea4 100644 --- a/examples/cx16/amiga.p8 +++ b/examples/cx16/amiga.p8 @@ -10,10 +10,8 @@ main { sub start() { - palette.set_monochrome($0aaa, $0000) - gfx2.screen_mode(6) ; select 640*480 mode - - sys.wait(200) + gfx2.screen_mode(5) ; select 640*480 mode + palette.set_monochrome($0aaa, $0000) ; TODO fix setting the palette... the isNoClobberRisk() for lsb/msb broke it cx16.VERA_DC_VSCALE = 64 ; have the vertical resolution so it is 640*240 - more or less Amiga's default non interlaced mode cx16.mouse_config(1, 1) ; enable mouse TODO make it an Amiga mouse pointer if possible diff --git a/examples/cx16/highresbitmap-4c.p8 b/examples/cx16/highresbitmap-4c.p8 index 04ccaf1cd..017454d28 100644 --- a/examples/cx16/highresbitmap-4c.p8 +++ b/examples/cx16/highresbitmap-4c.p8 @@ -19,14 +19,14 @@ main { ubyte color uword yy - for color in 3 downto 0 { - for yy in 100 to 120 { - uword xx - for xx in 10 to 500 { - gfx2.plot(xx, yy, color) - } - } - } +; for color in 3 downto 0 { +; for yy in 100 to 120 { +; uword xx +; for xx in 10 to 500 { +; gfx2.plot(xx, yy, color) +; } +; } +; } for color in 3 downto 0 {