Subversion Repositories Kolibri OS

Rev

Rev 33 | Rev 102 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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