Subversion Repositories Kolibri OS

Rev

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

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