void Core_LoadPaletteAndSmallTileset() { try { MapTileFrame frame = CurrentTileAnim.Frames[TileAnim_Frame_ByteBox.Value]; byte[] tileset = Core.ReadData(Tileset1_PointerBox.Value, 0); byte[] palette = Core.ReadData(Palette_PointerBox.Value, Map.PALETTES * Palette.LENGTH); if (ViewAnimation_CheckBox.Checked) { byte[] change; if (frame.IsPaletteAnimation()) { change = TileAnim_PaletteBox.Colors.ToBytes(false); Array.Copy(change, 0, palette, TileAnim_Offset_ByteBox.Value * 2, change.Length); } else { change = Core.ReadData(frame.FrameData, frame.Length * 8 * Tile.LENGTH); Array.Copy(change, 0, tileset, 32 * 8 * Tile.LENGTH, change.Length); } } Tileset_PaletteBox.Load(new GBA.Palette(palette, Map.PALETTES * Palette.MAX)); Tileset_ImageBox.Load(new Tileset(tileset).ToImage(32, 32, palette.GetBytes((uint)(ViewPalette_ByteBox.Value * Palette.LENGTH), Palette.LENGTH))); } catch (Exception ex) { Program.ShowError("Could not load the palette.", ex); CurrentTileAnim = null; } }
void Core_LoadTileAnimFrame() { TileAnim_Data_PointerBox.ValueChanged -= TileAnim_Data_PointerBox_ValueChanged; TileAnim_Duration_ByteBox.ValueChanged -= TileAnim_Duration_ByteBox_ValueChanged; TileAnim_Length_ByteBox.ValueChanged -= TileAnim_Length_ByteBox_ValueChanged; TileAnim_Offset_ByteBox.ValueChanged -= TileAnim_Offset_ByteBox_ValueChanged; try { MapTileFrame frame = CurrentTileAnim.Frames[TileAnim_Frame_ByteBox.Value]; TileAnim_Data_PointerBox.Value = frame.FrameData; TileAnim_Duration_ByteBox.Value = frame.Duration; TileAnim_Length_ByteBox.Value = frame.Length; if (frame.IsPaletteAnimation()) { TileAnim_Palette_RadioButton.Checked = true; TileAnim_Tileset_RadioButton.Checked = false; TileAnim_Offset_Label.Enabled = true; TileAnim_Offset_ByteBox.Enabled = true; TileAnim_Offset_ByteBox.Value = frame.Offset; byte[] change = Core.ReadData(frame.FrameData, frame.Length * 2); TileAnim_PaletteBox.Load(new Palette(change)); TileAnim_ImageBox.Reset(); } else { TileAnim_Palette_RadioButton.Checked = false; TileAnim_Tileset_RadioButton.Checked = true; TileAnim_Offset_Label.Enabled = false; TileAnim_Offset_ByteBox.Enabled = false; TileAnim_Offset_ByteBox.Value = 0; byte[] tileset = Core.ReadData(frame.FrameData, frame.Length * 8 * Tile.LENGTH); byte[] palette = Core.ReadData(Palette_PointerBox.Value + ViewPalette_ByteBox.Value * Palette.LENGTH, Palette.LENGTH); TileAnim_ImageBox.Load(new Tileset(tileset).ToImage(32, 4, palette)); TileAnim_PaletteBox.Reset(); } } catch (Exception ex) { Program.ShowError("There has been an error trying to load the tileset values.", ex); } TileAnim_Data_PointerBox.ValueChanged += TileAnim_Data_PointerBox_ValueChanged; TileAnim_Duration_ByteBox.ValueChanged += TileAnim_Duration_ByteBox_ValueChanged; TileAnim_Length_ByteBox.ValueChanged += TileAnim_Length_ByteBox_ValueChanged; TileAnim_Offset_ByteBox.ValueChanged += TileAnim_Offset_ByteBox_ValueChanged; }