Subversion Repositories Kolibri OS

Rev

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

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