home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
tipi
/
mouse.tpi
< prev
next >
Wrap
Text File
|
1993-11-02
|
2KB
|
99 lines
# MOUSE.TPI
# Demos the use of the MOUSE instruction
# 9/21/93 by Kent Peterson
define InitMouse ( -- n )
# Checks if a mouse is available and initializes it.
# This should be called before you try to do anything
# with a mouse.
# If n is 0, there is no mouse
0 0 0 0 mouse
drop drop drop
enddef
define MouseButtons ( -- n )
# Returns the current state of the mouse buttons
# if n = 0 no buttons are pressed
# if n = 1 the left button is pressed
# if n = 2 the right button is pressed
# if n = 3 both buttons are pressed
3 0 0 0 mouse
drop drop swap drop
enddef
define MouseCol ( -- col )
# Returns the column of the mouse cursor
3 0 0 0 mouse
drop swap drop swap drop 8 /
enddef
define MouseRow ( -- row )
# Returns the row of the mouse cursor
3 0 0 0 mouse
swap drop swap drop swap drop 8 /
enddef
define ShowMouse ( -- )
# Makes the mouse cursor visible
1 0 0 0 mouse
drop drop drop drop
enddef
define HideMouse ( -- )
# Makes the mouse cursor visible
2 0 0 0 mouse
drop drop drop drop
enddef
define StackVoodoo ( n m x -- )
# This is a weird little instruction to put the stack
# into the proper form and then calls MOUSE.
rot rot 0 rot 8 * rot 8 * swap
mouse drop drop drop drop
enddef
define MouseLocate ( row col -- )
# Places the mouse at row, col.
4 StackVoodoo
enddef
define MouseRowLimit ( leftrow rightrow -- )
# Limits the mouse travel to the area from leftrow to rightrow.
8 StackVoodoo
enddef
define MouseColLimit ( leftcol rightcol -- )
# Limits the mouse travel to the area from leftcol to rightcol.
7 StackVoodoo
enddef
InitMouse not if "No Mouse!" print$ bye endif
5 20 MouseRowLimit
10 70 MouseColLimit
10 45 MouseLocate
0 cursor # hide the normal cursor
ShowMouse
cls
"Press any key to end the program" print$
begin
2 0 locate "Mouse Row is " print$ MouseRow print " " print$ cr
"Mouse Column is " print$ MouseCol print " " print$ cr
"The following buttons are pressed " print$
MouseButtons
case 1 of "LEFT " endof
2 of "RIGHT" endof
3 of "BOTH " endof
default "NONE "
endcase
print$
key until
HideMouse
1 cursor