//F U N C T I O N S F O R A U G A T 8 1 3 6 B O A R D
get "sysdefs.d"
get "gob.defs"

external
[
BoardB
]


let BoardB() be
[

GetSVCoords=GetSVCoordsB//(typeletter,,index,cv) returns (in cv) the coordinates of svolt source pins
GetSVindex=GetSVindexB //(pinchar,bl,boardpin) returns index of closest svolt source
SVoltReq= table [ 100; 100; 0 ; 0; 0 ] //GND,VCC,etc
NetHasSVolt = NetHasSvoltB //(net name string) returns svolt source pin char. if the board supplies this net as a special case
LegalBloc = LegalBlocT
ChiptoPinPos = ChiptoPinPosT
GetEpinCoords = GetEpinCoordsB
GetCpinCoords = ErrCfn
GetICcoords = GetICcoordsB
AddPotentialTerms = AddPotentialTermsB
FindBestTerm = ErrTfn
SetUpTerms = Nullfn
GetBoardPins = GetBoardPinsT
maxn = 12 //board locations 1-12
maxalph = $e-$a
TableZeroString = "*nZero Table At E60: <0> {232,000}*nZero Table At E2: <0> {000,000}*nZero Table At e1.8: <0> {000,240}*nZero Table At e12.9: <0> {232,240}"
]


and AddPotentialTermsB() 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 GetSVCoordsB(svlet,index,cv) be
[
let xbase = (index-1) rem 12
let ybase = (index-1)/12

cv!0 = 20*xbase + (svlet eq $F?12,0)
cv!1 = 48 + 40*ybase
]

and GetSVindexB(pinchar,bl,pin)=valof
[
let alph = bl rem 26
let num = bl/26
switchon pinchar into
[
case $G: //ground
if (pin ge 6)&(pin le 12)&(alph ls ($e-$a)) then resultis (alph+1)*12 + num
resultis (alph*12)+num

case $F: //Vcc
if (pin ge 5)&(pin le 11)&(alph ls ($e-$a)) then resultis (alph+1)*12 + num
resultis (alph*12)+num

default: resultis 0
]
]

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

and GetICcoordsB(alph,num,pin,cv) be
[
cv!0 = (num-1)*20 + (pin gr 8? 12,0)

cv!1 = 52 + (alph*40) + (pin gr 8? (16-pin),(pin-1))*4
]

and GetEpinCoordsB(pin,cv) be
[
test (pin & 1) ne 0
ifso //1,3,5 ... 63,65,67,...
[
cv!0 = (pin ge 63? (pin-63),(pin-1))*4

cv!1 = (pin ge 63? 16,8)
]

ifnot //2,4,6,... 62,64,66,...
[
cv!0 = (pin ge 62? (pin-62),(pin-2))*4

cv!1 = (pin ge 62? 24,0)
]
]