Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
4429 Serge 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
6
;;  VESA20.INC                                                  ;;
7
;;                                                              ;;
8
;;  Vesa 2.0 functions for MenuetOS                             ;;
9
;;                                                              ;;
10
;;  Copyright 2002 Ville Turjanmaa                              ;;
11
;;  Alexey, kgaz@crosswindws.net                                ;;
12
;;  - Voodoo compatible graphics                                ;;
13
;;  Juan M. Caravaca                                            ;;
14
;;  - Graphics optimimizations eg. drawline                     ;;
15
;;                                                              ;;
16
;;  See file COPYING for details                                ;;
17
;;                                                              ;;
18
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
19
 
20
$Revision: 3606 $
21
 
22
 
23
; If you're planning to write your own video driver I suggest
24
; you replace the VESA12.INC file and see those instructions.
25
 
26
 
27
;-----------------------------------------------------------------------------
28
; getpixel
29
;
30
; in:
31
; eax = x coordinate
32
; ebx = y coordinate
33
;
34
; ret:
35
; ecx = 00 RR GG BB
36
;-----------------------------------------------------------------------------
37
align 4
38
getpixel:
39
        push    eax ebx edx edi
40
        call    dword [GETPIXEL]
41
        pop     edi edx ebx eax
42
        ret
43
;-----------------------------------------------------------------------------
44
align 4
45
Vesa20_getpixel24:
46
; eax = x
47
; ebx = y
48
;--------------------------------------
49
; check for hardware cursor
50
        cmp     [_display.select_cursor], select_cursor
51
        je      @f
52
        cmp     [_display.select_cursor], 0
53
        jne     .no_mouseunder
54
;--------------------------------------
55
align 4
56
@@:
57
; check mouse area for putpixel
58
        test    ecx, 0x04000000  ; don't load to mouseunder area
59
        jnz     .no_mouseunder
60
        call    [_display.check_m_pixel]
61
        test    ecx, ecx        ;0xff000000
62
        jnz     @f
63
;--------------------------------------
64
align 4
65
.no_mouseunder:
66
;--------------------------------------
67
;        imul    ebx, [BytesPerScanLine] ; ebx = y * y multiplier
68
        mov     ebx, [BPSLine_calc_area+ebx*4]
69
        lea     edi, [eax+eax*2]; edi = x*3
70
        add     edi, ebx      ; edi = x*3+(y*y multiplier)
71
        mov     ecx, [LFB_BASE+edi]
72
;--------------------------------------
73
align 4
74
@@:
75
        and     ecx, 0xffffff
76
        ret
77
;-----------------------------------------------------------------------------
78
align 4
79
Vesa20_getpixel32:
80
;--------------------------------------
81
; check for hardware cursor
82
        cmp     [_display.select_cursor], select_cursor
83
        je      @f
84
        cmp     [_display.select_cursor], 0
85
        jne     .no_mouseunder
86
;--------------------------------------
87
align 4
88
@@:
89
; check mouse area for putpixel
90
        test    ecx, 0x04000000  ; don't load to mouseunder area
91
        jnz     .no_mouseunder
92
        call    [_display.check_m_pixel]
93
        test    ecx, ecx        ;0xff000000
94
        jnz     @f
95
;--------------------------------------
96
align 4
97
.no_mouseunder:
98
;--------------------------------------
99
;        imul    ebx, [BytesPerScanLine] ; ebx = y * y multiplier
100
        mov     ebx, [BPSLine_calc_area+ebx*4]
101
        lea     edi, [ebx+eax*4]; edi = x*4+(y*y multiplier)
102
        mov     ecx, [LFB_BASE+edi]
103
;--------------------------------------
104
align 4
105
@@:
106
        and     ecx, 0xffffff
107
        ret
108
;-----------------------------------------------------------------------------
109
virtual at esp
110
 putimg:
111
   .real_sx        dd ?
112
   .real_sy        dd ?
113
   .image_sx       dd ?
114
   .image_sy       dd ?
115
   .image_cx       dd ?
116
   .image_cy       dd ?
117
   .pti            dd ?
118
   .abs_cx         dd ?
119
   .abs_cy         dd ?
120
   .line_increment dd ?
121
   .winmap_newline dd ?
122
   .screen_newline dd ?
123
   .real_sx_and_abs_cx dd ?
124
   .real_sy_and_abs_cy dd ?
125
   .stack_data = 4*14
126
   .edi         dd      ?
127
   .esi         dd      ?
128
   .ebp         dd      ?
129
   .esp         dd      ?
130
   .ebx         dd      ?
131
   .edx         dd      ?
132
   .ecx         dd      ?
133
   .eax         dd      ?
134
   .ret_addr    dd      ?
135
   .arg_0       dd      ?
136
end virtual
137
;-----------------------------------------------------------------------------
138
align 16
139
; ebx = pointer
140
; ecx = size [x|y]
141
; edx = coordinates [x|y]
142
; ebp = pointer to 'get' function
143
; esi = pointer to 'init' function
144
; edi = parameter for 'get' function
145
vesa20_putimage:
146
        pushad
147
        sub     esp, putimg.stack_data
148
; save pointer to image
149
        mov     [putimg.pti], ebx
150
; unpack the size
151
        mov     eax, ecx
152
        and     ecx, 0xFFFF
153
        shr     eax, 16
154
        mov     [putimg.image_sx], eax
155
        mov     [putimg.image_sy], ecx
156
; unpack the coordinates
157
        mov     eax, edx
158
        and     edx, 0xFFFF
159
        shr     eax, 16
160
        mov     [putimg.image_cx], eax
161
        mov     [putimg.image_cy], edx
162
; calculate absolute (i.e. screen) coordinates
163
        mov     eax, [TASK_BASE]
164
        mov     ebx, [eax-twdw + WDATA.box.left]
165
        add     ebx, [putimg.image_cx]
166
        mov     [putimg.abs_cx], ebx
167
        mov     ebx, [eax-twdw + WDATA.box.top]
168
        add     ebx, [putimg.image_cy]
169
        mov     [putimg.abs_cy], ebx
170
; real_sx = MIN(wnd_sx-image_cx, image_sx);
171
        mov     ebx, [eax-twdw + WDATA.box.width]; ebx = wnd_sx
172
; \begin{diamond}[20.08.2006]
173
; note that WDATA.box.width is one pixel less than real window x-size
174
        inc     ebx
175
; \end{diamond}[20.08.2006]
176
        sub     ebx, [putimg.image_cx]
177
        ja      @f
178
        add     esp, putimg.stack_data
179
        popad
180
        ret
181
;--------------------------------------
182
align 4
183
@@:
184
        cmp     ebx, [putimg.image_sx]
185
        jbe     .end_x
186
        mov     ebx, [putimg.image_sx]
187
;--------------------------------------
188
align 4
189
.end_x:
190
        mov     [putimg.real_sx], ebx
191
; init real_sy
192
        mov     ebx, [eax-twdw + WDATA.box.height]; ebx = wnd_sy
193
; \begin{diamond}[20.08.2006]
194
        inc     ebx
195
; \end{diamond}[20.08.2006]
196
        sub     ebx, [putimg.image_cy]
197
        ja      @f
198
        add     esp, putimg.stack_data
199
        popad
200
        ret
201
;--------------------------------------
202
align 4
203
@@:
204
        cmp     ebx, [putimg.image_sy]
205
        jbe     .end_y
206
        mov     ebx, [putimg.image_sy]
207
;--------------------------------------
208
align 4
209
.end_y:
210
        mov     [putimg.real_sy], ebx
211
; line increment
212
        mov     eax, [putimg.image_sx]
213
        mov     ecx, [putimg.real_sx]
214
        sub     eax, ecx
215
;;     imul    eax, [putimg.source_bpp]
216
;     lea     eax, [eax + eax * 2]
217
        call    esi
218
        add     eax, [putimg.arg_0]
219
        mov     [putimg.line_increment], eax
220
; winmap new line increment
221
        mov     eax, [Screen_Max_X]
222
        inc     eax
223
        sub     eax, [putimg.real_sx]
224
        mov     [putimg.winmap_newline], eax
225
; screen new line increment
226
        mov     eax, [_display.pitch]
227
        mov     ebx, [_display.bpp]
228
        shr     ebx, 3
229
        imul    ecx, ebx
230
        sub     eax, ecx
231
        mov     [putimg.screen_newline], eax
232
; pointer to image
233
        mov     esi, [putimg.pti]
234
; pointer to screen
235
        mov     edx, [putimg.abs_cy]
236
;        imul    edx, [BytesPerScanLine]
237
        mov     edx, [BPSLine_calc_area+edx*4]
238
        mov     eax, [putimg.abs_cx]
239
;        movzx   ebx, byte [ScreenBPP]
240
;        shr     ebx, 3
241
        imul    eax, ebx
242
        add     edx, eax
243
; pointer to pixel map
244
        mov     eax, [putimg.abs_cy]
245
        mov     eax, [d_width_calc_area + eax*4]
246
 
247
        add     eax, [putimg.abs_cx]
248
        add     eax, [_WinMapAddress]
249
        xchg    eax, ebp
250
;--------------------------------------
251
        mov     ecx, [putimg.real_sx]
252
        add     ecx, [putimg.abs_cx]
