Subversion Repositories Kolibri OS

Rev

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