Subversion Repositories Kolibri OS

Rev

Rev 33 | Rev 41 | 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:
36 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
36 mario79 516
;     dec   [mouse_pause]
517
     call   [draw_pointer]
1 ha 518
ret
519
 
520
 
521
hline:
522
; draw an horizontal line
523
; eax = x1
524
; edx = x2
525
; ebx = y
526
; ecx = color
527
; edi = force ?
528
        push    eax edx
529
 
530
        cmp     edx, eax      ; make sure x2 is above x1
531
        jge     @f
532
        xchg    eax, edx
533
        align   4
534
   @@:
535
        call    [putpixel]
536
        inc     eax
537
        cmp     eax, edx
538
        jle     @b
539
 
540
        pop     edx eax
541
ret
542
 
543
 
544
vline:
545
; draw a vertical line
546
; eax = x
547
; ebx = y1
548
; edx = y2
549
; ecx = color
550
; edi = force ?
551
        push    ebx edx
552
 
553
        cmp     edx, ebx      ; make sure y2 is above y1
554
        jge     @f
555
        xchg    ebx, edx
556
        align   4
557
   @@:
558
        call    [putpixel]
559
        inc     ebx
560
        cmp     ebx, edx
561
        jle     @b
562
 
563
        pop     edx ebx
564
ret
565
 
566
 
567
;*************************************************
568
 
569
 
570
virtual at esp
571
      drbar:
572
        .bar_sx       dd ?
573
        .bar_sy       dd ?
574
        .bar_cx       dd ?
575
        .bar_cy       dd ?
576
        .abs_cx       dd ?
577
        .abs_cy       dd ?
578
        .real_sx      dd ?
579
        .real_sy      dd ?
580
        .color        dd ?
581
        .line_inc_scr dd ?
582
        .line_inc_map dd ?
583
        .stack_data = 4*11
584
end virtual
585
 
586
align 4
587
; eax   cx
588
; ebx   cy
589
; ecx   xe
590
; edx   ye
591
; edi   color
592
vesa20_drawbar:
33 mario79 593
 
1 ha 594
        pushad
595
        call    [disable_mouse]
596
 
597
        sub     esp, drbar.stack_data
598
 
599
        mov     [drbar.color], edi
600
 
601
        sub     edx, ebx
602
        sub     ecx, eax
603
        mov     [drbar.bar_sy], edx
604
        mov     [drbar.bar_sx], ecx
605
 
606
        mov     [drbar.bar_cx], eax
607
        mov     [drbar.bar_cy], ebx
608
 
609
        mov     edi, [0x3010]
610
        add     eax, [edi-twdw + 0] ; win_cx
611
        add     ebx, [edi-twdw + 4] ; win_cy
612
        mov     [drbar.abs_cx], eax
613
        mov     [drbar.abs_cy], ebx
614
 
615
        ; real_sx = MIN(wnd_sx-bar_cx, bar_sx);
616
        mov     ebx, [edi-twdw + 8] ; ebx = wnd_sx
617
        sub     ebx, [drbar.bar_cx]
618
        ja      @f
619
        add     esp, drbar.stack_data
620
        popad
621
        xor     eax, eax
622
        inc     eax
33 mario79 623
 
1 ha 624
        ret
625
      @@:
626
        cmp     ebx, [drbar.bar_sx]
627
        jbe     .end_x
628
        mov     ebx, [drbar.bar_sx]
629
      .end_x:
630
        mov     [drbar.real_sx], ebx
631
 
632
        ; real_sy = MIN(wnd_sy-bar_cy, bar_sy);
633
        mov     ebx, [edi-twdw + 12] ; ebx = wnd_sy
634
        sub     ebx, [drbar.bar_cy]
635
        ja      @f
636
        add     esp, drbar.stack_data
637
        popad
638
        xor     eax, eax
639
        inc     eax
33 mario79 640
 
1 ha 641
        ret
642
      @@:
643
        cmp     ebx, [drbar.bar_sy]
644
        jbe     .end_y
645
        mov     ebx, [drbar.bar_sy]
646
      .end_y:
647
        mov     [drbar.real_sy], ebx
648
 
649
        ; line_inc_map
650
        mov     eax, [ScreenWidth]
651
        sub     eax, [drbar.real_sx]
652
        inc     eax
653
        mov     [drbar.line_inc_map], eax
654
 
655
        ; line_inc_scr
656
        mov     eax, [drbar.real_sx]
657
        movzx   ebx, byte [ScreenBPP]
658
        shr     ebx, 3
659
        imul    eax, ebx
660
        neg     eax
661
        add     eax, [BytesPerScanLine]
662
        mov     [drbar.line_inc_scr], eax
663
 
664
        ; pointer to screen
665
        mov     edx, [drbar.abs_cy]
666
        imul    edx, [BytesPerScanLine]
667
        mov     eax, [drbar.abs_cx]
668
;        movzx   ebx, byte [ScreenBPP]
669
;        shr     ebx, 3
670
        imul    eax, ebx
671
        add     edx, eax
672
        add     edx, [LFBAddress]
673
 
674
        ; pointer to pixel map
675
        mov     eax, [drbar.abs_cy]
676
        imul    eax, [ScreenWidth]
677
        add     eax, [drbar.abs_cy]
678
        add     eax, [drbar.abs_cx]
679
        add     eax, WinMapAddress
680
        xchg    eax, ebp
681
 
682
        ; get process number
683
        mov     eax, [0x3010]
684
        mov     bl, [eax+0xE]
685
 
686
        cmp     byte [ScreenBPP], 24
687
        jne     draw_bar_end_32
688
draw_bar_end_24:
689
        ;cli ; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
690
        mov     eax, [drbar.color]    ;; BBGGRR00
691
        mov     bh, al                ;; bh  = BB
692
        shr     eax, 8                ;; eax = RRGG
693
; eax - color high   RRGG
694
; bl - process num
695
; bh - color low    BB
696
; ecx - temp
697
; edx - pointer to screen
698
; esi - counter
699
; edi - counter
700
 
701
        mov     esi, [drbar.real_sy]
702
        align   4
703
     .new_y:
704
        mov     edi, [drbar.real_sx]
705
        align   4
706
     .new_x:
707
 
708
        cmp     byte [ebp], bl
709
        jne     .skip
710
        mov     [edx], bh
711
        mov     [edx + 1], ax
712
      .skip:
713
 
714
        ; add pixel
715
        add     edx, 3
716
        inc     ebp
717
 
718
        dec     edi
719
        jnz     .new_x
720
 
721
        ; add line
722
        add     edx, [drbar.line_inc_scr]
723
        add     ebp, [drbar.line_inc_map]
724
 
725
    ;  drawing gradient bars
726
        test    eax, 0x00800000
727
        jz      @f
728
        test    bh, bh
729
        jz      @f
730
        dec     bh
731
      @@:
732
    ; 
733
 
734
        dec     esi
735
        jnz     .new_y
736
 
737
        add     esp, drbar.stack_data
738
        popad
739
        xor     eax, eax
740
        ;sti ; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
741
ret
742
 
743
draw_bar_end_32:
744
        mov     eax, [drbar.color]    ;; BBGGRR00
745
 
746
        mov     esi, [drbar.real_sy]
747
        align   4
748
     .new_y:
749
        mov     edi, [drbar.real_sx]
750
        align   4
751
     .new_x:
752
 
753
        cmp     byte [ebp], bl
754
        jne     .skip
755
        mov     [edx], eax
756
      .skip:
757
 
758
        ; add pixel
759
        add     edx, 4
760
        inc     ebp
761
 
762
        dec     edi
763
        jnz     .new_x
764
 
765
        ; add line
766
        add     edx, [drbar.line_inc_scr]
767
        add     ebp, [drbar.line_inc_map]
768
 
769
    ;  drawing gradient bars
770
        test    eax, 0x80000000
771
        jz      @f
772
        test    al, al
773
        jz      @f
774
        dec     al
775
      @@:
776
    ; 
777
 
778
        dec     esi
779
        jnz     .new_y
780
 
781
        add     esp, drbar.stack_data
782
        popad
783
        xor     eax, eax
33 mario79 784
 
1 ha 785
ret
786
 
787
 
788
;voodoodbcplimit:
789
 
790
; ebp:=(y+Ywin)*(ScreenXSize+1)+(x+Xwin)+AddrBuffer
791
 
792
 
793
;     pusha
794
 
795
;     xor edx,edx
796
;     mov eax,ebp
797
;     mov ebx,[ScreenWidth] ; Screen_X_size
798
;     inc ebx   ; +1
799
;     sub eax,WinMapAddress ; -AddrBuffer
800
;     div ebx ;
801
;     mov ebx,eax ; ebx:=Y
802
;     mov eax,edx ; eax:=X
803
;     call cplimit
804
 
805
;     test ecx,ecx
806
;     jne  dbcpl12
807
;     popa
808
;     clc
809
;     ret
810
;   dbcpl12:
811
;     popa
812
;     stc
813
;     ret
814
 
815
 
816
 
817
 
818
;dbcplimit:
819
 
820
;        pusha
821
 
