Subversion Repositories Kolibri OS

Rev

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

Rev 221 Rev 230
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
        push [edx+PROC_BASE+APPDATA.cursor]
105
        mov ecx, [edx+PROC_BASE+APPDATA.cursor]
-
 
106
 
-
 
107
        cmp [ecx+CURSOR.magic], 'CURS'
-
 
108
        jne .fail
-
 
109
        cmp [ecx+CURSOR.size], CURSOR_SIZE
-
 
110
        jne .fail
-
 
111
        push ecx
106
        call [set_hw_cursor]
112
        call [set_hw_cursor]
107
        popad
113
        popad
108
        ret
114
        ret
-
 
115
.fail:
-
 
116
        mov ecx, [def_cursor]
-
 
117
        mov [edx+PROC_BASE+APPDATA.cursor], ecx
-
 
118
        push ecx
-
 
119
        call [set_hw_cursor]
-
 
120
        popad
-
 
121
        ret
-
 
122
 
109
@@:
123
@@:
110
        pushad
124
        pushad
111
        ; save & draw
125
        ; save & draw
112
        mov    [0xfb4a],ax
126
        mov    [0xfb4a],ax
113
        mov    [0xfb4c],bx
127
        mov    [0xfb4c],bx
114
        push   eax
128
        push   eax
115
        push   ebx
129
        push   ebx
116
        mov    ecx,0
130
        mov    ecx,0
117
        mov    edx,0
131
        mov    edx,0
118
        align  4
132
        align  4
119
drm:
133
drm:
120
        push   eax
134
        push   eax
121
        push   ebx
135
        push   ebx
122
        push   ecx
136
        push   ecx
123
        push   edx
137
        push   edx
124
        ; helloworld
138
        ; helloworld
125
        push  ecx
139
        push  ecx
126
        add    eax,ecx  ; save picture under mouse
140
        add    eax,ecx  ; save picture under mouse
127
        add    ebx,edx
141
        add    ebx,edx
128
        push   ecx
142
        push   ecx
129
        call   getpixel
143
        call   getpixel
130
        mov    [0xfb30],ecx
144
        mov    [0xfb30],ecx
131
        pop    ecx
145
        pop    ecx
132
        mov    eax,edx
146
        mov    eax,edx
133
        shl    eax,6
147
        shl    eax,6
134
        shl    ecx,2
148
        shl    ecx,2
135
        add    eax,ecx
149
        add    eax,ecx
136
        add    eax,mouseunder
150
        add    eax,mouseunder
137
        mov    ebx,[0xfb30]
151
        mov    ebx,[0xfb30]
138
        mov    [eax],ebx
152
        mov    [eax],ebx
139
        pop  ecx
153
        pop  ecx
140
        mov    edi,edx       ; y cycle
154
        mov    edi,edx       ; y cycle
141
        shl    edi,4       ; *16 bytes per row
155
        shl    edi,4       ; *16 bytes per row
142
        add    edi,ecx       ; x cycle
156
        add    edi,ecx       ; x cycle
143
        mov    esi, edi
157
        mov    esi, edi
144
        add    edi, esi
158
        add    edi, esi
145
        add    edi, esi       ; *3
159
        add    edi, esi       ; *3
146
        add    edi,[0xf200]      ; we have our str address
160
        add    edi,[0xf200]      ; we have our str address
147
        mov    esi, edi
161
        mov    esi, edi
148
        add    esi, 16*24*3
162
        add    esi, 16*24*3
149
        push   ecx
163
        push   ecx
150
        mov    ecx, [0xfb30]
164
        mov    ecx, [0xfb30]
151
        call   combine_colors
165
        call   combine_colors
152
        mov    [0xfb10], ecx
166
        mov    [0xfb10], ecx
153
        pop    ecx
167
        pop    ecx
154
        pop    edx
168
        pop    edx
155
        pop    ecx
169
        pop    ecx
156
        pop    ebx
170
        pop    ebx
157
        pop    eax
171
        pop    eax
158
        add    eax,ecx       ; we have x coord+cycle
172
        add    eax,ecx       ; we have x coord+cycle
159
        add    ebx,edx       ; and y coord+cycle
173
        add    ebx,edx       ; and y coord+cycle
160
        push   ecx
174
        push   ecx
