Subversion Repositories Kolibri OS

Rev

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

Rev 425 Rev 431
1
$Revision: 425 $
1
$Revision: 431 $
-
 
2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
 
3
;;                                                              ;;
-
 
4
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
-
 
5
;; Distributed under terms of the GNU General Public License    ;;
-
 
6
;;                                                              ;;
-
 
7
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
 
8
 
2
;   check mouse
9
;   check mouse
3
;
10
;
4
;
11
;
5
;   FB00  ->   FB0F   mouse memory 00 chunk count - FB0A-B x - FB0C-D y
12
;   FB00  ->   FB0F   mouse memory 00 chunk count - FB0A-B x - FB0C-D y
6
;   FB10  ->   FB17   mouse color mem
13
;   FB10  ->   FB17   mouse color mem
7
;   FB21              x move
14
;   FB21              x move
8
;   FB22              y move
15
;   FB22              y move
9
;   FB30              color temp
16
;   FB30              color temp
10
;   FB28              high bits temp
17
;   FB28              high bits temp
11
;   FB4A  ->   FB4D   FB4A-B x-under - FB4C-D y-under
18
;   FB4A  ->   FB4D   FB4A-B x-under - FB4C-D y-under
12
;   FC00  ->   FCFE   com1/ps2 buffer
19
;   FC00  ->   FCFE   com1/ps2 buffer
13
;   FCFF              com1/ps2 buffer count starting from FC00
20
;   FCFF              com1/ps2 buffer count starting from FC00
14
 
21
 
15
uglobal
22
uglobal
16
  mousecount  dd  0x0
23
  mousecount  dd  0x0
17
  mousedata   dd  0x0
24
  mousedata   dd  0x0
18
endg
25
endg
19
 
26
 
20
mouse_delay     dd  10
27
mouse_delay     dd  10
21
mouse_speed_factor dw 3
28
mouse_speed_factor dw 3
22
 
29
 
23
include 'm_ps2.inc'
30
include 'm_ps2.inc'
24
include 'm_com1.inc'
31
include 'm_com1.inc'
25
include 'm_com2.inc'
32
include 'm_com2.inc'
26
 
33
 
27
 
34
 
28
;test_mario79:
35
;test_mario79:
29
;        push   esi
36
;        push   esi
30
;        push   eax
37
;        push   eax
31
;        mov    [write_error_to],process_test_m79+43
38
;        mov    [write_error_to],process_test_m79+43
32
;        movzx  eax,al  ;[DevErrorCode]
39
;        movzx  eax,al  ;[DevErrorCode]
33
;        call   writehex
40
;        call   writehex
34
;        mov    esi,process_test_m79
41
;        mov    esi,process_test_m79
35
;        call   sys_msg_board_str
42
;        call   sys_msg_board_str
36
;        pop    eax
43
;        pop    eax
37
;        pop    esi
44
;        pop    esi
38
;        ret
45
;        ret
39
;process_test_m79 db 'K : Process - test Mario79 error    00000000',13,10,0
46
;process_test_m79 db 'K : Process - test Mario79 error    00000000',13,10,0
40
 
47
 
41
draw_mouse_under:
48
draw_mouse_under:
42
        ; return old picture
49
        ; return old picture
43
 
50
 
44
        cmp [set_hw_cursor], 0
51
        cmp [set_hw_cursor], 0
45
        jz @F
52
        jz @F
46
        pushad
53
        pushad
47
        movzx  eax,word [X_UNDER]
54
        movzx  eax,word [X_UNDER]
48
        movzx  ebx,word [Y_UNDER]
55
        movzx  ebx,word [Y_UNDER]
49
        stdcall [hw_restore], eax, ebx
56
        stdcall [hw_restore], eax, ebx
50
        popad
57
        popad
51
        ret
58
        ret
52
@@:
59
@@:
53
        pushad
60
        pushad
54
        xor    ecx,ecx
61
        xor    ecx,ecx
55
        xor    edx,edx
62
        xor    edx,edx
56
        align  4
63
        align  4
57
mres:
64
mres:
58
        movzx  eax,word [X_UNDER]
65
        movzx  eax,word [X_UNDER]
