program stuff; uses crt; const leng = 320; years = 199; VGA = $a000; Type Virtual = Array [1..64000] of byte; { The size of our Virtual Screen } VirtPtr = ^Virtual; { Pointer to the virtual screen } Virtual2 = Array [1..64000] of byte; { The size of our Virtual Screen } VirtPtr2 = ^Virtual2; { Pointer to the virtual screen } Virtual3 = Array [1..64000] of byte; { The size of our Virtual Screen } VirtPtr3 = ^Virtual3; { Pointer to the virtual screen } Virtual4 = Array [1..64000] of byte; { The size of our Virtual Screen } VirtPtr4 = ^Virtual4; { Pointer to the virtual screen } VAR a : integer; Virscr : VirtPtr; { Virtual screen } Vaddr : word; { The segment of the virtual screen} Virscr2 : VirtPtr2; { Virtual screen } Vaddr2 : word; { The segment of the virtual screen} Virscr3 : VirtPtr3; { Virtual screen } Vaddr3 : word; { The segment of the virtual screen} Virscr4 : VirtPtr4; { Virtual screen } Vaddr4 : word; { The segment of the virtual screen} Scr_Ofs : Array[0..199] of Word; { Put Pixel } p : integer; phase : real; xx :integer; yy : integer; x : integer; y : real; d1 : real; d2 : real; amp1 : real; amp2 : real; intensity: real; col : integer; d : real; s1 : real; s2 : real; wl : real; Procedure SetMCGA; BEGIN asm mov ax,0013h int 10h end; END; Procedure SetText; BEGIN asm mov ax,0003h int 10h end; END; Procedure Cls (Where:word;Col : Byte); assembler; { This clears the screen to the specified color } asm push es mov cx, 32000; mov es,[where] xor di,di mov al,[col] mov ah,al rep stosw pop es End; Procedure SetUpVirtual; { This sets up the memory needed for the virtual screen } BEGIN GetMem (VirScr,64000); vaddr := seg (virscr^); GetMem (VirScr2,64000); vaddr2 := seg (virscr2^); GetMem (VirScr3,64000); vaddr3 := seg (virscr3^); GetMem (VirScr4,64000); vaddr4 := seg (virscr4^); END; Procedure DistroyVirtual; { This frees the memory used by the virtual screen } BEGIN FreeMem (VirScr,64000); FreeMem (VirScr2,64000); FreeMem (VirScr3,64000); FreeMem (VirScr4,64000); END; procedure WaitRetrace; assembler; { This waits until you are in a Verticle Retrace } label l1, l2; asm mov dx,3DAh l1: in al,dx and al,08h jnz l1 l2: in al,dx and al,08h jz l2 end; Procedure Putpixel (X,Y : Integer; Col : Byte; where:word); { This puts a pixel on the screen by writing directly to memory. } BEGIN Asm push ds {; Make sure these two go out the } push es {; same they went in } mov ax,[where] mov es,ax {; Point to segment of screen } mov bx,[X] mov dx,[Y] push bx {; and this again for later} mov bx, dx {; bx = dx} mov dh, dl {; dx = dx * 256} xor dl, dl shl bx, 1 shl bx, 1 shl bx, 1 shl bx, 1 shl bx, 1 shl bx, 1 {; bx = bx * 64} add dx, bx {; dx = dx + bx (ie y*320)} pop bx {; get back our x} add bx, dx {; finalise location} mov di, bx {; di = offset } {; es:di = where to go} xor al,al mov ah, [Col] mov es:[di],ah {; move the value in ah to screen point es:[di] } pop es pop ds End; END; procedure flip(source,dest:Word); { This copies the entire screen at "source" to destination } begin asm push ds mov ax, [Dest] mov es, ax { ES = Segment of source } mov ax, [Source] mov ds, ax { DS = Segment of source } xor si, si { SI = 0 Faster then mov si,0 } xor di, di { DI = 0 } mov cx, 32000 rep movsw { Repeat movsw 32000 times } pop ds end; end; begin { clrscr;} SetupVirtual; SetMCGA; { Start } Cls (VGA, 0); Cls (Vaddr, 0); Cls (Vaddr2, 0); Cls (Vaddr3, 0); Cls (Vaddr4, 0); { putpixel(1,1,1,vaddr); putpixel(2,2,2,vaddr2); putpixel(4,4,2,vaddr2); putpixel(3,3,3,vaddr3); putpixel(6,6,3,vaddr3); putpixel(9,9,3,vaddr3); putpixel(4,4,4,vaddr4); putpixel(8,8,4,vaddr4); putpixel(12,12,4,vaddr4);} d := 10; s1 := -d; s2 := d; wl := 100; p := 3; repeat phase := p * 3.1415926 / 2; yy := 10; repeat xx := 0; repeat {-----} x := xx - 100; y := (320 - yy) / 1.5 - 50; d1 := SQRT(SQR((x - s1)) + y * y); amp1 := SIN(d1 + phase); d2 := SQRT(SQR((x - s2)) + y * y); amp2 := SIN(d2 + phase); intensity := amp1 + amp2 + 1; col := 0; IF random(1) > intensity THEN col := 15; if p = 0 then begin putpixel (xx,yy,col, vaddr); putpixel (-xx,yy,col, vaddr); end; if p = 1 then begin putpixel (xx,yy,col, vaddr2); putpixel (-xx,yy,col, vaddr2); end; if p = 2 then begin putpixel (xx,yy,col, vaddr3); putpixel (-xx,yy,col, vaddr3); end; if p = 3 then begin putpixel (xx,yy,col, vaddr4); putpixel (-xx,yy,col, vaddr4); end; {PSET (xx, yy), col: PSET (-xx, yy), col} {-----} xx := xx + 2; until xx >= 200; yy := yy + 2; until yy >= 200; { Loop 2 } p := p - 1; until p < 0; { Loop 1 } repeat flip(vaddr, vga); delay(500); flip(vaddr2, vga); delay(500); flip(vaddr3, vga); delay(500); flip(vaddr4, vga); delay(500); until keypressed; readln; SetText; DistroyVirtual; end.