//routesb1.bcpl
// Board-specific Route routines for the D0 Main Logic Board

// Part 1 of 2, last modified by S. Tom Chang, May 16, 1978 8:58 AM
// all co-ordinates are described with respect to the bottom or
// wiring side of the board. LevelTransform fixes these as necessary.
// change ZeroTable names to match these used in old WL
// correction on Gnd and voltage pins on odd locations

get "route.defs"

static [ maxICs = 200; boardInterfaceVersion = interfaceVersion ]

let DeclareInitialNets(BuildTWNet, BuildTermNet, BuildConnector) be
[
BuildConnector("E", 200, EPinPos)
BuildConnector("C", 765, CPinPos)
BuildTWNet("GND", 216, GNDPinPos)
BuildTWNet("VCC", 171, VCCPinPos)
BuildTWNet("VDD", 171, VDDPinPos)
BuildTWNet("VEE", 171, VEEPinPos)
]

and ZeroTablePoint(point) = selecton point into
[
case 0: "Sk" // board type
case 1: "Z-i1.10"
case 2: "E98"
case 3: "E2"
case 4: "Z-a1.1"
default: empty
]

and LevelTransform(level, x, y, px, py, pName, pPullComponents, pWire; numargs na) = valof
[
DefaultArgs(lv na, -1, 0, 0, lv na, lv na, lv na, lv na, lv na)
switchon level into
[
case TopLevel:
@px = x
@py = 500-y
@pName = "Component side"
@pPullComponents = true
@pWire = false
resultis true

case BottomLevel:
@px = x
@py = y
@pName = "Wiring side"
@pPullComponents = false
@pWire = true
resultis true

default: resultis false
]
]

and EPinPos(icinst, pin, px, py) = valof
[
if (pin ls 2) % (pin gr 199) then resultis illegal
if ((pin eq 100)%(pin eq 101)) then resultis illegal // +12 volts
let pv = pin rem 50
if ((pv eq 0)%(pv eq 1)) then resultis illegal // +5 volts
let pg = pin rem 10
if (pg eq 0) then resultis illegal // ground Epins
let pd = 99 - (pin rem 100)
@px = 4 + pd*4 + (pd le 48?0,20)
@py = 500 - ((pin - 1)/100)*4
resultis absolute
]

