implemented an attempt-based fix for the arm9 decompression bug

This commit is contained in:
AdAstra-LD
2021-01-12 16:44:50 +01:00
parent 1917f6ea32
commit 2215fa4447

View File

@@ -60,20 +60,26 @@ namespace DSPRE {
}
private bool DecompressArm9() {
if (new FileInfo(workDir + @"arm9.bin").Length < 0xBC000) {
BinaryWriter arm9Truncate = new BinaryWriter(File.OpenWrite(workDir + @"arm9.bin"));
long arm9Length = new FileInfo(workDir + @"arm9.bin").Length;
arm9Truncate.BaseStream.SetLength(arm9Length - 0xc);
arm9Truncate.Close();
}
int attempts = 0;
do {
attempts++;
if (new FileInfo(workDir + @"arm9.bin").Length < 0xBC000) {
BinaryWriter arm9Truncate = new BinaryWriter(File.OpenWrite(workDir + @"arm9.bin"));
long arm9Length = new FileInfo(workDir + @"arm9.bin").Length;
arm9Truncate.BaseStream.SetLength(arm9Length - 0xc);
arm9Truncate.Close();
Process decompress = new Process();
decompress.StartInfo.FileName = @"Tools\blz.exe";
decompress.StartInfo.Arguments = @" -d " + '"' + workDir + "arm9.bin" + '"';
decompress.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
decompress.StartInfo.CreateNoWindow = true;
decompress.Start();
decompress.WaitForExit();
}
} while (new FileInfo(workDir + @"arm9.bin").Length < 1122000 && attempts < 2);
Process decompress = new Process();
decompress.StartInfo.FileName = @"Tools\blz.exe";
decompress.StartInfo.Arguments = @" -d " + '"' + workDir + "arm9.bin" + '"';
decompress.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
decompress.StartInfo.CreateNoWindow = true;
decompress.Start();
decompress.WaitForExit();
return (new FileInfo(workDir + @"arm9.bin").Length > 1122000);
}