winedos / Fix VGA window handling and fake mickeys in mouse callback

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Okay, this patch contains two unrelated changes, but because they
are pretty small ones, I though to post them as a single patch.

First change makes VGA window handling finally work properly.
Previous patch was enough to prevent a crash but this patch should
make VGA window handling proof against strange uses of window offset.

Second change passes faked mickeys to mouse callback routine.
It should make it possible to fully use those programs that want
to use mickeys even though mouse handling will be far from perfect.
Real fix would involve either use of DirectInput or manually warping
mouse.





Changelog:
  Allow application to use VGA window that overlaps framebuffer only partially. 
  Workaround has been implemented for passing faked mickeys to mouse callback routine.





Index: dlls/winedos/vga.c
===================================================================
RCS file: /home/wine/wine/dlls/winedos/vga.c,v
retrieving revision 1.39
diff -u -r1.39 vga.c
--- dlls/winedos/vga.c	25 Aug 2003 00:53:35 -0000	1.39
+++ dlls/winedos/vga.c	29 Aug 2003 17:35:17 -0000
@@ -363,6 +363,32 @@
   int ret;
 } ModeSet;
 
+
+/**********************************************************************
+ *         VGA_SyncWindow
+ *
+ * Copy VGA window into framebuffer (if argument is TRUE) or
+ * part of framebuffer into VGA window (if argument is FALSE).
+ */
+static void VGA_SyncWindow( BOOL target_is_fb )
+{
+    int size = VGA_WINDOW_SIZE;
+
+    /* Window does not overlap framebuffer. */
+    if (vga_fb_window >= vga_fb_size)
+        return;
+
+    /* Check if window overlaps framebuffer only partially. */
+    if (vga_fb_size - vga_fb_window < VGA_WINDOW_SIZE)
+        size = vga_fb_size - vga_fb_window;
+
+    if (target_is_fb)
+        memmove( vga_fb_data + vga_fb_window, VGA_WINDOW_START, size );
+    else
+        memmove( VGA_WINDOW_START, vga_fb_data + vga_fb_window, size );
+}
+
+
 static void WINAPI VGA_DoExit(ULONG_PTR arg)
 {
     VGA_DeinstallTimer();
@@ -603,17 +629,15 @@
 
     if(vga_fb_window == -1)
         FIXME("Remove VGA memory emulation.\n");
-    else if(vga_fb_window + VGA_WINDOW_SIZE < vga_fb_size)
-        memmove(vga_fb_data + vga_fb_window, VGA_WINDOW_START,
-                VGA_WINDOW_SIZE);
+    else
+        VGA_SyncWindow( TRUE );
 
     vga_fb_window = start;
 
     if(vga_fb_window == -1)
         FIXME("Install VGA memory emulation.\n");
-    else if(vga_fb_window + VGA_WINDOW_SIZE < vga_fb_size)
-        memmove( VGA_WINDOW_START, vga_fb_data + vga_fb_window, 
-                 VGA_WINDOW_SIZE);
+    else
+        VGA_SyncWindow( FALSE );
 
     LeaveCriticalSection(&vga_lock);
 }
@@ -925,9 +949,8 @@
   /*
    * Synchronize framebuffer contents.
    */
-  if(vga_fb_window != -1 && vga_fb_window + VGA_WINDOW_SIZE < vga_fb_size)
-    memmove(vga_fb_data + vga_fb_window, VGA_WINDOW_START,
-            VGA_WINDOW_SIZE);
+  if (vga_fb_window != -1)
+      VGA_SyncWindow( TRUE );
 
   /*
    * Double VGA framebuffer (320x200 -> 640x400), if needed.




Index: dlls/winedos/int33.c
===================================================================
RCS file: /home/wine/wine/dlls/winedos/int33.c,v
retrieving revision 1.11
diff -u -r1.11 int33.c
--- dlls/winedos/int33.c	25 Aug 2003 01:01:01 -0000	1.11
+++ dlls/winedos/int33.c	29 Aug 2003 17:35:26 -0000
@@ -205,6 +205,17 @@
     data->but = mouse_info.but;
     data->x = mouse_info.x;
     data->y = mouse_info.y;
+
+    /*
+     * Fake mickeys. 
+     *
+     * FIXME: This is not entirely correct. If mouse if moved to the edge
+     *        of the screen, mouse will stop moving and mickeys won't
+     *        be updated even though they should be.
+     */
+    data->mx = mouse_info.x * (mouse_info.HMPratio / 8);
+    data->my = mouse_info.y * (mouse_info.VMPratio / 8);
+
     DOSVM_QueueEvent(-1, DOS_PRIORITY_MOUSE, MouseRelay, data);
   }
 }



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


[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux