private void ButtonChange_Click(object sender, EventArgs e) { byte newPalette = byte.Parse(TextBoxPalette.Text, System.Globalization.NumberStyles.HexNumber); if (foundPalettes.Contains(newPalette) || !MenuItemBoundPalette.Checked) { //Write the palette byte write.WriteByte(newPalette, sHeaderOffset + 2); //Adjust the palette reg byte a = CalculatePalReg(newPalette); if (a != 0xFF) { write.WriteByte(a, sHeaderOffset + 12); } navigate(); } else { //generate a list of palettes in a string string palettes = foundPalettes[0].ToString("X"); for (int i = 1; i < foundPalettes.Count; i++) { palettes += ", " + foundPalettes[i].ToString("X"); } //Yep, there is no palette "9000!" but here's a list of actual palettes: MessageBox.Show(this, "Palette selected is not a valid palette for the current ROM.\n\nValid Palettes:\n" + palettes, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); TextBoxPalette.Text = sPaletteIndex.ToString("X2"); } }
private void NumericUpDownPalette_ValueChanged(object sender, EventArgs e) { if (!Navigating) { int INDEX = int.Parse(IndexText.Text); byte P_INDEX = (byte)NumericUpDownPalette.Value; Write.WriteByte(P_INDEX, MiniPaletteIndex + INDEX); // Read palette pointer int paletteOffset = Read.ReadPointer(MiniPalettes + 8 * P_INDEX); // Fix both MINI frames EditBox.Sprites[4].Palette = new SpritePalette(SpritePalette.PaletteType.Color16, Read.ReadBytes(paletteOffset, 32)); EditBox.Sprites[5].Palette = EditBox.Sprites[4].Palette; NSE_Framework.Draw.uDrawSprite(ref bM1, EditBox.Sprites[4]); NSE_Framework.Draw.uDrawSprite(ref bM2, EditBox.Sprites[5]); PictureboxA1.Image = bM1; PictureboxA2.Image = bM2; if (EditBox.CurrentIndex == 4 || EditBox.CurrentIndex == 5) { EditBox.Redraw(); } } }