//D1Prin3.bcpl	Procedures to prettyprint DMux
//	Last edited: 20 November 1979

get "mcommon.d"
get "d1.d"
manifest [ get "d1dmux.d" ]

external [
// MASM
	@WssCSS; WssCS1; PutsCSS

// MMPRGN
	UpdateMPDValues

// MCMD
	WnsCSS; FormCmdMenu

// MPRINS
	NWss; NWss1

// MPATTERN
	@PATTERN

// D1I0
	DWrong; DChecked; @DMuxTab; @OldDMuxTab; DMuxSelect

// D1PRIN3W
	PrintDMXw

// D1PRIN3X
	PrintDMXx

// D1PRIN3Y
	PrintDMXy

// D1PRIN3Z
	PrintDMXz

// D1PRIN3V
	PrintDMXv

// D1PRIN4
	PrinDMww; PrintDWrong

// Defined here
	PrintDMUX; PrintMCR; PrintESTAT; ShowDMux
]


//Action to change the DMux display mode
let ShowDMux(nil,MBunion,nil) be
[	let old = DMuxSelect
	DMuxSelect = selecton MBunion into
	[
default:
case TopButton:			DMuxTab
case MiddleButton:		DWrong		//(DMux errors)
case BottomButton:		OldDMuxTab	//Last saved DMuxTab
case TopButton+BottomButton:	DChecked	//Bits checked by simulator
	]
	if old ne DMuxSelect then
	[ UpdateMPDValues(); FormCmdMenu()
	]
	if DMuxSelect eq DWrong then PrintDWrong()
]

and PrintDMUX(X,DVec,AVec,ExtRadix) be
[	let Addr = AVec!1
//Table has 1 for low-true bits
	let LowTrueBits = table [
	#000360; #000000; #000000; #000000 //CJNK0, CIAINC, CIA, BNT
	#000000; #000000; #000000; #000000 //PENC, TNIA, BNPC, CTASK
	#000000; #000000; #170000; #000000 //NEXT, CTD, RA, TOPE
	#057744; #000010; #001523; #000000 //CJNK1, FFEQ, CJNK3, READY
	#000000; #000000; #142304; #140000 //ALUB, ALUA, ABCON, PERR
	#000000; #177777; #000000; #177777 //SHMV, MAR, SPARE, PRFA
	#017437; #174370; #024000; #177777 //SCCON, QPDCON, ALUCON, NEXTCL
	#177760; #155743; #122244; #120214 //RADDR, STKRB, RTSB, PJUNK
	#000000; #000000; #000000; #000400 //PVAH, PVAL, MAPAD, HIT
	#017217; #021061; #000000; #000000 //HOLD, PAIR, PIPEAD, --
	#004000; #037700; #001300; #006157 //MEMD0, DAD, FD, EC
	#000000; #000017; #176000; #000002 //TSYN, MDMAD, DADE, MCR
	#000000; #000010; #000160; #050200 //MAPBUF, P34INEC, MCDTSK, STA
	#000000; #176060; #005100; #020020 //APESRN, STOUT, TAGAT, MEMST
	#000000; #010054; #000400; #140001 //--, FLTMEM, RFSSRN, EC1MAKE
	#037170; #000200; #175400; #000000 //MAPCTRL, PEEC, INMAP, --
	#000070; #000000; #000000; #000000 //KSTATE, KSTAT, KRAM, KTAG
	#002000; #000000; #005400; #000500 //KFIFO, ERX0, ETX, ERX1
	#000140; #000000; #000000; #000000 //CLKRUN, --, --, --
	#000000; #000000; #000000; #000000 //--, --, --. --
	#000006; #000601; #000000; #022000 //MEMRQ, LOADS, HJ, MX
	#000000; #000200; #041030; #007000 //JMPEXC, PCJ, FFK, IDLY
	#000000; #000000; #000000; #000000 //--, --, --, --
	#000000; #000000; #000000; #000000 //--, --, --, --
	#000000; #000000; #000000; #000000 //APTRS, BPTRS, ITEMS, SPSIZE
	#000000; #000000; #000000; #000000 //RESON, --, --, --
	#000000; #000000; #000000; #000000 //--, --, --, --
	#000000; #000000; #000000; #000000 //--, --, --, --
	#000000; #000000; #000000; #000000 //TEMP, AAD, MEMB, BMUX
	#000000; #000000; #000000; #000000 //ESTAT, --, MIRA, MIRB
	#000000; #000000; #000000; #000000 //MIRC, MIRD, IMOUTA, IMOUTB
	#000000; #000000; #000000; #000000 //IMOUTC, IMOUTD
	] !Addr

	test (DMuxSelect eq DMuxTab) % (DMuxSelect eq OldDMuxTab)
	ifso	//Regular printout
	[ PATTERN = DVec!0 xor LowTrueBits	//Convert to hi-true
	  test Addr ge 40B
	  ifso test Addr ge 110B
	    ifso PrintDMXv(Addr)	//ge 110
	    ifnot test Addr ge 70B
	      ifso PrintDMXz(Addr)	//70-107
	      ifnot PrintDMXy(Addr)	//40-67
	  ifnot test Addr < 20B
	    ifso PrintDMXw(Addr)	//0-17
	    ifnot PrintDMXx(Addr)	//20-37
	  return
	]
	ifnot	//Individual bit printout for DWrong & DChecked
	[ let ECSS,ECS1 = 1,0
	  WssCSS((DMuxSelect eq DChecked ? "Check:","Errors"))
	  PrinDMww(Addr,DVec!0,lv ECSS,lv ECS1,false)
	]
]


//X, AVec1!0 ignored--do it this way to allow different printout for
//various DMux tables
and PrintMCR(X,DVec,AVec,ExtRadix) be
	PrintDMUX(X,DVec,table [ 0; dMCR ] ,ExtRadix)


and PrintESTAT(X,DVec,AVec,ExtRadix) be
	PrintDMUX(X,DVec,table [ 0; dESTAT ] ,ExtRadix)