fix kefrenbars example (use gfx2 instead of kernal routines)

This commit is contained in:
Irmen de Jong 2022-11-06 16:38:31 +01:00
parent 7315b581ce
commit 207cdaf7a4
3 changed files with 13 additions and 17 deletions

View File

@ -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))

View File

@ -3,7 +3,6 @@ TODO
For next release
^^^^^^^^^^^^^^^^
- fix cx16/kefrenbars.p8
- ir: write addresses as hex into p8ir file
...

View File

@ -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)