Page 1 of 1
VESA (again) draw a simple line
Posted: Thu Jun 12, 2003 12:17 pm
by engine252
ok i've been looking on the net for examples and non seem to actualy work so if some of you guys know how to simple draw a line in assembler (NASM) or to simple put a picel wood do aswell.
this is what i do i first swith to vesa mode 1024x768x32
and then i wood like to draw a line (well a few lines but 1 wood get me going)
code for switching to that mode :
setvesa:
mov ax,0x4f02
mov bx,280
int 0x10
Re:VESA (again) draw a simple line
Posted: Thu Jun 12, 2003 12:33 pm
by Slasher
hi,
your setup code is not the best cause you are using a fixed mode number which might not be for 1024x768x32 on another video card.
Also read the VESA docs very well they explain how to display a pixel.
In 32 bit mode you will need to place a double word at video offset calculates
offset = y*bytesperline+x*4; (i think this is right, don't have my docs here but this should give you an idea)
the double word have a format which you will find in the mode info block (read vesa doc for better explaination)
RRRRGGGGGBBBBB R - red, G - green, B - blue
y=m*x + c is one equation for a line
m=y2 - y1/ x2 - x1
so for any point (x,y) on the line that satisfies m above
y=m*(x2 - x) + y1
hope this helps
Re:VESA (again) draw a simple line
Posted: Thu Jun 12, 2003 2:39 pm
by Thunder
Code slasher,
I other document I saw that in 32bpp resolution pixel is made so:
byte | byte | byte | byte
------------------------------
? B G R
Engine252,
your setting vesa mode code is wrong, you need:
setvesa:
mov ax,0x4f02
mov bx,118h
int 0x10
Re:VESA (again) draw a simple line
Posted: Thu Jun 12, 2003 3:51 pm
by Pype.Clicker
thunder, what's the difference between engine's code and yours knowing that 280=0x118 ?
Re:VESA (again) draw a simple line
Posted: Fri Jun 13, 2003 2:53 am
by Thunder
Sorry...
I thaught, that 280 was in hex.
And how about 32bpp resolution and pixel color order?
Re:VESA (again) draw a simple line
Posted: Fri Jun 13, 2003 4:17 am
by Pype.Clicker
codeslasher's color scheme looks odd, indeed. Mainly because of the fact it only has 14 bits described.
afaik, the 32bit format is indeed "ARGB", but alpha value is ignored by the VESA card (only useful for offscreen buffers)
now, make sure you use a doubleword while writing to the onscreen memory for both faster access and keeping bytes ordering (remember
0xaa1266bb will write "bb" byte at [0], "66" byte at [1], etc.
thus if blue are absent, and red and green mixed, you're probably using the wrong endianness
Re:VESA (again) draw a simple line
Posted: Fri Jun 13, 2003 4:18 am
by Thunder
Now I managed
:
Color value is made so:
byte byte byte byte
G B R 0
Bye.