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; { Our first Virtual screen } Vaddr : word; { The segment of our virtual screen} Virscr2 : VirtPtr2; { Our first Virtual screen } Vaddr2 : word; { The segment of our virtual screen} Virscr3 : VirtPtr3; { Our first Virtual screen } Vaddr3 : word; { The segment of our virtual screen} Virscr4 : VirtPtr4; { Our first Virtual screen } Vaddr4 : word; { The segment of our virtual screen} Scr_Ofs : Array[0..199] of Word; { Put Pixel } 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); 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.