home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 2 BBS
/
02-BBS.zip
/
MXMS_160.LZH
/
FOSSIL.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-06-17
|
4KB
|
188 lines
/****************************************************************************/
/* */
/* Fossil.c :Fossil routines for MaxMail */
/* */
/****************************************************************************/
#include "MaxMail.h"
#include <Bios.h>
/* Higher level fossil routines */
union REGS r;
struct SREGS sr;
/* Initialize fossil */
int FossilInit(void)
{
r.h.ah = 0x4;
r.x.dx = prm.com_port;
r.x.bx = 0;
/* r.x.cx = FP_OFF(&break_flag);
sr.es = FP_SEG(&break_flag); */
int86x(0x14,&r,&r,&sr); /* Call Fossil */
if (0x1954 != r.x.ax)
return FALSE;
else if (r.h.bl < 0x18 || r.h.bh < 5){
logit("Level 5 FOSSIL req'd",'!');
return FALSE;
}
else {
r.h.ah = 0x0f;
r.h.al = (byte) prm.handshake_mask;
r.x.dx = prm.com_port;
int86x(0x14,&r,&r,&sr); /* Call Fossil */
return TRUE;
}
}
/* De-initialize fossil */
void FossilDeInit(void)
{
r.h.ah = 0x5;
r.x.dx = prm.com_port;
int86(0x14,&r,&r); /* Call Fossil */
}
/* Purge Fossil buffer. If Mode is TRUE, purge input buffer, FALSE
purge outout buffer */
void FossPurgeBuff(int mode)
{
r.x.dx = prm.com_port;
if (mode) { /* purge input buffer */
r.h.ah = 0x0a;
int86(0x14,&r,&r); /* Call Fossil */
}
else { /* Purge output buffer */
r.h.ah = 0x09;
int86(0x14,&r,&r); /* Call Fossil */
}
/* Turn on break */
FossBreak(10);
delay_s(1);
}
void FossFlow(byte mask)
{
r.x.dx = prm.com_port;
r.h.al = mask;
r.h.ah = 0x0f;
int86(0x14,&r,&r); /* Call Fossil */
}
/* Toggle DTR, if mode = TRUE, raise DTR. If mode = FALSE lower DTR */
void FossDtr(int mode)
{
r.x.dx = prm.com_port;
r.h.ah = 0x06;
r.h.al = (byte) mode;
int86(0x14,&r,&r); /* Call Fossil */
}
unsigned FossMdmStatus(void)
{
int x;
x = prm.com_port;
_asm {
mov ah,03
mov dx,x
int 14h
mov x,ax
}
return(x);
}
/* Return a keystroke. Check local keyboard first, then fossil */
unsigned FossGetCh(void)
{
if (_bios_keybrd(_KEYBRD_READY)) { /* Local keyboard has priority */
return(_bios_keybrd(_KEYBRD_READ));
}
r.x.dx = prm.com_port;
r.h.ah = 0x0c; /* Non destructive fossil read-ahead */
int86(0x14,&r,&r); /* Call Fossil */
if (r.x.ax != 0xffff) {
r.x.dx = prm.com_port;
r.h.ah = 0x02; /* Read fossil char with wait */
int86(0x14,&r,&r); /* Call Fossil */
}
return(r.x.ax);
}
/* Transmit a character to fossil with wait */
void FossSendCh(byte chr)
{
_asm {
mov bx, OFFSET prm
mov dx,[bx]prm.com_port
mov al,chr
mov ah,1
int 14h
}
}
/* Transmit a string to fossil with wait */
void FossSendStr(char *strng)
{
if (IsLocal)
return;
_asm {
mov bx, OFFSET prm
mov dx,[bx]prm.com_port
mov si,strng
strstart:
lodsb
cmp al,0
je strret
mov ah,1
int 14h
jmp strstart
strret:
}
}
void FossBreak(int tsecs)
{
if (prm.flags & FLAG_break_clr) {
r.x.dx = prm.com_port;
r.h.ah = 0x1a;
r.h.al = 1; /* Send break */
int86(0x14,&r,&r); /* Call Fossil */
delay_ms(100 * tsecs);
r.x.dx = prm.com_port;
r.h.ah = 0x1a;
r.h.al = 0; /* Stop break */
int86(0x14,&r,&r); /* Call Fossil */
}
}