diff -u --recursive --new-file dosemu0.53.52/ChangeLog dosemu0.53.53/ChangeLog
--- dosemu0.53.52/ChangeLog	Fri Mar 17 22:46:38 1995
+++ dosemu0.53.53/ChangeLog	Sun Mar 19 12:12:36 1995
@@ -1,3 +1,11 @@
+Sun Mar 19	1995
+
+-	Release pre0.53.53
+-	Latest DPMI from Dong
+-	Locking serial ttys from:
+		 Matthew Grant <grantma@ritz.equinox.gen.nz>
+-	Little work on ctrl-alt-del rebooting, but no success.
+
 Fri Mar 17	1995
 
 -	Release pre0.53.52
diff -u --recursive --new-file dosemu0.53.52/Makefile dosemu0.53.53/Makefile
--- dosemu0.53.52/Makefile	Fri Mar 17 22:47:00 1995
+++ dosemu0.53.53/Makefile	Sun Mar 19 11:58:56 1995
@@ -98,6 +98,16 @@
 export PICOBJS
 endif
 
+# The next lines define the Lock file set up.  You must do a make clean
+# make config if change these lines
+# Uncomment the following if you still have your UUCP locks in /usr/spool/uucp
+PATH_LOCKD = -DPATH_LOCKD=\"/usr/spool/uucp\"
+# Uncomment the following if you your UUCP locks in /var/locks
+#PATH_LOCKD = -DPATH_LOCKD=\"/var/locks\"
+# First part of Lock file names, prepended to 'tty5' etc.
+NAME_LOCKF = -DNAME_LOCKF=\"LCK..\"
+
+
 # enable this target to make a different way
 # do_DEBUG=true
 ifdef ELF
@@ -118,7 +128,7 @@
 EMUVER  =   0.53
 export EMUVER
 VERNUM  =   0x53
-PATCHL  =   52
+PATCHL  =   53
 LIBDOSEMU = libdosemu$(EMUVER).$(PATCHL)
 
 # DON'T CHANGE THIS: this makes libdosemu start high enough to be safe. 
@@ -231,10 +241,11 @@
 PIPE=-pipe
 export CFLAGS     = $(OPT) $(PIPE) $(USING_NET)
 CFLAGS+=$(NEW_PIC) $(DPMI) $(XDEFS) $(CDEBUGOPTS) $(COPTFLAGS) $(INCDIR)
+CFLAGS+=$(PATH_LOCKD) $(NAME_LOCKF)
 CFLAGS+=$(X86_EMULATOR_FLAGS)
 
 # set for DPMI want windows
-# CFLAGS+=-DWANT_WINDOWS
+CFLAGS+=-DWANT_WINDOWS
 # set to use a simpler fork for unix command
 # CFLAGS+=-DSIMPLE_FORK
 # set to debug fork with environment
diff -u --recursive --new-file dosemu0.53.52/dosemu/dosio.c dosemu0.53.53/dosemu/dosio.c
--- dosemu0.53.52/dosemu/dosio.c	Fri Mar 17 20:34:03 1995
+++ dosemu0.53.53/dosemu/dosio.c	Fri Mar 17 23:33:27 1995
@@ -471,12 +471,10 @@
 		m_printf("MOUSE: We have data\n");
 #ifdef NEW_PIC
 	  pic_request(PIC_IRQ12);
-	  m_printf("MOUSE: PIC will be requesting it\n");
 #else
 	  DOSEMUMouseEvents();
 #endif
 	}
-
       if (FD_ISSET(kbd_fd, &fds)) {
 	getKeys();
       }
@@ -487,6 +485,11 @@
 #endif
       break;
     }
+#if 0
+#ifdef USING_NET
+    pic_request(16);
+#endif
+#endif
 
 }
 
diff -u --recursive --new-file dosemu0.53.52/dosemu/int.c dosemu0.53.53/dosemu/int.c
--- dosemu0.53.52/dosemu/int.c	Fri Mar 17 20:23:11 1995
+++ dosemu0.53.53/dosemu/int.c	Sat Mar 18 20:37:59 1995
@@ -282,7 +282,7 @@
     break;
 #endif
     case 0x80:
-        LWORD(eax) = getcwd(SEG_ADR((char *), es, dx), (u_short *)LWORD(eax));
+        LWORD(eax) = getcwd(SEG_ADR((char *), es, dx), (u_short)LWORD(eax));
         break;
   case 0x81:
         LWORD(eax) = chdir(SEG_ADR((char *), es, dx));
@@ -957,8 +957,10 @@
     return;
 
   case 0x1600:		/* WINDOWS ENHANCED MODE INSTALLATION CHECK */
+#if 0			/* it seens this confuse winos2 */
     if (in_dpmi && in_win31)
       LO(ax) = 3;	/* let's try enhaced mode :-))))))) */
+#endif    
     D_printf("DPMI: WINDOWS ENHANCED MODE INSTALLATION CHECK\n");
     return;
 
diff -u --recursive --new-file dosemu0.53.52/dosemu/serial.c dosemu0.53.53/dosemu/serial.c
--- dosemu0.53.52/dosemu/serial.c	Tue Mar 14 20:41:44 1995
+++ dosemu0.53.53/dosemu/serial.c	Sun Mar 19 11:57:14 1995
@@ -12,7 +12,22 @@
  *	mdrejhon@csclub.uwaterloo.ca
  *	ag115@freenet.carleton.ca
  *
+ *              Lock file stuff stolen from Taylor UUCP
+ *              Copyright (C) 1991, 1992 Ian Lance Taylor
  *
+ *              Uri Blumenthal <uri@watson.ibm.com>
+ *              (C) 1994
+ *
+ *              Paul Cadach, <paul@paul.east.alma-ata.su>
+ *              (C) 1994
+ *
+ *              Lock file stuff is free software; you can redistribute it
+ *              and/or  modify it under  the terms of  the GNU General
+ *              Public  License as  published  by  the  Free  Software
+ *              Foundation;  either  version 2 of the License, or  (at
+ *              your option) any later version.
+ *
+ *
  * $Date: 1995/02/25 22:38:01 $
  * $Source: /home/src/dosemu0.60/dosemu/RCS/serial.c,v $
  * $Revision: 2.9 $
@@ -134,6 +149,8 @@
 #include <termios.h>
 #include <signal.h>
 #include <sys/ioctl.h>
+#include <linux/fs.h>
+#include <pwd.h>
 
 #include "config.h"
 #include "cpu.h"
@@ -208,6 +225,9 @@
 void pic_serial_run(void);
 #endif
 
+static int tty_already_locked(char *nam);
+static int tty_lock(char *path, int mode);
+ 
 /*************************************************************************/
 /*                 MISCALLENOUS serial support functions                 */
 /*************************************************************************/
@@ -462,8 +482,168 @@
   com[num].newbaud = baud;
   tcsetattr(com[num].fd, TCSANOW, &com[num].newset);   /* DOS_SYSCALL */
 }
+/*  Determines if the tty is already locked.  Stolen from uri-dip-3.3.7k
+ *  Nice work Uri Blumenthal & Ian Lance Taylor!
+ *			[nam = lock file +path, return = locked (!=0) or not]
+ */
+static int
+tty_already_locked(char *nam) /* nam - complete path to lock file */
+{
+  int  i = 0, pid = 0;
+  FILE *fd = (FILE *)0;
+
+  /* Does the lock file on our device exist? */
+  if ((fd = fopen(nam, "r")) == (FILE *)0)
+    return 0; /* No, return perm to continue */
+
+  /* Yes, the lock is there.  Now let's make sure */
+  /* at least there's no active process that owns */
+  /* that lock.                                   */
+  if(config.tty_lockbinary){
+    i = read(fileno(fd), &pid, sizeof(pid)) == sizeof(pid);
+  }
+  else {
+    i = fscanf(fd, "%d", &pid);
+  }
+  (void) fclose(fd);
+
+  if (i != 1) /* Lock file format's wrong! Kill't */
+    return 0;
+
+  /* We got the pid, check if the process's alive */
+  if (kill(pid, 0) == 0)      /* it found process */
+      return 1;           /* Yup, it's running... */
+
+  /* Dead, we can proceed locking this device...  */
+  return 0;
+}
+
+
+/*  Locks or unlocks a terminal line Stolen from uri-dip-3.3.7k
+ *  Nice work Uri Blumenthal & Ian Lance Taylor!
+ * [path = device name, 
+ *  mode: 1 = lock, 2 = reaquire lock, anythingelse = unlock,
+ *  return = success (0) or failure (< 0)]
+ */
+/* Lock or unlock a terminal line. */
+static int
+tty_lock(char *path, int mode)
+{
+  static char saved_path[PATH_MAX];
+  static char nam_tmp[PATH_MAX];
+  static char dev_nam[20];
+  static int saved_lock = 0;
+  struct passwd *pw;
+  pid_t ime;
+  int cwrote;
+
+  bzero(nam_tmp, sizeof(nam_tmp));
+
+  /* Check that lockfiles can be created! */
+  if((mode == 1 || mode == 2) && geteuid() != (uid_t)0) {
+    s_printf("DOSEMU: Need to be suid root to create Lock Files!\n"
+	     "        Serial port on %s not configured!\n", path);
+    error("\nDOSEMU: Need to be suid root to create Lock Files!\n"
+	  "        Serial port on %s not configured!\n", path);
+    return(-1);
+  }
+
+  if (mode == 1) {      /* lock */
+    if (path == NULL) return(0);        /* standard input */
+    bzero(dev_nam, sizeof(dev_nam));
+    sprintf(saved_path, "%s/%s%s", config.tty_lockdir, config.tty_lockfile, 
+	    (strrchr(path, '/')+1));
+    strcpy(dev_nam, path);
+    {
+      FILE *fd;
+      if (tty_already_locked(saved_path) == 1) {
+        s_printf("DOSEMU: attempt to use already locked tty %s\n",
+               saved_path);
+        error("\nDOSEMU: attempt to use already locked tty %s\n",
+                saved_path);
+        return (-1);
+      }
+      if ((fd = fopen(saved_path, "w")) == (FILE *)0) {
+        s_printf("DOSEMU: lock: (%s): %s\n",
+               saved_path, strerror(errno));
+        error("\nDOSEMU: tty: lock: (%s): %s\n",
+                saved_path, strerror(errno));
+        return(-1);
+      }
+      ime = getpid();
+      if(config.tty_lockbinary) {
+	cwrote = write (fileno(fd), &ime, sizeof(ime));
+      }
+      else {
+	fprintf(fd, "%10d\n", (int)ime);
+      }
+      (void)fclose(fd);
+    }
+
+    /* Make sure UUCP owns the lockfile.  Required by some packages. */
+    if ((pw = getpwnam(OWNER_LOCKS)) == NULL) {
+      error("\nDOSEMU: tty: lock: UUCP user %s unknown!\n",
+              OWNER_LOCKS);
+      return(0);        /* keep the lock anyway */
+    }
+    (void) chown(saved_path, pw->pw_uid, pw->pw_gid);
+    (void) chmod(saved_path, 0644);
+    saved_lock = 1;
+  } else {
+    if (mode == 2) { /* re-acquire a lock after a fork() */
+      FILE *fd;
+
+      if (saved_lock != 1) {
+        s_printf("DOSEMU: tty_lock reaquire: lock was not saved!\n");
+        return (-1);
+      }
+      if ((fd = fopen(saved_path, "w")) == (FILE *)0) {
+        s_printf("DOSEMU:tty_lock(%s) reaquire: %s\n",
+               saved_path, strerror(errno));
+        error("\nDOSEMU:tty_lock: reacquire (%s): %s\n",
+                saved_path, strerror(errno));
+        return(-1);
+      }
+      ime = getpid();
+      if(config.tty_lockbinary) {
+	cwrote = write (fileno(fd), &ime, sizeof(ime));
+      }
+      else {
+	fprintf(fd, "%10d\n", (int)ime);
+      }
+      (void)fclose(fd);
+      (void) chmod(saved_path, 0444);
+      (void) chown(saved_path, getuid(), getgid());
+      return(0);
+    } else {    /* unlock */
+      FILE *fd;
+
+      if (saved_lock != 1) {
+        s_printf("DOSEMU:tty_lock: lock was not saved?!\n");
+        return(0);
+      }
+      if ((fd = fopen(saved_path, "w")) == (FILE *)0) {
+        s_printf("DOSEMU:tty_lock: can't reopen to delete: %s\n",
+               strerror(errno));
+        return (-1);
+      }
+      if (unlink(saved_path) < 0) {
+        s_printf("DOSEMU: tty: unlock: (%s): %s\n", saved_path,
+               strerror(errno));
+        error("\nDOSEMU: tty: unlock: (%s): %s\n", saved_path,
+                strerror(errno));
+        saved_lock = 0;
+        return(-1);
+      }
+      saved_lock = 0;
+    }
+  }
+
+  return(0);
+}
 
 
+
 /* This function opens the serial port for DOSEMU.  Normally called only
  * by do_ser_init below.   [num = port, return = file descriptor]
  */
@@ -525,6 +705,7 @@
   **
   ** If COMx is unspecified, the next unused COMx port number is assigned.
   */
+
   if (com[num].real_comport == 0) {		/* Is comport number undef? */
     for (i = 1; i < 16; i++) if (com_port_used[i] != 1) break;
     com[num].real_comport = i;
@@ -547,6 +728,7 @@
     default: com[num].base_port = 0x3F8; break;
     }
   }
+
   if (com[num].dev[0] == 0) {			/* Is the device file undef? */
     switch (com[num].real_comport) {		/* Define it using std devs */
     case 4:  strcpy(com[num].dev, "/dev/cua3"); break;
@@ -555,6 +737,17 @@
     default: strcpy(com[num].dev, "/dev/cua0"); break;
     }
   }
+  
+  /* Insert lock file function here */
+  if ( !com[num].mouse ) {
+    if ( tty_lock( com[num].dev, 1) >= 0) {
+      com[num].dev_locked = TRUE;
+    }
+    else {
+      return;
+    }
+  }
+
 #if NEW_PIC==2
   /* convert irq number to pic_ilevel number and set up interrupt */
   /* if irq is invalid, no interrupt will be assigned */
@@ -683,6 +876,7 @@
   /* Do UART init here - Need to set up registers and init the lines. */
   for (i = 0; i < config.num_ser; i++) {
     com[i].fd = -1;
+    com[i].dev_locked = FALSE;
 #ifdef X_SUPPORT
     if ((!config.usesX && config.console_video ) || !com[i].mouse)   /* skip "mouse" ports in X mode */
 #else
@@ -706,6 +900,8 @@
     if ( ( ! config.usesX ) || ( ! com[i].mouse ) ){
       RPT_SYSCALL(tcsetattr(com[i].fd, TCSANOW, &com[i].oldset));
       ser_close(i);
+      if ( com[i].dev_locked ) 
+	tty_lock(com[i].dev, 0);
     }
   }
 }
diff -u --recursive --new-file dosemu0.53.52/dpmi/dpmi.c dosemu0.53.53/dpmi/dpmi.c
--- dosemu0.53.52/dpmi/dpmi.c	Thu Mar 16 20:07:53 1995
+++ dosemu0.53.53/dpmi/dpmi.c	Sat Mar 18 20:29:37 1995
@@ -137,7 +137,7 @@
 #define RM_AFFECT_IF
 #endif
 
-#if 0
+#if 1
 #undef inline /*for gdb*/
 #define inline
 #endif
@@ -487,6 +487,7 @@
 {
   unsigned short ldt_entry = selector >> 3;
   unsigned long *lp;
+  struct modify_ldt_ldt_s ldt_info;
 
   if (ldt_entry >= MAX_SELECTORS)
     return -1;
@@ -504,7 +505,12 @@
   lp = (unsigned long *) &ldt_buffer[ldt_entry*LDT_ENTRY_SIZE];
   *lp = 0;
   *(lp+1) = 0;
-  return 0;
+
+  /* WinOS2 depends on freeed descrpitor really free */
+  memset((void *)&ldt_info, 0, sizeof(ldt_info));
+  ldt_info.entry_number = ldt_entry;
+  return modify_ldt(1, &ldt_info, sizeof(ldt_info));
+
 }
 
 static inline int ConvertSegmentToDescriptor(unsigned short segment)
@@ -794,7 +800,16 @@
 	    return tmp;
     return 0;
 }
-			 
+
+#define CHECK_SELECTOR(x) \
+{ if ((((x) & 4) != 4) || (((x) & 0xfffc) == (DPMI_SEL & 0xfffc)) \
+      || (((x) & 0xfffc ) == (PMSTACK_SEL & 0xfffc)) \
+	|| (((x) & 0xfffc ) == (LDT_ALIAS & 0xfffc))) { \
+      _LWORD(eax) = 0x8011; \
+      _eflags |= CF; \
+      break; \
+    } \
+}      
 void do_int31(struct sigcontext_struct *scp, int inumber)
 {
   _eflags &= ~CF;
@@ -806,10 +821,18 @@
     }
     break;
   case 0x0001:
+    CHECK_SELECTOR(_LWORD(ebx));
     if (FreeDescriptor(_LWORD(ebx))){
       _LWORD(eax) = 0x8011;
       _eflags |= CF;
     }
+#if 0    
+    /* do it dpmi 1.00 host\'s way */
+    if ( _ds == _LWORD(ebx)) _ds = 0;
+    if ( _es == _LWORD(ebx)) _es = 0;
+    if ( _fs == _LWORD(ebx)) _fs = 0;
+    if ( _gs == _LWORD(ebx)) _gs = 0;
+#endif    
     break;
   case 0x0002:
     if (!(_LWORD(eax)=ConvertSegmentToDescriptor(_LWORD(ebx)))) {
@@ -832,6 +855,7 @@
     }
     break;
   case 0x0007:
+    CHECK_SELECTOR(_LWORD(ebx));
     if (SetSegmentBaseAddress(_LWORD(ebx), (_LWORD(ecx))<<16 | (_LWORD(edx)))) {
       _eflags |= CF;
       _LWORD(eax) = 0x8025;
@@ -838,6 +862,7 @@
     }
     break;
   case 0x0008:
+    CHECK_SELECTOR(_LWORD(ebx));
     if (SetSegmentLimit(_LWORD(ebx), ((unsigned long)(_LWORD(ecx))<<16) | (_LWORD(edx)))) {
       _eflags |= CF;
       _LWORD(eax) = 0x8025;
@@ -844,10 +869,7 @@
     }
     break;
   case 0x0009:
-    if ((_LWORD(ebx) & 0x7 != 0x7) || (Segments[_LWORD(ebx)>>3].used == 0)) {
-      _eflags |= CF;
-      break;
-    }
+    CHECK_SELECTOR(_LWORD(ebx));
     if (SetDescriptorAccessRights(_LWORD(ebx), _ecx & (DPMIclient_is_32 ? 0xffff : 0x00ff))) {
       _eflags |= CF;
     }
@@ -857,19 +879,12 @@
       _eflags |= CF;
     break;
   case 0x000b:
-    if ((_LWORD(ebx) & 0x7 != 0x7) || (Segments[_LWORD(ebx)>>3].used == 0)) {
-      _eflags |= CF;
-      break;
-    }
     GetDescriptor(_LWORD(ebx),
 		(unsigned long *) (GetSegmentBaseAddress(_es) +
 			(DPMIclient_is_32 ? _edi : _LWORD(edi)) ) );
     break;
   case 0x000c:
-    if ((_LWORD(ebx) & 0x7 != 0x7) || (Segments[_LWORD(ebx)>>3].used == 0)) {
-      _eflags |= CF;
-      break;
-    }
+    CHECK_SELECTOR(_LWORD(ebx));
     if (SetDescriptor(_LWORD(ebx),
 		      (unsigned long *) (GetSegmentBaseAddress(_es) +
 			(DPMIclient_is_32 ? _edi : _LWORD(edi)) ) ))
@@ -876,10 +891,6 @@
       _eflags |= CF;
     break;
   case 0x000d:
-    if (_LWORD(ebx) & 0x7 != 0x7) {
-      _eflags |= CF;
-      break;
-    }
     if (AllocateSpecificDescriptor(_LWORD(ebx)))
       _eflags |= CF;
     break;
@@ -1630,7 +1641,6 @@
   in_dpmi++;
   in_win31 = 0;
   in_dpmi_dos_int = 0;
-  in_sigsegv--;
   pm_block_root[current_client] = 0;
   memset((void *)(&realModeCallBack[current_client][0]), 0,
 	 sizeof(RealModeCallBack)*0x10);
@@ -1653,6 +1663,7 @@
 
   if (in_dpmi>1) return; /* return immediately to the main loop */
 
+  in_sigsegv--;
   for (; (!fatalerr && in_dpmi) ;) {
     run_dpmi();
     run_irqs();
@@ -1914,7 +1925,7 @@
 #endif
 	return;
       }
-      if (_cs==DPMI_SEL)
+      if (_cs==DPMI_SEL) {
 	if (_eip==DPMI_OFF+1+HLT_OFF(DPMI_raw_mode_switch)) {
 	  D_printf("DPMI: switching from protected to real mode\n");
 	  REG(ds) = (long) _LWORD(eax);
@@ -2052,6 +2063,8 @@
 
 	} else
 	  return;
+      } else			/* in client\'s code, set back eip */
+	_eip -= 1;
       break;
     case 0xfa:			/* cli */
       _eip += 1;
diff -u --recursive --new-file dosemu0.53.52/dpmi/kernel.diff dosemu0.53.53/dpmi/kernel.diff
--- dosemu0.53.52/dpmi/kernel.diff	Tue Mar 14 18:56:49 1995
+++ dosemu0.53.53/dpmi/kernel.diff	Sat Mar 18 20:25:25 1995
@@ -62,3 +62,17 @@
 +			 int limit_in_pages_flag, int seg_not_present_flag, int useable);
  
  #endif
+diff -ru linux/arch/i386/kernel/signal.c linux.new/arch/i386/kernel/signal.c
+--- linux/arch/i386/kernel/signal.c.pl12	Tue Mar 14 03:13:34 1995
++++ linux/arch/i386/kernel/signal.c	Tue Mar 14 04:08:31 1995
+@@ -47,7 +47,7 @@
+ {
+ #define COPY(x) regs->x = context.x
+ #define COPY_SEG(x) \
+-if ((context.x & 0xfffc) && (context.x & 3) != 3) goto badframe; COPY(x);
++if ((context.x & 0xfffc) && (context.x & 0x4) != 0x4 && (context.x & 3) != 3) goto badframe; COPY(x);
+ #define COPY_SEG_STRICT(x) \
+ if (!(context.x & 0xfffc) || (context.x & 3) != 3) goto badframe; COPY(x);
+ 	struct sigcontext_struct context;
+
+
diff -u --recursive --new-file dosemu0.53.52/dpmi/msdos.h dosemu0.53.53/dpmi/msdos.h
--- dosemu0.53.52/dpmi/msdos.h	Wed Mar 15 19:18:03 1995
+++ dosemu0.53.53/dpmi/msdos.h	Sat Mar 18 20:29:37 1995
@@ -48,6 +48,8 @@
 static inline void restore_pm_regs();
 static inline unsigned short AllocateDescriptors(int);
 
+/* We use static varialbes because DOS in non-reentrant, but maybe a */
+/* better way? */
 static unsigned short DS_MAPPED;
 static unsigned short ES_MAPPED;
 static char READ_DS_COPIED;
@@ -61,10 +63,25 @@
     REG(cs)  = CURRENT_PSP;
     REG(eip) = 0x100;
     if (in_win31) {
+	/* is seems that winos2 uses a PSP that not allocate via dos, */
+	/* so we can\'t let dos to free it. just restore some DOS int */
+	/* vectors and return. */
+
+	/* restore terminate address address */
+	((unsigned long *)0)[0x22] =
+	             *(unsigned long *)((char *)(CURRENT_PSP<<4) + 0xa);
+	/* restore Ctrl-Break address */
+	((unsigned long *)0)[0x23] =
+	             *(unsigned long *)((char *)(CURRENT_PSP<<4) + 0xe);
+	/* restore critical error  address */
+	((unsigned long *)0)[0x24] =
+	             *(unsigned long *)((char *)(CURRENT_PSP<<4) + 0x12);
+	return 1;
+
+#if 0
 	int i;
 	unsigned short parent_seg;
 	unsigned short parent_off;
-
 	parent_off = *(unsigned short *)((char *)(CURRENT_PSP<<4) + 0xa);
 	parent_seg = *(unsigned short *)((char *)(CURRENT_PSP<<4) + 0xa+2);
 
@@ -88,6 +105,7 @@
 	/* no need for register translation */
 	*(unsigned short *)((char *)(CURRENT_PSP<<4) + 0xa) =
 	     DPMI_OFF + HLT_OFF(DPMI_return_from_dos);
+#endif	
     }
     return 0;
 }
