コード例 #1
0
        private unsafe void DrawPatternView(PatternViewer dest, byte[] src)
        {
            int  b0;
            int  b1;
            byte value;
            int  cvalue;

            var bmpdata = dest.pattern.LockBits(
                new Rectangle(new Point(0, 0), dest.pattern.Size),
                ImageLockMode.WriteOnly,
                PixelFormat.Format32bppArgb);

            var framebuf = (int *)bmpdata.Scan0.ToPointer();

            for (int z = 0; z < 2; z++)
            {
                int pal;
                pal = z == 0 ? PatternView.Pal0 : PatternView.Pal1;                 // change?

                for (int i = 0; i < 16; i++)
                {
                    for (int j = 0; j < 16; j++)
                    {
                        for (int x = 0; x < 8; x++)
                        {
                            for (int y = 0; y < 8; y++)
                            {
                                int address = (z << 12) + (i << 8) + (j << 4) + y;
                                b0 = (byte)((src[address] >> (7 - x)) & 1);
                                b1 = (byte)((src[address + 8] >> (7 - x)) & 1);

                                value  = (byte)(b0 + (b1 << 1));
                                cvalue = _nes.LookupColor(_nes.ppu.PALRAM[value + (pal << 2)]);
                                int adr = (x + (j << 3)) + (y + (i << 3)) * (bmpdata.Stride >> 2);
                                framebuf[adr + (z << 7)] = cvalue;
                            }
                        }
                    }
                }
            }

            dest.pattern.UnlockBits(bmpdata);
            dest.Refresh();
        }
コード例 #2
0
ファイル: NESPPU.cs プロジェクト: SaxxonPike/BizHawk
		private unsafe void DrawPatternView(PatternViewer dest, byte[] src, int[] FinalPalette, byte[] PALRAM)
		{
			int b0;
			int b1;
			byte value;
			int cvalue;

			var bmpdata = dest.pattern.LockBits(
				new Rectangle(new Point(0, 0), dest.pattern.Size),
				ImageLockMode.WriteOnly,
				PixelFormat.Format32bppArgb);

			int* framebuf = (int*)bmpdata.Scan0;
			for (int z = 0; z < 2; z++)
			{
				int pal;
				pal = z == 0 ? PatternView.Pal0 : PatternView.Pal1; // change?

				for (int i = 0; i < 16; i++)
				{
					for (int j = 0; j < 16; j++)
					{
						for (int x = 0; x < 8; x++)
						{
							for (int y = 0; y < 8; y++)
							{
								int address = (z << 12) + (i << 8) + (j << 4) + y;
								b0 = (byte)((src[address] >> (7 - x)) & 1);
								b1 = (byte)((src[address + 8] >> (7 - x)) & 1);

								value = (byte)(b0 + (b1 << 1));
								cvalue = FinalPalette[PALRAM[value + (pal << 2)]];
								int adr = (x + (j << 3)) + (y + (i << 3)) * (bmpdata.Stride >> 2);
								framebuf[adr + (z << 7)] = cvalue;
							}
						}
					}
				}
			}

			dest.pattern.UnlockBits(bmpdata);
			dest.Refresh();
		}