Subversion Repositories Kolibri OS

Rev

Rev 9930 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9930 Rev 9941
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2022. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2023. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
 
7
 
8
$Revision: 9930 $
8
$Revision: 9941 $
9
 
9
 
10
 
10
 
11
;   check mouse
11
;   check mouse
12
;
12
;
13
;
13
;
14
;   FB00  ->   FB0F   mouse memory 00 chunk count - FB0A-B x - FB0C-D y
14
;   FB00  ->   FB0F   mouse memory 00 chunk count - FB0A-B x - FB0C-D y
15
;   FB10  ->   FB17   mouse color mem
15
;   FB10  ->   FB17   mouse color mem
16
;   FB21              x move
16
;   FB21              x move
17
;   FB22              y move
17
;   FB22              y move
18
;   FB30              color temp
18
;   FB30              color temp
19
;   FB28              high bits temp
19
;   FB28              high bits temp
20
;   FB4A  ->   FB4D   FB4A-B x-under - FB4C-D y-under
20
;   FB4A  ->   FB4D   FB4A-B x-under - FB4C-D y-under
21
;   FC00  ->   FCFE   com1/ps2 buffer
21
;   FC00  ->   FCFE   com1/ps2 buffer
22
;   FCFF              com1/ps2 buffer count starting from FC00
22
;   FCFF              com1/ps2 buffer count starting from FC00
23
 
23
 
24
uglobal
24
uglobal
25
;--------------------------------------
25
;--------------------------------------
26
align 4
26
align 4
27
mousecount                      dd ?
27
mousecount                      dd ?
28
mousedata                       dd ?
28
mousedata                       dd ?
29
Y_UNDER_sub_CUR_hot_y_add_curh  dw ?
29
Y_UNDER_sub_CUR_hot_y_add_curh  dw ?
30
Y_UNDER_subtraction_CUR_hot_y   dw ?
30
Y_UNDER_subtraction_CUR_hot_y   dw ?
31
X_UNDER_sub_CUR_hot_x_add_curh  dw ?
31
X_UNDER_sub_CUR_hot_x_add_curh  dw ?
32
X_UNDER_subtraction_CUR_hot_x   dw ?
32
X_UNDER_subtraction_CUR_hot_x   dw ?
33
endg
33
endg
34
 
34
 
35
iglobal
35
iglobal
36
;--------------------------------------
36
;--------------------------------------
37
align 4
37
align 4
38
mouse_speed_factor      dw 4
38
mouse_speed_factor      dw 4
39
mouse_delay             db 3
39
mouse_delay             db 3
40
mouse_doubleclick_delay db 64
40
mouse_doubleclick_delay db 64
41
endg
41
endg
42
 
42
 
43
;-----------------------------------------------------------------------------
43
;-----------------------------------------------------------------------------
44
 
44
 
45
align 4
45
align 4
46
draw_mouse_under:
46
draw_mouse_under:
47
 
47
 
48
        ; return old picture
48
        ; return old picture
49
        cmp     [_display.restore_cursor], 0
49
        cmp     [_display.restore_cursor], 0
50
        je      @F
50
        je      @F
51
 
51
 
52
        pushad
52
        pushad
53
        movzx   eax, word [X_UNDER]
53
        movzx   eax, word [X_UNDER]
54
        movzx   ebx, word [Y_UNDER]
54
        movzx   ebx, word [Y_UNDER]
55
        stdcall [_display.restore_cursor], eax, ebx
55
        stdcall [_display.restore_cursor], eax, ebx
56
        popad
56
        popad
57
        ret
-
 
58
 
-
 
59
  @@:
57
@@:
60
        pushad
-
 
61
        xor     ecx, ecx
-
 
62
        xor     edx, edx
-
 
63
 
-
 
64
  .mres:
-
 
65
        movzx   eax, word [X_UNDER]
-
 
66
        movzx   ebx, word [Y_UNDER]
-
 
67
        add     eax, ecx
-
 
68
        add     ebx, edx
-
 
69
        push    ecx
-
 
70
        push    edx
-
 
71
        push    eax
-
 
