High Res VGA Working!

Topics: Developing Cosmos (Working on Cosmos source code directly), Using Cosmos (Developing your own OS, projects, etc)
Sep 27, 2012 at 2:29 AM

I got VGA working with High Res!
But I could not figure out how to write a GetPixel function for 640x480 and 720x480. So if someone would not mind writing that, that would be epic.

http://pastebin.com/tdFa4QuJ

My youtube Cosmos Dev channel: http://www.youtube.com/user/PearOSDev?feature=mhee

Anyways, there you go. 640x480 and 720x480 both work. The VGAColors and Color class are usedfor the resolutions to take high color images/colors to colors that match the resolutionor the color close to it. Thanks - Matt

Developer
Sep 27, 2012 at 2:31 AM
On 27/09/12 12:00, civilwarrock wrote:

From: civilwarrock

I got VGA working with High Res!
But I could not figure out how to write a GetPixel function for 640x480 and 720x480. So if someone would not mind writing that, that would be epic.

http://pastebin.com/tdFa4QuJ

My youtube Cosmos Dev channel: http://www.youtube.com/user/PearOSDev?feature=mhee

Anyways, there you go. 640x480 and 720x480 both work. The VGAColors and Color class are usedfor the resolutions to take high color images/colors to colors that match the resolutionor the color close to it. Thanks - Matt

640x480x16 means 16 million colours. Not 16...
Sep 27, 2012 at 2:39 AM
Cman332 wrote:
On 27/09/12 12:00, civilwarrock wrote:

From: civilwarrock

I got VGA working with High Res!
But I could not figure out how to write a GetPixel function for 640x480 and 720x480. So if someone would not mind writing that, that would be epic.

http://pastebin.com/tdFa4QuJ

My youtube Cosmos Dev channel: http://www.youtube.com/user/PearOSDev?feature=mhee

Anyways, there you go. 640x480 and 720x480 both work. The VGAColors and Color class are usedfor the resolutions to take high color images/colors to colors that match the resolutionor the color close to it. Thanks - Matt

640x480x16 means 16 million colours. Not 16...

I've tried to set more than 16 palette entry's and it doesn't work. You can set all kinds of colors, but you can only have 16 pallette's. Hence '16'. =)

Sep 27, 2012 at 2:43 AM

We understand Matt. We're saying the 16 in the resolution isn't the number of palettes. Because in 320x200x8 you can have 16 palettes.

On Sep 26, 2012 10:39 PM, "civilwarrock" <notifications@codeplex.com> wrote:

From: civilwarrock

Cman332 wrote:
On 27/09/12 12:00, civilwarrock wrote:

From: civilwarrock

I got VGA working with High Res!
But I could not figure out how to write a GetPixel function for 640x480 and 720x480. So if someone would not mind writing that, that would be epic.

http://pastebin.com/tdFa4QuJ

My youtube Cosmos Dev channel: http://www.youtube.com/user/PearOSDev?feature=mhee

Anyways, there you go. 640x480 and 720x480 both work. The VGAColors and Color class are usedfor the resolutions to take high color images/colors to colors that match the resolutionor the color close to it. Thanks - Matt

640x480x16 means 16 million colours. Not 16...

I've tried to set more than 16 palette entry's and it doesn't work. You can set all kinds of colors, but you can only have 16 pallette's. Hence '16'. =)

Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@discussions.codeplex.com)

To start a new discussion for this project, email Cosmos@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Sep 27, 2012 at 2:45 AM
DelfinoIsland wrote:

We understand Matt. We're saying the 16 in the resolution isn't the number of palettes. Because in 320x200x8 you can have 16 palettes.

On Sep 26, 2012 10:39 PM, "civilwarrock" <notifications@codeplex.com> wrote:

From: civilwarrock

Cman332 wrote:
On 27/09/12 12:00, civilwarrock wrote:

From: civilwarrock

I got VGA working with High Res!
But I could not figure out how to write a GetPixel function for 640x480 and 720x480. So if someone would not mind writing that, that would be epic.

http://pastebin.com/tdFa4QuJ

My youtube Cosmos Dev channel: http://www.youtube.com/user/PearOSDev?feature=mhee

Anyways, there you go. 640x480 and 720x480 both work. The VGAColors and Color class are usedfor the resolutions to take high color images/colors to colors that match the resolutionor the color close to it. Thanks - Matt

640x480x16 means 16 million colours. Not 16...

I've tried to set more than 16 palette entry's and it doesn't work. You can set all kinds of colors, but you can only have 16 pallette's. Hence '16'. =)

Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@discussions.codeplex.com)

