Subversion Repositories Kolibri OS

Rev

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