ChristopherD [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=31158 Exported binary apps trigger virus/security alerts <p>I've asked this question before, but it was lumped in with other export-related stuff; so I'm breaking this out into a standalone post. macOS and Windows exported binary applications trigger security/virus warnings that scare off potential users of my software. As recommended by Pico-8 docs I am &quot;distribut(ing) the outputted zip files as-is to ensure users on other operating systems can run them.&quot;</p> <p><strong>On Windows:</strong><br /> The executable on first launch triggers Windows Defender on Windows 7 and 10 (reported so far). I tried codesigning the .exe with signtool to no avail. Is there a way to fix this?</p> <p><strong>On macOS:</strong><br /> Like Windows, the unsigned app triggers a security warning. Has anyone successfully fixed this, perhaps with an Apple developer account and re-codesigning?</p> <p>I don't mind signing up and paying for Microsoft and Apple developer accounts if it will resolve the problem, but I don't want to pay just to find out it doesn't help. Hoping the community has experience I can leverage before making any financial commitments. </p> https://www.lexaloffle.com/bbs/?tid=47193 https://www.lexaloffle.com/bbs/?tid=47193 Sat, 02 Apr 2022 00:13:43 UTC (half-solved) \# control code clips custom font by 1px <p>Here's an example of trying to add a continuous underscore to the #font_snippet alternate font. Printing works fine with <code>\014\f7</code> but the font gets clipped by 1px on the right with <code>\014\#1\f7</code><br /> (color is irrelevant; the inclusion of <code>\#(number)</code> triggers it.</p> <img style="" border=0 src="/media/31158/clipped_font_example.png" alt="" /> <p>EDIT: see below for the fix.</p> https://www.lexaloffle.com/bbs/?tid=46717 https://www.lexaloffle.com/bbs/?tid=46717 Wed, 23 Feb 2022 04:14:37 UTC print returns [nil] with \^d <p>According to documentation<br /> <code>PRINT returns the right-most x position that occurred while printing</code></p> <p>One can make a valid case that certain print control codes may result in unusual return values, but this one doesn't feel right to me.</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>x = print('\^iabcde') print(x) y = print('\^d2abcde') print(y)</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>results in</p> <img style="" border=0 src="/media/31158/Screenshot 2022-02-05 173710.png" alt="" /> <p>The <em>speed</em> of the print output shouldn't affect our ability to receive the final x position, IMHO.</p> https://www.lexaloffle.com/bbs/?tid=46455 https://www.lexaloffle.com/bbs/?tid=46455 Sat, 05 Feb 2022 08:36:28 UTC &gt; Status Line v2.0: Play Infocom classics (and more) on your Pico-8 <img style="" border=0 src="/media/31158/status_line_5.png" alt="" /> <h2>Your Pico-8 just got a big graphics upgrade</h2> <p>With game graphics drawn &quot;from the limitless imagery of your imagination&quot; (according to an <a href="http://www.infocom-if.org/ads/ads05.html">old Infocom advertisement</a>), a world of classic text adventures is now playable on the Pico-8.</p> <p>Status Line implements the z-machine v3/v4 specifications, allowing you to play .z3 and .z4 text adventures like <em>Zork</em>, <em>Hitchhiker's Guide to the Galaxy</em>, <em>Trinity</em>, <em>A Mind Forever Voyaging</em> and more. There are those who continue to keep the Infocom flame alive, and their games will work as well.</p> <p><img style="" border=0 src="/media/31158/witness.png" alt="" /> <img style="" border=0 src="/media/31158/17_zork.png" alt="" /> </p> <h2>Features</h2> <ul> <li>Can play every game in the &quot;z3&quot; and &quot;z4&quot; format</li> <li>Custom font with multi-font display, includes mixed plain/bold/italic</li> <li>Supports game sizes up to 256K</li> <li>Supports simple sound effects (used by many z4 games)</li> <li>Save/restore games in progress</li> <li>Multiple color themes to recreate a &quot;classic feel&quot;</li> <li>Player-selectable text scroll speed</li> <li>Player-selectable cursor style, because why not</li> <li>Choose 24 or 12-hour clock for time-based games</li> </ul> <h3>Status Line Available Now at itch.io</h3> <p>Details, where to find games to play, future work, etc. can be found on the project page at <a href="https://christopherdrum.itch.io/statusline">https://christopherdrum.itch.io/statusline</a>.<br /> Source code now on github: <a href="https://github.com/ChristopherDrum/status-line">https://github.com/ChristopherDrum/status-line</a></p> <h2>Special Feature: Status Line Classics</h2> <p>I've modified a handful of original Infocom games, from original source code, to look and play great on the Pico-8. Lots of UX changes, text layout/formatting changes, etc. to accomodate the Pico-8's tiny, cozy screen. Source and playable .z4 files are available at github: <a href="https://github.com/ChristopherDrum/status-line-classics">https://github.com/ChristopherDrum/status-line-classics</a></p> <p><img style="" border=0 src="/media/31158/qjFIYc.png" alt="" /><img style="" border=0 src="/media/31158/bur_mixed_fonts_250.png" alt="" /></p> <h2>Update - v2.0 Released (Mar. 22, 2022)</h2> <p>This update adds .z4 game support, multi-font display, better core engine, slightly faster core performance, more compact input cursor, some deep bug fixes, and more. Status Line Classics v1.0 is released in conjunction with this update to give the Pico-8 community best-in-class adaptations of Infocom classics for our beloved machine. Extended notes and full changelog are here:<br /> <a href="https://christopherdrum.itch.io/statusline/devlog/349264/status-line-v20-released-z4-support-multi-font-display-custom-infocom-classics-and-the-resurrection-of-bureaucracy">https://christopherdrum.itch.io/statusline/devlog/349264/status-line-v20-released-z4-support-multi-font-display-custom-infocom-classics-and-the-resurrection-of-bureaucracy</a></p> <h2>Update - v1.2 Released (Feb. 13, 2022)</h2> <p>This update focuses on lowering memory usage, general performance improvements, and improved text layout handling. This puts the project in good shape for z4 game support in the near future. Write-up of the changes and the full changelog are here:<br /> <a href="https://christopherdrum.itch.io/statusline/devlog/343409/status-line-v12-released">https://christopherdrum.itch.io/statusline/devlog/343409/status-line-v12-released</a></p> <h2>Update - v1.1 Released</h2> <p>v1.1 was uploaded today to the product page on itch.io. Most changes handle various typographic inconsistencies and strive to give a more clean, consistent presentation. Additional color schemes, player-selectable cursor style, and more are also added. Write-up of the changes and the full changelog are here:<br /> <a href="https://christopherdrum.itch.io/statusline/devlog/330128/status-line-11-released">https://christopherdrum.itch.io/statusline/devlog/330128/status-line-11-released</a></p> https://www.lexaloffle.com/bbs/?tid=45892 https://www.lexaloffle.com/bbs/?tid=45892 Wed, 29 Dec 2021 01:20:44 UTC Exporting Executables Questions <p>I can't find any posts talking about this, which may just mean I'm terrible at finding thing in the BBS.</p> <p>At any rate, I'm doing Windows, macOS(OS X), and Linux executable exports. I've noticed a few things, and I need to know if this is &quot;just how things are,&quot; &quot;that sounds broken,&quot; or &quot;that is something we can fix.&quot;</p> <p>On Windows:</p> <ul> <li>The executable on first launch triggers Windows Defender. I tried codesigning the .exe with <code>signtool</code> to no avail. Is there a way to fix this?</li> <li>On first launch, the exe runs full-screen. I don't want this for my release as it relies on file system interaction via drag-and-drop. Can we default to windowed mode?</li> </ul> <p>On macOS:</p> <ul> <li>Like Windows, the unsigned app triggers a security warning. Has anyone successfully done a codesign to fix this?</li> <li>Also, the full-screen mode occurred for one person, but not for another. Does having Pico-8 installed affect how this launches? (person with Pico-8 was windowed mode on first launch; person without Pico-8 was full-screen on first launch)</li> </ul> <p>On Linux:</p> <ul> <li>The executable had no icon, but a separate .png file was in the .zip file. Is this normal?</li> <li>The full-screen mode issue occurred on my Linux machine, yet I <em>do</em> have Pico-8 installed.</li> </ul> <p>I thank the community in advance for any assistance in these matters.</p> https://www.lexaloffle.com/bbs/?tid=45886 https://www.lexaloffle.com/bbs/?tid=45886 Tue, 28 Dec 2021 13:42:44 UTC Eliza8: A Scriptable Clone of ELIZA <img style="" border=0 src="/media/31158/eliza8_box_with_cartridge_banner.png" alt="" /> <h2>Your Pico-8 has something to say.</h2> <p>The power of MIT's Artificial Intelligence Lab (circa 1966) has been brought to the Pico-8. The software that once took on the Turing Test is now yours to command. Marvel as the illusion of a living computer breaks down within seconds!</p> <p>ELIZA's creator, Joseph Weizenbaum, once wrote, &quot;I had not realized ... that extremely short exposures to a relatively simple computer program could induce powerful delusional thinking in quite normal people.&quot; Maybe you'll be powerfully deluded as well!</p> <p>Features of this release:</p> <ul> <li>An interesting archaelogical look at early AI</li> <li>User-scriptable! (see blog for info)</li> <li>Reproduces precisely a famous ELIZA conversation</li> <li>Not based on the simplified BASIC version; this is the real deal!</li> </ul> <img style="" border=0 src="/media/31158/eliza8_2.png" alt="" /> <p>While this release implements the most famous ELIZA script called &quot;DOCTOR,&quot; I have endeavored to make it simple to create your own script. With Pico-8's 2MiB of RAM and the light footprint of the engine itself, it is theoretically possible to create much more advanced chatbots than could have been achieved in 1966.</p> <p>More information and downloads available on itch.io now.<br /> <a href="https://christopherdrum.itch.io/eliza8">https://christopherdrum.itch.io/eliza8</a></p> <p>Full blog post on how the script works, so you can write your own is also posted.<br /> <a href="https://christopherdrum.itch.io/eliza8/devlog/255329/customizing-eliza8-scripts">https://christopherdrum.itch.io/eliza8/devlog/255329/customizing-eliza8-scripts</a></p> https://www.lexaloffle.com/bbs/?tid=42986 https://www.lexaloffle.com/bbs/?tid=42986 Fri, 21 May 2021 22:03:46 UTC making tables with unusual keys <p>Is there any way to do the following?</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>t = { &quot;key 1&quot; = &quot;foofoo&quot;, &quot;key 2&quot; = &quot;barbar&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>We <em>can't</em> use quoted keys when defining a table, but we <em>can</em> use them when adding elements.</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>t = {} t[&quot;key 1&quot;] = &quot;foofoo&quot; t[&quot;key 2&quot;] = &quot;barbar&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>Is this &quot;just how things are?&quot; because it would really be beneficial to be able to do it all inline and build out a complex table structure without having to isolate out special cases and insert them as a separate sequence of setter calls.</p> <p>(the example above uses spaces in the key intentionally, where it might be a substring paired with its substitution or maybe I just want to make it very clear in the definition that some of the keys represent specific words, like vocabulary words; don't get me wrong, I know lots of workarounds, but sometimes the workarounds are a drag, especially when it looks like we're so close to just having a simple way of doing things)</p> <p>--EDIT<br /> Clarification here. The first example fails to compile with a &quot;missing {&quot; error when trying to use inline quoted keys. @fred72 shows below that wrapping those in square brackets allows for using the quoted key without resorting to the second method shown.</p> https://www.lexaloffle.com/bbs/?tid=42796 https://www.lexaloffle.com/bbs/?tid=42796 Fri, 07 May 2021 03:00:47 UTC ALT key as BTN blocks stat(30)? <p><em>(this &quot;bug&quot; may actually be &quot;a feature&quot;... not sure)</em></p> <p>In the following code, a simultaneous btn+key method is used.<br /> I am using Player 2 &quot;X&quot; key for this example.</p> <p>In keyconfig, set Player 2 &quot;X&quot; to be a key, like &quot;\&quot;<br /> You should find that you can hold &quot;\&quot; to get a yellow line drawn on screen.<br /> While holding that BTN down, type &quot;c&quot; and you should see a red circle flash on screen.</p> <p>Back in keyconfig, set Player 2 &quot;X&quot; to be &quot;Alt&quot;<br /> (I'm on Windows; I think the Mac Option key has the same behavior)</p> <p>When running this sample program, hold down Player 2 &quot;X&quot; and the line appears as before.<br /> Type &quot;c&quot; and nothing happens.</p> <p>I can understand not allowing &quot;Ctrl&quot; (for example) but I can't think of any &quot;would interfere with expected system operations&quot; reason why &quot;Alt&quot; would have its use restricted in this way.</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 _init() poke(0x5f2d,1) end function _update() cls() if btn(5,1) then line(0,0,127,127,10) if stat(30) then local key = stat(31) if (key == 'c') circfill(63,63,20,8) flip() end 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> https://www.lexaloffle.com/bbs/?tid=42196 https://www.lexaloffle.com/bbs/?tid=42196 Sat, 27 Mar 2021 03:01:20 UTC v0.2.2c tab issues <p>According to the manual</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>:: Special Commands These commands all start with &quot;\^&quot; and take between none and 2 parameters (P0, P1) s set tab stop width to P0 pixels (used by &quot;\t&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>However, it appears to me that it isn't in pixels, but rather by characters.</p> <p>This code snippet</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>?&quot;1234567890&quot; ?&quot;----------&quot; for i = 1,9 do ?&quot;\^s&quot;..tostr(i)..&quot;1\t2\t3\t4\t5&quot; 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>yields this output</p> <img style="" border=0 src="/media/31158/9_tab_control_code_problem.png" alt="" /> <p>Additionally, if \t is the first character in the string, it seems to be ignored.</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>?&quot;\t1234567890&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>outputs exactly as if no tab were included.</p> <img style="" border=0 src="/media/31158/tab_control_code_problem2.png" alt="" /> https://www.lexaloffle.com/bbs/?tid=42181 https://www.lexaloffle.com/bbs/?tid=42181 Fri, 26 Mar 2021 10:30:58 UTC Suppressing control-codes <p>For characters in the Japanese kana range, it seems we must type <strong>ctrl + alpha</strong><br /> to get a kana to input. However, <strong>ctrl</strong> is also used to activate some Pico-8 things like &quot;save&quot; and such.</p> <p>With <strong>poke(0x5f30,1)</strong><br /> we can suppress &quot;ENTER&quot; from bringing up the Pico-8 menu in-game.<br /> Is there a poke I'm failing to see that will suppress Pico-8 from having its &quot;save&quot; function activated every time the user enters <strong>ctrl + s</strong> to type キ (for example)?</p> <p>(on another note, backtik-surrounded text to format &quot;code snippet within a line&quot; doesn't seem to work right?)</p> https://www.lexaloffle.com/bbs/?tid=41793 https://www.lexaloffle.com/bbs/?tid=41793 Sun, 28 Feb 2021 02:41:49 UTC PicoCalc: A Fully-Functional Clone of VisiCalc <img style="" border=0 src="/media/31158/picocalc_cover_image.png" alt="" /> <h2>Your Pico-8 just got down to business.</h2> <p>The full-featured, high-precision spreadsheet application for the Pico-8 that nobody asked for has finally arrived! PicoCalc is a feature-complete1 clone of the 1979 classic VisiCalc, which introduced the world to an entirely new category of business application. Steve Jobs said of VisiCalc, it's &quot;what really drove -- propelled -- the Apple ][ to the success it achieved.&quot;</p> <img style="" border=0 src="/media/31158/Screenshot 2021-02-23 144152.png" alt="" /> <p>PicoCalc does everything* VisiCalc can do, with some enhancements over the Apple ][ classic:</p> <ul> <li>18.18 integer/fractional precision vs. VisiCalc's 12.<br /> Handles numbers as big as 999999999999999999.999999999999999999</li> <li>Granular error reporting!<br /> Get informed of division by zero, number overflow, and more.</li> <li>Multi-color representation of active/inactive cursor, locked titles, truncated values, and error messages</li> <li>Save and load your work</li> <li>Full arrow-key support (LOL)</li> </ul> <p>To use it effectively, you do need to know how to use VisiCalc.<br /> <a href="https://archive.org/details/bitsavers_visicorpaplcAppleIIJan82_8240804/mode/2up">Here's a manual to help you along.</a></p> <p>More information and download available on itch.io now.<br /> <a href="https://christopherdrum.itch.io/picocalc">https://christopherdrum.itch.io/picocalc</a></p> <p>*OK, I ran out of tokens and only got 99.5% in; still thinking how to hit 100%</p> <h2>Updated to 1.0.1</h2> <p>Available now. Writeup of bug fixes at itch.io.<br /> <a href="https://christopherdrum.itch.io/picocalc/devlog/226707/picocalc-updated-to-101">https://christopherdrum.itch.io/picocalc/devlog/226707/picocalc-updated-to-101</a></p> https://www.lexaloffle.com/bbs/?tid=41739 https://www.lexaloffle.com/bbs/?tid=41739 Wed, 24 Feb 2021 12:41:12 UTC V0.2.2 &quot;tall&quot; font rendering bug <p>In the new v0.2.2, it seems that &quot;tall&quot; mode for print rendering does not render the final row of pixels.<br /> See in this shot the difference between &quot;tall&quot; and &quot;wide&quot;</p> <p>Haven&rsquo;t tried it in &ldquo;non-inverse&rdquo; mode yet.<br /> Discovered by using Zep&rsquo;s &ldquo;pinball everything&rdquo; example.</p> <img style="" border=0 src="/media/31158/Screenshot 2021-02-14 084228.png" alt="" /> https://www.lexaloffle.com/bbs/?tid=41548 https://www.lexaloffle.com/bbs/?tid=41548 Sat, 13 Feb 2021 23:41:17 UTC Default code for functions <p>I have a number of functions which, before doing any real work, need to do the exact same pre-processing routine of the passed parameters. As such, they all start 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>local p1, p2, error = preprocess(param1, param2) if (error) return error --early return</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Is there a way to use metatables to inject this kind of default behavior into functions, without having to copy/paste that boilerplate code each time?</p> https://www.lexaloffle.com/bbs/?tid=41460 https://www.lexaloffle.com/bbs/?tid=41460 Mon, 08 Feb 2021 02:01:37 UTC -0 bug in 0.2.0c? <p>Hit a strange bug tonight in trying to compare some values.<br /> Ultimately, I was being told that 0 != 0 (apparently).<br /> In digging in further, I can reproduce the problem in one line.</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>&gt; print(8.5333-3.7667-4.7667) -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>I understand that there can be rounding issues, but -0 is not such a useful return value I think.</p> <p><strong>Edit:</strong> Another strange occurrence<br /> I'm doing time profiling on functions in my code. Call time() at the beginning and end of a test and subtract the results. </p> <p>In the test, I received <code>37.4667 - 35.6333 = 1.8333</code> </p> <p>but if I just ask Pico-8 to compute that in the console I get the proper <code>1.8334</code></p> https://www.lexaloffle.com/bbs/?tid=37439 https://www.lexaloffle.com/bbs/?tid=37439 Sun, 19 Apr 2020 09:45:04 UTC What am I missing in line intersections? <p>Purpose: calculating a line-line intersection point</p> <p>I've been trying to learn physics coding, which also means re-learning math I have long forgotten. Recent studies in vectors, sin/cos, etc. were difficult but successful, so this task seemed like it would be pretty simple. And yet....</p> <p>I cannot see what I'm doing wrong here.</p> <p>I've implemented line-line intersection algorithms as transcribed in various places all over the internet, and the resulting {x,y} is always the same. So the answers are consistent, but do not match expectations whatsoever.</p> <p>Note: I understand this algorithm does not catch all cases, but rather I'm trying to show the simplest form of the problem I'm struggling with. It should be working for the case illustrated, as far as I understand. The line endpoints are chosen specifically to intersect on-screen, but the intersection algorithm will generate negative values in most, but not all, cases (?!?!?)</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 line_intersection(line1, line2) local p1, p2 = line1.p1, line1.p2 local p3, p4 = line2.p1, line2.p2 local a1 = p2.y - p1.y local b1 = p1.x - p2.x local c1 = a1 * p1.x + b1 * p1.y local a2 = p4.y - p3.y local b2 = p3.x - p4.x local c2 = a2 * p3.x + b2 * p3.y local denominator = a1 * b2 - a2 * b1 local x = (b2*c1-b1*c2)/denominator local y = (a1*c2-a2*c1)/denominator print(x..&quot;,&quot;..y,0,120) return {x=x,y=y} end --l1 = {p1={x=10, y=25}, p2={x=25, y=10}} --THIS WORKS l1 = {p1={x=10, y=26}, p2={x=26, y=10}} --THIS DOESN'T l2 = {p1={x=0, y=0}, p2={x=60, y=60}} function _draw() cls() line(l1.p1.x, l1.p1.y, l1.p2.x, l1.p2.y, 7) line(l2.p1.x, l2.p1.y, l2.p2.x, l2.p2.y, 7) local intersect = line_intersection(l1, l2) circ(intersect.x, intersect.y, 2, 8) 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>Is there a trick to doing this in Pico-8 that I'm not understanding? Other attempts to translate algorithms (say from Wikipedia or Stack Overflow) were successful, so I thought I had a handle on things. It's frustrating being stumped by something that seems so simple. If anyone can point me in the right direction, I'd appreciate the assist.</p> https://www.lexaloffle.com/bbs/?tid=32806 https://www.lexaloffle.com/bbs/?tid=32806 Sun, 06 Jan 2019 07:48:18 UTC New(?) Method for Stroked Text &amp; Sprites <p>Here I present a method for stroking text and sprites.</p> <p>In looking through solutions for stroked/filled text, I usually see print()on the string called 9 times; i.e. once at each cardinal location with a 1px offset. I realized if pixels were represented by &quot;fat pixels&quot; outlines of various thicknesses could be simulated.</p> <p>For example, if a pixel is at (x,y), </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> rectfill(x-thickness, y-thickness, x+thickness, y+thickness,color) </pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>with a normal pixel draw on top would look like an outlined pixel. I further realized that <strong>anything</strong> with transparent pixels could be outlined in this same manner, and so applied it to sprites.</p> <p><strong>This method works in the following:</strong></p> <ol> <li>Video space is &quot;borrowed&quot; for less than a frame (?) to render the text and capture it's pixel data to user data space. (the specific address space used for this caching can be set to wherever you like; sprites are read as-is from sprite memory space)</li> <li>The bytes are walked and used to draw fat pixels (via rectfill()).</li> <li>The string is then rendered &quot;as normal&quot; at the location requested. (print()is only called twice: once to grab the pixel data cache, once to draw the string on top of the effects)</li> <li>Seems to be at 300 tokens currently.</li> </ol> <p><strong>This method has the following benefits:</strong></p> <ol> <li>Visual effects are defined as a table (list) of inner tables, where each inner table defines: </li> </ol> <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> {fill_color, stroke_color, line_thickness, effect_x_offset, effect_y_offset} </pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <ol start="2"> <li>Effects in a list are applied in the &quot;painter method&quot; from [1]..[#effect] where each subsequent effect is drawn on top of the previous. This allows for complex stackings of routines.</li> <li>Effects are just tables, and so can be pre-defined and re-used on other elements, including sprites.</li> <li>Effects are animatable, by simply swapping colors and offset values.</li> <li>Uses no sprites, only Pico-8 native text (though it could be pretty easily adapted to work with mini-font libraries that use custom sprites, I think)</li> </ol> <p><strong>Optimization possibilities</strong><br /> Unlike the &quot;draw a string 9 times&quot; methods, this methodology presents an opportunity for optimization. I'm still very new to Pico-8 and Lua, so this really only represents a starting point toward a better algorithm. </p> <p>For example, I'm sure there are ways to make it more efficient. </p> <ol> <li>I believe the call to peek() could be switched to a peek4()?</li> <li>I believe the call to rectfill() could be swapped for direct writes to the bytes?</li> <li>I'm certain there are ways to reduce the token count from the current 300, but for the purpose of this post I tried to consolidate redundant code without sacrificing (too much) legibility.</li> </ol> <p>(P.S. - I don't see how a name can be attached to a cart? @clip didn't use the file name? I see no tools here for setting title, license, etc.)</p> <p> <table><tr><td> <a href="/bbs/?pid=56191#p"> <img src="/bbs/thumbs/pico56189.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=56191#p"> Untitled</a><br><br> by <a href="/bbs/?uid=31158"> ChristopherD</a> <br><br><br> <a href="/bbs/?pid=56191#p"> [Click to Play]</a> </td></tr></table> </p> https://www.lexaloffle.com/bbs/?tid=31816 https://www.lexaloffle.com/bbs/?tid=31816 Tue, 04 Sep 2018 20:03:47 UTC Animate image onto screen <p>I've been studying Pico-8 only for about a week now and really having a good time. I enjoy thinking within it's constraints. In particular I like fiddling around with the graphics memory directly to do fun video effects.</p> <p>With the following code snippet I can move every other video line offscreen to the left or right, giving an interesting &quot;tearing apart&quot; video effect. This works great and is very fast, and gets me to a blank screen where &quot;blank&quot; just means the screen is filled with a chosen &quot;clear color.&quot;</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 (y%2==0) then memcpy(dst,src,63) memset(src,clear,1) else memcpy(src,dst,63) memset(src+63,clear,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>So, now that the screen is clear, I want to do the opposite. Bring in a full screen image (perhaps a map or scaled sprite) onto screen in the reverse. i.e. Odd-lumbered video lines scroll in from the left and even-lumbered lines scroll in from the right.</p> <p>This would assume that some pre-composed block of memory is waiting from which i do a similar memcpy() from off-screen to on-screen... or at least that is conceptually what i think needs to happen. But i do not understand the possibilities of Pico-8 deeply enough to understand how/where to keep such an offscreen buffer, or if that is even possible.</p> <p>Any pointers on how to tackle this?</p> https://www.lexaloffle.com/bbs/?tid=31726 https://www.lexaloffle.com/bbs/?tid=31726 Thu, 23 Aug 2018 05:48:35 UTC