and CPinPos(icinst, pin, px, py) = valof
[
let pn = pin rem 100 - 1
let pd = pn rem 50
@px = 0
@py = 0
switchon pin/100 into
[
case 0:
[
if ((pd ge 19)&(pd le 36)) then @py = 4
if ((pn ge 0)&(pn le 36)) then
@px = table [ 312; 308; 304; 296; 292; 288; 284; 280; 276; 272;
268; 260; 256; 252; 248; 244; 240; 236; 232; 312;
308; 304; 292; 288; 284; 280; 276; 272; 268; 260;
256; 252; 248; 244; 240; 236; 232 ]!pn

if ((pn ge 50)&(pn le 86)) then
@px = table [ 184; 180; 176; 172; 168; 164; 160; 156; 148; 144;
140; 136; 132; 128; 124; 116; 112; 108; 104; 184;
180; 176; 172; 168; 164; 160; 156; 148; 144; 140;
136; 132; 128; 124; 112; 108; 104 ]!pd

resultis absolute
]
case 1:
[
if ((pd ge 19)&(pd le 36)) then @py = 4
if ((pn ge 0)&(pn le 36)) then
@px = table [ 232; 236; 240; 244; 248; 252; 256; 260; 268; 272;
276; 280; 284; 288; 292; 296; 304; 308; 312; 232;
236; 240; 244; 248; 252; 256; 260; 268; 272; 276;
280; 284; 288; 292; 304; 308; 312 ]!pn

if ((pn ge 50)&(pn le 86)) then
@px = table [ 104; 108; 112; 116; 124; 128; 132; 136; 140; 144;
148; 156; 160; 164; 168; 172; 176; 180; 184; 104;
108; 112; 124; 128; 132; 136; 140; 144; 148; 156;
160; 164; 168; 172; 176; 180; 184 ]!pd

resultis absolute
]

case 2:
[
if ((pd ge 13)&(pd le 24)) then @py = 4
if ((pn ge 0)&(pn le 24)) then
@px = table [ 284; 280; 276; 272; 268; 260; 256; 252; 248; 244;
240; 236; 232; 280; 276; 272; 268; 260; 256; 252;
248; 244; 240; 236; 232 ]!pn

if ((pn ge 50)&(pn le 74)) then
@px = table [ 184; 180; 176; 172; 168; 164; 160; 156; 148; 144;
140; 136; 132; 184; 180; 176; 172; 168; 164; 160;
156; 148; 144; 140; 136 ]!pd

resultis absolute
]

case 3:
[
if ((pd ge 13)&(pd le 24)) then @py = 4
if ((pn ge 0)&(pn le 24)) then
@px = table [ 232; 236; 240; 244; 248; 252; 256; 260; 268; 272;
276; 280; 284; 232; 236; 240; 244; 248; 252; 256;
260; 268; 272; 276; 280 ]!pn

if ((pn ge 50)&(pn le 74)) then
@px = table [ 132; 136; 140; 144; 148; 156; 160; 164; 168; 172;
176; 180; 184; 136; 140; 144; 148; 156; 160; 164;
168; 172; 176; 180; 184 ]!pd

resultis absolute
]

case 4:
[
if ((pd ge 8)&(pd le 14)) then @py = 4
if ((pn ge 0)&(pn le 14)) then
@px = table [ 328; 324; 320; 316; 312; 308; 304; 296; 328; 324;
320; 316; 312; 308; 304 ]!pn

if ((pn ge 50)&(pn le 74)) then
@px = table [ 184; 180; 176; 172; 168; 164; 160; 156; 184; 180;
176; 172; 168; 164; 160 ]!pd

resultis absolute
]

case 5:
[
if ((pd ge 8)&(pd le 14)) then @py = 4
if ((pn ge 0)&(pn le 14)) then
@px = table [ 296; 304; 308; 312; 316; 320; 324; 328; 304; 308;
312; 316; 320; 324; 328 ]!pn

if ((pn ge 50)&(pn le 74)) then
@px = table [ 156; 160; 164; 168; 172; 176; 180; 184; 160; 164;
168; 172; 176; 180; 184 ]!pd

resultis absolute
]

case 6:
[
if ((pd ge 8)&(pd le 14)) then @py = 4
if ((pn ge 0)&(pn le 14)) then
@px = table [ 260; 256; 252; 248; 244; 240; 236; 232; 256; 252;
248; 244; 240; 236; 232 ]!pn

if ((pn ge 50)&(pn le 74)) then
@px = table [ 116; 112; 108; 104; 100; 96; 92; 88; 112; 108;
104; 100; 96; 92; 88 ]!pd

resultis absolute
]

case 7:
[
if ((pd ge 8)&(pd le 14)) then @py = 4
if ((pn ge 0)&(pn le 14)) then
@px = table [ 232; 236; 240; 244; 248; 252; 256; 260; 232; 236;
240; 244; 248; 252; 256 ]!pn

if ((pn ge 50)&(pn le 74)) then
@px = table [ 88; 92; 96; 100; 104; 108; 112; 116; 88; 92;
96; 100; 104; 108; 112 ]!pd

resultis absolute
]
]
resultis illegal
]

and VDDPinPos(icinst, pin, px, py, pInfo; numargs na) = valof
[
DefaultArgs(lv na, -4, lv na)
@pInfo = noDisconnect+noReconnect+TopLevel
if pin le 0 then resultis illegal
let noexpin = 0
if pin le 171 then
[
pin=pin-1
let VddRow = (pin/9)+1
let VddCol = 9 - (pin rem 9)
@px = 44*VddCol - 4 + (VddCol ge 6?16,0)
@py = 24*VddRow - 12 +(VddRow ge 9?12,0) +(VddRow ge 13?12,0)
if (VddRow rem 5) eq 0 then
[
if (VddCol eq 1)%(VddCol eq 9) then noexpin = 1
@px = 48*VddCol - 24 + (VddCol ge 6?16,0)
]
if (VddRow eq 8)%(VddRow eq 12) then
[
if (VddCol eq 1)%(VddCol eq 6) then noexpin = 1
if VddCol ge 7 then VddCol = VddCol - 1
@px = 52*VddCol - 44 + (VddCol gr 5?16,0)
]
if (VddRow eq 19) then @py = @py - 8
if noexpin ne 0 then [ @px = 412; @py = 500 ]
resultis absolute
]
resultis illegal
]

