Subversion Repositories Kolibri OS

Rev

Rev 41 | Rev 75 | 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:
52 mikedld 308
        push  ecx               ; save 24th bit in case negative pixel wanted
1 ha 309
        call  checkpixel
310
        test  ecx,ecx
52 mikedld 311
        pop   ecx
1 ha 312
        jnz   .exit
313
      .forced:
314
        cmp   [ScreenWidth], eax
315
        jb    .exit
316
        cmp   [ScreenHeight], ebx
317
        jb    .exit
318
      .ok:
319
        ; check if negation
320
        test  ecx,0x01000000
321
        jz    .noneg
322
        call  getpixel
323
        not   ecx
324
        mov   [esp+32-8],ecx
325
      .noneg:
326
        ; OK to set pixel
327
        call  dword [0xe020]        ; call the real put_pixel function
328
      .exit:
329
        popad
33 mario79 330
 
1 ha 331
        ret
332
 
333
align 4
334
Vesa20_putpixel24:
335
 
336
        ; eax = x
337
        ; ebx = y
338
 
339
        imul    ebx, [BytesPerScanLine]     ; ebx = y * y multiplier
340
        lea     edi, [eax+eax*2]  ; edi = x*3
341
        mov     eax, [esp+32-8+4]
342
        add     edi, [LFBAddress]
343
        add     edi, ebx          ; ebx = where to put pixel in memory
344
        mov     [edi], ax
345
        shr     eax, 16
346
        mov     [edi+2], al
347
 
348
        ret
349
 
350
 
351
align 4
352
Vesa20_putpixel32:
353
 
354
        ; eax = x
355
        ; ebx = y
356
 
357
        imul    ebx, [BytesPerScanLine]     ; ebx = y * y multiplier
358
        lea     edi, [ebx+eax*4]  ; edi = x*4+(y*y multiplier)
359
        mov     eax, [esp+32-8+4] ; eax = color
360
        add     edi, [LFBAddress]     ; ebx = where to put pixel in memory
361
        mov     [edi], eax
362
 
363
        ret
364
 
365
 
366
;*************************************************
367
 
368
;align 4
369
calculate_edi:
370
        mov     edi, ebx
371
        imul    edi, [ScreenWidth]
372
        add     edi, ebx
373
        add     edi, eax
374
ret
375
 
376
;*************************************************
377
 
378
; DRAWLINE
379
 
380
align 4
381
__sys_draw_line:
36 mario79 382
;     inc   [mouse_pause]
1 ha 383
        call    [disable_mouse]
384
 
385
; draw a line
386
; eax = HIWORD = x1
387
;       LOWORD = x2
388
; ebx = HIWORD = y1
389
;       LOWORD = y2
390
; ecx = color
391
; edi = force ?
392
        pusha
393
 
394
dl_x1 equ esp+20
395
dl_y1 equ esp+16
396
dl_x2 equ esp+12
397
dl_y2 equ esp+8
398
dl_dx equ esp+4
399
dl_dy equ esp+0
400
 
401
        xor     edx, edx      ; clear edx
402
        xor     esi, esi      ; unpack arguments
403
        xor     ebp, ebp
404
        mov     si, ax        ; esi = x2
405
        mov     bp, bx        ; ebp = y2
406
        shr     eax, 16       ; eax = x1
407
        shr     ebx, 16       ; ebx = y1
408
 
409
        push    eax           ; save x1
410
        push    ebx           ; save y1
411
        push    esi           ; save x2
412
        push    ebp           ; save y2
413
 
414
        ; checking x-axis...
415
        sub     esi, eax      ; esi = x2-x1
416
        push    esi           ; save y2-y1
417
        jl      .x2lx1        ; is x2 less than x1 ?
418
        jg      .no_vline     ; x1 > x2 ?
419
        mov     edx, ebp      ; else (if x1=x2)
420
        call    vline
421
        push    edx    ; necessary to rightly restore stack frame at .exit
422
        jmp     .exit
423
.x2lx1:
424
        neg     esi            ; get esi absolute value
425
.no_vline:
426
 
427
        ; checking y-axis...
428
        sub     ebp, ebx       ; ebp = y2-y1
429
        push    ebp            ; save y2-y1
430
        jl      .y2ly1         ; is y2 less than y1 ?
431
        jg      .no_hline      ; y1 > y2 ?
432
        mov     edx, [dl_x2]   ; else (if y1=y2)