59
        movzx  ebx,word [Y_UNDER]
66
        movzx  ebx,word [Y_UNDER]
60
        add    eax,ecx
67
        add    eax,ecx
61
        add    ebx,edx
68
        add    ebx,edx
62
        push   ecx
69
        push   ecx
63
        push   edx
70
        push   edx
64
        push   eax
71
        push   eax
65
        push   ebx
72
        push   ebx
66
        mov    eax,edx
73
        mov    eax,edx
67
        shl    eax,6
74
        shl    eax,6
68
        shl    ecx,2
75
        shl    ecx,2
69
        add    eax,ecx
76
        add    eax,ecx
70
        add    eax,mouseunder
77
        add    eax,mouseunder
71
        mov    ecx,[eax]
78
        mov    ecx,[eax]
72
        pop    ebx
79
        pop    ebx
73
        pop    eax
80
        pop    eax
74
        mov    edi, 1 ;force
81
        mov    edi, 1 ;force
75
        call   [putpixel]
82
        call   [putpixel]
76
        pop    edx
83
        pop    edx
77
        pop    ecx
84
        pop    ecx
78
        inc    ecx
85
        inc    ecx
79
        cmp    ecx, 16
86
        cmp    ecx, 16
80
        jnz    mres
87
        jnz    mres
81
        xor    ecx, ecx
88
        xor    ecx, ecx
82
        inc    edx
89
        inc    edx
83
        cmp    edx, 24
90
        cmp    edx, 24
84
        jnz    mres
91
        jnz    mres
85
        popad
92
        popad
86
        ret
93
        ret
87
 
94
 
88
save_draw_mouse:
95
save_draw_mouse:
89
 
96
 
90
        cmp [set_hw_cursor], 0
97
        cmp [set_hw_cursor], 0
91
        jz @F
98
        jz @F
92
        pushad
99
        pushad
93
 
100
 
94
        mov    [X_UNDER],ax
101
        mov    [X_UNDER],ax
95
        mov    [Y_UNDER],bx
102
        mov    [Y_UNDER],bx
96
        movzx  eax,word [MOUSE_Y]
103
        movzx  eax,word [MOUSE_Y]
97
        movzx  ebx,word [MOUSE_X]
104
        movzx  ebx,word [MOUSE_X]
98
        push eax
105
        push eax
99
        push ebx
106
        push ebx
100
 
107
 
101
        mov ecx, [ScreenWidth]
108
        mov ecx, [ScreenWidth]
102
        inc ecx
109
        inc ecx
103
        mul ecx
110
        mul ecx
104
 
111
 
105
        movzx edx, byte [display_data+ebx+eax]
112
        movzx edx, byte [display_data+ebx+eax]
106
        shl edx, 8
113
        shl edx, 8
107
        mov ecx, [edx+SLOT_BASE+APPDATA.cursor]
114
        mov ecx, [edx+SLOT_BASE+APPDATA.cursor]
108
 
115
 
109
        cmp [ecx+CURSOR.magic], 'CURS'
116
        cmp [ecx+CURSOR.magic], 'CURS'
110
        jne .fail
117
        jne .fail
111
;        cmp [ecx+CURSOR.size], CURSOR_SIZE
118
;        cmp [ecx+CURSOR.size], CURSOR_SIZE
112
;        jne .fail
119
;        jne .fail
113
        push ecx
120
        push ecx
114
        call [set_hw_cursor]
121
        call [set_hw_cursor]
115
        popad
122
        popad
116
        ret
123
        ret
117
.fail:
124
.fail:
118
        mov ecx, [def_cursor]
125
        mov ecx, [def_cursor]
119
        mov [edx+SLOT_BASE+APPDATA.cursor], ecx
126
        mov [edx+SLOT_BASE+APPDATA.cursor], ecx
120
        push ecx
127
        push ecx
121
        call [set_hw_cursor]
128
        call [set_hw_cursor]
122
        popad
129
        popad
123
        ret
130
        ret
124
 
131
 
125
@@:
132
@@:
126
        pushad
133
        pushad
127
        ; save & draw
134
        ; save & draw
128
        mov    [X_UNDER],ax
135
        mov    [X_UNDER],ax
