hotn-gay-digital-garden/twitter/tweets/11_15_2020_replies.md
2026-02-15 21:39:13 -06:00

51 lines
No EOL
1.2 KiB
Markdown

{{{
"planted": "11/15/2020",
"repotted": "1/4/2026",
"nobreak": "true"
}}}
<div class="code"><p>
cls()
while(not btn(4))print("press 🅾️ to confirm",32,61,8)
o=8
for y=0,128do
for i=0,128/o,4do
for x=i*o,i*o+o do
if(sget(x,y)!=0)sset(x,y,1)
for s=1,3do
if(sget(x+s*o,y)!=0)sset(x,y,sget(x,y)|(1<<s))
end
end
end
end
cstore(0,0,8192)
</p></div>
### [@ThatTomHall](https://twitter.com/ThatTomHall)
* Very cool! A draw_compressed_sprite or decompress_sprites routine would rock too.
### ValerADHD
* Absolutely! It's a little odd because #pico8 has an inbuilt feature for doing color masking, but since it works directly on the draw palette it's hard to handle drawing different colors. I'll put two functions in the replies, one using pure bitmasking and one with actual coloring
<div class="code"><p>
--colored manual bitmasking!
function spr_1bpp_colored(sp,layer,col,x,y,w,h)
mask=1<<layer
for i=0,15do
if(i&mask!=0)pal(i,col)else palt(i,true)
end
spr(sp,x,y,w or 1,h or 1)
pal()palt()
end
</p></div>
<div class="code"><p>
--uncolored, pure bitmasking!
function spr_1bpp(sp,layer,x,y,w,h)
poke(0x5f5e,(1<<layer)|0xf0)
spr(sp,x,y,w or 1,h or 1)
pal(1<<layer,col,1)
poke(0x5f5e,0)
end
</p></div>