Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
2288 clevermous 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2455 mario79 3
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
2288 clevermous 4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
 
8
$Revision: 2483 $
9
 
10
 
11
LOAD_FROM_FILE  equ 0
12
LOAD_FROM_MEM   equ 1
13
LOAD_INDIRECT   equ 2
14
LOAD_SYSTEM     equ 3
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
 
2384 hidnplayr 46
        cmp     [esi+BITMAPINFOHEADER.BitCount], 24
2288 clevermous 47
        je      .img_24
2384 hidnplayr 48
        cmp     [esi+BITMAPINFOHEADER.BitCount], 8
2288 clevermous 49
        je      .img_8
2384 hidnplayr 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
93
        mov     ecx, [esi+ecx*4]
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
150
        mov     ecx, [esi+ecx]
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
163
        mov     ecx, [esi+ecx*4]
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]
218
        mov     ecx, [esi+ecx*4]
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
2384 hidnplayr 243
        mov     eax, [esi+BITMAPINFOHEADER.Width]
2288 clevermous 244
        mov     [width], eax
2384 hidnplayr 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]
292
        cmp     [eax+CURSOR.magic], 'CURS'
293
        jne     .fail
294
;           cmp [eax+CURSOR.size], CURSOR_SIZE
295
;           jne .fail
296
        mov     ebx, [current_slot]
297
        xchg    eax, [ebx+APPDATA.cursor]
298
        ret
2430 mario79 299
;--------------------------------------
300
align 4
2288 clevermous 301
.fail:
302
        mov     eax, [def_cursor]
303
        mov     ebx, [current_slot]
304
        xchg    eax, [ebx+APPDATA.cursor]
305
        ret
306
endp
2430 mario79 307
;------------------------------------------------------------------------------
308
align 4
2288 clevermous 309
; param
310
;  eax= pid
311
;  ebx= src
312
;  ecx= flags
313
 
314
create_cursor:
315
.src     equ esp
316
.flags   equ esp+4
317
.hcursor equ esp+8
318
 
319
        sub     esp, 4         ;space for .hcursor
320
        push    ecx
321
        push    ebx
322
 
323
        mov     ebx, eax
2384 hidnplayr 324
        mov     eax, sizeof.CURSOR
2288 clevermous 325
        call    create_kernel_object
326
        test    eax, eax
327
        jz      .fail
328
 
329
        mov     [.hcursor], eax
330
 
331
        xor     ebx, ebx
332
        mov     [eax+CURSOR.magic], 'CURS'
333
        mov     [eax+CURSOR.destroy], destroy_cursor
334
        mov     [eax+CURSOR.hot_x], ebx
335
        mov     [eax+CURSOR.hot_y], ebx
336
 
337
        stdcall kernel_alloc, 0x1000
338
        test    eax, eax
339
        jz      .fail
340
 
341
        mov     edi, [.hcursor]
342
        mov     [edi+CURSOR.base], eax
343
 
344
        mov     esi, [.src]
345
        mov     ebx, [.flags]
346
        cmp     bx, LOAD_INDIRECT
347
        je      .indirect
348
 
349
        movzx   ecx, word [esi+10]
350
        movzx   edx, word [esi+12]
351
        mov     [edi+CURSOR.hot_x], ecx
352
        mov     [edi+CURSOR.hot_y], edx
353
 
354
        stdcall init_cursor, eax, esi
355
 
2473 Serge 356
align 4
357
.add_cursor:
2337 Serge 358
        mov     ecx, [.hcursor]
359
        lea     ecx, [ecx+CURSOR.list_next]
2288 clevermous 360
        lea     edx, [_display.cr_list.next]
361
 
362
        pushfd
363
        cli
2337 Serge 364
        list_add ecx, edx   ;list_add_tail(new, head)
2288 clevermous 365
        popfd
366
 
367
        mov     eax, [.hcursor]
368
        cmp     [_display.init_cursor], 0
369
        je      .fail
370
 
371
        push    eax
372
        call    [_display.init_cursor]
373
        add     esp, 4
374
 
