12
mouse_regs : trealregs; external name '___v2prt0_rmcb_regs';
13
mouse_seginfo : tseginfo;
16
mouse_numbuttons : longint;
19
mouse_x, mouse_y : Word;
22
userproc_installed : Longbool;
23
userproc_length : Longint;
24
userproc_proc : pointer;
26
procedure callback_handler; assembler;
33
cmpl $1, USERPROC_INSTALLED
36
movw DOSmemSELECTOR, %ax
47
movl %eax, %es: 42(%edi)
52
procedure mouse_dummy; begin end;
54
procedure textuserproc;
56
mouse_b := mouse_regs.bx;
57
mouse_x := (mouse_regs.cx shr 3) + 1;
58
mouse_y := (mouse_regs.dx shr 3) + 1;
61
procedure install_mouse(userproc : pointer; userproclen : longint);
64
r.eax := $0; realintr(mouseint, r);
65
if (r.eax <> $FFFF) then begin
66
Writeln('No Microsoft compatible mouse found');
67
Writeln('A Microsoft compatible mouse driver is necessary ',
68
'to run this example');
71
if (r.bx = $ffff) then mouse_numbuttons := 2
72
else mouse_numbuttons := r.bx;
73
Writeln(mouse_numbuttons, ' button Microsoft compatible mouse ',
75
if (userproc <> nil) then begin
76
userproc_proc := userproc;
77
userproc_installed := true;
78
userproc_length := userproclen;
79
lock_code(userproc_proc, userproc_length);
83
userproc_installed := false;
85
lock_data(mouse_x, sizeof(mouse_x));
86
lock_data(mouse_y, sizeof(mouse_y));
87
lock_data(mouse_b, sizeof(mouse_b));
88
lock_data(mouse_action, sizeof(mouse_action));
90
lock_data(userproc_installed, sizeof(userproc_installed));
91
lock_data(userproc_proc, sizeof(userproc_proc));
93
lock_data(mouse_regs, sizeof(mouse_regs));
94
lock_data(mouse_seginfo, sizeof(mouse_seginfo));
95
lock_code(@callback_handler,
96
longint(@mouse_dummy)-longint(@callback_handler));
97
get_rm_callback(@callback_handler, mouse_regs, mouse_seginfo);
98
r.eax := $0c; r.ecx := $7f;
99
r.edx := longint(mouse_seginfo.offset);
100
r.es := mouse_seginfo.segment;
101
realintr(mouseint, r);
103
realintr(mouseint, r);
106
procedure remove_mouse;
110
r.eax := $02; realintr(mouseint, r);
111
r.eax := $0c; r.ecx := 0; r.edx := 0; r.es := 0;
112
realintr(mouseint, r);
113
free_rm_callback(mouse_seginfo);
114
if (userproc_installed) then begin
115
unlock_code(userproc_proc, userproc_length);
116
userproc_proc := nil;
117
userproc_length := 0;
118
userproc_installed := false;
120
unlock_data(mouse_x, sizeof(mouse_x));
121
unlock_data(mouse_y, sizeof(mouse_y));
122
unlock_data(mouse_b, sizeof(mouse_b));
123
unlock_data(mouse_action, sizeof(mouse_action));
125
unlock_data(userproc_proc, sizeof(userproc_proc));
126
unlock_data(userproc_installed, sizeof(userproc_installed));
128
unlock_data(mouse_regs, sizeof(mouse_regs));
129
unlock_data(mouse_seginfo, sizeof(mouse_seginfo));
130
unlock_code(@callback_handler,
131
longint(@mouse_dummy)-longint(@callback_handler));
132
fillchar(mouse_seginfo, sizeof(mouse_seginfo), 0);
137
install_mouse(@textuserproc, 400);
138
Writeln('Press any key to exit...');
139
while (not keypressed) do begin
141
write('MouseX : ', mouse_x:2, ' MouseY : ', mouse_y:2,
142
' Buttons : ', mouse_b:2);
b'\\ No newline at end of file'