|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.webcodepro.applecommander.util.AppleUtil
public class AppleUtil
This class contains helper methods for dealing with Apple2 data.
Date created: Oct 5, 2002 4:16:16 PM
Constructor Summary | |
---|---|
AppleUtil()
|
Method Summary | |
---|---|
static void |
changeImageOrderByBlock(ImageOrder sourceOrder,
ImageOrder targetOrder)
Change ImageOrder from source order to target order by copying block by block. |
static void |
changeImageOrderByTrackAndSector(ImageOrder sourceOrder,
ImageOrder targetOrder)
Change ImageOrder from source order to target order by copying sector by sector. |
static byte |
clearBit(byte byt,
int bit)
Clear a specific bit (turn it off). |
static int |
convertFormattedWord(java.lang.String word)
Convert a typical Apple formatted word. |
static boolean |
disksEqualByBlock(FormattedDisk sourceDisk,
FormattedDisk targetDisk)
Compare two disks block by block. |
static boolean |
disksEqualByTrackAndSector(FormattedDisk sourceDisk,
FormattedDisk targetDisk)
Compare two disks by track and sector. |
static int |
get3ByteValue(byte[] buffer,
int offset)
Compute the value of a 3 byte value. |
static byte[] |
getApplesoftFloat(double number)
Convert a double number to an Applesoft float. |
static int |
getBitCount(byte byt)
Count the number of bits set in a byte. |
static java.lang.String |
getFormatted3ByteAddress(int addr)
Format a 3 byte value as hexidecimal. |
static java.lang.String |
getFormattedByte(int byt)
Format a byte value as hexidecimal. |
static java.lang.String |
getFormattedWord(int word)
Format a word value as hexidecimal. |
static java.lang.String |
getHexDump(byte[] bytes)
Generate a simple hex dump from the given byte array. |
static java.lang.String |
getNiceFilename(java.lang.String filename)
Make a "nice" filename. |
static java.util.Date |
getPascalDate(byte[] buffer,
int offset)
Extract a Pascal date from the buffer. Bits 0-3: month (1-12) Bits 4-8: day (1-31) Bits 9-15: year (0-99) |
static java.lang.String |
getPascalString(byte[] buffer,
int offset)
Extract a Pascal string from the buffer. |
static java.util.Date |
getProdosDate(byte[] buffer,
int offset)
Extract a ProDOS date from the buffer. |
static java.lang.String |
getProdosString(byte[] buffer,
int offset)
Extract a ProDOS string from the buffer. |
static double |
getSaneNumber(byte[] buffer,
int offset)
Pull a SANE formatted number from the buffer and return it as a Java double datatype. |
static int |
getSignedWordValue(byte[] buffer,
int offset)
Compute the signed value of a word. |
static java.lang.String |
getString(byte[] buffer,
int offset,
int length)
Extract a string from the buffer. |
static int |
getUnsignedByte(byte value)
Extract out an unsigned byte as an int. |
static int |
getWordValue(byte[] buffer,
int offset)
Compute the value of a word. |
static int |
getWordValue(byte low,
byte high)
Compute the value of a word. |
static boolean |
isBitSet(byte byt,
int bit)
Determine if a specific bit is set. |
protected static boolean |
sameBlocksPerDisk(ImageOrder sourceOrder,
ImageOrder targetOrder)
Answers true if the two disks have the same number of blocks per disk. |
protected static boolean |
sameSectorsPerDisk(ImageOrder sourceOrder,
ImageOrder targetOrder)
Answers true if the two disks have the same sectors per disk. |
static void |
set3ByteValue(byte[] buffer,
int offset,
int value)
Set the value of a 3 byte value. |
static byte |
setBit(byte byt,
int bit)
Set a specific bit (turn it on). |
static void |
setPascalDate(byte[] buffer,
int offset,
java.util.Date date)
Set a Pascal data to the buffer. Bits 0-3: month (1-12) Bits 4-8: day (1-31) Bits 9-15: year (0-99) |
static void |
setPascalString(byte[] buffer,
int offset,
java.lang.String string,
int maxLength)
Set a Pascal string into the buffer. |
static void |
setProdosDate(byte[] buffer,
int offset,
java.util.Date date)
Set a ProDOS date into the buffer. |
static void |
setProdosString(byte[] buffer,
int offset,
java.lang.String string,
int maxLength)
Sets a ProDOS string into the buffer. |
static void |
setString(byte[] buffer,
int offset,
java.lang.String string)
Create an Apple string that is the same length as the given string. |
static void |
setString(byte[] buffer,
int offset,
java.lang.String string,
int length)
Create an Apple string that is space delimited. |
static void |
setString(byte[] buffer,
int offset,
java.lang.String string,
int length,
boolean highBitOn)
Create an Apple string that is space delimited. |
static void |
setWordValue(byte[] buffer,
int offset,
int value)
Set a word value. |
static byte[] |
unpackBytes(byte[] compressedData)
Mimic the Apple IIGS UnPackBytes method call. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AppleUtil()
Method Detail |
---|
public static int getWordValue(byte[] buffer, int offset)
public static int getWordValue(byte low, byte high)
public static int getSignedWordValue(byte[] buffer, int offset)
public static void setWordValue(byte[] buffer, int offset, int value)
public static int get3ByteValue(byte[] buffer, int offset)
public static void set3ByteValue(byte[] buffer, int offset, int value)
public static int getUnsignedByte(byte value)
public static int getBitCount(byte byt)
public static boolean isBitSet(byte byt, int bit)
public static byte setBit(byte byt, int bit)
public static byte clearBit(byte byt, int bit)
public static java.lang.String getString(byte[] buffer, int offset, int length)
public static void setString(byte[] buffer, int offset, java.lang.String string, int length)
public static void setString(byte[] buffer, int offset, java.lang.String string, int length, boolean highBitOn)
public static void setString(byte[] buffer, int offset, java.lang.String string)
public static java.lang.String getPascalString(byte[] buffer, int offset)
public static void setPascalString(byte[] buffer, int offset, java.lang.String string, int maxLength)
public static java.util.Date getPascalDate(byte[] buffer, int offset)
public static void setPascalDate(byte[] buffer, int offset, java.util.Date date)
public static java.lang.String getProdosString(byte[] buffer, int offset)
public static void setProdosString(byte[] buffer, int offset, java.lang.String string, int maxLength)
public static java.lang.String getFormattedByte(int byt)
public static java.lang.String getFormattedWord(int word)
public static java.lang.String getFormatted3ByteAddress(int addr)
public static int convertFormattedWord(java.lang.String word)
public static java.util.Date getProdosDate(byte[] buffer, int offset)
public static void setProdosDate(byte[] buffer, int offset, java.util.Date date)
public static java.lang.String getNiceFilename(java.lang.String filename)
public static byte[] unpackBytes(byte[] compressedData)
public static double getSaneNumber(byte[] buffer, int offset)
E SSSSSSSSSSS FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF...FWhere E is the sign bit, S is the exponent bits and F is the fraction bits. The format is discussed within the Double class documentation as around the web. Be aware that the fraction bits are base 2. Meaning that a fraction of .101 is, in reality, a binary fraction. In decimal, this is 1/2 + 0/4 + 1/8 = 5/8 or .625. See http://www.psc.edu/general/software/packages/ieee/ieee.html for an example.
0 1........11 12....................................63
Note: SANE numbers, as stored by AppleWorks are in typical low/high format.
public static byte[] getApplesoftFloat(double number)
Since the number is 5 bytes long, a float will not work - hence the double. Some precision is lost, but (hopefully) nothing significant!
More specificially, the mapping is as follows:
(Applesoft)
EEEEEEEE SFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
(IEEE 754 - Java)
SEEEEEEE EEEEFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
The mapping will blank the following Double bits:
S000EEEE EEEEFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFF0000 00000000 00000000
public static java.lang.String getHexDump(byte[] bytes)
This is in the general form of:
MMMMMM: HH HH HH HH HH HH HH HH HH HH HH HH HH HH HH HH AAAAAAAA AAAAAAAA
Where MMMMMM = memory address, HH = hex byte, and
A = ASCII character.
public static void changeImageOrderByTrackAndSector(ImageOrder sourceOrder, ImageOrder targetOrder)
protected static boolean sameSectorsPerDisk(ImageOrder sourceOrder, ImageOrder targetOrder)
public static boolean disksEqualByTrackAndSector(FormattedDisk sourceDisk, FormattedDisk targetDisk)
public static void changeImageOrderByBlock(ImageOrder sourceOrder, ImageOrder targetOrder)
protected static boolean sameBlocksPerDisk(ImageOrder sourceOrder, ImageOrder targetOrder)
public static boolean disksEqualByBlock(FormattedDisk sourceDisk, FormattedDisk targetDisk)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |