home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
APPS
/
dm14.lzh
/
mspak.h
< prev
next >
Wrap
Text File
|
2009-11-06
|
6KB
|
245 lines
# asm
nam MsPak
ttl subroutine library
**********************************
* *
* MsPak.h *
* *
**********************************
* J.F.Adamthwaite 88/08/31
* This is a collection of mouse driver subroutines
* which allows a C program to access the mouse.
* It is used as an include file at compilation time
*
* Use: #include mspak.h
vsect
Ms_Path ds.w 1 mouse path no. store
ends
org 0
Ms.Abs: do.b 1 return absolute mouse pos I$GetStt SVC
Ms.Rel: do.b 1 return relative mouse pos
Ms.Rdy: do.b 1 return data ready flag
Ms.Put: do.b 1 set new mouse position I$SetStt SVC
Ms.Xmm: do.b 1 set hi/low X coord limits
Ms.Ymm: do.b 1 set hi/low Y coord limits
Ms.Sns: do.b 1 set motion sensitivity
Ms.Thr: do.b 1 set double speed threshold
Ms.Pol: do.b 1 set directional polarity
* Open path to mouse device
*
* Call syntax: mp = MsOpen("/mouse");
*
* Input: (d0.l) = ptr to name string
* Returns: (d0.l) = error status <> 0 if error
MsOpen movem.l d1/a0,-(a7)
clr.w Ms_Path(a6)
move.l d0,a0 string ptr
moveq #Read_+Write_,d0 access mode = update
os9 I$Open
bcs.s OpnMs2 OK?
move.w d0,Ms_Path(a6)
clr.w d1 no errors
OpnMs2 clr.l d0 return error status as result
move.w d1,d0
movem.l (a7)+,d1/a0
rts
* Read absolute mouse position and button status.
*
* Call syntax: MsRdAbs(&lb, &rb, &mx, &my);
*
* Input: (d0.l) = ptr to left button store
* (d1.l) = ptr to right button store
* @4(a7) = ptr to X coord store
* @8(a7) = ptr to Y coord store
* Returns: above stores updated
* (d0.l) = error status (0 = OK)
MsRdAbs: movem.l d0-d5/a0,-(a7)
moveq.l #Ms.Abs,d2 absolute mouse position
MRA2 move.w Ms_Path(a6),d0 path
moveq.l #SS_Joy,d1 joystick
os9 I$GetStt
bcs.s MRA3 OK?
clr.w d1 no errors
MRA3 clr.l d0 return 32 bit
move.w d1,d0 error code
movea.l (a7),a0 lb ptr
move.l d2,(a0)
movea.l 4(a7),a0 rb ptr
move.l d3,(a0)
movea.l 32(a7),a0 x ptr
move.l d4,(a0)
movea.l 36(a7),a0 y ptr
move.l d5,(a0)
addq.l #4,a7 drop old d0 from stack
movem.l (a7)+,d1-d5/a0
rts
* Read relative change in mouse status since the
* last call to either this or MsRdAbs function.
*
* Call syntax: MsRdRel(&lb, &rb, &mx, &my);
*
* Input: (d0.l) = ptr to left button store
* (d1.l) = ptr to right button store
* @4(a7) = ptr to X coord store
* @8(a7) = ptr to Y coord store
* Returns: above stores updated
* (d0.l) = error status (0 = OK)
MsRdRel: movem.l d0-d5/a0,-(a7)
moveq.l #Ms.Rel,d2 read relative function
bra.s MRA2 use existing code
* Test if any new mouse data is ready.
*
* Call syntax: z = MsReady();
*
* Input: none
* Output: (d0.l) = 0 if no data, 1 if ready
MsReady: movem.l d1-d2,-(a7)
move.w Ms_Path(a6),d0 path
moveq #SS_Joy,d1 joystick
moveq.l #Ms.Rdy,d2 ready status function
os9 I$GetStt
bcc.s MsR2 OK?
moveq #0,d2 no data if error
MsR2 move.l d2,d0
movem.l (a7)+,d1-d2
rts
* Set new mouse position.
*
* Call syntax: MsSetPos(newX, newY);
*
* Input: (d0.l) = new mouse X coord
* (d1.l) = new mouse Y coord
* Output: (d0.l) = error status (0 = OK)
MsSetPos: movem.l d1-d5,-(a7)
moveq.l #Ms.Put,d2 set position sub-function
MSP2 move.l d0,d4 params into d4,d5
move.l d1,d5
move.w Ms_Path(a6),d0 path
moveq.l #SS_Joy,d1 joystick SCF function
os9 I$SetStt
bcc.s MSP3 OK?
clr.w d1 no errors
MSP3 clr.l d0 return 32 bit error code
move.w d1,d0
movem.l (a7)+,d1-d5
rts
* Set horizontal min & max coords
*
* Call syntax: MsMnMxXPos(minX, minY);
*
* Input: (d0.l) = minimum (most negative) X coord
* (d1.l) = maximum (most positive) X coord
* Output: (d0.l) = error status (0 = OK)
MsMnMxX: movem.l d1-d5,-(a7)
moveq.l #Ms.Xmm,d2 Xminmax sub-function
bra.s MSP2 conserve code
* Set vertical min & max coords
*
* Call syntax: MsMnMxY(minY, minX);
*
* Input: (d0.l) = minimum (most negative) Y coord
* (d1.l) = maximum (most positive) Y coord
* Output: (d0.w) = error status (0 = OK)
MsMnMxY: movem.l d1-d5,-(a7)
moveq.l #Ms.Ymm,d2 Yminmax sub-function
bra.s MSP2
* Set mouse motion sensitivity.
*
* Call syntax: MsSetSns(mickX, mickY);
*
* Input: (d0.l) = X mickeys per coord unit
* (d1.l) = Y mickeys per coord unit
* OutPut: (d0.l) = error status (0 = OK)
MsSetSns: movem.l d1-d5,-(a7)
moveq.l #Ms.Sns,d2 mickeys/coord unit sub-func
bra.s MSP2
* Set double speed threshold.
*
* Call syntax: MsSetDbl(xThresh, yThresh);
*
* Input: (d0.l) = X mickeys per second
* (d1.l) = Y mickeys per second
* OutPut: (d0.l) = error status (0 = OK)
MsSetDbl: movem.l d1-d5,-(a7)
moveq.l #Ms.Thr,d2 threshold sub-function
bra.s MSP2
* Set the directional sense of the mouse.
*
* Call syntax: MsSetPol(dirX, dirY);
*
* Input: (d0.l) = x polarity.
* +1 sets: right motion = more positive coords.
* -1 sets: right motion = more negative coords.
*
* (d1.l) = y polarity.
* +1 sets: up motion = more positive coords.
* -1 sets: up motion = more negative coords.
MsSetPol: movem.l d1-d5,-(a7)
moveq.l #Ms.Pol,d2 polarity function
bra.s MSP2
* Tell driver to call main program F$Icpt handler
* whenever mouse data is ready. The signal code
* equals SS_Joy ($13) for signal identification.
* Reduces system overhead of polling mouse status.
* Must be called each time it is acted on.
*
* Call syntax: MsSetTrp();
*
* Input: none
* OutPut: (d0.l) = error status (0 = OK)
*
MsSetTrp: movem.l d1-d2,-(a7)
move.w Ms_Path(a6),d0 path
moveq #SS_SSig,d1 send_signal function
move.w #SS_Joy,d2 actual signal to send
os9 I$SetStt set it
bcc.s MsST2 OK?
clr.w d1 no errors
MsST2 clr.l d0 return 32 bit error code
move.w d1,d0
movem.l (a7)+,d1-d2
rts
# endasm