From 093391840657007c852eb2d9930e64998a1aba6b Mon Sep 17 00:00:00 2001 From: Kistaro Windrider Date: Sun, 1 Oct 2023 12:47:57 -0700 Subject: [PATCH] palette loaders --- pal_from_spr.p8 | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/pal_from_spr.p8 b/pal_from_spr.p8 index beb3214..5eaade5 100644 --- a/pal_from_spr.p8 +++ b/pal_from_spr.p8 @@ -200,6 +200,39 @@ function palette:compile_palt() self.cpl_tr = bits return bits end +-->8 +-- load palettes + +function load_box_palette(sidx) + local sint,sfrac=sidx\1,sidx%1 + local x0,y0=sint%16*8,sint\16*8+sfrac*8\1 + local c0ls,tr={},{} + for i=0,15 do + local x,y=x0+i%4,y0+i\4 + local c,f= sget(x,y),sget(x+4,y) + if (f&0x1 ~= 0) c += 128 + if (f&0x2 ~= 0) tr[i]=true + if (f&0x4 ~= 0) tr[i]=false + if (f&0x8 == 0) cols[i] = c + end + local ret=palette.new{cols=cols,tr=tr} + ret:compile_palt() + return ret +end + +function load_row_palette(sx, sy) + local cols,tr={},{} + for i=0,15 do + local c,f = sget(sx+i,sy),sget(sx+i,sy+1) + if (f&0x1 ~= 0) c += 128 + if (f&0x2 ~= 0) tr[i]=true + if (f&0x4 ~= 0) tr[i]=false + if (f&0x8 == 0) cols[i] = c + end + local ret=palette.new{cols=cols,tr=tr} + ret:compile_palt() + return ret +end __gfx__ 00000000012300000123555501230000012355550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000456700004567555545670000456755550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000