Subversion Repositories Kolibri OS

Rev

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