📄 mouse.asm
字号:
; bit 6 of the high word.
assumes CS,KERNEL
assumes SS,DATA
assumes DS,DATA
assumes ES,nothing
cPublic SetMouseCursor,<ATOMIC>,<DS>
parmD pmcb
cBegin SetMouseCursor
StartPublic
mov ax,10 ; ah = 0
cmp fMousePresent,ah
jz @F
mov dx,instCur.finstInst
lds bx,pmcb ; ds:bx -> Mouse Cursor Block.
assumes ds,nothing
push bx
and dx,(finstText OR finstFont) ; This will be true only in
cmp dx,(finstText OR finstFont) ; Hercules RAMFont mode.
mov cx,[bx].wAndMaskTextMcb
mov dx,[bx].wXorMaskTextMcb
ifndef KANJI
jne NotRAMFont ; If 48K RAMFont, then make sure that
mov ch,0BFh ; only bit 6 of the high word gets
mov dh,040h ; toggled (the reverse video bit).
NotRAMFont:
endif ; not KANJI
xor bx,bx ; 0/1 -> Soft/hardware text cursor.
int 33h ; Set Text Cursor
pop bx
; Do not set both cursor, because Japanese machine has super-impose.
ifndef KANJI
mov cx,ds
mov es,cx
assumes es,nothing
lea dx,[bx].rgwAndMaskGfxMcb ; es:dx -> And & Xor blocks.
mov cx,[bx].rowHotMcb
mov bx,[bx].colHotMcb
dec al
AssertEq ax,9
int 33h ; Set Graphics Cursor Block
endif ; not KANJI
@@:
StopPublic
cEnd SetMouseCursor
;********** MouseConditionalOff **********
;
; entry : pmcob = near pointer to a Mouse Conditional Off Block
;
; Defines a region on the screen for mouse updating
;
; This is needed by Word in its Page Preview mode, when Word is working with
; the GSDs. When Word is in character-graphics mode (with CSDs), the CSD
; driver takes care of turning the mouse off and back on.
;
; So, we can assume that we're in graphics mode when this gets called.
assumes CS,KERNEL
assumes SS,DATA
assumes DS,DATA
assumes ES,nothing
cPublic MouseConditionalOff,<ATOMIC>,<si,di>
parmW pmcob
cBegin MouseConditionalOff
StartPublic
mov ax,16 ; ah = 0
cmp fMousePresent,ah
jz @F
mov bx,pmcob
mov cx,[bx].xLeftMCOB
mov dx,[bx].yTopMCOB
mov si,[bx].xRightMCOB
mov di,[bx].yBottomMCOB
int 33h
@@:
StopPublic
cEnd MouseConditionalOff
;********** MouseOn **********
;
; Un-does the MouseConditionalOff
;
assumes CS,KERNEL
assumes SS,DATA
assumes DS,DATA
assumes ES,nothing
cPublic MouseShowCursor,<ATOMIC>
cBegin MouseShowCursor
StartPublic
mov ax,1 ; ah = 0
cmp fMousePresent,ah
jz @F
int 33h
@@:
StopPublic
cEnd MouseShowCursor
sEnd KERNEL
;----------------------------------------------------------------------------
IFDEF MOUSE_EXTRAS
sBegin MOUSE ;* discardable MOUSE segment
assumes CS,MOUSE
assumes SS,DATA
assumes DS,DATA
assumes ES,nothing
;********** SetMouseDoubleSpeed **********
;* entry : mps = mickey / second speed
;* * Set mouse double speed threshold
;* exit : n/a
cPublic SetMouseDoubleSpeed,<ATOMIC>
parmW mps
cBegin SetMouseDoubleSpeed
StartPublic
mov ax,19
cmp fMousePresent,ah
jz @F
mov dx,mps
int 33H ;* Set double speed
@@:
StopPublic
cEnd SetMouseDoubleSpeed
IFDEF MOUSE_SWAP
;********** SwapMouseButton **********
;* entry : fSwap : TRUE => swap buttons
;* * Set fSwapButton to state specified
;* exit : AX = old value of fSwapButton
cPublic SwapMouseButton,<ATOMIC>
parmW fSwap
cBegin SwapMouseButton
StartPublic
mov al,fSwapButton
xor ah,ah ;* old value 0 or 1
mov cx,fSwap
jcxz turn_swap_off
mov fSwapButton,1
jmp short swap_end
turn_swap_off:
mov fSwapButton,0
swap_end:
StopPublic
cEnd SwapMouseButton
ENDIF ;MOUSE_SWAP
sEnd MOUSE
ENDIF ;MOUSE_EXTRAS
;----------------------------------------------------------------------------
;* * Mouse Interrupt (in FIXED KERNEL segment)
externFP MouseMessage ;* from event.c
sBegin KERNEL
assumes CS,KERNEL
assumes SS,NOTHING
assumes DS,NOTHING
;********** MouseInterrupt **********
;* MOUSE USER DEFINED SUB-ROUTINE (called from mouse driver)
;* entry : AX = condition mask
;* BX = button state
;* CX = horiz. coordinate
;* DX = vert. coordinate
;* * Process a mouse event
;* * If necessary perform mouse lock out
;* exit : n/a
cProc MouseInterrupt,<FAR, ATOMIC>,<DS,ES>
cBegin MouseInterrupt
CLI ;* DISABLE INTERRUPTS TO AVOID RECURSION
; Establish ds addressing
push ax
mov ax,SEG dataBase
mov ds,ax
assumes ds,DATA
; Save Button State
mov sstMouse,bx
; convert mouse location from pixel to character based.
cCall SetMousePixelPos
pop ax
; Save interrupt conditions
mov dx,ax
IFDEF MOUSE_SWAP
;* * First see if buttons reversed
test fSwapButton,0ffh
jz dont_swap_buttons
;* * Swap Mouse buttons for interrupt state
Assert <LEFT_BUTTON_DOWN EQ 2>
Assert <LEFT_BUTTON_UP EQ 4>
Assert <RIGHT_BUTTON_DOWN EQ 8>
Assert <RIGHT_BUTTON_UP EQ 10H>
mov ah,al ;* copy in AH
and dl,11100001B ;* clear 4 bits in question
shl al,1
shl al,1
and al,011000B ;* map left to right
shr ah,1
shr ah,1
and ah,000110B ;* map right to left
or al,ah
or dl,al ;* put back together
;* * Swap sstMouse (ls2bits)
mov ax,sstMouse
mov bl,al
mov bh,al
and al,11111100B ;* clear ls2b
shr bl,1
shl bh,1
or bl,bh
and bl,11B
or al,bl
mov sstMouse,ax
;* * DX = mouse state
dont_swap_buttons:
ENDIF ;MOUSE_SWAP
; Post Messages according to the events
mov al,dl ;* test in AL shorter
MouseMove?:
test al,MOUSE_MOVE
jz LeftButtonDown?
mov ax,WM_MOUSEMOVE
cCall DoMouseMessage
LeftButtonDown?:
test al,LEFT_BUTTON_DOWN
jz LeftButtonUp?
mov ax,WM_LBUTTONDOWN
cCall DoMouseMessage
LeftButtonUp?:
test al,LEFT_BUTTON_UP
jz RightButtonDown?
mov ax,WM_LBUTTONUP
cCall DoMouseMessage
RightButtonDown?:
test al,RIGHT_BUTTON_DOWN
jz RightButtonUp?
mov ax,WM_RBUTTONDOWN
cCall DoMouseMessage
RightButtonUp?:
test al,RIGHT_BUTTON_UP
jz done_messages
mov ax,WM_RBUTTONUP
cCall DoMouseMessage
done_messages:
;* * 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
do_lockout:
;* * 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
mov ax,2
int 33H ;* turn off mouse
mov fMouseOn,0 ;* mouse is off
mov fMouseLockedOut,0ffh ;* set locked out flag
lockout_done:
STI ;* RE-ENABLE INTERRUPTS
cEnd MouseInterrupt
;********** DoMouseMessage **********
;* entry : ax = Message type
;* dx = mouse mask
;* * Call MouseMessage with parameter
;* exit : dx retained
;* al restored with dl
cProc DoMouseMessage,<NEAR,ATOMIC> ;* all code FIXED !
cBegin DoMouseMessage
push dx
cCall MouseMessage,<ax>
pop dx
mov al,dl
cEnd DoMouseMessage
;*****************************************************************************
;********** SetMousePixelPos **********
;* entry: cx = xMouse (pixels)
;* dx = yMouse (pixels)
;* * convert to character coords and store in (axMouse, ayMouse)
cProc SetMousePixelPos, <NEAR, ATOMIC>
cBegin SetMousePixelPos
IFDEF LATER
-- characters other than 8 pixels wide (graphics modes)
ENDIF
mov ax,cx
mov cl,3 ;* 8 pixels wide
shr ax,cl
mov axMouse,al
mov ax,dx ;* vertical
mov cl,instCur.inftInst.dyCharInft
or cl,cl
jnz @F
mov cl,8 ;* default 8 pixels high
@@:
div cl
mov ayMouse,al
cEnd SetMousePixelPos
sEnd KERNEL
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -