[comp.emacs] MicroEMACS fix and new IBMPC driver

jsa@kolvi.UUCP (Jari Salminen) (03/21/87)

Here's diffs for MicroEMACS 3.8b to fix some bugs with IBM PC and
a new IBMPC driver which supports monochrome, CGA and EGA cards.

Spawn.c was changed to work correctly with Microsoft C.

Bind.c and main.c were changed to work with IBM 8-bit character set
(European users need them !).

Display.c and ibmpc.c were changed to support EGA in 43-line mode.
Now you can switch between 25- and 43-line modes with following macros:

;;;;;;;;;;;;;;;
; Macros for switching between 25 and 43 line mode with EGA
; 25-line mode
1 store-macro
	set $sres CGA
	delete-other-windows
	clear-and-redraw
!endm

; 43-line mode
2 store-macro
	set $sres EGA
	delete-other-windows
	clear-and-redraw
!endm
;;;;;;;;;;;;;;;

I call my version 3.8g and I hope you'll find these changes useful.

			Enjoy !

Jari Salminen
UUCP:  ..mcvax!kolvi!jsa

------ diff for bind.c follows ----------------------------

*** org/bind.c	Sat Mar 21 00:33:43 1987
--- ./bind.c	Sat Mar 21 00:21:47 1987
***************
*** 182
! 	register int c; 	/* command key to bind */

--- 182 -----
! 	register unsigned int c; 	/* command key to bind */
***************
*** 518,519
! 	register int c; 	/* character fetched */
! 	register char *tp;	/* pointer into the token */

