Browse Source

* mouse support for vesa resolutions under go32v2, needs currently the define
custommouse

florian 25 years ago
parent
commit
340c0d2772
5 changed files with 246 additions and 12 deletions
  1. 203 5
      api/go32v2/mouse.inc
  2. 9 2
      api/go32v2/vesamode.pas
  3. 12 2
      api/go32v2/video.inc
  4. 12 1
      api/inc/mouse.pas
  5. 10 2
      api/inc/video.pas

+ 203 - 5
api/go32v2/mouse.inc

@@ -5,6 +5,9 @@
 }
 
 uses
+{$ifdef custommouse}
+  video,
+{$endif custommouse}
   go32;
 
 var
@@ -29,17 +32,95 @@ const
   MouseError   : longint = 0;
   CallCounter  : longint = 0;
 {$endif DEBUG}
+{$ifdef custommouse}
+  drawmousecursor : boolean = false;
+  mouseisvisible : boolean = false;
+  { position where the mouse was drawn the last time }
+  oldmousex : longint = -1;
+  oldmousey : longint = -1;
+  mouselock : boolean = false;
+
+{ if the cursor is drawn by this the unit, we must be careful }
+{ when drawing while the interrupt handler is called          }
+procedure lockmouse;assembler;
+
+  asm
+  .Ltrylockagain:
+     movb    $1,%al
+     xchgb   mouselock,%al
+     orb     %al,%al
+     jne     .Ltrylockagain
+  end;
+
+procedure unlockmouse;
+
+  begin
+     mouselock:=false;
+  end;
+{$endif custommouse}
+
+
 {$ASMMODE ATT}
 procedure MouseInt;assembler;
 asm
         movb    %bl,mousebuttons
         movw    %cx,mousewherex
         movw    %dx,mousewherey
