Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
1 ha 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                        ;;
3
;;  VESA20.INC                                            ;;
4
;;                                                        ;;
5
;;  Vesa 2.0 functions for MenuetOS                       ;;
6
;;                                                        ;;
7
;;  Copyright 2002 Ville Turjanmaa                        ;;
8
;;  Alexey, kgaz@crosswindws.net                          ;;
9
;;  - Voodoo compatible graphics                          ;;
10
;;  Juan M. Caravaca                                      ;;
11
;;  - Graphics optimimizations eg. drawline               ;;
12
;;                                                        ;;
13
;;  See file COPYING for details                          ;;
14
;;                                                        ;;
15
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16
 
17
; If you're planning to write your own video driver I suggest
18
; you replace the VESA12.INC file and see those instructions.
19
 
20
ScreenWidth             equ     0xfe00
21
ScreenHeight            equ     0xfe04
22
BytesPerScanLine        equ     0xfe08
23
LFBAddress              equ     0xfe80
24
ScreenBPP               equ     0xfbf1
25
WinMapAddress           equ     0x460000
26
 
27
 
28
 
29
;*************************************************
30
; getpixel
31
;
32
; in:
33
; eax = x coordinate
34
; ebx = y coordinate
35
;
36
; ret:
37
; ecx = 00 RR GG BB
38
 
39
getpixel:
40
        push    eax ebx edx edi
41
        call    dword [0xe024]
42
        pop     edi edx ebx eax
43
        ret
44
 
45
Vesa20_getpixel24:
46
        ; eax = x
47
        ; ebx = y
48
        imul    ebx, [BytesPerScanLine]    ; ebx = y * y multiplier
49
        lea     edi, [eax+eax*2] ; edi = x*3
50
        add     edi, ebx         ; edi = x*3+(y*y multiplier)
51
        add     edi, [LFBAddress]    ; ebx = where pixel is in memory
52
        mov     ecx, [edi]
53
        and     ecx, 0xffffff
54
        ret
55
 
56
 
57
Vesa20_getpixel32:
58
        imul    ebx, [BytesPerScanLine]    ; ebx = y * y multiplier
59
        lea     edi, [ebx+eax*4] ; edi = x*4+(y*y multiplier)
60
        add     edi, [LFBAddress]    ; ebx = where pixel is in memory
61
        mov     ecx, [edi]
62
        and     ecx, 0xffffff
63
        ret
64
 
65
;*************************************************
66
 
67
virtual at esp
68
 putimg:
69
   .real_sx        dd ?
70
   .real_sy        dd ?
71
   .image_sx       dd ?
72
   .image_sy       dd ?
73
   .image_cx       dd ?
74
   .image_cy       dd ?
75
   .pti            dd ?
76
   .abs_cx         dd ?
77
   .abs_cy         dd ?
78
   .line_increment dd ?
79
   .source_bpp     dd ?
80
   .winmap_newline dd ?
81
   .screen_newline dd ?
82
   .stack_data = 4*13
83
end virtual
84
 
85
align 4
86
; ebx = pointer
87
; ecx = size [x|y]
88
; edx = coordinates [x|y]
89
vesa20_putimage:
90
        pushad
91
        call    [disable_mouse]
92
 
93
        sub     esp, putimg.stack_data
94
 
95
        mov     [putimg.source_bpp], 3
96
;        test    ebx, 0x80000000
97
;        jz      @f
98
;        inc     [putimg.source_bpp]
99
;      @@:
100
;        and     ebx, 0x7FFFFFFF
101
 
102
        ; save pointer to image
103
        mov     [putimg.pti], ebx
104
 
105
        ; unpack the size
106
        mov     eax, ecx
107
        and     ecx, 0xFFFF
108
        shr     eax, 16
109
        mov     [putimg.image_sx], eax
110
        mov     [putimg.image_sy], ecx
111
 
112
        ; unpack the coordinates
113
        mov     eax, edx
114
        and     edx, 0xFFFF
115
        shr     eax, 16
116
        mov     [putimg.image_cx], eax
117
        mov     [putimg.image_cy], edx
118
 
119
        ; calculate absolute (i.e. screen) coordinates
120
        mov     eax, [0x3010]
121
        mov     ebx, [eax-twdw + 0]
122
        add     ebx, [putimg.image_cx]
123
        mov     [putimg.abs_cx], ebx
124
        mov     ebx, [eax-twdw + 4]
125
        add     ebx, [putimg.image_cy]
126
        mov     [putimg.abs_cy], ebx
127
 