375
        mov     eax, [.hcursor]
2430 mario79 376
;--------------------------------------
377
align 4
2288 clevermous 378
.fail:
379
        add     esp, 12
380
        ret
2430 mario79 381
;--------------------------------------
382
align 4
2288 clevermous 383
.indirect:
384
        shr     ebx, 16
385
        movzx   ecx, bh
386
        movzx   edx, bl
2483 mario79 387
        mov     [edi+CURSOR.hot_x], ecx
388
        mov     [edi+CURSOR.hot_y], edx
2288 clevermous 389
 
390
        xchg    edi, eax
391
        mov     ecx, 1024
392
        cld
393
        rep movsd
2473 Serge 394
        jmp     .add_cursor
2430 mario79 395
;------------------------------------------------------------------------------
2288 clevermous 396
align 4
397
proc load_cursor stdcall, src:dword, flags:dword
398
           locals
399
             handle  dd ?
400
           endl
401
 
402
        xor     eax, eax
403
        cmp     [create_cursor], eax
404
        je      .fail2
405
 
406
        mov     [handle], eax
407
        cmp     word [flags], LOAD_FROM_FILE
408
        jne     @F
409
 
410
        stdcall load_file, [src]
411
        test    eax, eax
412
        jz      .fail
413
        mov     [src], eax
2430 mario79 414
;--------------------------------------
415
align 4
2288 clevermous 416
@@:
417
        push    ebx
418
        push    esi
419
        push    edi
420
 
421
        mov     eax, [CURRENT_TASK]
422
        shl     eax, 5
423
        mov     eax, [CURRENT_TASK+eax+4]
424
        mov     ebx, [src]
425
        mov     ecx, [flags]
426
        call    create_cursor    ;eax, ebx, ecx
427
        mov     [handle], eax
428
 
429
        cmp     word [flags], LOAD_FROM_FILE
430
        jne     .exit
431
        stdcall kernel_free, [src]
2430 mario79 432
;--------------------------------------
433
align 4
2288 clevermous 434
.exit:
435
        pop     edi
436
        pop     esi
437
        pop     ebx
2430 mario79 438
;--------------------------------------
439
align 4
2288 clevermous 440
.fail:
441
        mov     eax, [handle]
2430 mario79 442
;--------------------------------------
443
align 4
2288 clevermous 444
.fail2:
445
        ret
446
endp
2430 mario79 447
;------------------------------------------------------------------------------
2288 clevermous 448
align 4
449
proc delete_cursor stdcall, hcursor:dword
450
           locals
451
             hsrv       dd ?
452
             io_code    dd ?
453
             input      dd ?
454
             inp_size   dd ?
455
             output     dd ?
456
             out_size   dd ?
457
           endl
458
 
459
        mov     esi, [hcursor]
460
        cmp     [esi+CURSOR.magic], 'CURS'
461
        jne     .fail
462
 
463
        mov     ebx, [CURRENT_TASK]
464
        shl     ebx, 5
465
        mov     ebx, [CURRENT_TASK+ebx+4]
466
        cmp     ebx, [esi+CURSOR.pid]
467
        jne     .fail
468
 
469
        mov     ebx, [current_slot]
470
        cmp     esi, [ebx+APPDATA.cursor]
471
        jne     @F
472
        mov     eax, [def_cursor]
473
        mov     [ebx+APPDATA.cursor], eax
2430 mario79 474
;--------------------------------------
475
align 4
2288 clevermous 476
@@:
477
        mov     eax, [hcursor]
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
491
        stdcall kernel_free, [eax+CURSOR.base]
2337 Serge 492
 
493
        mov     eax, [esp]
494
        lea     eax, [eax+CURSOR.list_next]
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:
507
        mov     eax, [esp+4]
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]
526
        lea     ecx, [ecx+ecx*2]
527
        push    ecx
2430 mario79 528
;--------------------------------------
529
align 4
2288 clevermous 530
@@:
531
        mov     edi, ebx
532
        add     ebx, [BytesPerScanLine]
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
567
        add     ebx, [BytesPerScanLine]
568
 
