diff -u --recursive --new-file dosemu0.53old//.depend dosemu0.53//.depend
--- dosemu0.53old//.depend	Wed Aug 17 22:58:23 1994
+++ dosemu0.53//.depend	Wed Aug 24 22:14:24 1994
@@ -1,31 +1,29 @@
-Xkeyb.o : Xkeyb.c emu.h machcompat.h cpu.h 
-bios_emm.o : bios_emm.c emu.h machcompat.h cpu.h 
 cmos.o : cmos.c emu.h machcompat.h cpu.h cmos.h disks.h 
-cpu.o : cpu.c config.h memory.h cpu.h termio.h emu.h machcompat.h /home/src/dosemu0.60/include/port.h \
-  dpmi/dpmi.h 
-detach.o : detach.c 
-disks.o : disks.c emu.h machcompat.h cpu.h disks.h 
 dos.o : dos.c config.h 
-dosconfig.o : dosconfig.c 
-dosio.o : dosio.c memory.h emu.h machcompat.h cpu.h termio.h dosio.h /home/src/dosemu0.60/include/mouse.h 
-dyndeb.o : dyndeb.c emu.h machcompat.h cpu.h 
 emu.o : emu.c config.h memory.h emu.h machcompat.h cpu.h /home/src/dosemu0.60/include/bios.h \
   termio.h /home/src/dosemu0.60/include/video.h timers.h cmos.h /home/src/dosemu0.60/include/mouse.h \
   dosio.h disks.h xms.h dpmi/dpmi.h /home/src/dosemu0.60/include/ipx.h /home/src/dosemu0.60/include/../cpu.h \
   serial.h /home/src/dosemu0.60/include/keymaps.h int.h 
+termio.o : termio.c config.h memory.h emu.h machcompat.h cpu.h termio.h /home/src/dosemu0.60/include/video.h \
+  /home/src/dosemu0.60/include/mouse.h dosio.h /home/src/dosemu0.60/include/keymaps.h 
+xms.o : xms.c emu.h machcompat.h cpu.h config.h memory.h xms.h dosio.h 
+disks.o : disks.c emu.h machcompat.h cpu.h disks.h 
 keymaps.o : keymaps.c config.h 
-lpt.o : lpt.c emu.h machcompat.h cpu.h dosio.h lpt.h 
-mfs.o : mfs.c mfs.h emu.h machcompat.h cpu.h config.h memory.h 
 mutex.o : mutex.c config.h emu.h machcompat.h cpu.h mutex.h 
-prnt.o : prnt.c 
+timers.o : timers.c emu.h machcompat.h cpu.h timers.h 
+dosio.o : dosio.c memory.h emu.h machcompat.h cpu.h termio.h dosio.h /home/src/dosemu0.60/include/mouse.h 
+cpu.o : cpu.c config.h memory.h cpu.h termio.h emu.h machcompat.h /home/src/dosemu0.60/include/port.h \
+  dpmi/dpmi.h 
+mfs.o : mfs.c mfs.h emu.h machcompat.h cpu.h config.h memory.h 
+bios_emm.o : bios_emm.c emu.h machcompat.h cpu.h 
+lpt.o : lpt.c emu.h machcompat.h cpu.h dosio.h lpt.h 
 serial.o : serial.c config.h cpu.h emu.h machcompat.h dosio.h serial.h /home/src/dosemu0.60/include/mouse.h 
+dyndeb.o : dyndeb.c emu.h machcompat.h cpu.h 
 sigsegv.o : sigsegv.c emu.h machcompat.h cpu.h /home/src/dosemu0.60/include/bios.h \
   /home/src/dosemu0.60/include/mouse.h serial.h xms.h timers.h cmos.h memory.h \
   termio.h config.h /home/src/dosemu0.60/include/port.h /home/src/dosemu0.60/include/ipx.h \
   /home/src/dosemu0.60/include/../cpu.h video/vc.h /home/src/dosemu0.60/emu.h \
   dpmi/dpmi.h ports.h 
-termio.o : termio.c config.h memory.h emu.h machcompat.h cpu.h termio.h /home/src/dosemu0.60/include/video.h \
-  /home/src/dosemu0.60/include/mouse.h dosio.h /home/src/dosemu0.60/include/keymaps.h 
-timers.o : timers.c emu.h machcompat.h cpu.h timers.h 
-xms.o : xms.c emu.h machcompat.h cpu.h config.h memory.h xms.h dosio.h 
+detach.o : detach.c 
+Xkeyb.o : Xkeyb.c emu.h machcompat.h cpu.h 
 bios.o : bios.S
diff -u --recursive --new-file dosemu0.53old//ChangeLog dosemu0.53//ChangeLog
--- dosemu0.53old//ChangeLog	Wed Aug 17 22:58:22 1994
+++ dosemu0.53//ChangeLog	Wed Aug 24 22:14:24 1994
@@ -1,3 +1,17 @@
+Wed Aug 24 1994 Jmaclean
+
+-	Added Enhancements to CDROM driver by Karsten Rucker.
+-	Added Lutz's STI patches and kernel patch sti.pat in .kernel
+
+Fri Aug 19 1994 Jmaclean
+
+-	Changed OpenKeyboard to keyboard_init and closeKeyboard
+	to keyboard_close. Moved these out of video init procs and
+	into there own separate calls. This was causing problems
+	in video_config_init() as it would map in video bios
+	illegally :-(.
+-	Added Conditional for SIG in sigalrm to help io_select()
+
 Wed Aug 17 1994 Jmaclean
 
 -	Added scan to charcode returned in Xkeyb.c by put_key()
diff -u --recursive --new-file dosemu0.53old//Makefile dosemu0.53//Makefile
--- dosemu0.53old//Makefile	Wed Aug 17 22:58:22 1994
+++ dosemu0.53//Makefile	Wed Aug 24 22:14:24 1994
@@ -1,8 +1,8 @@
 # Makefile for Linux DOSEMU
 #
-# $Date: 1994/08/17 02:08:22 $
+# $Date: 1994/08/25 00:49:34 $
 # $Source: /home/src/dosemu0.60/RCS/Makefile,v $
-# $Revision: 2.25 $
+# $Revision: 2.26 $
 # $State: Exp $
 #
 # You should do a "make doeverything" or a "make most" (excludes TeX)
@@ -33,6 +33,7 @@
 XLIBS   = -lX11 -u _XOpenDisplay
 XDEFS   = -DX_SUPPORT
 endif
+
 export X_SUPPORT
 export XDEFS
 
@@ -49,6 +50,7 @@
 SHLIBOBJS=$(OBJS)
 DOSLNK=
 #LNKOPTS=-s
+# LNKOPTS=-Ttext
 #MAGIC=-zmagic
 #endif
 
@@ -55,7 +57,7 @@
 # dosemu version
 EMUVER  =   0.53
 VERNUM  =   0x53
-PATCHL  =   15
+PATCHL  =   16
 
 # DON'T CHANGE THIS: this makes libdosemu start high enough to be safe. 
 # should be okay at...0x20000000 for .5 GB mark.
@@ -253,7 +255,7 @@
 		install -m 0700 /usr/bin/xdosemu /tmp; \
 		rm -f /usr/bin/xdosemu; \
 	fi
-	ifdef X_SUPPORT
+ifdef X_SUPPORT
 	@ln -sf dos xdos
 	@install -m 0755 xtermdos /usr/bin
 	@if [ ! -e /usr/bin/xdos ]; then ln -s dos /usr/bin/xdos; fi
@@ -266,7 +268,7 @@
 			mkfontdir; \
 		fi \
 	fi
-	endif
+endif
 	@echo ""
 	@echo "---------------------------------DONE compiling-------------------------------"
 	@echo ""
@@ -274,10 +276,10 @@
 	@echo "  - Update your /etc/dosemu.conf by editing a copy of './examples/config.dist'"
 	@echo "  - Using your old DOSEMU 0.52 configuration file might not work."
 	@echo "  - After configuring DOSEMU, you can type 'dos' to run DOSEMU."
-	ifdef X_SUPPORT
+ifdef X_SUPPORT
 	@echo "  - Use 'xdos' instead of 'dos' to cause DOSEMU to open its own Xwindow."
 	@echo "  - If Xwindows is running now, restart it before 'xdos' for the first time."
-	endif
+endif
 	@echo ""
 
 converthd: hdimage
@@ -320,7 +322,7 @@
         done
 
 depend dep: 
-	$(CPP) -MM $(CFLAGS) *.c > .depend ;echo "bios.o : bios.S" >>.depend
+	$(CPP) -MM $(CFLAGS) $(CFILES) > .depend ;echo "bios.o : bios.S" >>.depend
 	cd clients;$(CPP) -MM -I../ -I../include $(CFLAGS) *.c > .depend
 	cd video; make depend
 	cd mouse; make depend
diff -u --recursive --new-file dosemu0.53old//README.CDROM dosemu0.53//README.CDROM
--- dosemu0.53old//README.CDROM	Wed Aug 17 22:58:23 1994
+++ dosemu0.53//README.CDROM	Wed Aug 24 22:14:24 1994
@@ -11,6 +11,8 @@
    lucas arts adventures are so sloooow in dosemu?)
 - acdc (a shareware audio player)
 Please send any suggestions&bug reports to rucker@astro.uni-bonn.de.
+- make sure that you have a link /dev/cdrom to
+  the device file of your drive
 
 To use it:
 - load cdrom.sys within your config.sys file
@@ -17,10 +19,9 @@
 - start microsoft cdrom extension as follows:
     mscdex /d:mscd0001 /l:driveletter
 
-Restrictions:
-The driver does not support the eject function. This means, the
-exchange of cd's while dosemu is running is curently (i'm working on 
-this) not supported. With most drives this is even physically impossible,
-because the cdrom drive is locked after /dev/sr0 has been opened.
+To change the cd while dosemu is running, use the dos
+program 'eject.com'. It is not possible to change the
+disk, when the drive has been opened by another process
+(e.g. mounted)!
 
  
diff -u --recursive --new-file dosemu0.53old//README.X dosemu0.53//README.X
--- dosemu0.53old//README.X	Wed Aug 17 22:58:23 1994
+++ dosemu0.53//README.X	Wed Aug 24 22:14:24 1994
@@ -5,10 +5,8 @@
 
 What you should take care of:
 
--- uncomment the "X_SUPPORT = 1" line in the makefile and rebuild
-   dosemu.
-   this affects only emu.c, dyndeb.c and video/terminal.c, so you
-   don't have to recompile all if you just delete the related .o files.
+-- Make sure dosemu has X support compiled in. 
+   (X_SUPPORT = 1 in the Makefile)
 
 -- you need to have the vga font installed. See README.ncurses.
 
@@ -17,33 +15,29 @@
    dosemu will automatically assume -X. 
    There is also a new debug flag 'X' for X-related messages.
 
