Skip to content
Permalink
Browse files
Avoid printing BLZ warnings multiple times.
  • Loading branch information
AdmiralCurtiss committed Nov 2, 2014
1 parent b8a8361 commit f90c4491c287d2fc2cf2b3e114dd109469a3bf03
Showing with 15 additions and 11 deletions.
  1. +3 −3 Program.cs
  2. +12 −8 blz.cs
@@ -135,7 +135,7 @@ class Program {
// new ARM is actually bigger, redo without the additional nullterm replacement
decData = decDataUnmodified;
ReplaceInData( decData, 0x00, false );
data = blz.BLZ_Encode( decData, 0 );
data = blz.BLZ_Encode( decData, 0, supressWarnings: true );
newCompressedSize = (uint)data.Length;

int arm9diff = (int)len - (int)newCompressedSize;
@@ -147,7 +147,7 @@ class Program {
#if DEBUG
System.IO.File.WriteAllBytes( "arm9-dec-without-debug.bin", decData );
#endif
data = blz.BLZ_Encode( decData, 0 );
data = blz.BLZ_Encode( decData, 0, supressWarnings: true );
newCompressedSize = (uint)data.Length;

arm9diff = (int)len - (int)newCompressedSize;
@@ -327,7 +327,7 @@ class Program {
if ( diff < 0 ) {
Console.WriteLine( "Removing known debug strings and recompressing overlay " + id + "..." );
RemoveDebugStrings( decData );
data = blz.BLZ_Encode( decData, 0 );
data = blz.BLZ_Encode( decData, 0, supressWarnings: true );
newCompressedSize = (uint)data.Length;

newOverlaySize = data.Length;
20 blz.cs
@@ -256,7 +256,7 @@ class blz {
}

//*----------------------------------------------------------------------------
public byte[] BLZ_Encode( byte[] raw_buffer, uint mode ) {
public byte[] BLZ_Encode( byte[] raw_buffer, uint mode, bool supressWarnings = false ) {
byte[] pak_buffer, new_buffer;
uint raw_len, pak_len, new_len;

@@ -267,7 +267,7 @@ class blz {
pak_buffer = null;
pak_len = BLZ_MAXIM + 1;

new_buffer = BLZ_Code(raw_buffer, raw_len, out new_len, mode);
new_buffer = BLZ_Code( raw_buffer, raw_len, out new_len, mode, supressWarnings );
if (new_len < pak_len) {
pak_buffer = new_buffer;
pak_len = new_len;
@@ -306,7 +306,7 @@ class blz {
}
}
//*----------------------------------------------------------------------------
byte[] BLZ_Code( byte[] raw_buffer, uint raw_len, out uint new_len, uint best ) {
byte[] BLZ_Code( byte[] raw_buffer, uint raw_len, out uint new_len, uint best, bool supressWarnings = false ) {
byte[] pak_buffer;
uint pak, raw, raw_end, flg = 0;
byte[] tmp;
@@ -325,7 +325,9 @@ class blz {
raw_new = raw_len;
if (arm9 != 0) {
if (raw_len < 0x4000) {
Console.Write(", WARNING: ARM9 must be greater as 16KB, switch [9] disabled");
if ( !supressWarnings ) {
Console.WriteLine( "WARNING: ARM9 must be greater than 16KB, switch [9] disabled" );
}
//} else if (
// BitConverter.ToUInt32(raw_buffer, 0x0) != 0xE7FFDEFFu ||
// BitConverter.ToUInt32(raw_buffer, 0x4) != 0xE7FFDEFFu ||
@@ -339,10 +341,12 @@ class blz {
crc = BLZ_CRC16(raw_buffer, 0x10, 0x07F0);
byte[] crcbytes = BitConverter.GetBytes( crc );
if (!(raw_buffer[0x0E] == crcbytes[0] && raw_buffer[0x0F] == crcbytes[1])) {
Console.WriteLine( "NOTICE: CRC16 Secure Area 2KB do not match" );
Console.WriteLine( " This may be indicative of a bad dump." );
Console.WriteLine( " If you're patching a modified ROM, such as a hack or" );
Console.WriteLine( " fan-translation, you can safely ignore this." );
if ( !supressWarnings ) {
Console.WriteLine( "NOTICE: CRC16 Secure Area 2KB do not match" );
Console.WriteLine( " This may be indicative of a bad dump." );
Console.WriteLine( " If you're patching a modified ROM, such as a hack or" );
Console.WriteLine( " fan-translation, you can safely ignore this." );
}
raw_buffer[0x0E] = crcbytes[0];
raw_buffer[0x0F] = crcbytes[1];
}

0 comments on commit f90c449

Please sign in to comment.