Subversion Repositories Kolibri OS

Rev

Rev 928 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
431 serge 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
 
593 mikedld 8
$Revision: 996 $
9
 
10
 
33 mario79 11
;   check mouse
12
;
13
;
14
;   FB00  ->   FB0F   mouse memory 00 chunk count - FB0A-B x - FB0C-D y
15
;   FB10  ->   FB17   mouse color mem
16
;   FB21              x move
17
;   FB22              y move
18
;   FB30              color temp
19
;   FB28              high bits temp
20
 
21
uglobal
22
  mousecount  dd  0x0
23
  mousedata   dd  0x0
24
endg
25
 
473 diamond 26
iglobal
928 serge 27
mouse_delay         dd 10
479 kastigar 28
mouse_speed_factor: dd 3
928 serge 29
mouse_timer_ticks   dd 0
473 diamond 30
endg
120 mario79 31
 
928 serge 32
align 4
33 mario79 33
draw_mouse_under:
769 Rus 34
	; return old picture
214 serge 35
 
996 serge 36
           cmp [set_hw_cursor], 0
37
           jz .exit
38
           pushad
39
           mov  eax, [x_under]
40
           mov  ebx, [y_under]
41
           stdcall [hw_restore], eax, ebx
42
           popad
43
.exit:
44
           ret
33 mario79 45
 
46
save_draw_mouse:
214 serge 47
 
996 serge 48
           cmp [set_hw_cursor], 0
49
           je .exit
221 serge 50
 
996 serge 51
           pushad
221 serge 52
 
996 serge 53
           mov [x_under], eax
54
           mov    [y_under], ebx
55
           movzx  eax,word [MOUSE_Y]
56
           movzx  ebx,word [MOUSE_X]
57
           push eax
58
           push ebx
230 serge 59
 
996 serge 60
           mov ecx, [Screen_Max_X]
61
           inc ecx
62
           mul ecx
63
           add eax, [_display_data]
64
           movzx edx, byte [ebx+eax]
65
           shl edx, 8
66
           mov esi, [edx+SLOT_BASE+APPDATA.cursor]
630 serge 67
 
996 serge 68
           cmp esi, [current_cursor]
69
           je .draw
630 serge 70
 
996 serge 71
           push esi
72
           call [select_hw_cursor]
73
           mov [current_cursor], esi
630 serge 74
.draw:
996 serge 75
           stdcall [set_hw_cursor], esi
76
           popad
77
.exit:
78
           ret
230 serge 79
 
33 mario79 80
 
81
__sys_disable_mouse:
928 serge 82
      cmp  [MOUSE_VISIBLE], 0
36 mario79 83
      je    @f
84
      ret
214 serge 85
@@:
33 mario79 86
      pushad
379 serge 87
      cmp  [CURRENT_TASK],dword 1
33 mario79 88
      je   disable_m
379 serge 89
      mov  edx,[CURRENT_TASK]
33 mario79 90
      shl  edx,5
91
      add  edx,window_data
381 serge 92
      movzx  eax, word [MOUSE_X]
93
      movzx  ebx, word [MOUSE_Y]
753 serge 94
      mov  ecx,[Screen_Max_X]
33 mario79 95
      inc  ecx
96
      imul  ecx,ebx
97
      add  ecx,eax
840 serge 98
      add  ecx, [_display_data]
379 serge 99
      mov   eax, [CURRENT_TASK]
33 mario79 100
      movzx ebx, byte [ecx]
101
      cmp   eax,ebx
102
      je    yes_mouse_disable
996 serge 103
      movzx ebx, byte [ecx+32]
33 mario79 104
      cmp   eax,ebx
105
      je    yes_mouse_disable
753 serge 106
      mov   ebx,[Screen_Max_X]
33 mario79 107
      inc   ebx
108
      imul  ebx,10
109
      add   ecx,ebx
110
      movzx ebx, byte [ecx]
111
      cmp   eax,ebx
112
      je    yes_mouse_disable
996 serge 113
      movzx ebx, byte [ecx+32]
33 mario79 114
      cmp   eax,ebx
115
      je    yes_mouse_disable
116
      jmp   no_mouse_disable
119 mario79 117
yes_mouse_disable:
379 serge 118
      mov  edx,[CURRENT_TASK]
33 mario79 119
      shl  edx,5
120
      add  edx,window_data
381 serge 121
      movzx  eax, word [MOUSE_X]
122
      movzx  ebx, word [MOUSE_Y]
769 Rus 123
      mov  ecx,[edx+0]	 ; mouse inside the area ?
739 heavyiron 124
      add  eax,10
33 mario79 125
      cmp  eax,ecx
126
      jb   no_mouse_disable
739 heavyiron 127
      sub  eax,10
33 mario79 128
      add  ecx,[edx+8]
129
      cmp  eax,ecx
130
      jg   no_mouse_disable
131
      mov  ecx,[edx+4]
739 heavyiron 132
      add  ebx,14
33 mario79 133
      cmp  ebx,ecx
134
      jb   no_mouse_disable
739 heavyiron 135
      sub  ebx,14
33 mario79 136
      add  ecx,[edx+12]
137
      cmp  ebx,ecx
138
      jg   no_mouse_disable
119 mario79 139
disable_m:
928 serge 140
      cmp  [MOUSE_VISIBLE], 0
119 mario79 141
      jne  no_mouse_disable
389 serge 142
      pushf
36 mario79 143
      cli
119 mario79 144
      call draw_mouse_under
389 serge 145
      popf
928 serge 146
      mov  [MOUSE_VISIBLE], 1
119 mario79 147
no_mouse_disable:
33 mario79 148
      popad
149
      ret
150
 
151
__sys_draw_pointer:
769 Rus 152
	cmp   [mouse_pause],0
153
	je    @f
154
	ret
119 mario79 155
@@:
769 Rus 156
	push   eax
157
	mov	eax,[timer_ticks]
158
	sub	eax,[MouseTickCounter]
159
	cmp	eax,1
160
	ja	@f
161
	pop    eax
162
	ret
119 mario79 163
@@:
769 Rus 164
	mov	eax,[timer_ticks]
165
	mov	[MouseTickCounter],eax
166
	pop	eax
167
	pushad
928 serge 168
    cmp    [MOUSE_VISIBLE], 0  ; mouse visible ?
769 Rus 169
	je     chms00
928 serge 170
    mov [MOUSE_VISIBLE], 0
769 Rus 171
	movzx  ebx,word [MOUSE_Y]
172
	movzx  eax,word [MOUSE_X]
173
	pushfd
174
	cli
175
	call   save_draw_mouse
176
	popfd
119 mario79 177
nodmu2:
769 Rus 178
	popad
179
	ret
119 mario79 180
chms00:
928 serge 181
    mov  ecx, [x_under]
182
    mov  edx, [y_under]
769 Rus 183
	movzx  ebx,word [MOUSE_Y]
184
	movzx  eax,word [MOUSE_X]
185
	cmp    eax,ecx
186
	jne    redrawmouse
187
	cmp    ebx,edx
188
	jne    redrawmouse
189
	jmp    nodmp
119 mario79 190
redrawmouse:
769 Rus 191
	pushfd
192
	cli
193
	call   draw_mouse_under
194
	call   save_draw_mouse
195
	popfd
119 mario79 196
nodmp:
769 Rus 197
	popad
198
	ret
119 mario79 199
 
479 kastigar 200
proc set_mouse_data stdcall, BtnState:dword, XMoving:dword, YMoving:dword, VScroll:dword, HScroll:dword
630 serge 201
 
479 kastigar 202
    mov  eax,[BtnState]
928 serge 203
    mov  [btn_down],eax
479 kastigar 204
 
205
    mov  eax,[XMoving]
206
    call mouse_acceleration
769 Rus 207
    add  ax,[MOUSE_X]	 ;[XCoordinate]
479 kastigar 208
    cmp  ax,0
209
    jge  @@M1
210
    mov  eax,0
211
    jmp  @@M2
212
@@M1:
928 serge 213
    cmp  ax, word [Screen_Max_X]   ;ScreenLength
769 Rus 214
    jl	 @@M2
928 serge 215
    mov  ax, word [Screen_Max_X]   ;ScreenLength-1
479 kastigar 216
 
217
@@M2:
769 Rus 218
    mov  [MOUSE_X],ax	  ;[XCoordinate]
479 kastigar 219
 
220
    mov  eax,[YMoving]
221
    neg  eax
222
    call mouse_acceleration
223
 
769 Rus 224
    add  ax,[MOUSE_Y]	;[YCoordinate]
479 kastigar 225
    cmp  ax,0
226
    jge  @@M3
227
    mov  ax,0
228
    jmp  @@M4
229
@@M3:
928 serge 230
    cmp  ax, word [Screen_Max_Y]  ;ScreenHeigth
769 Rus 231
    jl	 @@M4
928 serge 232
    mov  ax, word [Screen_Max_Y] ;ScreenHeigth-1
479 kastigar 233
 
234
@@M4:
769 Rus 235
    mov  [MOUSE_Y],ax	  ;[YCoordinate]
479 kastigar 236
 
237
    mov  eax,[VScroll]
928 serge 238
    add  [mouse_scroll_v], eax
630 serge 239
 
479 kastigar 240
    mov  eax,[HScroll]
928 serge 241
    add  [mouse_scroll_h], eax
479 kastigar 242
 
243
    mov  [mouse_active],1
244
    mov  eax,[timer_ticks]
245
    mov  [mouse_timer_ticks],eax
246
    ret
247
endp
248
 
249
mouse_acceleration:
769 Rus 250
	push  eax
251
	mov   eax,[timer_ticks]
252
	sub   eax,[mouse_timer_ticks]
253
	cmp   eax,[mouse_delay]
254
	pop   eax
255
	ja    @f
256
	;push  edx
257
	imul  eax,[mouse_speed_factor]
258
	;pop   edx
479 kastigar 259
@@:
769 Rus 260
	ret
479 kastigar 261
 
996 serge 262
 
263
;[ecx]     x
264
;[ecx+4]   y
265
;[ecx+8]   w
266
;[ecx+12]  h
267
 
268
align 4
269
lock_cursor:
270
 
271
           pushfd
272
           cli
273
 
274
           xor eax, eax
275
           mov edx, [ecx]
276
           mov ebx, [ecx+4]
277
           cmp edx, [cur.right]
278
           jg .done
279
 
280
           cmp ebx, [cur.bottom]
281
           jg .done
282
 
283
           add edx, [ecx+8]
284
           add ebx, [ecx+12]
285
           cmp edx, [cur.left]
286
           jle .done
287
 
288
           cmp ebx, [cur.top]
289
           jle .done
290
 
291
           mov ecx, [CURRENT_TASK]
292
 
293
           mov ebx, [cur.left]
294
           mov eax, [cur.top]
295
           add ebx, [_display_data]
296
           mul [_screen_width]
297
           add ebx, eax
298
 
299
           cmp cl, [ebx]
300
           je .disable
301
 
302
           cmp cl, [ebx+31]
303
           je .disable
304
 
305
           mov eax, [_screen_width]
306
           shl eax, 5
307
           sub eax, [_screen_width]
308
 
309
           cmp cl, [ebx+eax]
310
           je .disable
311
 
312
           cmp cl, [ebx+eax+31]
313
           jne .done
314
 
315
.disable:
316
           call draw_mouse_under
317
 
318
           mov eax, 1
319
.done:
320
           inc eax
321
           mov [cur.lock], eax
322
           popfd
323
           ret
324
 
325
align 4
326
unlock_cursor:
327
           pushfd
328
           cli
329
           cmp [cur.lock], 2
330
           jne .done
331
 
332
           call save_draw_mouse
333
.done:
334
           mov [cur.lock], 1
335
           popfd
336
           ret