Subversion Repositories Kolibri OS

Rev

Rev 9926 | Rev 9941 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2288 clevermous 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
9715 Doczom 3
;; Copyright (C) KolibriOS team 2004-2022. All rights reserved. ;;
2288 clevermous 4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
 
8
$Revision: 9930 $
9
 
10
 
7136 dunkaist 11
LOAD_FROM_FILE  = 0
12
LOAD_FROM_MEM   = 1
13
LOAD_INDIRECT   = 2
14
LOAD_SYSTEM     = 3
2288 clevermous 15
 
2384 hidnplayr 16
struct  BITMAPINFOHEADER
17
        Size                    dd ?
18
        Width                   dd ?
19
        Height                  dd ?
20
        Planes                  dw ?
21
        BitCount                dw ?
22
        Compression             dd ?
23
        SizeImage               dd ?
24
        XPelsPerMeter           dd ?
25
        YPelsPerMeter           dd ?
26
        ClrUsed                 dd ?
27
        ClrImportant            dd ?
28
ends
2430 mario79 29
;------------------------------------------------------------------------------
2288 clevermous 30
align 4
31
proc init_cursor stdcall, dst:dword, src:dword
32
           locals
33
             rBase    dd ?
34
             pQuad    dd ?
35
             pBits    dd ?
36
             pAnd     dd ?
37
             width    dd ?
38
             height   dd ?
39
             counter  dd ?
40
           endl
41
 
42
        mov     esi, [src]
43
        add     esi, [esi+18]
44
        mov     eax, esi
45
 
9715 Doczom 46
        cmp     [esi + BITMAPINFOHEADER.BitCount], 24
2288 clevermous 47
        je      .img_24
9715 Doczom 48
        cmp     [esi + BITMAPINFOHEADER.BitCount], 8
2288 clevermous 49
        je      .img_8
9715 Doczom 50
        cmp     [esi + BITMAPINFOHEADER.BitCount], 4
2288 clevermous 51
        je      .img_4
2430 mario79 52
;--------------------------------------
53
align 4
2288 clevermous 54
.img_2:
55
        add     eax, [esi]
56
        mov     [pQuad], eax
57
        add     eax, 8
58
        mov     [pBits], eax
59
        add     eax, 128
60
        mov     [pAnd], eax
61
        mov     eax, [esi+4]
62
        mov     [width], eax
63
        mov     ebx, [esi+8]
64
        shr     ebx, 1
65
        mov     [height], ebx
66
 
67
        mov     edi, [dst]
68
        add     edi, 32*31*4
69
        mov     [rBase], edi
70
 
71
        mov     esi, [pQuad]
2430 mario79 72
;--------------------------------------
73
align 4
2288 clevermous 74
.l21:
75
        mov     ebx, [pBits]
76
        mov     ebx, [ebx]
77
        bswap   ebx
78
        mov     eax, [pAnd]
79
        mov     eax, [eax]
80
        bswap   eax
81
        mov     [counter], 32
2430 mario79 82
;--------------------------------------
83
align 4
2288 clevermous 84
@@:
85
        xor     edx, edx
86
        shl     eax, 1
87
        setc    dl
88
        dec     edx
89
 
90
        xor     ecx, ecx
91
        shl     ebx, 1
92
        setc    cl
9715 Doczom 93
        mov     ecx, [esi + ecx*4]
2288 clevermous 94
        and     ecx, edx
95
        and     edx, 0xFF000000
96
        or      edx, ecx
97
        mov     [edi], edx
98
 
99
        add     edi, 4
100
        dec     [counter]
101
        jnz     @B
102
 
103
        add     [pBits], 4
104
        add     [pAnd], 4
105
        mov     edi, [rBase]
106
        sub     edi, 128
107
        mov     [rBase], edi
108
        sub     [height], 1
109
        jnz     .l21
110
        ret
2430 mario79 111
;--------------------------------------
112
align 4
2288 clevermous 113
.img_4:
114
        add     eax, [esi]
115
        mov     [pQuad], eax
116
        add     eax, 64
117
        mov     [pBits], eax
118
        add     eax, 0x200
119
        mov     [pAnd], eax
120
        mov     eax, [esi+4]
121
        mov     [width], eax
122
        mov     ebx, [esi+8]
123
        shr     ebx, 1
124
        mov     [height], ebx
125
 
126
        mov     edi, [dst]
127
        add     edi, 32*31*4
128
        mov     [rBase], edi
129
 
130
        mov     esi, [pQuad]
131
        mov     ebx, [pBits]
2430 mario79 132
;--------------------------------------
133
align 4
2288 clevermous 134
.l4:
135
        mov     eax, [pAnd]
136
        mov     eax, [eax]
137
        bswap   eax
138
        mov     [counter], 16
2430 mario79 139
;--------------------------------------
140
align 4
2288 clevermous 141
@@:
142
        xor     edx, edx
143
        shl     eax, 1
144
        setc    dl
145
        dec     edx
146
 
147
        movzx   ecx, byte [ebx]
148
        and     cl, 0xF0
149
        shr     ecx, 2
9715 Doczom 150
        mov     ecx, [esi + ecx]
2288 clevermous 151
        and     ecx, edx
152
        and     edx, 0xFF000000
153
        or      edx, ecx
154
        mov     [edi], edx
155
 
156
        xor     edx, edx
157
        shl     eax, 1
158
        setc    dl
159
        dec     edx
160
 
161
        movzx   ecx, byte [ebx]
162
        and     cl, 0x0F
9715 Doczom 163
        mov     ecx, [esi + ecx*4]
2288 clevermous 164
        and     ecx, edx
165
        and     edx, 0xFF000000
166
        or      edx, ecx
167
        mov     [edi+4], edx
168
 
169
        inc     ebx
170
        add     edi, 8
171
        dec     [counter]
172
        jnz     @B
173
 
174
        add     [pAnd], 4
175
        mov     edi, [rBase]
176
        sub     edi, 128
177
        mov     [rBase], edi
178
        sub     [height], 1
179
        jnz     .l4
180
        ret
2430 mario79 181
;--------------------------------------
182
align 4
2288 clevermous 183
.img_8:
184
        add     eax, [esi]
185
        mov     [pQuad], eax
186
        add     eax, 1024
187
        mov     [pBits], eax
188
        add     eax, 1024
189
        mov     [pAnd], eax
190
        mov     eax, [esi+4]
191
        mov     [width], eax
192
        mov     ebx, [esi+8]
193
        shr     ebx, 1
194
        mov     [height], ebx
195
 
196
        mov     edi, [dst]
197
        add     edi, 32*31*4
198
        mov     [rBase], edi
199
 
200
        mov     esi, [pQuad]
201
        mov     ebx, [pBits]
2430 mario79 202
;--------------------------------------
203
align 4
2288 clevermous 204
.l81:
205
        mov     eax, [pAnd]
206
        mov     eax, [eax]
207
        bswap   eax
208
        mov     [counter], 32
2430 mario79 209
;--------------------------------------
210
align 4
2288 clevermous 211
@@:
212
        xor     edx, edx
213
        shl     eax, 1
214
        setc    dl
215
        dec     edx
216
 
217
        movzx   ecx, byte [ebx]
9715 Doczom 218
        mov     ecx, [esi + ecx*4]
2288 clevermous 219
        and     ecx, edx
220
        and     edx, 0xFF000000
221
        or      edx, ecx
222
        mov     [edi], edx
223
 
224
        inc     ebx
225
        add     edi, 4
226
        dec     [counter]
227
        jnz     @B
228
 
229
        add     [pAnd], 4
230
        mov     edi, [rBase]
231
        sub     edi, 128
232
        mov     [rBase], edi
233
        sub     [height], 1
234
        jnz     .l81
235
        ret
2430 mario79 236
;--------------------------------------
237
align 4
2288 clevermous 238
.img_24:
239
        add     eax, [esi]
240
        mov     [pQuad], eax
241
        add     eax, 0xC00
242
        mov     [pAnd], eax
9715 Doczom 243
        mov     eax, [esi + BITMAPINFOHEADER.Width]
2288 clevermous 244
        mov     [width], eax
9715 Doczom 245
        mov     ebx, [esi + BITMAPINFOHEADER.Height]
2288 clevermous 246
        shr     ebx, 1
247
        mov     [height], ebx
248
 
249
        mov     edi, [dst]
250
        add     edi, 32*31*4
251
        mov     [rBase], edi
252
 
253
        mov     esi, [pAnd]
254
        mov     ebx, [pQuad]
2430 mario79 255
;--------------------------------------
256
align 4
2288 clevermous 257
.row_24:
258
        mov     eax, [esi]
259
        bswap   eax
260
        mov     [counter], 32
2430 mario79 261
;--------------------------------------
262
align 4
2288 clevermous 263
@@:
264
        xor     edx, edx
265
        shl     eax, 1
266
        setc    dl
267
        dec     edx
268
 
269
        mov     ecx, [ebx]
270
        and     ecx, 0x00FFFFFF
271
        and     ecx, edx
272
        and     edx, 0xFF000000
273
        or      edx, ecx
274
        mov     [edi], edx
275
        add     ebx, 3
276
        add     edi, 4
277
        dec     [counter]
278
        jnz     @B
279
 
280
        add     esi, 4
281
        mov     edi, [rBase]
282
        sub     edi, 128
283
        mov     [rBase], edi
284
        sub     [height], 1
285
        jnz     .row_24
286
        ret
287
endp
2430 mario79 288
;------------------------------------------------------------------------------
2288 clevermous 289
align 4
290
proc set_cursor stdcall, hcursor:dword
291
        mov     eax, [hcursor]
9715 Doczom 292
        cmp     [eax + CURSOR.magic], 'CURS'
2288 clevermous 293
        jne     .fail
294
;           cmp [eax+CURSOR.size], CURSOR_SIZE
295
;           jne .fail
296
        mov     ebx, [current_slot]
9930 Doczom 297
        mov     ebx, [ebx + APPDATA.window]
298
        xchg    eax, [ebx + WDATA.cursor]
4507 lev 299
        jmp     .end
2430 mario79 300
;--------------------------------------
301
align 4
2288 clevermous 302
.fail:
303
        mov     eax, [def_cursor]
304
        mov     ebx, [current_slot]
9930 Doczom 305
        mov     ebx, [ebx + APPDATA.window]
306
        xchg    eax, [ebx + WDATA.cursor]
4507 lev 307
align 4
308
.end:
309
        mov     [redrawmouse_unconditional], 1
5350 serge 310
        call    __sys_draw_pointer
2288 clevermous 311
        ret
312
endp
2430 mario79 313
;------------------------------------------------------------------------------
314
align 4
2288 clevermous 315
; param
316
;  eax= pid
317
;  ebx= src
318
;  ecx= flags
319
 
320
create_cursor:
321
.src     equ esp
322
.flags   equ esp+4
323
.hcursor equ esp+8
324
 
325
        sub     esp, 4         ;space for .hcursor
326
        push    ecx
327
        push    ebx
328
 
329
        mov     ebx, eax
2384 hidnplayr 330
        mov     eax, sizeof.CURSOR
2288 clevermous 331
        call    create_kernel_object
332
        test    eax, eax
333
        jz      .fail
334
 
335
        mov     [.hcursor], eax
336
 
337
        xor     ebx, ebx
9715 Doczom 338
        mov     [eax + CURSOR.magic], 'CURS'
339
        mov     [eax + CURSOR.destroy], destroy_cursor
340
        mov     [eax + CURSOR.hot_x], ebx
341
        mov     [eax + CURSOR.hot_y], ebx
2288 clevermous 342
 
9926 Doczom 343
        stdcall kernel_alloc, PAGE_SIZE
2288 clevermous 344
        test    eax, eax
345
        jz      .fail
346
 
347
        mov     edi, [.hcursor]
9715 Doczom 348
        mov     [edi + CURSOR.base], eax
2288 clevermous 349
 
350
        mov     esi, [.src]
351
        mov     ebx, [.flags]
352
        cmp     bx, LOAD_INDIRECT
353
        je      .indirect
354
 
355
        movzx   ecx, word [esi+10]
356
        movzx   edx, word [esi+12]
9715 Doczom 357
        mov     [edi + CURSOR.hot_x], ecx
358
        mov     [edi + CURSOR.hot_y], edx
2288 clevermous 359
 
360
        stdcall init_cursor, eax, esi
361
 
2473 Serge 362
align 4
363
.add_cursor:
2337 Serge 364
        mov     ecx, [.hcursor]
9715 Doczom 365
        lea     ecx, [ecx + CURSOR.list_next]
2288 clevermous 366
        lea     edx, [_display.cr_list.next]
367
 
368
        pushfd
369
        cli
2337 Serge 370
        list_add ecx, edx   ;list_add_tail(new, head)
2288 clevermous 371
        popfd
372
 
373
        mov     eax, [.hcursor]
374
        cmp     [_display.init_cursor], 0
375
        je      .fail
376
 
377
        push    eax
378
        call    [_display.init_cursor]
379
        add     esp, 4
380
 
381
        mov     eax, [.hcursor]
2430 mario79 382
;--------------------------------------
383
align 4
2288 clevermous 384
.fail:
385
        add     esp, 12
386
        ret
2430 mario79 387
;--------------------------------------
388
align 4
2288 clevermous 389
.indirect:
390
        shr     ebx, 16
391
        movzx   ecx, bh
392
        movzx   edx, bl
9715 Doczom 393
        mov     [edi + CURSOR.hot_x], ecx
394
        mov     [edi + CURSOR.hot_y], edx
2288 clevermous 395
 
396
        xchg    edi, eax
9926 Doczom 397
        mov     ecx, PAGE_SIZE/4
2288 clevermous 398
        cld
399
        rep movsd
2473 Serge 400
        jmp     .add_cursor
2430 mario79 401
;------------------------------------------------------------------------------
2288 clevermous 402
align 4
403
proc load_cursor stdcall, src:dword, flags:dword
404
           locals
405
             handle  dd ?
406
           endl
407
 
408
        xor     eax, eax
409
        cmp     [create_cursor], eax
410
        je      .fail2
411
 
412
        mov     [handle], eax
413
        cmp     word [flags], LOAD_FROM_FILE
414
        jne     @F
415
 
416
        stdcall load_file, [src]
417
        test    eax, eax
418
        jz      .fail
419
        mov     [src], eax
2430 mario79 420
;--------------------------------------
421
align 4
2288 clevermous 422
@@:
423
        push    ebx
424
        push    esi
425
        push    edi
426
 
9828 Doczom 427
        mov     eax, [current_slot]
428
        mov     eax, [eax + APPDATA.tid]
2288 clevermous 429
        mov     ebx, [src]
430
        mov     ecx, [flags]
431
        call    create_cursor    ;eax, ebx, ecx
432
        mov     [handle], eax
433
 
434
        cmp     word [flags], LOAD_FROM_FILE
435
        jne     .exit
436
        stdcall kernel_free, [src]
2430 mario79 437
;--------------------------------------
438
align 4
2288 clevermous 439
.exit:
440
        pop     edi
441
        pop     esi
442
        pop     ebx
2430 mario79 443
;--------------------------------------
444
align 4
2288 clevermous 445
.fail:
446
        mov     eax, [handle]
2430 mario79 447
;--------------------------------------
448
align 4
2288 clevermous 449
.fail2:
450
        ret
451
endp
2430 mario79 452
;------------------------------------------------------------------------------
2288 clevermous 453
align 4
454
proc delete_cursor stdcall, hcursor:dword
455
 
3069 serge 456
;        DEBUGF 1,'K : delete_cursor %x\n', [hcursor]
457
 
2288 clevermous 458
        mov     esi, [hcursor]
3069 serge 459
 
9715 Doczom 460
        cmp     [esi + CURSOR.magic], 'CURS'
2288 clevermous 461
        jne     .fail
462
 
9828 Doczom 463
        mov     ebx, [current_slot]
464
        mov     ebx, [ebx + APPDATA.tid]
465
        cmp     ebx, [esi + CURSOR.pid]
2288 clevermous 466
        jne     .fail
467
 
468
        mov     ebx, [current_slot]
9930 Doczom 469
        mov     ebx, [ebx + APPDATA.window]
470
        cmp     esi, [ebx + WDATA.cursor]
2288 clevermous 471
        jne     @F
472
        mov     eax, [def_cursor]
9930 Doczom 473
        mov     [ebx + WDATA.cursor], eax
2430 mario79 474
;--------------------------------------
475
align 4
2288 clevermous 476
@@:
477
        mov     eax, [hcursor]
9715 Doczom 478
        call    [eax + APPOBJ.destroy]
2430 mario79 479
;--------------------------------------
480
align 4
2288 clevermous 481
.fail:
482
        ret
483
endp
2430 mario79 484
;------------------------------------------------------------------------------
485
align 4
2288 clevermous 486
; param
487
;  eax= cursor
488
destroy_cursor:
489
 
