VESA (again) draw a simple line

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
engine252

VESA (again) draw a simple line

Post 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
Slasher

Re:VESA (again) draw a simple line

Post 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
Thunder

Re:VESA (again) draw a simple line

Post 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
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:VESA (again) draw a simple line

Post by Pype.Clicker »

thunder, what's the difference between engine's code and yours knowing that 280=0x118 ?
Thunder

Re:VESA (again) draw a simple line

Post by Thunder »

Sorry...
I thaught, that 280 was in hex.

And how about 32bpp resolution and pixel color order?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:VESA (again) draw a simple line

Post 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
Thunder

Re:VESA (again) draw a simple line

Post by Thunder »

Now I managed :D:

Color value is made so:
byte byte byte byte
G B R 0


Bye.
Post Reply