]> icculus.org git repositories - btb/d2x.git/blob - unused/bios/mouse.asm
remove rcs tags
[btb/d2x.git] / unused / bios / mouse.asm
1 ; THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
2 ; SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
3 ; END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
4 ; ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
5 ; IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
6 ; SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
7 ; FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
8 ; CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
9 ; AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
10 ; COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
11 ;***************************************************************************
12 ;***************************************************************************
13 ;*****                                                                 *****
14 ;*****                      M O U S E . A S M                          *****
15 ;*****                                                                 *****
16 ;***** Contains routines for a mouse interface.                        *****
17 ;*****                                                                 *****
18 ;*****                                                                 *****
19 ;***** PROCEDURES                                                      *****
20 ;*****                                                                 *****
21 ;***** VARIABLES                                                       *****
22 ;*****                                                                 *****
23 ;*****                                                                 *****
24 ;***** CONSTANTS                                                       *****
25 ;*****                                                                 *****
26 ;*****                                                                 *****
27 ;***************************************************************************
28 ;***************************************************************************
29
30 .386
31
32 ;************************************************************************
33 ;**************** FLAT MODEL DATA SEGMENT STUFF *************************
34 ;************************************************************************
35
36 _DATA   SEGMENT BYTE PUBLIC USE32 'DATA'
37
38                 MOUSE_EVENT STRUCT 2
39                         MouseDX         dw  ?
40                         MouseDY         dw  ?
41                         MouseButtons    dw  ?
42                         MouseFlags      dw  ?
43                 MOUSE_EVENT ENDS
44
45                 NumberOfButtons dw ?
46
47                 MyEvent             MOUSE_EVENT < >
48                 MyEventHandler      dd  0
49
50
51
52 _DATA   ENDS
53
54 DGROUP  GROUP _DATA
55
56
57 ;************************************************************************
58 ;**************** FLAT MODEL CODE SEGMENT STUFF *************************
59 ;************************************************************************
60
61 _TEXT   SEGMENT BYTE PUBLIC USE32 'CODE'
62
63                 ASSUME  ds:_DATA
64                 ASSUME  cs:_TEXT
65
66 PUBLIC  mouse_init_
67
68 mouse_init_:
69
70                 push    bx
71                 xor     ax, ax      ; Reset mouse
72                 int     33h
73                 mov     NumberOfButtons, bx
74                 pop     bx
75                 or      ax, ax
76                 jnz     present
77                 jmp     absent
78
79
80 present:
81                 mov     ax, 0020h   ; Enable driver
82                 int     33h
83
84                 mov     ax, 1
85                 ret
86
87 absent:
88                 mov     ax, 0
89                 ret
90
91
92
93 PUBLIC  mouse_get_pos_
94
95 mouse_get_pos_:
96
97                 push    eax
98                 push    ebx
99                 push    ecx
100                 push    edx
101
102                 push    eax
103
104                 mov     ax, 03h     ; Get Mouse Position and Button Status
105                 int     33h
106                 ; bx = buttons, cx = x, dx = y
107
108                 pop     eax
109                 mov     [eax], cx
110                 pop     eax
111                 mov     [eax], dx
112                 mov     edx, eax
113
114                 pop     ecx
115                 pop     ebx
116                 pop     eax
117
118                 ret
119
120 PUBLIC  mouse_get_delta_
121
122 mouse_get_delta_:
123
124                 push    eax
125                 push    ebx
126                 push    ecx
127                 push    edx
128
129
130                 push    eax
131
132                 mov     eax, 0bh    ; Read Mouse Motion Counters
133                 int     33h
134
135                 pop     eax
136                 mov     [eax], cx
137                 pop     eax
138                 mov     [eax], dx
139                 mov     edx, eax
140
141                 pop     ecx
142                 pop     ebx
143                 pop     eax
144                 ret
145
146
147 PUBLIC  mouse_get_btns_
148
149 mouse_get_btns_:
150
151                 push    ebx
152                 push    ecx
153                 push    edx
154
155                 mov     ax, 03h     ; Get Mouse Position and Button Status
156                 int     33h
157                 ; bx = buttons, cx = x, dx = y
158
159                 movzx   eax, bx
160
161                 pop     edx
162                 pop     ecx
163                 pop     ebx
164
165                 ret
166
167
168 PUBLIC  mouse_close_
169
170 mouse_close_:
171
172                 push    eax
173                 push    ebx
174                 push    es
175
176                 mov     ax, 01fh    ; Disable mouse driver
177                 int     33h
178
179                 pop     es
180                 pop     ebx
181                 pop     eax
182
183                 ret
184
185 MyHandler:
186
187                 pushad
188                 push    ds
189
190                 push    ax
191                 mov     ax, DGROUP
192                 mov     ds, ax
193                 pop     ax
194
195                 mov     MyEvent.MouseDX, cx
196                 mov     MyEvent.MouseDY, dx
197                 mov     MyEvent.MouseButtons, bx
198                 mov     MyEvent.MouseFlags, ax
199
200                 mov     eax, offset MyEvent
201
202                 call    MyEventHandler
203
204                 pop     ds
205                 popad
206
207                 retf
208
209 PUBLIC  mouse_set_handler_
210
211 mouse_set_handler_:
212
213                 push    eax
214                 push    ebx
215                 push    ecx
216                 push    edx
217                 push    es
218
219                 mov     MyEventHandler, edx
220
221                 mov     ecx, eax    ; Event flags
222                 mov     edx, MyHandler
223                 mov     ax, cs
224                 mov     es, ax
225                 mov     ax, 0Ch     ; Set User-defined Mouse Event Handler
226                 int     33h
227
228                 pop     es
229                 pop     edx
230                 pop     ecx
231                 pop     edx
232                 pop     eax
233
234                 ret
235
236 PUBLIC  mouse_clear_handler_
237
238 mouse_clear_handler_:
239
240                 push    eax
241                 push    ebx
242                 push    ecx
243                 push    edx
244                 push    es
245
246                 mov     MyEventHandler, 0
247
248                 mov     ecx, 0    ; Event flags
249                 mov     edx, MyHandler
250                 mov     ax, cs
251                 mov     es, ax
252                 mov     ax, 0Ch     ; Set User-defined Mouse Event Handler
253                 int     33h
254
255                 pop     es
256                 pop     edx
257                 pop     ecx
258                 pop     edx
259                 pop     eax
260
261                 ret
262
263
264 PUBLIC  mouse_set_limits_
265
266 mouse_set_limits_:
267
268                 ; EAX = minx
269                 ; EDX = miny
270                 ; EBX = maxx
271                 ; ECX = maxy
272
273                 push    edx     ; Save Vertical stuff
274                 push    ecx
275
276                 mov     cx, ax
277                 mov     dx, bx
278                 mov     ax, 7
279                 int     33h
280
281                 pop     edx
282                 pop     ecx
283                 mov     ax, 8
284                 int     33h
285
286                 ret
287
288
289 ;extern void mouse_set_pos( short x, short y);
290
291
292 PUBLIC  mouse_set_pos_
293
294 mouse_set_pos_:
295
296                 ; EAX = x
297                 ; EDX = y
298
299                 push    ecx
300
301                 mov     ecx, eax
302                 mov     eax, 04h
303                 int     33h
304                 pop     ecx
305
306
307                 ret
308
309
310
311 _TEXT   ENDS
312
313
314                 END