Subversion Repositories Kolibri OS

Rev

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

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