home *** CD-ROM | disk | FTP | other *** search
- Unit Tek4010 ;
- (* ------------------------------------------------------------------ *)
- (* Tektronics 4010 Graphics emulation unit *)
- (* ------------------------------------------------------------------ *)
- Interface
- Uses Crt,Graph, (* Standard Turbo Pascal Units *)
- Fonts,Drivers, (* Optional Turbo Pascal generated Units *)
- KGlobals, (* Kermit Global constants *)
- Sysfunc,
- Modempro,
- Packets ;
- Const
- Gversion = ' a' ;
- Var
- NewGraph : Boolean ;
- Graphics : string [25] ;
- Procedure Tektronics (var achar,bchar : byte) ;
-
- Implementation
- (* ------------------------------------------------------------------ *)
- { Type
- screen = array [0..$7FFF] of byte ; }
- var (* Tek 4010 variables *)
- LastX, LastY, NewX, NewY : Integer ;
- XDim,YDim : integer ;
- CursorX,CursorY : integer ;
- Xscale,Yscale : Real ;
- HiY, LoY, HiX, LoX : byte ;
- XFlag, DrawVector : Boolean ;
- alphastr : string ;
- alphacnt : integer ;
- GraphDriver,GraphMode : integer ;
- (* GraphScreen,SaveScreen : ^screen ; *)
- SaveScreenP : pointer ;
-
- (* ------------------------------------------------------------------ *)
- Procedure CrossHair ( X,Y : integer );
- const CrossX = 24;
- CrossY = 10;
- var x1,y1,x2,y2 : integer;
- begin (* Cross Hair *)
- x1 := X - CrossX; if x1 < 0 then x1 := 0;
- x2 := X + CrossX; if x2 >= XDim then x2 := XDim - 1;
- y1 := Y - CrossY; if y1 < 0 then y1 := 0;
- y2 := Y + CrossY; if y2 >= Ydim then y2 := YDim - 1;
- for x1 := x1 to x2 do PutPixel(x1,(YDim-Y),GetPixel(x1,(YDim-Y)) xor $0F);
- for y1 := y1 to y2 do PutPixel(X,(YDim-y1),GetPixel(X,(YDim-y1)) xor $0F);
- end ; (* CrossHair *)
-
- (* ------------------------------------------------------------------ *)
- Procedure Tektronics (var achar,bchar : byte) ;
- Const
- BitCheck = $60 ;
- LoYBit = $60 ;
- LoXBit = $40 ;
- HiBit = $20 ;
- Bit6 = $20 ;
- FiveBits = $1F ;
- Var
- TekState : (AlphaState,GraphicState,GraphicEscState);
- Done : boolean;
- Temp,ix : Integer;
- Label
- Exit ;
-
- Begin (* Tektronics Procedure *)
- InitGraph(GraphDriver,GraphMode,' ') ;
- If Newgraph then
- begin (* init new graph *)
- Newgraph := false ;
- CursorX := Xdim div 2 ;
- CursorY := Ydim div 2 ;
- end (* init new graph *)
- else
- (* GraphScreen^ := Savescreen^ ;*)
- PutImage(0,0,SaveScreenP^,Normalput) ;
- Tekstate := GraphicState ;
- HiY := 0; LoY := 0;
- HiX := 0; LoX := 0;
- LastX := 0; LastY := 0;
- XFlag := FALSE;
- DrawVector := FALSE;
- AlphaCnt := 0 ;
- AlphaStr := '' ;
- If achar = us then TekState := AlphaState
- else TekState := GraphicState ;
- While True Do
- Case TekState of
- (* ==================== Alpha State ============================= *)
- AlphaState :
- BEGIN {alphamode}
- If achar = us then else
- IF (AlphaCnt < 255) and not (achar in [esc,gs,ff,sub,bel]) then
- BEGIN
- AlphaStr := alphaStr + chr(achar);
- AlphaCnt := AlphaCnt + 1;
- END
- else
- Begin
- SetTextStyle(SmallFont,0,4) ;
- OutTextXY(Trunc(LastX*Xscale),Trunc(LastY*Yscale),AlphaStr);
- DrawVector := false ;
- AlphaCnt := 0 ;
- AlphaStr := '' ;
- IF (achar = gs) THEN TekState := GraphicState ;
- IF (achar = esc) THEN TekState := GraphicEscState ;
- If (achar = bel) THEN
- begin
- write(chr(achar));
- repeat until keypressed ;
- CloseGraph ;
- goto exit ;
- end ;
- End ;
- If ReadMchar(achar) then else goto exit ;
- END; {alphamode}
-
- (* ==================== Graphic State ============================= *)
- GraphicState :
- Begin (* GraphicState *)
- IF achar = GS then DrawVector := False
- else
- IF achar = US then TekState := AlphaState
- else
- IF achar = ESC then TekState := GraphicEscState
- else
- IF achar = bel then
- begin
- write(chr(achar));
- repeat until keypressed ;
- RestoreCrtMode ;
- CloseGraph ;
- goto exit ;
- end
- else
- BEGIN (* assume it a Hi or Lo byte for X or Y *)
- IF (achar and BitCheck) = HiBit THEN
- IF XFlag THEN HiX := achar and FiveBits
- ELSE HiY := achar and FiveBits
- ELSE
- IF (achar and BitCheck) = LoYBit THEN
- BEGIN
- LoY := achar and FiveBits;
- XFlag := TRUE;
- END
- ELSE
- IF (achar and BitCheck) = LoXBit THEN
- BEGIN (* LoXBit *)
- LoX := achar and FiveBits;
- XFlag := FALSE;
- NewX := (HiX*32 + LoX);
- NewY := 779 - (HiY*32 + LoY);
- if Round(NewX * Xscale) > XDim then NewX := 1 ;
- if Round(Newy * Yscale) > YDim then NewY := 1 ;
- IF DrawVector THEN
- Line ( Round(LastX * Xscale),
- Round(LastY * Yscale),
- Round(NewX * Xscale),
- Round(NewY * Yscale) )
- ELSE
- BEGIN
- DrawVector := TRUE;
- END;
- LastX := NewX;
- LastY := NewY;
- END ; (* LoXBit *)
- END ; (* assume it a Hi or Lo byte for X or Y *)
- If ReadMchar(achar) then else goto exit ;
- End ; (* Graphic State *)
-
- (* ==================== Graphic Escape State ======================= *)
- GraphicEscState :
- Begin (* Graphic Escape State *)
- (* savescreen^ := GraphScreen^ ; *)
- GetImage(0,0,Xdim,Ydim,SaveScreenP^);
- If achar=Sub then
- begin (* GIN - Graphics INput *)
- Done := false;
- repeat
- begin (* move cursor *)
- CrossHair(CursorX, CursorY); {draw it}
- REPEAT UNTIL KeyChar(achar,bchar);
- CrossHair(CursorX, CursorY); {erase it}
- if achar = 0 then
- begin {special key}
- case bchar of
- $48: begin {up arrow}
- CursorY := CursorY + 1 ;
- if CursorY >= YDim then
- CursorY := (YDim - 1) ;
- end;
- $4B: begin {left arrow}
- CursorX := CursorX - 1 ;
- if CursorX < 0 then CursorX := 0;
- end;
- $4D: begin {right arrow}
- CursorX := CursorX + 1 ;
- if CursorX >= XDim then
- CursorX := (XDim - 1) ;
- end;
- $50: begin {down arrow}
- CursorY := CursorY - 1 ;
- if CursorY < 0 then CursorY := 0;
- end;
- $4F: begin {END}
- Done := true;
- SendChar($0D);
- end;
- else
- {not recognized}
- end (* of case *);
- end { special key }
- else
- begin (* send cursor location *)
- SendChar(achar);
- Temp := Round(CursorX / XScale );
- SendChar((Temp div 32) or Bit6 ) ; (* Hi X *)
- SendChar((Temp and FiveBits) or Bit6); (* Lo X *)
- Temp := Round(CursorY / YScale );
- SendChar((Temp div 32) or Bit6) ; (* Hi Y *)
- SendChar((Temp and FiveBits) or Bit6); (* Lo Y *)
- SendChar($0D);
- Done := True;
- end; (* send cursor location *)
- end until Done; (* move cursor *)
- End (* GIN - Graphics INput *)
- else
- If achar = FF then
- begin
- RestoreCrtMode ; TextMode(2) ;
- InitGraph(GraphDriver,Graphmode,' ') ; (* clear screen *)
- CloseGraph ;
- newgraph := true ;
- end
- else
- CloseGraph ;
- Goto Exit ; (* exit Graphics procedure *)
- End ; (* Graphic Escape State *)
- (* ================================================================= *)
- End ; (* Case of Tekmode *)
- Exit:
- CloseGraph ;
- End ; (* Tektronics Procedure *)
-
- (* ----------------------------------------------------------------- *)
- Begin (* Tek4010 Unit *)
- DetectGraph(GraphDriver,GraphMode);
- Case GraphDriver of
- CGA : Begin
- Graphmode := CGAHi ;
- { GraphScreen := PTR($B800,0000); }
- Graphics := ' - Tek4010 / CGA ';
- End ;
- MCGA : Begin
- Graphmode := MCGAHi ;
- { GraphScreen := PTR($A000,0000); }
- Graphics := ' - Tek4010 / MCGA ';
- End ;
- EGA : Begin
- Graphmode := EGAHi ;
- { GraphScreen := PTR($A000,0000); }
- Graphics := ' - Tek4010 / EGA ';
- End ;
- EGA64 : Begin
- Graphmode := EGA64Hi ;
- { GraphScreen := PTR($A000,0000); }
- Graphics := ' - Tek4010 / EGA64 ';
- End ;
- EGAMono: Begin
- Graphmode := EGAMonoHi ;
- { GraphScreen := PTR($A000,0000); }
- Graphics := ' - Tek4010 / EGAMono ';
- End ;
- HercMono : Begin
- Graphmode := HercMonoHi ;
- { GraphScreen := PTR($B000,0000); }
- Graphics := ' - Tek4010 / Hercules ';
- End ;
- ATT400 : Begin
- Graphmode := ATT400Hi ;
- { GraphScreen := PTR($B800,0000); }
- Graphics := ' - Tek4010 / AT&T ';
- End ;
- VGA : Begin
- Graphmode := VGAHi ;
- { GraphScreen := PTR($A000,0000); }
- Graphics := ' - Tek4010 / VGA ';
- End ;
- PC3270 : Begin
- Graphmode := PC3270Hi ;
- { GraphScreen := PTR($B800,0000); }
- Graphics := ' - Tek4010 / PC3270 ';
- End ;
- End ; (* case *)
- { New(Savescreen); }
- InitGraph(GraphDriver,Graphmode,' ');
- XDim := GetMaxX ;
- YDim := GetMaxY ;
- XScale := XDim / 1024 ;
- YScale := YDim / 780 ;
- getmem(SaveScreenP,ImageSize(0,0,Xdim,YDim) ) ;
- SetTextStyle(SmallFont,0,4) ;
- CloseGraph ;
- End. (* Tek4010 Unit *)
-