--- Keyboard input yet runs through the terminal routines, so your
-   input focus must be in the window you started dosemu from, not
-   in the dosemu window! 
-   This of course also means that only the key combinations 
-   supported in terminal mode will work. (this will hopefully 
-   be changed soon.)
+-- Keyboard support in the dosemu window isn't perfect yet. It's somewhat
+   slow, Alt-xx keys don't work, etc...
+   However, input through the terminal window (i.e. the window you started
+   dosemu from) is still supported. If you have problems, better put
+   your focus in there.
+
+-- Keyboard support of course depends on your X keyboard mappings (xmodmap).
+   If certain keys don't work (like Pause, Backspace,...), it *might* be 
+   because you haven't defined them in your xmodmap, or defined to something
+   other than dosemu expects.
 
 -- video modes other than 80x25 color don't work correctly.
 
--- dosemu currently doesn't honor the DISPLAY variable, nor any
-   standard command line options like -geometry etc.
-   DISPLAY is hardcoded to ":0", if you need another setting, you
-   have to change video/X.c.
-
 -- If anything else does not work as expected, don't panic :-)
    Remember the thing is still under construction.
    However, if you think it's a real bug, please tell me.
 
-important changes to previous version (pre53_9):
+important changes to previous version (pre53_13):
 
-- serial mouse ports are now REALLY automatically disabled
-  (removed my silly changes to the config parser)
-- added 'xdos' calling method
-- attempt to implement keyboard
-- implemented mouse support (X part works, but the internal mouse
-  driver is VERY buggy)
-- handle delete window message
+- fixed mouse bug which blanked screen in dosshell
+- latin1 national character support for keyboard (please let 
+  me know if anything is wrong here!)
+- minor keyboard improvements (Backspace, Fn keys)
 
 Rainer Zimmermann
 (zimmerm@mathematik.uni-marburg.de)
@@ -71,6 +65,7 @@
 Handle close ("delete") window event - (copied from xloadimage)
 X keyboard support (use xdos code? pcemu code?)
 Mouse support
+X configuration (display, updatefreq, updatelines,... what else?)
 
 ToDo (in no special order)
 --------------------------
@@ -81,6 +76,5 @@
 int10 video mode switches (resize window)
 Window SizeHints - fixed size or max size?
 fine-tune X_update_screen
-X configuration (display, updatefreq, updatelines,... what else?)
 graphics support?
 create icon :-)
diff -u --recursive --new-file dosemu0.53old//Xkeyb.c dosemu0.53//Xkeyb.c
--- dosemu0.53old//Xkeyb.c	Wed Aug 17 22:58:22 1994
+++ dosemu0.53//Xkeyb.c	Wed Aug 24 22:14:23 1994
@@ -54,6 +54,10 @@
 typedef unsigned short ushort;
 */
 
+#if 1    /* use highscan in termio.c now, which is essentially the same */
+byte highscan[];
+
+#else
 /* ASCII 0x20..0x7E */
 
 static byte ascii_scan[] =
@@ -71,6 +75,22 @@
     0x19, 0x10, 0x13, 0x1f, 0x14, 0x16, 0x2f, 0x11,
     0x2d, 0x15, 0x2c, 0x1a, 0x2b, 0x1b, 0x29
 };
+#endif
+
+static u_char latin1_to_dos[] = {
+    0,    0xad, 0x9b, 0x9c, 0,    0x9d, 0x7c, 0x15,  /* A0-A7 */
+    0x22, 0,    0xa6, 0xae, 0xaa, 0x2d, 0,    0,     /* A8-AF */
+    0xf8, 0xf1, 0xfd, 0xfc, 0x27, 0xe6, 0x14, 0xf9,  /* B0-B7 */
+    0x2c, 0,    0xa7, 0xaf, 0xac, 0xab, 0,    0xa8,  /* B8-BF */
+    0,    0,    0,    0,    0x8e, 0x8f, 0x92, 0x80,  /* C0-C7 */
+    0,    0x90, 0,    0,    0,    0,    0,    0,     /* C8-CF */
+    0,    0xa5, 0,    0,    0,    0,    0x99, 0,     /* D0-D7 */
+    0xed, 0,    0,    0,    0x9a, 0,    0,    0xe1,  /* D8-DF */
+    0x85, 0xa0, 0x83, 0,    0x84, 0x86, 0x91, 0x87,  /* E0-E7 */
+    0x8a, 0x82, 0x88, 0x89, 0x8d, 0xa1, 0x8c, 0x8b,  /* E8-EF */
+    0,    0xa4, 0xa2, 0x95, 0x93, 0,    0x94, 0xf6,  /* F0-F7 */
+    0xed, 0x97, 0xa3, 0x96, 0x81, 0,    0,    0x98   /* F8-FF */
+};
 
 static byte cursor_scan[] = 
 {
@@ -102,7 +122,6 @@
     ushort scan_code;
 } other_scan[] =
 {
-    { XK_BackSpace,     0x0e },
     { XK_Tab,           0x0f },
     { XK_Return,        0x1c },
     { XK_Escape,        0x01 },
@@ -126,12 +145,17 @@
 /* This is a very quick'n dirty put_key...  */
 void put_key(ushort scan, short charcode) {
 #if 0
-   printf("put_key(0x%X,'%c')\n",scan,charcode>=0x20?charcode:'?');
+   printf("put_key(0x%X,'%c'=%d)\n",scan,charcode>=0x20?charcode:'?',charcode);
 #else
-   X_printf("put_key(0x%X,'%c')\n",scan,charcode>=0x20?charcode:'?');
+   X_printf("put_key(0x%X,'%c'=%d)\n",scan,charcode>=0x20?charcode:'?',charcode);
 #endif
+   
    if (charcode!=-1) {
-      if (scan&0x80) DOS_setscan(((scan & 0x7f)<< 8) | charcode);
+#if 0
+     if (scan&0x80) DOS_setscan(((scan & 0x7f)<< 8) | charcode);
+#else
+     if (!(scan&0x80)) DOS_setscan((scan<<8) | charcode);
+#endif
    }
    else {
       if (scan & 0xFF00) DOS_setscan(scan&0xFF00);
@@ -144,15 +168,27 @@
     int i;
 
     /* ascii keys */
-    if (key >= 0x20 && key <= 0x20+sizeof(ascii_scan))
-        return (ascii_scan[key - 0x20]);
+    if (key >= 0x20 && key <= 0x7e) {
+#if 0
+      return (ascii_scan[key - 0x20]);
+#else
+      return highscan[key];
+#endif
+    }
+
+    /* function keys:
+       note that shift-F1..F12 actually give shift-F11..F22, so
+       we have to do a little translation here.
+       It's not perfect for shift-F1,F2...
+    */
+    
+    if (key >= XK_F1 && key <= XK_F22) {
+       if (key >= XK_F13) key-=10;
 
-    /* function keys */
-    if (key >= XK_F1 && key <= XK_F12) {
        if (key > XK_F10)
-          return key-XK_F10+0x57;
+          return key-XK_F10+0x57;     /* F11, F12 */
        else
-          return key-XK_F1+0x3b;
+          return key-XK_F1+0x3b;      /* F1..F10  */
     }
 
     /* cursor keys */
@@ -185,7 +221,7 @@
 {
     ushort scan;
     KeySym key;
-    char chars[MAXCHARS];
+    u_char chars[MAXCHARS];
     int count;
     short ch;
     static XComposeStatus compose_status = {NULL, 0};
@@ -241,10 +277,17 @@
     }
     else if (key == XK_X386_SysReq)
        scan = 0x54;
+    else if (key == XK_BackSpace) {
+       scan = 0x0e;
+       ch = 8;
+    }
     else {
        scan = translate(key);
     }
+
+    /* do latin1 translation */
+    if (ch>=0xa0) ch=latin1_to_dos[ch-0xa0];
     
-    if (scan)
+    if (scan || ch)
        put_key((e->type==KeyPress) ? scan : scan|0x80, ch);
 }
diff -u --recursive --new-file dosemu0.53old//commands/Makefile dosemu0.53//commands/Makefile
--- dosemu0.53old//commands/Makefile	Wed Aug 17 22:58:28 1994
+++ dosemu0.53//commands/Makefile	Wed Aug 24 22:14:28 1994
@@ -1,9 +1,9 @@
 AS86 = as86 -0 -a
 LD86 = ld86 -0
 
-SRC=exitemu.S vgaoff.S vgaon.S lredir.c lredir.readme dumpconf.asm \
+SRC=exitemu.S vgaoff.S vgaon.S eject.S lredir.c lredir.readme dumpconf.asm \
 	bootoff.S booton.S dosdbg.c dosdbg.readme
-COM=exitemu.com vgaoff.com vgaon.com bootoff.com booton.com pdipx.com
+COM=exitemu.com vgaoff.com vgaon.com eject.com bootoff.com booton.com pdipx.com
 EXE=lredir.exe dumpconf.exe dosdbg.exe lancheck.exe
 
 all: $(COM)
@@ -15,16 +15,16 @@
 	rm -f $*.tmp $*.o
 
 checkin:
-	-ci exitemu.S vgaoff.S vgaon.S dumpconf.exe dumpconf.asm \
+	-ci exitemu.S vgaoff.S vgaon.S eject.S dumpconf.exe dumpconf.asm \
 	bootoff.S booton.S Makefile dosdbg.c lredir.c pdipx.com 
 
 checkout:
-	-co -l exitemu.S vgaoff.S vgaon.S dumpconf.exe dumpconf.asm
+	-co -l exitemu.S vgaoff.S vgaon.S eject.S dumpconf.exe dumpconf.asm
 	-co -l bootoff.S booton.S Makefile dosdbg.c lredir.c
 	-co -l pdipx.com
 
 clean:
-	rm -f exitemu.com vgaoff.com vgaon.com booton.com bootoff.com *.o
+	rm -f exitemu.com vgaoff.com vgaon.com eject.com booton.com bootoff.com *.o
 
 dist: $(SRC) $(COM)
 	install -d $(DISTPATH)/commands
diff -u --recursive --new-file dosemu0.53old//commands/eject.S dosemu0.53//commands/eject.S
--- dosemu0.53old//commands/eject.S
+++ dosemu0.53//commands/eject.S	Wed Aug 24 22:14:28 1994
@@ -0,0 +1,27 @@
+! eject.S for dosemu 0.53, 8/18/94
+!    eject cd in drive
+!
+
+use16
+.text
+.data
+.bss
+
+.align 0
+
+.globl _main           ! for ld86
+_main:
+
+       .org     0
+        mov al, #0x40  ! unlock door
+        mov ah, #0x0C
+        int     #0xe6
+
+	mov al, #0x40  ! eject disk
+        mov ah, #0x0D
+	int     #0xe6
+
+	int     #0x20  ! exit
+
+
+
Binary files dosemu0.53old//commands/eject.com and dosemu0.53//commands/eject.com differ
diff -u --recursive --new-file dosemu0.53old//dos.c dosemu0.53//dos.c
--- dosemu0.53old//dos.c	Wed Aug 17 22:58:21 1994
+++ dosemu0.53//dos.c	Wed Aug 24 22:14:23 1994
@@ -1,12 +1,15 @@
 /* dos emulator, Matthias Lautner */
 /* Extensions by Robert Sanders, 1992-93
  *
- * $Date: 1994/07/14 23:19:20 $
+ * $Date: 1994/08/25 00:49:34 $
  * $Source: /home/src/dosemu0.60/RCS/dos.c,v $
- * $Revision: 2.2 $
+ * $Revision: 2.3 $
  * $State: Exp $
  *
  * $Log: dos.c,v $
+ * Revision 2.3  1994/08/25  00:49:34  root
+ * HJ's patches for new linking (Actually new dos.c)
+ *
  * Revision 2.2  1994/07/14  23:19:20  root
  * Jochen's Patches
  *
@@ -37,13 +40,16 @@
  */
 
 #include <stdio.h>
+#include <a.out.h>
 #include <locale.h>
 #include "config.h"
 
-void (*dosemu) ();
+#define LIBDOSEMU	"/usr/lib/libdosemu"
+
+void (*dosemu) (int argc, char **argv);
 
 #if !STATIC
-char dummy[1088 * 1024];	/* ensure that the lower 1MB+64K is unused */
+char buf [1088 * 1024];	/* ensure that the lower 1MB+64K is unused */
 
 #endif
 
@@ -58,13 +64,44 @@
   fprintf(stderr, "WARNING: running static, emulate @ %x!\n", emulate);
   emulate(argc, argv);
 #else
-  if (uselib("/usr/lib/libdosemu") != 0) {
-    fprintf(stderr, "cannot load shared library /usr/lib/libdosemu!\n");
+  struct exec header;
+  FILE *f;
+
+  f = fopen(LIBDOSEMU, "r");
+  if (f == NULL)
+  {
+    sprintf (buf, "%s: cannot open shared library: %s", argv [0],
+	LIBDOSEMU);
+    perror (buf);
+    exit(1);
+  }
+
+  if (fread(&header, sizeof(header), 1, f) != 1)
+  {
+    sprintf (buf, "%s: cannot read shared library: %s", argv [0],
+	LIBDOSEMU);
+    perror (buf);
+    exit(1);
+  }
+
+  if (N_BADMAG (header))
+  {
+    fprintf (stderr, "%s: invalid shared library format: %s\n", argv [0],
+	LIBDOSEMU);
+    exit(1);
+  }
+
+  if (uselib(LIBDOSEMU) != 0) {
+    sprintf (buf, "%s: cannot load shared library: %s", argv [0],
+	LIBDOSEMU);
+    perror (buf);
     exit(1);
   }
   setlocale(LC_CTYPE,"");
-  dosemu = (void *) LIBSTART;
-  dosemu(argc, argv);
+
+  dosemu = (void *) header.a_entry;
+
+  (* dosemu)(argc, argv);
 #endif
 
 }
diff -u --recursive --new-file dosemu0.53old//drivers/cdrom.S dosemu0.53//drivers/cdrom.S
--- dosemu0.53old//drivers/cdrom.S	Wed Aug 17 22:58:29 1994
+++ dosemu0.53//drivers/cdrom.S	Wed Aug 24 22:14:29 1994
@@ -244,7 +244,7 @@
 IOCTLOUT_VOL     = 22		! not used (4 bytes)	
 
 ! ioctlout jump table
-IoctloutTbl:	.word	cmderr
+IoctloutTbl:	.word	eject
 		.word	lockunlock
 		.word	resetdrive
 		.word	audio_ctrl
@@ -277,6 +277,18 @@
 ioctlout_err:
 	br	cmderr
 
+! eject disk
+eject:
+	seg cs
+	les	di,[ptrsav]
+	movb	al,#Helper
+	movb	ah,#0x0D
+	int	LinuxCD
+
+	mov	ax,#0
+	br	exit
+	
+
 ! function lock - unlock drive
 lockunlock:
 	seg cs
@@ -542,7 +554,7 @@
 
 
 Message:
-	.ascii	"[dosemu 0.53 cdrom driver installed]"
+	.ascii	"[dosemu 0.53 cdrom driver installed (V0.2)]"
         .byte	cr,lf,eom
 FailMsg:
         .byte	cr,lf,lf
Binary files dosemu0.53old//drivers/cdrom.sys and dosemu0.53//drivers/cdrom.sys differ
diff -u --recursive --new-file dosemu0.53old//emu.c dosemu0.53//emu.c
--- dosemu0.53old//emu.c	Wed Aug 17 22:58:21 1994
+++ dosemu0.53//emu.c	Wed Aug 24 22:14:23 1994
@@ -12,12 +12,15 @@
  * DANG_END_MODULE
  *
  * DANG_BEGIN_CHANGELOG
- * $Date: 1994/08/17 02:08:22 $
+ * $Date: 1994/08/25 00:49:34 $
  * $Source: /home/src/dosemu0.60/RCS/emu.c,v $
- * $Revision: 2.20 $
+ * $Revision: 2.21 $
  * $State: Exp $
  *
  * $Log: emu.c,v $
+ * 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.
  *
@@ -444,6 +447,7 @@
 #include <sys/vm86.h>
 #include <syscall.h>
 #include <linux/cdrom.h>
+#include <linux/config.h>
 
 #include "config.h"
 #include "memory.h"
@@ -502,6 +506,8 @@
 unsigned long last_ticks;
 
 extern void video_config_init(void);
+extern int keyboard_init(void);
+extern void keyboard_close(void);
 
 /*
    Tables that hold information of currently specified storage
@@ -1002,8 +1008,6 @@
 
   keybuf_clear();
 
-  video_config_init();
-
   bios_vdu_control = 9;		/* current 3x8 (x=b or d) value */
   bios_ctrl_alt_del_flag = 0x0000;
   *(char *) 0x487 = 0x61;
@@ -1210,7 +1214,11 @@
       h_printf("NOT CONFIG.TIMERS\n");
   }
 
-  if (!use_sigio) {
+  if (!use_sigio
+#ifdef SIG
+    | SillyG
+#endif
+     ) {
   /* Call select to see if any I/O is ready on devices */
     io_select();
   }
@@ -1873,12 +1881,6 @@
   /* setup DOS memory, whether shared or not */
   memory_setup();
 
-  /* initialize some video config variables, possibly map video bios,
-     get graphics chars
-  */
-  video_config_init();
-
-
   g_printf("EMULATE\n");
 
   /* we assume system call restarting... under linux 0.99pl8 and earlier,
@@ -1944,19 +1946,31 @@
 
   vm86s.flags=0;
 
-  video_init();
+  /* Verify that Keyboard is OK as well as turn off some
+     options if not at a console
+  */
+  if (keyboard_init() != 0) {
+    error("ERROR: can't open keyboard\n");
+    leavedos(19);
+  }
+  /* initialize some video config variables, possibly map video bios,
+     get graphics chars
+  */
+  video_config_init();
+#ifdef SIG
+  SIG_init();
+#endif
   mouse_init();
+#if 0
+  video_init();
+#endif
   disk_init();
-  
+  serial_init();
   NEWSETSIG(SIGSEGV, dosemu_fault);
   hardware_init();
 
   boot();
 
-/*
-  boot(config.hdiskboot ? hdisktab : disktab);
-*/
-
   fflush(stdout);
   itv.it_interval.tv_sec = 0;
   itv.it_interval.tv_usec = UPDATE / TIMER_DIVISOR;
@@ -1965,16 +1979,15 @@
   setitimer(TIMER_TIME, &itv, NULL);
   k_printf("Used %d for update\n", UPDATE / TIMER_DIVISOR);
 
-
-  serial_init();
-#ifdef SIG
-  SIG_init();
-#endif
-
   for (; !fatalerr;) {
     run_vm86();
-    serial_run();
-    int_queue_run();
+#ifdef CONFIG_CORRECT_STI /* defined in linux/autoconfig.h */
+    if (!(REG(eflags) & STIP_MASK))
+#endif
+    {
+      serial_run();
+      int_queue_run();
+    }
   }
 
   error("error exit: (%d,0x%04x) in_sigsegv: %d ignore_segv: %d\n",
@@ -2040,6 +2053,7 @@
   show_regs();
   disk_close_all();
   video_close();
+  keyboard_close();
   fflush(stderr);
   fflush(stdout);
 
@@ -2090,7 +2104,7 @@
 
 void
  usage(void) {
-  fprintf(stdout, "$Header: /home/src/dosemu0.60/RCS/emu.c,v 2.20 1994/08/17 02:08:22 root Exp root $\n");
+  fprintf(stdout, "$Header: /home/src/dosemu0.60/RCS/emu.c,v 2.21 1994/08/25 00:49:34 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");
@@ -2165,12 +2179,11 @@
   while (*s) char_out(*s++, bios_current_screen_page);
 }
 
-
-
 int cdrom_fd = -1;
 
 unsigned int device_status;
 struct audio_status { unsigned int status;
+		      unsigned char media_changed;
                       unsigned char paused_bit;
                       unsigned int last_StartSector,last_EndSector;
                       unsigned char outchan0,outchan1,outchan2,outchan3;
@@ -2225,6 +2238,16 @@
 #define MSCD_CTRL_VOLUME2          6
 #define MSCD_CTRL_VOLUME3          8
 
+
+void cdrom_reset()
+{
+  /* after a disk change a new read access will 
+     return in error. In order to unlock this condition
+     the drive must be reopend.
+     Does some one knows a better way?                   */
+  close (cdrom_fd); 
+  cdrom_fd = open ("/dev/cdrom", O_RDONLY);
+ }
 #define MSCD_AUDCHAN_VOLUME0       2
 #define MSCD_AUDCHAN_VOLUME1       4
 #define MSCD_AUDCHAN_VOLUME2       6
@@ -2242,7 +2265,7 @@
    struct cdrom_volctrl cdrom_volctrl;
    int n,ioctlin;
    
-              /*  error ("call function %d !\n", HI(ax));
+                /* error ("call function %d !\n", HI(ax));
 
                 ioctlin = 0;
                 req_buf = SEG_ADR((char *), es, di);
@@ -2261,11 +2284,12 @@
                      error ("  %3x", req_buf[n]);
                   error ("\n");
                 }
-                error ("\n"); */
-
+                error ("\n");
+                */
    switch (HI(ax)) {
      case 0x01: audio_status.status = 0x00000310;
                 audio_status.paused_bit = 0;
+                audio_status.media_changed = 0;
                 audio_status.volume0 = 0xFF;
                 audio_status.volume1 = 0xFF;
                 audio_status.volume2 = 0;
@@ -2326,14 +2350,19 @@
 
                 audio_status.last_EndSector = Sector_plus_150;
                 audio_status.paused_bit = 0;
-                if (ioctl (cdrom_fd, CDROMPLAYMSF, &cdrom_msf) == -1) {
-                  LO(ax) = 1;
-                 }
-                 else LO(ax) = 0;
+                if (ioctl (cdrom_fd, CDROMPLAYMSF, &cdrom_msf)) {
+                  audio_status.media_changed = 1;
+                  if (ioctl (cdrom_fd, CDROMPLAYMSF, &cdrom_msf)) {
+                    /* no disk in drive */
+                    LO(ax) = 1;
+                    break;
+                  }
+                }
+                LO(ax) = 0;
                 break;                 
      case 0x05: /* pause (stop) audio */
                 LO(ax) = 0;
-                if (ioctl (cdrom_fd, CDROMSUBCHNL, &cdrom_subchnl) != -1) {
+                if (ioctl (cdrom_fd, CDROMSUBCHNL, &cdrom_subchnl) == 0) {
                   if (cdrom_subchnl.cdsc_audiostatus == CDROM_AUDIO_PLAY) {
                     audio_status.last_StartSector =             
                                 cdrom_subchnl.cdsc_absaddr.msf.minute*60*75
@@ -2346,12 +2375,17 @@
                          audio_status.last_EndSector = 0;
                          audio_status.paused_bit = 0;
                        }
-                }
+                 }
+                 else { audio_status.last_StartSector = 0;
+                        audio_status.last_EndSector = 0;
+                        audio_status.paused_bit = 0;
+                        audio_status.media_changed = 1;
+                      }
                 break;
      case 0x06: /* resume audio */
                 LO(ax) = 0;
                 if (audio_status.paused_bit) {
-                  if (ioctl (cdrom_fd, CDROMRESUME, NULL) != -1) {
+                  if (ioctl (cdrom_fd, CDROMRESUME, NULL) == 0) {
                     audio_status.paused_bit = 0;
                     HI(ax) = 1;
                   }
@@ -2359,26 +2393,30 @@
                 else LO(ax) = 1;
                 break;                
      case 0x07: /* location of head */
-                if (ioctl (cdrom_fd, CDROMSUBCHNL, &cdrom_subchnl) == -1)
-                  LO(ax) = 1;
-                 else { 
-                        req_buf = SEG_ADR((char *), ds, si);
-                        if (*CALC_PTR(req_buf,MSCD_LOCH_ADRESSING,u_char) == 0) {
-                          *CALC_PTR(req_buf,MSCD_LOCH_LOCATION,u_long)
-                             = cdrom_subchnl.cdsc_absaddr.msf.minute*60*75
-                                    +cdrom_subchnl.cdsc_absaddr.msf.second*75
-                                     +cdrom_subchnl.cdsc_absaddr.msf.frame-150;                                                
-                         }
-                         else {
-                               *CALC_PTR(req_buf,MSCD_LOCH_LOCATION+3,u_char) = 0;
-                               *CALC_PTR(req_buf,MSCD_LOCH_LOCATION+2,u_char) = cdrom_subchnl.cdsc_absaddr.msf.minute;
-                               *CALC_PTR(req_buf,MSCD_LOCH_LOCATION+1,u_char) = cdrom_subchnl.cdsc_absaddr.msf.second;
-                               *CALC_PTR(req_buf,MSCD_LOCH_LOCATION+0,u_char) = cdrom_subchnl.cdsc_absaddr.msf.frame;
-                              }
-                        if (cdrom_subchnl.cdsc_audiostatus == CDROM_AUDIO_PLAY)
-                          HI(ax) = 1;   
-                         else HI(ax) = 0;
-                        LO(ax) = 0;
+                LWORD(eax) = 0;
+                if (ioctl (cdrom_fd, CDROMSUBCHNL, &cdrom_subchnl)) {
+                  audio_status.media_changed = 1;
+                  if (ioctl (cdrom_fd, CDROMSUBCHNL, &cdrom_subchnl)) {
+                    /* no disk in drive */
+                    LO(ax) = 1;
+                    break;
+                  }
+                }
+                if (cdrom_subchnl.cdsc_audiostatus == CDROM_AUDIO_PLAY)
+                  HI(ax) = 1;   
+
+                req_buf = SEG_ADR((char *), ds, si);
+                if (*CALC_PTR(req_buf,MSCD_LOCH_ADRESSING,u_char) == 0) {
+                  *CALC_PTR(req_buf,MSCD_LOCH_LOCATION,u_long)
+                     = cdrom_subchnl.cdsc_absaddr.msf.minute*60*75
+                            +cdrom_subchnl.cdsc_absaddr.msf.second*75
+                             +cdrom_subchnl.cdsc_absaddr.msf.frame-150;                                                
+                 }
+                 else {/* red book adressing */
+                       *CALC_PTR(req_buf,MSCD_LOCH_LOCATION+3,u_char) = 0;
+                       *CALC_PTR(req_buf,MSCD_LOCH_LOCATION+2,u_char) = cdrom_subchnl.cdsc_absaddr.msf.minute;
+                       *CALC_PTR(req_buf,MSCD_LOCH_LOCATION+1,u_char) = cdrom_subchnl.cdsc_absaddr.msf.second;
+                       *CALC_PTR(req_buf,MSCD_LOCH_LOCATION+0,u_char) = cdrom_subchnl.cdsc_absaddr.msf.frame;
                       }
                 break;
      case 0x08: /* return sectorsize */
@@ -2386,20 +2424,37 @@
                 LWORD(ebx) = 2048;
                 break;
      case 0x09: /* media changed */
-                HI(ax) = 0;
-                if (ioctl (cdrom_fd, CDROMSUBCHNL, &cdrom_subchnl) != -1) 
-                  if (cdrom_subchnl.cdsc_audiostatus == CDROM_AUDIO_PLAY)
-                    HI(ax) = 1;
-                LO(ax) = 0;
-                LO(bx) = 0;
+                /* this function will be called from MSCDEX before 
+                   each new disk access !                         */
+                HI(ax) = 0; LO(ax) = 0; LO(bx) = 0;
+                if ((audio_status.media_changed) ||
+                      ioctl (cdrom_fd, CDROMSUBCHNL, &cdrom_subchnl)) {
+                  audio_status.media_changed = 0;
+                  LO(bx) = 1; /* media has been changed */
+                  if (! ioctl (cdrom_fd, CDROMSUBCHNL, &cdrom_subchnl)) {
+                    /* new disk inserted */
+                    cdrom_reset();
+                  }
+                 }
+                 else /* media has not changed, check audio status */
+                      if (cdrom_subchnl.cdsc_audiostatus == CDROM_AUDIO_PLAY)
+                        HI(ax) = 1; /* audio playing in progress */
                 break;
      case 0x0A: /* device status */
+                HI(ax) = 0; LO(ax) = 0;
+                if (ioctl (cdrom_fd, CDROMSUBCHNL, &cdrom_subchnl))
+                  if (ioctl (cdrom_fd, CDROMSUBCHNL, &cdrom_subchnl))
+                    { /* no disk in drive */
+                      LWORD(ebx) = audio_status.status | 0x800;
+                      break;
+                    }
+                   else { /* disk has been changed; new disk in drive ! */
+                          cdrom_reset();
+                        }
+                /* disk in drive */
                 LWORD(ebx) = audio_status.status;
-                HI(ax) = 0;
-                if (ioctl (cdrom_fd, CDROMSUBCHNL, &cdrom_subchnl) != -1) 
-                  if (cdrom_subchnl.cdsc_audiostatus == CDROM_AUDIO_PLAY)
-                    HI(ax) = 1;
-                LO(ax) = 0;
+                if (cdrom_subchnl.cdsc_audiostatus == CDROM_AUDIO_PLAY)
+                  HI(ax) = 1;
                 break;
      case 0x0B: /* drive reset */
                 LO(ax) = 0;
@@ -2411,9 +2466,10 @@
                 LO(ax) = 0;
                 break;
      case 0x0D: /* eject */
-                if (ioctl (cdrom_fd, CDROMEJECT, NULL) != -1)
-                  LO(ax) = 0;
-                 else LO(ax) = 1;
+                LO(ax) = 0;
+                if (audio_status.status & 0x02) /* drive unlocked ? */
+                  if (ioctl (cdrom_fd, CDROMEJECT, NULL))
+                    LO(ax) = 1;
                 break;
      case 0x0E: /* close tray */
                 LO(ax) = 0;
@@ -2420,9 +2476,17 @@
                 break;
      case 0x0F: /* audio channel control */
                 LWORD(eax) = 0;
-                if (ioctl (cdrom_fd, CDROMSUBCHNL, &cdrom_subchnl) != -1) 
-                  if (cdrom_subchnl.cdsc_audiostatus == CDROM_AUDIO_PLAY)
-                    HI(ax) = 1;
+                if (ioctl (cdrom_fd, CDROMSUBCHNL, &cdrom_subchnl)) {
+                  audio_status.media_changed = 1;
+                  if (ioctl (cdrom_fd, CDROMSUBCHNL, &cdrom_subchnl)) {
+                    /* no disk in drive */
+                    LO(ax) = 1;
+                    break;
+                  }
+                }
+                if (cdrom_subchnl.cdsc_audiostatus == CDROM_AUDIO_PLAY)
+                  HI(ax) = 1;
+ 
                 req_buf = SEG_ADR((char *), ds, si);
                 cdrom_volctrl.channel0 = *CALC_PTR(req_buf, MSCD_CTRL_VOLUME0, u_char);
                 cdrom_volctrl.channel1 = *CALC_PTR(req_buf, MSCD_CTRL_VOLUME1, u_char);
@@ -2439,74 +2503,105 @@
                 ioctl (cdrom_fd, CDROMVOLCTRL, &cdrom_volctrl);
                 break;
      case 0x10: /* audio disk info */
-                LO(ax) = 1;
-                if (ioctl (cdrom_fd, CDROMREADTOCHDR, &cdrom_tochdr) != -1) {
-                  req_buf = SEG_ADR((char *), ds, si);
-                  *CALC_PTR(req_buf,MSCD_DISKINFO_LTN,u_char) = cdrom_tochdr.cdth_trk0;
-                  *CALC_PTR(req_buf,MSCD_DISKINFO_HTN,u_char) = cdrom_tochdr.cdth_trk1;
-                  cdrom_tocentry.cdte_track = CDROM_LEADOUT;
-                  cdrom_tocentry.cdte_format = CDROM_MSF;
-                  if (ioctl (cdrom_fd, CDROMREADTOCENTRY, &cdrom_tocentry) != -1) {
-                    *CALC_PTR(req_buf,MSCD_DISKINFO_LEADOUT+3,u_char) = 0;
-                    *CALC_PTR(req_buf,MSCD_DISKINFO_LEADOUT+2,u_char) = cdrom_tocentry.cdte_addr.msf.minute;
-                    *CALC_PTR(req_buf,MSCD_DISKINFO_LEADOUT+1,u_char) = cdrom_tocentry.cdte_addr.msf.second;
-                    *CALC_PTR(req_buf,MSCD_DISKINFO_LEADOUT+0,u_char) = cdrom_tocentry.cdte_addr.msf.frame;
-                    LO(ax) = 0;
+                LWORD(eax) = 0;
+                if (ioctl (cdrom_fd, CDROMREADTOCHDR, &cdrom_tochdr)) {
+                  audio_status.media_changed = 1;
+                  if (ioctl (cdrom_fd, CDROMREADTOCHDR, &cdrom_tochdr)) {
+                    /* no disk in drive */
+                    LO(ax) = 1;
+                    break;
                   }
                 }
+
+                req_buf = SEG_ADR((char *), ds, si);
+                *CALC_PTR(req_buf,MSCD_DISKINFO_LTN,u_char) = cdrom_tochdr.cdth_trk0;
+                *CALC_PTR(req_buf,MSCD_DISKINFO_HTN,u_char) = cdrom_tochdr.cdth_trk1;
+                cdrom_tocentry.cdte_track = CDROM_LEADOUT;
+                cdrom_tocentry.cdte_format = CDROM_MSF;
+                if (ioctl (cdrom_fd, CDROMREADTOCENTRY, &cdrom_tocentry)) {
+                  error ("Fatal cdrom error(audio disk info); read toc header succeeded but following read entry didn't\n");
+                  LO(ax) = 1;
+                  break;
+                }
+                *CALC_PTR(req_buf,MSCD_DISKINFO_LEADOUT+3,u_char) = 0;
+                *CALC_PTR(req_buf,MSCD_DISKINFO_LEADOUT+2,u_char) = cdrom_tocentry.cdte_addr.msf.minute;
+                *CALC_PTR(req_buf,MSCD_DISKINFO_LEADOUT+1,u_char) = cdrom_tocentry.cdte_addr.msf.second;
+                *CALC_PTR(req_buf,MSCD_DISKINFO_LEADOUT+0,u_char) = cdrom_tocentry.cdte_addr.msf.frame;
                 break;                
      case 0x11: /* track info */
                 req_buf = SEG_ADR((char *), ds, si);
                 cdrom_tocentry.cdte_track = *CALC_PTR(req_buf,MSCD_TRACKINFO_TRACKNUM,u_char);
                 cdrom_tocentry.cdte_format = CDROM_MSF;
-                if (ioctl (cdrom_fd, CDROMREADTOCENTRY, &cdrom_tocentry) != -1) {
-                  *CALC_PTR(req_buf,MSCD_TRACKINFO_TRACKPOS+3,u_char) = 0;
-                  *CALC_PTR(req_buf,MSCD_TRACKINFO_TRACKPOS+2,u_char) = cdrom_tocentry.cdte_addr.msf.minute;
-                  *CALC_PTR(req_buf,MSCD_TRACKINFO_TRACKPOS+1,u_char) = cdrom_tocentry.cdte_addr.msf.second;
-                  *CALC_PTR(req_buf,MSCD_TRACKINFO_TRACKPOS+0,u_char) = cdrom_tocentry.cdte_addr.msf.frame;                  
-                  *CALC_PTR(req_buf,MSCD_TRACKINFO_CTRL,u_char) = cdrom_tocentry.cdte_ctrl;
-                  LO(ax) = 0;
-                 }
-                 else LO(ax) = 1;
+                if (ioctl (cdrom_fd, CDROMREADTOCENTRY, &cdrom_tocentry)) {
+                  audio_status.media_changed = 1;
+                  if (ioctl (cdrom_fd, CDROMREADTOCENTRY, &cdrom_tocentry)) {
+                    /* no disk in drive */
+                    LO(ax) = 1;
+                    break;
+                  }
+                }
+                *CALC_PTR(req_buf,MSCD_TRACKINFO_TRACKPOS+3,u_char) = 0;
+                *CALC_PTR(req_buf,MSCD_TRACKINFO_TRACKPOS+2,u_char) = cdrom_tocentry.cdte_addr.msf.minute;
+                *CALC_PTR(req_buf,MSCD_TRACKINFO_TRACKPOS+1,u_char) = cdrom_tocentry.cdte_addr.msf.second;
+                *CALC_PTR(req_buf,MSCD_TRACKINFO_TRACKPOS+0,u_char) = cdrom_tocentry.cdte_addr.msf.frame;                  
+                *CALC_PTR(req_buf,MSCD_TRACKINFO_CTRL,u_char) = cdrom_tocentry.cdte_ctrl << 4 | 0x20;
+                LO(ax) = 0;
                 break;                
      case 0x12: /* volume size */
                 cdrom_tocentry.cdte_track = CDROM_LEADOUT;
                 cdrom_tocentry.cdte_format = CDROM_MSF;
-                if (ioctl (cdrom_fd, CDROMREADTOCENTRY, &cdrom_tocentry) != -1) {
-                  req_buf = SEG_ADR((char *), ds, si);
-                  *CALC_PTR(req_buf,MSCD_GETVOLUMESIZE_SIZE,int) = cdrom_tocentry.cdte_addr.msf.minute*60*75
-                                                                      +cdrom_tocentry.cdte_addr.msf.second*60
-                                                                      +cdrom_tocentry.cdte_addr.msf.frame;
-                  LO(ax) = 0;
-                 }                              
-                else LO(ax) = 1;
+                if (ioctl (cdrom_fd, CDROMREADTOCENTRY, &cdrom_tocentry)) {
+                  audio_status.media_changed = 1;
+                  if (ioctl (cdrom_fd, CDROMREADTOCENTRY, &cdrom_tocentry)) {
+                    /* no disk in drive */
+                    LO(ax) = 1;
+                    break;
+                  }
+                }
+                req_buf = SEG_ADR((char *), ds, si);
+                *CALC_PTR(req_buf,MSCD_GETVOLUMESIZE_SIZE,int) = cdrom_tocentry.cdte_addr.msf.minute*60*75
+                                                                    +cdrom_tocentry.cdte_addr.msf.second*60
+                                                                    +cdrom_tocentry.cdte_addr.msf.frame;
+                LO(ax) = 0;
                 break;                
      case 0x13: /* q channel */
                 LWORD(eax) = 0;
-                if (ioctl (cdrom_fd, CDROMSUBCHNL, &cdrom_subchnl) != -1) { 
-                  if (cdrom_subchnl.cdsc_audiostatus == CDROM_AUDIO_PLAY)
-                    HI(ax) = 1;
-             
-                  req_buf = SEG_ADR((char *), ds, si);
-                  *CALC_PTR(req_buf,MSCD_QCHAN_CTRL,u_char) = (cdrom_subchnl.cdsc_adr << 4) + (cdrom_subchnl.cdsc_ctrl);
-                  *CALC_PTR(req_buf,MSCD_QCHAN_TNO,u_char)  = cdrom_subchnl.cdsc_trk;
-                  *CALC_PTR(req_buf,MSCD_QCHAN_IND,u_char)  = cdrom_subchnl.cdsc_ind;
-                  *CALC_PTR(req_buf,MSCD_QCHAN_MIN,u_char)  = cdrom_subchnl.cdsc_reladdr.msf.minute;
-                  *CALC_PTR(req_buf,MSCD_QCHAN_SEC,u_char)  = cdrom_subchnl.cdsc_reladdr.msf.second;
-                  *CALC_PTR(req_buf,MSCD_QCHAN_FRM,u_char)  = cdrom_subchnl.cdsc_reladdr.msf.frame;
-                  *CALC_PTR(req_buf,MSCD_QCHAN_ZERO,u_char) = 0;
-                  *CALC_PTR(req_buf,MSCD_QCHAN_AMIN,u_char) = cdrom_subchnl.cdsc_absaddr.msf.minute;
-                  *CALC_PTR(req_buf,MSCD_QCHAN_ASEC,u_char) = cdrom_subchnl.cdsc_absaddr.msf.second;
-                  *CALC_PTR(req_buf,MSCD_QCHAN_AFRM,u_char) = cdrom_subchnl.cdsc_absaddr.msf.frame;
-                  LO(ax) = 0;
-                 }
-                 else LO(ax) = 1;
+                if (ioctl (cdrom_fd, CDROMSUBCHNL, &cdrom_subchnl)) {
+                  audio_status.media_changed = 1;
+                  if (ioctl (cdrom_fd, CDROMSUBCHNL, &cdrom_subchnl)) {
+                    /* no disk in drive */
+                    LO(ax) = 1;
+                    break;
+                  }
+                }
+                if (cdrom_subchnl.cdsc_audiostatus == CDROM_AUDIO_PLAY)
+                  HI(ax) = 1;
+            
+                req_buf = SEG_ADR((char *), ds, si);
+                *CALC_PTR(req_buf,MSCD_QCHAN_CTRL,u_char) = (cdrom_subchnl.cdsc_adr << 4) + (cdrom_subchnl.cdsc_ctrl);
+                *CALC_PTR(req_buf,MSCD_QCHAN_TNO,u_char)  = cdrom_subchnl.cdsc_trk;
+                *CALC_PTR(req_buf,MSCD_QCHAN_IND,u_char)  = cdrom_subchnl.cdsc_ind;
+                *CALC_PTR(req_buf,MSCD_QCHAN_MIN,u_char)  = cdrom_subchnl.cdsc_reladdr.msf.minute;
+                *CALC_PTR(req_buf,MSCD_QCHAN_SEC,u_char)  = cdrom_subchnl.cdsc_reladdr.msf.second;
+                *CALC_PTR(req_buf,MSCD_QCHAN_FRM,u_char)  = cdrom_subchnl.cdsc_reladdr.msf.frame;
+                *CALC_PTR(req_buf,MSCD_QCHAN_ZERO,u_char) = 0;
+                *CALC_PTR(req_buf,MSCD_QCHAN_AMIN,u_char) = cdrom_subchnl.cdsc_absaddr.msf.minute;
+                *CALC_PTR(req_buf,MSCD_QCHAN_ASEC,u_char) = cdrom_subchnl.cdsc_absaddr.msf.second;
+                *CALC_PTR(req_buf,MSCD_QCHAN_AFRM,u_char) = cdrom_subchnl.cdsc_absaddr.msf.frame;
                 break;
      case 0x14: /* audio status */
                 LWORD(eax) = 0;
-                if (ioctl (cdrom_fd, CDROMSUBCHNL, &cdrom_subchnl) != -1) 
-                  if (cdrom_subchnl.cdsc_audiostatus == CDROM_AUDIO_PLAY)
-                    HI(ax) = 1;
+                if (ioctl (cdrom_fd, CDROMSUBCHNL, &cdrom_subchnl)) {
+                  audio_status.media_changed = 1;
+                  if (ioctl (cdrom_fd, CDROMSUBCHNL, &cdrom_subchnl)) {
+                    /* no disk in drive */
+                    LO(ax) = 1;
+                    break;
+                  }
+                }
+                if (cdrom_subchnl.cdsc_audiostatus == CDROM_AUDIO_PLAY)
+                  HI(ax) = 1;
+
                 req_buf = SEG_ADR((char *), ds, si);
                 *CALC_PTR(req_buf,MSCD_AUDSTAT_PAUSED,u_short)= audio_status.paused_bit;
                 *CALC_PTR(req_buf,MSCD_AUDSTAT_START ,u_long) = audio_status.last_StartSector;
@@ -2514,12 +2609,18 @@
                 break;
      case 0x15: /* get audio channel information */
                 LWORD(eax) = 0;
-                if (ioctl (cdrom_fd, CDROMSUBCHNL, &cdrom_subchnl) != -1) { 
-                  if (cdrom_subchnl.cdsc_audiostatus == CDROM_AUDIO_PLAY)
-                    HI(ax) = 1;
+                if (ioctl (cdrom_fd, CDROMSUBCHNL, &cdrom_subchnl)) {
+                  audio_status.media_changed = 1;
+                  if (ioctl (cdrom_fd, CDROMSUBCHNL, &cdrom_subchnl)) {
+                    /* no disk in drive */
+                    LO(ax) = 1;
+                    break;
+                  }
                 }
-                req_buf = SEG_ADR((char *), ds, si);
+                if (cdrom_subchnl.cdsc_audiostatus == CDROM_AUDIO_PLAY)
+                  HI(ax) = 1;
 
+                req_buf = SEG_ADR((char *), ds, si);
                 *CALC_PTR(req_buf,MSCD_AUDCHAN_VOLUME0,u_char) = audio_status.volume0;
                 *CALC_PTR(req_buf,MSCD_AUDCHAN_VOLUME1,u_char) = audio_status.volume1;
                 *CALC_PTR(req_buf,MSCD_AUDCHAN_VOLUME2,u_char) = audio_status.volume2; 
@@ -2532,7 +2633,7 @@
      default: error ("CDROM: unknown request !\n");
    }
 
-/*                if (ioctlin) {
+                /* if (ioctlin) {
                   error ("            return  : ");
                   req_buf = SEG_ADR((char *), ds, si);
                   for (n = 0; n <= 9; ++n)
@@ -2542,7 +2643,7 @@
                 else ("\n");
 
                 error ("Leave cdrom request with return status %d !\n\n", LWORD(eax));
-*/
+                */
    return ;
 }
 
@@ -2699,7 +2800,7 @@
     }
 
   case 5:			/* show banner */
-    p_dos_str("\n\nLinux DOS emulator " VERSTR "pl" PATCHSTR " $Date: 1994/08/17 02:08:22 $\n");
+    p_dos_str("\n\nLinux DOS emulator " VERSTR "pl" PATCHSTR " $Date: 1994/08/25 00:49:34 $\n");
     p_dos_str("Last configured at %s\n", CONFIG_TIME);
     p_dos_str("on %s\n", CONFIG_HOST);
     /* p_dos_str("Formerly maintained by Robert Sanders, gt8134b@prism.gatech.edu\n\n"); */
diff -u --recursive --new-file dosemu0.53old//emu.h dosemu0.53//emu.h
--- dosemu0.53old//emu.h	Wed Aug 17 22:58:22 1994
+++ dosemu0.53//emu.h	Wed Aug 24 22:14:24 1994
@@ -3,12 +3,15 @@
 #define EMU_H
 /* Extensions by Robert Sanders, 1992-93
  *
- * $Date: 1994/08/17 02:08:22 $
+ * $Date: 1994/08/25 00:49:34 $
  * $Source: /home/src/dosemu0.60/RCS/emu.h,v $
- * $Revision: 2.12 $
+ * $Revision: 2.13 $
  * $State: Exp $
  *
  * $Log: emu.h,v $
+ * Revision 2.13  1994/08/25  00:49:34  root
+ * prep for pre53_16
+ *
  * Revision 2.12  1994/08/17  02:08:22  root
  * Mods to Rain's patches to get all modes back on the road.
  *
@@ -236,7 +239,6 @@
 int ext_fs(int, char *, char *, int);
 int outch(int c);
 void termioInit(void);
-void termioClose(void);
 __inline__ void run_vm86(void);
 
 #define NOWAIT  0
diff -u --recursive --new-file dosemu0.53old//examples/config.dist dosemu0.53//examples/config.dist
--- dosemu0.53old//examples/config.dist	Wed Aug 17 22:58:33 1994
+++ dosemu0.53//examples/config.dist	Wed Aug 24 22:14:33 1994
@@ -48,7 +48,7 @@
 #    With the "layout" keyword, you can specify your country's keyboard
 #    layout.  The following layouts are implemented:
 #        finnish           us           dvorak       sf
-#        finnish_latin1    uk           sg           sf-latin1
+#        finnish-latin1    uk           sg           sf-latin1
 #        gr                dk           sg-latin1    es
 #        gr-latin1         dk-latin1    fr           es-latin1
 #        be                no           fr-latin1
diff -u --recursive --new-file dosemu0.53old//kernel/Makefile dosemu0.53//kernel/Makefile
--- dosemu0.53old//kernel/Makefile	Wed Aug 17 22:58:33 1994
+++ dosemu0.53//kernel/Makefile	Wed Aug 24 22:14:32 1994
@@ -25,7 +25,8 @@
 # Insert all source- and header-files here.
 
 ALL = $(CFILES) $(HFILES) kernel.1.0.x.diff \
-	net.inet.ipxcall.h include.linux.ipx.h net.inet.ipx.c kernel-ipx.dif
+	net.inet.ipxcall.h include.linux.ipx.h net.inet.ipx.c kernel-ipx.dif \
+	sti.pat
 
 
 # All object-files are included here.
diff -u --recursive --new-file dosemu0.53old//kernel/sti.pat dosemu0.53//kernel/sti.pat
--- dosemu0.53old//kernel/sti.pat
+++ dosemu0.53//kernel/sti.pat	Wed Aug 24 22:14:32 1994
@@ -0,0 +1,258 @@
+diff -ru linux.1.1.44/config.in linux/config.in
+--- linux.1.1.44/config.in	Fri Aug 12 18:55:00 1994
++++ linux/config.in	Sun Aug 14 12:50:49 1994
+@@ -12,6 +12,7 @@
+ bool 'Limit memory to low 16MB' CONFIG_MAX_16M n
+ bool 'System V IPC' CONFIG_SYSVIPC y
+ bool 'Use -m486 flag for 486-specific optimizations' CONFIG_M486 y
++bool 'Correct but slow STI handling (virtual 8086 mode)' CONFIG_CORRECT_STI n
+ 
+ if [ "$CONFIG_NET" = "y" ]; then
+ comment 'Networking options'
+diff -ru linux.1.1.44/include/linux/vm86.h linux/include/linux/vm86.h
+--- linux.1.1.44/include/linux/vm86.h	Mon May  2 08:31:55 1994
++++ linux/include/linux/vm86.h	Sat Aug 13 22:35:16 1994
+@@ -21,6 +21,7 @@
+ #define VIF_MASK	0x00080000	/* virtual interrupt flag */
+ #define VIP_MASK	0x00100000	/* virtual interrupt pending */
+ #define ID_MASK		0x00200000
++#define STIP_MASK	0x80000000	/* STI pending */
+ 
+ #define BIOSSEG		0x0f000
+ 
+@@ -101,8 +102,7 @@
+ 
+ #ifdef __KERNEL__
+ 
+-void handle_vm86_fault(struct vm86_regs *, long);
+-void handle_vm86_debug(struct vm86_regs *, long);
++void handle_vm86_fault(struct vm86_regs *, long, int);
+ 
+ #endif
+ 
+diff -ru linux.1.1.44/kernel/traps.c linux/kernel/traps.c
+--- linux.1.1.44/kernel/traps.c	Thu Aug 11 16:06:32 1994
++++ linux/kernel/traps.c	Fri Aug 12 19:00:39 1994
+@@ -39,6 +39,21 @@
+ 	die_if_kernel(str,regs,error_code); \
+ }
+ 
++#define DO_VM86_ERROR(trapnr, signr, str, name, tsk) \
++asmlinkage void do_##name(struct pt_regs * regs, long error_code) \
++{ \
++	if (regs->eflags & VM_MASK) { \
++		handle_vm86_fault((struct vm86_regs *) regs, error_code, trapnr); \
++		return; \
++	} \
++	tsk->tss.error_code = error_code; \
++	tsk->tss.trap_no = trapnr; \
++	if (signr == SIGTRAP && current->flags & PF_PTRACED) \
++		current->blocked &= ~(1 << (SIGTRAP-1)); \
++	send_sig(signr, tsk, 1); \
++	die_if_kernel(str,regs,error_code); \
++}
++
+ #define get_seg_byte(seg,addr) ({ \
+ register unsigned char __res; \
+ __asm__("push %%fs;mov %%ax,%%fs;movb %%fs:%2,%%al;pop %%fs" \
+@@ -114,12 +129,12 @@
+ 	do_exit(SIGSEGV);
+ }
+ 
+-DO_ERROR( 0, SIGFPE,  "divide error", divide_error, current)
+-DO_ERROR( 3, SIGTRAP, "int3", int3, current)
+-DO_ERROR( 4, SIGSEGV, "overflow", overflow, current)
+-DO_ERROR( 5, SIGSEGV, "bounds", bounds, current)
++DO_VM86_ERROR( 0, SIGFPE,  "divide error", divide_error, current)
++DO_VM86_ERROR( 3, SIGTRAP, "int3", int3, current)
++DO_VM86_ERROR( 4, SIGSEGV, "overflow", overflow, current)
++DO_VM86_ERROR( 5, SIGSEGV, "bounds", bounds, current)
+ DO_ERROR( 6, SIGILL,  "invalid operand", invalid_op, current)
+-DO_ERROR( 7, SIGSEGV, "device not available", device_not_available, current)
++DO_VM86_ERROR( 7, SIGSEGV, "device not available", device_not_available, current)
+ DO_ERROR( 8, SIGSEGV, "double fault", double_fault, current)
+ DO_ERROR( 9, SIGFPE,  "coprocessor segment overrun", coprocessor_segment_overrun, last_task_used_math)
+ DO_ERROR(10, SIGSEGV, "invalid TSS", invalid_TSS, current)
+@@ -133,7 +148,7 @@
+ 	int signr = SIGSEGV;
+ 
+ 	if (regs->eflags & VM_MASK) {
+-		handle_vm86_fault((struct vm86_regs *) regs, error_code);
++		handle_vm86_fault((struct vm86_regs *) regs, error_code, 13);
+ 		return;
+ 	}
+ 	die_if_kernel("general protection",regs,error_code);
+@@ -158,7 +173,7 @@
+ asmlinkage void do_debug(struct pt_regs * regs, long error_code)
+ {
+ 	if (regs->eflags & VM_MASK) {
+-		handle_vm86_debug((struct vm86_regs *) regs, error_code);
++		handle_vm86_fault((struct vm86_regs *) regs, error_code, 1);
+ 		return;
+ 	}
+ 	if (current->flags & PF_PTRACED)
+diff -ru linux.1.1.44/kernel/vm86.c linux/kernel/vm86.c
+--- linux.1.1.44/kernel/vm86.c	Mon May 23 00:45:07 1994
++++ linux/kernel/vm86.c	Sun Aug 14 12:22:49 1994
+@@ -3,6 +3,7 @@
+  *
+  *  Copyright (C) 1994  Linus Torvalds
+  */
++#include <linux/config.h>
+ #include <linux/errno.h>
+ #include <linux/sched.h>
+ #include <linux/kernel.h>
+@@ -21,11 +22,8 @@
+  *   after a "mov ss,xx" to make stack handling atomic even without
+  *   the 'lss' instruction. We can't guarantee this in v86 mode,
+  *   as the next instruction might result in a page fault or similar.
+- * - a real x86 will have interrupts disabled for one instruction
+- *   past the 'sti' that enables them. We don't bother with all the
+- *   details yet..
+  *
+- * Hopefully these problems do not actually matter for anything.
++ * Hopefully this problem do not actually matter for anything.
+  */
+ 
+ /*
+@@ -56,7 +54,14 @@
+ 		printk("no vm86_info: BAD\n");
+ 		do_exit(SIGSEGV);
+ 	}
++#ifdef CONFIG_CORRECT_STI
++	if (VEFLAGS & STIP_MASK)
++		set_flags(regs->eflags, VEFLAGS, STIP_MASK|VIP_MASK|TF_MASK|VIF_MASK | current->v86mask);
++	else
++		set_flags(regs->eflags, VEFLAGS, STIP_MASK|VIP_MASK|VIF_MASK | current->v86mask);
++#else
+ 	set_flags(regs->eflags, VEFLAGS, VIF_MASK | current->v86mask);
++#endif
+ 	memcpy_tofs(&current->vm86_info->regs,regs,sizeof(*regs));
+ 	put_fs_long(current->screen_bitmap,&current->vm86_info->screen_bitmap);
+ 	tmp = current->tss.esp0;
+@@ -114,6 +119,10 @@
+ 	info.regs.eflags &= SAFE_MASK;
+ 	info.regs.eflags |= pt_regs->eflags & ~SAFE_MASK;
+ 	info.regs.eflags |= VM_MASK;
++#ifdef CONFIG_CORRECT_STI
++	if ((VEFLAGS & (STIP_MASK|VIP_MASK)) == (STIP_MASK|VIP_MASK))
++		info.regs.eflags |= TF_MASK; /* single step to set IF next instruction */
++#endif
+ 
+ 	switch (info.cpu_type) {
+ 		case CPU_286:
+@@ -162,8 +171,10 @@
+ static inline void set_IF(struct vm86_regs * regs)
+ {
+ 	VEFLAGS |= VIF_MASK;
++#ifndef CONFIG_CORRECT_STI
+ 	if (VEFLAGS & VIP_MASK)
+ 		return_to_32bit(regs, VM86_STI);
++#endif
+ }
+ 
+ static inline void clear_IF(struct vm86_regs * regs)
+@@ -302,20 +313,7 @@
+ 	return;
+ }
+ 
+-void handle_vm86_debug(struct vm86_regs * regs, long error_code)
+-{
+-#if 0
+-	do_int(regs, 1, (unsigned char *) (regs->ss << 4), SP(regs));
+-#else
+-	if (current->flags & PF_PTRACED)
+-		current->blocked &= ~(1 << (SIGTRAP-1));
+-	send_sig(SIGTRAP, current, 1);
+-	current->tss.trap_no = 1;
+-	current->tss.error_code = error_code;
+-#endif
+-}
+-
+-void handle_vm86_fault(struct vm86_regs * regs, long error_code)
++static inline void vm86_gp_fault(struct vm86_regs * regs, long error_code)
+ {
+ 	unsigned char *csp, *ssp;
+ 	unsigned long ip, sp;
+@@ -360,12 +358,6 @@
+ 		set_vflags_short(popw(ssp, sp), regs);
+ 		return;
+ 
+-	/* int 3 */
+-	case 0xcc:
+-		IP(regs)++;
+-		do_int(regs, 3, ssp, sp);
+-		return;
+-
+ 	/* int xx */
+ 	case 0xcd:
+ 		IP(regs) += 2;
+@@ -387,18 +379,61 @@
+ 		return;
+ 
+ 	/* sti */
+-	/*
+-	 * Damn. This is incorrect: the 'sti' instruction should actually
+-	 * enable interrupts after the /next/ instruction. Not good.
+-	 *
+-	 * Probably needs some horsing around with the TF flag. Aiee..
+-	 */
+ 	case 0xfb:
+ 		IP(regs)++;
+-		set_IF(regs);
++		if (!(VEFLAGS & VIF_MASK)) {
++#ifdef CONFIG_CORRECT_STI
++			if (VEFLAGS & VIP_MASK) {
++				VEFLAGS |= STIP_MASK;
++
++				set_flags(VEFLAGS, regs->eflags, TF_MASK);
++
++				/* single step to set IF next instruction */
++				regs->eflags |= TF_MASK;
++
++			}
++#else
++			set_IF(regs);
++#endif
++		}
+ 		return;
+ 
+ 	default:
+ 		return_to_32bit(regs, VM86_UNKNOWN);
++	}
++}
++
++void handle_vm86_fault(struct vm86_regs * regs, long error_code, int trapno)
++{
++#ifdef CONFIG_CORRECT_STI
++	if (VEFLAGS & STIP_MASK) {
++		VEFLAGS &= ~STIP_MASK;
++
++		VEFLAGS |= VIF_MASK;
++		if (!(VEFLAGS & TF_MASK))
++			clear_TF(regs);
++	}
++#endif
++	switch (trapno) {
++#ifdef CONFIG_CORRECT_STI
++	case 1:
++		if (regs->eflags & TF_MASK)
++			/* Trap Flag was set - handle it as single step */
++			do_int(regs, trapno, (unsigned char *) (regs->ss << 4), SP(regs));
++		else
++			return_to_32bit(regs, VM86_STI);
++		return;
++#endif
++	case 13:
++		vm86_gp_fault(regs, error_code);
++#ifdef CONFIG_CORRECT_STI
++		if ((VEFLAGS & (VIP_MASK|VIF_MASK)) == (VIP_MASK|VIF_MASK))
++			return_to_32bit(regs, VM86_STI);
++#endif
++		return;
++
++	default:
++		do_int(regs, trapno, (unsigned char *) (regs->ss << 4), SP(regs));
++		return;
+ 	}
+ }
diff -u --recursive --new-file dosemu0.53old//mouse/mouse.c dosemu0.53//mouse/mouse.c
--- dosemu0.53old//mouse/mouse.c	Wed Aug 17 22:58:26 1994
+++ dosemu0.53//mouse/mouse.c	Wed Aug 24 22:14:27 1994
@@ -1,12 +1,15 @@
 /* mouse.c for the DOS emulator
  *       Robert Sanders, gt8134b@prism.gatech.edu
  *
- * $Date: 1994/08/14 02:54:28 $
+ * $Date: 1994/08/25 00:52:24 $
  * $Source: /home/src/dosemu0.60/mouse/RCS/mouse.c,v $
- * $Revision: 2.9 $
+ * $Revision: 2.10 $
  * $State: Exp $
  *
  * $Log: mouse.c,v $
+ * Revision 2.10  1994/08/25  00:52:24  root
+ * Prep for pre53_16.
+ *
  * Revision 2.9  1994/08/14  02:54:28  root
  * Rain's CLEANUP and DOS in a X box MOUSE additions.
  *
@@ -468,7 +471,9 @@
 {
   m_printf("MOUSE: set gfx cursor...hspot: %d, vspot: %d, masks: %04x:%04x\n",
 	   LWORD(ebx), LWORD(ecx), LWORD(es), LWORD(edx));
+#if 0
   gfx_cursor = TRUE;
+#endif
 }
 
 void 
@@ -476,7 +481,9 @@
 {
   m_printf("MOUSE: set text cursor...type: %d, start: 0x%04x, end: 0x%04x\n",
 	   LWORD(ebx), LWORD(ecx), LWORD(edx));
+#if 0
   gfx_cursor = FALSE;
+#endif
 }
 
 void 
@@ -763,6 +770,7 @@
   if (config.X) {
     mice->intdrv = TRUE;
     mice->type = MOUSE_X;
+    m_printf("MOUSE: X Mouse being set\n");
     return;
   }
 #endif
Binary files dosemu0.53old//periph/hdinfo and dosemu0.53//periph/hdinfo differ
Binary files dosemu0.53old//periph/mkhdimage and dosemu0.53//periph/mkhdimage differ
Binary files dosemu0.53old//periph/putrom and dosemu0.53//periph/putrom differ
diff -u --recursive --new-file dosemu0.53old//termio.c dosemu0.53//termio.c
--- dosemu0.53old//termio.c	Wed Aug 17 22:58:21 1994
+++ dosemu0.53//termio.c	Wed Aug 24 22:14:23 1994
@@ -20,11 +20,14 @@
  * DANG_BEGIN_CHANGELOG
  * Extensions by Robert Sanders, 1992-93
  *
- * $Date: 1994/08/17 02:08:22 $
+ * $Date: 1994/08/25 00:49:34 $
  * $Source: /home/src/dosemu0.60/RCS/termio.c,v $
- * $Revision: 2.11 $
+ * $Revision: 2.12 $
  * $State: Exp $
  * $Log: termio.c,v $
+ * Revision 2.12  1994/08/25  00:49:34  root
+ * Lutz's STI patches and prep for pre53_16.
+ *
  * Revision 2.11  1994/08/17  02:08:22  root
  * Mods to Rain's patches to get all modes back on the road.
  *
@@ -160,8 +163,6 @@
 extern void clear_console_video();
 extern void clear_process_control();
 void set_raw_mode();
-extern void set_console_video();
-extern void set_process_control();
 void get_leds();
 extern void DOS_setscan(u_short);
 void activate(int);
@@ -189,7 +190,7 @@
 #define put_queue(psc) (queue = psc)
 
 static void gettermcap(void),
- CloseKeyboard(void), sysreq(unsigned int), ctrl(unsigned int),
+ sysreq(unsigned int), ctrl(unsigned int),
  alt(unsigned int), Unctrl(unsigned int), unalt(unsigned int), lshift(unsigned int),
  unlshift(unsigned int), rshift(unsigned int), unrshift(unsigned int),
  caps(unsigned int), uncaps(unsigned int), Scroll(unsigned int), unscroll(unsigned int),
@@ -206,7 +207,7 @@
 
 int kbd_flag(int), child_kbd_flag(int), key_flag(int);
 
-/* initialize these in OpenKeyboard! */
+/* initialize these in keyboard_init()! */
 unsigned int child_kbd_flags = 0;
 
 int altchar = 0;
@@ -574,28 +575,26 @@
   }
 }
 
-static void
-CloseKeyboard(void)
+void
+keyboard_close(void)
 {
   if (kbd_fd != -1) {
 
     if (config.console_keyb) {
-      v_printf("CloseKeyboard:clear raw keyb\n");
+      k_printf("KBD: keyboard_close:clear raw keyb\n");
       clear_raw_mode();
     }
     if (config.console_video) {
-      v_printf("CloseKeyboard:clear console video\n");
+      k_printf("KBD: keyboard_close:clear console video\n");
       clear_console_video();
     }
 
     if (config.console_keyb || config.console_video) {
-      v_printf("CloseKeyboard: clear process control\n");
+      k_printf("KBD: keyboard_close: clear process control\n");
       clear_process_control();
     }
 
-    v_printf("CloseKeyboard: F_SETFL\n");
     fcntl(kbd_fd, F_SETFL, old_kbd_flags);
-    v_printf("CloseKeyboard: TCSETAF\n");
     ioctl(kbd_fd, TCSETAF, &oldtermio);
 
     close(kbd_fd);
@@ -614,8 +613,8 @@
  k_printf("KBD: 	c_line =%x\n", term.c_line);
 }
 
-static int
-OpenKeyboard(void)
+int
+keyboard_init(void)
 {
   struct termio newtermio;	/* new terminal modes */
   struct stat chkbuf;
@@ -696,18 +695,13 @@
   if (ioctl(kbd_fd, TCSETAF, &newtermio) < 0) {
     error("ERROR: Couldn't ioctl(STDIN,TCSETAF,...) !\n");
   }
-  if (config.console_keyb || config.console_video)
-    set_process_control();
 
   kbd_flags = 0;
   child_kbd_flags = 0;
   key_flags = 0;
 
-  if (config.console_video)
-    set_console_video();
+  dbug_printf("$Header: /home/src/dosemu0.60/RCS/termio.c,v 2.12 1994/08/25 00:49:34 root Exp root $\n");
 
-  dbug_printf("$Header: /home/src/dosemu0.60/RCS/termio.c,v 2.11 1994/08/17 02:08:22 root Exp root $\n");
-
   return 0;
 }
 
@@ -741,8 +735,6 @@
 
   buf = save_termios;
 
-  print_termios(buf);
-
   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);
@@ -751,9 +743,6 @@
   buf.c_cc[VMIN] = 1;
   buf.c_cc[VTIME] = 0;
 
-  k_printf("KBD: Setting TERMIOS Structure.\n");
-
-  print_termios(buf);
   if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &buf) < 0) { 
     k_printf("KBD: Setting to RAW mode failed.\n");
     return (-1);
@@ -761,6 +750,7 @@
   if (tcgetattr(fd, &buf) < 0) {
     k_printf("Termios ERROR\n");
   }
+  k_printf("KBD: Setting TERMIOS Structure.\n");
   print_termios(buf);
 
   return (0);
@@ -1089,14 +1079,6 @@
   struct funkeystruct *fkp;
 
   scr_state.current = 1;
-  if (OpenKeyboard() != 0) {
-    error("ERROR: can't open keyboard\n");
-    leavedos(19);
-  }
-
-#if 0
-  terminal_initialize();       /* now called from video_init() */
-#endif
 
   if (config.console_keyb) {
     set_raw_mode();
@@ -1113,15 +1095,6 @@
   for (fkp = funkey; fkp->code; fkp++) 
     numkeys++;
   qsort(funkey, numkeys, sizeof(struct funkeystruct), &fkcmp);
-}
-
-void
-termioClose()
-{
-#if 0
-  terminal_close();
-#endif
-  CloseKeyboard(); 
 }
 
 /***************************************************************
diff -u --recursive --new-file dosemu0.53old//video/Makefile dosemu0.53//video/Makefile
--- dosemu0.53old//video/Makefile	Wed Aug 17 22:58:26 1994
+++ dosemu0.53//video/Makefile	Wed Aug 24 22:14:26 1994
@@ -63,7 +63,7 @@
 	install -m 0644 $(ALL) Makefile $(DISTPATH)/video
 
 depend dep: $(CFILES) $(HFILES)
-	$(CPP) -MM $(CFLAGS) *.c $(INCDIR) > .depend
+	$(CPP) -MM $(CFLAGS) $(CFILES) $(INCDIR) > .depend
 
 dummy:
 
diff -u --recursive --new-file dosemu0.53old//video/console.c dosemu0.53//video/console.c
--- dosemu0.53old//video/console.c	Wed Aug 17 22:58:25 1994
+++ dosemu0.53//video/console.c	Wed Aug 24 22:14:26 1994
@@ -76,7 +76,7 @@
   allow_switch();
 
   if (config.vga) {
-    v_printf("VID: Taking mouse control\n");
+    k_printf("KBD: Taking mouse control\n");
     ioctl(ioc_fd, KDSETMODE, KD_GRAPHICS);
   }
 
@@ -136,7 +136,7 @@
     fprintf(stdout,"\033[?25h");        /* Turn on the cursor */
 
   if (config.console_video) {
-    v_printf("VID: Release mouse control\n");
+    k_printf("KBD: Release mouse control\n");
     ioctl(ioc_fd, KDSETMODE, KD_TEXT);
   }
 }
diff -u --recursive --new-file dosemu0.53old//video/int10.c dosemu0.53//video/int10.c
--- dosemu0.53old//video/int10.c	Wed Aug 17 22:58:25 1994
+++ dosemu0.53//video/int10.c	Wed Aug 24 22:14:26 1994
@@ -405,7 +405,12 @@
 
   case 0x4:			/* get light pen */
     error("ERROR: video error(no light pen)\n");
+#if 0
     CARRY;
+#else
+    HI(ax) = 0;   /* "light pen switch not pressed" */
+                  /* This is how my VGA BIOS behaves [rz] */
+#endif    
     return;
 
   case 0x1a:			/* get display combo */
diff -u --recursive --new-file dosemu0.53old//video/vc.c dosemu0.53//video/vc.c
--- dosemu0.53old//video/vc.c	Wed Aug 17 22:58:25 1994
+++ dosemu0.53//video/vc.c	Wed Aug 24 22:14:26 1994
@@ -21,9 +21,9 @@
  *
  * DANG_BEGIN_CHANGELOG
  *
- * $Date: 1994/08/17 02:10:31 $
+ * $Date: 1994/08/25 00:52:10 $
  * $Source: /home/src/dosemu0.60/video/RCS/vc.c,v $
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
  * $State: Exp $
  *
  * Revision 1.3  1993/10/03  21:38:22  root
@@ -156,7 +156,7 @@
 
 struct screen_stat scr_state;	/* main screen status variables */
 void release_vt(), acquire_vt();
-void get_video_ram(int), open_kmem(), set_console_video();
+void get_video_ram(int), open_kmem();
 extern int mem_fd, ioc_fd;
 
 int gfx_mode = TEXT;
@@ -214,6 +214,7 @@
   struct sigaction siga;
   void *oldalrm;
 
+  v_printf("VID: Acquiring VC\n");
   forbid_switch();
 
 #if 1
@@ -299,6 +300,7 @@
 {
   struct sigaction siga;
 
+  v_printf("VID: Releasing VC\n");
   SETSIG(siga, SIG_RELEASE, release_vt);
 
   parent_close_mouse();
@@ -576,6 +578,7 @@
 
   if (do_ioctl(ioc_fd, VT_SETMODE, (int) &vt_mode))
     v_printf("initial VT_SETMODE failed!\n");
+  v_printf("VID: Set process control\n");
 }
 
 void
diff -u --recursive --new-file dosemu0.53old//video/video.c dosemu0.53//video/video.c
--- dosemu0.53old//video/video.c	Wed Aug 17 22:58:25 1994
+++ dosemu0.53//video/video.c	Wed Aug 24 22:14:26 1994
@@ -14,7 +14,9 @@
 #include "memory.h"
 #include "video.h"
 
-void open_kmem();      /* from vc.c */
+extern void open_kmem();      /* from vc.c */
+extern void set_process_control();
+extern void set_console_video();
 
 
 int video_mode = 0;		/* Init Screen Mode in emu.c     */
@@ -39,7 +41,7 @@
 {
   /* figure out which video front end we are to use */
   
-  if (config.graphics) {
+  if (config.vga) {
      v_printf("VID: Video set to Video_graphics\n");
      Video=&Video_graphics;
   }
@@ -58,10 +60,10 @@
      Video=&Video_term;       /* ansi or ncurses */
   }
 
-  termioInit();            /* kludge! */
-
   Video->init();              /* call the specific init routine */
 
+  termioInit();            /* kludge! */
+
   if (!Video->is_mapped) {
      /* allocate screen buffer for non-console video compare speedup */
      prev_screen = (ushort *)malloc(CO * LI * 2);
@@ -73,7 +75,9 @@
      vm86s.flags |= VM86_SCREEN_BITMAP;
   }
   
+#if 0
   if (config.vga) vga_initialize();
+#endif
   clear_screen(video_page, 7);
 
   return 0;
@@ -85,7 +89,6 @@
     Video->close();
     v_printf("VID: video_close()->Video->close() called\n");
   }
-  termioClose();          /* kludge! */
 }
 
 /* load <msize> bytes of file <name> starting at offset <foffset>
@@ -118,26 +121,6 @@
 void
  video_config_init(void) {
 
-  struct stat chkbuf;
-  int major, minor;
-  fstat(STDIN_FILENO, &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)))
-  {
-    if (config.console_keyb || config.console_video)
-      error("ERROR: STDIN not a console-can't do console modes! major=%d, minor=%d\n", major, minor);
-    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;
-  }
-
   switch (config.cardtype) {
   case CARD_MDA:
     {
@@ -221,6 +204,15 @@
 
   /* copy graphics characters from system BIOS */
   load_file("/dev/kmem", GFX_CHARS, (char *) GFX_CHARS, GFXCHAR_SIZE);
+
+
+  if (config.console_keyb || config.console_video)
+    set_process_control();
+
+  if (config.console_video)
+    set_console_video();
+
+  video_init();
 
 }
 