490
        push    eax
9715 Doczom 491
        stdcall kernel_free, [eax + CURSOR.base]
2337 Serge 492
 
493
        mov     eax, [esp]
9715 Doczom 494
        lea     eax, [eax + CURSOR.list_next]
2337 Serge 495
 
496
        pushfd
497
        cli
498
        list_del eax
499
        popfd
500
 
2288 clevermous 501
        pop     eax
502
        call    destroy_kernel_object
503
        ret
2430 mario79 504
;------------------------------------------------------------------------------
2288 clevermous 505
align 4
506
select_cursor:
9828 Doczom 507
        mov     eax, [esp + 4]
2288 clevermous 508
        mov     [_display.cursor], eax
509
        ret     4
2430 mario79 510
;------------------------------------------------------------------------------
2288 clevermous 511
align 4
512
proc restore_24 stdcall, x:dword, y:dword
513
 
514
        push    ebx
515
 
516
        mov     ebx, [cur_saved_base]
517
        mov     edx, [cur.h]
518
        test    edx, edx
519
        jz      .ret
520
 
521
        push    esi
522
        push    edi
523
 
524
        mov     esi, cur_saved_data
525
        mov     ecx, [cur.w]
9828 Doczom 526
        lea     ecx, [ecx + ecx*2]
2288 clevermous 527
        push    ecx
2430 mario79 528
;--------------------------------------
529
align 4
2288 clevermous 530
@@:
531
        mov     edi, ebx
5351 serge 532
        add     ebx, [_display.lfb_pitch]
2288 clevermous 533
 
534
        mov     ecx, [esp]
535
        rep movsb
536
        dec     edx
537
        jnz     @B
538
 
539
        pop     ecx
540
        pop     edi
541
        pop     esi
2430 mario79 542
;--------------------------------------
543
align 4
2288 clevermous 544
.ret:
545
        pop     ebx
546
        ret
547
endp
2430 mario79 548
;------------------------------------------------------------------------------
2288 clevermous 549
align 4
550
proc restore_32 stdcall, x:dword, y:dword
551
 
552
        push    ebx
553
 
554
        mov     ebx, [cur_saved_base]
555
        mov     edx, [cur.h]
556
        test    edx, edx
557
        jz      .ret
558
 
559
        push    esi
560
        push    edi
561
 
562
        mov     esi, cur_saved_data
2430 mario79 563
;--------------------------------------
564
align 4
2288 clevermous 565
@@:
566
        mov     edi, ebx
5351 serge 567
        add     ebx, [_display.lfb_pitch]
2288 clevermous 568
 
569
        mov     ecx, [cur.w]
570
        rep movsd
571
        dec     edx
572
        jnz     @B
573
 
574
        pop     edi
6127 serge 575
        pop     esi
576
 
2430 mario79 577
;--------------------------------------
578
align 4
2288 clevermous 579
.ret:
580
        pop     ebx
581
        ret
582
endp
2430 mario79 583
;------------------------------------------------------------------------------
2288 clevermous 584
align 4
5154 hidnplayr 585
proc restore_16 stdcall, x:dword, y:dword
586
 
587
        push    ebx
588
 
589
        mov     ebx, [cur_saved_base]
590
        mov     edx, [cur.h]
591
        test    edx, edx
592
        jz      .ret
593
 
594
        push    esi
595
        push    edi
596
 
597
        mov     esi, cur_saved_data
598
;--------------------------------------
599
align 4
600
@@:
601
        mov     edi, ebx
5351 serge 602
        add     ebx, [_display.lfb_pitch]
5154 hidnplayr 603
 
604
        mov     ecx, [cur.w]
605
        rep movsw
606
        dec     edx
607
        jnz     @B
608
 
609
        pop     edi
6127 serge 610
        pop     esi
611
 
5154 hidnplayr 612
;--------------------------------------
613
align 4
614
.ret:
615
        pop     ebx
616
        ret
617
endp
618
;------------------------------------------------------------------------------
619
align 4
2288 clevermous 620
proc move_cursor_24 stdcall, hcursor:dword, x:dword, y:dword
621
           locals
622
             h      dd ?
623
             _dx     dd ?
624
             _dy     dd ?
625
           endl
626
 
627
        mov     esi, [hcursor]
628
        mov     ecx, [x]
629
        mov     eax, [y]
2446 mario79 630
;        mov     ebx, [BytesPerScanLine]
2288 clevermous 631
 
632
        xor     edx, edx
9715 Doczom 633
        sub     ecx, [esi + CURSOR.hot_x]
634
        lea     ebx, [ecx + 32-1]
2288 clevermous 635
        mov     [x], ecx
636
        sets    dl
637
        dec     edx
638
        and     ecx, edx      ;clip x to 0<=x
639
        mov     [cur.left], ecx
640
        mov     edi, ecx
641
        sub     edi, [x]
642
        mov     [_dx], edi
643
 
644
        xor     edx, edx
9715 Doczom 645
        sub     eax, [esi + CURSOR.hot_y]
2288 clevermous 646
        lea     edi, [eax+32-1]
647
        mov     [y], eax
648
        sets    dl
649
        dec     edx
650
        and     eax, edx      ;clip y to 0<=y
651
        mov     [cur.top], eax
652
        mov     edx, eax
653
        sub     edx, [y]
654
        mov     [_dy], edx
655
 
2446 mario79 656
;        mul     dword [BytesPerScanLine]
9715 Doczom 657
        mov     eax, [BPSLine_calc_area + eax*4]
658
        lea     edx, [LFB_BASE + ecx*3]
2288 clevermous 659
        add     edx, eax
660
        mov     [cur_saved_base], edx
