mirror of
https://github.com/AdAstra-LD/DS-Pokemon-Rom-Editor.git
synced 2026-05-11 06:24:14 -05:00
Decompression hotfix (#97)
* fix arm9 decompression issue (I blame ndstool) * rename "europeByte" to revisionByte
This commit is contained in:
parent
eeae1ee67c
commit
4ecb493780
|
|
@ -23,6 +23,7 @@ namespace DSPRE {
|
|||
}
|
||||
}
|
||||
public static bool Decompress(string path) {
|
||||
|
||||
Process decompress = DSUtils.CreateDecompressProcess(path);
|
||||
decompress.Start();
|
||||
decompress.WaitForExit();
|
||||
|
|
|
|||
|
|
@ -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<ushort /*evFile*/, ushort /*header*/> eventToHeader = new Dictionary<ushort, ushort>();
|
||||
|
||||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user