253
        mov     [putimg.real_sx_and_abs_cx], ecx
254
        mov     ecx, [putimg.real_sy]
255
        add     ecx, [putimg.abs_cy]
256
        mov     [putimg.real_sy_and_abs_cy], ecx
257
;--------------------------------------
258
; get process number
259
        mov     ebx, [CURRENT_TASK]
260
        cmp     byte [_display.bpp], 32
261
        je      put_image_end_32
262
;--------------------------------------
263
put_image_end_24:
264
        mov     edi, [putimg.real_sy]
265
;--------------------------------------
266
; check for hardware cursor
267
        mov     ecx, [_display.select_cursor]
268
        cmp     ecx, select_cursor
269
        je      put_image_end_24_new
270
        cmp     ecx, 0
271
        je      put_image_end_24_old
272
;--------------------------------------
273
align 4
274
.new_line:
275
        mov     ecx, [putimg.real_sx]
276
;--------------------------------------
277
align 4
278
.new_x:
279
        push    [putimg.edi]
280
        mov     eax, [putimg.ebp+4]
281
        call    eax
282
        cmp     [ebp], bl
283
        jne     .skip
284
;--------------------------------------
285
; store to real LFB
286
        mov     [LFB_BASE+edx], ax
287
        shr     eax, 16
288
        mov     [LFB_BASE+edx+2], al
289
;--------------------------------------
290
align 4
291
.skip:
292
        add     edx, 3
293
        inc     ebp
294
        dec     ecx
295
        jnz     .new_x
296
 
297
        add     esi, [putimg.line_increment]
298
        add     edx, [putimg.screen_newline];[BytesPerScanLine]
299
        add     ebp, [putimg.winmap_newline];[Screen_Max_X]
300
 
301
        cmp     [putimg.ebp], putimage_get1bpp
302
        jz      .correct
303
        cmp     [putimg.ebp], putimage_get2bpp
304
        jz      .correct
305
        cmp     [putimg.ebp], putimage_get4bpp
306
        jnz     @f
307
;--------------------------------------
308
align 4
309
.correct:
310
        mov     eax, [putimg.edi]
311
        mov     byte [eax], 80h
312
;--------------------------------------
313
align 4
314
@@:
315
        dec     edi
316
        jnz     .new_line
317
;--------------------------------------
318
align 4
319
.finish:
320
        add     esp, putimg.stack_data
321
        popad
322
        ret
323
;------------------------------------------------------------------------------
324
align 4
325
put_image_end_24_old:
326
;--------------------------------------
327
align 4
328
.new_line:
329
        mov     ecx, [putimg.real_sx]
330
;--------------------------------------
331
align 4
332
.new_x:
333
        push    [putimg.edi]
334
        mov     eax, [putimg.ebp+4]
335
        call    eax
336
        cmp     [ebp], bl
337
        jne     .skip
338
;--------------------------------------
339
        push    ecx
340
 
341
        neg     ecx
342
        add     ecx, [putimg.real_sx_and_abs_cx + 4]
343
        shl     ecx, 16
344
        add     ecx, [putimg.real_sy_and_abs_cy + 4]
345
        sub     ecx, edi
346
 
347
; check mouse area for putpixel
348
        call    check_mouse_area_for_putpixel
349
        pop     ecx
350
; store to real LFB
351
        mov     [LFB_BASE+edx], ax
352
        shr     eax, 16
353
        mov     [LFB_BASE+edx+2], al
354
;--------------------------------------
355
align 4
356
.skip:
357
        add     edx, 3
358
        inc     ebp
359
        dec     ecx
360
        jnz     .new_x
361
 
362
        add     esi, [putimg.line_increment]
363
        add     edx, [putimg.screen_newline];[BytesPerScanLine]
364
        add     ebp, [putimg.winmap_newline];[Screen_Max_X]
365
 
366
        cmp     [putimg.ebp], putimage_get1bpp
367
        jz      .correct
368
        cmp     [putimg.ebp], putimage_get2bpp
369
        jz      .correct
370
        cmp     [putimg.ebp], putimage_get4bpp
371
        jnz     @f
372
;--------------------------------------
373
align 4
374
.correct:
375
        mov     eax, [putimg.edi]
376
        mov     byte [eax], 80h
377
;--------------------------------------
378
align 4
379
@@:
380
        dec     edi
381
        jnz     .new_line
382
        jmp     put_image_end_24.finish
383
;------------------------------------------------------------------------------
384
align 4
385
put_image_end_24_new:
386
;--------------------------------------
387
align 4
388
.new_line:
389
        mov     ecx, [putimg.real_sx]
390
;--------------------------------------
391
align 4
392
.new_x:
393
        push    [putimg.edi]
394
        mov     eax, [putimg.ebp+4]
395
        call    eax
396
        cmp     [ebp], bl
397
        jne     .skip
398
;--------------------------------------
399
        push    ecx
400
;--------------------------------------
401
align 4
402
.sh:
403
        neg     ecx
404
        add     ecx, [putimg.real_sx_and_abs_cx + 4]
405
;--------------------------------------
406
; check for X
407
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
408
        jae     .no_mouse_area
409
 
410
        sub     cx, [X_UNDER_subtraction_CUR_hot_x]
411
        jb      .no_mouse_area
412
 
413
        shl     ecx, 16
414
 
415
        add     ecx, [putimg.real_sy_and_abs_cy + 4]
416
        sub     ecx, edi
417
;--------------------------------------
418
; check for Y
419
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
420
        jae     .no_mouse_area
421
 
422
        sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
423
        jb      .no_mouse_area
424
;--------------------------------------
425
; check mouse area for putpixel
426
        call    check_mouse_area_for_putpixel_new.1
427
        cmp     ecx, -1   ;SHIT HAPPENS?
428
        jne     .no_mouse_area
429
 
430
        mov     ecx, [esp]
431
        jmp     .sh
432
;--------------------------------------
433
align 4
434
.no_mouse_area:
435
        pop     ecx
436
; store to real LFB
437
        mov     [LFB_BASE+edx], ax
438
        shr     eax, 16
439
        mov     [LFB_BASE+edx+2], al
440
;--------------------------------------
441
align 4
442
.skip:
443
        add     edx, 3
444
        inc     ebp
445
        dec     ecx
446
        jnz     .new_x
447
 
448
        add     esi, [putimg.line_increment]
449
        add     edx, [putimg.screen_newline];[BytesPerScanLine]
450
        add     ebp, [putimg.winmap_newline];[Screen_Max_X]
451
 
452
        cmp     [putimg.ebp], putimage_get1bpp
453
        jz      .correct
454
        cmp     [putimg.ebp], putimage_get2bpp
455
        jz      .correct
456
        cmp     [putimg.ebp], putimage_get4bpp
457
        jnz     @f
458
;--------------------------------------
459
align 4
460
.correct:
461
        mov     eax, [putimg.edi]
462
        mov     byte [eax], 80h
463
;--------------------------------------
464
align 4
465
@@:
466
        dec     edi
467
        jnz     .new_line
468
        jmp     put_image_end_24.finish
469
;------------------------------------------------------------------------------
470
align 4
471
put_image_end_32:
472
        mov     edi, [putimg.real_sy]
473
;--------------------------------------
474
; check for hardware cursor
475
        mov     ecx, [_display.select_cursor]
476
        cmp     ecx, select_cursor
477
        je      put_image_end_32_new
478
        cmp     ecx, 0
479
        je      put_image_end_32_old
480
;--------------------------------------
481
align 4
482
.new_line:
483
        mov     ecx, [putimg.real_sx]
484
;--------------------------------------
485
align 4
486
.new_x:
487
        push    [putimg.edi]
488
        mov     eax, [putimg.ebp+4]
489
        call    eax
490
        cmp     [ebp], bl
491
        jne     .skip
492
;--------------------------------------
493
; store to real LFB
494
        mov     [LFB_BASE+edx], eax
495
;--------------------------------------
496
align 4
497
.skip:
498
        add     edx, 4
499
        inc     ebp
500
        dec     ecx
501
        jnz     .new_x
502
 
503
        add     esi, [putimg.line_increment]
504
        add     edx, [putimg.screen_newline];[BytesPerScanLine]
505
        add     ebp, [putimg.winmap_newline];[Screen_Max_X]
506
 
507
        cmp     [putimg.ebp], putimage_get1bpp
508
        jz      .correct
509
        cmp     [putimg.ebp], putimage_get2bpp
510
        jz      .correct
511
        cmp     [putimg.ebp], putimage_get4bpp
512
        jnz     @f
513
;--------------------------------------
514
align 4
515
.correct:
516
        mov     eax, [putimg.edi]
517
        mov     byte [eax], 80h
518
;--------------------------------------
519
align 4
520
@@:
521
        dec     edi
522
        jnz     .new_line
523
;--------------------------------------
524
align 4
525
.finish:
526
        add     esp, putimg.stack_data
527
        popad
528
        cmp     [SCR_MODE], 0x12
529
        jne     @f
530
        call    VGA__putimage
531
;--------------------------------------
532
align 4
533
@@:
534
        mov     [EGA_counter], 1
535
        ret
536
;------------------------------------------------------------------------------
537
align 4
538
put_image_end_32_old:
539
;--------------------------------------
540
align 4
541
.new_line:
542
        mov     ecx, [putimg.real_sx]
