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);
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 iBlkPath;
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;
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 rows = (icons.size () - 1) / columns + 1;
image = new BufferedImage ( //
columns * maxWidth + 2 * base + (columns - 1) * gap, //
rows * maxHeight + 2 * base + (rows - 1) * gap, //
image = new BufferedImage ( //
dimension (columns, base, maxWidth, gap), //
dimension (rows, base, maxHeight, gap), //
BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = image.createGraphics ();
@ -87,6 +87,13 @@ public class IconFile extends AbstractFile implements ProdosConstants
graphics.dispose ();
}
// ---------------------------------------------------------------------------------//
private int dimension (int chars, int border, int size, int gap)
// ---------------------------------------------------------------------------------//
{
return border * 2 + chars * (size + gap) - gap;
}
@Override
public String getText ()
{
@ -197,6 +204,10 @@ public class IconFile extends AbstractFile implements ProdosConstants
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)
throw new InvalidImageException (String.format ("Bad icon type: %04X", iconType));

View File

@ -14,20 +14,6 @@ public class Utility
public static final List<String> suffixes =
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)
// ---------------------------------------------------------------------------------//
@ -57,19 +43,27 @@ public class Utility
// ---------------------------------------------------------------------------------//
{
for (int i = 0; i < buffer.length; i++)
{
if (buffer[i] == key[0])
if (matches (buffer, i, key))
{
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;
}
// ---------------------------------------------------------------------------------//
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)
// ---------------------------------------------------------------------------------//
@ -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)
// ---------------------------------------------------------------------------------//