diff --git a/DS_Map/DSUtils/ARM9.cs b/DS_Map/DSUtils/ARM9.cs
index 8c57c25..639c7fa 100644
--- a/DS_Map/DSUtils/ARM9.cs
+++ b/DS_Map/DSUtils/ARM9.cs
@@ -23,6 +23,7 @@ namespace DSPRE {
}
}
public static bool Decompress(string path) {
+
Process decompress = DSUtils.CreateDecompressProcess(path);
decompress.Start();
decompress.WaitForExit();
diff --git a/DS_Map/Main Window.cs b/DS_Map/Main Window.cs
index fe6a1c6..0d262bd 100644
--- a/DS_Map/Main Window.cs
+++ b/DS_Map/Main Window.cs
@@ -103,7 +103,7 @@ namespace DSPRE
/* ROM Information */
public static string gameCode;
- public static byte europeByte;
+ public static byte revisionByte;
public RomInfo romInfo;
public Dictionary eventToHeader = new Dictionary();
@@ -666,8 +666,6 @@ namespace DSPRE
string workDir = DSUtils.WorkDirPathFromFile(openRom.FileName);
AppLogger.Info(workDir + " will be used as the working directory for the ROM.");
-
-
int userchoice = UnpackRomCheckUserChoice(workDir);
switch (userchoice)
{
@@ -825,7 +823,7 @@ namespace DSPRE
if (RomInfo.gameLanguage == GameLanguages.English)
{
- if (europeByte == 0x0A)
+ if (revisionByte == 0x0A)
{
languageLabel.Text += " [Europe]";
}
@@ -893,6 +891,12 @@ namespace DSPRE
gameIcon.Refresh(); // Paint game icon
AppLogger.Debug("Game icon refreshed.");
+ if (!CheckAndDecompressARM9())
+ {
+ AppLogger.Error("ARM9 decompression failed. Aborting.");
+ return;
+ }
+
ReadROMInitData();
AppLogger.Info("ROM initialization data loaded.");
}
@@ -904,26 +908,39 @@ namespace DSPRE
{
gameCode = Encoding.UTF8.GetString(br.ReadBytes(4));
br.BaseStream.Position = 0x1E;
- europeByte = br.ReadByte();
+ revisionByte = br.ReadByte();
}
}
+ private bool CheckAndDecompressARM9()
+ {
+ if (!ARM9.CheckCompressionMark())
+ {
+ return true; // ARM9 is not compressed, proceed normally
+ }
+
+ if (!RomInfo.gameFamily.Equals(GameFamilies.HGSS))
+ {
+ MessageBox.Show("Unexpected compressed ARM9. It is advised that you double check the ARM9.");
+ return false;
+ }
+
+ ARM9.EditSize(-12); // Fix ARM9 size before decompression
+
+ if (!ARM9.Decompress(RomInfo.arm9Path))
+ {
+ MessageBox.Show("ARM9 decompression failed. The program can't proceed.\nAborting.",
+ "Error with ARM9 decompression", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return false;
+ }
+
+ AppLogger.Info("ARM9 decompressed and size fixed.");
+
+ return true;
+ }
+
private void ReadROMInitData()
{
- if (ARM9.CheckCompressionMark())
- {
- if (!RomInfo.gameFamily.Equals(GameFamilies.HGSS))
- {
- MessageBox.Show("Unexpected compressed ARM9. It is advised that you double check the ARM9.");
- }
- if (!ARM9.Decompress(RomInfo.arm9Path))
- {
- MessageBox.Show("ARM9 decompression failed. The program can't proceed.\nAborting.",
- "Error with ARM9 decompression", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- }
-
/* Setup essential editors */
EditorPanels.headerEditor.SetupHeaderEditor(this);