	SECTION _TEXT align=1 CLASS=CODE USE32
	SECTION _DATA align=16 CLASS=DATA USE32
	SECTION _BSS align=16 CLASS=BSS USE32
	SECTION _CONST align=16 CLASS=CONST USE32
	SECTION _STRING align=4 CLASS=STRING USE32
	SECTION cstartup align=4 CLASS=INITDATA USE32
	SECTION crundown align=4 CLASS=EXITDATA USE32
	SECTION cppinit  align=4 CLASS=CPPINIT USE32
	SECTION cppexit  align=4 CLASS=CPPEXIT USE32
	GROUP DGROUP _DATA _BSS _CONST _STRING

SECTION _TEXT
;
; Line 8:	static void near mouse(int m1,int m2,int m3,int m4)
;
_mouse:
	PUSH	EBP
	MOV	EBP,ESP
	PUSH	ESI
	MOV	ESI,DWORD _regs
L_2:
;
; Line 9:	{
;
;
; Line 11:	regs.h.flags = 0x72;
;
	MOV	WORD [ESI+020H],072H
;
; Line 12:	regs.h.ss = 0;
;
	MOV	WORD [ESI+030H],00H
;
; Line 13:	regs.h.sp = 0;
;
	MOV	WORD [ESI+02EH],00H
;
; Line 14:	regs.h.ds = 0; 
;
	MOV	WORD [ESI+024H],00H
;
; Line 15:	regs.h.es = 0; 
;
	MOV	WORD [ESI+022H],00H
;
; Line 16:	regs.h.dx = m4;
;
	MOV	EAX,DWORD [EBP+014H]
	MOV	WORD [ESI+014H],AX
;
; Line 17:	regs.h.cx = m3;
;
	MOV	EAX,DWORD [EBP+010H]
	MOV	WORD [ESI+018H],AX
;
; Line 18:	regs.h.bx = m2;
;
	MOV	EAX,DWORD [EBP+0CH]
	MOV	WORD [ESI+010H],AX
;
; Line 19:	regs.h.ax = m1;
;
	MOV	EAX,DWORD [EBP+08H]
	MOV	WORD [ESI+01CH],AX
;
; Line 20:	dpmi_simulate_real_interrupt(MOUSE,&regs);
;
	PUSH	ESI
	PUSH	BYTE 033H
	CALL	_dpmi_simulate_real_interrupt
	ADD	ESP,BYTE 08H
;
; Line 21:	}
;
L_1:
	POP	ESI
	POP	EBP
	RET
[GLOBAL	_resetmouse]
;
; Line 24:	void resetmouse(void)
;
_resetmouse:
L_4:
;
; Line 25:	{
;
;
; Line 26:	mouse(0,0,0,0);
;
	PUSH	BYTE 00H
	PUSH	BYTE 00H
	PUSH	BYTE 00H
	PUSH	BYTE 00H
	CALL	_mouse
	ADD	ESP,BYTE 010H
;
; Line 27:	}
;
L_3:
	RET
[GLOBAL	_mouse_installed]
;
; Line 30:	BOOL mouse_installed(void)
;
_mouse_installed:
	PUSH	EBP
	MOV	EBP,ESP
	SUB	ESP,BYTE 0CH
	PUSH	EBX
	PUSH	ESI
	LEA	ESI,[EBP-08H]