72
        push    ebx
-
 
73
        mov     eax, edx
-
 
74
        shl     eax, 6
-
 
75
        shl     ecx, 2
-
 
76
        add     eax, ecx
-
 
77
        add     eax, mouseunder
-
 
78
        mov     ecx, [eax]
-
 
79
        pop     ebx
-
 
80
        pop     eax
-
 
81
        mov     edi, 1 ; force
-
 
82
        or      ecx, 0x04000000  ; don't save to mouseunder area
-
 
83
;        call    [putpixel]
-
 
84
        call    __sys_putpixel
-
 
85
        pop     edx
-
 
86
        pop     ecx
-
 
87
        inc     ecx
-
 
88
        cmp     ecx, 16
-
 
89
        jnz     .mres
-
 
90
 
-
 
91
        xor     ecx, ecx
-
 
92
        inc     edx
-
 
93
        cmp     edx, 24
-
 
94
        jnz     .mres
-
 
95
 
-
 
96
        popad
-
 
97
        ret
58
        ret
98
 
59
 
99
;-----------------------------------------------------------------------------
60
;-----------------------------------------------------------------------------
100
 
61
 
101
align 4
62
align 4
102
save_draw_mouse:
63
save_draw_mouse:
103
        cmp     [_display.move_cursor], 0
64
        cmp     [_display.move_cursor], 0
104
        je      .no_hw_cursor
65
        je      .exit
105
        pushad
66
        pushad
106
 
67
 
107
        mov     [X_UNDER], ax
68
        mov     [X_UNDER], ax
108
        mov     [Y_UNDER], bx
69
        mov     [Y_UNDER], bx
109
        movzx   eax, word [MOUSE_Y]
70
        movzx   eax, word [MOUSE_Y]
110
        movzx   ebx, word [MOUSE_X]
71
        movzx   ebx, word [MOUSE_X]
111
        push    eax
72
        push    eax
112
        push    ebx
73
        push    ebx
113
 
74
 
114
        mov     eax, [d_width_calc_area + eax*4]
75
        mov     eax, [d_width_calc_area + eax*4]
115
 
76
 
116
        add     eax, [_display.win_map]
77
        add     eax, [_display.win_map]
117
        movzx   edx, byte [ebx + eax]
78
        movzx   edx, byte [ebx + eax]
118
        shl     edx, BSF sizeof.WDATA
79
        shl     edx, BSF sizeof.WDATA
119
        ; edx - thread slot of window under cursor
80
        ; edx - thread slot of window under cursor
120
        mov     esi, [window_data + edx + WDATA.cursor] ; cursor of window under cursor
81
        mov     esi, [window_data + edx + WDATA.cursor] ; cursor of window under cursor
121
 
82
 
122
        ; if cursor of window under cursor already equal to the
83
        ; if cursor of window under cursor already equal to the
123
        ; current_cursor then just draw it
84
        ; current_cursor then just draw it
124
        cmp     esi, [current_cursor]
85
        cmp     esi, [current_cursor]
125
        je      .draw
86
        je      .draw
126
 
87
 
127
        ; eax = thread slot of current active window
88
        ; eax = thread slot of current active window
128
        mov     eax, [thread_count]
89
        mov     eax, [thread_count]
129
        movzx   eax, word [WIN_POS + eax*2]
90
        movzx   eax, word [WIN_POS + eax*2]
130
        shl     eax, BSF sizeof.WDATA
91
        shl     eax, BSF sizeof.WDATA
131
 
92
 
132
        ; window under cursor == active window ?
93
        ; window under cursor == active window ?
133
        cmp     eax, edx
94
        cmp     eax, edx
134
        je      @f
95
        je      @f
135
 
96
 
136
        ; check whether active window is being resized now:
97
        ; check whether active window is being resized now:
137
        mov     bl, [mouse.active_sys_window.action]
98
        mov     bl, [mouse.active_sys_window.action]
138
        and     bl, mouse.WINDOW_RESIZE_S_FLAG or mouse.WINDOW_RESIZE_W_FLAG or mouse.WINDOW_RESIZE_E_FLAG
99
        and     bl, mouse.WINDOW_RESIZE_S_FLAG or mouse.WINDOW_RESIZE_W_FLAG or mouse.WINDOW_RESIZE_E_FLAG
139
        test    bl, bl
100
        test    bl, bl
140
        jz      .active_isnt_resizing
101
        jz      .active_isnt_resizing
141
        mov     esi, [window_data + eax + WDATA.cursor] ; esi = cursor of active window, it is resizing cursor
102
        mov     esi, [window_data + eax + WDATA.cursor] ; esi = cursor of active window, it is resizing cursor
142
        jmp     @f
103
        jmp     @f
143
        .active_isnt_resizing:
104
        .active_isnt_resizing:
144
 
105
 
145
        ; if cursor of window under the cursor is resizing cursor then draw it.
106
        ; if cursor of window under the cursor is resizing cursor then draw it.
146
        cmp     esi, [def_cursor_hresize]
107
        cmp     esi, [def_cursor_hresize]
147
        je      @f
108
        je      @f
148
        cmp     esi, [def_cursor_vresize]
109
        cmp     esi, [def_cursor_vresize]
149
        je      @f
110
        je      @f
150
        cmp     esi, [def_cursor_dresize1]
111
        cmp     esi, [def_cursor_dresize1]
151
        je      @f
112
        je      @f
152
        cmp     esi, [def_cursor_dresize2]
113
        cmp     esi, [def_cursor_dresize2]
153
        je      @f
114
        je      @f
154
 
115
 
155
        ; set cursor of window under cursor
116
        ; set cursor of window under cursor
156
        mov     esi, [window_data + edx + WDATA.cursor]
117
        mov     esi, [window_data + edx + WDATA.cursor]
157
        cmp     esi, [current_cursor]
118
        cmp     esi, [current_cursor]
158
        je      .draw
119
        je      .draw
159
 
120
 
160
@@:
121
@@:
-
 
122
        cmp     [_display.select_cursor], 0
161
        push    esi
123
        jz      .error
-
 
124
 
162
        call    [_display.select_cursor]
125
        stdcall [_display.select_cursor], esi
163
        mov     [current_cursor], esi
126
        mov     [current_cursor], esi
164
;--------------------------------------
127
;--------------------------------------
165
align 4
128
align 4
166
.draw:
129
.draw:
167
        stdcall [_display.move_cursor], esi
130
        stdcall [_display.move_cursor], esi
168
        popad
131
        popad
169
        ret
132
        ret
170
;--------------------------------------
133
;--------------------------------------
171
;align 4
134
;align 4
172
;.fail:
135
;.fail:
173
;        mov     ecx, [def_cursor]
136
;        mov     ecx, [def_cursor]
174
;        mov     [window_data + edx + WDATA.cursor], ecx
137
;        mov     [window_data + edx + WDATA.cursor], ecx
175
;        stdcall [_display.move_cursor], ecx        ; stdcall: [esp]=ebx,eax
138
;        stdcall [_display.move_cursor], ecx        ; stdcall: [esp]=ebx,eax
176
;        popad
139
;        popad
177
;        ret
140
;        ret
178
;--------------------------------------
141
;--------------------------------------
179
align 4
142
align 4
180
.no_hw_cursor:
-
 
181
        pushad
-
 
182
        ; save & draw
-
 
183
        mov     [X_UNDER], ax
-
 
184
        mov     [Y_UNDER], bx
-
 
185
        push    eax
-
 
186
        push    ebx
-
 
187
        mov     ecx, 0
-
 
188
        mov     edx, 0
-
 
189
;--------------------------------------
-
 
190
align 4
-
 
191
.drm:
143
.error:
192
        push    eax
-
 
193
        push    ebx
-
 
194
        push    ecx
-
 
195
        push    edx
-
 
196
        ; helloworld
-
 
197
        push    ecx
-
 
198
        add     eax, ecx        ; save picture under mouse
-
 
199
        add     ebx, edx
-
 
200
        push    ecx
-
 
201
        or      ecx, 0x04000000 ; don't load to mouseunder area
-
 
202
        push    eax ebx edx edi
-
 
203
        call    [GETPIXEL]
-
 
204
        pop     edi edx ebx eax
-
 
205
        mov     [COLOR_TEMP], ecx
-
 
206
        pop     ecx
-
 
207
        mov     eax, edx
-
 
208
        shl     eax, 6
-
 
209
        shl     ecx, 2
-
 
210
        add     eax, ecx
-
 
211
        add     eax, mouseunder
-
 
212
        mov     ebx, [COLOR_TEMP]
-
 
213
        and     ebx, 0xffffff
-
 
214
        mov     [eax], ebx
-
 
215
        pop     ecx
-
 
216
        mov     edi, edx        ; y cycle
-
 
217
        shl     edi, 4          ; *16 bytes per row
-
 
218
        add     edi, ecx        ; x cycle
-
 
219
        mov     esi, edi
-
 
220
        add     edi, esi
-
 
221
        add     edi, esi        ; *3
-
 
222
        add     edi, [MOUSE_PICTURE]    ; we have our str address
-
 
223
        mov     esi, edi
-
 
224
        add     esi, 16*24*3
-
 
225
        push    ecx
-
 
226
        mov     ecx, [COLOR_TEMP]
-
 
227
        call    combine_colors
-
 
228
        and     ecx, 0xffffff
-
 
229
        mov     [MOUSE_COLOR_MEM], ecx
-
 
230
        pop     ecx
-
 
231
        pop     edx
-
 
232
        pop     ecx
-
 
233
        pop     ebx
-
 
234
        pop     eax
-
 
235
        add     eax, ecx        ; we have x coord+cycle
-
 
236
        add     ebx, edx        ; and y coord+cycle
-
 
237
        push    ecx
-
 
238
        mov     ecx, [MOUSE_COLOR_MEM]
-
 
239
        mov     edi, 1 ; force
-
 
240
        or      ecx, 0x04000000 ; don't save to mouseunder area
-
 
241
;        call    [putpixel]
-
 
242
        call    __sys_putpixel
-
 
243
        pop     ecx
-
 
244
        mov     ebx, [esp+0]    ; pure y coord again
-
 
245
        mov     eax, [esp+4]    ; and x
-
 
246
        inc     ecx             ; +1 cycle
-
 
247
        cmp     ecx, 16         ; if more than 16
-
 
248
        jnz     .drm
-
 
249
 
-
 
250
        xor     ecx, ecx
-
 
251
        inc     edx
-
 
252
        cmp     edx, 24
-
 
253
        jnz     .drm
-
 
254
 
-
 
255
        add     esp, 8
-
 
256
        popad
144
        popad
257
        ret
-
 
258
 
-
 
259
;-----------------------------------------------------------------------------
-
 
260
 
-
 
261
align 4
-
 
262
combine_colors:
-
 
263
      ; in
-
 
264
      ; ecx - color ( 00 RR GG BB )
-
 
265
      ; edi - ref to new color byte
-
 
266
      ; esi - ref to alpha byte
-
 
267
      ;
-
 
268
      ; out
-
 
269
      ; ecx - new color ( roughly (ecx*[esi]>>8)+([edi]*[esi]>>8) )
-
 
270
        push    eax
-
 
271
        push    ebx
-
 
272
        push    edx
-
 
273
        push    ecx
-
 
274
        xor     ecx, ecx
-
 
275
         ; byte 0
-
 
276
        mov     eax, 0xff
-
 
277
        sub     al, [esi+0]
-
 
278
        mov     ebx, [esp]
-
 
279
        shr     ebx, 16
-
 
280
        and     ebx, 0xff
-
 
281
        mul     ebx
-
 
282
        shr     eax, 8
-
 
283
        add     ecx, eax
-
 
284
        xor     eax, eax
-
 
285
        xor     ebx, ebx
-
 
286
        mov     al, [edi+0]
-
 
287
        mov     bl, [esi+0]
-
 
288
        mul     ebx
-
 
289
        shr     eax, 8
-
 
290
        add     ecx, eax
-
 
291
        shl     ecx, 8
-
 
292
         ; byte 1
-
 
293
        mov     eax, 0xff
-
 
294
        sub     al, [esi+1]
-
 
295
        mov     ebx, [esp]
-
 
296
        shr     ebx, 8
-
 
297
        and     ebx, 0xff
-
 
298
        mul     ebx
-
 
299
        shr     eax, 8
-
 
300
        add     ecx, eax
-
 
301
        xor     eax, eax
-
 
302
        xor     ebx, ebx
-
 
303
        mov     al, [edi+1]
-
 
304
        mov     bl, [esi+1]
-
 
305
        mul     ebx
-
 
306
        shr     eax, 8
-
 
307
        add     ecx, eax
-
 
308
        shl     ecx, 8
-
 
309
         ; byte 2
-
 
310
        mov     eax, 0xff
-
 
311
        sub     al, [esi+2]
-
 
312
        mov     ebx, [esp]
-
 
313
        and     ebx, 0xff
-
 
314
        mul     ebx
-
 
315
        shr     eax, 8
-
 
316
        add     ecx, eax
-
 
317
        xor     eax, eax
-
 
318
        xor     ebx, ebx
-
 
319
        mov     al, [edi+2]
-
 
320
        mov     bl, [esi+2]
-
 
321
        mul     ebx
-
 
322
        shr     eax, 8
-
 
323
        add     ecx, eax
-
 
324
        pop     eax
-
 
325
        pop     edx
-
 
326
        pop     ebx
-
 
327
        pop     eax
-
 
328
        ret
-
 
329
 
-
 
330
;-----------------------------------------------------------------------------
-
 
331
 
-
 
332
align 4
-
 
333
check_mouse_area_for_getpixel:
-
 
334
; in:
-
 
335
; eax = x
-
 
336
; ebx = y
-
 
337
; out:
-
 
338
; ecx = new color
-
 
339
        push    eax ebx
-
 
340
; check for Y
-
 
341
        xor     ecx, ecx
-
 
342
        mov     cx, [Y_UNDER]   ; [MOUSE_Y]
-
 
343
 
-
 
344
        cmp     ebx, ecx
-
 
345
        jb      .no_mouse_area
-
 
346
        add     ecx, 23         ; mouse cursor Y size
-
 
347
        cmp     ebx, ecx
-
 
348
        ja      .no_mouse_area
-
 
349
; offset Y
-
 
350
        sub     bx, [Y_UNDER]   ; [MOUSE_Y]
-
 
351
;--------------------------------------
-
 
352
; check for X
-
 
353
        xor     ecx, ecx
-
 
354
        mov     cx, [X_UNDER]   ; [MOUSE_X]
-
 
355
        cmp     eax, ecx
-
 
356
        jb      .no_mouse_area
-
 
357
        add     ecx, 15         ; mouse cursor X size
-
 
358
        cmp     eax, ecx
-
 
359
        ja      .no_mouse_area
-
 
360
; offset X
-
 
361
        sub     ax, [X_UNDER]   ; [MOUSE_X]
-
 
362
;--------------------------------------
-
 
363
; eax = offset x
-
 
364
; ebx = offset y
-
 
365
        shl     ebx, 6  ;y
-
 
366
        shl     eax, 2  ;x
-
 
367
        add     eax, ebx
-
 
368
        add     eax, mouseunder
-
 
369
        mov     ecx, [eax]
-
 
370
        and     ecx, 0xffffff
-
 
371
        or      ecx, 0xff000000
-
 
372
        pop     ebx eax
-
 
373
        ret
-
 
374
 
-
 
375
  .no_mouse_area:
-
 
376
        xor     ecx, ecx
-
 
377
        pop     ebx eax
-
 
378
        ret
-
 
379
 
-
 
380
;-----------------------------------------------------------------------------
-
 
381
 
-
 
382
align 4
-
 
383
check_mouse_area_for_putpixel:
-
 
384
; in:
-
 
385
; ecx = x shl 16 + y
-
 
386
; eax = color
-
 
387
; out:
145
.exit:
388
; eax = new color
-
 
389
        push    eax
-
 
390
; check for Y
-
 
391
        mov     ax, [Y_UNDER]   ; [MOUSE_Y]
-
 
392
        cmp     cx, ax
-
 
393
        jb      .no_mouse_area
-
 
394
        add     ax, 23          ; mouse cursor Y size
-
 
395
        cmp     cx, ax
-
 
396
        ja      .no_mouse_area
-
 
397
; offset Y
-
 
398
        sub     cx, [Y_UNDER]   ; [MOUSE_Y]
-
 
399
        mov     ax, cx
-
 
400
        shl     eax, 16
-
 
401
 
-
 
402
; check for X
-
 
403
        mov     ax, [X_UNDER]   ; [MOUSE_X]
-
 
404
        shr     ecx, 16
-
 
405
        cmp     cx, ax
-
 
406
        jb      .no_mouse_area
-
 
407
        add     ax, 15          ; mouse cursor X size
-
 
408
        cmp     cx, ax
-
 
409
        ja      .no_mouse_area
-
 
410
; offset X
-
 
411
        sub     cx, [X_UNDER]   ; [MOUSE_X]
-
 
412
        mov     ax, cx
-
 
413
 
-
 
414
; eax = (offset y) shl 16 + (offset x)
-
 
415
 
-
 
416
        pop     ecx
-
 
417
 
-
 
418
        push    eax ebx
-
 
419
 
-
 
420
        mov     ebx, eax
-
 
421
        shr     ebx, 16         ; y
-
 
422
        and     eax, 0xffff     ; x
-
 
423
 
-
 
424
        shl     ebx, 6
-
 
425
        shl     eax, 2
-
 
426
        add     eax, ebx
-
 
427
        add     eax, mouseunder
-
 
428
        and     ecx, 0xFFFFFF
-
 
429
        mov     [eax], ecx
-
 
430
 
-
 
431
        pop     ebx eax
-
 
432
 
-
 
433
        push    esi edi
-
 
434
        rol     eax, 16
-
 
435
        movzx   edi, ax         ; y cycle
-
 
436
        shl     edi, 4          ; *16 bytes per row
-
 
437
        shr     eax, 16
-
 
438
        add     edi, eax        ; x cycle
-
 
439
        lea     edi, [edi*3]
-
 
440
        add     edi, [MOUSE_PICTURE]    ; we have our str address
-
 
441
        mov     esi, edi
-
 
442
        add     esi, 16*24*3
-
 
443
        call    combine_colors
-
 
444
        pop     edi esi
-
 
445
        mov     eax, ecx
-
 
446
        ret
-
 
447
 
-
 
448
  .no_mouse_area:
-
 
449
        pop     eax
-
 
450
        ret
146
        ret
451
 
147
 
452
;-----------------------------------------------------------------------------
148
;-----------------------------------------------------------------------------
453
 
149
 
454
align 4
150
align 4
455
__sys_draw_pointer:
151
__sys_draw_pointer:
456
        pushad
152
        pushad
457
        movzx   ecx, word [X_UNDER]
153
        movzx   ecx, word [X_UNDER]
458
        movzx   edx, word [Y_UNDER]
154
        movzx   edx, word [Y_UNDER]
459
        movzx   ebx, word [MOUSE_Y]
155
        movzx   ebx, word [MOUSE_Y]
460
        movzx   eax, word [MOUSE_X]
156
        movzx   eax, word [MOUSE_X]
461
        cmp     [redrawmouse_unconditional], 0
157
        cmp     [redrawmouse_unconditional], 0
462
        je      @f
158
        je      @f
463
        mov     [redrawmouse_unconditional], 0
159
        mov     [redrawmouse_unconditional], 0
464
        jmp     redrawmouse
160
        jmp     .redrawmouse
465
  @@:
161
  @@:
466
        cmp     eax, ecx
162
        cmp     eax, ecx
467
        jne     redrawmouse
163
        jne     .redrawmouse
468
        cmp     ebx, edx
164
        cmp     ebx, edx
469
        je      nodmp
165
        je      .nodmp
470
 
166
 
471
;--------------------------------------
167
;--------------------------------------
472
 
168
 
473
align 4
169
align 4
474
redrawmouse:
170
.redrawmouse:
475
        pushfd
171
        pushfd
476
        cli
172
        cli
477
        call    draw_mouse_under
173
        call    draw_mouse_under
478
        call    save_draw_mouse
174
        call    save_draw_mouse
479
 
-
 
480
;        mov     eax, [_display.select_cursor]
-
 
481
;        test    eax, eax
-
 
482
;        jz      @f
175
 
483
        cmp     [_display.select_cursor], select_cursor
176
        cmp     [_display.select_cursor], select_cursor
484
        jne     @f
177
        jne     @f
485
 
178
 
486
        xor     eax, eax
179
        xor     eax, eax
487
        mov     esi, [current_cursor]
180
        mov     esi, [current_cursor]
488
 
181
 
489
        mov     ax, [Y_UNDER]
182
        mov     ax, [Y_UNDER]
490
        sub     eax, [esi + CURSOR.hot_y]
183
        sub     eax, [esi + CURSOR.hot_y]
491
        mov     [Y_UNDER_subtraction_CUR_hot_y], ax
184
        mov     [Y_UNDER_subtraction_CUR_hot_y], ax
492
        add     eax, [cur.h]
185
        add     eax, [cur.h]
493
        mov     [Y_UNDER_sub_CUR_hot_y_add_curh], ax
186
        mov     [Y_UNDER_sub_CUR_hot_y_add_curh], ax
494
 
187
 
495
        mov     ax, [X_UNDER]
188
        mov     ax, [X_UNDER]
496
        sub     eax, [esi + CURSOR.hot_x]
189
        sub     eax, [esi + CURSOR.hot_x]
497
        mov     [X_UNDER_subtraction_CUR_hot_x], ax
190
        mov     [X_UNDER_subtraction_CUR_hot_x], ax
498
        add     eax, [cur.w]
191
        add     eax, [cur.w]
499
        mov     [X_UNDER_sub_CUR_hot_x_add_curh], ax
192
        mov     [X_UNDER_sub_CUR_hot_x_add_curh], ax
500
  @@:
193
  @@:
501
        popfd
194
        popfd
502
  nodmp:
195
.nodmp:
503
        popad
196
        popad
504
        ret
197
        ret
505
 
198
 
506
;-----------------------------------------------------------------------------
199
;-----------------------------------------------------------------------------
507
 
200
 
508
align 4
201
align 4
509
proc set_mouse_data stdcall uses ecx edx, BtnState:dword, XMoving:dword, YMoving:dword, VScroll:dword, HScroll:dword
202
proc set_mouse_data stdcall uses ecx edx, BtnState:dword, XMoving:dword, YMoving:dword, VScroll:dword, HScroll:dword
510
 
203
 
511
        mov     eax, [BtnState]
204
        mov     eax, [BtnState]
512
        and     eax, 0x3FFFFFFF         ; Top 2 bits are used to flag absolute movements
205
        and     eax, 0x3FFFFFFF         ; Top 2 bits are used to flag absolute movements
513
        mov     [BTN_DOWN], eax
206
        mov     [BTN_DOWN], eax
514
;--------------------------------------
207
;--------------------------------------
515
        mov     eax, [XMoving]
208
        mov     eax, [XMoving]
516
        test    [BtnState], 0x80000000
209
        test    [BtnState], 0x80000000
517
        jnz     .absolute_x
210
        jnz     .absolute_x
518
        test    eax, eax
211
        test    eax, eax
519
        jz      @f
212
        jz      @f
520
        call    mouse_acceleration
213
        call    mouse_acceleration
521
        add     ax, [MOUSE_X]
214
        add     ax, [MOUSE_X]
522
        jns     .check_x
215
        jns     .check_x
523
        xor     eax, eax
216
        xor     eax, eax
524
        jmp     .set_x
217
        jmp     .set_x
525
 .absolute_x:
218
 .absolute_x:
526
        mov     edx, [_display.width]
219
        mov     edx, [_display.width]
527
        mul     edx
220
        mul     edx
528
        shr     eax, 15
221
        shr     eax, 15
529
 .check_x:
222
 .check_x:
530
        cmp     ax, word[_display.width]
223
        cmp     ax, word[_display.width]
531
        jl      .set_x
224
        jl      .set_x
532
        mov     ax, word[_display.width]
225
        mov     ax, word[_display.width]
533
        dec     ax
226
        dec     ax
534
 .set_x:
227
 .set_x:
535
        mov     [MOUSE_X], ax
228
        mov     [MOUSE_X], ax
536
;--------------------------------------
229
;--------------------------------------
537
@@:
230
@@:
538
        mov     eax, [YMoving]
231
        mov     eax, [YMoving]
539
        test    [BtnState], 0x40000000
232
        test    [BtnState], 0x40000000
540
        jnz     .absolute_y
233
        jnz     .absolute_y
541
        test    eax, eax
234
        test    eax, eax
542
        jz      @f
235
        jz      @f
543
        neg     eax
236
        neg     eax
544
        call    mouse_acceleration
237
        call    mouse_acceleration
545
        add     ax, [MOUSE_Y]
238
        add     ax, [MOUSE_Y]
546
        jns     .check_y
239
        jns     .check_y
547
        xor     eax, eax
240
        xor     eax, eax
548
        jmp     .set_y
241
        jmp     .set_y
549
 .absolute_y:
242
 .absolute_y:
550
        mov     edx, [_display.height]
243
        mov     edx, [_display.height]
551
        mul     edx
244
        mul     edx
552
        shr     eax, 15
245
        shr     eax, 15
553
 .check_y:
246
 .check_y:
554
        cmp     ax, word[_display.height]
247
        cmp     ax, word[_display.height]
555
        jl      .set_y
248
        jl      .set_y
556
        mov     ax, word[_display.height]
249
        mov     ax, word[_display.height]
557
        dec     ax
250
        dec     ax
558
 .set_y:
251
 .set_y:
559
        mov     [MOUSE_Y], ax
252
        mov     [MOUSE_Y], ax
560
;--------------------------------------
253
;--------------------------------------
561
@@:
254
@@:
562
        mov     eax, [VScroll]
255
        mov     eax, [VScroll]
563
        test    eax, eax
256
        test    eax, eax
564
        jz      @f
257
        jz      @f
565
        add     [MOUSE_SCROLL_V], ax
258
        add     [MOUSE_SCROLL_V], ax
566
        bts     word [BTN_DOWN], 15
259
        bts     word [BTN_DOWN], 15
567
@@:
260
@@:
568
        mov     eax, [HScroll]
261
        mov     eax, [HScroll]
569
        test    eax, eax
262
        test    eax, eax
570
        jz      @f
263
        jz      @f
571
        add     [MOUSE_SCROLL_H], ax
264
        add     [MOUSE_SCROLL_H], ax
572
        bts     dword [BTN_DOWN], 23
265
        bts     dword [BTN_DOWN], 23
573
@@:
266
@@:
574
        mov     [mouse_active], 1
267
        mov     [mouse_active], 1
575
        call    wakeup_osloop
268
        call    wakeup_osloop
576
        ret
269
        ret
577
endp
270
endp
578
 
271
 
579
;-----------------------------------------------------------------------------
272
;-----------------------------------------------------------------------------
580
mouse_acceleration:
273
mouse_acceleration:
581
        neg     ax
274
        neg     ax
582
        jl      mouse_acceleration
275
        jl      mouse_acceleration
583
        add     al, [mouse_delay]
276
        add     al, [mouse_delay]
584
        mul     al
277
        mul     al
585
        mov     cx, [mouse_speed_factor]
278
        mov     cx, [mouse_speed_factor]
586
        dec     ax
279
        dec     ax
587
        shr     ax, cl
280
        shr     ax, cl
588
        inc     ax
281
        inc     ax
589
        test    eax, eax
282
        test    eax, eax
590
        jns     @f
283
        jns     @f
591
        neg     ax
284
        neg     ax
592
@@:
285
@@:
593
        ret
286
        ret