128
        ; real_sx = MIN(wnd_sx-image_cx, image_sx);
129
        mov     ebx, [eax-twdw + 8] ; ebx = wnd_sx
130
        sub     ebx, [putimg.image_cx]
131
        ja      @f
132
        add     esp, putimg.stack_data
133
        popad
134
        xor     eax, eax
135
        inc     eax
136
        ret
137
      @@:
138
        cmp     ebx, [putimg.image_sx]
139
        jbe     .end_x
140
        mov     ebx, [putimg.image_sx]
141
        dec     ebx
142
      .end_x:
143
        inc     ebx
144
        mov     [putimg.real_sx], ebx
145
 
146
        ; init real_sy
147
        mov     ebx, [eax-twdw + 12] ; ebx = wnd_sy
148
        sub     ebx, [putimg.image_cy]
149
        ja      @f
150
        add     esp, putimg.stack_data
151
        popad
152
        xor     eax, eax
153
        inc     eax
154
        ret
155
      @@:
156
        cmp     ebx, [putimg.image_sy]
157
        jbe     .end_y
158
        mov     ebx, [putimg.image_sy]
159
        dec     ebx
160
      .end_y:
161
        inc     ebx
162
        mov     [putimg.real_sy], ebx
163
 
164
        ; line increment
165
        mov     eax, [putimg.image_sx]
166
        sub     eax, [putimg.real_sx]
167
;;        imul    eax, [putimg.source_bpp]
168
        lea     eax, [eax + eax * 2]
169
        mov     [putimg.line_increment], eax
170
 
171
        ; winmap new line increment
172
        mov     eax, [ScreenWidth]
173
        inc     eax
174
        sub     eax, [putimg.real_sx]
175
        mov     [putimg.winmap_newline], eax
176
 
177
        ; screen new line increment
178
        mov     eax, [BytesPerScanLine]
179
        mov     ecx, [putimg.real_sx]
180
        movzx   ebx, byte [ScreenBPP]
181
        shr     ebx, 3
182
        imul    ecx, ebx
183
        sub     eax, ecx
184
        mov     [putimg.screen_newline], eax
185
 
186
        ; pointer to image
187
        mov     ecx, [putimg.pti]
188
 
189
        ; pointer to screen
190
        mov     edx, [putimg.abs_cy]
191
        imul    edx, [BytesPerScanLine]
192
        mov     eax, [putimg.abs_cx]
193
        movzx   ebx, byte [ScreenBPP]
194
        shr     ebx, 3
195
        imul    eax, ebx
196
        add     edx, eax
197
        add     edx, [LFBAddress]
198
 
199
        ; pointer to pixel map
200
        mov     eax, [putimg.abs_cy]
201
        imul    eax, [ScreenWidth]
202
        add     eax, [putimg.abs_cy]
203
        add     eax, [putimg.abs_cx]
204
        add     eax, WinMapAddress
205
        xchg    eax, ebp
206
 
207
        ; get process number
208
        mov     eax, [0x3010]
209
        mov     bl, [eax+0xE]
210
 
211
        cmp     byte [ScreenBPP], 32
212
        je      put_image_end_32
213
 
214
;put_image_end_24:
215
        ;cli ; !!!!!!!!!!!!!!!!!!!!!!
216
        mov     edi, [putimg.real_sy]
217
        align   4
218
      .new_line:
219
        mov     esi, [putimg.real_sx]
220
 
221
;        push    ebp edx
222
        align   4
223
          .new_x:
224
 
225
                cmp     [ebp], bl
226
                jne     .skip
227
                mov     eax, [ecx]        ; ecx = RRBBGGRR
228
                mov     [edx], ax
229
                shr     eax, 16
230
                mov     [edx+2], al
231
              .skip:
232
 
233
            add     ecx, 3 ;[putimg.source_bpp]
234
            add     edx, 3
235
            inc     ebp
236
 
237
            dec     esi
238
            jnz     .new_x
239
;        pop     edx ebp
240
 
241
        add     ecx, [putimg.line_increment]
242
        add     edx, [putimg.screen_newline] ;[BytesPerScanLine]
243
        add     ebp, [putimg.winmap_newline] ;[ScreenWidth]
244
        ;inc     ebp
245
 
246
        dec     edi
247
        jnz     .new_line
248
   .finish:
249
        add     esp, putimg.stack_data
250
        popad
251
        xor     eax, eax
252
        ;sti ; !!!!!!!!!!!!!!!!!!!!!
253
ret
254
 
255
put_image_end_32:
256
        mov     edi, [putimg.real_sy]
257
        align   4
