home *** CD-ROM | disk | FTP | other *** search
- Program GrafDemo; { Author: William P. Smith }
- { Mitchellville, Md }
-
- Type
- line = String[80];
- GraphFileName = String[15];
-
- Var
- color,n,i:integer;
- name: Array[1..10] of GraphFileName;
- scrnfil: File;
- Buffer1,Buffer2,Buffer3: Array[1..$4000] of Byte;
- Video: Byte Absolute $B800:0000;
- ah,al: Byte;
- ch: char;
-
- function mkstr(ch: char; n: integer): line;
- var st: line;
- i: integer;
- begin
- st:='';
- for i:=1 to n do st:=st+ch;
- mkstr:=st;
- end;
- procedure Vwrite(st: line; attribute: byte);
- var X,Y,i: integer;
- begin
- X:=whereX; Y:=whereY;
- write(st);
- for i:=1 to length(st) do mem[$B800:2*((Y-1)*80+i+X-2)+1]:=attribute;
- end;
- procedure Box(st: line);
- var X,Y: byte;
- ch: char;
- begin
- ch:=chr(205);
- x:=whereX; Y:=whereY;
- gotoxy(X,Y); write(#201,mkstr(ch,length(st)+2),#187);
- gotoxy(X,Y+1); write(#186); gotoxy(X+length(st)+3,Y+1); write(#186);
- gotoxy(X,Y+2); write(#200,mkstr(ch,length(st)+2),#188);
- gotoxy(X+2,Y+1); Vwrite(st,$70);
- end;
- procedure GetScanCode(var ah,al: byte);
- type
- regpack = record
- ax,bx,cx,dx,bp,di,si,ds,es,flags: integer;
- end;
- var
- recpack: regpack;
-
- begin
- ah := $0;
- with recpack do
- begin
- ax := ah shl 8 + al;
- end;
- intr($16,recpack);
- with recpack do
- begin
- ah:=ax shr 8;
- al:=ax mod 256;
- end;
- end;
- procedure GetColor;
- var row,col: integer;
- procedure hilite(attribute: byte);
- var X,Y,i: integer;
- begin
- X:=whereX; Y:=whereY;
- for i:=1 to 11 do mem[$B800:2*((Y-1)*80+i+X-2)+1]:=attribute;
- end;
- procedure ListColors;
- begin
- col:=30; row:=15;
- gotoxy(col,row); write(#201,mkstr(chr(205),11),#187);
- gotoxy(col,row+1); write(#186,' Blue ',#186);
- gotoxy(col,row+2); write(#186,' Green ',#186);
- gotoxy(col,row+3); write(#186,' Cyan ',#186);
- gotoxy(col,row+4); write(#186,' Red ',#186);
- gotoxy(col,row+5); write(#186,' Magenta ',#186);
- gotoxy(col,row+6); write(#186,' Brown ',#186);
- gotoxy(col,row+7); write(#186,' Yellow ',#186);
- gotoxy(col,row+8); write(#186,' White ',#186);
- gotoxy(col,row+9); write(#200,mkstr(chr(205),11),#188);
- end;
- procedure select(var varnum: integer);
- begin
- repeat
- getScanCode(ah,al);
- case ah of
- 72: begin
- varnum:=varnum-1;
- if varnum<1 then varnum:=8;
- end;
- 80: begin
- varnum:=varnum+1;
- if varnum>8 then varnum:=1;
- end;
- end;
- hilite($7);
- gotoxy(col+1,row+varnum);
- hilite($70);
- until al=13;
- end;
- begin
- listcolors;
- color:=1;
- gotoxy(col+1,row+color);
- hilite($70);
- select(color);
- if color>6 then color:=color+7;
- end;
- begin
- gotoxy(19,1); Box(' TURBO PASCAL GRAPHICS DEMO ');
- gotoxy(35,4); write('by');
- gotoxy(28,5); write('William P. Smith');
- lowvideo;
- gotoxy(28,6); write('Mitchellville, MD');
- gotoxy(1,10); write('This is a demonstration of some ');
- Vwrite('3-D',$8F);
- writeln(' graphics that I created with Turbo. To');
- writeln('begin select a color. Each graph will continue to be displayed until any');
- Vwrite('key',$70);
- writeln(' is pressed. A high resolution graphics display device is required.');
- write('Please use cursor keys to choose desired color then confirm with CR. ');
- Vwrite('Enjoy!',$F0);
- name[1]:='peak';
- name[2]:='towers';
- name[3]:='peaks';
- name[4]:='sinexp';
- name[5]:='cosexp';
- name[6]:='well';
- name[7]:='sph1';
- GetColor;
- for n:=1 to 7 do begin
- assign(scrnfil,name[n]+'.pic'); reset(scrnfil);
- blockread(scrnfil,buffer1,128);
- close(scrnfil);
- hires; hirescolor(color);
- move(Buffer1,Video,$4000);
- read(kbd,ch);
- end;
- assign(scrnfil,'sph2.pic'); reset(scrnfil);
- blockread(scrnfil,Buffer2,128);
- close(scrnfil);
- assign(scrnfil,'sph3.pic'); reset(scrnfil);
- blockread(scrnfil,Buffer3,128);
- close(scrnfil);
- repeat
- move(Buffer2,Video,$4000);
- move(Buffer3,Video,$4000);
- move(Buffer1,Video,$4000);
- until keypressed;
- textmode(2);
- gotoxy(30,13); Vwrite(' That''s all folks! ',$F0);
- end.