From 973a1fab96332b8ca46d464127696f985d7c3e51 Mon Sep 17 00:00:00 2001 From: Denis Molony Date: Fri, 22 Mar 2019 11:59:25 +1100 Subject: [PATCH] woz2 changes --- src/com/bytezone/diskbrowser/nib/MC3470.java | 28 +++++++++++-------- src/com/bytezone/diskbrowser/nib/WozFile.java | 16 ++++++----- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/com/bytezone/diskbrowser/nib/MC3470.java b/src/com/bytezone/diskbrowser/nib/MC3470.java index 115a2fe..ac8ee52 100644 --- a/src/com/bytezone/diskbrowser/nib/MC3470.java +++ b/src/com/bytezone/diskbrowser/nib/MC3470.java @@ -79,7 +79,7 @@ class MC3470 finished = false; int zeroBits = 0; - while (inPtr < max && !finished) + main: while (inPtr < max && !finished) { byte b = buffer[inPtr++]; @@ -88,24 +88,26 @@ class MC3470 for (int mask = 0x80; mask != 0; mask >>>= 1) { - value <<= 1; - if ((b & mask) != 0) + value <<= 1; // make space for next bit + if ((b & mask) != 0) // is next bit = 1? { - value |= 0x01; - zeroBits = 0; + value |= 0x01; // store 1 + zeroBits = 0; // reset zero counter } else { - ++zeroBits; - if (zeroBits > 2) + ++zeroBits; // increment zero counter + if (zeroBits > 2) // looks like copy protection { if (debug) - System.out.printf (zeroBits + " consecutive zeroes @ %d/%d %s%n", - diskSectors.size (), dataPtr, currentState); + System.out.printf ("%d consecutive zeroes @ %d/%d %s - %,d%n", zeroBits, + diskSectors.size (), dataPtr, currentState, totalBits); + value |= 0x01; // store 1 + zeroBits = 0; // reset zero counter } } - if ((value & 0x80) != 0) // value is not valid until the hi-bit is set + if ((value & 0x80) != 0) // value is not valid until the hi-bit is set { if (dump) { @@ -127,11 +129,15 @@ class MC3470 } if (++totalBits == bitCount) // only use this many bits + { + if (debug) + System.out.println ("bitcount reached"); break; + } } // check for unfinished data block, we may need to restart from the beginning - if (inPtr == max && currentState == State.DATA && !restarted) + if (totalBits == bitCount && currentState == State.DATA && !restarted) { inPtr = offset; restarted = true; diff --git a/src/com/bytezone/diskbrowser/nib/WozFile.java b/src/com/bytezone/diskbrowser/nib/WozFile.java index d884efb..51cdbf4 100644 --- a/src/com/bytezone/diskbrowser/nib/WozFile.java +++ b/src/com/bytezone/diskbrowser/nib/WozFile.java @@ -44,13 +44,9 @@ public class WozFile boolean valid = false; if (matches (WOZ1_FILE_HEADER, buffer)) - { wozVersion = 1; - } else if (matches (WOZ2_FILE_HEADER, buffer)) - { wozVersion = 2; - } else { System.out.println (HexFormatter.format (buffer, 0, 20)); @@ -199,12 +195,18 @@ public class WozFile int blockCount = readInt (buffer, p + 2, 2); int bitCount = readInt (buffer, p + 4, 4); + if (debug) + { + System.out.println ("******************************"); + System.out.printf ("* Track ......... %,6d *%n", trackNo); + System.out.printf ("* Block count ... %,6d *%n", blockCount); + System.out.printf ("* Bit count .... %,6d *%n", bitCount); + System.out.println ("******************************"); + } + if (startingBlock == 0) break; - if (debug) - System.out.printf ("%3d %3d %6d%n", startingBlock, blockCount, bitCount); - try { // nibbleTracks.add (mc3470.getNibbleTrack (buffer, ptr, bytesUsed, bitCount));