569
        mov     ecx, [cur.w]
570
        rep movsd
571
        dec     edx
572
        jnz     @B
573
 
574
        pop     edi
2430 mario79 575
;--------------------------------------
576
align 4
2288 clevermous 577
.ret:
578
        pop     esi
579
        pop     ebx
580
        ret
581
endp
2430 mario79 582
;------------------------------------------------------------------------------
2288 clevermous 583
align 4
584
proc move_cursor_24 stdcall, hcursor:dword, x:dword, y:dword
585
           locals
586
             h      dd ?
587
             _dx     dd ?
588
             _dy     dd ?
589
           endl
590
 
591
        mov     esi, [hcursor]
592
        mov     ecx, [x]
593
        mov     eax, [y]
2446 mario79 594
;        mov     ebx, [BytesPerScanLine]
2288 clevermous 595
 
596
        xor     edx, edx
597
        sub     ecx, [esi+CURSOR.hot_x]
598
        lea     ebx, [ecx+32-1]
599
        mov     [x], ecx
600
        sets    dl
601
        dec     edx
602
        and     ecx, edx      ;clip x to 0<=x
603
        mov     [cur.left], ecx
604
        mov     edi, ecx
605
        sub     edi, [x]
606
        mov     [_dx], edi
607
 
608
        xor     edx, edx
609
        sub     eax, [esi+CURSOR.hot_y]
610
        lea     edi, [eax+32-1]
611
        mov     [y], eax
612
        sets    dl
613
        dec     edx
614
        and     eax, edx      ;clip y to 0<=y
615
        mov     [cur.top], eax
616
        mov     edx, eax
617
        sub     edx, [y]
618
        mov     [_dy], edx
619
 
2446 mario79 620
;        mul     dword [BytesPerScanLine]
2480 mario79 621
        mov     eax, [BPSLine_calc_area+eax*4]
2288 clevermous 622
        lea     edx, [LFB_BASE+ecx*3]
623
        add     edx, eax
624
        mov     [cur_saved_base], edx
625
 
626
        cmp     ebx, [Screen_Max_X]
627
        jbe     @F
628
        mov     ebx, [Screen_Max_X]
2430 mario79 629
;--------------------------------------
630
align 4
2288 clevermous 631
@@:
632
        cmp     edi, [Screen_Max_Y]
633
        jbe     @F
634
        mov     edi, [Screen_Max_Y]
2430 mario79 635
;--------------------------------------
636
align 4
2288 clevermous 637
@@:
638
        mov     [cur.right], ebx
639
        mov     [cur.bottom], edi
640
 
641
        sub     ebx, [x]
642
        sub     edi, [y]
643
        inc     ebx
644
        inc     edi
645
 
646
        mov     [cur.w], ebx
647
        mov     [cur.h], edi
648
        mov     [h], edi
649
 
650
        mov     eax, edi
651
        mov     edi, cur_saved_data
2430 mario79 652
;--------------------------------------
653
align 4
2288 clevermous 654
@@:
655
        mov     esi, edx
656
        add     edx, [BytesPerScanLine]
657
        mov     ecx, [cur.w]
658
        lea     ecx, [ecx+ecx*2]
659
        rep movsb
660
        dec     eax
661
        jnz     @B
662
 
663
;draw cursor
664
        mov     ebx, [cur_saved_base]
665
        mov     eax, [_dy]
666
        shl     eax, 5
667
        add     eax, [_dx]
668
 
669
        mov     esi, [hcursor]
670
        mov     esi, [esi+CURSOR.base]
671
        lea     edx, [esi+eax*4]
2430 mario79 672
;--------------------------------------
673
align 4
2288 clevermous 674
.row:
675
        mov     ecx, [cur.w]
676
        mov     esi, edx
677
        mov     edi, ebx
678
        add     edx, 32*4
679
        add     ebx, [BytesPerScanLine]
2430 mario79 680
;--------------------------------------
681
align 4
2288 clevermous 682
.pix:
683
        lodsd
684
        test    eax, 0xFF000000
685
        jz      @F