433
        call    hline
434
        jmp     .exit
435
.y2ly1:
436
        neg     ebp            ; get ebp absolute value
437
.no_hline:
438
 
439
 
440
        cmp     ebp, esi
441
        jle     .x_rules       ; |y2-y1| < |x2-x1|  ?
442
 
443
        cmp     [dl_y2], ebx   ; make sure y1 is at the begining
444
        jge     .no_reverse1
445
 
446
        neg     dword [dl_dx]
447
        mov     edx, [dl_x2]
448
        mov     [dl_x2], eax
449
        mov     [dl_x1], edx
450
        mov     edx, [dl_y2]
451
        mov     [dl_y2], ebx
452
        mov     [dl_y1], edx
453
 
454
.no_reverse1:
455
 
456
        mov     eax, [dl_dx]
457
        cdq                    ; extend eax sing to edx
458
        shl     eax, 16        ; using 16bit fix-point maths
459
        idiv    ebp            ; eax = ((x2-x1)*65536)/(y2-y1)
460
        mov     edx, ebp       ; edx = counter (number of pixels to draw)
461
        mov     ebp, 1 *65536  ; <<16   ; ebp = dy = 1.0
462
        mov     esi, eax       ; esi = dx
463
 
464
        jmp     .y_rules
465
.x_rules:
466
 
467
        cmp     [dl_x2], eax    ; make sure x1 is at the begining
468
        jge     .no_reverse2
469
 
470
        neg     dword [dl_dy]
471
        mov     edx, [dl_x2]
472
        mov     [dl_x2], eax
473
        mov     [dl_x1], edx
474
        mov     edx, [dl_y2]
475
        mov     [dl_y2], ebx
476
        mov     [dl_y1], edx
477
 
478
.no_reverse2:
479
 
480
        xor     edx, edx
481
        mov     eax, [dl_dy]
482
        cdq                    ; extend eax sing to edx
483
        shl     eax, 16        ; using 16bit fix-point maths
484
        idiv    esi            ; eax = ((y2-y1)*65536)/(x2-x1)
485
        mov     edx, esi       ; edx = counter (number of pixels to draw)
486
        mov     esi, 1 *65536  ;<< 16   ; esi = dx = 1.0
487
        mov     ebp, eax       ; ebp = dy
488
 
489
.y_rules:
490
 
491
        mov     eax, [dl_x1]
492
        mov     ebx, [dl_y1]
493
        shl     eax, 16
494
        shl     ebx, 16
495
 
496
align 4
497
 
498
.draw:
499
        push    eax ebx
500
        shr     eax, 16
501
        shr     ebx, 16
502
        call    [putpixel]
503
        pop     ebx eax
504
 
505
        add     ebx, ebp        ; y = y+dy
506
        add     eax, esi        ; x = x+dx
507
 
508
        dec     edx
509
        jnz     .draw
510
 
511
        ; force last drawn pixel to be at (x2,y2)
512
        mov     eax, [dl_x2]
513
        mov     ebx, [dl_y2]
514
        call    [putpixel]
515
.exit:
516
        add     esp, 6*4
517
        popa
36 mario79 518
;     dec   [mouse_pause]
519
     call   [draw_pointer]
1 ha 520
ret
521
 
522
 
523
hline:
524
; draw an horizontal line
525
; eax = x1
526
; edx = x2
527
; ebx = y
528
; ecx = color
529
; edi = force ?
530
        push    eax edx
531
 
532
        cmp     edx, eax      ; make sure x2 is above x1
533
        jge     @f
534
        xchg    eax, edx
535
        align   4
536
   @@:
537
        call    [putpixel]
538
        inc     eax
539
        cmp     eax, edx
540
        jle     @b
541
 
542
        pop     edx eax
543
ret
544
 
545
 
546
vline:
547
; draw a vertical line
548
; eax = x
549
; ebx = y1
550
; edx = y2
551
; ecx = color
552
; edi = force ?
553
        push    ebx edx
554
 
555
        cmp     edx, ebx      ; make sure y2 is above y1
556
        jge     @f
557
        xchg    ebx, edx
558
        align   4
559
   @@:
560
        call    [putpixel]
561
        inc     ebx
562
        cmp     ebx, edx
563
        jle     @b
564
 
565
        pop     edx ebx
566
ret
567
 
568
 
569
;*************************************************
570
 
571
 
572
virtual at esp
573
      drbar:
574
        .bar_sx       dd ?
575
        .bar_sy       dd ?
576
        .bar_cx       dd ?
577
        .bar_cy       dd ?
578
        .abs_cx       dd ?
579
        .abs_cy       dd ?
580
        .real_sx      dd ?
581
        .real_sy      dd ?
582
        .color        dd ?
583
        .line_inc_scr dd ?
584
        .line_inc_map dd ?
585
        .stack_data = 4*11
586
end virtual
587
 
588
align 4
589
; eax   cx
590
; ebx   cy
591
; ecx   xe
592
; edx   ye
593
; edi   color
594
vesa20_drawbar:
33 mario79 595
 
1 ha 596
        pushad
597
        call    [disable_mouse]
598
 
599
        sub     esp, drbar.stack_data
600
 
601
        mov     [drbar.color], edi
602
 
603
        sub     edx, ebx
41 mikedld 604
        jle     .exit          ;// mike.dld, 2005-01-29
1 ha 605
        sub     ecx, eax
41 mikedld 606
        jle     .exit          ;// mike.dld, 2005-01-29
1 ha 607
        mov     [drbar.bar_sy], edx
608
        mov     [drbar.bar_sx], ecx
609
 
610
        mov     [drbar.bar_cx], eax
611
        mov     [drbar.bar_cy], ebx
612
 
613
        mov     edi, [0x3010]
614
        add     eax, [edi-twdw + 0] ; win_cx
615
        add     ebx, [edi-twdw + 4] ; win_cy
616
        mov     [drbar.abs_cx], eax
617
        mov     [drbar.abs_cy], ebx
618
 
619
        ; real_sx = MIN(wnd_sx-bar_cx, bar_sx);
620
        mov     ebx, [edi-twdw + 8] ; ebx = wnd_sx
621
        sub     ebx, [drbar.bar_cx]
622
        ja      @f
41 mikedld 623
  .exit:                       ;// mike.dld, 2005-01-29
1 ha 624
        add     esp, drbar.stack_data
625
        popad
626
        xor     eax, eax
627
        inc     eax
33 mario79 628
 
1 ha 629
        ret
630
      @@:
631
        cmp     ebx, [drbar.bar_sx]
632
        jbe     .end_x
633
        mov     ebx, [drbar.bar_sx]
634
      .end_x:
635
        mov     [drbar.real_sx], ebx
636
 
637
        ; real_sy = MIN(wnd_sy-bar_cy, bar_sy);
638
        mov     ebx, [edi-twdw + 12] ; ebx = wnd_sy
639
        sub     ebx, [drbar.bar_cy]
640
        ja      @f
641
        add     esp, drbar.stack_data
642
        popad
643
        xor     eax, eax
644
        inc     eax
33 mario79 645
 
1 ha 646
        ret
647
      @@:
648
        cmp     ebx, [drbar.bar_sy]
649
        jbe     .end_y
650
        mov     ebx, [drbar.bar_sy]
651
      .end_y:
652
        mov     [drbar.real_sy], ebx
653
 
654
        ; line_inc_map
655
        mov     eax, [ScreenWidth]
656
        sub     eax, [drbar.real_sx]
657
        inc     eax
658
        mov     [drbar.line_inc_map], eax
659
 
660
        ; line_inc_scr
661
        mov     eax, [drbar.real_sx]
662
        movzx   ebx, byte [ScreenBPP]
663
        shr     ebx, 3
664
        imul    eax, ebx
665
        neg     eax
666
        add     eax, [BytesPerScanLine]
667
        mov     [drbar.line_inc_scr], eax
668
 
669
        ; pointer to screen
670
        mov     edx, [drbar.abs_cy]
671
        imul    edx, [BytesPerScanLine]
672
        mov     eax, [drbar.abs_cx]
673
;        movzx   ebx, byte [ScreenBPP]
674
;        shr     ebx, 3
675
        imul    eax, ebx
676
        add     edx, eax
677
        add     edx, [LFBAddress]
678
 
679
        ; pointer to pixel map
680
        mov     eax, [drbar.abs_cy]
681
        imul    eax, [ScreenWidth]
682
        add     eax, [drbar.abs_cy]
683
        add     eax, [drbar.abs_cx]
684
        add     eax, WinMapAddress
685
        xchg    eax, ebp
686
 
687
        ; get process number
688
        mov     eax, [0x3010]
689
        mov     bl, [eax+0xE]
690
 
