Subversion Repositories Kolibri OS

Rev

Rev 3537 | Rev 4181 | 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: 3606 $
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
 
3069 serge 451
;        DEBUGF 1,'K : delete_cursor %x\n', [hcursor]
452
 
2288 clevermous 453
        mov     esi, [hcursor]
3069 serge 454
 
2288 clevermous 455
        cmp     [esi+CURSOR.magic], 'CURS'
456
        jne     .fail
457
 
458
        mov     ebx, [CURRENT_TASK]
459
        shl     ebx, 5
460
        mov     ebx, [CURRENT_TASK+ebx+4]
461
        cmp     ebx, [esi+CURSOR.pid]
462
        jne     .fail
463
 
464
        mov     ebx, [current_slot]
465
        cmp     esi, [ebx+APPDATA.cursor]
466
        jne     @F
467
        mov     eax, [def_cursor]
468
        mov     [ebx+APPDATA.cursor], eax
2430 mario79 469
;--------------------------------------
470
align 4
2288 clevermous 471
@@:
472
        mov     eax, [hcursor]
473
        call    [eax+APPOBJ.destroy]
2430 mario79 474
;--------------------------------------
475
align 4
2288 clevermous 476
.fail:
477
        ret
478
endp
2430 mario79 479
;------------------------------------------------------------------------------
480
align 4
2288 clevermous 481
; param
482
;  eax= cursor
483
destroy_cursor:
484
 
485
        push    eax
486
        stdcall kernel_free, [eax+CURSOR.base]
2337 Serge 487
 
488
        mov     eax, [esp]
489
        lea     eax, [eax+CURSOR.list_next]
490
 
491
        pushfd
492
        cli
493
        list_del eax
494
        popfd
495
 
2288 clevermous 496
        pop     eax
497
        call    destroy_kernel_object
498
        ret
2430 mario79 499
;------------------------------------------------------------------------------
2288 clevermous 500
align 4
501
select_cursor:
502
        mov     eax, [esp+4]
503
        mov     [_display.cursor], eax
504
        ret     4
2430 mario79 505
;------------------------------------------------------------------------------
2288 clevermous 506
align 4
507
proc restore_24 stdcall, x:dword, y:dword
508
 
509
        push    ebx
510
 
511
        mov     ebx, [cur_saved_base]
512
        mov     edx, [cur.h]
513
        test    edx, edx
514
        jz      .ret
515
 
516
        push    esi
517
        push    edi
518
 
519
        mov     esi, cur_saved_data
520
        mov     ecx, [cur.w]
521
        lea     ecx, [ecx+ecx*2]
522
        push    ecx
2430 mario79 523
;--------------------------------------
524
align 4
2288 clevermous 525
@@:
526
        mov     edi, ebx
3606 Serge 527
        add     ebx, [_display.pitch]
2288 clevermous 528
 
529
        mov     ecx, [esp]
530
        rep movsb
531
        dec     edx
532
        jnz     @B
533
 
534
        pop     ecx
535
        pop     edi
536
        pop     esi
2430 mario79 537
;--------------------------------------
538
align 4
2288 clevermous 539
.ret:
540
        pop     ebx
541
        ret
542
endp
2430 mario79 543
;------------------------------------------------------------------------------
2288 clevermous 544
align 4
545
proc restore_32 stdcall, x:dword, y:dword
546
 
547
        push    ebx
548
 
549
        mov     ebx, [cur_saved_base]
550
        mov     edx, [cur.h]
551
        test    edx, edx
552
        jz      .ret
553
 
554
        push    esi
555
        push    edi
556
 
557
        mov     esi, cur_saved_data
2430 mario79 558
;--------------------------------------
559
align 4
2288 clevermous 560
@@:
561
        mov     edi, ebx
3606 Serge 562
        add     ebx, [_display.pitch]
2288 clevermous 563
 
564
        mov     ecx, [cur.w]
565
        rep movsd
566
        dec     edx
567
        jnz     @B
568
 
569
        pop     edi
2430 mario79 570
;--------------------------------------
571
align 4
2288 clevermous 572
.ret:
573
        pop     esi
574
        pop     ebx
575
        ret
