mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-11-26 23:51:57 +00:00
SHR
This commit is contained in:
parent
f5ed58d922
commit
1d144492ce
@ -52,21 +52,6 @@ public abstract class HiResImage extends AbstractFile
|
||||
|
||||
this.fileType = fileType;
|
||||
this.auxType = auxType;
|
||||
|
||||
if (fileType == ProdosConstants.FILE_TYPE_PNT)
|
||||
{
|
||||
if (auxType == 1)
|
||||
{
|
||||
unpackedBuffer = unpackBytes (buffer);
|
||||
makeScreen (unpackedBuffer);
|
||||
System.out.println ("aux 1 - " + name);
|
||||
}
|
||||
|
||||
// if (auxType == 2)
|
||||
// {
|
||||
// System.out.println ("aux 2 - " + name);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
protected void createImage ()
|
||||
@ -159,11 +144,7 @@ public abstract class HiResImage extends AbstractFile
|
||||
|
||||
case ProdosConstants.FILE_TYPE_PNT:
|
||||
if (auxType == 1)
|
||||
{
|
||||
if (unpackedBuffer == null)
|
||||
unpackedBuffer = unpackBytes (buffer);
|
||||
auxText = "Packed Super Hi-Res Image";
|
||||
}
|
||||
else if (auxType == 2)
|
||||
auxText = "Super Hi-Res Image";
|
||||
else if (auxType == 3)
|
||||
|
21
src/com/bytezone/diskbrowser/applefile/PackedSHR.java
Normal file
21
src/com/bytezone/diskbrowser/applefile/PackedSHR.java
Normal file
@ -0,0 +1,21 @@
|
||||
package com.bytezone.diskbrowser.applefile;
|
||||
|
||||
public class PackedSHR extends HiResImage
|
||||
{
|
||||
|
||||
public PackedSHR (String name, byte[] buffer, int fileType, int auxType)
|
||||
{
|
||||
super (name, buffer, fileType, auxType);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createMonochromeImage ()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createColourImage ()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
@ -5,11 +5,11 @@ import java.util.List;
|
||||
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
|
||||
public class PaintFile extends HiResImage
|
||||
public class SHRPictureFile extends HiResImage
|
||||
{
|
||||
List<Block> blocks = new ArrayList<Block> ();
|
||||
|
||||
public PaintFile (String name, byte[] buffer, int fileType, int auxType)
|
||||
public SHRPictureFile (String name, byte[] buffer, int fileType, int auxType)
|
||||
{
|
||||
super (name, buffer, fileType, auxType);
|
||||
|
||||
@ -131,6 +131,76 @@ public class PaintFile extends HiResImage
|
||||
System.arraycopy (data, ptr, packedScanLines[i], 0, len);
|
||||
ptr += len;
|
||||
}
|
||||
|
||||
if (true)
|
||||
{
|
||||
byte[] newBuf = new byte[32768];
|
||||
ptr = 0;
|
||||
for (int line = 0; line < numScanLines; line++)
|
||||
{
|
||||
byte[] lineBuffer = packedScanLines[line];
|
||||
if (lineBuffer.length % 2 == 1 && isEmpty (lineBuffer))
|
||||
{
|
||||
System.out.println ("Odd number of bytes in empty buffer in " + name);
|
||||
break;
|
||||
}
|
||||
ptr = unpackLine (lineBuffer, newBuf, ptr);
|
||||
}
|
||||
makeScreen (newBuf);
|
||||
}
|
||||
}
|
||||
|
||||
// Super Hi-res IIGS
|
||||
protected int unpackLine (byte[] buffer, byte[] newBuf, int newPtr)
|
||||
{
|
||||
byte[] fourBuf = new byte[4];
|
||||
|
||||
int ptr = 0;
|
||||
while (ptr < buffer.length)
|
||||
{
|
||||
int type = (buffer[ptr] & 0xC0) >> 6; // 0-3
|
||||
int count = (buffer[ptr++] & 0x3F) + 1; // 1-64
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
while (count-- != 0)
|
||||
// if (ptr < buffer.length) // fixes a bug in some images
|
||||
newBuf[newPtr++] = buffer[ptr++];
|
||||
break;
|
||||
|
||||
case 1:
|
||||
byte b = buffer[ptr++];
|
||||
while (count-- != 0)
|
||||
newBuf[newPtr++] = b;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
for (int i = 0; i < 4; i++)
|
||||
fourBuf[i] = buffer[ptr++];
|
||||
while (count-- != 0)
|
||||
for (int i = 0; i < 4; i++)
|
||||
newBuf[newPtr++] = fourBuf[i];
|
||||
break;
|
||||
|
||||
case 3:
|
||||
b = buffer[ptr++];
|
||||
count *= 4;
|
||||
while (count-- != 0)
|
||||
newBuf[newPtr++] = b;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return newPtr;
|
||||
}
|
||||
|
||||
private boolean isEmpty (byte[] buffer)
|
||||
{
|
||||
for (byte b : buffer)
|
||||
if (b != 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -166,15 +236,26 @@ public class PaintFile extends HiResImage
|
||||
text.append ("\nScan Lines\n");
|
||||
text.append ("----------\n\n");
|
||||
|
||||
text.append (" # Mode Packed Data\n");
|
||||
text.append ("--- ---- ---------------------------------------------");
|
||||
text.append (" # Mode Len Packed Data\n");
|
||||
text.append ("--- ---- --- ---------------------------------------");
|
||||
text.append ("------------------------------------------\n");
|
||||
|
||||
int lineSize = 24;
|
||||
for (int i = 0; i < scanLineDirectory.length; i++)
|
||||
{
|
||||
DirEntry dirEntry = scanLineDirectory[i];
|
||||
byte[] packedScanLine = packedScanLines[i];
|
||||
text.append (String.format ("%3d %2d ", i, dirEntry.mode));
|
||||
text.append (HexFormatter.getHexString (packedScanLine));
|
||||
text.append (String.format ("%3d %2d %3d ", i, dirEntry.mode,
|
||||
packedScanLine.length));
|
||||
int ptr = 0;
|
||||
while (true)
|
||||
{
|
||||
text.append (HexFormatter.getHexString (packedScanLine, ptr, lineSize));
|
||||
ptr += lineSize;
|
||||
if (ptr >= packedScanLine.length)
|
||||
break;
|
||||
text.append ("\n ");
|
||||
}
|
||||
text.append ("\n");
|
||||
}
|
||||
|
@ -354,8 +354,10 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
||||
file = new IconFile (name, exactBuffer);
|
||||
break;
|
||||
case FILE_TYPE_PNT:
|
||||
if (auxType == 1)
|
||||
file = new PackedSHR (name, exactBuffer, fileType, auxType);
|
||||
if (auxType == 2)
|
||||
file = new PaintFile (name, exactBuffer, fileType, auxType);
|
||||
file = new SHRPictureFile (name, exactBuffer, fileType, auxType);
|
||||
else
|
||||
file = new OriginalHiResImage (name, exactBuffer, fileType, auxType);
|
||||
break;
|
||||
@ -387,10 +389,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
||||
private byte[] getExactBuffer (byte[] buffer)
|
||||
{
|
||||
if (buffer.length < endOfFile)
|
||||
{
|
||||
System.out.println ("Buffer shorter than EOF in " + name);
|
||||
System.out.printf (" buffer %,d, eof %,d%n", buffer.length, endOfFile);
|
||||
}
|
||||
System.out.printf ("Buffer (%,d) shorter than EOF (%,d) in %s%n", buffer.length,
|
||||
endOfFile, name);
|
||||
|
||||
byte[] exactBuffer;
|
||||
if (buffer.length < endOfFile)
|
||||
|
@ -205,9 +205,10 @@ public class HexFormatter
|
||||
public static String getHexString (byte[] buffer, int offset, int length, boolean space)
|
||||
{
|
||||
StringBuilder hex = new StringBuilder ();
|
||||
for (int i = 0; i < length; i++)
|
||||
int max = Math.min (offset + length, buffer.length);
|
||||
for (int i = offset; i < max; i++)
|
||||
{
|
||||
hex.append (String.format ("%02X", buffer[offset + i]));
|
||||
hex.append (String.format ("%02X", buffer[i]));
|
||||
if (space)
|
||||
hex.append (' ');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user