Subversion Repositories Kolibri OS

Rev

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