tunnel256
A flight down a tunnel of light for DOS. Two ramps of colour, one FPU, no lookup tables, under 256 bytes.
nasm -f bin tunnel.asm -o tunnel.comRun it in DOSBox with cycles=max. Every pixel calls fpatan and fsqrt, so a real 386 gives you a slideshow. Esc returns to text mode.
How it moves
0xCCCD × diturns a screen offset into the row indhand 0.8 × the column indl, with no division. The 0.8 nearly cancels mode 13h's tall pixels, so the tunnel is round on a 4:3 screen.- The angle around the axis, times 256/π, becomes
u: eight segments around the wall.8192 / distancebecomesv.u xor vis the texture. bpcounts frames. It is added once tou(spin) and twice tov(forward).- Bit 6 of the texture picks the amber or cyan ramp.
v / 16, capped at 63, is the fog that darkens the far end. - Cyan is amber with red and blue swapped, so the palette loop needs one set of
outs.
Credits
Isolde Varga, with kerf taking bytes out.