r/tinycode • • Apr 06 '26

Writeup for 16 byte Intro "Rainbow Surf" (1st place at Revision 2026 - 256b Compo)

Post image
93 Upvotes

Because of my surprise win at Revison 2026 (and some people asking for it), I am thrilled to do a writeup of the inner workings of this intro and the things that led to its creation.

For starters it would be helpful if you knew this reddit post of mine from 2 years ago: https://www.reddit.com/r/tinycode/comments/1aq13hj/text_plasmosis_14_byte_plasma_winner_of_16b/

Back then I had just discovered the effect I coined "Plasmosis", which became a surprise winner of the 16 byte intro contest at Lovebyte 2024.

In the two years since, I turned this effect inside out and upside down and tried to find new ways to combine it with other techniques. Some Examples:

Plasmosis played a role in 22 of my 37 productions from the last 2 years: https://demozoo.org/productions/tagged/plasmosis/

In January this year, still in some desperate hope for Lovebyte 2026 taking place in some form or another, I started looking at 16 byte intros again, trying to find an improvement over "Text Plasmosis".

As a result of a long train ride I came up with this:

[org 100h]

  les ax,[si]
next:
  dec ax
  stosw
  add ax, [es:di-80-2]
  add ax, [es:di]
  shr ax, 2
  jmp next

It shares many of the ideas from "Text Plasmosis":

  • averaging between adjacent pixels

  • using 16 bit values (perfectly matching the memory layout of text mode)

  • using "dec ax" to trigger a wrap around from 0 to 65535

The important difference is that in "Rainbow Surf" the decrementing is not the only way to decrease the value.

  • Old: newValue = (a + b) / 2 - 1

  • New: newValue = (a + b + c) / 4 - 1

This changes the behavior drastically, from a linear decline to an exponential one, because dividing by 3 would give you a normal average of a+b+c, but dividing by 4 gives you only 75% of that average, on every iteration.

This elegantly solves the problem of the long ramp up phase in the beginning of "Text Plasmosis", because it took a long time until the first pixels got decremented down to 0 and started to wrap around and show the plasma effect.

When mulitplying by 0.75 and decrementing, it takes only something like 30 iterations (maximum width of a 'wave') to get from 65535 to a "wrap around". So no long wait in the beginning.

On the other hand this also changed the visuals completely:

  • The pixels are drawn from left to right and after a "wrap around" from 0 to a high value they start with a bright color (white crest of the wave) and then quickly cycle through all the colors down to black.

  • Then there is a black gap before the next "wrap around", this is because foreground and background colors are both black when the value drops below 256. This gives the impression of isolated waves traveling accross the screen.

  • Because the value of the next pixel is not only dependent on the last pixel, but also on a pixel in the line above it, the waves are not always behaving the same, but interfere with each other. If there was a "wrap around" in the line above, the "wrap around" in the line below will be delayed, because a much higher value will be part of the sum (a+b+c).

Finding something pleasing to watch, did take some trial and error (mostly shuffling around which pixels to use in the averageing).

So here is the final result: https://www.youtube.com/watch?v=QKLhH_ANwIc

Conclusion: For me sizecoding is the most fun part of the demo scene, because it has the best chance to surprise and feel like seeing a "magic trick", where I stand in awe and wonder how the hell has this been done? (Exactly the feeling I connect with the demo scene of my youth.)

And if this 16 byte intro did this for some of you, then I am happy.

Plex / BionFX


P.S.: Originally the code was 17 bytes long, because referencing a pixel in the line above would be done by "add ax, [es:di-160-2]". But an offest >= 128 takes one additional byte to encode, so I had to change it to "add ax, [es:di-80-2]". Now it references a pixel only half of a line away. To me this looks even better, because it creates a bit more visual symmetry.

P.P.S.: When I have some minutes to spare (e.g. during commute to work) I start up Tic-80 and create a new version of the "Plasmosis"-effect. I just count up in the filenames and am currently at "plasmosis466.tic". So I want to thank nesbox very much for creating this wonderful fantasy console!

P.P.P.S.: I am really thankful for all the parties providing a 256 byte compo, and even more for those also hosting a 128 byte one (e.g. Outline). But I also miss the ultra small sizecoding competitions Lovebyte used to provide. Maybe some other party will pick up the torch and create something similar?


r/tinycode • • Oct 21 '22

