mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2025-01-02 06:31:03 +00:00
method header lines
This commit is contained in:
parent
32de2aa69d
commit
09965c02aa
@ -3,7 +3,9 @@ package com.bytezone.diskbrowser.utilities;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class LZW
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
static protected final String[] st = new String[0x1000];
|
||||
static protected final int TRACK_LENGTH = 0x1000;
|
||||
@ -21,31 +23,41 @@ class LZW
|
||||
private int startPtr;
|
||||
protected byte[] bytes;
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
static
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
for (int i = 0; i < 256; i++)
|
||||
st[i] = "" + (char) i;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void setBuffer (byte[] buffer, int ptr)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
bytes = buffer;
|
||||
startPtr = this.ptr = ptr;
|
||||
bitsLeft = 0;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public int bytesRead ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return ptr - startPtr;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void fillBuffer ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
buffer = bytes[ptr++] & 0xFF;
|
||||
bitsLeft = 8;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private boolean readBoolean ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (bitsLeft == 0)
|
||||
fillBuffer ();
|
||||
@ -55,7 +67,9 @@ class LZW
|
||||
return bit;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
int readInt (int width)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (width < 8 || width > 12)
|
||||
throw new RuntimeException ("Illegal value of r = " + width);
|
||||
@ -68,7 +82,9 @@ class LZW
|
||||
return x;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
byte[] undoRLE (byte[] inBuffer, int inPtr, int length)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
byte[] outBuffer = new byte[TRACK_LENGTH];
|
||||
int outPtr = 0;
|
||||
@ -92,7 +108,9 @@ class LZW
|
||||
return outBuffer;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public byte[] getData ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
byte[] buffer = new byte[chunks.size () * TRACK_LENGTH];
|
||||
int trackNumber = 0;
|
||||
@ -106,7 +124,9 @@ class LZW
|
||||
return buffer;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
protected int width (int maximumValue)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return 32 - Integer.numberOfLeadingZeros (maximumValue);
|
||||
}
|
||||
|
@ -2,9 +2,13 @@ package com.bytezone.diskbrowser.utilities;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class LZW1 extends LZW
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public LZW1 (byte[] buffer)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
bytes = Objects.requireNonNull (buffer);
|
||||
|
||||
@ -49,11 +53,13 @@ class LZW1 extends LZW
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
protected byte[] undoLZW (int rleLength)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
byte[] lzwBuffer = new byte[rleLength]; // must fill this array from input
|
||||
byte[] lzwBuffer = new byte[rleLength]; // must fill this array from input
|
||||
int ptr = 0;
|
||||
int nextEntry = 0x100; // always start with a fresh table
|
||||
int nextEntry = 0x100; // always start with a fresh table
|
||||
String prev = "";
|
||||
|
||||
while (ptr < rleLength)
|
||||
@ -72,8 +78,10 @@ class LZW1 extends LZW
|
||||
return lzwBuffer;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String toString ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
|
||||
|
@ -2,13 +2,17 @@ package com.bytezone.diskbrowser.utilities;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class LZW2 extends LZW
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private int nextEntry = 0x100;
|
||||
private String prev = "";
|
||||
private int codeWord;
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public LZW2 (byte[] buffer, int crc)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
bytes = Objects.requireNonNull (buffer);
|
||||
|
||||
@ -67,7 +71,9 @@ class LZW2 extends LZW
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
protected byte[] undoLZW (int rleLength)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
byte[] lzwBuffer = new byte[rleLength]; // must fill this array from buffer
|
||||
int ptr = 0;
|
||||
@ -97,8 +103,10 @@ class LZW2 extends LZW
|
||||
return lzwBuffer;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String toString ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
|
||||
|
@ -7,7 +7,9 @@ import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class NuFX
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private static String[] fileSystems =
|
||||
{ "", "ProDOS/SOS", "DOS 3.3", "DOS 3.2", "Apple II Pascal", "Macintosh HFS",
|
||||
@ -20,19 +22,25 @@ public class NuFX
|
||||
private final List<Record> records = new ArrayList<> ();
|
||||
private final List<Thread> threads = new ArrayList<> ();
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public NuFX (Path path) throws FileFormatException, IOException
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
buffer = Files.readAllBytes (path);
|
||||
readBuffer ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public NuFX (File file) throws FileFormatException, IOException
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
buffer = Files.readAllBytes (file.toPath ());
|
||||
readBuffer ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void readBuffer ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
header = new Header (buffer);
|
||||
|
||||
@ -67,7 +75,9 @@ public class NuFX
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public byte[] getBuffer ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
for (Thread thread : threads)
|
||||
if (thread.hasDisk ())
|
||||
@ -75,8 +85,10 @@ public class NuFX
|
||||
return null;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String toString ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
for (Thread thread : threads)
|
||||
if (thread.hasDisk ())
|
||||
@ -84,7 +96,9 @@ public class NuFX
|
||||
return "no disk";
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
protected static int getCRC (final byte[] buffer, int base)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int crc = base;
|
||||
for (int j = 0; j < buffer.length; j++)
|
||||
@ -100,7 +114,9 @@ public class NuFX
|
||||
return crc;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
class Header
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
private final int totalRecords;
|
||||
private final int version;
|
||||
@ -178,7 +194,9 @@ public class NuFX
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
class Record
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
private final int totThreads;
|
||||
private final int crc;
|
||||
|
@ -4,25 +4,35 @@ import java.text.NumberFormat;
|
||||
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class NumberRenderer extends FormatRenderer
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public NumberRenderer (NumberFormat formatter)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (formatter);
|
||||
setHorizontalAlignment (SwingConstants.RIGHT);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static NumberRenderer getCurrencyRenderer ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return new NumberRenderer (NumberFormat.getCurrencyInstance ());
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static NumberRenderer getIntegerRenderer ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return new NumberRenderer (NumberFormat.getIntegerInstance ());
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static NumberRenderer getPercentRenderer ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return new NumberRenderer (NumberFormat.getPercentInstance ());
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.bytezone.diskbrowser.utilities;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class Thread
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private static String[] threadClassText = { "Message", "Control", "Data", "Filename" };
|
||||
private static String[] formatText =
|
||||
@ -18,7 +20,9 @@ class Thread
|
||||
private String message;
|
||||
private LZW lzw;
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public Thread (byte[] buffer, int offset, int dataOffset)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
header = new ThreadHeader (buffer, offset);
|
||||
|
||||
@ -60,23 +64,31 @@ class Thread
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public byte[] getData ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return hasDisk () ? lzw.getData () : null;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
int getCompressedEOF ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return header.compressedEOF;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public boolean hasDisk ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return lzw != null;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String toString ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
StringBuilder text = new StringBuilder (header.toString ());
|
||||
|
||||
@ -93,7 +105,9 @@ class Thread
|
||||
return text.toString ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
class ThreadHeader
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
private final int threadClass;
|
||||
private final int format;
|
||||
|
Loading…
Reference in New Issue
Block a user