void Core_LoadScreen() { try { byte[] tileset = Core.ReadData(Core.GetPointer("Battle Screen Tileset"), 0); byte[] palettes = Core.ReadData(Core.GetPointer("Battle Screen Palettes"), 4 * Palette.LENGTH); TSA_Array tsa = Core.ReadTSA(Core.GetPointer("Battle Screen TSA"), 16, 32, false, false); CurrentScreen = new BattleScreen( palettes, tileset, BattleScreen.GetReadibleTSA(tsa), new Tileset(Core.ReadData(Core.GetPointer("Battle Screen L Name"), 0)), new Tileset(Core.ReadData(Core.GetPointer("Battle Screen L Weapon"), 0)), new Tileset(Core.ReadData(Core.GetPointer("Battle Screen R Name"), 0)), new Tileset(Core.ReadData(Core.GetPointer("Battle Screen R Weapon"), 0))); Screen_GridBox.Load(CurrentScreen); Screen_PaletteBox.Load(new Palette(palettes, 4 * Palette.MAX)); } catch (Exception ex) { Program.ShowError("Could not load the battle platform image.", ex); Screen_GridBox.Reset(); Screen_PaletteBox.Reset(); } }
public Background( byte[] palettes, byte[] tileset, TSA_Array tsa) : base(palettes, tileset, tsa) { }
public MapTileset(byte[] palettes, byte[] tileset1, byte[] tileset2, byte[] tsa_terrain) { Palettes = new Palette[palettes.Length / Palette.LENGTH]; byte[] buffer = new byte[Palette.LENGTH]; for (int p = 0; p < Palettes.Length; p++) { Array.Copy(palettes, p * Palette.LENGTH, buffer, 0, Palette.LENGTH); Palettes[p] = new Palette(buffer); } if (tileset2 == null || tileset2.Length == 0) { Tileset1 = new Tileset(tileset1, 1024); Tileset2 = null; } else { Tileset1 = new Tileset(tileset1, 512); Tileset2 = new Tileset(tileset2, 512); } Terrain = tsa_terrain.GetBytes(WIDTH * HEIGHT * 2); Tiles = new List <MapTile>(); TSA_Array tsa = new TSA_Array(WIDTH, HEIGHT, tsa_terrain); int length = 32 * 32; for (int i = 0; i < length; i++) { Tiles.Add(new MapTile( tsa[0, i * 2], tsa[0, i * 2 + 1], tsa[1, i * 2], tsa[1, i * 2 + 1])); } }
void Core_Insert( Palette palette, byte[] graphics, TSA_Array tsa = null) { Core.SuspendUpdate(); try { byte[] data_palette = palette.ToBytes(Palette_CheckBox.Checked); byte[] data_tileset = Tileset_CheckBox.Checked ? LZ77.Compress(graphics) : graphics; byte[] data_tsa = null; List <Tuple <string, Pointer, int> > repoints = new List <Tuple <string, Pointer, int> >(); repoints.Add(Tuple.Create("Palette", Palette_PointerBox.Value, data_palette.Length)); repoints.Add(Tuple.Create("Tileset", Tileset_PointerBox.Value, data_tileset.Length)); if (tsa != null) { data_tsa = tsa.ToBytes(TSA_CheckBox.Checked, TSA_FlipRows_CheckBox.Checked); repoints.Add(Tuple.Create("TSA", TSA_PointerBox.Value, data_tsa.Length)); } bool cancel = Prompt.ShowRepointDialog(this, "Repoint Graphics", "The image and palette to insert might need to be repointed.", "Image at " + Tileset_PointerBox.Value + " - ", repoints.ToArray()); if (cancel) { return; } Core.WriteData(this, Palette_PointerBox.Value, data_palette, "Palette at " + Palette_PointerBox.Value + " changed"); Core.WriteData(this, Tileset_PointerBox.Value, data_tileset, "Tileset at " + Tileset_PointerBox.Value + " changed"); if (tsa != null) { Core.WriteData(this, TSA_PointerBox.Value, data_tsa, "TSA Array at " + TSA_PointerBox.Value + " changed"); } } catch (Exception ex) { Program.ShowError("Could not insert image.", ex); } Core.ResumeUpdate(); Core.PerformUpdate(); }
void Core_WriteBattleScreenTSA(TSA_Array tsa) { bool[,] selection = Screen_GridBox.Selection; Core.WriteData(this, Core.GetPointer("Battle Screen TSA"), BattleScreen.GetInsertableTSA(CurrentScreen.Tiling).ToBytes(false, false), BattleScreenEntry + "TSA changed"); Screen_GridBox.Selection = selection; }
public BattleScreen( byte[] palettes, byte[] tileset, TSA_Array tsa, Tileset L_name, Tileset L_weapon, Tileset R_name, Tileset R_weapon) : base(palettes, tileset, tsa) { LoadSecondaryTileset(L_name, L_NAME_OFFSET); LoadSecondaryTileset(L_weapon, L_WEAPON_OFFSET); LoadSecondaryTileset(R_name, R_NAME_OFFSET); LoadSecondaryTileset(R_weapon, R_WEAPON_OFFSET); }
private void Tool_OpenTSAEditor_Click(Object sender, EventArgs e) { TSA_Array tsa = ((TSA_Image)Image_ImageBox.Display).Tiling; Core.OpenTSAEditor(this, "Unknown TSA Array - ", Palette_PointerBox.Value, Palette_CheckBox.Checked ? 0 : 16 * Palette.LENGTH, Tileset_PointerBox.Value, Tileset_CheckBox.Checked ? 0 : (int)(Width_NumBox.Value * Height_NumBox.Value) * Tile.LENGTH, TSA_PointerBox.Value, tsa.Width, tsa.Height, TSA_CheckBox.Checked, TSA_FlipRows_CheckBox.Checked); }
public WorldMap_FE7_Large(string path, Palette palette = null) { TSA_Image image; if (palette == null) { image = new TSA_Image(WIDTH, HEIGHT, new GBA.Bitmap(path), PALETTES, false); } else { image = new TSA_Image(WIDTH, HEIGHT, new GBA.Bitmap(path), palette, PALETTES, false); } Palettes = image.Palettes; Graphics = new Tileset[SECTIONS]; TSA_Sections = new TSA_Array[SECTIONS]; int width = 32; int height = 32; for (int i = 0; i < SECTIONS; i++) { if (i == 8) { height = 22; } Graphics[i] = new Tileset(width * height); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { Graphics[i].Add(image.Graphics[ (i % 4 * width + x) + (i / 4 * width + y) * WIDTH]); } } TSA_Sections[i] = TSA_Array.GetBasicTSA(width, height); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { TSA_Sections[i].SetPalette(x, y, image.Tiling[ (i % 4 * width) + x, (i / 4 * width) + y].Palette); } } } }
private void LoadButton_Click(object sender, EventArgs e) { OpenFileDialog openWindow = new OpenFileDialog(); openWindow.Filter = "TSA data (*.tsa)|*.tsa|All files (*.*)|*.*"; openWindow.FilterIndex = 1; openWindow.RestoreDirectory = true; openWindow.Multiselect = false; if (openWindow.ShowDialog() == DialogResult.OK) { Current = new TSA_Array(Current.Width, Current.Height, File.ReadAllBytes(openWindow.FileName)); Core.WriteData(this, Address, Current.ToBytes(IsCompressed, FlipRows), Entry + "TSA changed"); } }
void Core_Screen_InsertData(string filepath) { BattleScreen screen; try { string path = Path.GetDirectoryName(filepath) + '\\'; string file = Path.GetFileNameWithoutExtension(filepath); if (!File.Exists(path + file + ".chr")) { throw new Exception("Could not find Tileset file:\n" + path + file + ".chr"); } if (!File.Exists(path + file + ".pal")) { throw new Exception("Could not find Palette file:\n" + path + file + ".pal"); } if (!File.Exists(path + file + ".tsa")) { throw new Exception("Could not find TSA file:\n" + path + file + ".tsa"); } byte[] tileset = File.ReadAllBytes(path + file + ".chr"); byte[] palette = File.ReadAllBytes(path + file + ".pal"); TSA_Array tsa = new TSA_Array( BattleScreen.WIDTH, BattleScreen.HEIGHT, File.ReadAllBytes(path + file + ".tsa")); screen = new BattleScreen( palette, tileset, tsa, new Tileset(File.ReadAllBytes(path + file + " L name.chr")), new Tileset(File.ReadAllBytes(path + file + " L weapon.chr")), new Tileset(File.ReadAllBytes(path + file + " R name.chr")), new Tileset(File.ReadAllBytes(path + file + " R weapon.chr"))); } catch (Exception ex) { Program.ShowError("Could not load the image data.", ex); return; } Core_Insert(screen); }
public TSAEditor( Editor owner, String entry, Pointer palette_address, int palette_length, Pointer tileset_address, int tileset_length, Pointer address, int width, int height, bool compressed, bool flipRows) { try { InitializeComponent(); base.Owner = owner; Owner = owner; Entry = entry; PaletteAddress = palette_address; PaletteLength = palette_length; TilesetAddress = tileset_address; TilesetLength = tileset_length; Address = address; IsCompressed = compressed; FlipRows = flipRows; Current = new TSA_Array(width, height); MenuBar.LayoutStyle = ToolStripLayoutStyle.Flow; EntryInfo_Label.Text = entry + address; TSA_GridBox.Size = new Size(width * 8, height * 8); this.Size = new Size(40 + width * 8 + 4, 210 + height * 8 + 4); this.MaximumSize = this.Size; } catch (Exception ex) { Program.ShowError("Could not properly open the " + this.Text, ex); Core_CloseEditor(this, null); } }
void Core_InsertData(string filepath) { string path = Path.GetDirectoryName(filepath) + '\\'; string file = Path.GetFileNameWithoutExtension(filepath); Palette palette; byte[] graphics; TSA_Array tsa = null; try { if (!File.Exists(path + file + ".pal")) { throw new Exception("Could not find Palette file:\n" + path + file + ".pal"); } if (!File.Exists(path + file + ".chr")) { throw new Exception("Could not find Tileset file:\n" + path + file + ".chr"); } palette = new Palette(path + file + ".pal", 256); graphics = File.ReadAllBytes(path + file + ".chr"); if (!File.Exists(path + file + ".tsa")) { tsa = new TSA_Array( (int)Width_NumBox.Value, (int)Height_NumBox.Value, File.ReadAllBytes(path + file + ".tsa")); } } catch (Exception ex) { Program.ShowError("Could not load image data files.", ex); return; } Core_Insert(palette, graphics, tsa); }
void Core_InsertData(string filepath) { Background background; try { string path = Path.GetDirectoryName(filepath) + '\\'; string file = Path.GetFileNameWithoutExtension(filepath); if (!File.Exists(path + file + ".pal")) { throw new Exception("Could not find Palette file:\n" + path + file + ".pal"); } if (!File.Exists(path + file + ".chr")) { throw new Exception("Could not find Tileset file:\n" + path + file + ".chr"); } if (!File.Exists(path + file + ".tsa")) { throw new Exception("Could not find TSA Array file:\n" + path + file + ".tsa"); } byte[] palette = File.ReadAllBytes(path + file + ".pal"); byte[] tileset = File.ReadAllBytes(path + file + ".chr"); TSA_Array tsa = new TSA_Array( CurrentBackground.Tiling.Width, CurrentBackground.Tiling.Height, File.ReadAllBytes(path + file + ".tsa")); background = new Background(palette, tileset, tsa); } catch (Exception ex) { Program.ShowError("Could not load image data.", ex); return; } Core_Insert(background); }
/// <summary> /// Makes the battle screen frame into a readible nicely formatted image /// </summary> public static TSA_Array GetReadibleTSA(TSA_Array tsa_array) { TSA_Array result = new TSA_Array(WIDTH, HEIGHT); tsa_array.Width = 15; // top left for (int y = 0; y < NAME_HEIGHT; y++) { for (int x = 0; x < 15; x++) { result[1 + x, y] = tsa_array[x, y]; } } // bottom left for (int y = 0; y < WEAPON_HEIGHT; y++) { for (int x = 0; x < 15; x++) { result[1 + x, NAME_HEIGHT + y] = tsa_array[x, NAME_HEIGHT * 2 + y]; } } // top right for (int y = 0; y < NAME_HEIGHT; y++) { for (int x = 0; x < 15; x++) { result[HALFWIDTH + x, y] = tsa_array[x, NAME_HEIGHT + y]; } } // bottom right tsa_array.Width = 16; for (int y = 0; y < WEAPON_HEIGHT; y++) { for (int x = 0; x < 2; x++) { result[HALFWIDTH + x, NAME_HEIGHT + y] = tsa_array[14 + x, 17 + y]; } } for (int y = 0; y < WEAPON_HEIGHT; y++) { for (int x = 0; x < 14; x++) { result[HALFWIDTH + 2 + x, NAME_HEIGHT + y] = tsa_array[x, 18 + y]; } } if (Core.CurrentROM is FE8) { for (int i = 0; i < WEAPON_HEIGHT; i++) { result[0, NAME_HEIGHT + i] = result[WIDTH - 1, NAME_HEIGHT + i]; result.SetPalette(0, NAME_HEIGHT + i, 1); result.SetFlipH(0, NAME_HEIGHT + i, true); } } else { int offset = 398; for (int i = 0; i < NAME_HEIGHT; i++) { result[0, i] = tsa_array.Tiles[offset + i * 2 + 1]; result[WIDTH - 1, i] = tsa_array.Tiles[offset + i * 2]; } offset += (NAME_HEIGHT + 7) * 2; for (int i = 0; i < WEAPON_HEIGHT; i++) { result[0, NAME_HEIGHT + i] = tsa_array.Tiles[offset + i * 2]; result.SetPalette(0, NAME_HEIGHT + i, 1); result.SetFlipH(0, NAME_HEIGHT + i, false); } } return(result); }
static TSA_Image MakeTextBubble(int longestLine, Pointer tilesetAddress, Pointer paletteAddress) { Palette palette = Core.ReadPalette(paletteAddress, Palette.LENGTH); Tileset tileset = new Tileset(Core.ReadData(tilesetAddress, 0)); TSA_Array tsa = new TSA_Array(30, 8); for (int y = 0; y < 8; y++) { for (int x = 0; x < 30; x++) { tsa.SetTile(x, y, 0xF); } } int length = 2; if (longestLine / 8 > length) { length = longestLine / 8; if (longestLine % 8 != 0) { length++; } } tsa.SetTile(0, 0, 0x0); for (int i = 1; i <= length; i++) { tsa.SetTile(i, 0, 0x1); } tsa.SetTile(0, 1, 0x2); tsa.SetTile(0, 2, 0x2); tsa.SetTile(0, 3, 0x2); tsa.SetTile(0, 4, 0x2); tsa.SetTile(0, 5, 0x0); tsa.SetFlipV(0, 5, true); for (int i = 2; i <= length; i++) { tsa.SetTile(i, 5, 0x1); tsa.SetFlipV(i, 5, true); } tsa.SetTile(1, 5, 0x4); tsa.SetTile(2, 5, 0x4); tsa.SetFlipH(2, 5, true); tsa.SetFlipV(2, 5, false); tsa.SetTile(1, 6, 0x6); tsa.SetFlipH(1, 6, true); tsa.SetTile(2, 6, 0x5); tsa.SetFlipH(2, 6, true); tsa.SetTile(1 + length, 0, 0x0); tsa.SetFlipH(1 + length, 0, true); tsa.SetTile(1 + length, 1, 0x2); tsa.SetFlipH(1 + length, 1, true); tsa.SetTile(1 + length, 2, 0x2); tsa.SetFlipH(1 + length, 2, true); tsa.SetTile(1 + length, 3, 0x2); tsa.SetFlipH(1 + length, 3, true); tsa.SetTile(1 + length, 4, 0x2); tsa.SetFlipH(1 + length, 4, true); tsa.SetTile(1 + length, 5, 0x0); tsa.SetFlipH(1 + length, 5, true); tsa.SetFlipV(1 + length, 5, true); for (int y = 1; y <= 4; y++) { for (int x = 1; x <= length; x++) { tsa.SetTile(x, y, 0x3); } } return(new TSA_Image(palette, tileset, tsa)); }
public BattleScreen(Bitmap image, Palette[] palettes) : base(WIDTH, HEIGHT) { if (image.Width != Width || image.Height != Height) { throw new Exception("Image given has invalid dimensions, should be " + Width + "x" + Height + " pixels."); } Palettes = palettes; Graphics = new Tileset(WIDTH * HEIGHT); Tiling = new TSA_Array(WIDTH, HEIGHT); const int X_L_NAME = 1; const int X_L_WEAPON = 8; int X_R_NAME = Core.CurrentROM is FE8 ? 24 : 25; const int X_R_WEAPON = 18; const int Y_NAME = 1; const int Y_WEAPON = 8; Tile tile; byte paletteIndex; System.Drawing.Rectangle region; for (int y = 0; y < HEIGHT; y++) { for (int x = 0; x < WIDTH; x++) { if (x >= HALFWIDTH) { if ((x >= X_R_NAME && x < X_R_NAME + NAME_WIDTH && y >= Y_NAME && y < Y_NAME + 2) || (x >= X_R_WEAPON && x < X_R_WEAPON + 6 && y >= Y_WEAPON && y < Y_WEAPON + 2)) { continue; } paletteIndex = 0; } else { if ((x >= X_L_NAME && x < X_L_NAME + NAME_WIDTH && y >= Y_NAME && y < Y_NAME + 2) || (x >= X_L_WEAPON && x < X_L_WEAPON + WEAPON_WIDTH && y >= Y_WEAPON && y < Y_WEAPON + 2)) { continue; } paletteIndex = 1; } region = new System.Drawing.Rectangle(x * Tile.SIZE, y * Tile.SIZE, Tile.SIZE, Tile.SIZE); tile = new Tile(new Image(image, region, palettes[paletteIndex])); if (Graphics.Count == EMPTY_TILE) { Graphics.Add(Tile.Empty); } if (Graphics.Count == TILE_LIMIT) { for (int i = 0; TILE_LIMIT + i < TILE_LIMIT_END; i++) { Graphics.Add(Tile.Empty); } } if (Graphics.Count >= 128) { throw new Exception("Battle Screen Frame cannot have more than 128 tiles."); } if (tile.IsEmpty()) { Tiling[x, y] = new TSA(EMPTY_TILE, paletteIndex, false, false); } else { var match = Graphics.FindMatch(tile); if (match == null) { Tiling[x, y] = new TSA(Graphics.Count, paletteIndex, false, false); Graphics.Add(tile); } else { Tiling[x, y] = new TSA(match.Item1, paletteIndex, match.Item2, match.Item3); } } } } while (Graphics.Count < TILE_LIMIT_END) { Graphics.Add(Tile.Empty); } LoadSecondaryTileset(image, palettes, L_NAME_OFFSET, 1, X_L_NAME, Y_NAME, NAME_WIDTH, 2); LoadSecondaryTileset(image, palettes, L_WEAPON_OFFSET, 1, X_L_WEAPON, Y_WEAPON, WEAPON_WIDTH, 2); LoadSecondaryTileset(image, palettes, R_NAME_OFFSET, 0, X_R_NAME, Y_NAME, NAME_WIDTH, 2); LoadSecondaryTileset(image, palettes, R_WEAPON_OFFSET, 0, X_R_WEAPON, Y_WEAPON, WEAPON_WIDTH, 2); }
void Core_LoadBackground() { try { Size bgsize = Background.GetBGSize(CurrentType); byte[] palette = Core.ReadData((Pointer)Current["Palette"], (CurrentType == BackgroundType.Battle) ? 0 : // is compressed Background.GetPaletteAmount(CurrentType) * GBA.Palette.LENGTH); byte[] tileset; TSA_Array tsa; switch (CurrentType) { case BackgroundType.Dialog: tileset = Core.ReadData((Pointer)Current["Tileset"], 0); tsa = Core.ReadTSA((Pointer)Current["TSA"], bgsize.Width, bgsize.Height, false, true); break; case BackgroundType.Battle: palette[0] = 0x00; palette[1] = 0x00; // force 1st color black on battle BGs tileset = Core.ReadData((Pointer)Current["Tileset"], 0); tsa = Core.ReadTSA((Pointer)Current["TSA"], bgsize.Width, bgsize.Height, true, false); break; case BackgroundType.Screen: if (Core.CurrentROM is FE6) { tileset = Core.ReadData((Pointer)Current["Tileset"], 0); tsa = TSA_Array.GetBasicTSA(bgsize.Width, bgsize.Height); } else if (Core.CurrentROM is FE7 && Core.ReadByte(Current.GetAddress(Current.EntryIndex)) == 0x00) { tileset = Core.ReadData((Pointer)Current["Tileset"], 0); tsa = Core.ReadTSA((Pointer)Current["TSA"], bgsize.Width, bgsize.Height, false, true); } else // its stored in 32x2 strips { tsa = Core.ReadTSA((Pointer)Current["TSA"], bgsize.Width, bgsize.Height, false, true); int amount = 10; int length = 32 * 2 * Tile.LENGTH; tileset = new byte[amount * length]; Pointer table = (Pointer)Current["Tileset"]; Pointer address; byte[] buffer; for (int i = 0; i < amount; i++) { address = Core.ReadPointer(table + i * 4); buffer = Core.ReadData(address, 0); Array.Copy(buffer, 0, tileset, i * length, length); } // assemble BGs that are stored in 32x2 strips } break; default: throw new Exception("Invalid background type."); } CurrentBackground = new Background(palette, tileset, tsa); Background_ImageBox.Load(CurrentBackground); Background_PaletteBox.Load(Palette.Merge(CurrentBackground.Palettes)); } catch (Exception ex) { Program.ShowError("Could not load the background image from the ROM.", ex); Background_ImageBox.Reset(); Background_PaletteBox.Reset(); } }
void Core_LoadTitleScreen_FE8( Palette bg_palette, Tileset bg_tileset, TSA_Array bg_tsa, Palette mg_palette, Tileset mg_tileset, TSA_Array mg_tsa, Palette fg_palette, Tileset fg_tileset) { GBA.Bitmap result; Palette palette = Palette.Empty(256); for (int i = 0; i < bg_palette.Count; i++) { bg_palette[i] = bg_palette[i].SetAlpha(false); palette.Set(GBA.Palette.MAX * 15 + i, bg_palette[i]); } for (int i = 0; i < mg_palette.Count; i++) { palette.Set(GBA.Palette.MAX * 14 + i, mg_palette[i]); } for (int i = 0; i < fg_palette.Count; i++) { palette.Set(i, fg_palette[i]); } result = new GBA.Bitmap(GBA.Screen.WIDTH, GBA.Screen.HEIGHT); result.Colors = palette; if (BG_CheckBox.Checked) { TSA_Image bg = new TSA_Image(bg_palette, bg_tileset, bg_tsa); for (int y = 0; y < bg.Height; y++) { for (int x = 0; x < bg.Width; x++) { if (bg[x, y] != 0) { result[x, y] = GBA.Palette.MAX * 15 + bg[x, y]; } } } } if (MG_CheckBox.Checked) { TSA_Image mg = new TSA_Image(mg_palette, mg_tileset, mg_tsa); for (int y = 0; y < mg.Height; y++) { for (int x = 0; x < mg.Width; x++) { if (mg[x, y] != 0) { result[x, y] = GBA.Palette.MAX * 14 + mg[x, y]; } } } } if (FG_CheckBox.Checked) { Palette[] palettes = Palette.Split(fg_palette, 8); GBA.Image fg; if (Core.CurrentROM.Version == GameVersion.JAP) { // large 'FIRE EMBLEM' title logo fg = fg_tileset.ToImage(32, 32, palettes[2].ToBytes(false)); Core_DrawLayer(result, fg, new Rectangle(0, 48, 240, 48), 0, 44); // shadow Core_DrawLayer(result, fg, new Rectangle(0, 0, 240, 48), 0, 39); // logo Core_DrawLayer(result, fg, new Rectangle(240, 0, 16, 16), 216, 39); // TM // small 'FIRE EMBLEM' overhead fg.Colors = palettes[1]; Core_DrawLayer(result, fg, new Rectangle(128, 104, 120, 16), 60, 26); // 'THE SACRED STONES' subtitle/scroll thingy fg.Colors = palettes[3]; Core_DrawLayer(result, fg, new Rectangle(0, 104, 128, 32), 56, 87); // 'Press START' fg.Colors = palettes[0]; Core_DrawLayer(result, fg, new Rectangle(128, 120, 80, 16), 80, 124); // Nintendo & IS copyrights fg.Colors = palettes[1]; Core_DrawLayer(result, fg, new Rectangle(0, 96, 240, 8), 16, 148); } else { // large 'FIRE EMBLEM' title logo fg = fg_tileset.ToImage(32, 32, palettes[2].ToBytes(false)); Core_DrawLayer(result, fg, new Rectangle(0, 32, 240, 32), 4, 53); // shadow Core_DrawLayer(result, fg, new Rectangle(0, 0, 240, 32), 4, 48); // logo Core_DrawLayer(result, fg, new Rectangle(240, 0, 16, 16), 220, 41); // TM // 'THE SACRED STONES' subtitle/scroll thingy fg.Colors = palettes[3]; Core_DrawLayer(result, fg, new Rectangle(0, 72, 208, 32), 16, 85); // 'Press START' fg.Colors = palettes[0]; Core_DrawLayer(result, fg, new Rectangle(208, 72, 48, 16), 72, 124); Core_DrawLayer(result, fg, new Rectangle(208, 88, 48, 16), 120, 124); // Nintendo & IS copyrights fg.Colors = palettes[1]; Core_DrawLayer(result, fg, new Rectangle(0, 64, 240, 8), 4, 148); } } Current = result; CurrentPalette = palette; }
void Core_LoadTitleScreen_FE7( Palette bg_palette, Tileset bg_tileset, Palette mg_palette, Tileset mg_tileset, TSA_Array mg_tsa, Palette fg_palette, Tileset fg_tileset) { GBA.Bitmap result; Palette palette = Palette.Empty(256); for (int i = 0; i < bg_palette.Count; i++) { palette.Set(GBA.Palette.MAX * 15 + i, bg_palette[i]); } for (int i = 0; i < mg_palette.Count; i++) { palette.Set(GBA.Palette.MAX * 14 + i, mg_palette[i]); } for (int i = 0; i < fg_palette.Count; i++) { palette.Set(i, fg_palette[i]); } result = new GBA.Bitmap(GBA.Screen.WIDTH, GBA.Screen.HEIGHT); result.Colors = palette; if (BG_CheckBox.Checked) { GBA.Image bg = bg_tileset.ToImage(GBA.Screen.W_TILES, GBA.Screen.H_TILES + 1, bg_palette.ToBytes(false)); for (int y = 0; y < GBA.Screen.HEIGHT; y++) { for (int x = 0; x < GBA.Screen.WIDTH; x++) { if (x < 8 && y < 8) { result[x, y] = GBA.Palette.MAX * 15 + bg[x, GBA.Screen.HEIGHT + y]; } else { result[x, y] = GBA.Palette.MAX * 15 + bg[x, y]; } } } } if (MG_CheckBox.Checked) { TSA_Image mg = new TSA_Image(mg_palette, mg_tileset, mg_tsa); for (int y = 0; y < mg.Height; y++) { for (int x = 0; x < mg.Width; x++) { if (mg[x, y] != 0) { result[x, 8 + y] = GBA.Palette.MAX * 14 + mg[x, y]; } } } } if (FG_CheckBox.Checked) { bool jap = (Core.CurrentROM.Version == GameVersion.JAP); bool eur = (Core.CurrentROM.Version == GameVersion.EUR); Palette[] palettes = Palette.Split(fg_palette, 8); GBA.Image fg; // durandal sword fg = fg_tileset.ToImage(32, 32, palettes[0].ToBytes(false)); Core_DrawLayer(result, fg, new Rectangle(0, 0, 192, 112), 32, 16); // large 'FIRE EMBLEM' title fg.Colors = palettes[4]; Core_DrawLayer(result, fg, new Rectangle(0, GBA.Screen.HEIGHT, GBA.Screen.WIDTH, 48), 2, jap ? 52 : 54); Core_DrawLayer(result, fg, new Rectangle(0, GBA.Screen.HEIGHT - 48, GBA.Screen.WIDTH, 48), 0, jap ? 48 : 52); // Nintendo & IS copyrights fg.Colors = palettes[2]; Core_DrawLayer(result, fg, new Rectangle(0, GBA.Screen.WIDTH - 16, GBA.Screen.HEIGHT - 16, 8), eur ? 8 : 16, GBA.Screen.HEIGHT - 16); Core_DrawLayer(result, fg, new Rectangle(0, GBA.Screen.WIDTH - 8, GBA.Screen.HEIGHT - 64, 8), eur ? 136 : GBA.Screen.HEIGHT, GBA.Screen.HEIGHT - 16); // 'Press Start' fg.Colors = palettes[1]; Core_DrawLayer(result, fg, new Rectangle(128, 208, 96, 16), jap ? 80 : 72, 120); if (jap) { // japanese subtitle fg.Colors = palettes[3]; Core_DrawLayer(result, fg, new Rectangle(144, 224, 112, 32), 64, 96); // japanese 'FIRE EMBLEM' overhead fg.Colors = palettes[2]; Core_DrawLayer(result, fg, new Rectangle(0, 208, 128, 16), 56, 40); } } Current = result; CurrentPalette = palette; }
void Core_LoadTitleScreen_FE6( Palette mg_palette, Tileset mg_tileset, Tileset fg_tileset, TSA_Array mg_tsa, Palette bg_palette, Tileset bg_tileset) { GBA.Bitmap result; Palette palette = Palette.Empty(256); for (int i = 0; i < mg_palette.Count; i++) { palette.Set(i, mg_palette[i]); } for (int i = 0; i < bg_palette.Count; i++) { bg_palette[i] = bg_palette[i].SetAlpha(false); palette.Set(GBA.Palette.MAX * 15 + i, bg_palette[i]); } result = new GBA.Bitmap(GBA.Screen.WIDTH, GBA.Screen.HEIGHT); result.Colors = palette; if (BG_CheckBox.Checked) { GBA.Image bg = bg_tileset.ToImage(GBA.Screen.W_TILES + 2, GBA.Screen.H_TILES, bg_palette.ToBytes(false)); for (int y = 0; y < GBA.Screen.HEIGHT; y++) { for (int x = 0; x < GBA.Screen.WIDTH; x++) { result[x, y] = GBA.Palette.MAX * 15 + bg[x, y]; } } } if (MG_CheckBox.Checked) { TSA_Image mg = new TSA_Image(mg_palette, mg_tileset, mg_tsa); for (int y = 0; y < GBA.Screen.HEIGHT; y++) { for (int x = 0; x < GBA.Screen.WIDTH; x++) { if (mg.GetColor(x, y).Value != 0) { result[x, y] = mg[x, y]; } } } } if (FG_CheckBox.Checked) { Palette[] palettes = Palette.Split(mg_palette, 8); GBA.Image fg; // large japanese 'FIRE EMBLEM' title fg = mg_tileset.ToImage(32, 25, palettes[4].ToBytes(false)); Core_DrawLayer(result, fg, new Rectangle(0, 152, GBA.Screen.WIDTH, 48), 0, 48); Core_DrawLayer(result, fg, new Rectangle(0, 104, GBA.Screen.WIDTH, 48), 0, 40); // small english 'FIRE EMBLEM' fg = fg_tileset.ToImage(32, 32, palettes[2].ToBytes(false)); Core_DrawLayer(result, fg, new Rectangle(0, 0, 128, 16), 99, 27); // Nintendo & IS copyrights Core_DrawLayer(result, fg, new Rectangle(0, 48, 208, 8), 16, 152); // japanese subtitle scroll thingy fg.Colors = palettes[3]; Core_DrawLayer(result, fg, new Rectangle(128, 16, 120, 32), 64, 85); // 'Press Start' fg.Colors = palettes[1]; Core_DrawLayer(result, fg, new Rectangle(128, 0, 80, 16), 80, 120); } Current = result; CurrentPalette = palette; }
/// <summary> /// Makes a readible battle frame TSA into an insertable version /// </summary> public static TSA_Array GetInsertableTSA(TSA_Array tsa_array) { TSA_Array result = (Core.CurrentROM is FE8) ? new TSA_Array(16, 32) : new TSA_Array(16, 28); result.Width = 15; // top left for (int y = 0; y < NAME_HEIGHT; y++) { for (int x = 0; x < 15; x++) { result[x, y] = tsa_array[1 + x, y]; } } // bottom left for (int y = 0; y < WEAPON_HEIGHT; y++) { for (int x = 0; x < 15; x++) { result[x, NAME_HEIGHT * 2 + y] = tsa_array[1 + x, NAME_HEIGHT + y]; } } // top right for (int y = 0; y < NAME_HEIGHT; y++) { for (int x = 0; x < 15; x++) { result[x, NAME_HEIGHT + y] = tsa_array[HALFWIDTH + x, y]; } } // bottom right result.Width = 16; for (int y = 0; y < WEAPON_HEIGHT; y++) { for (int x = 0; x < 2; x++) { result[14 + x, 17 + y] = tsa_array[HALFWIDTH + x, NAME_HEIGHT + y]; } } for (int y = 0; y < WEAPON_HEIGHT; y++) { for (int x = 0; x < 14; x++) { result[x, 18 + y] = tsa_array[HALFWIDTH + 2 + x, NAME_HEIGHT + y]; } } // bottom right, set the rest of the TSA if (Core.CurrentROM is FE8) { // (used for unit promotion) for (int y = 0; y < WEAPON_HEIGHT; y++) { for (int x = 0; x < 2; x++) { result[14 + x, 24 + y] = tsa_array[HALFWIDTH + x, NAME_HEIGHT + y]; } } for (int y = 0; y < WEAPON_HEIGHT; y++) { for (int x = 0; x < 14; x++) { result[x, 25 + y] = tsa_array[HALFWIDTH + 2 + x, NAME_HEIGHT + y]; } } } else { // (used when screenshaking) int empty_height = 7; int offset = 398; TSA tsa; for (int i = 0; i < (HEIGHT + empty_height); i++) { if (i < NAME_HEIGHT) { tsa = tsa_array[WIDTH - 1, i]; result.Tiles[offset + i * 2] = new TSA(tsa.TileIndex, 0, tsa.FlipH, tsa.FlipV); tsa = tsa_array[0, i]; result.Tiles[offset + i * 2 + 1] = new TSA(tsa.TileIndex, 1, tsa.FlipH, tsa.FlipV); } else if (i < (NAME_HEIGHT + empty_height)) { tsa = new TSA(EMPTY_TILE, 0, false, false); result.Tiles[offset + i * 2] = tsa; result.Tiles[offset + i * 2 + 1] = tsa; } else { tsa = tsa_array[WIDTH - 1, i - empty_height]; result.Tiles[offset + i * 2] = new TSA(tsa.TileIndex, 0, tsa.FlipH, tsa.FlipV); tsa = tsa_array[0, i - empty_height]; result.Tiles[offset + i * 2 + 1] = new TSA(tsa.TileIndex, 1, tsa.FlipH, tsa.FlipV); } } } return(result); }