Subversion Repositories Kolibri OS

Rev

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