Subversion Repositories Kolibri OS

Rev

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

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