//D1PrinMic.bcpl	Prettyprint code for microcomputer.
//	Last edited: 25 October 1979

get "d1mic.d"
get "d1.d"

external [
// OS
	Puts

// MIDAS
	MidasSwat

// MASM
	Wss; @WssCSS; WssCS1; PutsCS1

// MIOC
	Wns

// MCMD
	CmdCS1; WnsCS1; WnsCS1D

// MPRINS
	NWss; NWss1

// MPATTERN
	@PATTERN

// D1MICRES
	PrinVoltage; PrinCurrent; PrinTemperature; MPrintMSTAT

// Defined here
	PrintMSTAT; PrintABSOL
]

let PrintABSOL(X,DVec,AVec,Radix) be
[	PATTERN = DVec>>lh
	switchon AVec!1 into
	[
case #0:  WssCS1("Microcomputer code version = ")
	  WnsCS1D(PATTERN); return

case #1:	//OUTOFSPEC
case #147:	//BADSUPPLYSPEC
	  test (PATTERN & 360B) eq 0
	  ifso WssCSS("No voltages out of spec")
	  ifnot
	  [ WssCSS("Voltages out of spec: ")
	    NWss("+12 ",#200)
	    NWss("+5 ")
	    NWss("-2 ")
	    NWss("-5 ")
	  ]
	  test (PATTERN & 17B) eq 0
	  ifso WssCS1("No currents out of spec")
	  ifnot
	  [ WssCS1("Currents out of spec: ")
	    NWss1("+12 ",#10)
	    NWss1("+5 ")
	    NWss1("-2 ")
	    NWss1("-5")
	  ]
	  return

case #150:	//PROBLEMS
	  NWss("Normal-wait ",#200)
	  NWss("Couldn't-boot ")
	  NWss("Transient-power-problem ")
	  NWss("Power-problem-now ")
	  NWss1("Normal-shut-down ")
	  NWss1("Over-temperature-shut-down ")
	  NWss1("Midas-hogging-CPbus ")
	  return

default:  PutsCS1($%); Wns(CmdCS1,PATTERN,0,16);
	  WssCS1(" = !"); WnsCS1D(PATTERN)
	  WssCS1(" = #"); WnsCS1(PATTERN); return
	]
]

and PrintMSTAT(X,DVec,AVec,Radix) be
[	let t0,t1,t2,t3 = DVec>>lh,DVec>>rh,(DVec+1)>>lh,(DVec+1)>>rh
	WssCSS(selecton AVec!1 into
	[
case mVOLTS: case mAMPS:
case mTEMP0: case mTEMP1: case mTEMP2:
	"Immediate "

case mFVOLTS: case mFAMPS:
case mFTEMP0: case mFTEMP1: case mFTEMP2:
	"Boot-time "

case mMINVOLTS: case mMINAMPS:
case mMINTEMP0: case mMINTEMP1: case mMINTEMP2:
	"Minimum "

case mMAXVOLTS: case mMAXAMPS:
case mMAXTEMP0: case mMAXTEMP1: case mMAXTEMP2:
	"Maximum "

default:	0
	] )
	let TempS = "temperatures (degrees C):"
	switchon AVec!1 into
	[
case mVOLTS: case mFVOLTS: case mMINVOLTS: case mMAXVOLTS:
	  WssCSS("voltages: ")
	  MPrintMSTAT(CmdCS1,X,DVec,AVec); return

case mAMPS: case mFAMPS: case mMINAMPS: case mMAXAMPS:
	  WssCSS("currents (amps): ")
	  MPrintMSTAT(CmdCS1,X,DVec,AVec); return

case mTEMP0: case mFTEMP0: case mMINTEMP0: case mMAXTEMP0:
	  WssCSS(TempS)
	  WssCS1("Base ="); PrinTemperature(CmdCS1,t0)
	  WssCS1(", ContB ="); PrinTemperature(CmdCS1,t1)
	  WssCS1(", ContA ="); PrinTemperature(CmdCS1,t2)
	  WssCS1(", ProcL ="); PrinTemperature(CmdCS1,t3); return

case mTEMP1: case mFTEMP1: case mMINTEMP1: case mMAXTEMP1:
	  WssCSS(TempS)
	  WssCS1("ProcH ="); PrinTemperature(CmdCS1,t0)
	  WssCS1(", IFU ="); PrinTemperature(CmdCS1,t1)
	  WssCS1(", MemC ="); PrinTemperature(CmdCS1,t2)
	  WssCS1(", MemX ="); PrinTemperature(CmdCS1,t3); return

case mTEMP2: case mFTEMP2: case mMINTEMP2: case mMAXTEMP2:
	  WssCSS(TempS)
	  WssCS1("MemD ="); PrinTemperature(CmdCS1,t0)
	  WssCS1(", DskEth ="); PrinTemperature(CmdCS1,t1)
	  WssCS1(", Display ="); PrinTemperature(CmdCS1,t2)
	  //WssCS1(", ?? ="); PrinTemperature(CmdCS1,t3)
	  return

default:  MidasSwat(MSTATbug)
	]
]