L_7:
;
; Line 31:	{
;
;
; Line 34:	aa = peek(__seg0000, MOUSE *4 + 2);
;
	MOV	EAX,0CEH
	MOVZX	ECX,WORD [___seg0000]
	MOV	EDX,ECX
	MOV	FS,DX
	MOV	AX,WORD [FS:EAX+00H]
	MOV	WORD [EBP-02H],AX
;
; Line 35:	bb = peek(__seg0000, MOUSE * 4);
;
	MOV	EAX,0CCH
	MOVZX	ECX,WORD [___seg0000]
	MOV	EDX,ECX
	MOV	FS,DX
	MOV	BX,WORD [FS:EAX+00H]
;
; Line 36:	asm {
;
	MOV	AX,02H
;
; Line 38:	mov bx,[aa]
;
	MOV	BX,WORD [EBP-02H]
;
; Line 39:	int 0x31
;
	INT	031H
;
; Line 40:	mov [aa],ax
;
	MOV	WORD [EBP-02H],AX
;
; Line 41:	jnc ok
;
	JNC	SHORT	L_5
;
; Line 42:	}
;
;
; Line 43:	return FALSE;
;
	MOV	EAX,00H
	JMP	SHORT	L_6
L_5:
;
; Line 45:	ms = MK_FP(aa, bb);
;
	MOVZX	EAX,BX
	MOVZX	ECX,WORD [EBP-02H]
	MOV	EDX,ECX
	MOV	DWORD [SS:ESI+00H],EAX
	MOV	WORD [SS:ESI+00H+04H],DX
;
; Line 46:	return (SCREENWIDTH <= 80 && ms != NULL && *ms != 0xcf);
;
	MOV	EAX,04AH
	MOVZX	ECX,WORD [___seg0040]
	MOV	EDX,ECX
	MOV	FS,DX
	MOVSX	EAX,BYTE [FS:EAX+00H]
	MOVZX	EAX,AL
	CMP	EAX,BYTE 050H
	JG	SHORT	L_9
	CMP	DWORD [SS:ESI+00H],BYTE 00H
	JE	SHORT	L_9
	LFS	EAX,[SS:ESI+00H]
	MOVZX	EAX,BYTE [FS:EAX+00H]
	CMP	EAX,0CFH
	JNE	SHORT	L_8
L_9:
	SUB	EAX,EAX
; TEST EAX,IMMED (branches around next four bytes of code)
	DB	0A9H
L_8:
	SUB	EAX,EAX
	INC	EAX
	NOP
L_6:
	POP	ESI
	POP	EBX
	MOV	ESP,EBP
	POP	EBP
	RET
[GLOBAL	_mousebuttons]
;
; Line 50:	int mousebuttons(void)
;
_mousebuttons:
L_11:
;
; Line 51:	{
;
;
; Line 52:	if (mouse_installed())	{
;
	CALL	_mouse_installed
	TEST	EAX,EAX
	JE	SHORT	L_12
;
; Line 53:	mouse(3,0,0,0);
;
	PUSH	BYTE 00H
	PUSH	BYTE 00H
	PUSH	BYTE 00H
	PUSH	BYTE 03H
	CALL	_mouse
	ADD	ESP,BYTE 010H
;
; Line 54:	return regs.h.bx & 3;
;
	MOVZX	EAX,WORD [_regs+010H]
	AND	EAX,BYTE 03H
	JMP	SHORT	L_10
L_12:
;
; Line 56:	return 0;
;
	MOV	EAX,00H
L_10:
	RET
[GLOBAL	_get_mouseposition]
;
; Line 60:	void get_mouseposition(int *x, int *y)
;
_get_mouseposition:
	PUSH	EBP
	MOV	EBP,ESP
	PUSH	ESI
	PUSH	EDI
	MOV	ESI,DWORD [EBP+08H]
	MOV	EDI,DWORD [EBP+0CH]
L_15:
;
; Line 61:	{
;
;
; Line 62:	*x = *y = -1;
;
	MOV	DWORD [EDI+00H],0FFFFFFFFH
	MOV	DWORD [ESI+00H],0FFFFFFFFH
;
; Line 63:	if (mouse_installed())    {
;
	CALL	_mouse_installed
	TEST	EAX,EAX
	JE	SHORT	L_16
;
; Line 64:	mouse(3,0,0,0);
;
	PUSH	BYTE 00H
	PUSH	BYTE 00H
	PUSH	BYTE 00H
	PUSH	BYTE 03H
	CALL	_mouse
	ADD	ESP,BYTE 010H
;
; Line 65:	*x = regs.h.cx/8;
;
	MOVZX	EAX,WORD [_regs+018H]
	SHR	EAX,03H
	MOV	DWORD [ESI+00H],EAX
;
; Line 66:	*y = regs.h.dx/8;
;
	MOVZX	EAX,WORD [_regs+014H]
	SHR	EAX,03H
	MOV	DWORD [EDI+00H],EAX
;
; Line 67:	if (SCREENWIDTH == 40)
;
	MOV	EAX,04AH
	MOVZX	ECX,WORD [___seg0040]
	MOV	EDX,ECX
	MOV	FS,DX
	MOVSX	EAX,BYTE [FS:EAX+00H]
	MOVZX	EAX,AL
	CMP	EAX,BYTE 028H
	JNE	SHORT	L_18
;
; Line 68:	*x /= 2;
;
	TEST	DWORD [ESI+00H],080000000H
	JNS	SHORT	L_20
	INC	DWORD [ESI+00H]
L_20:
	SAR	DWORD [ESI+00H],01H
L_18:
L_16:
;
; Line 70:	}
;
L_14:
	POP	EDI
	POP	ESI
	POP	EBP
	RET
[GLOBAL	_set_mouseposition]
;
; Line 73:	void set_mouseposition(int x, int y)
;
_set_mouseposition:
	PUSH	EBP
	MOV	EBP,ESP
	PUSH	EBX
	MOV	EBX,DWORD [EBP+08H]
L_22:
;
; Line 74:	{
;
;
; Line 75:	if (mouse_installed())	{
;
	CALL	_mouse_installed
	TEST	EAX,EAX
	JE	SHORT	L_23
;
; Line 76:	if (SCREENWIDTH == 40)
;
	MOV	EAX,04AH
	MOVZX	ECX,WORD [___seg0040]
	MOV	EDX,ECX
	MOV	FS,DX
	MOVSX	EAX,BYTE [FS:EAX+00H]
	MOVZX	EAX,AL
	CMP	EAX,BYTE 028H
	JNE	SHORT	L_25
;
; Line 77:	x *= 2;
;
	SAL	EBX,01H
L_25:
;
; Line 78:	mouse(4,0,x*8,y*8);
;
	MOV	EAX,DWORD [EBP+0CH]
	SHL	EAX,03H
	PUSH	EAX
	MOV	EAX,EBX
	SHL	EAX,03H
	PUSH	EAX
	PUSH	BYTE 00H
	PUSH	BYTE 04H
	CALL	_mouse
	ADD	ESP,BYTE 010H
L_23:
;
; Line 80:	}
;
L_21:
	POP	EBX
	POP	EBP
	RET
[GLOBAL	_show_mousecursor]
;
; Line 83:	void show_mousecursor(void)
;
_show_mousecursor:
L_28:
;
; Line 84:	{
;
;
; Line 85:	if (mouse_installed())	{
;
	CALL	_mouse_installed
	TEST	EAX,EAX
	JE	SHORT	L_29
;
; Line 86:	mouse(1,0,0,0);
;
	PUSH	BYTE 00H
	PUSH	BYTE 00H
	PUSH	BYTE 00H
	PUSH	BYTE 01H
	CALL	_mouse
	ADD	ESP,BYTE 010H
L_29:
;
; Line 88:	}
;
L_27:
	RET
[GLOBAL	_hide_mousecursor]
;
; Line 91:	void hide_mousecursor(void)
;
_hide_mousecursor:
L_32:
;
; Line 92:	{
;
;
; Line 93:	if (mouse_installed())	{
;
	CALL	_mouse_installed
	TEST	EAX,EAX
	JE	SHORT	L_33
;
; Line 94:	mouse(2,0,0,0);
;
	PUSH	BYTE 00H
	PUSH	BYTE 00H
	PUSH	BYTE 00H
	PUSH	BYTE 02H
	CALL	_mouse
	ADD	ESP,BYTE 010H
L_33:
;
; Line 96:	}
;
L_31:
	RET
[GLOBAL	_button_releases]
;
; Line 99:	int button_releases(void)
;
_button_releases:
L_36:
;
; Line 100:	{
;
;
; Line 101:	if (mouse_installed())	{
;
	CALL	_mouse_installed
	TEST	EAX,EAX
	JE	SHORT	L_37
;
; Line 102:	mouse(6,0,0,0);
;
	PUSH	BYTE 00H
	PUSH	BYTE 00H
	PUSH	BYTE 00H
	PUSH	BYTE 06H
	CALL	_mouse
	ADD	ESP,BYTE 010H
;
; Line 103:	return regs.h.bx;
;
	MOVZX	EAX,WORD [_regs+010H]
	JMP	SHORT	L_35
L_37:
;
; Line 105:	return 0;
;
	MOV	EAX,00H
L_35:
	RET
[GLOBAL	_set_mousetravel]
;
; Line 109:	void set_mousetravel(int minx, int maxx, int miny, int maxy)
;
_set_mousetravel:
	PUSH	EBP
	MOV	EBP,ESP
	PUSH	EBX
	PUSH	ESI
	MOV	EBX,DWORD [EBP+0CH]
	MOV	ESI,DWORD [EBP+08H]
L_40:
;
; Line 110:	{
;
;
; Line 111:	if (mouse_installed())	{
;
	CALL	_mouse_installed
	TEST	EAX,EAX
	JE	SHORT	L_41
;
; Line 112:	if (SCREENWIDTH == 40)	{
;
	MOV	EAX,04AH
	MOVZX	ECX,WORD [___seg0040]
	MOV	EDX,ECX
	MOV	FS,DX
	MOVSX	EAX,BYTE [FS:EAX+00H]
	MOVZX	EAX,AL
	CMP	EAX,BYTE 028H
	JNE	SHORT	L_43
;
; Line 113:	minx *= 2;
;
	SAL	ESI,01H
;
; Line 114:	maxx *= 2;
;
	SAL	EBX,01H
L_43:
;
; Line 116:	mouse(7, 0, minx*8, maxx*8);
;
	MOV	EAX,EBX
	SHL	EAX,03H
	PUSH	EAX
	MOV	EAX,ESI
	SHL	EAX,03H
	PUSH	EAX
	PUSH	BYTE 00H
	PUSH	BYTE 07H
	CALL	_mouse
	ADD	ESP,BYTE 010H
;
; Line 117:	mouse(8, 0, miny*8, maxy*8);
;
	MOV	EAX,DWORD [EBP+014H]
	SHL	EAX,03H
	PUSH	EAX
	MOV	EAX,DWORD [EBP+010H]
	SHL	EAX,03H
	PUSH	EAX
	PUSH	BYTE 00H
	PUSH	BYTE 08H
	CALL	_mouse
	ADD	ESP,BYTE 010H
L_41:
;
; Line 119:	}
;
L_39:
	POP	ESI
	POP	EBX
	POP	EBP
	RET
SECTION _BSS
[GLOBAL	_regs]

_regs	RESB	032H

_sregs	RESB	0CH
SECTION _CONST

SECTION _TEXT
[EXTERN	___seg0000]
[EXTERN	___seg0040]
[EXTERN	_dpmi_simulate_real_interrupt]
