📄 mouse5.asm
字号:
; Set the mouse cursor
;
; Amazingly, there is no OS/2 support for the Graphics Mouse Cursor in
; protect mode.
cPublic SetMouseCursor,<>,<DS>
parmD pmcb
localV moupsInfo,<size PtrShapeMou>
;---------------
;localV pbGetBuffer,100
;localV moupsGetInfo,<size PtrShapeMou>
;---------------
cBegin SetMouseCursor
;---------------
;
; These two calls are intended to Get the current mouse shape. I was hoping
; to what the proper structure is for protect mode, but hey - no such luck.
;
; mov cx,hPointer
; mov ax,0FFFFh ; cb is bogus - it'll give
; mov moupsGetInfo.cbPtrShapeMou,ax ; us the size.
; lea ax,pbGetBuffer
; lea bx,moupsGetInfo
; cCall MouGetPtrShape,<ss,ax,ss,bx,cx>
;
; mov cx,hPointer
; lea ax,pbGetBuffer
; lea bx,moupsGetInfo
; cCall MouGetPtrShape,<ss,ax,ss,bx,cx>
;
;---------------
xor ax,ax ; Set up for text mode.
cmp fMousePresent,al
jz Nix
test instCur.finstInst,finstGraphics
jnz Nix
mov cx,hPointer ; Get this before we lose ds.
lds bx,pmcb ; ds:bx -> Mouse Cursor Block.
assumes ds,nothing
mov moupsInfo.colHotPtrShapeMou,ax
mov moupsInfo.rowHotPtrShapeMou,ax
inc ax
mov moupsInfo.colPtrShapeMou,ax
mov moupsInfo.rowPtrShapeMou,ax
shl ax,1
shl ax,1
mov moupsInfo.cbPtrShapeMou,ax
lea ax,[bx].wAndMaskTextMcb
; jmp short DoIt
;
;ItsGfx:
; mov ax,16 ; Set up for graphics mode.
; mov moupsInfo.colPtrShapeMou,ax
; mov moupsInfo.rowPtrShapeMou,ax
; shl ax,1
; shl ax,1
; mov moupsInfo.cbPtrShapeMou,ax
; mov ax,[bx].colHot
; mov moupsInfo.colHotPtrShapeMou,ax
; mov ax,[bx].rowHot
; mov moupsInfo.rowHotPtrShapeMou,ax
;
; lea ax,[bx].rgwAndMaskGfxMcb
;
;DoIt:
lea dx,moupsInfo
cCall MouSetPtrShape,<ds,ax,ss,dx,cx>
AssertEq ax,0
Nix:
cEnd SetMouseCursor
;********** MouseConditionalOff **********
;
; entry : pmcob = near pointer to a Mouse Conditional Off Block
;
; Defines a region on the screen for mouse updating
;
; Here's a great catch-22. This call is only needed in graphics mode, but
; OS/2 doesn't support a graphics mouse cursor. So it's a big NilFactor.
assumes CS,KERNEL
assumes SS,DATA
assumes DS,DATA
assumes ES,nothing
cPublic MouseConditionalOff,<ATOMIC>
;parmW pmcob
cBegin nogen ; MouseConditionalOff
retf 2 ; Clean up stack of parm.
cEnd nogen ; MouseConditionalOff
;********** MouseOn **********
;
; Un-does the MouseConditionalOff, which means also a big NilFactor.
;
assumes CS,KERNEL
assumes SS,DATA
assumes DS,DATA
assumes ES,nothing
cPublic MouseShowCursor,<ATOMIC>
cBegin MouseShowCursor
cEnd MouseShowCursor
;********** SetMouseDoubleSpeed **********
;* entry : mps = mickey / second speed
;* * Set mouse double speed threshold
;* exit : n/a
cPublic SetMouseDoubleSpeed,<>
parmW mps
cBegin SetMouseDoubleSpeed
IFDEF LATER
test fMousePresent,0ffH
jz set_speed_end
mov dx,mps
mov ax,19
int 33H ;* Set double speed
set_speed_end:
ENDIF ;LATER
cEnd SetMouseDoubleSpeed
sEnd MOUSE
;*****************************************************************************
externFP MouseMessage ;* from event.c
sBegin KERNEL
assumes CS,KERNEL
assumes DS,DATA
; MouseThread - Mouse monitor thread
;
; IMPLEMENTATION:
; Start
; Read Input from Monitor
; switch (FLAGS record)
; case OPEN
; break;
; case FLUSH
; Write output to monitor structure
; break;
; case CLOSE
; Exit to Dos
; default
; Analyse record and Call Windows Event procedure
; break;
; goto Start
cProc MouseThread,<FAR, ATOMIC>
cBegin nogen ;MouseThread
ThreadStart:
mov [Bytecnt],SIZE DataBuffer
PushArg <ds, dataOffset(BufferI)>
PushArg <0> ; WaitFlag=0 (wait)
PushArg <ds, dataOffset(DataBuffer)>
PushArg <ds, dataOffset(Bytecnt)>
cCall DosMonRead ;* read (do not propagate)
or ax,ax
jnz Close
mov si,dataOffset DataBuffer
mov ax,[si].flags
test ax,fClose
jnz Close ;* close it down
cmp fEnableMonitor,0
jne not_literal_monitor
;* * in literal monitor mode
PushArg <ds, dataOffset(BufferO)>
PushArg <ds, dataOffset(DataBuffer)>
PushArg Bytecnt
cCall DosMonWrite
jmp short ThreadStart
not_literal_monitor:
test ax,fOpen OR fFlush OR fClose
jnz no_default
cCall ProcessRecord ; default
jmp short ThreadStart
no_default:
test ax,fClose
jz ThreadStart ;* keep going
Close: ; return will end this thread
ret
cEnd nogen ;MouseThread
; ProcessRecord - Analyze records contents and send event to Windows
;
; Note: Replace what used to be the hardware mouse service
;
; IMPLEMENTATION:
; Set motion mask bit
; Set buttons mask bits
; Set Time stamps
; Call Windows event proc
;
cProc ProcessRecord, <NEAR, ATOMIC>
cBegin nogen ;ProcessRecord
mov ax,[si].Eventmsk ; get events mask
mov bx,[si].axMouCur
mov axMouse,bl
mov bx,[si].ayMouCur
mov ayMouse,bl
;* * convert move-with-button-down to button-down
mov ah,al
and ah,mouButMotion ;* move-with-button-down
shl ah,1 ;* convert to button-down (only)
or al,ah
;* * figure out the sstMouse states
xor dx,dx
test al,mouBut1Only
jz left_not_down
or dl,MK_LBUTTON
left_not_down:
test al,mouBut2Only
jz right_not_down
or dl,MK_RBUTTON
right_not_down:
mov sstMouse,dx
mov dx,ax ;* save value in dx
not_mouse_move:
;* * convert state into transitions
mov ah,al
not ah ;* ah = !new, al = new
mov bh,al
xchg bh,mstateOld ;* update state, get old (bh = old)
mov bl,bh
not bl ;* bh = old, bl = !old
and ax,bx ;* ah = !new & old = key up
;* al = new & !old = key down
mov dx,ax
;* * al = dl = key down transitions
;* * ah = dh = key up transitions
MouseMove?:
test ax,(mouBut1Only OR mouBut2Only) * 101H
jnz LeftButtonDown?
;* * no buttons set (just move)
mov ax,WM_MOUSEMOVE
cCall DoMouseMessage
LeftButtonDown?:
test al,mouBut1Only
jz LeftButtonUp?
mov ax,WM_LBUTTONDOWN
cCall DoMouseMessage
LeftButtonUp?:
test ah,mouBut1Only
jz RightButtonDown?
mov ax,WM_LBUTTONUP
cCall DoMouseMessage
RightButtonDown?:
test al,mouBut2Only
jz RightButtonUp?
mov ax,WM_RBUTTONDOWN
cCall DoMouseMessage
RightButtonUp?:
test ah,mouBut2Only
jz test_for_mouse_lock
mov ax,WM_RBUTTONUP
cCall DoMouseMessage
test_for_mouse_lock:
;* * Check for mouse lockout
;* * If ABS(ayDrawing - ayMouse{new}) = FE,FF,0,1,2 then kill mouse
mov al,ayMouse
sub al,ayDrawing
add al,2 ;* 0, 1, 2, 3, 4 => kill it
cmp al,5
jae lockout_done ;* no conflict
;* * drawing conflict, turn mouse of if not already turned off
test fMouseOn,0ffh
jz lockout_done ;* already off
test fMouseLockedOut,0ffh
jnz lockout_done ;* already locked out
;* * turn off mouse
PushArg <ds, dataOffset(areamouOff)>
PushArg <hPointer>
cCall MouRemovePtr ;* turn off
mov fMouseOn,0 ;* mouse is off
mov fMouseLockedOut,0ffh ;* set locked out flag
lockout_done:
ret
cEnd nogen ;ProcessRecord
;********** DoMouseMessage **********
;* entry : ax = Message type
;* dx = mouse info
;* * Call MouseMessage with parameter
;* exit : dx retained
;* ax restored with dx
cProc DoMouseMessage,<NEAR,ATOMIC> ;* all code FIXED !
cBegin DoMouseMessage
push dx
cCall MouseMessage,<ax>
pop dx
mov ax,dx
cEnd DoMouseMessage
sEnd KERNEL
;*****************************************************************************
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -