Subversion Repositories Kolibri OS

Rev

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

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