Siapran [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=9770 Parens-8 V3 <p>After a long journey, I'm proud to present to you...</p> <h1>parens-8 <em>v3!</em></h1> <img style="margin-bottom:16px" border=0 src="/media/9770/parens-8_v3_splash.gif" alt="" /> <p>...Along with the obligatory demo, a cart that stores its entire game code in ROM:<br /> <table><tr><td> <a href="/bbs/?pid=142700#p"> <img src="/bbs/thumbs/pico8_parens8_v3_demo-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=142700#p"> Parens-8 V3</a><br><br> by <a href="/bbs/?uid=9770"> Siapran</a> <br><br><br> <a href="/bbs/?pid=142700#p"> [Click to Play]</a> </td></tr></table> </p> <p>Parens-8 is a tool for bypassing the pico-8 token limit. It takes up 5% of the allowed 8192 tokens, and gives you practically infinite code space in return: store extra code in strings or cart ROM, load it during init, run it like regular Lua code.</p> <p>Parens-8 is designed for maximum interoperability with Lua. Functions, tables, values and coroutines can be passed and used seamlessly between Lua and parens-8. Think of parens-8 as Lua semantics with Lisp syntax.</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>local a, b, c = parens8(&quot;1 2 3&quot;) ?(b == 2) -- true local myfunction = parens8&quot;(fn(x) (print x))&quot; myfunction(42) -- prints 42 -- use the lua multiline string syntax: [[]] parens8[[ (set foo 256) (set bar (fn (a b) (when a (print b) (print &quot;a was false or nil&quot;) ) )) ]] bar(foo, &quot;hello&quot;) -- prints &quot;hello&quot; bar(false, &quot;goodbye&quot;) -- prints &quot;a was false or nil&quot;</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>The new v3 implementation greatly improves on previous versions:</p> <ul> <li>significantly faster (50-100% speedup)</li> <li>lower memory usage</li> <li>more extensions (variadics, table constructors, field syntax)</li> <li>safer (no nil invisibility issue)</li> </ul> <p>For more information and documentation, please refer to the <strong><a href="https://github.com/Siapran/parens-8">parens-8 Github repository</a></strong>.</p> https://www.lexaloffle.com/bbs/?tid=140578 https://www.lexaloffle.com/bbs/?tid=140578 Sun, 10 Mar 2024 00:29:43 UTC parens-8, a tiny lisp for your pico-8 carts <img style="margin-bottom:16px" border=0 src="/media/9770/parens-8.png" alt="" /> <p>first off, a demo. here's a cart that stores the entirety of its game logic in its sprite sheet:<br /> <table><tr><td> <a href="/bbs/?pid=135521#p"> <img src="/bbs/thumbs/pico8_baloonbomber_rom-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=135521#p"> baloonbomber_rom</a><br><br> by <a href="/bbs/?uid=9770"> Siapran</a> <br><br><br> <a href="/bbs/?pid=135521#p"> [Click to Play]</a> </td></tr></table> </p> <p>this is a parens-8 port of an <a href="https://www.lexaloffle.com/bbs/?tid=28773">old cart of mine</a>. it has the lua code for the parens-8 language, and then parens-8 code for loading parens-8 game logic from ROM. you can find the full source for the game logic <a href="https://github.com/Siapran/parens-8/blob/main/examples/baloonbomber.p8">here</a></p> <p>parens-8 is a lisp interpreter/compiler designed specifically to bypass the lua token limit.<br /> the idea: use a portion of your cart (between 330 and 900 tokens, depending on your use case) to store the parens-8 interpreter, offload performance noncritical code into strings, and then optionally into ROM.</p> <p>the <a href="https://github.com/Siapran/parens-8">parens-8 github repo</a> has detailed instructions on how to achieve this, and how to customize parens-8 to best fit your project.</p> <p>let's look at an excerpt of the original lua code for baloonbomber:</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>function make_explosion( x, y, r ) local explosion = { x = x, y = y, r = r, ttl = 10, fg = true } function explosion:update( ) if self.ttl &lt; 5 then self.x -= speed make_smoke(self.x + rnd(self.r) - self.r / 2, self.y + rnd(self.r) - self.r / 2) end end function explosion:draw( ) circfill(self.x, self.y, self.r * min(self.ttl / 8, 1), explosion_colors[11 - self.ttl] or 0) end add_particle(explosion) 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>and here is the corresponding parens-8 implementation:</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>(set make_explosion (fn (x y r) (add particles (zip (split &quot;x,y,r,ttl,fg,update,draw&quot;) (pack x y r 10 1 (fn (self) (env self (when (&lt; ttl 5) (id (set x (- x speed)) (make_smoke (- (+ x (rnd r)) (/ r 2)) (- (+ y (rnd r)) (/ r 2))))))) (fn (self) (env self (circfill x y (* r (min (/ ttl 8) 1)) (or ([] explosion_colors (- 11 ttl)) 0)))))))))</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>the syntax may seem hostile, but the semantics are very much similar to that of lua. you may even identify common pico-8 patterns like using <code>split</code> or remapping <code>_ENV</code>.</p> <p>parens-8 comes with a pretty significant performance overhead (see github repo for benchmarks), so while calls to the pico-8 api and lua functions are unaffected, tight loops and the like are dramatically slower in parens-8. make sure you minimize the cpu time spent in parens-8 code.</p> <p>things you could probably offload as parens-8 code:</p> <ul> <li>your <code>_init</code>, <code>_update</code> and <code>_draw</code> functions</li> <li>complicated actor behavior where different actors have very different logic (coroutines are supported!)</li> <li>weird glue code that <code>poke</code>s a bunch of flags, sets up <code>pal</code> calls, etc</li> </ul> <p>things you definitely shouldn't write in parens-8:</p> <ul> <li>your particle system</li> <li>your rendering routines</li> <li>3d rotation matrix computations</li> </ul> <p><em>baloonbomber - parens-8 edition</em> is the answer to the question &quot;can I offload my entire game to ROM&quot;:<br /> yes, but you probably shouldn't.</p> https://www.lexaloffle.com/bbs/?tid=54486 https://www.lexaloffle.com/bbs/?tid=54486 Fri, 06 Oct 2023 19:06:31 UTC picomake - a simple tool for making carts on unix <p><a href="https://github.com/Siapran/picomake">Github repo</a></p> <p>I was tired of navigating through all my code in a single file, so I made a simple tool for building carts code from multiple smaller files.</p> <p>Nothing fancy as of now, but I hope it can save some people some time.</p> https://www.lexaloffle.com/bbs/?tid=28798 https://www.lexaloffle.com/bbs/?tid=28798 Mon, 06 Feb 2017 17:22:45 UTC Baloonbomber <p> <table><tr><td> <a href="/bbs/?pid=37028#p"> <img src="/bbs/thumbs/pico37025.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=37028#p"> Baloonbomber 0.1</a><br><br> by <a href="/bbs/?uid=9770"> Siapran</a> <br><br><br> <a href="/bbs/?pid=37028#p"> [Click to Play]</a> </td></tr></table> </p> <p>Here's a small cart I made to teach programming to a friend.<br /> It's far from complete, and I'll post more updates as they make progress.</p> <p>I restrained myself from using lua tricks like coroutines, metatables, and abusive oop, so the code could be kept as much approachable as possible.</p> <p>Direction keys to move, C/Z to cycle lifes.</p> https://www.lexaloffle.com/bbs/?tid=28773 https://www.lexaloffle.com/bbs/?tid=28773 Wed, 01 Feb 2017 18:09:11 UTC [tool] Organ <p> <table><tr><td> <a href="/bbs/?pid=20310#p"> <img src="/bbs/thumbs/pico20313.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=20310#p"> [tool] Organ 0.1.1</a><br><br> by <a href="/bbs/?uid=9770"> Siapran</a> <br><br><br> <a href="/bbs/?pid=20310#p"> [Click to Play]</a> </td></tr></table> </p> <p>Organ is a simple sfx organizer.</p> <p>When I make music with the pico8 tracker, I usually end up with an unreadable mess of samples that have nothing in common.</p> <p>This utility lets you switch sfx indexes and update the song data accordingly.<br /> You can either specify a filename in the code (still waiting for a usable ls()), or paste the song data of another cart manually.</p> <p>The data is saved on the editor itself (even when a filename is specified). To save it to your music cart, you'll need to edit it manually (I'll make a better UI in the future).</p> <p>I may or may not extend this to make a music compression utility :T</p> https://www.lexaloffle.com/bbs/?tid=3308 https://www.lexaloffle.com/bbs/?tid=3308 Sun, 08 May 2016 08:49:03 UTC 3D Cloth Simulator <p> <table><tr><td> <a href="/bbs/?pid=11458#p"> <img src="/bbs/thumbs/pico11461.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=11458#p"> 3D Cloth Simulator</a><br><br> by <a href="/bbs/?uid=9770"> Siapran</a> <br><br><br> <a href="/bbs/?pid=11458#p"> [Click to Play]</a> </td></tr></table> </p> <p>A veeery old thing I did in 2013 when I didn't really know how to program yet.<br /> I was bored in math class so I did this thingy on my calculator.</p> <p>I pretty much copy-pasted the whole thing and applied a few fixes for pico8, but it's really the same old code (ewww...)<br /> At the time, the thing blurted out a frame every 28 seconds. Needless to say I was REALLY bored.</p> <p><a href="http://www.planet-casio.com/Fr/programmes/programme2159-1-3dcl.lua-siapran-lua.html">nostalgia link to the original code</a><br /> A friend of mine already adapted it for Love2D a while ago, with much better results (<a href="https://www.youtube.com/watch?v=IIWhpBcX5IM">video</a>).</p> <p>For fun times, try doing what I first did when I wrote this code: setting elasticity above 1/2.</p> <p>EDIT: oh, yeah, you can control the camera with the arrow keys and reset the cloth with x</p> https://www.lexaloffle.com/bbs/?tid=2100 https://www.lexaloffle.com/bbs/?tid=2100 Sun, 05 Jul 2015 08:49:30 UTC Boxes! <p> <table><tr><td> <a href="/bbs/?pid=11244#p"> <img src="/bbs/thumbs/pico11243.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=11244#p"> Boxes!</a><br><br> by <a href="/bbs/?uid=9770"> Siapran</a> <br><br><br> <a href="/bbs/?pid=11244#p"> [Click to Play]</a> </td></tr></table> </p> <p>I WAS BORED OK</p> https://www.lexaloffle.com/bbs/?tid=2067 https://www.lexaloffle.com/bbs/?tid=2067 Thu, 11 Jun 2015 11:56:11 UTC Note visualizer <p> <table><tr><td> <a href="/bbs/?pid=10885#p"> <img src="/bbs/thumbs/pico10893.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=10885#p"> Note visualizer 0.3</a><br><br> by <a href="/bbs/?uid=9770"> Siapran</a> <br><br><br> <a href="/bbs/?pid=10885#p"> [Click to Play]</a> </td></tr></table> </p> <p>Update: tweaked the cooldown</p> <p> <table><tr><td> <a href="/bbs/?pid=10885#p"> <img src="/bbs/thumbs/pico10888.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=10885#p"> Note visualizer 0.2</a><br><br> by <a href="/bbs/?uid=9770"> Siapran</a> <br><br><br> <a href="/bbs/?pid=10885#p"> [Click to Play]</a> </td></tr></table> </p> <p>just a simple demonstration of <a href="https://www.lexaloffle.com/bbs/?tid=1925">the undocumented feature of stat(x)</a><br /> using the demo musics of course</p> <p>feel free to use it in your music carts :D</p> https://www.lexaloffle.com/bbs/?tid=2015 https://www.lexaloffle.com/bbs/?tid=2015 Sat, 23 May 2015 15:38:34 UTC