258
      .new_line:
259
        mov     esi, [putimg.real_sx]
260
 
261
;        push    ebp edx
262
        align   4
263
          .new_x:
264
 
265
                cmp     [ebp], bl
266
                jne     .skip
267
                mov     eax, [ecx]        ; ecx = RRBBGGRR
268
                mov     [edx], eax
269
              .skip:
270
 
271
            add     ecx, [putimg.source_bpp]
272
            add     edx, 4
273
            inc     ebp
274
 
275
            dec     esi
276
            jnz     .new_x
277
;        pop     edx ebp
278
 
279
        add     ecx, [putimg.line_increment]
280
        add     edx, [putimg.screen_newline] ;[BytesPerScanLine]
281
        add     ebp, [putimg.winmap_newline] ;[ScreenWidth]
282
        ;inc     ebp
283
 
284
        dec     edi
285
        jnz     .new_line
286
   .finish:
287
        add     esp, putimg.stack_data
288
        popad
289
        xor     eax, eax
290
ret
291
 
292
 
293
;*************************************************
294
align 4
295
__sys_putpixel:
296
 
297
; eax = x coordinate
298
; ebx = y coordinate
299
; ecx = ?? RR GG BB    ; 0x01000000 negation
300
; edi = 0x00000001 force
301
 
302
;;;        mov  [novesachecksum], dword 0
303
 
304
        pushad
305
        test  edi,1                 ; force ?
306
        jnz   .forced
307
      ; not forced:
308
        call  checkpixel
309
        test  ecx,ecx
310
        jnz   .exit
311
      .forced:
312
        cmp   [ScreenWidth], eax
313
        jb    .exit
314
        cmp   [ScreenHeight], ebx
315
        jb    .exit
316
      .ok:
317
        ; check if negation
318
        test  ecx,0x01000000
319
        jz    .noneg
320
        call  getpixel
321
        not   ecx
322
        mov   [esp+32-8],ecx
323
      .noneg:
324
        ; OK to set pixel
325
        call  dword [0xe020]        ; call the real put_pixel function
326
      .exit:
327
        popad
33 mario79 328
 
1 ha 329
        ret
330
 
331
align 4
332
Vesa20_putpixel24:
333
 
334
        ; eax = x
335
        ; ebx = y
336
 
337
        imul    ebx, [BytesPerScanLine]     ; ebx = y * y multiplier
338
        lea     edi, [eax+eax*2]  ; edi = x*3
339
        mov     eax, [esp+32-8+4]
340
        add     edi, [LFBAddress]
341
        add     edi, ebx          ; ebx = where to put pixel in memory
342
        mov     [edi], ax
343
        shr     eax, 16
344
        mov     [edi+2], al
345
 
346
        ret
347
 
348
 
349
align 4
350
Vesa20_putpixel32:
351
 
352
        ; eax = x
353
        ; ebx = y
354
 
355
        imul    ebx, [BytesPerScanLine]     ; ebx = y * y multiplier
356
        lea     edi, [ebx+eax*4]  ; edi = x*4+(y*y multiplier)
357
        mov     eax, [esp+32-8+4] ; eax = color
358
        add     edi, [LFBAddress]     ; ebx = where to put pixel in memory
359
        mov     [edi], eax
360
 
361
        ret
362
 
363
 
364
;*************************************************
365
 
366
;align 4
367
calculate_edi:
368
        mov     edi, ebx
369
        imul    edi, [ScreenWidth]
370
        add     edi, ebx
371
        add     edi, eax
372
ret
373
 
374
;*************************************************
375
 
376
; DRAWLINE
377
 
378
align 4
379
__sys_draw_line:
33 mario79 380
     inc   [mouse_pause]
1 ha 381
        call    [disable_mouse]
382
 
383
; draw a line
384
; eax = HIWORD = x1
385
;       LOWORD = x2
386
; ebx = HIWORD = y1
387
;       LOWORD = y2
388
; ecx = color
389
; edi = force ?
390
        pusha
391
 
392
dl_x1 equ esp+20
393
dl_y1 equ esp+16
394
dl_x2 equ esp+12
395
dl_y2 equ esp+8
396
dl_dx equ esp+4
397
dl_dy equ esp+0
398
 
399
        xor     edx, edx      ; clear edx
400
        xor     esi, esi      ; unpack arguments
401
        xor     ebp, ebp
402
        mov     si, ax        ; esi = x2
403
        mov     bp, bx        ; ebp = y2
404
        shr     eax, 16       ; eax = x1
405
        shr     ebx, 16       ; ebx = y1
406
 
407
        push    eax           ; save x1
408
        push    ebx           ; save y1
409
        push    esi           ; save x2
410
        push    ebp           ; save y2
411
 
412
        ; checking x-axis...
413
        sub     esi, eax      ; esi = x2-x1
414
        push    esi           ; save y2-y1
415
        jl      .x2lx1        ; is x2 less than x1 ?
416
        jg      .no_vline     ; x1 > x2 ?
417
        mov     edx, ebp      ; else (if x1=x2)
418
        call    vline
419
        push    edx    ; necessary to rightly restore stack frame at .exit
420
        jmp     .exit
421
.x2lx1:
422
        neg     esi            ; get esi absolute value
423
.no_vline:
424
 
425
        ; checking y-axis...
426
        sub     ebp, ebx       ; ebp = y2-y1
427
        push    ebp            ; save y2-y1
428
        jl      .y2ly1         ; is y2 less than y1 ?
429
        jg      .no_hline      ; y1 > y2 ?
430
        mov     edx, [dl_x2]   ; else (if y1=y2)
431
        call    hline
432
        jmp     .exit
433
.y2ly1:
434
        neg     ebp            ; get ebp absolute value
435
.no_hline:
436
 
437
 
438
        cmp     ebp, esi
439
        jle     .x_rules       ; |y2-y1| < |x2-x1|  ?
440
 
441
        cmp     [dl_y2], ebx   ; make sure y1 is at the begining
442
        jge     .no_reverse1
443
 
444
        neg     dword [dl_dx]
445
        mov     edx, [dl_x2]
446
        mov     [dl_x2], eax
447
        mov     [dl_x1], edx
448
        mov     edx, [dl_y2]
449
        mov     [dl_y2], ebx
450
        mov     [dl_y1], edx
451
 
452
.no_reverse1:
453
 
454
        mov     eax, [dl_dx]
455
        cdq                    ; extend eax sing to edx
456
        shl     eax, 16        ; using 16bit fix-point maths
457
        idiv    ebp            ; eax = ((x2-x1)*65536)/(y2-y1)
458
        mov     edx, ebp       ; edx = counter (number of pixels to draw)
459
        mov     ebp, 1 *65536  ; <<16   ; ebp = dy = 1.0
460
        mov     esi, eax       ; esi = dx
461
 
462
        jmp     .y_rules
463
.x_rules:
464
 
465
        cmp     [dl_x2], eax    ; make sure x1 is at the begining
466
        jge     .no_reverse2
467
 
468
        neg     dword [dl_dy]
469
        mov     edx, [dl_x2]
470
        mov     [dl_x2], eax
471
        mov     [dl_x1], edx
472
        mov     edx, [dl_y2]
473
        mov     [dl_y2], ebx
474
        mov     [dl_y1], edx
475
 
476
.no_reverse2:
477
 
478
        xor     edx, edx
479
        mov     eax, [dl_dy]
480
        cdq                    ; extend eax sing to edx
481
        shl     eax, 16        ; using 16bit fix-point maths
482
        idiv    esi            ; eax = ((y2-y1)*65536)/(x2-x1)
483
        mov     edx, esi       ; edx = counter (number of pixels to draw)
484
        mov     esi, 1 *65536  ;<< 16   ; esi = dx = 1.0
485
        mov     ebp, eax       ; ebp = dy
486
 
487
.y_rules:
488
 
489
        mov     eax, [dl_x1]
490
        mov     ebx, [dl_y1]
491
        shl     eax, 16
492
        shl     ebx, 16
493
 
494
align 4
495
 
496
.draw:
497
        push    eax ebx
498
        shr     eax, 16
499
        shr     ebx, 16
500
        call    [putpixel]
501
        pop     ebx eax
502
 
503
        add     ebx, ebp        ; y = y+dy
504
        add     eax, esi        ; x = x+dx
505
 
506
        dec     edx
507
        jnz     .draw
508
 
509
        ; force last drawn pixel to be at (x2,y2)
510
        mov     eax, [dl_x2]
511
        mov     ebx, [dl_y2]
512
        call    [putpixel]
513
.exit:
514
        add     esp, 6*4
515
        popa
33 mario79 516
     dec   [mouse_pause]
1 ha 517
ret
518
 
519
 
520
hline:
521
; draw an horizontal line
522
; eax = x1
523
; edx = x2
524
; ebx = y
525
; ecx = color
526
; edi = force ?
527
        push    eax edx
528
 
529
        cmp     edx, eax      ; make sure x2 is above x1
530
        jge     @f