@@ -107,6 +125,15 @@
 static inline int
 msdos_pre_extender(struct sigcontext_struct *scp, int intr)
 {
+    /* only consider DOS services */
+    switch (intr) {
+    case 0x20 ... 0x21:
+    case 0x25 ... 0x26:
+	break;
+    default:
+	return 0;
+    }
+    
     DS_MAPPED = 0;
     ES_MAPPED = 0;
     switch (intr) {
@@ -448,6 +475,7 @@
     case 0x25:			/* Absolute Disk Read */
     case 0x26:			/* Absolute Disk write */
 	DS_MAPPED = 1;
+	D_printf("DPMI: msdos Absolute Disk Read/Write called.\n");
 	break;
     default:
 	return 0;
@@ -516,6 +544,26 @@
 static inline void
 msdos_post_extender(int intr)
 {
+    switch (intr) {
+    case 0x15:
+      switch(S_HI(ax)) {
+        case 0xc0:      /* Get Configuartion */
+                if (REG(eflags)&CF)
+                        return;
+                if (!(dpmi_stack_frame[current_client].es =
+                         ConvertSegmentToDescriptor(REG(es))))
+                return;
+        default:
+                return;
+      }
+    /* only copy buffer for dos services */
+    case 0x21:
+    case 0x25 ... 0x26:
+	break;
+    default:
+	return;
+    }
+
     if (DS_MAPPED) {
 	unsigned short my_ds;
 	my_ds =   DPMI_private_data_segment+DPMI_private_paragraphs;
@@ -533,17 +581,6 @@
     ES_MAPPED = 0;
 	       
     switch (intr) {
-    case 0x15:
-      switch(S_HI(ax)) {
-        case 0xc0:      /* Get Configuartion */
-                if (REG(eflags)&CF)
-                        return;
-                if (!(dpmi_stack_frame[current_client].es =
-                         ConvertSegmentToDescriptor(REG(es))))
-                break;
-        default:
-                return;
-      }
     case 0x21:
 	switch (S_HI(ax)) {
 	case 0x29:		/* Parse a file name for FCB */
@@ -672,6 +709,22 @@
 	    return;
 	}
 	break;
+    case 0x25:			/* Absolute Disk Read */
+    case 0x26:			/* Absolute Disk Write */
+	/* the flags should be pushed to stack */
+	if (DPMIclient_is_32) {
+	    dpmi_stack_frame[current_client].esp -= 4;
+	    *(unsigned long *)(GetSegmentBaseAddress(
+		dpmi_stack_frame[current_client].ss) +
+	      dpmi_stack_frame[current_client].esp) = REG(eflags);
+	} else {
+	    dpmi_stack_frame[current_client].esp -= 2;
+	    *(unsigned short *)(GetSegmentBaseAddress(
+		dpmi_stack_frame[current_client].ss) +
+	      (dpmi_stack_frame[current_client].esp&0xffff)) =
+		 LWORD(eflags);
+	}
+	return;
     default:
 	return;
     }
@@ -1078,35 +1131,65 @@
 	/* although dpmiload allocates data alias selector for every */
 	/* code selector, but it insists to write on code segment :=(.*/
 	char fix_alias = 0;
-
-	/* see if it is a cs prefix problem */
-	if (msdos_fix_cs_prefix(scp))
-	    return 1;
+	unsigned char *csp;
+#if 0
+	if (in_bcc) {
+	    /* see if it is a cs prefix problem */
+	    if (msdos_fix_cs_prefix(scp))
+		return 1;
 	
-	if ((Segments[_ds>>3].type & MODIFY_LDT_CONTENTS_CODE) &&
-	    (Segments[(_ds>>3)+1].base_addr == Segments[_ds>>3].base_addr)
-	    &&((Segments[(_ds>>3)+1].type & MODIFY_LDT_CONTENTS_CODE)==0)){
-	    _ds += 8;
-	    fix_alias=1;
-	}
-	if ((Segments[_es>>3].type & MODIFY_LDT_CONTENTS_CODE) &&
-	    (Segments[(_es>>3)+1].base_addr == Segments[_es>>3].base_addr)
-	    &&((Segments[(_es>>3)+1].type & MODIFY_LDT_CONTENTS_CODE)==0)){
-	    _es += 8;
-	    fix_alias=1;
-	}
-	/* see if bcc want use GDT 0 */
-	if (_ds == 0) {
-	    D_printf("BCC: try to use use gdt 0 as ds\n");
-	    _ds = ConvertSegmentToDescriptor(0);
-	    fix_alias = 1;
+	    if ((Segments[_ds>>3].type & MODIFY_LDT_CONTENTS_CODE) &&
+		(Segments[(_ds>>3)+1].base_addr == Segments[_ds>>3].base_addr)
+		&&((Segments[(_ds>>3)+1].type & MODIFY_LDT_CONTENTS_CODE)==0)){
+		_ds += 8;
+		fix_alias=1;
+	    }
+	    if ((Segments[_es>>3].type & MODIFY_LDT_CONTENTS_CODE) &&
+		(Segments[(_es>>3)+1].base_addr == Segments[_es>>3].base_addr)
+		&&((Segments[(_es>>3)+1].type & MODIFY_LDT_CONTENTS_CODE)==0)){
+		_es += 8;
+		fix_alias=1;
+	    }
 	}
-	if (_es == 0) {
-	    D_printf("BCC: try to use use gdt 0 as es\n");
-	    _es = ConvertSegmentToDescriptor(0);
-	    fix_alias = 1;
+#endif 	
+
+	csp = (unsigned char *) SEL_ADR(_cs, _eip);
+	switch (*csp) {
+	case 0x2e:		/* cs: */
+	    break;		/* do nothing */
+	case 0x36:		/* ss: */
+	    break;		/* do nothing */
+	case 0x26:		/* es: */
+	    if (_es == 0) {
+		D_printf("DPMI: client tries to use use gdt 0 as es\n");
+		_es = ConvertSegmentToDescriptor(0);
+		fix_alias = 1;
+	    }
+	    break;
+	case 0x64:		/* fs: */
+	    if (_fs == 0) {
+		D_printf("DPMI: client tries to use use gdt 0 as fs\n");
+		_fs = ConvertSegmentToDescriptor(0);
+		fix_alias = 1;
+	    }
+	    break;
+	case 0x65:		/* gs: */
+	    if (_gs == 0) {
+		D_printf("DPMI: client tries to use use gdt 0 as es\n");
+		_gs = ConvertSegmentToDescriptor(0);
+		fix_alias = 1;
+	    }
+	    break;
+	case 0x3e:		/* ds: */
+	default:		/* assmue default is using ds, but if the */
+				/* client sets ss to 0, it is totally broken */
+	    if (_ds == 0) {
+		D_printf("DPMI: client tries to use use gdt 0 as ds\n");
+		_ds = ConvertSegmentToDescriptor(0);
+		fix_alias = 1;
+	    }
+	    break;
 	}
-	    
 	return fix_alias;
     }
 
@@ -1119,16 +1202,23 @@
 
     D_printf("DPMI: try mov to a invalid selector 0x%04x\n", segment);
 
+#if 1
+    /* olny allow using some special GTD\'s */
+    if ((segment != 0x0040) && (segment != 0xa000) &&
+	(segment != 0xb000) && (segment != 0xb800) &&
+	(segment != 0xc000) && (segment != 0xe000) && (segment != 0xf000))
+	return 0;
+
+    if (!(desc = ConvertSegmentToDescriptor(segment)))
+	return 0;
+    desc = desc >>3;
+
+#else						     
     base_addr = ((unsigned long)segment) << 4;
     for(desc=0; desc < MAX_SELECTORS; desc++)
 	if ((Segments[desc].base_addr == base_addr)&&
 	    Segments[desc].used)
 	    break;
-
-#if 0    
-    if (desc >= MAX_SELECTORS)
-	return 0;
-#else
     if (desc >= MAX_SELECTORS) {
 	if (!(desc = ConvertSegmentToDescriptor(segment)))
 	    return 0;
diff -u --recursive --new-file dosemu0.53.52/emu.c dosemu0.53.53/emu.c
--- dosemu0.53.52/emu.c	Thu Mar 16 19:20:12 1995
+++ dosemu0.53.53/emu.c	Sun Mar 19 08:58:41 1995
@@ -1,482 +1,390 @@
-/* Extensions by Robert Sanders, 1992-93
- *
+/*
+ * Extensions by Robert Sanders, 1992-93
+ * 
  * DANG_BEGIN_MODULE
  * 
- * Here is where DOSEMU gets booted. From emu.c external calls are made
- * to the specific I/O systems (video/keyboard/serial/etc...) to
- * initialize them. Memory is cleared/set up and the boot sector is read
- * from the boot drive. Many SIGNALS are set so that DOSEMU can 
- * exploit things like timers, I/O signals, illegal instructions, etc...
- * When every system gives the green light, vm86()
- * is called to switch into vm86 mode and start executing i86 code. 
- *
- * The vm86() function will return to DOSEMU when certain `exceptions`
- * occur as when some interrupt instructions occur (0xcd).
- *
- * The top level function emulate() is called from dos.c by way of a
- * dll entry point.
- *
+ * Here is where DOSEMU gets booted. From emu.c external calls are made to
+ * the specific I/O systems (video/keyboard/serial/etc...) to initialize
+ * them. Memory is cleared/set up and the boot sector is read from the
+ * boot drive. Many SIGNALS are set so that DOSEMU can exploit things like
+ * timers, I/O signals, illegal instructions, etc... When every system
+ * gives the green light, vm86() is called to switch into vm86 mode and
+ * start executing i86 code.
+ * 
+ * The vm86() function will return to DOSEMU when certain `exceptions` occur
+ * as when some interrupt instructions occur (0xcd).
+ * 
+ * The top level function emulate() is called from dos.c by way of a dll
+ * entry point.
+ * 
  * DANG_END_MODULE
- *
- * DANG_BEGIN_CHANGELOG
- * $Date: 1995/02/25 22:38:10 $
- * $Source: /home/src/dosemu0.60/RCS/emu.c,v $
- * $Revision: 2.36 $
- * $State: Exp $
- *
- * $Log: emu.c,v $
- * Revision 2.36  1995/02/25  22:38:10  root
- * *** empty log message ***
- *
- * Revision 2.35  1995/02/25  21:53:22  root
- * *** empty log message ***
- *
- * Revision 2.34  1995/02/05  16:51:10  root
- * Prep for Scotts patches.
- *
- * Revision 2.33  1995/01/19  02:20:11  root
- * Testing for Marty.
- *
- * Revision 2.32  1995/01/14  15:28:03  root
- * New Year checkin.
- *
- * Revision 2.32  1994/12/06  03:33:50  leisner
- * *** empty log message ***
- *
- * Revision 2.31  1994/11/13  00:40:45  root
- * Prep for Hans's latest.
- *
- * Revision 2.30  1994/11/06  02:35:24  root
- * Testing co -M.
- *
- * Revision 2.28  1994/10/14  17:58:38  root
- * Prep for pre53_27.tgz
- *
- * Revision 2.27  1994/10/03  00:24:25  root
- * Checkin prior to pre53_25.tgz
- *
- * Revision 2.26  1994/09/26  23:10:13  root
- * Prep for pre53_22.
- *
- * Revision 2.25  1994/09/23  01:29:36  root
- * Prep for pre53_21.
- *
- * Revision 2.24  1994/09/22  23:51:57  root
- * Prep for pre53_21.
- *
- * Revision 2.23  1994/09/20  01:53:26  root
- * Prep for pre53_21.
- *
- * Revision 2.22  1994/09/11  01:01:23  root
- * Prep for pre53_19.
- *
- * Revision 2.21  1994/08/25  00:49:34  root
- * Lutz's STI patches and prep for pre53_16.
- *
- * Revision 2.20  1994/08/17  02:08:22  root
- * Mods to Rain's patches to get all modes back on the road.
- *
- * Revision 2.19  1994/08/14  02:52:04  root
- * Rain's latest CLEANUP and MOUSE for X additions.
- *
- * Revision 2.18  1994/08/09  01:49:57  root
- * Prep for pre53_11.
- *
- * Revision 2.17  1994/08/05  22:29:31  root
- * Prep dir pre53_10.
- *
- * Revision 2.16  1994/08/02  00:08:51  root
- * Markk's latest.
- *
- * Revision 2.15  1994/08/01  14:58:59  root
- * Added detach (-d) option from Karl Hakimian.
- *
- * Revision 2.14  1994/08/01  14:26:23  root
- * Prep for pre53_7  with Markks latest, EMS patch, and Makefile changes.
- *
- * Revision 2.13  1994/07/26  01:12:20  root
- * prep for pre53_6.
- *
- * Revision 2.12  1994/07/14  23:19:20  root
- * Markkk's patches.
- *
- * Revision 2.11  1994/07/09  14:29:43  root
- * prep for pre53_3.
- *
- * Revision 2.10  1994/07/05  21:59:13  root
- * NCURSES IS HERE.
- *
- * Revision 2.9  1994/07/04  23:59:23  root
- * Prep for Markkk's NCURSES patches.
- *
- * Revision 2.8  1994/06/28  22:47:46  root
- * Prep for Markk's latest.
- *
- * Revision 2.7  1994/06/27  02:15:58  root
- * Prep for pre53
- *
- * Revision 2.6  1994/06/24  14:51:06  root
- * Markks's patches plus.
- *
- * Revision 2.5  1994/06/17  00:13:32  root
- * Let's wrap it up and call it DOSEMU0.52.
- *
- * Revision 2.4  1994/06/14  22:28:38  root
- * Prep for pre51_28.
- *
- * Revision 2.3  1994/06/14  22:00:18  root
- * Alistair's DANG inserted for the first time :-).
- *
- * Revision 2.2  1994/06/14  21:34:25  root
- * Second series of termcap patches.
- *
- * Revision 2.1  1994/06/12  23:15:37  root
- * Wrapping up prior to release of DOSEMU0.52.
- *
- * Revision 1.89  1994/06/05  21:17:35  root
- * Prep for pre51_24.
- *
- * Revision 1.88  1994/06/03  00:58:55  root
- * pre51_23 prep, Daniel's fix for scrbuf malloc().
- *
- * Revision 1.87  1994/05/30  00:08:20  root
- * Prep for pre51_22 and temp kludge fix for dir a: error.
- *
- * Revision 1.86  1994/05/26  23:15:01  root
- * Prep. for pre51_21.
- *
- * Revision 1.85  1994/05/24  01:23:00  root
- * Lutz's latest, int_queue_run() update.
- *
- * Revision 1.84  1994/05/21  23:39:19  root
- * PRE51_19.TGZ with Lutz's latest updates.
- *
- * Revision 1.83  1994/05/18  00:15:51  root
- * pre15_17.
- *
- * Revision 1.82  1994/05/16  23:13:23  root
- * Prep for pre51_16.
- *
- * Revision 1.81  1994/05/13  23:20:15  root
- * Pre51_15.
- *
- * Revision 1.80  1994/05/13  17:21:00  root
- * pre51_15.
- *
- * Revision 1.79  1994/05/13  01:47:59  root
- * Updates 1 for DV.
- *
- * Revision 1.78  1994/05/10  23:14:44  root
- * pre51_14.
- *
- * Revision 1.77  1994/05/10  23:08:10  root
- * pre51_14.
- *
- * Revision 1.76  1994/05/09  23:35:11  root
- * pre51_13.
- *
- * Revision 1.75  1994/05/05  00:16:26  root
- * Prep for pre51_12.
- *
- * Revision 1.74  1994/05/04  22:16:00  root
- * Patches by Alan to mouse subsystem.
- *
- * Revision 1.73  1994/05/04  21:56:55  root
- * Prior to Alan's mouse patches.
- *
- * Revision 1.72  1994/04/30  22:12:30  root
- * Prep for pre51_11.
- *
- * Revision 1.71  1994/04/30  01:05:16  root
- * Lutz's latest 94/04/29
- *
- * Revision 1.70  1994/04/29  23:52:06  root
- * Prior to Lutz's latest 94/04/29.
- *
- * Revision 1.69  1994/04/27  23:39:57  root
- * Lutz's patches to get dosemu up under 1.1.9.
- *
- * Revision 1.68  1994/04/27  21:34:15  root
- * Jochen's Latest.
- *
- * Revision 1.67  1994/04/23  20:51:40  root
- * Get new stack over/underflow working in VM86 mode.
- *
- * Revision 1.66  1994/04/23  20:10:38  root
- * Updated again for SP over/under flow.
- *
- * Revision 1.65  1994/04/20  23:43:35  root
- * pre51_8 out the door.
- *
- * Revision 1.64  1994/04/20  21:05:01  root
- * Prep for Rob's patches to linpkt...
- *
- * Revision 1.63  1994/04/18  22:52:19  root
- * Ready pre51_7.
- *
- * Revision 1.62  1994/04/18  20:57:34  root
- * Checkin prior to Jochen's latest patches.
- *
- * Revision 1.61  1994/04/16  14:41:41  root
- * Prep for pre51_6.
- *
- * Revision 1.60  1994/04/16  01:28:47  root
- * Prep for pre51_6.
- *
- * Revision 1.59  1994/04/13  00:07:09  root
- * Multiple patches from various sources.
- *
- * Revision 1.58  1994/04/09  18:41:52  root
- * Prior to Lutz's kernel enhancements.
- *
- * Revision 1.57  1994/04/07  20:50:59  root
- * More updates.
- *
- * Revision 1.56  1994/04/04  22:51:55  root
- * Patches for PS/2 mice.
- *
- * Revision 1.55  1994/03/30  22:12:30  root
- * Prep for 0.51 pre 2.
- *
- * Revision 1.54  1994/03/23  23:24:51  root
- * Prepare to split out do_int.
- *
- * Revision 1.53  1994/03/18  23:17:51  root
- * Prep for 0.50pl1
- *
- * Revision 1.52  1994/03/15  02:08:20  root
- * Testing
- *
- * Revision 1.51  1994/03/15  01:38:20  root
- * DPMI,serial, other changes.
- *
- * Revision 1.50  1994/03/14  00:35:44  root
- * Moved int_queue_run back into static array.
- *
- * Revision 1.49  1994/03/13  21:52:02  root
- * More speed testing :-(
- *
- * Revision 1.48  1994/03/13  01:07:31  root
- * Poor attempts to optimize.
- *
- * Revision 1.47  1994/03/10  23:52:52  root
- * Lutz DPMI patches
- *
- * Revision 1.46  1994/03/10  02:49:27  root
- * Back to SINGLE Process.
- *
- * Revision 1.45  1994/03/04  15:23:54  root
- * Run through indent.
- *
- * Revision 1.44  1994/03/04  14:46:13  root
- * Jochen patches.
- *
- * Revision 1.43  1994/03/04  00:01:58  root
- * Readying for 0.50
- *
- * Revision 1.42  1994/02/21  20:28:19  root
- * DPMI update
- *
- * Revision 1.41  1994/02/20  10:55:25  root
- * Added set_leds to int08 :-(.
- *
- * Revision 1.40  1994/02/20  10:00:16  root
- * More keyboard work :-(.
- *
- * Revision 1.39  1994/02/15  19:04:46  root
- * Roonie's cleaning up of inb/outb.
- *
- * Revision 1.38  1994/02/10  20:41:14  root
- * Last cleanup prior to release of pl4.
- *
- * Revision 1.37  1994/02/09  20:10:24  root
- * Added dosbanner config option for optionally displaying dosemu bannerinfo.
- * Added allowvideportaccess config option to deal with video ports.
- *
- * Revision 1.36  1994/02/05  21:45:55  root
- * Fixing Keyboard int15 4f to return AH=0x86.
- *
- * Revision 1.35  1994/02/02  21:12:56  root
- * Bringing the pktdrvr up to speed.
- *
- * Revision 1.34  1994/02/01  20:57:31  root
- * With unlimited thanks to gorden@jegnixa.hsc.missouri.edu (Jason Gorden),
- * here's a packet driver  to compliment Tim_R_Bird@Novell.COM's IPX work.
- *
- * Revision 1.33  1994/02/01  19:25:49  root
- * Fix to allow multiple graphics DOS sessions with my Trident card.
- *
- * Revision 1.32  1994/01/31  18:44:24  root
- * Work on making mouse work
- *
- * Revision 1.30  1994/01/30  14:29:51  root
- * Changed FCB callout for redirector, now inline and works with Create|O_TRUNC.
- *
- * Revision 1.29  1994/01/30  12:30:23  root
- * Changed dos_helper to int 0xe6.
- *
- * Revision 1.28  1994/01/28  20:04:07  root
- * Tim's IPX is ready to go.
+ * 
+ * DANG_BEGIN_CHANGELOG $Date: 1995/02/25 22:38:10 $ $Source:
+ * /home/src/dosemu0.60/RCS/emu.c,v $ $Revision: 2.36 $ $State: Exp $
+ * 
+ * $Log: emu.c,v $ Revision 2.36  1995/02/25  22:38:10  root *** empty log
+ * message ***
+ * 
+ * Revision 2.35  1995/02/25  21:53:22  root *** empty log message ***
+ * 
+ * Revision 2.34  1995/02/05  16:51:10  root Prep for Scotts patches.
+ * 
+ * Revision 2.33  1995/01/19  02:20:11  root Testing for Marty.
+ * 
+ * Revision 2.32  1995/01/14  15:28:03  root New Year checkin.
+ * 
+ * Revision 2.32  1994/12/06  03:33:50  leisner *** empty log message ***
+ * 
+ * Revision 2.31  1994/11/13  00:40:45  root Prep for Hans's latest.
+ * 
+ * Revision 2.30  1994/11/06  02:35:24  root Testing co -M.
+ * 
+ * Revision 2.28  1994/10/14  17:58:38  root Prep for pre53_27.tgz
+ * 
+ * Revision 2.27  1994/10/03  00:24:25  root Checkin prior to pre53_25.tgz
+ * 
+ * Revision 2.26  1994/09/26  23:10:13  root Prep for pre53_22.
+ * 
+ * Revision 2.25  1994/09/23  01:29:36  root Prep for pre53_21.
+ * 
+ * Revision 2.24  1994/09/22  23:51:57  root Prep for pre53_21.
+ * 
+ * Revision 2.23  1994/09/20  01:53:26  root Prep for pre53_21.
+ * 
+ * Revision 2.22  1994/09/11  01:01:23  root Prep for pre53_19.
+ * 
+ * Revision 2.21  1994/08/25  00:49:34  root Lutz's STI patches and prep for
+ * pre53_16.
+ * 
+ * Revision 2.20  1994/08/17  02:08:22  root Mods to Rain's patches to get
+ * all modes back on the road.
+ * 
+ * Revision 2.19  1994/08/14  02:52:04  root Rain's latest CLEANUP and MOUSE
+ * for X additions.
+ * 
+ * Revision 2.18  1994/08/09  01:49:57  root Prep for pre53_11.
+ * 
+ * Revision 2.17  1994/08/05  22:29:31  root Prep dir pre53_10.
+ * 
+ * Revision 2.16  1994/08/02  00:08:51  root Markk's latest.
+ * 
+ * Revision 2.15  1994/08/01  14:58:59  root Added detach (-d) option from
+ * Karl Hakimian.
+ * 
+ * Revision 2.14  1994/08/01  14:26:23  root Prep for pre53_7  with Markks
+ * latest, EMS patch, and Makefile changes.
+ * 
+ * Revision 2.13  1994/07/26  01:12:20  root prep for pre53_6.
+ * 
+ * Revision 2.12  1994/07/14  23:19:20  root Markkk's patches.
+ * 
+ * Revision 2.11  1994/07/09  14:29:43  root prep for pre53_3.
+ * 
+ * Revision 2.10  1994/07/05  21:59:13  root NCURSES IS HERE.
+ * 
+ * Revision 2.9  1994/07/04  23:59:23  root Prep for Markkk's NCURSES
+ * patches.
+ * 
+ * Revision 2.8  1994/06/28  22:47:46  root Prep for Markk's latest.
+ * 
+ * Revision 2.7  1994/06/27  02:15:58  root Prep for pre53
+ * 
+ * Revision 2.6  1994/06/24  14:51:06  root Markks's patches plus.
+ * 
+ * Revision 2.5  1994/06/17  00:13:32  root Let's wrap it up and call it
+ * DOSEMU0.52.
+ * 
+ * Revision 2.4  1994/06/14  22:28:38  root Prep for pre51_28.
+ * 
+ * Revision 2.3  1994/06/14  22:00:18  root Alistair's DANG inserted for the
+ * first time :-).
+ * 
+ * Revision 2.2  1994/06/14  21:34:25  root Second series of termcap patches.
+ * 
+ * Revision 2.1  1994/06/12  23:15:37  root Wrapping up prior to release of
+ * DOSEMU0.52.
+ * 
+ * Revision 1.89  1994/06/05  21:17:35  root Prep for pre51_24.
+ * 
+ * Revision 1.88  1994/06/03  00:58:55  root pre51_23 prep, Daniel's fix for
+ * scrbuf malloc().
+ * 
+ * Revision 1.87  1994/05/30  00:08:20  root Prep for pre51_22 and temp
+ * kludge fix for dir a: error.
+ * 
+ * Revision 1.86  1994/05/26  23:15:01  root Prep. for pre51_21.
+ * 
+ * Revision 1.85  1994/05/24  01:23:00  root Lutz's latest, int_queue_run()
+ * update.
+ * 
+ * Revision 1.84  1994/05/21  23:39:19  root PRE51_19.TGZ with Lutz's latest
+ * updates.
+ * 
+ * Revision 1.83  1994/05/18  00:15:51  root pre15_17.
+ * 
+ * Revision 1.82  1994/05/16  23:13:23  root Prep for pre51_16.
+ * 
+ * Revision 1.81  1994/05/13  23:20:15  root Pre51_15.
+ * 
+ * Revision 1.80  1994/05/13  17:21:00  root pre51_15.
+ * 
+ * Revision 1.79  1994/05/13  01:47:59  root Updates 1 for DV.
+ * 
+ * Revision 1.78  1994/05/10  23:14:44  root pre51_14.
+ * 
+ * Revision 1.77  1994/05/10  23:08:10  root pre51_14.
+ * 
+ * Revision 1.76  1994/05/09  23:35:11  root pre51_13.
+ * 
+ * Revision 1.75  1994/05/05  00:16:26  root Prep for pre51_12.
+ * 
+ * Revision 1.74  1994/05/04  22:16:00  root Patches by Alan to mouse
+ * subsystem.
+ * 
+ * Revision 1.73  1994/05/04  21:56:55  root Prior to Alan's mouse patches.
+ * 
+ * Revision 1.72  1994/04/30  22:12:30  root Prep for pre51_11.
+ * 
+ * Revision 1.71  1994/04/30  01:05:16  root Lutz's latest 94/04/29
+ * 
+ * Revision 1.70  1994/04/29  23:52:06  root Prior to Lutz's latest 94/04/29.
+ * 
+ * Revision 1.69  1994/04/27  23:39:57  root Lutz's patches to get dosemu up
+ * under 1.1.9.
+ * 
+ * Revision 1.68  1994/04/27  21:34:15  root Jochen's Latest.
+ * 
+ * Revision 1.67  1994/04/23  20:51:40  root Get new stack over/underflow
+ * working in VM86 mode.
+ * 
+ * Revision 1.66  1994/04/23  20:10:38  root Updated again for SP over/under
+ * flow.
+ * 
+ * Revision 1.65  1994/04/20  23:43:35  root pre51_8 out the door.
+ * 
+ * Revision 1.64  1994/04/20  21:05:01  root Prep for Rob's patches to
+ * linpkt...
+ * 
+ * Revision 1.63  1994/04/18  22:52:19  root Ready pre51_7.
+ * 
+ * Revision 1.62  1994/04/18  20:57:34  root Checkin prior to Jochen's latest
+ * patches.
+ * 
+ * Revision 1.61  1994/04/16  14:41:41  root Prep for pre51_6.
+ * 
+ * Revision 1.60  1994/04/16  01:28:47  root Prep for pre51_6.
+ * 
+ * Revision 1.59  1994/04/13  00:07:09  root Multiple patches from various
+ * sources.
+ * 
+ * Revision 1.58  1994/04/09  18:41:52  root Prior to Lutz's kernel
+ * enhancements.
+ * 
+ * Revision 1.57  1994/04/07  20:50:59  root More updates.
+ * 
+ * Revision 1.56  1994/04/04  22:51:55  root Patches for PS/2 mice.
+ * 
+ * Revision 1.55  1994/03/30  22:12:30  root Prep for 0.51 pre 2.
+ * 
+ * Revision 1.54  1994/03/23  23:24:51  root Prepare to split out do_int.
+ * 
+ * Revision 1.53  1994/03/18  23:17:51  root Prep for 0.50pl1
+ * 
+ * Revision 1.52  1994/03/15  02:08:20  root Testing
+ * 
+ * Revision 1.51  1994/03/15  01:38:20  root DPMI,serial, other changes.
+ * 
+ * Revision 1.50  1994/03/14  00:35:44  root Moved int_queue_run back into
+ * static array.
+ * 
+ * Revision 1.49  1994/03/13  21:52:02  root More speed testing :-(
+ * 
+ * Revision 1.48  1994/03/13  01:07:31  root Poor attempts to optimize.
+ * 
+ * Revision 1.47  1994/03/10  23:52:52  root Lutz DPMI patches
+ * 
+ * Revision 1.46  1994/03/10  02:49:27  root Back to SINGLE Process.
+ * 
+ * Revision 1.45  1994/03/04  15:23:54  root Run through indent.
+ * 
+ * Revision 1.44  1994/03/04  14:46:13  root Jochen patches.
+ * 
+ * Revision 1.43  1994/03/04  00:01:58  root Readying for 0.50
+ * 
+ * Revision 1.42  1994/02/21  20:28:19  root DPMI update
+ * 
+ * Revision 1.41  1994/02/20  10:55:25  root Added set_leds to int08 :-(.
+ * 
+ * Revision 1.40  1994/02/20  10:00:16  root More keyboard work :-(.
+ * 
+ * Revision 1.39  1994/02/15  19:04:46  root Roonie's cleaning up of
+ * inb/outb.
+ * 
+ * Revision 1.38  1994/02/10  20:41:14  root Last cleanup prior to release of
+ * pl4.
+ * 
+ * Revision 1.37  1994/02/09  20:10:24  root Added dosbanner config option
+ * for optionally displaying dosemu bannerinfo. Added allowvideportaccess
+ * config option to deal with video ports.
+ * 
+ * Revision 1.36  1994/02/05  21:45:55  root Fixing Keyboard int15 4f to
+ * return AH=0x86.
+ * 
+ * Revision 1.35  1994/02/02  21:12:56  root Bringing the pktdrvr up to
+ * speed.
+ * 
+ * Revision 1.34  1994/02/01  20:57:31  root With unlimited thanks to
+ * gorden@jegnixa.hsc.missouri.edu (Jason Gorden), here's a packet driver
+ * to compliment Tim_R_Bird@Novell.COM's IPX work.
+ * 
+ * Revision 1.33  1994/02/01  19:25:49  root Fix to allow multiple graphics
+ * DOS sessions with my Trident card.
+ * 
+ * Revision 1.32  1994/01/31  18:44:24  root Work on making mouse work
+ * 
+ * Revision 1.30  1994/01/30  14:29:51  root Changed FCB callout for
+ * redirector, now inline and works with Create|O_TRUNC.
+ * 
+ * Revision 1.29  1994/01/30  12:30:23  root Changed dos_helper to int 0xe6.
+ * 
+ * Revision 1.28  1994/01/28  20:04:07  root Tim's IPX is ready to go.
  * Modified mmap strategy.
- *
- * Revision 1.27  1994/01/28  18:52:58  root
- * Fix int15 0xc0 call.
- *
- * Revision 1.26  1994/01/27  22:09:20  root
- * Allow USAGE to display before default stderr redirection.
- *
- * Revision 1.25  1994/01/27  21:47:09  root
- * Introducing IPX from Tim_R_Bird@Novell.COM.
- *
- * Revision 1.24  1994/01/27  19:43:54  root
- * Preparing for Tim's IPX.
- * Added dos auto-redirect to stderr.
- * Started saytime() function
- *
- * Revision 1.23  1994/01/25  20:02:44  root
- * Modified hard_int routine again.
- * Exchange stderr <-> stdout.
- * Made stderr redirect to /dev/null if user does not redirect it.
- *
- * Revision 1.22  1994/01/20  21:14:24  root
- * Indent, more work serially handling multiple interrupts.
- *
- * Revision 1.21  1994/01/19  20:27:20  root
- * Deleted comment about int16 to inline.
- *
- * Revision 1.20  1994/01/19  17:51:14  root
- * Added dpmi/dpmi.h include for interrupts.
- * Added code to allow int09 (keyboard) to allow another interrupt by using
- * outb(20) called by dos programs.
- * Added code to allow FCB callbacks when mfs.c does an FCB open, kinda kludgy
- * at this time.
- * Modified inline int09 to pass ALL keys to int15-4f function.
- * Added a far return for DPMI call to go protected.
- * Removed old int16 function.
+ * 
+ * Revision 1.27  1994/01/28  18:52:58  root Fix int15 0xc0 call.
+ * 
+ * Revision 1.26  1994/01/27  22:09:20  root Allow USAGE to display before
+ * default stderr redirection.
+ * 
+ * Revision 1.25  1994/01/27  21:47:09  root Introducing IPX from
+ * Tim_R_Bird@Novell.COM.
+ * 
+ * Revision 1.24  1994/01/27  19:43:54  root Preparing for Tim's IPX. Added
+ * dos auto-redirect to stderr. Started saytime() function
+ * 
+ * Revision 1.23  1994/01/25  20:02:44  root Modified hard_int routine again.
+ * Exchange stderr <-> stdout. Made stderr redirect to /dev/null if user
+ * does not redirect it.
+ * 
+ * Revision 1.22  1994/01/20  21:14:24  root Indent, more work serially
+ * handling multiple interrupts.
+ * 
+ * Revision 1.21  1994/01/19  20:27:20  root Deleted comment about int16 to
+ * inline.
+ * 
+ * Revision 1.20  1994/01/19  17:51:14  root Added dpmi/dpmi.h include for
+ * interrupts. Added code to allow int09 (keyboard) to allow another
+ * interrupt by using outb(20) called by dos programs. Added code to allow
+ * FCB callbacks when mfs.c does an FCB open, kinda kludgy at this time.
+ * Modified inline int09 to pass ALL keys to int15-4f function. Added a
+ * far return for DPMI call to go protected. Removed old int16 function.
  * Changed dos_helper int e5 to not be revectored. Still no good for my
- * Direct Access, but I'll fix that next :-).
- * Changed int08 inside of do_int() to return after being called.
- * Allowed dos_helper to pass through if redirected, after being called.
- *
- * Revision 1.19  1994/01/12  21:27:15  root
- * Some more EMS fixups
- *
- * Revision 1.18  1994/01/03  22:19:25  root
- * Debugging
- *
- * Revision 1.17  1994/01/01  17:06:19  root
- * Hack to fix EMS not having ax on top of stack. Needs to be debugged !
- *
- * Revision 1.16  1993/12/31  09:29:01  root
- * Added dos_helper hook to Theadore T'so's booton bootoff patch. Now a
- * user can boot from a bootdisk a: type diskimage, and then return control
- * of a: to /dev/fd0. Alright :-).
- *
- * Revision 1.15  1993/12/30  15:11:50  root
- * Fixing multiple emufs.sys problem.
- *
- * Revision 1.14  1993/12/30  11:18:32  root
- * Updates for Diamond Card.
- *
- * Revision 1.13  1993/12/27  19:06:29  root
- * Small fixes for EMS
- *
- * Revision 1.12  1993/12/22  11:45:36  root
- * Keyboard enhancements, and more debug for EMS
- *
- * Revision 1.11  1993/12/05  20:59:03  root
- * Dimond card work.
- *
- * Revision 1.10  1993/11/30  22:21:03  root
- * Final Freeze for release pl3
- *
- * Revision 1.9  1993/11/30  21:26:44  root
- * Chips First set of patches, WOW!
- *
- * Revision 1.8  1993/11/29  22:44:11  root
- * Prepare for release of pl3
- *
- * Revision 1.7  1993/11/29  00:05:32  root
- * Overhauling keyboard and some timing stuff.
- *
- * Revision 1.6  1993/11/25  22:45:21  root
- * About to destroy keybaord routines.
- *
- * Revision 1.5  1993/11/23  22:24:53  root
- * *** empty log message ***
- *
- * Revision 1.4  1993/11/17  22:29:33  root
- * *** empty log message ***
- *
- * Revision 1.3  1993/11/15  19:56:49  root
- * Fixed sp -> ssp overflow, it is a hack at this time, but it works.
- *
- * Revision 1.2  1993/11/12  13:00:04  root
- * Keybuffer updates. REAL_INT16 addition. Link List for Hard INTs.
- *
- * Revision 1.7  1993/07/21  01:52:19  rsanders
- * uses new ems.sys for EMS emulation
- *
- * Revision 1.6  1993/07/19  18:44:01  rsanders
- * removed all "wait on ext. event" messages
- *
- * Revision 1.5  1993/07/14  04:34:06  rsanders
- * changed printing of "wait on external event" warnings.
- *
- * Revision 1.4  1993/07/13  19:18:38  root
- * changes for using the new (0.99pl10) signal stacks
- *
- * Revision 1.3  1993/07/07  21:42:04  root
- * minor changes for -Wall
- *
- * Revision 1.2  1993/07/07  01:33:10  root
- * hook for parse_config(name);
- *
- * Revision 1.1  1993/07/07  00:49:06  root
- * Initial revision
- *
- * Revision 1.27  1993/05/04  05:29:22  root
- * added console switching, new parse commands, and serial emulation
- *
- * Revision 1.26  1993/04/07  21:04:26  root
- * big move
- *
- * Revision 1.25  1993/04/05  17:25:13  root
- * big pre-49 checkin; EMS, new MFS redirector, etc.
- *
- * Revision 1.24  1993/03/04  22:35:12  root
- * put in perfect shared memory, HMA and everything.  added PROPER_STI.
- *
- * Revision 1.23  1993/03/02  03:06:42  root
- * somewhere between 0.48pl1 and 0.49 (with IPC).  added virtual IOPL
- * and AC support (for 386/486 tests), -3 and -4 flags for choosing.
- * Split dosemu into 2 processes; the child select()s on the keyboard,
- * and signals the parent when a key is received (also sends it on a
- * UNIX domain socket...this might not work well for non-console keyb).
- *
+ * Direct Access, but I'll fix that next :-). Changed int08 inside of
+ * do_int() to return after being called. Allowed dos_helper to pass
+ * through if redirected, after being called.
+ * 
+ * Revision 1.19  1994/01/12  21:27:15  root Some more EMS fixups
+ * 
+ * Revision 1.18  1994/01/03  22:19:25  root Debugging
+ * 
+ * Revision 1.17  1994/01/01  17:06:19  root Hack to fix EMS not having ax on
+ * top of stack. Needs to be debugged !
+ * 
+ * Revision 1.16  1993/12/31  09:29:01  root Added dos_helper hook to
+ * Theadore T'so's booton bootoff patch. Now a user can boot from a
+ * bootdisk a: type diskimage, and then return control of a: to /dev/fd0.
+ * Alright :-).
+ * 
+ * Revision 1.15  1993/12/30  15:11:50  root Fixing multiple emufs.sys
+ * problem.
+ * 
+ * Revision 1.14  1993/12/30  11:18:32  root Updates for Diamond Card.
+ * 
+ * Revision 1.13  1993/12/27  19:06:29  root Small fixes for EMS
+ * 
+ * Revision 1.12  1993/12/22  11:45:36  root Keyboard enhancements, and more
+ * debug for EMS
+ * 
+ * Revision 1.11  1993/12/05  20:59:03  root Dimond card work.
+ * 
+ * Revision 1.10  1993/11/30  22:21:03  root Final Freeze for release pl3
+ * 
+ * Revision 1.9  1993/11/30  21:26:44  root Chips First set of patches, WOW!
+ * 
+ * Revision 1.8  1993/11/29  22:44:11  root Prepare for release of pl3
+ * 
+ * Revision 1.7  1993/11/29  00:05:32  root Overhauling keyboard and some
+ * timing stuff.
+ * 
+ * Revision 1.6  1993/11/25  22:45:21  root About to destroy keybaord
+ * routines.
+ * 
+ * Revision 1.5  1993/11/23  22:24:53  root *** empty log message ***
+ * 
+ * Revision 1.4  1993/11/17  22:29:33  root *** empty log message ***
+ * 
+ * Revision 1.3  1993/11/15  19:56:49  root Fixed sp -> ssp overflow, it is a
+ * hack at this time, but it works.
+ * 
+ * Revision 1.2  1993/11/12  13:00:04  root Keybuffer updates. REAL_INT16
+ * addition. Link List for Hard INTs.
+ * 
+ * Revision 1.7  1993/07/21  01:52:19  rsanders uses new ems.sys for EMS
+ * emulation
+ * 
+ * Revision 1.6  1993/07/19  18:44:01  rsanders removed all "wait on ext.
+ * event" messages
+ * 
+ * Revision 1.5  1993/07/14  04:34:06  rsanders changed printing of "wait on
+ * external event" warnings.
+ * 
+ * Revision 1.4  1993/07/13  19:18:38  root changes for using the new
+ * (0.99pl10) signal stacks
+ * 
+ * Revision 1.3  1993/07/07  21:42:04  root minor changes for -Wall
+ * 
+ * Revision 1.2  1993/07/07  01:33:10  root hook for parse_config(name);
+ * 
+ * Revision 1.1  1993/07/07  00:49:06  root Initial revision
+ * 
+ * Revision 1.27  1993/05/04  05:29:22  root added console switching, new
+ * parse commands, and serial emulation
+ * 
+ * Revision 1.26  1993/04/07  21:04:26  root big move
+ * 
+ * Revision 1.25  1993/04/05  17:25:13  root big pre-49 checkin; EMS, new MFS
+ * redirector, etc.
+ * 
+ * Revision 1.24  1993/03/04  22:35:12  root put in perfect shared memory,
+ * HMA and everything.  added PROPER_STI.
+ * 
+ * Revision 1.23  1993/03/02  03:06:42  root somewhere between 0.48pl1 and
+ * 0.49 (with IPC).  added virtual IOPL and AC support (for 386/486
+ * tests), -3 and -4 flags for choosing. Split dosemu into 2 processes;
+ * the child select()s on the keyboard, and signals the parent when a key
+ * is received (also sends it on a UNIX domain socket...this might not
+ * work well for non-console keyb).
+ * 
  * DANG_END_CHANGELOG
  */
 
 
 /*
- * DANG_BEGIN_REMARK
-   DOSEMU must not work within the 1 meg DOS limit, so start of code
-   is loaded at a higher address, at some time this could conflict with
-   other shared libs. If DOSEMU is compiled statically (without shared
-   libs), and org instruction is used to provide the jump above 1 meg.
- * DANG_END_REMARK
-*/
+ * DANG_BEGIN_REMARK DOSEMU must not work within the 1 meg DOS limit, so
+ * start of code is loaded at a higher address, at some time this could
+ * conflict with other shared libs. If DOSEMU is compiled statically
+ * (without shared libs), and org instruction is used to provide the jump
+ * above 1 meg. DANG_END_REMARK
+ */
 
 #ifndef __ELF__
 /*
  * DANG_BEGIN_FUNCTION jmp_emulate
- *
- * description:
- * This function allows the startup program `dos` to know how to call
- * the emulate function by way of the dll headers.
- * Always make sure that this line is the first of emu.c
- * and link emu.o as the first object file to the lib
- *
+ * 
+ * description: This function allows the startup program `dos` to know how to
+ * call the emulate function by way of the dll headers. Always make sure
+ * that this line is the first of emu.c and link emu.o as the first object
+ * file to the lib
+ * 
  * DANG_END_FUNCTION
  */
 __asm__("___START___: jmp _emulate\n");
@@ -529,285 +437,296 @@
 #include "dpmi.h"
 #endif
 
-extern void stdio_init(void);
-extern void time_setting_init(void);
-extern void tmpdir_init(void);
-extern void low_mem_init(void);
-
-extern void shared_memory_exit(void);
-extern void restore_vt (unsigned short);
-extern void disallocate_vt (void);
-extern void keyboard_close(void);
-extern void vm86_GP_fault();
-extern void config_init(int argc, char **argv);
+extern void     stdio_init(void);
+extern void     time_setting_init(void);
+extern void     tmpdir_init(void);
+extern void     low_mem_init(void);
+
+extern void     shared_memory_exit(void);
+extern void     restore_vt(unsigned short);
+extern void     disallocate_vt(void);
+extern void     keyboard_close(void);
+extern void     vm86_GP_fault();
+extern void     config_init(int argc, char **argv);
 
 
 #ifndef NEW_PIC
 /* Programmable Interrupt Controller, 8259 */
 struct pic {
-  int stage;			/* where in init. , 0=ICW1 */
-  /* the seq. is ICW1 to 0x20, ICW2 to 0x21
-         * if ICW1:D1=0, ICW3 to 0x20h,
-	 * ICW4 to 0x21, OCWs any order
-	 */
-  unsigned char
-   ICW1,			/* Input Control Words */
-   ICW2, ICW3, ICW4, OCW1,	/* Output Control Words */
-   OCW2, OCW3;
+    int             stage;	/* where in init. , 0=ICW1 */
+    /*
+     * the seq. is ICW1 to 0x20, ICW2 to 0x21 if ICW1:D1=0, ICW3 to 0x20h,
+     * ICW4 to 0x21, OCWs any order
+     */
+    unsigned char
+                    ICW1,	/* Input Control Words */
+                    ICW2,
+                    ICW3,
+                    ICW4,
+                    OCW1,	/* Output Control Words */
+                    OCW2,
+                    OCW3;
 }
 
-pics[2];
+pics            [2];
 #endif
-static int special_nowait = 0;
+static int      special_nowait = 0;
 
 
 
-static int poll_io = 1;		/* polling io, default on */
+static int      poll_io = 1;	/* polling io, default on */
 
 
 /*
  * DANG_BEGIN_FUNCTION run_vm86
- *
- * description:
- *  Here is where DOSEMU runs VM86 mode with the vm86() call which
- *  also has the registers that it will be called with. It will stop
- *  vm86 mode for many reasons, like trying to execute an interrupt,
- *  doing port I/O to ports not opened for I/O, etc ...
- *
+ * 
+ * description: Here is where DOSEMU runs VM86 mode with the vm86() call
+ * which also has the registers that it will be called with. It will stop
+ * vm86 mode for many reasons, like trying to execute an interrupt, doing
+ * port I/O to ports not opened for I/O, etc ...
+ * 
  * DANG_END_FUNCTION
  */
 void
 run_vm86(void)
 {
-  /* FIXME: why static *? */
-  static int retval;
-  static u_short next_signal=0;
-  /*
-   * always invoke vm86() with this call.  all the messy stuff will
-   * be in here.
-   */
+    /* FIXME: why static *? */
+    static int      retval;
+    static u_short  next_signal = 0;
+    /*
+     * always invoke vm86() with this call.  all the messy stuff will be
+     * in here.
+     */
     in_vm86 = 1;
 #ifdef NEW_PIC
-    if(pic_icount) 
-      REG(eflags) |= (VIP);
+    if (pic_icount)
+	REG(eflags) |= (VIP);
 #endif
     /* FIXME: this needs to be clarified and rewritten */
 
     retval = vm86(&vm86s);
     in_vm86 = 0;
-    switch VM86_TYPE(retval) {
-	case VM86_UNKNOWN:
-		vm86_GP_fault();
-		break;
-	case VM86_STI:
-		I_printf("Return from vm86() for timeout\n");
+    switch VM86_TYPE
+	(retval) {
+    case VM86_UNKNOWN:
+	vm86_GP_fault();
+	break;
+    case VM86_STI:
+	I_printf("Return from vm86() for timeout\n");
 #ifndef NEW_PIC
-		REG(eflags) &= ~(VIP);
+	REG(eflags) &= ~(VIP);
 #else
-          	pic_iret();
+	pic_iret();
 #endif
-		break;
-	case VM86_INTx:
-		do_int(VM86_ARG(retval));
-		break;
-	case VM86_SIGNAL:
-		I_printf("Return for SIGNAL\n");
-		break;
-	default:
-		error("unknown return value from vm86()=%x,%d-%x\n", VM86_TYPE(retval), VM86_TYPE(retval), VM86_ARG(retval));
-		fatalerr = 4;
-    }
+	break;
+    case VM86_INTx:
+	do_int(VM86_ARG(retval));
+	break;
+    case VM86_SIGNAL:
+	I_printf("Return for SIGNAL\n");
+	break;
+    default:
+	error("unknown return value from vm86()=%x,%d-%x\n", VM86_TYPE(retval), VM86_TYPE(retval), VM86_ARG(retval));
+	fatalerr = 4;
+	}
 
-  handle_signals();
+    handle_signals();
 
-  /* 
-   * This is here because ioctl() is non-reentrant, and signal handlers
-   * may have to use ioctl().  This results in a possible (probable) time
-   * lag of indeterminate length (and a bad return value).
-   * Ah, life isn't perfect.
-   *
-   * I really need to clean up the queue functions to use real queues.
-   */
-  if (iq.queued)
-    do_queued_ioctl();
+    /*
+     * This is here because ioctl() is non-reentrant, and signal handlers
+     * may have to use ioctl().  This results in a possible (probable)
+     * time lag of indeterminate length (and a bad return value). Ah, life
+     * isn't perfect.
+     * 
+     * I really need to clean up the queue functions to use real queues.
+     */
+    if (iq.queued)
+	do_queued_ioctl();
 #ifdef NEW_PIC
-/* update the pic to reflect IEF */
-  if (REG(eflags)&IF_MASK) {
-    if (pic_iflag) pic_sti();
+    /* update the pic to reflect IEF */
+    if (REG(eflags) & IF_MASK) {
+	if (pic_iflag)
+	    pic_sti();
+    } else {
+	if (!pic_iflag)
+	    pic_cli();		/* pic_iflag=0 => enabled */
     }
-  else {
-    if (!pic_iflag) pic_cli(); /* pic_iflag=0 => enabled */
-    }
 #endif
 }
 
-void boot(void)
+void 
+boot(void)
 {
-  char *buffer;
-  struct disk *dp = NULL;
+    char           *buffer;
+    struct disk    *dp = NULL;
 
-  switch (config.hdiskboot) {
-  case 0:
-    if (config.bootdisk)
-      dp = &bootdisk;
-    else
-      dp = &disktab[0];
-    break;
-  case 1:
-    dp = &hdisktab[0];
-    break;
-  case 2:
-    dp = &disktab[1];
-    break;
-  default:
-    error("ERROR: unexpected value for config.hdiskboot\n");
-    leavedos(15);
-  }
-
-  ignore_segv++;
-
-  disk_close();
-  disk_open(dp);
-
-  buffer = (char *) 0x7c00;
-
-  if (dp->type == PARTITION) {   /* we boot partition boot record, not MBR! */
-    d_printf("Booting partition boot record from part=%s....\n", dp->dev_name);
-    if (RPT_SYSCALL(read(dp->fdesc, buffer, SECTOR_SIZE)) != SECTOR_SIZE) {
-      error("ERROR: reading partition boot sector using partition %s.\n", dp->dev_name);
-      leavedos(16);
+    switch (config.hdiskboot) {
+    case 0:
+	if (config.bootdisk)
+	    dp = &bootdisk;
+	else
+	    dp = &disktab[0];
+	break;
+    case 1:
+	dp = &hdisktab[0];
+	break;
+    case 2:
+	dp = &disktab[1];
+	break;
+    default:
+	error("ERROR: unexpected value for config.hdiskboot\n");
+	leavedos(15);
     }
-  }
-  else if (read_sectors(dp, buffer, 0, 0, 0, 1) != SECTOR_SIZE) {
-    error("ERROR: can't boot from %s, using harddisk\n", dp->dev_name);
-    dp = hdisktab;
-    if (read_sectors(dp, buffer, 0, 0, 0, 1) != SECTOR_SIZE) {
-      error("ERROR: can't boot from hard disk\n");
-      leavedos(16);
+
+    ignore_segv++;
+
+    disk_close();
+    disk_open(dp);
+
+    buffer = (char *) 0x7c00;
+
+    if (dp->type == PARTITION) {/* we boot partition boot record, not MBR! */
+	d_printf("Booting partition boot record from part=%s....\n", dp->dev_name);
+	if (RPT_SYSCALL(read(dp->fdesc, buffer, SECTOR_SIZE)) != SECTOR_SIZE) {
+	    error("ERROR: reading partition boot sector using partition %s.\n", dp->dev_name);
+	    leavedos(16);
+	}
+    } else if (read_sectors(dp, buffer, 0, 0, 0, 1) != SECTOR_SIZE) {
+	error("ERROR: can't boot from %s, using harddisk\n", dp->dev_name);
+	dp = hdisktab;
+	if (read_sectors(dp, buffer, 0, 0, 0, 1) != SECTOR_SIZE) {
+	    error("ERROR: can't boot from hard disk\n");
+	    leavedos(16);
+	}
     }
-  }
-  disk_close();
-  ignore_segv--;
+    disk_close();
+    ignore_segv--;
 }
 
 /* Silly Interrupt Generator Initialization/Closedown */
 
 #ifdef SIG
-SillyG_t *SillyG = 0;
-static SillyG_t SillyG_[16+1];
+SillyG_t       *SillyG = 0;
+static SillyG_t SillyG_[16 + 1];
 #endif
 
-/* 
+/*
  * DANG_BEGIN_FUNCTION SIG_int
- *
- * description:
- *  Allow DOSEMU to be made aware when a hard interrupt occurs
- *  Requires the sig/sillyint.o driver loaded (using NEW modules package),
- *  or a kernel patch (implementing sig/int.c driver).
- *
- *  The IRQ numbers to monitor are taken from config.sillyint, each bit
- *  corresponding to one IRQ. The higher 16 bit are defining the use of SIGIO
- *
+ * 
+ * description: Allow DOSEMU to be made aware when a hard interrupt occurs
+ * Requires the sig/sillyint.o driver loaded (using NEW modules package),
+ * or a kernel patch (implementing sig/int.c driver).
+ * 
+ * The IRQ numbers to monitor are taken from config.sillyint, each bit
+ * corresponding to one IRQ. The higher 16 bit are defining the use of
+ * SIGIO
+ * 
  * DANG_END_FUNCTION
  */
-static inline void SIG_init()
+static inline void 
+SIG_init()
 {
 #ifdef SIG
-  /* Get in touch with my Silly Interrupt Driver */
-  if (config.sillyint) {
-    char devname[20];
-    char prio_table[]={9,10,11,12,14,15,3,4,5,6,7};
-    int i,irq,fd;
-    SillyG_t *sg=SillyG_;
-    for (i=0; i<sizeof(prio_table); i++) {
-      irq=prio_table[i];
-      if (config.sillyint & (1 << irq)) {
+    /* Get in touch with my Silly Interrupt Driver */
+    if (config.sillyint) {
+	char            devname[20];
+	char            prio_table[] =
+	{9, 10, 11, 12, 14, 15, 3, 4, 5, 6, 7};
+	int             i,
+	                irq,
+	                fd;
+	SillyG_t       *sg = SillyG_;
+	for (i = 0; i < sizeof(prio_table); i++) {
+	    irq = prio_table[i];
+	    if (config.sillyint & (1 << irq)) {
 #ifdef REQUIRES_EMUMODULE
-        if (emusyscall(EMUSYS_REQUEST_IRQ, irq)<0) {
-          g_printf("Not gonna touch IRQ %d you requested!\n",irq);
-        }
-        else {
-          g_printf("Gonna monitor the IRQ %d you requested\n", irq);
-          sg->fd=-1;
+		if (emusyscall(EMUSYS_REQUEST_IRQ, irq) < 0) {
+		    g_printf("Not gonna touch IRQ %d you requested!\n", irq);
+		} else {
+		    g_printf("Gonna monitor the IRQ %d you requested\n", irq);
+		    sg->fd = -1;
 #else
-        sprintf(devname, "/dev/int/%d", irq);
-        if ((fd = open(devname, O_RDWR)) < 1) {
-          g_printf("Not gonna touch IRQ %d you requested!\n",irq);
-        }
-        else {
-          /* Reset interupt incase it went off already */
-          RPT_SYSCALL(write(fd, NULL, (int) NULL));
-          g_printf("Gonna monitor the IRQ %d you requested, Return=0x%02x\n", irq ,fd);
-          if (config.sillyint & (0x10000 << irq)) {
-            /* Use SIGIO, this should be faster */ 
-            add_to_io_select(fd, 1);
-          }
-          /* DANG_BEGIN_REMARK
-           * At this time we have to use SIGALRM in addition to SIGIO
-           * I don't (yet) know why the SIGIO signal gets lost sometimes
-           * (once per minute or longer). 
-           * But if it happens, we can retrigger this way over SIGALRM.
-           * Normally SIGIO happens before SIGALARM, so nothing hurts.
-           * (Hans)
-           * DANG_END_REMARK
-           */  
+		sprintf(devname, "/dev/int/%d", irq);
+		if ((fd = open(devname, O_RDWR)) < 1) {
+		    g_printf("Not gonna touch IRQ %d you requested!\n", irq);
+		} else {
+		    /* Reset interupt incase it went off already */
+		    RPT_SYSCALL(write(fd, NULL, (int) NULL));
+		    g_printf("Gonna monitor the IRQ %d you requested, Return=0x%02x\n", irq, fd);
+		    if (config.sillyint & (0x10000 << irq)) {
+			/* Use SIGIO, this should be faster */
+			add_to_io_select(fd, 1);
+		    }
+		    /*
+		     * DANG_BEGIN_REMARK At this time we have to use
+		     * SIGALRM in addition to SIGIO I don't (yet) know why
+		     * the SIGIO signal gets lost sometimes (once per
+		     * minute or longer). But if it happens, we can
+		     * retrigger this way over SIGALRM. Normally SIGIO
+		     * happens before SIGALARM, so nothing hurts. (Hans)
+		     * DANG_END_REMARK
+		     */
 #if 0
-          else 
+		    else
 #endif
-          {
-            /* use SIGALRM  */
-            add_to_io_select(fd, 0);
-          }
-          sg->fd=fd;
-#endif /* NOT REQUIRES_EMUMODULE */
+		    {
+			/* use SIGALRM  */
+			add_to_io_select(fd, 0);
+		    }
+		    sg->fd = fd;
+#endif				/* NOT REQUIRES_EMUMODULE */
 #ifndef NEW_PIC
-          (sg++)->irq=irq;
+		    (sg++)->irq = irq;
 #else
-    	  sg->irq = pic_irq_list[irq];
-    	  g_printf("SIG %x: enabling interrupt %x\n", irq, sg->irq);
-    	  pic_seti(sg->irq,do_irq,0);
-    	  pic_unmaski(sg->irq);
-	  sg++;
+		    sg->irq = pic_irq_list[irq];
+		    g_printf("SIG %x: enabling interrupt %x\n", irq, sg->irq);
+		    pic_seti(sg->irq, do_irq, 0);
+		    pic_unmaski(sg->irq);
+		    sg++;
 #endif
-        }
-      }
+		}
+	    }
+	}
+	sg->fd = 0;
+	if (sg != SillyG_)
+	    SillyG = SillyG_;
     }
-    sg->fd=0;
-    if (sg != SillyG_) SillyG=SillyG_;
-  }
 #endif
 }
 
-static inline void SIG_close()
+static inline void 
+SIG_close()
 {
 #ifdef SIG
-  if (SillyG) {
-    SillyG_t *sg=SillyG;
+    if (SillyG) {
+	SillyG_t       *sg = SillyG;
 #ifdef REQUIRES_EMUMODULE
-    while (sg->fd) {
-      emusyscall(EMUSYS_FREE_IRQ,sg->irq);
-      sg++;
-    }
+	while (sg->fd) {
+	    emusyscall(EMUSYS_FREE_IRQ, sg->irq);
+	    sg++;
+	}
 #else
-    while (sg->fd) close((sg++)->fd);
+	while (sg->fd)
+	    close((sg++)->fd);
 #endif
-    fprintf(stderr, "Closing all IRQ you opened!\n");
-  }
+	fprintf(stderr, "Closing all IRQ you opened!\n");
+    }
 #endif
 }
 
-static inline void emumodule_init(void)
+static inline void 
+emumodule_init(void)
 {
 #ifdef REQUIRES_EMUMODULE
-  resolve_emusyscall();
-  if (EMUSYS_AVAILABLE) {
-    if (emusyscall(EMUSYS_GETVERSION,0) < EMUSYSVERSION) {
-      fprintf(stderr, "emumodule not loaded or wrong version\n\r");
-      fflush(stdout);
-      fflush(stderr);
-      _exit(1);
+    resolve_emusyscall();
+    if (EMUSYS_AVAILABLE) {
+	if (emusyscall(EMUSYS_GETVERSION, 0) < EMUSYSVERSION) {
+	    fprintf(stderr, "emumodule not loaded or wrong version\n\r");
+	    fflush(stdout);
+	    fflush(stderr);
+	    _exit(1);
+	}
     }
-  }
 #endif
 }
 
@@ -814,321 +733,341 @@
 static inline void
 module_init(void)
 {
-  version_init();              /* Check the OS version */
-  emumodule_init();            /* emumodule support */
-  SIG_init();                  /* silly int generator support */
-  memcheck_init();             /* lower 1M memory map support */
-  tmpdir_init();               /* create our temporary dir */
+    version_init();		/* Check the OS version */
+    emumodule_init();		/* emumodule support */
+    SIG_init();			/* silly int generator support */
+    memcheck_init();		/* lower 1M memory map support */
+    tmpdir_init();		/* create our temporary dir */
 }
 
 /*
  * DANG_BEGIN_FUNCTION emulate
- *
- * arguments:
- * argc - Argument count.
- * argv - Arguments.
- *
- * description:
- *  Emulate gets called from dos.c. It initializes DOSEMU to prepare it
- *  for running in vm86 mode. This involves catching signals, preparing
- *  memory, calling all the initialization functions for the I/O
- *  subsystems (video/serial/etc...), getting the boot sector instructions
- *  and calling vm86().
- *
+ * 
+ * arguments: argc - Argument count. argv - Arguments.
+ * 
+ * description: Emulate gets called from dos.c. It initializes DOSEMU to
+ * prepare it for running in vm86 mode. This involves catching signals,
+ * preparing memory, calling all the initialization functions for the I/O
+ * subsystems (video/serial/etc...), getting the boot sector instructions
+ * and calling vm86().
+ * 
  * DANG_END_FUNCTION
- *
+ * 
  */
 #ifdef __ELF__
-void main (int argc, char **argv)
+void 
+main(int argc, char **argv)
 #else
-void emulate(int argc, char **argv)
+void 
+emulate(int argc, char **argv)
 #endif
 {
-  FD_ZERO(&fds_sigio);         /* initialize both fd_sets to 0 */
-  FD_ZERO(&fds_no_sigio);
-  vm86s.flags = 0;
+    FD_ZERO(&fds_sigio);	/* initialize both fd_sets to 0 */
+    FD_ZERO(&fds_no_sigio);
+#if 0 /* Why mess with vm86 flags here? */
+    vm86s.flags = 0;
+#endif
 
-  if(0 == geteuid()) {
-	warn(stderr, "I am root\n");
+    if (0 == geteuid()) {
+	warn("I am root\n");
 	i_am_root = 1;
-  } else {
-	if(getuid() != geteuid()) {
-		fprintf(stderr, "Can't setuid to anyone else but root\n");
-		exit(1);
+    } else {
+	if (getuid() != geteuid()) {
+	    fprintf(stderr, "Can't setuid to anyone else but root\n");
+	    exit(1);
 	}
-  }
+    }
 
 #ifdef RUN_AS_USER
-  /* start running as real, not effective user.  This is moved from */
-  /* stdio_init, as that and config_init have now changed places and */
-  /* allowing reading arbitrary files while being root is not smart */
-
-  exchange_uids();	
-#endif
-
-  /* the transposal of (config_|stdio_)init allows the addition of -o */
-  /* to specify a debug out filename, if you're wondering */
-
-  config_init(argc, argv);     /* parse the commands & config file(s) */
-  stdio_init();                /* initialize stdio & open debug file */
-
-  module_init();
-  low_mem_init();              /* initialize the lower 1Meg */
-  time_setting_init();         /* get the startup time */
-  signal_init();               /* initialize sig's & sig handlers */
-  device_init();               /* initialize keyboard, disk, video, etc. */
-  cpu_setup();                 /* setup the CPU */
-  hardware_setup();            /* setup any hardware */
-  memory_init();               /* initialize the memory contents */
-  boot();                      /* read the boot sector & get moving */
-  timer_interrupt_init();      /* start sending int 8h int signals */
-
-  if (not_use_sigio)
-    k_printf("Atleast 1 NON-SIGIO file handle in use.\n");
-  else
-    k_printf("No NON-SIGIO file handles in use.\n");
-  g_printf("EMULATE\n");
+    /* start running as real, not effective user.  This is moved from */
+    /* stdio_init, as that and config_init have now changed places and */
+    /* allowing reading arbitrary files while being root is not smart */
+
+    exchange_uids();
+#endif
+
+    /* the transposal of (config_|stdio_)init allows the addition of -o */
+    /* to specify a debug out filename, if you're wondering */
+
+    config_init(argc, argv);	/* parse the commands & config file(s) */
+    stdio_init();		/* initialize stdio & open debug file */
+    module_init();
+    low_mem_init();		/* initialize the lower 1Meg */
+    time_setting_init();	/* get the startup time */
+    signal_init();		/* initialize sig's & sig handlers */
+    device_init();		/* initialize keyboard, disk, video, etc. */
+    cpu_setup();		/* setup the CPU */
+    hardware_setup();		/* setup any hardware */
+    memory_init();		/* initialize the memory contents */
+    boot();			/* read the boot sector & get moving */
+    timer_interrupt_init();	/* start sending int 8h int signals */
 
-  fflush(stdout);
+    if (not_use_sigio)
+	k_printf("Atleast 1 NON-SIGIO file handle in use.\n");
+    else
+	k_printf("No NON-SIGIO file handles in use.\n");
+    g_printf("EMULATE\n");
+
+    fflush(stdout);
 
-  while(!fatalerr) {
-    run_vm86();
+    while (!fatalerr) {
+	run_vm86();
 #ifdef NEW_PIC
-    run_irqs();      /*  trigger any hardware interrupts requested */
+	run_irqs();		/* trigger any hardware interrupts
+				 * requested */
 #endif
-    serial_run();
+	serial_run();
 #if 0
 #ifdef USING_NET
-    /* check for available packets on the packet driver interface */
-    /* (timeout=0, so it immediately returns when none are available) */
-    pkt_check_receive(0);
+	/* check for available packets on the packet driver interface */
+	/* (timeout=0, so it immediately returns when none are available) */
+#ifdef NEW_PIC
+	pic_request(16);
+#else
+	pkt_check_receive(0);
+#endif
 #endif
 #endif
-    int_queue_run();
-  }
+	int_queue_run();
+    }
 
-  error("error exit: (%d,0x%04x) in_sigsegv: %d ignore_segv: %d\n",
-	fatalerr, fatalerr, in_sigsegv, ignore_segv);
+    error("error exit: (%d,0x%04x) in_sigsegv: %d ignore_segv: %d\n",
+	  fatalerr, fatalerr, in_sigsegv, ignore_segv);
 
-  sync();
-  fprintf(stderr, "ARG!!!!!\n");
-  leavedos(99);
+    sync();
+    fprintf(stderr, "Not a good day to die!!!!!\n");
+    leavedos(99);
 }
 
+extern void HMA_MAP(int);
+
 void
 dos_ctrl_alt_del(void)
 {
-  dbug_printf("DOS ctrl-alt-del requested.  Rebooting!\n");
-  disk_close();
-  clear_screen(READ_BYTE(BIOS_CURRENT_SCREEN_PAGE), 7);
-  special_nowait = 0;
-  p_dos_str("Rebooting DOS.  Be careful...this is partially implemented\r\n");
-  disk_init();
-  memory_init();
-  cpu_setup();
-  hardware_setup();
-  boot();
+    dbug_printf("DOS ctrl-alt-del requested.  Rebooting!\n");
+    HMA_MAP(1);
+    time_setting_init();
+    keyboard_flags_init();
+    serial_init();
+    mouse_init();
+    printer_init();
+    disk_close();
+    disk_init();
+    scr_state_init();
+    video_config_init();
+    clear_screen(READ_BYTE(BIOS_CURRENT_SCREEN_PAGE), 7);
+    special_nowait = 0;
+    p_dos_str("Rebooting DOS.  Be careful...this is partially implemented\r\n");
+    disk_init();
+    cpu_setup();
+    hardware_setup();
+    memcheck_init();		/* lower 1M memory map support */
+    memory_init();
+    boot();
+    timer_interrupt_init();	/* start sending int 8h int signals */
 }
 
 void
 dos_ctrlc(void)
 {
-  k_printf("DOS ctrl-c!\n");
-  p_dos_str("^C\n\r");		/* print ctrl-c message */
-  keybuf_clear();
+    k_printf("DOS ctrl-c!\n");
+    p_dos_str("^C\n\r");	/* print ctrl-c message */
+    keybuf_clear();
 
-  do_soft_int(0x23);
+    do_soft_int(0x23);
 }
 
 static void
-ign_sigs(int sig) {
-  static int timerints = 0;
-  static int otherints = 0;
-
-  g_printf("ERROR: signal %d received in leavedos()\n", sig);
-  show_regs(__FILE__, __LINE__);
-  if (sig == SIG_TIME)
-    timerints++;
-  else
-    otherints++;
+ign_sigs(int sig)
+{
+    static int      timerints = 0;
+    static int      otherints = 0;
+
+    g_printf("ERROR: signal %d received in leavedos()\n", sig);
+    show_regs(__FILE__, __LINE__);
+    if (sig == SIG_TIME)
+	timerints++;
+    else
+	otherints++;
 
 #define LEAVEDOS_TIMEOUT (3 * FREQ)
 #define LEAVEDOS_SIGOUT  5
-  if ((timerints >= LEAVEDOS_TIMEOUT) || (otherints >= LEAVEDOS_SIGOUT)) {
-    error("ERROR: timed/signalled out in leavedos()\n");
-    	exit(1);
-  }
+    if ((timerints >= LEAVEDOS_TIMEOUT) || (otherints >= LEAVEDOS_SIGOUT)) {
+	error("ERROR: timed/signalled out in leavedos()\n");
+	exit(1);
+    }
 }
 
 /* "graceful" shutdown */
 void
- leavedos(int sig) {
-  struct sigaction sa;
+leavedos(int sig)
+{
+    struct sigaction sa;
 
-  in_vm86 = 0;
+    in_vm86 = 0;
 
-  /* remove tmpdir */
-  rmdir(tmpdir);
+    /* remove tmpdir */
+    rmdir(tmpdir);
 
-  setitimer(TIMER_TIME, NULL, NULL);
-  SETSIG(SIG_TIME, ign_sigs);
-  SETSIG(SIGSEGV, ign_sigs);
-  SETSIG(SIGILL, ign_sigs);
-  SETSIG(SIGFPE, ign_sigs);
-  SETSIG(SIGTRAP, ign_sigs);
-  warn("leavedos(%d) called - shutting down\n", sig );
-
-  g_printf("calling close_all_printers\n");
-  close_all_printers();
-
-  g_printf("calling serial_close\n");
-  serial_close();
-  g_printf("calling mouse_close\n");
-  mouse_close();
+    setitimer(TIMER_TIME, NULL, NULL);
+    SETSIG(SIG_TIME, ign_sigs);
+    SETSIG(SIGSEGV, ign_sigs);
+    SETSIG(SIGILL, ign_sigs);
+    SETSIG(SIGFPE, ign_sigs);
+    SETSIG(SIGTRAP, ign_sigs);
+    warn("leavedos(%d) called - shutting down\n", sig);
+
+    g_printf("calling close_all_printers\n");
+    close_all_printers();
+
+    g_printf("calling serial_close\n");
+    serial_close();
+    g_printf("calling mouse_close\n");
+    mouse_close();
 
 #ifdef SIG
-  g_printf("calling SIG_close\n");
+    g_printf("calling SIG_close\n");
 #endif
-  SIG_close();
+    SIG_close();
 
-  show_ints(0, 0x33);
-  g_printf("calling disk_close_all\n");
-  disk_close_all();
-  g_printf("calling video_close\n");
-  video_close();
-  g_printf("calling keyboard_close\n");
-  fflush(stderr);
-  fflush(stdout);
-  keyboard_close();
-
-  g_printf("calling shared memory exit\n");
-  shared_memory_exit();
-   if (config.detach) {
-     restore_vt(config.detach);
-     disallocate_vt ();
-   }
-  _exit(sig);
+    show_ints(0, 0x33);
+    g_printf("calling disk_close_all\n");
+    disk_close_all();
+    g_printf("calling video_close\n");
+    video_close();
+    g_printf("calling keyboard_close\n");
+    fflush(stderr);
+    fflush(stdout);
+    keyboard_close();
+
+    g_printf("calling shared memory exit\n");
+    shared_memory_exit();
+    if (config.detach) {
+	restore_vt(config.detach);
+	disallocate_vt();
+    }
+    _exit(sig);
 }
 
 #if 0
 /* check the fd for data ready for reading */
 int
- d_ready(int fd) {
-  struct timeval w_time;
-  fd_set checkset;
-
-  w_time.tv_sec = 0;
-  w_time.tv_usec = 200000;
-
-  FD_ZERO(&checkset);
-  FD_SET(fd, &checkset);
-
-  if (RPT_SYSCALL(select(fd + 1, &checkset, NULL, NULL, &w_time)) == 1) {
-    if (FD_ISSET(fd, &checkset))
-      return (1);
-    else
-      return (0);
-  }
-  else
-    return (0);
+d_ready(int fd)
+{
+    struct timeval  w_time;
+    fd_set          checkset;
+
+    w_time.tv_sec = 0;
+    w_time.tv_usec = 200000;
+
+    FD_ZERO(&checkset);
+    FD_SET(fd, &checkset);
+
+    if (RPT_SYSCALL(select(fd + 1, &checkset, NULL, NULL, &w_time)) == 1) {
+	if (FD_ISSET(fd, &checkset))
+	    return (1);
+	else
+	    return (0);
+    } else
+	return (0);
 }
 #endif
 
-static inline uid_t
- be(uid_t who) {
-  if (getuid() != who)
-    return setreuid(geteuid(), getuid());
-  else
-    return 0;
-}
-
-static inline uid_t
- be_me(void) {
-  if (geteuid() == 0) {
-    return setreuid(geteuid(), getuid());
-    return 0;
-  }
-  else
-    return geteuid();
-}
-
-static inline uid_t
- be_root(void) {
-  if (geteuid() != 0) {
-    setreuid(geteuid(), getuid());
-    return getuid();
-  }
-  else
-    return 0;
+static inline   uid_t
+be(uid_t who)
+{
+    if (getuid() != who)
+	return setreuid(geteuid(), getuid());
+    else
+	return 0;
+}
+
+static inline   uid_t
+be_me(void)
+{
+    if (geteuid() == 0) {
+	return setreuid(geteuid(), getuid());
+	return 0;
+    } else
+	return geteuid();
+}
+
+static inline   uid_t
+be_root(void)
+{
+    if (geteuid() != 0) {
+	setreuid(geteuid(), getuid());
+	return getuid();
+    } else
+	return 0;
 }
 /* return status of io_perm call */
 int
- set_ioperm(int start, int size, int flag) {
-  int tmp;
+set_ioperm(int start, int size, int flag)
+{
+    int             tmp;
 
-  if(!i_am_root) 
-	return -1;	/* don't bother */
+    if (!i_am_root)
+	return -1;		/* don't bother */
 
-  tmp = ioperm(start, size, flag);
-  return tmp;
+    tmp = ioperm(start, size, flag);
+    return tmp;
 }
 
 /*
  * DANG_BEGIN_FUNCTION add_to_io_select
  * 
- * arguments:
- *  fd - File handle to add to select statment.
- *  want_sigio - Specifiy whether you want SIGIO (1) if it's available, or
- * 		 not (0).
- *
- * description:
- *  Add file handle to one of 2 select FDS_SET's depending on 
- *  whether the kernel can handle SIGIO.
- *
+ * arguments: fd - File handle to add to select statment. want_sigio -
+ * Specifiy whether you want SIGIO (1) if it's available, or not (0).
+ * 
+ * description: Add file handle to one of 2 select FDS_SET's depending on
+ * whether the kernel can handle SIGIO.
+ * 
  * DANG_END_FUNCTION
  */
-void add_to_io_select(int new_fd, u_char want_sigio) {
-  if ( use_sigio && want_sigio ) {
-    int flags;
-    flags = fcntl(new_fd, F_GETFL);
-    fcntl(new_fd, F_SETOWN,  getpid());
-    fcntl(new_fd, F_SETFL, flags | use_sigio);
-    FD_SET(new_fd, &fds_sigio);
-    g_printf("GEN: fd=%d gets SIGIO\n", new_fd);
-  } else {
-    FD_SET(new_fd, &fds_no_sigio);
-    g_printf("GEN: fd=%d does not get SIGIO\n", new_fd);
-    not_use_sigio++;
-  }
+void 
+add_to_io_select(int new_fd, u_char want_sigio)
+{
+    if (use_sigio && want_sigio) {
+	int             flags;
+	flags = fcntl(new_fd, F_GETFL);
+	fcntl(new_fd, F_SETOWN, getpid());
+	fcntl(new_fd, F_SETFL, flags | use_sigio);
+	FD_SET(new_fd, &fds_sigio);
+	g_printf("GEN: fd=%d gets SIGIO\n", new_fd);
+    } else {
+	FD_SET(new_fd, &fds_no_sigio);
+	g_printf("GEN: fd=%d does not get SIGIO\n", new_fd);
+	not_use_sigio++;
+    }
 }
 
 /*
  * DANG_BEGIN_FUNCTION remove_from_io_select
  * 
- * arguments:
- *  fd - File handle to remove from select statment.
- *  used_sigio - Specifiy whether you used SIGIO (1) if it's available, or
- * 		 not (0).
- *
- * description:
- *  Remove a file handle from one of 2 select FDS_SET's depending on 
- *  whether the kernel can handle SIGIO.
- *
+ * arguments: fd - File handle to remove from select statment. used_sigio -
+ * Specifiy whether you used SIGIO (1) if it's available, or not (0).
+ * 
+ * description: Remove a file handle from one of 2 select FDS_SET's depending
+ * on whether the kernel can handle SIGIO.
+ * 
  * DANG_END_FUNCTION
  */
-void remove_from_io_select(int new_fd, u_char used_sigio) {
-  if ( use_sigio && used_sigio ) {
-    int flags;
-    flags = fcntl(new_fd, F_GETFL);
-    fcntl(new_fd, F_SETOWN,  NULL);
-    fcntl(new_fd, F_SETFL, flags & ~(use_sigio));
-    FD_CLR(new_fd, &fds_sigio);
-    g_printf("GEN: fd=%d removed from select SIGIO\n", new_fd);
-  } else {
-    FD_CLR(new_fd, &fds_no_sigio);
-    g_printf("GEN: fd=%d removed from select\n", new_fd);
-    not_use_sigio++;
-  }
+void 
+remove_from_io_select(int new_fd, u_char used_sigio)
+{
+    if (use_sigio && used_sigio) {
+	int             flags;
+	flags = fcntl(new_fd, F_GETFL);
+	fcntl(new_fd, F_SETOWN, NULL);
+	fcntl(new_fd, F_SETFL, flags & ~(use_sigio));
+	FD_CLR(new_fd, &fds_sigio);
+	g_printf("GEN: fd=%d removed from select SIGIO\n", new_fd);
+    } else {
+	FD_CLR(new_fd, &fds_no_sigio);
+	g_printf("GEN: fd=%d removed from select\n", new_fd);
+	not_use_sigio++;
+    }
 }
 
 #if 1
@@ -1135,68 +1074,66 @@
 int
 do_ioctl(int fd, int req, int param3)
 {
-  int tmp;
+    int             tmp;
 
-  if (in_sighandler && in_ioctl) {
-    k_printf("KBD: do_ioctl(): in ioctl %d 0x%04x 0x%04x.\nqueuing: %d 0x%04x 0x%04x\n",
-	     curi.fd, curi.req, curi.param3, fd, req, param3);
-    queue_ioctl(fd, req, param3);
-    errno = EDEADLOCK;
+    if (in_sighandler && in_ioctl) {
+	k_printf("KBD: do_ioctl(): in ioctl %d 0x%04x 0x%04x.\nqueuing: %d 0x%04x 0x%04x\n",
+		 curi.fd, curi.req, curi.param3, fd, req, param3);
+	queue_ioctl(fd, req, param3);
+	errno = EDEADLOCK;
 #ifdef SYNC_ALOT
-    fflush(stdout);
-    sync();			/* for safety */
+	fflush(stdout);
+	sync();			/* for safety */
 #endif
-    return -1;
-  }
-  else {
-    in_ioctl = 1;
-    curi.fd = fd;
-    curi.req = req;
-    curi.param3 = param3;
-    if (iq.queued) {
-      k_printf("KBD: detected queued ioctl in do_ioctl(): %d 0x%04x 0x%04x\n",
-	       iq.fd, iq.req, iq.param3);
+	return -1;
+    } else {
+	in_ioctl = 1;
+	curi.fd = fd;
+	curi.req = req;
+	curi.param3 = param3;
+	if (iq.queued) {
+	    k_printf("KBD: detected queued ioctl in do_ioctl(): %d 0x%04x 0x%04x\n",
+		     iq.fd, iq.req, iq.param3);
+	}
+	k_printf("KBD: IOCTL fd=0x%x, req=0x%x, param3=0x%x\n", fd, req, param3);
+	tmp = ioctl(fd, req, param3);
+	in_ioctl = 0;
+	return tmp;
     }
-    k_printf("KBD: IOCTL fd=0x%x, req=0x%x, param3=0x%x\n", fd, req, param3);
-    tmp = ioctl(fd, req, param3);
-    in_ioctl = 0;
-    return tmp;
-  }
 }
 
 int
 queue_ioctl(int fd, int req, int param3)
 {
-  if (iq.queued) {
-    error("ioctl already queued: %d 0x%04x 0x%04x\n", iq.fd, iq.req,
-	  iq.param3);
-    return 1;
-  }
-  iq.fd = fd;
-  iq.req = req;
-  iq.param3 = param3;
-  iq.queued = 1;
+    if (iq.queued) {
+	error("ioctl already queued: %d 0x%04x 0x%04x\n", iq.fd, iq.req,
+	      iq.param3);
+	return 1;
+    }
+    iq.fd = fd;
+    iq.req = req;
+    iq.param3 = param3;
+    iq.queued = 1;
 
-  return 0;			/* success */
+    return 0;			/* success */
 }
 
 void
 do_queued_ioctl(void)
 {
-  if (iq.queued) {
-    iq.queued = 0;
-    do_ioctl(iq.fd, iq.req, iq.param3);
-  }
+    if (iq.queued) {
+	iq.queued = 0;
+	do_ioctl(iq.fd, iq.req, iq.param3);
+    }
 }
 
 void
 activate(int con_num)
 {
-  if (in_ioctl) {
-    k_printf("KBD: can't ioctl for activate, in a signal handler\n");
-    do_ioctl(kbd_fd, VT_ACTIVATE, con_num);
-  }
-  else
-    do_ioctl(kbd_fd, VT_ACTIVATE, con_num);
+    if (in_ioctl) {
+	k_printf("KBD: can't ioctl for activate, in a signal handler\n");
+	do_ioctl(kbd_fd, VT_ACTIVATE, con_num);
+    } else
+	do_ioctl(kbd_fd, VT_ACTIVATE, con_num);
 }
 #endif
diff -u --recursive --new-file dosemu0.53.52/include/Makefile dosemu0.53.53/include/Makefile
--- dosemu0.53.52/include/Makefile	Fri Mar 17 22:47:35 1995
+++ dosemu0.53.53/include/Makefile	Sun Mar 19 12:13:20 1995
@@ -3,18 +3,18 @@
 
 
 ALL = bios.h cmos.h cpu.h disks.h dosio.h dosnet.h emu.h \
-	emusys.h hgc.h inifile.h ipx.h keymaps.h \
-	lpt.h machcompat.h memory.h mouse.h mutex.h port.h \
-	serial.h slang.h syscallmgr.h termio.h timers.h video.h xms.h \
-	macros86.h vc.h extern.h int.h shared.h pktdrvr.h dos2linux.h \
-	pic.h bitops.h
+emusys.h hgc.h inifile.h ipx.h keymaps.h \
+lpt.h machcompat.h memory.h mouse.h mutex.h port.h \
+serial.h slang.h syscallmgr.h termio.h timers.h video.h xms.h \
+macros86.h vc.h extern.h int.h shared.h pktdrvr.h dos2linux.h \
+                pic.h bitops.h
 
-OBJS = 
+                OBJS =
 
 all:
 
 .c.o:
-	$(CC) $(CFLAGS) $(INCDIR) -c $<
+	$(CC) $(CFLAGS) $(INCDIR) -c $ <
 
 checkin:
 	-ci $(ALL) Makefile
@@ -25,23 +25,16 @@
 	rm -f *.o
 	rm -f kversion.h
 
-realclean: clean
-	rm -f .depend
+realclean:clean
+	rm -f.depend
 
 install:
 
-dist: $(ALL) Makefile
+dist:$(ALL) Makefile
 	install -d $(DISTPATH)/include
 	install -m 0644 $(ALL) Makefile $(DISTPATH)/include
 
-depend dep: 
+depend dep:
 
 
 dummy:
-
-#
-# include a dependency file if one exists
-#
-ifeq (.depend,$(wildcard .depend))
-include .depend
-endif
diff -u --recursive --new-file dosemu0.53.52/include/bios.h dosemu0.53.53/include/bios.h
--- dosemu0.53.52/include/bios.h	Fri Mar 17 22:47:35 1995
+++ dosemu0.53.53/include/bios.h	Sun Mar 19 12:13:18 1995
@@ -7,9 +7,10 @@
 
 #define INT2F_IDLE_MAGIC	0x1680
 
-/* symbols to access BIOS-data with meaningful names, not just
- * addresses, which are only numbers.
- * The names are retranslatios from an old german book :-(
+/*
+ * symbols to access BIOS-data with meaningful names, not just addresses,
+ * which are only numbers. The names are retranslatios from an old german
+ * book :-(
  */
 
 #ifdef X86_EMULATOR
@@ -24,15 +25,15 @@
 #define bios_address_lpt1               (*(unsigned short *) 0x408)
 #define bios_address_lpt2               (*(unsigned short *) 0x40a)
 #define bios_address_lpt3               (*(unsigned short *) 0x40c)
-                                      /* 0x40e is reserved */
+/* 0x40e is reserved */
 #define bios_configuration              (*(unsigned short *) 0x410)
-                                      /* 0x412 is reserved */
+/* 0x412 is reserved */
 #define bios_memory_size                (*(unsigned short *) 0x413)
 /* #define bios_expansion_memory_size      (*(unsigned int   *) 0x415) */
 #define bios_keyboard_state             (*(unsigned short *) 0x417)
 #define bios_keyboard_leds              (*(unsigned char  *) 0x418)
 #define bios_keyboard_token             (*(unsigned short *) 0x419)
-      /* used for keyboard input with Alt-Number */
+/* used for keyboard input with Alt-Number */
 #define bios_keyboard_buffer_head       (*(unsigned short *) 0x41a)
 #define bios_keyboard_buffer_tail       (*(unsigned short *) 0x41c)
 /* #define bios_keyboard_buffer            (*(unsigned int   *) 0x41e) */
@@ -50,7 +51,7 @@
                         (*(unsigned char *)(0x450 + 2*(screen)))
 #define bios_cursor_y_position(screen) \
                         (*(unsigned char *)(0x451 + 2*(screen)))
- 
+
 #define bios_cursor_shape               (*(unsigned short *) 0x460)
 #define bios_cursor_last_line           (*(unsigned char  *) 0x460)
 #define bios_cursor_first_line          (*(unsigned char  *) 0x461)
@@ -58,23 +59,23 @@
 #define bios_video_port                 (*(unsigned short *) 0x463)
 #define bios_vdu_control                (*(         char  *) 0x465)
 #define bios_vdu_color_register         (*(unsigned short *) 0x466)
-                                      /* 0x467-0x468 is reserved */
+/* 0x467-0x468 is reserved */
 #define bios_timer                      (*(unsigned long  *) 0x46c)
 #define bios_24_hours_flag              (*(unsigned char  *) 0x470)
 #define bios_keyboard_flags             (*(unsigned char  *) 0x471)
 #define bios_ctrl_alt_del_flag          (*(unsigned short *) 0x472)
-                                      /* 0x474-0x477 is reserved */
+/* 0x474-0x477 is reserved */
 #define bios_lpt1_timeout               (*(unsigned char  *) 0x478)
 #define bios_lpt2_timeout               (*(unsigned char  *) 0x479)
 #define bios_lpt3_timeout               (*(unsigned char  *) 0x47a)
-                                      /* 0x47b is reserved */
+/* 0x47b is reserved */
 #define bios_com1_timeout               (*(unsigned char  *) 0x47c)
 #define bios_com2_timeout               (*(unsigned char  *) 0x47d)
-                                      /* 0x47e is reserved */
-                                      /* 0x47f-0x4ff is unknow for me */
+/* 0x47e is reserved */
+/* 0x47f-0x4ff is unknow for me */
 #define bios_keyboard_buffer_start      (*(unsigned short *) 0x480)
 #define bios_keyboard_buffer_end        (*(unsigned short *) 0x482)
- 
+
 #define bios_rows_on_screen_minus_1     (*(unsigned char  *) 0x484)
 #define bios_font_height                (*(unsigned short *) 0x485)
 
@@ -87,7 +88,7 @@
 #define bios_print_screen_flag          (*(unsigned short *) 0x500)
 
 #define bios_video_saveptr              (*(unsigned long  *) 0x4a8)
-#endif /* X86_EMULATOR_CHECK */
+#endif				/* X86_EMULATOR_CHECK */
 
 
 
@@ -94,9 +95,9 @@
 
 #ifndef X86_EMULATOR
 
-typedef unsigned char  ubyte_t;
+typedef unsigned char ubyte_t;
 typedef unsigned short uword_t;
-typedef unsigned long  udword_t;
+typedef unsigned long udword_t;
 
 #define READ_BYTE(addr)                 (*(ubyte_t *) (addr))
 #define WRITE_BYTE(addr, val)           (*(ubyte_t *) (addr) = (val) )
@@ -127,15 +128,15 @@
 #define BIOS_ADDRESS_LPT1               0x408
 #define BIOS_ADDRESS_LPT2               0x40a
 #define BIOS_ADDRESS_LPT3               0x40c
-                                      /* 0x40e is reserved */
+/* 0x40e is reserved */
 #define BIOS_CONFIGURATION              0x410
-                                      /* 0x412 is reserved */
+/* 0x412 is reserved */
 #define BIOS_MEMORY_SIZE                0x413
 /* #define bios_expansion_memory_size      (*(unsigned int   *) 0x415) */
 #define BIOS_KEYBOARD_STATE             0x417
 #define BIOS_KEYBOARD_LEDS              0x418
 #define BIOS_KEYBOARD_TOKEN             0x419
-      /* used for keyboard input with Alt-Number */
+/* used for keyboard input with Alt-Number */
 #define BIOS_KEYBOARD_BUFFER_HEAD       0x41a
 #define BIOS_KEYBOARD_BUFFER_TAIL       0x41c
 /* #define bios_keyboard_buffer            (*(unsigned int   *) 0x41e) */
@@ -160,7 +161,7 @@
 #define get_bios_cursor_y_position(screen) \
                         READ_BYTE(0x451 + 2*(screen))
 
- 
+
 #define BIOS_CURSOR_SHAPE               0x460
 #define BIOS_CURSOR_LAST_LINE           0x460
 #define BIOS_CURSOR_FIRST_LINE          0x461
@@ -168,23 +169,23 @@
 #define BIOS_VIDEO_PORT                 0x463
 #define BIOS_VDU_CONTROL                0x465
 #define BIOS_VDU_COLOR_REGISTER         0x466
-                                      /* 0x467-0x468 is reserved */
+/* 0x467-0x468 is reserved */
 #define BIOS_TIMER                      0x46c
 #define BIOS_24_HOURS_FLAG              0x470
 #define BIOS_KEYBOARD_FLAGS             0x471
 #define BIOS_CTRL_ALT_DEL_FLAG          0x472
-                                      /* 0x474-0x477 is reserved */
+/* 0x474-0x477 is reserved */
 #define BIOS_LPT1_TIMEOUT               0x478
 #define BIOS_LPT2_TIMEOUT               0x479
 #define BIOS_LPT3_TIMEOUT               0x47a
-                                      /* 0x47b is reserved */
+/* 0x47b is reserved */
 #define BIOS_COM1_TIMEOUT               0x47c
 #define BIOS_COM2_TIMEOUT               0x47d
-                                      /* 0x47e is reserved */
-                                      /* 0x47f-0x4ff is unknow for me */
+/* 0x47e is reserved */
+/* 0x47f-0x4ff is unknow for me */
 #define BIOS_KEYBOARD_BUFFER_START      0x480
 #define BIOS_KEYBOARD_BUFFER_END        0x482
- 
+
 #define BIOS_ROWS_ON_SCREEN_MINUS_1     0x484
 #define BIOS_FONT_HEIGHT                0x485
 
@@ -197,11 +198,12 @@
 #define BIOS_PRINT_SCREEN_FLAG          0x500
 
 #define BIOS_VIDEO_SAVEPTR              0x4a8
-    
+
 
 #define BIT(x)  	(1<<x)
 
-/* int 11h config single bit tests
+/*
+ * int 11h config single bit tests
  */
 
 #define CONF_FLOP	BIT(0)
@@ -210,7 +212,8 @@
 #define CONF_DMA	BIT(8)
 #define CONF_GAME	BIT(12)
 
-/* don't use CONF_NSER with num > 4, CONF_NLPT with num > 3, CONF_NFLOP
+/*
+ * don't use CONF_NSER with num > 4, CONF_NLPT with num > 3, CONF_NFLOP
  * with num > 4
  */
 #define CONF_NSER(c,num)	{c&=~(BIT(9)|BIT(10)|BIT(11)); c|=(num<<9);}
@@ -218,34 +221,35 @@
 #define CONF_NFLOP(c,num) 	{c&=~(CONF_FLOP|BIT(6)|BIT(7)); \
 				   if (num) c|=((num-1)<<6)|CONF_FLOP;}
 
-EXTERN unsigned int configuration INIT(0); /* The virtual BIOS-configuration */
+EXTERN unsigned int configuration INIT(0);	/* The virtual
+						 * BIOS-configuration */
 
-void setup_rom_bios(void);
-void bios_configuration_init(void);        /* init BIOS-configuration */
-void bios_data_init(void);                 /* init BIOS-data-areas */
-
-void INT16_dummy_start();
-void INT16_dummy_end();
-void INT09_dummy_start();
-void INT09_dummy_end();
-void INT08_dummy_start();
-void INT08_dummy_end();
-void DPMI_dummy_start();
-void DPMI_dummy_end();
-void DPMI_dpmi_init();
-void DPMI_return_from_dos();
-void DPMI_return_from_dos_exec();
-void DPMI_return_from_dosint();
-void DPMI_return_from_realmode();
-void DPMI_return_from_dos_memory();
-void DPMI_realmode_callback();
-void DPMI_raw_mode_switch();
-void DPMI_save_restore();
-void DPMI_API_extension();
-void DPMI_return_from_pm();
-void DPMI_return_from_exception();
-void DPMI_return_from_rm_callback();
-void DPMI_exception();
-void DPMI_interrupt();
+void            setup_rom_bios(void);
+void            bios_configuration_init(void);	/* init BIOS-configuration */
+void            bios_data_init(void);	/* init BIOS-data-areas */
+
+void            INT16_dummy_start();
+void            INT16_dummy_end();
+void            INT09_dummy_start();
+void            INT09_dummy_end();
+void            INT08_dummy_start();
+void            INT08_dummy_end();
+void            DPMI_dummy_start();
+void            DPMI_dummy_end();
+void            DPMI_dpmi_init();
+void            DPMI_return_from_dos();
+void            DPMI_return_from_dos_exec();
+void            DPMI_return_from_dosint();
+void            DPMI_return_from_realmode();
+void            DPMI_return_from_dos_memory();
+void            DPMI_realmode_callback();
+void            DPMI_raw_mode_switch();
+void            DPMI_save_restore();
+void            DPMI_API_extension();
+void            DPMI_return_from_pm();
+void            DPMI_return_from_exception();
+void            DPMI_return_from_rm_callback();
+void            DPMI_exception();
+void            DPMI_interrupt();
 
-#endif /* BIOS_H */
+#endif				/* BIOS_H */
diff -u --recursive --new-file dosemu0.53.52/include/bitops.h dosemu0.53.53/include/bitops.h
--- dosemu0.53.52/include/bitops.h	Fri Mar 17 22:47:35 1995
+++ dosemu0.53.53/include/bitops.h	Sun Mar 19 12:13:20 1995
@@ -1,18 +1,18 @@
 #ifndef _ASM_BITOPS_H
 #define _ASM_BITOPS_H
-/* This is a hacked-up version of Linus' bitops.h file.
-   I've added a function and removed the "extern"s (in the i386 part) for 
-   convenience.  If I can figure out how to use Linus' bitops.h directly, I'll 
-   reduce this file to an #include and just my added function.
-   For now, this works. -JLS
-   $Id: bitops.h,v 2.3 1995/02/25 22:38:08 root Exp root $
-
-   */
+/*
+ * This is a hacked-up version of Linus' bitops.h file. I've added a
+ * function and removed the "extern"s (in the i386 part) for convenience.
+ * If I can figure out how to use Linus' bitops.h directly, I'll reduce
+ * this file to an #include and just my added function. For now, this
+ * works. -JLS $Id: bitops.h,v 2.3 1995/02/25 22:38:08 root Exp root $
+ * 
+ */
 
 /*
  * Copyright 1992, Linus Torvalds.
  */
- 
+
 /*
  * find_bit() Copyright 1994, J. Lawrence Stephan.
  */
@@ -19,25 +19,25 @@
 
 /* function definitions */
 
- int find_bit(void * addr);
- long atomic_inc(long * addr);
- long atomic_dec(long * addr);
- int set_bit(int nr, void * addr);
- int clear_bit(int nr, void * addr);
- int test_bit(int nr, void * addr);
- int pic0_to_emu(char flags);
+int             find_bit(void *addr);
+long            atomic_inc(long *addr);
+long            atomic_dec(long *addr);
+int             set_bit(int nr, void *addr);
+int             clear_bit(int nr, void *addr);
+int             test_bit(int nr, void *addr);
+int             pic0_to_emu(char flags);
 
 #ifndef  C_RUN_IRQS
 #define _INLINE_ extern __inline__
 #else
-#define _INLINE_ static __inline__ 
+#define _INLINE_ static __inline__
 #endif
 
 /*
- * These have to be done with inline assembly: that way the bit-setting
- * is guaranteed to be atomic. All bit operations return 0 if the bit
- * was cleared before the operation and != 0 if it was not.
- *
+ * These have to be done with inline assembly: that way the bit-setting is
+ * guaranteed to be atomic. All bit operations return 0 if the bit was
+ * cleared before the operation and != 0 if it was not.
+ * 
  * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
  */
 
@@ -44,7 +44,9 @@
 /*
  * Some hacks to defeat gcc over-optimizations..
  */
-struct __dummy { unsigned long a[100]; };
+struct __dummy {
+    unsigned long   a[100];
+};
 #define ADDR (*(struct __dummy *) addr)
 
 /* JLS's stuff */
@@ -51,94 +53,109 @@
 /* find_bit returns the bit number of the lowest bit that's set */
 /* it doesn't need to be atomic, but it's much faster than using c */
 
-_INLINE_ int find_bit(void * addr)
+_INLINE_ int
+find_bit(void *addr)
 {
-	int bitno;
+    int             bitno;
 
-	__asm__ __volatile__("bsfl %1,%0"
-		:"=r" (bitno):"m" (ADDR));
-	return bitno;
+    __asm__         __volatile__("bsfl %1,%0"
+				 :"=r"           (bitno):"m"(ADDR));
+    return bitno;
 }
 /* atomic increment flag and decrement flag operations */
-_INLINE_ long int atomic_inc(long * addr)
-{        
-        __asm__ __volatile__("incl %1"
-                :"=m" (ADDR):"0" (ADDR));
-        return *addr;
- }
-_INLINE_ long int atomic_dec(long * addr)
-{        
-        __asm__ __volatile__("decl %1"
-                :"=m" (ADDR):"0" (ADDR));
-        return *addr;
- }
- 
-_INLINE_ int pic0_to_emu(char flags)
-{
-   /* This function maps pic0 bits to their positions in priority order */
-   /* It makes room for the pic1 bits in between.  This could be done in c,
-      but it would be messier, and might get clobbered by optimization */
-
-   /* move bits xxxx xxxx 7654 3210 to 7654 3ooo oooo 210o             */
-   /* where 76543210 are original 8 bits, x = don't care, and o = zero */
-
-        long result;    
-        __asm__ __volatile__("movzbl %1,%0\n\t
-                              shll $13,%0\n\t
-                              sarw $7,%0\n\t
-                              shrl $5,%0" 
-                :"=r" (result):"r" (flags));
-        return result;
- }
-_INLINE_ long emu_to_pic0(long flags)
-{
-   /* This function takes the pic0 bits from the overall pic bit field
-      and concatenates them into a single byte.  This could be done in c,
-      but it would be messier and might get clobbered by optimization.  */
-      
-   /* move bits 7654 3xxx xxxx 210x to xxxx xxxx 7654 3210          */
-   /* where 76543210 are final 8 bits and x = don't care            */
-
-        __asm__ __volatile__("shll $6,%0\n\t
-                              shlw $7,%0\n\t
-                              shrl $14,%0" 
-                :"=r" (flags):"0" (flags));
-        return flags;
- }
-                              
-/* Linus' stuff follows - except each __inline__ had an extern in front of it*/
-_INLINE_ int set_bit(int nr, void * addr)
-{
-	int oldbit;
-
-	__asm__ __volatile__("btsl %2,%1\n\tsbbl %0,%0"
-		:"=r" (oldbit),"=m" (ADDR)
-		:"r" (nr));
-	return oldbit;
-}
-
-_INLINE_ int clear_bit(int nr, void * addr)
-{
-	int oldbit;
-
-	__asm__ __volatile__("btrl %2,%1\n\tsbbl %0,%0"
-		:"=r" (oldbit),"=m" (ADDR)
-		:"r" (nr));
-	return oldbit;
-}
-
-/*
- * This routine doesn't need to be atomic, but it's faster to code it
- * this way.
- */
-_INLINE_ int test_bit(int nr, void * addr)
-{
-	int oldbit;
-
-	__asm__ __volatile__("btl %2,%1\n\tsbbl %0,%0"
-		:"=r" (oldbit)
-		:"m" (ADDR),"r" (nr));
-	return oldbit;
+_INLINE_ long int
+atomic_inc(long *addr)
+{
+    __asm__         __volatile__("incl %1"
+				 :"=m"           (ADDR):"0"(ADDR));
+    return *addr;
+}
+_INLINE_ long int
+atomic_dec(long *addr)
+{
+    __asm__         __volatile__("decl %1"
+				 :"=m"           (ADDR):"0"(ADDR));
+    return *addr;
+}
+
+_INLINE_ int
+pic0_to_emu(char flags)
+{
+    /* This function maps pic0 bits to their positions in priority order */
+    /*
+     * It makes room for the pic1 bits in between.  This could be done in
+     * c, but it would be messier, and might get clobbered by optimization
+     */
+
+    /* move bits xxxx xxxx 7654 3210 to 7654 3ooo oooo 210o             */
+    /* where 76543210 are original 8 bits, x = don't care, and o = zero */
+
+    long            result;
+    __asm__         __volatile__("movzbl %1,%0\n\t
+				 shll $13, %0\n\t
+				 sarw $7, %0\n\t
+				 shrl $5, %0 " 
+				 :"=r"           (result):"r"(flags));
+    return result;
+}
+_INLINE_ long
+emu_to_pic0(long flags)
+{
+    /*
+     * This function takes the pic0 bits from the overall pic bit field
+     * and concatenates them into a single byte.  This could be done in c,
+     * but it would be messier and might get clobbered by optimization.
+     */
+
+    /* move bits 7654 3xxx xxxx 210x to xxxx xxxx 7654 3210          */
+    /* where 76543210 are final 8 bits and x = don't care            */
+
+    __asm__         __volatile__("shll $6,%0\n\t
+				 shlw $7, %0\n\t
+				 shrl $14, %0 " 
+				 :"=r"           (flags):"0"(flags));
+    return flags;
+}
+
+/*
+ * Linus' stuff follows - except each __inline__ had an extern in front of
+ * it
+ */
+_INLINE_ int
+set_bit(int nr, void *addr)
+{
+    int             oldbit;
+
+    __asm__         __volatile__("btsl %2,%1\n\tsbbl %0,%0"
+				 :"=r"           (oldbit), "=m"(ADDR)
+				 :"r"            (nr));
+    return oldbit;
+}
+
+_INLINE_ int
+clear_bit(int nr, void *addr)
+{
+    int             oldbit;
+
+    __asm__         __volatile__("btrl %2,%1\n\tsbbl %0,%0"
+				 :"=r"           (oldbit), "=m"(ADDR)
+				 :"r"            (nr));
+    return oldbit;
+}
+
+/*
+ * This routine doesn't need to be atomic, but it's faster to code it this
+ * way.
+ */
+_INLINE_ int
+test_bit(int nr, void *addr)
+{
+    int             oldbit;
+
+    __asm__         __volatile__("btl %2,%1\n\tsbbl %0,%0"
+				 :"=r"           (oldbit)
+				 :"m"            (ADDR), "r"(nr));
+    return oldbit;
 }
 
-#endif /* _ASM_BITOPS_H */
+#endif				/* _ASM_BITOPS_H */
diff -u --recursive --new-file dosemu0.53.52/include/emu.h dosemu0.53.53/include/emu.h
--- dosemu0.53.52/include/emu.h	Fri Mar 17 22:47:35 1995
+++ dosemu0.53.53/include/emu.h	Sun Mar 19 12:13:18 1995
@@ -335,6 +335,7 @@
        int hdiskboot;
 
        /* for video */
+       boolean console;
        boolean console_video;
        boolean graphics;
        boolean vga;
@@ -412,6 +413,12 @@
        unsigned char *num_table;
        unsigned short detach;
        unsigned char *debugout;
+
+       /* Lock File business */
+       char *tty_lockdir;	/* The Lock directory  */
+       char *tty_lockfile;	/* Lock file pretext ie LCK.. */
+       boolean tty_lockbinary;	/* Binary lock files ? */
+
      }
 
 config_t;
diff -u --recursive --new-file dosemu0.53.52/include/mouse.h dosemu0.53.53/include/mouse.h
--- dosemu0.53.52/include/mouse.h	Fri Mar 17 22:47:35 1995
+++ dosemu0.53.53/include/mouse.h	Sun Mar 19 12:13:18 1995
@@ -48,6 +48,7 @@
   int fd;
   int type;
   int flags;
+  boolean add_to_io_select;
   boolean intdrv;
   boolean emulate3buttons;
   boolean cleardtr;
diff -u --recursive --new-file dosemu0.53.52/include/serial.h dosemu0.53.53/include/serial.h
--- dosemu0.53.52/include/serial.h	Fri Mar 17 22:47:35 1995
+++ dosemu0.53.53/include/serial.h	Sun Mar 19 12:13:18 1995
@@ -54,6 +54,19 @@
 #ifndef SERIAL_H
 #define SERIAL_H
 
+
+/* the Lock file stuff.  Default user is uucp!
+ */
+#ifndef OWNER_LOCKS
+#define OWNER_LOCKS        "uucp"                  /* owns locks  */
+#endif
+#ifndef PATH_LOCKD
+#define PATH_LOCKD         "/var/locks"            /* lock files */
+#endif
+#ifndef NAME_LOCKF
+#define NAME_LOCKF         "LCK.."                 /* lock file name */
+#endif
+
 /* the UART definitions are quoted from linux/include/linux/serial.h, a work
  * by Theodore Ts'o
  */
@@ -220,6 +233,8 @@
   int interrupt;		/* IRQ line handled by device */
   int fd;			/* File descriptor of device */
   boolean mouse;		/* Flag to turn on mouse sharing features */
+  boolean dev_locked;           /* Flag to indicate wether device is locked */
+                                /* or not */
 
   u_char int_pend;		/* Interrupt Pending Flag */
   u_char int_type;		/* Interrupts Waiting Flags */
diff -u --recursive --new-file dosemu0.53.52/init/config.c dosemu0.53.53/init/config.c
--- dosemu0.53.52/init/config.c	Fri Mar 17 15:17:28 1995
+++ dosemu0.53.53/init/config.c	Sun Mar 19 11:59:59 1995
@@ -1,5 +1,5 @@
 /*
- * $Id: config.c,v 1.4 1995/02/25 22:37:46 root Exp root $ 
+ * $Id: config.c,v 1.4 1995/02/25 22:37:46 root Exp root $
  */
 #include <stdio.h>
 #include <unistd.h>
@@ -12,6 +12,7 @@
 #include "cpu.h"
 #include "video.h"
 #include "mouse.h"
+#include "serial.h"
 #include "keymaps.h"
 #include "memory.h"
 #include "bios.h"
@@ -19,560 +20,557 @@
 
 #include "dos2linux.h"
 
-/* XXX - the mem size of 734 is much more dangerous than 704.
- * 704 is the bottom of 0xb0000 memory.  use that instead?
+/*
+ * XXX - the mem size of 734 is much more dangerous than 704. 704 is the
+ * bottom of 0xb0000 memory.  use that instead?
  */
-#ifdef EXPERIMENTAL_GFX
 #define MAX_MEM_SIZE    640
-#else
-#define MAX_MEM_SIZE    734	/* up close to the 0xB8000 mark */
-#endif
 
 struct debug_flags d =
 {0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0};
 
 
-static void parse_debugflags(const char *s);
-static void usage(void);
+static void     check_for_env_autoexec_or_config(void);
+static void     parse_debugflags(const char *s);
+static void     usage(void);
 
 /*
  * DANG_BEGIN_FUNCTION config_defaults
- *
- * description:
- *  Set all values in the `config` structure to their default value.
- *  These will be modified by the config parser.
- *
+ * 
+ * description: Set all values in the `config` structure to their default
+ * value. These will be modified by the config parser.
+ * 
  * DANG_END_FUNCTION
- *
+ * 
  */
 static void
 config_defaults(void)
 {
-  config.hdiskboot = 1;		/* default hard disk boot */
-
-  config.mem_size = 640;
-  config.ems_size = 0;
-  config.ems_frame = 0xd000;
-  config.xms_size = 0;
-  config.max_umb = 0;
-  config.dpmi = 0;
-  config.mathco = 1;
-  config.mouse_flag = 0;
-  config.mapped_bios = 0;
-  config.mapped_sbios = 0;
-  config.vbios_file = NULL;
-  config.vbios_copy = 0;
-  config.vbios_seg = 0xc000;
-  config.vbios_size = 0x10000;
-  config.console_keyb = 0;
-  config.kbd_tty = 0;
-  config.console_video = 0;
-  config.fdisks = 0;
-  config.hdisks = 0;
-  config.bootdisk = 0;
-  config.exitearly = 0;
-  config.term_method = METHOD_FAST;
-  config.term_color = COLOR_NORMAL;
-  config.term_updatelines = 25;
-  config.term_updatefreq = 2;
-  config.term_charset = CHARSET_LATIN;
-  config.term_corner = 1;
-  config.X_updatelines = 25;
-  config.X_updatefreq  = 8;
-  config.X_display     = NULL;     /* NULL means use DISPLAY variable */
-  config.X_title       = "dosemu";
-  config.X_icon_name   = "dosemu";
-  config.X_blinkrate   = 8;
-  config.X_keycode     = 1;
-  config.X_font = "vga";
-  config.usesX   = 0;
-  config.X   = 0;
-  config.hogthreshold = 10;     /* bad estimate of a good garrot value */
-  config.chipset = PLAINVGA;
-  config.cardtype = CARD_VGA;
-  config.fullrestore = 0;
-  config.graphics = 0;
-  config.gfxmemsize = 256;
-  config.vga = 0;		/* this flags BIOS graphics */
-  config.dualmon =0;
-
-  config.speaker = SPKR_EMULATED;
-
-#if 0 /* This is too slow, but why? */
-  config.update = 54945;
+    config.hdiskboot = 1;	/* default hard disk boot */
+    config.mem_size = 640;
+    config.ems_size = 0;
+    config.ems_frame = 0xd000;
+    config.xms_size = 0;
+    config.max_umb = 0;
+    config.dpmi = 0;
+    config.mathco = 1;
+    config.mouse_flag = 0;
+    config.mapped_bios = 0;
+    config.mapped_sbios = 0;
+    config.vbios_file = NULL;
+    config.vbios_copy = 0;
+    config.vbios_seg = 0xc000;
+    config.vbios_size = 0x10000;
+    config.console = 0;
+    config.console_keyb = 0;
+    config.console_video = 0;
+    config.kbd_tty = 0;
+    config.fdisks = 0;
+    config.hdisks = 0;
+    config.bootdisk = 0;
+    config.exitearly = 0;
+    config.term_method = METHOD_FAST;
+    config.term_color = COLOR_NORMAL;
+    config.term_updatelines = 25;
+    config.term_updatefreq = 2;
+    config.term_charset = CHARSET_LATIN;
+    config.term_corner = 1;
+    config.X_updatelines = 25;
+    config.X_updatefreq = 8;
+    config.X_display = NULL;	/* NULL means use DISPLAY variable */
+    config.X_title = "dosemu";
+    config.X_icon_name = "dosemu";
+    config.X_blinkrate = 8;
+    config.X_keycode = 1;
+    config.X_font = "vga";
+    config.usesX = 0;
+    config.X = 0;
+    config.hogthreshold = 10;	/* bad estimate of a good garrot value */
+    config.chipset = PLAINVGA;
+    config.cardtype = CARD_VGA;
+    config.fullrestore = 0;
+    config.graphics = 0;
+    config.gfxmemsize = 256;
+    config.vga = 0;		/* this flags BIOS graphics */
+    config.dualmon = 0;
+    config.speaker = SPKR_EMULATED;
+#if 0				/* This is too slow, but why? */
+    config.update = 54945;
 #else
-  config.update = 27472;
+    config.update = 27472;
 #endif
-  config.freq = 18;		/* rough frequency */
-
-  config.timers = 1;		/* deliver timer ints */
-  config.keybint = 0;		/* keyboard interrupts */
-
-  config.num_ser = 0;
-  config.num_lpt = 0;
-  vm86s.cpu_type = CPU_386;
-  config.fastfloppy = 1;
-
-  config.emusys = (char *) NULL;
-  config.emubat = (char *) NULL;
-  tmpdir = strdup(tempnam("/tmp", "dosemu"));
-  config.dosbanner = 1;
-  config.allowvideoportaccess = 0;
-
-  config.keyboard = KEYB_US;	/* What's the current keyboard  */
-  config.key_map = key_map_us;	/* pointer to the keyboard-maps */
-  config.shift_map = shift_map_us;	/* Here the Shilt-map           */
-  config.alt_map = alt_map_us;	/* And the Alt-map              */
-  config.num_table = num_table_dot;	/* Numeric keypad has a dot     */
-  config.detach = 0; /* Don't detach from current tty and open new VT. */
-  config.debugout=NULL;		/* default to no debug output file */
-  config.sillyint = 0;
-  config.must_spare_hardware_ram =0;
-  memset(config.hardware_pages,0,sizeof(config.hardware_pages));
-  
-  mice->fd         = -1;
-  mice->type       = 0;
-  mice->flags      = 0;
-  mice->intdrv     = 0;
-  mice->cleardtr   = 0;
-  mice->baudRate   = 0;
-  mice->sampleRate = 0;
-  mice->lastButtons= 0;
-  mice->chordMiddle= 0;
+    config.freq = 18;		/* rough frequency */
+    config.timers = 1;		/* deliver timer ints */
+    config.keybint = 1;		/* keyboard interrupts */
+ 
+    /* Lock file stuff */
+    config.tty_lockdir = PATH_LOCKD;    /* The Lock directory  */
+    config.tty_lockfile = NAME_LOCKF;   /* Lock file pretext ie LCK.. */
+    config.tty_lockbinary = FALSE;        /* Binary lock files ? */
+
+    config.num_ser = 0;
+    config.num_lpt = 0;
+    vm86s.cpu_type = CPU_386;
+    config.fastfloppy = 1;
+
+    config.emusys = (char *) NULL;
+    config.emubat = (char *) NULL;
+    tmpdir = strdup(tempnam("/tmp", "dosemu"));
+    config.dosbanner = 1;
+    config.allowvideoportaccess = 0;
+
+    config.keyboard = KEYB_US;	/* What's the current keyboard  */
+    config.key_map = key_map_us;/* pointer to the keyboard-maps */
+    config.shift_map = shift_map_us;	/* Here the Shilt-map           */
+    config.alt_map = alt_map_us;/* And the Alt-map              */
+    config.num_table = num_table_dot;	/* Numeric keypad has a dot     */
+    config.detach = 0;		/* Don't detach from current tty and open
+				 * new VT. */
+    config.debugout = NULL;	/* default to no debug output file */
+    config.sillyint = 0;
+    config.must_spare_hardware_ram = 0;
+    memset(config.hardware_pages, 0, sizeof(config.hardware_pages));
+
+    mice->fd = -1;
+    mice->add_to_io_select = 0;
+    mice->type = 0;
+    mice->flags = 0;
+    mice->intdrv = 0;
+    mice->cleardtr = 0;
+    mice->baudRate = 0;
+    mice->sampleRate = 0;
+    mice->lastButtons = 0;
+    mice->chordMiddle = 0;
 }
 
-static void open_terminal_pipe(char *path)
+static void 
+open_terminal_pipe(char *path)
 {
-  terminal_fd = DOS_SYSCALL(open(path, O_RDWR));
-  if (terminal_fd == -1) {
-    terminal_pipe = 0;
-    error("ERROR: open_terminal_pipe failed - cannot open %s!\n", path);
-    return;
-  }
-  else
-    terminal_pipe = 1;
+    terminal_fd = DOS_SYSCALL(open(path, O_RDWR));
+    if (terminal_fd == -1) {
+	terminal_pipe = 0;
+	error("ERROR: open_terminal_pipe failed - cannot open %s!\n", path);
+	return;
+    } else
+	terminal_pipe = 1;
 }
 
-static void open_Xkeyboard_pipe(char *path)
+static void 
+open_Xkeyboard_pipe(char *path)
 {
-  keypipe = DOS_SYSCALL(open(path, O_RDWR));
-  if (keypipe == -1) {
-    keypipe = 0;
-    error("ERROR: open_Xkeyboard_pipe failed - cannot open %s!\n", path);
+    keypipe = DOS_SYSCALL(open(path, O_RDWR));
+    if (keypipe == -1) {
+	keypipe = 0;
+	error("ERROR: open_Xkeyboard_pipe failed - cannot open %s!\n", path);
+	return;
+    }
     return;
-  }
-  return;
 }
 
-static void open_Xmouse_pipe(char *path)
+static void 
+open_Xmouse_pipe(char *path)
 {
-  mousepipe = DOS_SYSCALL(open(path, O_RDWR));
-  if (mousepipe == -1) {
-    mousepipe = 0;
-    error("ERROR: open_Xmouse_pipe failed - cannot open %s!\n", path);
+    mousepipe = DOS_SYSCALL(open(path, O_RDWR));
+    if (mousepipe == -1) {
+	mousepipe = 0;
+	error("ERROR: open_Xmouse_pipe failed - cannot open %s!\n", path);
+	return;
+    }
     return;
-  }
-  return;
 }
 
 /*
  * DANG_BEGIN_FUNCTION config_init
- *
- * description:
- *  This is called to parse the command-line arguments and config files.
- * DANG_END_FUNCTION
- *
+ * 
+ * description: This is called to parse the command-line arguments and config
+ * files. DANG_END_FUNCTION
+ * 
  */
-void config_init(int argc, char **argv)
+void 
+config_init(int argc, char **argv)
 {
-  int c;
-  char *confname = NULL;
+    int             c;
+    char           *confname = NULL;
 
-  config_defaults();
+    config_defaults();
 
-/*
- * DANG_BEGIN_REMARK
- *  For simpler support of X, DOSEMU can be started by a symbolic
- *  link called `xdos` which DOSEMU will use to switch into X-mode.
- * DANG_END_REMARK
- */
 #ifdef X_SUPPORT
-  {  char *p;
-     p = strrchr(argv[0],'/');    /* parse the program name */
-     p = p ? p+1 : argv[0];
-    
-     if (strcmp(p,"xdos")==0)
-        config.X=1;               /* activate X mode if dosemu was */ 
-                                  /* called as 'xdos'              */
-  }
+    /*
+     * DANG_BEGIN_REMARK For simpler support of X, DOSEMU can be started
+     * by a symbolic link called `xdos` which DOSEMU will use to switch
+     * into X-mode. DANG_END_REMARK
+     */
+    {
+	char           *p;
+	p = strrchr(argv[0], '/');	/* parse the program name */
+	p = p ? p + 1 : argv[0];
+
+	if (strcmp(p, "xdos") == 0)
+	    config.X = 1;	/* activate X mode if dosemu was */
+	/* called as 'xdos'              */
+    }
 #endif
-     
-  opterr = 0;
-  confname = CONFIG_FILE;
-  while ((c = getopt(argc, argv, "ABCcF:kM:D:P:VNtsgx:Km234e:E:dXY:Z:o:")) != EOF) {
-    switch (c) {
-    case 'F':
-      confname = optarg;	/* someone reassure me that this is *safe*? */
-      break;
-    case 'd':
-      if (config.detach)
-	break;
-      config.detach = (unsigned short)detach();
-      break;
-    case 'D':
-      parse_debugflags(optarg);
-      break;
+
+    opterr = 0;
+    confname = CONFIG_FILE;
+    while ((c = getopt(argc, argv, "ABCcF:kM:D:P:VNtsgx:Km234e:E:dXY:Z:o:")) != EOF) {
+	switch (c) {
+	case 'F':
+	    confname = optarg;	/* someone reassure me that this is *safe*? */
+	    break;
+	case 'd':
+	    if (config.detach)
+		break;
+	    config.detach = (unsigned short) detach();
+	    break;
+	case 'D':
+	    parse_debugflags(optarg);
+	    break;
+	}
     }
-  }
 
-  parse_config(confname);
+    parse_config(confname);
 
-  if (config.exitearly)
-    leavedos(0);
+    if (config.exitearly)
+	leavedos(0);
 
-  optind = 0;
-  opterr = 0;
-  while ((c = getopt(argc, argv, "ABCcF:kM:D:P:v:VNtT:sgx:Km234e:dXY:Z:E:o:")) != EOF) {
-    switch (c) {
-    case 'F':			/* previously parsed config file argument */
-    case 'd':
-      break;
-    case 'A':
-      config.hdiskboot = 0;
-      break;
-    case 'B':
-      config.hdiskboot = 2;
-      break;
-    case 'C':
-      config.hdiskboot = 1;
-      break;
-    case 'c':
-      config.console_video = 1;
-      break;
-    case 'k':
-      config.console_keyb = 1;
-      break;
-    case 'X':
+    optind = 0;
+    opterr = 0;
+    while ((c = getopt(argc, argv, "ABCcF:kM:D:P:v:VNtT:sgx:Km234e:dXY:Z:E:o:")) != EOF) {
+	switch (c) {
+	case 'F':		/* previously parsed config file argument */
+	case 'd':
+	    break;
+	case 'A':
+	    config.hdiskboot = 0;
+	    break;
+	case 'B':
+	    config.hdiskboot = 2;
+	    break;
+	case 'C':
+	    config.hdiskboot = 1;
+	    break;
+	case 'c':
+	    config.console_video = 1;
+	    break;
+	case 'k':
+	    config.console_keyb = 1;
+	    break;
+	case 'X':
 #ifdef X_SUPPORT
-      config.X = 1;
-#else
-      error("X support not compiled in\n");
-#endif
-      break;
-    case 'Y':
-      open_Xkeyboard_pipe(optarg);
-      config.cardtype = CARD_MDA;
-      config.mapped_bios = 0;
-      config.vbios_file = NULL;
-      config.vbios_copy = 0;
-      config.vbios_seg = 0xc000;
-      config.console_video = 0;
-      config.chipset = 0;
-      config.fullrestore = 0;
-      config.graphics = 0;
-      config.vga = 0;  /* this flags BIOS graphics */
-      config.usesX = 1;
-      config.console_keyb = 1;
-      break;
-    case 'Z':
-      open_Xmouse_pipe(optarg);
-      config.usesX = 1;
-      break;
-    case 'K':
-      warn("Keyboard interrupt enabled...this is still buggy!\n");
-      config.keybint = 1;
-      break;
-    case 'M':{
-	int max_mem = config.vga ? 640 : MAX_MEM_SIZE;
-
-	config.mem_size = atoi(optarg);
-	if (config.mem_size > max_mem)
-	  config.mem_size = max_mem;
-	break;
-      }
-    case 'D':
-      parse_debugflags(optarg);
-      break;
-    case 'o':
-      config.debugout = strdup(optarg);
-      dbg_fd=fopen(config.debugout,"w");
-      if(!dbg_fd) {
-	fprintf(stderr, "can't open \"%s\" for writing\n",config.debugout);
-	exit(1);
-      }
-      break;
-    case 'P':
-      if (terminal_fd == -1)
-	open_terminal_pipe(optarg);
-      else
-	error("ERROR: terminal pipe already open\n");
-      break;
-    case 'V':
-      g_printf("Configuring as VGA video card & mapped ROM\n");
-      config.vga = 1;
-      config.mapped_bios = 1;
-      if (config.mem_size > 640)
-	config.mem_size = 640;
-      break;
-    case 'v':
-      config.cardtype = atoi(optarg);
-      if(config.cardtype > 4)
-	config.cardtype = 1;
-      g_printf("Configuring cardtype as %d\n", config.cardtype);
-      break;
-    case 'N':
-      warn("DOS will not be started\n");
-      config.exitearly = 1;
-      break;
-    case 'T':
-      g_printf("Using tmpdir=%s\n", optarg);
-      free(tmpdir);
-      tmpdir = strdup(optarg);
-      break;
-    case 't':
-      g_printf("doing timer emulation\n");
-      config.timers = 1;
-      break;
-    case 's':
-      g_printf("using new scrn size code\n");
-      sizes = 1;
-      break;
-    case 'g':
-#ifdef EXPERIMENTAL_GFX
-      g_printf("turning graphics option on\n");
-      config.graphics = 1;
+	    config.X = 1;
 #else
-      error("Graphics support not compiled in!\n");
+	    error("X support not compiled in\n");
 #endif
-      break;
-
-    case 'x':
-      config.xms_size = atoi(optarg);
-      x_printf("enabling %dK XMS memory\n", config.xms_size);
-      break;
-
-    case 'e':
-      config.ems_size = atoi(optarg);
-      g_printf("enabling %dK EMS memory\n", config.ems_size);
-      break;
-
-    case 'm':
-      g_printf("turning MOUSE support on\n");
-      config.mouse_flag = 1;
-      break;
-
-    case '2':
-      g_printf("CPU set to 286\n");
-      vm86s.cpu_type = CPU_286;
-      break;
-
-    case '3':
-      g_printf("CPU set to 386\n");
-      vm86s.cpu_type = CPU_386;
-      break;
-
-    case '4':
-      g_printf("CPU set to 486\n");
-      vm86s.cpu_type = CPU_486;
-      break;
-
-    case 'E':
-      g_printf("DOS command given on command line\n");
-      misc_e6_store_command (optarg);
-      break;
-
-    case '?':
-    default:
-      fprintf(stderr, "unrecognized option: -%c\n\r", c);
-      usage();
-      fflush(stdout);
-      fflush(stderr);
-      _exit(1);
+	    break;
+	case 'Y':
+	    open_Xkeyboard_pipe(optarg);
+	    config.cardtype = CARD_MDA;
+	    config.mapped_bios = 0;
+	    config.vbios_file = NULL;
+	    config.vbios_copy = 0;
+	    config.vbios_seg = 0xc000;
+	    config.console_video = 0;
+	    config.chipset = 0;
+	    config.fullrestore = 0;
+	    config.graphics = 0;
+	    config.vga = 0;	/* this flags BIOS graphics */
+	    config.usesX = 1;
+	    config.console_keyb = 1;
+	    break;
+	case 'Z':
+	    open_Xmouse_pipe(optarg);
+	    config.usesX = 1;
+	    break;
+	case 'K':
+	    warn("Keyboard interrupt enabled...this is still buggy!\n");
+	    config.keybint = 1;
+	    break;
+	case 'M':{
+		int             max_mem = config.vga ? 640 : MAX_MEM_SIZE;
+		config.mem_size = atoi(optarg);
+		if (config.mem_size > max_mem)
+		    config.mem_size = max_mem;
+		break;
+	    }
+	case 'D':
+	    parse_debugflags(optarg);
+	    break;
+	case 'o':
+	    config.debugout = strdup(optarg);
+	    dbg_fd = fopen(config.debugout, "w");
+	    if (!dbg_fd) {
+		fprintf(stderr, "can't open \"%s\" for writing\n", config.debugout);
+		exit(1);
+	    }
+	    break;
+	case 'P':
+	    if (terminal_fd == -1)
+		open_terminal_pipe(optarg);
+	    else
+		error("ERROR: terminal pipe already open\n");
+	    break;
+	case 'V':
+	    g_printf("Configuring as VGA video card & mapped ROM\n");
+	    config.vga = 1;
+	    config.mapped_bios = 1;
+	    if (config.mem_size > 640)
+		config.mem_size = 640;
+	    break;
+	case 'v':
+	    config.cardtype = atoi(optarg);
+	    if (config.cardtype > 4)
+		config.cardtype = 1;
+	    g_printf("Configuring cardtype as %d\n", config.cardtype);
+	    break;
+	case 'N':
+	    warn("DOS will not be started\n");
+	    config.exitearly = 1;
+	    break;
+	case 'T':
+	    g_printf("Using tmpdir=%s\n", optarg);
+	    free(tmpdir);
+	    tmpdir = strdup(optarg);
+	    break;
+	case 't':
+	    g_printf("doing timer emulation\n");
+	    config.timers = 1;
+	    break;
+	case 's':
+	    g_printf("using new scrn size code\n");
+	    sizes = 1;
+	    break;
+	case 'g':
+	    g_printf("turning graphics option on\n");
+	    config.graphics = 1;
+	    break;
+
+	case 'x':
+	    config.xms_size = atoi(optarg);
+	    x_printf("enabling %dK XMS memory\n", config.xms_size);
+	    break;
+
+	case 'e':
+	    config.ems_size = atoi(optarg);
+	    g_printf("enabling %dK EMS memory\n", config.ems_size);
+	    break;
+
+	case 'm':
+	    g_printf("turning MOUSE support on\n");
+	    config.mouse_flag = 1;
+	    break;
+
+	case '2':
+	    g_printf("CPU set to 286\n");
+	    vm86s.cpu_type = CPU_286;
+	    break;
+
+	case '3':
+	    g_printf("CPU set to 386\n");
+	    vm86s.cpu_type = CPU_386;
+	    break;
+
+	case '4':
+	    g_printf("CPU set to 486\n");
+	    vm86s.cpu_type = CPU_486;
+	    break;
+
+	case 'E':
+	    g_printf("DOS command given on command line\n");
+	    misc_e6_store_command(optarg);
+	    break;
+
+	case '?':
+	default:
+	    fprintf(stderr, "unrecognized option: -%c\n\r", c);
+	    usage();
+	    fflush(stdout);
+	    fflush(stderr);
+	    _exit(1);
+	}
     }
-  }
-  if (config.X) {
-    config.console_video = config.vga = config.graphics = 0;
-  }
-
-  check_for_env_autoexec_or_config();
+    if (config.X) {
+	config.console_video = config.vga = config.graphics = 0;
+    }
+    check_for_env_autoexec_or_config();
 }
 
 
-static void check_for_env_autoexec_or_config(void)
+static void 
+check_for_env_autoexec_or_config(void)
 {
-      char *cp;
-      cp = getenv("AUTOEXEC");
-      if(cp)
-              config.emubat = cp;
-      cp = getenv("CONFIG");
-      if(cp)
-              config.emusys = cp;
-
-
-      if(config.emubat)
-              fprintf(stderr, "autoexec extension = %s\n", config.emubat);
-      if(config.emusys)
-              fprintf(stderr, "config extension = %s\n", config.emusys);
+    char           *cp;
+    cp = getenv("AUTOEXEC");
+    if (cp)
+	config.emubat = cp;
+    cp = getenv("CONFIG");
+    if (cp)
+	config.emusys = cp;
+
 
-} 
+    if (config.emubat)
+	fprintf(stderr, "autoexec extension = %s\n", config.emubat);
+    if (config.emusys)
+	fprintf(stderr, "config extension = %s\n", config.emusys);
 
-/* 
+}
+
+/*
  * DANG_BEGIN_FUNCTION parse_debugflags
- *
- * arguments:
- *  s - string of options.
+ * 
+ * arguments: s - string of options.
+ * 
+ * description: This part is fairly flexible...you specify the debugging
+ * flags you wish with -D string.  The string consists of the following
+ * characters: +   turns the following options on (initial state) -
+ * turns the following options off a   turns all the options on/off,
+ * depending on whether +/- is set 0-9 sets debug levels (0 is off, 9 is
+ * most verbose) #   where # is a letter from the valid option list (see
+ * docs), turns that option off/on depending on the +/- state.
  * 
- * description:
- *  This part is fairly flexible...you specify the debugging flags you wish
- * with -D string.  The string consists of the following characters:
- *   +   turns the following options on (initial state)
- *   -   turns the following options off
- *   a   turns all the options on/off, depending on whether +/- is set
- *   0-9 sets debug levels (0 is off, 9 is most verbose)
- *   #   where # is a letter from the valid option list (see docs), turns
- *       that option off/on depending on the +/- state.
- *
  * Any option letter can occur in any place.  Even meaningless combinations,
- * such as "01-a-1+0vk" will be parsed without error, so be careful.
- * Some options are set by default, some are clear. This is subject to my
- * whim.  You can ensure which are set by explicitly specifying.
- *
+ * such as "01-a-1+0vk" will be parsed without error, so be careful. Some
+ * options are set by default, some are clear. This is subject to my whim.
+ * You can ensure which are set by explicitly specifying.
+ * 
  * DANG_END_FUNCTION
  */
 static void
 parse_debugflags(const char *s)
 {
-  char c;
-  unsigned char flag = 1;
-  const char allopts[] = "vsdDRWkpiwghxmIEcXP";
-
-  /* if you add new classes of debug messages, make sure to add the
-	 * letter to the allopts string above so that "1" and "a" can work
-	 * correctly.
-	 */
-
-  dbug_printf("debug flags: %s\n", s);
-  while ((c = *(s++)))
-    switch (c) {
-    case '+':			/* begin options to turn on */
-      if (!flag)
-	flag = 1;
-      break;
-    case '-':			/* begin options to turn off */
-      flag = 0;
-      break;
-    case 'v':			/* video */
-      d.video = flag;
-      break;
+    char            c;
+    unsigned char   flag = 1;
+    const char      allopts[] = "vsdDRWkpiwghxmIEcXP";
+
+    /*
+     * if you add new classes of debug messages, make sure to add the
+     * letter to the allopts string above so that "1" and "a" can work
+     * correctly.
+     */
+
+    dbug_printf("debug flags: %s\n", s);
+    while ((c = *(s++)))
+	switch (c) {
+	case '+':		/* begin options to turn on */
+	    if (!flag)
+		flag = 1;
+	    break;
+	case '-':		/* begin options to turn off */
+	    flag = 0;
+	    break;
+	case 'v':		/* video */
+	    d.video = flag;
+	    break;
 #ifdef X_SUPPORT
-    case 'X':
-      d.X = flag;
-      break;
+	case 'X':
+	    d.X = flag;
+	    break;
 #endif
-    case 's':			/* serial */
-      d.serial = flag;
-      break;
-    case 'c':			/* disk */
-      d.config = flag;
-      break;
-    case 'd':			/* disk */
-      d.disk = flag;
-      break;
-    case 'R':			/* disk READ */
-      d.read = flag;
-      break;
-    case 'W':			/* disk WRITE */
-      d.write = flag;
-      break;
-    case 'k':			/* keyboard */
-      d.keyb = flag;
-      break;
-    case 'p':			/* printer */
-      d.printer = flag;
-      break;
-    case 'i':			/* i/o instructions (in/out) */
-      d.io = flag;
-      break;
-    case 'w':			/* warnings */
-      d.warning = flag;
-      break;
-    case 'g':			/* general messages */
-      d.general = flag;
-      break;
-    case 'x':			/* XMS */
-      d.xms = flag;
-      break;
-    case 'D':			/* DPMI */
-      d.dpmi = flag;
-      break;
-    case 'm':			/* mouse */
-      d.mouse = flag;
-    case 'P':
-      d.pd = flag;
-      d.network=flag;
-      break;
-    case 'a':{			/* turn all on/off depending on flag */
-	char *newopts = (char *) malloc(strlen(allopts) + 2);
-
-	d.all = flag;
-	newopts[0] = flag ? '+' : '-';
-	newopts[1] = 0;
-	strcat(newopts, allopts);
-	parse_debugflags(newopts);
-	free(newopts);
-	break;
-      }
-    case 'h':			/* hardware */
-      d.hardware = flag;
-      break;
-    case 'I':			/* IPC */
-      d.IPC = flag;
-      break;
-    case 'E':			/* EMS */
-      d.EMS = flag;
-      break;
-    case '0'...'9':		/* set debug level, 0 is off, 9 is most verbose */
-      flag = c - '0';
-      break;
-    default:
-      fprintf(stderr, "Unknown debug-msg mask: %c\n\r", c);
-      dbug_printf("Unknown debug-msg mask: %c\n", c);
-    }
+	case 's':		/* serial */
+	    d.serial = flag;
+	    break;
+	case 'c':		/* disk */
+	    d.config = flag;
+	    break;
+	case 'd':		/* disk */
+	    d.disk = flag;
+	    break;
+	case 'R':		/* disk READ */
+	    d.read = flag;
+	    break;
+	case 'W':		/* disk WRITE */
+	    d.write = flag;
+	    break;
+	case 'k':		/* keyboard */
+	    d.keyb = flag;
+	    break;
+	case 'p':		/* printer */
+	    d.printer = flag;
+	    break;
+	case 'i':		/* i/o instructions (in/out) */
+	    d.io = flag;
+	    break;
+	case 'w':		/* warnings */
+	    d.warning = flag;
+	    break;
+	case 'g':		/* general messages */
+	    d.general = flag;
+	    break;
+	case 'x':		/* XMS */
+	    d.xms = flag;
+	    break;
+	case 'D':		/* DPMI */
+	    d.dpmi = flag;
+	    break;
+	case 'm':		/* mouse */
+	    d.mouse = flag;
+	case 'P':
+	    d.pd = flag;
+	    d.network = flag;
+	    break;
+	case 'a':{		/* turn all on/off depending on flag */
+		char           *newopts = (char *) malloc(strlen(allopts) + 2);
+
+		d.all = flag;
+		newopts[0] = flag ? '+' : '-';
+		newopts[1] = 0;
+		strcat(newopts, allopts);
+		parse_debugflags(newopts);
+		free(newopts);
+		break;
+	    }
+	case 'h':		/* hardware */
+	    d.hardware = flag;
+	    break;
+	case 'I':		/* IPC */
+	    d.IPC = flag;
+	    break;
+	case 'E':		/* EMS */
+	    d.EMS = flag;
+	    break;
+	case '0'...'9':	/* set debug level, 0 is off, 9 is most
+				 * verbose */
+	    flag = c - '0';
+	    break;
+	default:
+	    fprintf(stderr, "Unknown debug-msg mask: %c\n\r", c);
+	    dbug_printf("Unknown debug-msg mask: %c\n", c);
+	}
 }
 
 static void
- usage(void) {
-  fprintf(stdout, "$Header: /home/src/dosemu0.60/init/RCS/config.c,v 1.4 1995/02/25 22:37:46 root Exp root $\n");
-  fprintf(stdout, "usage: dos [-ABCckbVNtsgxKm234e] [-D flags] [-M SIZE] [-P FILE] [ -F File ] 2> dosdbg\n");
-  fprintf(stdout, "    -A boot from first defined floppy disk (A)\n");
-  fprintf(stdout, "    -B boot from second defined floppy disk (B) (#)\n");
-  fprintf(stdout, "    -C boot from first defined hard disk (C)\n");
-  fprintf(stdout, "    -c use PC console video (kernel 0.99pl3+) (!%%)\n");
-  fprintf(stdout, "    -k use PC console keyboard (kernel 0.99pl3+) (!)\n");
+usage(void)
+{
+    fprintf(stdout, "$Header: /home/src/dosemu0.60/init/RCS/config.c,v 1.4 1995/02/25 22:37:46 root Exp root $\n");
+    fprintf(stdout, "usage: dos [-ABCckbVNtsgxKm234e] [-D flags] [-M SIZE] [-P FILE] [ -F File ] 2> dosdbg\n");
+    fprintf(stdout, "    -A boot from first defined floppy disk (A)\n");
+    fprintf(stdout, "    -B boot from second defined floppy disk (B) (#)\n");
+    fprintf(stdout, "    -C boot from first defined hard disk (C)\n");
+    fprintf(stdout, "    -c use PC console video (kernel 0.99pl3+) (!%%)\n");
+    fprintf(stdout, "    -k use PC console keyboard (kernel 0.99pl3+) (!)\n");
 #ifdef X_SUPPORT
-  fprintf(stdout, "    -X run in X Window (#)\n");
-  fprintf(stdout, "    -X NAME use MDA direct and FIFO NAME for keyboard (only with x2dos!)\n");
-  fprintf(stdout, "    -Y NAME use FIFO NAME for mouse (only with x2dos!)\n");
-  fprintf(stdout, "    -D set debug-msg mask to flags (+-)(dRWDvXk?is#pgwhxmIEcn01)\n");
-#else /* X_SUPPORT */
-  fprintf(stdout, "    -D set debug-msg mask to flags (+-)(dRWDvk?is#pgwhxmIEcn01)\n");
-#endif /* X_SUPPORT */
-  fprintf(stdout, "    -M set memory size to SIZE kilobytes (!)\n");
-  fprintf(stdout, "    -P copy debugging output to FILE\n");
-  fprintf(stdout, "    -b map BIOS into emulator RAM (%%)\n");
-  fprintf(stdout, "    -F use config-file File\n");
-  fprintf(stdout, "    -V use BIOS-VGA video modes (!#%%)\n");
-  fprintf(stdout, "    -N No boot of DOS\n");
-  fprintf(stdout, "    -t try new timer code (#)\n");
-  fprintf(stdout, "    -s try new screen size code (COMPLETELY BROKEN)(#)\n");
-  fprintf(stdout, "    -g enable graphics modes (COMPLETELY BROKEN) (!%%#)\n");
-  fprintf(stdout, "    -x SIZE enable SIZE K XMS RAM\n");
-  fprintf(stdout, "    -e SIZE enable SIZE K EMS RAM\n");
-  fprintf(stdout, "    -m enable mouse support (!#)\n");
-  fprintf(stdout, "    -2,3,4 choose 286, 386 or 486 CPU\n");
-  fprintf(stdout, "    -K Do int9 (!#)\n");
-  fprintf(stdout, "\n     (!) means BE CAREFUL! READ THE DOCS FIRST!\n");
-  fprintf(stdout, "     (%%) marks those options which require dos be run as root (i.e. suid)\n");
-  fprintf(stdout, "     (#) marks options which do not fully work yet\n");
+    fprintf(stdout, "    -X run in X Window (#)\n");
+    fprintf(stdout, "    -X NAME use MDA direct and FIFO NAME for keyboard (only with x2dos!)\n");
+    fprintf(stdout, "    -Y NAME use FIFO NAME for mouse (only with x2dos!)\n");
+    fprintf(stdout, "    -D set debug-msg mask to flags (+-)(dRWDvXk?is#pgwhxmIEcn01)\n");
+#else				/* X_SUPPORT */
+    fprintf(stdout, "    -D set debug-msg mask to flags (+-)(dRWDvk?is#pgwhxmIEcn01)\n");
+#endif				/* X_SUPPORT */
+    fprintf(stdout, "    -M set memory size to SIZE kilobytes (!)\n");
+    fprintf(stdout, "    -P copy debugging output to FILE\n");
+    fprintf(stdout, "    -b map BIOS into emulator RAM (%%)\n");
+    fprintf(stdout, "    -F use config-file File\n");
+    fprintf(stdout, "    -V use BIOS-VGA video modes (!#%%)\n");
+    fprintf(stdout, "    -N No boot of DOS\n");
+    fprintf(stdout, "    -t try new timer code (#)\n");
+    fprintf(stdout, "    -s try new screen size code (COMPLETELY BROKEN)(#)\n");
+    fprintf(stdout, "    -g enable graphics modes (COMPLETELY BROKEN) (!%%#)\n");
+    fprintf(stdout, "    -x SIZE enable SIZE K XMS RAM\n");
+    fprintf(stdout, "    -e SIZE enable SIZE K EMS RAM\n");
+    fprintf(stdout, "    -m enable mouse support (!#)\n");
+    fprintf(stdout, "    -2,3,4 choose 286, 386 or 486 CPU\n");
+    fprintf(stdout, "    -K Do int9 (!#)\n");
+    fprintf(stdout, "\n     (!) means BE CAREFUL! READ THE DOCS FIRST!\n");
+    fprintf(stdout, "     (%%) marks those options which require dos be run as root (i.e. suid)\n");
+    fprintf(stdout, "     (#) marks options which do not fully work yet\n");
 }
-
diff -u --recursive --new-file dosemu0.53.52/init/init.c dosemu0.53.53/init/init.c
--- dosemu0.53.52/init/init.c	Fri Mar 17 20:17:24 1995
+++ dosemu0.53.53/init/init.c	Sat Mar 18 20:56:13 1995
@@ -21,6 +21,7 @@
 #include "int.h"
 #include "timers.h"
 #include "termio.h"
+#include "vc.h"
 #include "mouse.h"
 #ifdef USING_NET
 #include "ipx.h"
@@ -30,6 +31,7 @@
 #include "pic.h"
 #endif
 
+extern void pkt_check_receive_quick(void);
 
 #if 0
 static inline void dbug_dumpivec(void)
@@ -185,6 +187,10 @@
     pic_seti(PIC_IRQ12, DOSEMUMouseEvents, 0);
     pic_unmaski(PIC_IRQ12);
   }
+#ifdef USING_NET
+  pic_seti(16, pkt_check_receive_quick, 0);
+  pic_unmaski(16);
+#endif
 #else 
   for (i = 0; i < 2; i++) {
     pics[i].OCW1 = 0;		/* no IRQ's serviced */
@@ -480,6 +486,7 @@
  */
 void version_init(void) {
   struct new_utsname unames;
+
   uname(&unames);
   warn("DOSEMU%spl%s is coming up on %s version %s\n", VERSTR, PATCHSTR, unames.sysname, unames.release);  
   warn("Built for %d\n", KERNEL_VERSION);
@@ -489,6 +496,7 @@
       use_sigio=FASYNC;
     }
   }
+
   /* Next Check input */
   if (isatty(STDIN_FILENO)) {
     k_printf("STDIN is tty\n");
@@ -497,6 +505,7 @@
     k_printf("STDIN not a tty\n");
     config.kbd_tty = 1;
   }
+
 }
 
 
diff -u --recursive --new-file dosemu0.53.52/keyboard/keyboard-client.c dosemu0.53.53/keyboard/keyboard-client.c
--- dosemu0.53.52/keyboard/keyboard-client.c	Thu Mar 16 21:02:04 1995
+++ dosemu0.53.53/keyboard/keyboard-client.c	Sat Mar 18 22:02:45 1995
@@ -1,26 +1,22 @@
-/* dosmemulator, Matthias Lautner
- *
+/*
+ * dosmemulator, Matthias Lautner
+ * 
  * DANG_BEGIN_MODULE
- *
+ * 
  * This handles the keyboard.
- *
- * Two keyboard modes are handled 'raw' and 'xlate'. 'Raw' works with
- * codes as sent out by the kernel and 'xlate' uses plain ASCII as used over
+ * 
+ * Two keyboard modes are handled 'raw' and 'xlate'. 'Raw' works with codes
+ * as sent out by the kernel and 'xlate' uses plain ASCII as used over
  * serial lines. The mapping for different languages & the two ALT-keys is
  * done here, but the definitions are elsewhere. Only the default (US)
  * keymap is stored here.
- *
+ * 
  * DANG_END_MODULE
- *
- *
+ * 
+ * 
  * DANG_BEGIN_CHANGELOG
- *
- * $Date: $
- * $Source: $
- * $Revision:$
- * $State: $
- * $Log: $
- * DANG_END_CHANGELOG
+ * 
+ * $Date: $ $Source: $ $Revision:$ $State: $ $Log: $ DANG_END_CHANGELOG
  */
 
 #include <unistd.h>
@@ -38,154 +34,143 @@
 #include "shared.h"
 #include "vc.h"
 
-static int tty_raw (int);
-inline void child_set_flags (int);
-static void clear_raw_mode ();
-extern void clear_console_video ();
-extern void clear_consoleX_video ();
-extern void clear_process_control ();
-static void set_raw_mode ();
-void set_leds ();
-extern void set_leds_area ();
-extern void add_scancode_to_queue (u_short);
-extern void activate (int);
-extern int terminal_initialize ();
-extern void terminal_close ();
-void convascii (int *);
+static int      tty_raw(int);
+inline void     child_set_flags(int);
+static void     clear_raw_mode();
+extern void     clear_console_video();
+extern void     clear_consoleX_video();
+extern void     clear_process_control();
+static void     set_raw_mode();
+void            set_leds();
+extern void     set_leds_area();
+extern void     add_scancode_to_queue(u_short);
+extern void     activate(int);
+extern int      terminal_initialize();
+extern void     terminal_close();
+void            convascii(int *);
 
 static unsigned int queue;
 
 #define put_queue(psc) (queue = psc)
 
-void getKeys ();
+void            getKeys();
 
-void child_set_flags (int sc);
+void            child_set_flags(int sc);
 
-void child_set_kbd_flag (int), child_clr_kbd_flag (int);
-int child_kbd_flag (int);
-extern int kbd_flag (int);
+void            child_set_kbd_flag(int),
+                child_clr_kbd_flag(int);
+int             child_kbd_flag(int);
+extern int      kbd_flag(int);
 
 /* initialize these in keyboard_init()! */
-unsigned int child_kbd_flags = 0;
+unsigned int    child_kbd_flags = 0;
 
-static int altchar = 0;
+static int      altchar = 0;
 
-static int old_kbd_flags = -1;	/* flags for STDIN before our fcntl */
+static int      old_kbd_flags = -1;	/* flags for STDIN before our
+					 * fcntl */
 
-int kbcount = 0;
-unsigned char kbbuf[KBBUF_SIZE], *kbp, erasekey;
+int             kbcount = 0;
+unsigned char   kbbuf[KBBUF_SIZE],
+               *kbp,
+                erasekey;
 static struct termios oldtermios;	/* original terminal modes */
 
 #if 0
 int
-do_ioctl (int fd, int req, int param3)
+do_ioctl(int fd, int req, int param3)
 {
-  int tmp;
+    int             tmp;
 
-  if (in_sighandler && in_ioctl)
-    {
-      k_printf ("KBD: do_ioctl(): in ioctl %d 0x%04x 0x%04x.\nqueuing: %d 0x%04x 0x%04x\n",
-		curi.fd, curi.req, curi.param3, fd, req, param3);
-      queue_ioctl (fd, req, param3);
-      errno = EDEADLOCK;
+    if (in_sighandler && in_ioctl) {
+	k_printf("KBD: do_ioctl(): in ioctl %d 0x%04x 0x%04x.\nqueuing: %d 0x%04x 0x%04x\n",
+		 curi.fd, curi.req, curi.param3, fd, req, param3);
+	queue_ioctl(fd, req, param3);
+	errno = EDEADLOCK;
 #ifdef SYNC_ALOT
-      fflush (stdout);
-      sync ();			/* for safety */
+	fflush(stdout);
+	sync();			/* for safety */
 #endif
-      return -1;
-    }
-  else
-    {
-      in_ioctl = 1;
-      curi.fd = fd;
-      curi.req = req;
-      curi.param3 = param3;
-      if (iq.queued)
-	{
-	  k_printf ("KBD: detected queued ioctl in do_ioctl(): %d 0x%04x 0x%04x\n",
-		    iq.fd, iq.req, iq.param3);
+	return -1;
+    } else {
+	in_ioctl = 1;
+	curi.fd = fd;
+	curi.req = req;
+	curi.param3 = param3;
+	if (iq.queued) {
+	    k_printf("KBD: detected queued ioctl in do_ioctl(): %d 0x%04x 0x%04x\n",
+		     iq.fd, iq.req, iq.param3);
 	}
-      k_printf ("KBD: IOCTL fd=0x%x, req=0x%x, param3=0x%x\n", fd, req, param3);
-      tmp = ioctl (fd, req, param3);
-      in_ioctl = 0;
-      return tmp;
+	k_printf("KBD: IOCTL fd=0x%x, req=0x%x, param3=0x%x\n", fd, req, param3);
+	tmp = ioctl(fd, req, param3);
+	in_ioctl = 0;
+	return tmp;
     }
 }
 
 int
-queue_ioctl (int fd, int req, int param3)
+queue_ioctl(int fd, int req, int param3)
 {
-  if (iq.queued)
-    {
-      error ("ioctl already queued: %d 0x%04x 0x%04x\n", iq.fd, iq.req,
-	     iq.param3);
-      return 1;
-    }
-  iq.fd = fd;
-  iq.req = req;
-  iq.param3 = param3;
-  iq.queued = 1;
+    if (iq.queued) {
+	error("ioctl already queued: %d 0x%04x 0x%04x\n", iq.fd, iq.req,
+	      iq.param3);
+	return 1;
+    }
+    iq.fd = fd;
+    iq.req = req;
+    iq.param3 = param3;
+    iq.queued = 1;
 
-  return 0;			/* success */
+    return 0;			/* success */
 }
 
 void
-do_queued_ioctl (void)
+do_queued_ioctl(void)
 {
-  if (iq.queued)
-    {
-      iq.queued = 0;
-      do_ioctl (iq.fd, iq.req, iq.param3);
+    if (iq.queued) {
+	iq.queued = 0;
+	do_ioctl(iq.fd, iq.req, iq.param3);
     }
 }
 
 void
-activate (int con_num)
+activate(int con_num)
 {
-  if (in_ioctl)
-    {
-      k_printf ("KBD: can't ioctl for activate, in a signal handler\n");
-      do_ioctl (kbd_fd, VT_ACTIVATE, con_num);
-    }
-  else
-    do_ioctl (kbd_fd, VT_ACTIVATE, con_num);
+    if (in_ioctl) {
+	k_printf("KBD: can't ioctl for activate, in a signal handler\n");
+	do_ioctl(kbd_fd, VT_ACTIVATE, con_num);
+    } else
+	do_ioctl(kbd_fd, VT_ACTIVATE, con_num);
 }
 
 #endif
 
 void
-keyboard_close (void)
+keyboard_close(void)
 {
-  if (kbd_fd != -1)
-    {
+    if (kbd_fd != -1) {
 
-      if (config.console_keyb)
-	{
-	  k_printf ("KBD: keyboard_close:clear raw keyb\n");
-	  clear_raw_mode ();
+	if (config.console_keyb) {
+	    k_printf("KBD: keyboard_close:clear raw keyb\n");
+	    clear_raw_mode();
 	}
-      if (config.console_video)
-	{
-	  k_printf ("KBD: keyboard_close:clear console video\n");
-	  clear_console_video ();
+	if (config.console_video) {
+	    k_printf("KBD: keyboard_close:clear console video\n");
+	    clear_console_video();
 	}
-      if (config.usesX)
-	{
-	  v_printf ("CloseKeyboard:clear console video\n");
-	  clear_consoleX_video ();
+	if (config.usesX) {
+	    v_printf("CloseKeyboard:clear console video\n");
+	    clear_consoleX_video();
 	}
-
-      if ((config.console_keyb || config.console_video) && !config.usesX)
-	{
-	  k_printf ("KBD: keyboard_close: clear process control\n");
-	  clear_process_control ();
+	if ((config.console_keyb || config.console_video) && !config.usesX) {
+	    k_printf("KBD: keyboard_close: clear process control\n");
+	    clear_process_control();
 	}
+	fcntl(kbd_fd, F_SETFL, old_kbd_flags);
+	tcsetattr(kbd_fd, TCSANOW, &oldtermios);
 
-      fcntl (kbd_fd, F_SETFL, old_kbd_flags);
-      tcsetattr (kbd_fd, TCSANOW, &oldtermios);
-
-      close (kbd_fd);
-      kbd_fd = -1;
+	close(kbd_fd);
+	kbd_fd = -1;
     }
 }
 
@@ -192,30 +177,30 @@
 static struct termios save_termios;
 
 static void
-print_termios (struct termios term)
+print_termios(struct termios term)
 {
-  k_printf ("KBD: TERMIOS Structure:\n");
-  k_printf ("KBD: 	c_iflag=%x\n", term.c_iflag);
-  k_printf ("KBD: 	c_oflag=%x\n", term.c_oflag);
-  k_printf ("KBD: 	c_cflag=%x\n", term.c_cflag);
-  k_printf ("KBD: 	c_lflag=%x\n", term.c_lflag);
-  k_printf ("KBD: 	c_line =%x\n", term.c_line);
+    k_printf("KBD: TERMIOS Structure:\n");
+    k_printf("KBD: 	c_iflag=%x\n", term.c_iflag);
+    k_printf("KBD: 	c_oflag=%x\n", term.c_oflag);
+    k_printf("KBD: 	c_cflag=%x\n", term.c_cflag);
+    k_printf("KBD: 	c_lflag=%x\n", term.c_lflag);
+    k_printf("KBD: 	c_line =%x\n", term.c_line);
 }
 
 #ifdef X_SUPPORT
 void
-keyboard_X_init (void)
+keyboard_X_init(void)
 {
-  scr_state.console_no = 0;
-  config.console_keyb = 0;
-  config.console_video = 0;
-  config.mapped_bios = 0;
-  config.vga = 0;
-  config.graphics = 0;
-  if (config.speaker == SPKR_NATIVE)
-    config.speaker = SPKR_EMULATED;
-  child_kbd_flags = 0;
-  scr_state.current = 1;
+    scr_state.console_no = 0;
+    config.console_keyb = 0;
+    config.console_video = 0;
+    config.mapped_bios = 0;
+    config.vga = 0;
+    config.graphics = 0;
+    if (config.speaker == SPKR_NATIVE)
+	config.speaker = SPKR_EMULATED;
+    child_kbd_flags = 0;
+    scr_state.current = 1;
 
 }
 
@@ -223,183 +208,169 @@
 
 /*
  * DANG_BEGIN_FUNCTION keyboard_init
- *
- * description:
- *  Initialize the keyboard to DOSEMU deafaults plus those requested
- *  in the configs if allowable.
- *
+ * 
+ * description: Initialize the keyboard to DOSEMU deafaults plus those
+ * requested in the configs if allowable.
+ * 
  * DANG_END_FUNCTION
  */
 int
-keyboard_init (void)
+keyboard_init(void)
 {
-  struct termios newtermio;	/* new terminal modes */
-  struct stat chkbuf;
-  int major, minor;
+    struct termios  newtermio;	/* new terminal modes */
+    struct stat     chkbuf;
+    int             major,
+                    minor;
 
 #ifdef X_SUPPORT
-  if (config.X)
-    {
-      keyboard_X_init ();
-      return 0;
+    if (config.X) {
+	keyboard_X_init();
+	return 0;
     }
 #endif
 
-  if (config.usesX)
-    {
-      kbd_fd = dup (keypipe);
-      if (kbd_fd < 0)
-	{
-	  error ("ERROR: Couldn't duplicate STDIN !\n");
-	  leavedos (66);
+    if (config.usesX) {
+	kbd_fd = dup(keypipe);
+	if (kbd_fd < 0) {
+	    error("ERROR: Couldn't duplicate STDIN !\n");
+	    leavedos(66);
 	}
-    }
-  else
-    {
-      kbd_fd = STDIN_FILENO;
-    }
-
-  old_kbd_flags = fcntl (kbd_fd, F_GETFL);
-  fcntl (kbd_fd, F_SETFL, O_RDONLY | O_NONBLOCK);
-
-  if (use_sigio && !config.kbd_tty)
-    {
-      k_printf ("KBD: Using SIGIO\n");
-      add_to_io_select (kbd_fd, 1);
-    }
-  else
-    {
-      k_printf ("KBD: Not using SIGIO\n");
-      add_to_io_select (kbd_fd, 0);
-    }
-
-  fstat (kbd_fd, &chkbuf);
-  major = chkbuf.st_rdev >> 8;
-  minor = chkbuf.st_rdev & 0xff;
-
-  /* console major num is 4, minor 64 is the first serial line */
-  if ((major == 4) && (minor < 64))
-    scr_state.console_no = minor;	/* get minor number */
-  else
-    {
-      if (config.console_keyb || config.console_video)
-	error ("ERROR: STDIN not a console-can't do console modes!\n");
-      scr_state.console_no = 0;
-      config.console_keyb = 0;
-      config.console_video = 0;
-      config.mapped_bios = 0;
-      config.vga = 0;
-      config.graphics = 0;
-      if (config.speaker == SPKR_NATIVE)
-	config.speaker = SPKR_EMULATED;
+    } else {
+	kbd_fd = STDIN_FILENO;
     }
 
-  if (tcgetattr (kbd_fd, &oldtermios) < 0)
-    {
-      error ("ERROR: Couldn't tcgetattr(STDIN,...) !\n");
-      leavedos (66);
+    fstat(kbd_fd, &chkbuf);
+    major = chkbuf.st_rdev >> 8;
+    minor = chkbuf.st_rdev & 0xff;
+
+    /* console major num is 4, minor 64 is the first serial line */
+    if ((major == 4) && (minor < 64)) {
+	scr_state.console_no = minor;	/* get minor number */
+	config.console = 1;
+    } else {
+	if (config.console_keyb || config.console_video)
+	    error("ERROR: STDIN not a console-can't do console modes!\n");
+	scr_state.console_no = 0;
+	config.console_keyb = 0;
+	config.console_video = 0;
+	config.mapped_bios = 0;
+	config.vga = 0;
+	config.graphics = 0;
+	config.console = 0;
+	if (config.speaker == SPKR_NATIVE)
+	    config.speaker = SPKR_EMULATED;
+    }
+
+    old_kbd_flags = fcntl(kbd_fd, F_GETFL);
+    fcntl(kbd_fd, F_SETFL, O_RDONLY | O_NONBLOCK);
+
+    if (use_sigio && !config.kbd_tty) {
+	k_printf("KBD: Using SIGIO\n");
+	add_to_io_select(kbd_fd, 1);
+    } else {
+	k_printf("KBD: Not using SIGIO\n");
+	add_to_io_select(kbd_fd, 0);
+    }
+
+    if (tcgetattr(kbd_fd, &oldtermios) < 0) {
+	error("ERROR: Couldn't tcgetattr(STDIN,...) !\n");
+	leavedos(66);
+    }
+    /*
+     * DANG_BEGIN_REMARK
+     * 
+     * Code is called at start up to set up the terminal line for non-raw
+     * mode.
+     * 
+     * DANG_END_REMARK
+     */
+    newtermio = oldtermios;
+    newtermio.c_iflag &= (ISTRIP | IGNBRK | IXON | IXOFF);	/* (IXON|IXOFF|IXANY|ISTR
+								 * IP|IGNBRK); */
+    /*
+     * newtermio.c_oflag &= ~OPOST; newtermio.c_cflag &= ~(HUPCL);
+     */
+    newtermio.c_cflag &= ~(CLOCAL | CSIZE | PARENB);
+    newtermio.c_cflag |= CS8;
+    newtermio.c_lflag &= 0;	/* ISIG */
+    newtermio.c_cc[VMIN] = 1;
+    newtermio.c_cc[VTIME] = 0;
+    erasekey = newtermio.c_cc[VERASE];
+    cfgetispeed(&newtermio);
+    cfgetospeed(&newtermio);
+    if (tcsetattr(kbd_fd, TCSANOW, &newtermio) < 0) {
+	error("ERROR: Couldn't tcsetattr(STDIN,TCSANOW,...) !\n");
+    }
+    child_kbd_flags = 0;
+    scr_state.current = 1;
+    if (config.console_keyb) {
+	set_raw_mode();
+    }
+    if (-1 == init_slang_keymaps()) {
+	error("ERROR: Unable to initialize S-Lang keymaps.\n");
+	leavedos(31);
     }
-
-  /*
- * DANG_BEGIN_REMARK
- *
- *  Code is called at start up to set up the terminal line for non-raw
- *  mode.
- *
- * DANG_END_REMARK
- */
-  newtermio = oldtermios;
-  newtermio.c_iflag &= (ISTRIP | IGNBRK | IXON | IXOFF);	/* (IXON|IXOFF|IXANY|ISTRIP|IGNBRK);*/
-  /* newtermio.c_oflag &= ~OPOST;
-     newtermio.c_cflag &= ~(HUPCL); */
-  newtermio.c_cflag &= ~(CLOCAL | CSIZE | PARENB);
-  newtermio.c_cflag |= CS8;
-  newtermio.c_lflag &= 0;	/* ISIG */
-  newtermio.c_cc[VMIN] = 1;
-  newtermio.c_cc[VTIME] = 0;
-  erasekey = newtermio.c_cc[VERASE];
-  cfgetispeed (&newtermio);
-  cfgetospeed (&newtermio);
-  if (tcsetattr (kbd_fd, TCSANOW, &newtermio) < 0)
-    {
-      error ("ERROR: Couldn't tcsetattr(STDIN,TCSANOW,...) !\n");
-    }
-  child_kbd_flags = 0;
-  scr_state.current = 1;
-  if (config.console_keyb)
-    {
-      set_raw_mode ();
-    }
-  if (-1 == init_slang_keymaps ())
-    {
-      error ("ERROR: Unable to initialize S-Lang keymaps.\n");
-      leavedos (31);
-    }
-  dbug_printf ("TERMIO: $Header: /home/src/dosemu0.60/keyboard/RCS/keyboard.c,v 1.3 1995/02/25 22:38:32 root Exp root $\n");
-  return 0;
+    dbug_printf("TERMIO: $Header: /home/src/dosemu0.60/keyboard/RCS/keyboard.c,v 1.3 1995/02/25 22:38:32 root Exp root $\n");
+    return 0;
 }
 
 static void
-clear_raw_mode (void)
+clear_raw_mode(void)
 {
-  do_ioctl (kbd_fd, KDSKBMODE, K_XLATE);
-  if (tcsetattr (kbd_fd, TCSAFLUSH, &save_termios) < 0)
-    {
-      k_printf ("KBD: Resetting Keyboard to K_XLATE mode failed.\n");
-      return;
+    do_ioctl(kbd_fd, KDSKBMODE, K_XLATE);
+    if (tcsetattr(kbd_fd, TCSAFLUSH, &save_termios) < 0) {
+	k_printf("KBD: Resetting Keyboard to K_XLATE mode failed.\n");
+	return;
     }
 }
 
 static void
-set_raw_mode (void)
+set_raw_mode(void)
 {
-  k_printf ("KBD: Setting keyboard to RAW mode\n");
-  if (!config.console_video)
-    fprintf (stderr, "\nKBD: Entering RAW mode for DOS!\n");
-  do_ioctl (kbd_fd, KDSKBMODE, K_RAW);
-  tty_raw (kbd_fd);
+    k_printf("KBD: Setting keyboard to RAW mode\n");
+    if (!config.console_video)
+	fprintf(stderr, "\nKBD: Entering RAW mode for DOS!\n");
+    do_ioctl(kbd_fd, KDSKBMODE, K_RAW);
+    tty_raw(kbd_fd);
 }
 
 static int
-tty_raw (int fd)
+tty_raw(int fd)
 {
-  struct termios buf;
+    struct termios  buf;
 
-  if (tcgetattr (fd, &save_termios) < 0)
-    return (-1);
+    if (tcgetattr(fd, &save_termios) < 0)
+	return (-1);
 
-  buf = save_termios;
+    buf = save_termios;
 
-  buf.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG);
-  buf.c_iflag &= ~(IMAXBEL | IGNBRK | IGNCR | IGNPAR | BRKINT | INLCR | ICRNL | INPCK | ISTRIP | IXON | IUCLC | IXANY | IXOFF | IXON);
-  buf.c_cflag &= ~(CSIZE | PARENB);
-  buf.c_oflag &= ~(OCRNL | OLCUC | ONLCR | OPOST);
-  buf.c_cflag |= CS8;
-  buf.c_cc[VMIN] = 1;
-  buf.c_cc[VTIME] = 0;
+    buf.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG);
+    buf.c_iflag &= ~(IMAXBEL | IGNBRK | IGNCR | IGNPAR | BRKINT | INLCR | ICRNL | INPCK | ISTRIP | IXON | IUCLC | IXANY | IXOFF | IXON);
+    buf.c_cflag &= ~(CSIZE | PARENB);
+    buf.c_oflag &= ~(OCRNL | OLCUC | ONLCR | OPOST);
+    buf.c_cflag |= CS8;
+    buf.c_cc[VMIN] = 1;
+    buf.c_cc[VTIME] = 0;
 
-  if (tcsetattr (STDIN_FILENO, TCSAFLUSH, &buf) < 0)
-    {
-      k_printf ("KBD: Setting to RAW mode failed.\n");
-      return (-1);
+    if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &buf) < 0) {
+	k_printf("KBD: Setting to RAW mode failed.\n");
+	return (-1);
     }
-  if (tcgetattr (fd, &buf) < 0)
-    {
-      k_printf ("Termios ERROR\n");
+    if (tcgetattr(fd, &buf) < 0) {
+	k_printf("Termios ERROR\n");
     }
-  k_printf ("KBD: Setting TERMIOS Structure.\n");
-  print_termios (buf);
+    k_printf("KBD: Setting TERMIOS Structure.\n");
+    print_termios(buf);
 
-  return (0);
+    return (0);
 }
 
 void
-add_key_depress (u_short scan)
+add_key_depress(u_short scan)
 {
-  if (scan < 0x80 && scan > 0)
-    {
-      k_printf ("Adding Key-Release\n");
-      add_scancode_to_queue (scan | 0x80);
+    if (scan < 0x80 && scan > 0) {
+	k_printf("Adding Key-Release\n");
+	add_scancode_to_queue(scan | 0x80);
     }
 }
 
@@ -406,90 +377,84 @@
 #include "slang-keyboard.c"
 
 void
-getKeys (void)
+getKeys(void)
 {
-  int cc;
+    int             cc;
 
-  if (config.console_keyb)
-    {				/* Keyboard at the console */
-      if (scr_state.current != 1)
-	{
-	  k_printf ("KBD: Not current screen!\n");
-	  return;
+    if (config.console_keyb) {	/* Keyboard at the console */
+	if (scr_state.current != 1) {
+	    k_printf("KBD: Not current screen!\n");
+	    return;
 	}
-      kbcount = 0;
-      kbp = kbbuf;
+	kbcount = 0;
+	kbp = kbbuf;
 
-      cc = RPT_SYSCALL (read (kbd_fd, &kbp[kbcount], KBBUF_SIZE - 1));
-      k_printf ("KBD: cc found %d characters (Raw)\n", cc);
-      if (cc == -1)
-	return;
-
-      if (cc > 0)
-	{
-	  int i;
-
-	  for (i = 0; i < cc; i++)
-	    {
-	      k_printf ("KEY: readcode: %d \n", kbp[kbcount + i]);
-	      child_set_flags (kbp[kbcount + i]);
-	      add_scancode_to_queue (kbp[kbcount + i]);
-	      k_printf ("KBD: cc pushing %d'th character\n", i);
+	cc = RPT_SYSCALL(read(kbd_fd, &kbp[kbcount], KBBUF_SIZE - 1));
+	k_printf("KBD: cc found %d characters (Raw)\n", cc);
+	if (cc == -1)
+	    return;
+
+	if (cc > 0) {
+	    int             i;
+
+	    for (i = 0; i < cc; i++) {
+		k_printf("KEY: readcode: %d \n", kbp[kbcount + i]);
+		child_set_flags(kbp[kbcount + i]);
+		add_scancode_to_queue(kbp[kbcount + i]);
+		k_printf("KBD: cc pushing %d'th character\n", i);
 	    }
 	}
+    } else {			/* Not keyboard at the console (not
+				 * config.console_keyb) */
+	do_slang_getkeys();
     }
-  else
-    {				/* Not keyboard at the console (not config.console_keyb) */
-      do_slang_getkeys ();
-    }
 }
 
 void
-child_set_flags (int sc)
+child_set_flags(int sc)
 {
-  switch (sc)
-    {
+    switch (sc) {
     case 0xe0:
     case 0xe1:
-      child_set_kbd_flag (4);
-      return;
+	child_set_kbd_flag(4);
+	return;
     case 0x2a:
-      if (!child_kbd_flag (4))
-	child_set_kbd_flag (1);
-      child_clr_kbd_flag (4);
-      return;
+	if (!child_kbd_flag(4))
+	    child_set_kbd_flag(1);
+	child_clr_kbd_flag(4);
+	return;
     case 0x36:
-      child_set_kbd_flag (1);
-      child_clr_kbd_flag (4);
-      return;
+	child_set_kbd_flag(1);
+	child_clr_kbd_flag(4);
+	return;
     case 0x1d:
     case 0x10:
-      child_set_kbd_flag (2);
-      child_clr_kbd_flag (4);
-      return;
+	child_set_kbd_flag(2);
+	child_clr_kbd_flag(4);
+	return;
     case 0x38:
-      if (!child_kbd_flag (4))
-	child_set_kbd_flag (3);
-      child_clr_kbd_flag (4);
-      return;
+	if (!child_kbd_flag(4))
+	    child_set_kbd_flag(3);
+	child_clr_kbd_flag(4);
+	return;
     case 0xaa:
-      if (!child_kbd_flag (4))
-	child_clr_kbd_flag (1);
-      child_clr_kbd_flag (4);
-      return;
+	if (!child_kbd_flag(4))
+	    child_clr_kbd_flag(1);
+	child_clr_kbd_flag(4);
+	return;
     case 0xb6:
-      child_clr_kbd_flag (4);
-      child_clr_kbd_flag (1);
-      return;
+	child_clr_kbd_flag(4);
+	child_clr_kbd_flag(1);
+	return;
     case 0x9d:
     case 0x90:
-      child_clr_kbd_flag (4);
-      child_clr_kbd_flag (2);
-      return;
+	child_clr_kbd_flag(4);
+	child_clr_kbd_flag(2);
+	return;
     case 0xb8:
-      child_clr_kbd_flag (3);
-      child_clr_kbd_flag (4);
-      return;
+	child_clr_kbd_flag(3);
+	child_clr_kbd_flag(4);
+	return;
     case 0x3b:
     case 0x3c:
     case 0x3d:
@@ -502,86 +467,84 @@
     case 0x44:
     case 0x57:
     case 0x58:
-      child_clr_kbd_flag (4);
-      if (
+	child_clr_kbd_flag(4);
+	if (
 #ifdef X_SUPPORT
-	   !config.X &&
+	       !config.X &&
 #endif
-	   (child_kbd_flag (3) && child_kbd_flag (2) && !child_kbd_flag (1)))
-	{
-	  int fnum = sc - 0x3a;
-
-	  k_printf ("KDB: Doing VC switch\n");
-	  if (fnum > 10)
-	    fnum -= 0x12;	/* adjust if f11 or f12 */
-
-	  /* can't just do the ioctl() here, as ReadKeyboard will probably have
- * been called from a signal handler, and ioctl() is not reentrant.
- * hence the delay until out of the signal handler...
- */
-	  child_clr_kbd_flag (3);
-	  child_clr_kbd_flag (2);
-	  activate (fnum);
-	  return;
+	(child_kbd_flag(3) && child_kbd_flag(2) && !child_kbd_flag(1))) {
+	    int             fnum = sc - 0x3a;
+
+	    k_printf("KDB: Doing VC switch\n");
+	    if (fnum > 10)
+		fnum -= 0x12;	/* adjust if f11 or f12 */
+
+	    /*
+	     * can't just do the ioctl() here, as ReadKeyboard will
+	     * probably have been called from a signal handler, and
+	     * ioctl() is not reentrant. hence the delay until out of the
+	     * signal handler...
+	     */
+	    child_clr_kbd_flag(3);
+	    child_clr_kbd_flag(2);
+	    activate(fnum);
+	    return;
 	}
-      return;
+	return;
     case 0x51:
-      if (
+	if (
 #ifdef X_SUPPORT
-	   !config.X &&
+	       !config.X &&
 #endif
-	   (child_kbd_flag (2) && child_kbd_flag (3) && !child_kbd_flag (1)))
-	{
-	  dbug_printf ("ctrl-alt-pgdn\n");
-	  leavedos (42);
+	(child_kbd_flag(2) && child_kbd_flag(3) && !child_kbd_flag(1))) {
+	    dbug_printf("ctrl-alt-pgdn\n");
+	    leavedos(42);
 	}
-      child_clr_kbd_flag (4);
-      return;
+	child_clr_kbd_flag(4);
+	return;
     default:
-      child_clr_kbd_flag (4);
-      return;
+	child_clr_kbd_flag(4);
+	return;
     }
 }
 
 void
-set_leds ()
+set_leds()
 {
-  unsigned int led_state = 0;
+    unsigned int    led_state = 0;
 
-  if (kbd_flag (KF_SCRLOCK))
-    {
-      led_state |= (1 << LED_SCRLOCK);
+    if (kbd_flag(KF_SCRLOCK)) {
+	led_state |= (1 << LED_SCRLOCK);
     }
-  if (kbd_flag (KF_NUMLOCK))
-    {
-      led_state |= (1 << LED_NUMLOCK);
+    if (kbd_flag(KF_NUMLOCK)) {
+	led_state |= (1 << LED_NUMLOCK);
     }
-  if (kbd_flag (KF_CAPSLOCK))
-    {
-      led_state |= (1 << LED_CAPSLOCK);
+    if (kbd_flag(KF_CAPSLOCK)) {
+	led_state |= (1 << LED_CAPSLOCK);
     }
-
-  k_printf ("KBD: SET_LEDS() called\n");
-  do_ioctl (kbd_fd, KDSETLED, led_state);
+    k_printf("KBD: SET_LEDS() called\n");
+    do_ioctl(kbd_fd, KDSETLED, led_state);
 }
 
-/* These are added to allow the CHILD process to keep its own flags on keyboard
-   status */
+/*
+ * These are added to allow the CHILD process to keep its own flags on
+ * keyboard status
+ */
 
 void
-child_set_kbd_flag (int flag)
+child_set_kbd_flag(int flag)
 {
-  child_kbd_flags |= (1 << flag);
+    child_kbd_flags |= (1 << flag);
 }
 
 void
-child_clr_kbd_flag (int flag)
+child_clr_kbd_flag(int flag)
 {
-  child_kbd_flags &= ~(1 << flag);
+    child_kbd_flags &= ~(1 << flag);
 }
 
 int
-child_kbd_flag (int flag)
+child_kbd_flag(int flag)
 {
-  return ((child_kbd_flags >> flag) & 1);
+    return ((child_kbd_flags >> flag) & 1);
 }
diff -u --recursive --new-file dosemu0.53.52/mouse/mouse.c dosemu0.53.53/mouse/mouse.c
--- dosemu0.53.52/mouse/mouse.c	Sat Feb 25 17:54:24 1995
+++ dosemu0.53.53/mouse/mouse.c	Sat Mar 18 10:05:03 1995
@@ -1491,10 +1491,11 @@
       if (mice->fd == -1) {
  	mice->intdrv = FALSE;
  	mice->type = MOUSE_NONE;
+ 	mice->add_to_io_select = 0;
  	return;
       }
       /* want_sigio causes problems with internal mouse driver */
-      add_to_io_select(mice->fd, 0);
+      add_to_io_select(mice->fd, mice->add_to_io_select);
       DOSEMUSetupMouse();
       memcpy(p,mouse_ver,sizeof(mouse_ver));
       return;
@@ -1502,7 +1503,8 @@
 
     if ((mice->type == MOUSE_PS2) || (mice->type == MOUSE_BUSMOUSE)) {
       mice->fd = DOS_SYSCALL(open(mice->dev, O_RDWR | O_NONBLOCK));
-      add_to_io_select(mice->fd, 0); 
+      mice->add_to_io_select = 0;
+      add_to_io_select(mice->fd, mice->add_to_io_select); 
       memcpy(p,mouse_ver,sizeof(mouse_ver));
     }
     else {
@@ -1522,9 +1524,10 @@
     if (mice->fd == -1) {
       mice->intdrv = FALSE;
       mice->type = MOUSE_NONE;
+      mice->add_to_io_select = 1;
       return;
     }
-    add_to_io_select(mice->fd, 1);
+    add_to_io_select(mice->fd, mice->add_to_io_select);
     DOSEMUSetupMouse();
     memcpy(p,mouse_ver,sizeof(mouse_ver));
     return;
diff -u --recursive --new-file dosemu0.53.52/net/pktnew.c dosemu0.53.53/net/pktnew.c
--- dosemu0.53.52/net/pktnew.c	Sat Feb 25 17:53:26 1995
+++ dosemu0.53.53/net/pktnew.c	Sat Mar 18 00:04:28 1995
@@ -480,6 +480,11 @@
     return 1;
 }
 
+void
+pkt_check_receive_quick(void) {
+  pkt_check_receive(0);
+}
+
 int
 pkt_check_receive(timeout)
 int timeout;
diff -u --recursive --new-file dosemu0.53.52/net/pktnew.c.multi dosemu0.53.53/net/pktnew.c.multi
--- dosemu0.53.52/net/pktnew.c.multi	Mon Feb 13 19:34:47 1995
+++ dosemu0.53.53/net/pktnew.c.multi	Fri Mar 17 23:10:42 1995
@@ -558,6 +558,10 @@
   }
 }
 
+void
+pkt_check_receive_quick(void){
+  pkt_check_receive(0);
+}
 
 int
 pkt_check_receive(timeout)
diff -u --recursive --new-file dosemu0.53.52/net/pktnew.c.single dosemu0.53.53/net/pktnew.c.single
--- dosemu0.53.52/net/pktnew.c.single	Mon Feb 13 19:31:53 1995
+++ dosemu0.53.53/net/pktnew.c.single	Fri Mar 17 23:10:03 1995
@@ -480,6 +480,11 @@
     return 1;
 }
 
+void
+pkt_check_receive_quick(void) {
+  pkt_check_receive(0);
+}
+
 int
 pkt_check_receive(timeout)
 int timeout;
Binary files dosemu0.53.52/periph/hdinfo and dosemu0.53.53/periph/hdinfo differ
Binary files dosemu0.53.52/periph/mkhdimage and dosemu0.53.53/periph/mkhdimage differ
Binary files dosemu0.53.52/periph/putrom and dosemu0.53.53/periph/putrom differ
diff -u --recursive --new-file dosemu0.53.52/video/console.c dosemu0.53.53/video/console.c
--- dosemu0.53.52/video/console.c	Fri Oct 14 15:02:03 1994
+++ dosemu0.53.53/video/console.c	Sat Mar 18 20:43:49 1995
@@ -64,7 +64,7 @@
 
 void set_console_video(void)
 {
-  if (config.vga) {
+  if (config.console_video) {
     k_printf("KBD: Taking mouse control\n");
     ioctl(kbd_fd, KDSETMODE, KD_GRAPHICS);
   }
diff -u --recursive --new-file dosemu0.53.52/video/vc.c dosemu0.53.53/video/vc.c
--- dosemu0.53.52/video/vc.c	Thu Mar 16 21:02:25 1995
+++ dosemu0.53.53/video/vc.c	Sat Mar 18 10:09:09 1995
@@ -192,13 +192,7 @@
 {
   if (mice->intdrv)
     {
-      DOS_SYSCALL (close (mice->fd));
-      if (use_sigio)
-	{
-	  FD_CLR (mice->fd, &fds_sigio);
-	}
-      else
-	FD_CLR (mice->fd, &fds_no_sigio);
+	remove_from_io_select(mice->fd, mice->add_to_io_select);
     }
   else
     child_close_mouse ();
@@ -211,15 +205,7 @@
     {
       static int old_mice_flags;
       mice->fd = DOS_SYSCALL (open (mice->dev, O_RDWR | O_NONBLOCK));
-      if (use_sigio)
-	{
-	  old_mice_flags = fcntl (mice->fd, F_GETFL);
-	  fcntl (mice->fd, F_SETOWN, getpid ());
-	  fcntl (mice->fd, F_SETFL, old_mice_flags | use_sigio);
-	  FD_SET (mice->fd, &fds_sigio);
-	}
-      else
-	FD_SET (mice->fd, &fds_no_sigio);
+	add_to_io_select(mice->fd, mice->add_to_io_select);
     }
   else
     child_open_mouse ();
diff -u --recursive --new-file dosemu0.53.52/video/video.c dosemu0.53.53/video/video.c
--- dosemu0.53.52/video/video.c	Tue Mar  7 21:20:11 1995
+++ dosemu0.53.53/video/video.c	Sat Mar 18 20:43:11 1995
@@ -368,8 +368,10 @@
   if ((config.console_keyb || config.console_video) && !config.usesX)
     set_process_control();
 
-  if (config.console_video)
+  if (config.console_video) {
     set_console_video();
+  }
+
   if (config.usesX)
     set_consoleX_video();
 
