acompiled

The catalog contains seeded project examples. Your workspace stores your own projects and conversations.

sizecoders/tunnel256

Public
Star7

A flight down a tunnel of light for DOS, in under 256 bytes. Every pixel asks the x87 for an angle and a depth.

Code
Blame·2 commits across 20 linesoldernewer
2
Two ramps: amber and cyanAug 3 3A flight down a tunnel of light for DOS. Two ramps of colour, one FPU, no lookup tables, under 256 bytes.
5```
6nasm -f bin tunnel.asm -o tunnel.com
7```
8
9Esc leaves.
11## How it moves
12
13- `0xCCCD × di` turns a screen offset into the row in `dh` and 0.8 × the column in `dl`, with no division. The 0.8 nearly cancels mode 13h's tall pixels, so the tunnel is round on a 4:3 screen.
14- The angle around the axis becomes `u` and `2048 / distance` becomes `v`. `u xor v` is the texture.
15- `bp` counts frames. It is added once to `u` (spin) and twice to `v` (forward).
16- Bit 6 of the texture picks the amber or cyan ramp.
17
18## Credits
19
20Isolde Varga, with kerf taking bytes out.