public final int row;
public final int col;
public SectorWire(boolean horizontal, int plane, int col, int row) {
+ this(horizontal, plane, col, row, false);
+ }
+
+ public void useColumnClock() {
+ // this is very poorly understood
+ if (horizontal) throw new RuntimeException();
+ mode4(0x25, (row>>2)+1, col, 0x80);
+ mode4(0x29, (row>>2), col, 0x40);
+ }
+
+ public SectorWire(boolean horizontal, int plane, int col, int row, boolean global) {
this.horizontal=horizontal;
- this.global = false;
+ this.global=global;
this.plane=plane;
this.col= horizontal ? (col & ~0x3) : col;
this.row=!horizontal ? (row & ~0x3) : row;
}
+ public SectorWire global() {
+ return new SectorWire(horizontal, plane, col, row, true);
+ }
public boolean isDriven() {
// FIXME: bridging connections (horiz-to-vert)
for(int i=0; i<4; i++)
private int z(int z) { return (horizontal ? 0x30 : 0x20) | z; }
public int code(boolean topleft) {
switch(plane) {
- case 0: return z(6)+(topleft?0:1);
- case 1: return z(8)+(topleft?0:1);
+ case 0: return z(8)+(topleft?0:1);
+ case 1: return z(6)+(topleft?0:1);
case 2: return z(2*(4-plane))+(topleft?0:1);
case 3: return z(2*(4-plane))+(topleft?0:1);
case 4: return z(2*(4-plane))+(topleft?0:1);
throw new Error("not implemented");
}
+ public void dork() {
+ mode4zyx(switchbox(north()), (1<<6), (1<<6));
+ }
+
public void drives(SectorWire w, boolean enable) {
- mode4zyx(switchbox(w), enable?0x02:0x00, 0x07);
+ // FIXME: better error checks?
+ int val = 0;
+ if (enable) {
+ if (!global) val = 0x02;
+ else val = 0x04;
+ }
+ int mask = 0x07;
+ if (w.global) { mask = mask << 3; val = val << 3; }
+ mode4zyx(switchbox(w), val, mask);
}
public boolean drives(SectorWire w) {
+ // FIXME: better error checks?
int connect = (mode4zyx(switchbox(w)) >> (global?3:0)) & 0x7;
return (connect & 0x2)!=0;
}
public final int col;
public final int row;
+ public void setColumnClock(int where) {
+ mode4(0x50, 0x00, col, where);
+ }
+
+ public String toString() { return "cell@("+col+","+row+")"; }
+
public Cell(int col, int row) {
this.row = row;
this.col = col;
}
+ public Fpslic fpslic() { return Fpslic.this; }
+ public int hashCode() { return col ^ row ^ Fpslic.this.hashCode(); }
+ public boolean equals(Object o) {
+ if (o==null || (!(o instanceof Cell))) return false;
+ Cell c = (Cell)o;
+ return c.col == col && c.row == row && c.fpslic()==fpslic();
+ }
+
// Accessors for Neighbors //////////////////////////////////////////////////////////////////////////////
public SectorWire hwire(int plane) { return new SectorWire(true, plane, col, row); }
public int yi() {
if ((mode4(0x02, row, col) & (1<<6))!=0) return L4;
switch(mode4(0x04, row, col) & 0xff) {
- case 0x80: return NORTH;
+ case (1<<7): return NORTH;
case (1<<5): return SOUTH;
case (1<<6): return WEST;
case (1<<4): return EAST;
}
}
+ public Cell dir(int i) {
+ switch(i) {
+ case NORTH: return north();
+ case SOUTH: return south();
+ case EAST: return east();
+ case WEST: return west();
+ case NW: return nw();
+ case SW: return sw();
+ case SE: return se();
+ case NE: return ne();
+ }
+ return null;
+ }
+ public int dir(Cell c) {
+ if (c.row==row-1 && c.col==col-1) return SW;
+ else if (c.row==row+1 && c.col==col-1) return NW;
+ else if (c.row==row-1 && c.col==col+1) return SE;
+ else if (c.row==row+1 && c.col==col+1) return NE;
+ else if (c.row==row-1 && c.col==col) return SOUTH;
+ else if (c.row==row+1 && c.col==col) return NORTH;
+ else if (c.row==row && c.col==col-1) return WEST;
+ else if (c.row==row && c.col==col+1) return EAST;
+ return -1;
+ }
public void generalized_c_element() {
}
return out && connect;
}
+
public boolean fb_relevant() {
+ /*
if (!(zi_to_xlut_relevant()) ||
!(zi_to_ylut_relevant())) return false;
switch(ti()) {
case 0x30: return true;
}
return false;
+ */
+ return true;
}