686
        mov     [edi], ax
687
        shr     eax, 16
688
        mov     [edi+2], al
2430 mario79 689
;--------------------------------------
690
align 4
2288 clevermous 691
@@:
692
        add     edi, 3
693
        dec     ecx
694
        jnz     .pix
695
 
696
        dec     [h]
697
        jnz     .row
698
        ret
699
endp
2430 mario79 700
;------------------------------------------------------------------------------
2288 clevermous 701
align 4
702
proc move_cursor_32 stdcall, hcursor:dword, x:dword, y:dword
703
           locals
704
             h      dd ?
705
             _dx     dd ?
706
             _dy     dd ?
707
           endl
708
 
709
        mov     esi, [hcursor]
710
        mov     ecx, [x]
711
        mov     eax, [y]
712
 
713
        xor     edx, edx
714
        sub     ecx, [esi+CURSOR.hot_x]
715
        lea     ebx, [ecx+32-1]
716
        mov     [x], ecx
717
        sets    dl
718
        dec     edx
719
        and     ecx, edx      ;clip x to 0<=x
720
        mov     [cur.left], ecx
721
        mov     edi, ecx
722
        sub     edi, [x]
723
        mov     [_dx], edi
724
 
725
        xor     edx, edx
726
        sub     eax, [esi+CURSOR.hot_y]
727
        lea     edi, [eax+32-1]
728
        mov     [y], eax
729
        sets    dl
730
        dec     edx
731
        and     eax, edx      ;clip y to 0<=y
732
        mov     [cur.top], eax
733
        mov     edx, eax
734
        sub     edx, [y]
735
        mov     [_dy], edx
736
 
2446 mario79 737
;        mul     dword [BytesPerScanLine]
2480 mario79 738
        mov     eax, [BPSLine_calc_area+eax*4]
2288 clevermous 739
        lea     edx, [LFB_BASE+eax+ecx*4]
740
        mov     [cur_saved_base], edx
741
 
742
        cmp     ebx, [Screen_Max_X]
743
        jbe     @F
744
        mov     ebx, [Screen_Max_X]
2430 mario79 745
;--------------------------------------
746
align 4
2288 clevermous 747
@@:
748
        cmp     edi, [Screen_Max_Y]
749
        jbe     @F
750
        mov     edi, [Screen_Max_Y]
2430 mario79 751
;--------------------------------------
752
align 4
2288 clevermous 753
@@:
754
        mov     [cur.right], ebx
755
        mov     [cur.bottom], edi
756
 
757
        sub     ebx, [x]
758
        sub     edi, [y]
759
        inc     ebx
760
        inc     edi
761
 
762
        mov     [cur.w], ebx
763
        mov     [cur.h], edi
764
        mov     [h], edi
765
 
766
        mov     eax, edi
767
        mov     edi, cur_saved_data
2430 mario79 768
;--------------------------------------
769
align 4
2288 clevermous 770
@@:
771
        mov     esi, edx
772
        add     edx, [BytesPerScanLine]
773
        mov     ecx, [cur.w]
774
        rep movsd
775
        dec     eax
776
        jnz     @B
777
 
778
;draw cursor
779
        mov     ebx, [cur_saved_base]
780
        mov     eax, [_dy]
781
        shl     eax, 5
782
        add     eax, [_dx]
783
 
784
        mov     esi, [hcursor]
785
        mov     esi, [esi+CURSOR.base]
786
        lea     edx, [esi+eax*4]
2430 mario79 787
;--------------------------------------
788
align 4
2288 clevermous 789
.row:
790
        mov     ecx, [cur.w]
791
        mov     esi, edx
792
        mov     edi, ebx
793
        add     edx, 32*4
794
        add     ebx, [BytesPerScanLine]
2430 mario79 795
;--------------------------------------
796
align 4
2288 clevermous 797
.pix:
798
        lodsd
799
        test    eax, 0xFF000000
800
        jz      @F
801
        mov     [edi], eax
2430 mario79 802
;--------------------------------------
803
align 4
2288 clevermous 804
@@:
805
        add     edi, 4
