private void getPalette() { tLoader = new TileLoader(gb); tLoader.loadPallete((byte)dungeonIndex, (byte)mapIndex, overWorld, sideView); label3.Text = "Palette Location: 0x" + tLoader.paletteLocation.ToString("X"); palette = tLoader.palette; drawPalette(); }
public PaletteEditor(TileLoader t, Form1 f, Color[,] pal, byte[] g, int dungeon, int map, bool overworld, bool sideview, bool special, bool crystal, byte off) { InitializeComponent(); tLoader = t; palette = pal; form1 = f; gb = new GBHL.GBFile(g); if (overworld) { nDungeon.Enabled = false; } overWorld = overworld; sideView = sideview; specialMaps = special; crystals = crystal; mapIndex = map; mapIndexOriginal = map; dungeonIndex = dungeon; dungeonIndexOriginal = dungeon; nMap.Value = map; if (!overworld) { nDungeon.Value = dungeon; nIndex.Enabled = false; gb.BufferLocation = 0x8523A; for (int i = 0; i < 0x2D; i++) { if (gb.ReadByte() != dungeonIndex) { gb.BufferLocation += 3; continue; } if (gb.ReadByte() != mapIndex) { gb.BufferLocation += 2; continue; } byte q = gb.ReadByte(); if (q != 4) { gb.BufferLocation++; continue; } nIndex.Enabled = true; nIndex.Maximum = 0x3F; offset = off; nIndex.Value = off & 0x3F; break; } } if (dungeon == 0xFF) { nMap.Maximum = 0x15; } pTileset.Image = form1.pTiles.Image; palette = pal; Bitmap b = new Bitmap(128, 128); Graphics gra = Graphics.FromImage(b); for (int k = 0; k < 8; k++) { for (int i = 0; i < 4; i++) { gra.FillRectangle(new SolidBrush(pal[k, i]), i * 32, k * 16, 32, 16); } } pPalette.Image = b; getPaletteLocation(); getPalettePointer(); if (overworld) { offset = off; nIndex.Value = off; } }
public void Analyze(string filename) { if (File.Exists(filename)) { byte[] buffer; spritebankinfo = new SortedDictionary <int, HashSet <byte> >(); reversespritebankinfo = new SortedDictionary <byte, HashSet <int> >(); spritelocationinfo = new SortedDictionary <byte, HashSet <Room> >(); using (BinaryReader br = new BinaryReader(File.OpenRead(filename))) { buffer = br.ReadBytes((Int32)br.BaseStream.Length); } gb = new GBHL.GBFile(buffer); tileLoader = new TileLoader(gb); dungeonDrawer = new DungeonDrawer(gb); minimapDrawer = new MinimapDrawer(gb); overworldDrawer = new OverworldDrawer(gb); patches = new Patch(gb); sprites = new Sprites(gb); AELogger.Log("BEGIN ANALYSIS"); for (int room_index = 0; room_index < 0xFF; room_index++) { DoOverworld((byte)room_index); DoDungeon(0, (byte)room_index); DoDungeon(0x6, (byte)room_index); } { StringBuilder sb = new StringBuilder(); sb.Append("\n\n================================================\nSprite banks contain these sprites:\n"); foreach (KeyValuePair <int, HashSet <byte> > pair in spritebankinfo) { sb.Append("bank "); sb.Append(pair.Key.ToString("X2")); foreach (byte id in pair.Value) { sb.Append("\n\t"); sb.Append(Names.GetName(Names.sprites, id)); sb.Append(","); } sb.Length = sb.Length - 1; sb.Append("\n"); } AELogger.Log(sb); } { StringBuilder sb = new StringBuilder(); sb.Append("\n\n================================================\nSprites are used in these rooms:\n"); foreach (KeyValuePair <byte, HashSet <Room> > pair in spritelocationinfo) { sb.Append("sprite '"); sb.Append(Names.GetName(Names.sprites, pair.Key)); sb.Append("' in rooms:\n"); foreach (Room room in pair.Value) { if (room.bOverworld) { sb.Append("\tOVE ---: "); } else if (room.dungeonIndex < 6) { sb.Append("\tDUN 0-5: "); } else { sb.Append("\tDUN 6-?: "); } sb.Append(room.mapIndex.ToString("X2")); sb.Append(" (bank "); sb.Append(room.bank.ToString("X2")); sb.Append("),\n"); } sb.Length = sb.Length - 1; sb.Append("\n"); } AELogger.Log(sb); } { StringBuilder sb = new StringBuilder(); sb.Append("\n\n================================================\nSprites are pickable in these sprite banks:\n"); foreach (KeyValuePair <byte, HashSet <int> > pair in reversespritebankinfo) { sb.Append("sprite '"); sb.Append(Names.GetName(Names.sprites, pair.Key)); sb.Append("':\n\t"); foreach (int id in pair.Value) { sb.Append(id.ToString("X2")); sb.Append(", "); } sb.Length = sb.Length - 1; sb.Append("\n"); } AELogger.Log(sb); } } // if file.exists } // analyze