Skip to content

Commit

Permalink
Remove debug from ARM9 too if it's too big after recompression.
Browse files Browse the repository at this point in the history
  • Loading branch information
AdmiralCurtiss committed Aug 17, 2014
1 parent 9215189 commit b1d5869
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,16 @@ static void PatchArm9( System.IO.FileStream nds, uint pos, uint len ) {

int arm9diff = (int)len - (int)newCompressedSize;
if ( arm9diff < 0 ) {
Console.WriteLine( "WARNING: Recompressed ARM9 is " + -arm9diff + " bytes bigger than original!" );
Console.WriteLine( " Patched game may be corrupted!" );
// still too big, remove debug strings
decData = RemoveDebugStrings( decData );
data = blz.BLZ_Encode( decData, 0 );
newCompressedSize = (uint)data.Length;

arm9diff = (int)len - (int)newCompressedSize;
if ( arm9diff < 0 ) {
Console.WriteLine( "WARNING: Recompressed ARM9 is " + -arm9diff + " bytes bigger than original!" );
Console.WriteLine( " Patched game may be corrupted!" );
}
}
}

Expand Down Expand Up @@ -324,6 +332,7 @@ static byte[] RemoveDebugStrings( byte[] data ) {
"NULL byte expected!",
"Processing adderror packet",
"Out of memory.",
" buf->buffer",
};

foreach ( string s in debugStrings ) {
Expand Down

0 comments on commit b1d5869

Please sign in to comment.