806
        dec     ecx
807
        jnz     .pix
808
 
809
        dec     [h]
810
        jnz     .row
811
        ret
812
endp
2430 mario79 813
;------------------------------------------------------------------------------
814
align 4
815
check_mouse_area_for_getpixel_new:
816
; in:
817
; eax = x
818
; ebx = y
819
; out:
820
; ecx = new color
821
;--------------------------------------
822
; check for Y
823
        cmp     bx, [Y_UNDER_subtraction_CUR_hot_y]
824
        jb      .no_mouse_area
2288 clevermous 825
 
2430 mario79 826
        cmp     bx, [Y_UNDER_sub_CUR_hot_y_add_curh]
827
        jae     .no_mouse_area
828
;--------------------------------------
829
; check for X
830
        cmp     ax, [X_UNDER_subtraction_CUR_hot_x]
831
        jb      .no_mouse_area
2288 clevermous 832
 
2430 mario79 833
        cmp     ax, [X_UNDER_sub_CUR_hot_x_add_curh]
834
        jae     .no_mouse_area
835
;--------------------------------------
836
        push    eax ebx
837
; offset X
838
        mov     ecx, [X_UNDER_subtraction_CUR_hot_x]
839
        sub     eax, ecx        ; x1
840
; offset Y
841
        mov     ecx, [Y_UNDER_subtraction_CUR_hot_y]
842
        sub     ebx, ecx        ; y1
843
;--------------------------------------
844
; ebx = offset y
845
; eax = offset x
846
        imul    ebx, [cur.w]     ;y
847
        add     eax, ebx
848
        mov     ebx, eax
849
        shl     eax, 2
850
        cmp     [ScreenBPP], byte 32
851
        je      @f
852
        sub     eax, ebx
853
;--------------------------------------
2288 clevermous 854
align 4
2430 mario79 855
@@:
856
        add     eax, cur_saved_data
857
        mov     ecx, [eax]
858
        and     ecx, 0xffffff
859
        add     ecx, 0xff000000
860
        pop     ebx eax
861
        ret
862
;--------------------------------------
863
align 4
864
.no_mouse_area:
865
        xor     ecx, ecx
866
        ret
867
;-----------------------------------------------------------------------------
868
align 4
869
check_mouse_area_for_putpixel_new:
870
; in:
871
; ecx = x shl 16 + y
872
; eax = color
873
; out:
874
; eax = new color
875
;--------------------------------------
876
; check for Y
877
        cmp     cx, [Y_UNDER_subtraction_CUR_hot_y]
878
        jb      .no_mouse_area
879
 
880
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
881
        jae     .no_mouse_area
882
 
883
        rol     ecx, 16
884
;--------------------------------------
885
; check for X
886
        cmp     cx, [X_UNDER_subtraction_CUR_hot_x]
887
        jb      .no_mouse_area
888
 
889
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
890
        jae     .no_mouse_area
891
;--------------------------------------
892
align 4
893
.1:
894
        push    eax
895
; offset X
896
        mov     ax, [X_UNDER_subtraction_CUR_hot_x]
897
        sub     cx, ax        ; x1
898
        ror     ecx, 16
899
; offset Y
900
        mov     ax, [Y_UNDER_subtraction_CUR_hot_y]
901
        sub     cx, ax        ; y1
902
;--------------------------------------
903
; ecx = (offset x) shl 16 + (offset y)
904
        push    ebx
905
        mov     ebx, ecx
906
        shr     ebx, 16        ; x
907
        and     ecx, 0xffff    ; y
908
; ecx = offset y
909
; ebx = offset x
910
        mov     eax, [esp + 4]
911
 
912
        push    ebx ecx
913
        imul    ecx, [cur.w]    ;y
914
        add     ecx, ebx
915
        mov     ebx, ecx
916
        shl     ecx, 2
917
        cmp     [ScreenBPP], byte 24
918
        je      .24
919
        and     eax, 0xFFFFFF
920
        mov     [ecx + cur_saved_data], eax   ;store new color  to
921
        jmp     @f
