32 bits message processing for color dialog.
[wine.git] / msdos / int33.c
blob6c6dbf0bdfad566bb55740e6bf40e3156bc9c712
1 /*
2 * DOS interrupt 33h handler
3 */
5 #include <stdlib.h>
6 #include "windef.h"
7 #include "wingdi.h"
8 #include "winuser.h"
9 #include "miscemu.h"
10 #include "dosexe.h"
11 #include "debugtools.h"
13 DEFAULT_DEBUG_CHANNEL(int)
15 typedef struct {
16 DWORD x, y, but;
17 FARPROC16 callback;
18 WORD callmask;
19 } MOUSESYSTEM;
21 /**********************************************************************
22 * INT_Int33Handler
24 * Handler for int 33h (MS MOUSE).
26 void WINAPI INT_Int33Handler( CONTEXT86 *context )
28 MOUSESYSTEM *sys = (MOUSESYSTEM *)DOSVM_GetSystemData(0x33);
30 switch (AX_reg(context)) {
31 case 0x00:
32 TRACE("Reset mouse driver and request status\n");
33 AX_reg(context) = 0xFFFF; /* installed */
34 BX_reg(context) = 3; /* # of buttons */
35 sys = calloc(1,sizeof(MOUSESYSTEM));
36 DOSVM_SetSystemData(0x33, sys);
37 break;
38 case 0x03:
39 TRACE("Return mouse position and button status\n");
40 BX_reg(context) = sys->but;
41 CX_reg(context) = sys->x;
42 DX_reg(context) = sys->y;
43 break;
44 case 0x0C: /* Define interrupt subroutine */
45 TRACE("Define mouse interrupt subroutine\n");
46 sys->callmask = CX_reg(context);
47 sys->callback = (FARPROC16)PTR_SEG_OFF_TO_SEGPTR(ES_reg(context), DX_reg(context));
48 break;
49 default:
50 INT_BARF(context,0x33);
54 typedef struct {
55 FARPROC16 proc;
56 WORD mask,but,x,y,mx,my;
57 } MCALLDATA;
59 static void MouseRelay(LPDOSTASK lpDosTask,CONTEXT86 *context,void *mdata)
61 MCALLDATA *data = (MCALLDATA *)mdata;
62 CONTEXT86 ctx = *context;
64 EAX_reg(&ctx) = data->mask;
65 EBX_reg(&ctx) = data->but;
66 ECX_reg(&ctx) = data->x;
67 EDX_reg(&ctx) = data->y;
68 ESI_reg(&ctx) = data->mx;
69 EDI_reg(&ctx) = data->my;
70 CS_reg(&ctx) = SELECTOROF(data->proc);
71 EIP_reg(&ctx) = OFFSETOF(data->proc);
72 free(data);
73 DPMI_CallRMProc(&ctx, NULL, 0, 0);
76 void WINAPI INT_Int33Message(UINT message,WPARAM wParam,LPARAM lParam)
78 MOUSESYSTEM *sys = (MOUSESYSTEM *)DOSVM_GetSystemData(0x33);
79 WORD mask = 0;
81 if (!sys) return;
82 sys->x = LOWORD(lParam);
83 sys->y = HIWORD(lParam);
84 switch (message) {
85 case WM_MOUSEMOVE:
86 mask |= 0x01;
87 break;
88 case WM_LBUTTONDOWN:
89 case WM_LBUTTONDBLCLK:
90 sys->but |= 0x01;
91 mask |= 0x02;
92 break;
93 case WM_LBUTTONUP:
94 sys->but &= ~0x01;
95 mask |= 0x04;
96 break;
97 case WM_RBUTTONDOWN:
98 case WM_RBUTTONDBLCLK:
99 sys->but |= 0x02;
100 mask |= 0x08;
101 break;
102 case WM_RBUTTONUP:
103 sys->but &= ~0x02;
104 mask |= 0x10;
105 break;
106 case WM_MBUTTONDOWN:
107 case WM_MBUTTONDBLCLK:
108 sys->but |= 0x04;
109 mask |= 0x20;
110 break;
111 case WM_MBUTTONUP:
112 sys->but &= ~0x04;
113 mask |= 0x40;
114 break;
117 if ((mask & sys->callmask) && sys->callback) {
118 MCALLDATA *data = calloc(1,sizeof(MCALLDATA));
119 data->proc = sys->callback;
120 data->mask = mask & sys->callmask;
121 data->but = sys->but;
122 data->x = sys->x;
123 data->y = sys->y;
124 DOSVM_QueueEvent(-1, DOS_PRIORITY_MOUSE, MouseRelay, data);