Subversion Repositories Kolibri OS

Rev

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