661
 
5350 serge 662
        cmp     ebx, [_display.width]
663
        jb      @F
664
        mov     ebx, [_display.width]
2430 mario79 665
;--------------------------------------
666
align 4
2288 clevermous 667
@@:
5350 serge 668
        cmp     edi, [_display.height]
669
        jb      @F
670
        mov     edi, [_display.height]
2430 mario79 671
;--------------------------------------
672
align 4
2288 clevermous 673
@@:
674
 
675
        sub     ebx, [x]
676
        sub     edi, [y]
2576 mario79 677
        sub     ebx, [_dx]
678
        sub     edi, [_dy]
2288 clevermous 679
 
680
        mov     [cur.w], ebx
681
        mov     [cur.h], edi
682
        mov     [h], edi
683
 
684
        mov     eax, edi
685
        mov     edi, cur_saved_data
2430 mario79 686
;--------------------------------------
687
align 4
2288 clevermous 688
@@:
689
        mov     esi, edx
5351 serge 690
        add     edx, [_display.lfb_pitch]
2288 clevermous 691
        mov     ecx, [cur.w]
9715 Doczom 692
        lea     ecx, [ecx + ecx*2]
2288 clevermous 693
        rep movsb
694
        dec     eax
695
        jnz     @B
696
 
697
;draw cursor
698
        mov     ebx, [cur_saved_base]
699
        mov     eax, [_dy]
700
        shl     eax, 5
701
        add     eax, [_dx]
702
 
703
        mov     esi, [hcursor]
9715 Doczom 704
        mov     esi, [esi + CURSOR.base]
705
        lea     edx, [esi + eax*4]
2430 mario79 706
;--------------------------------------
707
align 4
2288 clevermous 708
.row:
709
        mov     ecx, [cur.w]
710
        mov     esi, edx
711
        mov     edi, ebx
712
        add     edx, 32*4
5351 serge 713
        add     ebx, [_display.lfb_pitch]
2430 mario79 714
;--------------------------------------
715
align 4
2288 clevermous 716
.pix:
717
        lodsd
718
        test    eax, 0xFF000000
719
        jz      @F
720
        mov     [edi], ax
721
        shr     eax, 16
722
        mov     [edi+2], al
2430 mario79 723
;--------------------------------------
724
align 4
2288 clevermous 725
@@:
726
        add     edi, 3
727
        dec     ecx
728
        jnz     .pix
729
 
730
        dec     [h]
731
        jnz     .row
732
        ret
733
endp
2430 mario79 734
;------------------------------------------------------------------------------
2288 clevermous 735
align 4
736
proc move_cursor_32 stdcall, hcursor:dword, x:dword, y:dword
737
           locals
738
             h      dd ?
739
             _dx     dd ?
740
             _dy     dd ?
741
           endl
742
 
743
        mov     esi, [hcursor]
744
        mov     ecx, [x]
745
        mov     eax, [y]
746
 
747
        xor     edx, edx
9715 Doczom 748
        sub     ecx, [esi + CURSOR.hot_x]
2288 clevermous 749
        lea     ebx, [ecx+32-1]
750
        mov     [x], ecx
751
        sets    dl
752
        dec     edx
753
        and     ecx, edx      ;clip x to 0<=x
754
        mov     [cur.left], ecx
755
        mov     edi, ecx
756
        sub     edi, [x]
757
        mov     [_dx], edi
758
 
759
        xor     edx, edx
9715 Doczom 760
        sub     eax, [esi + CURSOR.hot_y]
2288 clevermous 761
        lea     edi, [eax+32-1]
762
        mov     [y], eax
763
        sets    dl
764
        dec     edx
765
        and     eax, edx      ;clip y to 0<=y
766
        mov     [cur.top], eax
767
        mov     edx, eax
768
        sub     edx, [y]
769
        mov     [_dy], edx
770
 
2446 mario79 771
;        mul     dword [BytesPerScanLine]
2480 mario79 772
        mov     eax, [BPSLine_calc_area+eax*4]
9715 Doczom 773
        lea     edx, [LFB_BASE + eax + ecx*4]
2288 clevermous 774
        mov     [cur_saved_base], edx
775
 
5350 serge 776
        cmp     ebx, [_display.width]
777
        jb      @F
778
        mov     ebx, [_display.width]
2430 mario79 779
;--------------------------------------
780
align 4
2288 clevermous 781
@@:
5350 serge 782
        cmp     edi, [_display.height]
783
        jb      @F
784
        mov     edi, [_display.height]
2430 mario79 785
;--------------------------------------
786
align 4
2288 clevermous 787
@@:
788
        sub     ebx, [x]
789
        sub     edi, [y]
2576 mario79 790
        sub     ebx, [_dx]
791
        sub     edi, [_dy]
2288 clevermous 792
 
793
        mov     [cur.w], ebx
794
        mov     [cur.h], edi
795
        mov     [h], edi
796
 
797
        mov     eax, edi
798
        mov     edi, cur_saved_data
2430 mario79 799
;--------------------------------------
800
align 4
2288 clevermous 801
@@:
802
        mov     esi, edx
5351 serge 803
        add     edx, [_display.lfb_pitch]
2288 clevermous 804
        mov     ecx, [cur.w]
805
        rep movsd
806
        dec     eax
807
        jnz     @B
808
 
809
;draw cursor
810
        mov     ebx, [cur_saved_base]
811
        mov     eax, [_dy]
812
        shl     eax, 5
813
        add     eax, [_dx]
814
 
815
        mov     esi, [hcursor]
9715 Doczom 816
        mov     esi, [esi + CURSOR.base]
2288 clevermous 817
        lea     edx, [esi+eax*4]