To start a new discussion for this project, email Cosmos@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Oh lol. I didn't know that! Now I feel dumb, I just saw the 320x480x256 and thought 256 meant only 256 pallette's and 640x480x16 meant only 16 pallette's, but I guess that stands for something else! =) Oops. - Matt

Sep 27, 2012 at 2:55 AM

The third number in the resolution is the number of colours. Like Cman said, 16 is 16 million. You just multiply the number times one million. Don't feel dumb, I once thought the same. Live and learn.

Your Friend,
Eamon

On Sep 26, 2012 10:46 PM, "civilwarrock" <notifications@codeplex.com> wrote:

From: civilwarrock

DelfinoIsland wrote:

We understand Matt. We're saying the 16 in the resolution isn't the number of palettes. Because in 320x200x8 you can have 16 palettes.

On Sep 26, 2012 10:39 PM, "civilwarrock" <notifications@codeplex.com> wrote:

From: civilwarrock

Cman332 wrote:
On 27/09/12 12:00, civilwarrock wrote:

From: civilwarrock

I got VGA working with High Res!
But I could not figure out how to write a GetPixel function for 640x480 and 720x480. So if someone would not mind writing that, that would be epic.

http://pastebin.com/tdFa4QuJ

My youtube Cosmos Dev channel: http://www.youtube.com/user/PearOSDev?feature=mhee

Anyways, there you go. 640x480 and 720x480 both work. The VGAColors and Color class are usedfor the resolutions to take high color images/colors to colors that match the resolutionor the color close to it. Thanks - Matt

640x480x16 means 16 million colours. Not 16...

I've tried to set more than 16 palette entry's and it doesn't work. You can set all kinds of colors, but you can only have 16 pallette's. Hence '16'. =)

Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@discussions.codeplex.com)

To start a new discussion for this project, email Cosmos@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Oh lol. I didn't know that! Now I feel dumb, I just saw the 320x480x256 and thought 256 meant only 256 pallette's and 640x480x16 meant only 16 pallette's, but I guess that stands for something else! =) Oops. - Matt

Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@discussions.codeplex.com)

To start a new discussion for this project, email Cosmos@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Sep 27, 2012 at 3:19 AM

Lol, Thanks Delfino. Well now we just need someone really smart to make a GetPixel for 640x480 and 720x480 cause I have no idea how, as you use 4 planes and a weird combination. So I have no idea, but I'm sure someone will figure it out. =). Well hope you guys find this useful, I jumped about 15 ft in the air when I found out it was working! =). Thanks, Matt.

Developer
Sep 27, 2012 at 3:21 AM
On 27/09/12 12:50, civilwarrock wrote:

From: civilwarrock

Lol, Thanks Delfino. Well now we just need someone really smart to make a GetPixel for 640x480 and 720x480 cause I have no idea how, as you use 4 planes and a weird combination. So I have no idea, but I'm sure someone will figure it out. =). Well hope you guys find this useful, I jumped about 15 ft in the air when I found out it was working! =). Thanks, Matt.

Why would you need a GetPixel function if you already have a Double buffer?
Sep 27, 2012 at 3:22 AM

svga works with higher resolutions. like 1280x720.

Developer
Sep 27, 2012 at 3:24 AM
On 27/09/12 12:52, jpal wrote:

From: jpal

svga works with higher resolutions. like 1280x720.

You aren't going to find VMWare SVGA anywhere but VMWare, which isn't practical.
Sep 27, 2012 at 3:27 AM

Looks like I found a bug, I couldn't ever figure out why the 640x480 setpixel didn't actually use the uint c's value, which controls the color. So looks like the Set Pixel has a bug, where its not even really using the color number you give it. Guess ill have to look for some better source for that. - Matt

Sep 27, 2012 at 5:47 AM

In the VGA.cs replace this method, with this new one.

Method:

private static void SetPixel_4(uint x, uint y, uint c)
        {
            uint wd_in_bytes = (uint)ScreenWidth / 8;
            uint off = wd_in_bytes * y + x / 8;
            x = (x & 7) * 1;
            byte mask = (byte)(0x80 >> (int)x);
            uint pmask = 1;
            for (byte p = 0; p < 4; p++)
            {
                SetPlane(p);
                if ((pmask & c) != 0)
                {
                    mIO.VGAMemoryBlock[off] = (byte)(mIO.VGAMemoryBlock[off] | mask);
                }
                else {
                    mIO.VGAMemoryBlock[off] = (byte)(mIO.VGAMemoryBlock[off] & ~mask);
                }
                pmask <<= 1;
            }
        }