--- 518,519 -----
! 	register unsigned int c;	/* character fetched */
! 	register unsigned char *tp;	/* pointer into the token */
***************
*** 537
! 		if (*tp == 'F' && *(tp+1) == 'N') {

--- 537 -----
! 		else if (*tp == 'F' && *(tp+1) == 'N') {
***************
*** 543
! 		if (*tp == '^' && *(tp+1) == 'X') {

--- 543 -----
! 		else if (*tp == '^' && *(tp+1) == 'X') {
***************
*** 554,556
! 		/* make sure we are not lower case */
! 		if (c >= 'a' && c <= 'z')
! 			c -= 32;

--- 554,556 -----
! 		/* make sure we are not lower case (not with function keys) */
! 		if (*tp >= 'a' && *tp <= 'z' && !(c & SPEC))
! 			*tp -= 32;
***************
*** 558
! 		/* the final sequence... */

--- 558 -----
! 		/* get the character */

------ diff for display.c follows ----------------------------

*** org/display.c	Sat Mar 21 00:34:54 1987
--- ./display.c	Sat Mar 21 00:23:15 1987
***************
*** 55
!     vscreen = (VIDEO **) malloc(term.t_nrow*sizeof(VIDEO *));

--- 55 -----
!     vscreen = (VIDEO **) malloc(term.t_mrow*sizeof(VIDEO *));
***************
*** 61
!     pscreen = (VIDEO **) malloc(term.t_nrow*sizeof(VIDEO *));

--- 61 -----
!     pscreen = (VIDEO **) malloc(term.t_mrow*sizeof(VIDEO *));
***************
*** 67
!     for (i = 0; i < term.t_nrow; ++i)

--- 67 -----
!     for (i = 0; i < term.t_mrow; ++i)

------ diff for ibmpc.c follows ----------------------------

*** org/ibmpc.c	Sat Mar 21 00:32:03 1987
--- ./ibmpc.c	Sat Mar 21 00:23:41 1987
***************
*** 4

--- 5 -----
+  * Supports: IBM Monochrome, IBM CGA and IBM EGA display cards.
***************
*** 14

--- 16,21 -----
+ #if MSC
+ #include	<memory.h>
+ #define peek(a,b,c,d) movedata(a,b,FP_SEG(c),FP_OFF(c),d)
+ #define poke(a,b,c,d) movedata(FP_SEG(c),FP_OFF(c),a,b,d)
+ #endif
+ 
***************
*** 15

--- 23 -----
+ #define NROW43	43			/* Screen size for EGA 43-line mode */
***************
*** 28

--- 37 -----
+ #define CDEGA	2			/* EGA graphics card		*/
***************
*** 30

--- 40,47 -----
+ #define SRES_MONO "MONO"		/* $sres text for monochrome	*/
+ #define SRES_CGA "CGA"			/* $sres text for CGA		*/
+ #define SRES_EGA "EGA"			/* $sres text for EGA		*/
+ 
+ #define MONOCURSOR 0x0B0D		/* monochrome cursor		*/
+ #define CGACURSOR 0x0607		/* CGA cursor			*/
+ #define EGACURSOR 0x0709		/* EGA cursor			*/
+ 
***************
*** 33
! int *scptr[NROW];			/* pointer to screen lines	*/

--- 50 -----
! int *scptr[NROW43];			/* pointer to screen lines	*/
***************
*** 34

--- 52,53 -----
+ int curmode;				/* cursor mode			*/
+ int vidmode_changed = 0;		/* has video mode been changed	*/
***************
*** 68

--- 88 -----
+ 	NROW43-1,
***************
*** 70
- 	NROW-1,

--- 89 -----
***************
*** 95,96
- extern union REGS rg;
- 

--- 113 -----
***************
*** 142
! 	if (dtype == CDCGA)

--- 159 -----
! 	if ((dtype == CDCGA) || (dtype == CDEGA))
***************
*** 194
! 	rg.x.dx = 0x184f;	/* lower right corner of scroll */

--- 211,212 -----
! 	rg.x.dx = (term.t_nrow << 8) | (term.t_ncol-1);
! 				/* lower right corner of scroll */
***************
*** 220
! 	if (strcmp(res, "CGA") == 0) {

--- 238,244 -----
! 	vidmode_changed = 0;
! 	if (strcmp(res, SRES_CGA) == 0 || strcmp(res, SRES_EGA) == 0) {
! 		if (strcmp(res, SRES_EGA) == 0 && dtype == CDEGA) {
! 			vidmode_changed = 1;
! 			scinit(CDEGA);
! 			return(TRUE);
! 		} else {
***************
*** 223
! 	} else if (strcmp(res, "MONO") == 0) {

--- 247,248 -----
! 		}
! 	} else if (strcmp(res, SRES_MONO) == 0) {
***************
*** 240

--- 266,271 -----
+ 	/* get current cursor mode */
+ 	rg.x.ax = 0x0300;
+ 	rg.h.bh = 0;
+ 	int86(0x10, &rg, &rg);
+ 	curmode = rg.x.cx;
+ 
***************
*** 252

--- 284,291 -----
+ 	if (vidmode_changed)
+ 		scinit(CDSENSE);	/* initialize display */
+ 
+ 	/* restore cursor mode */
+ 	rg.x.ax = 0x0100;
+ 	rg.x.cx = curmode;
+ 	int86(0x10, &rg, &rg);
+ 
***************
*** 275

--- 315,319 -----
+ #if MSC
+ 	char far *buf;
+ #else
+ 	char *buf;
+ #endif
***************
*** 277
! 	/* if asked...find out what display is connected */

--- 321,322 -----
! 	/* if asked...find out what display is connected (CGA default) */
! 	if (type == CDSENSE) {
***************
*** 281
! 	strcpy(sres, "CGA");

--- 326 -----
! 		strcpy(sres, SRES_CGA);
***************
*** 283
! 		strcpy(sres, "MONO");

--- 328 -----
! 			strcpy(sres, SRES_MONO);
***************
*** 285

--- 331,337 -----
+ 		} else {
+ 			/* test if EGA present */
+ 			rg.x.ax = 0x1200;
+ 			rg.x.bx = 0xff10;
+ 			int86(0x10,&rg, &rg);	/* If EGA, bh=0-1 and bl=0-3 */
+ 			if ( !(rg.x.bx & 0xfefc)) {	/* Yes, it's EGA */
+ 				dtype = CDEGA;
***************
*** 286

--- 339,340 -----
+ 		}
+ 	}
***************
*** 287

--- 342,391 -----
+ 	/* If forced to EGA 43-line mode */
+ 	if (type == CDEGA) {
+ 		term.t_nrow = NROW43-1;
+ 
+ 		/* and put the beast into EGA 43 row mode */
+ 		rg.x.ax = 3;
+ 		int86(0x10, &rg, &rg);
+ 
+ 		rg.x.ax = 0x1112;
+ 		rg.h.bl = 0;
+ 		int86(0x10, &rg, &rg);
+ 
+ 		peek(0x40, 0x87, buf, 1);
+ 		*buf |= 1;
+ 		poke(0x40, 0x87, buf, 1);
+ 		*buf = 0xf8;
+ 		poke(0x40, 0x88, buf, 1);
+ 
+ 	
+ 		/* set the cursor */
+ 		rg.x.ax = 0x0100;
+ 		rg.h.bh = 0;
+ 		rg.x.cx = EGACURSOR;
+ 		int86(0x10, &rg, &rg);
+ 
+ 		*buf = 0xf9;
+ 		poke(0x40, 0x88, buf, 1);
+ 
+ 		strcpy(sres, SRES_EGA);
+ 	} else {
+ 		if (type == CDMONO) strcpy(sres, SRES_MONO);
+ 		else if (type == CDCGA) strcpy(sres, SRES_CGA);
+ 
+ 		term.t_nrow = NROW-1;
+ 
+ 		/* and put the beast into 80 column mode */
+ 		rg.x.ax = (dtype == CDMONO) ? 0x0002 : 0x0003;
+ 		int86(0x10, &rg, &rg);
+ 
+ 		peek(0x40, 0x87, buf, 1);
+ 		*buf &= 0xFE;
+ 		poke(0x40, 0x87, buf, 1);
+ 
+ 		/* set the cursor */
+ 	rg.x.ax = 0x0100;
+ 		rg.h.bl = 0;
+ 		rg.x.cx = (dtype == CDMONO) ? MONOCURSOR : CGACURSOR;
+ 		int86(0x10, &rg, &rg);
+ 	}
+ 		
***************
*** 289,290
! 	for (i = 0; i < NROW; i++) {
! 		addr.laddr = scadd + (long)(NCOL * i * 2);

--- 393,394 -----
! 	for (i = 0; i <= term.t_mrow; i++) {
! 		addr.laddr = scadd + (long)(term.t_mcol * i * 2);

------ diff for main.c follows ----------------------------

*** org/main.c	Sat Mar 21 00:33:14 1987
--- ./main.c	Sat Mar 21 00:21:05 1987
***************
*** 554

--- 555,560 -----
+  *	4-mar-87
+  *	- updated patches by Walter Bright (3.8f)
+  *	20-mar-87 [3.8g by Jari Salminen]
+  *	- fixed bugs with IBM PC 8-bit characters
+  *      - EGA support added to IBMPC.C. Switching between 25 and 43 line mode
+  *	  possible.
***************
*** 940,941
! 	if ((c>=0x20 && c<=0x7E)		/* Self inserting.	*/
! 	||  (c>=0xA0 && c<=0xFE)) {

--- 946,951 -----
! 	if ((c>=0x20 && c<=0x7E) ||		/* Self inserting.	*/
! #if IBMPC
! 	    (c>=0x80 && c<=0xFE)) {		/* Allow 8-bit characters */
! #else
! 	    (c>=0xA0 && c<=0xFE)) {		/* Allow 8-bit characters */
! #endif

------ diff for spawn.c follows ----------------------------

*** org/spawn.c	Sat Mar 21 00:34:11 1987
--- ./spawn.c	Sat Mar 21 00:22:24 1987
***************
*** 43
- #define system(a)	spawnlp(P_WAIT, a, NULL)

--- 42 -----
***************
*** 89
! #if	MSDOS & AZTEC

--- 89 -----
! #if	MSDOS & (AZTEC | MSC)
***************
*** 271
! 	return (TRUE);

--- 271 -----
! 	return(TRUE);
***************
*** 306
! 	static char filnam[] = "command";

--- 306 -----
! 	static char filnam[25] = "command";
***************
*** 321,323
! 	if ((tmp = getenv("TMP")) == NULL)
! 		strcpy(filnam, "command");
! 	else

--- 321 -----
! 	if ((tmp = getenv("TMP")) != NULL)
***************
*** 324

--- 323 -----
+ 	strcat(filnam, "command");
***************
*** 365
! 	strcat(line," >>");

--- 364 -----
! 	strcat(line," >");
***************
*** 559
! #if	~AZTEC & MSDOS

--- 558 -----
! #if	(~MSC & ~AZTEC) & MSDOS
***************
*** 587,589
- #if	MSC
- 	return(spawnlp(P_WAIT, cmd, tail, NULL));
- #endif

--- 585 -----

---- END OF DIFFS ------