Subversion Repositories Kolibri OS

Rev

Rev 425 | Rev 469 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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