Skip to content
Snippets Groups Projects
Commit 18bcbeb7 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Fix some FOSSIL functions

Function 0Ch (peek) never worked correctly (character was not returned in AX); I guess nothing uses this function (?).

Function 01h (transmit char w/wait) now will set the timeout flag (0x8000) in the AX if the VDD_WRITE function fails (returns value other than 1).

Optimize Function 18h (read block) - no need for the extra VDD_STATUS call.

Use newly defined FOSSIL macros instead of magic numbers of port status bits.

Log the git branch/hash values to the Windows debug log (via sbbsexec.dll).
parent 48874e1e
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #2498 passed
...@@ -191,26 +191,26 @@ void vdd_getstatus(vdd_status_t* status) ...@@ -191,26 +191,26 @@ void vdd_getstatus(vdd_status_t* status)
WORD PortStatus() WORD PortStatus()
{ {
WORD status=0x0008; /* AL bit 3 (change in DCD) always set */ WORD status=FOSSIL_MDM_STATUS_DCD_CHNG; /* AL bit 3 (change in DCD) always set */
vdd_status_t vdd_status; vdd_status_t vdd_status;
vdd_getstatus(&vdd_status); vdd_getstatus(&vdd_status);
if(vdd_status.online) /* carrier detect */ if(vdd_status.online) /* carrier detect */
status|=0x0080; /* DCD */ status|=FOSSIL_MDM_STATUS_DCD;
if(vdd_status.inbuf_full) /* receive data ready */ if(vdd_status.inbuf_full) /* receive data ready */
status|=0x0100; /* RDA */ status|=FOSSIL_LINE_STATUS_RDA;
/* if(vm->overrun) /* overrun error detected */ /* if(vm->overrun) /* overrun error detected */
/* status|=0x0200; /* OVRN */ /* status|=0x0200; /* OVRN */
if(vdd_status.outbuf_full if(vdd_status.outbuf_full
<vdd_status.outbuf_size/2) /* room available in output buffer */ <vdd_status.outbuf_size/2) /* room available in output buffer */
status|=0x2000; /* THRE */ status|=FOSSIL_LINE_STATUS_THRE;
if(!vdd_status.outbuf_full) /* output buffer is empty */ if(!vdd_status.outbuf_full) /* output buffer is empty */
status|=0x4000; /* TSRE */ status|=FOSSIL_LINE_STATUS_TSRE;
return(status); return(status);
} }
...@@ -256,6 +256,7 @@ void interrupt winNTint14( ...@@ -256,6 +256,7 @@ void interrupt winNTint14(
BYTE ch; BYTE ch;
BYTE far* p; BYTE far* p;
WORD buf_seg; WORD buf_seg;
int rd;
int wr; int wr;
vdd_status_t vdd_status; vdd_status_t vdd_status;
fossil_info_t info = { fossil_info_t info = {
...@@ -288,22 +289,23 @@ void interrupt winNTint14( ...@@ -288,22 +289,23 @@ void interrupt winNTint14(
case FOSSIL_FUNC_PUT_CHAR: /* write char to com port, with wait */ case FOSSIL_FUNC_PUT_CHAR: /* write char to com port, with wait */
ch=_ax&0xff; ch=_ax&0xff;
_asm mov buf_seg, ss; _asm mov buf_seg, ss;
vdd_buf(VDD_WRITE, 1, buf_seg, (WORD)&ch); wr = vdd_buf(VDD_WRITE, 1, buf_seg, (WORD)&ch);
_ax = PortStatus(); _ax = PortStatus();
if(wr != 1)
_ax |= FOSSIL_LINE_STATUS_TIMEOUT;
break; break;
case FOSSIL_FUNC_GET_CHAR: /* read char from com port, with wait */ case FOSSIL_FUNC_GET_CHAR: /* read char from com port, with wait */
_asm mov buf_seg, ss; _asm mov buf_seg, ss;
_ax = vdd_buf(VDD_READ, 1, buf_seg, (WORD)&ch); rd = vdd_buf(VDD_READ, 1, buf_seg, (WORD)&ch);
if(!_ax) { _ax = ch;
_ax = 0x8000; /* timed-out */ if(rd != 1) {
vdd_op(VDD_YIELD); vdd_op(VDD_YIELD);
} else { _ax = FOSSIL_LINE_STATUS_TIMEOUT;
_ax = ch;
} }
break; break;
case FOSSIL_FUNC_GET_STATUS: /* request status */ case FOSSIL_FUNC_GET_STATUS: /* request status */
_ax=PortStatus(); _ax=PortStatus();
if(_ax==0x6088) if(_ax == FOSSIL_MDM_STATUS_DCD_CHNG | FOSSIL_MDM_STATUS_DCD | FOSSIL_LINE_STATUS_THRE | FOSSIL_LINE_STATUS_TSRE)
vdd_op(VDD_MAYBE_YIELD); vdd_op(VDD_MAYBE_YIELD);
break; break;
case FOSSIL_FUNC_INIT: /* initialize */ case FOSSIL_FUNC_INIT: /* initialize */
...@@ -323,32 +325,23 @@ void interrupt winNTint14( ...@@ -323,32 +325,23 @@ void interrupt winNTint14(
vdd_op(VDD_INBUF_PURGE); vdd_op(VDD_INBUF_PURGE);
break; break;
case FOSSIL_FUNC_WRITE_CHAR: /* write char to com port, no wait */ case FOSSIL_FUNC_WRITE_CHAR: /* write char to com port, no wait */
if(0 /*RingBufFree(&vm->out)<2 */) {
_ax=0; /* char was not accepted */
break;
}
ch=_ax&0xff; ch=_ax&0xff;
_asm mov buf_seg, ss; _asm mov buf_seg, ss;
_ax = vdd_buf(VDD_WRITE, 1, buf_seg, (WORD)&ch); _ax = vdd_buf(VDD_WRITE, 1, buf_seg, (WORD)&ch);
if(_ax != 1)
vdd_op(VDD_YIELD);
break; break;
case FOSSIL_FUNC_PEEK: /* non-destructive read-ahead */ case FOSSIL_FUNC_PEEK: /* non-destructive read-ahead */
vdd_getstatus(&vdd_status);
if(!vdd_status.inbuf_full) {
_ax=0xffff; /* no char available */
vdd_op(VDD_YIELD);
break;
}
_asm mov buf_seg, ss; _asm mov buf_seg, ss;
_ax = vdd_buf(VDD_PEEK, 1, buf_seg, (WORD)&ch); rd = vdd_buf(VDD_PEEK, 1, buf_seg, (WORD)&ch);
if(_ax == 0) _ax = ch;
if(rd == 0) {
vdd_op(VDD_YIELD); vdd_op(VDD_YIELD);
_ax = FOSSIL_CHAR_NOT_AVAILABLE;
}
break; break;
case FOSSIL_FUNC_READ_BLOCK: /* read block, no wait */ case FOSSIL_FUNC_READ_BLOCK: /* read block, no wait */
vdd_getstatus(&vdd_status); _ax = vdd_buf(VDD_READ, _cx, _es, _di);
if(!vdd_status.inbuf_full)
_ax = 0; /* no data available */
else
_ax = vdd_buf(VDD_READ, _cx, _es, _di);
if(_ax == 0) if(_ax == 0)
vdd_op(VDD_YIELD); vdd_op(VDD_YIELD);
break; break;
...@@ -374,7 +367,7 @@ void interrupt winNTint14( ...@@ -374,7 +367,7 @@ void interrupt winNTint14(
_ax=wr; _ax=wr;
break; break;
case FOSSIL_FUNC_GET_KB: case FOSSIL_FUNC_GET_KB:
_ax=0xffff; _ax = FOSSIL_CHAR_NOT_AVAILABLE;
break; break;
} }
} }
...@@ -625,7 +618,7 @@ int main(int argc, char **argv) ...@@ -625,7 +618,7 @@ int main(int argc, char **argv)
vdd_str(VDD_LOAD_INI_SECTION, getfname(arg[0])); vdd_str(VDD_LOAD_INI_SECTION, getfname(arg[0]));
sprintf(str,"%s, rev %u, %s %s mode=%u", __FILE__, DOSXTRN_REVISION, __DATE__, __TIME__, mode); sprintf(str,"%s, rev %u %s/%s, %s %s mode=%u", __FILE__, DOSXTRN_REVISION, GIT_BRANCH, GIT_HASH, __DATE__, __TIME__, mode);
vdd_str(VDD_DEBUG_OUTPUT, str); vdd_str(VDD_DEBUG_OUTPUT, str);
i=vdd_op(VDD_OPEN); i=vdd_op(VDD_OPEN);
...@@ -685,7 +678,7 @@ int main(int argc, char **argv) ...@@ -685,7 +678,7 @@ int main(int argc, char **argv)
#ifdef DEBUG_DOS_CALLS #ifdef DEBUG_DOS_CALLS
for(i=0;i<0x100;i++) { for(i=0;i<0x100;i++) {
if(dos_calls[i]>100) { if(dos_calls[i]>100) {
sprintf(str,"int21h function %02X calls: %u\n" sprintf(str,"int21h function %02X calls: %u"
,i, dos_calls[i]); ,i, dos_calls[i]);
vdd_str(VDD_DEBUG_OUTPUT, str); vdd_str(VDD_DEBUG_OUTPUT, str);
} }
......
/* fossdefs.h */
/* FOSSIL (FSC-15) structure and constant definitions */ /* FOSSIL (FSC-15) structure and constant definitions */
/* $Id: fossdefs.h,v 1.3 2018/07/24 01:11:07 rswindell Exp $ */
/**************************************************************************** /****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
...@@ -122,6 +118,23 @@ unsigned fossil_stop_bits[] = { 1, 2 }; ...@@ -122,6 +118,23 @@ unsigned fossil_stop_bits[] = { 1, 2 };
unsigned fossil_data_bits[] = { 5, 6, 7, 8 }; unsigned fossil_data_bits[] = { 5, 6, 7, 8 };
#define FOSSIL_MDM_STATUS_CTS_CHNG (1<<0) // Delta clear to send (not reliable)
#define FOSSIL_MDM_STATUS_DSR_CHNG (1<<1) // Delta data set ready (not reliable)
#define FOSSIL_MDM_STATUS_RI_CHNG (1<<2) // trailing edge of ring indicator (documented wrong in X00REF.DOC)
#define FOSSIL_MDM_STATUS_DCD_CHNG (1<<3) // Delta data carrier detect
#define FOSSIL_MDM_STATUS_CTS (1<<4) // Clear to send
#define FOSSIL_MDM_STATUS_DSR (1<<5) // Data set ready
#define FOSSIL_MDM_STATUS_RI (1<<6) // Ring indicator
#define FOSSIL_MDM_STATUS_DCD (1<<7) // Data carrier detect
#define FOSSIL_LINE_STATUS_RDA (1<<8) // input data is available in buffer
#define FOSSIL_LINE_STATUS_OVRN (1<<9) // the input buffer has been overrun
#define FOSSIL_LINE_STATUS_THRE (1<<13) // room is available in output buffer
#define FOSSIL_LINE_STATUS_TSRE (1<<14) // output buffer is empty
#define FOSSIL_LINE_STATUS_TIMEOUT (1<<15) // Timeout (set by functions 1 and 2 only)
#define FOSSIL_CHAR_NOT_AVAILABLE 0xffff
#if defined(__GNUC__) #if defined(__GNUC__)
#define PACKED_STRUCT __attribute__((packed)) #define PACKED_STRUCT __attribute__((packed))
#else /* non-GCC compiler */ #else /* non-GCC compiler */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment