This project is read-only.

Why won't my pixels stay?

Mar 12, 2012 at 10:59 PM

I'm testing out the VGA functions of Cosmos by using the following code to draw a single white vertical line on a black background:

            var screen = new Cosmos.Hardware.VGAScreen();
            screen.SetMode320x200x8();
            screen.Clear(0);
           
            for (uint i = 0; i <= 100; i++)
            {
           
                    screen.SetPixel(2, i, 15);
            }

However, Cosmos draws this line, but then quickly dissolves of it by making it shorter and shorter until it fully disappears. The entire line is completely visible for like half a second. I found that the line will stay with code like the following:

            var screen = new Cosmos.Hardware.VGAScreen();
            screen.SetMode320x200x8();
            screen.Clear(0);

            for (int i = a; a <= 10000; a++)
            {
            for (uint i = 0; i <= 100; i++)
            {
           
                    screen.SetPixel(2, i, 15);
            } }

But it's not necessarily I choice I would like to make. Is there any reason this line won't stay painted on the screen? Any help would be appreciated.

Mar 12, 2012 at 11:19 PM
Nickersoft wrote:

I'm testing out the VGA functions of Cosmos by using the following code to draw a single white vertical line on a black background:

            var screen = new Cosmos.Hardware.VGAScreen();
            screen.SetMode320x200x8();
            screen.Clear(0);
           
            for (uint i = 0; i <= 100; i++)
            {
           
                    screen.SetPixel(2, i, 15);
            }

However, Cosmos draws this line, but then quickly dissolves of it by making it shorter and shorter until it fully disappears. The entire line is completely visible for like half a second. I found that the line will stay with code like the following:

            var screen = new Cosmos.Hardware.VGAScreen();
            screen.SetMode320x200x8();
            screen.Clear(0);

            for (int i = a; a <= 10000; a++)
            {
            for (uint i = 0; i <= 100; i++)
            {
           
                    screen.SetPixel(2, i, 15);
            } }

But it's not necessarily I choice I would like to make. Is there any reason this line won't stay painted on the screen? Any help would be appreciated.

Well now heres where I help. First of all Screen.Setpixel I have not used, but I do know that Screen.SetPixel320x200x8 I think it is works. So it might be the function you are using. And second you did not set a pallette entry. You need to.

So 

byte[] color = {255,255,255};

Screen.SetPallette(color,15);

I believe that is what it is.

Then you can use Screen.SetPixel(2,i,15) Because you have to tell set colors to the screen unless you do Screen.TestMode(); Hope it helps - Matt

Mar 13, 2012 at 1:10 AM

Thanks for letting me know about the palette entry. I changed my code to the following:

            var screen = new Cosmos.Hardware.VGAScreen();
            screen.SetMode320x200x8();
            screen.Clear(0);
            byte[] color = { 255, 255, 255 };
            screen.SetPalette(15, color);
            for (uint i = 0; i <= 100; i++)
            {

                screen.SetPixel320x200x8(2, i, 15);
              
             
            }

The line still won't stay.  Any more suggestions?

Mar 13, 2012 at 1:29 AM

I think I figured it out. I had to place the code in the module's BeforeRun() function instead of Run(). For some reason, Run() kept looping the code. Could this be my problem?

Mar 13, 2012 at 1:54 AM

Run always loops the code. Put your init stuff in before run and your drawing stuff in rum

On Mar 12, 2012 6:29 PM, "Nickersoft" <notifications@codeplex.com> wrote:

From: Nickersoft

I think I figured it out. I had to place the code in the module's BeforeRun() function instead of Run(). For some reason, Run() kept looping the code. Could this be my problem?

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