Subversion Repositories Kolibri OS

Rev

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

Rev 802 Rev 983
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2008. 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: 802 $
8
$Revision: 983 $
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
  mousecount  dd  0x0
25
  mousecount  dd  0x0
26
  mousedata   dd  0x0
26
  mousedata   dd  0x0
27
endg
27
endg
28
 
28
 
29
iglobal
29
iglobal
30
mouse_delay	   dd 10
30
mouse_delay	   dd 10
31
mouse_speed_factor: dd 3
31
mouse_speed_factor: dd 3
32
mouse_timer_ticks  dd 0
32
mouse_timer_ticks  dd 0
33
endg
33
endg
34
 
34
 
35
;include 'm_com.inc'
35
;include 'm_com.inc'
36
 
36
 
37
 
37
 
38
;test_mario79:
38
;test_mario79:
39
;        push   esi
39
;        push   esi
40
;        push   eax
40
;        push   eax
41
;        mov    [write_error_to],process_test_m79+43
41
;        mov    [write_error_to],process_test_m79+43
42
;        movzx  eax,al  ;[DevErrorCode]
42
;        movzx  eax,al  ;[DevErrorCode]
43
;        call   writehex
43
;        call   writehex
44
;        mov    esi,process_test_m79
44
;        mov    esi,process_test_m79
45
;        call   sys_msg_board_str
45
;        call   sys_msg_board_str
46
;        pop    eax
46
;        pop    eax
47
;        pop    esi
47
;        pop    esi
48
;        ret
48
;        ret
49
;process_test_m79 db 'K : Process - test Mario79 error    00000000',13,10,0
49
;process_test_m79 db 'K : Process - test Mario79 error    00000000',13,10,0
50
 
50
 
51
draw_mouse_under:
51
draw_mouse_under:
52
	; return old picture
52
	; return old picture
53
 
53
 
54
	cmp [set_hw_cursor], 0
54
	cmp [set_hw_cursor], 0
55
	jz @F
55
	jz @F
56
	pushad
56
	pushad
57
	movzx  eax,word [X_UNDER]
57
	movzx  eax,word [X_UNDER]
58
	movzx  ebx,word [Y_UNDER]
58
	movzx  ebx,word [Y_UNDER]
59
	stdcall [hw_restore], eax, ebx
59
	stdcall [hw_restore], eax, ebx
60
	popad
60
	popad
61
	ret
61
	ret
62
@@:
62
@@:
63
	pushad
63
	pushad
64
	xor    ecx,ecx
64
	xor    ecx,ecx
65
	xor    edx,edx
65
	xor    edx,edx
66
	align  4
66
	align  4
67
mres:
67
mres:
68
	movzx  eax,word [X_UNDER]
68
	movzx  eax,word [X_UNDER]
69
	movzx  ebx,word [Y_UNDER]
69
	movzx  ebx,word [Y_UNDER]
70
	add    eax,ecx
70
	add    eax,ecx
71
	add    ebx,edx
71
	add    ebx,edx
72
	push   ecx
72
	push   ecx
73
	push   edx
73
	push   edx
74
	push   eax
74
	push   eax
75
	push   ebx
75
	push   ebx
76
	mov    eax,edx
76
	mov    eax,edx
77
	shl    eax,6
77
	shl    eax,6
78
	shl    ecx,2
78
	shl    ecx,2
79
	add    eax,ecx
79
	add    eax,ecx
80
	add    eax,mouseunder
80
	add    eax,mouseunder
81
	mov    ecx,[eax]
81
	mov    ecx,[eax]
82
	pop    ebx
82
	pop    ebx
83
	pop    eax
83
	pop    eax
84
	mov    edi, 1 ;force
84
	mov    edi, 1 ;force
85
	call   [putpixel]
85
	call   [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
save_draw_mouse:
98
save_draw_mouse:
99
 
99
 
100
	cmp [set_hw_cursor], 0
100
	cmp [set_hw_cursor], 0
101
	je .no_hw_cursor
101
	je .no_hw_cursor
102
	pushad
102
	pushad
103
 
103
 
104
	mov    [X_UNDER],ax
104
	mov    [X_UNDER],ax
105
	mov    [Y_UNDER],bx
105
	mov    [Y_UNDER],bx
106
	movzx  eax,word [MOUSE_Y]
106
	movzx  eax,word [MOUSE_Y]
107
	movzx  ebx,word [MOUSE_X]
107
	movzx  ebx,word [MOUSE_X]
108
	push eax
108
	push eax
109
	push ebx
109
	push ebx
110
 
110
 
111
	mov ecx, [Screen_Max_X]
111
	mov ecx, [Screen_Max_X]
112
	inc ecx
112
	inc ecx
113
	mul ecx
113
	mul ecx
114
 
114
 
115
	movzx edx, byte [display_data+ebx+eax]
115
	movzx edx, byte [display_data+ebx+eax]
116
	shl edx, 8
116
	shl edx, 8
117
        mov esi, [edx+SLOT_BASE+APPDATA.cursor]
117
        mov esi, [edx+SLOT_BASE+APPDATA.cursor]
118
 
118
 
119
        cmp esi, [current_cursor]
119
        cmp esi, [current_cursor]
120
	je .draw
120
	je .draw
121
 
121
 
122
       ; cmp [esi+CURSOR.magic], 'CURS'
122
       ; cmp [esi+CURSOR.magic], 'CURS'
123
       ; jne .fail
123
       ; jne .fail
124
 
124
 
125
        push esi
125
        push esi
126
	call [select_hw_cursor]
126
	call [select_hw_cursor]
127
        mov [current_cursor], esi
127
        mov [current_cursor], esi
128
.draw:
128
.draw:
129
        stdcall [set_hw_cursor], esi
129
        stdcall [set_hw_cursor], esi
130
	popad
130
	popad
131
	ret
131
	ret
132
.fail:
132
.fail:
133
	mov ecx, [def_cursor]
133
	mov ecx, [def_cursor]
134
	mov [edx+SLOT_BASE+APPDATA.cursor], ecx
134
	mov [edx+SLOT_BASE+APPDATA.cursor], ecx
135
        stdcall [set_hw_cursor], ecx            ; stdcall: [esp]=ebx,eax
135
        stdcall [set_hw_cursor], ecx            ; stdcall: [esp]=ebx,eax
136
	popad
136
	popad
137
	ret
137
	ret
138
 
138
 
139
.no_hw_cursor:
139
.no_hw_cursor:
140
	pushad
140
	pushad
141
	; save & draw
141
	; save & draw
142
	mov    [X_UNDER],ax
142
	mov    [X_UNDER],ax
143
	mov    [Y_UNDER],bx
143
	mov    [Y_UNDER],bx
144
	push   eax
144
	push   eax
145
	push   ebx
145
	push   ebx
146
	mov    ecx,0
146
	mov    ecx,0
147
	mov    edx,0
147
	mov    edx,0
148
	align  4
148
	align  4
149
drm:
149
drm:
150
	push   eax
150
	push   eax
151
	push   ebx
151
	push   ebx
152
	push   ecx
152
	push   ecx
153
	push   edx
153
	push   edx
154
	; helloworld
154
	; helloworld
155
	push  ecx
155
	push  ecx
156
	add    eax,ecx	; save picture under mouse
156
	add    eax,ecx	; save picture under mouse
157
	add    ebx,edx
157
	add    ebx,edx
158
	push   ecx
158
	push   ecx
159
	call   getpixel
159
	call   getpixel
160
	mov    [COLOR_TEMP],ecx
160
	mov    [COLOR_TEMP],ecx
161
	pop    ecx
161
	pop    ecx
162
	mov    eax,edx
162
	mov    eax,edx
163
	shl    eax,6
163
	shl    eax,6
164
	shl    ecx,2
164
	shl    ecx,2
165
	add    eax,ecx
165
	add    eax,ecx
166
	add    eax,mouseunder
166
	add    eax,mouseunder
167
	mov    ebx,[COLOR_TEMP]
167
	mov    ebx,[COLOR_TEMP]
168
	mov    [eax],ebx
168
	mov    [eax],ebx
169
	pop  ecx
169
	pop  ecx
170
	mov    edi,edx	     ; y cycle
170
	mov    edi,edx	     ; y cycle
171
	shl    edi,4	   ; *16 bytes per row
171
	shl    edi,4	   ; *16 bytes per row
172
	add    edi,ecx	     ; x cycle
172
	add    edi,ecx	     ; x cycle
173
	mov    esi, edi
173
	mov    esi, edi
174
	add    edi, esi
174
	add    edi, esi
175
	add    edi, esi       ; *3
175
	add    edi, esi       ; *3
176
	add    edi,[MOUSE_PICTURE]	; we have our str address
176
	add    edi,[MOUSE_PICTURE]	; we have our str address
177
	mov    esi, edi
177
	mov    esi, edi
178
	add    esi, 16*24*3
178
	add    esi, 16*24*3
179
	push   ecx
179
	push   ecx
180
	mov    ecx, [COLOR_TEMP]
180
	mov    ecx, [COLOR_TEMP]
181
	call   combine_colors
181
	call   combine_colors
182
	mov    [MOUSE_COLOR_MEM], ecx
182
	mov    [MOUSE_COLOR_MEM], ecx
183
	pop    ecx
183
	pop    ecx
184
	pop    edx
184
	pop    edx
185
	pop    ecx
185
	pop    ecx
186
	pop    ebx
186
	pop    ebx
187
	pop    eax
187
	pop    eax
188
	add    eax,ecx	     ; we have x coord+cycle
188
	add    eax,ecx	     ; we have x coord+cycle
189
	add    ebx,edx	     ; and y coord+cycle
189
	add    ebx,edx	     ; and y coord+cycle
190
	push   ecx
190
	push   ecx
191
	mov    ecx, [MOUSE_COLOR_MEM]
191
	mov    ecx, [MOUSE_COLOR_MEM]
192
	mov    edi, 1
192
	mov    edi, 1
193
	call   [putpixel]
193
	call   [putpixel]
194
	pop    ecx
194
	pop    ecx
195
	mov    ebx,[esp+0]	; pure y coord again
195
	mov    ebx,[esp+0]	; pure y coord again
196
	mov    eax,[esp+4]	; and x
196
	mov    eax,[esp+4]	; and x
197
	inc    ecx	    ; +1 cycle
197
	inc    ecx	    ; +1 cycle
198
	cmp    ecx,16	    ; if more than 16
198
	cmp    ecx,16	    ; if more than 16
199
	jnz    drm
199
	jnz    drm
200
	xor    ecx, ecx
200
	xor    ecx, ecx
201
	inc    edx
201
	inc    edx
202
	cmp    edx,24
202
	cmp    edx,24
203
	jnz    drm
203
	jnz    drm
204
	add   esp,8
204
	add   esp,8
205
	popad
205
	popad
206
	ret
206
	ret
207
 
207
 
208
 
208
 
209
combine_colors:
209
combine_colors:
210
      ; in
210
      ; in
211
      ; ecx - color ( 00 RR GG BB )
211
      ; ecx - color ( 00 RR GG BB )
212
      ; edi - ref to new color byte
212
      ; edi - ref to new color byte
213
      ; esi - ref to alpha byte
213
      ; esi - ref to alpha byte
214
      ;
214
      ;
215
      ; out
215
      ; out
216
      ; ecx - new color ( roughly (ecx*[esi]>>8)+([edi]*[esi]>>8) )
216
      ; ecx - new color ( roughly (ecx*[esi]>>8)+([edi]*[esi]>>8) )
217
      push eax
217
      push eax
218
      push ebx
218
      push ebx
219
      push edx
219
      push edx
220
      push ecx
220
      push ecx
221
      xor ecx, ecx
221
      xor ecx, ecx
222
	 ; byte 2
222
	 ; byte 2
223
      mov eax, 0xff
223
      mov eax, 0xff
224
      sub al, [esi+0]
224
      sub al, [esi+0]
225
      mov ebx, [esp]
225
      mov ebx, [esp]
226
      shr ebx, 16
226
      shr ebx, 16
227
      and ebx, 0xff
227
      and ebx, 0xff
228
      mul ebx
228
      mul ebx
229
      shr eax, 8
229
      shr eax, 8
230
      add ecx, eax
230
      add ecx, eax
231
      xor eax, eax
231
      xor eax, eax
232
      xor ebx, ebx
232
      xor ebx, ebx
233
      mov al, [edi+0]
233
      mov al, [edi+0]
234
      mov bl, [esi+0]
234
      mov bl, [esi+0]
235
      mul ebx
235
      mul ebx
236
      shr eax, 8
236
      shr eax, 8
237
      add ecx, eax
237
      add ecx, eax
238
      shl ecx, 8
238
      shl ecx, 8
239
	 ; byte 1
239
	 ; byte 1
240
      mov eax, 0xff
240
      mov eax, 0xff
241
      sub al, [esi+1]
241
      sub al, [esi+1]
242
      mov ebx, [esp]
242
      mov ebx, [esp]
243
      shr ebx, 8
243
      shr ebx, 8
244
      and ebx, 0xff
244
      and ebx, 0xff
245
      mul ebx
245
      mul ebx
246
      shr eax, 8
246
      shr eax, 8
247
      add ecx, eax
247
      add ecx, eax
248
      xor eax, eax
248
      xor eax, eax
249
      xor ebx, ebx
249
      xor ebx, ebx
250
      mov al, [edi+1]
250
      mov al, [edi+1]
251
      mov bl, [esi+1]
251
      mov bl, [esi+1]
252
      mul ebx
252
      mul ebx
253
      shr eax, 8
253
      shr eax, 8
254
      add ecx, eax
254
      add ecx, eax
255
      shl ecx, 8
255
      shl ecx, 8
256
	 ; byte 2
256
	 ; byte 2
257
      mov eax, 0xff
257
      mov eax, 0xff
258
      sub al, [esi+2]
258
      sub al, [esi+2]
259
      mov ebx, [esp]
259
      mov ebx, [esp]
260
      and ebx, 0xff
260
      and ebx, 0xff
261
      mul ebx
261
      mul ebx
262
      shr eax, 8
262
      shr eax, 8
263
      add ecx, eax
263
      add ecx, eax
264
      xor eax, eax
264
      xor eax, eax
265
      xor ebx, ebx
265
      xor ebx, ebx
266
      mov al, [edi+2]
266
      mov al, [edi+2]
267
      mov bl, [esi+2]
267
      mov bl, [esi+2]
268
      mul ebx
268
      mul ebx
269
      shr eax, 8
269
      shr eax, 8
270
      add ecx, eax
270
      add ecx, eax
271
      pop eax
271
      pop eax
272
      pop edx
272
      pop edx
273
      pop ebx
273
      pop ebx
274
      pop eax
274
      pop eax
275
      ret
275
      ret
276
 
276
 
277
 
277
 
278
__sys_disable_mouse:
278
__sys_disable_mouse:
279
      cmp  dword [MOUSE_VISIBLE],dword 0
279
      cmp  dword [MOUSE_VISIBLE],dword 0
280
      je    @f
280
      je    @f
281
      ret
281
      ret
282
@@:
282
@@:
283
      pushad
283
      pushad
284
      cmp  [CURRENT_TASK],dword 1
284
      cmp  [CURRENT_TASK],dword 1
285
      je   disable_m
285
      je   disable_m
286
      mov  edx,[CURRENT_TASK]
286
      mov  edx,[CURRENT_TASK]
287
      shl  edx,5
287
      shl  edx,5
288
      add  edx,window_data
288
      add  edx,window_data
289
      movzx  eax, word [MOUSE_X]
289
      movzx  eax, word [MOUSE_X]
290
      movzx  ebx, word [MOUSE_Y]
290
      movzx  ebx, word [MOUSE_Y]
291
      mov  ecx,[Screen_Max_X]
291
      mov  ecx,[Screen_Max_X]
292
      inc  ecx
292
      inc  ecx
293
      imul  ecx,ebx
293
      imul  ecx,ebx
294
      add  ecx,eax
294
      add  ecx,eax
295
      add  ecx, display_data
295
      add  ecx, display_data
296
      mov   eax, [CURRENT_TASK]
296
      mov   eax, [CURRENT_TASK]
297
      movzx ebx, byte [ecx]
297
      movzx ebx, byte [ecx]
298
      cmp   eax,ebx
298
      cmp   eax,ebx
299
      je    yes_mouse_disable
299
      je    yes_mouse_disable
300
      movzx ebx, byte [ecx+16]
300
      movzx ebx, byte [ecx+16]
301
      cmp   eax,ebx
301
      cmp   eax,ebx
302
      je    yes_mouse_disable
302
      je    yes_mouse_disable
303
      mov   ebx,[Screen_Max_X]
303
      mov   ebx,[Screen_Max_X]
304
      inc   ebx
304
      inc   ebx
305
      imul  ebx,10
305
      imul  ebx,10
306
      add   ecx,ebx
306
      add   ecx,ebx
307
      movzx ebx, byte [ecx]
307
      movzx ebx, byte [ecx]
308
      cmp   eax,ebx
308
      cmp   eax,ebx
309
      je    yes_mouse_disable
309
      je    yes_mouse_disable
310
      movzx ebx, byte [ecx+16]
310
      movzx ebx, byte [ecx+16]
311
      cmp   eax,ebx
311
      cmp   eax,ebx
312
      je    yes_mouse_disable
312
      je    yes_mouse_disable
313
      jmp   no_mouse_disable
313
      jmp   no_mouse_disable
314
yes_mouse_disable:
314
yes_mouse_disable:
315
      mov  edx,[CURRENT_TASK]
315
      mov  edx,[CURRENT_TASK]
316
      shl  edx,5
316
      shl  edx,5
317
      add  edx,window_data
317
      add  edx,window_data
318
      movzx  eax, word [MOUSE_X]
318
      movzx  eax, word [MOUSE_X]
319
      movzx  ebx, word [MOUSE_Y]
319
      movzx  ebx, word [MOUSE_Y]
320
      mov  ecx,[edx+0]	 ; mouse inside the area ?
320
      mov  ecx,[edx+0]	 ; mouse inside the area ?
321
      add  eax,10
321
      add  eax,10
322
      cmp  eax,ecx
322
      cmp  eax,ecx
323
      jb   no_mouse_disable
323
      jb   no_mouse_disable
324
      sub  eax,10
324
      sub  eax,10
325
      add  ecx,[edx+8]
325
      add  ecx,[edx+8]
326
      cmp  eax,ecx
326
      cmp  eax,ecx
327
      jg   no_mouse_disable
327
      jg   no_mouse_disable
328
      mov  ecx,[edx+4]
328
      mov  ecx,[edx+4]
329
      add  ebx,14
329
      add  ebx,14
330
      cmp  ebx,ecx
330
      cmp  ebx,ecx
331
      jb   no_mouse_disable
331
      jb   no_mouse_disable
332
      sub  ebx,14
332
      sub  ebx,14
333
      add  ecx,[edx+12]
333
      add  ecx,[edx+12]
334
      cmp  ebx,ecx
334
      cmp  ebx,ecx
335
      jg   no_mouse_disable
335
      jg   no_mouse_disable
336
disable_m:
336
disable_m:
337
      cmp  dword [MOUSE_VISIBLE],dword 0
337
      cmp  dword [MOUSE_VISIBLE],dword 0
338
      jne  no_mouse_disable
338
      jne  no_mouse_disable
339
      pushf
339
      pushf
340
      cli
340
      cli
341
      call draw_mouse_under
341
      call draw_mouse_under
342
      popf
342
      popf
343
      mov  [MOUSE_VISIBLE],dword 1
343
      mov  [MOUSE_VISIBLE],dword 1
344
no_mouse_disable:
344
no_mouse_disable:
345
      popad
345
      popad
346
      ret
346
      ret
347
 
347
 
348
__sys_draw_pointer:
348
__sys_draw_pointer:
349
	cmp   [mouse_pause],0
349
	cmp   [mouse_pause],0
350
	je    @f
350
	je    @f
351
	ret
351
	ret
352
@@:
352
@@:
353
	push   eax
353
	push   eax
354
	mov	eax,[timer_ticks]
354
	mov	eax,[timer_ticks]
355
	sub	eax,[MouseTickCounter]
355
	sub	eax,[MouseTickCounter]
356
	cmp	eax,1
356
	cmp	eax,1
357
	ja	@f
357
	ja	@f
358
	pop    eax
358
	pop    eax
359
	ret
359
	ret
360
@@:
360
@@:
361
	mov	eax,[timer_ticks]
361
	mov	eax,[timer_ticks]
362
	mov	[MouseTickCounter],eax
362
	mov	[MouseTickCounter],eax
363
	pop	eax
363
	pop	eax
364
	pushad
364
	pushad
365
	cmp    dword [MOUSE_VISIBLE],dword 0  ; mouse visible ?
365
	cmp    dword [MOUSE_VISIBLE],dword 0  ; mouse visible ?
366
	je     chms00
366
	je     chms00
367
	mov	[MOUSE_VISIBLE], dword 0
367
	mov	[MOUSE_VISIBLE], dword 0
368
	movzx  ebx,word [MOUSE_Y]
368
	movzx  ebx,word [MOUSE_Y]
369
	movzx  eax,word [MOUSE_X]
369
	movzx  eax,word [MOUSE_X]
370
	pushfd
370
	pushfd
371
	cli
371
	cli
372
	call   save_draw_mouse
372
	call   save_draw_mouse
373
	popfd
373
	popfd
374
nodmu2:
374
nodmu2:
375
	popad
375
	popad
376
	ret
376
	ret
377
chms00:
377
chms00:
378
	movzx  ecx,word [X_UNDER]
378
	movzx  ecx,word [X_UNDER]
379
	movzx  edx,word [Y_UNDER]
379
	movzx  edx,word [Y_UNDER]
380
	movzx  ebx,word [MOUSE_Y]
380
	movzx  ebx,word [MOUSE_Y]
381
	movzx  eax,word [MOUSE_X]
381
	movzx  eax,word [MOUSE_X]
382
	cmp    eax,ecx
382
	cmp    eax,ecx
383
	jne    redrawmouse
383
	jne    redrawmouse
384
	cmp    ebx,edx
384
	cmp    ebx,edx
385
	jne    redrawmouse
385
	jne    redrawmouse
386
	jmp    nodmp
386
	jmp    nodmp
387
redrawmouse:
387
redrawmouse:
388
	pushfd
388
	pushfd
389
	cli
389
	cli
390
	call   draw_mouse_under
390
	call   draw_mouse_under
391
	call   save_draw_mouse
391
	call   save_draw_mouse
392
	popfd
392
	popfd
393
nodmp:
393
nodmp:
394
	popad
394
	popad
395
	ret
395
	ret
396
 
396
 
397
proc set_mouse_data stdcall, BtnState:dword, XMoving:dword, YMoving:dword, VScroll:dword, HScroll:dword
397
proc set_mouse_data stdcall, BtnState:dword, XMoving:dword, YMoving:dword, VScroll:dword, HScroll:dword
398
 
398
 
399
    mov  eax,[BtnState]
399
    mov  eax,[BtnState]
400
    mov  [BTN_DOWN],eax
400
    mov  [BTN_DOWN],eax
401
 
401
 
402
    mov  eax,[XMoving]
402
    mov  eax,[XMoving]
403
    call mouse_acceleration
403
    call mouse_acceleration
404
    add  ax,[MOUSE_X]	 ;[XCoordinate]
404
    add  ax,[MOUSE_X]	 ;[XCoordinate]
405
    cmp  ax,0
405
    cmp  ax,0
406
    jge  @@M1
406
    jge  @@M1
407
    mov  eax,0
407
    mov  eax,0
408
    jmp  @@M2
408
    jmp  @@M2
409
@@M1:
409
@@M1:
410
    cmp  ax,[Screen_Max_X]   ;ScreenLength
410
    cmp  ax,[Screen_Max_X]   ;ScreenLength
411
    jl	 @@M2
411
    jl	 @@M2
412
    mov  ax,[Screen_Max_X]   ;ScreenLength-1
412
    mov  ax,[Screen_Max_X]   ;ScreenLength-1
413
 
413
 
414
@@M2:
414
@@M2:
415
    mov  [MOUSE_X],ax	  ;[XCoordinate]
415
    mov  [MOUSE_X],ax	  ;[XCoordinate]
416
 
416
 
417
    mov  eax,[YMoving]
417
    mov  eax,[YMoving]
418
    neg  eax
418
    neg  eax
419
    call mouse_acceleration
419
    call mouse_acceleration
420
 
420
 
421
    add  ax,[MOUSE_Y]	;[YCoordinate]
421
    add  ax,[MOUSE_Y]	;[YCoordinate]
422
    cmp  ax,0
422
    cmp  ax,0
423
    jge  @@M3
423
    jge  @@M3
424
    mov  ax,0
424
    mov  ax,0
425
    jmp  @@M4
425
    jmp  @@M4
426
@@M3:
426
@@M3:
427
    cmp  ax,[Screen_Max_Y]  ;ScreenHeigth
427
    cmp  ax,[Screen_Max_Y]  ;ScreenHeigth
428
    jl	 @@M4
428
    jl	 @@M4
429
    mov  ax,[Screen_Max_Y] ;ScreenHeigth-1
429
    mov  ax,[Screen_Max_Y] ;ScreenHeigth-1
430
 
430
 
431
@@M4:
431
@@M4:
432
    mov  [MOUSE_Y],ax	  ;[YCoordinate]
432
    mov  [MOUSE_Y],ax	  ;[YCoordinate]
433
 
433
 
434
    mov  eax,[VScroll]
434
    mov  eax,[VScroll]
435
    add  [MOUSE_SCROLL_V],ax
435
    add  [MOUSE_SCROLL_V],ax
436
 
436
 
437
    mov  eax,[HScroll]
437
    mov  eax,[HScroll]
438
    add  [MOUSE_SCROLL_H],ax
438
    add  [MOUSE_SCROLL_H],ax
439
 
439
 
440
    mov  [mouse_active],1
440
    mov  [mouse_active],1
441
    mov  eax,[timer_ticks]
441
    mov  eax,[timer_ticks]
442
    mov  [mouse_timer_ticks],eax
442
    mov  [mouse_timer_ticks],eax
443
    ret
443
    ret
444
endp
444
endp
445
 
445
 
446
mouse_acceleration:
446
mouse_acceleration:
447
	push  eax
447
	push  eax
448
	mov   eax,[timer_ticks]
448
	mov   eax,[timer_ticks]
449
	sub   eax,[mouse_timer_ticks]
449
	sub   eax,[mouse_timer_ticks]
450
	cmp   eax,[mouse_delay]
450
	cmp   eax,[mouse_delay]
451
	pop   eax
451
	pop   eax
452
	ja    @f
452
	ja    @f
453
	;push  edx
453
	;push  edx
454
	imul  eax,[mouse_speed_factor]
454
	imul  eax,[mouse_speed_factor]
455
	;pop   edx
455
	;pop   edx
456
@@:
456
@@:
457
	ret
457
	ret