public Map(int Offset, GBAROM ROM, int CurrentBank, int CurrentMap) { offset = Offset; originROM = ROM; currentBank = (byte)CurrentBank; currentMap = (byte)CurrentMap; rawHeaderOrig = originROM.GetData(offset, 0x1C); rawHeader = (byte[])rawHeaderOrig.Clone(); LoadMapHeaderFromRaw(); if (Program.mapLayouts.ContainsKey(mapLayoutIndex)) layout = Program.mapLayouts[mapLayoutIndex]; else { Program.mapLayoutNotFoundCount++; if (mapLayoutIndex > Program.maxLayout) { Program.maxLayout = mapLayoutIndex; } } }
private void WriteLayoutData(MapLayout layout) { PGMEBackend.Program.isEdited = true; layout.WriteLayoutHeaderToRaw(); hexViewerRawLayoutHeader.ByteProvider = new DynamicByteProvider(layout.rawHeader, true, false, false); }
private void LoadHeaderTabLayoutHeader(MapLayout mapLayout) { hexViewerRawLayoutHeader.ByteProvider = new DynamicByteProvider(mapLayout.rawHeader, true, false, false); hexNumberBoxHeaderTabBorderPointer.Text = (mapLayout.borderBlocksPointer + 0x8000000).ToString("X8"); hexNumberBoxHeaderTabMapPointer.Text = (mapLayout.mapDataPointer + 0x8000000).ToString("X8"); hexNumberBoxHeaderTabGlobalTilesetPointer.Text = (mapLayout.globalTilesetPointer + 0x8000000).ToString("X8"); hexNumberBoxHeaderTabLocalTilesetPointer.Text = (mapLayout.localTilesetPointer + 0x8000000).ToString("X8"); tbHeaderTabMapWidth.Text = mapLayout.layoutWidth.ToString(); tbHeaderTabMapHeight.Text = mapLayout.layoutHeight.ToString(); if (PGMEBackend.Program.currentGame.RomType == "FRLG") { tbHeaderTabBorderWidth.Text = mapLayout.borderWidth.ToString(); tbHeaderTabBorderHeight.Text = mapLayout.borderHeight.ToString(); tbHeaderTabBorderWidth.Enabled = true; tbHeaderTabBorderHeight.Enabled = true; } else { tbHeaderTabBorderWidth.Text = string.Empty; tbHeaderTabBorderHeight.Text = string.Empty; tbHeaderTabBorderWidth.Enabled = false; tbHeaderTabBorderHeight.Enabled = false; } }
public static int LoadMap(object map) { if (isEdited) { string result = UnsavedChangesDialog(); if (result == "Yes") SaveMap(); else if (result == "No") { if(currentMap != null) currentMap.Revert(); currentLayout.Revert(); } else if (result == "Cancel") return 1; isEdited = false; } Stopwatch loadTime = new Stopwatch(); UndoManager.Clear(); loadTime.Start(); mainGUI.EnableControlsOnMapLoad(); if (currentLayout != null) { currentLayout.Unload(); } if (map is Map) { currentMap = (Map)map; currentLayout = ((Map)map).layout; } else if (map is MapLayout) { currentMap = null; currentLayout = (MapLayout)map; } mainGUI.LoadMap(map); //Stop timer loadTime.Stop(); TimeSpan ts = loadTime.Elapsed; string elapsedTime = ts.Seconds + "." + (ts.Milliseconds / 10); mainGUI.SetTitleText(programTitle + " | " + currentFileName + " | " + ((currentMap != null) ? currentMap.name : currentLayout.name)); mainGUI.SetLoadingStatus(string.Format(rmInternalStrings.GetString("MapLoadedStatus"), (currentMap != null) ? currentMap.name : currentLayout.name, elapsedTime)); return 0; }
public static void LoadROM(string filename) { if (ROM.Edited || isEdited) { string result = ShowMessageBox(rmInternalStrings.GetString("UnsavedChanges"), rmInternalStrings.GetString("UnsavedChangesTitle"), "YesNoCancel", "Warning"); if (result == "Yes") SaveROM(); else if (result == "Cancel") return; } Stopwatch loadTime = new Stopwatch(); loadTime.Start(); //Put all loading code between here and "Stop timer" comment if (OpenROM(filename) == 0) { isEdited = false; mainGUI.AddRecentFile(filename); currentFilePath = filename; currentFileName = Path.GetFileName(filename); // You gotta initialize it all backwards so you can reference it loadExceptions = new List<Exception>(); maxLayout = 0; mapLayoutNotFoundCount = 0; mainGUI.ClearMapNodes(); extraLayoutsLoaded = false; currentLayout = null; mapTilesets = new SortedDictionary<int, MapTileset>(); mapLayouts = new Dictionary<int, MapLayout>(); LoadMapLayouts(); LoadMapNames(); LoadMapBanks(); mainGUI.EnableControlsOnROMLoad(); mainGUI.LoadMapNodes(); currentGame.Songs = Config.musicLists.Songs[currentGame.RomType]; mainGUI.LoadHeaderTabDropdowns(); //Stop timer loadTime.Stop(); TimeSpan ts = loadTime.Elapsed; string elapsedTime = ts.Seconds + "." + ts.Milliseconds; mainGUI.SetTitleText(programTitle + " | " + currentFileName); mainGUI.SetLoadingStatus(string.Format(rmInternalStrings.GetString("ROMLoadedStatus"), currentFileName, elapsedTime)); //Oh goodie, all the errors foreach (Exception ex in loadExceptions) { if (ex is TilesetLoadErrorException) ShowMessageBox(ex.Message, rmInternalStrings.GetString("CouldNotReadTilesetTitle"), "OK", "Warning"); else if (ex is MapLayoutLoadErrorException) ShowMessageBox(ex.Message, rmInternalStrings.GetString("CouldNotReadTilesetTitle"), "OK", "Warning"); } if (mapLayoutNotFoundCount > 0) ShowMessageBox(string.Format(rmInternalStrings.GetString("CouldNotFindLayout"), mapLayoutNotFoundCount), rmInternalStrings.GetString("CouldNotFindLayoutTitle"), "OK", "Warning"); } else { loadTime.Stop(); } }
public void Initialize(MapLayout mapLayout) { image = new Bitmap[16]; //layout = new MapLayout(mapDataPointer, ROM); //name = "[" + currentBank.ToString("X2") + ", " + currentMap.ToString("X2") + "] " + Program.mapNames[mapNameIndex].Name; int width = 128; int height = Program.currentGame.MainTSSize * 8; int palSpace = 6; if (Program.currentGame.RomType == "FRLG") palSpace = 7; if ((isSecondary & 1) == 0) height = Program.currentGame.LocalTSSize * 8; if (mapLayout.globalTileset != null) for (int i = 0; i < palSpace; i++) image[i] = Graphics.ImageManipulator.imageLoader(Program.ROM, imagePointer, mapLayout.globalTileset.imagePalsPointer + i * 32, width, height, (isCompressed & 1) == 1, false, true); if (mapLayout.localTileset != null) for (int i = palSpace; i < 13; i++) image[i] = Graphics.ImageManipulator.imageLoader(Program.ROM, imagePointer, mapLayout.localTileset.imagePalsPointer + i * 32, width, height, (isCompressed & 1) == 1, false, true); for (int i = 13; i < 16; i++) image[i] = Graphics.ImageManipulator.imageLoader(Program.ROM, imagePointer, 0, width, height, (isCompressed & 1) == 1, false, true); tileSheets = new Spritesheet[16]; for (int i = 0; i < 16; i++) if(image[i] != null) tileSheets[i] = Spritesheet.Load(image[i], 8, 8); }