]> code.delx.au - gnu-emacs/blobdiff - src/msdos.c
Initial revision
[gnu-emacs] / src / msdos.c
index 0b738c4a050ba3081e5f7137e7d3ab2033f44e8e..55d2fc27490610631f1a56042e746f796e73d622 100644 (file)
@@ -265,7 +265,11 @@ dos_rawgetc ()
      characters like { and } if their positions are overlaid.  */
   alt_p = ((extended_kbd ? (regs.h.ah & 2) : (regs.h.al & 8)) != 0);
 
-  while (kbhit ())
+  /* The following condition is equivalent to `kbhit ()', except that
+     it uses the bios to do its job.  This pleases DESQview/X.  */
+  while ((regs.h.ah = extended_kbd ? 0x11 : 0x01),
+        int86 (0x16, &regs, &regs),
+        (regs.x.flags & 0x40) == 0)
     {
       union REGS regs;
       register unsigned char c;
@@ -779,52 +783,38 @@ init_environment (argc, argv, skip_args)
 
 /* Flash the screen as a substitute for BEEPs.  */
 
-static unsigned char _xorattr;
-
 static void
 do_visible_bell (xorattr)
      unsigned char xorattr;
 {
-  _xorattr = xorattr;
   asm volatile
-    ("  pushl  %eax
-       pushl  %ebx
-       pushl  %ecx
-       pushl  %edx
-       movl   $1,%edx
+    ("  movb   $1,%%dl
 visible_bell_0:
-       call   _ScreenRows
-       pushl  %eax
-       call   _ScreenCols
-       pushl  %eax
-       movl   _ScreenPrimary,%eax
+       movl   _ScreenPrimary,%%eax
        call   dosmemsetup
-       movl   %eax,%ebx
-       popl   %ecx
-       popl   %eax
-       imull  %eax,%ecx
-       movb   (__xorattr),%al
-       incl   %ebx
+       movl   %%eax,%%ebx
+       movl   %1,%%ecx
+       movb   %0,%%al
+       incl   %%ebx
 visible_bell_1:
-       xorb   %al,%gs:(%ebx)
-       addl   $2,%ebx
-       decl   %ecx
+       xorb   %%al,%%gs:(%%ebx)
+       addl   $2,%%ebx
+       decl   %%ecx
        jne    visible_bell_1
-       decl   %edx
+       decb   %%dl
        jne    visible_bell_3
 visible_bell_2:
-       movzwl %ax,%eax
-        movzwl %ax,%eax
-       movzwl %ax,%eax
-       movzwl %ax,%eax
-       decw   %cx
+       movzwl %%ax,%%eax
+        movzwl %%ax,%%eax
+       movzwl %%ax,%%eax
+       movzwl %%ax,%%eax
+       decw   %%cx
        jne    visible_bell_2
        jmp    visible_bell_0
-visible_bell_3:
-       popl  %edx
-       popl  %ecx
-       popl  %ebx
-       popl  %eax");
+visible_bell_3:"
+     : /* no output */
+     : "m" (xorattr), "g" (ScreenCols () * ScreenRows ())
+     : "%eax", "%ebx", /* "%gs",*/ "%ecx", "%edx");
 }
 
 /* At screen position (X,Y), output C characters from string S with
@@ -1044,7 +1034,7 @@ install_ctrl_break_check ()
   if (!ctrlbreakinstalled)
     {
       /* Don't press Ctrl-Break if you don't have either DPMI or Emacs
-        was compiler with Djgpp 1.11 maintenance level 2 or later!  */
+        was compiler with Djgpp 1.11 maintenance level 5 or later!  */
       ctrlbreakinstalled = 1;
       ctrl_break_vector.pm_offset = (int) ctrl_break_func;
       _go32_dpmi_allocate_real_mode_callback_iret (&ctrl_break_vector,
@@ -1122,7 +1112,7 @@ mouse_pressed (b, xp, yp)
   regs.x.bx = mouse_button_translate[b];
   int86 (0x33, &regs, &regs);
   if (regs.x.bx)
-    *xp = regs.x.cx / 8, *yp = regs.x.dx /8;
+    *xp = regs.x.cx / 8, *yp = regs.x.dx / 8;
   return (regs.x.bx != 0);
 }
 
@@ -1157,8 +1147,8 @@ mouse_get_pos (f, bar_window, part, x, y, time)
   *f = selected_frame;
   *bar_window = Qnil;
   gettimeofday (&tv, NULL);
-  *x = make_number (regs.x.cx);
-  *y = make_number (regs.x.dx);
+  *x = make_number (regs.x.cx / 8);
+  *y = make_number (regs.x.dx / 8);
   *time = tv.tv_usec;
   mouse_moved = 0;
 }
@@ -1184,9 +1174,22 @@ mouse_init1 ()
   union REGS regs;
   int present;
 
+  if (!internal_terminal)
+    return 0;
+
   regs.x.ax = 0x0021;
   int86 (0x33, &regs, &regs);
-  present = internal_terminal && (regs.x.ax & 0xffff) == 0xffff;
+  present = (regs.x.ax & 0xffff) == 0xffff;
+  if (!present)
+    {
+      /* Reportedly, the above doesn't work for some mouse drivers.  There
+        is an additional detection method that should work, but might be
+        a little slower.  Use that as an alternative.  */
+      regs.x.ax = 0x0000;
+      int86 (0x33, &regs, &regs);
+      present = (regs.x.ax & 0xffff) == 0xffff;
+    }
+
   if (present)
     {
       if (regs.x.bx == 3)