543
;--------------------------------------
544
align 4
545
.new_x:
546
        push    [putimg.edi]
547
        mov     eax, [putimg.ebp+4]
548
        call    eax
549
        cmp     [ebp], bl
550
        jne     .skip
551
;--------------------------------------
552
        push    ecx
553
 
554
        neg     ecx
555
        add     ecx, [putimg.real_sx_and_abs_cx + 4]
556
        shl     ecx, 16
557
        add     ecx, [putimg.real_sy_and_abs_cy + 4]
558
        sub     ecx, edi
559
 
560
; check mouse area for putpixel
561
        call    check_mouse_area_for_putpixel
562
        pop     ecx
563
; store to real LFB
564
        mov     [LFB_BASE+edx], eax
565
;--------------------------------------
566
align 4
567
.skip:
568
        add     edx, 4
569
        inc     ebp
570
        dec     ecx
571
        jnz     .new_x
572
 
573
        add     esi, [putimg.line_increment]
574
        add     edx, [putimg.screen_newline];[BytesPerScanLine]
575
        add     ebp, [putimg.winmap_newline];[Screen_Max_X]
576
 
577
        cmp     [putimg.ebp], putimage_get1bpp
578
        jz      .correct
579
        cmp     [putimg.ebp], putimage_get2bpp
580
        jz      .correct
581
        cmp     [putimg.ebp], putimage_get4bpp
582
        jnz     @f
583
;--------------------------------------
584
align 4
585
.correct:
586
        mov     eax, [putimg.edi]
587
        mov     byte [eax], 80h
588
;--------------------------------------
589
align 4
590
@@:
591
        dec     edi
592
        jnz     .new_line
593
        jmp     put_image_end_32.finish
594
;------------------------------------------------------------------------------
595
align 4
596
put_image_end_32_new:
597
;--------------------------------------
598
align 4
599
.new_line:
600
        mov     ecx, [putimg.real_sx]
601
;--------------------------------------
602
align 4
603
.new_x:
604
        push    [putimg.edi]
605
        mov     eax, [putimg.ebp+4]
606
        call    eax
607
        cmp     [ebp], bl
608
        jne     .skip
609
;--------------------------------------
610
        push    ecx
611
;--------------------------------------
612
align 4
613
.sh:
614
        neg     ecx
615
        add     ecx, [putimg.real_sx_and_abs_cx + 4]
616
;--------------------------------------
617
; check for X
618
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
619
        jae     .no_mouse_area
620
 
621
        sub     cx, [X_UNDER_subtraction_CUR_hot_x]
622
        jb      .no_mouse_area
623
 
624
        shl     ecx, 16
625
 
626
        add     ecx, [putimg.real_sy_and_abs_cy + 4]
627
        sub     ecx, edi
628
;--------------------------------------
629
; check for Y
630
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
631
        jae     .no_mouse_area
632
 
633
        sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
634
        jb      .no_mouse_area
635
;--------------------------------------
636
; check mouse area for putpixel
637
        call    check_mouse_area_for_putpixel_new.1
638
        cmp     ecx, -1   ;SHIT HAPPENS?
639
        jne     .no_mouse_area
640
 
641
        mov     ecx, [esp]
642
        jmp     .sh
643
;--------------------------------------
644
align 4
645
.no_mouse_area:
646
        pop     ecx
647
; store to real LFB
648
        mov     [LFB_BASE+edx], eax
649
;--------------------------------------
650
align 4
651
.skip:
652
        add     edx, 4
653
        inc     ebp
654
        dec     ecx
655
        jnz     .new_x
656
 
657
        add     esi, [putimg.line_increment]
658
        add     edx, [putimg.screen_newline];[BytesPerScanLine]
659
        add     ebp, [putimg.winmap_newline];[Screen_Max_X]
660
 
661
        cmp     [putimg.ebp], putimage_get1bpp
662
        jz      .correct
663
        cmp     [putimg.ebp], putimage_get2bpp
664
        jz      .correct
665
        cmp     [putimg.ebp], putimage_get4bpp
666
        jnz     @f
667
;--------------------------------------
668
align 4
669
.correct:
670
        mov     eax, [putimg.edi]
671
        mov     byte [eax], 80h
672
;--------------------------------------
673
align 4
674
@@:
675
        dec     edi
676
        jnz     .new_line
677
        jmp     put_image_end_32.finish
678
;------------------------------------------------------------------------------
679
align 4
680
__sys_putpixel:
681
 
682
; eax = x coordinate
683
; ebx = y coordinate
684
; ecx = ?? RR GG BB    ; 0x01000000 negation
685
                       ; 0x02000000 used for draw_rectangle without top line
686
                       ;            for example drawwindow_III and drawwindow_IV
687
; edi = 0x00000001 force
688
 
689
        pushad
690
        cmp     [Screen_Max_X], eax
691
        jb      .exit
692
        cmp     [Screen_Max_Y], ebx
693
        jb      .exit
694
        test    edi, 1           ; force ?
695
        jnz     .forced
696
 
697
; not forced:
698
        mov     edx, [d_width_calc_area + ebx*4]
699
        add     edx, [_WinMapAddress]
700
        movzx   edx, byte [eax+edx]
701
        cmp     edx, [CURRENT_TASK]
702
        jne     .exit
703
;--------------------------------------
704
align 4
705
.forced:
706
; check if negation
707
        test    ecx, 0x01000000
708
        jz      .noneg
709
 
710
        call    getpixel
711
        not     ecx
712
 
713
        rol     ecx, 8
714
        mov     cl, [esp+32-8+3]
715
        ror     ecx, 8
716
        mov     [esp+32-8], ecx
717
;--------------------------------------
718
align 4
719
.noneg:
720
; OK to set pixel
721
        call    dword [PUTPIXEL]; call the real put_pixel function
722
;--------------------------------------
723
align 4
724
.exit:
725
        popad
726
        ret
727
;-----------------------------------------------------------------------------
728
align 4
729
Vesa20_putpixel24:
730
; eax = x
731
; ebx = y
732
        mov     ecx, eax
733
        shl     ecx, 16
734
        mov     cx, bx
735
 
736
;        imul    ebx, [BytesPerScanLine]  ; ebx = y * y multiplier
737
        mov     ebx, [BPSLine_calc_area+ebx*4]
738
        lea     edi, [eax+eax*2]; edi = x*3
739
        mov     eax, [esp+32-8+4]
740
;--------------------------------------
741
; check for hardware cursor
742
        cmp     [_display.select_cursor], 0
743
        jne     @f
744
; check mouse area for putpixel
745
        test    eax, 0x04000000
746
        jnz     @f
747
        call    check_mouse_area_for_putpixel
748
;--------------------------------------
749
align 4
750
@@:
751
; store to real LFB
752
        mov     [LFB_BASE+ebx+edi], ax
753
        shr     eax, 16
754
        mov     [LFB_BASE+ebx+edi+2], al
755
        ret
756
;-----------------------------------------------------------------------------
757
align 4
758
Vesa20_putpixel24_new:
759
; eax = x
760
; ebx = y
761
        mov     ecx, eax
762
        shl     ecx, 16
763
        mov     cx, bx
764
 
765
;        imul    ebx, [BytesPerScanLine]  ; ebx = y * y multiplier
766
        mov     ebx, [BPSLine_calc_area+ebx*4]
767
        lea     edi, [eax+eax*2]; edi = x*3
768
        mov     eax, [esp+32-8+4]
769
;--------------------------------------
770
; check for hardware cursor
771
        cmp     [_display.select_cursor], select_cursor
772
        jne     @f
773
; check mouse area for putpixel
774
        test    eax, 0x04000000
775
        jnz     @f
776
;--------------------------------------
777
; check for Y
778
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
779
        jae     @f
780
 
781
        sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
782
        jb      @f
783
 
784
        rol     ecx, 16
785
;--------------------------------------
786
; check for X
787
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
788
        jae     @f
789
 
790
        sub     cx, [X_UNDER_subtraction_CUR_hot_x]
791
        jb      @f
792
 
793
        ror     ecx, 16
794
 
795
        call    check_mouse_area_for_putpixel_new.1
796
;--------------------------------------
797
align 4
798
@@:
799
; store to real LFB
800
        mov     [LFB_BASE+ebx+edi], ax
801
        shr     eax, 16
802
        mov     [LFB_BASE+ebx+edi+2], al
803
        ret
804
;-----------------------------------------------------------------------------
805
align 4
806
Vesa20_putpixel32:
807
; eax = x
808
; ebx = y
809
        mov     ecx, eax
810
        shl     ecx, 16
811
        mov     cx, bx
812
 
813
;        imul    ebx, [BytesPerScanLine]  ; ebx = y * y multiplier
814
        mov     ebx, [BPSLine_calc_area+ebx*4]
815
        lea     edi, [ebx+eax*4]; edi = x*4+(y*y multiplier)
816
        mov     eax, [esp+32-8+4]; eax = color
817
;--------------------------------------
818
; check for hardware cursor
819
        cmp     [_display.select_cursor], 0
820
        jne     @f
821
; check mouse area for putpixel
822
        test    eax, 0x04000000
823
        jnz     @f
824
        call    check_mouse_area_for_putpixel
825
;--------------------------------------
826
align 4
827
@@:
828
        and     eax, 0xffffff
