예제 #1
0
        private Bitmap GetPattern(int addr)
        {
            Bitmap bmp = new Bitmap(8, 8);

            for (int y = 0; y < 8; ++y)
            {
                for (int x = 0; x < 8; ++x)
                {
                    int addr1 = addr + y;
                    int addr2 = addr + y + 8;
                    // Note: patternhigh should be same for both here
                    byte b1     = ppu.PatternTables[Ppu.PatternHigh(addr1)][Ppu.PatternLow(addr1)];
                    byte b2     = ppu.PatternTables[Ppu.PatternHigh(addr2)][Ppu.PatternLow(addr2)];
                    byte bit1   = (byte)((b1 >> (7 - x)) & 0x1);
                    byte bit2   = (byte)((b2 >> (7 - x)) & 0x1);
                    byte result = (byte)(bit2 << 1 | bit1);
                    int  color;
                    if (result == 3)
                    {
                        color = 0xFF << 24 | 0xFF0000;
                    }
                    else if (result == 2)
                    {
                        color = 0xFF << 24 | 0x00FF00;
                    }
                    else if (result == 1)
                    {
                        color = 0xFF << 24 | 0x0000FF;
                    }
                    else
                    {
                        color = 0;
                    }

                    if (result == 0)
                    {
                        bmp.SetPixel(x, y, Color.FromArgb(0, 0, 0, 0));
                    }
                    else
                    {
                        bmp.SetPixel(x, y, Color.FromArgb(color));
                    }

                    /*if (result == 0)
                     *  bmp.SetPixel(x, y, Color.FromArgb(0, 0, 0, 0));
                     * else
                     * {
                     *  int paletteEntry = ppu.Read(paletteAddr + result) % 64; // todo: bits
                     *  bmp.SetPixel(x, y, Color.FromArgb(0xFF << 24 | Palette[paletteEntry]));
                     * }*/
                }
            }

            return(bmp);
        }
예제 #2
0
        private Bitmap GetPattern(int addr, int paletteAddr)
        {
            Bitmap bmp = new Bitmap(8, 8);

            for (int y = 0; y < 8; ++y)
            {
                for (int x = 0; x < 8; ++x)
                {
                    int  addr1  = addr + y;
                    int  addr2  = addr + y + 8;
                    byte b1     = ppu.PatternTables[Ppu.PatternHigh(addr1)][Ppu.PatternLow(addr1)];
                    byte b2     = ppu.PatternTables[Ppu.PatternHigh(addr2)][Ppu.PatternLow(addr2)];
                    byte bit1   = (byte)((b1 >> (7 - x)) & 0x1);
                    byte bit2   = (byte)((b2 >> (7 - x)) & 0x1);
                    byte result = (byte)(bit2 << 1 | bit1);

                    /*byte intensity;
                     * if (result == 3)
                     *  intensity = 255;
                     * else if (result == 2)
                     *  intensity = 160;
                     * else if (result == 1)
                     *  intensity = 80;
                     * else
                     *  intensity = 0;
                     *
                     * if (result == 0)
                     *  bmp.SetPixel(x, y, Color.FromArgb(0,0,0,0));
                     * else
                     *  bmp.SetPixel(x, y, Color.FromArgb(intensity, intensity, intensity));*/
                    if (result == 0)
                    {
                        bmp.SetPixel(x, y, System.Drawing.Color.FromArgb(0, 0, 0, 0));
                    }
                    else
                    {
                        int paletteEntry = ppu.Read(paletteAddr + result) % 64; // todo: bits
                        bmp.SetPixel(x, y, System.Drawing.Color.FromArgb(0xFF << 24 | Palette[paletteEntry]));
                    }
                }
            }

            return(bmp);
        }