home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Black Box 4
/
BlackBox.cdr
/
progbas
/
apb16.arj
/
MOUSEI.ASM
< prev
next >
Wrap
Assembly Source File
|
1990-12-20
|
3KB
|
136 lines
Title Mouse routines for ApBasic
Page 60,130
; Created 11-12-1987 k. murray
;
Comment *
These routines allow interrupt driven mouse control.
The subprograms are defined as:
SUB SetMouseTrap CondMask%,TrapNo% External "MouseI.Com"
SUB ResetMouseTrap External "" 3
SUB GetMouseInfo CondMask%,Hpos%,Vpos%,Buttons% External "" 6
Updates:
None.
*
Cseg Segment byte public 'Code'
Assume Cs:Cseg,Ds:nothing,Es:nothing
Start:
Jmp SetMouseTrap ; set a trap for mouse interrupt
Jmp near ptr ResetMouseTrap ; reset mouse trap
Jmp GetMouseInfo ; get info returned from trap
;
; Some data locations
ProgDs Dw 0 ; Program's Data segment for int routine
TrapMask Dw 0,0 ; mask to use on trap doubleword
RT_CondMask Dw 0 ; Returned condition mask
RT_HPos Dw 0 ; Returned horizontal position
RT_VPos Dw 0 ; Returned vertical position
RT_Buttons Dw 0 ; Returned buttons status
;
Comment *
SUB GetMouseInfo CondMask%,Hpos%,Vpos%,Buttons%
Stack frame:
Bp+12 CondMask%
Bp+10 Hpos%
Bp+8 Vpos%
Bp+6 Buttons%
*
GetMouseInfo proc far
Push Bp
Mov Bp,Sp
Mov Ax,Cs:RT_CondMask
Mov Bx,[Bp+12]
Mov [Bx],Ax
Mov Ax,Cs:RT_HPos
Mov Bx,[Bp+10]
Mov [Bx],Ax
Mov Ax,Cs:RT_VPos
Mov Bx,[Bp+8]
Mov [Bx],Ax
Mov Ax,Cs:RT_Buttons
Mov Bx,[Bp+6]
Mov [Bx],Ax
Pop Bp
Ret 4*2 ; remove 4 parameters
GetMouseInfo endp
;
;
Comment *
SUB SetMouseTrap CondMask%, TrapNo%
Stack frame:
Bp+8 CondMask%
Bp+6 TrapNo% adr.
Bp+4 Return segment
Bp+2 Return offset
Bp+0 Saved Bp
*
SetMouseTrap Proc Far
Push Bp
Mov Bp,Sp
Mov Cs:ProgDs,Ds ; save program Ds
Mov Bx,[Bp+6] ; Get user number adr.
Mov Cx,[Bx] ; Get user number
Dec Cx ; make relative to zero
Cmp Cx,32
Jb SetMouse2
Mov Cx,32 ; use smallest
SetMouse2:
Xor Ax,Ax
Mov Dx,Ax
Inc Ax ; set low bit
Clc ; clear carry
Jcxz SetMouse6
SetMouse4:
Rcl Ax,1
Rcl Dx,1 ; shift dword over one bit
Loop SetMouse4
SetMouse6:
Mov Cs:TrapMask,Ax
Mov Cs:TrapMask+2,Dx ; save trap mask
Mov Bx,[Bp+8]
Mov Cx,[Bx] ; get condition mask in Cx
Push Cs
Pop Es
Mov Dx,offset MouseTrap ; Es:Dx=adr. of moust trap routine
Mov Ax,12
Int 33h ; set calling routine
Pop Bp
Ret 2*2 ; remove 2 parameters
SetMouseTrap Endp
;
; Mouse call will be set to this routine
MouseTrap Proc Far
Push Ds
Push Cs
Pop Ds
Assume Ds:Cseg
Mov RT_CondMask,Ax
Mov RT_Buttons,Bx
Mov RT_Hpos,Cx
Mov RT_Vpos,Dx ; save status
Mov Ax,TrapMask
Mov Dx,TrapMask+2
Mov Ds,ProgDs
Or Ds:[0],Ax
Or Ds:[2],Dx ; set trap bit
Pop Ds
Assume Ds:Nothing
Ret
MouseTrap Endp
;
; SUB ResetMouseTrap
ResetMouseTrap proc far
Push Bp
Mov Bp,Sp
Mov Ax,12
Xor Cx,Cx
Int 33h ; set calling routine with not conditions
Pop Bp
Ret
ResetMouseTrap endp
;
;
Cseg Ends
End Start