Einstein2 [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=47512 Feature request: info([cart]) <p>Basically the title. </p> <div> <div style="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>info([cart])--returns tokens,chars,compressed_size of [cart] or the current cart if given none</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>This could be useful for people who are creating carts using printh() and such, to detect if the cart is able to be run before load()ing it:</p> <div> <div style="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>tokens,chars,compressed=info(&quot;cart.p8&quot;) if(tokens&lt;8192 and chars&lt;65536)load(&quot;cart.p8&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>What do you all think?</p> https://www.lexaloffle.com/bbs/?tid=43975 https://www.lexaloffle.com/bbs/?tid=43975 Wed, 28 Jul 2021 18:51:25 UTC picoforth, a stack-based programming language <p> <table><tr><td> <a href="/bbs/?pid=93031#p"> <img src="/bbs/thumbs/pico8_picoforth-4.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=93031#p"> picoforth</a><br><br> by <a href="/bbs/?uid=47512"> Einstein2</a> <br><br><br> <a href="/bbs/?pid=93031#p"> [Click to Play]</a> </td></tr></table> <br /> Welp, this took way to long to finish. But now it's here!</p> <h3>about</h3> <p>picoforth is a programming language based on Forth, a family of stack-based programming languages. If you're unfamiliar with stack-based programming languages or Forth, I recommend you check out <a href="https://skilldrick.github.io/easyforth/">this site</a>.</p> <h3>wordlist</h3> <p>Here is a list of every word in picoforth. (A &quot;word&quot; in a stack-based language is roughly equivalent to a &quot;function&quot; or a &quot;subroutine&quot; in a normal programming language.)</p> <div> <div style="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>--typical forth stack-manipulating words pop 2pop dup 2dup over swap rotl rotr --mathematical operators + - * / // --integer division ^ --comparing operators = ~= &gt; &lt; --bitwise operators &amp; --bitwise and, or, shr, shl, xor, and not, respectively | &gt;&gt; &lt;&lt; ^^ ~ --storing and recalling ! --peek and poke, respectively @ --printing . --prints the popped item (works with strings and numbers) .stack --prints the entire stack (doesn't affect anything) --key operations chr ord key --halts the program until a key is pressed; pushes the pressed key input --repeats key until enter is pressed; pushes the finished string --branching branch --relative branch: I(nstruction)P(ointer) becomes the sum of itself and popped item goto --absolute branch: sets the IP to popped item --screen drawing cls flip spr pset --strings &quot; -- opens a string, then closes it the next time it's used (i.e. &quot; asdf &quot; . will print asdf) &quot;&quot; --pushes an empty string join --concatenates the two top popped items sub # --length of string --miscellaneous exec --runs the popped item as if it were forth code time --pushes t()\1 rnd --pushes rnd(poppeditem\1) sin --pushes sin(poppeditem) cos --pushes cos(poppeditem) def --pushes the definition of popped item interpret --repeats input + exec forever --creating new words : -- : name-of-new-word [definition] ; ;</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Here's an example program, the one that generated the label image:</p> <div> <div style="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>0 1 + dup dup 0x6000 + dup rotl ! 0x7fff &lt; 2 * goto</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Post any spinoffs of this cart/programs in picoforth that you made in the comments. I'd love to see them!<br /> <em>For the previous picoforth, which was a work-in-progress, see <a href="https://www.lexaloffle.com/bbs/?tid=42885">this cart</a>.</em></p> https://www.lexaloffle.com/bbs/?tid=43195 https://www.lexaloffle.com/bbs/?tid=43195 Sat, 05 Jun 2021 00:16:45 UTC picoforth - a stack-based programming language <p> <table><tr><td> <a href="/bbs/?pid=91954#p"> <img src="/bbs/thumbs/pico8_picoforth-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=91954#p"> picoforth</a><br><br> by <a href="/bbs/?uid=47512"> Einstein2</a> <br><br><br> <a href="/bbs/?pid=91954#p"> [Click to Play]</a> </td></tr></table> </p> <h1>picoforth - a stack-based programming language</h1> <p>picoforth is a project I started working on a while ago, and then gave up on, then returned to yesterday. It is unfinished (there are a few minor bugs, there is essentially no support for strings yet, and the method of inputting text is pretty bad), but still can do quite a lot.</p> <p>If you are unfamiliar with stack-based languages, I recommend you check out <a href="https://skilldrick.github.io/easyforth/">easyforth</a>, a stack-based language resembling a typical Forth. It can teach you the basics of stack-based languages, and to a lesser extent, Forth.</p> <p>Here's the list of the words (for those unfamiliar, a &quot;word&quot; in forth is roughly comparable to a function in most other languages) currently in picoforth:<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 style="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>(if a word doesn't have a comment, that means it works exactly like it would in a normal Forth) pop swap dup over rotl -- rotates the top three stack items left (n1 n2 n3 -&gt; n3 n1 n2) rotr -- same, but to the right (n1 n2 n3 -&gt; n2 n3 n1) + - * / // -- integer division = ~= -- not equals &gt; &lt; &amp; -- bitwise and | -- or ^^ -- xor ~ -- not &gt;&gt; -- shr &lt;&lt; -- shl not -- 1 -&gt; 0, 0 -&gt; 1 ! -- @ and ! are peek and poke, respectively @ . .stack -- prints the current stack, mostly useful for debugging key -- halts the program until a key is pressed; puts the ord() of that key on the stack emit branch -- relative branch: adds the instruction pointer with the value at the top of the stack (can be negative) absbranch -- absolute branch: sets the instruction pointer to the value of the item at the top of the stack : ; </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> <p>Here's an example program, the one that generated the label image: </p> <div> <div style="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>0 1 + dup dup 0x6000 + dup rotl ! 0x7fff &lt; 2 * absbranch</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>My eventual goal with this is to make tiny games/demos that you can copy and paste into this cart, similar to a tweetcart. If you want to, make spinoffs of this cart! I'd love to see them.</p> https://www.lexaloffle.com/bbs/?tid=42885 https://www.lexaloffle.com/bbs/?tid=42885 Fri, 14 May 2021 23:28:15 UTC Interesting feature(?): print(&quot;\^c[col]&quot;) is way faster than cls([col]) <h3>context</h3> <p>Earlier today, I learned that pressing ctrl+p while running a cart brings up a performance monitor (and something else I learned on accident: pressing ctrl+p in the commandline/text editor lets you use the tiny characters; this isn't documented in the pico-8 fandom wiki but is on pico-8's changelog in the manual.)</p> <p>I booted up one of my carts and opened the performance monitor. (It runs at a smooth 60fps, it's not very complicated at all). For fun, I changed the cls(1) to print(&quot;\^c1&quot;). To my great surprise, the performance monitor indicated that it did this ever so slightly <em>quicker</em> than cls(1). So I made a new cartridge (function _update60()for _=1,1000do print(&quot;\^c1&quot;) end) and it ran smoothly, never going over the virtual processor limit. I switched the print() to the respective cls() and it was almost <em>2 times more resource intensive</em>, constantly over the virtual limit, and running at an extremely choppy ~1fps.</p> <h3>conclusion</h3> <p>I'm not sure how this would be useful unless you're calling cls() an awful lot of times, as it takes quite a few extra characters. Even with the minor improvement of using ? rather than print() is small, as you still need a newline on either side. If you really wanted to, you could just redefine cls() to simply be something like this:</p> <div> <div style="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 cls(a)a=a or 0 ?&quot;\^c&quot;..split(&quot;0123456789abcdef&quot;,&quot;&quot;)[a+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> https://www.lexaloffle.com/bbs/?tid=42118 https://www.lexaloffle.com/bbs/?tid=42118 Sun, 21 Mar 2021 21:02:57 UTC Colors, lots of colors <p> <table><tr><td> <a href="/bbs/?pid=85434#p"> <img src="/bbs/thumbs/pico8_lotsocolors-2.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=85434#p"> lotsocolors</a><br><br> by <a href="/bbs/?uid=47512"> Einstein2</a> <br><br><br> <a href="/bbs/?pid=85434#p"> [Click to Play]</a> </td></tr></table> <br /> This is a simple pico-8 program that I thought I would share. The concept is simple; it's drawing circles where the center is a point on an (hidden) circle, incrementing the color each time. You can adjust the radius of the hidden circle by using left/right and the amount of circles being drawn with up/down. Since it never clears the screen, it gives really nice visuals with the trails left behind by the circles.</p> <p>edit: there is now a version 1.1, which allows you to press x/o to swap whether or not screen clearing is on or not. While this looks much more boring, it allows to see how it works much better.<br /> <table><tr><td> <a href="/bbs/?pid=85434#p"> <img src="/bbs/thumbs/pico8_lotsocolors-3.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=85434#p"> lotsocolors</a><br><br> by <a href="/bbs/?uid=47512"> Einstein2</a> <br><br><br> <a href="/bbs/?pid=85434#p"> [Click to Play]</a> </td></tr></table> </p> https://www.lexaloffle.com/bbs/?tid=40813 https://www.lexaloffle.com/bbs/?tid=40813 Tue, 15 Dec 2020 17:19:31 UTC Julia set renderer <p> <table><tr><td> <a href="/bbs/?pid=83705#p"> <img src="/bbs/thumbs/pico8_juliasetrender-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=83705#p"> Julia Set Renderer</a><br><br> by <a href="/bbs/?uid=47512"> Einstein2</a> <br><br><br> <a href="/bbs/?pid=83705#p"> [Click to Play]</a> </td></tr></table> <br /> This is a Julia set renderer. Not much else to say. The code was based off of the <a href="https://en.wikipedia.org/wiki/Julia_set#Pseudocode">Wikipedia Pseudocode for the Julia Set</a>.<br /> The controls are (X) to zoom out, (Z)/(C) to zoom in, and the arrow keys to adjust the fractal parameters.<br /> Hopefully you can enjoy it!<br /> PS There are probably ways to increase the speed of this program. (This is my third published cartridge and so I'm not too great at pico-8 yet.) Once you zoom to fit the screen it takes ~2 seconds to respond. Feel free to point out changes that can be made.</p> https://www.lexaloffle.com/bbs/?tid=40132 https://www.lexaloffle.com/bbs/?tid=40132 Wed, 04 Nov 2020 18:33:59 UTC Tiny collision function for squares <p> <table><tr><td> <a href="/bbs/?pid=82804#p"> <img src="/bbs/thumbs/pico8_wezemogowo-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=82804#p"> Collision Detection for rectangles</a><br><br> by <a href="/bbs/?uid=47512"> Einstein2</a> <br><br><br> <a href="/bbs/?pid=82804#p"> [Click to Play]</a> </td></tr></table> <br /> This is my second published Pico-8 cartridge. It shows a near-perfect (in collision detection, not in the way it works) tiny collision detection function for a square. It can be expanded to any arbitrarily-sized rectangle. A square was chosen for simplicity. </p> <p>There is no doubt in my mind that this can be improved upon. You know what, there's probably a way better, super obvious way that I glanced over.</p> <p>I don't recommend using this for any of your games, as it has a blazingly obvious issue: You can't go into anything that isn't a black pixel. Also, due to the way it detects the pixels, it cannot detect sprites/map tiles that are smaller then a square.</p> <p>The only reason I made this was to see if I could make a collision detection system that didn't use:</p> <ul> <li>Rocket science</li> <li>Quantum physics</li> <li>Carts that use coding like <a href="https://www.youtube.com/watch?v=rwOI1biZeD8">this video</a></li> <li>just kidding about most of those<br /> I included the code so you can see how short it is (yes this is the <strong>entire</strong> cartridge's code) <div> <div style="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>px=64 py=64 function collision() collr1=pget(px+8,py) collr2=pget(px+8,py+7) colll1=pget(px-1,py) colll2=pget(px-1,py+7) collu1=pget(px,py-1) collu2=pget(px+7,py-1) colld1=pget(px,py+8) colld2=pget(px+7,py+8) end function _update() cls() map(0,0,0,0,16,16) collision() spr(1,px,py) if btn(0) and colll1==0 and colll2==0 then px-=1 end if btn(1) and collr1==0 and collr2==0 then px+=1 end if btn(2) and collu1==0 and collu2==0 then py-=1 end if btn(3) and colld1==0 and colld2==0 then py+=1 end end</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div></li> </ul> https://www.lexaloffle.com/bbs/?tid=39888 https://www.lexaloffle.com/bbs/?tid=39888 Sun, 11 Oct 2020 20:17:04 UTC Simple Sprite Scroller <p> <table><tr><td> <a href="/bbs/?pid=82564#p"> <img src="/bbs/thumbs/pico8_sss-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=82564#p"> Simple Sprite Scroller</a><br><br> by <a href="/bbs/?uid=47512"> Einstein2</a> <br><br><br> <a href="/bbs/?pid=82564#p"> [Click to Play]</a> </td></tr></table> <br /> This is a simple program that picks a random sprite, displays it, moves, and then repeats. This is my first Pico-8 program and doesn't do much but is a decent screensaver in a pinch. If you're wondering where those sprites came from, it was my interpretation of <a href="http://tokipona.net/tp/janpije/hieroglyphs.php">sitelen pona</a>, one of the writing systems of <a href="https://tokipona.org/">Toki Pona</a>. Hopefully I didn't mess anything up!</p> https://www.lexaloffle.com/bbs/?tid=39816 https://www.lexaloffle.com/bbs/?tid=39816 Sun, 04 Oct 2020 19:21:27 UTC