SoftcardToolRegistersImpl.mesa
Copyright Ó 1987 by Xerox Corporation. All rights reserved.
Willie-Sue, March 6, 1987 2:08:53 pm PST
DIRECTORY
Basics USING [SwapHalves],
Buttons USING [Create],
Containers USING [ChildXBound],
IO,
Labels USING [Create],
PopUpSelection USING [Request],
ViewerTools USING [MakeNewTextViewer, SetContents, SetSelection],
SoftcardOps,
SoftcardToolPrivate;
SoftcardToolRegistersImpl: CEDAR PROGRAM
IMPORTS
Basics, Buttons, Containers, IO, Labels, PopUpSelection, ViewerTools,
SoftcardOps, SoftcardToolPrivate
EXPORTS
SoftcardToolPrivate
= BEGIN OPEN IO, SoftcardToolPrivate;
euRegValText: Viewer;
euSelectChoice: INT ← -1;
euSelectArray: PUBLIC ARRAY [0..8] OF ROPE;
aAddrText, bAddrText, cAddrText: Viewer;
leftSrcText, rightSrcText: Viewer;
st2ASrcText, st3ASrcText: Viewer;
euFieldInsertText, euFieldMaskText, euFieldShiftText: Viewer;
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
BuildRegisterButtons: PUBLIC PROC[topViewer, sibx: Viewer] RETURNS[sib: Viewer] = {
sib ← sibx;
Regular EU registers
sib ← Labels.Create[
info: [ name: " Regular EU Registers ", parent: topViewer,
 wx: leftEdge, wy: sib.wy+sib.wh+betweenHeight, wh: entryHeight,
 border: FALSE, scrollable: FALSE],
font: labelFont ];
sib ← Buttons.Create[
info: [name: " Read ", parent: topViewer,
wx: sib.wx+sib.ww+xFudge, wy: sib.wy, wh: entryHeight, scrollable: FALSE ],
font: activeFont, proc: ReadEUReg ];
sib ← Buttons.Create[
info: [name: " Write ", parent: topViewer,
wx: sib.wx+sib.ww+xFudge, wy: sib.wy, wh: entryHeight, scrollable: FALSE ],
font: activeFont, proc: WriteEUReg ];
sib ← Buttons.Create[
info: [name: "Val: ", parent: topViewer,
wx: sib.wx+sib.ww+xFudge+6, wy: sib.wy, wh: entryHeight,
border: FALSE, scrollable: FALSE ],
font: selectFont, proc: EUValProc ];
sib ← euRegValText ← ViewerTools.MakeNewTextViewer[
info: [parent: topViewer, wx: sib.wx+sib.ww+xFudge+2, wy: sib.wy,
 ww: 600, wh: entryHeight, border: FALSE, scrollable: FALSE]];
Containers.ChildXBound[topViewer, sib];
EU field register
sib ← Labels.Create[
info: [ name: " EU Field Register ", parent: topViewer,
 wx: leftEdge, wy: sib.wy+sib.wh+betweenHeight, wh: entryHeight,
 border: FALSE, scrollable: FALSE],
font: labelFont ];
sib ← Buttons.Create[
info: [name: " Read ", parent: topViewer,
wx: sib.wx+sib.ww+xFudge, wy: sib.wy, wh: entryHeight, scrollable: FALSE ],
font: activeFont, proc: ReadEUFieldReg ];
sib ← Buttons.Create[
info: [name: " Write ", parent: topViewer,
wx: sib.wx+sib.ww+xFudge, wy: sib.wy, wh: entryHeight, scrollable: FALSE ],
font: activeFont, proc: WriteEUFieldReg ];
sib ← Buttons.Create[
info: [name: "Insert [0..1] ", parent: topViewer,
wx: sib.wx+sib.ww+xFudge+6, wy: sib.wy, wh: entryHeight,
border: FALSE, scrollable: FALSE ],
font: tinySelectFont, proc: EUFieldInsertProc ];
sib ← euFieldInsertText ← ViewerTools.MakeNewTextViewer[
info: [parent: topViewer, wx: sib.wx+sib.ww+xFudge+2, wy: sib.wy,
 ww: 20, wh: entryHeight, border: FALSE, scrollable: FALSE]];
sib ← Buttons.Create[
info: [name: "Mask [0..1fH] ", parent: topViewer,
wx: sib.wx+sib.ww+xFudge+6, wy: sib.wy, wh: entryHeight,
border: FALSE, scrollable: FALSE ],
font: tinySelectFont, proc: EUFieldMaskProc ];
sib ← euFieldMaskText ← ViewerTools.MakeNewTextViewer[
info: [parent: topViewer, wx: sib.wx+sib.ww+xFudge+2, wy: sib.wy,
 ww: 60, wh: entryHeight, border: FALSE, scrollable: FALSE]];
sib ← Buttons.Create[
info: [name: "Shift [0..3fH] ", parent: topViewer,
wx: sib.wx+sib.ww+xFudge+6, wy: sib.wy, wh: entryHeight,
border: FALSE, scrollable: FALSE ],
font: tinySelectFont, proc: EUFieldShiftProc ];
sib ← euFieldShiftText ← ViewerTools.MakeNewTextViewer[
info: [parent: topViewer, wx: sib.wx+sib.ww+xFudge+2, wy: sib.wy,
 ww: 60, wh: entryHeight, border: FALSE, scrollable: FALSE]];
EU KReg
sib ← Labels.Create[
info: [ name: " EU KReg ", parent: topViewer,
 wx: leftEdge, wy: sib.wy+sib.wh+betweenHeight, wh: entryHeight,
 border: FALSE, scrollable: FALSE],
font: labelFont ];
sib ← Buttons.Create[
info: [name: " Read ", parent: topViewer,
wx: sib.wx+sib.ww+xFudge, wy: sib.wy, wh: entryHeight, scrollable: FALSE ],
font: activeFont, proc: ReadKReg ];
sib ← Buttons.Create[
info: [name: " Write ", parent: topViewer,
wx: sib.wx+sib.ww+xFudge, wy: sib.wy, wh: entryHeight, scrollable: FALSE ],
font: activeFont, proc: WriteKReg ];
sib ← Buttons.Create[
info: [name: " aAddr [0..ffH]: ", parent: topViewer,
wx: leftEdge+40, wy: sib.wy+sib.wh+betweenHeight, wh: entryHeight,
border: FALSE, scrollable: FALSE ],
font: tinySelectFont, proc: AAddrProc ];
sib ← aAddrText ← ViewerTools.MakeNewTextViewer[
info: [parent: topViewer, wx: sib.wx+sib.ww+xFudge+8, wy: sib.wy,
 ww: 70, wh: entryHeight, border: FALSE, scrollable: FALSE]];
sib ← Buttons.Create[
info: [name: " bAddr [0..ffH]: ", parent: topViewer,
wx: sib.wx+sib.ww+xFudge, wy: sib.wy, wh: entryHeight,
border: FALSE, scrollable: FALSE ],
font: tinySelectFont, proc: BAddrProc ];
sib ← bAddrText ← ViewerTools.MakeNewTextViewer[
info: [parent: topViewer, wx: sib.wx+sib.ww+xFudge+2, wy: sib.wy,
 ww: 70, wh: entryHeight, border: FALSE, scrollable: FALSE]];
sib ← Buttons.Create[
info: [name: " cAddr [0..ffH]: ", parent: topViewer,
wx: sib.wx+sib.ww+xFudge, wy: sib.wy, wh: entryHeight,
border: FALSE, scrollable: FALSE ],
font: tinySelectFont, proc: CAddrProc ];
sib ← cAddrText ← ViewerTools.MakeNewTextViewer[
info: [parent: topViewer, wx: sib.wx+sib.ww+xFudge+8, wy: sib.wy,
 ww: 70, wh: entryHeight, border: FALSE, scrollable: FALSE]];
sib ← Buttons.Create[
info: [name: " leftSrc [0..3]: ", parent: topViewer,
wx: leftEdge+40, wy: sib.wy+sib.wh+betweenHeight, wh: entryHeight,
border: FALSE, scrollable: FALSE ],
font: tinySelectFont, proc: LeftSrcProc ];
sib ← leftSrcText ← ViewerTools.MakeNewTextViewer[
info: [parent: topViewer, wx: sib.wx+sib.ww+xFudge+2, wy: sib.wy,
 ww: 40, wh: entryHeight, border: FALSE, scrollable: FALSE]];
sib ← Buttons.Create[
info: [name: " rightSrc [0..7]: ", parent: topViewer,
wx: sib.wx+sib.ww+xFudge, wy: sib.wy, wh: entryHeight,
border: FALSE, scrollable: FALSE ],
font: tinySelectFont, proc: RightSrcProc ];
sib ← rightSrcText ← ViewerTools.MakeNewTextViewer[
info: [parent: topViewer, wx: sib.wx+sib.ww+xFudge+8, wy: sib.wy,
 ww: 40, wh: entryHeight, border: FALSE, scrollable: FALSE]];
sib ← Buttons.Create[
info: [name: " st2ASrc [0..3]: ", parent: topViewer,
wx: sib.wx+sib.ww+xFudge, wy: sib.wy, wh: entryHeight,
border: FALSE, scrollable: FALSE ],
font: tinySelectFont, proc: St2ASrcProc ];
sib ← st2ASrcText ← ViewerTools.MakeNewTextViewer[
info: [parent: topViewer, wx: sib.wx+sib.ww+xFudge+8, wy: sib.wy,
 ww: 40, wh: entryHeight, border: FALSE, scrollable: FALSE]];
sib ← Buttons.Create[
info: [name: " st3ASrc [0..1]: ", parent: topViewer,
wx: sib.wx+sib.ww+xFudge, wy: sib.wy, wh: entryHeight,
border: FALSE, scrollable: FALSE ],
font: tinySelectFont, proc: St3ASrcProc ];
sib ← st3ASrcText ← ViewerTools.MakeNewTextViewer[
info: [parent: topViewer, wx: sib.wx+sib.ww+xFudge+8, wy: sib.wy,
 ww: 40, wh: entryHeight, border: FALSE, scrollable: FALSE]];
};
ReadEUReg: ClickProc = {
which: SoftcardOps.EUInternal;
name: ROPE;
val: CARD32;
[which, name] ← SelectEURegister[];
IF name = NIL THEN RETURN;
val ← SoftcardOps.ReadEURegister[which];
TSOutPutF[" The value of EUReg %g is: %xH\n", [rope[name]], [cardinal[val]] ];
ViewerTools.SetContents[euRegValText, IO.PutFR["%xH", [cardinal[val]]] ];
SetDragonStateLabelButton[stopped];
};
WriteEUReg: ClickProc = {
which: SoftcardOps.EUInternal;
name: ROPE;
val: CARD32;
[which, name] ← SelectEURegister[];
IF name = NIL THEN RETURN;
val ← GetAsCard[euRegValText];
SoftcardOps.WriteEURegister[which, val];
TSOutPutF["EUReg %g has been set: %xH\n", [rope[name]], [cardinal[val]] ];
SetDragonStateLabelButton[stopped];
};
EUValProc: ClickProc =
{ ViewerTools.SetSelection[euRegValText, NIL] };
SelectEURegister: PROC RETURNS[reg: SoftcardOps.EUInternal, name: ROPE] = {
which: INT = PopUpSelection.Request[
header: "Regular EU Register",
choice: LIST[euSelectArray[0], euSelectArray[1], euSelectArray[2], euSelectArray[3], euSelectArray[4], euSelectArray[5], euSelectArray[6], euSelectArray[7], euSelectArray[8]] ];
SELECT which FROM
1 => RETURN[left, euSelectArray[0]];
2 => RETURN[right, euSelectArray[1]];
3 => RETURN[st2A, euSelectArray[2]];
4 => RETURN[st2B, euSelectArray[3]];
5 => RETURN[st3A, euSelectArray[4]];
6 => RETURN[r2B, euSelectArray[5]];
7 => RETURN[r3A, euSelectArray[6]];
8 => RETURN[r3B, euSelectArray[7]];
9 => RETURN[dataIn, euSelectArray[8]];
ENDCASE => RETURN[left, NIL];
};
ReadEUFieldReg: ClickProc = {
val: CARD32 = SoftcardOps.ReadEURegister[field];
field: SoftcardOps.FieldDesc = LOOPHOLE[Basics.SwapHalves[LOOPHOLE[val]] ];
ViewerTools.SetContents[euFieldInsertText, IO.PutFR["%g", [cardinal[field.insert]]] ];
ViewerTools.SetContents[euFieldMaskText, IO.PutFR["%xH", [cardinal[field.mask]]] ];
ViewerTools.SetContents[euFieldShiftText, IO.PutFR["%xH", [cardinal[field.shift]]] ];
SetDragonStateLabelButton[stopped];
PrintEUField[field, "is"];
};
WriteEUFieldReg: ClickProc = {
field: SoftcardOps.FieldDesc;
typeIn: CARD32;
ok: BOOL;
[ok, typeIn] ← CheckedGetAsCard[euFieldInsertText, "Insert", 1];
IF ~ok THEN RETURN;
field.insert ← typeIn;
[ok, typeIn] ← CheckedGetAsCard[euFieldMaskText, "Mask", 1fH];
IF ~ok THEN RETURN;
field.mask ← typeIn;
[ok, typeIn] ← CheckedGetAsCard[euFieldShiftText, "Shift", 3fH];
IF ~ok THEN RETURN;
field.mask ← typeIn;
SoftcardOps.WriteEURegister[field, LOOPHOLE[field]];
SetDragonStateLabelButton[stopped];
PrintEUField[field, "has been set to"];
};
PrintEUField: PROC[field: SoftcardOps.FieldDesc, which: ROPE] = {
TSOutPutF[
"\tThe value of EU Field Register %g:\n[insert: %xH, mask: %xH, shift: %xH]\n",
[rope[which]], [cardinal[field.insert]], [cardinal[field.mask]], [cardinal[field.shift]] ];
};
EUFieldInsertProc: ClickProc =
{ ViewerTools.SetSelection[euFieldInsertText, NIL ] };
EUFieldMaskProc: ClickProc =
{ ViewerTools.SetSelection[euFieldMaskText, NIL ] };
EUFieldShiftProc: ClickProc =
{ ViewerTools.SetSelection[euFieldShiftText, NIL ] };
ReadKReg: ClickProc = {
val: CARD32 = SoftcardOps.ReadEURegister[kReg];
kReg: SoftcardOps.KReg = LOOPHOLE[Basics.SwapHalves[LOOPHOLE[val]] ];
ViewerTools.SetContents[aAddrText, IO.PutFR["%xH", [cardinal[kReg.aAddr]]] ];
ViewerTools.SetContents[bAddrText, IO.PutFR["%xH", [cardinal[kReg.bAddr]]] ];
ViewerTools.SetContents[cAddrText, IO.PutFR["%xH", [cardinal[kReg.cAddr]]] ];
ViewerTools.SetContents[leftSrcText, IO.PutFR["%g", [cardinal[kReg.leftSrc]]] ];
ViewerTools.SetContents[rightSrcText, IO.PutFR["%g", [cardinal[kReg.rightSrc]]] ];
ViewerTools.SetContents[st2ASrcText, IO.PutFR["%g", [cardinal[kReg.st2ASrc]]] ];
ViewerTools.SetContents[st3ASrcText, IO.PutFR["%g", [cardinal[kReg.st3ASrc]]] ];
SetDragonStateLabelButton[stopped];
TSOutPutF["\tThe value of EU KReg is:\n[aAddr: %xH, bAddr: %xH, cAddr: %xH, ",
[cardinal[kReg.aAddr]], [cardinal[kReg.bAddr]], [cardinal[kReg.cAddr]] ];
TSOutPutF["leftSrc: %g, rightSrc: %g, st2ASrc: %g, st3ASrc: %g]\n",
[cardinal[kReg.leftSrc]], [cardinal[kReg.rightSrc]], [cardinal[kReg.st2ASrc]],
[cardinal[kReg.st3ASrc]] ];
};
WriteKReg: ClickProc = {
kReg: SoftcardOps.KReg;
val, typeIn: CARD32;
ok: BOOL;
[ok, typeIn] ← CheckedGetAsCard[aAddrText, "aAddr", 0ffH];
IF ~ok THEN RETURN;
kReg.aAddr ← typeIn;
[ok, typeIn] ← CheckedGetAsCard[bAddrText, "bAddr", 0ffH];
IF ~ok THEN RETURN;
kReg.bAddr ← typeIn;
[ok, typeIn] ← CheckedGetAsCard[cAddrText, "cAddr", 0ffH];
IF ~ok THEN RETURN;
kReg.cAddr ← typeIn;
[ok, typeIn] ← CheckedGetAsCard[leftSrcText, "leftSrc", 3];
IF ~ok THEN RETURN;
kReg.leftSrc ← typeIn;
[ok, typeIn] ← CheckedGetAsCard[rightSrcText, "rightSrc", 7];
IF ~ok THEN RETURN;
kReg.rightSrc ← typeIn;
[ok, typeIn] ← CheckedGetAsCard[st2ASrcText, "st2ASrc", 3];
IF ~ok THEN RETURN;
kReg.st2ASrc ← typeIn;
[ok, typeIn] ← CheckedGetAsCard[st3ASrcText, "st3ASrc", 1];
IF ~ok THEN RETURN;
kReg.st3ASrc ← typeIn;
val ← LOOPHOLE[Basics.SwapHalves[LOOPHOLE[kReg]] ];
SoftcardOps.WriteEURegister[kReg, val];
SetDragonStateLabelButton[stopped];
TSOutPutRope[" The EU KReg has been written\n"];
};
AAddrProc: ClickProc = { ViewerTools.SetSelection[aAddrText, NIL] };
BAddrProc: ClickProc = { ViewerTools.SetSelection[bAddrText, NIL] };
CAddrProc: ClickProc = { ViewerTools.SetSelection[cAddrText, NIL] };
LeftSrcProc: ClickProc = { ViewerTools.SetSelection[leftSrcText, NIL] };
RightSrcProc: ClickProc = { ViewerTools.SetSelection[rightSrcText, NIL] };
St2ASrcProc: ClickProc = { ViewerTools.SetSelection[st2ASrcText, NIL] };
St3ASrcProc: ClickProc = { ViewerTools.SetSelection[st3ASrcText, NIL] };
Init: PROC = {
euSelectArray[0] ← "left";
euSelectArray[1] ← "right";
euSelectArray[2] ← "st2A";
euSelectArray[3] ← "st2B";
euSelectArray[4] ← "st3A";
euSelectArray[5] ← "r2B";
euSelectArray[6] ← "r3A";
euSelectArray[7] ← "r3B";
euSelectArray[8] ← "dataIn";
};
* * * * * start code
Init[];
END.