Subversion Repositories Kolibri OS

Rev

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