691
        cmp     byte [ScreenBPP], 24
692
        jne     draw_bar_end_32
693
draw_bar_end_24:
694
        ;cli ; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
695
        mov     eax, [drbar.color]    ;; BBGGRR00
696
        mov     bh, al                ;; bh  = BB
697
        shr     eax, 8                ;; eax = RRGG
698
; eax - color high   RRGG
699
; bl - process num
700
; bh - color low    BB
701
; ecx - temp
702
; edx - pointer to screen
703
; esi - counter
704
; edi - counter
705
 
706
        mov     esi, [drbar.real_sy]
707
        align   4
708
     .new_y:
709
        mov     edi, [drbar.real_sx]
710
        align   4
711
     .new_x:
712
 
713
        cmp     byte [ebp], bl
714
        jne     .skip
715
        mov     [edx], bh
716
        mov     [edx + 1], ax
717
      .skip:
718
 
719
        ; add pixel
720
        add     edx, 3
721
        inc     ebp
722
 
723
        dec     edi
724
        jnz     .new_x
725
 
726
        ; add line
727
        add     edx, [drbar.line_inc_scr]
728
        add     ebp, [drbar.line_inc_map]
729
 
730
    ;  drawing gradient bars
731
        test    eax, 0x00800000
732
        jz      @f
733
        test    bh, bh
734
        jz      @f
735
        dec     bh
736
      @@:
737
    ; 
738
 
739
        dec     esi
740
        jnz     .new_y
741
 
742
        add     esp, drbar.stack_data
743
        popad
744
        xor     eax, eax
745
        ;sti ; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
746
ret
747
 
748
draw_bar_end_32:
749
        mov     eax, [drbar.color]    ;; BBGGRR00
750
 
751
        mov     esi, [drbar.real_sy]
752
        align   4
753
     .new_y:
754
        mov     edi, [drbar.real_sx]
755
        align   4
756
     .new_x:
757
 
758
        cmp     byte [ebp], bl
759
        jne     .skip
760
        mov     [edx], eax
761
      .skip:
762
 
763
        ; add pixel
764
        add     edx, 4
765
        inc     ebp
766
 
767
        dec     edi
768
        jnz     .new_x
769
 
770
        ; add line
771
        add     edx, [drbar.line_inc_scr]
772
        add     ebp, [drbar.line_inc_map]
773
 
774
    ;  drawing gradient bars
775
        test    eax, 0x80000000
776
        jz      @f
777
        test    al, al
778
        jz      @f
779
        dec     al
780
      @@:
781
    ; 
782
 
783
        dec     esi
784
        jnz     .new_y
785
 
786
        add     esp, drbar.stack_data
787
        popad
788
        xor     eax, eax
33 mario79 789
 
1 ha 790
ret
791
 
792
 
793
;voodoodbcplimit:
794
 
795
; ebp:=(y+Ywin)*(ScreenXSize+1)+(x+Xwin)+AddrBuffer
796
 
797
 
798
;     pusha
799
 
800
;     xor edx,edx
801
;     mov eax,ebp
802
;     mov ebx,[ScreenWidth] ; Screen_X_size
803
;     inc ebx   ; +1
804
;     sub eax,WinMapAddress ; -AddrBuffer
805
;     div ebx ;
806
;     mov ebx,eax ; ebx:=Y
807
;     mov eax,edx ; eax:=X
808
;     call cplimit
809
 
810
;     test ecx,ecx
811
;     jne  dbcpl12
812
;     popa
813
;     clc
814
;     ret
815
;   dbcpl12:
816
;     popa
817
;     stc
818
;     ret
819
 
820
 
821
 
822
 
823
;dbcplimit:
824
 
825
;        pusha
826
 
827
;        xor  edx,edx
828
;        mov  ebx,[ScreenWidth]
829
;        inc  ebx
830
;        sub  eax,WinMapAddress
831
;        div  ebx
832
;        mov  ebx,eax
833
;        mov  eax,edx
834
;        call cplimit
835
 
836
;        test ecx,ecx
837
;        jne  dbcpl1
838
;        popa
839
;        clc
840
;        ret
841
;     dbcpl1:
842
;        popa
843
;        stc
844
;        ret
845
 
846
 
847
 
848
 
849
 
850
 
851
;--------------vbe voodoo ------------------------------------------------
852
vesa20_drawbackground_tiled:
853
 
854
     call [disable_mouse]
855
 
