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 / BEEHIVE / BBS / C128PICS.ARC / C1670.MCH < prev    next >
Text File  |  1991-08-11  |  4KB  |  182 lines

  1. { PICS.MCH -
  2.       Pascal Integrated Communications System Machine Dependent Routines }
  3.  
  4. { File:        C1670.MCH
  5.   Description: This driver set is designed to support a Commodore 1670 Modem
  6.   Date:        7/7/89
  7.   Author:      Peter B. Carter
  8. }
  9.  
  10. {** System routines **}
  11.  
  12. procedure di;
  13. begin
  14.      inline($f3);
  15. end;
  16.  
  17. procedure ei;
  18. begin
  19.      inline($fb);
  20. end;
  21.  
  22. function inbc(io : integer) : integer;
  23. {input from true 16b i/o space}
  24. var
  25.    ret_val : integer;
  26. begin
  27.      inline(
  28.      $ed/$4b/io/               {ld   bc,(io)}
  29.      $ed/$68/                  {in   l,(c)        ; input data off true 16b io space}
  30.      $26/0/                    {ld   h,0          ; zero high nibble}
  31.      $22/ret_val               {ld   (ret_val),hl}
  32.      );
  33.      inbc:=ret_val;
  34. end;
  35.  
  36. procedure outbc(io, data : integer);
  37. {output to true 16b i/o space}
  38. begin
  39.      inline(
  40.      $3a/data/                 {ld   a,(data)}
  41.      $ed/$4b/io/               {ld   bc,(io)}
  42.      $ed/$79                   {out  (c),a}
  43.      );
  44. end;
  45.  
  46.  
  47. procedure system_init;
  48. { Initialization to be done once when ROS first starts }
  49.   begin
  50.        mem[$fd4e]:=3; {8n2}
  51.        outbc($dd03,6); {ddr}
  52.        outbc($dd01,2); {dtr ok}
  53.        clock:=true;
  54.        mem[$fd22]:=0;
  55.        write(chr(26),chr(27),')');
  56.   end;
  57.  
  58.  
  59. procedure putstat(st: StrStd);
  60. { Display 'st' on status line }
  61.   const
  62.     status_line    = 25;                    { Line used for system status }
  63.     last_line      = 24;                    { Last line on screen }
  64.   begin
  65.     GotoXY(1, status_line);
  66.     ClrEol;
  67.     write(st);
  68.     GotoXY(1, last_line)
  69.   end;
  70.  
  71. {** Remote channel routines **}
  72.  
  73. procedure ch_init;
  74. { Initialize the remote channel }
  75.   begin
  76.   end;
  77.  
  78. procedure ch_on;
  79. { Turn on remote channel (usually by enabling DTR) }
  80. var
  81.    data : byte;
  82. begin
  83.      data:=inbc($dd01);
  84.      data:=data and 251;
  85.      outbc($dd01,data);
  86. end;
  87.  
  88. procedure ch_off;
  89. { Turn on remote channel (usually by disabling DTR) }
  90. var
  91.    data : byte;
  92. begin
  93.      data:=inbc($dd01);
  94.      data:=data or 4;
  95.      outbc($dd01,data);
  96. end;
  97.  
  98. function ch_carck: boolean;
  99. { Check to see if carrier is present }
  100. begin
  101.      if (inbc($dd01) and 16) = 0 then ch_carck:=true else ch_carck:=false;
  102. end;
  103.  
  104. function ch_inprdy: boolean;
  105. { Check for ready to input from port }
  106. begin
  107.      if (mem[$fd4f] and 1) = 1 then ch_inprdy:=true else ch_inprdy:=false;
  108. end;
  109.  
  110. function ch_inp: byte;
  111. { Input a byte from port - no wait - assumed ready }
  112. var
  113.    ch : byte;
  114. begin
  115.      ch:=mem[$fd51];
  116.      di;
  117.      mem[$fd4f]:=mem[$fd4f] and $fe;
  118.      ei;
  119.      ch_inp:=ch;
  120. end;
  121.  
  122. procedure ch_purge;
  123. {purge rs232 buffer (if any)}
  124. var
  125.    bt : byte;
  126. begin
  127.      while (mem[$fd4f] and 33) <> 0 do while ch_inprdy do bt:=ch_inp;
  128. end;
  129.  
  130. procedure ch_out(bt: byte);
  131. { Output a byte to port - wait until ready }
  132. begin
  133.     repeat
  134.     until (mem[$fd4f] and 128) = 0;
  135.     mem[$fd50]:=bt;
  136.     di;
  137.     mem[$fd4f]:=mem[$fd4f] or $80;
  138.     ei;
  139. end;
  140.  
  141. procedure set_timer(val : integer);
  142. var
  143.    lh : array[0..1] of byte absolute val;
  144. begin
  145.      di;
  146.      outbc($dc07,lh[1]);
  147.      outbc($dc06,lh[0]);
  148.      outbc($dc0f,$11);
  149.      ei;
  150. end;
  151.  
  152. procedure ch_set(r: integer);
  153. { Set the bps rate }
  154. begin
  155.     case r of
  156.       300 : begin
  157.                  set_timer(1136);
  158.                  mem[$fd52]:=3;
  159.                  rate:=300;
  160.             end;
  161.       450 : begin
  162.         set_timer(757);
  163.                 mem[$fd52]:=4;
  164.         rate:=450;
  165.             end;
  166.       1200: begin
  167.                  set_timer(284);
  168.                  mem[$fd52]:=12;
  169.                  rate:=1200;
  170.             end;
  171.     end;
  172. end;
  173.  
  174. procedure system_de_init;
  175. { De-initialization to be done once when ROS terminates }
  176.   begin
  177.        outbc($dd01,2); {dtr ok}
  178.        write(chr(27),')');
  179.        ch_set(300);
  180.   end;
  181.  
  182.