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"
|
2000-05-23 23:13:52 +02:00
|
|
|
#include "vga.h"
|
1999-06-26 21:09:08 +02:00
|
|
|
#include "debugtools.h"
|
1999-03-25 11:50:49 +01:00
|
|
|
|
2000-11-28 00:54:25 +01:00
|
|
|
DEFAULT_DEBUG_CHANNEL(int);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
2000-09-24 22:47:50 +02:00
|
|
|
static struct
|
|
|
|
{
|
1999-03-25 11:50:49 +01:00
|
|
|
DWORD x, y, but;
|
|
|
|
FARPROC16 callback;
|
|
|
|
WORD callmask;
|
2000-09-24 22:47:50 +02:00
|
|
|
} mouse_info;
|
1999-03-25 11:50:49 +01:00
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* 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
|
|
|
{
|
2000-09-26 01:53:07 +02:00
|
|
|
switch (LOWORD(context->Eax)) {
|
1999-03-25 11:50:49 +01:00
|
|
|
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 */
|
2000-09-24 22:47:50 +02:00
|
|
|
memset( &mouse_info, 0, sizeof(mouse_info) );
|
1999-03-25 11:50:49 +01:00
|
|
|
break;
|
2000-07-29 13:30:02 +02:00
|
|
|
case 0x01:
|
|
|
|
FIXME("Show mouse cursor\n");
|
|
|
|
break;
|
|
|
|
case 0x02:
|
|
|
|
FIXME("Hide mouse cursor\n");
|
|
|
|
break;
|
1999-03-25 11:50:49 +01:00
|
|
|
case 0x03:
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("Return mouse position and button status\n");
|
2000-09-24 22:47:50 +02:00
|
|
|
BX_reg(context) = mouse_info.but;
|
|
|
|
CX_reg(context) = mouse_info.x;
|
|
|
|
DX_reg(context) = mouse_info.y;
|
1999-03-25 11:50:49 +01:00
|
|
|
break;
|
2000-05-23 23:13:52 +02:00
|
|
|
case 0x04:
|
|
|
|
FIXME("Position mouse cursor\n");
|
|
|
|
break;
|
2000-07-29 13:30:02 +02:00
|
|
|
case 0x07:
|
|
|
|
FIXME("Define horizontal mouse cursor range\n");
|
|
|
|
break;
|
|
|
|
case 0x08:
|
|
|
|
FIXME("Define vertical mouse cursor range\n");
|
|
|
|
break;
|
|
|
|
case 0x09:
|
|
|
|
FIXME("Define graphics mouse cursor\n");
|
|
|
|
break;
|
|
|
|
case 0x0A:
|
|
|
|
FIXME("Define text mouse cursor\n");
|
|
|
|
break;
|
2000-05-23 23:13:52 +02:00
|
|
|
case 0x0C:
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("Define mouse interrupt subroutine\n");
|
2000-09-24 22:47:50 +02:00
|
|
|
mouse_info.callmask = CX_reg(context);
|
2000-12-13 21:20:09 +01:00
|
|
|
mouse_info.callback = (FARPROC16)MAKESEGPTR(context->SegEs, LOWORD(context->Edx));
|
1999-03-25 11:50:49 +01:00
|
|
|
break;
|
2000-07-29 13:30:02 +02:00
|
|
|
case 0x10:
|
|
|
|
FIXME("Define screen region for update\n");
|
|
|
|
break;
|
1999-03-25 11:50:49 +01:00
|
|
|
default:
|
|
|
|
INT_BARF(context,0x33);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
FARPROC16 proc;
|
|
|
|
WORD mask,but,x,y,mx,my;
|
|
|
|
} MCALLDATA;
|
|
|
|
|
2000-09-24 22:47:50 +02:00
|
|
|
static void MouseRelay(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
|
|
|
|
2000-09-26 01:53:07 +02:00
|
|
|
ctx.Eax = data->mask;
|
|
|
|
ctx.Ebx = data->but;
|
|
|
|
ctx.Ecx = data->x;
|
|
|
|
ctx.Edx = data->y;
|
|
|
|
ctx.Esi = data->mx;
|
|
|
|
ctx.Edi = data->my;
|
|
|
|
ctx.SegCs = SELECTOROF(data->proc);
|
|
|
|
ctx.Eip = 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)
|
|
|
|
{
|
|
|
|
WORD mask = 0;
|
2000-05-23 23:13:52 +02:00
|
|
|
unsigned Height, Width, SX=1, SY=1;
|
1999-03-25 11:50:49 +01:00
|
|
|
|
2000-05-23 23:13:52 +02:00
|
|
|
if (!VGA_GetMode(&Height,&Width,NULL)) {
|
|
|
|
/* may need to do some coordinate scaling */
|
|
|
|
SX = 640/Width;
|
|
|
|
if (!SX) SX=1;
|
|
|
|
}
|
2000-09-24 22:47:50 +02:00
|
|
|
mouse_info.x = LOWORD(lParam) * SX;
|
|
|
|
mouse_info.y = HIWORD(lParam) * SY;
|
1999-03-25 11:50:49 +01:00
|
|
|
switch (message) {
|
|
|
|
case WM_MOUSEMOVE:
|
|
|
|
mask |= 0x01;
|
|
|
|
break;
|
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
case WM_LBUTTONDBLCLK:
|
2000-09-24 22:47:50 +02:00
|
|
|
mouse_info.but |= 0x01;
|
1999-03-25 11:50:49 +01:00
|
|
|
mask |= 0x02;
|
|
|
|
break;
|
|
|
|
case WM_LBUTTONUP:
|
2000-09-24 22:47:50 +02:00
|
|
|
mouse_info.but &= ~0x01;
|
1999-03-25 11:50:49 +01:00
|
|
|
mask |= 0x04;
|
|
|
|
break;
|
|
|
|
case WM_RBUTTONDOWN:
|
|
|
|
case WM_RBUTTONDBLCLK:
|
2000-09-24 22:47:50 +02:00
|
|
|
mouse_info.but |= 0x02;
|
1999-03-25 11:50:49 +01:00
|
|
|
mask |= 0x08;
|
|
|
|
break;
|
|
|
|
case WM_RBUTTONUP:
|
2000-09-24 22:47:50 +02:00
|
|
|
mouse_info.but &= ~0x02;
|
1999-03-25 11:50:49 +01:00
|
|
|
mask |= 0x10;
|
|
|
|
break;
|
|
|
|
case WM_MBUTTONDOWN:
|
|
|
|
case WM_MBUTTONDBLCLK:
|
2000-09-24 22:47:50 +02:00
|
|
|
mouse_info.but |= 0x04;
|
1999-03-25 11:50:49 +01:00
|
|
|
mask |= 0x20;
|
|
|
|
break;
|
|
|
|
case WM_MBUTTONUP:
|
2000-09-24 22:47:50 +02:00
|
|
|
mouse_info.but &= ~0x04;
|
1999-03-25 11:50:49 +01:00
|
|
|
mask |= 0x40;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2000-09-24 22:47:50 +02:00
|
|
|
if ((mask & mouse_info.callmask) && mouse_info.callback) {
|
1999-03-25 11:50:49 +01:00
|
|
|
MCALLDATA *data = calloc(1,sizeof(MCALLDATA));
|
2000-09-24 22:47:50 +02:00
|
|
|
data->proc = mouse_info.callback;
|
|
|
|
data->mask = mask & mouse_info.callmask;
|
|
|
|
data->but = mouse_info.but;
|
|
|
|
data->x = mouse_info.x;
|
|
|
|
data->y = mouse_info.y;
|
1999-03-25 11:50:49 +01:00
|
|
|
DOSVM_QueueEvent(-1, DOS_PRIORITY_MOUSE, MouseRelay, data);
|
|
|
|
}
|
|
|
|
}
|