822
;        xor  edx,edx
823
;        mov  ebx,[ScreenWidth]
824
;        inc  ebx
825
;        sub  eax,WinMapAddress
826
;        div  ebx
827
;        mov  ebx,eax
828
;        mov  eax,edx
829
;        call cplimit
830
 
831
;        test ecx,ecx
832
;        jne  dbcpl1
833
;        popa
834
;        clc
835
;        ret
836
;     dbcpl1:
837
;        popa
838
;        stc
839
;        ret
840
 
841
 
842
 
843
 
844
 
845
 
846
;--------------vbe voodoo ------------------------------------------------
847
vesa20_drawbackground_tiled:
848
 
849
     call [disable_mouse]
850
 
851
     push ebp
852
     push eax
853
     push ebx
854
     push ecx
855
     push edx
856
 
857
     mov edx,dword [WinMapAddress-8] ; B
858
     add edx,dword [WinMapAddress-8] ; +B
859
     add edx,dword [WinMapAddress-8] ; +B
860
     push edx
861
 
862
     mov ebp,[draw_data+32+0] ; x start:=(x+Xwin)
863
     mov ebx,[draw_data+32+4] ; y start:=(y+Ywin)
864
 
865
     mov eax,[BytesPerScanLine]
866
     mul ebx
867
     xchg ebp, eax  ; BytesPerScanLine*(Ywin+y)
868
     add ebp, eax   ; +X
869
     add ebp, eax   ; +X
870
     add ebp, eax   ; +X
871
 
872
     cmp [ScreenBPP],byte 24 ; 24 or 32 bpp ? - x size
873
     jz @f
874
     add ebp,eax ; +X
875
   @@:
876
     add ebp,[LFBAddress]  ; +LFB
877
 
878
     ; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
879
 
880
     call calculate_edi
881
 
882
 
883
   dp3:                             ; MAIN LOOP
884
 
885
     cmp [edi+WinMapAddress],byte 1 ; ptrBuffer^<>byte(1)
886
;     je  ybgp
887
;
888
;     jmp nbgp
889
;
890
;   ybgp:
891
     jne nbgp
892
 
893
     push eax
894
     push ebx
895
 
896
     mov ecx,dword [WinMapAddress-8]    ; B
897
     xor edx,edx                   ; edx:=0
898
     div ecx                       ; Xstart/B
899
 
900
     ; eax=Int(qn) edx:=Rem
901
 
902
     lea esi,[edx+edx*2]           ; esi:=edx*3
903
 
904
     mov ecx,dword [WinMapAddress-4]    ; ecx:=H
905
     mov eax,[esp+0]               ; eax:=Ystart
906
     xor edx,edx                   ;
907
     div ecx                       ; Ystart/H
908
 
909
     mov eax,edx                   ; eax:=Rem
910
     xor edx,edx                   ;
911
     mov ebx,[esp+8]               ; ebx:=B*3
912
     mul ebx                       ;
913
     add esi,eax                   ;
914
     mov eax,[esi+0x300000]
915
     and eax,0xffffff
916
 
917
     xchg edi, ebp
918
     stosw
919
     shr eax,16
920
     stosb
921
     xchg ebp, edi                 ; ebp+=3
922
     cmp [ScreenBPP],byte 24       ; 24 or 32 bpp ? - x size
923
     jz @f
924
     inc ebp ; +1
925
   @@:
926
 
927
     pop ebx
928
     pop eax
929
 
930
     jmp hook1
931
 
932
   nbgp:
933
     add ebp,3                     ; +3
934
     cmp [ScreenBPP],byte 24       ; 24 or 32 bpp ? - x size
935
     jz  @f
936
     inc ebp ; +1
937
   @@:
938
 
939
   hook1:
940
 
941
     inc edi                       ; ptrBuffer++
942
     add esi,3                     ; ptrImage+=3
943
     inc eax
944
     cmp eax,[draw_data+32+8]         ; X > xend?
945
;     jg nodp3
946
;     jmp dp3
947
;
948
;   nodp3:
949
     jle dp3
950
 
951
     mov ebp,[draw_data+32+0]
952
 
953
     inc ebx
954
 
955
     mov  eax,[BytesPerScanLine]
956
     mul  ebx
957
     xchg ebp, eax                 ; BytesPerScanLine*(Ywin+y)
958
     add  ebp, eax                 ; +X
959
     add  ebp, eax                 ; +X=X*2
960
     add  ebp, eax                 ; +X=X*3
961
     cmp  [ScreenBPP],byte 24      ; 24 or 32 bpp ? - x size
962
     jz   @f
963
     add  ebp,eax                  ; +X=X*4
964
   @@:
965
     add ebp,[LFBAddress]          ; +LFB
966
 
967
     ; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
968
 
969
     call calculate_edi
970
 
971
     cmp ebx,[draw_data+32+12]
