-- MouseMossimImpl.mesa
-- created by Haeberli:  23-Dec-81 14:20:30

DIRECTORY
  Mouse,
  MOSSIMFns,
  String;

MouseMossimImpl: PROGRAM IMPORTS MOSSIMFns, String EXPORTS Mouse =
  {
  OPEN Mouse;

  PinMap: ARRAY Pin OF STRING = [
    RedA: "RedA", RedB: "RedB", YellowA: "YellowA", YellowB: "YellowB",
    BlueA: "BlueA", BlueB: "BlueB", TestEnable: "TestEnablePad", Gnd: "Gnd",
    YA: "YAPad", YB: "YBPad", XA: "XAPad", XB: "XBPad", TestData: "TestDataPad",
    TestClock: "TestClockPad", GateTest: "GateTestPad", Vdd: "Vdd",
    AnyGood: "AnyGoodPad", Jump: "JmpPad"];

  EndRecordPat: PUBLIC PROCEDURE = {};

  GetPin: PUBLIC PROCEDURE [pin: Mouse.Pin] RETURNS [value: Mouse.Value] = {
    SimSetPin[PinMap[pin], x];
    RETURN[LOOPHOLE[GetNodeValue[PinMap[pin]], Mouse.Value]]};

  GetNodeValue: PROC [name: STRING] RETURNS [v: INTEGER] = {
    MOSSIMFns.targc ← 2;
    MOSSIMFns.targv[1].length ← 0;
    String.AppendString[MOSSIMFns.targv[1], name];
    RETURN[MOSSIMFns.getNodeValue[]]};

  PlayPat: PUBLIC PROCEDURE [pat: Pattern] = {};

  RecordPat: PUBLIC PROCEDURE [pat: Pattern] = {};

  Reset: PUBLIC PROCEDURE = {};

  SimSetPin: PROCEDURE [pinname: STRING, value: Mouse.Value] = {
    SELECT value FROM
      zero => SetInputLow[pinname];
      one => SetInputHigh[pinname];
      x => SetInputX[pinname]
      ENDCASE;
    Step[]};

  SetInputLow: PROC [name: STRING] = {
    MOSSIMFns.targv[1].length ← 0;
    String.AppendString[MOSSIMFns.targv[1], name];
    MOSSIMFns.targc ← 2;
    MOSSIMFns.setInputL[]};

  SetInputHigh: PROC [name: STRING] = {
    MOSSIMFns.targv[1].length ← 0;
    String.AppendString[MOSSIMFns.targv[1], name];
    MOSSIMFns.targc ← 2;
    MOSSIMFns.setInputH[]};

  SetInputX: PROC [name: STRING] = {
    MOSSIMFns.targv[1].length ← 0;
    String.AppendString[MOSSIMFns.targv[1], name];
    MOSSIMFns.targc ← 2;
    MOSSIMFns.setInputX[]};

  Step: PROC = {value: INTEGER; MOSSIMFns.targc ← 1; value ← MOSSIMFns.step[]};

  SetPin: PUBLIC PROCEDURE [pin: Mouse.Pin, value: Mouse.Value] = {
    IF pin = GateTest THEN {
      SELECT value FROM
        zero => {SimSetPin[PinMap[pin], value]; SimSetPin["Done", x]};
        one => {SimSetPin["Done", zero]; SimSetPin[PinMap[pin], value]};
        x => SimSetPin[PinMap[pin], value];
        ENDCASE;
      }
    ELSE SimSetPin[PinMap[pin], value]};

  SetPinMap: PUBLIC PROCEDURE [pinMap: Mouse.PinMap] = {};

  SetVersion: PUBLIC PROCEDURE [version: Mouse.ChipVersion] = {};

  Reset;

  }.

MPH   23-Dec-81 14:20:20
	created initially