+        shrw    $3,%cx
+        shrw    $3,%dx
+{$ifdef custommouse}
+        { should we draw the mouse cursor? }
+        cmpb    $0,drawmousecursor
+        je      .Lmouse_nocursor
+        cmpb    $0,mouseisvisible
+        je      .Lmouse_nocursor
+        pushw   %fs
+        pushl   %eax
+        pushl   %edi
+        { check lock }
+        movb    $1,%al
+        xchgb   mouselock,%al
+        orl     %al,%al
+        { don't update the cursor yet, because hide/showcursor is called }
+        jne    .Ldont_draw
+
+        { load start of video buffer }
+        movzwl  videoseg,%edi
+        shll    $4,%edi
+        movw    dosmemselector,%fs
+
+        { calculate address of old mouse cursor }
+        movzwl  oldmousey,%eax
+        imulw   screenwidth,%ax
+        addw    oldmousex,%ax
+        leal    1(%edi,%eax,2),%eax
+        { remove old cursor }
+        xorb    $0xff,%fs:(%eax)
+
+        { store position of old cursor }
+        movw    %cx,oldmousex
+        movw    %dx,oldmousey
+
+        { calculate address of new cursor }
+        movzwl  %dx,%eax
+        imulw   screenwidth,%ax
+        addw    %cx,%ax
+        leal    1(%edi,%eax,2),%eax
+        { draw new cursor }
+        xorb    $0xff,%fs:(%eax)
+
+        { unlock mouse }
+        movb    $0,mouselock
+
+.Ldont_draw:
+        popl    %edi
+        popl    %eax
+        popw    %fs
+.Lmouse_nocursor:
+{$endif custommouse}
         cmpb    MouseEventBufSize,PendingMouseEvents
         je      .Lmouse_exit
         movl    PendingMouseTail,%edi
-        shrw    $3,%cx
-        shrw    $3,%dx
         movw    %bx,(%edi)
         movw    %cx,2(%edi)
         movw    %dx,4(%edi)
@@ -282,6 +363,12 @@ begin
     end;
   If MouseCallBack=Nil then
     Mouse_Action($ffff, @MouseInt);                    { Set masks/interrupt }
+{$ifdef custommouse}
+  drawmousecursor:=false;
+  mouseisvisible:=false;
+  if (screenwidth>80) or (screenheight>50) then
+    DoCustomMouse(true);
+{$endif custommouse}
   ShowMouse;
 end;
 
@@ -313,7 +400,35 @@ asm
 end;
 
 
-procedure ShowMouse;assembler;
+procedure ShowMouse;
+{$ifdef custommouse}
+begin
+   if drawmousecursor then
+     begin
+        lockmouse;
+        if not(mouseisvisible) then
+          begin
+             oldmousex:=getmousex-1;
+             oldmousey:=getmousey-1;
+             mem[videoseg:(((screenwidth*oldmousey)+oldmousex)*2)+1]:=
+               mem[videoseg:(((screenwidth*oldmousey)+oldmousex)*2)+1] xor $ff;
+             mouseisvisible:=true;
+          end;
+        unlockmouse;
+     end
+   else
+     asm
+             cmpb    $1,MousePresent
+             jne     .LShowMouseExit
+             movl    $1,%eax
+             pushl   %ebp
+             int     $0x33
+             popl    %ebp
+     .LShowMouseExit:
+     end;
+end;
+{$else custommouse}
+assembler;
 asm
         cmpb    $1,MousePresent
         jne     .LShowMouseExit
@@ -323,9 +438,39 @@ asm
         popl    %ebp
 .LShowMouseExit:
 end;
+{$endif custommouse}
 
 
-procedure HideMouse;assembler;
+procedure HideMouse;
+{$ifdef custommouse}
+
+begin
+   if drawmousecursor then
+     begin
+        lockmouse;
+        if mouseisvisible then
+          begin
+             mouseisvisible:=false;
+             mem[videoseg:(((screenwidth*oldmousey)+oldmousex)*2)+1]:=
+               mem[videoseg:(((screenwidth*oldmousey)+oldmousex)*2)+1] xor $ff;
+             oldmousex:=-1;
+             oldmousey:=-1;
+          end;
+        unlockmouse;
+     end
+   else
+     asm
+             cmpb    $1,MousePresent
+             jne     .LHideMouseExit
+             movl    $2,%eax
+             pushl   %ebp
+             int     $0x33
+             popl    %ebp
+     .LHideMouseExit:
+     end;
+end;
+{$else custommouse}
+assembler;
 asm
         cmpb    $1,MousePresent
         jne     .LHideMouseExit
@@ -335,6 +480,7 @@ asm
         popl    %ebp
 .LHideMouseExit:
 end;
+{$endif custommouse}
 
 
 function GetMouseX:word;assembler;
@@ -399,6 +545,54 @@ asm
 .LSetMouseXYExit:
 end;
 
+{$ifdef custommouse}
+
+Procedure SetMouseXRange (Min,Max:Longint);
+begin
+  If Not(MousePresent) Then Exit;
+  asm
+        movl    $7,%eax
+        movl    min,%ecx
+        movl    max,%edx
+        pushl   %ebp
+        int     $0x33
+        popl    %ebp
+  end;
+end;
+
+Procedure SetMouseYRange (min,max:Longint);
+begin
+  If Not(MousePresent) Then Exit;
+  asm
+        movl    $8,%eax
+        movl    min,%ecx
+        movl    max,%edx
+        pushl   %ebp
+        int     $0x33
+        popl    %ebp
+  end;
+end;
+
+procedure DoCustomMouse(b : boolean);
+
+  begin
+     HideMouse;
+     lockmouse;
+     oldmousex:=-1;
+     oldmousey:=-1;
+     SetMouseXRange(0,(screenwidth-1)*8);
+     SetMouseYRange(0,(screenheight-1)*8);
+     if b then
+       begin
+          mouseisvisible:=false;
+          drawmousecursor:=true;
+       end
+     else
+       drawmousecursor:=false;
+     unlockmouse;
+  end;
+
+{$endif custommouse}
 
 const
   LastCallcounter : longint = 0;
@@ -450,7 +644,11 @@ end;
 
 {
   $Log$
-  Revision 1.1  2000-01-06 01:20:30  peter
+  Revision 1.2  2000-02-06 14:29:45  florian
+    * mouse support for vesa resolutions under go32v2, needs currently the define
+      custommouse
+
+  Revision 1.1  2000/01/06 01:20:30  peter
     * moved out of packages/ back to topdir
 
   Revision 1.2  1999/12/08 13:25:20  pierre

+ 9 - 2
api/go32v2/vesamode.pas

@@ -26,7 +26,7 @@ unit vesamode;
   implementation
 
     uses
-       dos,go32,dpmiexcp,video;
+       dos,go32,dpmiexcp,video,mouse;
 
     type
        twordarray = array[0..0] of word;
@@ -91,6 +91,9 @@ unit vesamode;
               mem[$40:$4a]:=ScreenWidth;
               memw[$40:$4c]:=ScreenHeight*((ScreenWidth shl 1)-1);
               }
+{$ifdef custommouse}
+              DoCustomMouse(true);
+{$endif custommouse}
            end;
       end;
 
@@ -131,7 +134,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.1  2000-01-06 01:20:30  peter
+  Revision 1.2  2000-02-06 14:29:45  florian
+    * mouse support for vesa resolutions under go32v2, needs currently the define
+      custommouse
+
+  Revision 1.1  2000/01/06 01:20:30  peter
     * moved out of packages/ back to topdir
 
   Revision 1.2  1999/12/23 22:37:38  pierre

+ 12 - 2
api/go32v2/video.inc

@@ -7,10 +7,10 @@
 {$ASMMODE ATT}
 
 uses
+  mouse,
   go32;
 
 var
-  VideoSeg    : word;
   OldVideoBuf : PVideoBuf;
 
   { used to know if LastCursorType is valid }
@@ -179,6 +179,9 @@ begin
   regs.bx:=wordrec(Params).hi;
   realintr($10,regs);
   defaultvideomodeselector:=true;
+{$ifdef custommouse}
+  DoCustomMouse(false);
+{$endif custommouse}
 end;
 
 function VideoModeSelector8x8(const VideoMode: TVideoMode; Params: Longint): Boolean;
@@ -199,6 +202,9 @@ begin
   ScreenColor:=true;
   ScreenWidth:=80;
   ScreenHeight:=50;
+{$ifdef custommouse}
+  DoCustomMouse(false);
+{$endif custommouse}
 end;
 
 procedure ClearScreen;
@@ -264,7 +270,11 @@ end;
 
 {
   $Log$
-  Revision 1.1  2000-01-06 01:20:30  peter
+  Revision 1.2  2000-02-06 14:29:45  florian
+    * mouse support for vesa resolutions under go32v2, needs currently the define
+      custommouse
+
+  Revision 1.1  2000/01/06 01:20:30  peter
     * moved out of packages/ back to topdir
 
   Revision 1.1  1999/11/24 23:36:38  peter

+ 12 - 1
api/inc/mouse.pas

@@ -110,6 +110,13 @@ function PollMouseEvent(var MouseEvent: TMouseEvent):boolean;
 { Checks if a Mouseevent is available, and returns it if one is found. If no
   event is pending, it returns 0 }
 
+{$ifdef go32v2}
+{$ifdef custommouse}
+{ tells the mouse unit to draw the mouse cursor itself }
+procedure DoCustomMouse(b : boolean);
+{$endif custommouse}
+{$endif go32v2}
+
 implementation
 
 { Include platform dependent routines }
@@ -136,7 +143,11 @@ end;
 end.
 {
   $Log$
-  Revision 1.1  2000-01-06 01:20:31  peter
+  Revision 1.2  2000-02-06 14:28:19  florian
+    * mouse support for vesa resolutions under go32v2, needs currently the define
+      custommouse
+
+  Revision 1.1  2000/01/06 01:20:31  peter
     * moved out of packages/ back to topdir
 
   Revision 1.2  1999/12/31 17:25:24  marco

+ 10 - 2
api/inc/video.pas

@@ -150,6 +150,10 @@ type
 
 const
   Modes: PVideoModeList = nil;
+{$ifdef go32v2}
+var
+  VideoSeg    : word;
+{$endif go32v2}
 implementation
 
 { Include system dependent part }
@@ -219,7 +223,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.1  2000-01-06 01:20:31  peter
+  Revision 1.2  2000-02-06 14:28:19  florian
+    * mouse support for vesa resolutions under go32v2, needs currently the define
+      custommouse
+
+  Revision 1.1  2000/01/06 01:20:31  peter
     * moved out of packages/ back to topdir
 
   Revision 1.1  1999/12/23 19:36:47  peter
@@ -281,4 +289,4 @@ end.
                                   Mode-switching implemented
    07/28/97   0.3.1     bazsi     added support for terminfo. remote terminal
                                   support is broken now
-}
+}