161
        mov    ecx, [0xfb10]
175
        mov    ecx, [0xfb10]
162
        mov    edi, 1
176
        mov    edi, 1
163
        call   [putpixel]
177
        call   [putpixel]
164
        pop    ecx
178
        pop    ecx
165
        mov    ebx,[esp+0]      ; pure y coord again
179
        mov    ebx,[esp+0]      ; pure y coord again
166
        mov    eax,[esp+4]      ; and x
180
        mov    eax,[esp+4]      ; and x
167
        inc    ecx          ; +1 cycle
181
        inc    ecx          ; +1 cycle
168
        cmp    ecx,16       ; if more than 16
182
        cmp    ecx,16       ; if more than 16
169
        jnz    drm
183
        jnz    drm
170
        xor    ecx, ecx
184
        xor    ecx, ecx
171
        inc    edx
185
        inc    edx
172
        cmp    edx,24
186
        cmp    edx,24
173
        jnz    drm
187
        jnz    drm
174
        add   esp,8
188
        add   esp,8
175
        popad
189
        popad
176
        ret
190
        ret
177
 
191
 
178
 
192
 
179
combine_colors:
193
combine_colors:
180
      ; in
194
      ; in
181
      ; ecx - color ( 00 RR GG BB )
195
      ; ecx - color ( 00 RR GG BB )
182
      ; edi - ref to new color byte
196
      ; edi - ref to new color byte
183
      ; esi - ref to alpha byte
197
      ; esi - ref to alpha byte
184
      ;
198
      ;
185
      ; out
199
      ; out
186
      ; ecx - new color ( roughly (ecx*[esi]>>8)+([edi]*[esi]>>8) )
200
      ; ecx - new color ( roughly (ecx*[esi]>>8)+([edi]*[esi]>>8) )
187
      push eax
201
      push eax
188
      push ebx
202
      push ebx
189
      push edx
203
      push edx
190
      push ecx
204
      push ecx
191
      xor ecx, ecx
205
      xor ecx, ecx
192
         ; byte 2
206
         ; byte 2
193
      mov eax, 0xff
207
      mov eax, 0xff
194
      sub al, [esi+0]
208
      sub al, [esi+0]
195
      mov ebx, [esp]
209
      mov ebx, [esp]
196
      shr ebx, 16
210
      shr ebx, 16
197
      and ebx, 0xff
211
      and ebx, 0xff
198
      mul ebx
212
      mul ebx
199
      shr eax, 8
213
      shr eax, 8
200
      add ecx, eax
214
      add ecx, eax
201
      xor eax, eax
215
      xor eax, eax
202
      xor ebx, ebx
216
      xor ebx, ebx
203
      mov al, [edi+0]
217
      mov al, [edi+0]
204
      mov bl, [esi+0]
218
      mov bl, [esi+0]
205
      mul ebx
219
      mul ebx
206
      shr eax, 8
220
      shr eax, 8
207
      add ecx, eax
221
      add ecx, eax
208
      shl ecx, 8
222
      shl ecx, 8
209
         ; byte 1
223
         ; byte 1
210
      mov eax, 0xff
224
      mov eax, 0xff
211
      sub al, [esi+1]
225
      sub al, [esi+1]
212
      mov ebx, [esp]
226
      mov ebx, [esp]
213
      shr ebx, 8
227
      shr ebx, 8
214
      and ebx, 0xff
228
      and ebx, 0xff
215
      mul ebx
229
      mul ebx
216
      shr eax, 8
230
      shr eax, 8
217
      add ecx, eax
231
      add ecx, eax
218
      xor eax, eax
232
      xor eax, eax
219
      xor ebx, ebx
233
      xor ebx, ebx
220
      mov al, [edi+1]
234
      mov al, [edi+1]
221
      mov bl, [esi+1]
235
      mov bl, [esi+1]
222
      mul ebx
236
      mul ebx
223
      shr eax, 8
237
      shr eax, 8
224
      add ecx, eax
238
      add ecx, eax
225
      shl ecx, 8
239
      shl ecx, 8
226
         ; byte 2
240
         ; byte 2
227
      mov eax, 0xff
241
      mov eax, 0xff
228
      sub al, [esi+2]
242
      sub al, [esi+2]
229
      mov ebx, [esp]
243
      mov ebx, [esp]
