Subversion Repositories Kolibri OS

Rev

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