//F U N C T I O N S F O R 9200 COPIER BOARD
get "sysdefs.d"
get "gob.defs"
external
[
BoardC
]

let BoardC() be
[
GetSVCoords=GetSVCoordsC
GetSVindex=GetSVindexC
SVoltReq = table [ 140; 140; 0 ; 0; 0 ]
NetHasSVolt = NetHasSvoltC
LegalBloc = LegalBlocT
ChiptoPinPos = ChiptoPinPosT
GetEpinCoords = GetEpinCoordsC
GetCpinCoords = GetCpinCoordsC
GetICcoords = GetICcoordsC
AddPotentialTerms = AddPotentialTermsC
FindBestTerm = ErrTfn
SetUpTerms = Nullfn
GetBoardPins = GetBoardPinsT
maxn = 26 //board locations 1-26
maxalph = 4 // a to e
TableZeroString = "*nZero Table At e01.16: <0> {021,000}*nZero Table At e26.01: <0> {021,412}*nZero Table At a26.GND: <0> {213,412}*nZero Table At a1.VCC: <0> {213,000}"
]

and AddPotentialTermsC() be
[
//this function assigns svolt nodes to the corner pins of all TTL ICs
for alph = 0 to maxalph do
[
for n=1 to maxn do
[
let bl = 26*n + alph
let icptr = Boardvec!bl
if icptr eq 0 then loop
let ictype = icptr>>icdesc.ictype
let npins = icptr>>icdesc.npins //number of chip pins
switchon ictype into
[
case Ptype: //pull up with vcc on pin 14/16
AddSVoltNode($F,bl,ChiptoPinPos(bl,npins))
endcase

case Ntype: //N TTL
case Htype: //H TTL
case Stype: //S TTL (Vcc on 14/16, GND on 7/8)
AddSVoltNode($F,bl,ChiptoPinPos(bl,npins))
AddSVoltNode($G,bl,ChiptoPinPos(bl,npins/2))
endcase
]
]
]

]

and GetSVCoordsC(svlet,index,cv) be
[
let numM1 = (index-1) rem 26
let alph = (index-1)/26

cv!0 = 213 - 40*alph
cv!1 = 16*numM1
if svlet eq $G then cv!1=cv!1 + 12
]

and GetSVindexC(pinchar,bl,pin)=valof
[
let alph = bl rem 26
let num = bl/26
switchon pinchar into
[
case $G: resultis alph*26 + num

case $F: resultis alph*26 + num

default: resultis 0
]
]

and NetHasSvoltC(netname) = valof
[
if StEq("VCC",netname) then resultis $F
if StEq("GND",netname) then resultis $G
resultis 0
]


and GetEpinCoordsC(pin,cv) be
[
if (pin ls 1) % ((pin gr 88) & (pin ls 101)) % (pin gr 188)
then ErrN("*NSignal assigned to invalid Epin: ",pin)
cv!0=0
if (pin & 1) eq 0 then cv!0=4
cv!1=3
if pin gr 88 then cv!1=40
pin=(pin-1) rshift 1
cv!1=cv!1 + 4*pin
]


and GetCpinCoordsC(pin,cv) be
[
if (pin ls 1) % (pin gr 208) then
ErrN("*NSignal assigned to invalid Cpin: ",pin)
cv!0=241
if (pin & 1) eq 0 then cv!0=237
pin=(pin-1) rshift 1
cv!1=4*pin
]

and GetICcoordsC(alph,num,pin,cv) be
[
cv!0=181-40*alph
cv!1=16*num-4
test pin le 8
ifso cv!0=cv!0 + 4*(pin-1)
ifnot
[
cv!0=cv!0 + 4*(16-pin)
cv!1=cv!1 - 12
]
]