int33h.asm
来自「开放源码的编译器open watcom 1.6.0版的源代码」· 汇编 代码 · 共 813 行 · 第 1/2 页
ASM
813 行
;
;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
;
.386P
_Int33h segment para private 'extension code' use32
assume cs:_Int33h, ds:nothing, es:nothing
Int33hStart label byte
MouseEventTab db size RealRegsStruc dup (0)
db 1024 dup (0)
MouseEventStack df 0
;
OldInt33h df 0
Int33hCSeg dw ?
Int33hDSeg dw ?
Int33hDDSeg dw ?
;
Int33hCallBack dd 0
Int33hUserCode df 0
Int33hUserMask dw 0
Int33hUserOK dw 0
;
db 4 dup (0)
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Int33hOpen proc near
;
;Setup int 33h patch.
;
assume ds:_Int33h
assume es:_cwMain
mov Int33hDSeg,es ;Store cwCode selector.
mov Int33hCSeg,cs ;store this segment.
mov Int33hDDSeg,ds
test BYTE PTR es:SystemFlags,1
jz int331_32bit
mov eax,offset Int33hDummy
mov w[Int33hUserCode],ax
mov w[Int33hUserCode+2],cs
jmp int331_0bit
int331_32bit: mov d[Int33hUserCode],offset Int33hDummy
mov w[Int33hUserCode+4],cs
int331_0bit: ;
;Check mouse driver present.
;
; mov ax,0
; int 33h
; cmp ax,0 ;mouse driver present?
; jz @@9
;
;Get call back.
;
push ds
push es
push ds
pop es
mov esi,offset MouseEvent
mov edi,offset MouseEventTab
push cs
pop ds
sys GetCallBack
pop es
pop ds
jc int331_9
mov w[Int33hCallBack],dx
mov w[Int33hCallBack+2],cx
;
;Set patch vector.
;
mov bl,33h
sys GetVect
test BYTE PTR es:SystemFlags,1
jz int331_Use32
mov w[OldInt33h],dx
mov w[OldInt33h+2],cx
jmp int331_Use0
int331_Use32: mov d[OldInt33h],edx
mov w[OldInt33h+4],cx
int331_Use0: mov edx,offset Int33h
mov cx,cs
mov bl,33h
sys SetVect
;
assume es:nothing
assume ds:nothing
int331_9: clc
;
db 66h
retf
Int33hOpen endp
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Int33hClose proc near
;
;Remove int 33h patch.
;
push ds
mov ds,cs:Int33hDDSeg
assume ds:_Int33h
;
;Release CallBack.
;
cmp d[Int33hCallBack],0
jz int332_8
; mov ax,0
; int 33h
mov dx,w[Int33hCallBack]
mov cx,w[Int33hCallBack+2]
sys RelCallBack
;
int332_8: ;Release interupt vector.
;
cmp d[OldInt33h],0
jz int332_9
mov ds,Int33hDseg
assume ds:_cwMain
test BYTE PTR SystemFlags,1
assume ds:nothing
mov ds,cs:Int33hDDSeg
assume ds:_Int33h
jz int332_Use32
movzx edx,w[OldInt33h]
mov cx,w[OldInt33h+2]
jmp int332_Use0
int332_Use32: mov edx,d[OldInt33h]
mov cx,w[OldInt33h+4]
int332_Use0: mov bl,33h
sys SetVect
assume ds:nothing
int332_9: pop ds
;
db 66h
retf
Int33hClose endp
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Int33h proc far
cmp ax,0 ;Reset?
jz int333_Reset
cmp ax,9 ;Set pointer shape?
jz int333_SetCursor
cmp ax,0ch ;Set event handler?
jz int333_SetEvent
cmp ax,14h ;Swap event handlers?
jz int333_SwapEvent
cmp ax,15h ;Get state buffer size?
jz int333_GetStateSize
cmp ax,16h ;Save state?
jz int333_SaveState
cmp ax,17h ;Restore state?
jz int333_ResState
jmp int333_NotOurs
;
int333_SwapEvent: ;Swap event handlers.
;
push eax
push ebx
push esi
push edi
push ebp
push ds
assume ds:nothing
mov ds,cs:Int33hDDSeg
assume ds:_Int33h
cmp Int33hUserOK,0 ;handler installed?
jnz int333_se0
;
push ds
mov ds,cs:Int33hDSeg
assume ds:_cwMain
test BYTE PTR SystemFlags,1
assume ds:_Int33h
pop ds
jz int333_se1
xchg dx,w[Int33hUserCode]
mov ax,w[Int33hUserCode+2]
mov w[Int33hUserCode+2],es
mov es,ax
jmp int333_se2
int333_se1: xchg edx,d[Int33hUserCode]
mov ax,w[Int33hUserCode+4]
mov w[Int33hUserCode+4],es
mov es,ax
int333_se2: xchg cx,w[Int33hUserMask]
push ecx
push edx
push es
mov cx,w[Int33hUserMask]
mov es,Int33hDSeg
assume es:_cwMain
mov edi,offset Int33Buffer
mov es:RealRegsStruc.Real_EAX[edi],0ch
mov es:RealRegsStruc.Real_ECX[edi],ecx
mov dx,w[Int33hCallBack]
mov es:RealRegsStruc.Real_EDX[edi],edx
mov cx,w[Int33hCallBack+2]
mov es:RealRegsStruc.Real_ES[edi],cx
mov bl,33h
sys IntXX
mov Int33hUserOK,1 ;enable user routine.
assume es:nothing
pop es
pop edx
pop ecx
jmp int333_se9
;
int333_se0: push ds
mov ds,cs:Int33hDSeg
assume ds:_cwMain
test BYTE PTR SystemFlags,1
assume ds:_Int33h
pop ds
jz int333_se3
xchg dx,w[Int33hUserCode]
mov ax,w[Int33hUserCode+2]
mov w[Int33hUserCode+2],es
mov bx,es
mov es,ax
mov ax,cs
cmp ax,bx
jnz int333_se4
mov Int33hUserOK,0
push eax
mov eax,offset Int33hDummy
mov w[Int33hUserCode],ax
pop eax
mov w[Int33hUserCode+2],cs
jmp int333_se5
int333_se3: xchg edx,d[Int33hUserCode]
mov ax,w[Int33hUserCode+4]
mov w[Int33hUserCode+4],es
mov bx,es
mov es,ax
mov ax,cs
cmp ax,bx
jnz int333_se4
mov Int33hUserOK,0
mov d[Int33hUserCode],offset Int33hDummy
mov w[Int33hUserCode+4],cs
int333_se5:
push ecx
push edx
push es
mov es,Int33hDSeg
assume es:_cwMain
mov edi,offset Int33Buffer
mov es:RealRegsStruc.Real_EAX[edi],0
mov bl,33h
sys IntXX
assume es:nothing
pop es
pop edx
pop ecx
;
int333_se4: xchg cx,w[Int33hUserMask]
;
int333_se9:
pop ds
pop ebp
pop edi
pop esi
pop ebx
pop eax
assume ds:nothing
jmp int333_Done
;
int333_Reset: ;Remove's event handler among other things.
;
push ds
mov ds,cs:Int33hDDSeg
assume ds:_Int33h
mov Int33hUserOK,0
mov d[Int33hUserCode],offset Int33hDummy
push ds
mov ds,Int33hDSeg
assume ds:_cwMain
test BYTE PTR SystemFlags,1
assume ds:_Int33h
pop ds
jz int333_r32
mov w[Int33hUserCode+2],cs
jmp int333_r0
int333_r32: mov w[Int33hUserCode+4],cs
int333_r0: mov w[Int33hUserMask],0
assume ds:nothing
pop ds
jmp int333_NotOurs ;carry onto real mode handler.
;
int333_SetCursor: ;Set graphics cursor shape.
;
push eax
push ebx
push ecx
push edx
push esi
push edi
push ebp
push ds
push es
push fs
push eax
xor eax,eax
mov ax,es
lsl eax,eax
cmp eax,10000h
jnc int333_Use32Bit50
movzx edx,dx
int333_Use32Bit50: pop eax
mov esi,edx ;source buffer.
push es
mov ds,cs:Int33hDseg
assume ds:_cwMain
mov fs,PSPSegment
xor edi,edi
mov es,WORD PTR fs:[EPSP_Struc.EPSP_TransProt]
pop ds
assume ds:nothing
cld
push ecx
mov ecx,64
rep movsb ;copy into transfer buffer.
pop ecx
mov edi,offset Int33Buffer
mov es,cs:Int33hDseg
assume es:_cwMain
xor edx,edx
mov es:[edi].RealRegsStruc.Real_EAX,eax
mov es:[edi].RealRegsStruc.Real_EDX,edx
mov ax,WORD PTR fs:[EPSP_Struc.EPSP_TransReal]
mov es:[edi].RealRegsStruc.Real_ES,ax
mov es:[edi].RealRegsStruc.Real_EBX,ebx
mov es:[edi].RealRegsStruc.Real_ECX,ecx
assume es:nothing
mov bl,33h
sys IntXX
pop fs
pop es
pop ds
pop ebp
pop edi
pop esi
pop edx
pop ecx
pop ebx
pop eax
jmp int333_Done
;
int333_SetEvent: ;Set event handler.
;
push eax
push ebx
push ecx
push edx
push esi
push edi
push ebp
push ds
push es
mov ds,cs:Int33hDSeg
assume ds:_cwMain
test BYTE PTR SystemFlags,1
assume ds:nothing
mov ds,cs:Int33hDDSeg
assume ds:_Int33h
mov Int33hUserOK,0 ;disable old handler.
jz int333_Use32Bit51
mov w[Int33hUserCode],dx
mov w[Int33hUserCode+2],es
jmp int333_Use16Bit51
int333_Use32Bit51: mov d[Int33hUserCode],edx
mov w[Int33hUserCode+4],es
int333_Use16Bit51: mov w[Int33hUserMask],cx
assume ds:nothing
mov ds,cs:Int33hDDSeg
mov es,cs:Int33hDSeg
assume ds:_Int33h
assume es:_cwMain
mov edi,offset Int33Buffer
mov es:RealRegsStruc.Real_EAX[edi],eax
mov es:RealRegsStruc.Real_ECX[edi],ecx
mov dx,w[Int33hCallBack]
mov es:RealRegsStruc.Real_EDX[edi],edx
mov cx,w[Int33hCallBack+2]
mov es:RealRegsStruc.Real_ES[edi],cx
mov bl,33h
sys IntXX
mov Int33hUserOK,1 ;enable user routine.
assume ds:nothing
assume es:nothing
pop es
pop ds
pop ebp
pop edi
pop esi
pop edx
pop ecx
pop ebx
pop eax
jmp int333_Done
;
int333_GetStateSize: ; Get state buffer size.
;
push eax
push ecx
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?