Collecting DOS console output

Jukka Heinonen jhei at iki.fi
Tue Apr 2 12:32:39 CST 2002


About half of the text displayed by DOS NetHack is printed
into stdout. This text is visible for a very short amount of time
before it is overwritten by contents of the VGA text buffers.
This patch redirects all writes to stdout/console through 
single function DOSVM_PutChar. This function should both update
VGA buffers and put characters into stdout. However, VGA
part is still missing.

This patch should work even though stdout does not go
to console. The patch removes some CONSOLE_ calls which
should be a good thing.

Changelog:
  Redirect DOS writes to stdout/console to DOSVM_PutChar.

Index: dosexe.h
===================================================================
RCS file: /home/wine/wine/dlls/winedos/dosexe.h,v
retrieving revision 1.4
diff -u -r1.4 dosexe.h
--- dosexe.h    19 Mar 2002 02:05:57 -0000      1.4
+++ dosexe.h    2 Apr 2002 18:09:39 -0000
@@ -79,6 +79,7 @@
 
 /* int10.c */
 extern void WINAPI DOSVM_Int10Handler(CONTEXT86*);
+extern void WINAPI DOSVM_PutChar(BYTE ascii);
 
 /* int16.c */
 extern void WINAPI DOSVM_Int16Handler(CONTEXT86*);



Index: int21.c
===================================================================
RCS file: /home/wine/wine/dlls/winedos/int21.c,v
retrieving revision 1.4
diff -u -r1.4 int21.c
--- int21.c     9 Mar 2002 23:44:32 -0000       1.4
+++ int21.c     2 Apr 2002 18:10:57 -0000
@@ -92,7 +92,7 @@
 
     case 0x02: /* WRITE CHARACTER TO STANDARD OUTPUT */
         TRACE("Write Character to Standard Output\n");
-        CONSOLE_Write(DL_reg(context), 0, 0, 0);
+        DOSVM_PutChar(DL_reg(context));
         break;
 
     case 0x06: /* DIRECT CONSOLE IN/OUTPUT */
@@ -123,7 +123,7 @@
             }
         } else {
             TRACE("Direct Console Output\n");
-            CONSOLE_Write(DL_reg(context), 0, 0, 0);
+            DOSVM_PutChar(DL_reg(context));
         }
         break;
 
@@ -162,6 +162,20 @@
             BX_reg(context) = OFFSETOF(addr);
         }
         break;
+
+    case 0x40: /* WRITE TO FILE OR DEVICE */
+        /* Writes to stdout are handled here. */
+        if (BX_reg(context) == 1) {
+          BYTE *ptr = CTX_SEG_OFF_TO_LIN(context,
+                                         context->SegDs,
+                                         context->Edx);
+          int i;
+
+          for(i=0; i<CX_reg(context); i++)
+            DOSVM_PutChar(ptr[i]);
+        } else
+          DOS3Call( context );
+        break;
 
     case 0x44: /* IOCTL */
         DOSVM_Int21Handler_Ioctl( context );



Index: int29.c
===================================================================
RCS file: /home/wine/wine/dlls/winedos/int29.c,v
retrieving revision 1.2
diff -u -r1.2 int29.c
--- int29.c     9 Mar 2002 23:44:32 -0000       1.2
+++ int29.c     2 Apr 2002 18:13:27 -0000
@@ -24,6 +24,7 @@
 
 #include "console.h"
 #include "miscemu.h"
+#include "dosexe.h"
 
 /**********************************************************************
  *         DOSVM_Int29Handler
@@ -33,6 +34,5 @@
 void WINAPI DOSVM_Int29Handler( CONTEXT86 *context )
 {
    /* Yes, it seems that this is really all this interrupt does. */
-   CONSOLE_Write(AL_reg(context), 0, 0, 0);
+   DOSVM_PutChar(AL_reg(context));
 }
-



Index: int10.c
===================================================================
RCS file: /home/wine/wine/dlls/winedos/int10.c,v
retrieving revision 1.3
diff -u -r1.3 int10.c
--- int10.c     20 Mar 2002 00:55:05 -0000      1.3
+++ int10.c     2 Apr 2002 18:13:51 -0000
@@ -27,6 +27,7 @@
 #include "vga.h"
 #include "wine/debug.h"
 #include "console.h"
+#include "dosexe.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(int);
 
@@ -548,7 +549,7 @@
               
     case 0x0e: /* TELETYPE OUTPUT */
         TRACE("Teletype Output\n");
-        CONSOLE_Write(AL_reg(context), 0, 0, 0);
+        DOSVM_PutChar(AL_reg(context));
         break;
 
     case 0x0f: /* GET CURRENT VIDEO MODE */
@@ -826,3 +827,22 @@
    }
 }
    
+
+/**********************************************************************
+ *         DOSVM_PutChar
+ *
+ */
+
+void WINAPI DOSVM_PutChar(BYTE ascii)
+{
+  BIOSDATA *data = DOSMEM_BiosData();
+  unsigned  xpos, ypos;
+
+  TRACE("char: 0x%02x\n", ascii);
+
+  // FIXME: Update VGA text buffers here...
+  WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), &ascii, 1, NULL, NULL);
+
+  VGA_GetCursorPos(&xpos, &ypos);
+  BIOS_SetCursorPos(data, 0, xpos, ypos);
+}



-- 
Jukka Heinonen <http://www.iki.fi/jhei/>



More information about the wine-patches mailing list