972
;     jg  dp4
973
;
974
;     jmp dp3
975
;
976
;   dp4:
977
     jle dp3
978
 
979
     add esp,4
980
 
981
     pop edx
982
     pop ecx
983
     pop ebx
984
     pop eax
985
     pop ebp
986
 
987
     ret
988
 
989
; ----------
990
 
991
 
992
vesa20_drawbackground_stretch:
993
 
994
     call  [disable_mouse]
995
 
996
     push ebp
997
     push eax
998
     push ebx
999
     push ecx
1000
     push edx
1001
 
1002
     mov edx,dword [WinMapAddress-8] ; B
1003
     add edx,dword [WinMapAddress-8] ; +B
1004
     add edx,dword [WinMapAddress-8] ; +B
1005
     push edx
1006
 
1007
     mov ebp,[draw_data+32+0] ; x start:=(x+Xwin)
1008
     mov ebx,[draw_data+32+4] ; y start:=(y+Ywin)
1009
 
1010
     mov eax,[BytesPerScanLine]
1011
     mul ebx
1012
     xchg ebp, eax  ; BytesPerScanLine*(Ywin+y)
1013
     add ebp, eax   ; +X
1014
     add ebp, eax   ; +X
1015
     add ebp, eax   ; +X
1016
 
1017
     cmp [ScreenBPP],byte 24 ; 24 or 32 bpp ? - x size
1018
     jz  @f
1019
     add ebp,eax ; +X
1020
   @@:
1021
     add ebp,[LFBAddress] ; +LFB
1022
 
1023
     ; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
1024
 
1025
     call calculate_edi
1026
 
1027
 
1028
   sdp3:                            ; MAIN LOOP
1029
 
1030
     cmp [edi+WinMapAddress],byte 1     ; ptrBuffer^<>byte(1)
1031
     jne snbgp
1032
 
1033
     push eax
1034
     push ebx
1035
 
1036
     mov   eax,dword [WinMapAddress-8]
1037
     imul  eax, [esp+4]      ;4
1038
     xor   edx,edx
1039
     mov   ebx,[ScreenWidth]
1040
     div   ebx
1041
     lea   esi,[eax+eax*2]
1042
     mov   eax,dword [WinMapAddress-4]
1043
     imul  eax, [esp+0]      ;0
1044
     xor   edx,edx
1045
     mov   ebx,[ScreenHeight]
1046
     div   ebx
1047
     imul  eax, [esp+8]      ;8
1048
     add   esi,eax
1049
 
1050
     mov   eax,[esi+0x300000]
1051
     and   eax,0xffffff
1052
 
1053
     xchg edi, ebp
1054
     stosw
1055
     shr eax,16
1056
     stosb
1057
     xchg ebp, edi                 ; ebp+=3
1058
     cmp [ScreenBPP],byte 24       ; 24 or 32 bpp ? - x size
1059
     jz  @f
1060
     inc ebp ; +1
1061
   @@:
1062
 
1063
     pop ebx
1064
     pop eax
1065
 
1066
     jmp shook1
1067
 
1068
   snbgp:
1069
     add  ebp,3                     ; +3
1070
     cmp [ScreenBPP],byte 24        ; 24 or 32 bpp ? - x size
1071
     jz  @f
1072
     inc ebp ; +1
1073
   @@:
1074
 
1075
   shook1:
1076
 
1077
     inc edi                       ; ptrBuffer++
1078
     add esi,3                     ; ptrImage+=3
1079
     inc eax
1080
     cmp eax,[draw_data+32+8]         ; X > xend?
1081
     jle sdp3
1082
 
1083
     mov ebp,[draw_data+32+0]
1084
 
1085
     inc ebx
1086
 
1087
     mov  eax,[BytesPerScanLine]
1088
     mul  ebx
1089
     xchg ebp, eax                 ; BytesPerScanLine*(Ywin+y)
1090
     add  ebp, eax                 ; +X
1091
     add  ebp, eax                 ; +X=X*2
1092
     add  ebp, eax                 ; +X=X*3
1093
     cmp  [ScreenBPP],byte 24      ; 24 or 32 bpp ? - x size
1094
     jz   @f
1095
     add  ebp,eax                  ; +X=X*4
1096
   @@:
1097
     add ebp,[LFBAddress]          ; +LFB
1098
 
1099
     ; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
1100
 
1101
     call calculate_edi
1102
 
1103
     cmp ebx,[draw_data+32+12]
1104
     jle sdp3
1105
 
1106
     add esp,4
1107
 
1108
     pop edx
1109
     pop ecx
1110
     pop ebx
1111
     pop eax
1112
     pop ebp
1113
 
1114
     ret