829
; store to real LFB
830
        mov     [LFB_BASE+edi], eax
831
        ret
832
;-----------------------------------------------------------------------------
833
align 4
834
Vesa20_putpixel32_new:
835
; eax = x
836
; ebx = y
837
        mov     ecx, eax
838
        shl     ecx, 16
839
        mov     cx, bx
840
 
841
;        imul    ebx, [BytesPerScanLine]  ; ebx = y * y multiplier
842
        mov     ebx, [BPSLine_calc_area+ebx*4]
843
        lea     edi, [ebx+eax*4]; edi = x*4+(y*y multiplier)
844
        mov     eax, [esp+32-8+4]; eax = color
845
;--------------------------------------
846
; check for hardware cursor
847
        cmp     [_display.select_cursor], select_cursor
848
        jne     @f
849
; check mouse area for putpixel
850
        test    eax, 0x04000000
851
        jnz     @f
852
;--------------------------------------
853
; check for Y
854
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
855
        jae     @f
856
 
857
        sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
858
        jb      @f
859
 
860
        rol     ecx, 16
861
;--------------------------------------
862
; check for X
863
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
864
        jae     @f
865
 
866
        sub     cx, [X_UNDER_subtraction_CUR_hot_x]
867
        jb      @f
868
 
869
        ror     ecx, 16
870
 
871
        call    check_mouse_area_for_putpixel_new.1
872
;--------------------------------------
873
align 4
874
@@:
875
        and     eax, 0xffffff
876
; store to real LFB
877
        mov     [LFB_BASE+edi], eax
878
        ret
879
;-----------------------------------------------------------------------------
880
align 4
881
calculate_edi:
882
        mov     edi, [d_width_calc_area + ebx*4]
883
        add     edi, eax
884
        ret
885
;-----------------------------------------------------------------------------
886
; DRAWLINE
887
;-----------------------------------------------------------------------------
888
align 4
889
__sys_draw_line:
890
; draw a line
891
; eax = HIWORD = x1
892
;       LOWORD = x2
893
; ebx = HIWORD = y1
894
;       LOWORD = y2
895
; ecx = color
896
; edi = force ?
897
        pusha
898
 
899
dl_x1 equ esp+20
900
dl_y1 equ esp+16
901
dl_x2 equ esp+12
902
dl_y2 equ esp+8
903
dl_dx equ esp+4
904
dl_dy equ esp+0
905
 
906
        xor     edx, edx   ; clear edx
907
        xor     esi, esi   ; unpack arguments
908
        xor     ebp, ebp
909
        mov     si, ax     ; esi = x2
910
        mov     bp, bx     ; ebp = y2
911
        shr     eax, 16    ; eax = x1
912
        shr     ebx, 16    ; ebx = y1
913
        push    eax        ; save x1
914
        push    ebx        ; save y1
915
        push    esi        ; save x2
916
        push    ebp        ; save y2
917
; checking x-axis...
918
        sub     esi, eax   ; esi = x2-x1
919
        push    esi        ; save y2-y1
920
        jl      .x2lx1     ; is x2 less than x1 ?
921
        jg      .no_vline  ; x1 > x2 ?
922
        mov     edx, ebp   ; else (if x1=x2)
923
        call    vline
924
        push    edx ; necessary to rightly restore stack frame at .exit
925
        jmp     .exit
926
;--------------------------------------
927
align 4
928
.x2lx1:
929
        neg     esi         ; get esi absolute value
930
;--------------------------------------
931
align 4
932
.no_vline:
933
; checking y-axis...
934
        sub     ebp, ebx    ; ebp = y2-y1
935
        push    ebp         ; save y2-y1
936
        jl      .y2ly1      ; is y2 less than y1 ?
937
        jg      .no_hline   ; y1 > y2 ?
938
        mov     edx, [dl_x2]; else (if y1=y2)
939
        call    hline
940
        jmp     .exit
941
;--------------------------------------
942
align 4
943
.y2ly1:
944
        neg     ebp         ; get ebp absolute value
945
;--------------------------------------
946
align 4
947
.no_hline:
948
        cmp     ebp, esi
949
        jle     .x_rules    ; |y2-y1| < |x2-x1|  ?
950
        cmp     [dl_y2], ebx; make sure y1 is at the begining
951
        jge     .no_reverse1
952
        neg     dword [dl_dx]
953
        mov     edx, [dl_x2]
954
        mov     [dl_x2], eax
955
        mov     [dl_x1], edx
956
        mov     edx, [dl_y2]
957
        mov     [dl_y2], ebx
958
        mov     [dl_y1], edx
959
;--------------------------------------
960
align 4
961
.no_reverse1:
962
        mov     eax, [dl_dx]
963
        cdq                 ; extend eax sing to edx
964
        shl     eax, 16     ; using 16bit fix-point maths
965
        idiv    ebp         ; eax = ((x2-x1)*65536)/(y2-y1)
966
;--------------------------------------
967
; correction for the remainder of the division
968
        shl     edx, 1
969
        cmp     ebp, edx
970
        jb      @f
971
        inc     eax
972
;--------------------------------------
973
align 4
974
@@:
975
;--------------------------------------
976
        mov     edx, ebp    ; edx = counter (number of pixels to draw)
977
        mov     ebp, 1 *65536; <<16   ; ebp = dy = 1.0
978
        mov     esi, eax    ; esi = dx
979
        jmp     .y_rules
980
;--------------------------------------
981
align 4
982
.x_rules:
983
        cmp     [dl_x2], eax ; make sure x1 is at the begining
984
        jge     .no_reverse2
985
        neg     dword [dl_dy]
986
        mov     edx, [dl_x2]
987
        mov     [dl_x2], eax
988
        mov     [dl_x1], edx
989
        mov     edx, [dl_y2]
990
        mov     [dl_y2], ebx
991
        mov     [dl_y1], edx
992
;--------------------------------------
993
align 4
994
.no_reverse2:
995
        xor     edx, edx
996
        mov     eax, [dl_dy]
997
        cdq                 ; extend eax sing to edx
998
        shl     eax, 16     ; using 16bit fix-point maths
999
        idiv    esi         ; eax = ((y2-y1)*65536)/(x2-x1)
1000
;--------------------------------------
1001
; correction for the remainder of the division
1002
        shl     edx, 1
1003
        cmp     esi, edx
1004
        jb      @f
1005
        inc     eax
1006
;--------------------------------------
1007
align 4
1008
@@:
1009
;--------------------------------------
1010
        mov     edx, esi    ; edx = counter (number of pixels to draw)
1011
        mov     esi, 1 *65536;<< 16   ; esi = dx = 1.0
1012
        mov     ebp, eax    ; ebp = dy
1013
;--------------------------------------
1014
align 4
1015
.y_rules:
1016
        mov     eax, [dl_x1]
1017
        mov     ebx, [dl_y1]
1018
        shl     eax, 16
1019
        shl     ebx, 16
1020
 
1021
        and     ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area
1022
;-----------------------------------------------------------------------------
1023
align 4
1024
.draw:
1025
        push    eax ebx
1026
;--------------------------------------
1027
; correction for the remainder of the division
1028
        test    ah, 0x80
1029
        jz      @f
1030
        add     eax, 1 shl 16
1031
;--------------------------------------
1032
align 4
1033
@@:
1034
;--------------------------------------
1035
        shr     eax, 16
1036
;--------------------------------------
1037
; correction for the remainder of the division
1038
        test    bh, 0x80
1039
        jz      @f
1040
        add     ebx, 1 shl 16
1041
;--------------------------------------
1042
align 4
1043
@@:
1044
;--------------------------------------
1045
        shr     ebx, 16
1046
;        and     ecx, 0xFBFFFFFF  ;negate 0x04000000 save to mouseunder area
1047
;        call    [putpixel]
1048
        call    __sys_putpixel
1049
        pop     ebx eax
1050
        add     ebx, ebp     ; y = y+dy
1051
        add     eax, esi     ; x = x+dx
1052
        dec     edx
1053
        jnz     .draw
1054
; force last drawn pixel to be at (x2,y2)
1055
        mov     eax, [dl_x2]
1056
        mov     ebx, [dl_y2]
1057
;        and     ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area
1058
;        call    [putpixel]
1059
        call    __sys_putpixel
1060
;--------------------------------------
1061
align 4
1062
.exit:
1063
        add     esp, 6*4
1064
        popa
1065
;        call    [draw_pointer]
1066
        ret
1067
;------------------------------------------------------------------------------
1068
align 4
1069
hline:
1070
; draw an horizontal line
1071
; eax = x1
1072
; edx = x2
1073
; ebx = y
1074
; ecx = color
1075
; edi = force ?
1076
        push    eax edx
1077
        cmp     edx, eax   ; make sure x2 is above x1
1078
        jge     @f
1079
        xchg    eax, edx
1080
;--------------------------------------
1081
align 4
1082
@@:
1083
        and     ecx, 0xFBFFFFFF  ;negate 0x04000000 save to mouseunder area
1084
;--------------------------------------
1085
align 4
1086
@@:
1087
;        call    [putpixel]
1088
        call    __sys_putpixel
1089
        inc     eax
1090
        cmp     eax, edx
1091
        jle     @b
1092
        pop     edx eax
1093
        ret
