crc bug with sdk disk images

This commit is contained in:
Denis Molony 2021-04-18 13:30:50 +10:00
parent a51a1251c6
commit 5681aa4270
5 changed files with 18 additions and 11 deletions

View File

@ -130,7 +130,10 @@ class LZW
int calculatedCrc = Utility.getCRC (buffer, length, crcBase); int calculatedCrc = Utility.getCRC (buffer, length, crcBase);
if (crc != calculatedCrc) if (crc != calculatedCrc)
{
System.out.printf ("%n*** LZW CRC mismatch *** %04X %04X%n", crc, calculatedCrc); System.out.printf ("%n*** LZW CRC mismatch *** %04X %04X%n", crc, calculatedCrc);
// throw new FileFormatException ("File CRC failed");
}
return buffer; return buffer;
} }

View File

@ -17,9 +17,10 @@ class LZW2 extends LZW
bytes = Objects.requireNonNull (buffer); bytes = Objects.requireNonNull (buffer);
this.crc = crc; this.crc = crc;
this.v3eof = eof;
crcBase = 0xFFFF; crcBase = 0xFFFF;
codeWord = 0; codeWord = 0;
v3eof = eof;
volume = buffer[0] & 0xFF; volume = buffer[0] & 0xFF;
runLengthChar = (byte) (buffer[1] & 0xFF); runLengthChar = (byte) (buffer[1] & 0xFF);

View File

@ -44,11 +44,11 @@ public class NuFX
for (int rec = 0; rec < masterHeader.getTotalRecords (); rec++) for (int rec = 0; rec < masterHeader.getTotalRecords (); rec++)
{ {
Record record = new Record (buffer, dataPtr); Record record = new Record (buffer, dataPtr);
if (record.getFileSystemID () != 1) // if (record.getFileSystemID () != 1)
{ // {
System.out.println ("Not Prodos"); // System.out.println ("Not Prodos: " + record.getFileSystemID ());
break; // break;
} // }
records.add (record); records.add (record);
if (debug) if (debug)
@ -175,7 +175,7 @@ public class NuFX
if (nameOffset > 0) // remove volume name from path if (nameOffset > 0) // remove volume name from path
fileName = fileName.substring (nameOffset); fileName = fileName.substring (nameOffset);
if (true) if (false)
System.out.printf ("%3d %-35s %02X %,7d %,7d %,7d %s %s%n", ++count, System.out.printf ("%3d %-35s %02X %,7d %,7d %,7d %s %s%n", ++count,
fileName, fileType, auxType, eof, buffer.length, created, modified); fileName, fileType, auxType, eof, buffer.length, created, modified);

View File

@ -37,7 +37,11 @@ class Thread
lzw = switch (header.threadFormat) lzw = switch (header.threadFormat)
{ {
case 2 -> new LZW1 (data); case 2 -> new LZW1 (data);
case 3 -> new LZW2 (data, header.threadCrc, header.uncompressedEOF); case 3 ->
{
int length = header.threadKind == 1 ? 0 : header.uncompressedEOF;
yield new LZW2 (data, header.threadCrc, length);
}
default -> null; // 1 = Huffman Squeeze default -> null; // 1 = Huffman Squeeze
}; };

View File

@ -49,9 +49,8 @@ class ThreadHeader
text.append (String.format (" kind .............. %d %s%n", threadKind, text.append (String.format (" kind .............. %d %s%n", threadKind,
threadKindText[threadClass][threadKind])); threadKindText[threadClass][threadKind]));
text.append (String.format (" crc ............... %,d (%<04X)%n", threadCrc)); text.append (String.format (" crc ............... %,d (%<04X)%n", threadCrc));
text.append (String.format (" uncompressedEOF ... %,d%n", uncompressedEOF)); text.append (String.format (" uncompressedEOF ... %,d (%<08X)%n", uncompressedEOF));
text.append (String.format (" compressedEOF ..... %,d (%08X)", compressedEOF, text.append (String.format (" compressedEOF ..... %,d (%<08X)", compressedEOF));
compressedEOF));
return text.toString (); return text.toString ();
} }
} }