Log In  
Log In  

@Makke

Follow
Follow

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.

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.

Here's the original code for version 1.0, takes 126 tokens:

--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

EDIT:
With great contributions and improvements by Felice here's a both faster, smaller and more API consistent version 2.0, takes 87 tokens:

_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

Hope you find it useful!

Cart [#48163#] | Code | 2018-01-14 | License: CC4-BY-NC-SA | Embed
5

P#47695 2017-12-27 11:57 ( Edited 2018-01-14 11:23)

Cart [#45809#] | Code | 2017-11-02 | No License | Embed
15

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.

Code by me (@MakkesProjects).
Thanks to @gruber_music for the beautiful music and sfx!
Special thanks to @kometbomb for the simple fade tool!

Nintendo owns all the original sprites and music, this is merely a recreation.

Enjoy.

P#45810 2017-11-02 18:23 ( Edited 2017-12-13 18:28)

X
About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2019-03-26 18:08 | 0.086s | 4194k | Q:31