1094
;------------------------------------------------------------------------------
1095
align 4
1096
vline:
1097
; draw a vertical line
1098
; eax = x
1099
; ebx = y1
1100
; edx = y2
1101
; ecx = color
1102
; edi = force ?
1103
        push    ebx edx
1104
        cmp     edx, ebx   ; make sure y2 is above y1
1105
        jge     @f
1106
        xchg    ebx, edx
1107
;--------------------------------------
1108
align 4
1109
@@:
1110
        and     ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area
1111
;--------------------------------------
1112
align 4
1113
@@:
1114
;        call    [putpixel]
1115
        call    __sys_putpixel
1116
        inc     ebx
1117
        cmp     ebx, edx
1118
        jle     @b
1119
        pop     edx ebx
1120
        ret
1121
;------------------------------------------------------------------------------
1122
align 4
1123
virtual at esp
1124
drbar:
1125
     .bar_sx       dd ?
1126
     .bar_sy       dd ?
1127
     .bar_cx       dd ?
1128
     .bar_cy       dd ?
1129
     .abs_cx       dd ?
1130
     .abs_cy       dd ?
1131
     .real_sx      dd ?
1132
     .real_sy      dd ?
1133
     .color        dd ?
1134
     .line_inc_scr dd ?
1135
     .line_inc_map dd ?
1136
     .real_sx_and_abs_cx dd ?
1137
     .real_sy_and_abs_cy dd ?
1138
     .stack_data = 4*13
1139
end virtual
1140
;--------------------------------------
1141
align 4
1142
; eax   cx
1143
; ebx   cy
1144
; ecx   xe
1145
; edx   ye
1146
; edi   color
1147
vesa20_drawbar:
1148
        pushad
1149
        sub     esp, drbar.stack_data
1150
        mov     [drbar.color], edi
1151
        sub     edx, ebx
1152
        jle     .exit       ;// mike.dld, 2005-01-29
1153
        sub     ecx, eax
1154
        jle     .exit       ;// mike.dld, 2005-01-29
1155
        mov     [drbar.bar_sy], edx
1156
        mov     [drbar.bar_sx], ecx
1157
        mov     [drbar.bar_cx], eax
1158
        mov     [drbar.bar_cy], ebx
1159
        mov     edi, [TASK_BASE]
1160
        add     eax, [edi-twdw + WDATA.box.left]; win_cx
1161
        add     ebx, [edi-twdw + WDATA.box.top]; win_cy
1162
        mov     [drbar.abs_cx], eax
1163
        mov     [drbar.abs_cy], ebx
1164
; real_sx = MIN(wnd_sx-bar_cx, bar_sx);
1165
        mov     ebx, [edi-twdw + WDATA.box.width]; ebx = wnd_sx
1166
; \begin{diamond}[20.08.2006]
1167
; note that WDATA.box.width is one pixel less than real window x-size
1168
        inc     ebx
1169
; \end{diamond}[20.08.2006]
1170
        sub     ebx, [drbar.bar_cx]
1171
        ja      @f
1172
;--------------------------------------
1173
align 4
1174
.exit:                       ;// mike.dld, 2005-01-29
1175
        add     esp, drbar.stack_data
1176
        popad
1177
        xor     eax, eax
1178
        inc     eax
1179
        ret
1180
;--------------------------------------
1181
align 4
1182
@@:
1183
        cmp     ebx, [drbar.bar_sx]
1184
        jbe     .end_x
1185
        mov     ebx, [drbar.bar_sx]
1186
;--------------------------------------
1187
align 4
1188
.end_x:
1189
        mov     [drbar.real_sx], ebx
1190
; real_sy = MIN(wnd_sy-bar_cy, bar_sy);
1191
        mov     ebx, [edi-twdw + WDATA.box.height]; ebx = wnd_sy
1192
; \begin{diamond}[20.08.2006]
1193
        inc     ebx
1194
; \end{diamond}
1195
        sub     ebx, [drbar.bar_cy]
1196
        ja      @f
1197
        add     esp, drbar.stack_data
1198
        popad
1199
        xor     eax, eax
1200
        inc     eax
1201
        ret
1202
;--------------------------------------
1203
align 4
1204
@@:
1205
        cmp     ebx, [drbar.bar_sy]
1206
        jbe     .end_y
1207
        mov     ebx, [drbar.bar_sy]
1208
;--------------------------------------
1209
align 4
1210
.end_y:
1211
        mov     [drbar.real_sy], ebx
1212
; line_inc_map
1213
        mov     eax, [Screen_Max_X]
1214
        sub     eax, [drbar.real_sx]
1215
        inc     eax
1216
        mov     [drbar.line_inc_map], eax
1217
; line_inc_scr
1218
        mov     eax, [drbar.real_sx]
1219
        mov     ebx, [_display.bpp]
1220
        shr     ebx, 3
1221
        imul    eax, ebx
1222
        neg     eax
1223
        add     eax, [_display.pitch]
1224
        mov     [drbar.line_inc_scr], eax
1225
; pointer to screen
1226
        mov     edx, [drbar.abs_cy]
1227
;        imul    edx, [BytesPerScanLine]
1228
        mov     edx, [BPSLine_calc_area+edx*4]
1229
        mov     eax, [drbar.abs_cx]
1230
        imul    eax, ebx
1231
        add     edx, eax
1232
; pointer to pixel map
1233
        mov     eax, [drbar.abs_cy]
1234
;        imul    eax, [Screen_Max_X]
1235
;        add     eax, [drbar.abs_cy]
1236
        mov     eax, [d_width_calc_area + eax*4]
1237
 
1238
        add     eax, [drbar.abs_cx]
1239
        add     eax, [_WinMapAddress]
1240
        xchg    eax, ebp
1241
;--------------------------------------
1242
        mov     ebx, [drbar.real_sx]
1243
        add     ebx, [drbar.abs_cx]
1244
        mov     [drbar.real_sx_and_abs_cx], ebx
1245
        mov     ebx, [drbar.real_sy]
1246
        add     ebx, [drbar.abs_cy]
1247
        mov     [drbar.real_sy_and_abs_cy], ebx
1248
 
1249
        add     edx, LFB_BASE
1250
;--------------------------------------
1251
; get process number
1252
        mov     ebx, [CURRENT_TASK]  ; bl - process num
1253
        mov     esi, [drbar.real_sy]
1254
        mov     eax, [drbar.color] ; BBGGRR00
1255
        rol     eax, 8
1256
        mov     bh, al  ; 0x80 drawing gradient bars
1257
        ror     eax, 8
1258
        cmp     byte [_display.bpp], 24
1259
        jne     draw_bar_end_32
1260
;--------------------------------------
1261
align 4
1262
draw_bar_end_24:
1263
; eax - color high   RRGGBB
1264
; bl - process num
1265
; ecx - temp
1266
; edx - pointer to screen
1267
; esi - counter
1268
; edi - counter
1269
;--------------------------------------
1270
; check for hardware cursor
1271
        mov     ecx, [_display.select_cursor]
1272
        cmp     ecx, select_cursor
1273
        je      draw_bar_end_24_new
1274
        cmp     ecx, 0
1275
        je      draw_bar_end_24_old
1276
;--------------------------------------
1277
align 4
1278
.new_y:
1279
        mov     edi, [drbar.real_sx]
1280
;--------------------------------------
1281
align 4
1282
.new_x:
1283
        cmp     byte [ebp], bl
1284
        jne     .skip
1285
;--------------------------------------
1286
; store to real LFB
1287
        mov     [edx], ax
1288
        shr     eax, 16
1289
        mov     [edx + 2], al
1290
;--------------------------------------
1291
align 4
1292
.skip:
1293
; add pixel
1294
        add     edx, 3
1295
        inc     ebp
1296
        dec     edi
1297
        jnz     .new_x
1298
; add line
1299
        add     edx, [drbar.line_inc_scr]
1300
        add     ebp, [drbar.line_inc_map]
1301
; drawing gradient bars
1302
        test    bh, 0x80
1303
        jz      @f
1304
        test    al, al
1305
        jz      @f
1306
        dec     al
1307
;--------------------------------------
1308
align 4
1309
@@:
1310
        dec     esi
1311
        jnz     .new_y
1312
;--------------------------------------
1313
align 4
1314
.end:
1315
        add     esp, drbar.stack_data
1316
        popad
1317
        xor     eax, eax
1318
        ret
1319
;------------------------------------------------------------------------------
1320
align 4
1321
draw_bar_end_24_old:
1322
;--------------------------------------
1323
align 4
1324
.new_y:
1325
        mov     edi, [drbar.real_sx]
1326
;--------------------------------------
1327
align 4
1328
.new_x:
1329
        cmp     byte [ebp], bl
1330
        jne     .skip
1331
;--------------------------------------
1332
        mov     ecx, [drbar.real_sx_and_abs_cx]
1333
        sub     ecx, edi
1334
        shl     ecx, 16
1335
        add     ecx, [drbar.real_sy_and_abs_cy]
1336
        sub     ecx, esi
1337
; check mouse area for putpixel
1338
        call    check_mouse_area_for_putpixel
1339
; store to real LFB
1340
        mov     [edx], ax
1341
        shr     eax, 16
1342
        mov     [edx + 2], al
1343
        mov     eax, [drbar.color]
