Page 1 of 1
VGA mode
Posted: Fri Mar 05, 2004 12:00 am
by St8ic
What VGA mode is 640x480? Is it 13h?
Thanks.
RE:VGA mode
Posted: Sat Mar 06, 2004 12:00 am
by St8ic
Sorry for the stupid question: 640x480 16 color graphic mode is 12h. I'm having problems drawing a desktop in 16-bit real mode (don't ask) though...
Does anyone have an example or code snippit? I just need to draw a colored box that is 640x480 pixels. My current code just draws two short horizontal lines then clears and does it again!
RE:VGA mode
Posted: Sat Mar 06, 2004 12:00 am
by ASHLEY4
HI
I think you would be best if you went to unreal mode,has you can use upto 4gb of memory.
ASHLEY4.
RE:VGA mode
Posted: Sun Mar 07, 2004 12:00 am
by common
I am assuming that you have a function in place to draw individual pixels? If not, you may want to create one. From that point forward, your only work would be calculating the areas around the box, then filling it in, one by one, one line down at a time. If you can draw a line, you can draw a box. Indeed, calling a function over and over is slower, but you will get the basics in doing it this way.
This may sound like a rather silly suggestion, but you could download and install libgd (and related libraries), as there are a number of examples which would accomplish things similiar to what you're trying to accomplish. It uses the same logic, at least.
Also, not sure what the suggestion concerning unreal mode has to do with what you're trying to do. It's also not standard and should generally be avoided.
RE:VGA mode
Posted: Sun Mar 07, 2004 12:00 am
by anton
Do you know how 16 color mode works? Do you know that it is not regular memory?
If you do, then paste your code, we will check:)
Anton.
RE:VGA mode
Posted: Sun Mar 07, 2004 12:00 am
by ASHLEY4
The suggestion concerning unreal mode has to do with this:
" Video mode 12H.
Resolution 640x480.
16 colours.
4 bits are required for each pixel.
Total storage required is 4*640*480 = 150K
However, only 64K addresses available.
Solution is to make the video RAM two-dimensional by bit-planes.
Special hardware is used to map 4 parallel memory chips to the video buffer address space.
A memory address in the video buffer is then used by four bytes from the four memory chips
A bit from the same position in each byte makes up the 4 bits representing a pixel.
To access a bit in a bit-plane needs
1) the byte-address in the video buffer.
2)to identify which memory chip, i.e. which bit plane by a register in the video card.
3)to identify which bit by another register in the video card.
Directly manipulating the video buffer then requires knowledge of the architecture of the video card."
So you are best do it with mode 13h (320x200 = 62.5k).
Or by going in to unreal mode you can do this:
BACKGROUND PROC
MOV ECX,0X25800
MOV AL,04h
REP STOSB
RET
BACKGROUND ENDP
ASHLEY4.
RE:VGA mode
Posted: Sun Mar 07, 2004 12:00 am
by St8ic
I'm taking Ashley4's suggestion to use mode 13h, but I'm not going to use unreal mode (real mode GUI is kinda the point). My current code to plot the desktop is:
//inc.h
unsigned char far*vidmem=(unsigned char far*)0xa0000; //define where video memory is
//inc.c
void plot(int x,int y,unsigned char colour)
{
vidmem[x+y*320]=colour; //map the pixel to video memory
}
//kernel.c
int x;
int y;
cls(); //clear text-mode screen
vidmode(); //set vga mode 13h
x = 0;
y = 0;
while(y <= 321){ //if the desktop isn't completely drawn then
plot(x,y,0x1); //draw the next pixel in blue
x = x+1; //get ready to draw the next pixel on this line
if(x >= 640){ //if we're done this line, go to the next one
x = 0;
y = y+1;
}
}
RE:VGA mode
Posted: Sun Mar 07, 2004 12:00 am
by St8ic
I changed plot(); to this:
void plot(int x,int y,unsigned char colour)
{
vidmem[x+(y<<8)+(y<<6)]=colour;
}
Slightly faster. I need to use a pallet for 256-color modes, right? How would I go about setting one of those up? By the way, I can use assembly in my OS, aswell.
RE:VGA mode
Posted: Sun Mar 07, 2004 12:00 am
by ASHLEY4
That is the best mode for real mode. here is a tip for making your gui,make a box ,fill in with the color you want, draw a line all the way around it, use 3 colors.
So say your box is gray,then make two of the lines dark gray and two light gray,this give you a 3d effext.
* * * * * * * * o dark gray = *, light gray = o
* o
* o
* o
*o o o o o o o
ASHLEY4.
RE:VGA mode
Posted: Sun Mar 07, 2004 12:00 am
by ASHLEY4
I can do no better than this link for. Graphics Programming Black Book
by Michael Abrash.
http://www.gamedev.net/reference/articl ... le1698.asp
ASHLEY4.
RE:VGA mode
Posted: Sun Mar 07, 2004 12:00 am
by ASHLEY4
This is code for VESA, not vga 640x480x16.
"Or by going in to unreal mode you can do this:
BACKGROUND PROC
MOV ECX,0X25800
MOV AL,04h
REP STOSB
RET
BACKGROUND ENDP"
ASHLEY4.