zovirl [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=44961 Perspective-correct texture mapping <p>3D texture mapping with tline (plus some other stuff, like wireframe rendering, and solid color polygon rendering). Did this as a learning project, to study old-school pre-GPU 3D graphics.</p> <p>Thanks to freds72 and johanp for inspiration &amp; example code.</p> <p> <table><tr><td> <a href="/bbs/?pid=83849#p"> <img src="/bbs/thumbs/pico8_texture_map-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=83849#p"> texture_map_0</a><br><br> by <a href="/bbs/?uid=44961"> zovirl</a> <br><br><br> <a href="/bbs/?pid=83849#p"> [Click to Play]</a> </td></tr></table> </p> <p>References if you want to learn.<br /> <a href="http://www.multi.fi/~mbc/sources/fatmap2.txt">http://www.multi.fi/~mbc/sources/fatmap2.txt</a><br /> <a href="https://chrishecker.com/miscellaneous_technical_articles#perspective_texture_mapping">https://chrishecker.com/miscellaneous_technical_articles#perspective_texture_mapping</a><br /> <a href="https://www.cs.cmu.edu/~fp/courses/graphics/pdf-color/14-raster.pdf">https://www.cs.cmu.edu/~fp/courses/graphics/pdf-color/14-raster.pdf</a><br /> <a href="https://en.wikipedia.org/wiki/digital_differential_analyzer_(graphics_algorithm">https://en.wikipedia.org/wiki/digital_differential_analyzer_(graphics_algorithm</a>)<br /> <a href="https://en.wikipedia.org/wiki/selection_sort">https://en.wikipedia.org/wiki/selection_sort</a><br /> <a href="https://en.wikipedia.org/wiki/sutherland%e2%80%93hodgman_algorithm">https://en.wikipedia.org/wiki/sutherland%e2%80%93hodgman_algorithm</a><br /> Book: &quot;Computer Graphics: Principles and Practice 2nd ed.&quot;</p> https://www.lexaloffle.com/bbs/?tid=40234 https://www.lexaloffle.com/bbs/?tid=40234 Fri, 06 Nov 2020 05:29:03 UTC Anonymous inline functions don't work in tabs? <p> <table><tr><td> <a href="/bbs/?pid=83769#p"> <img src="/bbs/thumbs/pico8_bug_anon_inline_func-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=83769#p"> bug_anon_inline_func</a><br><br> by <a href="/bbs/?uid=44961"> zovirl</a> <br><br><br> <a href="/bbs/?pid=83769#p"> [Click to Play]</a> </td></tr></table> </p> <p>I'm trying to use anonymous inline functions and I'm finding some weird behavior when they are on tabs.</p> <p>Putting everything in tab #0 works:</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=1 function _draw() cls(1) print('x is '..x) end (function() x=2 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 moving the inline function call to tab #1 works:</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=1 function _draw() cls(1) print('x is '..x) end --&gt;8 (function() x=3 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>But putting an inline function call on both tab #0 and tab #1 does not work:</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=1 function _draw() cls(1) print('x is '..x) end (function() x=2 end)() --&gt;8 (function() x=3 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>I don't understand why. It gives this error:</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>runtime error line 7 tab 0 (function() attempt to call a nil value at line 7 (tab 0)</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=40179 https://www.lexaloffle.com/bbs/?tid=40179 Thu, 05 Nov 2020 05:27:36 UTC Why is this cart so slow on Raspberry Pi Zero? <p>I'm trying to figure out why this cart only runs at 10 FPS on a Raspberry Pi Zero. stat(1) returns 0.49 and stat(7) returns 30. However, the screen is only updating at 10-11 FPS. Other carts with higher stat(1) values don't show this problem, so it seems specific to something in this cart.</p> <p>I can optimize to get the CPU usage down to 17%, and then the real framerate becomes acceptable. However, I'd actually like to understand why it is slow so I can work around it. (Also, I'd prefer to be able to use the whole CPU budget instead of just 17% of it!)</p> <p>I assume what's happening is that the pico-8 CPU costs are optimistic for some instructions, and the actual cost on the Pi Zero hardware is higher. But which instructions?</p> <p>Are there specific instructions I should be avoiding?</p> <p>Are there specific types of drawing (like large map areas, or off-screen drawing) I should avoid?</p> <p>Can I hook up a profiler to see what it is spending its time on?</p> <p>The original raspberry pi post (<a href="https://www.lexaloffle.com/bbs/?tid=3085">https://www.lexaloffle.com/bbs/?tid=3085</a>) says math-heavy carts run slowly. Is that still true?</p> <p>Are there any performance tricks for writing carts that run well on a raspberry pi?</p> <p> <table><tr><td> <a href="/bbs/?pid=78645#p"> <img src="/bbs/thumbs/pico8_slow-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=78645#p"> slow</a><br><br> by <a href="/bbs/?uid=44961"> zovirl</a> <br><br><br> <a href="/bbs/?pid=78645#p"> [Click to Play]</a> </td></tr></table> </p> https://www.lexaloffle.com/bbs/?tid=38602 https://www.lexaloffle.com/bbs/?tid=38602 Mon, 29 Jun 2020 00:59:33 UTC