1344
;--------------------------------------
1345
align 4
1346
.skip:
1347
; add pixel
1348
        add     edx, 3
1349
        inc     ebp
1350
        dec     edi
1351
        jnz     .new_x
1352
; add line
1353
        add     edx, [drbar.line_inc_scr]
1354
        add     ebp, [drbar.line_inc_map]
1355
; drawing gradient bars
1356
        test    bh, 0x80
1357
        jz      @f
1358
        test    al, al
1359
        jz      @f
1360
        dec     al
1361
;--------------------------------------
1362
align 4
1363
@@:
1364
        dec     esi
1365
        jnz     .new_y
1366
        jmp     draw_bar_end_24.end
1367
;------------------------------------------------------------------------------
1368
align 4
1369
draw_bar_end_24_new:
1370
;--------------------------------------
1371
align 4
1372
.new_y:
1373
        mov     edi, [drbar.real_sx]
1374
;--------------------------------------
1375
align 4
1376
.new_x:
1377
        cmp     byte [ebp], bl
1378
        jne     .skip
1379
;--------------------------------------
1380
        mov     ecx, [drbar.real_sy_and_abs_cy]
1381
        sub     ecx, esi
1382
;--------------------------------------
1383
; check for Y
1384
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
1385
        jae     .no_mouse_area
1386
 
1387
        sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
1388
        jb      .no_mouse_area
1389
 
1390
        rol     ecx, 16
1391
        add     ecx, [drbar.real_sx_and_abs_cx]
1392
        sub     ecx, edi
1393
;--------------------------------------
1394
; check for X
1395
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
1396
        jae     .no_mouse_area
1397
 
1398
        sub     cx, [X_UNDER_subtraction_CUR_hot_x]
1399
        jb      .no_mouse_area
1400
 
1401
        ror     ecx, 16
1402
;--------------------------------------
1403
; check mouse area for putpixel
1404
        push    eax
1405
        call    check_mouse_area_for_putpixel_new.1
1406
        mov     [edx], ax
1407
        shr     eax, 16
1408
        mov     [edx + 2], al
1409
        pop     eax
1410
        jmp     .skip
1411
; store to real LFB
1412
;--------------------------------------
1413
align 4
1414
.no_mouse_area:
1415
        mov     [edx], ax
1416
        ror     eax, 16
1417
        mov     [edx + 2], al
1418
        rol     eax, 16
1419
;--------------------------------------
1420
align 4
1421
.skip:
1422
; add pixel
1423
        add     edx, 3
1424
        inc     ebp
1425
        dec     edi
1426
        jnz     .new_x
1427
; add line
1428
        add     edx, [drbar.line_inc_scr]
1429
        add     ebp, [drbar.line_inc_map]
1430
; drawing gradient bars
1431
        test    bh, 0x80
1432
        jz      @f
1433
        test    al, al
1434
        jz      @f
1435
        dec     al
1436
;--------------------------------------
1437
align 4
1438
@@:
1439
        dec     esi
1440
        jnz     .new_y
1441
        jmp     draw_bar_end_24.end
1442
;------------------------------------------------------------------------------
1443
align 4
1444
draw_bar_end_32:
1445
; eax - color high   RRGGBB
1446
; bl - process num
1447
; ecx - temp
1448
; edx - pointer to screen
1449
; esi - counter
1450
; edi - counter
1451
;--------------------------------------
1452
; check for hardware cursor
1453
        mov     ecx, [_display.select_cursor]
1454
        cmp     ecx, select_cursor
1455
        je      draw_bar_end_32_new
1456
        cmp     ecx, 0
1457
        je      draw_bar_end_32_old
1458
;--------------------------------------
1459
align 4
1460
.new_y:
1461
        mov     edi, [drbar.real_sx]
1462
;--------------------------------------
1463
align 4
1464
.new_x:
1465
        cmp     byte [ebp], bl
1466
        jne     .skip
1467
;--------------------------------------
1468
; store to real LFB
1469
        mov     [edx], eax
1470
        mov     eax, [drbar.color]
1471
;--------------------------------------
1472
align 4
1473
.skip:
1474
; add pixel
1475
        add     edx, 4
1476
        inc     ebp
1477
        dec     edi
1478
        jnz     .new_x
1479
; add line
1480
        add     edx, [drbar.line_inc_scr]
1481
        add     ebp, [drbar.line_inc_map]
1482
; drawing gradient bars
1483
        test    bh, 0x80
1484
        jz      @f
1485
        test    al, al
1486
        jz      @f
1487
        dec     al
1488
;--------------------------------------
1489
align 4
1490
@@:
1491
        dec     esi
1492
        jnz     .new_y
1493
;--------------------------------------
1494
align 4
1495
.end:
1496
        add     esp, drbar.stack_data
1497
        popad
1498
        cmp     [SCR_MODE], 0x12
1499
        jne     @f
1500
        call    VGA_draw_bar
1501
;--------------------------------------
1502
align 4
1503
@@:
1504
        xor     eax, eax
1505
        mov     [EGA_counter], 1
1506
        ret
1507
;------------------------------------------------------------------------------
1508
align 4
1509
draw_bar_end_32_old:
1510
;--------------------------------------
1511
align 4
1512
.new_y:
1513
        mov     edi, [drbar.real_sx]
1514
;--------------------------------------
1515
align 4
1516
.new_x:
1517
        cmp     byte [ebp], bl
1518
        jne     .skip
1519
;--------------------------------------
1520
        mov     ecx, [drbar.real_sx_and_abs_cx]
1521
        sub     ecx, edi
1522
        shl     ecx, 16
1523
        add     ecx, [drbar.real_sy_and_abs_cy]
1524
        sub     ecx, esi
1525
 
1526
; check mouse area for putpixel
1527
        call    check_mouse_area_for_putpixel
1528
; store to real LFB
1529
        mov     [edx], eax
1530
        mov     eax, [drbar.color]
1531
;--------------------------------------
1532
align 4
1533
.skip:
1534
; add pixel
1535
        add     edx, 4
1536
        inc     ebp
1537
        dec     edi
1538
        jnz     .new_x
1539
; add line
1540
        add     edx, [drbar.line_inc_scr]
1541
        add     ebp, [drbar.line_inc_map]
1542
; drawing gradient bars
1543
        test    bh, 0x80
1544
        jz      @f
1545
        test    al, al
1546
        jz      @f
1547
        dec     al
1548
;--------------------------------------
1549
align 4
1550
@@:
1551
        dec     esi
1552
        jnz     .new_y
1553
        jmp     draw_bar_end_32.end
1554
;------------------------------------------------------------------------------
1555
align 4
1556
draw_bar_end_32_new:
1557
;--------------------------------------
1558
align 4
1559
.new_y:
1560
        mov     edi, [drbar.real_sx]
1561
;--------------------------------------
1562
align 4
1563
.new_x:
1564
        cmp     byte [ebp], bl
1565
        jne     .skip
1566
;--------------------------------------
1567
        mov     ecx, [drbar.real_sy_and_abs_cy]
1568
        sub     ecx, esi
1569
;--------------------------------------
1570
; check for Y
1571
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
1572
        jae     .no_mouse_area
1573
 
1574
        sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
1575
        jb      .no_mouse_area
1576
 
1577
        rol     ecx, 16
1578
        add     ecx, [drbar.real_sx_and_abs_cx]
1579
        sub     ecx, edi
1580
;--------------------------------------
1581
; check for X
1582
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
1583
        jae     .no_mouse_area
1584
 
1585
        sub     cx, [X_UNDER_subtraction_CUR_hot_x]
1586
        jb      .no_mouse_area
1587
 
1588
        ror     ecx, 16
1589
;--------------------------------------
1590
; check mouse area for putpixel
1591
        push    eax
1592
        call    check_mouse_area_for_putpixel_new.1
1593
        mov     [edx], eax
1594
        pop     eax
1595
        jmp     .skip
1596
; store to real LFB
1597
;--------------------------------------
1598
align 4
1599
.no_mouse_area:
1600
        mov     [edx], eax
1601
;--------------------------------------
1602
align 4
1603
.skip:
1604
; add pixel
1605
        add     edx, 4
1606
        inc     ebp
1607
        dec     edi
1608
        jnz     .new_x
1609
; add line
1610
        add     edx, [drbar.line_inc_scr]
1611
        add     ebp, [drbar.line_inc_map]
1612
; drawing gradient bars
1613
        test    bh, 0x80
1614
        jz      @f
1615
        test    al, al
1616
        jz      @f
1617
        dec     al
1618
;--------------------------------------
1619
align 4
1620
@@:
1621
        dec     esi
1622
        jnz     .new_y
1623
        jmp     draw_bar_end_32.end
1624
;------------------------------------------------------------------------------
1625
align 4
1626
vesa20_drawbackground_tiled:
1627
        pushad
1628
; External loop for all y from start to end
1629
        mov     ebx, [draw_data+32+RECT.top]    ; y start
1630
;--------------------------------------
1631
align 4
1632
dp2:
1633
        mov     ebp, [draw_data+32+RECT.left]   ; x start
1634
; 1) Calculate pointers in WinMapAddress (does pixel belong to OS thread?) [ebp]
1635
;                       and LFB data (output for our function) [edi]
1636
;        mov     eax, [BytesPerScanLine]
1637
;        mul     ebx
1638
        mov     eax, [BPSLine_calc_area+ebx*4]
