This commit is contained in:
Denis Molony 2019-11-05 07:07:20 +10:00
parent 93186f2b6d
commit b7e8c470f7
3 changed files with 37 additions and 47 deletions

View File

@ -25,9 +25,6 @@ public class CharacterRom extends CharacterList
super (name, buffer, charsX, charsY, HEADER_LENGTH); super (name, buffer, charsX, charsY, HEADER_LENGTH);
description = HexFormatter.getCString (buffer, 16); description = HexFormatter.getCString (buffer, 16);
assert sizeX == (buffer[5] & 0xFF);
assert sizeY == (buffer[6] & 0xFF);
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//

View File

@ -17,7 +17,7 @@ public class IconFile extends AbstractFile implements ProdosConstants
private final int iBlkID; private final int iBlkID;
private final int iBlkPath; private final int iBlkPath;
private final String iBlkName; private final String iBlkName;
private final List<Icon> icons = new ArrayList<IconFile.Icon> (); private final List<Icon> icons = new ArrayList<> ();
private final boolean debug = false; private final boolean debug = false;
public IconFile (String name, byte[] buffer) public IconFile (String name, byte[] buffer)
@ -59,9 +59,9 @@ public class IconFile extends AbstractFile implements ProdosConstants
int columns = Math.min (icons.size (), 4); int columns = Math.min (icons.size (), 4);
int rows = (icons.size () - 1) / columns + 1; int rows = (icons.size () - 1) / columns + 1;
image = new BufferedImage ( // image = new BufferedImage ( //
columns * maxWidth + 2 * base + (columns - 1) * gap, // dimension (columns, base, maxWidth, gap), //
rows * maxHeight + 2 * base + (rows - 1) * gap, // dimension (rows, base, maxHeight, gap), //
BufferedImage.TYPE_INT_RGB); BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = image.createGraphics (); Graphics2D graphics = image.createGraphics ();
@ -87,6 +87,13 @@ public class IconFile extends AbstractFile implements ProdosConstants
graphics.dispose (); graphics.dispose ();
} }
// ---------------------------------------------------------------------------------//
private int dimension (int chars, int border, int size, int gap)
// ---------------------------------------------------------------------------------//
{
return border * 2 + chars * (size + gap) - gap;
}
@Override @Override
public String getText () public String getText ()
{ {
@ -197,6 +204,10 @@ public class IconFile extends AbstractFile implements ProdosConstants
System.out.println (); System.out.println ();
} }
if (iconWidth == 0 || iconHeight == 0)
throw new InvalidImageException (
String.format ("Invalid icon: Height: %d, Width: %d", iconHeight, iconWidth));
if (iconType != 0 && iconType != 0x8000 && iconType != 0xFFFF && iconType != 0x00FF) if (iconType != 0 && iconType != 0x8000 && iconType != 0xFFFF && iconType != 0x00FF)
throw new InvalidImageException (String.format ("Bad icon type: %04X", iconType)); throw new InvalidImageException (String.format ("Bad icon type: %04X", iconType));
@ -260,7 +271,7 @@ public class IconFile extends AbstractFile implements ProdosConstants
/* /*
Offset Color RGB Mini-Palette Offset Color RGB Mini-Palette
0 Black 000 0 0 Black 000 0
1 Blue 00F 1 1 Blue 00F 1
2 Yellow FF0 2 2 Yellow FF0 2
@ -269,7 +280,7 @@ public class IconFile extends AbstractFile implements ProdosConstants
5 Red D00 1 5 Red D00 1
6 Green 0E0 2 6 Green 0E0 2
7 White FFF 3 7 White FFF 3
8 Black 000 0 8 Black 000 0
9 Blue 00F 1 9 Blue 00F 1
10 Yellow FF0 2 10 Yellow FF0 2
@ -278,18 +289,18 @@ public class IconFile extends AbstractFile implements ProdosConstants
13 Red D00 1 13 Red D00 1
14 Green 0E0 2 14 Green 0E0 2
15 White FFF 3 15 White FFF 3
The displayMode word bits are defined as: The displayMode word bits are defined as:
Bit 0 selectedIconBit 1 = invert image before copying Bit 0 selectedIconBit 1 = invert image before copying
Bit 1 openIconBit 1 = copy light-gray pattern instead of image Bit 1 openIconBit 1 = copy light-gray pattern instead of image
Bit 2 offLineBit 1 = AND light-gray pattern to image being copied Bit 2 offLineBit 1 = AND light-gray pattern to image being copied
Bits 3-7 reserved. Bits 3-7 reserved.
Bits 8-11 foreground color to apply to black part of black & white icons Bits 8-11 foreground color to apply to black part of black & white icons
Bits 12-15 background color to apply to white part of black & white icons Bits 12-15 background color to apply to white part of black & white icons
Bits 0-2 can occur at once and are tested in the order 1-2-0. Bits 0-2 can occur at once and are tested in the order 1-2-0.
"Color is only applied to the black and white icons if bits 15-8 are not all 0. "Color is only applied to the black and white icons if bits 15-8 are not all 0.
Colored pixels in an icon are inverted by black pixels becoming white and any Colored pixels in an icon are inverted by black pixels becoming white and any
other color of pixel becoming black." other color of pixel becoming black."

View File

@ -14,20 +14,6 @@ public class Utility
public static final List<String> suffixes = public static final List<String> suffixes =
Arrays.asList ("po", "dsk", "do", "hdv", "2mg", "v2d", "d13", "sdk", "woz"); Arrays.asList ("po", "dsk", "do", "hdv", "2mg", "v2d", "d13", "sdk", "woz");
// not used - it doesn't work with Oracle's JDK
// private static boolean hasRetinaDisplay ()
// {
// Object obj =
// Toolkit.getDefaultToolkit ().getDesktopProperty ("apple.awt.contentScaleFactor");
// if (obj instanceof Float)
// {
// Float f = (Float) obj;
// int scale = f.intValue ();
// return (scale == 2); // 1 indicates a regular mac display.
// }
// return false;
// }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
public static boolean test (Graphics2D g) public static boolean test (Graphics2D g)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@ -57,19 +43,27 @@ public class Utility
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
for (int i = 0; i < buffer.length; i++) for (int i = 0; i < buffer.length; i++)
{ if (matches (buffer, i, key))
if (buffer[i] == key[0])
{ {
if (matches (buffer, i, key)) System.out.printf ("Matches at %04X%n", i);
{ return true;
System.out.printf ("Matches at %04X%n", i);
return true;
}
} }
}
return false; return false;
} }
// ---------------------------------------------------------------------------------//
public static boolean matches (byte[] buffer, int offset, byte[] key)
// ---------------------------------------------------------------------------------//
{
int ptr = 0;
while (offset < buffer.length && ptr < key.length)
if (buffer[offset++] != key[ptr++])
return false;
return true;
}
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
public static LocalDateTime getDateTime (byte[] buffer, int ptr) public static LocalDateTime getDateTime (byte[] buffer, int ptr)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@ -90,18 +84,6 @@ public class Utility
} }
} }
// ---------------------------------------------------------------------------------//
public static boolean matches (byte[] buffer, int offset, byte[] key)
// ---------------------------------------------------------------------------------//
{
int ptr = 0;
while (offset < buffer.length && ptr < key.length)
if (buffer[offset++] != key[ptr++])
return false;
return true;
}
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
public static int getSuffixNo (String filename) public static int getSuffixNo (String filename)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//