531
        xchg    eax, edx
532
        align   4
533
   @@:
534
        call    [putpixel]
535
        inc     eax
536
        cmp     eax, edx
537
        jle     @b
538
 
539
        pop     edx eax
540
ret
541
 
542
 
543
vline:
544
; draw a vertical line
545
; eax = x
546
; ebx = y1
547
; edx = y2
548
; ecx = color
549
; edi = force ?
550
        push    ebx edx
551
 
552
        cmp     edx, ebx      ; make sure y2 is above y1
553
        jge     @f
554
        xchg    ebx, edx
555
        align   4
556
   @@:
557
        call    [putpixel]
558
        inc     ebx
559
        cmp     ebx, edx
560
        jle     @b
561
 
562
        pop     edx ebx
563
ret
564
 
565
 
566
;*************************************************
567
 
568
 
569
virtual at esp
570
      drbar:
571
        .bar_sx       dd ?
572
        .bar_sy       dd ?
573
        .bar_cx       dd ?
574
        .bar_cy       dd ?
575
        .abs_cx       dd ?
576
        .abs_cy       dd ?
577
        .real_sx      dd ?
578
        .real_sy      dd ?
579
        .color        dd ?
580
        .line_inc_scr dd ?
581
        .line_inc_map dd ?
582
        .stack_data = 4*11
583
end virtual
584
 
585
align 4
586
; eax   cx
587
; ebx   cy
588
; ecx   xe
589
; edx   ye
590
; edi   color
591
vesa20_drawbar:
33 mario79 592
 
1 ha 593
        pushad
594
        call    [disable_mouse]
595
 
596
        sub     esp, drbar.stack_data
597
 
598
        mov     [drbar.color], edi
599
 
600
        sub     edx, ebx
601
        sub     ecx, eax
602
        mov     [drbar.bar_sy], edx
603
        mov     [drbar.bar_sx], ecx
604
 
605
        mov     [drbar.bar_cx], eax
606
        mov     [drbar.bar_cy], ebx
607
 
608
        mov     edi, [0x3010]
609
        add     eax, [edi-twdw + 0] ; win_cx
610
        add     ebx, [edi-twdw + 4] ; win_cy
611
        mov     [drbar.abs_cx], eax
612
        mov     [drbar.abs_cy], ebx
613
 
614
        ; real_sx = MIN(wnd_sx-bar_cx, bar_sx);
615
        mov     ebx, [edi-twdw + 8] ; ebx = wnd_sx
616
        sub     ebx, [drbar.bar_cx]
617
        ja      @f
618
        add     esp, drbar.stack_data
619
        popad
620
        xor     eax, eax
621
        inc     eax
33 mario79 622
 
1 ha 623
        ret
624
      @@:
625
        cmp     ebx, [drbar.bar_sx]
626
        jbe     .end_x
627
        mov     ebx, [drbar.bar_sx]
628
      .end_x:
629
        mov     [drbar.real_sx], ebx
630
 
631
        ; real_sy = MIN(wnd_sy-bar_cy, bar_sy);
632
        mov     ebx, [edi-twdw + 12] ; ebx = wnd_sy
633
        sub     ebx, [drbar.bar_cy]
634
        ja      @f
635
        add     esp, drbar.stack_data
636
        popad
637
        xor     eax, eax
638
        inc     eax
33 mario79 639
 
1 ha 640
        ret
641
      @@:
642
        cmp     ebx, [drbar.bar_sy]
643
        jbe     .end_y
644
        mov     ebx, [drbar.bar_sy]
645
      .end_y:
646
        mov     [drbar.real_sy], ebx
647
 
648
        ; line_inc_map
649
        mov     eax, [ScreenWidth]
650
        sub     eax, [drbar.real_sx]
651
        inc     eax
652
        mov     [drbar.line_inc_map], eax
653
 
654
        ; line_inc_scr
655
        mov     eax, [drbar.real_sx]
656
        movzx   ebx, byte [ScreenBPP]
657
        shr     ebx, 3
658
        imul    eax, ebx
659
        neg     eax
660
        add     eax, [BytesPerScanLine]
661
        mov     [drbar.line_inc_scr], eax
662
 
663
        ; pointer to screen
664
        mov     edx, [drbar.abs_cy]
665
        imul    edx, [BytesPerScanLine]
666
        mov     eax, [drbar.abs_cx]
667
;        movzx   ebx, byte [ScreenBPP]
668
;        shr     ebx, 3
669
        imul    eax, ebx
670
        add     edx, eax
671
        add     edx, [LFBAddress]