2430 mario79 818
;--------------------------------------
819
align 4
2288 clevermous 820
.row:
821
        mov     ecx, [cur.w]
822
        mov     esi, edx
823
        mov     edi, ebx
824
        add     edx, 32*4
5351 serge 825
        add     ebx, [_display.lfb_pitch]
2430 mario79 826
;--------------------------------------
827
align 4
2288 clevermous 828
.pix:
829
        lodsd
830
        test    eax, 0xFF000000
831
        jz      @F
832
        mov     [edi], eax
2430 mario79 833
;--------------------------------------
834
align 4
2288 clevermous 835
@@:
836
        add     edi, 4
837
        dec     ecx
838
        jnz     .pix
839
 
840
        dec     [h]
841
        jnz     .row
842
        ret
843
endp
2430 mario79 844
;------------------------------------------------------------------------------
845
align 4
5154 hidnplayr 846
proc move_cursor_16 stdcall, hcursor:dword, x:dword, y:dword
847
           locals
848
             h      dd ?
849
             _dx     dd ?
850
             _dy     dd ?
851
           endl
852
 
853
        mov     esi, [hcursor]
854
        mov     ecx, [x]
855
        mov     eax, [y]
856
 
857
        xor     edx, edx
9715 Doczom 858
        sub     ecx, [esi + CURSOR.hot_x]
859
        lea     ebx, [ecx + 32-1]
5154 hidnplayr 860
        mov     [x], ecx
861
        sets    dl
862
        dec     edx
863
        and     ecx, edx      ;clip x to 0<=x
864
        mov     [cur.left], ecx
865
        mov     edi, ecx
866
        sub     edi, [x]
867
        mov     [_dx], edi
868
 
869
        xor     edx, edx
9715 Doczom 870
        sub     eax, [esi + CURSOR.hot_y]
871
        lea     edi, [eax + 32-1]
5154 hidnplayr 872
        mov     [y], eax
873
        sets    dl
874
        dec     edx
875
        and     eax, edx      ;clip y to 0<=y
876
        mov     [cur.top], eax
877
        mov     edx, eax
878
        sub     edx, [y]
879
        mov     [_dy], edx
880
 
881
;        mul     dword [BytesPerScanLine]
9715 Doczom 882
        mov     eax, [BPSLine_calc_area + eax*4]
883
        lea     edx, [LFB_BASE + eax + ecx*2]
5154 hidnplayr 884
        mov     [cur_saved_base], edx
885
 
5350 serge 886
        cmp     ebx, [_display.width]
887
        jb      @F
888
        mov     ebx, [_display.width]
5154 hidnplayr 889
;--------------------------------------
890
align 4
891
@@:
5350 serge 892
        cmp     edi, [_display.height]
893
        jb      @F
894
        mov     edi, [_display.height]
5154 hidnplayr 895
;--------------------------------------
896
align 4
897
@@:
898
        sub     ebx, [x]
899
        sub     edi, [y]
900
        sub     ebx, [_dx]
901
        sub     edi, [_dy]
902
 
903
        mov     [cur.w], ebx
904
        mov     [cur.h], edi
905
        mov     [h], edi
906
 
907
        mov     eax, edi
908
        mov     edi, cur_saved_data
909
;--------------------------------------
910
align 4
911
@@:
912
        mov     esi, edx
5351 serge 913
        add     edx, [_display.lfb_pitch]
5154 hidnplayr 914
        mov     ecx, [cur.w]
915
 
916
        rep movsw
917
        dec     eax
918
        jnz     @B
919
 
920
;draw cursor
921
        mov     ebx, [cur_saved_base]
922
        mov     eax, [_dy]
923
        shl     eax, 5
924
        add     eax, [_dx]
925
 
926
        mov     esi, [hcursor]
9715 Doczom 927
        mov     esi, [esi + CURSOR.base]
928
        lea     edx, [esi + eax*4]
5154 hidnplayr 929
;--------------------------------------
930
align 4
931
.row:
932
        mov     ecx, [cur.w]
933
        mov     esi, edx
934
        mov     edi, ebx
935
        add     edx, 32*4
5351 serge 936
        add     ebx, [_display.lfb_pitch]
5154 hidnplayr 937
;--------------------------------------
938
align 4
939
.pix:
940
        lodsd
941
        test    eax, 0xFF000000
942
        jz      @F
943
; convert to 16 bpp and store to real LFB
944
        and     eax, 00000000111110001111110011111000b
945
        shr     ah, 2
946
        shr     ax, 3
947
        ror     eax, 8
948
        add     al, ah
949
        rol     eax, 8
950
        mov     [edi], ax
951
;--------------------------------------
952
align 4
953
@@:
954
        add     edi, 2
955
        dec     ecx
956
        jnz     .pix
957
 
958
        dec     [h]
959
        jnz     .row
960
        ret
961
endp
962
;------------------------------------------------------------------------------
963
align 4
2430 mario79 964
check_mouse_area_for_getpixel_new:
965
; in:
966
; eax = x
967
; ebx = y
968
; out:
969
; ecx = new color
970
;--------------------------------------
971
; check for Y
972
        cmp     bx, [Y_UNDER_subtraction_CUR_hot_y]
973
        jb      .no_mouse_area
2288 clevermous 974
 
2430 mario79 975
        cmp     bx, [Y_UNDER_sub_CUR_hot_y_add_curh]
976
        jae     .no_mouse_area
977
;--------------------------------------
978
; check for X
979
        cmp     ax, [X_UNDER_subtraction_CUR_hot_x]
980
        jb      .no_mouse_area
2288 clevermous 981
 
2430 mario79 982
        cmp     ax, [X_UNDER_sub_CUR_hot_x_add_curh]
983
        jae     .no_mouse_area
984
;--------------------------------------
985
        push    eax ebx