That makes the set pixel work for the 640x480 and 720x480 resolutions. I tested it, so it should be fine. Enjoy! I love bug fixing, well sometimes. =) - Matt

Coordinator
Sep 27, 2012 at 12:09 PM
On 9/26/2012 10:32 PM, Cman332 wrote:
> 640x480x16 means 16 million colours. Not 16...

Nope, 16 million is x24.

x16 means 16 bit, which is 65536 colours.
Sep 27, 2012 at 1:18 PM
kudzu wrote:
On 9/26/2012 10:32 PM, Cman332 wrote:
> 640x480x16 means 16 million colours. Not 16...

Nope, 16 million is x24.

x16 means 16 bit, which is 65536 colours.

I see. Well guys guess what? After a bit of hacking, and some basic logic I was able to write a GetPixel function for the 640x480 and 720x480 resolutions!

Here the new GetPixel function

 

/// <summary>
        /// Gets a pixel.
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        public static uint GetPixel(uint x, uint y)
        {
            if (CurrentResolution == ScreenResolution.Res320x200x256)
            {
                return GetPixel_8(x, y);
            }
            else if (CurrentResolution == ScreenResolution.Res640x480x16 || CurrentResolution == ScreenResolution.Res640x480x2 || CurrentResolution == ScreenResolution.Res720x480x16)
            {
                return GetPixel_4(x, y);
            }
            else
            {
                return 0;
            }
        }

 

And then heres the actually void that gets called to get the pixel:

/// <summary>
        /// Gets a pixel, used for 640x480 and 720x480.
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        private static uint GetPixel_4(uint x, uint y)
        {
            uint wd_in_bytes = (uint)ScreenWidth / 8;
            uint off = wd_in_bytes * y + x / 8;
            uint pmask = 1;
            uint palletteid = 0;
            for (byte p = 0; p < 4; p++)
            {
                SetPlane(p);
                if (mIO.VGAMemoryBlock[off] == 255)
                {
                    palletteid += pmask;
                }
                pmask <<= 1;
            }
            return palletteid;
        }

There was no, docs or source on this. I don't think any OS not using the BIOS calls has been able to get a pixel for those modes. I figured it out, be reading the 4 planes values out, and noticing that 255 was in certain planes for certain colors and sometimes two planes. And I thought wait a second, maybe on the planes with 255 it uses pmask and adds it together to form the palette id, which would mean since pmask is usually 1, 2, 4, 8 it would mean a max of 16 colors I think. So I tried it, and sure enough, that's how it works. So like if I did Clear(13) for the 640x480 res, the pmask value for the planes with 255 would be (1,4,8) which 1+4+8 = 13. =) I tried this theory 8 times on different palette entry's. Works flawlessly. But now you get read your pixels for those res's too now! Enjoy! Matt

Coordinator
Sep 27, 2012 at 1:21 PM
On 9/26/2012 11:24 PM, Cman332 wrote:
> You aren't going to find VMWare SVGA anywhere but VMWare, which isn't
> practical.

VMware is our prime target right now, and supports VNC. So its very
practical.
Sep 27, 2012 at 1:30 PM
kudzu wrote:
On 9/26/2012 11:24 PM, Cman332 wrote:
> You aren't going to find VMWare SVGA anywhere but VMWare, which isn't
> practical.

VMware is our prime target right now, and supports VNC. So its very
practical.

We know, but most of us are not trying to write things for VMWare, were trying to get our stuff on real hardware because we like to see it work. However, yes the SVGA Driver is fun to mess with, but I know I like to actually see my OS boot on my laptop without VMWare, but plus, we did need some better VGA code. I mean the old one worked, but it was half between working and not working. This one fixes stuff, but also add new resolutions. I will be adding double buffer support, if I can manage it, and a few other functions like a drawrect that is really fast, and a blit function as well. Thanks, - Matt

Sep 27, 2012 at 6:05 PM

My bad. When I learned I was reading from Wikipedia. Figures. Either way, my first point was correct =)

On Sep 27, 2012 8:09 AM, "kudzu" <notifications@codeplex.com> wrote:

From: kudzu

On 9/26/2012 10:32 PM, Cman332 wrote:
> 640x480x16 means 16 million colours. Not 16...

Nope, 16 million is x24.

x16 means 16 bit, which is 65536 colours.

Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@discussions.codeplex.com)

To start a new discussion for this project, email Cosmos@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Developer
Sep 29, 2012 at 8:47 PM

Matt, how well does your driver handle high res text mode?