home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols000 / vol072 / crt.pas < prev    next >
Pascal/Delphi Source File  |  1984-04-29  |  3KB  |  123 lines

  1. { Donated by Warren Smith, Feb 1982 }
  2.  
  3. Module CRT_Televideo;
  4.  
  5. { This set of routines is designed to support a Televideo 912/920 type    }
  6. { of terminal.  If you have trouble adapting it to your terminal, give    }
  7. { me a call.                                }
  8.  
  9. Const
  10.     Direct_IO = 6 ;
  11.     Crt_Status_Port = $5D;    { Godbout System Support 1 serial status port }
  12.     Char_Rcvd_Bit    = 2;    { may be unique to the Signetics 2651 U/SART }
  13.  
  14. { This is an external function supplied with Pascal MT+ which gives    }
  15. { you a hook into CPM.                            }
  16. External Function @BDOS (Func, Parm : integer) : integer;
  17.  
  18. Function Con_In : char ;    { non-echoed input from the console    }
  19.  
  20.   Const
  21.     Parm = 255;
  22.  
  23.   Begin { Con_In }
  24.   Con_In := chr(@BDOS(Direct_IO, Parm))
  25.   end ; { Con_In }
  26.  
  27. Procedure Con_Out (Out_Char : char) ;
  28.  
  29.   Var
  30.     Dummy : integer ;
  31.  
  32.   Begin { Con_Out }
  33.   Dummy := @BDOS(Direct_IO, ord(Out_Char))
  34.   end ; { Con_Out }
  35.  
  36. Function KeyPressed : Boolean ;
  37.  
  38.   Begin { KeyPressed }
  39.   KeyPressed := Tstbit (Inp[$5D], 1)    { Specific to System Support board }
  40.   end ; { KeyPressed }
  41.  
  42. Function Get_Console : char ;    { waits for a single character from the    }
  43.                 { console.                }
  44.   Begin { Get_Console }
  45.   While not KeyPressed do;
  46.   Get_Console := Con_In
  47.   end ; { Get_Console }
  48.  
  49. Procedure GoToXY (X, Y : integer) ;
  50.  
  51. Const X_PLAC = 4 ;
  52.       Y_PLAC = 3 ;
  53.       MAX_X  = 80 ;
  54.       MAX_Y  = 24 ;
  55.       X_OFF  = 31 ;
  56.       Y_OFF  = 31 ;
  57.  
  58.   Var BUFFER : array [1..4] of char ;
  59.  
  60.   Begin { GoToXY }
  61.   BUFFER [1] := chr(27) ;
  62.   BUFFER [2] := '=' ;
  63.   If X < 1 Then
  64.     BUFFER [X_PLAC] := chr(X_OFF)
  65.   else
  66.     If X > MAX_X then
  67.       BUFFER [X_PLAC] := chr(MAX_X + X_OFF)
  68.     else
  69.       BUFFER [X_PLAC] := chr(X + X_OFF) ;
  70.  
  71.   If Y < 1 then
  72.     BUFFER [Y_PLAC] := chr(Y_OFF)
  73.   else
  74.     If Y > MAX_Y then
  75.       BUFFER [Y_PLAC] := chr(MAX_Y + Y_OFF)
  76.     else
  77.       BUFFER [Y_PLAC] := chr(Y + Y_OFF) ;
  78.  
  79.   Con_Out(Buffer[1]) ;
  80.   Con_Out(Buffer[2]) ;
  81.   Con_Out(Buffer[3]) ;
  82.   Con_Out(Buffer[4])
  83.  
  84.   end ; { GoToXY }
  85.  
  86. Procedure Home ;
  87.  
  88.   Begin { Home }
  89.   Con_Out (chr($1E))
  90.   end ; { Home }
  91.  
  92. Procedure ScreenClr ;
  93.  
  94.   Begin { ScreenClr }
  95.   Con_Out (chr(26))
  96.   end ; { ScreenClr }
  97.  
  98. Procedure LineClr;
  99.  
  100.   Begin { LineClr }
  101.   Con_Out (chr(27));
  102.   Con_Out ('t')
  103.   end;  { LineClr }
  104.  
  105. Procedure Read_Cursor (Var X, Y : integer);
  106.  
  107.     Var
  108.     Discard : char;
  109.  
  110.     begin { Read_Cursor }
  111.     { request cursor coordinates from TeleVideo 912 or 920 }
  112.     ConOut (chr(27));
  113.     ConOut ('?');
  114.     While not KeyPressed do;
  115.     Y := ord(ConIn) - $1F;
  116.     While not KeyPressed do;
  117.     X := ord(ConIn) - $1F;
  118.     While not KeyPressed do;
  119.     Discard := ConIn    { this last character is supposed to be a CR }
  120.     end;  { Read_Cursor }
  121.  
  122. ModEnd.
  123.