1639
        xchg    ebp, eax
1640
        add     ebp, eax
1641
        add     ebp, eax
1642
        add     ebp, eax
1643
        cmp     byte [_display.bpp], 24    ; 24 or 32 bpp ? - x size
1644
        jz      @f
1645
        add     ebp, eax
1646
;--------------------------------------
1647
align 4
1648
@@:
1649
        add     ebp, LFB_BASE
1650
; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
1651
        call    calculate_edi
1652
        xchg    edi, ebp
1653
        add     ebp, [_WinMapAddress]
1654
; Now eax=x, ebx=y, edi->output, ebp=offset in WinMapAddress
1655
; 2) Calculate offset in background memory block
1656
        push    eax
1657
        xor     edx, edx
1658
        mov     eax, ebx
1659
        div     dword [BgrDataHeight]   ; edx := y mod BgrDataHeight
1660
        pop     eax
1661
        push    eax
1662
        mov     ecx, [BgrDataWidth]
1663
        mov     esi, edx
1664
        imul    esi, ecx                ; esi := (y mod BgrDataHeight) * BgrDataWidth
1665
        xor     edx, edx
1666
        div     ecx             ; edx := x mod BgrDataWidth
1667
        sub     ecx, edx
1668
        add     esi, edx        ; esi := (y mod BgrDataHeight)*BgrDataWidth + (x mod BgrDataWidth)
1669
        pop     eax
1670
        lea     esi, [esi*3]
1671
        add     esi, [img_background]
1672
        xor     edx, edx
1673
        inc     edx
1674
; 3) Loop through redraw rectangle and copy background data
1675
; Registers meaning:
1676
; eax = x, ebx = y (screen coordinates)
1677
; ecx = deltax - number of pixels left in current tile block
1678
; edx = 1
1679
; esi -> bgr memory, edi -> output
1680
; ebp = offset in WinMapAddress
1681
;--------------------------------------
1682
align 4
1683
dp3:
1684
        cmp     [ebp], dl
1685
        jnz     nbgp
1686
;--------------------------------------
1687
        push    eax ecx
1688
 
1689
        mov     ecx, eax
1690
        shl     ecx, 16
1691
        add     ecx, ebx
1692
 
1693
        mov     eax, [esi]
1694
 
1695
; check for hardware cursor
1696
        cmp     [_display.select_cursor], select_cursor
1697
        je      @f
1698
        cmp     [_display.select_cursor], 0
1699
        jne     .no_mouseunder
1700
;--------------------------------------
1701
align 4
1702
@@:
1703
        and     eax, 0xffffff
1704
; check mouse area for putpixel
1705
        call    [_display.check_mouse]
1706
;--------------------------------------
1707
align 4
1708
.no_mouseunder:
1709
; store to real LFB
1710
        mov     [edi], ax
1711
        shr     eax, 16
1712
        mov     [edi+2], al
1713
 
1714
        pop     ecx eax
1715
;--------------------------------------
1716
align 4
1717
nbgp:
1718
        add     esi, 3
1719
        add     edi, 3
1720
;--------------------------------------
1721
align 4
1722
@@:
1723
        cmp     byte [_display.bpp], 25    ; 24 or 32 bpp?
1724
        sbb     edi, -1         ; +1 for 32 bpp
1725
; I do not use 'inc eax' because this is slightly slower then 'add eax,1'
1726
        add     ebp, edx
1727
        add     eax, edx
1728
        cmp     eax, [draw_data+32+RECT.right]
1729
        ja      dp4
1730
        sub     ecx, edx
1731
        jnz     dp3
1732
; next tile block on x-axis
1733
        mov     ecx, [BgrDataWidth]
1734
        sub     esi, ecx
1735
        sub     esi, ecx
1736
        sub     esi, ecx
1737
        jmp     dp3
1738
;--------------------------------------
1739
align 4
1740
dp4:
1741
; next scan line
1742
        inc     ebx
1743
        cmp     ebx, [draw_data+32+RECT.bottom]
1744
        jbe     dp2
1745
        popad
1746
        mov     [EGA_counter], 1
1747
        cmp     [SCR_MODE], 0x12
1748
        jne     @f
1749
        call    VGA_drawbackground
1750
;--------------------------------------
1751
align 4
1752
@@:
1753
        ret
1754
;------------------------------------------------------------------------------
1755
align 4
1756
vesa20_drawbackground_stretch:
1757
        pushad
1758
; Helper variables
1759
; calculate 2^32*(BgrDataWidth-1) mod (ScreenWidth-1)
1760
        mov     eax, [BgrDataWidth]
1761
        dec     eax
1762
        xor     edx, edx
1763
        div     dword [Screen_Max_X]
1764
        push    eax     ; high
1765
        xor     eax, eax
1766
        div     dword [Screen_Max_X]
1767
        push    eax     ; low
1768
; the same for height
1769
        mov     eax, [BgrDataHeight]
1770
        dec     eax
1771
        xor     edx, edx
1772
        div     dword [Screen_Max_Y]
1773
        push    eax     ; high
1774
        xor     eax, eax
1775
        div     dword [Screen_Max_Y]
1776
        push    eax     ; low
1777
; External loop for all y from start to end
1778
        mov     ebx, [draw_data+32+RECT.top]    ; y start
1779
        mov     ebp, [draw_data+32+RECT.left]   ; x start
1780
; 1) Calculate pointers in WinMapAddress (does pixel belong to OS thread?) [ebp]
1781
;                       and LFB data (output for our function) [edi]
1782
;        mov     eax, [BytesPerScanLine]
1783
;        mul     ebx
1784
        mov     eax, [BPSLine_calc_area+ebx*4]
1785
        xchg    ebp, eax
1786
        add     ebp, eax
1787
        add     ebp, eax
1788
        add     ebp, eax
1789
        cmp     byte [_display.bpp], 24    ; 24 or 32 bpp ? - x size
1790
        jz      @f
1791
        add     ebp, eax
1792
;--------------------------------------
1793
align 4
1794
@@:
1795
; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
1796
        call    calculate_edi
1797
        xchg    edi, ebp
1798
; Now eax=x, ebx=y, edi->output, ebp=offset in WinMapAddress
1799
        push    ebx
1800
        push    eax
1801
; 2) Calculate offset in background memory block
1802
        mov     eax, ebx
1803
        imul    ebx, dword [esp+12]
1804
        mul     dword [esp+8]
1805
        add     edx, ebx        ; edx:eax = y * 2^32*(BgrDataHeight-1)/(ScreenHeight-1)
1806
        mov     esi, edx
1807
        imul    esi, [BgrDataWidth]
1808
        push    edx
1809
        push    eax
1810
        mov     eax, [esp+8]
1811
        mul     dword [esp+28]
1812
        push    eax
1813
        mov     eax, [esp+12]
1814
        mul     dword [esp+28]
1815
        add     [esp], edx
1816
        pop     edx             ; edx:eax = x * 2^32*(BgrDataWidth-1)/(ScreenWidth-1)
1817
        add     esi, edx
1818
        lea     esi, [esi*3]
1819
        add     esi, [img_background]
1820
        push    eax
1821
        push    edx
1822
        push    esi
1823
; 3) Smooth horizontal
1824
;--------------------------------------
1825
align 4
1826
bgr_resmooth0:
1827
        mov     ecx, [esp+8]
1828
        mov     edx, [esp+4]
1829
        mov     esi, [esp]
1830
        push    edi
1831
        mov     edi, bgr_cur_line
1832
        call    smooth_line
1833
;--------------------------------------
1834
align 4
1835
bgr_resmooth1:
1836
        mov     eax, [esp+16+4]
1837
        inc     eax
1838
        cmp     eax, [BgrDataHeight]
1839
        jae     bgr.no2nd
1840
        mov     ecx, [esp+8+4]
1841
        mov     edx, [esp+4+4]
1842
        mov     esi, [esp+4]
1843
        add     esi, [BgrDataWidth]
1844
        add     esi, [BgrDataWidth]
1845
        add     esi, [BgrDataWidth]
1846
        mov     edi, bgr_next_line
1847
        call    smooth_line
1848
;--------------------------------------
1849
align 4
1850
bgr.no2nd:
1851
        pop     edi
1852
;--------------------------------------
1853
align 4
1854
sdp3:
1855
        xor     esi, esi
1856
        mov     ecx, [esp+12]
1857
; 4) Loop through redraw rectangle and copy background data
1858
; Registers meaning:
1859
; esi = offset in current line, edi -> output
1860
; ebp = offset in WinMapAddress
1861
; dword [esp] = offset in bgr data
1862
; qword [esp+4] = x * 2^32 * (BgrDataWidth-1) / (ScreenWidth-1)
1863
; qword [esp+12] = y * 2^32 * (BgrDataHeight-1) / (ScreenHeight-1)
1864
; dword [esp+20] = x
1865
; dword [esp+24] = y
1866
; precalculated constants:
1867
; qword [esp+28] = 2^32*(BgrDataHeight-1)/(ScreenHeight-1)
1868
; qword [esp+36] = 2^32*(BgrDataWidth-1)/(ScreenWidth-1)
1869
;--------------------------------------
1870
align 4
1871
sdp3a:
1872
        mov     eax, [_WinMapAddress]
