home *** CD-ROM | disk | FTP | other *** search
- (*
- ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓·── ──·▓▓▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓│ │░░▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓ Unit was conceived, designed and written ░░▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓ by Floor A.C. Naaijkens for ░░▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓ UltiHouse Software / The ECO Group. ░░▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓ ░░▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓ (C) MCMXCII by EUROCON PANATIONAL CORPORATION. ░░▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓ All Rights Reserved for The ECO Group. ░░▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓ ░░▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓│ │░░▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓·── ──·░░▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
- *)
- {$R-,S-,O+}
- unit eco_emou;
-
- {***************************************************************************}
- {* mouse - turbo pascal mouse unit version 2.2 *}
- {* by floor naaijkens 14/2/90 *}
- {* *}
- {* this program assumes that you have a ms (or compatible) *}
- {* mouse driver installed on the computer. *}
- {* *}
- {***************************************************************************}
-
- interface
-
- uses dos;
-
-
- {---------------------------------------------------------------------------}
- {externally accessable constants}
-
- const
-
- leftbutton = 1; {what the buttons are}
- rightbutton = 2;
- centerbutton = 4;
-
- standard = 1; {graphic cursor definitions}
- uparrow = 2;
- downarrow = 3;
- leftarrow = 4;
- rightarrow = 5;
- checkmark = 6;
- uphand = 7;
- downhand = 8;
- lefthand = 9;
- righthand = 10;
- stophand = 11;
- hourglass = 12;
- diagcross = 13;
- rectcross = 14;
- rectbox = 15;
- targetcross = 16;
- targetcircle = 17;
- targetbox = 18;
- questionmark = 19;
-
- maxmousecursorshape = 19;
-
- {---------------------------------------------------------------------------}
- {externally accessable variables}
-
- var
-
- mouse_installed : boolean; {initmouse - true if mouse is operable}
- mouse_error : integer; {initmouse - error code}
- mouse_type : integer; {initmouse - mouse type}
-
- mouse_clicked : boolean; {readmouse - true if button was clicked}
- mouse_buttons : word; {readmouse - current mouse button status}
- mouse_click_button : word; {readmouse - click button status}
- mousex : word; {readmouse - mouse text x position}
- mousey : word; {readmouse - mouse text y position}
- click_mousex : word; {readmouse - text x click position}
- click_mousey : word; {readmouse - text y click position}
- real_mousex : word; {readmouse - real mouse x position}
- real_mousey : word; {readmouse - real mouse y position}
-
- mousetextwidth : word; {size of text on screen for mouse}
- mousetextheight : word;
-
- {---------------------------------------------------------------------------}
- type
- masktype = record {mouse graphic cursor definition}
- def: array [0..1, 0..15] of word; {graphics cursor def}
- hotx, hoty: integer; { hot spot x,y }
- end;
-
- {---------------------------------------------------------------------------}
- {note: you must set the mousetextwidth and mousetextheight values}
- {to the current character pixel width and height to properly use the}
- {mouse text x,y coordinate system. startup default is 8x8.}
- {to start up the mouse you should do the following: }
- {initmouse; readmouse; showmouse; - this insures that the mouse is}
- {properly setup and ready to run. }
-
- {for more information on the mouse interface and programming with }
- {with a mouse refer to the microsoft mouse programmer's Reference Guide}
- {available from microsoft corporation.}
-
- {warning: all mouse drivers are not created equal. i've experienced some}
- {problems with non-ms mouse drivers (such as logitec which had trouble}
- {with the mouseareahide function) so be careful with the mice you use.}
-
- {---------------------------------------------------------------------------}
- { function 0 - initialize mouse software and hardware }
- procedure initmouse;
-
- {---------------------------------------------------------------------------}
- { function 1 - show mouse cursor }
- procedure showmouse;
-
- {---------------------------------------------------------------------------}
- { function 2 - hide mouse cursor }
- procedure hidemouse;
-
- {---------------------------------------------------------------------------}
- { function 3 - read mouse position and button status }
- procedure readmouse;
-
- {---------------------------------------------------------------------------}
- { function 4 - sets mouse position }
- { x and y values are scaled for text }
- procedure setmouseposition(x, y : word);
-
- {---------------------------------------------------------------------------}
- { function 4 - sets mouse position }
- { x and y values are scaled for graphics }
- procedure setmousepoint(x, y : word);
-
- {---------------------------------------------------------------------------}
- { function 5 - gets button press information }
- { x and y values are scaled for text }
- function mousepress(button: word;
- var count, lastx, lasty: word): word;
-
- {---------------------------------------------------------------------------}
- { function 6 - gets button release information }
- { x and y values are scaled for text }
- function mouserelease(button: word;
- var count, lastx, lasty: word): word;
-
- {---------------------------------------------------------------------------}
- { functions 7 and 8 - sets area where the mouse is allowed to run }
- { x and y values are scaled for text }
- procedure setmousearea(x1,y1,x2,y2: word);
-
- {---------------------------------------------------------------------------}
- { functions 7 and 8 - sets area where the mouse is allowed to run }
- { x and y values are scaled for graphics }
- procedure setmouseboxarea(var r);
-
- {---------------------------------------------------------------------------}
- { function 9 - sets the graphics cursor shape }
- procedure mousegraphiccursor(shape: integer);
-
- {---------------------------------------------------------------------------}
- { function 9 - sets a custom graphics cursor shape }
- procedure setmousegraphiccursor(var mask:masktype);
-
- {---------------------------------------------------------------------------}
- { function 10 - sets the text cursor shape }
- procedure mousetextcursor(select, start, stop: word);
-
- {---------------------------------------------------------------------------}
- { function 11 - read mouse motion counters }
- procedure readmickey(var x, y: word);
-
- {---------------------------------------------------------------------------}
- { function 12 - set mouse interrupt service routine and mask }
- procedure setmouseisr(mask:word; var address);
-
- {---------------------------------------------------------------------------}
- { function 13 and 14 - light pen emulation on/off }
- procedure lightpen(flag: boolean);
-
- {---------------------------------------------------------------------------}
- { function 15 - sets the mickey to pixel ratio }
- procedure setpixeltomickey(x, y: word);
-
- {---------------------------------------------------------------------------}
- { function 16 - conditional mouse hide - hides mouse if in text area }
- procedure hidemousearea(x1,y1,x2,y2: word);
-
- {---------------------------------------------------------------------------}
- { function 16 - conditional mouse hide - hides mouse if in graphics area }
- procedure hidemouseboxarea(var r);
-
- {---------------------------------------------------------------------------}
- { function 19 - set double speed threshold }
- procedure mousethreshold(threshold:word);
-
- {---------------------------------------------------------------------------}
- { function 20 - swap current mouse isr with a new one}
- { returns old isr and mask in the calling variables }
- procedure swapmouseisr(var mask:word; var address);
-
- {---------------------------------------------------------------------------}
- { function 29 - set mouse page }
- procedure setmousepage(page: word);
-
- {---------------------------------------------------------------------------}
- { function 30 - get mouse page }
- function getmousepage: word;
-
-
- {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
- { the following procedures use the mouse functions to provide }
- { a higher level of control over the mouse }
-
- {---------------------------------------------------------------------------}
- { checks if mouse is currently inside specified text area }
- function mousein(x1,y1,x2,y2: word):boolean;
-
- {---------------------------------------------------------------------------}
- { checks if mouse is currently inside specified graphic area }
- function mouseinbox(var r): boolean;
-
- {---------------------------------------------------------------------------}
- {has the mouse been clicked recently?}
- function mouseclick: boolean;
-
- {---------------------------------------------------------------------------}
- { checks if mouse was inside specified text area when clicked }
- function mouseclickin(x1,y1,x2,y2: word): boolean;
-
- {---------------------------------------------------------------------------}
- { checks if mouse was inside specified graphic area when clicked }
- function mouseclickinbox(var r): boolean;
-
- {---------------------------------------------------------------------------}
- {pushes current mouse status on the mouse stack}
- {returns false if not enough heap space to push}
- function pushmouse: boolean;
-
- {---------------------------------------------------------------------------}
- {pops mouse status from the mouse stack.}
- function popmouse: boolean;
-
- {---------------------------------------------------------------------------}
- {get rid of mouse stack}
- procedure zapmousestack;
-
- {***************************************************************************}
-
- implementation
-
- {---------------------------------------------------------------------------}
- { local mouse stuff }
-
- type
- mrect = record
- x1,y1,x2,y2 : word; {defines a mouse rectangle}
- end;
-
- mouseptrp = ^mouseptrrec; {defines a mouse stack record}
- mouseptrrec = record {prev points to previous stack record on heap}
- prev : mouseptrp; {if nil then is top record on stack}
- buf : pointer; {buf points to the mouse data saved}
- size : integer; {size = bytes in the mouse buffer}
- end;
- {array of predefined cursors}
- mgcarray = array [1..maxmousecursorshape] of masktype;
-
- {---------------------------------------------------------------------------}
- var
- mouse_reg : registers; {registers used to call mouse interrupt}
- mousestack : mouseptrp; {mousestack points to last rec on mouse stack}
- {if nil then there is nothing on the stack}
-
- {---------------------------------------------------------------------------}
- const
-
- mousecursor: mgcarray = {a predefined list of mouse graphic cursors}
-
- { standard }
- ((def: (($3fff,$1fff,$0fff,$07ff,$03ff,$01ff,$00ff,$007f, { screen mask }
- $003f,$001f,$01ff,$10ff,$30ff,$f87f,$f87f,$fc7f),
-
- ($0000,$4000,$6000,$7000,$7800,$7c00,$7e00,$7f00, { cursor mask }
- $7f80,$7c00,$6c00,$4600,$0600,$0300,$0300,$0000));
-
- hotx: -1; hoty: -1), { hot spot }
-
- { uparrow }
- (def: (($f9ff,$f0ff,$e07f,$e07f,$c03f,$c03f,$801f,$801f,
- $000f,$000f,$f0ff,$f0ff,$f0ff,$f0ff,$f0ff,$f0ff),
-
- ($0000,$0600,$0f00,$0f00,$1f80,$1f80,$3fc0,$3fc0,
- $7fe0,$0600,$0600,$0600,$0600,$0600,$0600,$0000));
-
- hotx: 5; hoty: 0),
-
- { downarrow }
- (def: (($f0ff,$f0ff,$f0ff,$f0ff,$f0ff,$f0ff,$000f,$000f,
- $801f,$801f,$c03f,$c03f,$e07f,$e07f,$f0ff,$f9ff),
-
- ($0000,$0600,$0600,$0600,$0600,$0600,$0600,$7fe0,
- $3fc0,$3fc0,$1f80,$1f80,$0f00,$0f00,$0600,$0000));
-
- hotx: 5; hoty: 15),
-
- { leftarrow }
- (def: (($fe1f,$f01f,$0000,$0000,$0000,$f01f,$fe1f,$ffff,
- $ffff,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff),
-
- ($0000,$00c0,$07c0,$7ffe,$07c0,$00c0,$0000,$0000,
- $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000));
-
- hotx: 0; hoty: 3),
-
- { rightarrow }
- (def: (($f87f,$f80f,$0000,$0000,$0000,$f80f,$f87f,$ffff,
- $ffff,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff),
-
- ($0000,$0300,$03e0,$7ffe,$03e0,$0300,$0000,$0000,
- $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000));
-
- hotx: 15; hoty: 3),
-
- { checkmark }
- (def: (($fff0,$ffe0,$ffc0,$ff03,$0607,$000f,$001f,$c03f,
- $f07f,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff),
-
- ($0000,$0006,$000c,$0018,$0030,$0060,$70c0,$1d80,
- $0700,$0000,$0000,$0000,$0000,$0000,$0000,$0000));
-
- hotx: 6; hoty: 7),
-
- { uphand }
- (def: (($e1ff,$e1ff,$e1ff,$e1ff,$e000,$e000,$e000,$0000, { screen mask }
- $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000),
-
- ($1e00,$1200,$1200,$1200,$13ff,$1249,$1249,$f249, { cursor mask }
- $9001,$9001,$9001,$8001,$8001,$8001,$8001,$ffff));
-
- hotx: 5; hoty: 0), { hot spot }
-
- { downhand }
- (def: (($0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,
- $0000,$e000,$e000,$e000,$e1ff,$e1ff,$e1ff,$e1ff),
-
- ($ffff,$8001,$8001,$8001,$8001,$9001,$9001,$9001,
- $f249,$1249,$1249,$13ff,$1200,$1200,$1200,$1e00));
-
- hotx: 5; hoty: 15),
-
- { lefthand }
- (def: (($ffff,$ff8f,$ff07,$ff03,$ff81,$8000,$0000,$0000,
- $0000,$8000,$f000,$f800,$f800,$fc00,$fc01,$fc03),
-
- ($0000,$0000,$0070,$0048,$0024,$0032,$7ff2,$800a,
- $7ff6,$0412,$07f2,$0212,$03f2,$0116,$01fc,$0000));
-
- hotx: 0; hoty: 7),
-
- { righthand }
- (def: (($ffff,$f1ff,$e0ff,$c0ff,$81ff,$0001,$0000,$0000,
- $0000,$0001,$000f,$001f,$001f,$003f,$803f,$c03f),
-
- ($0000,$0000,$0e00,$1200,$2400,$4c00,$4ffe,$5001,
- $6ffe,$4820,$4fe0,$4840,$4fc0,$6880,$3f80,$0000));
-
- hotx: 15; hoty: 7),
-
- { stophand }
- (def: (($fe3f,$f80f,$f007,$f003,$f001,$f001,$0001,$0001,
- $0001,$0001,$8001,$c001,$c001,$e003,$f007,$f80f),
-
- ($0000,$01c0,$0770,$0550,$055c,$0554,$0554,$7554,
- $5554,$4ffc,$2804,$1004,$180c,$0c18,$07f0,$0000));
-
- hotx: 7; hoty: 7),
-
- { hourglass }
- (def: (($0000,$0000,$0000,$0000,$8001,$c003,$e007,$f00f,
- $e007,$c003,$8001,$0000,$0000,$0000,$0000,$ffff),
-
- ($0000,$7ffe,$6006,$300c,$1818,$0c30,$0660,$03c0,
- $0660,$0c30,$1998,$33cc,$67e6,$7ffe,$0000,$0000));
-
- hotx: 7; hoty: 7),
-
- { diagcross }
- (def: (($07e0,$0180,$0000,$c003,$f00f,$c003,$0000,$0180,
- $07e0,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff),
-
- ($0000,$700e,$1c38,$0660,$03c0,$0660,$1c38,$700e,
- $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000));
-
- hotx: 7; hoty: 4),
-
- { rectcross }
- (def: (($fc3f,$fc3f,$fc3f,$0000,$0000,$0000,$fc3f,$fc3f,
- $fc3f,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff),
-
- ($0000,$0180,$0180,$0180,$7ffe,$0180,$0180,$0180,
- $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000));
-
- hotx: 7; hoty: 4),
-
-
- { these cursors need to be updated yet }
- { rectbox }
- (def: (($ffff,$ffff,$0000,$0000,$0000,$1ff8,$1ff8,$1ff8,
- $1ff8,$1ff8,$1ff8,$1ff8,$0000,$0000,$0000,$ffff),
-
- ($0000,$0000,$0000,$7ffe,$4002,$4002,$4002,$4002,
- $4002,$4002,$4002,$4002,$4002,$7ffe,$0000,$0000));
-
- hotx: 7; hoty: 8),
-
- { targetcross }
- (def: (($ffff,$ffff,$fc7f,$fc7f,$fc7f,$fc7f,$fc7f,$06c1,
- $0101,$06c1,$fc7f,$fc7f,$fc7f,$fc7f,$fc7f,$ffff),
-
- ($0000,$0000,$0000,$0100,$0100,$0100,$0100,$0000,
- $783c,$0000,$0100,$0100,$0100,$0100,$0000,$0000));
-
- hotx: 7; hoty: 4),
-
- { targetcircle }
- (def: (($ffff,$ffff,$f01f,$c007,$8003,$0001,$0c61,$06c1,
- $0101,$06c1,$0c61,$0001,$8003,$c007,$f01f,$ffff),
-
- ($0000,$0000,$0000,$07c0,$1d30,$3118,$610c,$600c,
- $783c,$600c,$610c,$3118,$1d30,$07c0,$0000,$0000));
-
- hotx: 7; hoty: 8),
-
- { targetbox }
- (def: (($ffff,$ffff,$0001,$0001,$0001,$1c71,$1c71,$06c1,
- $0101,$06c1,$1c71,$1c71,$0001,$0001,$0001,$ffff),
-
- ($0000,$0000,$0000,$7ffc,$4104,$4104,$4104,$4004,
- $783c,$4004,$4104,$4104,$4104,$7ffc,$0000,$0000));
-
- hotx: 7; hoty: 8),
-
- { questionmark }
- (def: (($ffff,$e00f,$c007,$8003,$0001,$0001,$0001,$0001,
- $0001,$0001,$0001,$0001,$0001,$8003,$c007,$e00f),
-
- ($0000,$0000,$1ff0,$3ff8,$783c,$739c,$739c,$7f3c,
- $7e7c,$7e7c,$7ffc,$7e7c,$7e7c,$3ff8,$1ff0,$0000));
-
- hotx: 7; hoty: 7));
-
-
- {---------------------------------------------------------------------------}
- { an inline function to limit an integer between min and max values}
- function intlimit(val,min,max: integer): integer;
- inline(
- $58 { pop ax}
- /$5b { pop bx}
- /$59 { pop cx}
- /$39/$c8 { cmp ax,cx}
- /$7c/$08 { jl done}
- /$89/$d8 { mov ax,bx}
- /$39/$c8 { cmp ax,cx}
- /$7f/$02 { jg done}
- /$89/$c8); { mov ax,cx}
- {done:}
-
- {***************************************************************************}
- { function 0 - initialize mouse software and hardware }
-
- procedure initmouse;
- begin
- mouse_reg.ax := 0; {tell the mouse to start over from scratch}
- intr($33,mouse_reg);
- mouse_error := mouse_reg.ax;
- mouse_type := mouse_reg.bx;
- mouse_installed := mouse_error = -1; {<-- check if mouse is out there}
- end;
-
- {---------------------------------------------------------------------------}
- { function 1 - show mouse cursor }
-
- procedure showmouse;
- begin
- if not(mouse_installed) then exit; {<-- can't do this, no mouse}
- mouse_reg.ax := 1;
- intr($33,mouse_reg);
- end;
-
- {---------------------------------------------------------------------------}
- { function 2 - hide mouse cursor }
-
- procedure hidemouse;
- begin
- if not(mouse_installed) then exit; {<-- can't do this, no mouse}
- mouse_reg.ax := 2;
- intr($33,mouse_reg);
- end;
-
- {---------------------------------------------------------------------------}
- { function 3 - read current mouse position and button status }
- { x and y values are scaled for text }
-
- procedure readmouse;
- begin
- if not(mouse_installed) then exit; {<-- can't do this, no mouse}
- mouse_reg.ax := 3;
- intr($33,mouse_reg); {get the current mouse status}
- with mouse_reg do
- begin
- real_mousex := cx; {save real mouse x and y values}
- real_mousey := dx;
- mousex := (cx div mousetextwidth); {save the x and y coordinates}
- mousey := (dx div mousetextheight);
- if (bx <> mouse_buttons) and (bx <> 0) then {<-- new button down?}
- begin
- mouse_click_button := bx; {if button down save which one}
- click_mousex := mousex; {and the current x,y}
- click_mousey := mousey;
- mouse_clicked := true; {tell them it was clicked}
- end;
- mouse_buttons := bx; {<-- save the current button status}
- end;
- end;
-
- {---------------------------------------------------------------------------}
- { function 4 - sets mouse position }
- { x and y values are scaled for text }
-
- procedure setmouseposition(x,y: word);
- begin
- if not(mouse_installed) then exit; {<-- can't do this, no mouse}
- mouse_reg.ax := 4;
- mouse_reg.cx := (x*mousetextwidth); {tell mouse where to go}
- mouse_reg.dx := (y*mousetextheight);
- intr($33,mouse_reg);
- mousex := x; {update local vars}
- mousey := y;
- end;
-
- {---------------------------------------------------------------------------}
- { function 4 - sets mouse position }
- { x and y values are scaled for graphics}
-
- procedure setmousepoint(x,y: word);
- begin
- if not(mouse_installed) then exit; {<-- can't do this, no mouse}
- mouse_reg.ax := 4;
- mouse_reg.cx := x; {tell mouse where to go}
- mouse_reg.dx := y;
- intr($33,mouse_reg);
- mousex := x div mousetextwidth; {update local vars}
- mousey := y div mousetextheight;
- end;
-
- {---------------------------------------------------------------------------}
- { function 5 - gets button press information }
- { x and y values are scaled for text }
-
- function mousepress(button: word;
- var count, lastx, lasty: word): word;
- begin
- if mouse_installed then {check if mouse installed}
- begin
- mouse_reg.ax := 5;
- mouse_reg.bx := button; {request info on the button}
- intr($33,mouse_reg);
- mousepress := mouse_reg.ax;
- count := mouse_reg.bx; {return the info for the button}
- lastx := (mouse_reg.cx div mousetextwidth);
- lasty := (mouse_reg.dx div mousetextheight);
- end
- else
- begin
- mousepress := 0; {if no mouse everything comes back as zero}
- lastx := 0;
- lasty := 0;
- count := 0;
- end;
- end;
-
- {---------------------------------------------------------------------------}
- { function 6 - gets button release information }
- { x and y values are scaled for text }
-
- function mouserelease(button: word;
- var count, lastx, lasty: word): word;
- begin
- if mouse_installed then {check if mouse installed}
- begin
- mouse_reg.ax := 6;
- mouse_reg.bx := button; {request info on the button}
- intr($33,mouse_reg);
- mouserelease := mouse_reg.ax;
- count := mouse_reg.bx; {return the info for the button}
- lastx := (mouse_reg.cx div mousetextwidth);
- lasty := (mouse_reg.dx div mousetextheight);
- end
- else
- begin
- mouserelease := 0; {if no mouse everything comes back as zero}
- lastx := 0;
- lasty := 0;
- count := 0;
- end;
- end;
-
- {---------------------------------------------------------------------------}
- { functions 7 and 8 - sets area where the mouse is allowed to run }
- { x and y values are scaled for text }
-
- procedure setmousearea(x1,y1,x2,y2: word);
- begin
- if not(mouse_installed) then exit; {<-- can't do this, no mouse}
- mouse_reg.ax := 7;
- mouse_reg.cx := (x1*mousetextwidth); {set the x values}
- mouse_reg.dx := (x2*mousetextwidth);
- intr($33,mouse_reg);
- mouse_reg.ax := 8;
- mouse_reg.cx := (y1*mousetextheight); {set the y values}
- mouse_reg.dx := (y2*mousetextheight);
- intr($33,mouse_reg);
- end;
-
- {---------------------------------------------------------------------------}
- { functions 7 and 8 - sets area where the mouse is allowed to run }
- { x and y values are scaled for graphics }
-
- procedure setmouseboxarea(var r);
- begin
- if not(mouse_installed) then exit; {<-- can't do this, no mouse}
- mouse_reg.ax := 7;
- mouse_reg.cx := mrect(r).x1; {set the x values}
- mouse_reg.dx := mrect(r).x2;
- intr($33,mouse_reg);
- mouse_reg.ax := 8;
- mouse_reg.cx := mrect(r).y1; {set the y values}
- mouse_reg.dx := mrect(r).y2;
- intr($33,mouse_reg);
- end;
-
- {---------------------------------------------------------------------------}
- { function 9 - sets a custom graphics cursor shape }
-
- procedure setmousegraphiccursor(var mask:masktype);
- begin
- if not(mouse_installed) then exit; {<-- can't do this, no mouse}
- mouse_reg.ax := 9;
- mouse_reg.bx := mask.hotx; { set the hot spot }
- mouse_reg.cx := mask.hoty;
- mouse_reg.es := seg(mask.def);
- mouse_reg.dx := ofs(mask.def); { set the new cursor shape }
- intr($33, mouse_reg);
- end;
-
- {---------------------------------------------------------------------------}
- { function 9 - sets the graphics cursor shape }
- { graphic cursor routine borrowed from egamouse }
-
- procedure mousegraphiccursor(shape:integer);
- begin
- if not(mouse_installed) then exit; {<-- can't do this, no mouse}
- with mousecursor[intlimit(shape,1,maxmousecursorshape)] do
- begin
- mouse_reg.ax := 9;
- mouse_reg.bx := hotx; { set the hot spot }
- mouse_reg.cx := hoty;
- mouse_reg.es := seg(def);
- mouse_reg.dx := ofs(def); { set the new cursor shape }
- intr($33, mouse_reg);
- end;
- end;
-
- {---------------------------------------------------------------------------}
- { function 10 - sets the text cursor shape }
-
- procedure mousetextcursor(select, start, stop: word);
- begin
- if not(mouse_installed) then exit; {<-- can't do this, no mouse}
- mouse_reg.ax := 10;
- mouse_reg.bx := select; {select the cursor type}
- mouse_reg.cx := start; {and the start/stop values}
- mouse_reg.dx := stop; {(or screen/cursor masks)}
- intr($33, mouse_reg);
- end;
-
- {---------------------------------------------------------------------------}
- { function 11 - read mouse motion counters }
-
- procedure readmickey(var x, y: word);
- begin
- if mouse_installed then {check if mouse installed}
- begin
- mouse_reg.ax := 11;
- intr($33, mouse_reg);
- x := mouse_reg.cx; {return mickey values}
- y := mouse_reg.dx;
- end
- else
- begin
- x := 0; {if no mouse return zero values}
- y := 0;
- end;
- end;
-
- {---------------------------------------------------------------------------}
- { function 12 - set mouse interrupt service routine and mask }
-
- procedure setmouseisr(mask:word; var address);
- type arec = record lo, hi: word; end;
- var a : arec absolute address;
- begin
- if not(mouse_installed) then exit; {<-- can't do this, no mouse}
- mouse_reg.cx := mask; {<-- set the isr service mask}
- mouse_reg.es := a.hi;
- mouse_reg.dx := a.lo; {set the isr service address}
- mouse_reg.ax := 12;
- intr($33, mouse_reg);
- end;
-
- {---------------------------------------------------------------------------}
- { function 13 and 14 - light pen emulation on/off }
-
- procedure lightpen(flag:boolean);
- begin
- if not(mouse_installed) then exit; {<-- can't do this, no mouse}
- if flag then
- mouse_reg.ax := 13 {set light pen emulation on}
- else
- mouse_reg.ax := 14; {set light pen emulation off}
- intr($33,mouse_reg)
- end;
-
-
- {---------------------------------------------------------------------------}
- { function 15 - sets the mickey to pixel ratio }
-
- procedure setpixeltomickey(x, y: word);
- begin
- if not(mouse_installed) then exit; {<-- can't do this, no mouse}
- mouse_reg.ax := 15;
- mouse_reg.cx := x; {set the new mickey values}
- mouse_reg.dx := y;
- intr($33,mouse_reg)
- end;
-
-
- {---------------------------------------------------------------------------}
- { function 16 - conditional mouse hide - hides mouse if in text area }
- { use showmouse after using this function - just like regular hidemouse }
-
- procedure hidemousearea(x1,y1,x2,y2: word);
- begin
- if not(mouse_installed) then exit; {<-- can't do this, no mouse}
- mouse_reg.ax := 16;
- mouse_reg.cx := (x1*mousetextwidth); {set the x and y values}
- mouse_reg.dx := (x2*mousetextwidth);
- mouse_reg.si := (y1*mousetextheight);
- mouse_reg.di := (y2*mousetextheight);
- intr($33,mouse_reg);
- end;
-
- {---------------------------------------------------------------------------}
- { function 16 - conditional mouse hide - hides mouse if in graphics area }
- { use showmouse after using this function - just like regular hidemouse }
-
- procedure hidemouseboxarea(var r);
- begin
- if not(mouse_installed) then exit; {<-- can't do this, no mouse}
- mouse_reg.ax := 16;
- mouse_reg.cx := mrect(r).x1; {set the x and y values}
- mouse_reg.dx := mrect(r).x2;
- mouse_reg.si := mrect(r).y1;
- mouse_reg.di := mrect(r).y2;
- intr($33,mouse_reg);
- end;
-
- {---------------------------------------------------------------------------}
- { function 19 - set double speed threshold }
-
- procedure mousethreshold(threshold:word);
- begin
- if not(mouse_installed) then exit; {<-- can't do this, no mouse}
- mouse_reg.ax := 19;
- mouse_reg.dx := threshold; {set the new threshold value}
- intr($33,mouse_reg)
- end;
-
-
- {---------------------------------------------------------------------------}
- { function 20 - swap current mouse isr with a new one}
- { returns old isr and mask in the calling variables }
-
- procedure swapmouseisr(var mask:word; var address);
- type arec = record lo, hi: word; end;
- var a : arec absolute address;
- begin
- if not(mouse_installed) then exit; {<-- can't do this, no mouse}
- mouse_reg.cx := mask; {<-- set new isr service mask}
- mouse_reg.es := a.hi;
- mouse_reg.dx := a.lo; {set new isr service address}
- mouse_reg.ax := 20;
- intr($33,mouse_reg);
- mask := mouse_reg.cx; {<-- get old isr service mask}
- a.hi := mouse_reg.es;
- a.lo := mouse_reg.dx; {get old isr service address}
- end;
-
- {---------------------------------------------------------------------------}
- { function 29 - set mouse page }
-
- procedure setmousepage(page:word);
- begin
- if not(mouse_installed) then exit; {<-- can't do this, no mouse}
- mouse_reg.ax := 29;
- mouse_reg.bx := page; {set the new threshold value}
- intr($33,mouse_reg)
- end;
-
- {---------------------------------------------------------------------------}
- { function 30 - get mouse page }
-
- function getmousepage:word;
- begin
- if not(mouse_installed) then exit; {<-- can't do this, no mouse}
- mouse_reg.ax := 29;
- intr($33,mouse_reg);
- getmousepage := mouse_reg.bx; {get the new threshold value}
- end;
-
-
- {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
- { the following procedures use the mouse functions to provide }
- { a higher level of control over the mouse }
-
- {---------------------------------------------------------------------------}
- {check if mouse is currently in the specified area}
- {returns true if it is, false if not}
- { x and y values scaled for text mode }
-
- function mousein(x1,y1,x2,y2:word):boolean;
- begin
- mousein := false; {<-- assume it won't be in the area first}
- if not(mouse_installed) then exit; {<-- can't do this, no mouse}
- readmouse; {<-- find out where thhe mouse is}
- if (mousex >= x1) and
- (mousex <= x2) and {check if it is in the area}
- (mousey >= y1) and
- (mousey <= y2)
- then mousein := true; {<-- return true if it is}
- end;
-
-
- {---------------------------------------------------------------------------}
- { check if mouse is currently in the specified box area }
- { returns true if it is, false if not }
- { x and y values are scaled for graphics }
-
- function mouseinbox(var r):boolean;
- begin
- mouseinbox := false; {<-- assume it won't be in the area first}
- if not(mouse_installed) then exit; {<-- can't do this, no mouse}
- readmouse; {<-- find out where thhe mouse is}
- if (mousex * mousetextwidth >= mrect(r).x1) and
- (mousex * mousetextwidth <= mrect(r).x2) and {check if in the box area}
- (mousey * mousetextheight >= mrect(r).y1) and
- (mousey * mousetextheight <= mrect(r).y2)
- then mouseinbox := true; {<-- return true if it is}
- end;
-
-
- {---------------------------------------------------------------------------}
- function mouseclick:boolean; {has the mouse been clicked recently?}
- begin
- mouseclick := mouse_clicked; {get a copy of the click status}
- mouse_clicked := false; {then clear the status}
- end;
-
- {---------------------------------------------------------------------------}
- {check if mouse was in the specified area when clicked.}
- {returns true if it was, false if not.}
- { x and y values scaled for text mode }
-
- function mouseclickin(x1,y1,x2,y2:word):boolean;
- begin
- mouseclickin := false;
- if not(mouse_installed) then exit; {<-- can't do this, no mouse}
- if (click_mousex >= x1) and
- (click_mousex >= x2) and {check if it is in the area}
- (click_mousey >= y1) and
- (click_mousey <= y2)
- then mouseclickin := true; {<-- return true if it is}
- end;
-
- {---------------------------------------------------------------------------}
- {check if mouse was in the specified area when clicked.}
- {returns true if it was, false if not.}
- { x and y values are scaled for graphics }
-
- function mouseclickinbox(var r):boolean;
- begin
- mouseclickinbox := false;
- if not(mouse_installed) then exit; {<-- can't do this, no mouse}
- if (click_mousex * mousetextwidth >= mrect(r).x1) and
- (click_mousex * mousetextwidth <= mrect(r).x2) and
- (click_mousey * mousetextheight >= mrect(r).y1) and {check if in box area}
- (click_mousey * mousetextheight <= mrect(r).y2)
- then mouseclickinbox := true; {<-- return true if it is}
- end;
-
- {---------------------------------------------------------------------------}
- function pushmouse:boolean; {pushes current mouse status on the mouse stack}
- var ptemp : mouseptrp; {returns false if not enough heap space to push}
-
- begin
- pushmouse := false; {<-- assume no good to begin with}
- if not(mouse_installed) then exit; {<-- can't do this, no mouse}
- mouse_reg.ax := 21; {find out how much data to save}
- intr($33,mouse_reg); {then check to see if it can be saved}
- if maxavail < ( mouse_reg.bx + sizeof(mouseptrrec) ) then exit;
- ptemp := mousestack; {<-- save old stack pointer}
- getmem(mousestack,sizeof(mouseptrrec)); {<-- get a new pointer record}
- with mousestack^ do
- begin
- prev := ptemp; {<-- link in old stack pointer}
- size := mouse_reg.bx; {<-- save how big the data is}
- getmem(buf,size); {<-- grab some buffer space for the data}
- mouse_reg.ax := 22;
- mouse_reg.es := seg(buf^); {save the mouse data in the buffer}
- mouse_reg.dx := ofs(buf^);
- intr($33,mouse_reg);
- end;
- pushmouse := true; {<-- tell them we made it}
- end;
-
- {---------------------------------------------------------------------------}
- function popmouse:boolean; {pops mouse status from the mouse stack.}
- var ptemp : mouseptrp; {returns false if nothing to pop.}
-
- begin
- popmouse := false; {<-- assume no good to begin with}
- if not(mouse_installed) then exit; {<-- can't do this, no mouse}
- if mousestack = nil then exit; {<-- nothing in the stack to pop}
- with mousestack^ do
- begin
- mouse_reg.ax := 23;
- mouse_reg.es := seg(buf^); {restore mouse data from the stack}
- mouse_reg.dx := ofs(buf^);
- intr($33,mouse_reg);
- ptemp := prev; {<-- unlink the prev pointer}
- freemem(buf,size); {and free up the heap space}
- freemem(mousestack,sizeof(mouseptrrec));
- mousestack := ptemp; {<-- update stack pointer}
- end;
- popmouse := true; {<-- tell them we made it}
- end;
-
- {---------------------------------------------------------------------------}
- procedure zapmousestack; {get rid of mouse stack}
- var ptemp : mouseptrp;
-
- begin
- while mousestack <> nil do {pop the stack until it is empty}
- with mousestack^ do
- begin
- ptemp := prev; {<-- unlink the prev pointer}
- freemem(buf,size); {and free up the heap space}
- freemem(mousestack,sizeof(mouseptrrec));
- mousestack := ptemp; {<-- update stack pointer}
- end;
- end;
-
- {***************************************************************************}
- {initialization section}
-
- begin
- mousetextwidth := 8; {size of text on screen for mouse}
- mousetextheight := 8;
- mousestack := nil;
- mouse_installed := false;
- mouse_buttons := 0;
- mouse_click_button := 0;
- mousex := 1;
- mousey := 1;
- click_mousex := 1;
- click_mousey := 1;
- mouse_clicked := false;
- initmouse;
- end.
-
- {***************************************************************************}
- { eof }
-