576
endp
2430 mario79 577
;------------------------------------------------------------------------------
2288 clevermous 578
align 4
579
proc move_cursor_24 stdcall, hcursor:dword, x:dword, y:dword
580
           locals
581
             h      dd ?
582
             _dx     dd ?
583
             _dy     dd ?
584
           endl
585
 
586
        mov     esi, [hcursor]
587
        mov     ecx, [x]
588
        mov     eax, [y]
2446 mario79 589
;        mov     ebx, [BytesPerScanLine]
2288 clevermous 590
 
591
        xor     edx, edx
592
        sub     ecx, [esi+CURSOR.hot_x]
593
        lea     ebx, [ecx+32-1]
594
        mov     [x], ecx
595
        sets    dl
596
        dec     edx
597
        and     ecx, edx      ;clip x to 0<=x
598
        mov     [cur.left], ecx
599
        mov     edi, ecx
600
        sub     edi, [x]
601
        mov     [_dx], edi
602
 
603
        xor     edx, edx
604
        sub     eax, [esi+CURSOR.hot_y]
605
        lea     edi, [eax+32-1]
606
        mov     [y], eax
607
        sets    dl
608
        dec     edx
609
        and     eax, edx      ;clip y to 0<=y
610
        mov     [cur.top], eax
611
        mov     edx, eax
612
        sub     edx, [y]
613
        mov     [_dy], edx
614
 
2446 mario79 615
;        mul     dword [BytesPerScanLine]
2480 mario79 616
        mov     eax, [BPSLine_calc_area+eax*4]
2288 clevermous 617
        lea     edx, [LFB_BASE+ecx*3]
618
        add     edx, eax
619
        mov     [cur_saved_base], edx
620
 
621
        cmp     ebx, [Screen_Max_X]
622
        jbe     @F
623
        mov     ebx, [Screen_Max_X]
2430 mario79 624
;--------------------------------------
625
align 4
2288 clevermous 626
@@:
627
        cmp     edi, [Screen_Max_Y]
628
        jbe     @F
629
        mov     edi, [Screen_Max_Y]
2430 mario79 630
;--------------------------------------
631
align 4
2288 clevermous 632
@@:
633
        mov     [cur.right], ebx
634
        mov     [cur.bottom], edi
635
 
636
        sub     ebx, [x]
637
        sub     edi, [y]
638
        inc     ebx
639
        inc     edi
2576 mario79 640
        sub     ebx, [_dx]
641
        sub     edi, [_dy]
2288 clevermous 642
 
643
        mov     [cur.w], ebx
644
        mov     [cur.h], edi
645
        mov     [h], edi
646
 
647
        mov     eax, edi
648
        mov     edi, cur_saved_data
2430 mario79 649
;--------------------------------------
650
align 4
2288 clevermous 651
@@:
652
        mov     esi, edx
3606 Serge 653
        add     edx, [_display.pitch]
2288 clevermous 654
        mov     ecx, [cur.w]
655
        lea     ecx, [ecx+ecx*2]
656
        rep movsb
657
        dec     eax
658
        jnz     @B
659
 
660
;draw cursor
661
        mov     ebx, [cur_saved_base]
662
        mov     eax, [_dy]
663
        shl     eax, 5
664
        add     eax, [_dx]
665
 
666
        mov     esi, [hcursor]
667
        mov     esi, [esi+CURSOR.base]
668
        lea     edx, [esi+eax*4]
2430 mario79 669
;--------------------------------------
670
align 4
2288 clevermous 671
.row:
672
        mov     ecx, [cur.w]
673
        mov     esi, edx
674
        mov     edi, ebx
675
        add     edx, 32*4
3606 Serge 676
        add     ebx, [_display.pitch]
2430 mario79 677
;--------------------------------------
678
align 4
2288 clevermous 679
.pix:
680
        lodsd
681
        test    eax, 0xFF000000
682
        jz      @F
683
        mov     [edi], ax
684
        shr     eax, 16
685
        mov     [edi+2], al
2430 mario79 686
;--------------------------------------
687
align 4
2288 clevermous 688
@@:
689
        add     edi, 3
690
        dec     ecx
691
        jnz     .pix
692
 
693
        dec     [h]
694
        jnz     .row
695
        ret
