setup vga error

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
wangy414
Posts: 13
Joined: Sat Nov 25, 2006 9:06 pm
Location: china

setup vga error

Post 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.
Attachments
my screen after set vga mode
my screen after set vga mode
sc.jpg (34.45 KiB) Viewed 1744 times
m
Member
Member
Posts: 67
Joined: Sat Nov 25, 2006 6:33 am
Location: PRC

Re: setup vga error

Post 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?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post 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
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
wangy414
Posts: 13
Joined: Sat Nov 25, 2006 9:06 pm
Location: china

Post 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.
User avatar
Steve the Pirate
Member
Member
Posts: 152
Joined: Fri Dec 15, 2006 7:01 am
Location: Brisbane, Australia
Contact:

Post by Steve the Pirate »

You need to clear the screen, that's all. That fixed the problem for me..

-Stephen
My Site | My Blog
Symmetry - My operating system.
User avatar
bubach
Member
Member
Posts: 1223
Joined: Sat Oct 23, 2004 11:00 pm
Location: Sweden
Contact:

Post 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?
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub
wangy414
Posts: 13
Joined: Sat Nov 25, 2006 9:06 pm
Location: china

Post 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!
User avatar
bubach
Member
Member
Posts: 1223
Joined: Sat Oct 23, 2004 11:00 pm
Location: Sweden
Contact:

Post by bubach »

Ok, good. Merry christmas to you too!
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub
User avatar
carbonBased
Member
Member
Posts: 382
Joined: Sat Nov 20, 2004 12:00 am
Location: Wellesley, Ontario, Canada
Contact:

Post 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
smbogan
Member
Member
Posts: 29
Joined: Tue Nov 21, 2006 3:17 pm

Post 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.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post 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...
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
wangy414
Posts: 13
Joined: Sat Nov 25, 2006 9:06 pm
Location: china

Post 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.
Post Reply