672
 
673
        ; pointer to pixel map
674
        mov     eax, [drbar.abs_cy]
675
        imul    eax, [ScreenWidth]
676
        add     eax, [drbar.abs_cy]
677
        add     eax, [drbar.abs_cx]
678
        add     eax, WinMapAddress
679
        xchg    eax, ebp
680
 
681
        ; get process number
682
        mov     eax, [0x3010]
683
        mov     bl, [eax+0xE]
684
 
685
        cmp     byte [ScreenBPP], 24
686
        jne     draw_bar_end_32
687
draw_bar_end_24:
688
        ;cli ; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
689
        mov     eax, [drbar.color]    ;; BBGGRR00
690
        mov     bh, al                ;; bh  = BB
691
        shr     eax, 8                ;; eax = RRGG
692
; eax - color high   RRGG
693
; bl - process num
694
; bh - color low    BB
695
; ecx - temp
696
; edx - pointer to screen
697
; esi - counter
698
; edi - counter
699
 
700
        mov     esi, [drbar.real_sy]
701
        align   4
702
     .new_y:
703
        mov     edi, [drbar.real_sx]
704
        align   4
705
     .new_x:
706
 
707
        cmp     byte [ebp], bl
708
        jne     .skip
709
        mov     [edx], bh
710
        mov     [edx + 1], ax
711
      .skip:
712
 
713
        ; add pixel
714
        add     edx, 3
715
        inc     ebp
716
 
717
        dec     edi
718
        jnz     .new_x
719
 
720
        ; add line
721
        add     edx, [drbar.line_inc_scr]
722
        add     ebp, [drbar.line_inc_map]
723
 
724
    ;  drawing gradient bars
725
        test    eax, 0x00800000
726
        jz      @f
727
        test    bh, bh
728
        jz      @f
729
        dec     bh
730
      @@:
731
    ; 
732
 
733
        dec     esi
734
        jnz     .new_y
735
 
736
        add     esp, drbar.stack_data
737
        popad
738
        xor     eax, eax
739
        ;sti ; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
740
ret
741
 
742
draw_bar_end_32:
743
        mov     eax, [drbar.color]    ;; BBGGRR00
744
 
745
        mov     esi, [drbar.real_sy]
746
        align   4
747
     .new_y:
748
        mov     edi, [drbar.real_sx]
749
        align   4
750
     .new_x:
751
 
752
        cmp     byte [ebp], bl
753
        jne     .skip
754
        mov     [edx], eax
755
      .skip:
756
 
757
        ; add pixel
758
        add     edx, 4
759
        inc     ebp
760
 
761
        dec     edi
762
        jnz     .new_x
763
 
764
        ; add line
765
        add     edx, [drbar.line_inc_scr]
766
        add     ebp, [drbar.line_inc_map]
767
 
768
    ;  drawing gradient bars
769
        test    eax, 0x80000000
770
        jz      @f
771
        test    al, al
772
        jz      @f
773
        dec     al
774
      @@:
775
    ; 
776
 
777
        dec     esi
778
        jnz     .new_y
779
 
780
        add     esp, drbar.stack_data
781
        popad
782
        xor     eax, eax
33 mario79 783
 
1 ha 784
ret
785
 
786
 
787
;voodoodbcplimit:
788
 
789
; ebp:=(y+Ywin)*(ScreenXSize+1)+(x+Xwin)+AddrBuffer
790
 
791
 
792
;     pusha
793
 
794
;     xor edx,edx
795
;     mov eax,ebp
796
;     mov ebx,[ScreenWidth] ; Screen_X_size
797
;     inc ebx   ; +1
798
;     sub eax,WinMapAddress ; -AddrBuffer
799
;     div ebx ;
800
;     mov ebx,eax ; ebx:=Y
801
;     mov eax,edx ; eax:=X
802
;     call cplimit
803
 
804
;     test ecx,ecx
805
;     jne  dbcpl12
806
;     popa
807
;     clc
808
;     ret
809
;   dbcpl12:
810
;     popa
811
;     stc
812
;     ret
813
 
814
 
815
 
816
 
817
;dbcplimit:
818
 
819
;        pusha
820
 
821
;        xor  edx,edx
822
;        mov  ebx,[ScreenWidth]
823
;        inc  ebx
824
;        sub  eax,WinMapAddress
825
;        div  ebx
826
;        mov  ebx,eax
827
;        mov  eax,edx
828
;        call cplimit
829
 
830
;        test ecx,ecx
831
;        jne  dbcpl1
832
;        popa
833
;        clc
834
;        ret
835
;     dbcpl1:
836
;        popa
837
;        stc
838
;        ret
839
 
