Subversion Repositories Kolibri OS

Rev

Rev 224 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
221 serge 1
 
2
LOAD_FROM_MEM   equ 1
3
LOAD_INDIRECT   equ 2
4
LOAD_SYSTEM     equ 3
5
6
 
7
proc vesa_init_cursor stdcall, dst:dword, src:dword
8
           locals
9
             rBase    dd ?
10
             pQuad    dd ?
11
             pBits    dd ?
12
             pAnd     dd ?
13
             width    dd ?
14
             height   dd ?
15
             counter  dd ?
16
           endl
17
18
 
19
           add esi,[esi+18d]
20
21
 
22
           add eax, [esi]
23
           mov [pQuad],eax
24
           add eax,64
25
           mov [pBits],eax
26
           add eax, 0x200
27
           mov [pAnd],eax
28
           mov eax,[esi+4]
29
           mov [width],eax
30
           mov ebx,[esi+8]
31
           shr ebx,1
32
           mov [height],ebx
33
34
 
35
           add edi, 32*31*4
36
           mov [rBase],edi
37
38
 
39
           mov ebx, [pBits]
40
.l1:
41
           mov eax, [esi]
42
           bswap eax
43
           mov [counter], 16
44
@@:
45
           xor edx, edx
46
           shl eax,1
47
           setc dl
48
           dec edx
49
50
 
51
           and ecx, 0xF0
52
           shr ecx, 2
53
           add ecx, [pQuad]
54
           mov ecx, [ecx]
55
           and ecx, edx
56
           and edx, 0xFF000000
57
           or edx, ecx
58
           mov [edi], edx
59
60
 
61
           shl eax,1
62
           setc dl
63
           dec edx
64
65
 
66
           and ecx, 0x0F
67
           shl ecx, 2
68
           add ecx, [pQuad]
69
           mov ecx, [ecx]
70
           and ecx, edx
71
           and edx, 0xFF000000
72
           or edx, ecx
73
           mov [edi+4], edx
74
75
 
76
           add edi, 8
77
           dec [counter]
78
           jnz @B
79
80
 
81
           mov edi,[rBase]
82
           sub edi,128
83
           mov [rBase],edi
84
           sub [height],1
85
           jnz .l1
86
           ret
87
endp
88
89
 
90
proc alloc_cursor
91
92
 
93
           cli
94
           mov ebx, [cursor_start]
95
           mov ecx, [cursor_end]
96
.l1:
97
           bsf eax,[ebx];
98
           jnz .found
99
           add ebx,4
100
           cmp ebx, ecx
101
           jb .l1
102
           popfd
103
           xor eax,eax
104
           ret
105
.found:
106
           btr [ebx], eax
107
           mov [cursor_start],ebx
108
           sub ebx, cursor_map
109
           shl ebx, 3
110
           add eax,ebx
111
           shl eax,3
112
           lea eax,[cursors+eax+eax*2]
113
           popfd
114
           ret
115
endp
116
117
 
118
proc create_cursor
119
           locals
120
             h_cur  dd ?
121
           endl
122
123
 
124
           test eax, eax
125
           jz .fail
126
127
 
128
           mov edi, eax
129
130
 
131
132
 
133
           mov [edi+CURSOR.size],  CURSOR_SIZE
134
           mov [edi+CURSOR.pid], ebx
135
           mov [edi+CURSOR.hot_x], ebx
136
           mov [edi+CURSOR.hot_y], ebx
137
138
 
139
           test eax, eax
140
           jz .fail
141
142
 
143
           mov eax, [h_cur]
144
           mov [eax+CURSOR.base], ebx
145
           ret
146
.fail:
147
           ret
148
endp
149
150
 
151
proc set_cursor stdcall, hcursor:dword
152
           mov eax, [hcursor]
153
           mov ebx, [CURRENT_TASK]
154
           shl ebx, 8
155
           xchg eax, [ebx+PROC_BASE+APPDATA.cursor]
156
           ret
157
endp
158
159
 
160
proc load_cursor stdcall, src:dword, flags:dword
161
           locals
162
             handle  dd ?
163
           endl
164
165
 
166
           cmp eax, LOAD_FROM_FILE
167
           jne .from_mem
168
169
 
170
           test eax, eax
171
           jz .exit
172
           mov [src], eax
173
174
 
175
           test eax, eax
176
           jz .fail
177
178
 
179
           mov esi, [src]
180
           movzx ebx, word [esi+10]
181
           movzx ecx, word [esi+12]
182
           mov [eax+CURSOR.hot_x], ebx
