-
Notifications
You must be signed in to change notification settings - Fork 1
/
VESA20.INC
1208 lines (863 loc) · 26 KB
/
VESA20.INC
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; VESA20.INC ;;
;; ;;
;; Vesa 2.0 functions for MenuetOS ;;
;; ;;
;; Copyright 2002 Ville Turjanmaa ;;
;; Alexey, [email protected] ;;
;; - Voodoo compatible graphics ;;
;; Juan M. Caravaca ;;
;; - Graphics optimimizations eg. drawline ;;
;; ;;
;; See file COPYING for details ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; If you're planning to write your own video driver I suggest
; you replace the VESA12.INC file and see those instructions.
ScreenWidth equ 0xfe00
ScreenHeight equ 0xfe04
BytesPerScanLine equ 0xfe08
LFBAddress equ 0xfe80
ScreenBPP equ 0xfbf1
WinMapAddress equ 0x400000
vesa20_read_screen_pixel:
and eax, 0x3FFFFF
shl eax, 2
cmp byte [ScreenBPP], 24 ; 24 or 32 bpp ?
jz .no24bpp
shr eax, 2
lea eax, [eax+eax*2]
.no24bpp:
add eax, [LFBAddress]
mov eax, [eax]
and eax, 0x00ffffff
ret
; getpixel
;
; in:
; eax = x coordinate
; ebx = y coordinate
;
; ret:
; ecx = 00 RR GG BB
getpixel:
push eax
push ebx
push edx
push edi
call dword [0xe024]
pop edi
pop edx
pop ebx
pop eax
ret
Vesa20_getpixel24:
; eax = x
; ebx = y
imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier
lea edi, [eax+eax*2] ; edi = x*3
add edi, ebx ; edi = x*3+(y*y multiplier)
add edi, [LFBAddress] ; ebx = where pixel is in memory
mov ecx, [edi]
and ecx, 0xffffff
ret
Vesa20_getpixel32:
imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier
lea edi, [ebx+eax*4] ; edi = x*4+(y*y multiplier)
add edi, [LFBAddress] ; ebx = where pixel is in memory
mov ecx, [edi]
and ecx, 0xffffff
ret
vesa20_putimage:
call disable_mouse
mov [novesachecksum],dword 0
push ebp ;
mov esi, ebx
xor ebx, ebx
mov bx, dx ; ebx := y
shr edx, 16 ; edx := x
mov eax, [0x3010]
add edx, [eax-twdw] ; edx+=Xwin
add ebx, [eax-twdw+4]; ebx+=Ywin
mov edi, ebx ; edi:=(y+Ywin)
imul edi, dword [BytesPerScanLine] ; edi:=BPScanLine*(y+Ywin)
mov ebp, ebx ; ebp:=(y+Ywin)
imul ebp, [ScreenWidth]
add ebp, ebx ; (ScreenXSize+1)*(Y+YWin)
; +(x+Xwin)+AddrBuffer
lea edi, [edi + edx*4] ; edi += (X+XWin)*4
lea ebp, [ebp + edx + WinMapAddress] ; ebp:=(y+Ywin)*(SXSize+
; +(x+Xwin)+AddrBuffer
add edi, [LFBAddress]
xor ebx, ebx ; ebx:=H
mov bx, cx
shr ecx, 16 ; ecx = B
mov eax, ecx
shl ecx, 2 ; ecx *= 4
cmp byte [ScreenBPP], 32
jz .bpp32
; corrections for 24 bpp
sub edi, edx
sub ecx, eax
.bpp32:
; ecx:=B*PytesPerPixel
;mov esi,[esp+8] ; esi:=AddrImg
; check limits while draw ?
push ebx
mov edx, [0x3010]
cmp dword [edx+draw_data-0x3000+0], 0
jnz dbcblimitlset2
cmp dword [edx+draw_data-0x3000+4], 0
jnz dbcblimitlset2
mov ebx, [edx+draw_data-0x3000+8]
cmp ebx, [ScreenWidth] ; ecx <> Screen X size
jnz dbcblimitlset2
mov ebx, [edx+draw_data-0x3000+12]
cmp ebx, [ScreenHeight] ; ecx <> Screen Y size
jnz dbcblimitlset2
mov bh, 0
jmp dbcblimitlno2
dbcblimitlset2:
mov bh, 1
dbcblimitlno2:
mov bl, [edx+0xe]
cmp [ScreenBPP],byte 24 ; 24 or 32 bpp ?
jz pi24bit
jmp pi32bit
; eax = B
; ecx = B*PytesPerPixel
; edx = 0x3010
; esi = ptr to image data
; edi = ptr to screen where begining painting
; ds:ebp = ptr to windows map
; bh = 0 force
; 1 not force
; bl = window ID on windows map
pi24bit:
.RenderBlock:
push edi
push esi
push eax
push ebp
.RenderLine:
cmp bl,[ds:ebp]
jnz .imp24no
cmp bh, 0
jz .imp24yes
call voodoodbcplimit
jnz .imp24no
.imp24yes:
mov edx, [esi]
mov [edi], dx
shr edx, 16
mov [edi+2], dl
.imp24no:
add esi, 3 ; esi+=3 ptrImage+=3
add edi, 3 ; edi+=3 ptrScreen+=3
inc ebp
dec eax ; B--
jnz .RenderLine
pop ebp
pop eax
pop esi
pop edi
add edi, [BytesPerScanLine] ; ptrScreen+=BytesPerScanLine
add esi, ecx
add ebp, [ScreenWidth]
inc ebp
dec dword [esp] ; H--
jnz .RenderBlock
pop ebx
pop ebp
xor eax, eax
ret
pi32bit:
sub ecx, eax ; ecx = B*4 - B = B*3
.RenderBlock:
push edi
push esi
push eax
push ebp
.RenderLine:
cmp bl,[ds:ebp]
jnz .imp32no
cmp bh,0
jz .imp32yes
call voodoodbcplimit
jnz .imp32no
.imp32yes:
mov edx, [esi]
mov [edi], edx
.imp32no:
add esi, 3 ; esi+=3 ptrImage+=3
add edi, 4 ; edi+=4 ptrScreen+=4
inc ebp
dec eax ; B--
jnz .RenderLine
pop ebp
pop eax
pop esi
pop edi
add edi, [BytesPerScanLine] ; ptrScreen+=BytesPerScanLine
add esi, ecx
add ebp, [ScreenWidth]
inc ebp
dec dword [esp] ; H--
jnz .RenderBlock
pop ebx
pop ebp
xor eax, eax
ret
putpixel:
; eax = x coordinate
; ebx = y coordinate
; ecx = ?? RR GG BB ; 0x01000000 negation
; edi = 0x00000001 force
mov [novesachecksum], dword 0
pusha
test edi,1 ; force ?
jnz drawok2
noforce:
call checkpixel
cmp ecx, 0
jnz ppr
drawok2:
cmp [ScreenWidth], eax
jb ppr
cmp [ScreenHeight], ebx
jb ppr
ppok:
; check if negation
test ecx,0x01000000
jz noneg
call getpixel
not ecx
mov [esp+32-8],ecx
noneg:
; OK to set pixel
call dword [0xe020]
ppr:
popa
ret
Vesa20_putpixel24:
; eax = x
; ebx = y
imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier
lea edi, [eax+eax*2] ; edi = x*3
mov eax, [esp+32-8+4]
add edi, [LFBAddress]
add edi, ebx ; ebx = where to put pixel in memory
mov [edi], ax
shr eax, 16
mov [edi+2], al
ret
Vesa20_putpixel32:
; eax = x
; ebx = y
imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier
lea edi, [ebx+eax*4] ; edi = x*4+(y*y multiplier)
mov eax, [esp+32-8+4] ; eax = color
add edi, [LFBAddress] ; ebx = where to put pixel in memory
mov [edi], eax
ret
;-------------------------------------------------
calculate_edi:
mov edi, ebx
imul edi, [ScreenWidth]
add edi, ebx
add edi, eax
ret
;-------------------------------------------------
; DRAWLINE
draw_line:
call disable_mouse
; draw a line
; eax = HIWORD = x1
; LOWORD = x2
; ebx = HIWORD = y1
; LOWORD = y2
; ecx = color
; edi = force ?
pusha
dl_x1 equ esp+20
dl_y1 equ esp+16
dl_x2 equ esp+12
dl_y2 equ esp+8
dl_dx equ esp+4
dl_dy equ esp+0
xor edx, edx ; clear edx
xor esi, esi ; unpack arguments
xor ebp, ebp
mov si, ax ; esi = x2
mov bp, bx ; ebp = y2
shr eax, 16 ; eax = x1
shr ebx, 16 ; ebx = y1
push eax ; save x1
push ebx ; save y1
push esi ; save x2
push ebp ; save y2
; checking x-axis...
sub esi, eax ; esi = x2-x1
push esi ; save y2-y1
jl .x2lx1 ; is x2 less than x1 ?
jg .no_vline ; x1 > x2 ?
mov edx, ebp ; else (if x1=x2)
call vline
push edx ; necessary to rightly restore stack frame at .exit
jmp .exit
.x2lx1:
neg esi ; get esi absolute value
.no_vline:
; checking y-axis...
sub ebp, ebx ; ebp = y2-y1
push ebp ; save y2-y1
jl .y2ly1 ; is y2 less than y1 ?
jg .no_hline ; y1 > y2 ?
mov edx, [dl_x2] ; else (if y1=y2)
call hline
jmp .exit
.y2ly1:
neg ebp ; get ebp absolute value
.no_hline:
cmp ebp, esi
jle .x_rules ; |y2-y1| < |x2-x1| ?
cmp [dl_y2], ebx ; make sure y1 is at the begining
jge .no_reverse1
neg dword [dl_dx]
mov edx, [dl_x2]
mov [dl_x2], eax
mov [dl_x1], edx
mov edx, [dl_y2]
mov [dl_y2], ebx
mov [dl_y1], edx
.no_reverse1:
mov eax, [dl_dx]
cdq ; extend eax sing to edx
shl eax, 16 ; using 16bit fix-point maths
idiv ebp ; eax = ((x2-x1)*65536)/(y2-y1)
mov edx, ebp ; edx = counter (number of pixels to draw)
mov ebp, 1 *65536 ; <<16 ; ebp = dy = 1.0
mov esi, eax ; esi = dx
jmp .y_rules
.x_rules:
cmp [dl_x2], eax ; make sure x1 is at the begining
jge .no_reverse2
neg dword [dl_dy]
mov edx, [dl_x2]
mov [dl_x2], eax
mov [dl_x1], edx
mov edx, [dl_y2]
mov [dl_y2], ebx
mov [dl_y1], edx
.no_reverse2:
xor edx, edx
mov eax, [dl_dy]
cdq ; extend eax sing to edx
shl eax, 16 ; using 16bit fix-point maths
idiv esi ; eax = ((y2-y1)*65536)/(x2-x1)
mov edx, esi ; edx = counter (number of pixels to draw)
mov esi, 1 *65536 ;<< 16 ; esi = dx = 1.0
mov ebp, eax ; ebp = dy
.y_rules:
mov eax, [dl_x1]
mov ebx, [dl_y1]
shl eax, 16
shl ebx, 16
.draw:
push eax
push ebx
shr eax, 16
shr ebx, 16
call putpixel
pop ebx
pop eax
add ebx, ebp ; y = y+dy
add eax, esi ; x = x+dx
dec edx
jnz .draw
; force last drawn pixel to be at (x2,y2)
mov eax, [dl_x2]
mov ebx, [dl_y2]
call putpixel
.exit:
add esp, 6*4
popa
ret
hline:
; draw an horizontal line
; eax = x1
; edx = x2
; ebx = y
; ecx = color
; edi = force ?
push eax
push edx
cmp edx, eax ; make sure x2 is above x1
jge .draw_hline
xchg eax, edx
.draw_hline:
call putpixel
inc eax
cmp eax, edx
jle .draw_hline
pop edx
pop eax
ret
vline:
; draw a vertical line
; eax = x
; ebx = y1
; edx = y2
; ecx = color
; edi = force ?
push ebx
push edx
cmp edx, ebx ; make sure y2 is above y1
jge .draw_vline
xchg ebx, edx
.draw_vline:
call putpixel
inc ebx
cmp ebx, edx
jle .draw_vline
pop edx
pop ebx
ret
vesa20_drawbar:
call disable_mouse
mov [novesachecksum],dword 0
sub edx,ebx ; edx:=Yend-Ystart=H
sub ecx,eax ; ecx:=Xend-Xstat=B
push ebp ; +24
push esi ; +20
push edi ; +16
push eax ; +12
push ebx ; +8
push ecx ; +4
push edx ; +0
mov ecx,[0x3010] ;
add eax,[ecx-twdw] ; eax:=Xwin+x
add ebx,[ecx-twdw+4] ; ebx:=Ywin+y
mov ecx, eax ; ecx:=(x+Xwin)
mov eax, [BytesPerScanLine] ; BytesPerScanLine
mul ebx ; *(y+Ywin)
mov edi, eax ; edi:=BytesPerScanLine*(y+Ywin)
mov eax, [ScreenWidth] ; ScreenXSize
inc eax ; +1
mul ebx ; *(y+Ywin)
mov ebp, eax ;
add ebp, ecx ; +(x+Win)
add ebp, WinMapAddress ; ebp:=(y+Ywin)*(ScreenXSize+1)+(x+Xwin)+AdrBf
add edi,ecx ; +(x+Xwin)
add edi,ecx ; +(x+Xwin)
add edi,ecx ; +(x+Xwin)
cmp [ScreenBPP],byte 24 ; 24 or 32 bpp ? - x start
jz dbpi24
add edi,ecx ; +(x+Xwin)
dbpi24:
add edi,[LFBAddress] ; +AddrLFB
; edi:=(y+Ywin)*Screen_Y_multiplier+X*BytesPerPixel
; ebp:=(y+Ywin)*(ScreenXSize+1)+(x+Xwin)+AddrBuffer
; x size
mov eax,[esp+4] ; B [esp+4]
mov ecx,eax ; B
add ecx,eax ; +B
add ecx,eax ; +B
cmp [ScreenBPP],byte 24 ; 24 or 32 bpp ? - x size
jz dbpi243
add ecx,eax ; +B if 32bpp
; ecx:=B*BytesPerPixel, eax:=B
dbpi243:
mov ebx,[esp+0] ; H
; check limits ?
push eax
push ecx
mov eax,[0x3010]
mov ecx,[eax+draw_data-0x3000+0]
cmp ecx,0
jnz dbcblimitlset
mov ecx,[eax+draw_data-0x3000+4]
cmp ecx,0
jnz dbcblimitlset
mov ecx,[eax+draw_data-0x3000+8]
cmp ecx,[ScreenWidth]
jnz dbcblimitlset
mov ecx,[eax+draw_data-0x3000+12]
cmp ecx,[ScreenHeight]
jnz dbcblimitlset
pop ecx
pop eax
push dword 0
jmp dbcblimitlno
dbcblimitlset:
pop ecx ; B*BytesPerPixel
pop eax ; B
push dword 1
dbcblimitlno:
cmp [ScreenBPP],byte 24 ; 24 or 32 bpp ?
jz dbpi24bit
jmp dbpi32bit
; DRAWBAR 24 BBP
dbpi24bit:
mov ecx,eax ; B
cld
dbnewpi:
push ebx
push edi
push ecx ; B
mov ebx,[0x3010]
movzx ebx,byte[ebx+0xe]
cld
dbnp24:
mov dl,[ds:ebp]
push eax
push ecx
cmp dl,bl
jnz dbimp24no
mov eax,[esp+8+3*4+16+4] ; NoCurrentWin|NoCurrentWin
mov ecx,[esp+5*4]
cmp ecx,0
jz dbimp24yes
call voodoodbcplimit
jnz dbimp24no
dbimp24yes:
mov [edi],ax
shr eax,16
mov [edi+2],al
dbimp24no:
pop ecx
pop eax
add edi,3 ; ptrScreen+=3
inc ebp
dec ecx
jnz dbnp24 ; while ecx > 0
;
mov eax,[esp+3*4+16+4] ; color glide
test eax,0x80000000
jz nodbgl24
cmp al,0
jz nodbgl24
dec eax
mov [esp+3*4+16+4],eax
nodbgl24:
pop ecx ; ecx:=B
pop edi
pop ebx
add edi,[BytesPerScanLine] ; ptrScreen+=BytesPerScanLine
add ebp,[ScreenWidth] ;
sub ebp, ecx ;
inc ebp ; ptrBuffer:=ptrBuffer-B+BytesPerPixel+1
dec ebx ; H--
jz dbnonewpi ; H <> 0
jmp dbnewpi
dbnonewpi:
add esp,7*4
pop ebp
ret
; DRAWBAR 32 BBP
dbpi32bit:
cld
shr ecx,2
dbnewpi32:
push ebx
push edi
push ecx
mov ebx,[0x3010]
movzx ebx,byte[ebx+0xe]
cld
dbnp32:
mov dl,[ds:ebp]
push eax
push ecx
cmp dl,bl
jnz dbimp32no
mov eax,[esp+8+3*4+16+4]
mov ecx,[esp+5*4]
cmp ecx,0
jz dbimp32yes
call voodoodbcplimit
jnz dbimp32no
dbimp32yes:
mov [edi],ax
shr eax,16
mov [edi+2],al
dbimp32no:
pop ecx
pop eax
add edi,4 ; ptrScreen+=4
inc ebp
dec ecx
jnz dbnp32
dbnp32d:
mov eax,[esp+12+16+4] ; color glide
test eax,0x80000000
jz nodbgl32
cmp al,0
jz nodbgl32
dec eax
mov [esp+12+16+4],eax
nodbgl32:
pop ecx
pop edi
pop ebx
add edi,[BytesPerScanLine] ; ptrScreen+=BytesPerScanLine
add ebp,[ScreenWidth] ;
sub ebp, ecx ;
inc ebp ; ptrBuffer:=ptrBuffer-B+BytesPerPixel+1
dec ebx ; H--
jz nodbnewpi32 ; H<>0
jmp dbnewpi32
nodbnewpi32:
add esp,7*4
pop ebp
ret
voodoodbcplimit:
; ebp:=(y+Ywin)*(ScreenXSize+1)+(x+Xwin)+AddrBuffer
pusha
xor edx,edx
mov eax,ebp
mov ebx,[ScreenWidth] ; Screen_X_size
add ebx,1 ; +1
sub eax,WinMapAddress ; -AddrBuffer
div ebx ;
mov ebx,eax ; ebx:=Y
mov eax,edx ; eax:=X
call cplimit
cmp ecx,0
jne dbcpl12
popa
clc
ret
dbcpl12:
popa
stc
ret
dbcplimit:
pusha
xor edx,edx
mov ebx,[ScreenWidth]
add ebx,1
sub eax,WinMapAddress
div ebx
mov ebx,eax
mov eax,edx
call cplimit
cmp ecx,0
jne dbcpl1
popa
clc
ret
dbcpl1:
popa
stc
ret
;--------------vbe voodoo ------------------------------------------------
vesa20_drawbackground_tiled:
call disable_mouse
push ebp
push eax
push ebx
push ecx
push edx
mov edx,dword [WinMapAddress-8] ; B
add edx,dword [WinMapAddress-8] ; +B
add edx,dword [WinMapAddress-8] ; +B
push edx
mov ebp,[draw_data+32+0] ; x start:=(x+Xwin)
mov ebx,[draw_data+32+4] ; y start:=(y+Ywin)
mov eax,[BytesPerScanLine]
mul ebx
xchg ebp, eax ; BytesPerScanLine*(Ywin+y)
add ebp, eax ; +X
add ebp, eax ; +X
add ebp, eax ; +X
cmp [ScreenBPP],byte 24 ; 24 or 32 bpp ? - x size
jz bgl243
add ebp,eax ; +X
bgl243:
add ebp,[LFBAddress] ; +LFB
; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
call calculate_edi
dp3: ; MAIN LOOP
cmp [edi+WinMapAddress],byte 1 ; ptrBuffer^<>byte(1)
je ybgp
jmp nbgp
ybgp:
push eax
push ebx
mov ecx,dword [WinMapAddress-8] ; B
xor edx,edx ; edx:=0
div ecx ; Xstart/B
; eax=Int(qn) edx:=Rem
lea esi,[edx+edx*2] ; esi:=edx*3
mov ecx,dword [WinMapAddress-4] ; ecx:=H
mov eax,[esp+0] ; eax:=Ystart
xor edx,edx ;
div ecx ; Ystart/H
mov eax,edx ; eax:=Rem
xor edx,edx ;
mov ebx,[esp+8] ; ebx:=B*3
mul ebx ;
add esi,eax ;
mov eax,[esi+0x300000]
and eax,0xffffff
xchg edi, ebp
stosw
shr eax,16
stosb
xchg ebp, edi ; ebp+=3
cmp [ScreenBPP],byte 24 ; 24 or 32 bpp ? - x size
jz bgl24312
inc ebp ; +1
bgl24312:
pop ebx