Page 1 of 1

setup vga error

Posted: Thu Dec 21, 2006 3:31 am
by wangy414
hi, I use Chris Giese code, modes_c.c.
after I set VgaMode320x200x256, I can't draw anything on my video.
the below is my screen.

Re: setup vga error

Posted: Thu Dec 21, 2006 5:17 am
by m
Hi.
wangy414 wrote:hi, I use Chris Giese code, modes_c.c.
after I set VgaMode320x200x256, I can't draw anything on my video.
the below is my screen.
I've come across the similar situation shown in the picture while using a few SVGA modes defined in VESA's VBE(just random pixels in the upper area of the screen).In my case the reason is that I didn't set the bit indicating clearing the video buffer(screen).But I can still set pixels on the screen(maybe you can do it as well but it's hard to find them among the chaosy pixels).
How about you?If it doesn't hit the point,will you post your code here?

Posted: Thu Dec 21, 2006 5:30 am
by Combuster
Assuming you have tried to set pixels already, you're not alone having difficulty with that mode... :cry:

I kindof get the same problem that chain-4 modes dont work. I'm still trying to figure how to get the VGA Sequencer to properly address the likes of mode 13h.

It seems most emulators and cards are more comfortable with Mode X addressing.

You can have a look at my code about how this works (BASIC):

Mode setting code
http://dimensionalrift.homelinux.net/co ... vga_io.bas
a Putpixel is near the end of this file
http://dimensionalrift.homelinux.net/co ... st_gfx.bas

I'm still working on getting linear modes to work - you should watch this wiki page. Once i figure what's going on i'll be posting it here as soon as i can: User:Combuster/VGAwip

Posted: Thu Dec 21, 2006 5:59 am
by wangy414
hi, firstly, thank you help.now, i know little about the vga.
I just reuse other's code. if you have document about the VGA.
Please give me a copy. thanks a lot.

Posted: Thu Dec 21, 2006 8:22 am
by Steve the Pirate
You need to clear the screen, that's all. That fixed the problem for me..

-Stephen

Posted: Thu Dec 21, 2006 9:28 am
by bubach
I'm wondering if "I can't draw anything on my video" means that you don't know how, or that it doesn't work?

Posted: Fri Dec 22, 2006 5:09 am
by wangy414
hi bubach, thank you. In your web, I find some documents. they are useful to me. my English is not very well. hope you can understand me .
Merry Christmas!

Posted: Fri Dec 22, 2006 8:57 am
by bubach
Ok, good. Merry christmas to you too!

Posted: Sat Dec 30, 2006 11:45 am
by carbonBased
wangy414 wrote:hi, firstly, thank you help.now, i know little about the vga.
I just reuse other's code. if you have document about the VGA.
Please give me a copy. thanks a lot.
Michael Abrash's Zen of Graphics Programming is a great book for manipulating the VGA registers directly. It contains code and documentation for the standard VGA modes and various custom (mode-x) vga modes.

--Jeff

Posted: Wed Jan 03, 2007 11:25 am
by smbogan
Combuster wrote:I kindof get the same problem that chain-4 modes dont work. I'm still trying to figure how to get the VGA Sequencer to properly address the likes of mode 13h.
You are talking about the switching of planes thing are you? Virtual PC seems to emulate chain4 nicely, from my experience, but I know that what runs in VPC may not run nicely on hardware. I've never done the BIOS method of VGA, but this code from my kernel seems to switch planes...if that's your problem...

Code: Select all

void set_chain4(int plane)
//0-3 planes, -1 is all
{
   char adr = inportb(0x3c4);
   if(plane != -1)
   {
      outportw(0x3c4, 0x2 | ( (0x1 << 8) << plane));
   }
   else
   {
      outportw(0x3c4, 0x0f02);
   }
}
I write to a linear buffer, then write each plane one at a time...like so:

Code: Select all

void vga_flush()
{
   char * video = 0xA0000;
   char * buffer = 0x80000;  //Pick your own buffer address!!!
   int chain = 0;

   for(;chain < 4; chain++)
   {
      set_chain4(chain);
      buffer = (char *)((int)0x80000 + chain);
      video = (char *)0xA0000;
      while(buffer < (char *)((int)0x80000 + (screen_width * screen_height)))
      {
         *video = *buffer;
         buffer = buffer + 4;
         video++;
      }
   }
}
Hope that helps. If I recall it worked well for me, but I put VGA on hold a while ago.

Posted: Wed Jan 03, 2007 11:33 am
by Combuster
Oh i fixed it a while ago (thought of this thread as dead so never bothered to update it). Turned out to be some stupid thing like writing to the wrong register :oops: At least it works now...

Posted: Wed Jan 03, 2007 7:42 pm
by wangy414
Thank you, I have solved the error. because I when I get the frame buffer, I can't map it into the correct address. Thank you.