mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-06-06 06:29:27 +00:00
testing graphics changes
This commit is contained in:
parent
639330b24d
commit
ecb125f9dd
|
@ -78,7 +78,7 @@ public abstract class HiResImage extends AbstractFile
|
|||
// $08 8066 3
|
||||
// $C0 0000 1
|
||||
// $C0 0001 $C1 0000 2 1
|
||||
// $C0 0002 1
|
||||
// $C0 0002 1,5
|
||||
// $C0 0003 $C1 0001 . .
|
||||
// $C0 0004 $C1 0002 . 1
|
||||
// $C0 1000 .
|
||||
|
@ -99,6 +99,7 @@ public abstract class HiResImage extends AbstractFile
|
|||
// 2 0603 Katie's Farm - Disk 2.po
|
||||
// 3 CompressedSlides.do
|
||||
// 4 System Addons.hdv
|
||||
// 5 gfx.po
|
||||
//
|
||||
|
||||
// see also - https://docs.google.com/spreadsheets/d
|
||||
|
@ -332,7 +333,7 @@ public abstract class HiResImage extends AbstractFile
|
|||
int rgbLeft = colorTable.entries[left].color.getRGB ();
|
||||
int rgbRight = colorTable.entries[right].color.getRGB ();
|
||||
|
||||
// draw pixels on two lines
|
||||
// draw two pixels (twice) on two lines
|
||||
draw (dataBuffer, element + imageWidth, rgbLeft, rgbLeft, rgbRight, rgbRight);
|
||||
element = draw (dataBuffer, element, rgbLeft, rgbLeft, rgbRight, rgbRight);
|
||||
}
|
||||
|
@ -358,7 +359,7 @@ public abstract class HiResImage extends AbstractFile
|
|||
int rgb3 = colorTable.entries[p3].color.getRGB ();
|
||||
int rgb4 = colorTable.entries[p4 + 4].color.getRGB ();
|
||||
|
||||
// draw pixels on two lines
|
||||
// draw four pixels on two lines
|
||||
draw (dataBuffer, element + imageWidth, rgb1, rgb2, rgb3, rgb4); // 2nd line
|
||||
element = draw (dataBuffer, element, rgb1, rgb2, rgb3, rgb4); // 1st line
|
||||
}
|
||||
|
@ -369,6 +370,12 @@ public abstract class HiResImage extends AbstractFile
|
|||
int draw (DataBuffer dataBuffer, int element, int... rgb1)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (dataBuffer.getSize () < rgb1.length + element)
|
||||
{
|
||||
System.out.printf ("Bollocks: %d %d %d%n", dataBuffer.getSize (), rgb1.length,
|
||||
element);
|
||||
return element;
|
||||
}
|
||||
for (int i = 0; i < rgb1.length; i++)
|
||||
dataBuffer.setElem (element++, rgb1[i]);
|
||||
|
||||
|
@ -676,13 +683,54 @@ public abstract class HiResImage extends AbstractFile
|
|||
ColorEntry[] entries = new ColorEntry[16];
|
||||
|
||||
// -------------------------------------------------------------------------------//
|
||||
public ColorTable ()
|
||||
public ColorTable (int id, int mode)
|
||||
// -------------------------------------------------------------------------------//
|
||||
{
|
||||
// default empty table
|
||||
id = -1;
|
||||
for (int i = 0; i < 16; i++)
|
||||
entries[i] = new ColorEntry ();
|
||||
this.id = id;
|
||||
|
||||
if ((mode & 0x80) == 0)
|
||||
{
|
||||
entries[0] = new ColorEntry (0x00, 0x00, 0x00);
|
||||
entries[1] = new ColorEntry (0x07, 0x07, 0x07);
|
||||
entries[2] = new ColorEntry (0x08, 0x04, 0x01);
|
||||
entries[3] = new ColorEntry (0x07, 0x02, 0x0C);
|
||||
entries[4] = new ColorEntry (0x00, 0x00, 0x0F);
|
||||
entries[5] = new ColorEntry (0x00, 0x08, 0x00);
|
||||
entries[6] = new ColorEntry (0x0F, 0x07, 0x00);
|
||||
entries[7] = new ColorEntry (0x0D, 0x00, 0x00);
|
||||
|
||||
entries[8] = new ColorEntry (0x0F, 0x0A, 0x09);
|
||||
entries[9] = new ColorEntry (0x0F, 0x0F, 0x00);
|
||||
entries[10] = new ColorEntry (0x00, 0x0E, 0x00);
|
||||
entries[11] = new ColorEntry (0x04, 0x0D, 0x0F);
|
||||
entries[12] = new ColorEntry (0x0D, 0x0A, 0x0F);
|
||||
entries[13] = new ColorEntry (0x07, 0x08, 0x0F);
|
||||
entries[14] = new ColorEntry (0x0C, 0x0C, 0x0C);
|
||||
entries[15] = new ColorEntry (0x0F, 0x0F, 0x0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
entries[0] = new ColorEntry (0x00, 0x00, 0x00);
|
||||
entries[1] = new ColorEntry (0x00, 0x00, 0x0F);
|
||||
entries[2] = new ColorEntry (0x0F, 0x0F, 0x00);
|
||||
entries[3] = new ColorEntry (0x0F, 0x0F, 0x0F);
|
||||
|
||||
entries[4] = new ColorEntry (0x00, 0x00, 0x00);
|
||||
entries[5] = new ColorEntry (0x0D, 0x00, 0x00);
|
||||
entries[6] = new ColorEntry (0x00, 0x0E, 0x00);
|
||||
entries[7] = new ColorEntry (0x0F, 0x0F, 0x0F);
|
||||
|
||||
entries[0] = new ColorEntry (0x00, 0x00, 0x00);
|
||||
entries[1] = new ColorEntry (0x00, 0x00, 0x0F);
|
||||
entries[2] = new ColorEntry (0x0F, 0x0F, 0x00);
|
||||
entries[3] = new ColorEntry (0x0F, 0x0F, 0x0F);
|
||||
|
||||
entries[4] = new ColorEntry (0x00, 0x00, 0x00);
|
||||
entries[5] = new ColorEntry (0x0D, 0x00, 0x00);
|
||||
entries[6] = new ColorEntry (0x00, 0x0E, 0x00);
|
||||
entries[7] = new ColorEntry (0x0F, 0x0F, 0x0F);
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------//
|
||||
|
@ -730,7 +778,7 @@ public abstract class HiResImage extends AbstractFile
|
|||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
|
||||
text.append (String.format ("%2d ColorTable%n", id));
|
||||
text.append (String.format ("%3d ColorTable%n", id));
|
||||
for (int i = 0; i < 8; i++)
|
||||
text.append (String.format (" %2d: %04X", i, entries[i].value));
|
||||
text.append ("\n");
|
||||
|
@ -749,12 +797,12 @@ public abstract class HiResImage extends AbstractFile
|
|||
Color color;
|
||||
|
||||
// -------------------------------------------------------------------------------//
|
||||
public ColorEntry ()
|
||||
public ColorEntry (int red, int green, int blue)
|
||||
// -------------------------------------------------------------------------------//
|
||||
{
|
||||
// default empty entry
|
||||
value = 0;
|
||||
color = new Color (0, 0, 0);
|
||||
value = (red << 8) | (green << 4) | blue;
|
||||
color = new Color (red, green, blue);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------//
|
||||
|
|
|
@ -121,7 +121,12 @@ public class SHRPictureFile1 extends HiResImage
|
|||
return;
|
||||
}
|
||||
|
||||
boolean mode320 = (mainBlock.masterMode & 0x80) == 0;
|
||||
|
||||
int imageWidth = mainBlock.masterMode == 0x80 ? 640 : mainBlock.unpackedSize[0] * 4;
|
||||
imageWidth = Math.max (mainBlock.pixelsPerScanLine, imageWidth);
|
||||
assert imageWidth == 640;
|
||||
|
||||
image = new BufferedImage (imageWidth, mainBlock.numScanLines * 2,
|
||||
BufferedImage.TYPE_INT_RGB);
|
||||
DataBuffer dataBuffer = image.getRaster ().getDataBuffer ();
|
||||
|
@ -135,18 +140,21 @@ public class SHRPictureFile1 extends HiResImage
|
|||
int hi = dirEntry.mode & 0xFF00; // always 0
|
||||
int lo = dirEntry.mode & 0x00FF; // mode bit if hi == 0
|
||||
|
||||
boolean fillMode = (dirEntry.mode & 0x20) != 0;
|
||||
// assert fillMode == false;
|
||||
|
||||
if (hi != 0)
|
||||
System.out.println ("hi not zero");
|
||||
|
||||
ColorTable colorTable = multipalBlock != null ? multipalBlock.colorTables[line]
|
||||
: mainBlock.colorTables[lo & 0x0F];
|
||||
ColorTable colorTable = //
|
||||
multipalBlock != null ? multipalBlock.colorTables[line]
|
||||
: mainBlock.colorTables[lo & 0x0F];
|
||||
|
||||
boolean mode320 = (mainBlock.masterMode & 0x80) == 0;
|
||||
int max = mainBlock.unpackedSize[line];
|
||||
|
||||
if (mode320) // two pixels per col
|
||||
if (mode320) // two pixels per byte
|
||||
ptr = mode320Line (ptr, element, max, colorTable, dataBuffer, imageWidth);
|
||||
else // four pixels per col
|
||||
else // four pixels per byte
|
||||
ptr = mode640Line (ptr, element, max, colorTable, dataBuffer, imageWidth);
|
||||
|
||||
element += imageWidth * 2; // drawing two lines at a time
|
||||
|
@ -214,7 +222,7 @@ public class SHRPictureFile1 extends HiResImage
|
|||
private class Multipal extends Block
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int numPalettes;
|
||||
int numColorTables;
|
||||
ColorTable[] colorTables;
|
||||
|
||||
// -------------------------------------------------------------------------------//
|
||||
|
@ -224,19 +232,39 @@ public class SHRPictureFile1 extends HiResImage
|
|||
super (kind, data);
|
||||
|
||||
int ptr = 5 + kind.length ();
|
||||
numPalettes = HexFormatter.unsignedShort (data, ptr);
|
||||
numColorTables = HexFormatter.unsignedShort (data, ptr);
|
||||
|
||||
ptr += 2;
|
||||
colorTables = new ColorTable[numPalettes];
|
||||
for (int i = 0; i < numPalettes; i++)
|
||||
colorTables = new ColorTable[numColorTables];
|
||||
|
||||
for (int i = 0; i < numColorTables; i++)
|
||||
{
|
||||
if (ptr < data.length - 32)
|
||||
colorTables[i] = new ColorTable (i, data, ptr);
|
||||
else
|
||||
colorTables[i] = new ColorTable (); // default empty table
|
||||
colorTables[i] = new ColorTable (i, 0x00); // default empty table
|
||||
ptr += 32;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String toString ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
|
||||
text.append (String.format ("Kind ................. %s%n", kind));
|
||||
text.append (String.format ("NumColorTables ....... %d%n%n", numColorTables));
|
||||
|
||||
for (int line = 0; line < numColorTables; line++)
|
||||
{
|
||||
text.append (colorTables[line]);
|
||||
text.append ("\n\n");
|
||||
}
|
||||
|
||||
return text.toString ();
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -261,6 +289,7 @@ public class SHRPictureFile1 extends HiResImage
|
|||
masterMode = HexFormatter.unsignedShort (data, ptr);
|
||||
pixelsPerScanLine = HexFormatter.unsignedShort (data, ptr + 2);
|
||||
numColorTables = HexFormatter.unsignedShort (data, ptr + 4);
|
||||
assert numColorTables > 0;
|
||||
|
||||
ptr += 6;
|
||||
colorTables = new ColorTable[numColorTables];
|
||||
|
@ -277,28 +306,28 @@ public class SHRPictureFile1 extends HiResImage
|
|||
unpackedSize = new int[numScanLines];
|
||||
packedScanLines = new byte[numScanLines][];
|
||||
|
||||
for (int i = 0; i < numScanLines; i++)
|
||||
for (int line = 0; line < numScanLines; line++)
|
||||
{
|
||||
DirEntry dirEntry = new DirEntry (data, ptr);
|
||||
scanLineDirectory[i] = dirEntry;
|
||||
packedScanLines[i] = new byte[dirEntry.numBytes];
|
||||
scanLineDirectory[line] = dirEntry;
|
||||
packedScanLines[line] = new byte[dirEntry.numBytes];
|
||||
ptr += 4;
|
||||
}
|
||||
|
||||
for (int i = 0; i < numScanLines; i++)
|
||||
for (int line = 0; line < numScanLines; line++)
|
||||
{
|
||||
int len = scanLineDirectory[i].numBytes;
|
||||
if (ptr + len > data.length)
|
||||
int numBytes = scanLineDirectory[line].numBytes;
|
||||
if (ptr + numBytes > data.length)
|
||||
{
|
||||
System.out.println ("breaking early");
|
||||
break;
|
||||
}
|
||||
|
||||
System.arraycopy (data, ptr, packedScanLines[i], 0, len);
|
||||
ptr += len;
|
||||
System.arraycopy (data, ptr, packedScanLines[line], 0, numBytes);
|
||||
ptr += numBytes;
|
||||
}
|
||||
|
||||
int width = 320;
|
||||
int width = 160;
|
||||
byte[] unpackedBuffer = new byte[numScanLines * width];
|
||||
ptr = 0;
|
||||
for (int line = 0; line < numScanLines; line++)
|
||||
|
@ -313,6 +342,8 @@ public class SHRPictureFile1 extends HiResImage
|
|||
ptr = unpackLine (packedScanLines[line], unpackedBuffer, ptr);
|
||||
// System.out.printf ("%3d %5d %5d %3d%n", line, oldPtr, ptr, ptr - oldPtr);
|
||||
unpackedSize[line] = ptr - oldPtr;
|
||||
if (unpackedSize[line] != 160)
|
||||
System.out.printf ("Unexpected unpacked line size: %d%n", unpackedSize);
|
||||
|
||||
// something strange happening here
|
||||
if (line == 102 && name.equals ("DRAGON.SHR"))
|
||||
|
@ -320,6 +351,8 @@ public class SHRPictureFile1 extends HiResImage
|
|||
}
|
||||
|
||||
SHRPictureFile1.this.buffer = unpackedBuffer;
|
||||
|
||||
// System.out.printf ("Wasted: %d%n", (unpackedBuffer.length - ptr));
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------//
|
||||
|
@ -381,7 +414,7 @@ public class SHRPictureFile1 extends HiResImage
|
|||
DirEntry dirEntry = scanLineDirectory[i];
|
||||
byte[] packedScanLine = packedScanLines[i];
|
||||
text.append (
|
||||
String.format ("%3d %3d %3d ", i, dirEntry.mode, packedScanLine.length));
|
||||
String.format ("%3d %04X %3d ", i, dirEntry.mode, packedScanLine.length));
|
||||
int ptr = 0;
|
||||
while (true)
|
||||
{
|
||||
|
|
|
@ -373,7 +373,8 @@ class DataPanel extends JTabbedPane implements DiskSelectionListener,
|
|||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
private BufferedImage image;
|
||||
private int scale = 1;
|
||||
private double scale = 1;
|
||||
private double userScale = 1.5;
|
||||
|
||||
public ImagePanel ()
|
||||
{
|
||||
|
@ -406,7 +407,9 @@ class DataPanel extends JTabbedPane implements DiskSelectionListener,
|
|||
scale = 4;
|
||||
}
|
||||
|
||||
setPreferredSize (new Dimension (width * scale, height * scale));
|
||||
scale *= userScale;
|
||||
|
||||
setPreferredSize (new Dimension ((int) (width * scale), (int) (height * scale)));
|
||||
repaint ();
|
||||
}
|
||||
|
||||
|
@ -419,8 +422,8 @@ class DataPanel extends JTabbedPane implements DiskSelectionListener,
|
|||
{
|
||||
Graphics2D g2 = ((Graphics2D) g);
|
||||
g2.transform (AffineTransform.getScaleInstance (scale, scale));
|
||||
g2.drawImage (image, (getWidth () - image.getWidth () * scale) / 2 / scale, 4,
|
||||
this);
|
||||
g2.drawImage (image,
|
||||
(int) ((getWidth () - image.getWidth () * scale) / 2 / scale), 4, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user