Subversion Repositories Kolibri OS

Rev

Rev 5596 | Details | Compare with Previous | Last modification | View Log | RSS feed

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