986
; offset X
2575 mario79 987
        movzx   ecx, word [X_UNDER_subtraction_CUR_hot_x]
2430 mario79 988
        sub     eax, ecx        ; x1
989
; offset Y
2575 mario79 990
        movzx   ecx, word [Y_UNDER_subtraction_CUR_hot_y]
2430 mario79 991
        sub     ebx, ecx        ; y1
992
;--------------------------------------
993
; ebx = offset y
994
; eax = offset x
995
        imul    ebx, [cur.w]     ;y
996
        add     eax, ebx
997
        mov     ebx, eax
998
        shl     eax, 2
5154 hidnplayr 999
        cmp     byte [_display.bits_per_pixel], 32
2430 mario79 1000
        je      @f
1001
        sub     eax, ebx
5154 hidnplayr 1002
        cmp     byte [_display.bits_per_pixel], 24
1003
        je      @f
1004
        sub     eax, ebx
7510 hidnplayr 1005
        add     eax, cur_saved_data
1006
        mov     ecx, [eax]
1007
        shl     ecx, 3
1008
        ror     ecx, 8
1009
        shl     cx, 2
1010
        ror     ecx, 8
1011
        shl     cl, 3
1012
        rol     ecx, 16
1013
        or      ecx, 0xff000000
1014
        pop     ebx eax
1015
        ret
1016
 
2430 mario79 1017
;--------------------------------------
2288 clevermous 1018
align 4
2430 mario79 1019
@@:
1020
        add     eax, cur_saved_data
1021
        mov     ecx, [eax]
7510 hidnplayr 1022
        or      ecx, 0xff000000
2430 mario79 1023
        pop     ebx eax
1024
        ret
1025
;--------------------------------------
1026
align 4
1027
.no_mouse_area:
1028
        xor     ecx, ecx
1029
        ret
1030
;-----------------------------------------------------------------------------
1031
align 4
1032
check_mouse_area_for_putpixel_new:
1033
; in:
1034
; ecx = x shl 16 + y
1035
; eax = color
1036
; out:
1037
; eax = new color
1038
;--------------------------------------
1039
; check for Y
1040
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
1041
        jae     .no_mouse_area
1042
 
2575 mario79 1043
        sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
1044
        jb      .no_mouse_area
1045
 
2430 mario79 1046
        rol     ecx, 16
1047
;--------------------------------------
1048
; check for X
2575 mario79 1049
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
1050
        jae     .no_mouse_area
1051
 
1052
        sub     cx, [X_UNDER_subtraction_CUR_hot_x]
2430 mario79 1053
        jb      .no_mouse_area
1054
 
2575 mario79 1055
        ror     ecx, 16
2430 mario79 1056
;--------------------------------------
1057
align 4
1058
.1:
1059
        push    eax
1060
;--------------------------------------
1061
; ecx = (offset x) shl 16 + (offset y)
1062
        push    ebx
1063
        mov     ebx, ecx
1064
        shr     ebx, 16        ; x
1065
        and     ecx, 0xffff    ; y
2575 mario79 1066
 
1067
        cmp     ecx, [cur.h]
1068
        jae     @f
1069
 
1070
        cmp     ebx, [cur.w]
1071
        jb      .ok
1072
;--------------------------------------
1073
align 4
1074
@@:
1075
;        DEBUGF  1, "K : SHIT HAPPENS: %x %x \n", ecx,ebx
1076
        pop     ebx
1077
        jmp     .sh   ; SORRY! SHIT HAPPENS!
1078
;--------------------------------------
1079
align 4
1080
.ok:
2430 mario79 1081
; ecx = offset y
1082
; ebx = offset x
1083
        push    ebx ecx
1084
        imul    ecx, [cur.w]    ;y
1085
        add     ecx, ebx
1086
        mov     ebx, ecx
1087
        shl     ecx, 2
5154 hidnplayr 1088
        cmp     byte [_display.bits_per_pixel], 16
1089
        je      .16
1090
        cmp     byte [_display.bits_per_pixel], 24
2430 mario79 1091
        je      .24
1092
        and     eax, 0xFFFFFF
1093
        mov     [ecx + cur_saved_data], eax   ;store new color  to
1094
        jmp     @f
1095
;--------------------------------------
1096
align 4
5154 hidnplayr 1097
.16:
1098
        sub     ecx, ebx
1099
        sub     ecx, ebx
1100
; convert to 16 bpp and store to real LFB
1101
        and     eax, 00000000111110001111110011111000b
1102
        shr     ah, 2
1103
        shr     ax, 3
1104
        ror     eax, 8
1105
        add     al, ah
1106
        rol     eax, 8
1107
        mov     [ecx + cur_saved_data], ax      ;store new color  to
1108
        jmp     @f
1109
;--------------------------------------
1110
align 4
2430 mario79 1111
.24:
1112
        sub     ecx, ebx
1113
        mov     [ecx + cur_saved_data], ax      ;store new color  to
1114
        shr     eax, 16
1115
        mov     [ecx + cur_saved_data + 2], al  ;store new color  to
1116
;--------------------------------------
1117
align 4
1118
@@:
1119
        pop     ecx ebx
1120
 
1121
        shl     ecx, 5
1122
        add     ecx, ebx
1123
 
1124
        mov     eax, [current_cursor]
9715 Doczom 1125
        mov     eax, [eax + CURSOR.base]
1126
        lea     eax, [eax + ecx*4]
2430 mario79 1127
        mov     eax, [eax]
1128
 
1129
        pop     ebx
1130
 
1131
        test    eax, 0xFF000000
1132
        jz      @f
1133
 
2652 mario79 1134
        add     esp, 4
2430 mario79 1135
        ret