856
     push ebp
857
     push eax
858
     push ebx
859
     push ecx
860
     push edx
861
 
862
     mov edx,dword [WinMapAddress-8] ; B
863
     add edx,dword [WinMapAddress-8] ; +B
864
     add edx,dword [WinMapAddress-8] ; +B
865
     push edx
866
 
867
     mov ebp,[draw_data+32+0] ; x start:=(x+Xwin)
868
     mov ebx,[draw_data+32+4] ; y start:=(y+Ywin)
869
 
870
     mov eax,[BytesPerScanLine]
871
     mul ebx
872
     xchg ebp, eax  ; BytesPerScanLine*(Ywin+y)
873
     add ebp, eax   ; +X
874
     add ebp, eax   ; +X
875
     add ebp, eax   ; +X
876
 
877
     cmp [ScreenBPP],byte 24 ; 24 or 32 bpp ? - x size
878
     jz @f
879
     add ebp,eax ; +X
880
   @@:
881
     add ebp,[LFBAddress]  ; +LFB
882
 
883
     ; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
884
 
885
     call calculate_edi
886
 
887
 
888
   dp3:                             ; MAIN LOOP
889
 
890
     cmp [edi+WinMapAddress],byte 1 ; ptrBuffer^<>byte(1)
891
;     je  ybgp
892
;
893
;     jmp nbgp
894
;
895
;   ybgp:
896
     jne nbgp
897
 
898
     push eax
899
     push ebx
900
 
901
     mov ecx,dword [WinMapAddress-8]    ; B
902
     xor edx,edx                   ; edx:=0
903
     div ecx                       ; Xstart/B
904
 
905
     ; eax=Int(qn) edx:=Rem
906
 
907
     lea esi,[edx+edx*2]           ; esi:=edx*3
908
 
909
     mov ecx,dword [WinMapAddress-4]    ; ecx:=H
910
     mov eax,[esp+0]               ; eax:=Ystart
911
     xor edx,edx                   ;
912
     div ecx                       ; Ystart/H
913
 
914
     mov eax,edx                   ; eax:=Rem
915
     xor edx,edx                   ;
916
     mov ebx,[esp+8]               ; ebx:=B*3
917
     mul ebx                       ;
918
     add esi,eax                   ;
919
     mov eax,[esi+0x300000]
920
     and eax,0xffffff
921
 
922
     xchg edi, ebp
923
     stosw
924
     shr eax,16
925
     stosb
926
     xchg ebp, edi                 ; ebp+=3
927
     cmp [ScreenBPP],byte 24       ; 24 or 32 bpp ? - x size
928
     jz @f
929
     inc ebp ; +1
930
   @@:
931
 
932
     pop ebx
933
     pop eax
934
 
935
     jmp hook1
936
 
937
   nbgp:
938
     add ebp,3                     ; +3
939
     cmp [ScreenBPP],byte 24       ; 24 or 32 bpp ? - x size
940
     jz  @f
941
     inc ebp ; +1
942
   @@:
943
 
944
   hook1:
945
 
946
     inc edi                       ; ptrBuffer++
947
     add esi,3                     ; ptrImage+=3
948
     inc eax
949
     cmp eax,[draw_data+32+8]         ; X > xend?
950
;     jg nodp3
951
;     jmp dp3
952
;
953
;   nodp3:
954
     jle dp3
955
 
956
     mov ebp,[draw_data+32+0]
957
 
958
     inc ebx
959
 
960
     mov  eax,[BytesPerScanLine]
961
     mul  ebx
962
     xchg ebp, eax                 ; BytesPerScanLine*(Ywin+y)
963
     add  ebp, eax                 ; +X
964
     add  ebp, eax                 ; +X=X*2
965
     add  ebp, eax                 ; +X=X*3
966
     cmp  [ScreenBPP],byte 24      ; 24 or 32 bpp ? - x size
967
     jz   @f
968
     add  ebp,eax                  ; +X=X*4
969
   @@:
970
     add ebp,[LFBAddress]          ; +LFB
971
 
972
     ; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
973
 
974
     call calculate_edi
975
 
976
     cmp ebx,[draw_data+32+12]
977
;     jg  dp4
978
;
979
;     jmp dp3
980
;
981
;   dp4:
982
     jle dp3
983
 
984
     add esp,4
985
 
986
     pop edx
987
     pop ecx
988
     pop ebx
989
     pop eax
990
     pop ebp