696
endp
2430 mario79 697
;------------------------------------------------------------------------------
2288 clevermous 698
align 4
699
proc move_cursor_32 stdcall, hcursor:dword, x:dword, y:dword
700
           locals
701
             h      dd ?
702
             _dx     dd ?
703
             _dy     dd ?
704
           endl
705
 
706
        mov     esi, [hcursor]
707
        mov     ecx, [x]
708
        mov     eax, [y]
709
 
710
        xor     edx, edx
711
        sub     ecx, [esi+CURSOR.hot_x]
712
        lea     ebx, [ecx+32-1]
713
        mov     [x], ecx
714
        sets    dl
715
        dec     edx
716
        and     ecx, edx      ;clip x to 0<=x
717
        mov     [cur.left], ecx
718
        mov     edi, ecx
719
        sub     edi, [x]
720
        mov     [_dx], edi
721
 
722
        xor     edx, edx
723
        sub     eax, [esi+CURSOR.hot_y]
724
        lea     edi, [eax+32-1]
725
        mov     [y], eax
726
        sets    dl
727
        dec     edx
728
        and     eax, edx      ;clip y to 0<=y
729
        mov     [cur.top], eax
730
        mov     edx, eax
731
        sub     edx, [y]
732
        mov     [_dy], edx
733
 
2446 mario79 734
;        mul     dword [BytesPerScanLine]
2480 mario79 735
        mov     eax, [BPSLine_calc_area+eax*4]
2288 clevermous 736
        lea     edx, [LFB_BASE+eax+ecx*4]
737
        mov     [cur_saved_base], edx
738
 
739
        cmp     ebx, [Screen_Max_X]
740
        jbe     @F
741
        mov     ebx, [Screen_Max_X]
2430 mario79 742
;--------------------------------------
743
align 4
2288 clevermous 744
@@:
745
        cmp     edi, [Screen_Max_Y]
746
        jbe     @F
747
        mov     edi, [Screen_Max_Y]
2430 mario79 748
;--------------------------------------
749
align 4
2288 clevermous 750
@@:
751
        mov     [cur.right], ebx
752
        mov     [cur.bottom], edi
753
 
754
        sub     ebx, [x]
755
        sub     edi, [y]
756
        inc     ebx
757
        inc     edi
2576 mario79 758
        sub     ebx, [_dx]
759
        sub     edi, [_dy]
2288 clevermous 760
 
761
        mov     [cur.w], ebx
762
        mov     [cur.h], edi
763
        mov     [h], edi
764
 
765
        mov     eax, edi
766
        mov     edi, cur_saved_data
2430 mario79 767
;--------------------------------------
768
align 4
2288 clevermous 769
@@:
770
        mov     esi, edx
3606 Serge 771
        add     edx, [_display.pitch]
2288 clevermous 772
        mov     ecx, [cur.w]
773
        rep movsd
774
        dec     eax
775
        jnz     @B
776
 
777
;draw cursor
778
        mov     ebx, [cur_saved_base]
779
        mov     eax, [_dy]
780
        shl     eax, 5
781
        add     eax, [_dx]
782
 
783
        mov     esi, [hcursor]
784
        mov     esi, [esi+CURSOR.base]
785
        lea     edx, [esi+eax*4]
2430 mario79 786
;--------------------------------------
787
align 4
2288 clevermous 788
.row:
789
        mov     ecx, [cur.w]
790
        mov     esi, edx
791
        mov     edi, ebx
792
        add     edx, 32*4
3606 Serge 793
        add     ebx, [_display.pitch]
2430 mario79 794
;--------------------------------------
795
align 4
2288 clevermous 796
.pix:
797
        lodsd
798
        test    eax, 0xFF000000
799
        jz      @F
800
        mov     [edi], eax
2430 mario79 801
;--------------------------------------
802
align 4
2288 clevermous 803
@@:
804
        add     edi, 4
805
        dec     ecx
806
        jnz     .pix
807
 
808
        dec     [h]
809
        jnz     .row
810
        ret