230
      and ebx, 0xff
244
      and ebx, 0xff
231
      mul ebx
245
      mul ebx
232
      shr eax, 8
246
      shr eax, 8
233
      add ecx, eax
247
      add ecx, eax
234
      xor eax, eax
248
      xor eax, eax
235
      xor ebx, ebx
249
      xor ebx, ebx
236
      mov al, [edi+2]
250
      mov al, [edi+2]
237
      mov bl, [esi+2]
251
      mov bl, [esi+2]
238
      mul ebx
252
      mul ebx
239
      shr eax, 8
253
      shr eax, 8
240
      add ecx, eax
254
      add ecx, eax
241
      pop eax
255
      pop eax
242
      pop edx
256
      pop edx
243
      pop ebx
257
      pop ebx
244
      pop eax
258
      pop eax
245
      ret
259
      ret
246
 
260
 
247
 
261
 
248
__sys_disable_mouse:
262
__sys_disable_mouse:
249
      cmp  dword [0xf204],dword 0
263
      cmp  dword [0xf204],dword 0
250
      je    @f
264
      je    @f
251
      ret
265
      ret
252
@@:
266
@@:
253
      pushad
267
      pushad
254
      cmp  [0x3000],dword 1
268
      cmp  [0x3000],dword 1
255
      je   disable_m
269
      je   disable_m
256
      mov  edx,[0x3000]
270
      mov  edx,[0x3000]
257
      shl  edx,5
271
      shl  edx,5
258
      add  edx,window_data
272
      add  edx,window_data
259
      movzx  eax, word [0xfb0a]
273
      movzx  eax, word [0xfb0a]
260
      movzx  ebx, word [0xfb0c]
274
      movzx  ebx, word [0xfb0c]
261
      mov  ecx,[0xfe00]
275
      mov  ecx,[0xfe00]
262
      inc  ecx
276
      inc  ecx
263
      imul  ecx,ebx
277
      imul  ecx,ebx
264
      add  ecx,eax
278
      add  ecx,eax
265
      add  ecx, display_data
279
      add  ecx, display_data
266
      mov   eax, [0x3000]
280
      mov   eax, [0x3000]
267
      movzx ebx, byte [ecx]
281
      movzx ebx, byte [ecx]
268
      cmp   eax,ebx
282
      cmp   eax,ebx
269
      je    yes_mouse_disable
283
      je    yes_mouse_disable
270
      movzx ebx, byte [ecx+16]
284
      movzx ebx, byte [ecx+16]
271
      cmp   eax,ebx
285
      cmp   eax,ebx
272
      je    yes_mouse_disable
286
      je    yes_mouse_disable
273
      mov   ebx,[0xfe00]
287
      mov   ebx,[0xfe00]
274
      inc   ebx
288
      inc   ebx
275
      imul  ebx,10
289
      imul  ebx,10
276
      add   ecx,ebx
290
      add   ecx,ebx
277
      movzx ebx, byte [ecx]
291
      movzx ebx, byte [ecx]
278
      cmp   eax,ebx
292
      cmp   eax,ebx
279
      je    yes_mouse_disable
293
      je    yes_mouse_disable
280
      movzx ebx, byte [ecx+16]
294
      movzx ebx, byte [ecx+16]
281
      cmp   eax,ebx
295
      cmp   eax,ebx
282
      je    yes_mouse_disable
296
      je    yes_mouse_disable
283
      jmp   no_mouse_disable
297
      jmp   no_mouse_disable
284
yes_mouse_disable:
298
yes_mouse_disable:
285
      mov  edx,[0x3000]
299
      mov  edx,[0x3000]
286
      shl  edx,5
300
      shl  edx,5
287
      add  edx,window_data
301
      add  edx,window_data
288
      movzx  eax, word [0xfb0a]
302
      movzx  eax, word [0xfb0a]
289
      movzx  ebx, word [0xfb0c]
303
      movzx  ebx, word [0xfb0c]
290
      mov  ecx,[edx+0]   ; mouse inside the area ?
304
      mov  ecx,[edx+0]   ; mouse inside the area ?
291
      add  eax,14
305
      add  eax,14
292
      cmp  eax,ecx
306
      cmp  eax,ecx
293
      jb   no_mouse_disable
307
      jb   no_mouse_disable
