home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 13
/
CD_ASCQ_13_0494.iso
/
news
/
swag
/
mouse.swg
< prev
next >
Wrap
Text File
|
1994-03-11
|
129KB
|
1 lines
SWAGOLX.EXE (c) 1993 GDSOFT ALL RIGHTS RESERVED 00020 RODENT MANAGMENT ROUTINES 1 05-28-9313:52ALL SWAG SUPPORT TEAM MOUSLIB.PAS IMPORT 293 {π***************************************************************************π* MouseLib * *π* Release 6.0 - Added demo Program - Please refer to MOUSETST.PAS to *π* see a demo of the mouseLib Unit usage. *π***************************************************************************π}ππUnit Mouse;ππInterfaceππUsesπ Dos;ππConstπ MOUSEinT = $33; {mouse driver interrupt}π LEFTBUTtoN = 1; {bit 0}π RIGHTBUTtoN = 2; {bit 1}π MIDDLEBUTtoN = 4; {bit 2}ππ CURSor_LOCATION_CHANGED = 1; {event mask bits}π LEFT_BUTtoN_PRESSED = 2;π LEFT_BUTtoN_RELEASED = 4;π RIGHT_BUTtoN_PRESSED = 8;π RIGHT_BUTtoN_RELEASED = 16;π MIDDLE_BUTtoN_PRESSED = 32;π MIDDLE_BUTtoN_RELEASED = 64;ππTypeπ mouseType = (twoButton,threeButton,another);π buttonState = (buttonDown,buttonUp);π direction = (moveRight,moveLeft,moveUp,moveDown,noMove);π grCursorType = Recordπ xH,yH : Byte; {x,y Hot Point}π data : Pointer; {cursor look Pointer}π end;ππVarπ mouse_present : Boolean;π mouse_buttons : mouseType;π eventX,eventY,eventButtons : Word; {any event handler should update}π eventhappened : Boolean; {these Vars to use getLastEvent }π XMotions,YMotions : Word; {per 8 pixels}π mouseCursorLevel : Integer;ππ {if > 0 mouse cursor is visiable, otherwise not, containes the levelπ of showMouseCursor/hideMouseCursor}ππConstπ LastMask : Word = 0;π lastHandler : Pointer = Nil;ππ {when changing the interrupt handler temporarily, save BEForE theπ change these to Variables, and restore them when neccessary}ππ lastCursor : grCursorType = (π xH : 0;π yH : 0;π data : nil );ππ {when changing Graphic cursor temporarily, save these values BEForEπ the change, and restore when neccessary}ππConstπ click_Repeat = 10; { Recommended value For waitForRelease timeOut }ππProcedure initMouse; {when replacing mouse mode do that..!}πProcedure showMouseCursor;πProcedure hideMouseCursor;πFunction getMouseX : Word;πFunction getMouseY : Word;πFunction getButton(Button : Byte) : buttonState;πFunction buttonPressed : Boolean;πProcedure setMouseCursor(x,y : Word);πFunction LastXPress(Button : Byte) : Word;πFunction LastYPress(Button : Byte) : Word;πFunction ButtonPresses(Button : Byte) : Word; {from last last check}πFunction LastXRelease(Button : Byte) : Word;πFunction LastYRelease(Button : Byte) : Word;πFunction ButtonReleases(Button : Byte) : Word; {from last last check}πProcedure mouseBox(left,top,right,bottom : Word); {limit mouse rectangle}πProcedure GraphicMouseCursor(xHotPoint,yHotPoint : Byte; dataofs : Pointer);πProcedure HardwareTextCursor(fromLine,toLine : Byte);πProcedure softwareTextCursor(screenMask,cursorMask : Word);πFunction recentXmovement : direction;πFunction recentYmovement : direction;πProcedure setArrowCursor;πProcedure setWatchCursor;πProcedure setUpArrowCursor;πProcedure setLeftArrowCursor;πProcedure setCheckMarkCursor;πProcedure setPointingHandCursor;πProcedure setDiagonalCrossCursor;πProcedure setRectangularCrossCursor;πProcedure setHourGlassCursor;πProcedure setNewWatchCursor;πProcedure setEventHandler(mask : Word; handler : Pointer);πProcedure setDefaultHandler(mask : Word);πProcedure enableLightPenEmulation;πProcedure disableLightPenEmulation;πProcedure defineSensetivity(x,y : Word);πProcedure setHideCursorBox(left,top,right,bottom : Word);πProcedure defineDoubleSpeedTreshHold(treshHold : Word);πProcedure disableTreshHold;πProcedure defaultTreshHold;πProcedure setMouseGraph;πProcedure resetMouseGraph;πProcedure waitForRelease(timeOut : Word);πProcedure swapEventHandler(mask : Word; handler : Pointer);π{ return old in lastMask and lastHandler }πFunction getMouseSaveStateSize : Word;π{ get mouse from interrupted Program, and stop it ..}πProcedure interceptMouse;πProcedure restoreMouse;π{π**************************************************************************π* MouseLib * *π* * *π* mouseLib - Release 2 and abo *π* *π* because of quirks in hercules Graphic mode that is not detectab * *π* by the mouse driver we have to know when we initMouse if we wa * *π* to check For Graphic mode or not, if we do we must perForm a *π* setMouseGraph beFore initGraph, to initGraph in Text mode we m * *π* resetMouseGraph beFore.. , if these calling conventions are no * *π* taken we might have problems in hercules cards! *π* * *π* each call to hideMouseCursor must be balanced by a matching call * *π* to showMouseCursor, 2 calls to hideMou.. and only 1 to showM.. *π* will not show the mouse cursor on the screen! *π**************************************************************************π}πππImplementationππConst watchData : Array [0..31] of Word =π ($E007,$C003,$8001,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$8001,$C003,$E007,π $0,$1FF8,$318C,$6186,$4012,$4022,$4042,$718C,$718C,$4062,$4032,π $4002,$6186,$318C,$1FF8,$0);ππConst arrowData : Array [0..31] of Word =π ($FFFF,$8FFF,$8FFF,$87FF,$83FF,$81FF,$80FF,$807F,$803F,$801F,$800F,π $801F,$807F,$887F,$DC3F,$FC3F,π $0,$0,$2000,$3000,$3800,$3C00,$3E00,$3F00,$3F80,$3FC0,π $3FE0,$3E00,$3300,$2300,$0180,$0180);ππConst UpArrowCursor : Array [0..31] of Word =π ($f9ff,$f0ff,$e07f,$e07f,$c03f,$c03f,$801f,$801f,π $f,$f,$f0ff,$f0ff,$f0ff,$f0ff,$f0ff,$f0ff,π $0,$600,$f00,$f00,$1f80,$1f80,$3fc0,$3fc0,π $7fe0,$600, $600, $600, $600, $600, $600, $600);ππConst LeftArrowCursor : Array [0..31] of Wordπ = ($fe1f,$f01f,$0, $0, $0, $f01f,$fe1f,$ffff,π $ffff,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff,π $0, $c0, $7c0, $7ffe,$7c0, $c0, $0, $0,π $0, $0, $0, $0, $0, $0, $0, $0);ππConst CheckMarkCursor : Array [0..31] of Wordπ = ($fff0,$ffe0,$ffc0,$ff81,$ff03,$607, $f, $1f,π $c03f,$f07f,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff,π $0, $6, $c, $18, $30, $60, $70c0,$1d80,π $700, $0, $0, $0, $0, $0, $0, $0);ππConst PointingHandCursor : Array [0..31] of Wordπ = ($e1ff,$e1ff,$e1ff,$e1ff,$e1ff,$e000,$e000,$e000,π $0, $0, $0, $0, $0, $0, $0, $0,π $1e00,$1200,$1200,$1200,$1200,$13ff,$1249,$1249,π $f249,$9001,$9001,$9001,$8001,$8001,$8001,$ffff);ππConst DiagonalcrossCursor : Array [0..31] of Wordπ = ($7e0, $180, $0, $c003,$f00f,$c003,$0, $180,π $7e0, $ffff,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff,π $0, $700e,$1c38,$660, $3c0, $660, $1c38,$700e,π $0, $0, $0, $0, $0, $0, $0, $0);ππConst RectangularCrossCursor : Array [0..31] of Wordπ = ($fc3f,$fc3f,$fc3f,$0,$0, $0, $fc3f,$fc3f,π $fc3f,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff,π $0, $180, $180, $180, $7ffe,$180, $180, $180,π $0, $0, $0, $0, $0, $0, $0, $0);ππConst HourglassCursor : Array [0..31] of Wordπ = ($0, $0, $0, $0, $8001,$c003,$e007,$f00f,π $e007,$c003,$8001,$0, $0, $0, $0, $ffff,π $0, $7ffe,$6006,$300c,$1818,$c30, $660, $3c0,π $660, $c30, $1998,$33cc,$67e6,$7ffe,$0, $0);ππConst newWatchCursor : Array [0..31] of Wordπ = ( $ffff, $c003, $8001, $0, $0, $0, $0, $0, $0,π $0, $0, $0, $0, $8001, $c003, $ffff, $0, $0,π $1ff8, $2004, $4992, $4022, $4042, $518a, $4782,π $4002, $4992, $4002, $2004, $1ff8, $0, $0 );πππConstπ mouseGraph : Boolean = False; {assume Text mode upon entry}ππTypeπ box = Recordπ left,top,right,bottom : Word;π end; {Do not change field order !!!}ππVarπ hideBox : box;π reg : Registers; {general Registers used}π grMode,π grDrv : Integer; {detect Graphic mode if any}π grCode : Integer; {return initGraph code in here}π interceptX,π interceptY : Word;π{π***************************************************************************π* callMouse * *π* * *π* used to call mouse interrupt With global data reg - used as parameters * *π***************************************************************************π}πProcedure callMouse;πbeginπ intr(MOUSEinT,REG);πend; {callMouse}ππ(******************************************************************************π* initMouse *π* For some reason grCode is assigned a value of -11,($FFF5) in the second time*π* we call initmouse after we allready are in Graphics mode, override.. was *π* born because of that situation. *π******************************************************************************)ππProcedure initMouse;πVarπ overRideDriver : Boolean; { True if we over-ridden stupid driver hercules b}πbeginπ overRideDriver := False;π if (mouseGraph and (mem[0:$449] = 7)) then begin { assume no mda - hercules}π mem[0:$449] := 6;π overRideDriver := True;π end;π {trick stupid mouse driver to know we are in Graphic mode}π With reg doπ beginπ ax:=0; {detect genius mouse}π bx:=0; {be sure what mode we get}π callMouse;π mouse_present := (ax <> 0); {not an iret..}π if ((bx and 2) <> 0) thenπ mouse_buttons := twoButtonπ else if ((bx and 3) <> 0) thenπ mouse_buttons := threeButtonπ elseπ mouse_buttons := another; {unknown to us}π end; {with}π if (overRideDriver) thenπ mem[0:$449] := 7;π {restore the stupid situation}π eventX := 0;π eventButtons := 0;π eventY := 0;π eventhappened := False;π XMotions := 8;π YMotions := 16;π mouseCursorLevel := 0; { not visiable, one show to appear }πend; {initMouse}ππ(******************************************************************************ππ* showMouseCursor *ππ******************************************************************************)ππProcedure showMouseCursor;ππbeginπ reg.ax:=1; {enable cursor display}π callMouse;π inc(mouseCursorLevel);πend; {showMouseCursor}ππ(******************************************************************************ππ* hideMouseCursor *ππ******************************************************************************)ππProcedure hideMouseCursor;ππbeginπ reg.ax:=2; {disable cursor display}π callMouse;π dec(mouseCursorLevel);πend; {hideMouseCursor}ππ(******************************************************************************ππ* getMouseX *ππ******************************************************************************)ππFunction getMouseX : Word;πππbeginπ reg.ax := 3;π callMouse;π getMouseX := reg.cx;πend; {getMouseX}ππ(******************************************************************************ππ* getMouseY *ππ******************************************************************************)ππFunction getMouseY : Word;ππbeginπ reg.ax := 3;π callMouse;π getMouseY := reg.dx;πend; {getMouseX}ππ(******************************************************************************ππ* getButton *ππ******************************************************************************)ππFunction getButton(Button : Byte) : buttonState;ππbeginπ reg.ax := 3;π callMouse;π if ((reg.bx and Button) <> 0) thenπ getButton := buttonDownπ {bit 0 = left, 1 = right, 2 = middle}π else getButton := buttonUp;πend; {getButton}ππ(******************************************************************************ππ* buttonPressed *ππ******************************************************************************)ππFunction buttonPressed : Boolean;ππbeginπ reg.ax := 3;π callMouse;π if ((reg.bx and 7) <> 0) thenπ buttonPressed := Trueπ else buttonPressed := False;πend; {buttonPressed}ππ(******************************************************************************ππ* setMouseCursor *ππ******************************************************************************)ππProcedure setMouseCursor(x,y : Word);ππbeginπ With reg do beginπ ax := 4;π cx := x;π dx := y; {prepare parameters}π callMouse;π end; {with}πend; {setMouseCursor}ππ(******************************************************************************ππ* lastXPress *ππ******************************************************************************)ππFunction lastXPress(Button : Byte) : Word;ππbeginπ reg.ax := 5;π reg.bx := Button;π callMouse;π lastXPress := reg.cx;πend; {lastXpress}ππ(******************************************************************************ππ* lastYPress *ππ******************************************************************************)ππFunction lastYPress(Button : Byte) : Word;ππbeginπ reg.ax := 5;π reg.bx := Button;π callMouse;π lastYPress := reg.dx;πend; {lastYpress}ππ(******************************************************************************ππ* buttonPresses *ππ******************************************************************************)ππFunction buttonPresses(Button : Byte) : Word; {from last check}ππbeginπ reg.ax := 5;π reg.bx := Button;π callMouse;π buttonPresses := reg.bx;πend; {buttonPresses}πππ(******************************************************************************ππ* lastXRelease *ππ******************************************************************************)ππFunction lastXRelease(Button : Byte) : Word;ππbeginπ reg.ax := 6;π reg.bx := Button;π callMouse;π lastXRelease := reg.cx;πend; {lastXRelease}ππ(******************************************************************************ππ* lastYRelease *ππ******************************************************************************)ππFunction lastYRelease(Button : Byte) : Word;ππbeginπ reg.ax := 6;π reg.bx := Button;π callMouse;π lastYRelease := reg.dx;πend; {lastYRelease}ππ(******************************************************************************ππ* buttonReleases *ππ******************************************************************************)ππFunction buttonReleases(Button : Byte) : Word; {from last check}ππbeginπ reg.ax := 6;π reg.bx := Button;π callMouse;π buttonReleases := reg.bx;πend; {buttonReleases}ππ(******************************************************************************ππ* swap *ππ******************************************************************************)ππProcedure swap(Var a,b : Word);ππVar c : Word;ππbeginπ c := a;π a := b;π b := c; {swap a and b}πend; {swap}ππ(******************************************************************************ππ* mouseBox *ππ******************************************************************************)ππProcedure mouseBox(left,top,right,bottom : Word);ππbeginπ if (left > right) then swap(left,right);π if (top > bottom) then swap(top,bottom); {make sure they are ordered}π reg.ax := 7;π reg.cx := left;π reg.dx := right;π callMouse; {set x range}π reg.ax := 8;π reg.cx := top;π reg.dx := bottom;π callMouse; {set y range}πend; {mouseBox}ππ(******************************************************************************ππ* GraphicMouseCursor *ππ******************************************************************************)ππProcedure GraphicMouseCursor(xHotPoint,yHotPoint : Byte; dataofs : Pointer);ππ{define 16*16 cursor mask and screen mask, pointed by data,π dataofs is Pointer to data of the masks.}ππbeginπ reg.ax := 9;π reg.bx := xHotPoint;π reg.cx := yHotPoint;π reg.dx := ofs(dataofs^); {DS:DX point to masks}π reg.es := seg(dataofs^);π callMouse;π lastCursor.xH := xHotPoint;π lastCursor.yH := yHotPoint;π lastCursor.data := dataofs;π {save it in lastCursor, if someone needs to change cursor temporary}πend; {GraphicMouseCursor}ππ(******************************************************************************ππ* HardwareTextCursor *ππ******************************************************************************)ππProcedure HardwareTextCursor(fromLine,toLine : Byte);ππ{set Text cursor to Text, using the scan lines from..to,ππ(Continued to next message)π--- FreeMail 1.07bπ * origin: Meredith Place BBS * Tucson, AZ * 602-579-0869 * (1:300/15)π<<<>>>πππDate: 03-02-93 (20:07) Number: 14561 of 14567 (Echo)π to: ROBERT BAKER Refer#: NONEπFrom: STEVE CONNET Read: NOπSubj: MOUSE 6/10 Status: PUBLIC MESSAGEπConf: F-PASCAL (1221) Read Type: GENERAL (+)ππ(Continued from previous message)ππ same as intr 10 cursor set in bios :π color scan lines 0..7, monochrome 0..13 }ππbeginπ{ reg.ah:=$10;π reg.ch:=fromLine;π reg.cl:=toLine;π}π reg.ax := 10;π reg.bx := 1; {hardware Text}π reg.cx := fromLine;π reg.dx := toLine;π callMouse;πend; {hardwareTextCursor}ππ(******************************************************************************ππ* softwareTextCursor *ππ******************************************************************************)ππProcedure softwareTextCursor(screenMask,cursorMask : Word);ππ{ when in this mode the cursor will be achived by anding the screen Wordπ With the screen mask (Attr,Char in high,low order) andπ xoring the cursor mask, ussually used by putting the screen attrπ we want preserved in screen mask (and 0 into screen mask Characterπ Byte), and Character + attributes we want to set into cursor mask}ππbeginπ reg.ax := 10;π reg.bx := 0; {software cursor}π reg.cx := screenMask;π reg.dx := cursorMask;π callMouse;πend; {softwareMouseCursor}ππ(******************************************************************************ππ* recentXmovement *ππ******************************************************************************)ππFunction recentXmovement : direction;ππ{from recent call to which direction did we move ?}ππVar d : Integer;ππbeginπ reg.ax := 11;π callMouse;π d := reg.cx;π if (d > 0)π then recentXmovement := moveRightπ else if (d < 0)π then recentXmovement := moveLeftπ else recentXmovement := noMove;πend; {recentXmovement}ππ(******************************************************************************ππ* recentYmovement *ππ******************************************************************************)ππFunction recentYmovement : direction;ππ{from recent call to which direction did we move ?}ππVarπ d : Integer;πbeginπ reg.ax := 11;π callMouse;π d := reg.dx;π if (d > 0)π then recentYmovement := moveDownπ else if (d < 0)π then recentYmovement := moveUpπ else recentYmovement := noMove;πend; {recentYmovement}ππ(******************************************************************************ππ* setWatchCursor *ππ******************************************************************************)ππProcedure setWatchCursor;πbeginπ GraphicMouseCursor(0,0,@watchData);πend; {setWatchCursor}ππ(******************************************************************************ππ* setNewWatchCursor *ππ******************************************************************************)ππProcedure setNewWatchCursor;πbeginπ GraphicMouseCursor(0, 0, @newWatchCursor);πend; {setNewWatchCursor}ππ(******************************************************************************ππ* setUpArrowCursor *ππ******************************************************************************)ππProcedure setUpArrowCursor;ππbeginπ GraphicMouseCursor(5, 0, @upArrowCursor);πend; {setUpArrowCursor}ππ(******************************************************************************ππ* setLeftArrowCursor *ππ******************************************************************************)ππProcedure setLeftArrowCursor;πbeginπ GraphicMouseCursor(0, 3, @leftArrowCursor);πend; {setLeftArrowCursor}ππ(******************************************************************************ππ* setCheckMarkCursor *ππ******************************************************************************)ππProcedure setCheckMarkCursor;πbeginπ GraphicMouseCursor(6, 7, @checkMarkCursor);πend; {setCheckMarkCursor}ππ(******************************************************************************ππ* setPointingHandCursor *ππ******************************************************************************)ππProcedure setPointingHandCursor;πbeginπ GraphicMouseCursor(5, 0, @pointingHandCursor);πend; {setPointingHandCursor}ππ(******************************************************************************ππ* setDiagonalCrossCursor *ππ******************************************************************************)ππProcedure setDiagonalCrossCursor;πbeginπ GraphicMouseCursor(7, 4, @diagonalCrossCursor);πend; {setDiagonalCrossCursor}ππ(******************************************************************************ππ* setRectangularCrossCursor *ππ******************************************************************************)ππProcedure setRectangularCrossCursor;πbeginπ GraphicMouseCursor(7, 4, @rectangularCrossCursor);πend; {setRectangularCrossCursor}ππ(******************************************************************************ππ* setHourGlassCursor *ππ******************************************************************************)ππProcedure setHourGlassCursor;πbeginπ GraphicMouseCursor(7, 7, @hourGlassCursor);πend; {setHourGlassCursor}ππ(******************************************************************************ππ* setArrowCursor *ππ******************************************************************************)ππProcedure setArrowCursor;πbeginπ GraphicMouseCursor(1,1,@arrowData);πend; {setArrowCursor}ππ(******************************************************************************ππ* setEventHandler *ππ******************************************************************************)ππProcedure setEventHandler(mask : Word; handler : Pointer);ππ{handler must be a Far interrupt routine }ππbeginπ reg.ax := 12; {set event handler Function in mouse driver}π reg.cx := mask;π reg.es := seg(handler^);π reg.dx := ofs(handler^);π callMouse;π lastMask := mask;π lastHandler := handler;πend; {set event Handler}ππ(******************************************************************************ππ* defaultHandler *ππ******************************************************************************)ππ{$F+} Procedure defaultHandler; Assembler; {$F-}πAsmπ push ds; { save TP mouse driver }π mov ax, SEG @data;π mov ds, ax; { ds = TP:ds, not the driver's ds }π mov eventX, cx; { where in the x region did it occur }π mov eventY, dx;π mov eventButtons, bx;π mov eventHappened, 1; { eventHapppened := True }π pop ds; { restore driver's ds }π ret;πend;ππ{ this is the default event handler , it simulates :ππ beginπ eventX := cx;π eventY := dx;π eventButtons := bx;π eventhappened := True;π end;ππ}ππ(******************************************************************************ππ* GetLastEvent *ππ******************************************************************************)ππFunction GetLastEvent(Var x,y : Word;π Var left_button,right_button,middle_button : buttonState) : Boolean;ππbeginπ getLastEvent := eventhappened; {indicate if any event happened}π eventhappened := False; {clear to next read/event}π x := eventX;π y := eventY;π if ((eventButtons and LEFTBUTtoN) <> 0) thenπ left_button := buttonDownπ else left_button := buttonUp;π if ((eventButtons and RIGHTBUTtoN) <> 0) thenπ right_button := buttonDownπ else right_button := buttonUp;π if ((eventButtons and MIDDLEBUTtoN) <> 0) thenπ middle_button := buttonDownπ else middle_button := buttonUp;πend; {getLastEvent}ππ(******************************************************************************ππ* setDefaultHandler *ππ******************************************************************************)ππProcedure setDefaultHandler;ππ{get only event mask, and set event handler to defaultHandler}ππbeginπ setEventHandler(mask,@defaultHandler);πend; {setDefaultHandler}ππ(******************************************************************************ππ* enableLightPenEmulation *ππ******************************************************************************)ππProcedure enableLightPenEmulation;ππbeginπ reg.ax := 13;π callMouse;πend; {enableLightPenEmulation}ππ(******************************************************************************ππ* disableLightPenEmulation *ππ******************************************************************************)ππProcedure disableLightPenEmulation;ππbeginπ reg.ax := 14;π callMouse;πend; {disableLightPenEmulation}ππ(******************************************************************************ππ* defineSensetivity *ππ******************************************************************************)ππProcedure defineSensetivity(x,y : Word);ππbeginπ reg.ax := 15;π reg.cx := x; {# of mouse motions to horizontal 8 pixels}π reg.dx := y; {# of mouse motions to vertical 8 pixels}π callMouse;π XMotions := x;π YMotions := y; {update global Unit Variables}πend; {defineSensetivity}ππ(******************************************************************************ππ* setHideCursorBox *ππ******************************************************************************)ππProcedure setHideCursorBox(left,top,right,bottom : Word);ππbeginπ reg.ax := 16;π reg.es := seg(HideBox);π reg.dx := ofs(HideBox);π HideBox.left := left;π HideBox.right := right;π HideBox.top := top;π HideBox.bottom := bottom;π callMouse;πend; {setHideCursorBox}ππ(******************************************************************************ππ* defineDoubleSpeedTreshHold *ππ******************************************************************************)ππProcedure defineDoubleSpeedTreshHold(treshHold : Word);ππbeginπ reg.ax := 17;π reg.dx := treshHold;π callMouse;πend; {defineDoubleSpeedTreshHold - from what speed to Double mouse movement}ππ(******************************************************************************ππ* disableTreshHold *ππ******************************************************************************)ππProcedure disableTreshHold;ππbeginπ defineDoubleSpeedTreshHold($7FFF);πend; {disableTreshHold}ππ(******************************************************************************ππ* defaultTreshHold *ππ******************************************************************************)ππProcedure defaultTreshHold;ππbeginπ defineDoubleSpeedTreshHold(64);πend; {defaultTreshHold}ππ(******************************************************************************ππ* setMouseGraph *ππ******************************************************************************)ππProcedure setMouseGraph;ππbeginπ mouseGraph := True;πend; {setMouseGraph}ππ(******************************************************************************ππ* resetMouseGraph *ππ******************************************************************************)ππProcedure resetMouseGraph;ππbeginπ mouseGraph := False;πend; {resetMouseGraph}πππ(******************************************************************************ππ* waitForRelease *ππ* Wait Until button is release, or timeOut 1/100 seconds pass. (might miss a *ππ* tenth (1/10) of a second.ππ******************************************************************************)ππProcedure waitForRelease;πVarπ sHour, sMinute, sSecond, sSec100 : Word; { Time at start }π cHour, cMinute, cSecond, cSec100 : Word; { Current time }π stopSec : longInt;π currentSec : longInt;π Delta : longInt;πbeginπ getTime(sHour, sMinute, sSecond, sSec100);π stopSec := (sHour*36000 + sMinute*600 + sSecond*10 + sSec100 + timeOut) modππ (24*360000);π Repeatπ getTime(cHour, cMinute, cSecond, cSec100);π currentSec := (cHour*36000 + cMinute*600 + cSecond*10 + cSec100);π Delta := currentSec - stopSec;π Until (not ButtonPressed) or (Delta >=0) and (Delta < 36000);πend; {waitForRelease}ππ(******************************************************************************ππ* swapEventHandler *ππ* handler is a Far routine. *ππ******************************************************************************)ππProcedure swapEventHandler;πbeginπ reg.ax := $14;π reg.cx := mask;π reg.es := seg(handler^);π reg.dx := ofs(handler^);π callMouse;π lastMask := reg.cx;π lastHandler := ptr(reg.es,reg.dx);πend; {swapEventHandler}ππ(******************************************************************************ππ* getMouseSaveStateSize *ππ******************************************************************************)ππFunction getMouseSaveStateSize;πbeginπ reg.ax := $15;π callMouse;π getMouseSaveStateSize := reg.bx;πend; {getMouseSaveStateSize}πππ(******************************************************************************ππ* interceptMouse *ππ******************************************************************************)ππProcedure interceptMouse;πbeginπ With reg do beginπ ax := 3;π callMouse; { get place .. }π interceptX := cx;π interceptY := dx;π ax := 31;π callMouse;π end; { disable mouse driver .. }πend; {interceptMouse}ππ(******************************************************************************ππ* restoreMouse *ππ******************************************************************************)ππProcedure restoreMouse;πbeginπ With reg do beginπ ax := 32; { restore mouse driver .. }π callMouse;π ax := 4;π cx := interceptX;π dx := interceptY;π callMouse;π end; { With .. }πend; {restoreMouse}ππVarπ OldExitProc : Pointer;ππ(******************************************************************************ππ* MyExitProc *ππ******************************************************************************)ππ{$f+}Procedure MyExitProc;πbeginπ ExitProc := OldExitProc;π resetMouseGraph;π initMouse;πend; { myExitProc }ππ{ if this Unit is used With a Graphic Unit that is loaded and executed afterπ this Unit in the Uses clause, the mouse initialization will not beπ correct, be sure to call initMouse in your Program start to workπ properly }ππbegin {Unit initialization}π eventX := 0;π eventY := 0;π eventHappened := False; { initialize ... }π initMouse; {detect in global Variables}π setArrowCursor; {start like that in Graphic mode}π OldExitProc := ExitProc;π ExitProc := @MyExitProc;πend. {mouseLib}πππππππππThis is a demonstration of the previous Unit Robert.πππ(******************************************************************************ππ* mouseTest *ππ* This is a simple test Program that shows if the mouse is Functions, andππ* demonstrates basic mouse Programming using the mouseLib Unit.ππ******************************************************************************)ππProgram mouseTest;ππUses mouse,Crt,Graph;ππVarπ grdriver,π grmode,π ErrCode : Integer;ππProcedure Err(Msg: String);πbeginπ Writeln(Msg);πend;ππbeginπ clrScr;π if not (mouse_present) then beginπ { mouse_present was set by the mouseLib initialization code .. }π Write('mouse not installed');π Exit;π end;π Case mouse_buttons ofπ twoButton : WriteLn('MicroSoft mouse Mode');π threeButton : WriteLn('PC mouse Mode');π else WriteLn('UnRecognized mouse mode');π end; {Case}π Writeln('MouseLib demo Program, (c) 1992, Ron Loewy.');π Writeln;π Writeln('Move Cursor, Press Right & Left buttons together to continue');π Writeln(' Press any mouse button by itself to recognize');π Window(10, 7, 70, 20);π hardwareTextCursor(1,13); { "normal" Text cursor }π showMouseCursor; { display the cursor }π Repeatπ if getButton(leftButton) = buttonDown thenπ WriteLn('Left Button Pressed');π if getButton(rightButton) = buttonDown thenπ WriteLn('right Button Pressed');π if getButton(middleButton) = buttonDown thenπ WriteLn('Middle Button Pressed');π Until (getButton(leftButton) = buttonDown) andπ (getButton(RightButton) = buttonDown);π hideMouseCursor; { we hide the cursor }π grDriver := detect;π initGraph(grDriver, grMode, 'D:\TP\BGI');π ErrCode := GraphResult;π if ErrCode <> grOK then Err('ERRor! not initializing:'+GraphErrorMsg(ErrCoππ setMouseGraph; { fix quircks in Herc. Graphic card }π initMouse; { let the mouse sense it is in Graphic mode }π outTextXY(10, 10, 'MouseLib demo Program, (c) 1992, Ron Loewy.');π outTextXY(10, 30, 'Press the Right Button to end');π showMouseCursor; { draw the Graphic default arrow cursor }π Repeat Until getButton(rightButton) = buttonDown;π hideMouseCursor;π closeGraph;πend.π 2 05-28-9313:52ALL SWAG SUPPORT TEAM MOUSPIC1.PAS IMPORT 23 {π> 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.π 3 05-28-9313:52ALL SWAG SUPPORT TEAM MOUSPIC2.PAS IMPORT 11 {π>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;ππ 4 05-28-9313:52ALL SWAG SUPPORT TEAM RODENT.PAS IMPORT 51 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.ππ 5 08-17-9308:46ALL SWAG SUPPORT TEAM A Compelte Mouse Unit IMPORT 27 l╚ 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.π 6 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.π 7 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;π 8 11-21-9309:42ALL FRED JOHNSON Mouse Tutor SWAG9311 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π 9 10-28-9311:25ALL GAYLE DAIVS A GOOD Mouse Unit SWAG9311 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. 10 11-02-9317:39ALL LOU DUCHEZ Mouse Library SWAG9311 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.π 11 09-26-9309:18ALL RICHARD SADOWSKY The "Classic" mouse unit SWAG9311 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.π 12 11-26-9317:15ALL SWAG SUPPORT TEAM Rodent Control SWAG9311 129 l╚ 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.π 13 01-27-9411:56ALL MICHAEL NICOLAI Mouse Cursors SWAG9402 25 l╚ {π> 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ππ}π 14 01-27-9412:15ALL TORSTEN PINKERT Mouse Cursor Editor SWAG9402 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.π 15 01-27-9413:32ALL GREG ESTABROOKS What PORT is Mouse on SWAG9402 17 l╚ {************************************************************}π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}π{************************************************************}π 16 01-27-9417:32ALL BERNIE PALLEK Basic Mouse Routines SWAG9402 31 l╚ {π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.ππ 17 02-03-9416:12ALL RICHARD JORDAN Change Graphic Mouse CursSWAG9402 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.π 18 02-03-9416:16ALL SWAG SUPPORT TEAM Full Featured Mouse Unit SWAG9402 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.ππ 19 02-05-9407:57ALL MARK MILBRATH TP7 Mouse Unit SWAG9402 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.π 20 02-09-9411:49ALL SEAN PALMER GREAT Mouse Routines SWAG9402 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.π