Subversion Repositories Kolibri OS

Rev

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

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