811
endp
2430 mario79 812
;------------------------------------------------------------------------------
813
align 4
814
check_mouse_area_for_getpixel_new:
815
; in:
816
; eax = x
817
; ebx = y
818
; out:
819
; ecx = new color
820
;--------------------------------------
821
; check for Y
822
        cmp     bx, [Y_UNDER_subtraction_CUR_hot_y]
823
        jb      .no_mouse_area
2288 clevermous 824
 
2430 mario79 825
        cmp     bx, [Y_UNDER_sub_CUR_hot_y_add_curh]
826
        jae     .no_mouse_area
827
;--------------------------------------
828
; check for X
829
        cmp     ax, [X_UNDER_subtraction_CUR_hot_x]
830
        jb      .no_mouse_area
2288 clevermous 831
 
2430 mario79 832
        cmp     ax, [X_UNDER_sub_CUR_hot_x_add_curh]
833
        jae     .no_mouse_area
834
;--------------------------------------
835
        push    eax ebx
836
; offset X
2575 mario79 837
        movzx   ecx, word [X_UNDER_subtraction_CUR_hot_x]
2430 mario79 838
        sub     eax, ecx        ; x1
839
; offset Y
2575 mario79 840
        movzx   ecx, word [Y_UNDER_subtraction_CUR_hot_y]
2430 mario79 841
        sub     ebx, ecx        ; y1
842
;--------------------------------------
843
; ebx = offset y
844
; eax = offset x
845
        imul    ebx, [cur.w]     ;y
846
        add     eax, ebx
847
        mov     ebx, eax
848
        shl     eax, 2
3537 Serge 849
        cmp     byte [_display.bpp], 32
2430 mario79 850
        je      @f
851
        sub     eax, ebx
852
;--------------------------------------
2288 clevermous 853
align 4
2430 mario79 854
@@:
855
        add     eax, cur_saved_data
856
        mov     ecx, [eax]
857
        and     ecx, 0xffffff
858
        add     ecx, 0xff000000
859
        pop     ebx eax
860
        ret
861
;--------------------------------------
862
align 4
863
.no_mouse_area:
864
        xor     ecx, ecx
865
        ret
866
;-----------------------------------------------------------------------------
867
align 4
868
check_mouse_area_for_putpixel_new:
869
; in:
870
; ecx = x shl 16 + y
871
; eax = color
872
; out:
873
; eax = new color
874
;--------------------------------------
875
; check for Y
876
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
877
        jae     .no_mouse_area
878
 
2575 mario79 879
        sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
880
        jb      .no_mouse_area
881
 
2430 mario79 882
        rol     ecx, 16
883
;--------------------------------------
884
; check for X
2575 mario79 885
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
886
        jae     .no_mouse_area
887
 
888
        sub     cx, [X_UNDER_subtraction_CUR_hot_x]
2430 mario79 889
        jb      .no_mouse_area
890
 
2575 mario79 891
        ror     ecx, 16
2430 mario79 892
;--------------------------------------
893
align 4
894
.1:
895
        push    eax
896
;--------------------------------------
897
; ecx = (offset x) shl 16 + (offset y)
898
        push    ebx
899
        mov     ebx, ecx
900
        shr     ebx, 16        ; x
901
        and     ecx, 0xffff    ; y
2575 mario79 902
 
903
        cmp     ecx, [cur.h]
904
        jae     @f
905
 
906
        cmp     ebx, [cur.w]
907
        jb      .ok
908
;--------------------------------------
909
align 4
910
@@:
911
;        DEBUGF  1, "K : SHIT HAPPENS: %x %x \n", ecx,ebx
912
        pop     ebx
913
        jmp     .sh   ; SORRY! SHIT HAPPENS!
914
;--------------------------------------
915
align 4
916
.ok:
2430 mario79 917
; ecx = offset y
918
; ebx = offset x
919
        push    ebx ecx
920
        imul    ecx, [cur.w]    ;y
921
        add     ecx, ebx
922
        mov     ebx, ecx
923
        shl     ecx, 2
3537 Serge 924
        cmp     byte [_display.bpp], 24
2430 mario79 925
        je      .24
926
        and     eax, 0xFFFFFF
927
        mov     [ecx + cur_saved_data], eax   ;store new color  to
928
        jmp     @f
929
;--------------------------------------
930
align 4
931
.24:
932
        sub     ecx, ebx