vec4 u,q=u=vec4(7,5,1,2);vec3 p=q.zyx/.15,v,h,k;float s;v=vec3(FC.x-r.x*.5,r.x,FC.y-r.y)/r.x;for(p.y-=t/.02;v.y>.3;v*=.98,p+=v*h.z)for(s=.02,h=p;s<7.;s/=.8,q=normalize(fract(q+u/.3)),k=h.yxz+h.zxy)h+=sin((k+cross(q.rgb,cross(q.rgb,k)+q.w*k))*s)/s/3.5;o.rgb=fwidth(p);

91 Upvotes

r/tinycode • • Jul 12 '12

Four Lines of Python for a Spellchecker

90 Upvotes
import sys
a = sys.argv[1:]
s = [x.lower()[:-1] for x in open("/usr/share/dict/words")]
print " ".join([("\x1b[31m"+w+"\x1b[0m" if w in [_ for _ in a if _ not in s] else w) for w in a])

save it to spellcheck.py then test it out with

>> python spellcheck.py hello this woard is wrong

only works on a mac, and some linux distros. all in 186 bytes of python!


r/tinycode • • Apr 16 '22

City Blocks (tiny raycasting demo in a tweet of JavaScript)

89 Upvotes

r/tinycode • • May 04 '20

What people create in one tweet of code for a 1980s computer

Thumbnail
youtube.com
89 Upvotes

r/tinycode • • Aug 24 '12

Playing with HTML canvas; I made a spinning sphere in half a k of JavaScript

Thumbnail ompldr.org
88 Upvotes

r/tinycode • • Jan 13 '22

Eroded Wall in 441 bytes, source linked in comment

Post image
87 Upvotes

r/tinycode • • Aug 30 '20

Tiny Procedural Sprite Sheet Generator

Thumbnail
codepen.io
87 Upvotes

r/tinycode • • Dec 07 '19

๐ŸŒฑ Tiny Grass ๐ŸŒฑ

87 Upvotes

r/tinycode • • Sep 20 '12

A Mandelbrot fractal renderer in a single MySQL query

87 Upvotes

As a little challenge, I have written a MySql query that outputs a rendering of the fascinating Mandelbrot fractal set.

http://pastebin.com/JPbYggx9

It is a single query, no stored procedures. You can run it from phpMyAdmin or whatever way you prefer to run MySql queries.

If you're too lazy to try it out, here is a screenshot of the output.

I didn't pay attention to the query length, so there is still a lot of potential for shortening. I just thought that you might like it anyway, so I wanted to share this. :)

Edit: tested with MySql 5.5.16. There might be som backwards compatibility issues.


r/tinycode • • Apr 19 '23

vec3 q=vec3(0,0,99),p,u,v;for(float w,d,i=0.;i++<80.;v=u,u=q,q+=(FC.rgb*2.-r.xyx)/r.x*d+vec3(sin(i),cos(i),0))for(d=w=6.;--w>0.;p=q,p.xz*=rotate2D(t+w/.8),p.xy*=rotate2D(1.),d=min(d,dot(p+sin(p)*.3,sign(p)*.3)-9.));o+=sign(.5-cross(q-u,q-v).y-fract(FC.x/9.-FC.y/7.)); //...5 tiny octahedra

86 Upvotes

r/tinycode • • May 28 '21

POKEGB: a gameboy emulator that only plays Pokemon Blue, in 9956 bytes

Thumbnail
twitter.com
86 Upvotes

r/tinycode • • Dec 12 '19

Kaleidoscope - 194 Characters of JavaScript

85 Upvotes

r/tinycode • • Feb 19 '14

st4koverflow - As much Stack Overflow as possible in 4096 bytes

Thumbnail
danlec.com
82 Upvotes

r/tinycode • • May 02 '13

Cuz it came up in /r/programming and cuz I'm bored, i give you a non-portable HTTP server in C

82 Upvotes
char b[256];
main(s,k,f){
    if(bind(s=socket(2,1,0),"\0\x02\x1f\x90\0\0\0\0",16))exit(1);
    for(listen(s,10);read(k=accept(s,0,0),b,256);close(k)){
        write(k,"HTTP/1.0 200 O\n\n",16);
        *(strchr(b+5,32))=0;
        f=open(strlen(b+5)?b+5:"index.html",0,0);
        if(f+1)while(read(f,b,1)||close(f))write(k,b,1);
    }
}

Edit 1: trading browser compatibility for golfiness: 220 chars

