Text preview for : NubControl.mesa_Oct77.pdf part of xerox NubControl.mesa Oct77 xerox mesa 3.0_1977 listing NubControl.mesa_Oct77.pdf
Back to : NubControl.mesa_Oct77.pdf | Home
nubcONTROL.mESA 24-0CT-77 18:38:26 Page 1
-- NubControl.Mesa
-- Edited by Sandman on October 6, 1977 4:31 PM
DIRECTORY
AltoFileDefs: FROM "altofiledefs",
ControlDefs: FROM "con troldefs",
CoreSwapDefs: FROM "coreswapdefs",
FrameDefs: FROM "framedefs",
ImageDefs: FROM "imagedefs",
IODefs: FROM" iodefs",
LoaderDefs: FROM "loaderdefs",
SegmentDefs: FROM "segmentdefs",
StreamDefs: FROM "streamdefs",
StringDefs: FROM "stringdefs",
Rectangles: FROM "rectangles",
Windows: FROM "windows",
TimeDefs: FROM "timedefs":
NubControl: PROGRAM
IMPORTS CoreSwapDefs, FrameDefs, ImageDefs, IODefs, LoaderDefs, SegmentDefs, StreamDefs, StringDefs,
**TimeDefs. Rectangles, Windows
8EGIN
-- System Signals are converted to these to prevent NubCommand
-- from catching user generated signals
Delete: SIGNAL = CODE: nee Rubout
StringTooLong: ERROR = CODE: nee LineOverflow
BadFile: ERROR [badname: STRING] = CODE: -- nee FileNameError
BadNumber: ERROR = CODE: -- nee InvalidNumber
Program: TYPE = PROGRAM:
CallDebugger: PROCEDURE =
BEGIN -- user's entry point to debugger
state: ControlOefs.StateVector:
state.stkptr ~ 0:
state.X ~ defaultframe:
CoreSwapDefs.CoreSwap[explicitcall. @state]:
RETURN
END:
CommandChar: TYPE = {N,S.M.D,Q}:
CommandString: ARRAY CommandChar OF STRING =
["New". "Start", "Makelmage". "Debug". "Quit"]:
Command: PROCEDURE =
BEGIN OPEN IODefs:
c: CHARACTER:
i: CommandChar;
f: ControlDefs.GlobalFramelfandle:
IF comcmRequest.file # NIL THEN NubHack[]:
SELECT cpReadChar[] FROM
'N. 'n =>
BEGIN
WriteString[CommandString[N]]:
f .. LoadNew[getfilename[".bcd"]];
IF f # ControlOefs . NUl.l.Frame TIIEN defaul tframe .. f;
END:
'S, 's =>
BEGIN
WriteString[CommandString[S]]:
f .. getgframe[]:
WritefOL[]:
If f.pc = ControlDefs.WordPC[O] TII[N START LOOPIIOl.f[f, Program] flS[ RESTART f;
END;
'0, 'd =>
BfGIN
WriteSlring[CommandString[O]];
confil'm[];
CallDebugger[];
rNO:
'Q, 'q ~>
nubcONTROL.mESA 24-0CT-77 18:38:25 Pago 2
BEGIN
WriteString[CommandStrlng[Q]]:
confirm[]:
ImageDefs.StopMesa[]:
END:
'M, 'm =>
BEGIN
WriteString[CommandString[M]]:
ImageDefs.Makelmage[getfilename[".lmage"], FALSE]:
END:
CR,SP => NULL:
ENDCASE =>
BEGIN
WriteChar[c] :
WriteString[" Commands are:"]:
FOR i IN CommandChar DO
WriteChar[' ]: WriteString[CommandString[i]]; ENDlOOP;
END;
RETURN
END:
LoadNew: PROCEDURE [name: STRING] RETURNS [g: ControlDefs.GlobalFrameHandle] :
BEGIN
g ~ FrameOefs.New[name I BadFile, LoaderDefs.VersionMismatch, UNWIND => NULL;
ANY => ERROR BadFile[name]];
IODefs.WriteString[" -- "];
IOOefs.WriteOctal[g];
RETURN
END;
defaultframe: ControlDefs.GlobalFrameHandle ~ REGISTER[ControlDefs.Greg];
getgframe: PROCEDURE RETURNS [f: ControlDefs.GlobalFrameHandle]
BEGIN OPEN IODers:
WriteString[" Global frame: "];
f ~ ReadNumber[defaultframe,8
I LineOverflow =) ERROR StringTooLong;
Rubout =) SIGNAL Delete;
StringDefs.InvalidNumber =) ERROR BadNumber];
IF (f.accesslink # f) OR (FrameDefs.Class(f] # global) THEN
BEGIN WriteString[" not a global framel"]; SIGNAL CoreSwapDefs.CAbort END:
defaultframe ~ f;
RETURN
END;
idstring: STRING ~ [40];
getfilename: PROCEDURE [defaultextension: STRING] RETURNS [STRING]
BEGIN OPEN IODers;
WriteString[" Filename: "];
ReadID[idstring
I Rubout =) SIGNAL Delete;
LineOverflow =) [RROR StringTooLong];
deraultext[idstring, defaultextension];
RFTURN[idstring]
END;
defaultext: PROCrDURE [idstring, ext: STRING]
B[GIN
i: CARDINAL;
rOR i TN [0 .. idstring.length) DO
IF idstring[i] = '. THEN EXIT;
Rrp[AT rTNISllro =)
Str ingOefs.AppendStr ing[ idsLring, ext
! SLringDefs.StringRoundsfault =) [RROR StringTooLong]:
rNOLOOP;
[NO;
confirm: PROCEDURE
R[GTN OPEN IODefs;
WrILsSLring[" [confinn] "];
nubcONTROL.mESA 24-0CT-77 18:33:25 Page 3
DO
SELECT ReadChar[] FROM
CR => EXIT;
DEL =) SIGNAL Delete;
ENDCASE => WriteChar['?];
ENDLOOP;
WriteChar[CR];
RETURN
END;
WriteEOL: PROCEDURE =
BEGIN OPEN IODefs;
IF -NewLine[] THEN WriteChar[CR];
RETURN
END;
comcmRequest: short ImageDefs.FileRequest ~ [
body: shOrl[fil1:, name: "Com.Cm."].
file: NIL.
access: SegmentDefs.Read,
1 ink: ];
NubHaek: PROCEDURE =
BEGIN OPEN 10Defs, StreamDefs;
f: Contro1Defs.GlobalFrameHandle;
com: StreamHand1e;
name: STRING ~ [40];
fa: AltoFileDefs.FA;
GetToken: PROCEDURE [token: STRING] =
BEGIN
c: CIIARACTER;
token. length ~ 0;
WHILE -com.endof[eom] DO
SELECT (e ~ com.get[com]) FROM
SP, CR =) IF token. length # 0 THEN RETURN;
ENDCASE => StringDefs.AppendChar[token. e]:
ENDLOOP;
RETURN
END;
Cleanup: PROCEDURE
BEGIN
IF comcmRequest.file # NIL THEN
BEGIN
SegmentDefs.Un1oekFi1e[comemRequest.fi1e];
comemRequest.fi1e ~ NIL
END;
END;
SegmentDefs.LoekFi1e[eomcmRequest.file];
com ~ CreateByteStream[eomcmRequest.file. Read]:
GetToken[name]: -- Skip Image Name
GetToken[ name];
WHILE name. length # 0 DO
ENABLE UNWIND =) C1eanup[1 ANY =) NULL];
WriteSLring[name];
defau1texL[name, ".bed"];
S treamDe fs. Getf A[ com, @fa];
eom.destroy[com]; com ~ NIL;
f ~ loadNew[name];
Wr i LeEOL[];
If r # COlltrolDefs.~JULLFrame THEN START LOOPIIOLE[(defau1tframe ~ f). Program];
WriteChar[')]:
Ir c0l11cmRequesL.fi1e = NIL TIIEN RFTURN:
com ~ CreaLeRyLeSLream[comcmRequest.file. Read];
StreamOefs.JumpToFA[com. @fa ! StreamDefs.Streamfrror. SegmenLOefs.lnvalidFP =) rXIT];
GeLToken[name]:
[NOIOOP;
com.desLroy[com];
C1 eanup[]:
rND:
time: STRING ~ [IB];
Main body
[] ~ SLreamOefs.GeLOeraul LKey[]; -- Slal"l keyboard pl'ocess
nubcONTROL.mESA 24-0CT-77 18:38:26 Puge 4
ImageDefs.AddFileRequest[@comcmRequest]:
START Rectangles[40, 30]:
START Windows["Mesa.Typescript."]:
STOP:
RESTART Rectangles:
RESTART Windows:
START IODefs.StreamIO[NtL. NIL]:
[] ~ LoaderDefs.LoadBcd[NIL I ANY =) CONTINUE];
TimeDefs.AppendDayTime[time. TimeDefs.UnpackDT[ImageOefs.ImageVersion[].time]]:
time.length ~ time. length - 3;
IODefs.WriteString["Alto/Mesa 3.0 "]: IODefs.WriteString[time]:
DO OPEN IODers; -- fore'!er
WriteEOl[]; WriteChar[')]:
Command[
I Delete =) BEGIN WriteString[" XXX"]; CONTINUE END;
CoreSwapDefs.CAbort =) CONTINUE;
BadFile =>
BEGIN
WriteEOL[]:
WriteString["IFile: a]:
WriteString[badname]:
CONTINUE
END;
BadNumber =)
BEGIN WriteEOl[]; WriteString["INumber"]: CONTINUE END;
StringTooLong =>
BEGIN Write[Ol[]; WriteString["IString too long"]; CONTINUE END;
CoreSwapDefs.CantSwap =>
BEGIN
WriteEOL[];
WriteString["External Debugger not installed, type DEL to Abort "];
UNTIL ReadChar[]=DEL DO WriteChar['?] ENDLOOP;
WriteString(" ... Aborted ... "];
CONTINUE
END;
LoaderDefs.VersionMismatch --[name: STRING] --=)
BEGIN
Wr iteEOL[];
WriteStringC"IFile: "];
WriteString[name];
WriteStringC" referenced in different versions."];
RESUME
END;
UNWIND =)CONTINUE
];
ENDLOOP;
END ...