/* Rountines to Get and Set the Character Table (22_Jan_84) * -------------------------------------------------------- */ # include "su3hdr.h" /* Offsets in ch_tab * ----------------- */ # define CBAUDOFF 0 /* Console baud rate byte in ch_tab */ # define PBAUDOFF 1 /* Printer baud rate byte in ch_tab */ # define REVISION 9 /* Bios revision byte (clevel) in ch_tab */ # define CFLAG 3 /* CFlag byte copy in ch_tab */ /* Bit definitions for the CFlag byte * ---------------------------------- */ # define HARDBIT (1 << 4) /* Printer hardware handshaking */ # define CENTBIT (1 << 5) /* centronics is list device flag */ /* Compatibility Definitions * ------------------------- */ # define CPMPLUS 0x31 /* Current version of CP/M */ # define MD11ne DRD 33 /* Read record */ # define DWR 34 /* Write record */ # define USERFUN 32 /* Function Call for BDOS */ /* FCB definition * -------------- */ struct fcb { UTINY dr, name [8], type [3], ex, s1, s2; UTINY rc, dn [4]; UCOUNT inumber; UCOUNT device; UTINY ro; /* read only */ TINY fd; /* file descriptor */ UCOUNT nrec; /* no. of recs in the file */ UCOUNT nexts; /* no. of extents */ UCOUNT currec; /* current record number */ /* currec of 0 indicates uncertainty */ UTINY cr, /* filled in by the user */ /* current record to read or write in a sequential file operation */ /* normally set to zero by the user */ rand [3]; }; /* Move the char table into the external array: ch_tab. (20_Jan_84) * ---------------------------------------------------------------- * Check CP/M Rev. and BIOS compatbility. */ char ch_tab[]; load_sys () { extern char ch_tab[]; if (cpm(GETVER) < CPMPLUS) { fatal ("Wrong version of CP/M.\r\nThis copy of SETUP requires CP/M Plus.\r\n$"); } gt_tab(); if (ch_tab[REVISION] < MD11) { fatal ("Wrong revison of CP/M.\r\nThis copy of SETUP requires CP/M Plus revison 1.4 or greater.\r\n$"); } } /* read the settings from ch_tab (20_Jan_84) * ----------------------------------------- */ readsettings () { extern char ch_tab[]; cbaud = ch_tab [CBAUDOFF] % NBAUD; pbaud = ch_tab [PBAUDOFF] % NBAUD; if (ch_tab [CFLAG] & CENTBIT) ptype = CENTRONICS; else ptype = SERIAL; if (ch_tab [CFLAG] & HARDBIT) protocol = HARDHAND; else protocol = XONXOFF; } /* write the settings to ch_tab (20_Jan_84) * ----------------------------------------- */ writesettings (a) char *a; { a [CBAUDOFF] = cba------------------ */ softset () { extern char ch_tab[]; writesettings (ch_tab); /*update ch_tab */ pt_tab (); /* put ch_tab back into the bios */ setctc (); /* call the bios to have appropriate settings made */ } hardset () { # define OFFSET 1 int i, cuser; struct fcb f; unsigned char p0, p1, p2, p3, p5, x; unsigned char *a = "CPM3 SYS"; unsigned char d[128]; for (i = 0; f.name[i] = a[i]; i++) ; f.type[1] = (f.type[1] | 0x80); f.dr = 0; f.cr = 0; cuser = cpm(USERFUN, 0xff); cpm(USERFUN, 0); cpm (DMA, &d); if (cpm (DOPEN, &f) != 0) { cpm(USERFUN, cuser); return NO; } f.rand[0] = f.rand[1] = f.rand[2] = 0; if (cpm (DRD, &f) != 0 ) { cpm(USERFUN, cuser); return NO; } p0 = d[0]; p1 = d[1]; p2 = d[2]; p3 = d[3]; p5 = d[5]; f.rand[0] = (2 * (p0 - p5)) + OFFSET; if (cpm (DRD, &f) != 0 ) { cpm(USERFUN, cuser); return NO; } f.rand[0] = (2 * ( (p2 - d[2]) + p1) ) + OFFSET; if (cpm (DRD, &f) != 0 ) { cpm(USERFUN, cuser); return NO; } writesettings (d + 3); if (cpm(DWR, &f) != 0 ) { cpm(USERFUN, cuser); return NO; } if (cpm(DCLOSE, &f) !=0 ) { cpm(USERFUN, cuser); return NO; } cpm(USERFUN, cuser); return YES; } fatal (a) char *a; { prs (a); exit (NO); }