Subversion Repositories Kolibri OS

Rev

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