From 9acec4d952e914d2c64c7d7c77f2bb590277fe4f Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Tue, 28 Sep 2021 23:12:16 +0200 Subject: [PATCH] changed to fixed point math to always generate bars of 32 lines height --- examples/cx16/colorbars.p8 | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/examples/cx16/colorbars.p8 b/examples/cx16/colorbars.p8 index 2cc974416..c24e82fd6 100644 --- a/examples/cx16/colorbars.p8 +++ b/examples/cx16/colorbars.p8 @@ -1,6 +1,5 @@ %import gfx2 %import palette -%import textio ; TODO WORK IN PROGRESS... @@ -9,23 +8,25 @@ main { sub start() { - palette.set_all_black() + ;palette.set_all_black() gfx2.screen_mode(4) ubyte yy for yy in 0 to 239 - gfx2.horizontal_line(0, yy, 320, yy & 31) + gfx2.horizontal_line(0, yy, 320, yy) repeat { - colors.random_half_bar() - colors.mirror_bar() - colors.set_palette() - repeat 20 + yy = 0 + repeat 8 { + colors.random_half_bar() + colors.mirror_bar() + colors.set_palette(yy) + yy+=32 + } + + repeat 10 sys.waitvsync() } - - repeat { - } } } @@ -107,11 +108,11 @@ colors { } } - sub set_palette() { + sub set_palette(ubyte offset) { ubyte ix for ix in 0 to 31 { uword color = mkword(reds[ix], (greens[ix] << 4) | blues[ix] ) - palette.set_color(ix, color) + palette.set_color(ix+offset, color) } } }