home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / bbs / picssup.ark / OSBEXEC.MCH < prev    next >
Encoding:
Text File  |  1986-10-18  |  6.0 KB  |  196 lines

  1. { ROS.MCH - Remote Operating System Clock Routines }
  2.  
  3. { File:        OSBEXEC.MCH
  4.   Description: Osborne Executive driver set.
  5.                All pertinent data and some subprogram "strategy" extracted
  6.                from Maurice Thaler's OX-MAC.INC for ROS 3.2 and my
  7.                ROS33QX2.LBR.  This is an attempt to get 3.3 running on the
  8.                Exec but as I have no access to an Exec, these files are
  9.                untested - I hope they are useful.
  10.   Date:        9/9/85
  11.   Author:      Mick Gaitor
  12.   Credits:     Maurice Thaler
  13. }
  14.  
  15. {** Remote channel routines **}
  16.  
  17. const
  18.  
  19. { Port locations }
  20.  
  21.   DataPort   = $0C;                         { Data port }
  22.   StatusPort = $0D;                         { Status port }
  23.   RatePort   = $04;                         { Data rate (bps) port }
  24.  
  25. { StatusPort commands }
  26.  
  27.   RESSTA     = $10;                         { Reset ext/status }
  28.   RESCHN     = $18;                         { Reset channel }
  29.   RESERR     = $30;                         { Reset error }
  30.   WRREG1     = $00;                         { Value to write to register 1 }
  31.   WRREG3     = $C1;                         { 8 bits/char, RX enable }
  32.   WRREG4     = $44;                         { 16x, 1 stop bit, no parity }
  33.   DTROFF     = $68;                         { DTR off, RTS off }
  34.   DTRON      = $EA;                         { DTR on, 8 bits/char, TX enable, RTS on }
  35.  
  36. { StatusPort masks }
  37.  
  38.   DAV        = $01;                         { Data available }
  39.   TRDY       = $04;                         { Transmit buffer empty }
  40.   DCD        = $08;                         { Data carrier detect }
  41.   PE         = $10;                         { Parity error }
  42.   OE         = $20;                         { Overrun error }
  43.   FE         = $40;                         { Framing error }
  44.   ERR        = $70;                         { Parity, overrun and framing error }
  45.  
  46. { Rate setting commands }
  47.  
  48.   BD300      : array[1..2] of byte = ($80,$01);    {  300 bps (=384 dec) }
  49.   BD1200     : array[1..2] of byte = ($60,$00);    { 1200 bps (= 96 dec) }
  50.   BD2400     : array[1..2] of byte = ($30,$00);    { 2400 bps (= 48 dec) }
  51.  
  52. procedure ch_init;
  53. { Initialize the remote channel }
  54.   const
  55.      sio_init: array[1..8] of byte =
  56.         (0, RESCHN, 4, WRREG4, 1, WRREG1, 3, WRREG3);
  57.   var
  58.      i: integer;
  59.   begin
  60.      for i := 1 to 8 do
  61.         port[StatusPort] := sio_init[i]
  62.   end;
  63.  
  64. procedure ch_on;
  65. { Turn on remote channel (usually by enabling DTR) }
  66.   begin
  67.      port[StatusPort] := 5;
  68.      port[StatusPort] := DTRON
  69.   end;
  70.  
  71. procedure ch_off;
  72. { Turn off remote channel (usually by disabling DTR) }
  73.   begin
  74.      port[StatusPort] := 5;
  75.      port[StatusPort] := DTROFF
  76.   end;
  77.  
  78. function ch_carck: boolean;
  79. { Check to see if carrier is present }
  80.   begin
  81.      port[StatusPort] := 0;
  82.      port[StatusPort] := RESSTA;
  83.      ch_carck := ((DCD and port[StatusPort]) <> 0)
  84.   end;
  85.  
  86. function ch_inprdy: boolean;
  87. { Check for ready to input from port }
  88.   var
  89.      bt: byte;
  90.   begin
  91.      if (DAV and port[StatusPort]) <> 0
  92.      then
  93.         begin
  94.            port[StatusPort] := 1;
  95.            if (ERR and port[StatusPort]) <> 0
  96.            then
  97.               begin
  98.                  port[StatusPort] := RESERR;
  99.                  bt := port[DataPort];      { "eat" char }
  100.                  ch_inprdy := FALSE
  101.               end
  102.            else
  103.               ch_inprdy := TRUE
  104.         end
  105.      else
  106.         ch_inprdy := FALSE
  107.   end;
  108.  
  109. function ch_inp: byte;
  110. { Input a byte from port - no wait - assumed ready }
  111.   begin
  112.      ch_inp := port[DataPort]
  113.   end;
  114.  
  115. procedure ch_out(bt: byte);
  116. { Output a byte to port - wait until ready }
  117.   begin
  118.      repeat
  119.      until ((TRDY and port[StatusPort]) <> 0);
  120.      port[DataPort] := bt
  121.   end;
  122.  
  123. procedure ch_set(r: integer);
  124. { Set the bps rate }
  125.   var
  126.      i         : integer;
  127.      RateVal : array[1..2] of byte;         { common area for rate vals }
  128.   begin
  129.      rate := r;
  130.      case rate of                           { move current rate values  }
  131.          300 : move( BD300,RateVal,2);      { to common area            }
  132.         1200 : move(BD1200,RateVal,2);
  133. (* Un-comment this if you can handle 2400 baud --
  134.         2400 : move(BD2400,RateVal,2);
  135. *)
  136.      end;
  137.      for i := 1 to 2 do                     { send rate values  }
  138.         port[RatePort] := RateVal[i]
  139.   end;
  140.  
  141.  
  142. {** System routines **}
  143. {  These were moved below the channel routines for the obvious (I hope)
  144.    reason of needing the channel routines declared before I could do
  145.    the system-init routine.  [MAG]
  146. }
  147.  
  148. procedure putstat(st: StrStd);
  149. { Display 'st' on status line }
  150.   const
  151.      status_line    = 24;                   { Line used for system status }
  152.      last_line      = 24;                   { Last line on screen }
  153.   begin
  154.      GotoXY(1,status_line);
  155.      LowVideo;
  156.      writeln(st);                           { issue <cr> to clear nxt line }
  157.      HighVideo;
  158.      GotoXY(1,last_line)
  159.   end;
  160.  
  161. procedure init_send(st : StrStd);
  162. { Send chars to the modem (in a manner per ROS 3.2) to set up defaults }
  163.   var
  164.      byt    : byte;
  165.      i      : integer;
  166.   begin
  167.      for i := 1 to Length(st) do
  168.         begin
  169.            byt := ord(st[i]);
  170.            ch_out(byt)
  171.         end
  172.      end;
  173.  
  174. procedure system_init;
  175. { Initialization to be done once when ROS first starts }
  176.   var
  177.      bt : byte;
  178.   begin
  179.      init_send('AT'+CR);                    { Get modem's attention   }
  180.      delay(2000);
  181.      init_send('AT Z'+CR);                  { Tell the modem to reset }
  182.      delay(2000);
  183.      init_send('AT V0'+CR);                 { Use numeric results     }
  184.      delay(2000);
  185.      bt := ch_inp;                          { Catch 'stray' chars     }
  186.      bt := ch_inp;
  187.   end;
  188.  
  189. procedure system_de_init;
  190. { De-initialization to be done once when ROS terminates }
  191.   begin
  192.      init_send('AT Z'+CR);                  { Tell the modem to reset }
  193.      putstat('')                            { Clear status line       }
  194.   end;
  195.  
  196.