129
        mov    [Y_UNDER],bx
136
        mov    [Y_UNDER],bx
130
        push   eax
137
        push   eax
131
        push   ebx
138
        push   ebx
132
        mov    ecx,0
139
        mov    ecx,0
133
        mov    edx,0
140
        mov    edx,0
134
        align  4
141
        align  4
135
drm:
142
drm:
136
        push   eax
143
        push   eax
137
        push   ebx
144
        push   ebx
138
        push   ecx
145
        push   ecx
139
        push   edx
146
        push   edx
140
        ; helloworld
147
        ; helloworld
141
        push  ecx
148
        push  ecx
142
        add    eax,ecx  ; save picture under mouse
149
        add    eax,ecx  ; save picture under mouse
143
        add    ebx,edx
150
        add    ebx,edx
144
        push   ecx
151
        push   ecx
145
        call   getpixel
152
        call   getpixel
146
        mov    [COLOR_TEMP],ecx
153
        mov    [COLOR_TEMP],ecx
147
        pop    ecx
154
        pop    ecx
148
        mov    eax,edx
155
        mov    eax,edx
149
        shl    eax,6
156
        shl    eax,6
150
        shl    ecx,2
157
        shl    ecx,2
151
        add    eax,ecx
158
        add    eax,ecx
152
        add    eax,mouseunder
159
        add    eax,mouseunder
153
        mov    ebx,[COLOR_TEMP]
160
        mov    ebx,[COLOR_TEMP]
154
        mov    [eax],ebx
161
        mov    [eax],ebx
155
        pop  ecx
162
        pop  ecx
156
        mov    edi,edx       ; y cycle
163
        mov    edi,edx       ; y cycle
157
        shl    edi,4       ; *16 bytes per row
164
        shl    edi,4       ; *16 bytes per row
158
        add    edi,ecx       ; x cycle
165
        add    edi,ecx       ; x cycle
159
        mov    esi, edi
166
        mov    esi, edi
160
        add    edi, esi
167
        add    edi, esi
161
        add    edi, esi       ; *3
168
        add    edi, esi       ; *3
162
        add    edi,[MOUSE_PICTURE]      ; we have our str address
169
        add    edi,[MOUSE_PICTURE]      ; we have our str address
163
        mov    esi, edi
170
        mov    esi, edi
164
        add    esi, 16*24*3
171
        add    esi, 16*24*3
165
        push   ecx
172
        push   ecx
166
        mov    ecx, [COLOR_TEMP]
173
        mov    ecx, [COLOR_TEMP]
167
        call   combine_colors
174
        call   combine_colors
168
        mov    [MOUSE_COLOR_MEM], ecx
175
        mov    [MOUSE_COLOR_MEM], ecx
169
        pop    ecx
176
        pop    ecx
170
        pop    edx
177
        pop    edx
171
        pop    ecx
178
        pop    ecx
172
        pop    ebx
179
        pop    ebx
173
        pop    eax
180
        pop    eax
174
        add    eax,ecx       ; we have x coord+cycle
181
        add    eax,ecx       ; we have x coord+cycle
175
        add    ebx,edx       ; and y coord+cycle
182
        add    ebx,edx       ; and y coord+cycle
176
        push   ecx
183
        push   ecx
177
        mov    ecx, [MOUSE_COLOR_MEM]
184
        mov    ecx, [MOUSE_COLOR_MEM]
178
        mov    edi, 1
185
        mov    edi, 1
179
        call   [putpixel]
186
        call   [putpixel]
180
        pop    ecx
187
        pop    ecx
181
        mov    ebx,[esp+0]      ; pure y coord again
188
        mov    ebx,[esp+0]      ; pure y coord again
182
        mov    eax,[esp+4]      ; and x
189
        mov    eax,[esp+4]      ; and x
183
        inc    ecx          ; +1 cycle
190
        inc    ecx          ; +1 cycle
184
        cmp    ecx,16       ; if more than 16
191
        cmp    ecx,16       ; if more than 16
185
        jnz    drm
192
        jnz    drm
186
        xor    ecx, ecx
193
        xor    ecx, ecx
187
        inc    edx
194
        inc    edx
188
        cmp    edx,24
195
        cmp    edx,24
189
        jnz    drm
196
        jnz    drm
190
        add   esp,8
197
        add   esp,8
191
        popad
198
        popad
192
        ret
199
        ret
193
 
200
 
194
 
201
 
195
combine_colors:
202
combine_colors:
196
      ; in
203
      ; in
197
      ; ecx - color ( 00 RR GG BB )
204
      ; ecx - color ( 00 RR GG BB )
198
      ; edi - ref to new color byte
205
      ; edi - ref to new color byte
199
      ; esi - ref to alpha byte
206
      ; esi - ref to alpha byte
200
      ;
207
      ;
201
      ; out
208
      ; out
202
      ; ecx - new color ( roughly (ecx*[esi]>>8)+([edi]*[esi]>>8) )
209
      ; ecx - new color ( roughly (ecx*[esi]>>8)+([edi]*[esi]>>8) )
203
      push eax
210
      push eax
204
      push ebx
211
      push ebx
205
      push edx
212
      push edx
206
      push ecx
213
      push ecx
207
      xor ecx, ecx
214
      xor ecx, ecx
208
         ; byte 2
215
         ; byte 2
209
      mov eax, 0xff
216
      mov eax, 0xff
210
      sub al, [esi+0]
217
      sub al, [esi+0]
211
      mov ebx, [esp]
218
      mov ebx, [esp]
212
      shr ebx, 16
219
      shr ebx, 16
213
      and ebx, 0xff
220
      and ebx, 0xff
214
      mul ebx
221
      mul ebx
215
      shr eax, 8
222
      shr eax, 8
216
      add ecx, eax
223
      add ecx, eax
217
      xor eax, eax
224
      xor eax, eax
218
      xor ebx, ebx
225
      xor ebx, ebx
219
      mov al, [edi+0]
226
      mov al, [edi+0]
220
      mov bl, [esi+0]
227
      mov bl, [esi+0]
221
      mul ebx
228
      mul ebx
222
      shr eax, 8
229
      shr eax, 8
223
      add ecx, eax
230
      add ecx, eax
224
      shl ecx, 8
231
      shl ecx, 8
225
         ; byte 1
232
         ; byte 1
226
      mov eax, 0xff
233
      mov eax, 0xff
227
      sub al, [esi+1]
234
      sub al, [esi+1]
228
      mov ebx, [esp]
235
      mov ebx, [esp]
229
      shr ebx, 8
236
      shr ebx, 8
230
      and ebx, 0xff
237
      and ebx, 0xff
231
      mul ebx
238
      mul ebx
232
      shr eax, 8
239
      shr eax, 8
233
      add ecx, eax
240
      add ecx, eax
234
      xor eax, eax
241
      xor eax, eax
235
      xor ebx, ebx
242
      xor ebx, ebx
236
      mov al, [edi+1]
243
      mov al, [edi+1]
237
      mov bl, [esi+1]
244
      mov bl, [esi+1]
238
      mul ebx
245
      mul ebx
239
      shr eax, 8
246
      shr eax, 8
240
      add ecx, eax
247
      add ecx, eax
241
      shl ecx, 8
248
      shl ecx, 8
242
         ; byte 2
249
         ; byte 2
243
      mov eax, 0xff
250
      mov eax, 0xff
244
      sub al, [esi+2]
251
      sub al, [esi+2]
245
      mov ebx, [esp]
252
      mov ebx, [esp]
246
      and ebx, 0xff
253
      and ebx, 0xff
247
      mul ebx
254
      mul ebx
248
      shr eax, 8
255
      shr eax, 8
249
      add ecx, eax
256
      add ecx, eax
250
      xor eax, eax
257
      xor eax, eax
251
      xor ebx, ebx
258
      xor ebx, ebx
252
      mov al, [edi+2]
259
      mov al, [edi+2]
253
      mov bl, [esi+2]
260
      mov bl, [esi+2]
254
      mul ebx
261
      mul ebx
255
      shr eax, 8
262
      shr eax, 8
256
      add ecx, eax
263
      add ecx, eax
257
      pop eax
264
      pop eax
258
      pop edx
265
      pop edx
259
      pop ebx
266
      pop ebx
260
      pop eax
267
      pop eax
261
      ret
268
      ret
262
 
269
 
263
 
270
 
264
__sys_disable_mouse:
271
__sys_disable_mouse:
265
      cmp  dword [MOUSE_VISIBLE],dword 0
272
      cmp  dword [MOUSE_VISIBLE],dword 0
266
      je    @f
273
      je    @f
267
      ret
274
      ret
268
@@:
275
@@:
269
      pushad
276
      pushad
270
      cmp  [CURRENT_TASK],dword 1
277
      cmp  [CURRENT_TASK],dword 1
271
      je   disable_m
278
      je   disable_m
272
      mov  edx,[CURRENT_TASK]
279
      mov  edx,[CURRENT_TASK]
273
      shl  edx,5
280
      shl  edx,5
274
      add  edx,window_data
281
      add  edx,window_data
275
      movzx  eax, word [MOUSE_X]
282
      movzx  eax, word [MOUSE_X]
276
      movzx  ebx, word [MOUSE_Y]
283
      movzx  ebx, word [MOUSE_Y]
277
      mov  ecx,[ScreenWidth]
284
      mov  ecx,[ScreenWidth]
278
      inc  ecx
285
      inc  ecx
279
      imul  ecx,ebx
286
      imul  ecx,ebx
280
      add  ecx,eax
287
      add  ecx,eax
281
      add  ecx, display_data
288
      add  ecx, display_data
282
      mov   eax, [CURRENT_TASK]
289
      mov   eax, [CURRENT_TASK]
283
      movzx ebx, byte [ecx]
290
      movzx ebx, byte [ecx]
284
      cmp   eax,ebx
291
      cmp   eax,ebx
285
      je    yes_mouse_disable
292
      je    yes_mouse_disable
286
      movzx ebx, byte [ecx+16]
293
      movzx ebx, byte [ecx+16]
287
      cmp   eax,ebx
294
      cmp   eax,ebx
288
      je    yes_mouse_disable
295
      je    yes_mouse_disable
289
      mov   ebx,[ScreenWidth]
296
      mov   ebx,[ScreenWidth]
290
      inc   ebx
297
      inc   ebx
291
      imul  ebx,10
298
      imul  ebx,10
292
      add   ecx,ebx
299
      add   ecx,ebx
293
      movzx ebx, byte [ecx]
300
      movzx ebx, byte [ecx]
294
      cmp   eax,ebx
301
      cmp   eax,ebx
295
      je    yes_mouse_disable
302
      je    yes_mouse_disable
296
      movzx ebx, byte [ecx+16]
303
      movzx ebx, byte [ecx+16]
297
      cmp   eax,ebx
304
      cmp   eax,ebx
298
      je    yes_mouse_disable
305
      je    yes_mouse_disable
299
      jmp   no_mouse_disable
306
      jmp   no_mouse_disable
300
yes_mouse_disable:
307
yes_mouse_disable:
301
      mov  edx,[CURRENT_TASK]
308
      mov  edx,[CURRENT_TASK]
302
      shl  edx,5
309
      shl  edx,5
303
      add  edx,window_data
310
      add  edx,window_data
304
      movzx  eax, word [MOUSE_X]
311
      movzx  eax, word [MOUSE_X]
305
      movzx  ebx, word [MOUSE_Y]
312
      movzx  ebx, word [MOUSE_Y]
306
      mov  ecx,[edx+0]   ; mouse inside the area ?
313
      mov  ecx,[edx+0]   ; mouse inside the area ?
307
      add  eax,14
314
      add  eax,14
308
      cmp  eax,ecx
315
      cmp  eax,ecx
309
      jb   no_mouse_disable
316
      jb   no_mouse_disable
310
      sub  eax,14
317
      sub  eax,14
311
      add  ecx,[edx+8]
318
      add  ecx,[edx+8]
312
      cmp  eax,ecx
319
      cmp  eax,ecx
313
      jg   no_mouse_disable
320
      jg   no_mouse_disable
314
      mov  ecx,[edx+4]
321
      mov  ecx,[edx+4]
315
      add  ebx,20
322
      add  ebx,20