and VEEPinPos(icinst, pin, px, py, pInfo; numargs na) = valof
[
DefaultArgs(lv na, -4, lv na)
@pInfo = noDisconnect+noReconnect+TopLevel
if pin le 0 then resultis illegal
let noexpin = 0
if pin le 171 then
[
pin=pin-1
let VeeRow = (pin/9)+1
let VeeCol = 9 - (pin rem 9)
@px = 44*VeeCol - 32 + (VeeCol ge 6?16,0)
@py = 24*VeeRow - 8 + (VeeRow ge 9?12,0) + (VeeRow ge 13?12,0)
if (VeeRow rem 5) eq 0 then
[
if VeeCol eq 1 % VeeCol eq 9 then noexpin = 1
@px = 48*VeeCol - 56 + (VeeCol ge 6?16,0)
]
if (VeeRow eq 8)%(VeeRow eq 12) then
[
if (VeeCol eq 1)%(VeeCol eq 6) then noexpin = 1
if VeeCol ge 7 then VeeCol = VeeCol - 1
@px = 52*VeeCol - 76 + (VeeCol gr 5?16,0)
@py = @py + 8
]
if (VeeRow eq 19) then @py = @py - 4
if noexpin ne 0 then [ @px = 412; @py = 500 ]
resultis absolute
]
resultis illegal
]
and GNDPinPos(icinst, pin, px, py, pInfo; numargs na) = valof
[
DefaultArgs(lv na, -4, lv na)
@pInfo = Disconnect+noReconnect+BottomLevel
if pin le 0 then resultis illegal
pin=pin-1
let GndRow = (pin/9) + 1
let GndCol = 9 - (pin rem 9)
let noexpin = 0
if pin ls 171 then
[
@px = 44*GndCol - 36 + (GndCol ge 6?16,0)
@py = 24*GndRow - 16 + (GndRow ge 8?12,0) + (GndRow ge 12?12,0)
if (GndRow rem 5) eq 0 then
[
@px = @px + 4*GndCol + (GndCol eq 1?16,0) - 24
]
if (GndRow eq 8)%(GndRow eq 12) then
[
if (GndCol eq 1)%(GndCol eq 6) then noexpin = 1
if GndCol ge 7 then GndCol = GndCol - 1
@px = 52*GndCol - 84 + (GndCol gr 5?16,0)
]
if noexpin ne 0 then [ @px = 412; @py = 500 ]
resultis absolute
]
if (pin ge 171)&(pin ls 189) then
[
if (GndCol eq 1)%(GndCol eq 6) then noexpin = 1
if GndCol ge 7 then GndCol = GndCol - 1
@px = 52*GndCol - 84 + (GndCol gr 5?16,0)
@py = 176 + (pin ge 180?108,0)
if noexpin ne 0 then [ @px = 412; @py = 500 ]
resultis absolute
]
if (pin ge 189)&(pin ls 216) then
[
if (GndCol eq 1)%(GndCol eq 9) then noexpin = 1
GndCol = GndCol - 1
@px = 48*GndCol + (GndCol ge 5?16,0)
@py = 132*((pin -189)/9) + 100
if noexpin ne 0 then [ @px = 412; @py = 500 ]
resultis absolute
]
resultis illegal
]

and VCCPinPos(icinst, pin, px, py, pInfo; numargs na) = valof
[
DefaultArgs(lv na, -4, lv na)
@pInfo = Disconnect+noReconnect+TopLevel
if pin le 0 then resultis illegal
let noexpin = 0
if pin le 171 then
[
pin=pin-1
let VccRow = (pin/9) + 1
let VccCol = 9 - (pin rem 9)
@px = 44*VccCol + (VccCol ge 6?16,0)
@py = 24*VccRow - 4 + (VccRow ge 8?12,0) + (VccRow ge 12?12,0)
if (VccRow rem 5) eq 0 then
[
@px = @px + 4*VccCol - (VccCol eq 9?16,0) - 20
]
if (VccRow eq 8)%(VccRow eq 12) then
[
if (VccCol eq 1)%(VccCol eq 6) then noexpin = 1
if VccCol ge 7 then VccCol = VccCol - 1
@pInfo = noDisconnect+noReconnect+TopLevel
@px = 52*VccCol - 40 + (VccCol gr 5?16,0)
]
if noexpin ne 0 then [ @px = 412; @py = 500 ]
resultis absolute
]
resultis illegal
]