183
           mov [eax+CURSOR.hot_y], ecx
184
185
 
186
           stdcall kernel_free, [src]
187
           mov eax, [handle]
188
           ret
189
190
 
191
           cmp eax, LOAD_FROM_MEM
192
           jne .indirect
193
194
 
195
           test eax, eax
196
           jz .exit
197
198
 
199
           mov esi, [src]
200
           movzx ebx, word [esi+10]
201
           movzx ecx, word [esi+12]
202
           mov [eax+CURSOR.hot_x], ebx
203
           mov [eax+CURSOR.hot_y], ecx
204
205
 
206
           mov eax, [handle]
207
           ret
208
209
 
210
           cmp eax, LOAD_INDIRECT
211
           jne .fail
212
213
 
214
           test eax, eax
215
           jz .exit
216
217
 
218
           movzx ebx, byte [flags+3]
219
           mov [eax+CURSOR.hot_x], ebx
220
           mov [eax+CURSOR.hot_y], edx
221
222
 
223
           mov esi, [src]
224
           mov ecx, 1024
225
           cld
226
           rep movsd
227
           ret
228
.fail:
229
           mov ebx, [src]
230
           stdcall kernel_free, ebx
231
.exit:
232
           xor eax, eax
233
           ret
234
endp
235
236
 
237
proc init_cursors
238
           movzx eax, byte [ScreenBPP]
239
           mov ebx, [SCR_BYTES_PER_LINE]
240
           cmp eax, 32
241
           jne @F
242
           sub ebx, 128
243
           jmp .init
244
@@:
245
           cmp eax, 24
246
           jne .fail
247
           sub ebx, 96
248
.init:
249
           mov [cur_def_interl], ebx
250
251
 
252
           mov edi, cursors
253
           mov ecx, CURSOR_SIZE*16
254
           cld
255
           rep stosd
256
257
 
258
           mov [cursor_map], eax
259
           mov [cursor_map+4], eax
260
           mov edx, cursor_map
261
           mov [cursor_start], edx
262
           add edx, 4
263
           mov [cursor_end], edx
264
265
 
266
           mov [def_cursor], eax
267
268
 
269
           mov edx, [SCR_Y_SIZE]
270
           inc ecx
271
           inc edx
272
           mov [scr_width], ecx
273
           mov [scr_height], edx
274
275
 
276
           cmp ebx, 32
277
           jne @F
278
279
 
280
           mov dword [hw_restore], restore_32
281
           ret
282
@@:
283
           mov dword [set_hw_cursor], cursor_24
284
           mov dword [hw_restore], restore_24
285
           ret
286
.fail:
287
           xor eax, eax
288
           mov dword [set_hw_cursor], eax
289
           mov dword [hw_restore], eax
290
           ret
291
endp
292
293
 
294
proc restore_24 stdcall, x:dword, y:dword
295
           locals
296
             w  dd ?
297
           endl
298
299
 
300
           mov edx, [cur_saved_h]
301
           mov ebx, [cur_saved_interl]
302
303
 
304
@@:
305
           mov ecx, [cur_saved_w]
306
           lea ecx, [ecx+ecx*2]
307
           rep movsb
308
           add edi, ebx
309
           dec edx
310
           jnz @B
311
           ret
312
endp
313
314
 
315
proc restore_32 stdcall, x:dword, y:dword
316
           locals
317
             w  dd ?
318
           endl
319
320
 
321
           mov edx, [cur_saved_h]
322
           mov ebx, [cur_saved_interl]
323
324
 
325
@@:
326
           mov ecx, [cur_saved_w]
327
           rep movsd
328
           add edi, ebx
329
           dec edx
330
           jnz @B
331
           ret
332
endp
333
334
 
335
proc cursor_24 stdcall, hcursor:dword, x:dword, y:dword
336
           locals
337
             w      dd ?
338
             h      dd ?
339
             st     dd ?
340
             _dx     dd ?
341
             _dy     dd ?
342
           endl
343
344
 
345
           mov ecx, [x]
346
           mov eax, [y]
347
           mov ebx, [BytesPerScanLine]
348
349
 
350
           sub ecx, [esi+CURSOR.hot_x]
351
           mov [x], ecx
352
           sets dl
353
           dec edx
354
           and ecx, edx       ;clip x to 0<=x
355
           mov edi, ecx
356
           sub edi, [x]
357
           mov [_dx], edi
358
359
 
360
           sub eax, [esi+CURSOR.hot_y]
361
           mov [y], eax
362
           sets dl
363
           dec edx
