This project is read-only.

3rd Pallet Entry Doesn't Work?

Aug 27, 2010 at 7:44 PM
Edited Aug 28, 2010 at 6:03 AM

I decided to squeeze two questions in here ;)

 

I finally managed to convert my boot logo to a uint array consisting of the color numbers in the first 16(0-15) pallet entries (They're just the default console colors for now ;) ), but now I'm stuck. :(

It draws just fine, except pallet entry three (a dark cyan) show up as black...

 

I'll post the source when I get the chance to :)

Aug 29, 2010 at 7:05 AM

Anyone? This is a real problem for me :(

Aug 29, 2010 at 1:16 PM

The current graphics code currently is only experimental. We need to fix current issues around interrupts etc before we can revisit graphics. I suggest for you you dig into the existing source code which supports the graphics.

Aug 29, 2010 at 9:39 PM
Edited Aug 29, 2010 at 9:39 PM

Please see some of the other posts on in the discussions regarding drawing images. If Cyan is showing as black then either your code is wrong, or you need to set the palette entry for it correctly.

Aug 29, 2010 at 10:36 PM

Yes, I looked into those, but their code returned one solid color, while mine actually shows multiple colors. Basically, what I did is set the first 15 colors to the default console colors.

Aug 30, 2010 at 9:52 AM
Edited Aug 30, 2010 at 10:10 AM

I understand that, but without seeing code I can only guess what your error is. And from what you have said: either you're decoding/encoding your image wrong or you are not setting the palette for cyan correct.

Aug 30, 2010 at 3:17 PM

Alright, here's the code:

 

private static uint[] screenbuffer = new uint[512000];
public static uint inviscolor = 255; //Some value that won�t be assigned to a color. Used to designate a pixel with no color info.
public static uint backColour = 255;

 

 

 

	public static void SetUpPallet()
        {
            Screen.SetPaletteEntry(0, 0, 0, 0);
            Screen.SetPaletteEntry(1, 0, 0, 128);
            Screen.SetPaletteEntry(2, 0, 128, 0);
            Screen.SetPaletteEntry(3, 0, 128, 128);
            Screen.SetPaletteEntry(4, 128, 0, 0);
            Screen.SetPaletteEntry(5, 128, 0, 128);
            Screen.SetPaletteEntry(6, 128, 128, 0);
            Screen.SetPaletteEntry(7, 192, 192, 192);
            Screen.SetPaletteEntry(8, 128, 128, 128);
            Screen.SetPaletteEntry(9, 0, 0, 255);
            Screen.SetPaletteEntry(10, 0, 255, 0);
            Screen.SetPaletteEntry(11, 0, 255, 255);
            Screen.SetPaletteEntry(12, 255, 0, 0);
            Screen.SetPaletteEntry(13, 255, 0, 255);
            Screen.SetPaletteEntry(14, 255, 255, 0);
            Screen.SetPaletteEntry(15, 255, 255, 255);
            Screen.SetPaletteEntry(255, 0, 0, 0);

        }

        public static void BootScreenv02()
        {
            Utilities.SetupEnviroment();
            for (int zxc = 0; zxc < 512320; zxc++)
            {
                screenbuffer[zxc] = inviscolor;
            }
            Screen.SetMode320x200x8();
            
            reDrawScreen(15);
            DrawImage(iceboot, 0, 0, 165, 198);
            reDrawScreen(15);
            Utilities.readf();
            Screen.SetTextMode(VGAScreen.TextSize.Size80x25);
            Utilitys.clearf();
            Utilities.SetColorsToDefalt();
            Utilities.printf("Welcome to the Interactive Command Environment Version 0.1!\nType help for a list of valid commands. To exit, type shutdown.\n", ConsoleColor.DarkGray, ConsoleColor.Black);
            Utilities.Wait(7000);
            Utilities.clearf();
            Utilities.printf("Welcome to the Interactive Command Environment Version 0.1!\nType help for a list of valid commands. To exit, type shutdown.\n", ConsoleColor.DarkYellow, ConsoleColor.Black);
            Utilities.Wait(7000);
            Utilities.clearf();
            Utilities.printf("Welcome to the Interactive Command Environment Version 0.1!\nType help for a list of valid commands. To exit, type shutdown.\n", ConsoleColor.Yellow, ConsoleColor.Black);
            Utilities.Wait(80000);
        }

 

 

	public static void DrawImage(uint[] image, uint x, uint y,uint sx, uint sy)
        {
            /*uint counter = 0;
            for (uint xx = x; xx < sx + x; xx++)
            {
                for (uint yy = y; yy < sy + y; yy++, counter++)
                {
                    uint color = image[counter];
                    //screenbuffer[yy * 320 + xx] = color;
                    Screen.SetPixel320x200x8(x + xx,y + yy,color);
                    counter++;
                }
            }*/
            for (uint i = 0; i < sx; i++)
            {
                for (uint t = 0, count = 0; t < sy; t++, count++)
                {
                    screenbuffer[t * 320 + i] = image[count];
                }
            }
        }

 

 

	public static void reDrawScreen(uint color)
        {
            for (uint xx = 0; xx < 320; xx++)
            {
                for (uint yy = 0; yy < 200; yy++)
                {
                    uint num = yy * 320 + xx;
                    if ((uint)screenbuffer[num] != inviscolor)
                        Screen.SetPixel320x200x8(xx, yy, screenbuffer[num]); //Screen.SetPixel320x200x8(num, screenbuffer[num]);
                    //I can�t remember which function I added, so if the un-commented one isn�t available, use the commented one instead.
                    else
                        Screen.SetPixel320x200x8(xx, yy, color); //Screen.SetPixel320x200x8(num, color);
                    //I can�t remember which function I added, so if the un-commented one isn�t available, use the commented one instead.
                    screenbuffer[num] = inviscolor; //clears the buffer after the pixel is drawn.
                }
            }
        }

 

Aug 31, 2010 at 12:01 AM

as i said before your rgb color values have to be 0 - 63 although i dont see why that would bake yan show as black

Aug 31, 2010 at 12:10 AM

Actually, the redraw screen scans the screenbuffer and draws it, excluding the transparency value of 255.

Aug 31, 2010 at 11:18 AM
Edited Aug 31, 2010 at 11:19 AM

dalutzx is correct.

 

  Screen.SetPaletteEntry(0, 0, 0, 0);
            Screen.SetPaletteEntry(1, 0, 0, 128);
            Screen.SetPaletteEntry(2, 0, 128, 0);
            Screen.SetPaletteEntry(3, 0, 128, 128);
            Screen.SetPaletteEntry(4, 128, 0, 0);
            Screen.SetPaletteEntry(5, 128, 0, 128);
            Screen.SetPaletteEntry(6, 128, 128, 0);
            Screen.SetPaletteEntry(7, 192, 192, 192);
            Screen.SetPaletteEntry(8, 128, 128, 128);
            Screen.SetPaletteEntry(9, 0, 0, 255);
            Screen.SetPaletteEntry(10, 0, 255, 0);
            Screen.SetPaletteEntry(11, 0, 255, 255);
            Screen.SetPaletteEntry(12, 255, 0, 0);
            Screen.SetPaletteEntry(13, 255, 0, 255);
            Screen.SetPaletteEntry(14, 255, 255, 0);
            Screen.SetPaletteEntry(15, 255, 255, 255);
            Screen.SetPaletteEntry(255, 0, 0, 0);

All these numbers must be range from 0-63. It shows up as black because:
Screen.SetPaletteEntry(3, 0, 128, 128);
128 & 0x3f = 0
Oct 11, 2010 at 6:17 AM

D:     you used some of my code. [that in and of itself may be the problem. ;)  ]

Sorry if the numbers where misguiding.
(I didn't really know about the 0-63 issue until now either. 0-255 worked back in revision 38782 [maybe because I made them byte, instead of uint])