Subversion Repositories Kolibri OS

Rev

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