364
           and eax, edx       ;clip y to 0<=y
365
           mov edi, eax
366
           sub edi, [y]
367
           mov [_dy], edi
368
369
 
370
           lea esi, [ecx+ecx*2]
371
           add esi, [LFBAddress]
372
           add esi, eax
373
           mov [cur_saved_base],esi
374
375
 
376
           mov edx, [scr_height]
377
           mov eax, 32
378
379
 
380
           cmp edi, eax
381
           cmovg edi, eax
382
           sub edi, [_dx]
383
384
 
385
           cmp edx, eax
386
           cmovg edx, eax
387
           sub edx, [_dy]
388
389
 
390
           mov [h], edx
391
           mov [cur_saved_w], edi
392
           mov [cur_saved_h], edx
393
394
 
395
           lea eax, [eax+eax*2]
396
           lea edi, [edi+edi*2]
397
           sub ebx, edi
398
           mov [cur_saved_interl], ebx
399
400
 
401
@@:
402
           mov ecx, [w]
403
           lea ecx, [ecx+ecx*2]
404
           rep movsb
405
           add esi, ebx
406
           dec edx
407
           jnz @B
408
409
 
410
           mov edx, eax
411
           mov edi, [cur_saved_base]
412
           mov eax, [_dy]
413
           shl eax, 5
414
           add eax, [_dx]
415
           shl eax, 2
416
417
 
418
           mov esi, [esi+CURSOR.base]
419
           add esi, eax
420
.row:
421
           mov ecx, [w]
422
.pix:
423
           lodsd
424
           test eax, 0xFF000000
425
           jz @F
426
427
 
428
           shr eax, 16
429
           mov [edi+2],al
430
@@:
431
           add edi, 3
432
           dec ecx
433
           jnz .pix
434
435
 
436
           add edi, ebx
437
           dec [h]
438
           jnz .row
439
           ret
440
endp
441
442
 
443
proc cursor_32 stdcall, hcursor:dword, x:dword, y:dword
444
           locals
445
             w      dd ?
446
             h      dd ?
447
             st     dd ?
448
             _dx     dd ?
449
             _dy     dd ?
450
           endl
451
452
 
453
           mov ecx, [x]
454
           mov eax, [y]
455
           mov ebx, [BytesPerScanLine]
456
457
 
458
           sub ecx, [esi+CURSOR.hot_x]
459
           mov [x], ecx
460
           sets dl
461
           dec edx
462
           and ecx, edx       ;clip x to 0<=x
463
           mov edi, ecx
464
           sub edi, [x]
465
           mov [_dx], edi
466
467
 
468
           sub eax, [esi+CURSOR.hot_y]
469
           mov [y], eax
470
           sets dl
471
           dec edx
472
           and eax, edx       ;clip y to 0<=y
473
           mov edi, eax
474
           sub edi, [y]
475
           mov [_dy], edi
476
477
 
478
           lea esi, [eax+ecx*4]
479
           add esi, [LFBAddress]
480
           mov [cur_saved_base],esi
481
482
 
483
           mov edx, [scr_height]
484
           mov eax, 32
485
486
 
487
           cmp edi, eax
488
           cmovg edi, eax
489
           sub edi, [_dx]
490
491
 
492
           cmp edx, eax
493
           cmovg edx, eax
494
           sub edx, [_dy]
495
496
 
497
           mov [h], edx
498
           mov [cur_saved_w], edi
499
           mov [cur_saved_h], edx
500
501
 
502
           shl eax, 2
503
           shl edi, 2
504
           sub ebx, edi
505
           mov [cur_saved_interl], ebx
506
507
 
508
@@:
509
           mov ecx, [w]
510
           rep movsd
511
           add esi, ebx
512
           dec edx
513
           jnz @B
514
515
 
516
           mov edx, eax
517
           mov edi, [cur_saved_base]
518
           mov eax, [_dy]
519
           shl eax, 5
520
           add eax, [_dx]
521
           shl eax, 2
522
523
 
524
           mov esi, [esi+CURSOR.base]
525
           add esi, eax
526
.row:
527
           mov ecx, [w]
528
.pix:
529
           lodsd
530
           test eax, 0xFF000000
531
           jz @F
532
           mov [edi], eax
533
@@:
534
           add edi, 4
535
           dec ecx
536
           jnz .pix
537
           add esi, edx
538
           add edi, ebx
539
           dec [h]
540
           jnz .row
541
           ret
542
endp
543
544
 
545
def_arrow:
546
  file 'arrow.cur'
547
>
548