Skip to content

Commit

Permalink
new version 0.85
Browse files Browse the repository at this point in the history
added Multi-Vocabulary Forth decompilation capability
added font size option in listings dialog
implemented file compare tool
  • Loading branch information
ricaflops committed Feb 3, 2016
1 parent f1a8309 commit 07e46b1
Show file tree
Hide file tree
Showing 9 changed files with 963 additions and 413 deletions.
2 changes: 1 addition & 1 deletion nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jar.compress=false
javac.classpath=\
${libs.beans-binding.classpath}
# Space-separated list of extra javac options
javac.compilerargs=
javac.compilerargs=-Xlint:unchecked
javac.deprecation=false
javac.processorpath=\
${javac.classpath}
Expand Down
82 changes: 47 additions & 35 deletions src/Jatm/JaTape.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class JaTape {
public static final byte BYT_FILE = (byte) 0x20;

/**
* Header Parameter Index
* Header Parameter Index
* to be used with getParameter and setParameter methods
*/
public static final int BLOCK_TYPE = 0; // 1 byte
Expand All @@ -49,31 +49,31 @@ public class JaTape {
public static final int VOCLNK = 22; // 2 bytes
public static final int STKBOT = 24; // 2 bytes
public static final int CRC = 26; // 1 byte

/**
* Header Block Size in Bytes
*/
public static final int HEADER_LENGTH = 27; // Header Block Size

private final JaTapeBlock header;
private final JaTapeBlock data;
private int baseAddress;

/**
* Constructor: Empty Tape File
*/
public JaTape() {
this(new byte[HEADER_LENGTH], new byte[2]);
}

/**
* Copy Constructor
* @param tape
* @param tape
*/
public JaTape(JaTape tape) {
this(tape.getHeaderBlock(), tape.getDataBlock());
}

/**
* Constructor: Tape File from header and data blocks
* @param hdr header block byte array
Expand All @@ -92,13 +92,13 @@ public JaTape(byte[] hdr, byte[] dat) {

/**
* Set a whole data block array, including block type and CRC bytes
* @param block data block
* @param block data block
*/
public void setDataBlock(byte[] block) {
data.set(block);

}

/**
* Get the whole data block array, including block type and CRC bytes
* @return data block
Expand All @@ -114,7 +114,7 @@ public byte[] getDataBlock() {
public byte[] getData() {
return data.getPart(1,data.length()-2);
}

/**
* Set byte value to a Data block position
* @param index position in Data block array (excluding block type byte)
Expand All @@ -123,7 +123,7 @@ public byte[] getData() {
public void setDataByte(int index, byte b) {
data.setByte(index+1,b); // skip block type byte
}

/**
* Get byte value from Data block position
* @param index position in Data block array (excluding block type byte)
Expand All @@ -149,7 +149,7 @@ public void setDataWord(int index, int w) {
*/
public int getDataWord(int index) {
return data.getWord(index+1); // skip block type byte
}
}

/**
* Set the Header block from a byte array
Expand All @@ -160,7 +160,7 @@ public void setHeaderBlock(byte[] b) {
byte[] h = new byte[HEADER_LENGTH];
int len = (h.length > b.length)?b.length:h.length;
System.arraycopy(h, 0, b, 0, len);

header.set(h);
baseAddress = getParameter(JaTape.ADDRESS); // file base address
}
Expand All @@ -175,24 +175,24 @@ public byte[] getHeaderBlock() {

/**
* Set Header Parameters to a canonical Byt file type
*/
*/
public void makeByt() {
header.setType(JaTapeBlock.HEADER_BLOCK);

header.setByte(FILE_TYPE, BYT_FILE);
header.setWord(CURR_WRD, 0x2020);
header.setWord(CURRENT, 0x2020);
header.setWord(CONTEXT, 0x2020);
header.setWord(VOCLNK, 0x2020);
header.setWord(STKBOT, 0x2020);
}

/**
* Set Header Parameters to a canonical Dict file type
*/
public void makeDict() {
header.setType(JaTapeBlock.HEADER_BLOCK);

header.setByte(FILE_TYPE, DICT_FILE);
header.setWord(ADDRESS, 0x3C51);
header.setWord(CURRENT, 0x3C4C);
Expand All @@ -209,25 +209,37 @@ public Boolean isDict() {
return (header.getByte(FILE_TYPE)==0x00);
}

/**
* get file type string
* @return file type as a String "dict" or " byt"
*/
public String getFileType() {
if(isDict()) {
return "dict";
} else {
return " byt";
}
}

/**
* Set file type: Dict or Byt
* @param type File type byte
*/
public void setType(byte type) {
header.setByte(FILE_TYPE, type);
}
}

/**
* Get File name
* @return file name string
*/
public String getFilename() {
return header.getString(FILE_NAME, 10);
}

/**
* Set the File name (max 10 characters)
* @param filename
* @param filename
*/
public void setFilename(String filename) {
filename = filename + " "; // Pad with Spaces
Expand All @@ -251,12 +263,12 @@ public int getParameter(int index) {
*/
public void setParameter(int index, int parameter) {
header.setWord(index, parameter);
}
}

/**
* Check if Header and Data blocks CRC's are correct
* @return True if Header and Data blocks CRC's are ok
*/
*/
public Boolean crcOk() {
return (header.crcOk() && data.crcOk());
}
Expand All @@ -268,30 +280,30 @@ public Boolean crcOk() {
public Boolean headerCrcOk() {
return header.crcOk();
}

/**
* Check if Data block CRC is correct
* @return True if Data block CRC is ok
*/
public Boolean dataCrcOk() {
return data.crcOk();
}

/**
* Calculate and set correct Header and Data blocks CRC bytes
*/
public void fixCrc() {
header.fixCrc();
data.fixCrc();
}

/**
* Calculate and set a correct Header block CRC byte
*/
public void fixHeaderCrc() {
header.fixCrc();
}

/**
* Calculate and set a correct Data block CRC byte
*/
Expand All @@ -306,31 +318,31 @@ public void fixDataCrc() {
public byte getHeaderCrc() {
return header.getCrc();
}

/**
* Get Data block CRC byte
* @return Data block CRC byte
*/
public byte getDataCrc() {
return data.getCrc();
}

/**
* Set Header block CRC byte
* @param crc
* @param crc
*/
public void setHeaderCrc(byte crc) {
header.setCrc(crc);
}

/**
* Set Data block CRC byte
* @param crc
* @param crc
*/
public void setDataCrc(byte crc) {
data.setCrc(crc);
}

/**
* Check for a valid file address
* @param address Address to be checked
Expand All @@ -340,7 +352,7 @@ public boolean validAddress(int address) {
return (address >= baseAddress)
&& (address < baseAddress + getParameter(JaTape.LENGTH));
}

/**
* Get byte from memory address. Returns Zero if invalid address
* @param address byte location
Expand All @@ -363,5 +375,5 @@ public int getMemWord(int address) {
return getDataWord(address - baseAddress);
}
return 0;
}
}
}
Loading

0 comments on commit 07e46b1

Please sign in to comment.