316
      cmp  ebx,ecx
323
      cmp  ebx,ecx
317
      jb   no_mouse_disable
324
      jb   no_mouse_disable
318
      sub  ebx,20
325
      sub  ebx,20
319
      add  ecx,[edx+12]
326
      add  ecx,[edx+12]
320
      cmp  ebx,ecx
327
      cmp  ebx,ecx
321
      jg   no_mouse_disable
328
      jg   no_mouse_disable
322
disable_m:
329
disable_m:
323
      cmp  dword [MOUSE_VISIBLE],dword 0
330
      cmp  dword [MOUSE_VISIBLE],dword 0
324
      jne  no_mouse_disable
331
      jne  no_mouse_disable
325
      pushf
332
      pushf
326
      cli
333
      cli
327
      call draw_mouse_under
334
      call draw_mouse_under
328
      popf
335
      popf
329
      mov  [MOUSE_VISIBLE],dword 1
336
      mov  [MOUSE_VISIBLE],dword 1
330
no_mouse_disable:
337
no_mouse_disable:
331
      popad
338
      popad
332
      ret
339
      ret
333
 
340
 
334
__sys_draw_pointer:
341
__sys_draw_pointer:
335
        cmp   [mouse_pause],0
342
        cmp   [mouse_pause],0
336
        je    @f
343
        je    @f
337
        ret
344
        ret
338
@@:
345
@@:
339
        push   eax
346
        push   eax
340
        mov     eax,[timer_ticks]
347
        mov     eax,[timer_ticks]
341
        sub     eax,[MouseTickCounter]
348
        sub     eax,[MouseTickCounter]
342
        cmp     eax,1
349
        cmp     eax,1
343
        ja      @f
350
        ja      @f
344
        pop    eax
351
        pop    eax
345
        ret
352
        ret
346
@@:
353
@@:
347
        mov     eax,[timer_ticks]
354
        mov     eax,[timer_ticks]
348
        mov     [MouseTickCounter],eax
355
        mov     [MouseTickCounter],eax
349
        pop     eax
356
        pop     eax
350
        pushad
357
        pushad
351
        cmp    dword [MOUSE_VISIBLE],dword 0  ; mouse visible ?
358
        cmp    dword [MOUSE_VISIBLE],dword 0  ; mouse visible ?
352
        je     chms00
359
        je     chms00
353
        mov     [MOUSE_VISIBLE], dword 0
360
        mov     [MOUSE_VISIBLE], dword 0
354
        movzx  ebx,word [MOUSE_Y]
361
        movzx  ebx,word [MOUSE_Y]
355
        movzx  eax,word [MOUSE_X]
362
        movzx  eax,word [MOUSE_X]
356
        pushfd
363
        pushfd
357
        cli
364
        cli
358
        call   save_draw_mouse
365
        call   save_draw_mouse
359
        popfd
366
        popfd
360
nodmu2:
367
nodmu2:
361
        popad
368
        popad
362
        ret
369
        ret
363
chms00:
370
chms00:
364
        movzx  ecx,word [X_UNDER]
371
        movzx  ecx,word [X_UNDER]
365
        movzx  edx,word [Y_UNDER]
372
        movzx  edx,word [Y_UNDER]
366
        movzx  ebx,word [MOUSE_Y]
373
        movzx  ebx,word [MOUSE_Y]
367
        movzx  eax,word [MOUSE_X]
374
        movzx  eax,word [MOUSE_X]
368
        cmp    eax,ecx
375
        cmp    eax,ecx
369
        jne    redrawmouse
376
        jne    redrawmouse
370
        cmp    ebx,edx
377
        cmp    ebx,edx
371
        jne    redrawmouse
378
        jne    redrawmouse
372
        jmp    nodmp
379
        jmp    nodmp
373
redrawmouse:
380
redrawmouse:
374
        pushfd
381
        pushfd
375
        cli
382
        cli
376
        call   draw_mouse_under
383
        call   draw_mouse_under
377
        call   save_draw_mouse
384
        call   save_draw_mouse
378
        popfd
385
        popfd
379
nodmp:
386
nodmp:
380
        popad
387
        popad
381
        ret
388
        ret