X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Fcom%2Fatmel%2Ffpslic%2FFpslic.java;h=670913801c27e2b8d20087aaf2fd3211238768fd;hb=f67325062280b30ad89cd9d53b1b276733e4d5e3;hp=b72a69b6148476ca1cdb9b1891eb8bf5103f8493;hpb=fc310b9cc6ef5c1b3dc1889809636cd3494cf611;p=slipway.git diff --git a/src/com/atmel/fpslic/Fpslic.java b/src/com/atmel/fpslic/Fpslic.java index b72a69b..6709138 100644 --- a/src/com/atmel/fpslic/Fpslic.java +++ b/src/com/atmel/fpslic/Fpslic.java @@ -60,12 +60,19 @@ public abstract class Fpslic { 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 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++) @@ -77,8 +84,8 @@ public abstract class Fpslic { 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); @@ -116,11 +123,24 @@ public abstract class Fpslic { 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; } @@ -171,12 +191,20 @@ public abstract class Fpslic { public final int col; public final int row; + 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 //////////////////////////////////////////////////////////////////////////////