wdt class, traces output of .wdt ATM (it will allow toggling of them by using
(eightbytes | 1) & automatically generating a blank .adt file if one does not exist in the future)
A problem exists for me creating a wdt file atm, i'm sure ill crack it soon!!!
Code:
import java.io.*;
import java.lang.String;
public class WDT
{
private boolean[] fileperms = {false,false};
private String filename = "";
private boolean debug = true;
private boolean[] data = new boolean[4096];//because there are 64*64 possibilities
public WDT(String _filename, boolean autoOpen)
{
filename = _filename;
File fil = new File(_filename);
if(fil.canRead())//check read capability
fileperms[0] = true;
if(fil.canWrite())//check write capability
fileperms[1] = true;
if(autoOpen)
read();
}
private char[] flip(char[] target)
{
char[] tmp = new char[target.length];
for(int i=0;i<target.length;i++)
{
tmp[(tmp.length-i)-1] = target[i];
}
return tmp;
}
private void trace()
{
for(int row = 1; row<=64 ;row++)
{
for(int col = 1;col<=64;col++)
{
System.out.print( ((data[((row-1)*64)+(col-1)]) ? ("x") : ("0")) + ((col == 64)?("\n"):("")) );// = ( ( (fourcc[0]|fourcc[1]|fourcc[2]|fourcc[3]) & 1 ) == 1) ? (true) : (false);
}
}
}
public boolean read()
{
if(!fileperms[0])
return false;
try
{
FileReader f = new FileReader(filename);
char[] fourcc = new char[4];
boolean eof = false;
while (!eof)
{
int tmp = f.read(fourcc);
if(tmp == -1)
eof = true;
fourcc = flip(fourcc);
if((fourcc[0] == 'M') && (fourcc[1] == 'A') && (fourcc[2] == 'I') && (fourcc[3] == 'N'))
{
f.read(fourcc);
f.read(fourcc);
for(int row = 1; row<=64 ;row++)
{
for(int col = 1;col<=64;col++)
{
f.read(fourcc);
f.read(fourcc);
data[((row-1)*64)+(col-1)] = ( ( (fourcc[0]|fourcc[1]|fourcc[2]|fourcc[3]) & 1 ) == 1) ? (true) : (false);
}
}
}
}
if(debug)
trace();
}
catch(IOException ioexc)
{
}
return true;
}
public void debugMode()
{
debug = !debug;
}
public void setActive(int row, int col)
{
(data[((row-1)*64)+(col-1)]) = true;
}
public void setInactive(int row, int col)
{
(data[((row-1)*64)+(col-1)]) = false;
}
}