char b[256];main(s,k,f){bind(s=socket(2,1,0),"\0\x02\x1f\x90\0\0\0\0",16);for(listen(s,10);read(k=accept(s,0,0),b,256);close(k)){0[strchr(b+5,32)]=0;f=open(5[b]?b+5:"index.html",0,0);while(~f&&read(f,b,1))write(k,b,1);}}

Edit 2: 215 chars

char b[99];main(s,k,f){bind(s=socket(2,1,0),"\0\2\x1f\x90\0\0\0\0",16);for(listen(s,10);read(k=accept(s,0,0),b,99);close(k)){0[strchr(b+5,32)]=0;f=open(5[b]?b+5:"index.html",0,0);while(write(k,b,~f&&read(f,b,1)));}}

r/tinycode • • Apr 22 '19

Mini BlackHole Simulation in 140 bytes of javascript

81 Upvotes

r/tinycode • • Dec 30 '21

Moon Surface created with 416 bytes of SVG, link in comment

Post image
79 Upvotes

r/tinycode • • Apr 30 '14

Minecraft in < 1k of JavaScript - my entrance to the js1k contest with code explanation.

Thumbnail
birdgames.nl
78 Upvotes

r/tinycode • • Nov 28 '21

274 chars in Processing: float t;PVector[] o=new PVector[150];void setup(){size(400,400);}void draw(){background(255);strokeWeight(1.5);for(int i=0;i<150;i++){o[i]=new PVector(0,floor(i)+40);if(i%2!=0){o[i].y*=2;}o[i].x=200+50*cos(t+i*PI+i);if(i%2!=0)line(o[i].x,o[i].y,o[i-1].x,o[i-1].y);}t+=0.05;}

77 Upvotes

r/tinycode • • Sep 30 '21

Treescape in 140 characters of JavaScript

Post image
76 Upvotes

r/tinycode • • Sep 16 '21

Lake Reflection inspired from Apple Event, 444 bytes

Post image
76 Upvotes

r/tinycode • • Apr 10 '20

Two Buddhabrots - 140 characters of JavaScript

Post image
75 Upvotes

r/tinycode • • Oct 06 '19

Moving cubes with pathtracing, lighting and ambient sound in 64 bytes

75 Upvotes

As you might have guessed, real path tracing and lighting is (yet) impossible in 64 bytes of assembler ;) but still, it's at least possible to generate the impression of both. Before you dive into the details, have a look at this screenshot and/or see a capture on youtube. Edit: Proof that the intro runs as is on real oldschool hardware -> https://www.youtube.com/watch?v=5_3CU6shKlY , thanks to "jmph" from Porta2Note!

Contrary to my last post here, i will provide details and comments to make things a bit more graspable. Since i'm normally too deep into sizecoding, please forgive me if i forgot essential things in the description. I'll happily add pieces of the puzzle and of course fix possible misunderstandings and errors on my side.

Now, there you go:

