Subversion Repositories Kolibri OS

Rev

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

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