home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 8 / CDASC08.ISO / NEWS / 554 / JUIN / FOSSIL.PAS < prev    next >
Pascal/Delphi Source File  |  1993-10-07  |  4KB  |  145 lines

  1. {─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
  2. Msg  : 421 of 436
  3. From : Sean Palmer                         1:104/123.0          26 Jun 93  03:58
  4. To   : Jim Coyle
  5. Subj : Hey!
  6. ────────────────────────────────────────────────────────────────────────────────
  7. JC>I'm looking for some really good routines to access the fossil driver, can
  8. JC>someone tell me a BBS where I could call or FREQ them from at 9600 v32 baud?
  9.  
  10. I think this is small enough to post..}
  11.  
  12. {$A-,B-,D+,E-,F-,G+,I-,L+,N-,O-,R-,S-,V-,X+}
  13. unit fossil;
  14. interface
  15.  
  16. const
  17.  curPort:word=0;  {0=COM1,1=COM2,$FF=none}
  18.  maxFunct:byte=0;
  19.  fossilVersion:byte=0;
  20.  
  21.  
  22.  statusOutEmpty  =$4000;  {masks for status}
  23.  statusOutNotFull=$2000;
  24.  statusInOverrun =$0200;
  25.  statusInWaiting =$0100;
  26.  statusCarrier   =$0080;
  27.  
  28.  flowRemXON=1; flowLocXON=8; flowRTSCTS=2;
  29.  
  30.  on=1; off=2; check=$FF;  {for boolean set/check functions like DTR}
  31.  
  32. type hook=procedure;
  33.  
  34.  function init:boolean;
  35.  procedure close;
  36.  function setBaud(s:byte):word;
  37.  function dtr(b:byte):boolean;
  38.  function carrier:boolean;
  39.  function received:boolean;
  40.  function status:word;
  41.  function get:char;
  42.  function put(c:char):word;
  43.  function next:char;
  44.  procedure purgeOut;
  45.  procedure purgeIn;
  46.  procedure flushOut;
  47.  procedure flow(f:byte);
  48.  procedure break(b:boolean);
  49.  procedure xmit(b:boolean);
  50.  procedure write(s:string);
  51.  function writeBlock(var b;n:word):word;
  52.  function readBlock(var b;n:word):word;
  53.  function watch(p:hook;add:boolean):boolean;
  54.  
  55. implementation
  56.  
  57. function setBaud(s:byte):word;assembler;asm
  58.  mov dx,curPort; mov al,s; mov ah,0; int $14; {returns status bits}
  59.  end;
  60.  
  61. function put(c:char):word;assembler;asm
  62.  mov dx,curPort; mov al,c; mov ah,1; int $14; {returns status bits}
  63.  end;
  64.  
  65. procedure write(s:string);var i:byte;begin
  66.  for i:=1 to length(s) do put(s[i]);
  67.  end;
  68.  
  69. function get:char;assembler;asm  {waits if none}
  70.  mov dx,curPort; mov ah,2; int $14;  {returns char}
  71.  end;
  72.  
  73. function status:word;assembler;asm
  74.  mov dx,curPort; mov ah,3; int $14;   {returns status bits}
  75.  end;
  76.  
  77. function carrier:boolean;assembler;asm
  78.  mov dx,curPort; mov ah,3; int $14; and ax,statusCarrier;
  79.  end;
  80.  
  81. function received:boolean;assembler;asm
  82.  mov dx,curPort; mov ah,3; int $14; and ax,statusInWaiting; mov al,ah;
  83.  end;
  84.  
  85. function init:boolean;assembler;asm {raises DTR, preserves baud if successful}
  86.  mov dx,curPort; xor bx,bx; mov ah,4; int $14;  {bx<>$BF50}
  87.  cmp ax,$1954; jne @FAIL; mov maxFunct,bl; mov fossilVersion,bh; jmp @X;
  88. @FAIL: xor ax,ax;
  89. @X:
  90.  end;
  91.  
  92. procedure close;assembler;asm
  93.  mov dx,curPort; mov ah,5; int $14;  {doesn't change DTR}
  94.  end;
  95.  
  96. function dtr(b:byte):boolean;assembler;asm
  97.  mov dx,curPort; mov al,b; mov ah,6; int $14; {returns current DTR setting}
  98.  end;
  99.  
  100. procedure flushOut;assembler;asm
  101.  mov dx,curPort; mov ah,8; int $14;
  102.  end;
  103.  
  104. procedure purgeOut;assembler;asm
  105.  mov dx,curPort; mov ah,9; int $14;
  106.  end;
  107.  
  108. procedure purgeIn;assembler;asm
  109.  mov dx,curPort; mov ah,$A; int $14;
  110.  end;
  111.  
  112. function next:char;assembler;asm {returns pending char, or #0 if none}
  113.  mov dx,curPort; mov ah,$C; int $14; {doesn't remove from buffer!!}
  114.  not ah; and al,ah; {if ax=$FF(no char) then set al=0}
  115.  end;
  116.  
  117. procedure flow(f:byte);assembler;asm
  118.  mov dx,curPort; mov al,f; mov ah,$F; int $14;
  119.  end;
  120.  
  121. procedure xmit(b:boolean);assembler;asm  {enable/disable transmitting}
  122.  mov dx,curPort; mov al,b; or al,al; jz @S; mov al,2; @S:
  123.  mov ah,$10; int $14;
  124.  end;
  125.  
  126. function watch(p:hook;add:boolean):boolean;assembler;asm {insert/delete timer t
  127.  les dx,p; mov al,add; or al,al; jz @S; mov al,1; @S:
  128.  mov ah,$16; int $14;  {returns 0 if success, $FFFF if not}
  129.  xor ax,ax; {fix boolean so true means success}
  130.  end;
  131.  
  132. function readBlock(var b;n:word):word;assembler;asm {won't wait for chars to be
  133.  mov dx,curPort; les di,b; mov cx,n; mov ah,$18; int $14; {returns chars read}
  134.  end;
  135.  
  136. function writeBlock(var b;n:word):word;assembler;asm {will only send as many as
  137.  mov dx,curPort; les di,b; mov cx,n; mov ah,$19; int $14; {returns chars sent}
  138.  end;
  139.  
  140. procedure break(b:boolean);assembler;asm {start/stop sending break}
  141.  mov dx,curPort; mov al,b; or al,al; jz @S; mov al,1; @S:
  142.  mov ah,$1A; int $14;
  143.  end;
  144.  
  145. end.