1873
        cmp     [ebp+eax], byte 1
1874
        jnz     snbgp
1875
        mov     eax, [bgr_cur_line+esi]
1876
        test    ecx, ecx
1877
        jz      .novert
1878
        mov     ebx, [bgr_next_line+esi]
1879
        call    [overlapping_of_points_ptr]
1880
;--------------------------------------
1881
align 4
1882
.novert:
1883
        push    ecx
1884
; check for hardware cursor
1885
        cmp     [_display.select_cursor], select_cursor
1886
        je      @f
1887
        cmp     [_display.select_cursor], 0
1888
        jne     .no_mouseunder
1889
;--------------------------------------
1890
align 4
1891
@@:
1892
        mov     ecx, [esp+20+4]        ;x
1893
        shl     ecx, 16
1894
        add     ecx, [esp+24+4]        ;y
1895
; check mouse area for putpixel
1896
        call    [_display.check_mouse]
1897
;--------------------------------------
1898
align 4
1899
.no_mouseunder:
1900
; store to real LFB
1901
        mov     [LFB_BASE+edi], ax
1902
        shr     eax, 16
1903
        mov     [LFB_BASE+edi+2], al
1904
        pop     ecx
1905
;--------------------------------------
1906
align 4
1907
snbgp:
1908
        cmp     byte [_display.bpp], 25
1909
        sbb     edi, -4
1910
        add     ebp, 1
1911
        mov     eax, [esp+20]
1912
        add     eax, 1
1913
        mov     [esp+20], eax
1914
        add     esi, 4
1915
        cmp     eax, [draw_data+32+RECT.right]
1916
        jbe     sdp3a
1917
;--------------------------------------
1918
align 4
1919
sdp4:
1920
; next y
1921
        mov     ebx, [esp+24]
1922
        add     ebx, 1
1923
        mov     [esp+24], ebx
1924
        cmp     ebx, [draw_data+32+RECT.bottom]
1925
        ja      sdpdone
1926
; advance edi, ebp to next scan line
1927
        sub     eax, [draw_data+32+RECT.left]
1928
        sub     ebp, eax
1929
        add     ebp, [Screen_Max_X]
1930
        add     ebp, 1
1931
        sub     edi, eax
1932
        sub     edi, eax
1933
        sub     edi, eax
1934
        cmp     byte [_display.bpp], 24
1935
        jz      @f
1936
        sub     edi, eax
1937
;--------------------------------------
1938
align 4
1939
@@:
1940
        add     edi, [_display.pitch]
1941
; restore ecx,edx; advance esi to next background line
1942
        mov     eax, [esp+28]
1943
        mov     ebx, [esp+32]
1944
        add     [esp+12], eax
1945
        mov     eax, [esp+16]
1946
        adc     [esp+16], ebx
1947
        sub     eax, [esp+16]
1948
        mov     ebx, eax
1949
        lea     eax, [eax*3]
1950
        imul    eax, [BgrDataWidth]
1951
        sub     [esp], eax
1952
        mov     eax, [draw_data+32+RECT.left]
1953
        mov     [esp+20], eax
1954
        test    ebx, ebx
1955
        jz      sdp3
1956
        cmp     ebx, -1
1957
        jnz     bgr_resmooth0
1958
        push    edi
1959
        mov     esi, bgr_next_line
1960
        mov     edi, bgr_cur_line
1961
        mov     ecx, [Screen_Max_X]
1962
        inc     ecx
1963
        rep movsd
1964
        jmp     bgr_resmooth1
1965
;--------------------------------------
1966
align 4
1967
sdpdone:
1968
        add     esp, 44
1969
        popad
1970
        mov     [EGA_counter], 1
1971
        cmp     [SCR_MODE], 0x12
1972
        jne     @f
1973
        call    VGA_drawbackground
1974
;--------------------------------------
1975
align 4
1976
@@:
1977
        ret
1978
 
1979
uglobal
1980
;--------------------------------------
1981
align 4
1982
bgr_cur_line    rd      1920    ; maximum width of screen
1983
bgr_next_line   rd      1920
1984
;--------------------------------------
1985
endg
1986
;--------------------------------------
1987
align 4
1988
smooth_line:
1989
        mov     al, [esi+2]
1990
        shl     eax, 16
1991
        mov     ax, [esi]
1992
        test    ecx, ecx
1993
        jz      @f
1994
        mov     ebx, [esi+2]
1995
        shr     ebx, 8
1996
        call    [overlapping_of_points_ptr]
1997
;--------------------------------------
1998
align 4
1999
@@:
2000
        stosd
2001
        mov     eax, [esp+20+8]
2002
        add     eax, 1
2003
        mov     [esp+20+8], eax
2004
        cmp     eax, [draw_data+32+RECT.right]
2005
        ja      @f
2006
        add     ecx, [esp+36+8]
2007
        mov     eax, edx
2008
        adc     edx, [esp+40+8]
2009
        sub     eax, edx
2010
        lea     eax, [eax*3]
2011
        sub     esi, eax
2012
        jmp     smooth_line
2013
;--------------------------------------
2014
align 4
2015
@@:
2016
        mov     eax, [draw_data+32+RECT.left]
2017
        mov     [esp+20+8], eax
2018
        ret
2019
;------------------------------------------------------------------------------
2020
align 16
2021
overlapping_of_points:
2022
if 0
2023
; this version of procedure works, but is slower than next version
2024
        push    ecx edx
2025
        mov     edx, eax
2026
        push    esi
2027
        shr     ecx, 24
2028
        mov     esi, ecx
2029
        mov     ecx, ebx
2030
        movzx   ebx, dl
2031
        movzx   eax, cl
2032
        sub     eax, ebx
2033
        movzx   ebx, dh
2034
        imul    eax, esi
2035
        add     dl, ah
2036
        movzx   eax, ch
2037
        sub     eax, ebx
2038
        imul    eax, esi
2039
        add     dh, ah
2040
        ror     ecx, 16
2041
        ror     edx, 16
2042
        movzx   eax, cl
2043
        movzx   ebx, dl
2044
        sub     eax, ebx
2045
        imul    eax, esi
2046
        pop     esi
2047
        add     dl, ah
2048
        mov     eax, edx
2049
        pop     edx
2050
        ror     eax, 16
2051
        pop     ecx
2052
        ret
2053
else
2054
        push    ecx edx
2055
        mov     edx, eax
2056
        push    esi
2057
        shr     ecx, 26
2058
        mov     esi, ecx
2059
        mov     ecx, ebx
2060
        shl     esi, 9
2061
        movzx   ebx, dl
2062
        movzx   eax, cl
2063
        sub     eax, ebx
2064
        movzx   ebx, dh
2065
        add     dl, [BgrAuxTable+(eax+0x100)+esi]
2066
        movzx   eax, ch
2067
        sub     eax, ebx
2068
        add     dh, [BgrAuxTable+(eax+0x100)+esi]
2069
        ror     ecx, 16
2070
        ror     edx, 16
2071
        movzx   eax, cl
2072
        movzx   ebx, dl
2073
        sub     eax, ebx
2074
        add     dl, [BgrAuxTable+(eax+0x100)+esi]
2075
        pop     esi
2076
        mov     eax, edx
2077
        pop     edx
2078
        ror     eax, 16
2079
        pop     ecx
2080
        ret
2081
end if
2082
 
2083
iglobal
2084
;--------------------------------------
2085
align 4
2086
overlapping_of_points_ptr       dd      overlapping_of_points
2087
;--------------------------------------
2088
endg
2089
;------------------------------------------------------------------------------
2090
align 4
2091
init_background:
2092
        mov     edi, BgrAuxTable
2093
        xor     edx, edx
2094
;--------------------------------------
2095
align 4
2096
.loop2:
2097
        mov     eax, edx
2098
        shl     eax, 8
2099
        neg     eax
2100
        mov     ecx, 0x200
2101
;--------------------------------------
2102
align 4
2103
.loop1:
2104
        mov     byte [edi], ah
2105
        inc     edi
2106
        add     eax, edx
2107
        loop    .loop1
2108
        add     dl, 4
2109
        jnz     .loop2
2110
        test    byte [cpu_caps+(CAPS_MMX/8)], 1 shl (CAPS_MMX mod 8)
2111
        jz      @f
2112
        mov     [overlapping_of_points_ptr], overlapping_of_points_mmx
2113
;--------------------------------------
2114
align 4
2115
@@:
2116
        ret
2117
;------------------------------------------------------------------------------
2118
align 16
2119
overlapping_of_points_mmx:
2120
        movd    mm0, eax
2121
        movd    mm4, eax
2122
        movd    mm1, ebx
2123
        pxor    mm2, mm2
2124
        punpcklbw mm0, mm2
2125
        punpcklbw mm1, mm2
2126
        psubw   mm1, mm0
2127
        movd    mm3, ecx
2128
        psrld   mm3, 24
2129
        packuswb mm3, mm3
2130
        packuswb mm3, mm3
2131
        pmullw  mm1, mm3
2132
        psrlw   mm1, 8
2133
        packuswb mm1, mm2
2134
        paddb   mm4, mm1
2135
        movd    eax, mm4
2136
        ret
2137
;------------------------------------------------------------------------------