Created
April 1, 2018 16:57
-
-
Save m0ppers/00643c3c4289d37d9db591980df41130 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#l 2 8 img/just_revision.png // load RGBA image into 8(+3) | |
#l 1 17 img/noglitches.png // load RGBA image into 17(+3) | |
// some "constants" | |
pi $0, si 0 // $0 = 0 | |
pi $1, si 1 // $1 = 1 | |
pi $2, si 2 // etc... | |
pi $3, si 3 | |
pi $4, si 4 | |
pi $8, si 8 | |
pi $16, si 16 | |
pi $32, si 32 | |
pi $64, si 64 | |
pi $96, si 96 | |
pi $112, si 112 | |
// colorswapper in buffer 12 | |
// color1 | |
xi 0, yi 0, zi 12, si 132 | |
xi 1, yi 0, zi 12, si 214 | |
xi 2, yi 0, zi 12, si 114 | |
// color2 | |
xi 3, yi 0, zi 12, si 112 | |
xi 4, yi 0, zi 12, si 207 | |
xi 5, yi 0, zi 12, si 89 | |
pi $colorsub, si 0 | |
@preparepattern // generates pattern in buffers 13,14,15,16 (RGBA) | |
pi $y, si 0 | |
@ypattern | |
pi $x, si 0 | |
@xpattern | |
pi $_, s $x, add $colorsub, mod $16 | |
seq $0 | |
j @continue | |
// color swap | |
xi 0, yi 0, zi 12, g $oldr | |
xi 1, yi 0, zi 12, g $oldg | |
xi 2, yi 0, zi 12, g $oldb | |
xi 3, yi 0, zi 12, g $r | |
xi 4, yi 0, zi 12, g $g | |
xi 5, yi 0, zi 12, g $b | |
xi 0, yi 0, zi 12, s $r | |
xi 1, yi 0, zi 12, s $g | |
xi 2, yi 0, zi 12, s $b | |
xi 3, yi 0, zi 12, s $oldr | |
xi 4, yi 0, zi 12, s $oldg | |
xi 5, yi 0, zi 12, s $oldb | |
@continue | |
xi 0, yi 0, zi 12, g $r | |
xi 1, yi 0, zi 12, g $g | |
xi 2, yi 0, zi 12, g $b | |
x $x, y $y, zi 13, s $r | |
x $x, y $y, zi 14, s $g | |
x $x, y $y, zi 15, s $b | |
x $x, y $y, zi 16, si 255 | |
pi $x, add $1 | |
seq $0 | |
j @xpattern | |
pi $_, s $y, mod $16 | |
seq $0 | |
j @continueyloop | |
pi $colorsub, add $1 | |
@continueyloop | |
pi $y, add $1 | |
seq $0 | |
j @ypattern | |
pi $backgroundsub, si 0 | |
pi $sin, si 0 | |
pi $topadd, si 96 | |
@main | |
pi $y, si 0 | |
@background | |
pi $i, si 0 | |
@backgroundloop | |
pi $x, s $i, mul $16 // $x = i * 16 | |
pi $y, s $i, div $16, mul $16 // $y = i / 16 * 16 | |
pi $_, si 13, spt $_ | |
pi $x, add $backgroundsub | |
x $x, y $y, zi 4, spa $i | |
pi $_, si 1, pi $i, add $_ // $i += 1 | |
seq $0 | |
j @backgroundloop | |
pi $_, si 200, zi 4, jpg $_ | |
@noglitchesprepare | |
pi $fullsprites, s $topadd, div $16, mul $16 | |
pi $spriterest, s $topadd, mod $16 | |
pi $rest, s $15, sub $spriterest | |
@noglitchesstartpreparesploop | |
pi $i, s $fullsprites | |
@noglitchespreparesploop | |
pi $x, s $i, mul $16 | |
pi $y, s $i, div $16, mul $16, sub $fullsprites, add $rest | |
pi $o, s $y, add $16, div $16 | |
seq $0 | |
j @nooverflow | |
pi $z, si 21 // start writing in the buffer before our target so that the correct remainder will be written to the real target buffer | |
j @noglitchespreparecontinue | |
@nooverflow | |
pi $z, si 22 | |
@noglitchespreparecontinue | |
pi $_, si 17, spt $_ // set sprite table to z=8 | |
x $x, y $y, z $z, sp8 $i // draw 32bit color sprite to ($x, $y, 4(,5,6,7) (= rgba buffer)) | |
pi $_, si 1, pi $i, add $_ // $i += 1 | |
seq $96 | |
j @noglitchespreparesploop | |
// now copy the prepared stuff over | |
pi $i, si 0 // $i = 0 | |
@noglitches | |
pi $x, s $i, mul $16 // $x = i * 16 | |
pi $y, s $i, div $16, mul $16 // $y = i / 16 * 16 | |
pi $_, si 22, spt $_ | |
x $x, y $y, zi 4, sp8 $i | |
pi $_, si 1, pi $i, add $_ // $i += 1 | |
seq $96 | |
j @noglitches | |
pi $__, sin $sin, div $3 | |
pi $sin, add $1 | |
pi $i, si 0 // $i = 0 | |
@imageloop | |
pi $x, s $i, mul $16 // $x = i * 16 | |
pi $y, s $i, div $16, mul $16, add $__ | |
pi $_, si 8, spt $_ | |
x $x, y $y, zi 4, spa $i | |
pi $_, si 1, pi $i, add $_ // $i += 1 | |
seq $0 | |
j @imageloop | |
pi $backgroundsub, sub $1 | |
pi $topadd | |
seq $0 | |
sub $1 | |
pi $_, si 1, w $_ | |
pi $topadd | |
seq $0 | |
j @noglitch | |
pi $x, si 0, rnd $x // $x = random() | |
pi $y, si 20, rnd $y // $y = random() (in range of 0 - 20) | |
pi $v, si 0, rnd $v // $v = random() | |
x $x, y $y, zi 1, s $v // GLITCH!! | |
@noglitch | |
j @main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment