Subversion Repositories Kolibri OS

Rev

Rev 5851 | Rev 5966 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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