840
 
841
 
842
 
843
 
844
 
845
;--------------vbe voodoo ------------------------------------------------
846
vesa20_drawbackground_tiled:
847
 
848
     call [disable_mouse]
849
 
850
     push ebp
851
     push eax
852
     push ebx
853
     push ecx
854
     push edx
855
 
856
     mov edx,dword [WinMapAddress-8] ; B
857
     add edx,dword [WinMapAddress-8] ; +B
858
     add edx,dword [WinMapAddress-8] ; +B
859
     push edx
860
 
861
     mov ebp,[draw_data+32+0] ; x start:=(x+Xwin)
862
     mov ebx,[draw_data+32+4] ; y start:=(y+Ywin)
863
 
864
     mov eax,[BytesPerScanLine]
865
     mul ebx
866
     xchg ebp, eax  ; BytesPerScanLine*(Ywin+y)
867
     add ebp, eax   ; +X
868
     add ebp, eax   ; +X
869
     add ebp, eax   ; +X
870
 
871
     cmp [ScreenBPP],byte 24 ; 24 or 32 bpp ? - x size
872
     jz @f
873
     add ebp,eax ; +X
874
   @@:
875
     add ebp,[LFBAddress]  ; +LFB
876
 
877
     ; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
878
 
879
     call calculate_edi
880
 
881
 
882
   dp3:                             ; MAIN LOOP
883
 
884
     cmp [edi+WinMapAddress],byte 1 ; ptrBuffer^<>byte(1)
885
;     je  ybgp
886
;
887
;     jmp nbgp
888
;
889
;   ybgp:
890
     jne nbgp
891
 
892
     push eax
893
     push ebx
894
 
895
     mov ecx,dword [WinMapAddress-8]    ; B
896
     xor edx,edx                   ; edx:=0
897
     div ecx                       ; Xstart/B
898
 
899
     ; eax=Int(qn) edx:=Rem
900
 
901
     lea esi,[edx+edx*2]           ; esi:=edx*3
902
 
903
     mov ecx,dword [WinMapAddress-4]    ; ecx:=H
904
     mov eax,[esp+0]               ; eax:=Ystart
905
     xor edx,edx                   ;
906
     div ecx                       ; Ystart/H
907
 
908
     mov eax,edx                   ; eax:=Rem
909
     xor edx,edx                   ;
910
     mov ebx,[esp+8]               ; ebx:=B*3
911
     mul ebx                       ;
912
     add esi,eax                   ;
913
     mov eax,[esi+0x300000]
914
     and eax,0xffffff
915
 
916
     xchg edi, ebp
917
     stosw
918
     shr eax,16
919
     stosb
920
     xchg ebp, edi                 ; ebp+=3
921
     cmp [ScreenBPP],byte 24       ; 24 or 32 bpp ? - x size
922
     jz @f
923
     inc ebp ; +1
924
   @@:
925
 
926
     pop ebx
927
     pop eax
928
 
929
     jmp hook1
930
 
931
   nbgp:
932
     add ebp,3                     ; +3
933
     cmp [ScreenBPP],byte 24       ; 24 or 32 bpp ? - x size
934
     jz  @f
935
     inc ebp ; +1
936
   @@:
937
 
938
   hook1:
939
 
940
     inc edi                       ; ptrBuffer++
941
     add esi,3                     ; ptrImage+=3
942
     inc eax
943
     cmp eax,[draw_data+32+8]         ; X > xend?
944
;     jg nodp3
945
;     jmp dp3
946
;
947
;   nodp3:
948
     jle dp3
949
 
950
     mov ebp,[draw_data+32+0]
951
 
952
     inc ebx
953
 
954
     mov  eax,[BytesPerScanLine]
955
     mul  ebx
956
     xchg ebp, eax                 ; BytesPerScanLine*(Ywin+y)
957
     add  ebp, eax                 ; +X
958
     add  ebp, eax                 ; +X=X*2
959
     add  ebp, eax                 ; +X=X*3
960
     cmp  [ScreenBPP],byte 24      ; 24 or 32 bpp ? - x size
961
     jz   @f
962
     add  ebp,eax                  ; +X=X*4
963
   @@:
964
     add ebp,[LFBAddress]          ; +LFB
965
 
966
     ; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
967
 
968
     call calculate_edi
969
 
970
     cmp ebx,[draw_data+32+12]
971
;     jg  dp4
972
;
973
;     jmp dp3
974
;
975
;   dp4:
976
     jle dp3
