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 mov al, cl
31 and al, 63 ; level
32 mov ah, al
33 shr ah, 2 ; level / 4
34 mov bl, ah
35 add bl, ah
36 add bl, ah ; 3 * level / 4
37 test cl, 64
39 out dx, al ; amber: red = level
40 mov al, bl
41 out dx, al ; green = 3/4 level
42 mov al, ah
43 out dx, al ; blue = 1/4 level
45.cyan: xchg al, ah
46 out dx, al ; cyan: red = 1/4 level
47 mov al, bl
48 out dx, al ; green = 3/4 level
49 mov al, ah
50 out dx, al ; blue = level
51.next: inc cl
54; --- one frame ----------------------------------------------------------------
56 xor di, di
57pixel:
Row and column from one multiply by 0xCCCDJul 29
58 mov ax, 0xCCCD ; di * 0.8: DH = row, DL = column * 0.8
59 mul di
60 sub dh, 100 ; centre the row
61 sub dl, 128 ; centre the column
62 movsx ax, dh
69 fpatan ; angle around the axis, -pi..pi
74 fmul st0, st0
76 fmul st0, st0
77 faddp st1, st0
78 fsqrt ; distance from the centre
83 add ax, bp ; spin
85 add bx, bp
86 add bx, bp ; fly forward, twice as fast
89 cmp di, 64000
92 inc bp ; next frame
93 in al, 0x60 ; Esc has scancode 1
94 dec al
96 ret
98k_angle: dd 40.743665 ; 128 / pi
99k_depth: dd 2048.0
101section .bss
102x: resw 1
103y: resw 1
104u: resw 1
105v: resw 1