home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / TURBOPAS / PMODEM.ARK / ROS.MCH < prev    next >
Text File  |  1987-02-22  |  5KB  |  187 lines

  1. { ROS.MCH - Remote Operating System Machine Dependent Routines }
  2.  
  3. { File:        KAYII.MCH
  4.   Description: This driver set is designed to support the Kaypro II (83).
  5.                taken from a Kaypro written by Chris DeBracy for 84&85 model
  6.                kaypros.
  7.   Date:        5/4/85
  8.   Author:      Chris DeBracy
  9.  
  10.   Description: Comment update and code cleanup.
  11.   Date:        9/7/85
  12.   Author:      Steve Fox
  13.  
  14.   Description:  Driver Derived from KPRO.MCH by C. DeBracy
  15.                 In response to a comment by Dave Gannon, the procedure
  16.                 Drive_off was added.  To complete this mod, call the procedure
  17.                 from files
  18.            ROSSND.INC, about line 55;
  19.                while (remaining > 0) and (errcnt < maxerr) do
  20.               begin
  21.                 blockread(XfrFile, Buffer, BufBlocks);
  22.                 Drive_off;
  23.                 remaining := pred(remaining);
  24.            ROSSND.INC, About 195
  25.                     EndOfFile := (IOresult <> 0);
  26.                     Drive_off;
  27.                   end;
  28.              ROSRCV.INC, about line 60;
  29.                                          Drive_off;
  30.                           OK := (IOresult = 0);
  31.                           Write_err := Not OK;
  32.  
  33.   Date:        4/20/86
  34.   Author:      Coleman Smith
  35. }
  36.  
  37. {** System routines **}
  38. Procedure Reset_Drives;
  39.           Begin
  40.           End;
  41.  
  42. Procedure Drive_off; {suggested by Dave Gannon, 14 Mar 86}
  43.   Var
  44.     x  :  Integer;
  45.   Begin
  46.      x := port[28];
  47.      x := (x or 64);
  48.      port[28] := x;
  49. end;
  50.  
  51. procedure system_init;
  52. { Initialization to be done once when ROS first starts }
  53.   begin
  54.   end;
  55.  
  56. procedure system_de_init;
  57. { De-initialization to be done once when ROS terminates }
  58.   begin
  59.   end;
  60.  
  61. procedure putstat(st: StrStd);
  62. { Display 'st'(status message) on status line }
  63.  
  64.   begin
  65.     GOTOXY(1,24);
  66. {    Write(^X);}
  67.     writeln(st);
  68.   end;
  69.  
  70. {** Remote channel routines **}
  71.  
  72. const
  73.  
  74. { Port locations }
  75.  
  76.   DataPort   = $04;                         { Data port }
  77.   StatusPort = $06;                         { Status port }
  78.   RatePort   = $00;                         { Data rate (bps) port }
  79.  
  80. { StatusPort commands }
  81.  
  82.   RESSTA     = $10;                         { Reset ext/status }
  83.   RESCHN     = $18;                         { Reset channel }
  84.   RESERR     = $30;                         { Reset error }
  85.   WRREG1     = $00;                         { Value to write to register 1 }
  86.   WRREG3     = $C1;                         { 8 bits/char, RX enable }
  87.   WRREG4     = $44;                         { 16x, 1 stop bit, no parity }
  88.   DTROFF     = $68;                         { DTR off, RTS off }
  89.   DTRON      = $EA;                         { DTR on, 8 bits/char, TX enable, RTS on }
  90.  
  91. { StatusPort masks }
  92.  
  93.   DAV        = $01;                         { Data available }
  94.   TRDY       = $04;                         { Transmit buffer empty }
  95.   DCD        = $08;                         { Data carrier detect }
  96.   PE         = $10;                         { Parity error }
  97.   OE         = $20;                         { Overrun error }
  98.   FE         = $40;                         { Framing error }
  99.   ERR        = $60;                         { Parity, overrun and framing error }
  100.  
  101. { Rate setting commands }
  102.  
  103.   BD300      = $5;                         {  300 bps }
  104.   BD1200     = $7;                         { 1200 bps }
  105.   BD2400     = $A;                         { 2400 bps }
  106.  
  107. procedure ch_init;
  108. { Initialize the remote channel }
  109.   const
  110.     sio_init: array[1..8] of byte =
  111.       (0, RESCHN, 4, WRREG4, 1, WRREG1, 3, WRREG3);
  112.   var
  113.     i: integer;
  114.   begin
  115.     for i := 1 to 8 do
  116.       port[StatusPort] := sio_init[i]
  117.   end;
  118.  
  119. procedure ch_on;
  120. { Turn on remote channel (usually by enabling DTR) }
  121.   begin
  122.     port[StatusPort] := 5;
  123.     port[StatusPort] := DTRON
  124.   end;
  125.  
  126. procedure ch_off;
  127. { Turn off remote channel (usually by disabling DTR) }
  128.   begin
  129.     port[StatusPort] := 5;
  130.     port[StatusPort] := DTROFF
  131.   end;
  132.  
  133. function ch_carck: boolean;
  134. { Check to see if carrier is present }
  135.   begin
  136.     port[StatusPort] := 0;
  137.     port[StatusPort] := RESSTA;
  138.     ch_carck := ((DCD and port[StatusPort]) <> 0)
  139.   end;
  140.  
  141. function ch_inprdy: boolean;
  142. { Check for ready to input from port }
  143. var
  144.   bt: byte;
  145. begin
  146.   if (DAV and port[StatusPort]) <> 0
  147.     then
  148.       begin
  149.         port[StatusPort] := 1;
  150.         if (ERR and port[StatusPort]) <> 0
  151.           then
  152.             begin
  153.               port[StatusPort] := RESERR;
  154.               bt := port[DataPort];
  155.               ch_inprdy := FALSE
  156.             end
  157.           else ch_inprdy := TRUE
  158.       end
  159.     else ch_inprdy := FALSE
  160. end;
  161.  
  162. function ch_inp: byte;
  163. { Input a byte from port - no wait - assumed ready }
  164.   begin
  165.     ch_inp := port[DataPort]
  166.   end;
  167.  
  168. procedure ch_out(bt: byte);
  169. { Output a byte to port - wait until ready }
  170.   begin
  171.     repeat
  172.     until ((TRDY and port[StatusPort]) <> 0);
  173.     port[DataPort] := bt
  174.   end;
  175.  
  176. procedure ch_set(r: integer);
  177. { Set the bps rate }
  178.   begin
  179.     rate := r;
  180.     case rate of
  181.        300: port[RatePort] := BD300;
  182.       1200: port[RatePort] := BD1200;
  183.       2400: port[RatePort] := BD2400
  184.     end
  185.   end;
  186.  
  187.