NPO [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=74717 Bad Apple On Pico8 <h1>Bad Apple on Pico8</h1> <img style="margin-bottom:16px" border=0 src="/media/74717/3_bad_apple_1.png" alt="" /> <p>Link to github <a href="https://github.com/NPO-197/BadApplePico8">here</a><br /> Note this works by dragging and dropping a frameData.bin onto the running cart so it dose not work on BBS.</p> <p>Drawing Function Used by Cart:<br /> <div><div><input type="button" value=" Show " onClick="if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = ''; this.innerText = ''; this.value = ' Hide '; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = ' Show '; }"></div><div><div style="display: none;"></p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>--main print(&quot;dropfile&quot;) repeat until stat(120) cls() polys={{}} i=0 p = 1 size=0 function _update() byte=0 while byte!=0xff do if i&gt;=size then size = serial(0x800,0x4300,1000) if size==0 then stop(&quot;done&quot;) end i=0 end byte = peek(0x4300+i) if byte!=0xff and byte!=0xfe then add(polys[p],byte) end if byte==0xfe then p+=1 add(polys,{}) end i+=1 end end function _draw() cls() for poly in all(polys) do line(poly[1],poly[2],poly[1],poly[2]) for i=1,#poly,2 do if poly[i]==0xff then stop(&quot;here&quot;) end line(poly[i],poly[i+1],7) end end polys={{}} p=1 end </pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p></div></div></div></p> <h2>How it works</h2> <p>frameData.bin contains all the video data, every 2 bytes is an x,y coordinate for the endpoint of a line, an 0xfe byte represents the end of a polygon, a 0xff byte represents the end of a frame.</p> <p>The pico8 cart reads this data 1,000 bytes at a time, and draws the outline of each polygon (filling them in would be a challenge).</p> <h2>Shout Out</h2> <p>Shout out to this project <a href="https://github.com/kevinjycui/css-video/tree/bb55bfc7f54495df760a0737c579e041763bba95">here</a> which did the initial work of turning the original video into a list of polygons, which this project is based on.</p> <h2>Follow Up</h2> <p>I'd like to investigate the possibility of compressing the frame data into a single cart, which might be difficult at full scale resolution. I'd also like to investigate algorithms for filling in the polygons efficiently. Any ideas / advice is most welcome! </p> https://www.lexaloffle.com/bbs/?tid=52948 https://www.lexaloffle.com/bbs/?tid=52948 Wed, 31 May 2023 23:53:16 UTC