//D1poke.bcpl -- actions to manipulate Dorado while only Passive display
//update is being done.
//	Last edited: 20 November 1979

manifest [ get "d1regmem.d" ]

external [
// MMPRGN
	UpdateMPDValues

// MCMD
	FormCmdMenu; PassiveOnly

// D1I0
	@SaveMIR

// D1ASM
	ReadDMux; @DoStrobe; LoadMIR

// D1RES
	ReadAllRegs; RestoreD1Temps

// Defined here
	SetPassive; UpdateVals; PassivePending
]

static [ PassivePending ]


//The Passive, PrePassive, and Active machine modes are in a ring
//such that the menu action shows the current mode and bugging it
//changes to the next mode.
let SetPassive(Flag,nil,nil) be
[	test Flag
	ifso test PassivePending
//Try to restore the hardware to its state at the last breakpoint, unless
//something irreversible has already been done.  Setup as though about to
//continue.  Then reload MIR, so that if the user has written into MIR, it
//won't change; if he has done this, continuing will resume as though the
//instruction in MIR were at CIA.
//Note: If TASK has changed, it is reloaded with its value at the break.
	  ifso
	  [ RestoreD1Temps(); LoadMIR(SaveMIR)
	    ReadDMux(); DoStrobe(Clock)
	    PassiveOnly = true; UpdateMPDValues()
	  ]
	  ifnot PassivePending = true
	ifnot
	[ PassiveOnly,PassivePending = false,false; ReadAllRegs(1)
	]
	FormCmdMenu()
]


and UpdateVals(nil,nil,nil) be
[	if PassiveOnly do
	[ PassiveOnly = false
//ReadAllRegs(1) will setup for reading the machine state and call
//UpdateMPDValues(), fixing up all the MPD menu values.
	  ReadAllRegs(1)
	  RestoreD1Temps(); LoadMIR(SaveMIR); ReadDMux(); DoStrobe(Clock)
	  PassiveOnly = true
	]
]