Subversion Repositories Kolibri OS

Rev

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

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