1999-03-25 11:50:49 +01:00
|
|
|
/*
|
|
|
|
* DOS interrupt 33h handler
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
2000-02-10 20:03:02 +01:00
|
|
|
#include "windef.h"
|
|
|
|
#include "wingdi.h"
|
1999-03-25 11:50:49 +01:00
|
|
|
#include "winuser.h"
|
|
|
|
#include "miscemu.h"
|
|
|
|
#include "dosexe.h"
|
1999-06-26 21:09:08 +02:00
|
|
|
#include "debugtools.h"
|
1999-03-25 11:50:49 +01:00
|
|
|
|
1999-04-19 16:56:29 +02:00
|
|
|
DEFAULT_DEBUG_CHANNEL(int)
|
|
|
|
|
1999-03-25 11:50:49 +01:00
|
|
|
typedef struct {
|
|
|
|
DWORD x, y, but;
|
|
|
|
FARPROC16 callback;
|
|
|
|
WORD callmask;
|
|
|
|
} MOUSESYSTEM;
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* INT_Int33Handler
|
|
|
|
*
|
|
|
|
* Handler for int 33h (MS MOUSE).
|
|
|
|
*/
|
1999-06-26 20:40:24 +02:00
|
|
|
void WINAPI INT_Int33Handler( CONTEXT86 *context )
|
1999-03-25 11:50:49 +01:00
|
|
|
{
|
|
|
|
MOUSESYSTEM *sys = (MOUSESYSTEM *)DOSVM_GetSystemData(0x33);
|
|
|
|
|
|
|
|
switch (AX_reg(context)) {
|
|
|
|
case 0x00:
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("Reset mouse driver and request status\n");
|
1999-03-25 11:50:49 +01:00
|
|
|
AX_reg(context) = 0xFFFF; /* installed */
|
|
|
|
BX_reg(context) = 3; /* # of buttons */
|
|
|
|
sys = calloc(1,sizeof(MOUSESYSTEM));
|
|
|
|
DOSVM_SetSystemData(0x33, sys);
|
|
|
|
break;
|
|
|
|
case 0x03:
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("Return mouse position and button status\n");
|
1999-03-25 11:50:49 +01:00
|
|
|
BX_reg(context) = sys->but;
|
|
|
|
CX_reg(context) = sys->x;
|
|
|
|
DX_reg(context) = sys->y;
|
|
|
|
break;
|
|
|
|
case 0x0C: /* Define interrupt subroutine */
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("Define mouse interrupt subroutine\n");
|
1999-03-25 11:50:49 +01:00
|
|
|
sys->callmask = CX_reg(context);
|
|
|
|
sys->callback = (FARPROC16)PTR_SEG_OFF_TO_SEGPTR(ES_reg(context), DX_reg(context));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
INT_BARF(context,0x33);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
FARPROC16 proc;
|
|
|
|
WORD mask,but,x,y,mx,my;
|
|
|
|
} MCALLDATA;
|
|
|
|
|
1999-06-26 20:40:24 +02:00
|
|
|
static void MouseRelay(LPDOSTASK lpDosTask,CONTEXT86 *context,void *mdata)
|
1999-03-25 11:50:49 +01:00
|
|
|
{
|
|
|
|
MCALLDATA *data = (MCALLDATA *)mdata;
|
1999-06-26 20:40:24 +02:00
|
|
|
CONTEXT86 ctx = *context;
|
1999-03-25 11:50:49 +01:00
|
|
|
|
1999-08-01 16:58:01 +02:00
|
|
|
EAX_reg(&ctx) = data->mask;
|
|
|
|
EBX_reg(&ctx) = data->but;
|
|
|
|
ECX_reg(&ctx) = data->x;
|
|
|
|
EDX_reg(&ctx) = data->y;
|
|
|
|
ESI_reg(&ctx) = data->mx;
|
|
|
|
EDI_reg(&ctx) = data->my;
|
|
|
|
CS_reg(&ctx) = SELECTOROF(data->proc);
|
|
|
|
EIP_reg(&ctx) = OFFSETOF(data->proc);
|
1999-03-25 11:50:49 +01:00
|
|
|
free(data);
|
|
|
|
DPMI_CallRMProc(&ctx, NULL, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WINAPI INT_Int33Message(UINT message,WPARAM wParam,LPARAM lParam)
|
|
|
|
{
|
|
|
|
MOUSESYSTEM *sys = (MOUSESYSTEM *)DOSVM_GetSystemData(0x33);
|
|
|
|
WORD mask = 0;
|
|
|
|
|
|
|
|
if (!sys) return;
|
|
|
|
sys->x = LOWORD(lParam);
|
|
|
|
sys->y = HIWORD(lParam);
|
|
|
|
switch (message) {
|
|
|
|
case WM_MOUSEMOVE:
|
|
|
|
mask |= 0x01;
|
|
|
|
break;
|
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
case WM_LBUTTONDBLCLK:
|
|
|
|
sys->but |= 0x01;
|
|
|
|
mask |= 0x02;
|
|
|
|
break;
|
|
|
|
case WM_LBUTTONUP:
|
|
|
|
sys->but &= ~0x01;
|
|
|
|
mask |= 0x04;
|
|
|
|
break;
|
|
|
|
case WM_RBUTTONDOWN:
|
|
|
|
case WM_RBUTTONDBLCLK:
|
|
|
|
sys->but |= 0x02;
|
|
|
|
mask |= 0x08;
|
|
|
|
break;
|
|
|
|
case WM_RBUTTONUP:
|
|
|
|
sys->but &= ~0x02;
|
|
|
|
mask |= 0x10;
|
|
|
|
break;
|
|
|
|
case WM_MBUTTONDOWN:
|
|
|
|
case WM_MBUTTONDBLCLK:
|
|
|
|
sys->but |= 0x04;
|
|
|
|
mask |= 0x20;
|
|
|
|
break;
|
|
|
|
case WM_MBUTTONUP:
|
|
|
|
sys->but &= ~0x04;
|
|
|
|
mask |= 0x40;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((mask & sys->callmask) && sys->callback) {
|
|
|
|
MCALLDATA *data = calloc(1,sizeof(MCALLDATA));
|
|
|
|
data->proc = sys->callback;
|
|
|
|
data->mask = mask & sys->callmask;
|
|
|
|
data->but = sys->but;
|
|
|
|
data->x = sys->x;
|
|
|
|
data->y = sys->y;
|
|
|
|
DOSVM_QueueEvent(-1, DOS_PRIORITY_MOUSE, MouseRelay, data);
|
|
|
|
}
|
|
|
|
}
|