gaertner@fauern.UUCP (04/03/87)
Re: Compiling MicroEMACS 3.8b with MSC 4.0 on IBM-XT recently postel!gerk writes: "Has anyone succeeded in compiling the sources for micro-emacs release 3.8b ..... with MSC 4.0 ?" I made some minor changes to MicroEMACS 3.8b to run it on a PC ( and compile it with MSC ) a) changes for the ibm pc ibmpc.c: - made scadd, scptr and sline static (I hate global variables) - modified scwrite() to use a register pointer - don't use a 0 attribute on clear screen this caused some characters to be invisible in the message line spawn.c: - allow spawncli if MSDOS & MSC are set - goto term.t_line instead of term.t_nrow-1 on all spawns, the status line won't get clobbered termio.c: - enabled call to kbhit() in typahead() for MSC display.c: - corrected possible transmission error main.c: - added lower_file() to ensure lower case filenames because ?setargv delivers all file names in upper case, which confuses CMODE and me efunc.h: - corrected possible transmission error - added scroll-next-up and scroll-next-down (possible transmission error) estruct.h: - enabled MSC, disabled AZTEC & COLOR b) the following changes are only for possible performance improvement: file.c: - removed call to strlen(), ffgetline() returns nbytes instead - removed call to strlen(), to check if a filename is long enough for the checking for CMODE use "if ( *fname && fname[1] )" instead fileio.c: - ffgetline() now returns the number of bytes read ffgetline(buf, nbuf, &nbytes) - use getc and putc instead of fgetc and fputc because macros should be faster than function calls c) Some other changes: termio.c: - setbuf() for UNIX ( not only BSD ) in ttopen() basic.c: - usage of register curWp instead of global pointer curwp display.c: - usage of register curWp instead of global pointer curwp window.c: - usage of register curWp instead of global pointer curwp ----------------------------------------------------------------------------- I'll add ibmpc.c and diffs of the changes to other files noted in a). I hope the diffs will help. unido!fauern!gaertner PS: compile it in the large memory model. MicroEMACS 3.7 did fit into the compact model(small program and large data), but 3.8b doesn't with all features (CRYPT etc.) enabled. Changes to spawn.c: ----------------------------------------------------------------------------- diffh spawn.c orig/spawn.c 4,10d3 < /* < * Modification History < * < * 20. Mar 1987 Gae < * - allow spawncli if MSDOS & MSC are set < * - goto term.t_line instead of term.t_nrow-1 on spawn < */ 96,97c89 < /* Gae #if MSDOS & AZTEC *Gae*/ < #if MSDOS & ( AZTEC | MSC ) --- > #if MSDOS & AZTEC 269,273c261 < #if ORIG /*Gae*/ < movecursor(term.t_nrow - 1, 0); < #else /* ORIG */ /*Gae*/ < movecursor(term.t_nrow, 0); /*Gae*/ < #endif /* ORIG */ /*Gae*/ --- > movecursor(term.t_nrow - 1, 0); 379,383c367 < #if ORIG /*Gae*/ < movecursor(term.t_nrow - 1, 0); < #else /* ORIG */ /*Gae*/ < movecursor(term.t_nrow, 0); /*Gae*/ < #endif /* ORIG */ /*Gae*/ --- > movecursor(term.t_nrow - 1, 0); 496,500c480 < #if ORIG /*Gae*/ < movecursor(term.t_nrow - 1, 0); < #else /* ORIG */ /*Gae*/ < movecursor(term.t_nrow, 0); /*Gae*/ < #endif /* ORIG */ /*Gae*/ --- > movecursor(term.t_nrow - 1, 0); ----------------------------------------------------------------------------- End of changes to spawn.c Changes to efunc.h: ----------------------------------------------------------------------------- diffh efunc.h orig/efunc.h 356,359c356 < {"save-window", savewnd}, < {"scroll-next-up", scrnextup}, < {"scroll-next-down", scrnextdw}, < {"search-forward", forwsearch}, --- > {"save-window", savewnd}X {"search-forward", forwsearch}, ----------------------------------------------------------------------------- End of changes to efunc.h Changes to termio.c: ----------------------------------------------------------------------------- diffh termio.c orig/termio.c 6,16d5 < < /* < * Modification History: < * < * 86-9-21 Lutz < * - setbuf() fuer UNIX in ttopen() < * 21. Mar 1987 Gae < * - enabled call to kbhit() in typahead() for MSC < * 25. Mar 1987 Gae < * - added rdchk() for XENIX < */ 94,95d82 < #else /* 86-9-21 Lutz */ < char tobuf[BUFSIZ]; /* terminal output buffer */ /* 86-9-21 Lutz */ 191,192d177 < #else /* 86-9-21 Lutz */ < setbuf(stdout, &tobuf[0] ); /* 86-9-21 Lutz */ 440,442c425,429 < #if MSDOS /*Gae*/ < < #if MSC /*Gae*/ --- > #if MSDOS & (LATTICE | AZTEC | MWC86) > int c; /* character read */ > int flags; /* cpu flags from dos call */ > > #if MSC 447,452c434 < #endif /* MSC */ /*Gae*/ < < #if (LATTICE | AZTEC | MWC86) /*Gae*/ < int c; /* character read */ < int flags; /* cpu flags from dos call */ < --- > #endif 474,475c456 < #endif /* (LATTICE | AZTEC | MWC86) */ /*Gae*/ < #endif /* MSDOS */ /*Gae*/ --- > #endif 482,$c463,$ < #if XENIX /*Gae*/ < return( rdchk(0) > 0 ); /*Gae*/ < #endif /* XENIX */ /*Gae*/ < < return(FALSE); < } < #endif < --- > return(FALSE); > } > #endif > ----------------------------------------------------------------------------- End of changes to termio.c Changes to main.c: ----------------------------------------------------------------------------- diffh main.c orig/main.c 555,559c555 < * < * 22-mar-87 Gae < * - added lower_file to ensure lower case filenames < */ < --- > */ 604,607d599 < #if MSDOS & MSC /*Gae*/ < static lower_file(); /*Gae*/ < #endif /* MSDOS & MSC */ /*Gae*/ < 714,716d705 < #if MSDOS & MSC /*Gae*/ < lower_file(argv[carg]); /*Gae*/ < #endif /* MSDOS & MSC */ /*Gae*/ 1235,$d1223 < /**Gae*/ < #if MSDOS & MSC < static lower_file(name) /* convert a filename to lower case */ < register char *name; < { < for( ; *name ; name++ ) < if( *name >= 'A' && *name <= 'Z' ) < *name += 'a' - 'A'; < } < #endif /* MSDOS & MSC */ < /*Gae**/ < ----------------------------------------------------------------------------- End of changes to main.c Changes to display.c: ----------------------------------------------------------------------------- 782,783c774 < vtputc(lchar); < --- > vtputc(lchaX ----------------------------------------------------------------------------- End of changes to display.c Start of ibmpc.c ----------------------------------------------------------------------------- /* * The routines in this file provide support for the IBM-PC and other * compatible terminals. It goes directly to the graphics RAM to do * screen output. It compiles into nothing if not an IBM-PC driver */ /* * Modification History: * * 21. Mar 1987 Gae * - made scadd, scptr and sline static * - modified scwrite() to use register pointers * - don't use a 0 attribute on clear screen */ #define termdef 1 /* don't define "term" external */ #include <stdio.h> #include "estruct.h" #include "edef.h" #if IBMPC #define NROW 25 /* Screen size. */ #define NCOL 80 /* Edit if you want to. */ #define MARGIN 8 /* size of minimim margin and */ #define SCRSIZ 64 /* scroll size for extended lines */ #define NPAUSE 200 /* # times thru update to pause */ #define BEL 0x07 /* BEL character. */ #define ESC 0x1B /* ESC character. */ #define SPACE 32 /* space character */ #define SCADC 0xb8000000L /* CGA address of screen RAM */ #define SCADM 0xb0000000L /* MONO address of screen RAM */ #define CDCGA 0 /* color graphics card */ #define CDMONO 1 /* monochrome text card */ #define CDSENSE 9 /* detect the card type */ int dtype = CDCGA; /* current display type */ static long scadd; /* address of screen ram */ static int *scptr[NROW]; /* pointer to screen lines */ static int sline[NCOL]; /* screen line image */ extern union REGS rg; /* cpu register for use of DOS calls */ extern int ttopen(); /* Forward references. */ extern int ttgetc(); extern int ttputc(); extern int ttflush(); extern int ttclose(); extern int ibmmove(); extern int ibmeeol(); extern int ibmeeop(); extern int ibmbeep(); extern int ibmopen(); extern int ibmrev(); extern int ibmcres(); extern int ibmclose(); extern int ibmputc(); extern int ibmkopen(); extern int ibmkclose(); #if COLOR extern int ibmfcol(); extern int ibmbcol(); int cfcolor = -1; /* current forground color */ int cbcolor = -1; /* current background color */ int ctrans[] = /* ansi to ibm color translation table */ {0, 4, 2, 6, 1, 5, 3, 7}; #endif /* * Standard terminal interface dispatch table. Most of the fields point into * "termio" code. */ TERM term = { NROW-1, NROW-1, NCOL, NCOL, MARGIN, SCRSIZ, NPAUSE, ibmopen, ibmclose, ibmkopen, ibmkclose, ttgetc, ibmputc, ttflush, ibmmove, ibmeeol, ibmeeop, ibmbeep, ibmrev, ibmcres #if COLOR , ibmfcol, ibmbcol #endif }; extern union REGS rg; #if COLOR ibmfcol(color) /* set the current output color */ int color; /* color to set */ { cfcolor = ctrans[color]; } ibmbcol(color) /* set the current background color */ int color; /* color to set */ { cbcolor = ctrans[color]; } #endif ibmmove(row, col) { rg.h.ah = 2; /* set cursor position function code */ rg.h.dl = col; rg.h.dh = row; rg.h.bh = 0; /* set screen page number */ int86(0x10, &rg, &rg); } ibmeeol() /* erase to the end of the line */ { int attr; /* attribute byte mask to place in RAM */ register int *lnptr; /* pointer to the destination line */ int i; int ccol; /* current column cursor lives */ int crow; /* row */ /* find the current cursor position */ rg.h.ah = 3; /* read cursor position function code */ rg.h.bh = 0; /* current video page */ int86(0x10, &rg, &rg); ccol = rg.h.dl; /* record current column */ crow = rg.h.dh; /* and row */ /* build the attribute byte and setup the screen pointer */ #if COLOR if (dtype == CDCGA) attr = (((cbcolor & 15) << 4) | (cfcolor & 15)) << 8; else attr = 0x0700; #else attr = 0x0700; #endif lnptr = &sline[0]; for (i=0; i < term.t_ncol; i++) *lnptr++ = SPACE | attr; if (flickcode) { /* wait for vertical retrace to be off */ while ((inp(0x3da) & 8)) ; /* and to be back on */ while ((inp(0x3da) & 8) == 0) ; } /* and send the string out */ movmem(&sline[0], scptr[crow]+ccol, (term.t_ncol-ccol)*2); } ibmputc(ch) /* put a character at the current position in the current colors */ int ch; { rg.h.ah = 14; /* write char to screen with current attrs */ rg.h.al = ch; #if COLOR if (dtype == CDCGA) rg.h.bl = cfcolor; else rg.h.bl = 0x07; #else rg.h.bl = 0x07; #endif int86(0x10, &rg, &rg); } ibmeeop() { int attr; /* attribute to fill screen with */ rg.h.ah = 6; /* scroll page up function code */ rg.h.al = 0; /* # lines to scroll (clear it) */ rg.x.cx = 0; /* upper left corner of scroll */ rg.x.dx = 0x184f; /* lower right corner of scroll */ #if COLOR if (dtype == CDCGA) attr = ((ctrans[gbcolor] & 15) << 4) | (ctrans[gfcolor] & 15); else #if ORIG /*Gae*/ attr = 0; #else /* ORIG */ /*Gae*/ attr = 0x07; /*Gae*/ #endif /* ORIG */ /*Gae*/ #else #if ORIG /*Gae*/ attr = 0; #else /* ORIG */ /*Gae*/ attr = 0x07; /*Gae*/ #endif /* ORIG */ /*Gae*/ #endif rg.h.bh = attr; int86(0x10, &rg, &rg); } ibmrev(state) /* change reverse video state */ int state; /* TRUE = reverse, FALSE = normal */ { /* This never gets used under the IBM-PC driver */ } ibmcres(res) /* change screen resolution */ char *res; /* resolution to change to */ { if (strcmp(res, "CGA") == 0) { scinit(CDCGA); return(TRUE); } else if (strcmp(res, "MONO") == 0) { scinit(CDMONO); return(TRUE); } else return(FALSE); } ibmbeep() { #if MWC86 putcnb(BEL); #else bdos(6, BEL, 0); #endif } ibmopen() { scinit(CDSENSE); revexist = TRUE; ttopen(); } ibmclose() { #if COLOR ibmfcol(7); ibmbcol(0); #endif ttclose(); } ibmkopen() /* open the keyboard */ { } ibmkclose() /* close the keyboard */ { } scinit(type) /* initialize the screen head pointers */ int type; /* type of adapter to init for */ { union { long laddr; /* long form of address */ int *paddr; /* pointer form of address */ } addr; int i; /* if asked...find out what display is connected */ int86(0x11, &rg, &rg); dtype = CDCGA; scadd = SCADC; strcpy(sres, "CGA"); if ((((rg.x.ax >> 4) & 11) == 3) || type == CDMONO) { strcpy(sres, "MONO"); dtype = CDMONO; scadd = SCADM; } /* initialize the screen pointer array */ for (i = 0; i < NROW; i++) { addr.laddr = scadd + (long)(NCOL * i * 2); scptr[i] = addr.paddr; } } scwrite(row, outstr, forg, bacg) /* write a line out*/ int row; /* row of screen to place outstr on */ register unsigned char *outstr; /* string to write out (must be term.t_ncol long) */ int forg; /* forground color of string to write */ int bacg; /* background color */ { int attr; /* attribute byte mask to place in RAM */ register int *lnptr; /* pointer to the destination line */ int i; /* build the attribute byte and setup the screen pointer */ #if COLOR if (dtype == CDCGA) attr = (((ctrans[bacg] & 15) << 4) | (ctrans[forg] & 15)) << 8; else attr = (((bacg & 15) << 4) | (forg & 15)) << 8; #else attr = (((bacg & 15) << 4) | (forg & 15)) << 8; #endif #if ORIG /*Gae*/ lnptr = &sline[0]; for (i=0; i<term.t_ncol; i++) *lnptr++ = (outstr[i] & 255) | attr; #else /* ORIG */ /*Gae*/ for( lnptr = sline ; lnptr < &(sline[NCOL]) ; ) /*Gae*/ *lnptr++ = *outstr++ | attr; #endif /* ORIG */ /*Gae*/ if (flickcode) { /* wait for vertical retrace to be off */ while ((inp(0x3da) & 8)) ; /* and to be back on */ while ((inp(0x3da) & 8) == 0) ; } /* and send the string out */ movmem(&sline[0], scptr[row],term.t_ncol*2); } #if FLABEL fnclabel(f, n) /* label a function key */ int f,n; /* default flag, numeric argument [unused] */ { /* on machines with no function keys...don't bother */ return(TRUE); } #endif #else ibmhello() { } #endif ------------------------------------------------------------------------------ End of ibmpc.c