home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 15 / CD_ASCQ_15_070894.iso / maj / swag / mouse.swg < prev    next >
Text File  |  1994-05-26  |  94KB  |  1 lines

  1. SWAGOLX.EXE (c) 1993 GDSOFT  ALL RIGHTS RESERVED 00020         RODENT MANAGMENT ROUTINES                                         1      05-28-9313:52ALL                      SWAG SUPPORT TEAM        MOUSPIC1.PAS             IMPORT              23     l╚\ {π>    I'm interested in how to change the default mouse cursor toπ> another user defined shape.  if you know how to do that, can youπ> please post the source For it?  Thanks in advance.π}πππUsesπ  Dos, Graph;ππVarπ   Regs : Registers;ππTypeπ   CursorType = Array[0..31] of Word;   { to store the cursor shape }πππ{ define a cursor shape }πConst HourGlass : CursorType =ππ  { this specific Constant, when used in the Procedure to change the cursorπ    shape will change it to an hourglass shaped cursor.  of course you canπ    define your own cursor shape to suit your needs.π    the comments beside the hex numbers are what it will look like (binary),π    they help TREMendOUSLY in designing a cursor shape. }πππ  { Screen mask : the 0's will show up as the background colour, the 1'sπ    will show whatever is on the screen at that location }ππ   ($0001,  { 0000000000000001 }π    $0001,  { 0000000000000001 }π    $8003,  { 1000000000000011 }π    $C7C7,  { 1100011111000111 }π    $E38F,  { 1110001110001111 }π    $F11F,  { 1111000100011111 }π    $F83F,  { 1111100000111111 }π    $FC7F,  { 1111110001111111 }π    $F83F,  { 1111100000111111 }π    $F11F,  { 1111000100011111 }π    $E38F,  { 1110001110001111 }π    $C7C7,  { 1100011111000111 }π    $8003,  { 1000000000000011 }π    $0001,  { 0000000000000001 }π    $0001,  { 0000000000000001 }π    $0000,  { 0000000000000000 }ππ  { Cursor mask : the 1's will show up as white (or whatever color you haveπ    reassigned it to if you have done a SetPalette or SetRGBPalette) }ππ    $0000,  { 0000000000000000 }π    $7FFC,  { 0111111111111100 }π    $2008,  { 0010000000001000 }π    $1010,  { 0001000000010000 }π    $0820,  { 0000100000100000 }π    $0440,  { 0000010001000000 }π    $0280,  { 0000001010000000 }π    $0100,  { 0000000100000000 }π    $0280,  { 0000001010000000 }π    $0440,  { 0000010001000000 }π    $0820,  { 0000100000100000 }π    $1010,  { 0001000000010000 }π    $2008,  { 0010000000001000 }π    $7FFC,  { 0111111111111100 }π    $0000,  { 0000000000000000 }π    $0000); { 0000000000000000 }ππProcedure SetMouseCursor(HotX, HotY: Integer; Var Pattern : CursorType);πbeginπ  Regs.AX := 9;    { Function 9 }π  Regs.BX := HotX; { X-ordinate of hot spot }π  Regs.CX := HotY; { Y-ordinate of hot spot }π  { the hot spots are the co-ordinates that will show up as being whereπ    the mouse is when reading the co-ordinates of the mouse }π  Regs.DX := ofs(Pattern);π  Regs.ES := Seg(Pattern);π  Intr($33, Regs);πend;ππbeginπ   { [...initialize the Graphics screen etc...] }ππ   SetMouseCursor(7, 7, HourGlass);π   { this will set the mouse cursor to an hourglass shape With the hot spotπ     right in the centre at position 7,7 from the top left of the shape }ππ   { [...continue Program...] }πend.π                                                                 2      05-28-9313:52ALL                      SWAG SUPPORT TEAM        MOUSPIC2.PAS             IMPORT              11     l╚F {π>Hey Programmers,π>    I'm trying to change the way my mouse cursor looks in one of myπ>Programs from the standard block to an arrow.  I looked up the inFormationπ>in my interrupt list and found that I need to use Interrupt 33h (Bigπ>surprise) With AX = 0009h.  I'm ok up to this point, but the inFormationπ>lost me when is says that ES:DX->bitmap With 16 Words screen mask and 16π>Words cursor mask.  Now I know what it means and have already defined theπ>code For my curse, but how do I assign ES:DX to its value? (Source exampleπ>below).  Any help would be great and please E-MAIL it to me.  Thanksπ}ππConstπ   ArrowCursor: Array [0..31] of Word = (π        $3fff,$1fff,$fff,$7ff,$3ff,$1ff,$ff,$7f,π       $3f,$1f,$f,$7,$1847,$387f,$fc3f,$fe7f,π       $0,$4000,$6000,$7000,$7800,$7c00,$7e00,$7f00,π       $7f80,$7fc0,$7fe0,$6730,$4300,$300,$180,$0);π   HotSpotX : Word = 1;π   HotSpotY : Word = 0;πππProcedure ArrowMouse;πVar regs : Registers;πbeginπ   Regs.AX := $000A;π   Regs.BX := HotSpotX;π   Regs.CX := HotSpotY;ππ   { ES:DX -> bitmap  16 Words screen mask  16 Words cusor mask }π   Regs.ES := Seg(ArrowCursor); { Answer :) }π   Regs.DX := ofs(ArrorCursor); { Answer :) }ππ   intr($33,Regs);πend;ππ                                                                                      3      05-28-9313:52ALL                      SWAG SUPPORT TEAM        RODENT.PAS               IMPORT              51     l╚á Unit Rodent;πInterfaceπUses Dos;ππconst MDD = $33;   { mouse interupt }π                   { Interupt driven        Polled       = AX  }π      bit_0 = $01; { mouse movement         left button down   }π      bit_1 = $02; { left button pressed    right button down  }π      bit_2 = $04; { left button released   center button down }π      bit_3 = $08; { right button pressed }π      bit_4 = $10; { right button released }π      bit_5 = $20; { center pressed }π      bit_6 = $40; { center released }π      bit_7 = $80;ππtypeπ  resetRec = recordπ    exists   : Boolean;π    nButtons : Integer;π  end;π  LocRec = recordπ    buttonStatus,π    opCount,π    column,π    row       : Integer;π  end;π  moveRec = recordπ    hCount,π    vCount    : Integer;π  end;π{$F+}π  eventRec = recordπ               flag, button, col, row: Word;π             end;π{$F-}ππvar mReg     : Registers;π    theMouse : resetRec;     { Does mouse exist }π    mrecord  : locRec;       { polled record    }π    mEvent   : eventRec;     { interupt record  }ππprocedure mFixXY (x1,y1,x2,y2:integer);πfunction mouseX (n:integer) : integer;πfunction mouseY (n:integer) : integer;πprocedure mReset (VAR Mouse: resetRec);                                {  0 }πprocedure mShow;                                                       {  1 }πprocedure mHide;                                                       {  2 }πprocedure mPos (VAR Mouse: LocRec);                                    {  3 }πprocedure mMoveto (col, row: Integer);                                 {  4 }πprocedure mPressed (button: Integer; VAR Mouse: LocRec);               {  5 }πprocedure mReleased (button: Integer; VAR Mouse: LocRec);              {  6 }πprocedure mColRange (min, max : Integer);                              {  7 }πprocedure mRowRange (min, max : Integer);                              {  8 }πprocedure mGraphCursor (hHot, vHot: Integer; maskSeg, maskOfs: Word);  {  9 }πprocedure mTextCursor (ctype, p1, p2: Word);                           { 10 }πprocedure mMotion (VAR moved: moveRec);                                { 11 }πprocedure mInstTask (mask: Word);                                      { 12 }πprocedure mLpenOn;                                                     { 13 }πprocedure mLpenOff;                                                    { 14 }πprocedure mRatio (horiz, vert: Integer);                               { 15 }ππimplementationπvarπ  maxcol   : word absolute $0040:$004A;   { x }ππprocedure EventHandler(Flags,CS,AX,BX,CX,DX,SI,DI,DS,ES,BP: Word);πinterrupt;πbeginπ  mEvent.flag   := AX;π  mEvent.button := BX;π  mEvent.col    := CX;π  mEvent.row    := DX;π  inLine($8B/$E5/$5D/$07/$1F/$5F/$5E/$5A/$59/$5B/$58/$CB);πend;ππfunction Lower (n1, n2: Integer): Integer;π  beginπ    if n1 < n2 then Lower := n1 else Lower := n2;π  end;ππfunction Upper (n1, n2: Integer): Integer;π  beginπ    if n1 > n2 then Upper := n1 else Upper := n2;π  end;ππprocedure mFixXY;π  var i : integer;π  beginπ    if maxcol = 80π    then i := 3π    else i := 4;π    mColRange(pred(x1) shl i,pred(x2) shl i);π    mRowRange(pred(y1) shl 3,pred(y2) shl 3);π  end;ππfunction mouseX;π  var i : integer;π  beginπ    if maxcol = 80π    then i := 3π    else i := 4;π    mouseX := succ(n shr i);π  end;ππfunction mouseY;π  beginπ    mouseY := succ(n shr 3);π  end;ππprocedure mReset (VAR Mouse: resetRec);π  beginπ    mreg.ax := 0;π    intr(MDD, mreg);π    Mouse.exists := boolean(mreg.ax <> 0);π    Mouse.nButtons := mreg.bx;π  end;ππprocedure mShow;π  beginπ    inline($B8/$01/$00/$CD/MDD);π{    mreg.ax := 1;    }π{    intr(MDD, mreg); }π  end;ππprocedure mHide;π  beginπ    inline($B8/$02/$00/$CD/MDD);π{    mreg.ax := 2;    }π{    intr(MDD, mreg); }π  end;ππprocedure mPos (VAR Mouse: LocRec);π  beginπ    mreg.ax := 3;π    intr(MDD, mreg);π    Mouse.buttonStatus := mreg.bx;π    Mouse.column := mreg.cx;π    Mouse.row := mreg.dx;π  end;ππprocedure mMoveto (col, row: Integer);π  var i : word;π  beginπ    if maxcol = 80π    then i := 3π    else i := 4;π    mreg.ax := 4;π    mreg.cx := col shl i;π    mreg.dx := row shl i;;π    intr(MDD, mreg);π  end;ππprocedure mPressed (button: Integer; VAR Mouse: LocRec);π  beginπ    mreg.ax := 5;π    mreg.bx := button;π    intr(MDD, mreg);π    Mouse.buttonStatus := mreg.ax;π    Mouse.opCount := mreg.bx;π    Mouse.column := mreg.cx;π    Mouse.row := mreg.dx;π  end;ππprocedure mReleased (button: Integer; VAR Mouse: LocRec);π  beginπ    mreg.ax := 6;π    mreg.bx := button;π    intr(MDD, mreg);π    Mouse.buttonStatus := mreg.ax;π    Mouse.opCount := mreg.bx;π    Mouse.column := mreg.cx;π    Mouse.row := mreg.dx;π  end;ππprocedure mColRange (min, max : Integer);π  beginπ    mreg.ax := 7;π    mreg.cx := Lower(min, max);π    mreg.dx := Upper(min, max);π    intr(MDD, mreg);π  end;ππprocedure mRowRange (min, max : Integer);π  beginπ    mreg.ax := 8;π    mreg.cx := Lower (min, max);π    mreg.dx := Upper (min, max);π    intr(MDD, mreg);π  end;ππprocedure mGraphCursor (hHot, vHot: Integer; maskSeg, maskOfs: Word);π  beginπ    mreg.ax := 9;π    mreg.bx := hHot;π    mreg.cx := vHot;π    mreg.dx := maskOfs;π    mreg.es := maskSeg;π    intr(MDD, mreg);π  end;ππprocedure mTextCursor (ctype, p1, p2: Word);π  beginπ    mreg.ax := 10;π    mreg.bx := ctype;       { 0=software, 1=hardware          }π    mreg.cx := p1;          { 0=and mask else start line      }π    mreg.dx := p2;          { 0=xor mask else Cursor end line }π    intr(MDD, mreg);π  end;ππ{ Returns mouse displacement in mickeys since last call }πprocedure mMotion (VAR moved: moveRec);π  beginπ    mreg.ax := 11;π    intr(MDD, mreg);π    moved.hCount := mreg.cx;π    moved.vCount := mreg.dx;π  end;ππprocedure mInstTask;π  beginπ    mreg.ax := 12;π    mreg.cx := mask;         { see bit constants above }π    mreg.dx := Ofs(EventHandler);π    mreg.es := Seg(EventHandler);π    intr(MDD, mreg);π  end;ππprocedure mLpenOn;π  beginπ    mreg.ax := 13;π    intr(MDD, mreg);π  end;ππprocedure mLpenOff;π  beginπ    mreg.ax := 14;π    intr(MDD, mreg);π  end;ππprocedure mRatio (horiz, vert: Integer);π  beginπ    mreg.ax := 15;π    mreg.cx := horiz;π    mreg.dx := vert;π    intr(MDD, mreg);π  end;ππ{ Sample base line program...π  mReset(theMouse);π  if theMouse.existsπ  then minstTask(15);      (* for 80x25 *)π  mFixXY(1,1,succ(lo(windmax)),succ(hi(windmax)));π  mEvent.Flag := 0;π<< do the program >>π  mReset(theMouse);π}πEND.ππ            4      08-17-9308:46ALL                      SWAG SUPPORT TEAM        A Compelte Mouse Unit    IMPORT              27     l╚H) UNIT Mouse;ππ{Program:   Master Mouse Routine Library}ππINTERFACEππUSES DOS;ππCONSTππ  {Button press definitions}ππ   PrL = 1;π   PrR = 2;π   PrLr = 3;π   PrM = 4;π   PrLM = 5;π   PrMR = 6;π   PrAll = 7;π   PrNone = 0;ππ  {Button definitions}ππ   ButtonLeft = 0;π   ButtonRight = 1;π   ButtonMiddle = 2;πππFUNCTION ThereIsAMouse: Boolean;πFUNCTION MouseReset: Boolean;πFUNCTION GetMouseStatusπ         (VAR MPosX, MPosY: Byte): Byte;ππPROCEDURE ClearButton (Button: Byte);πPROCEDURE MouseOn;πPROCEDURE MouseOff;πPROCEDURE SetMouseSoftCursorπ   (MouseChar, MouseFGColor, MouseBGColor: Byte);ππIMPLEMENTATIONππCONSTπ   MouseIntr = $33;ππVARπ   MouseVisible             : Boolean;π   MHMax, MVMax, MHCell, MVCell     : Word;π   Regs : Registers;ππPROCEDURE MouseHandler (A, B, C, D: Byte);π   BEGINπ      WITH Regs DOπ            BEGINπ                ax := A;π                bx := B;π                cx := C;π                dx := D;π                Intr(MouseIntr, Regs)π            ENDπ   END;ππFUNCTION GetButtonUpStatusπ  (Button: Byte;VAR MPosX, MPosY: Word): Boolean;ππ   BEGINπ      WITH Regs DOπ            BEGINπ                ax := 6;π                bx := Button;π                MouseHandler(ax, bx, 0, 0);π                MPosX := cx DIV MHCell + 1;π                MPosY := dx DIV MVCell + 1;π                IF ax = 0 THENπ                    GetButtonUpStatus := TRUEπ                ELSEπ                    GetButtonUpStatus := FALSEπ            ENDπ   END;ππPROCEDURE ClearButton (Button: Byte);πVARπ   MPosX,MPosY: Word;ππ   BEGINπ      REPEAT UNTILπ          GetButtonUpStatus(Button, MPosX,MPosY)π   END;ππFUNCTION GetMouseStatusπ         (VAR MPosX, MPosY: Byte): Byte;π   BEGINπ      WITH Regs DOπ            BEGINπ                ax := 3;π                MouseHandler(ax, 0, 0, 0);π                GetMouseStatus := bx;π                MPosX := cx DIV MHCell + 1;π                MPosY := dx DIV MVCell + 1π            ENDπ   END;ππPROCEDURE MouseOff;π   BEGINπ      IF MouseVisible THENπ            BEGINπ                MouseHandler(2, 0, 0, 0);π                MouseVisible := FALSEπ            ENDπ   END;ππPROCEDURE MouseOn;π   BEGINπ      IF NOT MouseVisible THENπ            BEGINπ                MouseHandler(1, 0, 0, 0);π                MouseVisible := TRUEπ            ENDπ   END;ππFUNCTION MouseReset: Boolean;π   BEGINπ      MHMax := 639; {Max virtual horizontal pos}π      MVMax := 199; {Max virtual vertical pos}π      MHCell := 8;  {Mouse horizontal cell width}π      MVCell := 8;  {Mouse vertical cell height}π      MouseHandler(0, 0, 0, 0);π      IF Regs.ax = 0 THENπ         MouseReset := FALSEπ      ELSEπ         MouseReset := TRUE;π            MouseVisible := FALSEπ   END;ππPROCEDURE SetMouseSoftCursorπ   (MouseChar, MouseFGColor, MouseBGColor: Byte);π   BEGINπ      MouseOn;π      Regs.ax := 10;π      Regs.bx := 0; {Select software cursor}π   {Screen Mask Value (don't change character)}π      Regs.cx := $8800;π      Regs.dx := $8800 + MouseBGColor * 4096 +π                  MouseFGColor * 256 + MouseChar;π      Intr($33,Regs);π      MouseOffπ   END;ππFUNCTION ThereIsAMouse: Boolean;πCONSTπ   IRET = 207;πVARπ   MouseSegment : Word ABSOLUTE $0000:$00CE;π   MouseOffset : Word ABSOLUTE $0000:$00CC;π   MouseInstruction: Byte;π   BEGINπ      IF (MouseSegment = 0) ANDπ           (MouseOffset = 0) THENπ         ThereIsAMouse := FALSEπ      ELSEπ            BEGINπ                MouseInstruction :=π                   MEM[MouseSegment:MouseOffset];π                IF MouseInstruction = IRET THENπ                    ThereIsAMouse := FALSEπ                ELSEπ                    ThereIsAMouse := TRUEπ            ENDπ   END;ππ{No initialization section}ππEND.π                                                                                           5      08-27-9321:38ALL                      RAPHAEL VANNEY           Set Mouse Cursor         IMPORT              7      l╚ì {πRAPHAEL VANNEYππ> Can anybody help me out on the Function INT 33 - 9/8. It's the set mouseπ> cursor Function. I see that you can draw your own mouse cursor, but I don'tπ> understand how to move a bitmap into Es:Dx. I don't know the size forπ> the bit map to be, or the dimensions. Could anybody help me out?π}ππConst Disque : Array [0..31] of Word =π      (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,π       0,32766,32766,32760,32760,32766,32382,31806,π       31806,32382,32766,32382,32382,32382,32766,0);ππProcedure CurseurSouris(Var Motif; x, y : Word); Assembler;πAsmπ  Mov  AX, 9     { set cursor shape }π  Mov  BX, xπ  Mov  CX, yπ  LES  DX, Motifπ  Int  $33πend ;ππbeginπ  { ... }π  CurseurSouris(Disque, 8, 8);π  { ... }πend.π                                             6      08-27-9321:38ALL                      MIKE BURNS               The easy Mouse unit      IMPORT              7      l╚'ë {πMIKE BURNSππ> How did you get a mouse Pointer into your Program?π}πππProcedure Clear_Regs;πbeginπ  FillChar(Regs, SizeOf(Regs), 0);πend;πππFunction InitMouse : Boolean;πbeginπ  Clear_Regs;ππ  Regs.AX := 00;π  Intr ($33, Regs);π  if Regs.AX <> 0 then            { if not 0 then YES THERE IS A MOUSE }π  beginπ    InitMouse := True;π    MbutS     := BX;              { Number of buttons on the mouse }π  endπ  elseπ  beginπ    InitMouse := False;π    Mbuts     := 0;π  end;πend;πππProcedure ShowMouse;π beginπ  Clear_Regs;π  Regs.AX := 01;π  Intr ($33, Regs);πend;ππProcedure HideMouse;π beginπ  Clear_Regs;π  Regs.AX := 02;π  Intr ($33, Regs);πend;π                                                                                                                      7      09-26-9309:18ALL                      RICHARD SADOWSKY         The "Classic" mouse unit IMPORT              38     l╚²¿ Unit Mouse4;ππ{*******************************************************************}π{*                   Mouse4 - Text Mouse Unit                      *}π{*                     version .9, 11/20/87                        *}π{*                by Richard Sadowsky 74017,1670                   *}π{*                 released to the public domain                   *}π{*******************************************************************}ππInterfaceππUses DOS;ππconstπ  CURPOS           = 1; { not used yet in this version }π  LEFTPRESS        = 2;π  LEFTREL          = 4;π  RIGHTPRESS       = 8;π  RIGHTREL         = 16;ππvarπ  Mouse_Reg        : Registers;π  Mouse_Installed  : Boolean;π  Mouse_Error      : Word;ππfunction InitMouse : Word;π{ Function 0 - Initialize mouse software and hardware }ππprocedure ShowMouse;π{ function 1 - show mouse cursor }ππprocedure HideMouse;π{ function 2 - hide mouse cursor }ππfunction MousePosition(var MouseX,MouseY : Word) : Word;π{ function 3 - return mouse position and button status }π{ X and Y values scaled for 80 col text mode }ππprocedure setmouseposition(mousex, mousey: Word);π{ function 4 - sets mouse position  }π{ X and Y values scaled for 80 col text mode }ππfunction mousepress(button: Word;π                     var count, lastx, lasty: Word): Word;π{ function 5 - gets button press information  }π{ X and Y values scaled for 80 col text mode }ππfunction mouserelease(button: Word;π                       var count, lastx, lasty: Word): Word;π{ function 6 - gets button release information  }π{ X and Y values scaled for 80 col text mode }ππprocedure setmousexy(x1,y1,x2,y2: Word);π{ functions 7 and 8 - sets min/max values for horizontal/vertical  }π{ X and Y values scaled for 80 col text mode }ππprocedure restoremousexy;π{ functions 7 and 8 - restores min/max values for CGA screen }ππprocedure SetPixeltoMickey(Horiz,Verti : Word);π{ function 15 - sets the mickey to pixel ratio }ππimplementationππfunction InitMouse : Word;π{ Function 0 - Initialize mouse software and hardware }πbeginπ  with Mouse_Reg doπ    Ax := 0;π  Intr($33,Mouse_Reg);π  InitMouse := Mouse_Reg.Ax;πend;ππprocedure ShowMouse;π{ function 1 - show mouse cursor }πbeginπ  Mouse_Reg.Ax := 1;π  Intr($33,Mouse_Reg);πend;ππprocedure HideMouse;π{ function 2 - hide mouse cursor }ππbeginπ  Mouse_Reg.AX := 2;π  Intr($33,Mouse_Reg);πend;ππfunction MousePosition(var MouseX,MouseY : Word) : Word;π{ function 3 - return mouse position and button status }π{ X and Y values scaled for 80 col text mode }πbeginπ  Mouse_Reg.Ax := 3;π  Intr($33,Mouse_Reg);π  with Mouse_Reg do beginπ    MouseX := Succ(Cx DIV 8);π    MouseY := Succ(Dx DIV 8);π    MousePosition := Bx;π  end;πend;ππprocedure setmouseposition(mousex, mousey: Word);π{ function 4 - sets mouse position  }π{ X and Y values scaled for 80 col text mode }πbeginπ  Mouse_Reg.ax:=4;π  Mouse_Reg.cx:=Pred(mousex*8);π  Mouse_Reg.dx:=Pred(mousey*8);π  intr($33,Mouse_Reg);πend;ππfunction mousepress(button: Word;π                     var count, lastx, lasty: Word): Word;π{ function 5 - gets button press information  }π{ X and Y values scaled for 80 col text mode }πbeginπ  Mouse_Reg.ax:=5;π  Mouse_Reg.bx:=button;π  intr($33,Mouse_Reg);;π  mousepress:=Mouse_Reg.ax;π  count:=Mouse_Reg.bx;π  lastx:=Succ(Mouse_Reg.cx div 8);π  lasty:=Succ(Mouse_Reg.dx div 8);πend;ππfunction mouserelease(button: Word;π                       var count, lastx, lasty: Word): Word;π{ function 6 - gets button release information  }π{ X and Y values scaled for 80 col text mode }πbeginπ  Mouse_Reg.ax:=6;π  Mouse_Reg.bx:=button;π  intr($33,Mouse_Reg);;π  mouserelease:=Mouse_Reg.ax;π  count:=Mouse_Reg.bx;π  lastx := Succ(Mouse_Reg.cx div 8);π  lasty := Succ(Mouse_Reg.dx div 8);πend;ππprocedure setmousexy(x1,y1,x2,y2: Word);π{ functions 7 and 8 - sets min/max values for horizontal/vertical  }π{ X and Y values scaled for 80 col text mode }πbeginπ  Mouse_Reg.ax:=7;π  Mouse_Reg.cx:=Pred(x1*8);π  Mouse_Reg.dx:=Pred(x2*8);π  intr($33,Mouse_Reg);π  Mouse_Reg.ax:=8;π  Mouse_Reg.cx:=Pred(y1*8);π  Mouse_Reg.dx:=Pred(y2*8);π  intr($33,Mouse_Reg);πend;ππprocedure restoremousexy;π{ functions 7 and 8 - restores min/max values for CGA screen }πbeginπ  Mouse_Reg.ax:=7;π  Mouse_Reg.cx:=0;π  Mouse_Reg.dx:=639;π  intr($33,Mouse_Reg);π  Mouse_Reg.ax:=8;π  Mouse_Reg.cx:=0;π  Mouse_Reg.dx:=199;π  intr($33,Mouse_Reg);πend;ππprocedure SetPixeltoMickey(Horiz,Verti : Word);π{ function 15 - sets the mickey to pixel ratio }ππbeginπ  with Mouse_Reg do beginπ    Ax := 15;π    Cx := Horiz;π    Dx := Verti;π  end;π  Intr($33,Mouse_Reg)πend;ππbeginπ  Mouse_Error := InitMouse;π  Mouse_Installed := Mouse_Error = 65535;πend.π                                                                             8      10-28-9311:25ALL                      GAYLE DAIVS              A GOOD Mouse Unit        IMPORT              26     l╚,{ πUNIT AMOUSE; (* mouse/keyboard Routines *)ππINTERFACEππCONSTπ          MouseInstalled : Boolean = FALSE;ππFUNCTION  InitMouse : WORD;πPROCEDURE ShowMouseCursor;πPROCEDURE HideMouseCursor;πPROCEDURE SetMouseWindow (X1, Y1, X2, Y2 : WORD);πPROCEDURE GetMousePos (VAR X, Y, button : WORD);πPROCEDURE SetMousePos (X, Y : WORD);πPROCEDURE GetButtonPressInfo (VAR X, Y, Button, NumberOfPresses : WORD);πPROCEDURE GetButtonRelInfo (VAR X, Y, Button, NumberOfReleases : WORD);πPROCEDURE KeyOrButton (VAR Code, X, Y, Button : WORD; VAR Ch : CHAR);πFUNCTION  KEYPRESSED : BOOLEAN;πFUNCTION  MousePRESSED : BOOLEAN;πFUNCTION  MouseORKeyPRESSED : BOOLEAN;ππIMPLEMENTATIONππUSES DOS;ππCONSTππ  MIO    = $33;  (* Mouse Services       *)π  KBIO   = $16;  (* BIOS Keyboard        *)ππVARπ   X, Y : WORD;π   reg  : REGISTERS;πππFUNCTION KEYPRESSED : BOOLEAN; Assembler;πASMπ  PUSH DSπ  MOV AX, 40hπ  MOV DS, AXπ  CLIπ  MOV AX, [1Ah]π  CMP AX, [1Ch]π  STIπ  MOV AX, 0π  JZ @NoPressπ  INC AXπ  @NoPress :π  POP DSπEND;πππFUNCTION PollKey (VAR Status : WORD) : WORD;πVAR s : WORD;πBEGINπ  asmπ    MOV AH, 01π    INT KBIOπ    MOV @Result, AXπ    LAHFπ    AND AX, 64π    MOV S, AXπ  END;π  Status := s;πEND;ππFUNCTION MousePressed : BOOLEAN;πVAR B : WORD;π  BEGINπ  Asmπ    MOV AX, $0003π    INT $33π    MOV B,  BXπ  END;π  MousePressed := (B <> 0);π  END;ππFUNCTION MouseORKeyPressed : BOOLEAN;πVAR B : WORD;π  BEGINπ  Asmπ    MOV AX, $0003π    INT $33π    MOV B,  BXπ  END;π  MouseORKeyPressed := (B <> 0) OR KeyPressed;π  END;ππPROCEDURE KeyOrButton (VAR Code, X, Y, Button : WORD; VAR Ch : CHAR);π (* wait for key or mouse click and returns data *)πVAR Status : WORD;πBEGINπ  REPEATπ    Code := PollKey (Status);π    GetMousePos (X, Y, Button);π  UNTIL (Button <> 0) OR (Status = 0);ππ  IF (LO (Status) = 0) AND (HI (Status) <> 0) THENπ        Ch := CHR ( HI (Status) + 128 )π      ELSEπ        Ch := CHR (LO (Status) );πEND;ππFUNCTION InitMouse : WORD;πBEGINπ  Asmπ    MOV AX, $0000π    INT MIOπ    MOV @Result, AXπ  END;πEND;ππPROCEDURE ShowMouseCursor; Assembler;πAsmπ  MOV AX, $0001π  INT MIOπEND;ππPROCEDURE HideMouseCursor; Assembler;πAsmπ  MOV AX, $0002π  INT MIOπEND;ππPROCEDURE GetMousePos (VAR X, Y, Button : WORD);πVAR X1, Y1, b : WORD;πBEGINπ  Asmπ    MOV AX, $0003π    INT MIOπ    MOV b,  BXπ    MOV X1, CXπ    MOV Y1, DXπ  END;π  X := X1;π  Y := Y1;π  Button := b;πEND;ππPROCEDURE SetMousePos (X, Y : WORD); Assembler;πAsmπ  MOV AX, $0004π  MOV CX, Xπ  MOV DX, Yπ  INT MIOπEND;ππPROCEDURE GetButtonPressInfo (VAR X, Y, Button, NumberOfPresses : WORD);πBEGINπ  reg. AX := $0005;π  reg. BX := Button;π  INTR (MIO, reg);π  Button := reg. AX;π  X := reg. CX;π  Y := reg. DX;π  NumberOfPresses := reg. BXπEND;ππPROCEDURE GetButtonRelInfo (VAR X, Y, Button, NumberOfReleases : WORD);πBEGINπ  reg. AX := $0006;π  reg. BX := Button;π  INTR (MIO, reg);π  Button := reg. AX;π  X := reg. CX;π  Y := reg. DX;π  NumberOfReleases := reg. BXπEND;ππPROCEDURE SetMouseWindow (X1, Y1, X2, Y2 : WORD);πBEGINπ  reg. AX := $0007;π  reg. CX := X1;π  reg. DX := X2;π  INTR ($33, reg);π  INC (reg. AX, 1);π  reg. CX := Y1;π  reg. DX := Y2;π  INTR (MIO, reg)πEND;ππBEGINπ  MouseInstalled := (InitMouse <> 0);πEND.               9      11-02-9317:39ALL                      LOU DUCHEZ               Mouse Library            IMPORT              49     l╚╬ {πFrom: LOU DUCHEZπSubj: mouse Libraryπ}ππunit mouse;πinterface                                 { "Global" declarations }πvar mouseexist, mousecursoron: boolean;   { Is a mouse hooked up? / Is the    }πprocedure mouseinit;                      {   mouse cursor "on"?              }πprocedure mouseon;πprocedure mouseoff;πfunction mousex: word;                    { Note about coordinates: these     }πfunction mousey: word;                    {  routines return values starting  }πfunction mouseleft: boolean;              {  at 0, not 1 (even in text mode). }πfunction mousemiddle: boolean;            {  So for text mode, you may want   }πfunction mouseright: boolean;             {  to modify a bit ...              }πprocedure setmousexy(newx, newy: word);πprocedure limitmouse(lox, loy, hix, hiy: word);πππimplementation                            { internal workings }πuses dos;πvar regs: registers;                      { Used for the "mouse" interrupts }π    xshift, yshift: byte;                 { Depending on your video mode, you }π                                          {  may need to convert "mouse"      }π                                          {  coordinates to / from "video"    }πprocedure calcshifts;                     {  coordinates.  It's a matter of   }πvar tempregs: registers;                  {  shifting left/right; xshift      }πbegin                                     {  records how to shift the "X",    }π  tempregs.ah := $0f;                     {  and yshift records for the "Y".  }π  intr($10, tempregs);                    { Procedure CalcShifts figures out  }π  case tempregs.al of                     {  what text mode you're in and how }π    0, 1, 2, 3, 7: begin                  {  much to shift by.  It gets the   }π      xshift := 3;                        {  video mode w/interrupt $10/$0f;  }π      yshift := 3;                        {  modes 0, 1, 2, 3 and 7 are text  }π      end;                                {  modes.  4, 5, $0d and $13 are    }π    4, 5, $0d, $13: begin                 {  320 x 200 graphics modes.  All   }π      xshift := 1;                        {  other graphics modes are okay    }π      yshift := 0;                        {  "as is", although come to think  }π      end;                                {  of it I had a CGA system when I  }π    else begin                            {  wrote this library and thus      }π      xshift := 0;                        {  couldn't text VGA modes ...      }π      yshift := 0;π      end;π    end;π  end;πππprocedure mouseinit;                  { Initializes mouse -- determines if   }πbegin                                 { one is present, then figures out the }π  regs.ax := $0000;                   { shifts, and initializes the "cursor" }π  intr($33, regs);                    { variable to "false". }π  mouseexist := (regs.ax = $FFFF);π  if mouseexist then calcshifts;      { Called automatically on startup; you }π  mousecursoron := false;             { should call it if you change video   }π  end;                                { modes in the program. }πππprocedure mouseon;                    { Turns cursor ON. }πbeginπ  if mouseexist then begin            { Note: you really should "pair" each }π    regs.ax := $0001;                 {  "on" with an "off"; if you don't,  }π    intr($33, regs);                  {  the PC can get confused. }π    mousecursoron := true;π    end;π  end;πππprocedure mouseoff;                   { Turns cursor OFF.  Note: when writing }πbegin                                 {  to the screen, you typically want to }π  if mouseexist then begin            {  turn the cursor OFF: the PC isn't    }π    regs.ax := $0002;                 {  smart enough to say, "I'm writing a  }π    intr($33, regs);                  {  character right where the mouse      }π    mousecursoron := false;           {  cursor is: better make it inverse    }π    end;                              {  video".  So you need to shut it off. }π  end;πππfunction mousex: word;                { Gets the current mouse column. }πvar tempword: word;πbeginπ  if mouseexist then beginπ    regs.ax := $0003;π    intr($33, regs);π    tempword := regs.cx;π    endπ   elseπ    tempword := 0;π  mousex := tempword shr xshift;      { one of those funky "shift" things }π  end;ππfunction mousey: word;                { Gets the current mouse row. }πvar tempword: word;πbeginπ  if mouseexist then beginπ    regs.ax := $0003;π    intr($33, regs);π    tempword := regs.dx;π    endπ   elseπ    tempword := 0;π  mousey := tempword shr yshift;π  end;πππfunction mouseleft: boolean;      { Is the left button down? }πvar tempword: word;πbeginπ  if mouseexist then beginπ    regs.ax := $0003;π    intr($33, regs);π    tempword := regs.bx;π    endπ   elseπ    tempword := 0;π  mouseleft := mouseexist and (1 and tempword = 1);π  end;πππfunction mousemiddle: boolean;    { Is the middle button down? }πvar tempword: word;πbeginπ  if mouseexist then beginπ    regs.ax := $0003;π    intr($33, regs);π    tempword := regs.bx;π    endπ   elseπ    tempword := 0;π  mousemiddle := mouseexist and (4 and tempword = 4);π  end;πππfunction mouseright: boolean;     { Is the right button down? }πvar tempword: word;πbeginπ  if mouseexist then beginπ    regs.ax := $0003;π    intr($33, regs);π    tempword := regs.bx;π    endπ   elseπ    tempword := 0;π  mouseright := mouseexist and (2 and tempword = 2);π  end;πππprocedure setmousexy(newx, newy: word);   { Position mouse cursor. }πbeginπ  regs.ax := $0004;π  regs.cx := newx shl xshift;             { Shifts to get it into "mouse" }π  regs.dx := newy shl yshift;             {  coordinates. }π  intr($33, regs);π  end;πππprocedure limitmouse(lox, loy, hix, hiy: word);   { Restrict mouse movements. }πbeginπ  regs.ah := $0f;π  intr($10, regs);π  regs.ax := $0007;π  regs.cx := lox shl xshift;π  regs.dx := hix shl xshift;π  intr($33, regs);π  regs.ax := $0008;π  regs.cx := loy shl yshift;π  regs.dx := hiy shl yshift;π  intr($33, regs);π  end;πππbegin                 { Startup code: initializes mouse and gets video mode. }π  mouseinit;π  end.π                                        10     11-21-9309:42ALL                      FRED JOHNSON             Mouse Tutor              IMPORT              38     l╚⌠ {πFrom: FRED JOHNSONπSubj: Mousey Control..πCan someone out there please explain how to read from the mouse?π}ππ{Explanation below in reference table}πUSES dos,crt;ππVARπ M1,M2,M3,M4 : word;π Regs        : Registers;  { MS DOS Registers }π satisfied   : boolean;    { if mouse pos and button are together }ππPROCEDURE mouse( var M1,M2,M3,M4 : word );π  beginπ    With Regs DOπ      beginπ        AX := M1; BX := M2; CX := M3; DX := M4;π      end;π    intr($33,Regs); { Interrupt $33, the mouse interrupt }π    With Regs DOπ      beginπ        M1 := AX; M2 := BX; M3 := CX; M4 := DX;π      end;π  end;ππPROCEDURE initmouse;π  beginπ    M1 := 1 ; Mouse( M1,M2,M3,M4 ) { Set mouse cursor ON }π  end;ππBEGINπ  satisfied := false;π  textcolor(7); { Grey }π  clrscr;π  initmouse;π while not keypressed do { until  KEYBOARD key is pressed }π    beginπ     M1 := 3;π      MOUSE(m1,M2,M3,M4);π      IF (M2 and 1) <> 0 thenπ        begin                { if left button pressed }π          writeln(' Left Button');π          write(' M3 =',M3 div 8); write(' M4 =',M4 div 8);π        end;π      if (M2 and 2) <> 0 thenπ        begin                { if rght button pressed }π          writeln(' Right Button');π          write(' M3 =',M3 div 8); write(' M4 =',M4 div 8);π        end;π      if (M2 and 4) <> 0 then                      {if midlbutton pressed}π        beginπ          M1 := 4; M2 := 0; M3 := 30*8; M4 := 11*8; {Sets MCursor out of }π          mouse( M1,M2,M3,M4 );                     {the way }π          gotoxy(25,10); write('***************');π          gotoxy(25,11); write('* ');textcolor(14);π          write('C'); textcolor(07); write('learscreen *');π          gotoxy(25,12); write('* '); textcolor(14);π          write('Q'); textcolor(07); write('uit        *');π          gotoxy(25,13); write('***************');π          repeatπ            M1 := 3;π            mouse(M1,M2,M3,M4);π            if (M3 div 8) = 26 then                 { Tests X position }π              if (M4 div 8) = 10 then               { Tests Y position }π                if (M2 and 1) <> 0 then             { Tests lft button }π                  beginπ                    satisfied := true;π                    M1 := 4; M2  := 0; M3 :=0; M4 :=0;{MCursor out of way}π                    mouse( M1,M2,M3,M4 );π                    clrscr;π                  end;ππ            if (M3 div 8) = 26 then                { Tests X position }π              if (M4 div 8) = 11 then              { Tests Y position }π                if (M2 and 1) <> 0 then            { Tests lft button }π                  beginπ                    satisfied := true;π                    M1 := 0; M2 :=0; M3 :=0; M4 := 0;  { Turn Mouse Off }π                    mouse( M1,M2,M3,M4 );π                    clrscr;π                    halt;π                  end;ππ          until satisfied = true;π          clrscr;π          end;π          satisfied := false;π   end;π   M1 := 0;                                            { Turn Mouse Off }π   mouse(M1,M2,M3,M4);πEND.ππReference Tableπ  M1 M2 M3 M4π  1  0  0  0   = Turn Mouse on with cursor.π  2  0  0  0   = Turn Mouse Off.π  3  ?  ?  ?   = To see if buttons are pressed.π                  Test registers with logical AND   (M2 is BX register)π                  M2 and 1 = Left Buttonπ                  M2 and 2 = Right Buttonπ                  M2 and 3 = Left and Right Buttonsπ                  M2 and 4 = Middle Buttonπ                  M2 and 5 = Left and Middle Buttonsπ                  M2 and 6 = Right and Middle Buttonsπ                  M2 and 7 = Left, Middle and Right Buttonsππ  3  0  X  Y  = Get Mouse Cursor position.π                 M3 (CX) will return Mouse X coordinates. (0  =left wall)π                 M4 (DX) will return Mouse Y coordinates. (632= rght wall)π                 Divide by 8 and add 1 for Turbo Pascal XY position.ππ  4  0  X  Y  = Set Mouse Cursor position.π                 M3 (CX) set for Mouse X coordinate.      (0  = left wall)π                 M4 (DX) set for Mouse Y coordinate.      (632= rght wall)ππ  6  ?  0  0  = Mouse Button Release Status.             M2(BX)set if Trueππ                          Assembly Language Exampleπmov ax,0001   ; (M1 := 1)πint 33h       ; Set Mouse cursor ONπhere:         ;πmov ax,0003   ; (M1 := 3)πint 33h       ; Test for mouse Keypressπand bx,1      ; left button?πjne lft       ;πmov ax,0003   ;πint 33h       ;πand bx,2      ; right button?πjne rht       ;πmov ax,0003   ;πint 33h       ;πand bx,4      ; middle button?πjne mid       ;πjmp here      ; if not keep loopingπlft:          ;πmov dx,lft_st ; address of string if left buttonπjmp prnt      ;πrht:          ;πmov dx,rht_st ; address of string if right buttonπ                     11     11-26-9317:15ALL                      SWAG SUPPORT TEAM        Rodent Control           IMPORT              129    l╚k UNIT Mouse;π{*****************************************************************************}π                               INTERFACEπ{*****************************************************************************}πUSES DOS;ππTYPE mouse_cursor_mask = RECORDπ                         screen_mask : ARRAY[0..7] OF BYTE;π                         cursor_mask : ARRAY[8..15] OF BYTE;π                         END;ππCONST on = TRUE;πCONST off = FALSE;πCONST left = $00;πCONST right = $01;ππCONST change_in_cursor_position = $0001;         {call masks for user defined}πCONST left_button_pressed = $0002;               {input mask and swap vectors}πCONST left_button_released = $0004;πCONST right_button_pressed = $0008;πCONST right_button_released = $0010;ππCONST alternate_key_pressed = $0001;   {call masks for alternate user handlers}πCONST control_key_pressed = $0002;πCONST shift_button_pressed = $0004;πCONST right_button_up = $0008;πCONST right_button_down = $0010;πCONST left_button_up = $0020;πCONST left_button_down = $0040;πCONST cursor_moved = $0080;ππVAR mouse_driver_disabled : BOOLEAN;πVAR number_of_presses, number_of_releases : INTEGER;πVAR number_buttons, x, y : INTEGER;πVAR button_status, horizontal_counts, vertical_counts : INTEGER;πVAR left_mouse_button_pressed, right_mouse_button_pressed,π    left_mouse_button_released, right_mouse_button_released : BOOLEAN;πVAR register : REGISTERS;ππPROCEDURE check_button_status;πPROCEDURE disable_mouse_driver (VAR int33h_vector_address : POINTER);πPROCEDURE enable_mouse_driver; INLINE($B8/$20/$00/$CD/$33);πFUNCTION  get_alternate_user_interrupt_vector (call_mask : WORD) : POINTER;πPROCEDURE get_left_button_press_information;πPROCEDURE get_left_button_release_information;πPROCEDURE get_mouse_position;πPROCEDURE get_mouse_sensitivity (VAR horizontal_coordinates_per_pixel,π                                     vertical_coordinates_per_pixel,π                                     double_speed_threshold : WORD);πPROCEDURE get_right_button_press_information;πPROCEDURE get_right_button_release_information;πPROCEDURE light_pen_emulation; INLINE($B8/$0D/$00/$CD/$33);πFUNCTION  mouse_button_pressed : BOOLEAN;πPROCEDURE mouse_cursor_off; INLINE($B8/$02/$00/$CD/$33);πPROCEDURE mouse_cursor_off_area (x1,y1,x2,y2 : INTEGER);πPROCEDURE mouse_cursor_on; INLINE($B8/$01/$00/$CD/$33);πFUNCTION  mouse_exists : BOOLEAN;πFUNCTION  mouse_state_buffer_size : INTEGER;πFUNCTION  mouse_video_page : WORD;πFUNCTION  number_of_buttons : INTEGER;πPROCEDURE relative_number_of_screen_positions_moved (VAR x, y : INTEGER);π          {reported in units of 0.02 inches - approximately 0.5 millimeters}πPROCEDURE reset_mouse_software; INLINE($B8/$21/$00/$CD/$33);πPROCEDURE restore_mouse_driver_state (mouse_state_buffer_segment,π                                      mouse_state_buffer_offset : WORD);π          {use when returning from another program to your program}πPROCEDURE save_mouse_driver_state (mouse_state_buffer_segment,π                                   mouse_state_buffer_offset : WORD);π          {use mouse_state_buffer_size to set up buffer first;π           use when EXEC another program from your program}πPROCEDURE set_alternate_mouse_user_handler (call_mask,π                                            function_offset : INTEGER);πPROCEDURE set_double_speed_threshold (threshold_speed : INTEGER);πPROCEDURE set_graphics_mouse_cursor (hot_spot_x, hot_spot_y : INTEGER;π                                   screen_and_cursor_mask : mouse_cursor_mask);πPROCEDURE set_mouse_physical_movement_ratio (x8_positions_to_move,π                                             y8_positions_to_move : INTEGER);π          {each position corresponds to 1/200th of an inch}πPROCEDURE set_mouse_position (x,y : INTEGER);πPROCEDURE set_mouse_sensitivity (horizontal_coordinates_per_pixel,π                                 vertical_coordinates_per_pixel,π                                 double_speed_threshold : WORD);πPROCEDURE set_mouse_video_page (page_number : WORD);πPROCEDURE set_mouse_x_bounds (minimum_x, maximum_x : WORD);πPROCEDURE set_mouse_y_bounds (minimum_y, maximum_y : WORD);πPROCEDURE set_text_mouse_attribute_cursor (screen_cursor_mask_offset : WORD);πPROCEDURE set_text_mouse_hardware_cursor (top_scan_line,π                                          bottom_scan_line : INTEGER);πPROCEDURE stop_light_pen_emulation; INLINE($B8/$0E/$00/$CD/$33);πPROCEDURE swap_mouse_interrupt_vector (VAR call_mask, mouse_vector_segment,π                                           mouse_vector_offset : WORD);π{*****************************************************************************}π                             IMPLEMENTATIONπ{*****************************************************************************}πPROCEDURE check_button_status;π   VAR check_left, check_right : WORD;π   BEGINπ      IF button_status AND $0001 = $0001 THENπ         left_mouse_button_pressed := TRUE ELSEπ         left_mouse_button_pressed := FALSE;ππ      IF button_status AND $0002 = $0002 THENπ         right_mouse_button_pressed := TRUE ELSEπ         right_mouse_button_pressed := FALSE;π   END;π{*****************************************************************************}πPROCEDURE disable_mouse_driver (VAR int33h_vector_address : POINTER);π   BEGINπ      register.AX := $001F;π      INTR($33,register);π      IF register.AX = $001F THENπ         BEGINπ            mouse_driver_disabled := TRUE;π            int33h_vector_address := PTR(register.ES,register.BX);π         END ELSE mouse_driver_disabled := FALSE;π   END;π{*****************************************************************************}πFUNCTION  get_alternate_user_interrupt_vector (call_mask : WORD) : POINTER;π   BEGINπ      register.AX := $0019;π      register.CX := call_mask;π      INTR($33,register);π      get_alternate_user_interrupt_vector := PTR(register.BX,register.DX);π   END;π{*****************************************************************************}πPROCEDURE get_left_button_press_information;π   BEGINπ      register.BX := $0000;π      register.AX := $0005;π      INTR($33,register);π      number_of_presses := register.BX;π      x := register.CX;π      y := register.DX;π      button_status := register.AX;π      check_button_status;π   END;π{*****************************************************************************}πPROCEDURE get_left_button_release_information;π   BEGINπ      register.BX := $0000;π      register.AX := $0006;π      INTR($33,register);π      number_of_releases := register.BX;π      x := register.CX;π      y := register.DX;π      button_status := register.AX;π      check_button_status;π   END;π{*****************************************************************************}πPROCEDURE get_mouse_position;π   BEGINπ      register.AX := $0003;π      INTR($33,register);π      x := register.CX;π      y := register.DX;π      button_status := register.BX;π      check_button_status;π   END;π{*****************************************************************************}πPROCEDURE get_mouse_sensitivity (VAR horizontal_coordinates_per_pixel,π                                     vertical_coordinates_per_pixel,π                                     double_speed_threshold : WORD);π   BEGINπ      register.AX := $001B;π      register.BX := horizontal_coordinates_per_pixel;π      register.CX := vertical_coordinates_per_pixel;π      register.DX := double_speed_threshold;π      INTR($33,register);π   END;π{*****************************************************************************}πPROCEDURE get_right_button_press_information;π   BEGINπ      register.BX := $0001;π      register.AX := $0005;π      INTR($33,register);π      number_of_presses := register.BX;π      x := register.CX;π      y := register.DX;π      button_status := register.AX;π      check_button_status;π   END;π{*****************************************************************************}πPROCEDURE get_right_button_release_information;π   BEGINπ      register.BX := $0001;π      register.AX := $0006;π      INTR($33,register);π      number_of_releases := register.BX;π      x := register.CX;π      y := register.DX;π      button_status := register.AX;π      check_button_status;π   END;π{*****************************************************************************}πFUNCTION mouse_button_pressed : BOOLEAN;π   BEGINπ      register.AX := $0003;π      INTR($33,register);π      button_status := register.BX;π      check_button_status;π   END;π{*****************************************************************************}πPROCEDURE mouse_cursor_off_area (x1,y1,x2,y2 : INTEGER);π   BEGINπ      register.AX := $0010;π      register.CX := x1;π      register.DX := y1;π      register.SI := x2;π      register.DI := y2;π      INTR($33,register);π      mouse_cursor_on;   {may need to remove this statement}π   END;π{*****************************************************************************}πFUNCTION  mouse_exists : BOOLEAN;π   BEGINπ      register.AX := $0021;π      INTR($33,register);π      IF (register.AX = $FFFF) AND (register.BX = $02) THENπ         mouse_exists := TRUE ELSEπ         mouse_exists := FALSE;π   END;π{*****************************************************************************}πFUNCTION  mouse_state_buffer_size : INTEGER;π   BEGINπ      register.AX := $15;π      INTR($33,register);π      mouse_state_buffer_size := register.BX;π   END;π{*****************************************************************************}πFUNCTION mouse_video_page : WORD;π   BEGINπ      INLINE($B8/$1E/$00/$CD/$33);π      mouse_video_page := register.BX;π   END;π{*****************************************************************************}πFUNCTION number_of_buttons : INTEGER;π   BEGINπ      register.AX := $0000;π      INTR($33,register);π      number_of_buttons := register.BX;π   END;π{*****************************************************************************}πPROCEDURE relative_number_of_screen_positions_moved (VAR x, y : INTEGER);π   BEGINπ      register.AX := $000B;π      INTR($33,register);π      register.CX := x;π      register.DX := y;π   END;π{*****************************************************************************}πPROCEDURE restore_mouse_driver_state (mouse_state_buffer_segment,π                                      mouse_state_buffer_offset : WORD);π   BEGINπ      register.AX := $17;π      register.ES := mouse_state_buffer_segment;π      register.DX := mouse_state_buffer_offset;π      INTR($33,register);π   END;π{*****************************************************************************}πPROCEDURE save_mouse_driver_state (mouse_state_buffer_segment,π                                   mouse_state_buffer_offset : WORD);π   BEGINπ      register.AX := $16;π      register.ES := mouse_state_buffer_segment;π      register.DX := mouse_state_buffer_offset;π      INTR($33,register);π   END;π{*****************************************************************************}πPROCEDURE set_alternate_mouse_user_handler (call_mask,π                                            function_offset : INTEGER);π   BEGINπ      register.AX := $0018;π      register.CX := call_mask;π      register.DX := function_offset;π      INTR($33,register);π      x := register.CX;π      y := register.DX;π      horizontal_counts := register.DI;π      vertical_counts := register.SI;π      button_status := register.BX;π      check_button_status;π   END;π{*****************************************************************************}πPROCEDURE set_mouse_video_page (page_number : WORD);π   BEGINπ      register.AX := $001D;π      register.BX := page_number;π      INTR($33,register);π   END;π{*****************************************************************************}πPROCEDURE set_double_speed_threshold (threshold_speed : INTEGER);π   BEGINπ      register.AX := $0013;π      register.DX := threshold_speed;π      INTR($33,register);π   END;π{*****************************************************************************}πPROCEDURE set_graphics_mouse_cursor (hot_spot_x, hot_spot_y : INTEGER;π                                   screen_and_cursor_mask : mouse_cursor_mask);π   BEGINπ      register.AX := $0009;π      register.BX := hot_spot_x;π      register.CX := hot_spot_y;π      register.ES := SEG(screen_and_cursor_mask);π      register.DX := OFS(screen_and_cursor_mask);π      INTR($33,register);π   END;π{*****************************************************************************}πPROCEDURE set_mouse_physical_movement_ratio (x8_positions_to_move,π                                             y8_positions_to_move : INTEGER);π   BEGINπ      register.AX := $000F;π      register.CX := x8_positions_to_move;π      register.DX := y8_positions_to_move;π      INTR($33,register);π   END;π{*****************************************************************************}πPROCEDURE set_mouse_position (x,y : INTEGER);π   BEGINπ      register.AX := $0004;π      register.CX := x;π      register.DX := y;π      INTR($33,register);π   END;π{*****************************************************************************}πPROCEDURE set_mouse_sensitivity (horizontal_coordinates_per_pixel,π                                 vertical_coordinates_per_pixel,π                                 double_speed_threshold : WORD);π   BEGINπ      register.AX := $001A;π      register.BX := horizontal_coordinates_per_pixel;π      register.CX := vertical_coordinates_per_pixel;π      register.DX := double_speed_threshold;π      INTR($33,register);π   END;π{*****************************************************************************}πPROCEDURE set_mouse_x_bounds (minimum_x, maximum_x : WORD);π   BEGINπ      register.AX := $0008;π      register.CX := minimum_x;π      register.DX := maximum_x;π      INTR($33,register);π   END;π{*****************************************************************************}πPROCEDURE set_mouse_y_bounds (minimum_y, maximum_y : WORD);π   BEGINπ      register.AX := $0007;π      register.CX := minimum_y;π      register.DX := maximum_y;π      INTR($33,register);π   END;π{*****************************************************************************}πPROCEDURE set_text_mouse_attribute_cursor (screen_cursor_mask_offset : WORD);π   BEGINπ      register.AX := $000A;π      register.BX := $0000;π      register.CX := screen_cursor_mask_offset;π      register.DX := screen_cursor_mask_offset + 8;π      INTR($33,register);π   END;π{*****************************************************************************}πPROCEDURE set_text_mouse_hardware_cursor (top_scan_line,π                                          bottom_scan_line : INTEGER);π   BEGINπ      register.AX := $000A;π      register.BX := $0001;π      register.CX := top_scan_line;π      register.DX := bottom_scan_line;π      INTR($33,register);π   END;π{*****************************************************************************}πPROCEDURE set_user_defined_input_mask (call_mask, function_offset : INTEGER);π   BEGINπ      register.AX := $000C;π      register.CX := call_mask;π      register.DX := function_offset;π      INTR($33,register);π   END;π{*****************************************************************************}πPROCEDURE swap_mouse_interrupt_vector (VAR call_mask, mouse_vector_segment,π                                           mouse_vector_offset : WORD);π   VAR register_DS : INTEGER;π   BEGINπ      register_DS := register.DS;  {save the data segment}π      register.AX := $0014;π      register.CX := call_mask;π      register.ES := mouse_vector_offset;π      register.DX := mouse_vector_offset;π      INTR($33,register);π      call_mask := register.CX;π      mouse_vector_segment := register.ES;π      mouse_vector_offset := register.DX;π      register.DS := register_DS;   {resets the data segment}π      button_status := register.BX;π      check_button_status;π      horizontal_counts := register.DI;π      vertical_counts := register.SI;π      x := register.CX;π      y := register.DX;π   END;π{*****************************************************************************}πBEGINπ   x := 0;π   y := 0;π   number_buttons := number_of_buttons;π   number_of_presses := 0;π   number_of_releases := 0;π   left_mouse_button_released := FALSE;π   right_mouse_button_released := FALSE;π   left_mouse_button_released := FALSE;π   right_mouse_button_released := FALSE;πEND.π                                                                                  12     01-27-9411:56ALL                      MICHAEL NICOLAI          Mouse Cursors            IMPORT              25     l╚H? {π> I whant to draw a new mouse cursor, and the routines that I'm using willπ> allow me to do this by passing an array [0..31] of integer; I don't knowπ> how to draw a cursor thought using this array. Some other routins haveπ> predifined cursors, but that nubers are out of range.ππHere's some explanation:ππAt the memory location where ES:DX points to, there have to be first 16πwords (the screen mask) followed by 16 words (the cursor mask).ππThe screen mask defines an AND with the background beneath the cursor, andπthe cursor mask defines a XOR with the background pixels.ππ- For each pixel use the following Equations:ππ 1. expand each mask-bit to the width needed to display one colored-pixelπ    in the used video-mode, e.g. if you are using mode $13 (320x200x256)π    each mask-bit is expanded to 8 bits (one byte). If you are usingπ    640x480x16, each mask-bit is expanded to 4 bits.ππ 2. Backgrd._pixel AND screen-mask_pixel XOR cursor-mask_pixel => newπ    pixel.ππExample: (standard arrow-cursor)ππ            screen-mask       cursor-mask    |   cursor-formπ                                             |π          1001111111111111  0000000000000000 | +00+++++++++++++π          1000111111111111  0010000000000000 | +010++++++++++++π          1000011111111111  0011000000000000 | +0110+++++++++++π          1000001111111111  0011100000000000 | +01110++++++++++π          1000000111111111  0011110000000000 | +011110+++++++++π          1000000011111111  0011111000000000 | +0111110++++++++π          1000000001111111  0011111100000000 | +01111110+++++++π          1000000000111111  0011111110000000 | +011111110++++++π          1000000000011111  0011111111000000 | +0111111110+++++π          1000000000001111  0011111000000000 | +01111100000++++π          1000000011111111  0011011000000000 | +0110110++++++++π          1000100001111111  0010001100000000 | +01000110+++++++π          1001100001111111  0000001100000000 | +00++0110+++++++π          1111110000111111  0000000110000000 | ++++++0110++++++π          1111110000111111  0000000110000000 | ++++++0110++++++π          1111111000111111  0000000000000000 | +++++++000++++++π                                             |ππAs you can easily see:πππ    screen-mask | cursor-mask | new pixelπ   -------------+-------------+-----------π        0       |      0      |  blackπ        0       |      1      |  whiteπ        1       |      0      |  background visibleπ        1       |      1      |  background invertedπππA quick example for the inverted background:ππLets say we have a 01101101 as a backgroundpixel, ok?ππ     1.       01101101π          AND 11111111 (expanded) screen-mask-bitπ         -----------------------------------------π              01101101 leaving the background-pixel untouched.πππ     2.       01101101π          XOR 11111111 (expanded) cursor-mask-bitπ         -----------------------------------------π              10010010 inverted background pixelππ}π                                                                                                                       13     01-27-9412:15ALL                      TORSTEN PINKERT          Mouse Cursor Editor      IMPORT              27     l╚╦· {πNow here's the source for the Mouse-Cursor-Editorππ}πPROGRAM Mouse_Edit;πuses Crt;πtypeπ Masktype = array[1..16] of word;πvarπ Cursor :  Array[1..2] of Masktype;π screenmask,Cursormask : Array [1..16,1..16] of Char;π x,y,oldx,oldy : Byte;π Fenster : Boolean; {False=Links,True=Rechts}π i,j : Byte;π c : Char;π wert : word;π  dest : text;π  s : string;ππprocedure Init;πbeginπ  TextMode (co40);π ClrScr;π for i:=1 to 16 doπ  for j:=1 to 16 doπ  beginπ   Screenmask[i,j]:='*';π   GoToXY(i+2,j);π   Write (Screenmask[i,j]);π   CursorMask[i,j]:='.';π   GoToXY (i+22,j);π   Write (CursorMask[i,j]);π  end;π x:=8; oldx:=8; y:=8; oldy:=8;π Fenster := false;π GotoXY(20,20); write('X=',x:3,'  Y=',y:3);π GotoXY (x+2,y);πend;πprocedure Changemask;πvarπ t : byte;πbeginπ t:=x; x:=oldx; oldx:=t;π t:=y; y:=oldy; oldy:=t;π fenster := fenster xor true;π GotoXY(20,20); write('X=',x:3,'  Y=',y:3);πend;πbeginπ init;π repeatπ  c:=readkey;π  if c=#9 thenπ   ChangeMaskπ  else if c=#32 thenπ   if fenster then beginπ    if cursormask[x,y]='.' thenπ     cursormask[x,y]:='*'π    elseπ     cursormask[x,y]:='.';π    write(cursormask[x,y]);π    GotoXY(wherex-1,wherey);π   end else beginπ    if screenmask[x,y]='.' thenπ     screenmask[x,y]:='*'π    elseπ     screenmask[x,y]:='.';π    write(screenmask[x,y]);π    GotoXY(wherex-1,wherey)π  end else if c=#0 then beginπ   c:=readkey;π   case c ofπ    #72 : if y > 1 thenπ        dec(y);π    #80 : if y < 16 thenπ        inc(y);π    #77 : if x<16 thenπ        inc(x);π    #75 : if x > 1 thenπ        dec(x);π   end;π   GotoXY(20,20); write('X=',x:3,'  Y=',y:3);π  end;π  if fenster thenπ   GotoXY(x+22,y)π  elseπ   GotoXY(x+2,y);π until c=#27;π for i:=1 to 16 do beginπ  wert:=0;π  for j:=1 to 16 doπ   if screenmask[j,i]='*' thenπ    inc(wert,1 shl (16-j));π  Cursor[1,i]:=wert;π end;π for i:=1 to 16 do beginπ  wert:=0;π  for j:=1 to 16 doπ   if cursormask[j,i]='*' thenπ    inc(wert,1 shl (16-j));π  Cursor[2,i]:=wert;π end;π  assign(dest,'pfeil.dat');π  rewrite(dest);π  writeln (dest,'const');π  write (dest,#7,'screenmask : masktype = (');π  for i:=1 to 16 do beginπ   str(cursor[1,i],s);π   write(dest,s);π    if i<16 thenπ     write(dest,',');π  end;π  writeln(dest,');');π  write (dest,#7,'cursormask : masktype = (');π  for i:=1 to 16 do beginπ   str(cursor[2,i],s);π   write(dest,s);π    if i<16 thenπ     write(dest,',');π  end;π  writeln(dest,');');π close(dest);πend.ππ{πTORSTEN PINKERTππAnd now here's the program to test how Mouse-Edit works...π}πPROGRAM Mouse_Edit_Test;πuses graph;πtypeπ masktype = array[1..16] of word;ππ{$I Pfeil.dat}ππvarπ cursor : array[1..2] of masktype;π  gd,gm : integer;ππprocedure ShowMouse; assembler;π asmπ  mov ax,1π  int 33hπend; {ShowMouse}πprocedure HideMouse; assembler;π asmπ  mov ax,2π  int 33hπend; {HideMouse}πprocedure ChangeMousePointer (x,y:integer; zeiger:word); assembler;πasmπ mov ax,9π mov bx,xπ mov bx,yπ mov dx,zeigerπ int 33hπend; {ChangeMousePointer}ππbeginπ gd:=VGA; gm := VGAHi;π initgraph(gd,gm,'c:\bp\bgi');π  setfillstyle(solidfill,white);π  bar (200,200,400,400);π cursor[1]:=screenmask; cursor[2]:=cursormask;π SetBKColor(black);π ShowMouse;π ChangeMousePointer(8,8,ofs(cursor));π  readln;π  HideMouse;π  closegraph;πend.π                                                                                                       14     01-27-9413:32ALL                      GREG ESTABROOKS          What PORT is Mouse on    IMPORT              17     l╚c  {************************************************************}πPROGRAM WhatPortIsTheMouseOn;   { Sept 18/93, Greg Estabrooks}πTYPEπ    MouseParamTable = RECORDπ                        BaudRate   :WORD; { Baud Rate Div 100}π                        Emulation  :WORD;π                        ReportRate :WORD; { Report Rate.     }π                        FirmRev    :WORD;π                        ZeroWord   :WORD; { Should be zero.  }π                        PortLoc    :WORD; { Com Port Used.   }π                        PhysButtons:WORD; { Physical Buttons.}π                        LogButtons :WORD; { Logical Buttons. }π                      END;πVARπ   MouseInf :MouseParamTable;ππPROCEDURE GetMouseInf( VAR MouseTable ); ASSEMBLER;π                       { Routine to Get info about mouse.   }π                       { NOTE Doesn't check to see if a     }π                       {  a mouse is installed.             }πASMπ  Push AX                      { Save Registers Used.       }π  Push ESπ  Push DXπ  Mov AX,$246C                 { Get Mouse Parameters.      }π  LES DX,MouseTable            { Point ES:DX to Param Table.}π  Int $33                      { Call Mouse Interrupt.      }π  Pop DX                       { Restore Registers used.    }π  Pop ESπ  Pop AXπEND;{GetMouseInf}ππBEGINπ  GetMouseInf(MouseInf);        { Get mouse info.            }π  Writeln('     ___Mouse Info___'); { Show a title.          }π  Writeln;π  WITH MouseInf DO              { Display Mouse Info.        }π    BEGINπ      Writeln('Baud Rate     : ',BaudRate * 100);π      Writeln('Emulation     : ',Emulation);π      Writeln('Report Rate   : ',ReportRate);π      Writeln('FirmWare Rev  : ',FirmRev);π      Writeln('Com Port      : ',PortLoc);π      Writeln('Physical Butns: ',PhysButtons);π      Writeln('Logical Buttns: ',LogButtons);π    END;π  Readln;                       { Wait for user to have a look.}πEND.{WhatPortIsTheMouseOn}π{************************************************************}π                                                       15     01-27-9417:32ALL                      BERNIE PALLEK            Basic Mouse Routines     IMPORT              31     l╚ΘI {πFrom: BERNIE PALLEKπSubj: Mouse routinesπ---------------------------------------------------------------------------π>I'm after a good mouse unit for Turbo Pascal 7.ππOK, here it is:π}π{$R-,S-}ππUNIT BMouse;  { basic mouse routines }πππINTERFACEπππTYPEπ  CustomMouseCursor = ARRAY[0..31] OF Word;ππCONSTπ  { button masks }π  Left_B    = $0001;π  Right_B   = $0002;π  Center_B  = $0004;π  { text pointer selectors }π  Software_Pointer = 0;π  Hardware_Pointer = 1;ππFUNCTION  Ms_Init(VAR numOfButtons : Word) : Boolean;πPROCEDURE Ms_SetHLimits(xmin, xmax : Word);πPROCEDURE Ms_SetVLimits(ymin, ymax : Word);πPROCEDURE Ms_Show;πPROCEDURE Ms_Hide;πPROCEDURE Ms_Read(VAR x, y, b_mask : Word);πPROCEDURE Ms_SetPos(x, y : Word);πPROCEDURE Ms_SetGraphPointer(newShape : CustomMouseCursor; hot_x, hot_y :πWord);πPROCEDURE Ms_SetTextPointer(select : Word; scr_char : Char; scr_attr : Byte;π                            ptr_char : Char; ptr_attr : Byte);πPROCEDURE Ms_SetMPP(hMPP, vMPP : Word);πPROCEDURE Ms_ReadPosFromLast(VAR hCount, vCount : Word);πππIMPLEMENTATIONπππUSES Dos;ππVARπ  mouse_detected : Boolean;π  r              : Registers; { scratch Registers variable }π  mi             : Pointer;   { mouse interrupt vector for initial test }πππFUNCTION Ms_Init(VAR numOfButtons : Word) : Boolean;πBEGINπ  IF mouse_detected THEN BEGINπ    r.AX := 0;π    Intr($33, r);π    IF (r.AX = 0) THEN BEGINπ      numOfButtons := 0;π      Ms_Init := False;π    END ELSE BEGINπ       numOfButtons := r.BX;π       Ms_Init := True;π    END;π  END ELSE BEGINπ    numOfButtons := 0;π    Ms_Init := False;π  END;πEND;ππPROCEDURE Ms_SetHLimits(xmin, xmax : Word);πBEGINπ  r.AX := 7;  { set horizontal limits }π  r.CX := xmin;π  r.DX := xmax;π  Intr($33, r);πEND;ππPROCEDURE Ms_SetVLimits(ymin, ymax : Word);πBEGINπ  r.AX := 8;  { set vertical limits }π  r.CX := ymin;π  r.DX := ymax;π  Intr($33, r);πEND;ππPROCEDURE Ms_Show;πBEGINπ  r.AX := 1;π  Intr($33, r);πEND;ππPROCEDURE Ms_Hide;πBEGINπ  r.AX := 2;π  Intr($33, r);πEND;ππPROCEDURE Ms_Read(VAR x, y, b_mask : Word);πBEGINπ  r.AX := 3;π  Intr($33, r);π  x := r.CX;π  y := r.DX;π  b_mask := r.BX;πEND;ππPROCEDURE Ms_SetPos(x, y : Word);πBEGINπ  r.AX := 4;π  r.CX := x;π  r.DX := y;π  Intr($33, r);πEND;ππPROCEDURE Ms_SetGraphPointer(newShape : CustomMouseCursor; hot_x, hot_y :πWord);πBEGINπ  r.AX := 9;π  r.BX := hot_x;π  r.CX := hot_y;π  r.DX := Ofs(newShape);π  r.ES := Seg(newShape);π  Intr($33, r);πEND;ππPROCEDURE Ms_SetTextPointer(select : Word; scr_char : Char; scr_attr : Byte;π                            ptr_char : Char; ptr_attr : Byte);πBEGINπ  r.AX := 10;π  r.BX := select;  { determines which pointer: software or hardware }π  r.CL := Byte(scr_char);π  r.CH := scr_attr;π  r.DL := Byte(ptr_char);π  r.DH := ptr_attr;π  Intr($33, r);πEND;ππPROCEDURE Ms_SetMPP(hMPP, vMPP : Word);  { Set [M]ickeys [P]er [P]ixel }π{  set horizontal and vertical mouse motion rates }π{  MPP (1 <= MPP <= 32767) = Mickeys / 8 pixels   }π{  default hMPP is 8:8                            }π{  default vMPP is 16:8                           }πBEGINπ  IF (hMPP >= 1) AND (hMPP <= 32767) AND (vMPP >= 1) AND (vMPP <= 32767) THENπBEGINπ    r.AX := 15;π    r.CX := hMPP;π    r.DX := vMPP;π    Intr($33, r);π  END;πEND;ππPROCEDURE Ms_ReadPosFromLast(VAR hCount, vCount : Word);π{ Return the number of Mickeys the mouse has moved since the }π{ last call to this function.                                }π{ A positive number is right/down.                           }πBEGINπ  r.AX := 11;π  Intr($33, r);π  hCount := r.CX;π  vCount := r.DX;πEND;πππ{=== UNIT INITIALIZATION ========================================}πBEGINπ  GetIntVec($33, mi);π  IF (mi = NIL) THENπ    mouse_detected := Falseπ  ELSEπ    IF (Byte(mi^) = $CF) THEN mouse_detected := Falseπ  ELSEπ    mouse_detected := True;πEND.ππ                               16     02-03-9416:12ALL                      RICHARD JORDAN           Change Graphic Mouse CursIMPORT              15     l╚   {π DR> Hello I was wondering how I might be able to load a batchπ DR> file under Turbo Pascal. I was also wondering how toπ DR> change how the mouse symbol looks like when you installπ DR> the mouse in your programs. Thank you.π}πTypeπ        CursorData  = Array [1..32] of Word;ππ        ArrowMask : CursorData = ($7fff,$3fff,$1fff,$0fff,π                                  $07ff,$03ff,$01ff,$00ff,π                                  $007f,$03ff,$03ff,$29ff,π                                  $71ff,$f0ff,$faff,$f8ff,ππ                                  $8000,$C000,$A000,$9000,π                                  $8800,$8400,$8200,$8100,π                                  $8f80,$9400,$b400,$d200,π                                  $8a00,$0900,$0500,$0700);ππ        HourGlassMask : CursorData = ($0000,$0000,$0000,$c003,π                                      $e007,$f00f,$F81F,$fc3f,π                                      $fc3F,$F81F,$F00F,$e007,π                                      $c003,$0000,$0000,$0000,ππ                                      $0000,$7ffe,$0000,$1ff8,π                                      $0ff0,$0000,$0000,$0000,π                                      $0180,$0340,$07e0,$0e78,π                                      $1818,$0000,$7ffe,$0000);πππππππππVarπ        Regs    : Registers;ππππProcedure SetMouseCursor(CursorMask : CursorData);ππBeginπ        Regs.AX := $0009;π        Regs.BX := $0004;π        Regs.CX := $0004;π        Regs.ES := Seg(CursorMask);π        Regs.DX := Ofs(CursorMask);π        Intr($33,Regs);πEnd;ππππHere's a little routine I used to change my cursor from an arrow to anπhour-glass and back.... You can design your own cursors by following myπexamples. The First 16 Words of the array are the cursor the next 16 areπthe mask.π                    17     02-03-9416:16ALL                      SWAG SUPPORT TEAM        Full Featured Mouse Unit IMPORT              112    l╚   π                    {MOUSE.PAS creates MOUSE.TPU Unit}π     {From the book "OBJECT ORIENTED PROGRAMMING IN TURBO PASCAL 5.5"}ππUnit Mouse;ππInterfaceππTypeπ    GCursor = recordπ            ScreenMask,π            CursorMask : array[0..15] of word;π            hotX,hotY  : integer;π            end; {record}πππ                  {================================}π                  {Graphics Cursors are predefined }π                  {for use with GraphicMouse       }π                  {================================}πππConst           {The graphics cursors are defined as constants       }ππ     HAMMER : GCursor =       {As in the hammer of THOR, my favorite}π            (ScreenMask : ($8003,$0001,$0001,$1831,π                           $1011,$0001,$0001,$8003,π                           $F83F,$F83F,$F83F,$F83F,π                           $F83F,$F83F,$F83F,$F83F);π             CursorMask : ($0000,$3FF8,$4284,$4104,π                           $4284,$4444,$3FF8,$0380,π                           $0380,$0380,$0380,$0380,π                           $0380,$0380,$0380,$0000);π             HotX : $0007;π             HotY : $0003);ππ     ARROW : GCursor =       {Your run-of-the-mill Graphics Arrow cursor}π           (ScreenMask : ($1FFF,$0FFF,$07FF,$03FF,π                          $01FF,$00FF,$007F,$003F,π                          $001F,$003F,$01FF,$01FF,π                          $E0FF,$F0FF,$F8FF,$F8FF);π            CursorMask : ($0000,$4000,$6000,$7000,π                          $7800,$7C00,$7E00,$7F00,π                          $7F80,$7C00,$4C00,$0600,π                          $0600,$0300,$0400,$0000);π            HotX : $0001;π            HotY : $0001);ππ     CHECK : GCursor =       {A check-mark cursor}π           (ScreenMask : ($FFF0,$FFE0,$FFC0,$FF81,π                          $FF03,$0607,$000F,$001F,π                          $803F,$C07F,$E0FF,$F1FF,π                          $FFFF,$FFFF,$FFFF,$FFFF);π            CursorMask : ($0000,$0006,$000C,$0018,π                          $0030,$0060,$70C0,$3980,π                          $1F00,$0E00,$0400,$0000,π                          $0000,$0000,$0000,$0000);π            HotX : $0005;π            HotY : $0010);ππ     CROSS : GCursor =       {A circle with center cross cursor}π           (ScreenMask : ($F01F,$E00F,$C007,$8003,π                          $0441,$0C61,$0381,$0381,π                          $0381,$0C61,$0441,$8003,π                          $C007,$E00F,$F01F,$FFFF);π            CursorMask : ($0000,$07C0,$0920,$1110,π                          $2108,$4004,$4004,$783C,π                          $4004,$4004,$2108,$1110,π                          $0920,$07C0,$0000,$0000);π            HotX : $0007;π            HotY : $0007);ππ     GLOVE : GCursor =       {The hand with pointing finger cursor}π           (ScreenMask : ($F3FF,$E1FF,$E1FF,$E1FF,π                          $E1FF,$E049,$E000,$8000,π                          $0000,$0000,$07FC,$07F8,π                          $9FF9,$8FF1,$C003,$E007);π            CursorMask : ($0C00,$1200,$1200,$1200,π                          $1200,$13B6,$1249,$7249,π                          $9249,$9001,$9001,$8001,π                          $4002,$4002,$2004,$1FF8);π            HotX : $0004;π            HotY : $0000);ππ     IBEAM : GCursor =       {Your normal text entering I shaped cursor}π           (ScreenMask : ($F3FF,$E1FF,$E1FF,$E1FF,π                          $E1FF,$E049,$E000,$8000,π                          $0000,$0000,$07FC,$07F8,π                          $9FF9,$8FF1,$C003,$E007);π            CursorMask : ($0C30,$0240,$0180,$0180,π                          $0180,$0180,$0180,$0180,π                          $0180,$0180,$0180,$0180,π                          $0180,$0180,$0240,$0C30);π            HotX : $0007;π            HotY : $0007);ππ      KKG : GCursor =     {KKG symbol, a little sorority stuff}π        (ScreenMask : ($FFFF,$1040,$1040,$0000,π                       $0000,$0000,$0411,$0411,π                       $0001,$0001,$0001,$1041,π                       $1041,$1041,$FFFF,$FFFF );π         CursorMask : ($0000,$0000,$4517,$4515,π                       $4925,$5144,$6184,$6184,π                       $5144,$4924,$4514,$4514,π                       $4514,$0000,$0000,$0000 );π         HotX : $0007;π         HotY : $0005);ππ      SMILEY : GCursor =  {a Smiley face for you!}π        (ScreenMask : ($C003,$8001,$07E0,$0000,π                       $0000,$0000,$0000,$0000,π                       $0000,$0000,$0000,$8001,π                       $C003,$C003,$E007,$F81F );π         CursorMask : ($0FF0,$1008,$2004,$4002,π                       $4E72,$4A52,$4E72,$4002,π                       $4992,$581A,$2424,$13C8,π                       $1008,$0C30,$03C0,$0000 );π         HotX : $0007;π         HotY : $0005);ππ      XOUT : GCursor =    {a BIG X marks the spot}π        (ScreenMask : ($1FF8,$0FF0,$07E0,$03C0,π                       $8181,$C003,$E007,$F00F,π                       $F81F,$F00F,$E007,$C003,π                       $8181,$03C0,$07E0,$0FF0 );π         CursorMask : ($8001,$C003,$6006,$300C,π                       $1818,$0C30,$0660,$03C0,π                       $0180,$03C0,$0660,$0C30,π                       $1818,$300C,$6006,$C003 );π         HotX : $0007;π         HotY : $0008);ππ      SWORD : GCursor =   {For the D&D buffs...}π        (ScreenMask : ($F83F,$F83F,$F83F,$F83F,π                       $F83F,$F83F,$F83F,$F83F,π                       $8003,$8003,$8003,$8003,π                       $8003,$F83F,$F01F,$F01F );π         CursorMask : ($0100,$0380,$0380,$0380,π                       $0380,$0380,$0380,$0380,π                       $0380,$3398,$3398,$3FF8,π                       $0380,$0380,$0380,$07C0 );π         HotX : $0007;π         HotY : $0000);πππTypeπ    Position = recordπ             btnStat,π             opCount,π             Xpos,Ypos : integer;π             end; {record}ππConstπ     ButtonL = 0;π     ButtonR = 1;π     ButtonM = 2;π     Software = 0;π     Hardware = 1;ππ     πTypeπ    GenMouse = objectπ             X,Y : integer;π             Visible : boolean;π             Function TestMouse : boolean;π             Procedure SetAccel(Threshold : integer);π             Procedure Show(Option : boolean);π             Procedure GetPosition(var BtnStatus,Xpos,Ypos : integer);π             Procedure QueryBtnDn(Button : integer;var mouse : position);π             Procedure QueryBtnUp(Button : integer;var mouse : position);π             Procedure ReadMove(var XMove,YMove : integer);π             Procedure Reset(var Status : boolean;var BtnCount : integer);π             Procedure SetRatio(HorPix,VerPix : integer);π             Procedure SetLimits(XPosMin,YPosMin,XPosMax,YPosMax : integer);π             Procedure SetPosition(XPos,YPos : integer);π             end; {object}ππ    GraphicMouse = object(GenMouse)π                 Procedure Initialize;π                 Procedure ConditionalHide(Left,Top,Right,Bottom : integer);π                 Procedure SetCursor(Cursor : GCursor);π                 end; {object}ππ    TextMouse = object(GenMouse)π              Procedure Initialize;π              Procedure SetCursor(Ctype,C1,C2 : word);π              end; {object}ππ    GraphicLightPen = object(GraphicMouse)π                    Procedure LightPen(Option : boolean);π                    end; {object}ππ    TextLightPen = object(TextMouse)π                 Procedure LightPen(Option : boolean);π                 end; {object}ππ{=========================================================================}ππImplementationππUsesπ    Crt,Graph,Dos;πVarπ   Regs : registers;ππ{*************************************************************************}ππFunction Lower(N1,N2 : integer) : integer;πBeginπ     if N1 < N2 thenπ        Lower := N1π     elseπ         Lower := N2;πEnd;ππ{*************************************************************************}ππFunction Upper(N1,N2 : integer) : integer;πBeginπ     if N1 > N2 thenπ        Upper := N1π     elseπ         Upper := N2;πEnd;ππ{*************************************************************************}ππFunction GenMouse.TestMouse : boolean;πConstπ     Iret = 207;πVarπ   dOff,dSeg : integer;πBeginπ     dOff := MemW[0000:0204];π     dSeg := MemW[0000:0206];π     if ((dSeg = 0) or (dOff = 0)) thenπ        TestMouse := Falseπ     elseπ         TestMouse := Mem[dSeg:dOff] <> Iret;πEnd;ππ{*************************************************************************}ππProcedure GenMouse.Reset(var Status : boolean; var BtnCount : integer);πBeginπ     Regs.AX := $00;            {Reset to default conditions}π     intr($33,Regs);π     Status := Regs.AX <> 0;    {Mouse Present}π     BtnCount := Regs.BX;       {Button Count}πEnd;ππ{*************************************************************************}ππProcedure GenMouse.SetAccel(Threshold : integer);πBeginπ     Regs.AX := $13;π     Regs.DX := Threshold;π     Intr($33,Regs);πEnd;ππ{*************************************************************************}ππProcedure GenMouse.Show(Option : boolean);πBeginπ     if Option and not Visible thenπ     beginπ          Regs.AX := $01;         {Show mouse cursor}π          Visible := True;π          Intr($33,Regs);π     endπ     elseπ     if Visible and not Option thenπ     beginπ          Regs.AX := $02;           {Hide mouse cursor}π          Visible := False;π          Intr($33,Regs);π     end;πEnd;ππ{*************************************************************************}ππProcedure GenMouse.GetPosition(var BtnStatus,Xpos,Ypos : integer);πBeginπ     Regs.AX := $03;π     Intr($33,Regs);π     BtnStatus := Regs.BX;π     Xpos      := Regs.CX;π     Ypos      := Regs.DX;πEnd;ππ{*************************************************************************}ππProcedure GenMouse.SetPosition(Xpos,Ypos : integer);πBeginπ     Regs.AX := $04;π     Regs.CX := Xpos;π     Regs.DX := Ypos;π     Intr($33,Regs);πEnd;ππ{*************************************************************************}ππProcedure GenMouse.SetRatio(HorPix,VerPix : integer);πBeginπ     Regs.AX := $0F;π     Regs.CX := HorPix;         {horizonal mickeys/pixel}π     Regs.DX := VerPix;         {vertical mickeys/pixel}π     Intr($33,Regs);πEnd;ππ{*************************************************************************}ππProcedure GenMouse.QueryBtnDn(Button : integer;var Mouse : position);πBeginπ     Regs.AX := $05;π     Regs.BX := Button;π     Intr($33,Regs);π     Mouse.BtnStat := Regs.AX;π     Mouse.OpCount := Regs.BX;π     Mouse.Xpos    := Regs.CX;π     Mouse.Ypos    := Regs.DX;πEnd;ππ{*************************************************************************}ππProcedure GenMouse.QueryBtnUp(Button : integer;var Mouse : position);πBeginπ     Regs.AX := $06;π     Regs.BX := Button;π     Intr($33,Regs);π     Mouse.BtnStat := Regs.AX;π     Mouse.OpCount := Regs.BX;π     Mouse.Xpos    := Regs.CX;π     Mouse.Ypos    := Regs.DX;πEnd;ππ{*************************************************************************}ππProcedure GenMouse.SetLimits(XPosMin,YPosMin,XPosMax,YPosMax : integer);πBeginπ     Regs.AX := $07;    {horizonal limits}π     Regs.CX := Lower(XPosMin,XPosMax);π     Regs.DX := Upper(XPosMin,XPosMax);π     Intr($33,Regs);π     Regs.AX := $08;    {vertical limits}π     Regs.CX := Lower(YPosMin,YPosMax);π     Regs.DX := Upper(YPosMin,YPosMax);π     Intr($33,Regs);πEnd;ππ{*************************************************************************}ππProcedure GenMouse.ReadMove(var XMove,YMove : integer);πBeginπ     Regs.AX := $0B;π     Intr($33,Regs);π     XMove := Regs.CX;π     YMove := Regs.DX;πEnd;ππ{*************************************************************************}ππ             {=======================================}π             {Implementation methods for GraphicMouse}π             {=======================================}ππProcedure GraphicMouse.SetCursor(Cursor : GCursor);πBeginπ     Regs.AX := $09;π     Regs.BX := Cursor.HotX;π     Regs.CX := Cursor.HotY;π     Regs.DX := Ofs(Cursor.ScreenMask);π     Regs.ES := Seg(Cursor.ScreenMask);π     Intr($33,Regs);πEnd;ππ{*************************************************************************}ππProcedure GraphicMouse.ConditionalHide(Left,Top,Right,Bottom : integer);πBeginπ     Regs.AX := $0A;π     Regs.CX := Left;π     Regs.DX := Top;π     Regs.SI := Right;π     Regs.DI := Bottom;π     Intr($33,Regs);πEnd;ππ{*************************************************************************}ππProcedure GraphicMouse.Initialize;πBeginπ     Visible := False;π     SetLimits(0,0,GetMaxX,GetMaxY);π     SetCursor(Arrow);π     SetPosition(GetMaxX div 2,GetMaxY div 2);π     Show(True);πEnd;ππ{*************************************************************************}ππ                    {====================================}π                    {Implementation methods for TextMouse}π                    {====================================}ππProcedure TextMouse.Initialize;πBeginπ     Visible := False;π     SetLimits(Lo(WindMin)*8,Hi(WindMin)*8,Lo(WindMax)*8,Hi(WindMax)*8);π     SetCursor(Hardware,6,7);π     SetPosition(0,0);π     Show(True);πEnd;ππ{*************************************************************************}ππProcedure TextMouse.SetCursor(CType,C1,C2 : word);πBeginπ     Regs.AX := $0A;            {function 10h}π     Regs.BX := CType;          {0=software,1=hardware}π     Regs.CX := C1;             {screen mask or scan start line}π     Regs.DX := C2;             {screen mask or scan stop line}π     Intr($33,Regs);πEnd;ππ{*************************************************************************}ππ             {===================================}π             {Implementation methods for LightPen}π             {===================================}ππProcedure TextLightPen.LightPen(Option : boolean);πBeginπ     if Option thenπ        Regs.AX := $0Dπ     elseπ         Regs.AX := $0E;π     Intr($33,Regs);πEnd;ππ{*************************************************************************}ππProcedure GraphicLightPen.LightPen(Option : boolean);πBeginπ     if Option thenπ        Regs.AX := $0Dπ     elseπ         Regs.AX := $0E;π     Intr($33,Regs);πEnd;ππ{*************************************************************************}ππBEGINπEND.ππ     18     02-05-9407:57ALL                      MARK MILBRATH            TP7 Mouse Unit           IMPORT              32     l╚   Program MouseDemo;   { I just learned this little piece of wizardry }πUses                 { so I thought I would pass it on -- have fun! }π  Crt,Dos,Drivers;πTypeπ  CharType=Set Of Char;πVarπ  Key:Char; ValidKeys:CharType;π  Button_Status,Mouse_X,Mouse_Y,ButtonPressed,X,Y:Word;πProcedure GetMouse (Var Button_Status,Mouse_X,Mouse_Y:Word;π                                              Monitor:Word);πVar                       { --------------------------------------- }π  Regs:Registers;         { Button_Status     0 = no button pressed }πBegin                     { Mouse_X           X coordinate          }π  Regs.AX:=3;             { Mouse_Y           Y coordinate          }π  Intr($33,Regs);         { Monitor           0 = off  1 = on       }π  Button_Status:=Regs.BX; { Monitor can be set to 1 While coding to }π  Mouse_X      :=Regs.CX; { display Button_Status,   Mouse_X,   and }π  Mouse_Y      :=Regs.DX; { Mouse_Y in the upper-left corner of the }π  If (Monitor=1) Then     { screen                                  }π    Begin                 { --------------------------------------- }π      TextBackGround(7); TextColor(8); GotoXY(1,1);π      Write('             '); GotoXY(1,1);π      Write(Button_Status:2,Mouse_X:5,Mouse_Y:5); Delay(100)π    EndπEnd;πProcedure GetEvent;πLabelπ  ExitLoop;πBeginπ  TextBackGround(0); ClrScr; TextColor(7);π  GotoXY(26,12); Write('Continue? [Y] or [N]? ');π  ValidKeys:=[#89,#78];          { accept only Y or N as valid keys }π  Key:=#255;                     { initialize Key to a nonvalid key }π  Repeatπ    While (Not KeyPressed) Doπ      Beginπ        GetMouse(Button_Status,Mouse_X,Mouse_Y,0);π        Repeat                               { ^  turns monitor off }π          GetMouse(ButtonPressed,X,Y,0) { X & Y are dummy variables }π        Until (KeyPressed) Or (ButtonPressed<>Button_Status);π    { Repeat ^ Until "waits" until a change in Button_Status occurs }π    { this eliminates a "slow" click from being processed as two or }π    { more clicks                                                   }π        If (Button_Status>0) THEN { a mouse button has been pressed }π          Begin { convert mouse clicks into corresponding key codes }π            If      (Mouse_X=288) And (Mouse_Y=88) Then Key:=#89π            Else If (Mouse_X=344) And (Mouse_Y=88) Then Key:=#78;π            If      (Key In ValidKeys)             Then Goto ExitLoopπ          End                              { exit the loop if valid }π      End;                                 { key codes are received }π    Key:=Upcase(ReadKey) { get keyboard event if KeyPressed is true }π  Until (Key In ValidKeys);π  ExitLoop: TextBackGround(0); ClrScr; TextColor(7);π  If Key=#89 Thenπ    Beginπ      Randomize;π      X:=Random(61)+10;      { pick a random X column from 10 to 60 }π      Y:=Random(21)+ 3;      { pick a random Y row    from  3 to 23 }π      GotoXY(X,Y);     Write(#177);π      GotoXY(X-5,Y+1); Write('Click here!');π              { the X column and Y row numbers must be converted to }π              { X and Y coordinates by multiplying the column & row }π              { numbers by 8 and then subtracting 8 from that value }π      Repeat  { for example:  column 40, row 10 converts to 312, 72 }π        GetMouse(Button_Status,Mouse_X,Mouse_Y,1)π                                             { ^   turns monitor on }π      Until(Button_Status>0) And (Mouse_X=X*8-8) And (Mouse_Y=Y*8-8);π      GetEvent                   {        ^^^^^               ^^^^^ }π    End;                         { X coordinate        Y coordinate }π  HideMouse; ClrScrπEnd;πBeginπ  InitEvents;π        { sets the "hide counter" to zero and displays mouse cursor }π        { use ShowMouse to decrement the hide counter               }π        { use HideMouse to increment the hide counter               }π        { when hide counter equals zero the mouse cursor is visible }π  GetEventπEnd.π                                                          19     02-09-9411:49ALL                      SEAN PALMER              GREAT Mouse Routines     IMPORT              49     l╚   π{ Rodent unit  v1.3      OooO }  { << isn't he cute? } {   09/01/93              \/  }π{ Interrupt-style interface for Microsoft mouse, Turbo Pascal 6.0+}ππ{ by Sean L. Palmer }π{ Released to the Public Domain }ππ{ Please credit me if your program uses these routines! }πππunit Rodent;π{$A-,B-,D-,E-,F-,G+,I-,L-,N-,O-,R-,S-,V-,X+}π{make sure you alloc enough stack space in main program!} {as written, requires a 286+ and that the mouse exists}ππinterfaceππconstπ x :integer=0; y :integer=0; {current mouse pos}π xs:integer=0; ys:integer=0; {mickey counts}π left=1; center=2; right=4;  {button masks- (btn and left)<>0 if left buttonπ                              down}π b:boolean=false;            {button status, true if any button down} varπ btn:byte absolute b;        {button status, mask with (btn and mask)<>0 toπ                              get a specific button}π hidden:boolean;πtypeπ pMouseHook=^tMouseHook;π tMouseHook=procedure;ππ{avoid calling dos, bios, and mouse routines from these if possible}πfunction erasHook(h:tMouseHook):pMouseHook;πfunction moveHook(h:tMouseHook):pMouseHook;πfunction drawHook(h:tMouseHook):pMouseHook; {change out handlers}πfunction clikHook(h:tMouseHook):pMouseHook;πfunction liftHook(h:tMouseHook):pMouseHook;ππprocedure show(f:boolean);          {true=show}πprocedure confine(l,t,r,b:integer); {set min,max bounds}πprocedure moveTo(h,v:integer);πprocedure setSpeed(xs,ys,thr:word); {set x,y pix per 16 mickeys, double speed threshold}ππimplementationππ{This unit should work in any mode, but you need to provide the routinesπ to draw and erase the cursor.}π{note: reason coords are scaled *8 throughout is because mouse driver}π {stupidly messes with the values differently in different modes.}π {This is just a work-around so it won't be limited to every eighth columnπ  or row in text modes.}π{PS: be very careful using mickey counts in DI & SI in event handler.}ππvarπ hideCount:byte absolute hidden;πππ{this procedure does nothing, used to disable an event} procedure defaultMouseHook;far;assembler;asm end;ππ{must save previous setting of I-flag}πprocedure clearInts;inline($9C/$FA); {pushF;cli} procedure restoreInts;inline($9D);   {popF}ππconstπ vDrawHook:tMouseHook=defaultMouseHook; {pre-set all hooks to do nothing}π vErasHook:tMouseHook=defaultMouseHook;π vMoveHook:tMouseHook=defaultMouseHook;π vClikHook:tMouseHook=defaultMouseHook;π vLiftHook:tMouseHook=defaultMouseHook;ππ{these all both set a hook to a procedure you provide, and also returnπ the old hook so you can later restore it} {Use something like:}ππ{var savedClikHook:tMouseHook;}π{...}π{@savedClikHook:=clikHook(myClikHook);}π{...}π{clikHook(savedClikHook)}ππfunction drawHook(h:tMouseHook):pMouseHook;beginπ drawHook:=@vDrawHook; clearInts; vDrawHook:=h; restoreInts;π end;πfunction erasHook(h:tMouseHook):pMouseHook;beginπ erasHook:=@vErasHook; clearInts; vErasHook:=h; restoreInts;π end;πfunction moveHook(h:tMouseHook):pMouseHook;beginπ moveHook:=@vMoveHook; clearInts; vMoveHook:=h; restoreInts;π end;πfunction clikHook(h:tMouseHook):pMouseHook;beginπ clikHook:=@vclikHook; clearInts; vClikHook:=h; restoreInts;π end;πfunction liftHook(h:tMouseHook):pMouseHook;beginπ liftHook:=@vLiftHook; clearInts; vLiftHook:=h; restoreInts;π end;ππ{here is the callback function for the mouse driver}ππ{calling regs:}π {ax:triggering event bit mask}π {bx:button status bit mask (bit 0=left,1=center,2=right)}π {cx:mouse X/bit 7 is sign for di,bit 0 always=0}π {dx:mouse Y/bit 7 is sign for si}π {di:abs mouse Delta X}π {si:abs mouse Delta Y}ππ{bits in event mask:}π {0:move}π {1:left btn down}π {2:left btn up}π {3,4:center btn}π {5,6:right btn}ππ{This code is real easy to break, be careful!} procedure doMouseHook;far;assembler;asmπ push ax; mov ax,seg @DATA; mov ds,ax; pop ax;π mov xs,si; mov ys,di; {disregard di,si mickey counts}π mov btn,bl;π and cx,$3FFF; shr cx,3; and dx,$3FFF; shr dx,3; {strip hi bits}π push ax; push cx; push dx;  {save event status}π test hidden,$FF; jnz @NOERAS; call vErasHook; @NOERAS:π pop dx; mov y,dx; pop cx; mov x,cx;π call vMoveHook;  {always assume mouse has moved, disregard bit 0 of ax}π test hidden,$FF; jnz @NODRAW; call vDrawHook; @NODRAW:π pop ax; {restore event status}π@CLIK: test al,00101010b; jz @LIFT; {check any button clik flag}π push ax; call vClikHook; pop ax;π@LIFT: test al,01010100b; jz @EXIT; {check any button lift flag}π call vLiftHook;π@EXIT:π end;ππprocedure show(f:boolean);beginπ clearInts;π if f then beginπ  if hidden then begin dec(hideCount); if not hidden then vDrawHook; end;π  endπ else begin if not hidden then vErasHook; inc(hideCount); end;π restoreInts;π end;ππProcedure confine(l,t,r,b:integer);assembler;asmπ mov ax,7; mov cx,l; shl cx,3; mov dx,r; shl dx,3; int $33;π mov ax,8; mov cx,t; shl cx,3; mov dx,b; shl dx,3; int $33;π end;ππprocedure moveTo(h,v:integer);beginπ if not hidden then vErasHook;π asm mov cx,h; mov x,cx; shl cx,3;π     mov dx,v; mov y,dx; shl dx,3;π     mov ax,4; int $33; end;π if not hidden then vDrawHook;π end;ππprocedure setSpeed(xs,ys,thr:word);assembler;asmπ mov ax,$1A; mov bx,xs; shl bx,3; mov cx,ys; shl cx,3; mov dx,thr; int $33;π end;ππvarπ oldMouseHook:pointer;π oldEventMask:word;ππprocedure removeMouse;beginπ if not hidden then show(false);π asm les dx,oldMouseHook; mov cx,oldEventMask; mov ax,$C; int $33;end;π end;ππvarπ mouseHook:pointer absolute 0:$33*4;πconstπ eventMask=$7F;  {all events}ππfunction exists:boolean;assembler;asmπ xor ax,ax; mov es,ax; {get ready to check interrupt vector for nil}π mov bx,es:[$33*4]; or bx,es:[$33*4+2]; jz @X; {no}π {ax still 0} int $33; @X:  {result in al}π end;ππbeginπ if exists then beginπ  setSpeed(32,64,4);    {set up a natural-feeling speed for 640x480}π  moveTo(0,0); confine(0,0,0,0); {trap the little sucker}π  hideCount:=1;π  asmπ   push cs; pop es; mov dx,offset doMouseHook; {loc of callback function}π   mov cx,eventMask; mov ax,$14; int $33;      {enable event callbacks}π   mov oldEventMask,cx;π   mov word ptr oldMouseHook,dx; mov word ptr oldMouseHook+2,es;π   end;π  endπ else begin writeln('Need mouse.'); halt(1);end;π end.π                         20     05-26-9406:17ALL                      FLORIAN ANSORGE          Mouse Detection          IMPORT              16     l╚   {π(The Procedure Mouse_Check can be done shorter, but this one "remembers" aπmouseclick, so you can click the mouse, and at a later time call thisπprocedure and it will tell you the mouse-information!)ππ>-----------------------------            }ππPROGRAM Mouse_on_the_screen;ππUSES DOS,Graph;ππTYPEπ     MouseType = RECORDπ                   x, y, Button     : Word;π                   RButton, LButton : Boolean;π                 END;πVARπ     Reg                              : Registers;π     Mouse                            : Mousetype;ππPROCEDURE Show_Mouse;πBEGINπ  Reg.AX := 1;π  Intr($33,Reg);πEND;ππPROCEDURE Hide_Mouse;πBEGINπ  Reg.AX := 2;π  Intr($33,Reg);πEND;ππPROCEDURE SetMouseArea(XMin,YMin,XMax,YMax :Word);πBEGINπ  Reg.AX := 7;π  Reg.CX := XMin;π  Reg.DX := XMax;π  Intr($33,Reg);π  Reg.AX := 8;π  Reg.CX := YMin;π  Reg.DX := YMax;π  Intr($33,Reg);πEND;ππPROCEDURE Init_Mouse;πBEGINπ  Reg.AX := 0;π  Intr($33,Reg);π  SetMouseArea(0,0,GetMaxX,GetMaxY);π  Reg.AX := 4;π  Reg.CX := 100;π  Reg.DX := 100;π  Intr($33,Reg);πEND;ππPROCEDURE Mouse_Check;πBEGINπ  Reg.AX := 5;π  Reg.BX := 1;π  Intr($33,Reg);π  Mouse.RButton := Reg.BX > 0;π  Mouse.Button := Reg.AX;π  IF Mouse.RButton THEN Mouse.Button := 2;π  Mouse.X := Reg.CX;π  Mouse.Y := Reg.DX;ππ  IF NOT Mouse.RButtonπ    THEN Beginπ           Reg.AX := 5;π           Reg.BX := 0;π           Intr($33,Reg);π           Mouse.LButton := Reg.BX > 0;π           Mouse.Button := Reg.AX;π           IF Mouse.LButton THEN Mouse.Button := 1;π           Mouse.X := Reg.CX;π           Mouse.Y := Reg.DX;π         End;πEND;ππBEGINπ  {Init graphics screen here!}ππ  Init_Mouse;π  Show_Mouse;π  .                     {You have to finish this part yourself}π  .                     { ___     }π  .                     { |-lorian}π  Hide_Mouse;π {CloseGraph};πEND.π