A flight down a tunnel of light for DOS, in under 256 bytes. Every pixel asks the x87 for an angle and a depth.
First light: mode 13h and an XOR patternJul 22
1; tunnel256: a flight down a tunnel of light, for DOS.
2;
Angle and depth from the FPUJul 24
3; Target: DOS .COM, 386+ with an x87, VGA mode 13h (320x200, 256 colours).
Angle and depth from the FPUJul 24
7; Every pixel asks the FPU two questions: which way is it from the centre
8; (fpatan) and how deep into the tunnel it sits (k / distance). The answers
9; become texture coordinates, scrolled by the frame counter in BP.
11 bits 16
12 cpu 386
13 org 0x100
15start:
18 int 0x10
19 push word 0xA000
20 pop es
21 cld
Two ramps: amber and cyanAug 3
23; --- palette: an amber ramp, then a cyan one, twice over ---------------------
24 xor cx, cx
25palette:
26 mov dx, 0x3C8
27 mov al, cl
28 out dx, al ; colour index
29 inc dx ; 0x3C9 takes red, green, blue
30 and al, 63 ; level
31 mov ah, al
32 shr ah, 2 ; level / 4
33 mov bl, ah
34 add bl, ah
35 add bl, ah ; 3 * level / 4
36 test cl, 64
38 xchg al, ah ; cyan is amber with red and blue swapped
39.amber: out dx, al ; red
44 inc cl
47; --- one frame ----------------------------------------------------------------
49 xor di, di
50pixel:
Row and column from one multiply by 0xCCCDJul 29
51 mov ax, 0xCCCD ; di * 0.8: DH = row, DL = column * 0.8
52 mul di
53 sub dh, 100 ; centre the row
54 sub dl, 128 ; centre the column
55 movsx ax, dh
62 fpatan ; angle around the axis, -pi..pi
67 fmul st0, st0
69 fmul st0, st0
70 faddp st1, st0
71 fsqrt ; distance from the centre
76 shr cx, 3
77 cmp cx, 63
79 mov cl, 63
83 add ax, bp ; spin
85 add bx, bp
86 add bx, bp ; fly forward, twice as fast
89 and ch, 64
90 and al, 63
91 mul cl ; shade by fog
92 shr ax, 6
93 or al, ch
95 cmp di, 64000
98 inc bp ; next frame
99 in al, 0x60 ; Esc has scancode 1
100 dec al
103 mov ax, 0x0003 ; back to text mode
104 int 0x10
107k_angle: dd 40.743665 ; 128 / pi
108k_depth: dd 2048.0
110section .bss
111x: resw 1
112y: resw 1
113u: resw 1
114v: resw 1