294
      sub  eax,14
308
      sub  eax,14
295
      add  ecx,[edx+8]
309
      add  ecx,[edx+8]
296
      cmp  eax,ecx
310
      cmp  eax,ecx
297
      jg   no_mouse_disable
311
      jg   no_mouse_disable
298
      mov  ecx,[edx+4]
312
      mov  ecx,[edx+4]
299
      add  ebx,20
313
      add  ebx,20
300
      cmp  ebx,ecx
314
      cmp  ebx,ecx
301
      jb   no_mouse_disable
315
      jb   no_mouse_disable
302
      sub  ebx,20
316
      sub  ebx,20
303
      add  ecx,[edx+12]
317
      add  ecx,[edx+12]
304
      cmp  ebx,ecx
318
      cmp  ebx,ecx
305
      jg   no_mouse_disable
319
      jg   no_mouse_disable
306
disable_m:
320
disable_m:
307
      cmp  dword [0xf204],dword 0
321
      cmp  dword [0xf204],dword 0
308
      jne  no_mouse_disable
322
      jne  no_mouse_disable
309
      cli
323
      cli
310
      call draw_mouse_under
324
      call draw_mouse_under
311
      sti
325
      sti
312
      mov  [0xf204],dword 1
326
      mov  [0xf204],dword 1
313
no_mouse_disable:
327
no_mouse_disable:
314
      popad
328
      popad
315
      ret
329
      ret
316
 
330
 
317
__sys_draw_pointer:
331
__sys_draw_pointer:
318
        cmp   [mouse_pause],0
332
        cmp   [mouse_pause],0
319
        je    @f
333
        je    @f
320
        ret
334
        ret
321
@@:
335
@@:
322
        push   eax
336
        push   eax
323
        mov     eax,[timer_ticks]
337
        mov     eax,[timer_ticks]
324
        sub     eax,[MouseTickCounter]
338
        sub     eax,[MouseTickCounter]
325
        cmp     eax,1
339
        cmp     eax,1
326
        ja      @f
340
        ja      @f
327
        pop    eax
341
        pop    eax
328
        ret
342
        ret
329
@@:
343
@@:
330
        mov     eax,[timer_ticks]
344
        mov     eax,[timer_ticks]
331
        mov     [MouseTickCounter],eax
345
        mov     [MouseTickCounter],eax
332
        pop     eax
346
        pop     eax
333
        pushad
347
        pushad
334
        cmp    dword [0xf204],dword 0  ; mouse visible ?
348
        cmp    dword [0xf204],dword 0  ; mouse visible ?
335
        je     chms00
349
        je     chms00
336
        mov     [0xf204], dword 0
350
        mov     [0xf204], dword 0
337
        movzx  ebx,word [0xfb0c]
351
        movzx  ebx,word [0xfb0c]
338
        movzx  eax,word [0xfb0a]
352
        movzx  eax,word [0xfb0a]
339
        cli
353
        cli
340
        call   save_draw_mouse
354
        call   save_draw_mouse
341
        sti
355
        sti
342
nodmu2:
356
nodmu2:
343
        popad
357
        popad
344
        ret
358
        ret
345
chms00:
359
chms00:
346
        movzx  ecx,word [0xfb4a]
360
        movzx  ecx,word [0xfb4a]
347
        movzx  edx,word [0xfb4c]
361
        movzx  edx,word [0xfb4c]
348
        movzx  ebx,word [0xfb0c]
362
        movzx  ebx,word [0xfb0c]
349
        movzx  eax,word [0xfb0a]
363
        movzx  eax,word [0xfb0a]
350
        cmp    eax,ecx
364
        cmp    eax,ecx
351
        jne    redrawmouse
365
        jne    redrawmouse
352
        cmp    ebx,edx
366
        cmp    ebx,edx
353
        jne    redrawmouse
367
        jne    redrawmouse
354
        jmp    nodmp
368
        jmp    nodmp
355
redrawmouse:
369
redrawmouse:
356
        cli
370
        cli
357
        call   draw_mouse_under
371
        call   draw_mouse_under
358
        call   save_draw_mouse
372
        call   save_draw_mouse
359
        sti
373
        sti
360
nodmp:
374
nodmp:
361
        popad
375
        popad
362
        ret
376
        ret