Subversion Repositories Kolibri OS

Rev

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

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