Subversion Repositories Kolibri OS

Rev

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

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