// Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator
// From input file "/var/home/pantec/src/turbo/ucdas/rs232b.p"


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//    rs232-unit using PC-Bios
//
//_____________________________________________________


//$DEFINE TRUEBIOS


#include <p2c/p2c.h>


#define RS232B_G
#include "/software/include/p2c/rs232b.h"


unsigned short BaseAddr = 0x3f8;
unsigned short StatusAddr = 0x3fd;
unsigned short TimeOut = 5;
boolean HandShake = true;
boolean XONOFF = false;
boolean XCtrl = true;
unsigned short MaxTimeOut = 1000;

#ifndef NCRT_H
#include "/software/include/p2c/ncrt.h"
#endif


void *ExitSave;
uchar PortNr;

boolean Exist;


void SetBaud(unsigned short Baud)
{
  //
  //Port[BaseAddr+3]:=Port[BaseAddr+3] or $80;
  //Port[BaseAddr]  :=lo(Baud);
  //Port[BaseAddr+1]:=hi(Baud);
  //Port[BaseAddr+3]:=Port[BaseAddr+3] and $7f;
  //
}


void SetLocal(uchar Data, uchar Parity, uchar Stop)
{
  //
  //Port[BaseAddr+3]:=((Data-5) or ((Stop-1)shl 2) or (parity shl 3));
  //
}


void Int14Type::CheckError(void)
{
  //
  //if (reg.ah and $80)>0
  //   then begin
  //          LastError:=true;
  //          CommStatus:=reg.ah and $7f;
  //        end
  //   else LastError:=false;
  //
}


void Int14Type::Send(uchar b)
{
  // $IFDEF TRUEBIOS
  //   reg.dx:=PortNr;
  //   reg.al:=b;
  //   reg.ah:=1;
  //   intr($14,reg);
  //   CheckError;
  //   $ELSE
  //   Port[BaseAddr]:=b;
  //   repeat
  //   until (Port[StatusAddr] and $20) >0;
  //  $ENDIF
}


static boolean Exist232(int Prt)
{
  //
  //w:=MemW[0:($400+(2*(Prt)))];
  //if w=0
  //   then Exist232:=false
  //   else begin
  //          Exist232:=true;
  //          BaseAddr:=w;
  //        end;
  //
}



void Int14Type::Init(uchar n, uchar b, uchar d, uchar p, uchar s)
{
  //
  //if not(Exist232(n))
  //   then LastError:=true
  //   else begin
  //          LastError:=false;
  //          StatusAddr:=BaseAddr+5;
  //
  //PortNr:=n;
  //reg.dx:=PortNr;
  //reg.ah:=0;
  //reg.al:=((b and 7) shl 5)  or
  //        ((d-5) and 3)      or
  //        ((p shl 3) and 24) or
  //        ((s-1) shl 2);
  //Intr($14,reg);
  //CommStatus:=reg.ah;
  //
  //end;
  //
}


uchar Int14Type::Receive(void)
{
  // $IFDEF TRUEBIOS
  //   reg.ah:=2;
  //   reg.dx:=PortNr;
  //   intr($14,reg);
  //   CheckError;
  //   Receive:=reg.al
  // $ELSE
  //   if (Port[StatusAddr] and 1)>0
  //      then begin
  //             Receive:=Port[BaseAddr];
  //             LastError:=false;
  //           end
  //      else LastError:=true;
  // $ENDIF
}


uchar Int14Type::Getc(void)
{
  //
  //LastError:=true;
  //while LastError do
  //  Getc:=Receive;
  //
}


unsigned short Int14Type::Status(void)
{
  // $IFDEF TRUEBIOS
  //   reg.ah:=3;
  //   reg.dx:=PortNr;
  //   intr($14,reg);
  //   Status:=reg.ax;
  // $ELSE
  //   w:=Port[StatusAddr];
  //   w:=w shl 8;
  //   w:=w or Port[StatusAddr+1];
  //   Status:=w;
  // $ENDIF
}


void Int14Type::Done(void)
{
}


void ReadPreSet(unsigned short &Baud, uchar &Data, uchar &Parity, uchar &Stop)
{
  //
  //b:=Port[BaseAddr+3];
  //Port[BaseAddr+3]:=b or $80;
  //k:=Port[BaseAddr];
  //l:=Port[BaseAddr+1];
  //Baud:=k + (l * 256);
  //Port[BaseAddr+3]:=b;
  //Data:=(b and 3)+5;
  //Parity:=(b and 24) shr 3;
  //Stop:=((b and 4) shr 2)+1;
  //
}



//$F+
static void Rs232Exit(void)
{
  //
  //ExitProc:=ExitSave;
  //
}



static void InstallPort(uchar nr)
{
  //
  //PortNr      :=Nr;
  //Exist       :=Exist232(PortNr);
  //StatusAddr  :=BaseAddr+5;
  //
}


void InstallRs232Exit(uchar Nr)
{
  //
  //InstallPort(Nr);
  //
  //ExitSave    :=ExitProc;
  //ExitProc    :=@Rs232Exit;
  //
}



void _Rs232B_init(void)
{
  static int _was_initialized = 0;
  if (_was_initialized++)
    return;
}
// p2c: Note: Remember to call _Rs232B_init() in main program [215]







// End.
