A flight down a tunnel of light for DOS, in under 256 bytes. Every pixel asks the x87 for an angle and a depth.
Eight segments and a longer tunnel
Browse filesk_angle doubles to 256 / pi, so the ramps alternate eight times around the wall instead of four. k_depth goes from 2048 to 8192, so rings arrive four times as often, and the fog shift goes from 3 to 4 so the dark end reaches twice as far. Same size.
failing
1 step in 1 ms
2 files changed
+6−5
@@ -11,9 +11,10 @@ Run it in DOSBox with `cycles=max`. Every pixel calls `fpatan` and `fsqrt`, so a
1111 ## How it moves
1212
1313 - `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.
14+- The angle around the axis, times 256/π, becomes `u`: eight segments around the wall. `8192 / distance` becomes `v`. `u xor v` is the texture.
1515 - `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, and `v / 8` is the fog.
16+- Bit 6 of the texture picks the amber or cyan ramp. `v / 16`, capped at 63, is the fog that darkens the far end.
17+- Cyan is amber with red and blue swapped, so the palette loop needs one set of `out`s.
1718
1819 ## Credits
1920
@@ -73,7 +73,7 @@ pixel:
7373 fistp word [v]
7474
7575 mov cx, [v] ; fog: the far end fades to black
76− shr cx, 3
76+ shr cx, 4
7777 cmp cx, 63
7878 jbe .near
7979 mov cl, 63
@@ -104,8 +104,8 @@ pixel:
104104 int 0x10
105105 ret
106106
107−k_angle: dd 40.743665 ; 128 / pi
108−k_depth: dd 2048.0
107+k_angle: dd 81.48733 ; 256 / pi: eight segments around the wall
108+k_depth: dd 8192.0
109109
110110 section .bss
111111 x: resw 1