933
        mov     [ecx + cur_saved_data], ax      ;store new color  to
934
        shr     eax, 16
935
        mov     [ecx + cur_saved_data + 2], al  ;store new color  to
936
;--------------------------------------
937
align 4
938
@@:
939
        pop     ecx ebx
940
 
941
        shl     ecx, 5
942
        add     ecx, ebx
943
 
944
        mov     eax, [current_cursor]
945
        mov     eax, [eax+CURSOR.base]
946
        lea     eax, [eax+ecx*4]
947
        mov     eax, [eax]
948
 
949
        pop     ebx
950
 
951
        test    eax, 0xFF000000
952
        jz      @f
953
 
2652 mario79 954
        add     esp, 4
2430 mario79 955
        ret
956
;--------------------------------------
957
align 4
2575 mario79 958
.sh:
959
        mov     ecx, -1
960
;--------------------------------------
961
align 4
2430 mario79 962
@@:
963
        pop     eax
964
;--------------------------------------
965
align 4
966
.no_mouse_area:
967
        ret
968
;------------------------------------------------------------------------------
969
align 4
2288 clevermous 970
get_display:
971
        mov     eax, _display
972
        ret
2430 mario79 973
;------------------------------------------------------------------------------
2288 clevermous 974
align 4
975
init_display:
976
        xor     eax, eax
977
        mov     edi, _display
978
 
979
        mov     [edi+display_t.init_cursor], eax
980
        mov     [edi+display_t.select_cursor], eax
981
        mov     [edi+display_t.show_cursor], eax
982
        mov     [edi+display_t.move_cursor], eax
983
        mov     [edi+display_t.restore_cursor], eax
984
 
985
        lea     ecx, [edi+display_t.cr_list.next]
986
        mov     [edi+display_t.cr_list.next], ecx
987
        mov     [edi+display_t.cr_list.prev], ecx
988
 
989
        cmp     [SCR_MODE], word 0x13
990
        jbe     .fail
991
 
992
        test    word [SCR_MODE], 0x4000
993
        jz      .fail
994
 
995
        mov     ebx, restore_32
996
        mov     ecx, move_cursor_32
3537 Serge 997
        mov     edx, Vesa20_putpixel32_new
998
        mov     eax, [_display.bpp]
999
        cmp     al, 32
1000
        jne     .24
2288 clevermous 1001
 
3537 Serge 1002
.set:
2288 clevermous 1003
        mov     [_display.select_cursor], select_cursor
1004
        mov     [_display.move_cursor], ecx
1005
        mov     [_display.restore_cursor], ebx
2430 mario79 1006
        mov     [_display.check_mouse], check_mouse_area_for_putpixel_new
1007
        mov     [_display.check_m_pixel], check_mouse_area_for_getpixel_new
2288 clevermous 1008
 
2436 mario79 1009
        cmp     [PUTPIXEL], dword VGA_putpixel
1010
        je      @f
3537 Serge 1011
        mov     [PUTPIXEL], edx
2436 mario79 1012
@@:
2497 mario79 1013
        stdcall load_cursor, clock_arrow, dword LOAD_FROM_MEM
1014
        mov     [def_cursor_clock], eax
2288 clevermous 1015
        stdcall load_cursor, def_arrow, dword LOAD_FROM_MEM
1016
        mov     [def_cursor], eax
1017
        ret
3537 Serge 1018
 
1019
.24:
1020
        mov     ebx, restore_24
1021
        mov     ecx, move_cursor_24
1022
        mov     edx, Vesa20_putpixel24_new
1023
        cmp     al, 24
1024
        je      .set
1025
 
2288 clevermous 1026
.fail:
1027
        xor     eax, eax
1028
        mov     [_display.select_cursor], eax
1029
        mov     [_display.move_cursor], eax
1030
        ret
2430 mario79 1031
;------------------------------------------------------------------------------
2288 clevermous 1032
align 4
1033
def_arrow:
1034
  file 'arrow.cur'
2430 mario79 1035
;------------------------------------------------------------------------------
2497 mario79 1036
align 4
1037
clock_arrow:
1038
  file 'arrow_clock.cur'
1039
;------------------------------------------------------------------------------
2288 clevermous 1040