home *** CD-ROM | disk | FTP | other *** search
- ;
- ; Name mocatch -- Catch mouse button presses and releases.
- ;
- ; Synopsis (Special mouse interrupt subroutine -- not to be called
- ; directly from C.)
- ;
- ; Register values on entry:
- ;
- ; AX Condition mask bits:
- ; 0001h Mouse movement.
- ; 0002h MO_L_PRESS Left button pressed.
- ; 0004h MO_L_RELEASE Left button released.
- ; 0008h MO_R_PRESS Right button pressed.
- ; 0010h MO_R_RELEASE Right button released.
- ; 0020h MO_M_PRESS Center button pressed.
- ; 0040h MO_M_RELEASE Center button released.
- ; BX Button state bits:
- ; 0001h MO_LEFT
- ; 0002h MO_RIGHT
- ; 0004h MO_MIDDLE
- ; CX Horizontal cursor position in pixels.
- ; DX Vertical cursor position in pixels.
- ; DI Horizontal mouse position in mickeys.
- ; SI Vertical mouse position in mickeys.
- ;
- ; Register values on exit:
- ;
- ; (All unchanged including flags.)
- ;
- ; Description This function receives control from certain mouse
- ; events. It keeps a history (b_mohist[]) of the
- ; locations and times of mouse button presses and releases
- ; and the shift key states at the time of those events.
- ;
- ; If a user interrupt handler is also installed (see
- ; MOHANDLR.C), this function may also pass control to the
- ; dispatcher routine inside MOHANDLR. It passes control
- ; only if the mouse event matches the user function's
- ; "call mask".
- ;
- ; Returns b_mohist Updated array of recent mouse events.
- ;
- ; Version 6.00 (C)Copyright Blaise Computing Inc. 1989
- ;
-
- include beginasm.mac
-
- beginMod mocatch
-
- MO_EVENT struc ; MO_EVENT: One mouse button
- ; event. This must match
- ; definition in BMOUSE.H.
- ;
- MO_EV_EVENT dw 0 ; MO_PRESS or MO_RELEASE.
- MO_EV_TIME dd 0ffffffffh ; BIOS clock ticks since midnight.
- MO_EV_C_VERT dw 0 ; Cursor location in pixels.
- MO_EV_C_HORIZ dw 0
- MO_EV_VERT dw 0 ; Mouse location in mickeys.
- MO_EV_HORIZ dw 0
- MO_EV_KSTAT dw 0
- MO_EV_RELEVANT dw 0 ; Newness bits:
- ; MO_CLICK, MO_DCLICK, MO_PRESS,
- ; and MO_RELEASE
- ; indicating whether this event
- MO_EVENT ends ; has been read & cleared.
-
- MO_LEFT equ 0001h ; Event symbols.
- MO_RIGHT equ 0002h ; Must match BMOUSE.H!
- MO_MIDDLE equ 0004h
- MO_PRESS equ 0008h
- MO_RELEASE equ 0010h
- MO_CLICK equ 0040h
- MO_DCLICK equ 0080h
-
- MO_HIST_LIMIT equ 5 ; Number of events recorded.
- ; Must match BMOUSE.H!
-
- MO_L_PRESS equ 0002h ; Condition mask bits in AX.
- MO_L_RELEASE equ 0004h
- MO_R_PRESS equ 0008h
- MO_R_RELEASE equ 0010h
- MO_M_PRESS equ 0020h
- MO_M_RELEASE equ 0040h
-
-
- REG_INPUT struc ; Saved copy of register
- REG_AX dw ? ; values, pushed on entry.
- REG_BX dw ?
- REG_CX dw ?
- REG_DX dw ?
- REG_DI dw ?
- REG_SI dw ?
- REG_INPUT ends
-
- ; External variables defined elsewhere.
-
- beginDSeg
-
- extSym b_modispat,dword ; Address of dispatcher that
- ; calls user interrupt handler.
-
- extSym b_mohanmask,word ; Mask value (if any) for user
- ; mouse interrupt handler.
-
- ; Define & initialize global variables.
-
- pubSym b_mohist,<MO_EVENT (3 * MO_HIST_LIMIT) dup (<>)>
- endDSeg
-
- beginCSeg mocatch
-
- temp_vector dd ? ; Temporary vector in code
- ; segment
-
- ;********************************************************************
- ;
- ; Internal routine DO_ONE_BUTTON:
- ;
- ; Entry registers:
- ;
- ; DX:AX 32-bit BIOS time of day (clock ticks).
- ; DI Copy of BIOS keyboard shift status word.
- ; DS:BX Address of first MO_EVENT structure for this button.
- ; ES Duplicate copy of DS.
- ; SS:BP Address of REG_INPUT structure containing register
- ; values on entry to MOCATCH.
- ; CX Mask to capture button state (MO_LEFT, MO_RIGHT, or
- ; MO_MIDDLE)
- ; DF (Direction Flag) = 1 (downward)
- ;
- ; Exit registers:
- ;
- ; CX,SI Undefined
- ; AX,BX,DX,DS,ES,DF,SS,BP,DI Unchanged
-
- do_one_button proc near
- assume ds:nothing,es:nothing
-
- ; Copy button's history backward one event to make room for new event.
-
- push di
- push cx
- mov si,bx
- add si,((MO_HIST_LIMIT - 1) * type b_mohist@) - 2
- mov di,si
- add di,type b_mohist@
- mov cx,((MO_HIST_LIMIT - 1) * type b_mohist@) / 2
- rep movsw
- pop cx
- pop di
-
- ; Record event type: press or release.
-
- test [bp].REG_BX,cx
- jnz button_down
-
- mov [bx].MO_EV_EVENT, MO_RELEASE
- mov [bx].MO_EV_RELEVANT,MO_RELEASE or MO_CLICK or MO_DCLICK
- jmp short state_done
- button_down:
- mov [bx].MO_EV_EVENT, MO_PRESS
- mov [bx].MO_EV_RELEVANT,MO_PRESS or MO_CLICK or MO_DCLICK
- state_done:
-
- ; Record other details of this event.
-
- mov [bx].MO_EV_KSTAT,di ; Keyboard status.
- mov word ptr [bx].MO_EV_TIME ,ax ; Time of day.
- mov word ptr [bx].MO_EV_TIME+2,dx
-
- mov cx,[bp].REG_CX ; Mouse cursor location.
- mov [bx].MO_EV_C_HORIZ,cx
- mov cx,[bp].REG_DX
- mov [bx].MO_EV_C_VERT,cx
- mov cx,[bp].REG_DI ; Mouse location.
- mov [bx].MO_EV_HORIZ,cx
- mov cx,[bp].REG_SI
- mov [bx].MO_EV_VERT,cx
-
- ret
-
- do_one_button endp
-
- ;********************************************************************
- ;
- ; Actual entry point for MOCATCH.
-
- beginProc mocatch ; Will exit via far RETurn.
-
- push bp
- mov bp,sp
-
- push ds
- push es
- pushf
-
- push si ; Save entry register values.
- push di
- push dx
- push cx
- push bx
- push ax
-
- ; Load registers with values that apply to all buttons.
-
- mov bp,sp ; SS:BP -> set of input registers.
-
- xor ax,ax ; Fetch BIOS time of day.
- mov ds,ax
- assume ds:nothing
- les ax,ds:[046ch]
- assume es:nothing
- mov dx,es ; DX:AX = time of day.
-
- mov di,ds:[0417h] ; Shift key status word.
-
- mov bx,seg b_mohist@
- mov ds,bx ; DS -> default data segment.
- assume ds:nothing
- mov es,bx
- assume es:nothing
- lea bx,b_mohist@
- ; DS:BX -> history for this button
- ; ES == DS
-
- std
-
- ; Record left button event if it was pressed or released.
-
- test [bp].REG_AX,MO_L_PRESS or MO_L_RELEASE
- jz did_left
-
- mov cx,MO_LEFT
- call do_one_button
- did_left:
- add bx,(MO_HIST_LIMIT * type b_mohist@)
-
- ; Record right button event if it was pressed or released.
-
- test [bp].REG_AX,MO_R_PRESS or MO_R_RELEASE
- jz did_right
-
- mov cx,MO_RIGHT
- call do_one_button
- did_right:
-
- ; Record middle button event if it was pressed or released.
-
- test [bp].REG_AX,MO_M_PRESS or MO_M_RELEASE
- jz did_middle
-
- add bx,(MO_HIST_LIMIT * type b_mohist@)
- mov cx,MO_MIDDLE
- call do_one_button
- did_middle:
-
- ; All done.
-
- ; Check whether to pass control to user's interrupt handler also.
-
- ; DS -> default data segment.
-
- mov ax,ds:b_mohanmask@ ; User event bits.
- test [bp].REG_AX,ax ; Actual event bits.
- jz straight_exit ; Zero implies user handler isn't
- ; interested in this event.
-
- ; Jump to user's interrupt handler.
-
- les ax,ds:b_modispat@ ; Set up copy of vector in
- assume es:nothing ; code segment.
- mov word ptr temp_vector ,ax
- mov word ptr temp_vector+2,es
-
- pop ax ; Restore registers.
- pop bx
- pop cx
- pop dx
- pop di
- pop si
-
- popff
- pop es
- assume es:nothing
- pop ds
- assume ds:nothing
-
- pop bp
- jmp temp_vector ; Jump to user's handler.
-
- ; Return directly to mouse driver.
-
- straight_exit:
- pop ax ; Restore registers and exit.
- pop bx
- pop cx
- pop dx
- pop di
- pop si
-
- popff
- pop es
- assume es:nothing
- pop ds
- assume ds:nothing
-
- pop bp
- db 0cbh ; Far return.
-
- endProc mocatch
- endCseg mocatch
- endMod mocatch
-
- end