922
;--------------------------------------
923
align 4
924
.24:
925
        sub     ecx, ebx
926
        mov     [ecx + cur_saved_data], ax      ;store new color  to
927
        shr     eax, 16
928
        mov     [ecx + cur_saved_data + 2], al  ;store new color  to
929
;--------------------------------------
930
align 4
931
@@:
932
        pop     ecx ebx
933
 
934
        shl     ecx, 5
935
        add     ecx, ebx
936
 
937
        mov     eax, [current_cursor]
938
        mov     eax, [eax+CURSOR.base]
939
        lea     eax, [eax+ecx*4]
940
        mov     eax, [eax]
941
 
942
        pop     ebx
943
 
944
        test    eax, 0xFF000000
945
        jz      @f
946
 
947
        pop     ecx
948
        ret
949
;--------------------------------------
950
align 4
951
@@:
952
        pop     eax
953
;--------------------------------------
954
align 4
955
.no_mouse_area:
956
        ret
957
;------------------------------------------------------------------------------
958
align 4
2288 clevermous 959
get_display:
960
        mov     eax, _display
961
        ret
2430 mario79 962
;------------------------------------------------------------------------------
2288 clevermous 963
align 4
964
init_display:
965
        xor     eax, eax
966
        mov     edi, _display
967
 
968
        mov     [edi+display_t.init_cursor], eax
969
        mov     [edi+display_t.select_cursor], eax
970
        mov     [edi+display_t.show_cursor], eax
971
        mov     [edi+display_t.move_cursor], eax
972
        mov     [edi+display_t.restore_cursor], eax
973
 
974
        lea     ecx, [edi+display_t.cr_list.next]
975
        mov     [edi+display_t.cr_list.next], ecx
976
        mov     [edi+display_t.cr_list.prev], ecx
977
 
978
        cmp     [SCR_MODE], word 0x13
979
        jbe     .fail
980
 
981
        test    word [SCR_MODE], 0x4000
982
        jz      .fail
2430 mario79 983
;        jmp      .fail
2288 clevermous 984
 
985
        mov     ebx, restore_32
986
        mov     ecx, move_cursor_32
987
        movzx   eax, byte [ScreenBPP]
988
        cmp     eax, 32
989
        je      @F
990
 
991
        mov     ebx, restore_24
992
        mov     ecx, move_cursor_24
993
        cmp     eax, 24
994
        jne     .fail
2430 mario79 995
;--------------------------------------
996
align 4
2288 clevermous 997
@@:
998
        mov     [_display.select_cursor], select_cursor
999
        mov     [_display.move_cursor], ecx
1000
        mov     [_display.restore_cursor], ebx
2430 mario79 1001
        mov     [_display.check_mouse], check_mouse_area_for_putpixel_new
1002
        mov     [_display.check_m_pixel], check_mouse_area_for_getpixel_new
2288 clevermous 1003
 
2436 mario79 1004
        cmp     [PUTPIXEL], dword VGA_putpixel
1005
        je      @f
1006
        cmp     [ScreenBPP], byte 32
1007
        je      .32
1008
        mov     [PUTPIXEL], dword Vesa20_putpixel24_new
1009
        jmp     @f
1010
;--------------------------------------
1011
align 4
1012
.32:
1013
        mov     [PUTPIXEL], dword Vesa20_putpixel32_new
1014
;--------------------------------------
1015
align 4
1016
@@:
2288 clevermous 1017
        stdcall load_cursor, def_arrow, dword LOAD_FROM_MEM
1018
        mov     [def_cursor], eax
1019
        ret
2430 mario79 1020
;--------------------------------------
1021
align 4
2288 clevermous 1022
.fail:
1023
        xor     eax, eax
1024
        mov     [_display.select_cursor], eax
1025
        mov     [_display.move_cursor], eax
1026
        ret
2430 mario79 1027
;------------------------------------------------------------------------------
2288 clevermous 1028
align 4
1029
def_arrow:
1030
  file 'arrow.cur'
2430 mario79 1031
;------------------------------------------------------------------------------
2288 clevermous 1032