diff --git a/pal_from_spr.p8 b/pal_from_spr.p8 index 6557ea5..8e05afe 100644 --- a/pal_from_spr.p8 +++ b/pal_from_spr.p8 @@ -18,31 +18,35 @@ function _init() dcy = 0 init_box_pals() - init_row_pals() + init_rows_pals() +end + +function boxspr(x, y) + return 1+x+16*(y\2)+(y%2*0.5) end function init_box_pals() box_pals = {} - for x=0,box_cols do + for x=0,box_cols-1 do local pal_col = {} - for y=0,box_rows do - pal_col[y] = load_box_palette(1+x+16*(y\2)+(0.5*y%2)) + for y=0,box_rows-1 do + pal_col[y] = load_box_palette(boxspr(x,y)) end box_pals[x] = pal_col end end -function init_row_pals() - row_pals = {} - for x=0,row_cols do +function init_rows_pals() + rows_pals = {} + for x=0,rows_cols-1 do local pal_col = {} - for y=0,row_rows do + for y=0,rows_rows-1 do pal_col[y] = load_row_palette( 8+16*x, 16+2*y ) end - row_pals[x] = pal_col + rows_pals[x] = pal_col end end @@ -69,14 +73,15 @@ end function _draw() cls() draw_hud() - local pals = (mode == "boxes") and box_pals or row_pals + local pals = (mode == "boxes") and box_pals or rows_pals pals[scx][scy]:do_both(0) pals[dcx][dcy]:do_both(1) draw_bars() end function draw_hud() - palt() + pal(0) + pal(1) if (mode == "boxes") return draw_box_hud() draw_rows_hud() end @@ -86,6 +91,12 @@ function print_shadow(s,x,y,c) print(s,x,y,c or 7) end +function lpad(str,w) + str=tostr(str) + while (#str < w) str = " "..str + return str +end + box_rows = 4 box_cols = 4 @@ -97,10 +108,12 @@ function draw_box_hud() spr(109 + (active == "draw" and toff or 0), 3+8*dcx,4*dcy,1,0.5) - print_shadow("spr",42,5,12) + print_shadow("spr",42,1,12) + print_shadow(lpad(boxspr(scx,scy),3),42,9,6) sspr(8+8*scx,4*scy,8,4,55,4,16,8) - print_shadow("draw",73,5,14) + print_shadow("draw",73,1,14) + print_shadow(lpad(boxspr(dcx,dcy),3),77,9,6) sspr(8+8*dcx,4*dcy,8,4,91,4,16,8) end @@ -193,7 +206,7 @@ end function palette:compile_palt() self.cpl_tr = nil local bits, tr = 0, self.tr - for i = 15,0,-1 do + for i = 0,15 do if (tr[i] == nil) return bits <<= 1 if (tr[i]) bits += 1 @@ -235,14 +248,14 @@ function load_row_palette(sx, sy) return ret end __gfx__ -00000000012300000123555501230000012355550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000456700004567555545670000456755550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -0070070089ab000089ab555589ab000089ab55550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00077000cdef0000cdef5555cdef0000cdef55550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000012300000123111101230000012311110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000456700004567111145670440456711110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0070070089ab000089ab111189ab024089ab11980000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00077000cdef0000cdef1111cdef0000cdef11990000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00077000012324440123355501232444012335550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00700700456744444567555545674444456755550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -0000000089ab444489ab555589ab444489ab55550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000cdef4444cdef5555cdef4444cdef55550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00700700456744444567555545674004456755550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000089ab444489ab555589ab420489ab55ca0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000cdef4444cdef5555cdef4444cdef55ba0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000012301230123012301230123012301230000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000456745674567456745674567456745670000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000089ab89ab89ab89ab89ab89ab89ab89ab0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000