-- CatEcho.mesa
-- D0 printer port CAT test
-- Last Modified LStewart January 27, 1981 9:26 PM
DIRECTORY
Inline USING [BITAND, BITOR],
Mopcodes USING [zMISC],
ProcessDefs USING [DisableInterrupts],
SystemDefs USING [AllocateSegment];
CatEcho: PROGRAM
IMPORTS Inline, ProcessDefs, SystemDefs =
BEGIN
-- Parts of printer port values
Device: CARDINAL = 100000B;
Idle: CARDINAL = 0B;
PreCharge: CARDINAL = 0B;
EnData: CARDINAL = 400B;
Strobe: CARDINAL = 1000B;
EnStatus: CARDINAL = 1400B;
Ready: CARDINAL = 1B;
-- Use these
idle: CARDINAL = Idle;
preCharge: CARDINAL = Device+PreCharge;
enData: CARDINAL = Device+EnData;
strobe: CARDINAL = Device+Strobe;
enStatus: CARDINAL = Device+EnStatus;
-- MISC Alpha bytes
RPrinter: CARDINAL = 12B;
WPrinter: CARDINAL = 13B;
-- Data buffer
SampleMask: CARDINAL = 377B;
Sample: TYPE = [0..377B];
BufSize: CARDINAL = 16000;
MaxBuf: CARDINAL = BufSize-1;
Buf: TYPE = PACKED ARRAY OF Sample;
buf: DESCRIPTOR FOR Buf;
Main: PROCEDURE =
BEGIN OPEN Inline;
bufIndex: CARDINAL ← 0;
data: CARDINAL ← 0;
pd: CARDINAL;
mb: DESCRIPTOR FOR Buf ← buf;
DO
-- SET[Idle];
SET[enStatus];
IF BITAND[GET[], Ready]=0 THEN
BEGIN
pd ← BITOR[data, preCharge];
SET[pd];
SET[BITOR[data, strobe]];
SET[pd];
SET[enData];
-- data ← BITAND[SampleMask, GET[]];
mb[bufIndex] ← BITAND[SampleMask, GET[]];
bufIndex ← IF bufIndex=MaxBuf THEN 0 ELSE bufIndex+1;
data ← mb[bufIndex];
END;
ENDLOOP;
END;
SET: PROCEDURE [x: CARDINAL] =
MACHINE CODE BEGIN
Mopcodes.zMISC, WPrinter;
END;
GET: PROCEDURE RETURNS [x: CARDINAL] =
MACHINE CODE BEGIN
Mopcodes.zMISC, RPrinter;
END;
-- Mainline code
buf ← DESCRIPTOR[SystemDefs.AllocateSegment[BufSize/2], BufSize];
ProcessDefs.DisableInterrupts[];
Main[];
END.