private void NameTableView_MouseMove(object sender, MouseEventArgs e) { int TileX, TileY, NameTable; if (NameTableView.Which == NameTableViewer.WhichNametable.NT_ALL) { TileX = e.X / 8; TileY = e.Y / 8; NameTable = (TileX / 32) + ((TileY / 30) * 2); } else { switch (NameTableView.Which) { default: case NameTableViewer.WhichNametable.NT_2000: NameTable = 0; break; case NameTableViewer.WhichNametable.NT_2400: NameTable = 1; break; case NameTableViewer.WhichNametable.NT_2800: NameTable = 2; break; case NameTableViewer.WhichNametable.NT_2C00: NameTable = 3; break; } TileX = e.X / 16; TileY = e.Y / 16; } XYLabel.Text = TileX + " : " + TileY; int PPUAddress = 0x2000 + (NameTable * 0x400) + ((TileY % 30) * 32) + (TileX % 32); PPUAddressLabel.Text = string.Format("{0:X4}", PPUAddress); int TileID = _ppu.PeekPPU(PPUAddress); TileIDLabel.Text = string.Format("{0:X2}", TileID); TableLabel.Text = NameTable.ToString(); int ytable = 0, yline = 0; if (e.Y >= 240) { ytable += 2; yline = 240; } int table = (e.X >> 8) + ytable; int ntaddr = (table << 10); int px = e.X & 255; int py = e.Y - yline; int tx = px >> 3; int ty = py >> 3; int atbyte_ptr = ntaddr + 0x3C0 + ((ty >> 2) << 3) + (tx >> 2); int at = _ppu.PeekPPU(atbyte_ptr + 0x2000); if ((ty & 2) != 0) { at >>= 4; } if ((tx & 2) != 0) { at >>= 2; } at &= 0x03; PaletteLabel.Text = at.ToString(); }