hi, now i know the screen buffer flat address, but i dont know how the screen framebuffer managed, i mean how do i convert (x,y) to get the flat address position?

thanks
Posted on 2002-10-18 21:34:38 by dion
Non DDRAW(Pitch==Xres) (y*xres+x)+fbaddress
DDRAW (Pitch!=Xres) (y*pitch+x*bytesperpixel)+fbaddress
Posted on 2002-10-19 18:59:29 by x86asm
hi x86asm, how are u, long time no see ;)
ummm... i want to ask these:
1. could u explain me what pitch meant? please tell me more details ;)
2. how do u get this info from? might be directx help? but, how do u know the Non-DDRAW calculation?
3. i've though for a while and write out these two possible calculation:

example:
flataddr = A
screen resolution = 800*600 with 20h bpp
given(x,y) position
1st possible calc : flataddr = A + ((y*800)+y+x)*(bpp/8);
2nd possible calc : flataddr = A + ((x*800)+y+x)*(bpp/8);

which one is right? or both false? do i made a mistake here?

thanks in advance
Posted on 2002-10-20 06:24:30 by dion
The pitch is the number of bytes in one scanline. It is not necessarily equal to ScreenX*BytesPerPixel I think this is for alignment/speed reasons. The Non-DDRAW is the one I used in DOS for the 320x200 screen mode (invoked by setting ax to 0013h and invoking int 10h). BogdanOtanu was the one that explained this pitch to me before because I was exactly where you were! May I ask if you will be using DirectDraw?

I looked for an explanation on the pitch on the web:

Link 1 - MSDN:
http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/ddraw7/directdraw7/ddover_5bnb.asp

Link 2- Some unknown DDRAW tutorial site (it shows the formula for using pitch)http://modena.intergate.ca/personal/iago/dirxtut/dd3.htm
Posted on 2002-10-20 12:41:51 by x86asm
hi x86asm, i think we must make something clear here. i saw bpp definition in MSDN that said that it stands for bits per pixel, not byte per pixel. then about ur formulas :

quote:
Non DDRAW(Pitch==Xres)(y*xres+x)+fbaddress
DDRAW (Pitch!=Xres)(y*pitch+x*bytesperpixel)+fbaddress

i'm agree with the 1st one, but i doubt the 2nd. would it be (y*pitch+x)*byteperpixel+fbaddress ?

i'm wait ur reply...
Posted on 2002-10-21 07:33:50 by dion
Quote:
(y*pitch+x)*byteperpixel+fbaddress

This formula has a problem though as you see, for the "pitch" member it also includes the bytesPerPixel. For example, on my GeForce2MX video card. I set the screen resoulution to 800x600 16-bit color. But my GeForce2MX reports as the video pitch in this resolution as 800h (2048 dec). So the Y*Pitch member is kept seperate as the pitch member already takes into account the BytesPerPixel. It is the X that needs to be multiplied by BytesPerPixel. I hope this cleared everything for ya!
Posted on 2002-10-21 15:55:54 by x86asm