void Core_UpdatePortrait() { try { if (IsGenericClassCard) { CurrentPortrait = new Portrait( Core.ReadPalette((Pointer)Current["Palette"], Palette.LENGTH), Core.ReadData((Pointer)Current[(Core.CurrentROM is FE6) ? "Main" : "Card"], 0)); } else { CurrentPortrait = new Portrait( Core.ReadPalette((Pointer)Current["Palette"], Palette.LENGTH), ((Core.CurrentROM is FE7 && Core.CurrentROM.Version == GameVersion.JAP) || Core.CurrentROM is FE8) ? Core.ReadData((Pointer)Current["Face"] + 4, Portrait.Face_Length) : Core.ReadData((Pointer)Current[(Core.CurrentROM is FE6) ? "Main" : "Face"], 0), Core.ReadData((Pointer)Current["Chibi"], (Core.CurrentROM is FE6) ? Portrait.Chibi_Length : 0), (Core.CurrentROM is FE6) ? null : Core.ReadData((Pointer)Current["Mouth"], Portrait.Mouth_Length)); } Image_ImageBox.Load(CurrentPortrait); Palette_PaletteBox.Load(CurrentPortrait.Colors); } catch (Exception ex) { Program.ShowError("Could not load the portrait image.", ex); Image_ImageBox.Reset(); Palette_PaletteBox.Reset(); } }
void Core_LoadTileset() { try { byte[] palette_data = Core.ReadData(Palette_PointerBox.Value, Map.PALETTES * GBA.Palette.LENGTH); CurrentTileset = new MapTileset(palette_data, Core.ReadData(Tileset1_PointerBox.Value, 0), Core.ReadData(Tileset2_PointerBox.Value, 0), Core.ReadData(TilesetTSA_PointerBox.Value, 0)); Tileset_GridBox.Load(CurrentTileset); Palette_PaletteBox.Load(new GBA.Palette(palette_data, Map.PALETTES * GBA.Palette.MAX)); } catch (Exception ex) { CurrentTileset = null; Program.ShowError("Could not load the the tileset for this chapter.", ex); } }
public override void Core_Update() { try { byte[] palette = Core.ReadData( Palette_PointerBox.Value + (int)Palette_Index_NumBox.Value * Palette.LENGTH, Palette_CheckBox.Checked ? 0 : 16 * Palette.LENGTH); byte[] tileset = Core.ReadData( Tileset_PointerBox.Value, Tileset_CheckBox.Checked ? 0 : (Tileset_8bpp_RadioButton.Checked ? ((int)Width_NumBox.Value * (int)Height_NumBox.Value * Tile.SIZE * Tile.SIZE) : ((int)Width_NumBox.Value * (int)Height_NumBox.Value * Tile.LENGTH))); if (Palette_Opaque_CheckBox.Checked) { for (int i = 0; i < palette.Length; i += 2) { palette[i + 1] &= 0x7F; } } if (palette == null || palette.Length == 0) { Palette_PaletteBox.Reset(); Image_ImageBox.Reset(); return; } if (tileset == null || tileset.Length == 0) { Palette_PaletteBox.Load(new Palette(palette, Palette.MAX * 16)); Image_ImageBox.Reset(); return; } IDisplayable image = null; if (TSA_Label.Checked && TSA_PointerBox.Value != new Pointer()) { image = new TSA_Image(palette, tileset, Core.ReadTSA(TSA_PointerBox.Value, (int)Width_NumBox.Value, (int)Height_NumBox.Value, TSA_CheckBox.Checked, TSA_FlipRows_CheckBox.Checked)); Tool_OpenTSAEditor.Enabled = true; } else if (Tileset_8bpp_RadioButton.Checked) { image = new Bitmap( (int)Width_NumBox.Value * Tile.SIZE, (int)Height_NumBox.Value * Tile.SIZE, View_GrayscalePalette.Checked ? GrayScale.ToBytes(false) : palette, tileset); Tool_OpenTSAEditor.Enabled = false; } else { image = new Tileset(tileset).ToImage( (int)Width_NumBox.Value, (int)Height_NumBox.Value, View_GrayscalePalette.Checked ? GrayScale.ToBytes(false) : palette.GetBytes(0, Palette.LENGTH)); Tool_OpenTSAEditor.Enabled = false; } Palette_PaletteBox.Load(new Palette(palette, Palette.MAX * 16)); Image_ImageBox.Size = new System.Drawing.Size(image.Width, image.Height); Image_ImageBox.Load(image); } catch (Exception ex) { Program.ShowError("There has been an error while trying to load the image.", ex); Image_ImageBox.Reset(); } }