c string reader

This commit is contained in:
Denis Molony 2019-11-04 18:30:13 +10:00
parent ca44da4c94
commit 93186f2b6d
3 changed files with 24 additions and 10 deletions

View File

@ -4,6 +4,8 @@ import java.awt.image.DataBuffer;
import java.util.ArrayList;
import java.util.List;
import com.bytezone.diskbrowser.utilities.HexFormatter;
// see graffidisk.v1.0.2mg
// -----------------------------------------------------------------------------------//
public class CharacterRom extends CharacterList
@ -22,7 +24,7 @@ public class CharacterRom extends CharacterList
{
super (name, buffer, charsX, charsY, HEADER_LENGTH);
description = new String (buffer, 16, 16);
description = HexFormatter.getCString (buffer, 16);
assert sizeX == (buffer[5] & 0xFF);
assert sizeY == (buffer[6] & 0xFF);
@ -35,10 +37,11 @@ public class CharacterRom extends CharacterList
if (buffer.length != 0x400)
return false;
// no idea what these mean
// see CHARROM.S on graffidisk
// BD 41 53 10 A0 07 08
return buffer[0] == (byte) 0xBD && buffer[1] == (byte) 0x41
&& buffer[2] == (byte) 0x53 && buffer[3] == (byte) 0x10;
&& buffer[2] == (byte) 0x53 && buffer[4] == (byte) 0xA0
&& buffer[5] == (byte) 0x07 && buffer[6] == (byte) 0x08;
}
// ---------------------------------------------------------------------------------//

View File

@ -18,11 +18,11 @@ import com.bytezone.diskbrowser.duplicates.RootFolderData;
public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitListener
// -----------------------------------------------------------------------------------//
{
static long start;
static
{
start = System.currentTimeMillis ();
}
// static long start;
// static
// {
// start = System.currentTimeMillis ();
// }
private static String[] args;
private static final String windowTitle = "Apple ][ Disk Browser";
private final Preferences prefs = Preferences.userNodeForPackage (this.getClass ());
@ -38,7 +38,7 @@ public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitLi
// ---------------------------------------------------------------------------------//
{
super (windowTitle);
System.out.printf ("Start Init: %,5d%n", System.currentTimeMillis () - start);
// System.out.printf ("Start Init: %,5d%n", System.currentTimeMillis () - start);
if (args.length > 0 && "-reset".equals (args[0]))
new WindowState (prefs).clear ();
@ -185,7 +185,7 @@ public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitLi
// activate the highest panel now that the listeners are ready
catalogPanel.activate ();
System.out.printf ("End Init : %,5d%n", System.currentTimeMillis () - start);
// System.out.printf ("End Init : %,5d%n", System.currentTimeMillis () - start);
}
// ---------------------------------------------------------------------------------//

View File

@ -528,4 +528,15 @@ public class HexFormatter
int length = buffer[offset] & 0xFF;
return HexFormatter.getString (buffer, offset + 1, length);
}
// ---------------------------------------------------------------------------------//
public static String getCString (byte[] buffer, int offset)
// ---------------------------------------------------------------------------------//
{
int end = offset;
while (buffer[end] != 0)
end++;
return HexFormatter.getString (buffer, offset, end - offset);
}
}