; "Essence" - by HellMood/DESiRE - 5th October 2019
; 64 bytes msdos intro, showing animated raycasted objects
; with fake pathtracing and fake lighting while playing
; ambient MIDI sound, which is coded for DosBox 0.74.
; On a real MsDos or FreeDos, the demo will work
; but no sound will be played unless a MIDI capable
; soundcard is present. On Dosbox, a custom configuration
; is needed, to provide sufficient emulation power and
; enable the MIDI UART mode, which saves a few bytes.
; --------------------------------------------------------------
; released at https://deadline.untergrund.net/2019/
; published at https://www.pouet.net/prod.php?which=83204
; see also : http://www.sizecoding.org/wiki/Main_Page
; assemble with "nasm.exe" <this> -fbin -o <this>.com
; --------------------------------------------------------------
; Set ES to the screen, to perform the "Rrrola Trick", see
; http://www.sizecoding.org/wiki/General_Coding_Tricks
push 0x9FF6
pop es
; Set mode to 0x13, +0x80 means not deleting the screen content
; that is 320x200 pixels in 256 colors
mov al,93h
int 10h
; Setting port to MIDI data port, assuming it is in UART mode
; 0x3F has to be sent to 0x331 first, if UART mode is not on.
mov dx,0x330
; Effectively outputting all the code to the MIDI data port.
; CX=255 at start, DS=CS, SI=0x100, see MIDI section below.
rep outsb
; Setting DS to zero, top stack normally contains the return
; adress. DS is needed to be 0 to access a timer later on.
pop ds
; CL is the iteration count for a ray, CH is 0 all the time.
; The value is chosen to generate a blue background texture.
; Chosing 64 instead would lead to a totally black background 
X: mov cl,63
; BL is the current depth of a ray, we start with minus(!) 64.
; We cast rays in negative direction to calculate the point
; in 3D and the texture color at the same time. if a ray hits
; an object from this side, the object function has a reasonable
; texture value, from the other side it would be always black.
; CL, BL are decoupled because decrementing -128 leads to 127
; and since we are using signed multiplication for keeping things
; centered, that would result in very buggy and ugly behaviour.
; They are also decoupled because of visual beauty: because of
; the usage of signed 8 bit coordinates, objects close to the
; projection center are way too coarse and move way too fast.
mov bl,-64
; At this point, AL contains the color of the previous pixel.
; By design of the object formula, the last 4 bits contain the
; texture value while the 5th bit is always set, which maps it
; to the 16 color gray scale subtable of the VGA default
; colors. Other bits may be set, too, so they are masked.
; https://www.fountainware.com/EXPL/vga_color_palettes.htm
; Simultaneously, the object function, in combination with the
; palette subset, creates the impression of lighting from the
; front top left. The right, bottom and back side appears to
; be black. Changing the object formula will result in
; changing the texture, visibility and lighting as well.
and al,31
; Outputting the pixel on the screen and increment pointer
stosb
; Instead of going pixel by pixel, the following jumps
; Pseudorandomly across the screen, this smoothes the
; animation a lot and looks a bit like pathtracing.
imul di,byte 117
; The inner loop for each ray, decrementing BX means
; advancing the ray in negative direction by 1
L: dec bx
; Assign the Rrrola constant to register AX
mov ax,0xcccd
; Place the signed coordinates X and Y into DL and DH
mul di
; Centering for X is implicitly done by offsetting the segment
; Centering Y has to be done "manually". any value can be used
; as long as it doesn't show the signed overflow on screen.
mov al,dh
sbb al,73
; Multiply AL=Y by the current distance, to get a projection(1)
imul bl
; Get X into AL, while saving the result in DX (DH)
xchg ax,dx
; Multiply AL=X by the current distance, to get a projection(2)
imul bl
; Considering an implicit division by 256, the projected 
; coordinates now reside in DH and AH, while the depth is in BL.
; the following sequence calculates whether the current 3D
; position belongs to an object. Objects are normal cubes
; defined by f(X,Y,Z) = (X & Y & Z & 16 != 0)
mov al,dh
; offset X by timer, effectively producing 18.2 FPS
; http://vitaly_filatov.tripod.com/ng/asm/asm_002.29.html
add ah,[0x46c]
and al,ah
and al,bl
test al,16
; the inner loop is done when either the iteration count has
; reached zero or the function f(X,Y,Z) is true (object hit)
loopz L
; the outer loop repeats endlessly
jmp short X
; MIDI Data Section, actually code above and memory below is
; sent to the MIDI data port as well, but it does not matter
db 0xc0	; set instrument on channel 0 to the next value
db 89	; instrument 89 = Pad2 of general MIDI
db 0x90	; play notes on channel 0, minor chord over 4 octaves
db 28	; note 1, very deep
db 127	; volume 1, maximum value to let the subwoofers shake
db 59	; note 2 fitting to note 1	
db 80	; volume 2, a bit reduced to not overshadow the bass
db 67	; note 3 fitting to notes 1 & 2
db 65	; volume 3, even more reduced to fit the other notes
;      #                   ยด                           #
;      #                   greetings                   #
;      #     sensenstahl,homecoded,rrrola,frag,T$      #
;      #     Optimus,Trixter,igor,gentleman,VileR      #
;      #     Whizart,g0blinish,Rudi,ryg,TomCat    .    #
;      #     orbitaldecay,wysiwtf,Kuemmel,p01,Lara     #
;      #     Oscar Toledo,Drift,maugli,Harekiet,etc    #

r/tinycode • • Dec 12 '25

Dweet of the Week #103 - Orbit and Chaos by Rodrigo Siqueira

Post image
74 Upvotes

https://www.dwitter.net/d/34598

c.style.filter=`invert()sepia(`
for(๐•=X=Y=i=3e4;i--;๐•=X,x.fillRect(Y*2300+2200,-X*3e3,t<2,.1))X=S(X*X-Y*Y*.6),Y=C(2*๐•*Y+2)-S(i-t)/(i%19+.03)

r/tinycode • • Aug 31 '20

Generative Tiny Invaders (code in comments)

74 Upvotes