1136
;--------------------------------------
1137
align 4
2575 mario79 1138
.sh:
1139
        mov     ecx, -1
1140
;--------------------------------------
1141
align 4
2430 mario79 1142
@@:
1143
        pop     eax
1144
;--------------------------------------
1145
align 4
1146
.no_mouse_area:
1147
        ret
1148
;------------------------------------------------------------------------------
1149
align 4
2288 clevermous 1150
get_display:
1151
        mov     eax, _display
1152
        ret
2430 mario79 1153
;------------------------------------------------------------------------------
2288 clevermous 1154
align 4
1155
init_display:
1156
        xor     eax, eax
1157
        mov     edi, _display
1158
 
9715 Doczom 1159
        mov     [edi + display_t.init_cursor], eax
1160
        mov     [edi + display_t.select_cursor], eax
1161
        mov     [edi + display_t.show_cursor], eax
1162
        mov     [edi + display_t.move_cursor], eax
1163
        mov     [edi + display_t.restore_cursor], eax
2288 clevermous 1164
 
9715 Doczom 1165
        lea     ecx, [edi + display_t.cr_list.next]
1166
        mov     [edi + display_t.cr_list.next], ecx
1167
        mov     [edi + display_t.cr_list.prev], ecx
2288 clevermous 1168
 
8284 dunkaist 1169
if ~defined UEFI
2288 clevermous 1170
        cmp     [SCR_MODE], word 0x13
1171
        jbe     .fail
1172
 
1173
        test    word [SCR_MODE], 0x4000
1174
        jz      .fail
8284 dunkaist 1175
end if
2288 clevermous 1176
        mov     ebx, restore_32
1177
        mov     ecx, move_cursor_32
3537 Serge 1178
        mov     edx, Vesa20_putpixel32_new
5154 hidnplayr 1179
        mov     eax, [_display.bits_per_pixel]
3537 Serge 1180
        cmp     al, 32
5154 hidnplayr 1181
        jne     .not_32bpp
2288 clevermous 1182
 
3537 Serge 1183
.set:
2288 clevermous 1184
        mov     [_display.select_cursor], select_cursor
1185
        mov     [_display.move_cursor], ecx
1186
        mov     [_display.restore_cursor], ebx
2430 mario79 1187
        mov     [_display.check_mouse], check_mouse_area_for_putpixel_new
1188
        mov     [_display.check_m_pixel], check_mouse_area_for_getpixel_new
2288 clevermous 1189
 
2436 mario79 1190
        cmp     [PUTPIXEL], dword VGA_putpixel
1191
        je      @f
3537 Serge 1192
        mov     [PUTPIXEL], edx
2436 mario79 1193
@@:
9848 rgimad 1194
        stdcall load_cursor, def_hresize, dword LOAD_FROM_MEM
1195
        mov     [def_cursor_hresize], eax
1196
        stdcall load_cursor, def_vresize, dword LOAD_FROM_MEM
1197
        mov     [def_cursor_vresize], eax
1198
        stdcall load_cursor, def_dresize1, dword LOAD_FROM_MEM
1199
        mov     [def_cursor_dresize1], eax
1200
        stdcall load_cursor, def_dresize2, dword LOAD_FROM_MEM
1201
        mov     [def_cursor_dresize2], eax
1202
 
2497 mario79 1203
        stdcall load_cursor, clock_arrow, dword LOAD_FROM_MEM
1204
        mov     [def_cursor_clock], eax
2288 clevermous 1205
        stdcall load_cursor, def_arrow, dword LOAD_FROM_MEM
1206
        mov     [def_cursor], eax
1207
        ret
3537 Serge 1208
 
5154 hidnplayr 1209
.not_32bpp:
1210
        cmp     al, 24
1211
        jne     .not_24bpp
1212
 
3537 Serge 1213
        mov     ebx, restore_24
1214
        mov     ecx, move_cursor_24
1215
        mov     edx, Vesa20_putpixel24_new
5154 hidnplayr 1216
        jmp     .set
3537 Serge 1217
 
5154 hidnplayr 1218
.not_24bpp:
1219
        cmp     al, 16
1220
        jne     .not_16bpp
1221
        mov     ebx, restore_16
1222
        mov     ecx, move_cursor_16
1223
        mov     edx, Vesa20_putpixel16_new
1224
        jmp     .set
1225
 
1226
.not_16bpp:
1227
;        cmp     al, 15
1228
;        jne     .fail
1229
;        mov     ebx, restore_15
1230
;        mov     ecx, move_cursor_15
1231
;        mov     edx, Vesa20_putpixel15_new
1232
;        jmp     .set
1233
 
2288 clevermous 1234
.fail:
1235
        xor     eax, eax
1236
        mov     [_display.select_cursor], eax
1237
        mov     [_display.move_cursor], eax
1238
        ret
2430 mario79 1239
;------------------------------------------------------------------------------
2288 clevermous 1240
align 4
1241
def_arrow:
1242
  file 'arrow.cur'
2430 mario79 1243
;------------------------------------------------------------------------------
2497 mario79 1244
align 4
9848 rgimad 1245
def_hresize:
1246
  file 'hresize.cur'
1247
;------------------------------------------------------------------------------
1248
align 4
1249
def_vresize:
1250
  file 'vresize.cur'
1251
;------------------------------------------------------------------------------
1252
align 4
1253
def_dresize1:
1254
  file 'dresize1.cur'
1255
;------------------------------------------------------------------------------
1256
align 4
1257
def_dresize2:
1258
  file 'dresize2.cur'
1259
;------------------------------------------------------------------------------
1260
align 4
2497 mario79 1261
clock_arrow:
1262
  file 'arrow_clock.cur'
1263
;------------------------------------------------------------------------------
2288 clevermous 1264