Makke [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=10932 Local Fill Pattern - Function <p>I wanted to achieve this effect with fill patterns for a recent project I started so I figured I'd share it here incase anyone else is interested in using it.</p> <p>The local fill pattern function is shifting each row/column in the fill pattern by given x and y amount. It's using binary arithmetics and a cache of shift masks.</p> <p>Here's the original code for version 1.0, takes 126 tokens:<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> --turns a screen-space fill pattern, into an object-space fill pattern by wrapping the patterns row and column by the given x and y amount. function get_local_fill_pattern(x,y,fill_pattern) local add_bits=band(fill_pattern,0x0000.FFFF) fill_pattern=band(fill_pattern,0xFFFF) y=flr(y)%4 if(y~=0)then local r_masks={0xFFF0,0xFF00,0xF000} local l_masks={0x000F,0x00FF,0x0FFF} fill_pattern=bxor(lshr(band(fill_pattern,r_masks[y]),y*4),shl(band(fill_pattern,l_masks[y]),(4-y)*4)) end x=flr(x)%4 if(x~=0)then local r_masks={0xEEEE,0xCCCC,0x8888} local l_masks={0x1111,0x3333,0x7777} fill_pattern=bxor(lshr(band(fill_pattern,r_masks[x]),x),shl(band(fill_pattern,l_masks[x]),4-x)) end return bxor(fill_pattern,add_bits) 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> <p><strong>EDIT:</strong><br /> With great contributions and improvements <a href="https://www.lexaloffle.com/bbs/?pid=47740#p47740">by Felice</a> here's a both faster, smaller and more API consistent <strong>version 2.0</strong>, takes 87 tokens:<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> _fillp_xmask_lo={[0]=0xffff,0x7777,0x3333,0x1111} _fillp_xmask_hi={[0]=0x0000,0x8888,0xcccc,0xeeee} _fillp_original=fillp function fillp(p,x,y) if y then x=band(x,3) local p16=flr(p) local p32=rotr(p16+lshr(p16,16),band(y,3)*4+x) p+=flr(band(p32,_fillp_xmask_lo[x])+band(rotl(p32,4),_fillp_xmask_hi[x]))-p16 end return _fillp_original(p) 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> <p>Hope you find it useful!</p> <p> <table><tr><td> <a href="/bbs/?pid=47695#p"> <img src="/bbs/thumbs/pico48163.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=47695#p"> Local Fill Pattern - Function 2.0</a><br><br> by <a href="/bbs/?uid=10932"> Makke</a> <br><br><br> <a href="/bbs/?pid=47695#p"> [Click to Play]</a> </td></tr></table> </p> https://www.lexaloffle.com/bbs/?tid=30518 https://www.lexaloffle.com/bbs/?tid=30518 Wed, 27 Dec 2017 11:57:26 UTC Zelda: fishing minigame remake <p> <table><tr><td> <a href="/bbs/?pid=45810#p"> <img src="/bbs/thumbs/pico45809.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=45810#p"> Zelda: fishing minigame remake 1.0</a><br><br> by <a href="/bbs/?uid=10932"> Makke</a> <br><br><br> <a href="/bbs/?pid=45810#p"> [Click to Play]</a> </td></tr></table> </p> <p>This is a remake of the old fishing minigame from Legend of Zelda: Links Awakening, it's not precise in any way. I've used nothing but my naked eyes recreating this; along with some nostalgia. Growing up, this was probably one of my favorites for the Game Boy Pocket.</p> <p>Code by me (<a href="https://twitter.com/MakkesProjects">@MakkesProjects</a>).<br /> Thanks to <a href="https://twitter.com/gruber_music">@gruber_music</a> for the beautiful music and sfx!<br /> Special thanks to <a href="https://twitter.com/kometbomb"><a href="https://www.lexaloffle.com/bbs/?uid=12489"> @kometbomb</a></a> for the <a href="http://kometbomb.net/pico8/fadegen.html">simple fade tool</a>!</p> <p>Nintendo owns all the original sprites and music, this is merely a recreation.</p> <p>Enjoy.</p> https://www.lexaloffle.com/bbs/?tid=30176 https://www.lexaloffle.com/bbs/?tid=30176 Thu, 02 Nov 2017 18:23:02 UTC