991
 
992
     ret
993
 
994
; ----------
995
 
996
 
997
vesa20_drawbackground_stretch:
998
 
999
     call  [disable_mouse]
1000
 
1001
     push ebp
1002
     push eax
1003
     push ebx
1004
     push ecx
1005
     push edx
1006
 
1007
     mov edx,dword [WinMapAddress-8] ; B
1008
     add edx,dword [WinMapAddress-8] ; +B
1009
     add edx,dword [WinMapAddress-8] ; +B
1010
     push edx
1011
 
1012
     mov ebp,[draw_data+32+0] ; x start:=(x+Xwin)
1013
     mov ebx,[draw_data+32+4] ; y start:=(y+Ywin)
1014
 
1015
     mov eax,[BytesPerScanLine]
1016
     mul ebx
1017
     xchg ebp, eax  ; BytesPerScanLine*(Ywin+y)
1018
     add ebp, eax   ; +X
1019
     add ebp, eax   ; +X
1020
     add ebp, eax   ; +X
1021
 
1022
     cmp [ScreenBPP],byte 24 ; 24 or 32 bpp ? - x size
1023
     jz  @f
1024
     add ebp,eax ; +X
1025
   @@:
1026
     add ebp,[LFBAddress] ; +LFB
1027
 
1028
     ; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
1029
 
1030
     call calculate_edi
1031
 
1032
 
1033
   sdp3:                            ; MAIN LOOP
1034
 
1035
     cmp [edi+WinMapAddress],byte 1     ; ptrBuffer^<>byte(1)
1036
     jne snbgp
1037
 
1038
     push eax
1039
     push ebx
1040
 
1041
     mov   eax,dword [WinMapAddress-8]
1042
     imul  eax, [esp+4]      ;4
1043
     xor   edx,edx
1044
     mov   ebx,[ScreenWidth]
1045
     div   ebx
1046
     lea   esi,[eax+eax*2]
1047
     mov   eax,dword [WinMapAddress-4]
1048
     imul  eax, [esp+0]      ;0
1049
     xor   edx,edx
1050
     mov   ebx,[ScreenHeight]
1051
     div   ebx
1052
     imul  eax, [esp+8]      ;8
1053
     add   esi,eax
1054
 
1055
     mov   eax,[esi+0x300000]
1056
     and   eax,0xffffff
1057
 
1058
     xchg edi, ebp
1059
     stosw
1060
     shr eax,16
1061
     stosb
1062
     xchg ebp, edi                 ; ebp+=3
1063
     cmp [ScreenBPP],byte 24       ; 24 or 32 bpp ? - x size
1064
     jz  @f
1065
     inc ebp ; +1
1066
   @@:
1067
 
1068
     pop ebx
1069
     pop eax
1070
 
1071
     jmp shook1
1072
 
1073
   snbgp:
1074
     add  ebp,3                     ; +3
1075
     cmp [ScreenBPP],byte 24        ; 24 or 32 bpp ? - x size
1076
     jz  @f
1077
     inc ebp ; +1
1078
   @@:
1079
 
1080
   shook1:
1081
 
1082
     inc edi                       ; ptrBuffer++
1083
     add esi,3                     ; ptrImage+=3
1084
     inc eax
1085
     cmp eax,[draw_data+32+8]         ; X > xend?
1086
     jle sdp3
1087
 
1088
     mov ebp,[draw_data+32+0]
1089
 
1090
     inc ebx
1091
 
1092
     mov  eax,[BytesPerScanLine]
1093
     mul  ebx
1094
     xchg ebp, eax                 ; BytesPerScanLine*(Ywin+y)
1095
     add  ebp, eax                 ; +X
1096
     add  ebp, eax                 ; +X=X*2
1097
     add  ebp, eax                 ; +X=X*3
1098
     cmp  [ScreenBPP],byte 24      ; 24 or 32 bpp ? - x size
1099
     jz   @f
1100
     add  ebp,eax                  ; +X=X*4
1101
   @@:
1102
     add ebp,[LFBAddress]          ; +LFB
1103
 
1104
     ; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
1105
 
1106
     call calculate_edi
1107
 
1108
     cmp ebx,[draw_data+32+12]
1109
     jle sdp3
1110
 
1111
     add esp,4
1112
 
1113
     pop edx
1114
     pop ecx
1115
     pop ebx
1116
     pop eax
1117
     pop ebp
1118
 
1119
     ret