From 207cdaf7a401c8c948547f479f443ed1236f73c5 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sun, 6 Nov 2022 16:38:31 +0100 Subject: [PATCH] fix kefrenbars example (use gfx2 instead of kernal routines) --- compiler/res/prog8lib/cx16/palette.p8 | 2 +- docs/source/todo.rst | 1 - examples/cx16/kefrenbars.p8 | 27 ++++++++++++--------------- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/compiler/res/prog8lib/cx16/palette.p8 b/compiler/res/prog8lib/cx16/palette.p8 index ce3e5a8e3..cc752650b 100644 --- a/compiler/res/prog8lib/cx16/palette.p8 +++ b/compiler/res/prog8lib/cx16/palette.p8 @@ -26,7 +26,7 @@ palette { } sub set_rgb(uword palette_words_ptr, uword num_colors) { - ; 1 word per color entry (in little endian format as layed out in video memory, so $gb0r) + ; 1 word per color entry (in little endian format as layed out in video memory, so $gb;$0r) vera_palette_ptr = $fa00 repeat num_colors*2 { cx16.vpoke(1, vera_palette_ptr, @(palette_words_ptr)) diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 73b9e276b..ddb3ce30a 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -3,7 +3,6 @@ TODO For next release ^^^^^^^^^^^^^^^^ -- fix cx16/kefrenbars.p8 - ir: write addresses as hex into p8ir file ... diff --git a/examples/cx16/kefrenbars.p8 b/examples/cx16/kefrenbars.p8 index 38b91b0fd..01b2a8e1d 100644 --- a/examples/cx16/kefrenbars.p8 +++ b/examples/cx16/kefrenbars.p8 @@ -1,11 +1,11 @@ %import palette %import math +%import gfx2 %option no_sysinit ; Vertical rasterbars a.k.a. "Kefren bars" ; also see: rasterbars.p8 - main { sub start() { @@ -23,9 +23,8 @@ main { ; Not yet implemented in ROM: cx16.FB_set_palette(&colors, 0, len(colors)*3) palette.set_rgb(&colors, len(colors)) - void cx16.screen_mode(128, false) ; low-res bitmap 256 colors - cx16.FB_init() - cx16.VERA_DC_VSCALE = 0 ; display trick spoiler.......: stretch display all the way to the bottom + gfx2.screen_mode(4) ; lores 256 colors + cx16.VERA_DC_VSCALE = 0 ; display trick spoiler.......: stretch 1 line of display all the way to the bottom cx16.set_rasterirq(&irq.irqhandler, 0) repeat { @@ -36,32 +35,30 @@ main { irq { + const ubyte BAR_Y_OFFSET = 5 uword next_irq_line = 0 ubyte anim1 = 0 ubyte av1 = 0 ubyte anim2 = 0 ubyte av2 = 0 - ubyte[32] pixels = 0 to 31 - const ubyte y_offset = 6 sub irqhandler() { - next_irq_line += y_offset - anim1 += 4 - anim2 += 6 - if next_irq_line > 480-y_offset { + next_irq_line += BAR_Y_OFFSET + anim1 += 7 + anim2 += 4 + if next_irq_line > 480-BAR_Y_OFFSET { av1++ av2 += 2 anim1 = av1 anim2 = av2 next_irq_line = 0 ; erase the bars - cx16.FB_cursor_position(0, 0) - cx16.FB_fill_pixels(320, 1, 0) + gfx2.horizontal_line(0, 0, 320, 3) } else { - ; add new bar - cx16.FB_cursor_position(math.sin8u(anim1)/2 + math.cos8u(anim2)/2 + $0010, 0) - cx16.FB_set_pixels(pixels, len(pixels)) + ; add new bar on top + gfx2.position(math.sin8u(anim1)/2 + math.cos8u(anim2)/2 + $0010, 0) + gfx2.next_pixels(pixels, len(pixels)) } cx16.set_rasterline(next_irq_line)