Subversion Repositories Kolibri OS

Rev

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