Subversion Repositories Kolibri OS

Rev

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

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