977
 
978
     add esp,4
979
 
980
     pop edx
981
     pop ecx
982
     pop ebx
983
     pop eax
984
     pop ebp
985
 
986
     ret
987
 
988
; ----------
989
 
990
 
991
vesa20_drawbackground_stretch:
992
 
993
     call  [disable_mouse]
994
 
995
     push ebp
996
     push eax
997
     push ebx
998
     push ecx
999
     push edx
1000
 
1001
     mov edx,dword [WinMapAddress-8] ; B
1002
     add edx,dword [WinMapAddress-8] ; +B
1003
     add edx,dword [WinMapAddress-8] ; +B
1004
     push edx
1005
 
1006
     mov ebp,[draw_data+32+0] ; x start:=(x+Xwin)
1007
     mov ebx,[draw_data+32+4] ; y start:=(y+Ywin)
1008
 
1009
     mov eax,[BytesPerScanLine]
1010
     mul ebx
1011
     xchg ebp, eax  ; BytesPerScanLine*(Ywin+y)
1012
     add ebp, eax   ; +X
1013
     add ebp, eax   ; +X
1014
     add ebp, eax   ; +X
1015
 
1016
     cmp [ScreenBPP],byte 24 ; 24 or 32 bpp ? - x size
1017
     jz  @f
1018
     add ebp,eax ; +X
1019
   @@:
1020
     add ebp,[LFBAddress] ; +LFB
1021
 
1022
     ; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
1023
 
1024
     call calculate_edi
1025
 
1026
 
1027
   sdp3:                            ; MAIN LOOP
1028
 
1029
     cmp [edi+WinMapAddress],byte 1     ; ptrBuffer^<>byte(1)
1030
     jne snbgp
1031
 
1032
     push eax
1033
     push ebx
1034
 
1035
     mov   eax,dword [WinMapAddress-8]
1036
     imul  eax, [esp+4]      ;4
1037
     xor   edx,edx
1038
     mov   ebx,[ScreenWidth]
1039
     div   ebx
1040
     lea   esi,[eax+eax*2]
1041
     mov   eax,dword [WinMapAddress-4]
1042
     imul  eax, [esp+0]      ;0
1043
     xor   edx,edx
1044
     mov   ebx,[ScreenHeight]
1045
     div   ebx
1046
     imul  eax, [esp+8]      ;8
1047
     add   esi,eax
1048
 
1049
     mov   eax,[esi+0x300000]
1050
     and   eax,0xffffff
1051
 
1052
     xchg edi, ebp
1053
     stosw
1054
     shr eax,16
1055
     stosb
1056
     xchg ebp, edi                 ; ebp+=3
1057
     cmp [ScreenBPP],byte 24       ; 24 or 32 bpp ? - x size
1058
     jz  @f
1059
     inc ebp ; +1
1060
   @@:
1061
 
1062
     pop ebx
1063
     pop eax
1064
 
1065
     jmp shook1
1066
 
1067
   snbgp:
1068
     add  ebp,3                     ; +3
1069
     cmp [ScreenBPP],byte 24        ; 24 or 32 bpp ? - x size
1070
     jz  @f
1071
     inc ebp ; +1
1072
   @@:
1073
 
1074
   shook1:
1075
 
1076
     inc edi                       ; ptrBuffer++
1077
     add esi,3                     ; ptrImage+=3
1078
     inc eax
1079
     cmp eax,[draw_data+32+8]         ; X > xend?
1080
     jle sdp3
1081
 
1082
     mov ebp,[draw_data+32+0]
1083
 
1084
     inc ebx
1085
 
1086
     mov  eax,[BytesPerScanLine]
1087
     mul  ebx
1088
     xchg ebp, eax                 ; BytesPerScanLine*(Ywin+y)
1089
     add  ebp, eax                 ; +X
1090
     add  ebp, eax                 ; +X=X*2
1091
     add  ebp, eax                 ; +X=X*3
1092
     cmp  [ScreenBPP],byte 24      ; 24 or 32 bpp ? - x size
1093
     jz   @f
1094
     add  ebp,eax                  ; +X=X*4
1095
   @@:
1096
     add ebp,[LFBAddress]          ; +LFB
1097
 
1098
     ; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
1099
 
1100
     call calculate_edi
1101
 
1102
     cmp ebx,[draw_data+32+12]
1103
     jle sdp3
1104
 
1105
     add esp,4
1106
 
1107
     pop edx
1108
     pop ecx
1109
     pop ebx
1110
     pop eax
1111
     pop ebp
1112
 
1113
     ret