/* ------------------------------------------- * Rountines to interface between internal and * external notions of what the settings are * -------------------------------------------- */ # include "su1hdr.h" /* Micro Decision specific offsets * ------------------------------- */ # define HIGHBYTE 0xFF00 # define BIOS 0xF200 # define RAMDATY 0x42 /* offsets from ramdaty * -------------------- */ # define CBAUDOFF (-6) # define PBAUDOFF (-5) # define OLDDFLAG (11) # define NEWDFLAG (0x12) /* bits * ---- */ # define HARDBIT (1 << 4) # define CENTBIT (1 << 5) /* revision numbers * ---------------- */ # define MINIMUM 0x20 /* minimum acceptable rev. level */ # define MD11 0x40 # define REVISION (bios [0x3f]) /* REV byte */ /* # define SET 0x52 */ static unsigned dflag = 0; /* block attempts to use with old versions of the system * ----------------------------------------------------- */ sysinit () { findsys (); version (); } /* determine the memory address of the BIOS in memory * -------------------------------------------------- */ findsys () { unsigned *i; i = 1; bios = *i & HIGHBYTE; i = bios + RAMDATY; ramdaty = *i; } version () { if (REVISION < MINIMUM) fatal ("Old version of CP/M\r\n$"); if (REVISION >= MD11) dflag = NEWDFLAG; else dflag = OLDDFLAG; } /* read the settings (always from the currently running bios) * ---------------------------------------------------------- */ readsettings () { cbaud = ramdaty [CBAUDOFF] % NBAUD; pbaud = ramdaty [PBAUDOFF] % NBAUD; if (ramdaty [dflag] & CENTBIT) ptype = CENTRONICS; else ptype = SERIAL; if (ramdaty [dflag] & HARDBIT) protocol = HARDHAND; else protocol = XONXOFF; } writesettings (a) unsigned char *a; { a [CBAUDOFF] = cbaud; a [PBAUDOFF] = pbaud; a [dflag] &= ~(CENTBIT | HARDBIT); if (protocol == HARDHAND) a [dflag] |= HARDBIT; if (ptype == CENTRONICS) a [dflag] |= CENTBIT; } softset () { writesettings (ramdaty); bioset (); /* call the bios to have appropriate settings made */ } hardset () { biosread (); writesettings (ramdaty + (unsigned) biosbuf - (unsigned) bios); bioswrite (); } /* Block I/O routines for the Micro Decision * ----------------------------------------- */ static spt = 0; # define DRIVE0 0 # define NBIOSREC 20 # define BIOSFIRST 53 # define CSELECT 14 # define CGETPARM 31 biosread () { static char *p; static s, n; spt = findspt (); p = biosbuf; s = BIOSFIRST; for (n = 0; n < NBIOSREC; n++, p += RECSIZE, s++) if (lio (READ, p, s)) fatal ("Can't read bios\n$"); } bioswrite () { static char *p; static s, n; p = biosbuf; s = BIOSFIRST; for (n = 0; n < NBIOSREC; n++, p += RECSIZE, s++) if (lio (WRITE, p, s, n == NBIOSREC - 1)) fatal ("Can't write bios\n$"); } lio (op, addr, sector, last) char *addr; { int t, s; sector--; t = sector / spt; s = sector % spt + 1; return sio (op, addr, t, s, last); } sio (op, addr, track, sector, last) { static char selected [5] = {NO}; callbios (SETDRV, DRIVE0, selected[DRIVE0]); selected[DRIVE0] = YES; callbios (SETTRK, track, 0); callbios (SETSEC, sector, 0); callbios (SETDMA, addr, 0); if (op == READ) return callbios (BIORED, 0, 0); else return callbios (BIOWRT, last, 0); } fatal (a) char *a; { prs (a); exit (NO); }