bobc@tikal.UUCP (Bob Campbell) (05/12/86)
# The rest of this file is a shell script which will extract: # BDPackage.MOD ControlManager.MOD Conversions.MOD Cursors.MOD DeskManager.MOD DialogManager.MOD echo x - BDPackage.MOD cat >BDPackage.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE BDPackage; FROM SYSTEM IMPORT ADDRESS,CODE,ADR,REGISTER,SETREG; FROM MacSYSTEM IMPORT LONGINT; FROM PascalStrings IMPORT MakeModulaString,MakePascalString; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) Push = 03F3CH; (* MOVE #VAL,-(A7) *) Pack7 = 0A9EEH; pNumToString= 0; pStringToNum= 1; PROCEDURE xStringToNum(theString:ADDRESS;VAR theNum:LONGINT); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(pStringToNum); CODE(Pack7); CODE(RestoreA7); CODE(Return); END xStringToNum; PROCEDURE NumToString(theNum:LONGINT;VAR theString:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN SETREG(0,theNum); SETREG(8,ADR(Str)); CODE(Push); CODE(pNumToString); CODE(Pack7); MakeModulaString(Str,theString) END NumToString; PROCEDURE StringToNum(VAR theString:ARRAY OF CHAR;VAR theNum:LONGINT); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(theString,Str); SETREG(8,ADR(Str)); CODE(Push); CODE(pStringToNum); CODE(Pack7); theNum := REGISTER(0) END StringToNum END BDPackage. !Funky!Stuff! echo x - ControlManager.MOD cat >ControlManager.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE ControlManager; FROM SYSTEM IMPORT ADDRESS,CODE,ADR,SETREG,REGISTER; FROM MacSYSTEM IMPORT LONGINT,Handle; FROM QuickDraw IMPORT Point,Rect; FROM WindowManager IMPORT WindowPtr; FROM PascalStrings IMPORT MakePascalString,MakeModulaString; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP (A4) *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) (* Init and Alloc *) PROCEDURE xNewControl(Wind:WindowPtr;VAR bounds:Rect;title:ADDRESS; visible:BOOLEAN;value:INTEGER;min,max:INTEGER;procID:INTEGER; refCon:LONGINT): ControlHandle; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A954H); CODE(RestoreA7); CODE(Return); END xNewControl; PROCEDURE NewControl(Wind:WindowPtr;bounds:Rect;VAR title:ARRAY OF CHAR; visible:BOOLEAN;value:INTEGER;min,max:INTEGER;procID:INTEGER; refCon:LONGINT): ControlHandle; (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(title,Str); RETURN(xNewControl(Wind,bounds,ADR(Str),visible,value,min,max,procID,refCon)) END NewControl; PROCEDURE GetNewControl (controlID:INTEGER;wind:WindowPtr):ControlHandle; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9BEH); CODE(RestoreA7); CODE(Return); END GetNewControl; PROCEDURE DisposeControl (theControl:ControlHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A955H); CODE(RestoreA7); CODE(Return); END DisposeControl; PROCEDURE KillControls (wind:WindowPtr); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A956H); CODE(RestoreA7); CODE(Return); END KillControls; (* Control Display *) PROCEDURE xSetCTitle (theControl:ControlHandle;title:ADDRESS); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A95FH); CODE(RestoreA7); CODE(Return); END xSetCTitle; PROCEDURE SetCTitle (theControl:ControlHandle;VAR title:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(title,Str); xSetCTitle(theControl,ADR(Str)) END SetCTitle; PROCEDURE xGetCTitle (theControl:ControlHandle;title:ADDRESS); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A95EH); CODE(RestoreA7); CODE(Return); END xGetCTitle; PROCEDURE GetCTitle (theControl:ControlHandle;VAR title:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN xGetCTitle(theControl,ADR(Str)); MakeModulaString(Str,title) END GetCTitle; PROCEDURE HideControl (theControl:ControlHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A958H); CODE(RestoreA7); CODE(Return); END HideControl; PROCEDURE ShowControl (theControl:ControlHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A957H); CODE(RestoreA7); CODE(Return); END ShowControl; PROCEDURE DrawControls (theWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A969H); CODE(RestoreA7); CODE(Return); END DrawControls; PROCEDURE HiliteControl (theControl:ControlHandle;hiliteState:INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A95DH); CODE(RestoreA7); CODE(Return); END HiliteControl; (* Mouse Location *) PROCEDURE xTestControl(theControl:ControlHandle;thePoint:LONGINT):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A966H); CODE(RestoreA7); CODE(Return); END xTestControl; PROCEDURE TestControl (theControl: ControlHandle;thePoint:Point):INTEGER; (*$P+*)(*$S-*) BEGIN RETURN(xTestControl(theControl,thePoint.param)) END TestControl; PROCEDURE xFindControl(thePoint:LONGINT;theWindow:WindowPtr; VAR whichControl:ControlHandle):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A96CH); CODE(RestoreA7); CODE(Return); END xFindControl; PROCEDURE FindControl(thePoint:Point;theWindow:WindowPtr; VAR whichControl:ControlHandle):INTEGER; (*$P+*)(*$S-*) BEGIN RETURN(xFindControl(thePoint.param,theWindow,whichControl)) END FindControl; PROCEDURE xTrackControl(theControl:ControlHandle;startPt:LONGINT; actionProc: ADDRESS):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A968H); CODE(RestoreA7); CODE(Return); END xTrackControl; PROCEDURE TrackControl (theControl: ControlHandle; startPt:Point; actionProc: ADDRESS):INTEGER; (*$P+*)(*$S-*) BEGIN RETURN(xTrackControl(theControl,startPt.param,actionProc)) END TrackControl; VAR ProcA:PROC; PROCEDURE ProcAInterface; (*$P-*) BEGIN CODE(04E56H);CODE(0); (* LINK A6,#0 *) CODE(048E7H);CODE(0FFFCH); (* MOVEM.L D0-D7/A0-A5,-(A7)*) SETREG(8,ProcA); CODE(04E90H); (* JSR (A0) *) CODE(04CDFH);CODE(03FFFH); (* MOVEM.L (A7)+,D0-D7/A0-A5*) CODE(04E5EH); (* UNLK A6 *) CODE(04E75H); (* RTS *) END ProcAInterface; PROCEDURE TrackProcA(p:PROC):ADDRESS; (*$P+*)(*$S-*) BEGIN ProcA := p; SETREG(8,ProcAInterface); RETURN(REGISTER(8)) END TrackProcA; VAR ProcB:PROCHI; PROCEDURE ProcBInterface; (*$P-*) BEGIN CODE(04E56H);CODE(0); (* LINK A6,#0 *) CODE(048E7H);CODE(0FFFCH); (* MOVEM.L D0-D7/A0-A5,-(A7) *) CODE(02F2EH);CODE(0AH); (* MOVE.L 0A(A6),-(A7) *) CODE(03F2EH);CODE(08H); (* MOVE.W 08(A6),-(A7) *) SETREG(8,ProcB); CODE(04E90H); (* JSR (A6) *) CODE(05C8FH); (* ADDQ.L #6,A7 *) CODE(04CDFH);CODE(03FFFH); (* MOVEM.L (A7)+,D0-D7/A0-A4 *) CODE(04E5EH); (* UNLK A6 *) CODE(02F5FH);CODE(2H); (* MOVE.L (A7)+,2(A7) *) CODE(0548FH); (* ADDQ.L #2,A7 *) CODE(04E75H); (* RTS *) END ProcBInterface; PROCEDURE TrackProcB(p:PROCHI):ADDRESS; (*$P+*)(*$S-*) BEGIN ProcB := p; SETREG(8,ProcBInterface); RETURN(REGISTER(8)) END TrackProcB; (* Control Movement and Sizing *) PROCEDURE MoveControl (theControl: ControlHandle; h,v: INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A959H); CODE(RestoreA7); CODE(Return); END MoveControl; PROCEDURE xDragControl (theControl: ControlHandle; startPt:LONGINT; VAR limitRect,slopRect: Rect; axis: INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A967H); CODE(RestoreA7); CODE(Return); END xDragControl; PROCEDURE DragControl (theControl: ControlHandle; startPt:Point; limitRect,slopRect: Rect; axis: INTEGER); (*$P+*)(*$S-*) BEGIN xDragControl(theControl,startPt.param,limitRect,slopRect,axis) END DragControl; PROCEDURE SizeControl (theControl: ControlHandle; w,h: INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A95CH); CODE(RestoreA7); CODE(Return); END SizeControl; (* Control Setting and Range *) PROCEDURE SetCtlValue (theControl: ControlHandle; theValue: INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A963H); CODE(RestoreA7); CODE(Return); END SetCtlValue; PROCEDURE GetCtlValue (theControl: ControlHandle):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A960H); CODE(RestoreA7); CODE(Return); END GetCtlValue; PROCEDURE SetCtlMin (theControl: ControlHandle;minValue:INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A964H); CODE(RestoreA7); CODE(Return); END SetCtlMin; PROCEDURE GetCtlMin (theControl: ControlHandle):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A961H); CODE(RestoreA7); CODE(Return); END GetCtlMin; PROCEDURE SetCtlMax (theControl: ControlHandle; maxValue:INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A965H); CODE(RestoreA7); CODE(Return); END SetCtlMax; PROCEDURE GetCtlMax (theControl: ControlHandle):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A962H); CODE(RestoreA7); CODE(Return); END GetCtlMax; (* Miscellaneous Utilities *) PROCEDURE SetCRefCon (theControl: ControlHandle; data: LONGINT); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A95BH); CODE(RestoreA7); CODE(Return); END SetCRefCon; PROCEDURE GetCRefCon (theControl: ControlHandle):LONGINT; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A95AH); CODE(RestoreA7); CODE(Return); END GetCRefCon; PROCEDURE SetCtlAction (theControl: ControlHandle;actionProc:ADDRESS); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A96BH); CODE(RestoreA7); CODE(Return); END SetCtlAction; PROCEDURE GetCtlAction (theControl: ControlHandle):ADDRESS; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A96BH); CODE(RestoreA7); CODE(Return); END GetCtlAction; END ControlManager. !Funky!Stuff! echo x - Conversions.MOD cat >Conversions.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE Conversions; FROM SYSTEM IMPORT WORD; PROCEDURE PAD(VAR s:ARRAY OF CHAR;size:INTEGER;c:CHAR); VAR i :CARDINAL; BEGIN IF (size >= 0) THEN FOR i := 0 TO size DO s[i] := c END END END PAD; PROCEDURE NtoS(x,base: CARDINAL; size:INTEGER; VAR str:ARRAY OF CHAR;sign,first:BOOLEAN;pad:CHAR):INTEGER; VAR RetSize : INTEGER; High : INTEGER; BEGIN High := VAL(INTEGER,HIGH(str)); IF (x = 0) THEN IF (first) THEN IF (size > High) THEN size := High END; IF (sign) THEN PAD(str,size - 2,pad); IF (size = 0) THEN size := 1; END; str[size - 1] := '-'; ELSE PAD(str,size - 1,pad); END; str[size] := '0'; ELSE IF (sign) THEN IF (size < 0) THEN PAD(str,High,'*'); RETURN(-2) END; PAD(str,size - 1,pad); str[size] := '-' ELSE PAD(str,size,pad); END; END; (*IF*) IF (first AND (size # High)) THEN str[size + 1] := 0C END; RETURN(size) ELSE (* x is not 0 *) IF (size < 0) THEN size := 0 END; RetSize := NtoS(x DIV base,base,size - 1,str,sign,FALSE,pad); IF (RetSize = -2) THEN RETURN(RetSize) END; IF size <= RetSize THEN size := RetSize + 1; END; IF (size > High) THEN PAD(str,High,'*'); RETURN(-2); ELSE str[size] := CHR(ORD('0') + x MOD base); IF str[size] > '9' THEN str[size] := CHR(ORD(str[size]) - ORD('0') + ORD('A') - 10) END; IF (first AND (size # High)) THEN str[size + 1] := 0C END; RETURN(size) END END END NtoS; PROCEDURE IntToStr(i : INTEGER;VAR s : ARRAY OF CHAR; p : CARDINAL):BOOLEAN; VAR RetSize : INTEGER; BEGIN IF (p = 0) THEN RetSize := 0 ELSE RetSize := VAL(INTEGER,p) - 1; END; RetSize := NtoS(ABS(i),10,RetSize,s,(i < 0),TRUE,' '); RETURN(RetSize # -2) END IntToStr; PROCEDURE StrToInt(VAR s : ARRAY OF CHAR; VAR x : INTEGER):BOOLEAN; VAR i : CARDINAL; neg : BOOLEAN; BEGIN i := 0; x := 0; WHILE ((i < HIGH(s)) AND ((s[i] = ' ') OR (s[i] = ' '))) DO INC(i) END; (* Assert at worst i = HIGH(s) *) IF (s[i] = '-') THEN neg := TRUE; INC(i); IF (i > HIGH(s)) THEN RETURN(FALSE) END END; REPEAT IF ((s[i] < '0') OR (s[i] > '9')) THEN RETURN(FALSE) ELSE x := x * 10 + INTEGER(ORD(s[i])) - INTEGER(ORD('0')) END; INC(i) UNTIL ((i > HIGH(s)) OR (s[i] = 0C)); IF neg THEN x := -x; END; RETURN(TRUE) END StrToInt; PROCEDURE CardToStr(c : CARDINAL; VAR s : ARRAY OF CHAR; p : CARDINAL):BOOLEAN; VAR RetSize : INTEGER; BEGIN IF (p = 0) THEN RetSize := 0 ELSE RetSize := VAL(INTEGER,p) - 1; END; RetSize := NtoS(c,10,RetSize,s,FALSE,TRUE,' '); RETURN(RetSize # -2) END CardToStr; PROCEDURE StrToCard(VAR s:ARRAY OF CHAR; VAR c:CARDINAL):BOOLEAN; VAR i : CARDINAL; BEGIN i := 0; c := 0; WHILE ((i < HIGH(s)) AND ((s[i] = ' ') OR (s[i] = ' '))) DO INC(i) END; (* Assert at worst i = HIGH(s) *) REPEAT IF ((s[i] < '0') OR (s[i] > '9')) THEN RETURN(FALSE) ELSE c := c * 10 + ORD(s[i]) - ORD('0') END; INC(i) UNTIL ((i > HIGH(s)) OR (s[i] = 0C)); RETURN(TRUE) END StrToCard; PROCEDURE HexToStr(w:WORD;VAR s:ARRAY OF CHAR; p : CARDINAL):BOOLEAN; VAR RetSize : INTEGER; BEGIN IF (p = 0) THEN RetSize := 0 ELSE RetSize := VAL(INTEGER,p) - 1; END; RetSize := NtoS(CARDINAL(w),16,RetSize,s,FALSE,TRUE,'0'); RETURN(RetSize # -2) END HexToStr; PROCEDURE StrToHex(VAR s:ARRAY OF CHAR;VAR w:WORD):BOOLEAN; VAR i : CARDINAL; c : CARDINAL; BEGIN i := 0; c := 0; WHILE ((i < HIGH(s)) AND ((s[i] = ' ') OR (s[i] = ' '))) DO INC(i) END; (* Assert at worst i = HIGH(s) *) REPEAT IF ((s[i] < '0') OR (s[i] > '9')) THEN IF ((s[i] >= 'A') AND (s[i] <= 'F')) THEN c := c * 10 + ORD(s[i]) - ORD('A') + 10 ELSE RETURN(FALSE) END ELSE c := c * 10 + ORD(s[i]) - ORD('0') END; INC(i) UNTIL ((i > HIGH(s)) OR (s[i] = 0C)); w := WORD(c); RETURN(TRUE) END StrToHex; PROCEDURE OctToStr(w:WORD;VAR s:ARRAY OF CHAR; p : CARDINAL):BOOLEAN; VAR RetSize : INTEGER; BEGIN IF (p = 0) THEN RetSize := 0 ELSE RetSize := VAL(INTEGER,p) - 1; END; RetSize := NtoS(CARDINAL(w),8,RetSize,s,FALSE,TRUE,'0'); RETURN(RetSize # -2) END OctToStr; PROCEDURE StrToOct(VAR s:ARRAY OF CHAR;VAR w:WORD):BOOLEAN; VAR i : CARDINAL; c : CARDINAL; BEGIN i := 0; c := 0; WHILE ((i < HIGH(s)) AND ((s[i] = ' ') OR (s[i] = ' '))) DO INC(i) END; (* Assert at worst i = HIGH(s) *) REPEAT IF ((s[i] < '0') OR (s[i] > '7')) THEN RETURN(FALSE) ELSE c := c * 10 + ORD(s[i]) - ORD('0') END; INC(i) UNTIL ((i > HIGH(s)) OR (s[i] = 0C)); w := WORD(c); RETURN(TRUE) END StrToOct; END Conversions. !Funky!Stuff! echo x - Cursors.MOD cat >Cursors.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE Cursors; FROM SYSTEM IMPORT ADDRESS,WORD,CODE,ADR,REGISTER; FROM MacSYSTEM IMPORT LONGINT; FROM QuickDraw IMPORT Point,Rect,Bits16,Cursor; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) (* Cursor Routines *) PROCEDURE GetCursor(cursorID:INTEGER):CursHandle; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9B9H); CODE(RestoreA7); CODE(Return); END GetCursor; PROCEDURE xShieldCursor(shieldRect:Rect;offsetPt:LONGINT); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A855H); CODE(RestoreA7); CODE(Return); END xShieldCursor; PROCEDURE ShieldCursor(shieldRect:Rect;offsetPt:Point); (*$P+*)(*$S-*) BEGIN xShieldCursor(shieldRect,offsetPt.param) END ShieldCursor; PROCEDURE InitCursor; (*$P+*)(*$S-*) BEGIN CODE(0A850H); END InitCursor; PROCEDURE SetCursor(VAR crsr: Cursor); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A851H); CODE(RestoreA7);CODE(Return); END SetCursor; PROCEDURE HideCursor; (*$P+*)(*$S-*) BEGIN CODE(0A852H); END HideCursor; PROCEDURE ShowCursor; (*$P+*)(*$S-*) BEGIN CODE(0A853H); END ShowCursor; PROCEDURE ObscureCursor; (*$P+*)(*S-*) BEGIN CODE(0A856H); END ObscureCursor; END Cursors. !Funky!Stuff! echo x - DeskManager.MOD cat >DeskManager.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE DeskManager; FROM SYSTEM IMPORT ADDRESS,WORD,CODE,ADR,REGISTER; FROM MacSYSTEM IMPORT LONGINT; FROM EventManager IMPORT EventRecord; FROM WindowManager IMPORT WindowPtr; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) PROCEDURE xOpenDeskAcc(theAcc:ADDRESS):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9B6H); CODE(RestoreA7); CODE(Return); END xOpenDeskAcc; (* This is for the silly null in DeskAcc names *) PROCEDURE DeskAccString(VAR in,out:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR i:CARDINAL; BEGIN out[1] := in[0]; (* copy the null *) i := 1; REPEAT out[i + 1] := in[i]; INC(i); UNTIL ((i > HIGH(in)) OR (in[i] = 0C)); out[0] := CHR(i) END DeskAccString; PROCEDURE OpenDeskAcc(VAR theAcc:ARRAY OF CHAR):INTEGER; (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN DeskAccString(theAcc,Str); RETURN(xOpenDeskAcc(ADR(Str))) END OpenDeskAcc; PROCEDURE CloseDeskAcc(refNum:INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9B7H); CODE(RestoreA7); CODE(Return); END CloseDeskAcc; PROCEDURE SystemClick(VAR theEvent:EventRecord;theWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9B3H); CODE(RestoreA7); CODE(Return); END SystemClick; PROCEDURE SystemEdit(editCmd:INTEGER):BOOLEAN; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9C2H); CODE(RestoreA7); CODE(Return); END SystemEdit; PROCEDURE SystemTask; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9B4H); CODE(RestoreA7); CODE(Return); END SystemTask; PROCEDURE SystemEvent(VAR theEvent:EventRecord):BOOLEAN; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9B2H); CODE(RestoreA7); CODE(Return); END SystemEvent; PROCEDURE SystemMenu(menuResult:LONGINT); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9B5H); CODE(RestoreA7); CODE(Return); END SystemMenu; END DeskManager. !Funky!Stuff! echo x - DialogManager.MOD cat >DialogManager.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE DialogManager; FROM SYSTEM IMPORT ADDRESS,CODE,ADR,SETREG,REGISTER; FROM Storage IMPORT ALLOCATE,DEALLOCATE; FROM QuickDraw IMPORT Rect; FROM MacSYSTEM IMPORT Handle, LONGINT, Ptr,StringPtr; FROM WindowManager IMPORT WindowPtr; FROM TextEdit IMPORT TEHandle,TECut,TECopy,TEPaste,TEDelete; FROM EventManager IMPORT EventRecord; FROM PascalStrings IMPORT MakePascalString, MakeModulaString; CONST GetRet=0285FH; Return=04ED4H; SaveA7=0264FH; RestoreA7=02E4BH; (* Misc *) VAR Sound : SoundProc; VAR MyParamText: ARRAY [0..3] OF StringPtr; PROCEDURE SoundInterface; (*$P-*) BEGIN CODE(04E56H);CODE(0); (* LINK A6,#0 *) CODE(048E7H);CODE(01F38H); (* MOVEM.L D3-D7/A2-A4,-(A7) *) CODE(03F2EH);CODE(08H); (* MOVE.W 08(A6),-(A7) *) SETREG(8,Sound); CODE(04E90H); (* JSR (A0) *) CODE(05C8FH); (* ADDQ.L #6,A7 *) CODE(04CDFH);CODE(01CF8H); (* MOVEM.L (A7)+,D3-D7/A2-A4 *) CODE(04E5EH); (* UNLK A6 *) CODE(0205FH); (* MOVEA.L (A7)+,A0 *) CODE(05C8FH); (* ADDQ.L #6,A7 *) CODE(04ED0H); (* JMP (A0) *) END SoundInterface; PROCEDURE UseSoundProc(MySound: SoundProc):ADDRESS; (*$P+*)(*$S-*) BEGIN Sound := MySound; SETREG(8,SoundInterface); RETURN(REGISTER(8)) END UseSoundProc; (* initialization *) PROCEDURE InitDialogs (restartProc: ADDRESS); (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A97BH); CODE(RestoreA7); CODE(Return); END InitDialogs; PROCEDURE ErrorSound (MySound: ADDRESS); BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A98CH); CODE(RestoreA7); CODE(Return); END ErrorSound; PROCEDURE SetDAFont (fontNum: INTEGER); (*$P+*) BEGIN DlgFont := fontNum END SetDAFont; (* Creating and disposing OF dialogs *) PROCEDURE xNewDialog(dStorage:ADDRESS;VAR boundsRect:Rect; title:ADDRESS; visible: BOOLEAN; procID: INTEGER; behind: WindowPtr; goAwayFlag: BOOLEAN; refCon: LONGINT; items: Handle) : DialogPtr; (* $P- *) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A97DH); CODE(RestoreA7); CODE(Return); END xNewDialog; PROCEDURE NewDialog(dStorage: ADDRESS; boundsRect:Rect; VAR title:ARRAY OF CHAR; visible: BOOLEAN; procID: INTEGER; behind: WindowPtr; goAwayFlag: BOOLEAN; refCon: LONGINT; items: Handle) : DialogPtr; VAR s: ARRAY[0..255] OF CHAR; (*$P+*)(*$S-*) BEGIN MakePascalString(title,s); RETURN(xNewDialog(dStorage,boundsRect,ADR(s),visible,procID,behind, goAwayFlag,refCon,items)) END NewDialog; PROCEDURE GetNewDialog(dialogID:INTEGER;dStorage:ADDRESS; behind:WindowPtr):DialogPtr; (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A97CH); CODE(RestoreA7); CODE(Return) END GetNewDialog; PROCEDURE CloseDialog(theDialog: DialogPtr); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A982H); CODE(RestoreA7); CODE(Return) END CloseDialog; PROCEDURE DisposDialog(theDialog:DialogPtr); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A983H); CODE(RestoreA7); CODE(Return) END DisposDialog; PROCEDURE CouldDialog(dialogID: INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A979H); CODE(RestoreA7); CODE(Return); END CouldDialog; PROCEDURE FreeDialog(dialogID: INTEGER); (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A97AH); CODE(RestoreA7); CODE(Return); END FreeDialog; (* Handling Dialog events *) PROCEDURE NoFilterProc():ADDRESS; BEGIN RETURN(ADDRESS(0)) END NoFilterProc; VAR Filter:FilterProc; PROCEDURE FilterInterface; (*$P-*) BEGIN CODE(04E56H);CODE(0); (* LINK A6,#0 *) CODE(048E7H);CODE(01F38H); (* MOVEM.L D3-D7/A2-A4,-(A7) *) CODE(04267H); (* CLR.W -(A7) *) CODE(02F2EH);CODE(010H); (* MOVE.L 010(A6),-(A7) *) CODE(02F2EH);CODE(0CH); (* MOVE.L 0C(A6),-(A7) *) CODE(02F2EH);CODE(08H); (* MOVE.L 08(A6),-(A7) *) SETREG(8,Filter); CODE(04E90H); (* JSR (A0) *) CODE(04FEFH);CODE(000CH); (* LEA A7,000C(A7) *) CODE(03D5FH);CODE(014H); (* MOVE.L (A7)+,14(A6) *) CODE(04CDFH);CODE(01CF8H); (* MOVEM.L (A7)+,D3-D7/A2-A4 *) CODE(04E5EH); (* UNLK A6 *) CODE(0205FH); (* MOVEA.L (A7)+,A0 *) CODE(04FEFH);CODE(000CH); (* LEA A7,000C(A7) *) CODE(04ED0H); (* JMP (A0) *) END FilterInterface; PROCEDURE UseFilterProc(myFilter:FilterProc):ADDRESS; (*$P+*)(*$S-*) BEGIN Filter := myFilter; SETREG(8,FilterInterface); RETURN(REGISTER(8)) END UseFilterProc; PROCEDURE ModalDialog(myFilter:ADDRESS; VAR itemHit: INTEGER); (* $P- *) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A991H); CODE(RestoreA7); CODE(Return); END ModalDialog; PROCEDURE IsDialogEvent(VAR theEvent: EventRecord) : BOOLEAN; (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A97FH); CODE(RestoreA7); CODE(Return); END IsDialogEvent; PROCEDURE DialogSelect(VAR theEvent: EventRecord; VAR theDialog: DialogPtr; VAR itemHit: INTEGER) : BOOLEAN; (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A980H); CODE(RestoreA7); CODE(Return); END DialogSelect; PROCEDURE DlgCut(theDialog: DialogPtr); (*$P+*) VAR d : DialogPeek; BEGIN d := DialogPeek(theDialog); IF (d^.editField >= 0) THEN TECut(d^.textH) END END DlgCut; PROCEDURE DlgCopy(theDialog: DialogPtr); VAR d : DialogPeek; BEGIN d := DialogPeek(theDialog); IF (d^.editField >= 0) THEN TECopy(d^.textH) END END DlgCopy; PROCEDURE DlgPaste(theDialog: DialogPtr); VAR d : DialogPeek; BEGIN d := DialogPeek(theDialog); IF (d^.editField >= 0) THEN TEPaste(d^.textH) END END DlgPaste; PROCEDURE DlgDelete(theDialog: DialogPtr); VAR d : DialogPeek; BEGIN d := DialogPeek(theDialog); IF (d^.editField >= 0) THEN TEDelete(d^.textH) END END DlgDelete; PROCEDURE DrawDialog (theDialog: DialogPtr); (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A981H); CODE(RestoreA7); CODE(Return); END DrawDialog; (* invoking alerts *) PROCEDURE Alert(alertID: INTEGER; myFilter:ADDRESS): INTEGER; (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A985H); CODE(RestoreA7); CODE(Return); END Alert; PROCEDURE StopAlert(alertID: INTEGER; myFilter:ADDRESS): INTEGER; (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A986H); CODE(RestoreA7); CODE(Return); END StopAlert; PROCEDURE NoteAlert(alertID: INTEGER; myFilter:ADDRESS): INTEGER; (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A987H); CODE(RestoreA7); CODE(Return); END NoteAlert; PROCEDURE CautionAlert(alertID: INTEGER; myFilter:ADDRESS): INTEGER; (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A988H); CODE(RestoreA7); CODE(Return); END CautionAlert; PROCEDURE CouldAlert(alertID: INTEGER); (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A989H); CODE(RestoreA7); CODE(Return); END CouldAlert; PROCEDURE FreeAlert(alertID: INTEGER); (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A98AH); CODE(RestoreA7); CODE(Return); END FreeAlert; (* manipulation items in dialog and alerts *) PROCEDURE ParamText(VAR param0,param1,param2,param3: ARRAY OF CHAR); (*$P+*)(*$S-*) BEGIN IF (MyParamText[0] # NIL) THEN DEALLOCATE(MyParamText[0],255) END; ALLOCATE(MyParamText[0],HIGH(param0)+2); MakePascalString(param0,MyParamText[0]^); IF (MyParamText[1] # NIL) THEN DEALLOCATE(MyParamText[1],255) END; ALLOCATE(MyParamText[1],HIGH(param1)+2); MakePascalString(param1,MyParamText[1]^); IF (MyParamText[2] # NIL) THEN DEALLOCATE(MyParamText[2],255) END; ALLOCATE(MyParamText[2],HIGH(param2)+2); MakePascalString(param2,MyParamText[2]^); IF (MyParamText[3] # NIL) THEN DEALLOCATE(MyParamText[3],255) END; ALLOCATE(MyParamText[3],HIGH(param3)+2); MakePascalString(param3,MyParamText[3]^); DAStrings[0] := ADDRESS(MyParamText[0]); DAStrings[1] := ADDRESS(MyParamText[1]); DAStrings[2] := ADDRESS(MyParamText[2]); DAStrings[3] := ADDRESS(MyParamText[3]); END ParamText; PROCEDURE GetDItem(theDialog: DialogPtr; itemNo: INTEGER; VAR type: INTEGER; VAR item: Handle; VAR box: Rect); (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A98DH); CODE(RestoreA7); CODE(Return); END GetDItem; PROCEDURE SetDItem (theDialog: DialogPtr; itemNo: INTEGER; type: INTEGER; item: Handle; VAR box: Rect); (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A98EH); CODE(RestoreA7); CODE(Return); END SetDItem; PROCEDURE xGetIText(item: Handle; text: ADDRESS); (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A990H); CODE(RestoreA7); CODE(Return); END xGetIText; PROCEDURE GetIText(item: Handle; VAR text: ARRAY OF CHAR); VAR s: ARRAY [0..255] OF CHAR; BEGIN xGetIText(item,ADR(s)); MakeModulaString(s,text); END GetIText; PROCEDURE xSetIText(item: Handle; text: ADDRESS); (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A98FH); CODE(RestoreA7); CODE(Return); END xSetIText; PROCEDURE SetIText(item: Handle; VAR text: ARRAY OF CHAR); VAR s: ARRAY [0..255] OF CHAR; BEGIN MakePascalString(text,s); xSetIText(item,ADR(s)); END SetIText; PROCEDURE SelIText(theDialog: DialogPtr; itemNo: INTEGER; strtSel,endSel: INTEGER); (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A97EH); CODE(RestoreA7); CODE(Return); END SelIText; PROCEDURE GetAlrtStage(): INTEGER; (*$P+*) BEGIN RETURN(ACount) END GetAlrtStage; PROCEDURE ResetAlrtStage; (*$P+*) BEGIN ACount := -1 END ResetAlrtStage; BEGIN MyParamText[0] := NIL; MyParamText[1] := NIL; MyParamText[2] := NIL; MyParamText[3] := NIL; InitDialogs(ADDRESS(0)); END DialogManager. !Funky!Stuff! # The rest of this file is a shell script which will extract: # BDPackage.MOD ControlManager.MOD Conversions.MOD Cursors.MOD DeskManager.MOD DialogManager.MOD echo x - BDPackage.MOD cat >BDPackage.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE BDPackage; FROM SYSTEM IMPORT ADDRESS,CODE,ADR,REGISTER,SETREG; FROM MacSYSTEM IMPORT LONGINT; FROM PascalStrings IMPORT MakeModulaString,MakePascalString; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) Push = 03F3CH; (* MOVE #VAL,-(A7) *) Pack7 = 0A9EEH; pNumToString= 0; pStringToNum= 1; PROCEDURE xStringToNum(theString:ADDRESS;VAR theNum:LONGINT); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(pStringToNum); CODE(Pack7); CODE(RestoreA7); CODE(Return); END xStringToNum; PROCEDURE NumToString(theNum:LONGINT;VAR theString:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN SETREG(0,theNum); SETREG(8,ADR(Str)); CODE(Push); CODE(pNumToString); CODE(Pack7); MakeModulaString(Str,theString) END NumToString; PROCEDURE StringToNum(VAR theString:ARRAY OF CHAR;VAR theNum:LONGINT); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(theString,Str); SETREG(8,ADR(Str)); CODE(Push); CODE(pStringToNum); CODE(Pack7); theNum := REGISTER(0) END StringToNum END BDPackage. !Funky!Stuff! echo x - ControlManager.MOD cat >ControlManager.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE ControlManager; FROM SYSTEM IMPORT ADDRESS,CODE,ADR,SETREG,REGISTER; FROM MacSYSTEM IMPORT LONGINT,Handle; FROM QuickDraw IMPORT Point,Rect; FROM WindowManager IMPORT WindowPtr; FROM PascalStrings IMPORT MakePascalString,MakeModulaString; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP (A4) *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) (* Init and Alloc *) PROCEDURE xNewControl(Wind:WindowPtr;VAR bounds:Rect;title:ADDRESS; visible:BOOLEAN;value:INTEGER;min,max:INTEGER;procID:INTEGER; refCon:LONGINT): ControlHandle; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A954H); CODE(RestoreA7); CODE(Return); END xNewControl; PROCEDURE NewControl(Wind:WindowPtr;bounds:Rect;VAR title:ARRAY OF CHAR; visible:BOOLEAN;value:INTEGER;min,max:INTEGER;procID:INTEGER; refCon:LONGINT): ControlHandle; (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(title,Str); RETURN(xNewControl(Wind,bounds,ADR(Str),visible,value,min,max,procID,refCon)) END NewControl; PROCEDURE GetNewControl (controlID:INTEGER;wind:WindowPtr):ControlHandle; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9BEH); CODE(RestoreA7); CODE(Return); END GetNewControl; PROCEDURE DisposeControl (theControl:ControlHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A955H); CODE(RestoreA7); CODE(Return); END DisposeControl; PROCEDURE KillControls (wind:WindowPtr); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A956H); CODE(RestoreA7); CODE(Return); END KillControls; (* Control Display *) PROCEDURE xSetCTitle (theControl:ControlHandle;title:ADDRESS); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A95FH); CODE(RestoreA7); CODE(Return); END xSetCTitle; PROCEDURE SetCTitle (theControl:ControlHandle;VAR title:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(title,Str); xSetCTitle(theControl,ADR(Str)) END SetCTitle; PROCEDURE xGetCTitle (theControl:ControlHandle;title:ADDRESS); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A95EH); CODE(RestoreA7); CODE(Return); END xGetCTitle; PROCEDURE GetCTitle (theControl:ControlHandle;VAR title:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN xGetCTitle(theControl,ADR(Str)); MakeModulaString(Str,title) END GetCTitle; PROCEDURE HideControl (theControl:ControlHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A958H); CODE(RestoreA7); CODE(Return); END HideControl; PROCEDURE ShowControl (theControl:ControlHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A957H); CODE(RestoreA7); CODE(Return); END ShowControl; PROCEDURE DrawControls (theWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A969H); CODE(RestoreA7); CODE(Return); END DrawControls; PROCEDURE HiliteControl (theControl:ControlHandle;hiliteState:INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A95DH); CODE(RestoreA7); CODE(Return); END HiliteControl; (* Mouse Location *) PROCEDURE xTestControl(theControl:ControlHandle;thePoint:LONGINT):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A966H); CODE(RestoreA7); CODE(Return); END xTestControl; PROCEDURE TestControl (theControl: ControlHandle;thePoint:Point):INTEGER; (*$P+*)(*$S-*) BEGIN RETURN(xTestControl(theControl,thePoint.param)) END TestControl; PROCEDURE xFindControl(thePoint:LONGINT;theWindow:WindowPtr; VAR whichControl:ControlHandle):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A96CH); CODE(RestoreA7); CODE(Return); END xFindControl; PROCEDURE FindControl(thePoint:Point;theWindow:WindowPtr; VAR whichControl:ControlHandle):INTEGER; (*$P+*)(*$S-*) BEGIN RETURN(xFindControl(thePoint.param,theWindow,whichControl)) END FindControl; PROCEDURE xTrackControl(theControl:ControlHandle;startPt:LONGINT; actionProc: ADDRESS):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A968H); CODE(RestoreA7); CODE(Return); END xTrackControl; PROCEDURE TrackControl (theControl: ControlHandle; startPt:Point; actionProc: ADDRESS):INTEGER; (*$P+*)(*$S-*) BEGIN RETURN(xTrackControl(theControl,startPt.param,actionProc)) END TrackControl; VAR ProcA:PROC; PROCEDURE ProcAInterface; (*$P-*) BEGIN CODE(04E56H);CODE(0); (* LINK A6,#0 *) CODE(048E7H);CODE(0FFFCH); (* MOVEM.L D0-D7/A0-A5,-(A7)*) SETREG(8,ProcA); CODE(04E90H); (* JSR (A0) *) CODE(04CDFH);CODE(03FFFH); (* MOVEM.L (A7)+,D0-D7/A0-A5*) CODE(04E5EH); (* UNLK A6 *) CODE(04E75H); (* RTS *) END ProcAInterface; PROCEDURE TrackProcA(p:PROC):ADDRESS; (*$P+*)(*$S-*) BEGIN ProcA := p; SETREG(8,ProcAInterface); RETURN(REGISTER(8)) END TrackProcA; VAR ProcB:PROCHI; PROCEDURE ProcBInterface; (*$P-*) BEGIN CODE(04E56H);CODE(0); (* LINK A6,#0 *) CODE(048E7H);CODE(0FFFCH); (* MOVEM.L D0-D7/A0-A5,-(A7) *) CODE(02F2EH);CODE(0AH); (* MOVE.L 0A(A6),-(A7) *) CODE(03F2EH);CODE(08H); (* MOVE.W 08(A6),-(A7) *) SETREG(8,ProcB); CODE(04E90H); (* JSR (A6) *) CODE(05C8FH); (* ADDQ.L #6,A7 *) CODE(04CDFH);CODE(03FFFH); (* MOVEM.L (A7)+,D0-D7/A0-A4 *) CODE(04E5EH); (* UNLK A6 *) CODE(02F5FH);CODE(2H); (* MOVE.L (A7)+,2(A7) *) CODE(0548FH); (* ADDQ.L #2,A7 *) CODE(04E75H); (* RTS *) END ProcBInterface; PROCEDURE TrackProcB(p:PROCHI):ADDRESS; (*$P+*)(*$S-*) BEGIN ProcB := p; SETREG(8,ProcBInterface); RETURN(REGISTER(8)) END TrackProcB; (* Control Movement and Sizing *) PROCEDURE MoveControl (theControl: ControlHandle; h,v: INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A959H); CODE(RestoreA7); CODE(Return); END MoveControl; PROCEDURE xDragControl (theControl: ControlHandle; startPt:LONGINT; VAR limitRect,slopRect: Rect; axis: INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A967H); CODE(RestoreA7); CODE(Return); END xDragControl; PROCEDURE DragControl (theControl: ControlHandle; startPt:Point; limitRect,slopRect: Rect; axis: INTEGER); (*$P+*)(*$S-*) BEGIN xDragControl(theControl,startPt.param,limitRect,slopRect,axis) END DragControl; PROCEDURE SizeControl (theControl: ControlHandle; w,h: INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A95CH); CODE(RestoreA7); CODE(Return); END SizeControl; (* Control Setting and Range *) PROCEDURE SetCtlValue (theControl: ControlHandle; theValue: INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A963H); CODE(RestoreA7); CODE(Return); END SetCtlValue; PROCEDURE GetCtlValue (theControl: ControlHandle):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A960H); CODE(RestoreA7); CODE(Return); END GetCtlValue; PROCEDURE SetCtlMin (theControl: ControlHandle;minValue:INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A964H); CODE(RestoreA7); CODE(Return); END SetCtlMin; PROCEDURE GetCtlMin (theControl: ControlHandle):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A961H); CODE(RestoreA7); CODE(Return); END GetCtlMin; PROCEDURE SetCtlMax (theControl: ControlHandle; maxValue:INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A965H); CODE(RestoreA7); CODE(Return); END SetCtlMax; PROCEDURE GetCtlMax (theControl: ControlHandle):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A962H); CODE(RestoreA7); CODE(Return); END GetCtlMax; (* Miscellaneous Utilities *) PROCEDURE SetCRefCon (theControl: ControlHandle; data: LONGINT); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A95BH); CODE(RestoreA7); CODE(Return); END SetCRefCon; PROCEDURE GetCRefCon (theControl: ControlHandle):LONGINT; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A95AH); CODE(RestoreA7); CODE(Return); END GetCRefCon; PROCEDURE SetCtlAction (theControl: ControlHandle;actionProc:ADDRESS); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A96BH); CODE(RestoreA7); CODE(Return); END SetCtlAction; PROCEDURE GetCtlAction (theControl: ControlHandle):ADDRESS; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A96BH); CODE(RestoreA7); CODE(Return); END GetCtlAction; END ControlManager. !Funky!Stuff! echo x - Conversions.MOD cat >Conversions.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE Conversions; FROM SYSTEM IMPORT WORD; PROCEDURE PAD(VAR s:ARRAY OF CHAR;size:INTEGER;c:CHAR); VAR i :CARDINAL; BEGIN IF (size >= 0) THEN FOR i := 0 TO size DO s[i] := c END END END PAD; PROCEDURE NtoS(x,base: CARDINAL; size:INTEGER; VAR str:ARRAY OF CHAR;sign,first:BOOLEAN;pad:CHAR):INTEGER; VAR RetSize : INTEGER; High : INTEGER; BEGIN High := VAL(INTEGER,HIGH(str)); IF (x = 0) THEN IF (first) THEN IF (size > High) THEN size := High END; IF (sign) THEN PAD(str,size - 2,pad); IF (size = 0) THEN size := 1; END; str[size - 1] := '-'; ELSE PAD(str,size - 1,pad); END; str[size] := '0'; ELSE IF (sign) THEN IF (size < 0) THEN PAD(str,High,'*'); RETURN(-2) END; PAD(str,size - 1,pad); str[size] := '-' ELSE PAD(str,size,pad); END; END; (*IF*) IF (first AND (size # High)) THEN str[size + 1] := 0C END; RETURN(size) ELSE (* x is not 0 *) IF (size < 0) THEN size := 0 END; RetSize := NtoS(x DIV base,base,size - 1,str,sign,FALSE,pad); IF (RetSize = -2) THEN RETURN(RetSize) END; IF size <= RetSize THEN size := RetSize + 1; END; IF (size > High) THEN PAD(str,High,'*'); RETURN(-2); ELSE str[size] := CHR(ORD('0') + x MOD base); IF str[size] > '9' THEN str[size] := CHR(ORD(str[size]) - ORD('0') + ORD('A') - 10) END; IF (first AND (size # High)) THEN str[size + 1] := 0C END; RETURN(size) END END END NtoS; PROCEDURE IntToStr(i : INTEGER;VAR s : ARRAY OF CHAR; p : CARDINAL):BOOLEAN; VAR RetSize : INTEGER; BEGIN IF (p = 0) THEN RetSize := 0 ELSE RetSize := VAL(INTEGER,p) - 1; END; RetSize := NtoS(ABS(i),10,RetSize,s,(i < 0),TRUE,' '); RETURN(RetSize # -2) END IntToStr; PROCEDURE StrToInt(VAR s : ARRAY OF CHAR; VAR x : INTEGER):BOOLEAN; VAR i : CARDINAL; neg : BOOLEAN; BEGIN i := 0; x := 0; WHILE ((i < HIGH(s)) AND ((s[i] = ' ') OR (s[i] = ' '))) DO INC(i) END; (* Assert at worst i = HIGH(s) *) IF (s[i] = '-') THEN neg := TRUE; INC(i); IF (i > HIGH(s)) THEN RETURN(FALSE) END END; REPEAT IF ((s[i] < '0') OR (s[i] > '9')) THEN RETURN(FALSE) ELSE x := x * 10 + INTEGER(ORD(s[i])) - INTEGER(ORD('0')) END; INC(i) UNTIL ((i > HIGH(s)) OR (s[i] = 0C)); IF neg THEN x := -x; END; RETURN(TRUE) END StrToInt; PROCEDURE CardToStr(c : CARDINAL; VAR s : ARRAY OF CHAR; p : CARDINAL):BOOLEAN; VAR RetSize : INTEGER; BEGIN IF (p = 0) THEN RetSize := 0 ELSE RetSize := VAL(INTEGER,p) - 1; END; RetSize := NtoS(c,10,RetSize,s,FALSE,TRUE,' '); RETURN(RetSize # -2) END CardToStr; PROCEDURE StrToCard(VAR s:ARRAY OF CHAR; VAR c:CARDINAL):BOOLEAN; VAR i : CARDINAL; BEGIN i := 0; c := 0; WHILE ((i < HIGH(s)) AND ((s[i] = ' ') OR (s[i] = ' '))) DO INC(i) END; (* Assert at worst i = HIGH(s) *) REPEAT IF ((s[i] < '0') OR (s[i] > '9')) THEN RETURN(FALSE) ELSE c := c * 10 + ORD(s[i]) - ORD('0') END; INC(i) UNTIL ((i > HIGH(s)) OR (s[i] = 0C)); RETURN(TRUE) END StrToCard; PROCEDURE HexToStr(w:WORD;VAR s:ARRAY OF CHAR; p : CARDINAL):BOOLEAN; VAR RetSize : INTEGER; BEGIN IF (p = 0) THEN RetSize := 0 ELSE RetSize := VAL(INTEGER,p) - 1; END; RetSize := NtoS(CARDINAL(w),16,RetSize,s,FALSE,TRUE,'0'); RETURN(RetSize # -2) END HexToStr; PROCEDURE StrToHex(VAR s:ARRAY OF CHAR;VAR w:WORD):BOOLEAN; VAR i : CARDINAL; c : CARDINAL; BEGIN i := 0; c := 0; WHILE ((i < HIGH(s)) AND ((s[i] = ' ') OR (s[i] = ' '))) DO INC(i) END; (* Assert at worst i = HIGH(s) *) REPEAT IF ((s[i] < '0') OR (s[i] > '9')) THEN IF ((s[i] >= 'A') AND (s[i] <= 'F')) THEN c := c * 10 + ORD(s[i]) - ORD('A') + 10 ELSE RETURN(FALSE) END ELSE c := c * 10 + ORD(s[i]) - ORD('0') END; INC(i) UNTIL ((i > HIGH(s)) OR (s[i] = 0C)); w := WORD(c); RETURN(TRUE) END StrToHex; PROCEDURE OctToStr(w:WORD;VAR s:ARRAY OF CHAR; p : CARDINAL):BOOLEAN; VAR RetSize : INTEGER; BEGIN IF (p = 0) THEN RetSize := 0 ELSE RetSize := VAL(INTEGER,p) - 1; END; RetSize := NtoS(CARDINAL(w),8,RetSize,s,FALSE,TRUE,'0'); RETURN(RetSize # -2) END OctToStr; PROCEDURE StrToOct(VAR s:ARRAY OF CHAR;VAR w:WORD):BOOLEAN; VAR i : CARDINAL; c : CARDINAL; BEGIN i := 0; c := 0; WHILE ((i < HIGH(s)) AND ((s[i] = ' ') OR (s[i] = ' '))) DO INC(i) END; (* Assert at worst i = HIGH(s) *) REPEAT IF ((s[i] < '0') OR (s[i] > '7')) THEN RETURN(FALSE) ELSE c := c * 10 + ORD(s[i]) - ORD('0') END; INC(i) UNTIL ((i > HIGH(s)) OR (s[i] = 0C)); w := WORD(c); RETURN(TRUE) END StrToOct; END Conversions. !Funky!Stuff! echo x - Cursors.MOD cat >Cursors.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE Cursors; FROM SYSTEM IMPORT ADDRESS,WORD,CODE,ADR,REGISTER; FROM MacSYSTEM IMPORT LONGINT; FROM QuickDraw IMPORT Point,Rect,Bits16,Cursor; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) (* Cursor Routines *) PROCEDURE GetCursor(cursorID:INTEGER):CursHandle; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9B9H); CODE(RestoreA7); CODE(Return); END GetCursor; PROCEDURE xShieldCursor(shieldRect:Rect;offsetPt:LONGINT); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A855H); CODE(RestoreA7); CODE(Return); END xShieldCursor; PROCEDURE ShieldCursor(shieldRect:Rect;offsetPt:Point); (*$P+*)(*$S-*) BEGIN xShieldCursor(shieldRect,offsetPt.param) END ShieldCursor; PROCEDURE InitCursor; (*$P+*)(*$S-*) BEGIN CODE(0A850H); END InitCursor; PROCEDURE SetCursor(VAR crsr: Cursor); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A851H); CODE(RestoreA7);CODE(Return); END SetCursor; PROCEDURE HideCursor; (*$P+*)(*$S-*) BEGIN CODE(0A852H); END HideCursor; PROCEDURE ShowCursor; (*$P+*)(*$S-*) BEGIN CODE(0A853H); END ShowCursor; PROCEDURE ObscureCursor; (*$P+*)(*S-*) BEGIN CODE(0A856H); END ObscureCursor; END Cursors. !Funky!Stuff! echo x - DeskManager.MOD cat >DeskManager.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE DeskManager; FROM SYSTEM IMPORT ADDRESS,WORD,CODE,ADR,REGISTER; FROM MacSYSTEM IMPORT LONGINT; FROM EventManager IMPORT EventRecord; FROM WindowManager IMPORT WindowPtr; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) PROCEDURE xOpenDeskAcc(theAcc:ADDRESS):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9B6H); CODE(RestoreA7); CODE(Return); END xOpenDeskAcc; (* This is for the silly null in DeskAcc names *) PROCEDURE DeskAccString(VAR in,out:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR i:CARDINAL; BEGIN out[1] := in[0]; (* copy the null *) i := 1; REPEAT out[i + 1] := in[i]; INC(i); UNTIL ((i > HIGH(in)) OR (in[i] = 0C)); out[0] := CHR(i) END DeskAccString; PROCEDURE OpenDeskAcc(VAR theAcc:ARRAY OF CHAR):INTEGER; (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN DeskAccString(theAcc,Str); RETURN(xOpenDeskAcc(ADR(Str))) END OpenDeskAcc; PROCEDURE CloseDeskAcc(refNum:INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9B7H); CODE(RestoreA7); CODE(Return); END CloseDeskAcc; PROCEDURE SystemClick(VAR theEvent:EventRecord;theWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9B3H); CODE(RestoreA7); CODE(Return); END SystemClick; PROCEDURE SystemEdit(editCmd:INTEGER):BOOLEAN; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9C2H); CODE(RestoreA7); CODE(Return); END SystemEdit; PROCEDURE SystemTask; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9B4H); CODE(RestoreA7); CODE(Return); END SystemTask; PROCEDURE SystemEvent(VAR theEvent:EventRecord):BOOLEAN; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9B2H); CODE(RestoreA7); CODE(Return); END SystemEvent; PROCEDURE SystemMenu(menuResult:LONGINT); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9B5H); CODE(RestoreA7); CODE(Return); END SystemMenu; END DeskManager. !Funky!Stuff! echo x - DialogManager.MOD cat >DialogManager.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE DialogManager; FROM SYSTEM IMPORT ADDRESS,CODE,ADR,SETREG,REGISTER; FROM Storage IMPORT ALLOCATE,DEALLOCATE; FROM QuickDraw IMPORT Rect; FROM MacSYSTEM IMPORT Handle, LONGINT, Ptr,StringPtr; FROM WindowManager IMPORT WindowPtr; FROM TextEdit IMPORT TEHandle,TECut,TECopy,TEPaste,TEDelete; FROM EventManager IMPORT EventRecord; FROM PascalStrings IMPORT MakePascalString, MakeModulaString; CONST GetRet=0285FH; Return=04ED4H; SaveA7=0264FH; RestoreA7=02E4BH; (* Misc *) VAR Sound : SoundProc; VAR MyParamText: ARRAY [0..3] OF StringPtr; PROCEDURE SoundInterface; (*$P-*) BEGIN CODE(04E56H);CODE(0); (* LINK A6,#0 *) CODE(048E7H);CODE(01F38H); (* MOVEM.L D3-D7/A2-A4,-(A7) *) CODE(03F2EH);CODE(08H); (* MOVE.W 08(A6),-(A7) *) SETREG(8,Sound); CODE(04E90H); (* JSR (A0) *) CODE(05C8FH); (* ADDQ.L #6,A7 *) CODE(04CDFH);CODE(01CF8H); (* MOVEM.L (A7)+,D3-D7/A2-A4 *) CODE(04E5EH); (* UNLK A6 *) CODE(0205FH); (* MOVEA.L (A7)+,A0 *) CODE(05C8FH); (* ADDQ.L #6,A7 *) CODE(04ED0H); (* JMP (A0) *) END SoundInterface; PROCEDURE UseSoundProc(MySound: SoundProc):ADDRESS; (*$P+*)(*$S-*) BEGIN Sound := MySound; SETREG(8,SoundInterface); RETURN(REGISTER(8)) END UseSoundProc; (* initialization *) PROCEDURE InitDialogs (restartProc: ADDRESS); (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A97BH); CODE(RestoreA7); CODE(Return); END InitDialogs; PROCEDURE ErrorSound (MySound: ADDRESS); BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A98CH); CODE(RestoreA7); CODE(Return); END ErrorSound; PROCEDURE SetDAFont (fontNum: INTEGER); (*$P+*) BEGIN DlgFont := fontNum END SetDAFont; (* Creating and disposing OF dialogs *) PROCEDURE xNewDialog(dStorage:ADDRESS;VAR boundsRect:Rect; title:ADDRESS; visible: BOOLEAN; procID: INTEGER; behind: WindowPtr; goAwayFlag: BOOLEAN; refCon: LONGINT; items: Handle) : DialogPtr; (* $P- *) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A97DH); CODE(RestoreA7); CODE(Return); END xNewDialog; PROCEDURE NewDialog(dStorage: ADDRESS; boundsRect:Rect; VAR title:ARRAY OF CHAR; visible: BOOLEAN; procID: INTEGER; behind: WindowPtr; goAwayFlag: BOOLEAN; refCon: LONGINT; items: Handle) : DialogPtr; VAR s: ARRAY[0..255] OF CHAR; (*$P+*)(*$S-*) BEGIN MakePascalString(title,s); RETURN(xNewDialog(dStorage,boundsRect,ADR(s),visible,procID,behind, goAwayFlag,refCon,items)) END NewDialog; PROCEDURE GetNewDialog(dialogID:INTEGER;dStorage:ADDRESS; behind:WindowPtr):DialogPtr; (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A97CH); CODE(RestoreA7); CODE(Return) END GetNewDialog; PROCEDURE CloseDialog(theDialog: DialogPtr); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A982H); CODE(RestoreA7); CODE(Return) END CloseDialog; PROCEDURE DisposDialog(theDialog:DialogPtr); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A983H); CODE(RestoreA7); CODE(Return) END DisposDialog; PROCEDURE CouldDialog(dialogID: INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A979H); CODE(RestoreA7); CODE(Return); END CouldDialog; PROCEDURE FreeDialog(dialogID: INTEGER); (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A97AH); CODE(RestoreA7); CODE(Return); END FreeDialog; (* Handling Dialog events *) PROCEDURE NoFilterProc():ADDRESS; BEGIN RETURN(ADDRESS(0)) END NoFilterProc; VAR Filter:FilterProc; PROCEDURE FilterInterface; (*$P-*) BEGIN CODE(04E56H);CODE(0); (* LINK A6,#0 *) CODE(048E7H);CODE(01F38H); (* MOVEM.L D3-D7/A2-A4,-(A7) *) CODE(04267H); (* CLR.W -(A7) *) CODE(02F2EH);CODE(010H); (* MOVE.L 010(A6),-(A7) *) CODE(02F2EH);CODE(0CH); (* MOVE.L 0C(A6),-(A7) *) CODE(02F2EH);CODE(08H); (* MOVE.L 08(A6),-(A7) *) SETREG(8,Filter); CODE(04E90H); (* JSR (A0) *) CODE(04FEFH);CODE(000CH); (* LEA A7,000C(A7) *) CODE(03D5FH);CODE(014H); (* MOVE.L (A7)+,14(A6) *) CODE(04CDFH);CODE(01CF8H); (* MOVEM.L (A7)+,D3-D7/A2-A4 *) CODE(04E5EH); (* UNLK A6 *) CODE(0205FH); (* MOVEA.L (A7)+,A0 *) CODE(04FEFH);CODE(000CH); (* LEA A7,000C(A7) *) CODE(04ED0H); (* JMP (A0) *) END FilterInterface; PROCEDURE UseFilterProc(myFilter:FilterProc):ADDRESS; (*$P+*)(*$S-*) BEGIN Filter := myFilter; SETREG(8,FilterInterface); RETURN(REGISTER(8)) END UseFilterProc; PROCEDURE ModalDialog(myFilter:ADDRESS; VAR itemHit: INTEGER); (* $P- *) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A991H); CODE(RestoreA7); CODE(Return); END ModalDialog; PROCEDURE IsDialogEvent(VAR theEvent: EventRecord) : BOOLEAN; (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A97FH); CODE(RestoreA7); CODE(Return); END IsDialogEvent; PROCEDURE DialogSelect(VAR theEvent: EventRecord; VAR theDialog: DialogPtr; VAR itemHit: INTEGER) : BOOLEAN; (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A980H); CODE(RestoreA7); CODE(Return); END DialogSelect; PROCEDURE DlgCut(theDialog: DialogPtr); (*$P+*) VAR d : DialogPeek; BEGIN d := DialogPeek(theDialog); IF (d^.editField >= 0) THEN TECut(d^.textH) END END DlgCut; PROCEDURE DlgCopy(theDialog: DialogPtr); VAR d : DialogPeek; BEGIN d := DialogPeek(theDialog); IF (d^.editField >= 0) THEN TECopy(d^.textH) END END DlgCopy; PROCEDURE DlgPaste(theDialog: DialogPtr); VAR d : DialogPeek; BEGIN d := DialogPeek(theDialog); IF (d^.editField >= 0) THEN TEPaste(d^.textH) END END DlgPaste; PROCEDURE DlgDelete(theDialog: DialogPtr); VAR d : DialogPeek; BEGIN d := DialogPeek(theDialog); IF (d^.editField >= 0) THEN TEDelete(d^.textH) END END DlgDelete; PROCEDURE DrawDialog (theDialog: DialogPtr); (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A981H); CODE(RestoreA7); CODE(Return); END DrawDialog; (* invoking alerts *) PROCEDURE Alert(alertID: INTEGER; myFilter:ADDRESS): INTEGER; (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A985H); CODE(RestoreA7); CODE(Return); END Alert; PROCEDURE StopAlert(alertID: INTEGER; myFilter:ADDRESS): INTEGER; (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A986H); CODE(RestoreA7); CODE(Return); END StopAlert; PROCEDURE NoteAlert(alertID: INTEGER; myFilter:ADDRESS): INTEGER; (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A987H); CODE(RestoreA7); CODE(Return); END NoteAlert; PROCEDURE CautionAlert(alertID: INTEGER; myFilter:ADDRESS): INTEGER; (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A988H); CODE(RestoreA7); CODE(Return); END CautionAlert; PROCEDURE CouldAlert(alertID: INTEGER); (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A989H); CODE(RestoreA7); CODE(Return); END CouldAlert; PROCEDURE FreeAlert(alertID: INTEGER); (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A98AH); CODE(RestoreA7); CODE(Return); END FreeAlert; (* manipulation items in dialog and alerts *) PROCEDURE ParamText(VAR param0,param1,param2,param3: ARRAY OF CHAR); (*$P+*)(*$S-*) BEGIN IF (MyParamText[0] # NIL) THEN DEALLOCATE(MyParamText[0],255) END; ALLOCATE(MyParamText[0],HIGH(param0)+2); MakePascalString(param0,MyParamText[0]^); IF (MyParamText[1] # NIL) THEN DEALLOCATE(MyParamText[1],255) END; ALLOCATE(MyParamText[1],HIGH(param1)+2); MakePascalString(param1,MyParamText[1]^); IF (MyParamText[2] # NIL) THEN DEALLOCATE(MyParamText[2],255) END; ALLOCATE(MyParamText[2],HIGH(param2)+2); MakePascalString(param2,MyParamText[2]^); IF (MyParamText[3] # NIL) THEN DEALLOCATE(MyParamText[3],255) END; ALLOCATE(MyParamText[3],HIGH(param3)+2); MakePascalString(param3,MyParamText[3]^); DAStrings[0] := ADDRESS(MyParamText[0]); DAStrings[1] := ADDRESS(MyParamText[1]); DAStrings[2] := ADDRESS(MyParamText[2]); DAStrings[3] := ADDRESS(MyParamText[3]); END ParamText; PROCEDURE GetDItem(theDialog: DialogPtr; itemNo: INTEGER; VAR type: INTEGER; VAR item: Handle; VAR box: Rect); (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A98DH); CODE(RestoreA7); CODE(Return); END GetDItem; PROCEDURE SetDItem (theDialog: DialogPtr; itemNo: INTEGER; type: INTEGER; item: Handle; VAR box: Rect); (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A98EH); CODE(RestoreA7); CODE(Return); END SetDItem; PROCEDURE xGetIText(item: Handle; text: ADDRESS); (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A990H); CODE(RestoreA7); CODE(Return); END xGetIText; PROCEDURE GetIText(item: Handle; VAR text: ARRAY OF CHAR); VAR s: ARRAY [0..255] OF CHAR; BEGIN xGetIText(item,ADR(s)); MakeModulaString(s,text); END GetIText; PROCEDURE xSetIText(item: Handle; text: ADDRESS); (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A98FH); CODE(RestoreA7); CODE(Return); END xSetIText; PROCEDURE SetIText(item: Handle; VAR text: ARRAY OF CHAR); VAR s: ARRAY [0..255] OF CHAR; BEGIN MakePascalString(text,s); xSetIText(item,ADR(s)); END SetIText; PROCEDURE SelIText(theDialog: DialogPtr; itemNo: INTEGER; strtSel,endSel: INTEGER); (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A97EH); CODE(RestoreA7); CODE(Return); END SelIText; PROCEDURE GetAlrtStage(): INTEGER; (*$P+*) BEGIN RETURN(ACount) END GetAlrtStage; PROCEDURE ResetAlrtStage; (*$P+*) BEGIN ACount := -1 END ResetAlrtStage; BEGIN MyParamText[0] := NIL; MyParamText[1] := NIL; MyParamText[2] := NIL; MyParamText[3] := NIL; InitDialogs(ADDRESS(0)); END DialogManager. !Funky!Stuff! # The rest of this file is a shell script which will extract: # BDPackage.MOD ControlManager.MOD Conversions.MOD Cursors.MOD DeskManager.MOD DialogManager.MOD echo x - BDPackage.MOD cat >BDPackage.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE BDPackage; FROM SYSTEM IMPORT ADDRESS,CODE,ADR,REGISTER,SETREG; FROM MacSYSTEM IMPORT LONGINT; FROM PascalStrings IMPORT MakeModulaString,MakePascalString; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) Push = 03F3CH; (* MOVE #VAL,-(A7) *) Pack7 = 0A9EEH; pNumToString= 0; pStringToNum= 1; PROCEDURE xStringToNum(theString:ADDRESS;VAR theNum:LONGINT); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(pStringToNum); CODE(Pack7); CODE(RestoreA7); CODE(Return); END xStringToNum; PROCEDURE NumToString(theNum:LONGINT;VAR theString:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN SETREG(0,theNum); SETREG(8,ADR(Str)); CODE(Push); CODE(pNumToString); CODE(Pack7); MakeModulaString(Str,theString) END NumToString; PROCEDURE StringToNum(VAR theString:ARRAY OF CHAR;VAR theNum:LONGINT); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(theString,Str); SETREG(8,ADR(Str)); CODE(Push); CODE(pStringToNum); CODE(Pack7); theNum := REGISTER(0) END StringToNum END BDPackage. !Funky!Stuff! echo x - ControlManager.MOD cat >ControlManager.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE ControlManager; FROM SYSTEM IMPORT ADDRESS,CODE,ADR,SETREG,REGISTER; FROM MacSYSTEM IMPORT LONGINT,Handle; FROM QuickDraw IMPORT Point,Rect; FROM WindowManager IMPORT WindowPtr; FROM PascalStrings IMPORT MakePascalString,MakeModulaString; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP (A4) *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) (* Init and Alloc *) PROCEDURE xNewControl(Wind:WindowPtr;VAR bounds:Rect;title:ADDRESS; visible:BOOLEAN;value:INTEGER;min,max:INTEGER;procID:INTEGER; refCon:LONGINT): ControlHandle; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A954H); CODE(RestoreA7); CODE(Return); END xNewControl; PROCEDURE NewControl(Wind:WindowPtr;bounds:Rect;VAR title:ARRAY OF CHAR; visible:BOOLEAN;value:INTEGER;min,max:INTEGER;procID:INTEGER; refCon:LONGINT): ControlHandle; (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(title,Str); RETURN(xNewControl(Wind,bounds,ADR(Str),visible,value,min,max,procID,refCon)) END NewControl; PROCEDURE GetNewControl (controlID:INTEGER;wind:WindowPtr):ControlHandle; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9BEH); CODE(RestoreA7); CODE(Return); END GetNewControl; PROCEDURE DisposeControl (theControl:ControlHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A955H); CODE(RestoreA7); CODE(Return); END DisposeControl; PROCEDURE KillControls (wind:WindowPtr); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A956H); CODE(RestoreA7); CODE(Return); END KillControls; (* Control Display *) PROCEDURE xSetCTitle (theControl:ControlHandle;title:ADDRESS); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A95FH); CODE(RestoreA7); CODE(Return); END xSetCTitle; PROCEDURE SetCTitle (theControl:ControlHandle;VAR title:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(title,Str); xSetCTitle(theControl,ADR(Str)) END SetCTitle; PROCEDURE xGetCTitle (theControl:ControlHandle;title:ADDRESS); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A95EH); CODE(RestoreA7); CODE(Return); END xGetCTitle; PROCEDURE GetCTitle (theControl:ControlHandle;VAR title:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN xGetCTitle(theControl,ADR(Str)); MakeModulaString(Str,title) END GetCTitle; PROCEDURE HideControl (theControl:ControlHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A958H); CODE(RestoreA7); CODE(Return); END HideControl; PROCEDURE ShowControl (theControl:ControlHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A957H); CODE(RestoreA7); CODE(Return); END ShowControl; PROCEDURE DrawControls (theWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A969H); CODE(RestoreA7); CODE(Return); END DrawControls; PROCEDURE HiliteControl (theControl:ControlHandle;hiliteState:INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A95DH); CODE(RestoreA7); CODE(Return); END HiliteControl; (* Mouse Location *) PROCEDURE xTestControl(theControl:ControlHandle;thePoint:LONGINT):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A966H); CODE(RestoreA7); CODE(Return); END xTestControl; PROCEDURE TestControl (theControl: ControlHandle;thePoint:Point):INTEGER; (*$P+*)(*$S-*) BEGIN RETURN(xTestControl(theControl,thePoint.param)) END TestControl; PROCEDURE xFindControl(thePoint:LONGINT;theWindow:WindowPtr; VAR whichControl:ControlHandle):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A96CH); CODE(RestoreA7); CODE(Return); END xFindControl; PROCEDURE FindControl(thePoint:Point;theWindow:WindowPtr; VAR whichControl:ControlHandle):INTEGER; (*$P+*)(*$S-*) BEGIN RETURN(xFindControl(thePoint.param,theWindow,whichControl)) END FindControl; PROCEDURE xTrackControl(theControl:ControlHandle;startPt:LONGINT; actionProc: ADDRESS):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A968H); CODE(RestoreA7); CODE(Return); END xTrackControl; PROCEDURE TrackControl (theControl: ControlHandle; startPt:Point; actionProc: ADDRESS):INTEGER; (*$P+*)(*$S-*) BEGIN RETURN(xTrackControl(theControl,startPt.param,actionProc)) END TrackControl; VAR ProcA:PROC; PROCEDURE ProcAInterface; (*$P-*) BEGIN CODE(04E56H);CODE(0); (* LINK A6,#0 *) CODE(048E7H);CODE(0FFFCH); (* MOVEM.L D0-D7/A0-A5,-(A7)*) SETREG(8,ProcA); CODE(04E90H); (* JSR (A0) *) CODE(04CDFH);CODE(03FFFH); (* MOVEM.L (A7)+,D0-D7/A0-A5*) CODE(04E5EH); (* UNLK A6 *) CODE(04E75H); (* RTS *) END ProcAInterface; PROCEDURE TrackProcA(p:PROC):ADDRESS; (*$P+*)(*$S-*) BEGIN ProcA := p; SETREG(8,ProcAInterface); RETURN(REGISTER(8)) END TrackProcA; VAR ProcB:PROCHI; PROCEDURE ProcBInterface; (*$P-*) BEGIN CODE(04E56H);CODE(0); (* LINK A6,#0 *) CODE(048E7H);CODE(0FFFCH); (* MOVEM.L D0-D7/A0-A5,-(A7) *) CODE(02F2EH);CODE(0AH); (* MOVE.L 0A(A6),-(A7) *) CODE(03F2EH);CODE(08H); (* MOVE.W 08(A6),-(A7) *) SETREG(8,ProcB); CODE(04E90H); (* JSR (A6) *) CODE(05C8FH); (* ADDQ.L #6,A7 *) CODE(04CDFH);CODE(03FFFH); (* MOVEM.L (A7)+,D0-D7/A0-A4 *) CODE(04E5EH); (* UNLK A6 *) CODE(02F5FH);CODE(2H); (* MOVE.L (A7)+,2(A7) *) CODE(0548FH); (* ADDQ.L #2,A7 *) CODE(04E75H); (* RTS *) END ProcBInterface; PROCEDURE TrackProcB(p:PROCHI):ADDRESS; (*$P+*)(*$S-*) BEGIN ProcB := p; SETREG(8,ProcBInterface); RETURN(REGISTER(8)) END TrackProcB; (* Control Movement and Sizing *) PROCEDURE MoveControl (theControl: ControlHandle; h,v: INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A959H); CODE(RestoreA7); CODE(Return); END MoveControl; PROCEDURE xDragControl (theControl: ControlHandle; startPt:LONGINT; VAR limitRect,slopRect: Rect; axis: INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A967H); CODE(RestoreA7); CODE(Return); END xDragControl; PROCEDURE DragControl (theControl: ControlHandle; startPt:Point; limitRect,slopRect: Rect; axis: INTEGER); (*$P+*)(*$S-*) BEGIN xDragControl(theControl,startPt.param,limitRect,slopRect,axis) END DragControl; PROCEDURE SizeControl (theControl: ControlHandle; w,h: INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A95CH); CODE(RestoreA7); CODE(Return); END SizeControl; (* Control Setting and Range *) PROCEDURE SetCtlValue (theControl: ControlHandle; theValue: INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A963H); CODE(RestoreA7); CODE(Return); END SetCtlValue; PROCEDURE GetCtlValue (theControl: ControlHandle):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A960H); CODE(RestoreA7); CODE(Return); END GetCtlValue; PROCEDURE SetCtlMin (theControl: ControlHandle;minValue:INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A964H); CODE(RestoreA7); CODE(Return); END SetCtlMin; PROCEDURE GetCtlMin (theControl: ControlHandle):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A961H); CODE(RestoreA7); CODE(Return); END GetCtlMin; PROCEDURE SetCtlMax (theControl: ControlHandle; maxValue:INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A965H); CODE(RestoreA7); CODE(Return); END SetCtlMax; PROCEDURE GetCtlMax (theControl: ControlHandle):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A962H); CODE(RestoreA7); CODE(Return); END GetCtlMax; (* Miscellaneous Utilities *) PROCEDURE SetCRefCon (theControl: ControlHandle; data: LONGINT); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A95BH); CODE(RestoreA7); CODE(Return); END SetCRefCon; PROCEDURE GetCRefCon (theControl: ControlHandle):LONGINT; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A95AH); CODE(RestoreA7); CODE(Return); END GetCRefCon; PROCEDURE SetCtlAction (theControl: ControlHandle;actionProc:ADDRESS); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A96BH); CODE(RestoreA7); CODE(Return); END SetCtlAction; PROCEDURE GetCtlAction (theControl: ControlHandle):ADDRESS; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A96BH); CODE(RestoreA7); CODE(Return); END GetCtlAction; END ControlManager. !Funky!Stuff! echo x - Conversions.MOD cat >Conversions.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE Conversions; FROM SYSTEM IMPORT WORD; PROCEDURE PAD(VAR s:ARRAY OF CHAR;size:INTEGER;c:CHAR); VAR i :CARDINAL; BEGIN IF (size >= 0) THEN FOR i := 0 TO size DO s[i] := c END END END PAD; PROCEDURE NtoS(x,base: CARDINAL; size:INTEGER; VAR str:ARRAY OF CHAR;sign,first:BOOLEAN;pad:CHAR):INTEGER; VAR RetSize : INTEGER; High : INTEGER; BEGIN High := VAL(INTEGER,HIGH(str)); IF (x = 0) THEN IF (first) THEN IF (size > High) THEN size := High END; IF (sign) THEN PAD(str,size - 2,pad); IF (size = 0) THEN size := 1; END; str[size - 1] := '-'; ELSE PAD(str,size - 1,pad); END; str[size] := '0'; ELSE IF (sign) THEN IF (size < 0) THEN PAD(str,High,'*'); RETURN(-2) END; PAD(str,size - 1,pad); str[size] := '-' ELSE PAD(str,size,pad); END; END; (*IF*) IF (first AND (size # High)) THEN str[size + 1] := 0C END; RETURN(size) ELSE (* x is not 0 *) IF (size < 0) THEN size := 0 END; RetSize := NtoS(x DIV base,base,size - 1,str,sign,FALSE,pad); IF (RetSize = -2) THEN RETURN(RetSize) END; IF size <= RetSize THEN size := RetSize + 1; END; IF (size > High) THEN PAD(str,High,'*'); RETURN(-2); ELSE str[size] := CHR(ORD('0') + x MOD base); IF str[size] > '9' THEN str[size] := CHR(ORD(str[size]) - ORD('0') + ORD('A') - 10) END; IF (first AND (size # High)) THEN str[size + 1] := 0C END; RETURN(size) END END END NtoS; PROCEDURE IntToStr(i : INTEGER;VAR s : ARRAY OF CHAR; p : CARDINAL):BOOLEAN; VAR RetSize : INTEGER; BEGIN IF (p = 0) THEN RetSize := 0 ELSE RetSize := VAL(INTEGER,p) - 1; END; RetSize := NtoS(ABS(i),10,RetSize,s,(i < 0),TRUE,' '); RETURN(RetSize # -2) END IntToStr; PROCEDURE StrToInt(VAR s : ARRAY OF CHAR; VAR x : INTEGER):BOOLEAN; VAR i : CARDINAL; neg : BOOLEAN; BEGIN i := 0; x := 0; WHILE ((i < HIGH(s)) AND ((s[i] = ' ') OR (s[i] = ' '))) DO INC(i) END; (* Assert at worst i = HIGH(s) *) IF (s[i] = '-') THEN neg := TRUE; INC(i); IF (i > HIGH(s)) THEN RETURN(FALSE) END END; REPEAT IF ((s[i] < '0') OR (s[i] > '9')) THEN RETURN(FALSE) ELSE x := x * 10 + INTEGER(ORD(s[i])) - INTEGER(ORD('0')) END; INC(i) UNTIL ((i > HIGH(s)) OR (s[i] = 0C)); IF neg THEN x := -x; END; RETURN(TRUE) END StrToInt; PROCEDURE CardToStr(c : CARDINAL; VAR s : ARRAY OF CHAR; p : CARDINAL):BOOLEAN; VAR RetSize : INTEGER; BEGIN IF (p = 0) THEN RetSize := 0 ELSE RetSize := VAL(INTEGER,p) - 1; END; RetSize := NtoS(c,10,RetSize,s,FALSE,TRUE,' '); RETURN(RetSize # -2) END CardToStr; PROCEDURE StrToCard(VAR s:ARRAY OF CHAR; VAR c:CARDINAL):BOOLEAN; VAR i : CARDINAL; BEGIN i := 0; c := 0; WHILE ((i < HIGH(s)) AND ((s[i] = ' ') OR (s[i] = ' '))) DO INC(i) END; (* Assert at worst i = HIGH(s) *) REPEAT IF ((s[i] < '0') OR (s[i] > '9')) THEN RETURN(FALSE) ELSE c := c * 10 + ORD(s[i]) - ORD('0') END; INC(i) UNTIL ((i > HIGH(s)) OR (s[i] = 0C)); RETURN(TRUE) END StrToCard; PROCEDURE HexToStr(w:WORD;VAR s:ARRAY OF CHAR; p : CARDINAL):BOOLEAN; VAR RetSize : INTEGER; BEGIN IF (p = 0) THEN RetSize := 0 ELSE RetSize := VAL(INTEGER,p) - 1; END; RetSize := NtoS(CARDINAL(w),16,RetSize,s,FALSE,TRUE,'0'); RETURN(RetSize # -2) END HexToStr; PROCEDURE StrToHex(VAR s:ARRAY OF CHAR;VAR w:WORD):BOOLEAN; VAR i : CARDINAL; c : CARDINAL; BEGIN i := 0; c := 0; WHILE ((i < HIGH(s)) AND ((s[i] = ' ') OR (s[i] = ' '))) DO INC(i) END; (* Assert at worst i = HIGH(s) *) REPEAT IF ((s[i] < '0') OR (s[i] > '9')) THEN IF ((s[i] >= 'A') AND (s[i] <= 'F')) THEN c := c * 10 + ORD(s[i]) - ORD('A') + 10 ELSE RETURN(FALSE) END ELSE c := c * 10 + ORD(s[i]) - ORD('0') END; INC(i) UNTIL ((i > HIGH(s)) OR (s[i] = 0C)); w := WORD(c); RETURN(TRUE) END StrToHex; PROCEDURE OctToStr(w:WORD;VAR s:ARRAY OF CHAR; p : CARDINAL):BOOLEAN; VAR RetSize : INTEGER; BEGIN IF (p = 0) THEN RetSize := 0 ELSE RetSize := VAL(INTEGER,p) - 1; END; RetSize := NtoS(CARDINAL(w),8,RetSize,s,FALSE,TRUE,'0'); RETURN(RetSize # -2) END OctToStr; PROCEDURE StrToOct(VAR s:ARRAY OF CHAR;VAR w:WORD):BOOLEAN; VAR i : CARDINAL; c : CARDINAL; BEGIN i := 0; c := 0; WHILE ((i < HIGH(s)) AND ((s[i] = ' ') OR (s[i] = ' '))) DO INC(i) END; (* Assert at worst i = HIGH(s) *) REPEAT IF ((s[i] < '0') OR (s[i] > '7')) THEN RETURN(FALSE) ELSE c := c * 10 + ORD(s[i]) - ORD('0') END; INC(i) UNTIL ((i > HIGH(s)) OR (s[i] = 0C)); w := WORD(c); RETURN(TRUE) END StrToOct; END Conversions. !Funky!Stuff! echo x - Cursors.MOD cat >Cursors.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE Cursors; FROM SYSTEM IMPORT ADDRESS,WORD,CODE,ADR,REGISTER; FROM MacSYSTEM IMPORT LONGINT; FROM QuickDraw IMPORT Point,Rect,Bits16,Cursor; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) (* Cursor Routines *) PROCEDURE GetCursor(cursorID:INTEGER):CursHandle; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9B9H); CODE(RestoreA7); CODE(Return); END GetCursor; PROCEDURE xShieldCursor(shieldRect:Rect;offsetPt:LONGINT); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A855H); CODE(RestoreA7); CODE(Return); END xShieldCursor; PROCEDURE ShieldCursor(shieldRect:Rect;offsetPt:Point); (*$P+*)(*$S-*) BEGIN xShieldCursor(shieldRect,offsetPt.param) END ShieldCursor; PROCEDURE InitCursor; (*$P+*)(*$S-*) BEGIN CODE(0A850H); END InitCursor; PROCEDURE SetCursor(VAR crsr: Cursor); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A851H); CODE(RestoreA7);CODE(Return); END SetCursor; PROCEDURE HideCursor; (*$P+*)(*$S-*) BEGIN CODE(0A852H); END HideCursor; PROCEDURE ShowCursor; (*$P+*)(*$S-*) BEGIN CODE(0A853H); END ShowCursor; PROCEDURE ObscureCursor; (*$P+*)(*S-*) BEGIN CODE(0A856H); END ObscureCursor; END Cursors. !Funky!Stuff! echo x - DeskManager.MOD cat >DeskManager.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE DeskManager; FROM SYSTEM IMPORT ADDRESS,WORD,CODE,ADR,REGISTER; FROM MacSYSTEM IMPORT LONGINT; FROM EventManager IMPORT EventRecord; FROM WindowManager IMPORT WindowPtr; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) PROCEDURE xOpenDeskAcc(theAcc:ADDRESS):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9B6H); CODE(RestoreA7); CODE(Return); END xOpenDeskAcc; (* This is for the silly null in DeskAcc names *) PROCEDURE DeskAccString(VAR in,out:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR i:CARDINAL; BEGIN out[1] := in[0]; (* copy the null *) i := 1; REPEAT out[i + 1] := in[i]; INC(i); UNTIL ((i > HIGH(in)) OR (in[i] = 0C)); out[0] := CHR(i) END DeskAccString; PROCEDURE OpenDeskAcc(VAR theAcc:ARRAY OF CHAR):INTEGER; (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN DeskAccString(theAcc,Str); RETURN(xOpenDeskAcc(ADR(Str))) END OpenDeskAcc; PROCEDURE CloseDeskAcc(refNum:INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9B7H); CODE(RestoreA7); CODE(Return); END CloseDeskAcc; PROCEDURE SystemClick(VAR theEvent:EventRecord;theWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9B3H); CODE(RestoreA7); CODE(Return); END SystemClick; PROCEDURE SystemEdit(editCmd:INTEGER):BOOLEAN; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9C2H); CODE(RestoreA7); CODE(Return); END SystemEdit; PROCEDURE SystemTask; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9B4H); CODE(RestoreA7); CODE(Return); END SystemTask; PROCEDURE SystemEvent(VAR theEvent:EventRecord):BOOLEAN; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9B2H); CODE(RestoreA7); CODE(Return); END SystemEvent; PROCEDURE SystemMenu(menuResult:LONGINT); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9B5H); CODE(RestoreA7); CODE(Return); END SystemMenu; END DeskManager. !Funky!Stuff! echo x - DialogManager.MOD cat >DialogManager.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE DialogManager; FROM SYSTEM IMPORT ADDRESS,CODE,ADR,SETREG,REGISTER; FROM Storage IMPORT ALLOCATE,DEALLOCATE; FROM QuickDraw IMPORT Rect; FROM MacSYSTEM IMPORT Handle, LONGINT, Ptr,StringPtr; FROM WindowManager IMPORT WindowPtr; FROM TextEdit IMPORT TEHandle,TECut,TECopy,TEPaste,TEDelete; FROM EventManager IMPORT EventRecord; FROM PascalStrings IMPORT MakePascalString, MakeModulaString; CONST GetRet=0285FH; Return=04ED4H; SaveA7=0264FH; RestoreA7=02E4BH; (* Misc *) VAR Sound : SoundProc; VAR MyParamText: ARRAY [0..3] OF StringPtr; PROCEDURE SoundInterface; (*$P-*) BEGIN CODE(04E56H);CODE(0); (* LINK A6,#0 *) CODE(048E7H);CODE(01F38H); (* MOVEM.L D3-D7/A2-A4,-(A7) *) CODE(03F2EH);CODE(08H); (* MOVE.W 08(A6),-(A7) *) SETREG(8,Sound); CODE(04E90H); (* JSR (A0) *) CODE(05C8FH); (* ADDQ.L #6,A7 *) CODE(04CDFH);CODE(01CF8H); (* MOVEM.L (A7)+,D3-D7/A2-A4 *) CODE(04E5EH); (* UNLK A6 *) CODE(0205FH); (* MOVEA.L (A7)+,A0 *) CODE(05C8FH); (* ADDQ.L #6,A7 *) CODE(04ED0H); (* JMP (A0) *) END SoundInterface; PROCEDURE UseSoundProc(MySound: SoundProc):ADDRESS; (*$P+*)(*$S-*) BEGIN Sound := MySound; SETREG(8,SoundInterface); RETURN(REGISTER(8)) END UseSoundProc; (* initialization *) PROCEDURE InitDialogs (restartProc: ADDRESS); (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A97BH); CODE(RestoreA7); CODE(Return); END InitDialogs; PROCEDURE ErrorSound (MySound: ADDRESS); BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A98CH); CODE(RestoreA7); CODE(Return); END ErrorSound; PROCEDURE SetDAFont (fontNum: INTEGER); (*$P+*) BEGIN DlgFont := fontNum END SetDAFont; (* Creating and disposing OF dialogs *) PROCEDURE xNewDialog(dStorage:ADDRESS;VAR boundsRect:Rect; title:ADDRESS; visible: BOOLEAN; procID: INTEGER; behind: WindowPtr; goAwayFlag: BOOLEAN; refCon: LONGINT; items: Handle) : DialogPtr; (* $P- *) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A97DH); CODE(RestoreA7); CODE(Return); END xNewDialog; PROCEDURE NewDialog(dStorage: ADDRESS; boundsRect:Rect; VAR title:ARRAY OF CHAR; visible: BOOLEAN; procID: INTEGER; behind: WindowPtr; goAwayFlag: BOOLEAN; refCon: LONGINT; items: Handle) : DialogPtr; VAR s: ARRAY[0..255] OF CHAR; (*$P+*)(*$S-*) BEGIN MakePascalString(title,s); RETURN(xNewDialog(dStorage,boundsRect,ADR(s),visible,procID,behind, goAwayFlag,refCon,items)) END NewDialog; PROCEDURE GetNewDialog(dialogID:INTEGER;dStorage:ADDRESS; behind:WindowPtr):DialogPtr; (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A97CH); CODE(RestoreA7); CODE(Return) END GetNewDialog; PROCEDURE CloseDialog(theDialog: DialogPtr); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A982H); CODE(RestoreA7); CODE(Return) END CloseDialog; PROCEDURE DisposDialog(theDialog:DialogPtr); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A983H); CODE(RestoreA7); CODE(Return) END DisposDialog; PROCEDURE CouldDialog(dialogID: INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A979H); CODE(RestoreA7); CODE(Return); END CouldDialog; PROCEDURE FreeDialog(dialogID: INTEGER); (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A97AH); CODE(RestoreA7); CODE(Return); END FreeDialog; (* Handling Dialog events *) PROCEDURE NoFilterProc():ADDRESS; BEGIN RETURN(ADDRESS(0)) END NoFilterProc; VAR Filter:FilterProc; PROCEDURE FilterInterface; (*$P-*) BEGIN CODE(04E56H);CODE(0); (* LINK A6,#0 *) CODE(048E7H);CODE(01F38H); (* MOVEM.L D3-D7/A2-A4,-(A7) *) CODE(04267H); (* CLR.W -(A7) *) CODE(02F2EH);CODE(010H); (* MOVE.L 010(A6),-(A7) *) CODE(02F2EH);CODE(0CH); (* MOVE.L 0C(A6),-(A7) *) CODE(02F2EH);CODE(08H); (* MOVE.L 08(A6),-(A7) *) SETREG(8,Filter); CODE(04E90H); (* JSR (A0) *) CODE(04FEFH);CODE(000CH); (* LEA A7,000C(A7) *) CODE(03D5FH);CODE(014H); (* MOVE.L (A7)+,14(A6) *) CODE(04CDFH);CODE(01CF8H); (* MOVEM.L (A7)+,D3-D7/A2-A4 *) CODE(04E5EH); (* UNLK A6 *) CODE(0205FH); (* MOVEA.L (A7)+,A0 *) CODE(04FEFH);CODE(000CH); (* LEA A7,000C(A7) *) CODE(04ED0H); (* JMP (A0) *) END FilterInterface; PROCEDURE UseFilterProc(myFilter:FilterProc):ADDRESS; (*$P+*)(*$S-*) BEGIN Filter := myFilter; SETREG(8,FilterInterface); RETURN(REGISTER(8)) END UseFilterProc; PROCEDURE ModalDialog(myFilter:ADDRESS; VAR itemHit: INTEGER); (* $P- *) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A991H); CODE(RestoreA7); CODE(Return); END ModalDialog; PROCEDURE IsDialogEvent(VAR theEvent: EventRecord) : BOOLEAN; (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A97FH); CODE(RestoreA7); CODE(Return); END IsDialogEvent; PROCEDURE DialogSelect(VAR theEvent: EventRecord; VAR theDialog: DialogPtr; VAR itemHit: INTEGER) : BOOLEAN; (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A980H); CODE(RestoreA7); CODE(Return); END DialogSelect; PROCEDURE DlgCut(theDialog: DialogPtr); (*$P+*) VAR d : DialogPeek; BEGIN d := DialogPeek(theDialog); IF (d^.editField >= 0) THEN TECut(d^.textH) END END DlgCut; PROCEDURE DlgCopy(theDialog: DialogPtr); VAR d : DialogPeek; BEGIN d := DialogPeek(theDialog); IF (d^.editField >= 0) THEN TECopy(d^.textH) END END DlgCopy; PROCEDURE DlgPaste(theDialog: DialogPtr); VAR d : DialogPeek; BEGIN d := DialogPeek(theDialog); IF (d^.editField >= 0) THEN TEPaste(d^.textH) END END DlgPaste; PROCEDURE DlgDelete(theDialog: DialogPtr); VAR d : DialogPeek; BEGIN d := DialogPeek(theDialog); IF (d^.editField >= 0) THEN TEDelete(d^.textH) END END DlgDelete; PROCEDURE DrawDialog (theDialog: DialogPtr); (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A981H); CODE(RestoreA7); CODE(Return); END DrawDialog; (* invoking alerts *) PROCEDURE Alert(alertID: INTEGER; myFilter:ADDRESS): INTEGER; (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A985H); CODE(RestoreA7); CODE(Return); END Alert; PROCEDURE StopAlert(alertID: INTEGER; myFilter:ADDRESS): INTEGER; (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A986H); CODE(RestoreA7); CODE(Return); END StopAlert; PROCEDURE NoteAlert(alertID: INTEGER; myFilter:ADDRESS): INTEGER; (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A987H); CODE(RestoreA7); CODE(Return); END NoteAlert; PROCEDURE CautionAlert(alertID: INTEGER; myFilter:ADDRESS): INTEGER; (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A988H); CODE(RestoreA7); CODE(Return); END CautionAlert; PROCEDURE CouldAlert(alertID: INTEGER); (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A989H); CODE(RestoreA7); CODE(Return); END CouldAlert; PROCEDURE FreeAlert(alertID: INTEGER); (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A98AH); CODE(RestoreA7); CODE(Return); END FreeAlert; (* manipulation items in dialog and alerts *) PROCEDURE ParamText(VAR param0,param1,param2,param3: ARRAY OF CHAR); (*$P+*)(*$S-*) BEGIN IF (MyParamText[0] # NIL) THEN DEALLOCATE(MyParamText[0],255) END; ALLOCATE(MyParamText[0],HIGH(param0)+2); MakePascalString(param0,MyParamText[0]^); IF (MyParamText[1] # NIL) THEN DEALLOCATE(MyParamText[1],255) END; ALLOCATE(MyParamText[1],HIGH(param1)+2); MakePascalString(param1,MyParamText[1]^); IF (MyParamText[2] # NIL) THEN DEALLOCATE(MyParamText[2],255) END; ALLOCATE(MyParamText[2],HIGH(param2)+2); MakePascalString(param2,MyParamText[2]^); IF (MyParamText[3] # NIL) THEN DEALLOCATE(MyParamText[3],255) END; ALLOCATE(MyParamText[3],HIGH(param3)+2); MakePascalString(param3,MyParamText[3]^); DAStrings[0] := ADDRESS(MyParamText[0]); DAStrings[1] := ADDRESS(MyParamText[1]); DAStrings[2] := ADDRESS(MyParamText[2]); DAStrings[3] := ADDRESS(MyParamText[3]); END ParamText; PROCEDURE GetDItem(theDialog: DialogPtr; itemNo: INTEGER; VAR type: INTEGER; VAR item: Handle; VAR box: Rect); (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A98DH); CODE(RestoreA7); CODE(Return); END GetDItem; PROCEDURE SetDItem (theDialog: DialogPtr; itemNo: INTEGER; type: INTEGER; item: Handle; VAR box: Rect); (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A98EH); CODE(RestoreA7); CODE(Return); END SetDItem; PROCEDURE xGetIText(item: Handle; text: ADDRESS); (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A990H); CODE(RestoreA7); CODE(Return); END xGetIText; PROCEDURE GetIText(item: Handle; VAR text: ARRAY OF CHAR); VAR s: ARRAY [0..255] OF CHAR; BEGIN xGetIText(item,ADR(s)); MakeModulaString(s,text); END GetIText; PROCEDURE xSetIText(item: Handle; text: ADDRESS); (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A98FH); CODE(RestoreA7); CODE(Return); END xSetIText; PROCEDURE SetIText(item: Handle; VAR text: ARRAY OF CHAR); VAR s: ARRAY [0..255] OF CHAR; BEGIN MakePascalString(text,s); xSetIText(item,ADR(s)); END SetIText; PROCEDURE SelIText(theDialog: DialogPtr; itemNo: INTEGER; strtSel,endSel: INTEGER); (* $P- *) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A97EH); CODE(RestoreA7); CODE(Return); END SelIText; PROCEDURE GetAlrtStage(): INTEGER; (*$P+*) BEGIN RETURN(ACount) END GetAlrtStage; PROCEDURE ResetAlrtStage; (*$P+*) BEGIN ACount := -1 END ResetAlrtStage; BEGIN MyParamText[0] := NIL; MyParamText[1] := NIL; MyParamText[2] := NIL; MyParamText[3] := NIL; InitDialogs(ADDRESS(0)); END DialogManager. !Funky!Stuff!
bobc@tikal.UUCP (Bob Campbell) (05/13/86)
# The rest of this file is a shell script which will extract: # EventManager.MOD FileManager.MOD FileTypes.MOD FontManager.MOD IUPackage.MOD InOut.MOD MacSYSTEM.MOD echo x - EventManager.MOD cat >EventManager.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE EventManager; (* MacIntosh ToolBox Event Manager Operations *) FROM MacSYSTEM IMPORT LONGINT,OSErr; FROM QuickDraw IMPORT Point; FROM SYSTEM IMPORT ADDRESS,CODE,SETREG,REGISTER,ADR,WORD; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) VAR SysEvtMask[00000144H]:CARDINAL; PROCEDURE EventAvail(mask:WORD; VAR theEvent: EventRecord):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A971H); CODE(RestoreA7);CODE(Return); END EventAvail; PROCEDURE GetNextEvent(mask:WORD; VAR theEvent: EventRecord):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A970H); CODE(RestoreA7);CODE(Return); END GetNextEvent; PROCEDURE StillDown():BOOLEAN; (* INLINE $A973;*) (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A973H); CODE(RestoreA7);CODE(Return); END StillDown; PROCEDURE WaitMouseUp():BOOLEAN; (* INLINE $A977;*) (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A977H); CODE(RestoreA7);CODE(Return); END WaitMouseUp; PROCEDURE xGetMouse (VAR pt: LONGINT); (* INLINE $A972;*) (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A972H); CODE(RestoreA7);CODE(Return); END xGetMouse; PROCEDURE GetMouse (VAR pt: Point); (*$P+*)(*$S-*) BEGIN xGetMouse(pt.param); END GetMouse; PROCEDURE TickCount():LONGINT; (* INLINE $A975;*) (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A975H); CODE(RestoreA7);CODE(Return); END TickCount; PROCEDURE Button():BOOLEAN; (*INLINE $A974;*) (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A974H); CODE(RestoreA7);CODE(Return); END Button; PROCEDURE GetKeys(VAR k: KeyMap); (*INLINE $A976;*) (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A976H); CODE(RestoreA7);CODE(Return); END GetKeys; PROCEDURE PostEvent (eventNum: WORD; eventMsg: LONGINT): OSErr; (*$P+*)(*$S-*) BEGIN SETREG(8,eventNum); SETREG(0,eventMsg); CODE(0A02FH); RETURN(INTEGER(REGISTER(0))); END PostEvent; PROCEDURE FlushEvents (whichMask,stopMask: WORD); (*$P+*)(*$S-*) BEGIN CODE(0202EH);CODE(00008H); (* MOVE.L 8(A6),D0 *) CODE(0A032H); END FlushEvents; PROCEDURE SetEventMask (theMask: WORD); BEGIN SysEvtMask := CARDINAL(theMask) END SetEventMask; PROCEDURE OSEventAvail (mask: WORD; VAR theEvent: EventRecord): BOOLEAN; BEGIN SETREG(8,ADR(theEvent)); SETREG(0,mask); CODE(0A030H); RETURN(REGISTER(0) = 0) END OSEventAvail; PROCEDURE GetOSEvent (mask: WORD; VAR theEvent: EventRecord): BOOLEAN; BEGIN SETREG(8,ADR(theEvent)); SETREG(0,mask); CODE(0A031H); RETURN(REGISTER(0) = 0); END GetOSEvent; END EventManager. !Funky!Stuff! echo x - FileManager.MOD cat >FileManager.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE FileManager; FROM SYSTEM IMPORT ADR,REGISTER,SETREG,CODE,ADDRESS,WORD; FROM Storage IMPORT ALLOCATE,DEALLOCATE; FROM PascalStrings IMPORT MakeModulaString,MakePascalString; FROM MacSYSTEM IMPORT LONGINT,StringPtr,OSErr,noErr; FROM FileTypes IMPORT (*CONST*) opWrErr,permErr, (*TYPE*) OSType,FInfo,ParamBlkPtr,ParamBlkType,ParamBlockRec; CONST OpenTrap = 0A000H; CloseTrap = 0A001H; ReadTrap = 0A002H; WriteTrap = 0A003H; ControlTrap = 0A004H; StatusTrap = 0A005H; KillIOTrap = 0A006H; GetVolInfoTrap = 0A007H; CreateTrap = 0A008H; DeleteTrap = 0A009H; OpenRFTrap = 0A00AH; RenameTrap = 0A00BH; GetFileInfoTrap = 0A00CH; SetFileInfoTrap = 0A00DH; UnmountVolTrap = 0A00EH; MountVolTrap = 0A00FH; AllocateTrap = 0A010H; GetEOFTrap = 0A011H; SetEOFTrap = 0A012H; FlushVolTrap = 0A013H; GetVolTrap = 0A014H; SetVolTrap = 0A015H; FInitQueueTrap = 0A016H; EjectTrap = 0A017H; GetFPosTrap = 0A018H; SetFilLockTrap = 0A041H; RstFilLockTrap = 0A042H; SetFilTypeTrap = 0A043H; SetFPosTrap = 0A044H; FlushFileTrap = 0A045H; TYPE SaveRecPtr= POINTER TO SaveRec; SaveRec = RECORD Next : SaveRecPtr; Buffer : ADDRESS; FileNum: INTEGER END; VAR HEAD : SaveRecPtr; PROCEDURE SaveBuffer(ref:INTEGER; buf : ADDRESS); (* remember the address of the file buffer *) VAR p : SaveRecPtr; BEGIN NEW(p); IF (p # NIL) THEN p^.Buffer := buf; p^.FileNum := ref; p^.Next := HEAD; HEAD := p END END SaveBuffer; PROCEDURE FreeBuffer(ref:INTEGER); (* free up the file buffer *) VAR p,q : SaveRecPtr; BEGIN p := HEAD; q := NIL; WHILE (p # NIL) DO IF (p^.FileNum = ref) THEN DEALLOCATE(p^.Buffer,524); p^.FileNum := 0; IF (q = NIL) THEN HEAD := p^.Next ELSE q^.Next := p^.Next END; DISPOSE(p); RETURN END; q := p; p := q^.Next END END FreeBuffer; (* Accessing Volumes *) PROCEDURE GetVInfo(drive:INTEGER;vol:StringPtr; VAR vRef:INTEGER;VAR free:LONGINT):OSErr; VAR PB:ParamBlockRec; TmpString: ARRAY [0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); IF (vol # NIL) AND (vol # StringPtr(0)) THEN PB.ioNamePtr := ADR(TmpString); MakePascalString(vol^,PB.ioNamePtr^); ELSE PB.ioNamePtr := StringPtr(0) END; PB.ioVolIndex := drive; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(GetVolInfoTrap); IF (vol # NIL) AND (vol # StringPtr(0)) THEN MakeModulaString(PB.ioNamePtr^,vol^); END; vRef := PB.ioVRefNum; free := LONGINT(PB.ioVFrBlk) * PB.ioVAlBlkSiz; RETURN(PB.ioResult); END GetVInfo; PROCEDURE GetVol(volName:StringPtr;VAR vRefNum:INTEGER):OSErr; VAR PB:ParamBlockRec; TmpString: ARRAY [0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); IF (volName # StringPtr(0)) AND (volName # NIL) THEN PB.ioNamePtr := StringPtr(0) ELSE PB.ioNamePtr := ADR(TmpString); END; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(GetVolTrap); IF (volName # StringPtr(0)) AND (volName # NIL) THEN MakeModulaString(PB.ioNamePtr^,volName^); END; vRefNum := PB.ioVRefNum; RETURN(PB.ioResult); END GetVol; PROCEDURE SetVol(volName:StringPtr;vRefNum:INTEGER):OSErr; VAR PB:ParamBlockRec; Str:ARRAY [0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); IF (volName # StringPtr(0)) AND (volName # NIL) THEN MakePascalString(volName^,Str); PB.ioNamePtr := ADR(Str); ELSE PB.ioNamePtr := StringPtr(0) END; PB.ioVRefNum := vRefNum; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(SetVolTrap); RETURN(PB.ioResult); END SetVol; PROCEDURE FlushVol(volName:StringPtr;vRefNum:INTEGER):OSErr; VAR PB:ParamBlockRec; Str:ARRAY [0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); IF (volName # NIL) AND (volName # StringPtr(0)) THEN MakePascalString(volName^,Str); PB.ioNamePtr := ADR(Str) ELSE PB.ioNamePtr := StringPtr(0) END; PB.ioVRefNum := vRefNum; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(FlushVolTrap); RETURN(PB.ioResult); END FlushVol; PROCEDURE UnmountVol(volName:StringPtr;vRefNum:INTEGER):OSErr; VAR PB:ParamBlockRec; Str:ARRAY [0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); IF (volName # NIL) AND (volName # StringPtr(0)) THEN MakePascalString(volName^,Str); PB.ioNamePtr := ADR(Str) ELSE PB.ioNamePtr := StringPtr(0) END; PB.ioVRefNum := vRefNum; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(UnmountVolTrap); RETURN(PB.ioResult); END UnmountVol; PROCEDURE Eject(volName:StringPtr;vRefNum:INTEGER):OSErr; VAR PB:ParamBlockRec; Str:ARRAY [0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); IF (volName # NIL) AND (volName # StringPtr(0)) THEN MakePascalString(volName^,Str); PB.ioNamePtr := ADR(Str) ELSE PB.ioNamePtr := StringPtr(0) END; PB.ioVRefNum := vRefNum; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(EjectTrap); RETURN(PB.ioResult); END Eject; (* Changine File Contents *) PROCEDURE Create(VAR Name:ARRAY OF CHAR;vRef:INTEGER; creator,type:OSType):OSErr; VAR PB:ParamBlockRec; Str:ARRAY[0..255] OF CHAR; f:FInfo; ret:OSErr; BEGIN PB.ioCompletion := ADDRESS(0); MakePascalString(Name,Str); PB.ioNamePtr := ADR(Str); PB.ioVRefNum := vRef; PB.ioFVersNum := 0C; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(CreateTrap); IF (PB.ioResult <> noErr) THEN RETURN(PB.ioResult); END; ret := GetFInfo(Name,vRef,f); IF (ret <>noErr) THEN RETURN(ret) END; f.fdType := type; f.fdCreator := creator; RETURN(SetFInfo(Name,vRef,f)); END Create; PROCEDURE FSOpen(VAR Name:ARRAY OF CHAR;vRef:INTEGER; VAR ref:INTEGER):OSErr; VAR PB:ParamBlockRec; Str:ARRAY[0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); MakePascalString(Name,Str); PB.ioNamePtr := ADR(Str); PB.ioVRefNum := vRef; PB.ioVersNum := 0C; PB.ioPermssn := 0C; ALLOCATE(PB.ioMisc,524); IF (PB.ioMisc = NIL) THEN PB.ioMisc := ADDRESS(0) END; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(OpenTrap); ref := PB.ioRefNum; IF (PB.ioMisc # ADDRESS(0)) THEN IF ((PB.ioResult = noErr) OR (PB.ioResult = opWrErr) OR (PB.ioResult = permErr)) THEN SaveBuffer(ref,PB.ioMisc); ELSE DEALLOCATE(PB.ioMisc,524) END END; RETURN(PB.ioResult); END FSOpen; PROCEDURE FSRead(refNum:INTEGER;VAR count:LONGINT;buff:ADDRESS):OSErr; VAR PB:ParamBlockRec; BEGIN PB.ioCompletion := ADDRESS(0); PB.ioRefNum := refNum; PB.ioReqCount := count; PB.ioPosMode := 0; PB.ioPosOffset := 0; PB.ioBuffer := buff; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(ReadTrap); count := PB.ioActCount; RETURN(PB.ioResult); END FSRead; PROCEDURE FSWrite(ref:INTEGER;VAR count:LONGINT;buff:ADDRESS):OSErr; VAR PB:ParamBlockRec; BEGIN PB.ioCompletion := ADDRESS(0); PB.ioRefNum := ref; PB.ioReqCount := count; PB.ioPosMode := 0; PB.ioPosOffset := 0; PB.ioBuffer := buff; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(WriteTrap); count := PB.ioActCount; RETURN(PB.ioResult); END FSWrite; PROCEDURE GetFPos(refNum:INTEGER;VAR filePos:LONGINT):OSErr; VAR PB:ParamBlockRec; BEGIN PB.ioCompletion := ADDRESS(0); PB.ioRefNum := refNum; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(GetFPosTrap); filePos := PB.ioPosOffset; RETURN(PB.ioResult); END GetFPos; PROCEDURE SetFPos(ref:INTEGER;posMode:INTEGER;posOff:LONGINT):OSErr; VAR PB:ParamBlockRec; BEGIN PB.ioCompletion := ADDRESS(0); PB.ioRefNum := ref; PB.ioPosMode := posMode; PB.ioPosOffset := posOff; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(SetFPosTrap); RETURN(PB.ioResult) END SetFPos; PROCEDURE GetEOF(ref:INTEGER;VAR logEOF:LONGINT):OSErr; VAR PB:ParamBlockRec; BEGIN PB.ioCompletion := ADDRESS(0); PB.ioRefNum := ref; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(GetEOFTrap); logEOF := PB.ioMisc; RETURN(PB.ioResult); END GetEOF; PROCEDURE SetEOF(ref:INTEGER;logEOF:LONGINT):OSErr; VAR PB:ParamBlockRec; BEGIN PB.ioCompletion := ADDRESS(0); PB.ioRefNum := ref; PB.ioMisc := ADDRESS(logEOF); SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(SetEOFTrap); RETURN(PB.ioResult); END SetEOF; PROCEDURE Allocate(ref:INTEGER;VAR count:LONGINT):OSErr; VAR PB:ParamBlockRec; BEGIN PB.ioCompletion := ADDRESS(0); PB.ioRefNum := ref; PB.ioReqCount := count; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(AllocateTrap); count := PB.ioActCount; RETURN(PB.ioResult); END Allocate; PROCEDURE FSClose(ref:INTEGER):OSErr; VAR PB:ParamBlockRec; BEGIN FreeBuffer(ref); PB.ioCompletion := ADDRESS(0); PB.ioRefNum := ref; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(CloseTrap); RETURN(PB.ioResult); END FSClose; (* Changing Information About Files *) PROCEDURE GetFInfo(VAR file:ARRAY OF CHAR;vRef:INTEGER;VAR fndr:FInfo):OSErr; VAR PB:ParamBlockRec; Str:ARRAY[0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); MakePascalString(file,Str); PB.ioNamePtr := ADR(Str); PB.ioVRefNum := vRef; PB.ioVersNum := 0C; PB.ioFDirIndex := 0; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(GetFileInfoTrap); IF (PB.ioResult = noErr) THEN fndr := PB.ioFlFndrInfo END; RETURN(PB.ioResult); END GetFInfo; PROCEDURE SetFInfo(VAR file:ARRAY OF CHAR;vRef:INTEGER;fndrInfo:FInfo):OSErr; VAR PB:ParamBlockRec; Str:ARRAY[0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); MakePascalString(file,Str); PB.ioNamePtr := ADR(Str); PB.ioVRefNum := vRef; PB.ioVersNum := 0C; PB.ioFDirIndex := 0; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(GetFileInfoTrap); (* get create/modification times *) PB.ioFlFndrInfo := fndrInfo; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(SetFileInfoTrap); RETURN(PB.ioResult); END SetFInfo; PROCEDURE SetFLock(VAR file:ARRAY OF CHAR;vRef:INTEGER):OSErr; VAR PB:ParamBlockRec; Str:ARRAY[0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); MakePascalString(file,Str); PB.ioNamePtr := ADR(Str); PB.ioVRefNum := vRef; PB.ioVersNum := 0C; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(SetFilLockTrap); RETURN(PB.ioResult); END SetFLock; PROCEDURE RstFLock(VAR file:ARRAY OF CHAR;vRef:INTEGER):OSErr; VAR PB:ParamBlockRec; Str:ARRAY[0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); MakePascalString(file,Str); PB.ioNamePtr := ADR(Str); PB.ioVRefNum := vRef; PB.ioVersNum := 0C; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(RstFilLockTrap); RETURN(PB.ioResult); END RstFLock; PROCEDURE Rename(VAR old:ARRAY OF CHAR;vRef:INTEGER; VAR new:ARRAY OF CHAR):OSErr; VAR PB:ParamBlockRec; Str,Str2:ARRAY[0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); MakePascalString(old,Str); PB.ioNamePtr := ADR(Str); PB.ioVRefNum := vRef; PB.ioVersNum := 0C; MakePascalString(new,Str2); PB.ioMisc := ADR(Str2); SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(RenameTrap); RETURN(PB.ioResult); END Rename; PROCEDURE FSDelete(VAR name:ARRAY OF CHAR;vRef:INTEGER):OSErr; VAR PB:ParamBlockRec; Str:ARRAY[0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); MakePascalString(name,Str); PB.ioNamePtr := ADR(Str); PB.ioVRefNum := vRef; PB.ioVersNum := 0C; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(DeleteTrap); RETURN(PB.ioResult); END FSDelete; BEGIN HEAD := NIL END FileManager. !Funky!Stuff! echo x - FileTypes.MOD cat >FileTypes.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE FileTypes; (* * Empty implementation *) END FileTypes. !Funky!Stuff! echo x - FontManager.MOD cat >FontManager.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE FontManager; FROM SYSTEM IMPORT ADDRESS,WORD,CODE,ADR,REGISTER; FROM MacSYSTEM IMPORT LONGINT; FROM PascalStrings IMPORT MakePascalString,MakeModulaString; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) PROCEDURE xGetFontName(fontNumber:INTEGER;name:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8FFH); CODE(RestoreA7);CODE(Return); END xGetFontName; PROCEDURE GetFontName(fontNumber:INTEGER;VAR name:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR s1:ARRAY [0..255] OF CHAR; BEGIN xGetFontName(fontNumber,ADR(s1)); MakeModulaString(s1,name); END GetFontName; PROCEDURE xGetFNum(name:ADDRESS;VAR fontNumber:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A900H); CODE(RestoreA7);CODE(Return); END xGetFNum; PROCEDURE GetFNum(VAR name:ARRAY OF CHAR;VAR fontNumber:INTEGER); (*$P+*)(*$S-*) VAR s1:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(name,s1); xGetFNum(ADR(s1),fontNumber) END GetFNum; PROCEDURE RealFont(fontNumber:INTEGER;pointSize:INTEGER):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A902H); CODE(RestoreA7);CODE(Return); END RealFont; PROCEDURE GetFontInfo(VAR info:FontInfo); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A88BH); CODE(RestoreA7);CODE(Return); END GetFontInfo; PROCEDURE SetFontLock(lock:BOOLEAN); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A903H); CODE(RestoreA7);CODE(Return); END SetFontLock; PROCEDURE FMSwapFont (inRec: FMInput) : FMOutPtr; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A901H); CODE(RestoreA7);CODE(Return); END FMSwapFont; BEGIN CODE(0A8FEH); (* INIT FONTS *) END FontManager. !Funky!Stuff! echo x - IUPackage.MOD cat >IUPackage.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE IUPackage; FROM SYSTEM IMPORT ADDRESS,CODE,ADR; FROM MacSYSTEM IMPORT LONGINT,Handle; FROM PascalStrings IMPORT MakeModulaString; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) Pack6 = 0A9EDH; pIUDatePString = 14; pIUDateString = 0; pIUGetIntl = 6; pIUMagIDString = 12; pIUMagString = 10; pIUMetric = 4; pIUSetIntl = 8; pIUTimePString = 16; pIUTimeString = 2; Push = 03F3CH; (* MOVE #VAL,-(A7) *) (* Routines *) PROCEDURE xIUDateString (dateTime:LONGINT;form:DateForm;result:ADDRESS); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(pIUDateString); CODE(Pack6); CODE(RestoreA7); CODE(Return); END xIUDateString; PROCEDURE IUDateString (dateTime:LONGINT;form:DateForm; VAR result:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN xIUDateString(dateTime,form,ADR(Str)); MakeModulaString(Str,result) END IUDateString; PROCEDURE xIUDatePString (dateTime:LONGINT;form:DateForm; result:ADDRESS;intlParam:Handle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(pIUDatePString); CODE(Pack6); CODE(RestoreA7); CODE(Return); END xIUDatePString; PROCEDURE IUDatePString (dateTime:LONGINT;form:DateForm; VAR result:ARRAY OF CHAR;intlParam:Handle); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN xIUDatePString(dateTime,form,ADR(Str),intlParam); MakeModulaString(Str,result) END IUDatePString; PROCEDURE xIUTimeString(dateTime:LONGINT;wantSeconds:BOOLEAN;result:ADDRESS); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(pIUTimeString); CODE(Pack6); CODE(RestoreA7); CODE(Return); END xIUTimeString; PROCEDURE IUTimeString(dateTime:LONGINT;wantSeconds:BOOLEAN; VAR result:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN xIUTimeString(dateTime,wantSeconds,ADR(Str)); MakeModulaString(Str,result) END IUTimeString; PROCEDURE xIUTimePString(dateTime:LONGINT;wantSeconds:BOOLEAN; result:ADDRESS; intlParam:Handle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(pIUTimePString); CODE(Pack6); CODE(RestoreA7); CODE(Return); END xIUTimePString; PROCEDURE IUTimePString(dateTime:LONGINT;wantSeconds:BOOLEAN; VAR result:ARRAY OF CHAR; intlParam:Handle); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN xIUTimePString(dateTime,wantSeconds,ADR(Str),intlParam); MakeModulaString(Str,result); END IUTimePString; PROCEDURE IUMetric():BOOLEAN; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(pIUMetric); CODE(Pack6); CODE(RestoreA7); CODE(Return); END IUMetric; PROCEDURE IUGetIntl(theID:INTEGER):Handle; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(pIUGetIntl); CODE(Pack6); CODE(RestoreA7); CODE(Return); END IUGetIntl; PROCEDURE IUSetIntl(refNum:INTEGER; theID:INTEGER;intlParam:Handle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(pIUSetIntl); CODE(Pack6); CODE(RestoreA7); CODE(Return); END IUSetIntl; PROCEDURE IUCompString(VAR aStr,bStr:ARRAY OF CHAR):INTEGER; (*$P+*)(*$S-*) VAR BEGIN RETURN(IUMagString(ADR(aStr),ADR(bStr),HIGH(aStr),HIGH(bStr))) END IUCompString; PROCEDURE IUMagString(aPtr,bPtr:ADDRESS;aLen,bLen:INTEGER):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(pIUMagString); CODE(Pack6); CODE(RestoreA7); CODE(Return); END IUMagString; PROCEDURE IUEqualString(VAR aStr,bStr:ARRAY OF CHAR):INTEGER; (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN RETURN(IUMagIDString(ADR(aStr),ADR(bStr),HIGH(aStr),HIGH(bStr))) END IUEqualString; PROCEDURE IUMagIDString(aPtr,bPtr:ADDRESS;aLen,bLen:INTEGER):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(pIUMagIDString); CODE(Pack6); CODE(RestoreA7); CODE(Return); END IUMagIDString; END IUPackage. !Funky!Stuff! echo x - InOut.MOD cat >InOut.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE InOut; (* * copied from the book "PROGRAMMING IN * MODULA-2" by Miklaus Wirth Edited by * David Gries pages 103 and 104. *) FROM SYSTEM IMPORT ADDRESS,WORD,ADR; FROM MacSYSTEM IMPORT LONGINT,OSErr; FROM QuickDraw IMPORT Point; IMPORT Terminal; FROM FileManager IMPORT OSType,FSOpen,FSClose,Create,FSRead,FSWrite,FSDelete,eofErr,opWrErr; FROM SFPackage IMPORT SFPutFile,SFGetFile,SFReply,SFTypeList,NoFileFilter,NoDlg; FROM Conversions IMPORT OctToStr, HexToStr,CardToStr, IntToStr,StrToOct,StrToHex,StrToCard,StrToInt; VAR InIsTerm: BOOLEAN; OutIsTerm: BOOLEAN; In: INTEGER; Out: INTEGER; PROCEDURE OpenInput (VAR defext: ARRAY OF CHAR); VAR Reply: SFReply; List: SFTypeList; P: Point; Ret: INTEGER; (* request a file name and open input file "in". * Done := "file was successfully opened". * If open, subsequent input is read from this * file. If name ends with ".", append extension defext *) (* This procedure will used the SFPackage on the Mac, * and the defext will not be used. BC *) BEGIN List[0] := 'TEXT'; P.h := 70; P.v := 100; SFGetFile(P,'Open What File?',NoFileFilter(),1,List,ADDRESS(0),Reply); IF (Reply.good) THEN Ret := FSOpen(Reply.fName,Reply.vRefNum,In); IF (Ret = 0) OR (Ret = opWrErr) THEN InIsTerm := FALSE; Done := TRUE ELSE Done := FALSE END; ELSE Done := FALSE; END END OpenInput; PROCEDURE OpenOutput (VAR defext: ARRAY OF CHAR); VAR DefName: ARRAY [0..255] OF CHAR; Reply: SFReply; P: Point; (* request a file name and open output file "out" * Done := "file was successfully opened. * If open, subsequent output is written on this file *) (* This procedure will also use the SFPackage on the Mac BC *) BEGIN P.h := 70; P.v := 100; SFPutFile(P,'Create What File?','OUTPUT.TEXT',NoDlg(),Reply); IF (Reply.good) THEN Done := FSDelete(Reply.fName,Reply.vRefNum) = 0; Done := Create(Reply.fName,Reply.vRefNum,'EDIT','TEXT') = 0; IF (FSOpen(Reply.fName,Reply.vRefNum,Out) = 0) THEN OutIsTerm := FALSE; Done := TRUE ELSE Done := TRUE END ELSE Done := FALSE; END END OpenOutput; PROCEDURE CloseInput; (* closes input file; returns input to the terminal *) BEGIN Done := FSClose(In) = 0; InIsTerm := TRUE; (* even if Close Fails Input becomes terminal again *) END CloseInput; PROCEDURE CloseOutput; (* closes output file; returns output to terminal*) BEGIN IF (NOT OutIsTerm) THEN Done := FSClose(Out) = 0; OutIsTerm := TRUE; END (* even if Close Fails Input becomes terminal again *) END CloseOutput; PROCEDURE Read (VAR ch:CHAR); (* Done := NOT in.eof *) VAR count : LONGINT; BEGIN IF (InIsTerm) THEN Terminal.Read(ch); (* Terminal Input can't fail? *) Done := TRUE; ELSE count := 1; Done := FSRead(In,count,ADR(ch)) = 0; IF (NOT Done) THEN ch := 0C END END END Read; PROCEDURE ReadString (VAR s:ARRAY OF CHAR); (* read string, i.e. sequence of characters not containing * blanks nor control characters; leading blanks are ignored. * Input is terminated by any character <= " "; * this character is assigned to termCH. * DEL is used for backspacing when input from terminal*) (* I will make this a backspace for the Mac BC *) VAR I: CARDINAL; BEGIN I := 0; REPEAT Read(s[I]) UNTIL ((s[I] # ' ') OR (NOT Done)); LOOP IF (s[I] = 10C) THEN (* BackSpace *) IF (I > 0) THEN I := I - 1 END ELSIF (s[I] <= ' ') THEN termCH := s[I]; s[I] := 0C; (* NULL TERMINATED STRINGS *) EXIT ELSIF (I >= HIGH(s)) THEN termCH := 0C; EXIT ELSE INC(I); Read(s[I]); IF (NOT Done) THEN s[I] := 0C; termCH := 0C; IF (I = 0) THEN Done := FALSE; (* End Of File *) ELSE Done := TRUE END; EXIT END END END (* LOOP *) END ReadString; PROCEDURE ReadInt (VAR x:INTEGER); (* read strings and convert to integer. Syntax: * integer = ["+"|"-"]digit{digit}. * leading blanks are ignored. * Done := "integer was read" *) VAR String: ARRAY [0..30] OF CHAR; BEGIN ReadString(String); Done := StrToInt(String,x); END ReadInt; PROCEDURE ReadCard (VAR x:CARDINAL); (* read string and convert to cardinal. Syntax: * cardinal = digit {digit} * Leading blanks are ignored. * Done := "cardinal was read" *) VAR String: ARRAY [0..30] OF CHAR; BEGIN ReadString(String); Done := StrToCard(String,x); END ReadCard; PROCEDURE Write (ch:CHAR); VAR count : LONGINT; BEGIN IF (OutIsTerm) THEN IF (ch = EOL) THEN Terminal.WriteLn ELSE Terminal.Write(ch) END; Done := TRUE ELSE count := 1; Done := FSWrite(Out,count,ADR(ch)) = 0; END END Write; PROCEDURE WriteLn; (*terminate line*) BEGIN Write(EOL); END WriteLn; PROCEDURE WriteString (VAR s:ARRAY OF CHAR); (* I will follow the convention here that a String Is upto * The LENGTH of the STRING or Ends at the First Null *) VAR i: CARDINAL; BEGIN i := 0; REPEAT IF (i <= HIGH(s)) THEN IF (s[i] = 0C) THEN i := HIGH(s) + 1; (* Let's Try This *) ELSE Write(s[i]); INC(i) END END UNTIL (i > HIGH(s)) END WriteString; PROCEDURE WriteInt (x: INTEGER; n: CARDINAL); VAR str : ARRAY [0..7] OF CHAR; i : CARDINAL; BEGIN IF (n > 8) THEN FOR i := 1 TO n - 8 DO Write(' ') END; n := 7; END; Done := IntToStr(x,str,n); WriteString(str); END WriteInt; PROCEDURE WriteCard (x,n: CARDINAL); VAR str : ARRAY [0..7] OF CHAR; i : CARDINAL; BEGIN IF (n > 8) THEN FOR i := 1 TO n - 8 DO Write(' ') END; n := 7; END; Done := CardToStr(x,str,n); WriteString(str); END WriteCard; PROCEDURE WriteOct (x: WORD; n: CARDINAL); VAR str : ARRAY [0..7] OF CHAR; i : CARDINAL; BEGIN IF (n > 8) THEN FOR i := 1 TO n - 8 DO Write(' ') END; n := 7; END; Done := OctToStr(x,str,n); WriteString(str); END WriteOct; PROCEDURE WriteHex (x:WORD;n: CARDINAL); VAR str : ARRAY [0..7] OF CHAR; i : CARDINAL; BEGIN IF (n > 8) THEN FOR i := 1 TO n - 8 DO Write(' ') END; n := 7; END; Done := HexToStr(x,str,n); WriteString(str); END WriteHex; BEGIN (* InOut Init *) InIsTerm := TRUE; OutIsTerm := TRUE; END InOut. !Funky!Stuff! echo x - MacSYSTEM.MOD cat >MacSYSTEM.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE MacSYSTEM; (* EMPTY IMPLEMENTATION *) END MacSYSTEM. !Funky!Stuff! # The rest of this file is a shell script which will extract: # EventManager.MOD FileManager.MOD FileTypes.MOD FontManager.MOD IUPackage.MOD InOut.MOD MacSYSTEM.MOD echo x - EventManager.MOD cat >EventManager.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE EventManager; (* MacIntosh ToolBox Event Manager Operations *) FROM MacSYSTEM IMPORT LONGINT,OSErr; FROM QuickDraw IMPORT Point; FROM SYSTEM IMPORT ADDRESS,CODE,SETREG,REGISTER,ADR,WORD; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) VAR SysEvtMask[00000144H]:CARDINAL; PROCEDURE EventAvail(mask:WORD; VAR theEvent: EventRecord):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A971H); CODE(RestoreA7);CODE(Return); END EventAvail; PROCEDURE GetNextEvent(mask:WORD; VAR theEvent: EventRecord):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A970H); CODE(RestoreA7);CODE(Return); END GetNextEvent; PROCEDURE StillDown():BOOLEAN; (* INLINE $A973;*) (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A973H); CODE(RestoreA7);CODE(Return); END StillDown; PROCEDURE WaitMouseUp():BOOLEAN; (* INLINE $A977;*) (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A977H); CODE(RestoreA7);CODE(Return); END WaitMouseUp; PROCEDURE xGetMouse (VAR pt: LONGINT); (* INLINE $A972;*) (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A972H); CODE(RestoreA7);CODE(Return); END xGetMouse; PROCEDURE GetMouse (VAR pt: Point); (*$P+*)(*$S-*) BEGIN xGetMouse(pt.param); END GetMouse; PROCEDURE TickCount():LONGINT; (* INLINE $A975;*) (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A975H); CODE(RestoreA7);CODE(Return); END TickCount; PROCEDURE Button():BOOLEAN; (*INLINE $A974;*) (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A974H); CODE(RestoreA7);CODE(Return); END Button; PROCEDURE GetKeys(VAR k: KeyMap); (*INLINE $A976;*) (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A976H); CODE(RestoreA7);CODE(Return); END GetKeys; PROCEDURE PostEvent (eventNum: WORD; eventMsg: LONGINT): OSErr; (*$P+*)(*$S-*) BEGIN SETREG(8,eventNum); SETREG(0,eventMsg); CODE(0A02FH); RETURN(INTEGER(REGISTER(0))); END PostEvent; PROCEDURE FlushEvents (whichMask,stopMask: WORD); (*$P+*)(*$S-*) BEGIN CODE(0202EH);CODE(00008H); (* MOVE.L 8(A6),D0 *) CODE(0A032H); END FlushEvents; PROCEDURE SetEventMask (theMask: WORD); BEGIN SysEvtMask := CARDINAL(theMask) END SetEventMask; PROCEDURE OSEventAvail (mask: WORD; VAR theEvent: EventRecord): BOOLEAN; BEGIN SETREG(8,ADR(theEvent)); SETREG(0,mask); CODE(0A030H); RETURN(REGISTER(0) = 0) END OSEventAvail; PROCEDURE GetOSEvent (mask: WORD; VAR theEvent: EventRecord): BOOLEAN; BEGIN SETREG(8,ADR(theEvent)); SETREG(0,mask); CODE(0A031H); RETURN(REGISTER(0) = 0); END GetOSEvent; END EventManager. !Funky!Stuff! echo x - FileManager.MOD cat >FileManager.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE FileManager; FROM SYSTEM IMPORT ADR,REGISTER,SETREG,CODE,ADDRESS,WORD; FROM Storage IMPORT ALLOCATE,DEALLOCATE; FROM PascalStrings IMPORT MakeModulaString,MakePascalString; FROM MacSYSTEM IMPORT LONGINT,StringPtr,OSErr,noErr; FROM FileTypes IMPORT (*CONST*) opWrErr,permErr, (*TYPE*) OSType,FInfo,ParamBlkPtr,ParamBlkType,ParamBlockRec; CONST OpenTrap = 0A000H; CloseTrap = 0A001H; ReadTrap = 0A002H; WriteTrap = 0A003H; ControlTrap = 0A004H; StatusTrap = 0A005H; KillIOTrap = 0A006H; GetVolInfoTrap = 0A007H; CreateTrap = 0A008H; DeleteTrap = 0A009H; OpenRFTrap = 0A00AH; RenameTrap = 0A00BH; GetFileInfoTrap = 0A00CH; SetFileInfoTrap = 0A00DH; UnmountVolTrap = 0A00EH; MountVolTrap = 0A00FH; AllocateTrap = 0A010H; GetEOFTrap = 0A011H; SetEOFTrap = 0A012H; FlushVolTrap = 0A013H; GetVolTrap = 0A014H; SetVolTrap = 0A015H; FInitQueueTrap = 0A016H; EjectTrap = 0A017H; GetFPosTrap = 0A018H; SetFilLockTrap = 0A041H; RstFilLockTrap = 0A042H; SetFilTypeTrap = 0A043H; SetFPosTrap = 0A044H; FlushFileTrap = 0A045H; TYPE SaveRecPtr= POINTER TO SaveRec; SaveRec = RECORD Next : SaveRecPtr; Buffer : ADDRESS; FileNum: INTEGER END; VAR HEAD : SaveRecPtr; PROCEDURE SaveBuffer(ref:INTEGER; buf : ADDRESS); (* remember the address of the file buffer *) VAR p : SaveRecPtr; BEGIN NEW(p); IF (p # NIL) THEN p^.Buffer := buf; p^.FileNum := ref; p^.Next := HEAD; HEAD := p END END SaveBuffer; PROCEDURE FreeBuffer(ref:INTEGER); (* free up the file buffer *) VAR p,q : SaveRecPtr; BEGIN p := HEAD; q := NIL; WHILE (p # NIL) DO IF (p^.FileNum = ref) THEN DEALLOCATE(p^.Buffer,524); p^.FileNum := 0; IF (q = NIL) THEN HEAD := p^.Next ELSE q^.Next := p^.Next END; DISPOSE(p); RETURN END; q := p; p := q^.Next END END FreeBuffer; (* Accessing Volumes *) PROCEDURE GetVInfo(drive:INTEGER;vol:StringPtr; VAR vRef:INTEGER;VAR free:LONGINT):OSErr; VAR PB:ParamBlockRec; TmpString: ARRAY [0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); IF (vol # NIL) AND (vol # StringPtr(0)) THEN PB.ioNamePtr := ADR(TmpString); MakePascalString(vol^,PB.ioNamePtr^); ELSE PB.ioNamePtr := StringPtr(0) END; PB.ioVolIndex := drive; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(GetVolInfoTrap); IF (vol # NIL) AND (vol # StringPtr(0)) THEN MakeModulaString(PB.ioNamePtr^,vol^); END; vRef := PB.ioVRefNum; free := LONGINT(PB.ioVFrBlk) * PB.ioVAlBlkSiz; RETURN(PB.ioResult); END GetVInfo; PROCEDURE GetVol(volName:StringPtr;VAR vRefNum:INTEGER):OSErr; VAR PB:ParamBlockRec; TmpString: ARRAY [0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); IF (volName # StringPtr(0)) AND (volName # NIL) THEN PB.ioNamePtr := StringPtr(0) ELSE PB.ioNamePtr := ADR(TmpString); END; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(GetVolTrap); IF (volName # StringPtr(0)) AND (volName # NIL) THEN MakeModulaString(PB.ioNamePtr^,volName^); END; vRefNum := PB.ioVRefNum; RETURN(PB.ioResult); END GetVol; PROCEDURE SetVol(volName:StringPtr;vRefNum:INTEGER):OSErr; VAR PB:ParamBlockRec; Str:ARRAY [0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); IF (volName # StringPtr(0)) AND (volName # NIL) THEN MakePascalString(volName^,Str); PB.ioNamePtr := ADR(Str); ELSE PB.ioNamePtr := StringPtr(0) END; PB.ioVRefNum := vRefNum; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(SetVolTrap); RETURN(PB.ioResult); END SetVol; PROCEDURE FlushVol(volName:StringPtr;vRefNum:INTEGER):OSErr; VAR PB:ParamBlockRec; Str:ARRAY [0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); IF (volName # NIL) AND (volName # StringPtr(0)) THEN MakePascalString(volName^,Str); PB.ioNamePtr := ADR(Str) ELSE PB.ioNamePtr := StringPtr(0) END; PB.ioVRefNum := vRefNum; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(FlushVolTrap); RETURN(PB.ioResult); END FlushVol; PROCEDURE UnmountVol(volName:StringPtr;vRefNum:INTEGER):OSErr; VAR PB:ParamBlockRec; Str:ARRAY [0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); IF (volName # NIL) AND (volName # StringPtr(0)) THEN MakePascalString(volName^,Str); PB.ioNamePtr := ADR(Str) ELSE PB.ioNamePtr := StringPtr(0) END; PB.ioVRefNum := vRefNum; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(UnmountVolTrap); RETURN(PB.ioResult); END UnmountVol; PROCEDURE Eject(volName:StringPtr;vRefNum:INTEGER):OSErr; VAR PB:ParamBlockRec; Str:ARRAY [0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); IF (volName # NIL) AND (volName # StringPtr(0)) THEN MakePascalString(volName^,Str); PB.ioNamePtr := ADR(Str) ELSE PB.ioNamePtr := StringPtr(0) END; PB.ioVRefNum := vRefNum; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(EjectTrap); RETURN(PB.ioResult); END Eject; (* Changine File Contents *) PROCEDURE Create(VAR Name:ARRAY OF CHAR;vRef:INTEGER; creator,type:OSType):OSErr; VAR PB:ParamBlockRec; Str:ARRAY[0..255] OF CHAR; f:FInfo; ret:OSErr; BEGIN PB.ioCompletion := ADDRESS(0); MakePascalString(Name,Str); PB.ioNamePtr := ADR(Str); PB.ioVRefNum := vRef; PB.ioFVersNum := 0C; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(CreateTrap); IF (PB.ioResult <> noErr) THEN RETURN(PB.ioResult); END; ret := GetFInfo(Name,vRef,f); IF (ret <>noErr) THEN RETURN(ret) END; f.fdType := type; f.fdCreator := creator; RETURN(SetFInfo(Name,vRef,f)); END Create; PROCEDURE FSOpen(VAR Name:ARRAY OF CHAR;vRef:INTEGER; VAR ref:INTEGER):OSErr; VAR PB:ParamBlockRec; Str:ARRAY[0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); MakePascalString(Name,Str); PB.ioNamePtr := ADR(Str); PB.ioVRefNum := vRef; PB.ioVersNum := 0C; PB.ioPermssn := 0C; ALLOCATE(PB.ioMisc,524); IF (PB.ioMisc = NIL) THEN PB.ioMisc := ADDRESS(0) END; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(OpenTrap); ref := PB.ioRefNum; IF (PB.ioMisc # ADDRESS(0)) THEN IF ((PB.ioResult = noErr) OR (PB.ioResult = opWrErr) OR (PB.ioResult = permErr)) THEN SaveBuffer(ref,PB.ioMisc); ELSE DEALLOCATE(PB.ioMisc,524) END END; RETURN(PB.ioResult); END FSOpen; PROCEDURE FSRead(refNum:INTEGER;VAR count:LONGINT;buff:ADDRESS):OSErr; VAR PB:ParamBlockRec; BEGIN PB.ioCompletion := ADDRESS(0); PB.ioRefNum := refNum; PB.ioReqCount := count; PB.ioPosMode := 0; PB.ioPosOffset := 0; PB.ioBuffer := buff; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(ReadTrap); count := PB.ioActCount; RETURN(PB.ioResult); END FSRead; PROCEDURE FSWrite(ref:INTEGER;VAR count:LONGINT;buff:ADDRESS):OSErr; VAR PB:ParamBlockRec; BEGIN PB.ioCompletion := ADDRESS(0); PB.ioRefNum := ref; PB.ioReqCount := count; PB.ioPosMode := 0; PB.ioPosOffset := 0; PB.ioBuffer := buff; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(WriteTrap); count := PB.ioActCount; RETURN(PB.ioResult); END FSWrite; PROCEDURE GetFPos(refNum:INTEGER;VAR filePos:LONGINT):OSErr; VAR PB:ParamBlockRec; BEGIN PB.ioCompletion := ADDRESS(0); PB.ioRefNum := refNum; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(GetFPosTrap); filePos := PB.ioPosOffset; RETURN(PB.ioResult); END GetFPos; PROCEDURE SetFPos(ref:INTEGER;posMode:INTEGER;posOff:LONGINT):OSErr; VAR PB:ParamBlockRec; BEGIN PB.ioCompletion := ADDRESS(0); PB.ioRefNum := ref; PB.ioPosMode := posMode; PB.ioPosOffset := posOff; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(SetFPosTrap); RETURN(PB.ioResult) END SetFPos; PROCEDURE GetEOF(ref:INTEGER;VAR logEOF:LONGINT):OSErr; VAR PB:ParamBlockRec; BEGIN PB.ioCompletion := ADDRESS(0); PB.ioRefNum := ref; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(GetEOFTrap); logEOF := PB.ioMisc; RETURN(PB.ioResult); END GetEOF; PROCEDURE SetEOF(ref:INTEGER;logEOF:LONGINT):OSErr; VAR PB:ParamBlockRec; BEGIN PB.ioCompletion := ADDRESS(0); PB.ioRefNum := ref; PB.ioMisc := ADDRESS(logEOF); SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(SetEOFTrap); RETURN(PB.ioResult); END SetEOF; PROCEDURE Allocate(ref:INTEGER;VAR count:LONGINT):OSErr; VAR PB:ParamBlockRec; BEGIN PB.ioCompletion := ADDRESS(0); PB.ioRefNum := ref; PB.ioReqCount := count; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(AllocateTrap); count := PB.ioActCount; RETURN(PB.ioResult); END Allocate; PROCEDURE FSClose(ref:INTEGER):OSErr; VAR PB:ParamBlockRec; BEGIN FreeBuffer(ref); PB.ioCompletion := ADDRESS(0); PB.ioRefNum := ref; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(CloseTrap); RETURN(PB.ioResult); END FSClose; (* Changing Information About Files *) PROCEDURE GetFInfo(VAR file:ARRAY OF CHAR;vRef:INTEGER;VAR fndr:FInfo):OSErr; VAR PB:ParamBlockRec; Str:ARRAY[0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); MakePascalString(file,Str); PB.ioNamePtr := ADR(Str); PB.ioVRefNum := vRef; PB.ioVersNum := 0C; PB.ioFDirIndex := 0; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(GetFileInfoTrap); IF (PB.ioResult = noErr) THEN fndr := PB.ioFlFndrInfo END; RETURN(PB.ioResult); END GetFInfo; PROCEDURE SetFInfo(VAR file:ARRAY OF CHAR;vRef:INTEGER;fndrInfo:FInfo):OSErr; VAR PB:ParamBlockRec; Str:ARRAY[0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); MakePascalString(file,Str); PB.ioNamePtr := ADR(Str); PB.ioVRefNum := vRef; PB.ioVersNum := 0C; PB.ioFDirIndex := 0; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(GetFileInfoTrap); (* get create/modification times *) PB.ioFlFndrInfo := fndrInfo; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(SetFileInfoTrap); RETURN(PB.ioResult); END SetFInfo; PROCEDURE SetFLock(VAR file:ARRAY OF CHAR;vRef:INTEGER):OSErr; VAR PB:ParamBlockRec; Str:ARRAY[0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); MakePascalString(file,Str); PB.ioNamePtr := ADR(Str); PB.ioVRefNum := vRef; PB.ioVersNum := 0C; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(SetFilLockTrap); RETURN(PB.ioResult); END SetFLock; PROCEDURE RstFLock(VAR file:ARRAY OF CHAR;vRef:INTEGER):OSErr; VAR PB:ParamBlockRec; Str:ARRAY[0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); MakePascalString(file,Str); PB.ioNamePtr := ADR(Str); PB.ioVRefNum := vRef; PB.ioVersNum := 0C; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(RstFilLockTrap); RETURN(PB.ioResult); END RstFLock; PROCEDURE Rename(VAR old:ARRAY OF CHAR;vRef:INTEGER; VAR new:ARRAY OF CHAR):OSErr; VAR PB:ParamBlockRec; Str,Str2:ARRAY[0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); MakePascalString(old,Str); PB.ioNamePtr := ADR(Str); PB.ioVRefNum := vRef; PB.ioVersNum := 0C; MakePascalString(new,Str2); PB.ioMisc := ADR(Str2); SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(RenameTrap); RETURN(PB.ioResult); END Rename; PROCEDURE FSDelete(VAR name:ARRAY OF CHAR;vRef:INTEGER):OSErr; VAR PB:ParamBlockRec; Str:ARRAY[0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); MakePascalString(name,Str); PB.ioNamePtr := ADR(Str); PB.ioVRefNum := vRef; PB.ioVersNum := 0C; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(DeleteTrap); RETURN(PB.ioResult); END FSDelete; BEGIN HEAD := NIL END FileManager. !Funky!Stuff! echo x - FileTypes.MOD cat >FileTypes.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE FileTypes; (* * Empty implementation *) END FileTypes. !Funky!Stuff! echo x - FontManager.MOD cat >FontManager.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE FontManager; FROM SYSTEM IMPORT ADDRESS,WORD,CODE,ADR,REGISTER; FROM MacSYSTEM IMPORT LONGINT; FROM PascalStrings IMPORT MakePascalString,MakeModulaString; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) PROCEDURE xGetFontName(fontNumber:INTEGER;name:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8FFH); CODE(RestoreA7);CODE(Return); END xGetFontName; PROCEDURE GetFontName(fontNumber:INTEGER;VAR name:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR s1:ARRAY [0..255] OF CHAR; BEGIN xGetFontName(fontNumber,ADR(s1)); MakeModulaString(s1,name); END GetFontName; PROCEDURE xGetFNum(name:ADDRESS;VAR fontNumber:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A900H); CODE(RestoreA7);CODE(Return); END xGetFNum; PROCEDURE GetFNum(VAR name:ARRAY OF CHAR;VAR fontNumber:INTEGER); (*$P+*)(*$S-*) VAR s1:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(name,s1); xGetFNum(ADR(s1),fontNumber) END GetFNum; PROCEDURE RealFont(fontNumber:INTEGER;pointSize:INTEGER):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A902H); CODE(RestoreA7);CODE(Return); END RealFont; PROCEDURE GetFontInfo(VAR info:FontInfo); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A88BH); CODE(RestoreA7);CODE(Return); END GetFontInfo; PROCEDURE SetFontLock(lock:BOOLEAN); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A903H); CODE(RestoreA7);CODE(Return); END SetFontLock; PROCEDURE FMSwapFont (inRec: FMInput) : FMOutPtr; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A901H); CODE(RestoreA7);CODE(Return); END FMSwapFont; BEGIN CODE(0A8FEH); (* INIT FONTS *) END FontManager. !Funky!Stuff! echo x - IUPackage.MOD cat >IUPackage.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE IUPackage; FROM SYSTEM IMPORT ADDRESS,CODE,ADR; FROM MacSYSTEM IMPORT LONGINT,Handle; FROM PascalStrings IMPORT MakeModulaString; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) Pack6 = 0A9EDH; pIUDatePString = 14; pIUDateString = 0; pIUGetIntl = 6; pIUMagIDString = 12; pIUMagString = 10; pIUMetric = 4; pIUSetIntl = 8; pIUTimePString = 16; pIUTimeString = 2; Push = 03F3CH; (* MOVE #VAL,-(A7) *) (* Routines *) PROCEDURE xIUDateString (dateTime:LONGINT;form:DateForm;result:ADDRESS); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(pIUDateString); CODE(Pack6); CODE(RestoreA7); CODE(Return); END xIUDateString; PROCEDURE IUDateString (dateTime:LONGINT;form:DateForm; VAR result:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN xIUDateString(dateTime,form,ADR(Str)); MakeModulaString(Str,result) END IUDateString; PROCEDURE xIUDatePString (dateTime:LONGINT;form:DateForm; result:ADDRESS;intlParam:Handle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(pIUDatePString); CODE(Pack6); CODE(RestoreA7); CODE(Return); END xIUDatePString; PROCEDURE IUDatePString (dateTime:LONGINT;form:DateForm; VAR result:ARRAY OF CHAR;intlParam:Handle); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN xIUDatePString(dateTime,form,ADR(Str),intlParam); MakeModulaString(Str,result) END IUDatePString; PROCEDURE xIUTimeString(dateTime:LONGINT;wantSeconds:BOOLEAN;result:ADDRESS); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(pIUTimeString); CODE(Pack6); CODE(RestoreA7); CODE(Return); END xIUTimeString; PROCEDURE IUTimeString(dateTime:LONGINT;wantSeconds:BOOLEAN; VAR result:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN xIUTimeString(dateTime,wantSeconds,ADR(Str)); MakeModulaString(Str,result) END IUTimeString; PROCEDURE xIUTimePString(dateTime:LONGINT;wantSeconds:BOOLEAN; result:ADDRESS; intlParam:Handle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(pIUTimePString); CODE(Pack6); CODE(RestoreA7); CODE(Return); END xIUTimePString; PROCEDURE IUTimePString(dateTime:LONGINT;wantSeconds:BOOLEAN; VAR result:ARRAY OF CHAR; intlParam:Handle); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN xIUTimePString(dateTime,wantSeconds,ADR(Str),intlParam); MakeModulaString(Str,result); END IUTimePString; PROCEDURE IUMetric():BOOLEAN; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(pIUMetric); CODE(Pack6); CODE(RestoreA7); CODE(Return); END IUMetric; PROCEDURE IUGetIntl(theID:INTEGER):Handle; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(pIUGetIntl); CODE(Pack6); CODE(RestoreA7); CODE(Return); END IUGetIntl; PROCEDURE IUSetIntl(refNum:INTEGER; theID:INTEGER;intlParam:Handle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(pIUSetIntl); CODE(Pack6); CODE(RestoreA7); CODE(Return); END IUSetIntl; PROCEDURE IUCompString(VAR aStr,bStr:ARRAY OF CHAR):INTEGER; (*$P+*)(*$S-*) VAR BEGIN RETURN(IUMagString(ADR(aStr),ADR(bStr),HIGH(aStr),HIGH(bStr))) END IUCompString; PROCEDURE IUMagString(aPtr,bPtr:ADDRESS;aLen,bLen:INTEGER):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(pIUMagString); CODE(Pack6); CODE(RestoreA7); CODE(Return); END IUMagString; PROCEDURE IUEqualString(VAR aStr,bStr:ARRAY OF CHAR):INTEGER; (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN RETURN(IUMagIDString(ADR(aStr),ADR(bStr),HIGH(aStr),HIGH(bStr))) END IUEqualString; PROCEDURE IUMagIDString(aPtr,bPtr:ADDRESS;aLen,bLen:INTEGER):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(pIUMagIDString); CODE(Pack6); CODE(RestoreA7); CODE(Return); END IUMagIDString; END IUPackage. !Funky!Stuff! echo x - InOut.MOD cat >InOut.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE InOut; (* * copied from the book "PROGRAMMING IN * MODULA-2" by Miklaus Wirth Edited by * David Gries pages 103 and 104. *) FROM SYSTEM IMPORT ADDRESS,WORD,ADR; FROM MacSYSTEM IMPORT LONGINT,OSErr; FROM QuickDraw IMPORT Point; IMPORT Terminal; FROM FileTypes IMPORT OSType; FROM Streams IMPORT STREAM, OpenMode, ReadChar, WriteChar, Open,Close,Create,EOS; FROM SFPackage IMPORT SFPutFile,SFGetFile,SFReply,SFTypeList,NoFileFilter,NoDlg; FROM Conversions IMPORT OctToStr, HexToStr,CardToStr, IntToStr,StrToOct,StrToHex,StrToCard,StrToInt; VAR InIsTerm: BOOLEAN; OutIsTerm: BOOLEAN; InStream: STREAM; OutStream: STREAM; PROCEDURE OpenInput (VAR defext: ARRAY OF CHAR); VAR Reply: SFReply; List: SFTypeList; P: Point; Ret: INTEGER; (* request a file name and open input file "in". * Done := "file was successfully opened". * If open, subsequent input is read from this * file. If name ends with ".", append extension defext *) (* This procedure will used the SFPackage on the Mac, * and the defext will not be used. BC *) BEGIN List[0] := 'TEXT'; P.h := 70; P.v := 100; SFGetFile(P,'Open What File?',NoFileFilter(),1,List,ADDRESS(0),Reply); IF (Reply.good) THEN Open(InStream,Reply.fName,Reply.vRefNum,ReadOnly); IF InStream # NIL THEN InIsTerm := FALSE; Done := TRUE ELSE Done := FALSE END; ELSE Done := FALSE; END END OpenInput; PROCEDURE OpenOutput (VAR defext: ARRAY OF CHAR); VAR DefName: ARRAY [0..255] OF CHAR; Reply: SFReply; P: Point; (* request a file name and open output file "out" * Done := "file was successfully opened. * If open, subsequent output is written on this file *) (* This procedure will also use the SFPackage on the Mac BC *) BEGIN P.h := 70; P.v := 100; SFPutFile(P,'Create What File?','OUTPUT.TEXT',NoDlg(),Reply); IF (Reply.good) THEN Create(Reply.fName,Reply.vRefNum,'EDIT','TEXT'); Open(OutStream,Reply.fName,Reply.vRefNum,WriteOnly); IF (OutStream # NIL) THEN OutIsTerm := FALSE; Done := TRUE ELSE Done := TRUE END ELSE Done := FALSE; END END OpenOutput; PROCEDURE CloseInput; (* closes input file; returns input to the terminal *) BEGIN IF (NOT InIsTerm) THEN Close(InStream); Done := TRUE END; InIsTerm := TRUE; (* even if Close Fails Input becomes terminal again *) END CloseInput; PROCEDURE CloseOutput; (* closes output file; returns output to terminal*) BEGIN IF (NOT OutIsTerm) THEN Close(OutStream); Done := TRUE; OutIsTerm := TRUE; END (* even if Close Fails Input becomes terminal again *) END CloseOutput; PROCEDURE Read (VAR ch:CHAR); (* Done := NOT in.eof *) VAR count : LONGINT; BEGIN IF (InIsTerm) THEN Terminal.Read(ch); (* Terminal Input can't fail? *) Done := TRUE; ELSE count := 1; IF (NOT EOS(InStream)) THEN ReadChar(InStream,ch); Done := TRUE ELSE ch := 0C; Done := FALSE END END END Read; PROCEDURE ReadString (VAR s:ARRAY OF CHAR); (* read string, i.e. sequence of characters not containing * blanks nor control characters; leading blanks are ignored. * Input is terminated by any character <= " "; * this character is assigned to termCH. * DEL is used for backspacing when input from terminal*) (* I will make this a backspace for the Mac BC *) VAR I: CARDINAL; BEGIN I := 0; REPEAT Read(s[I]) UNTIL ((s[I] # ' ') OR (NOT Done)); LOOP IF (s[I] = 10C) THEN (* BackSpace *) IF (I > 0) THEN I := I - 1 END ELSIF (s[I] <= ' ') THEN termCH := s[I]; s[I] := 0C; (* NULL TERMINATED STRINGS *) EXIT ELSIF (I >= HIGH(s)) THEN termCH := 0C; EXIT ELSE INC(I); Read(s[I]); IF (NOT Done) THEN s[I] := 0C; termCH := 0C; IF (I = 0) THEN Done := FALSE; (* End Of File *) ELSE Done := TRUE END; EXIT END END END (* LOOP *) END ReadString; PROCEDURE ReadInt (VAR x:INTEGER); (* read strings and convert to integer. Syntax: * integer = ["+"|"-"]digit{digit}. * leading blanks are ignored. * Done := "integer was read" *) VAR String: ARRAY [0..30] OF CHAR; BEGIN ReadString(String); Done := StrToInt(String,x); END ReadInt; PROCEDURE ReadCard (VAR x:CARDINAL); (* read string and convert to cardinal. Syntax: * cardinal = digit {digit} * Leading blanks are ignored. * Done := "cardinal was read" *) VAR String: ARRAY [0..30] OF CHAR; BEGIN ReadString(String); Done := StrToCard(String,x); END ReadCard; PROCEDURE Write (ch:CHAR); VAR count : LONGINT; BEGIN IF (OutIsTerm) THEN IF (ch = EOL) THEN Terminal.WriteLn ELSE Terminal.Write(ch) END; Done := TRUE ELSE count := 1; Done := TRUE; WriteChar(OutStream,ch) END END Write; PROCEDURE WriteLn; (*terminate line*) BEGIN Write(EOL); END WriteLn; PROCEDURE WriteString (VAR s:ARRAY OF CHAR); (* I will follow the convention here that a String Is upto * The LENGTH of the STRING or Ends at the First Null *) VAR i: CARDINAL; BEGIN i := 0; REPEAT IF (i <= HIGH(s)) THEN IF (s[i] = 0C) THEN i := HIGH(s) + 1; (* Let's Try This *) ELSE Write(s[i]); INC(i) END END UNTIL (i > HIGH(s)) END WriteString; PROCEDURE WriteInt (x: INTEGER; n: CARDINAL); VAR str : ARRAY [0..7] OF CHAR; i : CARDINAL; BEGIN IF (n > 8) THEN FOR i := 1 TO n - 8 DO Write(' ') END; n := 7; END; Done := IntToStr(x,str,n); WriteString(str); END WriteInt; PROCEDURE WriteCard (x,n: CARDINAL); VAR str : ARRAY [0..7] OF CHAR; i : CARDINAL; BEGIN IF (n > 8) THEN FOR i := 1 TO n - 8 DO Write(' ') END; n := 7; END; Done := CardToStr(x,str,n); WriteString(str); END WriteCard; PROCEDURE WriteOct (x: WORD; n: CARDINAL); VAR str : ARRAY [0..7] OF CHAR; i : CARDINAL; BEGIN IF (n > 8) THEN FOR i := 1 TO n - 8 DO Write(' ') END; n := 7; END; Done := OctToStr(x,str,n); WriteString(str); END WriteOct; PROCEDURE WriteHex (x:WORD;n: CARDINAL); VAR str : ARRAY [0..7] OF CHAR; i : CARDINAL; BEGIN IF (n > 8) THEN FOR i := 1 TO n - 8 DO Write(' ') END; n := 7; END; Done := HexToStr(x,str,n); WriteString(str); END WriteHex; BEGIN (* InOut Init *) InIsTerm := TRUE; OutIsTerm := TRUE; END InOut. !Funky!Stuff! echo x - MacSYSTEM.MOD cat >MacSYSTEM.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE MacSYSTEM; (* EMPTY IMPLEMENTATION *) END MacSYSTEM. !Funky!Stuff! # The rest of this file is a shell script which will extract: # EventManager.MOD FileManager.MOD FileTypes.MOD FontManager.MOD IUPackage.MOD InOut.MOD MacSYSTEM.MOD echo x - EventManager.MOD cat >EventManager.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE EventManager; (* MacIntosh ToolBox Event Manager Operations *) FROM MacSYSTEM IMPORT LONGINT,OSErr; FROM QuickDraw IMPORT Point; FROM SYSTEM IMPORT ADDRESS,CODE,SETREG,REGISTER,ADR,WORD; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) VAR SysEvtMask[00000144H]:CARDINAL; PROCEDURE EventAvail(mask:WORD; VAR theEvent: EventRecord):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A971H); CODE(RestoreA7);CODE(Return); END EventAvail; PROCEDURE GetNextEvent(mask:WORD; VAR theEvent: EventRecord):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A970H); CODE(RestoreA7);CODE(Return); END GetNextEvent; PROCEDURE StillDown():BOOLEAN; (* INLINE $A973;*) (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A973H); CODE(RestoreA7);CODE(Return); END StillDown; PROCEDURE WaitMouseUp():BOOLEAN; (* INLINE $A977;*) (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A977H); CODE(RestoreA7);CODE(Return); END WaitMouseUp; PROCEDURE xGetMouse (VAR pt: LONGINT); (* INLINE $A972;*) (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A972H); CODE(RestoreA7);CODE(Return); END xGetMouse; PROCEDURE GetMouse (VAR pt: Point); (*$P+*)(*$S-*) BEGIN xGetMouse(pt.param); END GetMouse; PROCEDURE TickCount():LONGINT; (* INLINE $A975;*) (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A975H); CODE(RestoreA7);CODE(Return); END TickCount; PROCEDURE Button():BOOLEAN; (*INLINE $A974;*) (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A974H); CODE(RestoreA7);CODE(Return); END Button; PROCEDURE GetKeys(VAR k: KeyMap); (*INLINE $A976;*) (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A976H); CODE(RestoreA7);CODE(Return); END GetKeys; PROCEDURE PostEvent (eventNum: WORD; eventMsg: LONGINT): OSErr; (*$P+*)(*$S-*) BEGIN SETREG(8,eventNum); SETREG(0,eventMsg); CODE(0A02FH); RETURN(INTEGER(REGISTER(0))); END PostEvent; PROCEDURE FlushEvents (whichMask,stopMask: WORD); (*$P+*)(*$S-*) BEGIN CODE(0202EH);CODE(00008H); (* MOVE.L 8(A6),D0 *) CODE(0A032H); END FlushEvents; PROCEDURE SetEventMask (theMask: WORD); BEGIN SysEvtMask := CARDINAL(theMask) END SetEventMask; PROCEDURE OSEventAvail (mask: WORD; VAR theEvent: EventRecord): BOOLEAN; BEGIN SETREG(8,ADR(theEvent)); SETREG(0,mask); CODE(0A030H); RETURN(REGISTER(0) = 0) END OSEventAvail; PROCEDURE GetOSEvent (mask: WORD; VAR theEvent: EventRecord): BOOLEAN; BEGIN SETREG(8,ADR(theEvent)); SETREG(0,mask); CODE(0A031H); RETURN(REGISTER(0) = 0); END GetOSEvent; END EventManager. !Funky!Stuff! echo x - FileManager.MOD cat >FileManager.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE FileManager; FROM SYSTEM IMPORT ADR,REGISTER,SETREG,CODE,ADDRESS,WORD; FROM Storage IMPORT ALLOCATE,DEALLOCATE; FROM PascalStrings IMPORT MakeModulaString,MakePascalString; FROM MacSYSTEM IMPORT LONGINT,StringPtr,OSErr,noErr; FROM FileTypes IMPORT (*CONST*) opWrErr,permErr, (*TYPE*) OSType,FInfo,ParamBlkPtr,ParamBlkType,ParamBlockRec; CONST OpenTrap = 0A000H; CloseTrap = 0A001H; ReadTrap = 0A002H; WriteTrap = 0A003H; ControlTrap = 0A004H; StatusTrap = 0A005H; KillIOTrap = 0A006H; GetVolInfoTrap = 0A007H; CreateTrap = 0A008H; DeleteTrap = 0A009H; OpenRFTrap = 0A00AH; RenameTrap = 0A00BH; GetFileInfoTrap = 0A00CH; SetFileInfoTrap = 0A00DH; UnmountVolTrap = 0A00EH; MountVolTrap = 0A00FH; AllocateTrap = 0A010H; GetEOFTrap = 0A011H; SetEOFTrap = 0A012H; FlushVolTrap = 0A013H; GetVolTrap = 0A014H; SetVolTrap = 0A015H; FInitQueueTrap = 0A016H; EjectTrap = 0A017H; GetFPosTrap = 0A018H; SetFilLockTrap = 0A041H; RstFilLockTrap = 0A042H; SetFilTypeTrap = 0A043H; SetFPosTrap = 0A044H; FlushFileTrap = 0A045H; TYPE SaveRecPtr= POINTER TO SaveRec; SaveRec = RECORD Next : SaveRecPtr; Buffer : ADDRESS; FileNum: INTEGER END; VAR HEAD : SaveRecPtr; PROCEDURE SaveBuffer(ref:INTEGER; buf : ADDRESS); (* remember the address of the file buffer *) VAR p : SaveRecPtr; BEGIN NEW(p); IF (p # NIL) THEN p^.Buffer := buf; p^.FileNum := ref; p^.Next := HEAD; HEAD := p END END SaveBuffer; PROCEDURE FreeBuffer(ref:INTEGER); (* free up the file buffer *) VAR p,q : SaveRecPtr; BEGIN p := HEAD; q := NIL; WHILE (p # NIL) DO IF (p^.FileNum = ref) THEN DEALLOCATE(p^.Buffer,524); p^.FileNum := 0; IF (q = NIL) THEN HEAD := p^.Next ELSE q^.Next := p^.Next END; DISPOSE(p); RETURN END; q := p; p := q^.Next END END FreeBuffer; (* Accessing Volumes *) PROCEDURE GetVInfo(drive:INTEGER;vol:StringPtr; VAR vRef:INTEGER;VAR free:LONGINT):OSErr; VAR PB:ParamBlockRec; TmpString: ARRAY [0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); IF (vol # NIL) AND (vol # StringPtr(0)) THEN PB.ioNamePtr := ADR(TmpString); MakePascalString(vol^,PB.ioNamePtr^); ELSE PB.ioNamePtr := StringPtr(0) END; PB.ioVolIndex := drive; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(GetVolInfoTrap); IF (vol # NIL) AND (vol # StringPtr(0)) THEN MakeModulaString(PB.ioNamePtr^,vol^); END; vRef := PB.ioVRefNum; free := LONGINT(PB.ioVFrBlk) * PB.ioVAlBlkSiz; RETURN(PB.ioResult); END GetVInfo; PROCEDURE GetVol(volName:StringPtr;VAR vRefNum:INTEGER):OSErr; VAR PB:ParamBlockRec; TmpString: ARRAY [0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); IF (volName # StringPtr(0)) AND (volName # NIL) THEN PB.ioNamePtr := StringPtr(0) ELSE PB.ioNamePtr := ADR(TmpString); END; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(GetVolTrap); IF (volName # StringPtr(0)) AND (volName # NIL) THEN MakeModulaString(PB.ioNamePtr^,volName^); END; vRefNum := PB.ioVRefNum; RETURN(PB.ioResult); END GetVol; PROCEDURE SetVol(volName:StringPtr;vRefNum:INTEGER):OSErr; VAR PB:ParamBlockRec; Str:ARRAY [0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); IF (volName # StringPtr(0)) AND (volName # NIL) THEN MakePascalString(volName^,Str); PB.ioNamePtr := ADR(Str); ELSE PB.ioNamePtr := StringPtr(0) END; PB.ioVRefNum := vRefNum; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(SetVolTrap); RETURN(PB.ioResult); END SetVol; PROCEDURE FlushVol(volName:StringPtr;vRefNum:INTEGER):OSErr; VAR PB:ParamBlockRec; Str:ARRAY [0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); IF (volName # NIL) AND (volName # StringPtr(0)) THEN MakePascalString(volName^,Str); PB.ioNamePtr := ADR(Str) ELSE PB.ioNamePtr := StringPtr(0) END; PB.ioVRefNum := vRefNum; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(FlushVolTrap); RETURN(PB.ioResult); END FlushVol; PROCEDURE UnmountVol(volName:StringPtr;vRefNum:INTEGER):OSErr; VAR PB:ParamBlockRec; Str:ARRAY [0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); IF (volName # NIL) AND (volName # StringPtr(0)) THEN MakePascalString(volName^,Str); PB.ioNamePtr := ADR(Str) ELSE PB.ioNamePtr := StringPtr(0) END; PB.ioVRefNum := vRefNum; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(UnmountVolTrap); RETURN(PB.ioResult); END UnmountVol; PROCEDURE Eject(volName:StringPtr;vRefNum:INTEGER):OSErr; VAR PB:ParamBlockRec; Str:ARRAY [0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); IF (volName # NIL) AND (volName # StringPtr(0)) THEN MakePascalString(volName^,Str); PB.ioNamePtr := ADR(Str) ELSE PB.ioNamePtr := StringPtr(0) END; PB.ioVRefNum := vRefNum; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(EjectTrap); RETURN(PB.ioResult); END Eject; (* Changine File Contents *) PROCEDURE Create(VAR Name:ARRAY OF CHAR;vRef:INTEGER; creator,type:OSType):OSErr; VAR PB:ParamBlockRec; Str:ARRAY[0..255] OF CHAR; f:FInfo; ret:OSErr; BEGIN PB.ioCompletion := ADDRESS(0); MakePascalString(Name,Str); PB.ioNamePtr := ADR(Str); PB.ioVRefNum := vRef; PB.ioFVersNum := 0C; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(CreateTrap); IF (PB.ioResult <> noErr) THEN RETURN(PB.ioResult); END; ret := GetFInfo(Name,vRef,f); IF (ret <>noErr) THEN RETURN(ret) END; f.fdType := type; f.fdCreator := creator; RETURN(SetFInfo(Name,vRef,f)); END Create; PROCEDURE FSOpen(VAR Name:ARRAY OF CHAR;vRef:INTEGER; VAR ref:INTEGER):OSErr; VAR PB:ParamBlockRec; Str:ARRAY[0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); MakePascalString(Name,Str); PB.ioNamePtr := ADR(Str); PB.ioVRefNum := vRef; PB.ioVersNum := 0C; PB.ioPermssn := 0C; ALLOCATE(PB.ioMisc,524); IF (PB.ioMisc = NIL) THEN PB.ioMisc := ADDRESS(0) END; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(OpenTrap); ref := PB.ioRefNum; IF (PB.ioMisc # ADDRESS(0)) THEN IF ((PB.ioResult = noErr) OR (PB.ioResult = opWrErr) OR (PB.ioResult = permErr)) THEN SaveBuffer(ref,PB.ioMisc); ELSE DEALLOCATE(PB.ioMisc,524) END END; RETURN(PB.ioResult); END FSOpen; PROCEDURE FSRead(refNum:INTEGER;VAR count:LONGINT;buff:ADDRESS):OSErr; VAR PB:ParamBlockRec; BEGIN PB.ioCompletion := ADDRESS(0); PB.ioRefNum := refNum; PB.ioReqCount := count; PB.ioPosMode := 0; PB.ioPosOffset := 0; PB.ioBuffer := buff; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(ReadTrap); count := PB.ioActCount; RETURN(PB.ioResult); END FSRead; PROCEDURE FSWrite(ref:INTEGER;VAR count:LONGINT;buff:ADDRESS):OSErr; VAR PB:ParamBlockRec; BEGIN PB.ioCompletion := ADDRESS(0); PB.ioRefNum := ref; PB.ioReqCount := count; PB.ioPosMode := 0; PB.ioPosOffset := 0; PB.ioBuffer := buff; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(WriteTrap); count := PB.ioActCount; RETURN(PB.ioResult); END FSWrite; PROCEDURE GetFPos(refNum:INTEGER;VAR filePos:LONGINT):OSErr; VAR PB:ParamBlockRec; BEGIN PB.ioCompletion := ADDRESS(0); PB.ioRefNum := refNum; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(GetFPosTrap); filePos := PB.ioPosOffset; RETURN(PB.ioResult); END GetFPos; PROCEDURE SetFPos(ref:INTEGER;posMode:INTEGER;posOff:LONGINT):OSErr; VAR PB:ParamBlockRec; BEGIN PB.ioCompletion := ADDRESS(0); PB.ioRefNum := ref; PB.ioPosMode := posMode; PB.ioPosOffset := posOff; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(SetFPosTrap); RETURN(PB.ioResult) END SetFPos; PROCEDURE GetEOF(ref:INTEGER;VAR logEOF:LONGINT):OSErr; VAR PB:ParamBlockRec; BEGIN PB.ioCompletion := ADDRESS(0); PB.ioRefNum := ref; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(GetEOFTrap); logEOF := PB.ioMisc; RETURN(PB.ioResult); END GetEOF; PROCEDURE SetEOF(ref:INTEGER;logEOF:LONGINT):OSErr; VAR PB:ParamBlockRec; BEGIN PB.ioCompletion := ADDRESS(0); PB.ioRefNum := ref; PB.ioMisc := ADDRESS(logEOF); SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(SetEOFTrap); RETURN(PB.ioResult); END SetEOF; PROCEDURE Allocate(ref:INTEGER;VAR count:LONGINT):OSErr; VAR PB:ParamBlockRec; BEGIN PB.ioCompletion := ADDRESS(0); PB.ioRefNum := ref; PB.ioReqCount := count; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(AllocateTrap); count := PB.ioActCount; RETURN(PB.ioResult); END Allocate; PROCEDURE FSClose(ref:INTEGER):OSErr; VAR PB:ParamBlockRec; BEGIN FreeBuffer(ref); PB.ioCompletion := ADDRESS(0); PB.ioRefNum := ref; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(CloseTrap); RETURN(PB.ioResult); END FSClose; (* Changing Information About Files *) PROCEDURE GetFInfo(VAR file:ARRAY OF CHAR;vRef:INTEGER;VAR fndr:FInfo):OSErr; VAR PB:ParamBlockRec; Str:ARRAY[0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); MakePascalString(file,Str); PB.ioNamePtr := ADR(Str); PB.ioVRefNum := vRef; PB.ioVersNum := 0C; PB.ioFDirIndex := 0; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(GetFileInfoTrap); IF (PB.ioResult = noErr) THEN fndr := PB.ioFlFndrInfo END; RETURN(PB.ioResult); END GetFInfo; PROCEDURE SetFInfo(VAR file:ARRAY OF CHAR;vRef:INTEGER;fndrInfo:FInfo):OSErr; VAR PB:ParamBlockRec; Str:ARRAY[0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); MakePascalString(file,Str); PB.ioNamePtr := ADR(Str); PB.ioVRefNum := vRef; PB.ioVersNum := 0C; PB.ioFDirIndex := 0; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(GetFileInfoTrap); (* get create/modification times *) PB.ioFlFndrInfo := fndrInfo; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(SetFileInfoTrap); RETURN(PB.ioResult); END SetFInfo; PROCEDURE SetFLock(VAR file:ARRAY OF CHAR;vRef:INTEGER):OSErr; VAR PB:ParamBlockRec; Str:ARRAY[0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); MakePascalString(file,Str); PB.ioNamePtr := ADR(Str); PB.ioVRefNum := vRef; PB.ioVersNum := 0C; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(SetFilLockTrap); RETURN(PB.ioResult); END SetFLock; PROCEDURE RstFLock(VAR file:ARRAY OF CHAR;vRef:INTEGER):OSErr; VAR PB:ParamBlockRec; Str:ARRAY[0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); MakePascalString(file,Str); PB.ioNamePtr := ADR(Str); PB.ioVRefNum := vRef; PB.ioVersNum := 0C; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(RstFilLockTrap); RETURN(PB.ioResult); END RstFLock; PROCEDURE Rename(VAR old:ARRAY OF CHAR;vRef:INTEGER; VAR new:ARRAY OF CHAR):OSErr; VAR PB:ParamBlockRec; Str,Str2:ARRAY[0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); MakePascalString(old,Str); PB.ioNamePtr := ADR(Str); PB.ioVRefNum := vRef; PB.ioVersNum := 0C; MakePascalString(new,Str2); PB.ioMisc := ADR(Str2); SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(RenameTrap); RETURN(PB.ioResult); END Rename; PROCEDURE FSDelete(VAR name:ARRAY OF CHAR;vRef:INTEGER):OSErr; VAR PB:ParamBlockRec; Str:ARRAY[0..255] OF CHAR; BEGIN PB.ioCompletion := ADDRESS(0); MakePascalString(name,Str); PB.ioNamePtr := ADR(Str); PB.ioVRefNum := vRef; PB.ioVersNum := 0C; SETREG(8,ADR(PB)); (* A0 := ADR(PB) *) CODE(DeleteTrap); RETURN(PB.ioResult); END FSDelete; BEGIN HEAD := NIL END FileManager. !Funky!Stuff! echo x - FileTypes.MOD cat >FileTypes.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE FileTypes; (* * Empty implementation *) END FileTypes. !Funky!Stuff! echo x - FontManager.MOD cat >FontManager.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE FontManager; FROM SYSTEM IMPORT ADDRESS,WORD,CODE,ADR,REGISTER; FROM MacSYSTEM IMPORT LONGINT; FROM PascalStrings IMPORT MakePascalString,MakeModulaString; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) PROCEDURE xGetFontName(fontNumber:INTEGER;name:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8FFH); CODE(RestoreA7);CODE(Return); END xGetFontName; PROCEDURE GetFontName(fontNumber:INTEGER;VAR name:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR s1:ARRAY [0..255] OF CHAR; BEGIN xGetFontName(fontNumber,ADR(s1)); MakeModulaString(s1,name); END GetFontName; PROCEDURE xGetFNum(name:ADDRESS;VAR fontNumber:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A900H); CODE(RestoreA7);CODE(Return); END xGetFNum; PROCEDURE GetFNum(VAR name:ARRAY OF CHAR;VAR fontNumber:INTEGER); (*$P+*)(*$S-*) VAR s1:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(name,s1); xGetFNum(ADR(s1),fontNumber) END GetFNum; PROCEDURE RealFont(fontNumber:INTEGER;pointSize:INTEGER):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A902H); CODE(RestoreA7);CODE(Return); END RealFont; PROCEDURE GetFontInfo(VAR info:FontInfo); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A88BH); CODE(RestoreA7);CODE(Return); END GetFontInfo; PROCEDURE SetFontLock(lock:BOOLEAN); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A903H); CODE(RestoreA7);CODE(Return); END SetFontLock; PROCEDURE FMSwapFont (inRec: FMInput) : FMOutPtr; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A901H); CODE(RestoreA7);CODE(Return); END FMSwapFont; BEGIN CODE(0A8FEH); (* INIT FONTS *) END FontManager. !Funky!Stuff! echo x - IUPackage.MOD cat >IUPackage.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE IUPackage; FROM SYSTEM IMPORT ADDRESS,CODE,ADR; FROM MacSYSTEM IMPORT LONGINT,Handle; FROM PascalStrings IMPORT MakeModulaString; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) Pack6 = 0A9EDH; pIUDatePString = 14; pIUDateString = 0; pIUGetIntl = 6; pIUMagIDString = 12; pIUMagString = 10; pIUMetric = 4; pIUSetIntl = 8; pIUTimePString = 16; pIUTimeString = 2; Push = 03F3CH; (* MOVE #VAL,-(A7) *) (* Routines *) PROCEDURE xIUDateString (dateTime:LONGINT;form:DateForm;result:ADDRESS); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(pIUDateString); CODE(Pack6); CODE(RestoreA7); CODE(Return); END xIUDateString; PROCEDURE IUDateString (dateTime:LONGINT;form:DateForm; VAR result:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN xIUDateString(dateTime,form,ADR(Str)); MakeModulaString(Str,result) END IUDateString; PROCEDURE xIUDatePString (dateTime:LONGINT;form:DateForm; result:ADDRESS;intlParam:Handle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(pIUDatePString); CODE(Pack6); CODE(RestoreA7); CODE(Return); END xIUDatePString; PROCEDURE IUDatePString (dateTime:LONGINT;form:DateForm; VAR result:ARRAY OF CHAR;intlParam:Handle); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN xIUDatePString(dateTime,form,ADR(Str),intlParam); MakeModulaString(Str,result) END IUDatePString; PROCEDURE xIUTimeString(dateTime:LONGINT;wantSeconds:BOOLEAN;result:ADDRESS); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(pIUTimeString); CODE(Pack6); CODE(RestoreA7); CODE(Return); END xIUTimeString; PROCEDURE IUTimeString(dateTime:LONGINT;wantSeconds:BOOLEAN; VAR result:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN xIUTimeString(dateTime,wantSeconds,ADR(Str)); MakeModulaString(Str,result) END IUTimeString; PROCEDURE xIUTimePString(dateTime:LONGINT;wantSeconds:BOOLEAN; result:ADDRESS; intlParam:Handle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(pIUTimePString); CODE(Pack6); CODE(RestoreA7); CODE(Return); END xIUTimePString; PROCEDURE IUTimePString(dateTime:LONGINT;wantSeconds:BOOLEAN; VAR result:ARRAY OF CHAR; intlParam:Handle); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN xIUTimePString(dateTime,wantSeconds,ADR(Str),intlParam); MakeModulaString(Str,result); END IUTimePString; PROCEDURE IUMetric():BOOLEAN; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(pIUMetric); CODE(Pack6); CODE(RestoreA7); CODE(Return); END IUMetric; PROCEDURE IUGetIntl(theID:INTEGER):Handle; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(pIUGetIntl); CODE(Pack6); CODE(RestoreA7); CODE(Return); END IUGetIntl; PROCEDURE IUSetIntl(refNum:INTEGER; theID:INTEGER;intlParam:Handle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(pIUSetIntl); CODE(Pack6); CODE(RestoreA7); CODE(Return); END IUSetIntl; PROCEDURE IUCompString(VAR aStr,bStr:ARRAY OF CHAR):INTEGER; (*$P+*)(*$S-*) VAR BEGIN RETURN(IUMagString(ADR(aStr),ADR(bStr),HIGH(aStr),HIGH(bStr))) END IUCompString; PROCEDURE IUMagString(aPtr,bPtr:ADDRESS;aLen,bLen:INTEGER):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(pIUMagString); CODE(Pack6); CODE(RestoreA7); CODE(Return); END IUMagString; PROCEDURE IUEqualString(VAR aStr,bStr:ARRAY OF CHAR):INTEGER; (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN RETURN(IUMagIDString(ADR(aStr),ADR(bStr),HIGH(aStr),HIGH(bStr))) END IUEqualString; PROCEDURE IUMagIDString(aPtr,bPtr:ADDRESS;aLen,bLen:INTEGER):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(pIUMagIDString); CODE(Pack6); CODE(RestoreA7); CODE(Return); END IUMagIDString; END IUPackage. !Funky!Stuff! echo x - InOut.MOD cat >InOut.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE InOut; (* * copied from the book "PROGRAMMING IN * MODULA-2" by Miklaus Wirth Edited by * David Gries pages 103 and 104. *) FROM SYSTEM IMPORT ADDRESS,WORD,ADR; FROM MacSYSTEM IMPORT LONGINT,OSErr; FROM QuickDraw IMPORT Point; IMPORT Terminal; FROM FileTypes IMPORT OSType; FROM Streams IMPORT STREAM, OpenMode, ReadChar, WriteChar, Open,Close,Create,EOS; FROM SFPackage IMPORT SFPutFile,SFGetFile,SFReply,SFTypeList,NoFileFilter,NoDlg; FROM Conversions IMPORT OctToStr, HexToStr,CardToStr, IntToStr,StrToOct,StrToHex,StrToCard,StrToInt; VAR InIsTerm: BOOLEAN; OutIsTerm: BOOLEAN; InStream: STREAM; OutStream: STREAM; PROCEDURE OpenInput (VAR defext: ARRAY OF CHAR); VAR Reply: SFReply; List: SFTypeList; P: Point; Ret: INTEGER; (* request a file name and open input file "in". * Done := "file was successfully opened". * If open, subsequent input is read from this * file. If name ends with ".", append extension defext *) (* This procedure will used the SFPackage on the Mac, * and the defext will not be used. BC *) BEGIN List[0] := 'TEXT'; P.h := 70; P.v := 100; SFGetFile(P,'Open What File?',NoFileFilter(),1,List,ADDRESS(0),Reply); IF (Reply.good) THEN Open(InStream,Reply.fName,Reply.vRefNum,ReadOnly); IF InStream # NIL THEN InIsTerm := FALSE; Done := TRUE ELSE Done := FALSE END; ELSE Done := FALSE; END END OpenInput; PROCEDURE OpenOutput (VAR defext: ARRAY OF CHAR); VAR DefName: ARRAY [0..255] OF CHAR; Reply: SFReply; P: Point; (* request a file name and open output file "out" * Done := "file was successfully opened. * If open, subsequent output is written on this file *) (* This procedure will also use the SFPackage on the Mac BC *) BEGIN P.h := 70; P.v := 100; SFPutFile(P,'Create What File?','OUTPUT.TEXT',NoDlg(),Reply); IF (Reply.good) THEN Create(Reply.fName,Reply.vRefNum,'EDIT','TEXT'); Open(OutStream,Reply.fName,Reply.vRefNum,WriteOnly); IF (OutStream # NIL) THEN OutIsTerm := FALSE; Done := TRUE ELSE Done := TRUE END ELSE Done := FALSE; END END OpenOutput; PROCEDURE CloseInput; (* closes input file; returns input to the terminal *) BEGIN IF (NOT InIsTerm) THEN Close(InStream); Done := TRUE END; InIsTerm := TRUE; (* even if Close Fails Input becomes terminal again *) END CloseInput; PROCEDURE CloseOutput; (* closes output file; returns output to terminal*) BEGIN IF (NOT OutIsTerm) THEN Close(OutStream); Done := TRUE; OutIsTerm := TRUE; END (* even if Close Fails Input becomes terminal again *) END CloseOutput; PROCEDURE Read (VAR ch:CHAR); (* Done := NOT in.eof *) VAR count : LONGINT; BEGIN IF (InIsTerm) THEN Terminal.Read(ch); (* Terminal Input can't fail? *) Done := TRUE; ELSE count := 1; IF (NOT EOS(InStream)) THEN ReadChar(InStream,ch); Done := TRUE ELSE ch := 0C; Done := FALSE END END END Read; PROCEDURE ReadString (VAR s:ARRAY OF CHAR); (* read string, i.e. sequence of characters not containing * blanks nor control characters; leading blanks are ignored. * Input is terminated by any character <= " "; * this character is assigned to termCH. * DEL is used for backspacing when input from terminal*) (* I will make this a backspace for the Mac BC *) VAR I: CARDINAL; BEGIN I := 0; REPEAT Read(s[I]) UNTIL ((s[I] # ' ') OR (NOT Done)); LOOP IF (s[I] = 10C) THEN (* BackSpace *) IF (I > 0) THEN I := I - 1 END ELSIF (s[I] <= ' ') THEN termCH := s[I]; s[I] := 0C; (* NULL TERMINATED STRINGS *) EXIT ELSIF (I >= HIGH(s)) THEN termCH := 0C; EXIT ELSE INC(I); Read(s[I]); IF (NOT Done) THEN s[I] := 0C; termCH := 0C; IF (I = 0) THEN Done := FALSE; (* End Of File *) ELSE Done := TRUE END; EXIT END END END (* LOOP *) END ReadString; PROCEDURE ReadInt (VAR x:INTEGER); (* read strings and convert to integer. Syntax: * integer = ["+"|"-"]digit{digit}. * leading blanks are ignored. * Done := "integer was read" *) VAR String: ARRAY [0..30] OF CHAR; BEGIN ReadString(String); Done := StrToInt(String,x); END ReadInt; PROCEDURE ReadCard (VAR x:CARDINAL); (* read string and convert to cardinal. Syntax: * cardinal = digit {digit} * Leading blanks are ignored. * Done := "cardinal was read" *) VAR String: ARRAY [0..30] OF CHAR; BEGIN ReadString(String); Done := StrToCard(String,x); END ReadCard; PROCEDURE Write (ch:CHAR); VAR count : LONGINT; BEGIN IF (OutIsTerm) THEN IF (ch = EOL) THEN Terminal.WriteLn ELSE Terminal.Write(ch) END; Done := TRUE ELSE count := 1; Done := TRUE; WriteChar(OutStream,ch) END END Write; PROCEDURE WriteLn; (*terminate line*) BEGIN Write(EOL); END WriteLn; PROCEDURE WriteString (VAR s:ARRAY OF CHAR); (* I will follow the convention here that a String Is upto * The LENGTH of the STRING or Ends at the First Null *) VAR i: CARDINAL; BEGIN i := 0; REPEAT IF (i <= HIGH(s)) THEN IF (s[i] = 0C) THEN i := HIGH(s) + 1; (* Let's Try This *) ELSE Write(s[i]); INC(i) END END UNTIL (i > HIGH(s)) END WriteString; PROCEDURE WriteInt (x: INTEGER; n: CARDINAL); VAR str : ARRAY [0..7] OF CHAR; i : CARDINAL; BEGIN IF (n > 8) THEN FOR i := 1 TO n - 8 DO Write(' ') END; n := 7; END; Done := IntToStr(x,str,n); WriteString(str); END WriteInt; PROCEDURE WriteCard (x,n: CARDINAL); VAR str : ARRAY [0..7] OF CHAR; i : CARDINAL; BEGIN IF (n > 8) THEN FOR i := 1 TO n - 8 DO Write(' ') END; n := 7; END; Done := CardToStr(x,str,n); WriteString(str); END WriteCard; PROCEDURE WriteOct (x: WORD; n: CARDINAL); VAR str : ARRAY [0..7] OF CHAR; i : CARDINAL; BEGIN IF (n > 8) THEN FOR i := 1 TO n - 8 DO Write(' ') END; n := 7; END; Done := OctToStr(x,str,n); WriteString(str); END WriteOct; PROCEDURE WriteHex (x:WORD;n: CARDINAL); VAR str : ARRAY [0..7] OF CHAR; i : CARDINAL; BEGIN IF (n > 8) THEN FOR i := 1 TO n - 8 DO Write(' ') END; n := 7; END; Done := HexToStr(x,str,n); WriteString(str); END WriteHex; BEGIN (* InOut Init *) InIsTerm := TRUE; OutIsTerm := TRUE; END InOut. !Funky!Stuff! echo x - MacSYSTEM.MOD cat >MacSYSTEM.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE MacSYSTEM; (* EMPTY IMPLEMENTATION *) END MacSYSTEM. !Funky!Stuff!
bobc@tikal.UUCP (Bob Campbell) (05/13/86)
# The rest of this file is a shell script which will extract: # MathLib0.MOD MathLib1.MOD MemoryManager.MOD MenuManager.MOD PascalStrings.MOD Pictures.MOD Regions.MOD echo x - MathLib0.MOD cat >MathLib0.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE MathLib0; (*Mathematical library 0 *) FROM SYSTEM IMPORT ADDRESS,CODE,ADR; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) FSQRTX = 00012H; FSINX = 00018H; (* ELEMS68K *) FCOSX = 0001AH; (* ELEMS68K *) FATANX = 0001EH; (* ELEMS68K *) FEXPX = 00008H; (* ELEMS68K *) FLNX = 00000H; (* ELEMS68K *) FTINTX = 00016H; FX2S = 01010H; FS2X = 0100EH; FI2X = 0200EH; FX2I = 02010H; ELEMS68K = 0A9ECH; TYPE EXTENDED = RECORD Exp : INTEGER; Value : ARRAY [0..3] OF CARDINAL; END; (*$S-*) PROCEDURE DoFS2X(VAR Sgl : REAL; VAR Ext : EXTENDED); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FS2X,-(SP) *) CODE(03F3CH);CODE(FS2X); (* _FP68K ; A9EB *) CODE(0A9EBH); CODE(RestoreA7);CODE(Return); END DoFS2X; PROCEDURE DoFX2S(VAR Ext : EXTENDED; VAR Sgl : REAL); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FX2S,-(SP) *) CODE(03F3CH);CODE(FX2S); (* _FP68K ; A9EB *) CODE(0A9EBH); CODE(RestoreA7);CODE(Return); END DoFX2S; (*$P+*) PROCEDURE DoFX2I(VAR Ext : EXTENDED; VAR Sgl : INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FX2I,-(SP) *) CODE(03F3CH);CODE(FX2I); (* _FP68K ; A9EB *) CODE(0A9EBH); CODE(RestoreA7);CODE(Return); END DoFX2I; (*$P+*) PROCEDURE DoFI2X(VAR I : INTEGER; VAR Ext : EXTENDED); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FI2X,-(SP) *) CODE(03F3CH);CODE(FI2X); (* _FP68K ; A9EB *) CODE(0A9EBH); CODE(RestoreA7);CODE(Return); END DoFI2X; (*$P+*) PROCEDURE DoFSQRTX(VAR Dst : EXTENDED); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FSQRTX,-(SP) *) CODE(03F3CH);CODE(FSQRTX); (* _FP68K ; A9EB *) CODE(0A9EBH); CODE(RestoreA7);CODE(Return); END DoFSQRTX; (*$P+*) PROCEDURE sqrt (x: REAL) : REAL; VAR xt : EXTENDED; BEGIN DoFS2X(x,xt); DoFSQRTX(xt); DoFX2S(xt,x); RETURN(x) END sqrt; PROCEDURE DoFSINX(VAR Dst : EXTENDED); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FSINX,-(SP) *) CODE(03F3CH);CODE(FSINX); (* _ELEMS68K ; A9EC *) CODE(ELEMS68K); CODE(RestoreA7);CODE(Return); END DoFSINX; (*$P+*) PROCEDURE sin(x: REAL) : REAL; VAR xt : EXTENDED; BEGIN DoFS2X(x,xt); DoFSINX(xt); DoFX2S(xt,x); RETURN(x) END sin; PROCEDURE DoFCOSX(VAR Dst : EXTENDED); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FCOSX,-(SP) *) CODE(03F3CH);CODE(FCOSX); (* _ELEMS68K ; A9EC *) CODE(ELEMS68K); CODE(RestoreA7);CODE(Return); END DoFCOSX; (*$P+*) PROCEDURE cos (x: REAL) : REAL; VAR xt : EXTENDED; BEGIN DoFS2X(x,xt); DoFCOSX(xt); DoFX2S(xt,x); RETURN(x) END cos; PROCEDURE DoFATANX(VAR Dst : EXTENDED); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FATANX,-(SP) *) CODE(03F3CH);CODE(FATANX); (* _ELEMS68K ; A9EC *) CODE(ELEMS68K); CODE(RestoreA7);CODE(Return); END DoFATANX; (*$P+*) PROCEDURE arctan (x: REAL) : REAL; VAR xt : EXTENDED; BEGIN DoFS2X(x,xt); DoFATANX(xt); DoFX2S(xt,x); RETURN(x) END arctan; PROCEDURE DoFEXPX(VAR Dst : EXTENDED); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FEXPX,-(SP) *) CODE(03F3CH);CODE(FEXPX); (* _ELEMS68K ; A9EC *) CODE(ELEMS68K); CODE(RestoreA7);CODE(Return); END DoFEXPX; (*$P+*) PROCEDURE exp (x: REAL) : REAL; VAR xt : EXTENDED; BEGIN DoFS2X(x,xt); DoFEXPX(xt); DoFX2S(xt,x); RETURN(x) END exp; PROCEDURE DoFLNX(VAR Dst : EXTENDED); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FLNX,-(SP) *) CODE(03F3CH);CODE(FLNX); (* _ELEMS68K ; A9EC *) CODE(ELEMS68K); CODE(RestoreA7);CODE(Return); END DoFLNX; (*$P+*) PROCEDURE ln (x: REAL) : REAL; VAR xt : EXTENDED; BEGIN DoFS2X(x,xt); DoFLNX(xt); DoFX2S(xt,x); RETURN(x) END ln; PROCEDURE DoFTINTX(VAR Dst : EXTENDED); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FTINTX,-(SP) *) CODE(03F3CH);CODE(FTINTX); (* _ELEMS68K ; A9EC *) CODE(ELEMS68K); CODE(RestoreA7);CODE(Return); END DoFTINTX; (*$P+*) PROCEDURE entier (x: REAL) : INTEGER; VAR xt : EXTENDED; i : INTEGER; BEGIN DoFS2X(x,xt); DoFTINTX(xt); DoFX2I(xt,i); RETURN(i) END entier; PROCEDURE real (x: INTEGER) : REAL; VAR xt : EXTENDED; r : REAL; BEGIN DoFI2X(x,xt); DoFX2S(xt,r); RETURN(r) END real; END MathLib0. !Funky!Stuff! echo x - MathLib1.MOD cat >MathLib1.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE MathLib1; (* Math. library 1 *) (* additional mathematical functions*) (* M. Schneider 4. Juli 1983 *) FROM SYSTEM IMPORT ADDRESS,CODE,ADR,WORD; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) FTINTX = 00016H; FX2S = 01010H; FS2X = 0100EH; FI2X = 0200EH; FX2I = 02010H; FLOG2X = 00002H; FEXP2X = 0000AH; FTANX = 0001CH; FRANDX = 00020H; FSCALBX = 00018H; (* scalb(I,X) : X *) pi = 3.1415926536; ELEMS68K = 0A9ECH; FP68K = 0A9EBH; TYPE EXTENDED = RECORD Exp : INTEGER; Value : ARRAY [0..3] OF CARDINAL; END; PROCEDURE ELEMS68K2(VAR src,dst:EXTENDED; code:WORD); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* _ELEMS68K ; A9EB *) CODE(ELEMS68K); CODE(RestoreA7);CODE(Return); END ELEMS68K2; PROCEDURE ELEMS68K1(VAR dst:EXTENDED; code:WORD); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* _ELEMS68K ; A9EB *) CODE(ELEMS68K); CODE(RestoreA7);CODE(Return); END ELEMS68K1; PROCEDURE FP68K2(VAR src,dst:EXTENDED; code:WORD); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* _FP68K ; A9EB *) CODE(FP68K); CODE(RestoreA7);CODE(Return); END FP68K2; PROCEDURE FP68K1(VAR dst:EXTENDED; code:WORD); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* _FP68K ; A9EB *) CODE(FP68K); CODE(RestoreA7);CODE(Return); END FP68K1; PROCEDURE DoFS2X(VAR Sgl : REAL; VAR Ext : EXTENDED); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FS2X,-(SP) *) CODE(03F3CH);CODE(FS2X); (* _FP68K ; A9EB *) CODE(0A9EBH); CODE(RestoreA7);CODE(Return); END DoFS2X; PROCEDURE DoFX2S(VAR Ext : EXTENDED; VAR Sgl : REAL); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FX2S,-(SP) *) CODE(03F3CH);CODE(FX2S); (* _FP68K ; A9EB *) CODE(0A9EBH); CODE(RestoreA7);CODE(Return); END DoFX2S; (*$P+*)(*$S-*) PROCEDURE exp2 ( x: REAL ): REAL; VAR p : EXTENDED; BEGIN DoFS2X(x,p); ELEMS68K1(p,FEXP2X); DoFX2S(p,x); END exp2; PROCEDURE log2 ( x: REAL ): REAL; VAR p : EXTENDED; BEGIN DoFS2X(x,p); ELEMS68K1(p,FLOG2X); DoFX2S(p,x); END log2; PROCEDURE tan ( x: REAL ): REAL; VAR p : EXTENDED; BEGIN DoFS2X(x,p); ELEMS68K1(p,FTANX); DoFX2S(p,x); END tan; VAR Seed:EXTENDED; Convert:REAL; PROCEDURE scalb(VAR i:INTEGER;VAR x:EXTENDED); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FSCALBX,-(SP) *) CODE(03F3CH);CODE(FSCALBX); (* _FP68K ; A9EB *) CODE(0A9EBH); CODE(RestoreA7);CODE(Return); END scalb; (*$P+*) PROCEDURE random(): REAL; (* range: 0.0 <= random < 1.0 *) VAR p : EXTENDED; i : INTEGER; BEGIN ELEMS68K1(p,FRANDX); i := 1; scalb(i,p); DoFX2S(p,Convert); RETURN(Convert); END random; PROCEDURE setrandom( x0: REAL ); BEGIN DoFS2X(x0,Seed); END setrandom; PROCEDURE PI(): REAL; BEGIN RETURN(pi) END PI; BEGIN Convert := 0.0; DoFS2X(Convert,Seed); END MathLib1. !Funky!Stuff! echo x - MemoryManager.MOD cat >MemoryManager.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE MemoryManager; FROM SYSTEM IMPORT ADDRESS,CODE,ADR,REGISTER,SETREG; FROM MacSYSTEM IMPORT Handle,LONGINT,OSErr; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) RD0 = 0; RA0 = 8; RD1 = 1; RA1 = 9; RD2 = 2; RA2 = 0AH; RD3 = 3; RA3 = 0BH; RD4 = 4; RA4 = 0CH; RD5 = 5; RA5 = 0DH; RD6 = 6; RA6 = 0EH; RD7 = 7; RA7 = 0FH; VAR MMError:OSErr; (* Routines *) (* Initialization and Allocation *) PROCEDURE InitApplZone; (*$S-*) BEGIN CODE(0A20CH); MMError := OSErr(REGISTER(RD0)); END InitApplZone; PROCEDURE SetApplBase(startPtr:ADDRESS); (*$S-*) BEGIN SETREG(RA0,startPtr); CODE(0A857H); MMError := OSErr(REGISTER(RD0)); END SetApplBase; PROCEDURE InitZone(pGrowZone:ADDRESS;cMoreMasters:INTEGER; limitPtr,startPtr:ADDRESS); BEGIN SETREG(RA0,ADR(startPtr)); MMError := OSErr(REGISTER(RD0)); END InitZone; PROCEDURE GetApplLimit():ADDRESS; (*$P+*)(*$S-*) BEGIN RETURN(ApplLimit) END GetApplLimit; PROCEDURE SetApplLimit(zoneLimit:ADDRESS); BEGIN SETREG(RA0,zoneLimit); CODE(0A02DH); MMError := OSErr(REGISTER(RD0)); END SetApplLimit; PROCEDURE MaxApplZone; (* No trap Macro *) (*$P+*) BEGIN END MaxApplZone; PROCEDURE MoreMasters; BEGIN CODE(0A036H); MMError := OSErr(REGISTER(RD0)); END MoreMasters; (* Heap Zone Access *) PROCEDURE GetZone():THz; BEGIN CODE(0A11AH); MMError := OSErr(REGISTER(RD0)); RETURN(REGISTER(RA0)) END GetZone; PROCEDURE SetZone(hz:THz); BEGIN SETREG(RA0,hz); CODE(0A01BH); MMError := OSErr(REGISTER(RD0)); END SetZone; PROCEDURE SystemZone():THz; (* No trap macro *) BEGIN RETURN(THz(SysZone)) END SystemZone; PROCEDURE ApplicZone():THz; (* No trap macro *) BEGIN RETURN(THz(ApplZone)) END ApplicZone; (* Allocating and Releasing Relocatable Blocks *) PROCEDURE NewHandle(logicalSize:Size):Handle; BEGIN SETREG(RD0,logicalSize); CODE(0A122H); MMError := OSErr(REGISTER(RD0)); RETURN(REGISTER(RA0)) END NewHandle; PROCEDURE DisposHandle(h:Handle); BEGIN SETREG(RA0,h); CODE(0A023H); MMError := OSErr(REGISTER(RD0)); END DisposHandle; PROCEDURE GetHandleSize(h:Handle):Size; BEGIN SETREG(RA0,h); CODE(0A025H); MMError := OSErr(REGISTER(RD0)); RETURN(REGISTER(RD0)) END GetHandleSize; PROCEDURE SetHandleSize(h:Handle;newSize:Size); BEGIN SETREG(RA0,h); SETREG(RD0,newSize); CODE(0A024H); MMError := OSErr(REGISTER(RD0)); END SetHandleSize; PROCEDURE HandleZone(h:Handle):THz; BEGIN SETREG(RA0,h); CODE(0A126H); MMError := OSErr(REGISTER(RD0)); RETURN(REGISTER(RA0)) END HandleZone; PROCEDURE RecoverHandle(p:ADDRESS):Handle; BEGIN SETREG(RA0,p); CODE(0A128H); MMError := OSErr(REGISTER(RD0)); RETURN(REGISTER(RA0)) END RecoverHandle; PROCEDURE ReallocHandle(h:Handle;logicalSize:Size); BEGIN SETREG(RA0,h); SETREG(RD0,logicalSize); CODE(0A127H); MMError := OSErr(REGISTER(RD0)); END ReallocHandle; (* Allocating and Releasing Nonrelocatable Blocks *) PROCEDURE NewPtr(logicalSize:Size):ADDRESS; BEGIN SETREG(RD0,logicalSize); CODE(0A1EH); MMError := OSErr(REGISTER(RD0)); RETURN(REGISTER(RA0)) END NewPtr; PROCEDURE DisposPtr(p:ADDRESS); BEGIN SETREG(RA0,p); CODE(0A01FH); MMError := OSErr(REGISTER(RD0)); END DisposPtr; PROCEDURE GetPtrSize(p:ADDRESS):Size; BEGIN SETREG(RA0,p); CODE(0A021H); MMError := OSErr(REGISTER(RD0)); RETURN(REGISTER(RD0)) END GetPtrSize; PROCEDURE SetPtrSize(p:ADDRESS;newSize:Size); BEGIN SETREG(RA0,p); SETREG(RD0,newSize); CODE(0A020H); MMError := OSErr(REGISTER(RD0)); END SetPtrSize; PROCEDURE PtrZone(p:ADDRESS):THz; BEGIN SETREG(RA0,p); CODE(0A148H); MMError := OSErr(REGISTER(RD0)); RETURN(REGISTER(RA0)) END PtrZone; (* Freeing Space in the Heap *) PROCEDURE FreeMem():LONGINT; BEGIN CODE(0A01CH); MMError := OSErr(REGISTER(RD0)); RETURN(REGISTER(RD0)) END FreeMem; PROCEDURE MaxMem(VAR grow:Size):Size; BEGIN CODE(0A01DH); MMError := OSErr(REGISTER(RD0)); RETURN(REGISTER(RD0)) END MaxMem; PROCEDURE CompactMem(cbNeeded:Size):Size; BEGIN SETREG(RD0,cbNeeded); CODE(0A04CH); MMError := OSErr(REGISTER(RD0)); RETURN(REGISTER(RD0)) END CompactMem; PROCEDURE ResrvMem(cbNeeded:Size); BEGIN SETREG(RD0,cbNeeded); CODE(0A040H); MMError := OSErr(REGISTER(RD0)); END ResrvMem; PROCEDURE PurgeMem(cbNeeded:Size); BEGIN SETREG(RD0,cbNeeded); CODE(0A04DH); MMError := OSErr(REGISTER(RD0)); END PurgeMem; PROCEDURE EmptyHandle(h:Handle); BEGIN SETREG(RA0,h); CODE(0A02BH); MMError := OSErr(REGISTER(RD0)); END EmptyHandle; (* Properties of Relocatable Blocks *) PROCEDURE HLock(h:Handle); BEGIN SETREG(RA0,h); CODE(0A029H); MMError := OSErr(REGISTER(RD0)); END HLock; PROCEDURE HUnlock(h:Handle); BEGIN SETREG(RA0,h); CODE(0A02AH); MMError := OSErr(REGISTER(RD0)); END HUnlock; PROCEDURE HPurge(h:Handle); BEGIN SETREG(RA0,h); CODE(0A049H); MMError := OSErr(REGISTER(RD0)); END HPurge; PROCEDURE HNoPurge(h:Handle); BEGIN SETREG(RA0,h); CODE(0A049H); MMError := OSErr(REGISTER(RD0)); END HNoPurge; (* Grow Zone Operations *) PROCEDURE SetGrowZone(growZone:ADDRESS); BEGIN SETREG(RA0,growZone); CODE(0A04BH); MMError := OSErr(REGISTER(RD0)); END SetGrowZone; PROCEDURE GZSaveHnd():Handle; (* No trap macro *) BEGIN RETURN(GZRootHnd) END GZSaveHnd; (* Miscellaneous Routines *) PROCEDURE BlockMove(src,dst:ADDRESS;count:Size); BEGIN SETREG(RA0,src); SETREG(RA1,dst); SETREG(RD0,count); CODE(0A02EH); MMError := OSErr(REGISTER(RD0)); END BlockMove; PROCEDURE TopMem():ADDRESS; (* No trap macro *) BEGIN RETURN(MemTop) END TopMem; PROCEDURE MoveHHi(h:Handle); BEGIN END MoveHHi; PROCEDURE MemError():OSErr; (* No trap macro *) BEGIN RETURN(MMError) END MemError; (* Grow Zone Function *) END MemoryManager. !Funky!Stuff! echo x - MenuManager.MOD cat >MenuManager.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE MenuManager; FROM SYSTEM IMPORT ADDRESS,WORD,CODE,ADR; FROM MacSYSTEM IMPORT LONGINT,Handle; FROM PascalStrings IMPORT MakePascalString,MakeModulaString; FROM QuickDraw IMPORT Point,Rect,Style; FROM WindowManager IMPORT inMenuBar; (* Init WindowManager First *) FROM ResourceManager IMPORT ResType,ParamResType; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) PROCEDURE xNewMenu(menuID:INTEGER;menuTitle:ADDRESS):MenuHandle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A931H); CODE(RestoreA7);CODE(Return); END xNewMenu; PROCEDURE NewMenu(menuID:INTEGER;VAR menuTitle:ARRAY OF CHAR):MenuHandle; (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(menuTitle,Str); RETURN(xNewMenu(menuID,ADR(Str))) END NewMenu; PROCEDURE GetMenu(resourceID:INTEGER):MenuHandle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9BFH); CODE(RestoreA7);CODE(Return); END GetMenu; PROCEDURE DisposeMenu(theMenu:MenuHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A932H); CODE(RestoreA7);CODE(Return); END DisposeMenu; (*Forming the Menus*) PROCEDURE xAppendMenu(theMenu:MenuHandle;data:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A933H); CODE(RestoreA7);CODE(Return); END xAppendMenu; PROCEDURE AppendMenu(theMenu:MenuHandle;VAR data:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(data,Str); xAppendMenu(theMenu,ADR(Str)) END AppendMenu; PROCEDURE xAddResMenu(theMenu:MenuHandle;theType:LONGINT); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A94DH); CODE(RestoreA7);CODE(Return); END xAddResMenu; PROCEDURE AddResMenu(theMenu:MenuHandle;theType:ResType); (*$P+*)(*$S-*) VAR x:ParamResType; BEGIN x.res := theType; xAddResMenu(theMenu,x.param); END AddResMenu; PROCEDURE xInsertResMenu(theMenu:MenuHandle;theType:LONGINT; afterItem:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A951H); CODE(RestoreA7);CODE(Return); END xInsertResMenu; PROCEDURE InsertResMenu(theMenu:MenuHandle;theType:ResType; afterItem:INTEGER); (*$P+*)(*$S-*) VAR x:ParamResType; BEGIN x.res := theType; xInsertResMenu(theMenu,x.param,afterItem) END InsertResMenu; (*Forming the Menus*) PROCEDURE InsertMenu(theMenu:MenuHandle;beforeID:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A935H); CODE(RestoreA7);CODE(Return); END InsertMenu; PROCEDURE DrawMenuBar; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A937H); CODE(RestoreA7);CODE(Return); END DrawMenuBar; PROCEDURE DeleteMenu(menuID:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A936H); CODE(RestoreA7);CODE(Return); END DeleteMenu; PROCEDURE ClearMenuBar; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A934H); CODE(RestoreA7);CODE(Return); END ClearMenuBar; PROCEDURE GetNewMBar(menuBarID:INTEGER):Handle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9C0H); CODE(RestoreA7);CODE(Return); END GetNewMBar; PROCEDURE GetMenuBar():Handle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A93BH); CODE(RestoreA7);CODE(Return); END GetMenuBar; PROCEDURE SetMenuBar(menuList:Handle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A93CH); CODE(RestoreA7);CODE(Return); END SetMenuBar; (*Choosing from a menu*) PROCEDURE xMenuSelect(startPt:LONGINT):LONGINT; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A93DH); CODE(RestoreA7);CODE(Return); END xMenuSelect; PROCEDURE MenuSelect(startPt:Point):LONGINT; (*$P+*)(*$S-*) BEGIN RETURN(xMenuSelect(startPt.param)) END MenuSelect; PROCEDURE xMenuKey(ch:CARDINAL):LONGINT; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A93EH); CODE(RestoreA7);CODE(Return); END xMenuKey; PROCEDURE MenuKey(ch:CHAR):LONGINT; (*$P+*)(*$S-*) BEGIN RETURN(xMenuKey(ORD(ch))) END MenuKey; PROCEDURE HiliteMenu(menuID:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A938H); CODE(RestoreA7);CODE(Return); END HiliteMenu; (*Controlling Items' Appearance*) PROCEDURE xSetItem(theMenu:MenuHandle;item:INTEGER;itemString:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A947H); CODE(RestoreA7);CODE(Return); END xSetItem; PROCEDURE SetItem(theMenu:MenuHandle;item:INTEGER;VAR itemString:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(itemString,Str); xSetItem(theMenu,item,ADR(Str)) END SetItem; PROCEDURE xGetItem(theMenu:MenuHandle;item:INTEGER;itemString:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A946H); CODE(RestoreA7);CODE(Return); END xGetItem; PROCEDURE GetItem(theMenu:MenuHandle;item:INTEGER;VAR itemString:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN xGetItem(theMenu,item,ADR(Str)); MakeModulaString(Str,itemString) END GetItem; PROCEDURE DisableItem(theMenu:MenuHandle;item:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A93AH); CODE(RestoreA7);CODE(Return); END DisableItem; PROCEDURE EnableItem(theMenu:MenuHandle;item:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A939H); CODE(RestoreA7);CODE(Return); END EnableItem; PROCEDURE CheckItem(theMenu:MenuHandle;item:INTEGER;checked:BOOLEAN); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A945H); CODE(RestoreA7);CODE(Return); END CheckItem; PROCEDURE xSetItemMark(theMenu:MenuHandle;item:INTEGER;markChar:CARDINAL); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A944H); CODE(RestoreA7);CODE(Return); END xSetItemMark; PROCEDURE SetItemMark(theMenu:MenuHandle;item:INTEGER;markChar:CHAR); (*$P+*)(*$S-*) BEGIN xSetItemMark(theMenu,item,ORD(markChar)) END SetItemMark; PROCEDURE GetItemMark(theMenu:MenuHandle;item:INTEGER;VAR markChar:CHAR); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A943H); CODE(RestoreA7);CODE(Return); END GetItemMark; PROCEDURE xSetItemIcon(theMenu:MenuHandle;item:INTEGER;icon:CARDINAL); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A940H); CODE(RestoreA7);CODE(Return); END xSetItemIcon; PROCEDURE SetItemIcon(theMenu:MenuHandle;item:INTEGER;icon:CHAR); (*$P+*)(*$S-*) BEGIN xSetItemIcon(theMenu,item,ORD(icon)) END SetItemIcon; PROCEDURE GetItemIcon(theMenu:MenuHandle;item:INTEGER;VAR icon:CHAR); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A93FH); CODE(RestoreA7);CODE(Return); END GetItemIcon; PROCEDURE SetItemStyle(theMenu:MenuHandle;item:INTEGER;chStyle:Style); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A942H); CODE(RestoreA7);CODE(Return); END SetItemStyle; PROCEDURE GetItemStyle (theMenu: MenuHandle;item:INTEGER; VAR chStyle:Style); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A941H); CODE(RestoreA7);CODE(Return); END GetItemStyle; (*Miscellaneous Routines*) PROCEDURE CalcMenuSize(theMenu:MenuHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A948H); CODE(RestoreA7);CODE(Return); END CalcMenuSize; PROCEDURE CountMItems(theMenu:MenuHandle):INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A950H); CODE(RestoreA7);CODE(Return); END CountMItems; PROCEDURE GetMHandle(menuID:INTEGER):MenuHandle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A949H); CODE(RestoreA7);CODE(Return); END GetMHandle; PROCEDURE FlashMenuBar(menuID:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A94CH); CODE(RestoreA7);CODE(Return); END FlashMenuBar; PROCEDURE SetMenuFlash(count:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A94AH); CODE(RestoreA7);CODE(Return); END SetMenuFlash; (*Menu Definition Procedure*) BEGIN CODE(0A930H); (*InitMenus*) END MenuManager. !Funky!Stuff! echo x - PascalStrings.MOD cat >PascalStrings.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE PascalStrings; PROCEDURE MakePascalString(VAR in: ARRAY OF CHAR; VAR out: ARRAY OF CHAR); VAR i:CARDINAL; (*$S-*) (*$T-*) BEGIN i := 0; WHILE ((i <= HIGH(in)) AND (i < HIGH(out)) AND (in[i] <> 0C)) DO out[i + 1]:=in[i]; INC(i) END; out[0] := CHAR(i); END MakePascalString; PROCEDURE MakeModulaString(VAR in: ARRAY OF CHAR; VAR out: ARRAY OF CHAR); VAR i:CARDINAL; (*$S-*) BEGIN i := 0; WHILE ((i < ORD(in[0])) AND (i <= HIGH(out))) DO out[i]:=in[i + 1]; INC(i) END; IF (i <= HIGH(out)) THEN out[i] := 0C; END END MakeModulaString; PROCEDURE emptyPascalString(VAR string:ARRAY OF CHAR); (*$S-*) BEGIN string[0] := 0C END emptyPascalString; END PascalStrings. !Funky!Stuff! echo x - Pictures.MOD cat >Pictures.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE Pictures; FROM SYSTEM IMPORT ADDRESS,CODE,ADR; FROM QuickDraw IMPORT Rect; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) (* Picture Routines *) PROCEDURE GetPicture(picID:INTEGER):PicHandle; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9BCH); CODE(RestoreA7); CODE(Return); END GetPicture; PROCEDURE OpenPicture (VAR picFrame:Rect):PicHandle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8F3H); CODE(RestoreA7);CODE(Return); END OpenPicture; PROCEDURE ClosePicture; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8F4H); CODE(RestoreA7);CODE(Return); END ClosePicture; PROCEDURE KillPicture (thePicture:PicHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8F5H); CODE(RestoreA7);CODE(Return); END KillPicture; PROCEDURE DrawPicture (thePicture:PicHandle;VAR inRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8F6H); CODE(RestoreA7);CODE(Return); END DrawPicture; PROCEDURE PicComment (kind,dataSize:INTEGER;data:PicHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8F2H); CODE(RestoreA7);CODE(Return); END PicComment; END Pictures. !Funky!Stuff! echo x - Regions.MOD cat >Regions.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE Regions; FROM SYSTEM IMPORT ADDRESS,WORD,CODE,ADR,REGISTER; FROM MacSYSTEM IMPORT LONGINT; FROM QuickDraw IMPORT RgnHandle,RgnPtr,Region,Point,Rect,Pattern; FROM PascalStrings IMPORT MakePascalString; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) (* Region Calculations *) PROCEDURE NewRgn():RgnHandle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8D8H); CODE(RestoreA7);CODE(Return); END NewRgn; PROCEDURE OpenRgn; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8DAH); CODE(RestoreA7);CODE(Return); END OpenRgn; PROCEDURE CloseRgn (theRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8DBH); CODE(RestoreA7);CODE(Return); END CloseRgn; PROCEDURE DisposeRgn (theRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8D9H); CODE(RestoreA7);CODE(Return); END DisposeRgn; PROCEDURE SetEmptyRgn (theRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8DDH); CODE(RestoreA7);CODE(Return); END SetEmptyRgn; PROCEDURE RectRgn (theRegion:RgnHandle;VAR theRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8DFH); CODE(RestoreA7);CODE(Return); END RectRgn; PROCEDURE SetRectRgn (theRegion:RgnHandle;left,top,right,bottom:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8DEH); CODE(RestoreA7);CODE(Return); END SetRectRgn; PROCEDURE CopyRgn (fromRegion,toRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8DCH); CODE(RestoreA7);CODE(Return); END CopyRgn; PROCEDURE xPtInRgn (thePoint:LONGINT;theRegion:RgnHandle):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8E8H); CODE(RestoreA7);CODE(Return); END xPtInRgn; PROCEDURE PtInRgn (thePoint:Point;theRegion:RgnHandle):BOOLEAN; (*$P+*)(*$S-*) BEGIN RETURN(xPtInRgn(thePoint.param,theRegion)) END PtInRgn; PROCEDURE RectInRgn (VAR theRect:Rect;theRegion:RgnHandle):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8E9H); CODE(RestoreA7);CODE(Return); END RectInRgn; PROCEDURE OffsetRgn (theRegion:RgnHandle;hOffset,vOffset:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8E0H); CODE(RestoreA7);CODE(Return); END OffsetRgn; PROCEDURE InsetRgn (theRegion:RgnHandle;hInset,vInset:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8E1H); CODE(RestoreA7);CODE(Return); END InsetRgn; PROCEDURE EmptyRgn (theRegion:RgnHandle):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8E2H); CODE(RestoreA7);CODE(Return); END EmptyRgn; PROCEDURE UnionRgn (region1,region2,resultRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8E5H); CODE(RestoreA7);CODE(Return); END UnionRgn; PROCEDURE SectRgn (region1,region2,resultRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8E4H); CODE(RestoreA7);CODE(Return); END SectRgn; PROCEDURE DiffRgn (region1,region2,resultRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8E6H); CODE(RestoreA7);CODE(Return); END DiffRgn; PROCEDURE XOrRgn (region1,region2,resultRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8E7H); CODE(RestoreA7);CODE(Return); END XOrRgn; PROCEDURE EqualRgn (region1,region2:RgnHandle):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8E3H); CODE(RestoreA7);CODE(Return); END EqualRgn; PROCEDURE MapRgn (theRegion:RgnHandle;VAR fromRect,toRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8FBH); CODE(RestoreA7);CODE(Return); END MapRgn; (* Drawing Regions *) PROCEDURE FrameRgn (theRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8D2H); CODE(RestoreA7);CODE(Return); END FrameRgn; PROCEDURE PaintRgn (theRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8D3H); CODE(RestoreA7);CODE(Return); END PaintRgn; PROCEDURE FillRgn (theRegion:RgnHandle;VAR fillPat:Pattern); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8D6H); CODE(RestoreA7);CODE(Return); END FillRgn; PROCEDURE EraseRgn (theRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8D4H); CODE(RestoreA7);CODE(Return); END EraseRgn; PROCEDURE InvertRgn (theRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8D5H); CODE(RestoreA7);CODE(Return); END InvertRgn; END Regions. !Funky!Stuff! # The rest of this file is a shell script which will extract: # MathLib0.MOD MathLib1.MOD MemoryManager.MOD MenuManager.MOD PascalStrings.MOD Pictures.MOD Regions.MOD echo x - MathLib0.MOD cat >MathLib0.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE MathLib0; (*Mathematical library 0 *) FROM SYSTEM IMPORT ADDRESS,CODE,ADR; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) FSQRTX = 00012H; FSINX = 00018H; (* ELEMS68K *) FCOSX = 0001AH; (* ELEMS68K *) FATANX = 0001EH; (* ELEMS68K *) FEXPX = 00008H; (* ELEMS68K *) FLNX = 00000H; (* ELEMS68K *) FTINTX = 00016H; FX2S = 01010H; FS2X = 0100EH; FI2X = 0200EH; FX2I = 02010H; ELEMS68K = 0A9ECH; TYPE EXTENDED = RECORD Exp : INTEGER; Value : ARRAY [0..3] OF CARDINAL; END; (*$S-*) PROCEDURE DoFS2X(VAR Sgl : REAL; VAR Ext : EXTENDED); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FS2X,-(SP) *) CODE(03F3CH);CODE(FS2X); (* _FP68K ; A9EB *) CODE(0A9EBH); CODE(RestoreA7);CODE(Return); END DoFS2X; PROCEDURE DoFX2S(VAR Ext : EXTENDED; VAR Sgl : REAL); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FX2S,-(SP) *) CODE(03F3CH);CODE(FX2S); (* _FP68K ; A9EB *) CODE(0A9EBH); CODE(RestoreA7);CODE(Return); END DoFX2S; (*$P+*) PROCEDURE DoFX2I(VAR Ext : EXTENDED; VAR Sgl : INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FX2I,-(SP) *) CODE(03F3CH);CODE(FX2I); (* _FP68K ; A9EB *) CODE(0A9EBH); CODE(RestoreA7);CODE(Return); END DoFX2I; (*$P+*) PROCEDURE DoFI2X(VAR I : INTEGER; VAR Ext : EXTENDED); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FI2X,-(SP) *) CODE(03F3CH);CODE(FI2X); (* _FP68K ; A9EB *) CODE(0A9EBH); CODE(RestoreA7);CODE(Return); END DoFI2X; (*$P+*) PROCEDURE DoFSQRTX(VAR Dst : EXTENDED); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FSQRTX,-(SP) *) CODE(03F3CH);CODE(FSQRTX); (* _FP68K ; A9EB *) CODE(0A9EBH); CODE(RestoreA7);CODE(Return); END DoFSQRTX; (*$P+*) PROCEDURE sqrt (x: REAL) : REAL; VAR xt : EXTENDED; BEGIN DoFS2X(x,xt); DoFSQRTX(xt); DoFX2S(xt,x); RETURN(x) END sqrt; PROCEDURE DoFSINX(VAR Dst : EXTENDED); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FSINX,-(SP) *) CODE(03F3CH);CODE(FSINX); (* _ELEMS68K ; A9EC *) CODE(ELEMS68K); CODE(RestoreA7);CODE(Return); END DoFSINX; (*$P+*) PROCEDURE sin(x: REAL) : REAL; VAR xt : EXTENDED; BEGIN DoFS2X(x,xt); DoFSINX(xt); DoFX2S(xt,x); RETURN(x) END sin; PROCEDURE DoFCOSX(VAR Dst : EXTENDED); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FCOSX,-(SP) *) CODE(03F3CH);CODE(FCOSX); (* _ELEMS68K ; A9EC *) CODE(ELEMS68K); CODE(RestoreA7);CODE(Return); END DoFCOSX; (*$P+*) PROCEDURE cos (x: REAL) : REAL; VAR xt : EXTENDED; BEGIN DoFS2X(x,xt); DoFCOSX(xt); DoFX2S(xt,x); RETURN(x) END cos; PROCEDURE DoFATANX(VAR Dst : EXTENDED); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FATANX,-(SP) *) CODE(03F3CH);CODE(FATANX); (* _ELEMS68K ; A9EC *) CODE(ELEMS68K); CODE(RestoreA7);CODE(Return); END DoFATANX; (*$P+*) PROCEDURE arctan (x: REAL) : REAL; VAR xt : EXTENDED; BEGIN DoFS2X(x,xt); DoFATANX(xt); DoFX2S(xt,x); RETURN(x) END arctan; PROCEDURE DoFEXPX(VAR Dst : EXTENDED); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FEXPX,-(SP) *) CODE(03F3CH);CODE(FEXPX); (* _ELEMS68K ; A9EC *) CODE(ELEMS68K); CODE(RestoreA7);CODE(Return); END DoFEXPX; (*$P+*) PROCEDURE exp (x: REAL) : REAL; VAR xt : EXTENDED; BEGIN DoFS2X(x,xt); DoFEXPX(xt); DoFX2S(xt,x); RETURN(x) END exp; PROCEDURE DoFLNX(VAR Dst : EXTENDED); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FLNX,-(SP) *) CODE(03F3CH);CODE(FLNX); (* _ELEMS68K ; A9EC *) CODE(ELEMS68K); CODE(RestoreA7);CODE(Return); END DoFLNX; (*$P+*) PROCEDURE ln (x: REAL) : REAL; VAR xt : EXTENDED; BEGIN DoFS2X(x,xt); DoFLNX(xt); DoFX2S(xt,x); RETURN(x) END ln; PROCEDURE DoFTINTX(VAR Dst : EXTENDED); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FTINTX,-(SP) *) CODE(03F3CH);CODE(FTINTX); (* _ELEMS68K ; A9EC *) CODE(ELEMS68K); CODE(RestoreA7);CODE(Return); END DoFTINTX; (*$P+*) PROCEDURE entier (x: REAL) : INTEGER; VAR xt : EXTENDED; i : INTEGER; BEGIN DoFS2X(x,xt); DoFTINTX(xt); DoFX2I(xt,i); RETURN(i) END entier; PROCEDURE real (x: INTEGER) : REAL; VAR xt : EXTENDED; r : REAL; BEGIN DoFI2X(x,xt); DoFX2S(xt,r); RETURN(r) END real; END MathLib0. !Funky!Stuff! echo x - MathLib1.MOD cat >MathLib1.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE MathLib1; (* Math. library 1 *) (* additional mathematical functions*) (* M. Schneider 4. Juli 1983 *) FROM SYSTEM IMPORT ADDRESS,CODE,ADR,WORD; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) FTINTX = 00016H; FX2S = 01010H; FS2X = 0100EH; FI2X = 0200EH; FX2I = 02010H; FLOG2X = 00002H; FEXP2X = 0000AH; FTANX = 0001CH; FRANDX = 00020H; FSCALBX = 00018H; (* scalb(I,X) : X *) pi = 3.1415926536; ELEMS68K = 0A9ECH; FP68K = 0A9EBH; TYPE EXTENDED = RECORD Exp : INTEGER; Value : ARRAY [0..3] OF CARDINAL; END; PROCEDURE ELEMS68K2(VAR src,dst:EXTENDED; code:WORD); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* _ELEMS68K ; A9EB *) CODE(ELEMS68K); CODE(RestoreA7);CODE(Return); END ELEMS68K2; PROCEDURE ELEMS68K1(VAR dst:EXTENDED; code:WORD); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* _ELEMS68K ; A9EB *) CODE(ELEMS68K); CODE(RestoreA7);CODE(Return); END ELEMS68K1; PROCEDURE FP68K2(VAR src,dst:EXTENDED; code:WORD); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* _FP68K ; A9EB *) CODE(FP68K); CODE(RestoreA7);CODE(Return); END FP68K2; PROCEDURE FP68K1(VAR dst:EXTENDED; code:WORD); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* _FP68K ; A9EB *) CODE(FP68K); CODE(RestoreA7);CODE(Return); END FP68K1; PROCEDURE DoFS2X(VAR Sgl : REAL; VAR Ext : EXTENDED); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FS2X,-(SP) *) CODE(03F3CH);CODE(FS2X); (* _FP68K ; A9EB *) CODE(0A9EBH); CODE(RestoreA7);CODE(Return); END DoFS2X; PROCEDURE DoFX2S(VAR Ext : EXTENDED; VAR Sgl : REAL); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FX2S,-(SP) *) CODE(03F3CH);CODE(FX2S); (* _FP68K ; A9EB *) CODE(0A9EBH); CODE(RestoreA7);CODE(Return); END DoFX2S; (*$P+*)(*$S-*) PROCEDURE exp2 ( x: REAL ): REAL; VAR p : EXTENDED; BEGIN DoFS2X(x,p); ELEMS68K1(p,FEXP2X); DoFX2S(p,x); END exp2; PROCEDURE log2 ( x: REAL ): REAL; VAR p : EXTENDED; BEGIN DoFS2X(x,p); ELEMS68K1(p,FLOG2X); DoFX2S(p,x); END log2; PROCEDURE tan ( x: REAL ): REAL; VAR p : EXTENDED; BEGIN DoFS2X(x,p); ELEMS68K1(p,FTANX); DoFX2S(p,x); END tan; VAR Seed:EXTENDED; Convert:REAL; PROCEDURE scalb(VAR i:INTEGER;VAR x:EXTENDED); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FSCALBX,-(SP) *) CODE(03F3CH);CODE(FSCALBX); (* _FP68K ; A9EB *) CODE(0A9EBH); CODE(RestoreA7);CODE(Return); END scalb; (*$P+*) PROCEDURE random(): REAL; (* range: 0.0 <= random < 1.0 *) VAR p : EXTENDED; i : INTEGER; BEGIN ELEMS68K1(p,FRANDX); i := 1; scalb(i,p); DoFX2S(p,Convert); RETURN(Convert); END random; PROCEDURE setrandom( x0: REAL ); BEGIN DoFS2X(x0,Seed); END setrandom; PROCEDURE PI(): REAL; BEGIN RETURN(pi) END PI; BEGIN Convert := 0.0; DoFS2X(Convert,Seed); END MathLib1. !Funky!Stuff! echo x - MemoryManager.MOD cat >MemoryManager.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE MemoryManager; FROM SYSTEM IMPORT ADDRESS,CODE,ADR,REGISTER,SETREG; FROM MacSYSTEM IMPORT Handle,LONGINT,OSErr; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) RD0 = 0; RA0 = 8; RD1 = 1; RA1 = 9; RD2 = 2; RA2 = 0AH; RD3 = 3; RA3 = 0BH; RD4 = 4; RA4 = 0CH; RD5 = 5; RA5 = 0DH; RD6 = 6; RA6 = 0EH; RD7 = 7; RA7 = 0FH; VAR MMError:OSErr; (* Routines *) (* Initialization and Allocation *) PROCEDURE InitApplZone; (*$S-*) BEGIN CODE(0A20CH); MMError := OSErr(REGISTER(RD0)); END InitApplZone; PROCEDURE SetApplBase(startPtr:ADDRESS); (*$S-*) BEGIN SETREG(RA0,startPtr); CODE(0A857H); MMError := OSErr(REGISTER(RD0)); END SetApplBase; PROCEDURE InitZone(pGrowZone:ADDRESS;cMoreMasters:INTEGER; limitPtr,startPtr:ADDRESS); BEGIN SETREG(RA0,ADR(startPtr)); MMError := OSErr(REGISTER(RD0)); END InitZone; PROCEDURE GetApplLimit():ADDRESS; (*$P+*)(*$S-*) BEGIN RETURN(ApplLimit) END GetApplLimit; PROCEDURE SetApplLimit(zoneLimit:ADDRESS); BEGIN SETREG(RA0,zoneLimit); CODE(0A02DH); MMError := OSErr(REGISTER(RD0)); END SetApplLimit; PROCEDURE MaxApplZone; (* No trap Macro *) (*$P+*) BEGIN END MaxApplZone; PROCEDURE MoreMasters; BEGIN CODE(0A036H); MMError := OSErr(REGISTER(RD0)); END MoreMasters; (* Heap Zone Access *) PROCEDURE GetZone():THz; BEGIN CODE(0A11AH); MMError := OSErr(REGISTER(RD0)); RETURN(REGISTER(RA0)) END GetZone; PROCEDURE SetZone(hz:THz); BEGIN SETREG(RA0,hz); CODE(0A01BH); MMError := OSErr(REGISTER(RD0)); END SetZone; PROCEDURE SystemZone():THz; (* No trap macro *) BEGIN RETURN(THz(SysZone)) END SystemZone; PROCEDURE ApplicZone():THz; (* No trap macro *) BEGIN RETURN(THz(ApplZone)) END ApplicZone; (* Allocating and Releasing Relocatable Blocks *) PROCEDURE NewHandle(logicalSize:Size):Handle; BEGIN SETREG(RD0,logicalSize); CODE(0A122H); MMError := OSErr(REGISTER(RD0)); RETURN(REGISTER(RA0)) END NewHandle; PROCEDURE DisposHandle(h:Handle); BEGIN SETREG(RA0,h); CODE(0A023H); MMError := OSErr(REGISTER(RD0)); END DisposHandle; PROCEDURE GetHandleSize(h:Handle):Size; BEGIN SETREG(RA0,h); CODE(0A025H); MMError := OSErr(REGISTER(RD0)); RETURN(REGISTER(RD0)) END GetHandleSize; PROCEDURE SetHandleSize(h:Handle;newSize:Size); BEGIN SETREG(RA0,h); SETREG(RD0,newSize); CODE(0A024H); MMError := OSErr(REGISTER(RD0)); END SetHandleSize; PROCEDURE HandleZone(h:Handle):THz; BEGIN SETREG(RA0,h); CODE(0A126H); MMError := OSErr(REGISTER(RD0)); RETURN(REGISTER(RA0)) END HandleZone; PROCEDURE RecoverHandle(p:ADDRESS):Handle; BEGIN SETREG(RA0,p); CODE(0A128H); MMError := OSErr(REGISTER(RD0)); RETURN(REGISTER(RA0)) END RecoverHandle; PROCEDURE ReallocHandle(h:Handle;logicalSize:Size); BEGIN SETREG(RA0,h); SETREG(RD0,logicalSize); CODE(0A127H); MMError := OSErr(REGISTER(RD0)); END ReallocHandle; (* Allocating and Releasing Nonrelocatable Blocks *) PROCEDURE NewPtr(logicalSize:Size):ADDRESS; BEGIN SETREG(RD0,logicalSize); CODE(0A1EH); MMError := OSErr(REGISTER(RD0)); RETURN(REGISTER(RA0)) END NewPtr; PROCEDURE DisposPtr(p:ADDRESS); BEGIN SETREG(RA0,p); CODE(0A01FH); MMError := OSErr(REGISTER(RD0)); END DisposPtr; PROCEDURE GetPtrSize(p:ADDRESS):Size; BEGIN SETREG(RA0,p); CODE(0A021H); MMError := OSErr(REGISTER(RD0)); RETURN(REGISTER(RD0)) END GetPtrSize; PROCEDURE SetPtrSize(p:ADDRESS;newSize:Size); BEGIN SETREG(RA0,p); SETREG(RD0,newSize); CODE(0A020H); MMError := OSErr(REGISTER(RD0)); END SetPtrSize; PROCEDURE PtrZone(p:ADDRESS):THz; BEGIN SETREG(RA0,p); CODE(0A148H); MMError := OSErr(REGISTER(RD0)); RETURN(REGISTER(RA0)) END PtrZone; (* Freeing Space in the Heap *) PROCEDURE FreeMem():LONGINT; BEGIN CODE(0A01CH); MMError := OSErr(REGISTER(RD0)); RETURN(REGISTER(RD0)) END FreeMem; PROCEDURE MaxMem(VAR grow:Size):Size; BEGIN CODE(0A01DH); MMError := OSErr(REGISTER(RD0)); RETURN(REGISTER(RD0)) END MaxMem; PROCEDURE CompactMem(cbNeeded:Size):Size; BEGIN SETREG(RD0,cbNeeded); CODE(0A04CH); MMError := OSErr(REGISTER(RD0)); RETURN(REGISTER(RD0)) END CompactMem; PROCEDURE ResrvMem(cbNeeded:Size); BEGIN SETREG(RD0,cbNeeded); CODE(0A040H); MMError := OSErr(REGISTER(RD0)); END ResrvMem; PROCEDURE PurgeMem(cbNeeded:Size); BEGIN SETREG(RD0,cbNeeded); CODE(0A04DH); MMError := OSErr(REGISTER(RD0)); END PurgeMem; PROCEDURE EmptyHandle(h:Handle); BEGIN SETREG(RA0,h); CODE(0A02BH); MMError := OSErr(REGISTER(RD0)); END EmptyHandle; (* Properties of Relocatable Blocks *) PROCEDURE HLock(h:Handle); BEGIN SETREG(RA0,h); CODE(0A029H); MMError := OSErr(REGISTER(RD0)); END HLock; PROCEDURE HUnlock(h:Handle); BEGIN SETREG(RA0,h); CODE(0A02AH); MMError := OSErr(REGISTER(RD0)); END HUnlock; PROCEDURE HPurge(h:Handle); BEGIN SETREG(RA0,h); CODE(0A049H); MMError := OSErr(REGISTER(RD0)); END HPurge; PROCEDURE HNoPurge(h:Handle); BEGIN SETREG(RA0,h); CODE(0A049H); MMError := OSErr(REGISTER(RD0)); END HNoPurge; (* Grow Zone Operations *) PROCEDURE SetGrowZone(growZone:ADDRESS); BEGIN SETREG(RA0,growZone); CODE(0A04BH); MMError := OSErr(REGISTER(RD0)); END SetGrowZone; PROCEDURE GZSaveHnd():Handle; (* No trap macro *) BEGIN RETURN(GZRootHnd) END GZSaveHnd; (* Miscellaneous Routines *) PROCEDURE BlockMove(src,dst:ADDRESS;count:Size); BEGIN SETREG(RA0,src); SETREG(RA1,dst); SETREG(RD0,count); CODE(0A02EH); MMError := OSErr(REGISTER(RD0)); END BlockMove; PROCEDURE TopMem():ADDRESS; (* No trap macro *) BEGIN RETURN(MemTop) END TopMem; PROCEDURE MoveHHi(h:Handle); BEGIN END MoveHHi; PROCEDURE MemError():OSErr; (* No trap macro *) BEGIN RETURN(MMError) END MemError; (* Grow Zone Function *) END MemoryManager. !Funky!Stuff! echo x - MenuManager.MOD cat >MenuManager.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE MenuManager; FROM SYSTEM IMPORT ADDRESS,WORD,CODE,ADR; FROM MacSYSTEM IMPORT LONGINT,Handle; FROM PascalStrings IMPORT MakePascalString,MakeModulaString; FROM QuickDraw IMPORT Point,Rect,Style; FROM WindowManager IMPORT inMenuBar; (* Init WindowManager First *) FROM ResourceManager IMPORT ResType,ParamResType; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) PROCEDURE xNewMenu(menuID:INTEGER;menuTitle:ADDRESS):MenuHandle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A931H); CODE(RestoreA7);CODE(Return); END xNewMenu; PROCEDURE NewMenu(menuID:INTEGER;VAR menuTitle:ARRAY OF CHAR):MenuHandle; (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(menuTitle,Str); RETURN(xNewMenu(menuID,ADR(Str))) END NewMenu; PROCEDURE GetMenu(resourceID:INTEGER):MenuHandle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9BFH); CODE(RestoreA7);CODE(Return); END GetMenu; PROCEDURE DisposeMenu(theMenu:MenuHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A932H); CODE(RestoreA7);CODE(Return); END DisposeMenu; (*Forming the Menus*) PROCEDURE xAppendMenu(theMenu:MenuHandle;data:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A933H); CODE(RestoreA7);CODE(Return); END xAppendMenu; PROCEDURE AppendMenu(theMenu:MenuHandle;VAR data:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(data,Str); xAppendMenu(theMenu,ADR(Str)) END AppendMenu; PROCEDURE xAddResMenu(theMenu:MenuHandle;theType:LONGINT); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A94DH); CODE(RestoreA7);CODE(Return); END xAddResMenu; PROCEDURE AddResMenu(theMenu:MenuHandle;theType:ResType); (*$P+*)(*$S-*) VAR x:ParamResType; BEGIN x.res := theType; xAddResMenu(theMenu,x.param); END AddResMenu; PROCEDURE xInsertResMenu(theMenu:MenuHandle;theType:LONGINT; afterItem:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A951H); CODE(RestoreA7);CODE(Return); END xInsertResMenu; PROCEDURE InsertResMenu(theMenu:MenuHandle;theType:ResType; afterItem:INTEGER); (*$P+*)(*$S-*) VAR x:ParamResType; BEGIN x.res := theType; xInsertResMenu(theMenu,x.param,afterItem) END InsertResMenu; (*Forming the Menus*) PROCEDURE InsertMenu(theMenu:MenuHandle;beforeID:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A935H); CODE(RestoreA7);CODE(Return); END InsertMenu; PROCEDURE DrawMenuBar; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A937H); CODE(RestoreA7);CODE(Return); END DrawMenuBar; PROCEDURE DeleteMenu(menuID:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A936H); CODE(RestoreA7);CODE(Return); END DeleteMenu; PROCEDURE ClearMenuBar; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A934H); CODE(RestoreA7);CODE(Return); END ClearMenuBar; PROCEDURE GetNewMBar(menuBarID:INTEGER):Handle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9C0H); CODE(RestoreA7);CODE(Return); END GetNewMBar; PROCEDURE GetMenuBar():Handle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A93BH); CODE(RestoreA7);CODE(Return); END GetMenuBar; PROCEDURE SetMenuBar(menuList:Handle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A93CH); CODE(RestoreA7);CODE(Return); END SetMenuBar; (*Choosing from a menu*) PROCEDURE xMenuSelect(startPt:LONGINT):LONGINT; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A93DH); CODE(RestoreA7);CODE(Return); END xMenuSelect; PROCEDURE MenuSelect(startPt:Point):LONGINT; (*$P+*)(*$S-*) BEGIN RETURN(xMenuSelect(startPt.param)) END MenuSelect; PROCEDURE xMenuKey(ch:CARDINAL):LONGINT; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A93EH); CODE(RestoreA7);CODE(Return); END xMenuKey; PROCEDURE MenuKey(ch:CHAR):LONGINT; (*$P+*)(*$S-*) BEGIN RETURN(xMenuKey(ORD(ch))) END MenuKey; PROCEDURE HiliteMenu(menuID:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A938H); CODE(RestoreA7);CODE(Return); END HiliteMenu; (*Controlling Items' Appearance*) PROCEDURE xSetItem(theMenu:MenuHandle;item:INTEGER;itemString:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A947H); CODE(RestoreA7);CODE(Return); END xSetItem; PROCEDURE SetItem(theMenu:MenuHandle;item:INTEGER;VAR itemString:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(itemString,Str); xSetItem(theMenu,item,ADR(Str)) END SetItem; PROCEDURE xGetItem(theMenu:MenuHandle;item:INTEGER;itemString:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A946H); CODE(RestoreA7);CODE(Return); END xGetItem; PROCEDURE GetItem(theMenu:MenuHandle;item:INTEGER;VAR itemString:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN xGetItem(theMenu,item,ADR(Str)); MakeModulaString(Str,itemString) END GetItem; PROCEDURE DisableItem(theMenu:MenuHandle;item:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A93AH); CODE(RestoreA7);CODE(Return); END DisableItem; PROCEDURE EnableItem(theMenu:MenuHandle;item:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A939H); CODE(RestoreA7);CODE(Return); END EnableItem; PROCEDURE CheckItem(theMenu:MenuHandle;item:INTEGER;checked:BOOLEAN); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A945H); CODE(RestoreA7);CODE(Return); END CheckItem; PROCEDURE xSetItemMark(theMenu:MenuHandle;item:INTEGER;markChar:CARDINAL); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A944H); CODE(RestoreA7);CODE(Return); END xSetItemMark; PROCEDURE SetItemMark(theMenu:MenuHandle;item:INTEGER;markChar:CHAR); (*$P+*)(*$S-*) BEGIN xSetItemMark(theMenu,item,ORD(markChar)) END SetItemMark; PROCEDURE GetItemMark(theMenu:MenuHandle;item:INTEGER;VAR markChar:CHAR); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A943H); CODE(RestoreA7);CODE(Return); END GetItemMark; PROCEDURE xSetItemIcon(theMenu:MenuHandle;item:INTEGER;icon:CARDINAL); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A940H); CODE(RestoreA7);CODE(Return); END xSetItemIcon; PROCEDURE SetItemIcon(theMenu:MenuHandle;item:INTEGER;icon:CHAR); (*$P+*)(*$S-*) BEGIN xSetItemIcon(theMenu,item,ORD(icon)) END SetItemIcon; PROCEDURE GetItemIcon(theMenu:MenuHandle;item:INTEGER;VAR icon:CHAR); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A93FH); CODE(RestoreA7);CODE(Return); END GetItemIcon; PROCEDURE SetItemStyle(theMenu:MenuHandle;item:INTEGER;chStyle:Style); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A942H); CODE(RestoreA7);CODE(Return); END SetItemStyle; PROCEDURE GetItemStyle (theMenu: MenuHandle;item:INTEGER; VAR chStyle:Style); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A941H); CODE(RestoreA7);CODE(Return); END GetItemStyle; (*Miscellaneous Routines*) PROCEDURE CalcMenuSize(theMenu:MenuHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A948H); CODE(RestoreA7);CODE(Return); END CalcMenuSize; PROCEDURE CountMItems(theMenu:MenuHandle):INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A950H); CODE(RestoreA7);CODE(Return); END CountMItems; PROCEDURE GetMHandle(menuID:INTEGER):MenuHandle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A949H); CODE(RestoreA7);CODE(Return); END GetMHandle; PROCEDURE FlashMenuBar(menuID:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A94CH); CODE(RestoreA7);CODE(Return); END FlashMenuBar; PROCEDURE SetMenuFlash(count:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A94AH); CODE(RestoreA7);CODE(Return); END SetMenuFlash; (*Menu Definition Procedure*) BEGIN CODE(0A930H); (*InitMenus*) END MenuManager. !Funky!Stuff! echo x - PascalStrings.MOD cat >PascalStrings.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE PascalStrings; PROCEDURE MakePascalString(VAR in: ARRAY OF CHAR; VAR out: ARRAY OF CHAR); VAR i:CARDINAL; (*$S-*) (*$T-*) BEGIN i := 0; WHILE ((i <= HIGH(in)) AND (i < HIGH(out)) AND (in[i] <> 0C)) DO out[i + 1]:=in[i]; INC(i) END; out[0] := CHAR(i); END MakePascalString; PROCEDURE MakeModulaString(VAR in: ARRAY OF CHAR; VAR out: ARRAY OF CHAR); VAR i:CARDINAL; (*$S-*) BEGIN i := 0; WHILE ((i < ORD(in[0])) AND (i <= HIGH(out))) DO out[i]:=in[i + 1]; INC(i) END; IF (i <= HIGH(out)) THEN out[i] := 0C; END END MakeModulaString; PROCEDURE emptyPascalString(VAR string:ARRAY OF CHAR); (*$S-*) BEGIN string[0] := 0C END emptyPascalString; END PascalStrings. !Funky!Stuff! echo x - Pictures.MOD cat >Pictures.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE Pictures; FROM SYSTEM IMPORT ADDRESS,CODE,ADR; FROM QuickDraw IMPORT Rect; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) (* Picture Routines *) PROCEDURE GetPicture(picID:INTEGER):PicHandle; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9BCH); CODE(RestoreA7); CODE(Return); END GetPicture; PROCEDURE OpenPicture (VAR picFrame:Rect):PicHandle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8F3H); CODE(RestoreA7);CODE(Return); END OpenPicture; PROCEDURE ClosePicture; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8F4H); CODE(RestoreA7);CODE(Return); END ClosePicture; PROCEDURE KillPicture (thePicture:PicHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8F5H); CODE(RestoreA7);CODE(Return); END KillPicture; PROCEDURE DrawPicture (thePicture:PicHandle;VAR inRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8F6H); CODE(RestoreA7);CODE(Return); END DrawPicture; PROCEDURE PicComment (kind,dataSize:INTEGER;data:PicHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8F2H); CODE(RestoreA7);CODE(Return); END PicComment; END Pictures. !Funky!Stuff! echo x - Regions.MOD cat >Regions.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE Regions; FROM SYSTEM IMPORT ADDRESS,WORD,CODE,ADR,REGISTER; FROM MacSYSTEM IMPORT LONGINT; FROM QuickDraw IMPORT RgnHandle,RgnPtr,Region,Point,Rect,Pattern; FROM PascalStrings IMPORT MakePascalString; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) (* Region Calculations *) PROCEDURE NewRgn():RgnHandle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8D8H); CODE(RestoreA7);CODE(Return); END NewRgn; PROCEDURE OpenRgn; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8DAH); CODE(RestoreA7);CODE(Return); END OpenRgn; PROCEDURE CloseRgn (theRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8DBH); CODE(RestoreA7);CODE(Return); END CloseRgn; PROCEDURE DisposeRgn (theRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8D9H); CODE(RestoreA7);CODE(Return); END DisposeRgn; PROCEDURE SetEmptyRgn (theRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8DDH); CODE(RestoreA7);CODE(Return); END SetEmptyRgn; PROCEDURE RectRgn (theRegion:RgnHandle;VAR theRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8DFH); CODE(RestoreA7);CODE(Return); END RectRgn; PROCEDURE SetRectRgn (theRegion:RgnHandle;left,top,right,bottom:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8DEH); CODE(RestoreA7);CODE(Return); END SetRectRgn; PROCEDURE CopyRgn (fromRegion,toRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8DCH); CODE(RestoreA7);CODE(Return); END CopyRgn; PROCEDURE xPtInRgn (thePoint:LONGINT;theRegion:RgnHandle):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8E8H); CODE(RestoreA7);CODE(Return); END xPtInRgn; PROCEDURE PtInRgn (thePoint:Point;theRegion:RgnHandle):BOOLEAN; (*$P+*)(*$S-*) BEGIN RETURN(xPtInRgn(thePoint.param,theRegion)) END PtInRgn; PROCEDURE RectInRgn (VAR theRect:Rect;theRegion:RgnHandle):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8E9H); CODE(RestoreA7);CODE(Return); END RectInRgn; PROCEDURE OffsetRgn (theRegion:RgnHandle;hOffset,vOffset:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8E0H); CODE(RestoreA7);CODE(Return); END OffsetRgn; PROCEDURE InsetRgn (theRegion:RgnHandle;hInset,vInset:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8E1H); CODE(RestoreA7);CODE(Return); END InsetRgn; PROCEDURE EmptyRgn (theRegion:RgnHandle):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8E2H); CODE(RestoreA7);CODE(Return); END EmptyRgn; PROCEDURE UnionRgn (region1,region2,resultRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8E5H); CODE(RestoreA7);CODE(Return); END UnionRgn; PROCEDURE SectRgn (region1,region2,resultRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8E4H); CODE(RestoreA7);CODE(Return); END SectRgn; PROCEDURE DiffRgn (region1,region2,resultRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8E6H); CODE(RestoreA7);CODE(Return); END DiffRgn; PROCEDURE XOrRgn (region1,region2,resultRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8E7H); CODE(RestoreA7);CODE(Return); END XOrRgn; PROCEDURE EqualRgn (region1,region2:RgnHandle):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8E3H); CODE(RestoreA7);CODE(Return); END EqualRgn; PROCEDURE MapRgn (theRegion:RgnHandle;VAR fromRect,toRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8FBH); CODE(RestoreA7);CODE(Return); END MapRgn; (* Drawing Regions *) PROCEDURE FrameRgn (theRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8D2H); CODE(RestoreA7);CODE(Return); END FrameRgn; PROCEDURE PaintRgn (theRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8D3H); CODE(RestoreA7);CODE(Return); END PaintRgn; PROCEDURE FillRgn (theRegion:RgnHandle;VAR fillPat:Pattern); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8D6H); CODE(RestoreA7);CODE(Return); END FillRgn; PROCEDURE EraseRgn (theRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8D4H); CODE(RestoreA7);CODE(Return); END EraseRgn; PROCEDURE InvertRgn (theRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8D5H); CODE(RestoreA7);CODE(Return); END InvertRgn; END Regions. !Funky!Stuff! # The rest of this file is a shell script which will extract: # MathLib0.MOD MathLib1.MOD MemoryManager.MOD MenuManager.MOD PascalStrings.MOD Pictures.MOD Regions.MOD echo x - MathLib0.MOD cat >MathLib0.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE MathLib0; (*Mathematical library 0 *) FROM SYSTEM IMPORT ADDRESS,CODE,ADR; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) FSQRTX = 00012H; FSINX = 00018H; (* ELEMS68K *) FCOSX = 0001AH; (* ELEMS68K *) FATANX = 0001EH; (* ELEMS68K *) FEXPX = 00008H; (* ELEMS68K *) FLNX = 00000H; (* ELEMS68K *) FTINTX = 00016H; FX2S = 01010H; FS2X = 0100EH; FI2X = 0200EH; FX2I = 02010H; ELEMS68K = 0A9ECH; TYPE EXTENDED = RECORD Exp : INTEGER; Value : ARRAY [0..3] OF CARDINAL; END; (*$S-*) PROCEDURE DoFS2X(VAR Sgl : REAL; VAR Ext : EXTENDED); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FS2X,-(SP) *) CODE(03F3CH);CODE(FS2X); (* _FP68K ; A9EB *) CODE(0A9EBH); CODE(RestoreA7);CODE(Return); END DoFS2X; PROCEDURE DoFX2S(VAR Ext : EXTENDED; VAR Sgl : REAL); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FX2S,-(SP) *) CODE(03F3CH);CODE(FX2S); (* _FP68K ; A9EB *) CODE(0A9EBH); CODE(RestoreA7);CODE(Return); END DoFX2S; (*$P+*) PROCEDURE DoFX2I(VAR Ext : EXTENDED; VAR Sgl : INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FX2I,-(SP) *) CODE(03F3CH);CODE(FX2I); (* _FP68K ; A9EB *) CODE(0A9EBH); CODE(RestoreA7);CODE(Return); END DoFX2I; (*$P+*) PROCEDURE DoFI2X(VAR I : INTEGER; VAR Ext : EXTENDED); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FI2X,-(SP) *) CODE(03F3CH);CODE(FI2X); (* _FP68K ; A9EB *) CODE(0A9EBH); CODE(RestoreA7);CODE(Return); END DoFI2X; (*$P+*) PROCEDURE DoFSQRTX(VAR Dst : EXTENDED); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FSQRTX,-(SP) *) CODE(03F3CH);CODE(FSQRTX); (* _FP68K ; A9EB *) CODE(0A9EBH); CODE(RestoreA7);CODE(Return); END DoFSQRTX; (*$P+*) PROCEDURE sqrt (x: REAL) : REAL; VAR xt : EXTENDED; BEGIN DoFS2X(x,xt); DoFSQRTX(xt); DoFX2S(xt,x); RETURN(x) END sqrt; PROCEDURE DoFSINX(VAR Dst : EXTENDED); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FSINX,-(SP) *) CODE(03F3CH);CODE(FSINX); (* _ELEMS68K ; A9EC *) CODE(ELEMS68K); CODE(RestoreA7);CODE(Return); END DoFSINX; (*$P+*) PROCEDURE sin(x: REAL) : REAL; VAR xt : EXTENDED; BEGIN DoFS2X(x,xt); DoFSINX(xt); DoFX2S(xt,x); RETURN(x) END sin; PROCEDURE DoFCOSX(VAR Dst : EXTENDED); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FCOSX,-(SP) *) CODE(03F3CH);CODE(FCOSX); (* _ELEMS68K ; A9EC *) CODE(ELEMS68K); CODE(RestoreA7);CODE(Return); END DoFCOSX; (*$P+*) PROCEDURE cos (x: REAL) : REAL; VAR xt : EXTENDED; BEGIN DoFS2X(x,xt); DoFCOSX(xt); DoFX2S(xt,x); RETURN(x) END cos; PROCEDURE DoFATANX(VAR Dst : EXTENDED); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FATANX,-(SP) *) CODE(03F3CH);CODE(FATANX); (* _ELEMS68K ; A9EC *) CODE(ELEMS68K); CODE(RestoreA7);CODE(Return); END DoFATANX; (*$P+*) PROCEDURE arctan (x: REAL) : REAL; VAR xt : EXTENDED; BEGIN DoFS2X(x,xt); DoFATANX(xt); DoFX2S(xt,x); RETURN(x) END arctan; PROCEDURE DoFEXPX(VAR Dst : EXTENDED); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FEXPX,-(SP) *) CODE(03F3CH);CODE(FEXPX); (* _ELEMS68K ; A9EC *) CODE(ELEMS68K); CODE(RestoreA7);CODE(Return); END DoFEXPX; (*$P+*) PROCEDURE exp (x: REAL) : REAL; VAR xt : EXTENDED; BEGIN DoFS2X(x,xt); DoFEXPX(xt); DoFX2S(xt,x); RETURN(x) END exp; PROCEDURE DoFLNX(VAR Dst : EXTENDED); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FLNX,-(SP) *) CODE(03F3CH);CODE(FLNX); (* _ELEMS68K ; A9EC *) CODE(ELEMS68K); CODE(RestoreA7);CODE(Return); END DoFLNX; (*$P+*) PROCEDURE ln (x: REAL) : REAL; VAR xt : EXTENDED; BEGIN DoFS2X(x,xt); DoFLNX(xt); DoFX2S(xt,x); RETURN(x) END ln; PROCEDURE DoFTINTX(VAR Dst : EXTENDED); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FTINTX,-(SP) *) CODE(03F3CH);CODE(FTINTX); (* _ELEMS68K ; A9EC *) CODE(ELEMS68K); CODE(RestoreA7);CODE(Return); END DoFTINTX; (*$P+*) PROCEDURE entier (x: REAL) : INTEGER; VAR xt : EXTENDED; i : INTEGER; BEGIN DoFS2X(x,xt); DoFTINTX(xt); DoFX2I(xt,i); RETURN(i) END entier; PROCEDURE real (x: INTEGER) : REAL; VAR xt : EXTENDED; r : REAL; BEGIN DoFI2X(x,xt); DoFX2S(xt,r); RETURN(r) END real; END MathLib0. !Funky!Stuff! echo x - MathLib1.MOD cat >MathLib1.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE MathLib1; (* Math. library 1 *) (* additional mathematical functions*) (* M. Schneider 4. Juli 1983 *) FROM SYSTEM IMPORT ADDRESS,CODE,ADR,WORD; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) FTINTX = 00016H; FX2S = 01010H; FS2X = 0100EH; FI2X = 0200EH; FX2I = 02010H; FLOG2X = 00002H; FEXP2X = 0000AH; FTANX = 0001CH; FRANDX = 00020H; FSCALBX = 00018H; (* scalb(I,X) : X *) pi = 3.1415926536; ELEMS68K = 0A9ECH; FP68K = 0A9EBH; TYPE EXTENDED = RECORD Exp : INTEGER; Value : ARRAY [0..3] OF CARDINAL; END; PROCEDURE ELEMS68K2(VAR src,dst:EXTENDED; code:WORD); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* _ELEMS68K ; A9EB *) CODE(ELEMS68K); CODE(RestoreA7);CODE(Return); END ELEMS68K2; PROCEDURE ELEMS68K1(VAR dst:EXTENDED; code:WORD); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* _ELEMS68K ; A9EB *) CODE(ELEMS68K); CODE(RestoreA7);CODE(Return); END ELEMS68K1; PROCEDURE FP68K2(VAR src,dst:EXTENDED; code:WORD); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* _FP68K ; A9EB *) CODE(FP68K); CODE(RestoreA7);CODE(Return); END FP68K2; PROCEDURE FP68K1(VAR dst:EXTENDED; code:WORD); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* _FP68K ; A9EB *) CODE(FP68K); CODE(RestoreA7);CODE(Return); END FP68K1; PROCEDURE DoFS2X(VAR Sgl : REAL; VAR Ext : EXTENDED); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FS2X,-(SP) *) CODE(03F3CH);CODE(FS2X); (* _FP68K ; A9EB *) CODE(0A9EBH); CODE(RestoreA7);CODE(Return); END DoFS2X; PROCEDURE DoFX2S(VAR Ext : EXTENDED; VAR Sgl : REAL); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FX2S,-(SP) *) CODE(03F3CH);CODE(FX2S); (* _FP68K ; A9EB *) CODE(0A9EBH); CODE(RestoreA7);CODE(Return); END DoFX2S; (*$P+*)(*$S-*) PROCEDURE exp2 ( x: REAL ): REAL; VAR p : EXTENDED; BEGIN DoFS2X(x,p); ELEMS68K1(p,FEXP2X); DoFX2S(p,x); END exp2; PROCEDURE log2 ( x: REAL ): REAL; VAR p : EXTENDED; BEGIN DoFS2X(x,p); ELEMS68K1(p,FLOG2X); DoFX2S(p,x); END log2; PROCEDURE tan ( x: REAL ): REAL; VAR p : EXTENDED; BEGIN DoFS2X(x,p); ELEMS68K1(p,FTANX); DoFX2S(p,x); END tan; VAR Seed:EXTENDED; Convert:REAL; PROCEDURE scalb(VAR i:INTEGER;VAR x:EXTENDED); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); (* MOVE #FSCALBX,-(SP) *) CODE(03F3CH);CODE(FSCALBX); (* _FP68K ; A9EB *) CODE(0A9EBH); CODE(RestoreA7);CODE(Return); END scalb; (*$P+*) PROCEDURE random(): REAL; (* range: 0.0 <= random < 1.0 *) VAR p : EXTENDED; i : INTEGER; BEGIN ELEMS68K1(p,FRANDX); i := 1; scalb(i,p); DoFX2S(p,Convert); RETURN(Convert); END random; PROCEDURE setrandom( x0: REAL ); BEGIN DoFS2X(x0,Seed); END setrandom; PROCEDURE PI(): REAL; BEGIN RETURN(pi) END PI; BEGIN Convert := 0.0; DoFS2X(Convert,Seed); END MathLib1. !Funky!Stuff! echo x - MemoryManager.MOD cat >MemoryManager.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE MemoryManager; FROM SYSTEM IMPORT ADDRESS,CODE,ADR,REGISTER,SETREG; FROM MacSYSTEM IMPORT Handle,LONGINT,OSErr; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) RD0 = 0; RA0 = 8; RD1 = 1; RA1 = 9; RD2 = 2; RA2 = 0AH; RD3 = 3; RA3 = 0BH; RD4 = 4; RA4 = 0CH; RD5 = 5; RA5 = 0DH; RD6 = 6; RA6 = 0EH; RD7 = 7; RA7 = 0FH; VAR MMError:OSErr; (* Routines *) (* Initialization and Allocation *) PROCEDURE InitApplZone; (*$S-*) BEGIN CODE(0A20CH); MMError := OSErr(REGISTER(RD0)); END InitApplZone; PROCEDURE SetApplBase(startPtr:ADDRESS); (*$S-*) BEGIN SETREG(RA0,startPtr); CODE(0A857H); MMError := OSErr(REGISTER(RD0)); END SetApplBase; PROCEDURE InitZone(pGrowZone:ADDRESS;cMoreMasters:INTEGER; limitPtr,startPtr:ADDRESS); BEGIN SETREG(RA0,ADR(startPtr)); MMError := OSErr(REGISTER(RD0)); END InitZone; PROCEDURE GetApplLimit():ADDRESS; (*$P+*)(*$S-*) BEGIN RETURN(ApplLimit) END GetApplLimit; PROCEDURE SetApplLimit(zoneLimit:ADDRESS); BEGIN SETREG(RA0,zoneLimit); CODE(0A02DH); MMError := OSErr(REGISTER(RD0)); END SetApplLimit; PROCEDURE MaxApplZone; (* No trap Macro *) (*$P+*) BEGIN END MaxApplZone; PROCEDURE MoreMasters; BEGIN CODE(0A036H); MMError := OSErr(REGISTER(RD0)); END MoreMasters; (* Heap Zone Access *) PROCEDURE GetZone():THz; BEGIN CODE(0A11AH); MMError := OSErr(REGISTER(RD0)); RETURN(REGISTER(RA0)) END GetZone; PROCEDURE SetZone(hz:THz); BEGIN SETREG(RA0,hz); CODE(0A01BH); MMError := OSErr(REGISTER(RD0)); END SetZone; PROCEDURE SystemZone():THz; (* No trap macro *) BEGIN RETURN(THz(SysZone)) END SystemZone; PROCEDURE ApplicZone():THz; (* No trap macro *) BEGIN RETURN(THz(ApplZone)) END ApplicZone; (* Allocating and Releasing Relocatable Blocks *) PROCEDURE NewHandle(logicalSize:Size):Handle; BEGIN SETREG(RD0,logicalSize); CODE(0A122H); MMError := OSErr(REGISTER(RD0)); RETURN(REGISTER(RA0)) END NewHandle; PROCEDURE DisposHandle(h:Handle); BEGIN SETREG(RA0,h); CODE(0A023H); MMError := OSErr(REGISTER(RD0)); END DisposHandle; PROCEDURE GetHandleSize(h:Handle):Size; BEGIN SETREG(RA0,h); CODE(0A025H); MMError := OSErr(REGISTER(RD0)); RETURN(REGISTER(RD0)) END GetHandleSize; PROCEDURE SetHandleSize(h:Handle;newSize:Size); BEGIN SETREG(RA0,h); SETREG(RD0,newSize); CODE(0A024H); MMError := OSErr(REGISTER(RD0)); END SetHandleSize; PROCEDURE HandleZone(h:Handle):THz; BEGIN SETREG(RA0,h); CODE(0A126H); MMError := OSErr(REGISTER(RD0)); RETURN(REGISTER(RA0)) END HandleZone; PROCEDURE RecoverHandle(p:ADDRESS):Handle; BEGIN SETREG(RA0,p); CODE(0A128H); MMError := OSErr(REGISTER(RD0)); RETURN(REGISTER(RA0)) END RecoverHandle; PROCEDURE ReallocHandle(h:Handle;logicalSize:Size); BEGIN SETREG(RA0,h); SETREG(RD0,logicalSize); CODE(0A127H); MMError := OSErr(REGISTER(RD0)); END ReallocHandle; (* Allocating and Releasing Nonrelocatable Blocks *) PROCEDURE NewPtr(logicalSize:Size):ADDRESS; BEGIN SETREG(RD0,logicalSize); CODE(0A1EH); MMError := OSErr(REGISTER(RD0)); RETURN(REGISTER(RA0)) END NewPtr; PROCEDURE DisposPtr(p:ADDRESS); BEGIN SETREG(RA0,p); CODE(0A01FH); MMError := OSErr(REGISTER(RD0)); END DisposPtr; PROCEDURE GetPtrSize(p:ADDRESS):Size; BEGIN SETREG(RA0,p); CODE(0A021H); MMError := OSErr(REGISTER(RD0)); RETURN(REGISTER(RD0)) END GetPtrSize; PROCEDURE SetPtrSize(p:ADDRESS;newSize:Size); BEGIN SETREG(RA0,p); SETREG(RD0,newSize); CODE(0A020H); MMError := OSErr(REGISTER(RD0)); END SetPtrSize; PROCEDURE PtrZone(p:ADDRESS):THz; BEGIN SETREG(RA0,p); CODE(0A148H); MMError := OSErr(REGISTER(RD0)); RETURN(REGISTER(RA0)) END PtrZone; (* Freeing Space in the Heap *) PROCEDURE FreeMem():LONGINT; BEGIN CODE(0A01CH); MMError := OSErr(REGISTER(RD0)); RETURN(REGISTER(RD0)) END FreeMem; PROCEDURE MaxMem(VAR grow:Size):Size; BEGIN CODE(0A01DH); MMError := OSErr(REGISTER(RD0)); RETURN(REGISTER(RD0)) END MaxMem; PROCEDURE CompactMem(cbNeeded:Size):Size; BEGIN SETREG(RD0,cbNeeded); CODE(0A04CH); MMError := OSErr(REGISTER(RD0)); RETURN(REGISTER(RD0)) END CompactMem; PROCEDURE ResrvMem(cbNeeded:Size); BEGIN SETREG(RD0,cbNeeded); CODE(0A040H); MMError := OSErr(REGISTER(RD0)); END ResrvMem; PROCEDURE PurgeMem(cbNeeded:Size); BEGIN SETREG(RD0,cbNeeded); CODE(0A04DH); MMError := OSErr(REGISTER(RD0)); END PurgeMem; PROCEDURE EmptyHandle(h:Handle); BEGIN SETREG(RA0,h); CODE(0A02BH); MMError := OSErr(REGISTER(RD0)); END EmptyHandle; (* Properties of Relocatable Blocks *) PROCEDURE HLock(h:Handle); BEGIN SETREG(RA0,h); CODE(0A029H); MMError := OSErr(REGISTER(RD0)); END HLock; PROCEDURE HUnlock(h:Handle); BEGIN SETREG(RA0,h); CODE(0A02AH); MMError := OSErr(REGISTER(RD0)); END HUnlock; PROCEDURE HPurge(h:Handle); BEGIN SETREG(RA0,h); CODE(0A049H); MMError := OSErr(REGISTER(RD0)); END HPurge; PROCEDURE HNoPurge(h:Handle); BEGIN SETREG(RA0,h); CODE(0A049H); MMError := OSErr(REGISTER(RD0)); END HNoPurge; (* Grow Zone Operations *) PROCEDURE SetGrowZone(growZone:ADDRESS); BEGIN SETREG(RA0,growZone); CODE(0A04BH); MMError := OSErr(REGISTER(RD0)); END SetGrowZone; PROCEDURE GZSaveHnd():Handle; (* No trap macro *) BEGIN RETURN(GZRootHnd) END GZSaveHnd; (* Miscellaneous Routines *) PROCEDURE BlockMove(src,dst:ADDRESS;count:Size); BEGIN SETREG(RA0,src); SETREG(RA1,dst); SETREG(RD0,count); CODE(0A02EH); MMError := OSErr(REGISTER(RD0)); END BlockMove; PROCEDURE TopMem():ADDRESS; (* No trap macro *) BEGIN RETURN(MemTop) END TopMem; PROCEDURE MoveHHi(h:Handle); BEGIN END MoveHHi; PROCEDURE MemError():OSErr; (* No trap macro *) BEGIN RETURN(MMError) END MemError; (* Grow Zone Function *) END MemoryManager. !Funky!Stuff! echo x - MenuManager.MOD cat >MenuManager.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE MenuManager; FROM SYSTEM IMPORT ADDRESS,WORD,CODE,ADR; FROM MacSYSTEM IMPORT LONGINT,Handle; FROM PascalStrings IMPORT MakePascalString,MakeModulaString; FROM QuickDraw IMPORT Point,Rect,Style; FROM WindowManager IMPORT inMenuBar; (* Init WindowManager First *) FROM ResourceManager IMPORT ResType,ParamResType; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) PROCEDURE xNewMenu(menuID:INTEGER;menuTitle:ADDRESS):MenuHandle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A931H); CODE(RestoreA7);CODE(Return); END xNewMenu; PROCEDURE NewMenu(menuID:INTEGER;VAR menuTitle:ARRAY OF CHAR):MenuHandle; (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(menuTitle,Str); RETURN(xNewMenu(menuID,ADR(Str))) END NewMenu; PROCEDURE GetMenu(resourceID:INTEGER):MenuHandle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9BFH); CODE(RestoreA7);CODE(Return); END GetMenu; PROCEDURE DisposeMenu(theMenu:MenuHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A932H); CODE(RestoreA7);CODE(Return); END DisposeMenu; (*Forming the Menus*) PROCEDURE xAppendMenu(theMenu:MenuHandle;data:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A933H); CODE(RestoreA7);CODE(Return); END xAppendMenu; PROCEDURE AppendMenu(theMenu:MenuHandle;VAR data:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(data,Str); xAppendMenu(theMenu,ADR(Str)) END AppendMenu; PROCEDURE xAddResMenu(theMenu:MenuHandle;theType:LONGINT); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A94DH); CODE(RestoreA7);CODE(Return); END xAddResMenu; PROCEDURE AddResMenu(theMenu:MenuHandle;theType:ResType); (*$P+*)(*$S-*) VAR x:ParamResType; BEGIN x.res := theType; xAddResMenu(theMenu,x.param); END AddResMenu; PROCEDURE xInsertResMenu(theMenu:MenuHandle;theType:LONGINT; afterItem:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A951H); CODE(RestoreA7);CODE(Return); END xInsertResMenu; PROCEDURE InsertResMenu(theMenu:MenuHandle;theType:ResType; afterItem:INTEGER); (*$P+*)(*$S-*) VAR x:ParamResType; BEGIN x.res := theType; xInsertResMenu(theMenu,x.param,afterItem) END InsertResMenu; (*Forming the Menus*) PROCEDURE InsertMenu(theMenu:MenuHandle;beforeID:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A935H); CODE(RestoreA7);CODE(Return); END InsertMenu; PROCEDURE DrawMenuBar; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A937H); CODE(RestoreA7);CODE(Return); END DrawMenuBar; PROCEDURE DeleteMenu(menuID:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A936H); CODE(RestoreA7);CODE(Return); END DeleteMenu; PROCEDURE ClearMenuBar; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A934H); CODE(RestoreA7);CODE(Return); END ClearMenuBar; PROCEDURE GetNewMBar(menuBarID:INTEGER):Handle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9C0H); CODE(RestoreA7);CODE(Return); END GetNewMBar; PROCEDURE GetMenuBar():Handle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A93BH); CODE(RestoreA7);CODE(Return); END GetMenuBar; PROCEDURE SetMenuBar(menuList:Handle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A93CH); CODE(RestoreA7);CODE(Return); END SetMenuBar; (*Choosing from a menu*) PROCEDURE xMenuSelect(startPt:LONGINT):LONGINT; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A93DH); CODE(RestoreA7);CODE(Return); END xMenuSelect; PROCEDURE MenuSelect(startPt:Point):LONGINT; (*$P+*)(*$S-*) BEGIN RETURN(xMenuSelect(startPt.param)) END MenuSelect; PROCEDURE xMenuKey(ch:CARDINAL):LONGINT; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A93EH); CODE(RestoreA7);CODE(Return); END xMenuKey; PROCEDURE MenuKey(ch:CHAR):LONGINT; (*$P+*)(*$S-*) BEGIN RETURN(xMenuKey(ORD(ch))) END MenuKey; PROCEDURE HiliteMenu(menuID:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A938H); CODE(RestoreA7);CODE(Return); END HiliteMenu; (*Controlling Items' Appearance*) PROCEDURE xSetItem(theMenu:MenuHandle;item:INTEGER;itemString:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A947H); CODE(RestoreA7);CODE(Return); END xSetItem; PROCEDURE SetItem(theMenu:MenuHandle;item:INTEGER;VAR itemString:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(itemString,Str); xSetItem(theMenu,item,ADR(Str)) END SetItem; PROCEDURE xGetItem(theMenu:MenuHandle;item:INTEGER;itemString:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A946H); CODE(RestoreA7);CODE(Return); END xGetItem; PROCEDURE GetItem(theMenu:MenuHandle;item:INTEGER;VAR itemString:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN xGetItem(theMenu,item,ADR(Str)); MakeModulaString(Str,itemString) END GetItem; PROCEDURE DisableItem(theMenu:MenuHandle;item:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A93AH); CODE(RestoreA7);CODE(Return); END DisableItem; PROCEDURE EnableItem(theMenu:MenuHandle;item:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A939H); CODE(RestoreA7);CODE(Return); END EnableItem; PROCEDURE CheckItem(theMenu:MenuHandle;item:INTEGER;checked:BOOLEAN); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A945H); CODE(RestoreA7);CODE(Return); END CheckItem; PROCEDURE xSetItemMark(theMenu:MenuHandle;item:INTEGER;markChar:CARDINAL); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A944H); CODE(RestoreA7);CODE(Return); END xSetItemMark; PROCEDURE SetItemMark(theMenu:MenuHandle;item:INTEGER;markChar:CHAR); (*$P+*)(*$S-*) BEGIN xSetItemMark(theMenu,item,ORD(markChar)) END SetItemMark; PROCEDURE GetItemMark(theMenu:MenuHandle;item:INTEGER;VAR markChar:CHAR); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A943H); CODE(RestoreA7);CODE(Return); END GetItemMark; PROCEDURE xSetItemIcon(theMenu:MenuHandle;item:INTEGER;icon:CARDINAL); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A940H); CODE(RestoreA7);CODE(Return); END xSetItemIcon; PROCEDURE SetItemIcon(theMenu:MenuHandle;item:INTEGER;icon:CHAR); (*$P+*)(*$S-*) BEGIN xSetItemIcon(theMenu,item,ORD(icon)) END SetItemIcon; PROCEDURE GetItemIcon(theMenu:MenuHandle;item:INTEGER;VAR icon:CHAR); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A93FH); CODE(RestoreA7);CODE(Return); END GetItemIcon; PROCEDURE SetItemStyle(theMenu:MenuHandle;item:INTEGER;chStyle:Style); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A942H); CODE(RestoreA7);CODE(Return); END SetItemStyle; PROCEDURE GetItemStyle (theMenu: MenuHandle;item:INTEGER; VAR chStyle:Style); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A941H); CODE(RestoreA7);CODE(Return); END GetItemStyle; (*Miscellaneous Routines*) PROCEDURE CalcMenuSize(theMenu:MenuHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A948H); CODE(RestoreA7);CODE(Return); END CalcMenuSize; PROCEDURE CountMItems(theMenu:MenuHandle):INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A950H); CODE(RestoreA7);CODE(Return); END CountMItems; PROCEDURE GetMHandle(menuID:INTEGER):MenuHandle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A949H); CODE(RestoreA7);CODE(Return); END GetMHandle; PROCEDURE FlashMenuBar(menuID:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A94CH); CODE(RestoreA7);CODE(Return); END FlashMenuBar; PROCEDURE SetMenuFlash(count:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A94AH); CODE(RestoreA7);CODE(Return); END SetMenuFlash; (*Menu Definition Procedure*) BEGIN CODE(0A930H); (*InitMenus*) END MenuManager. !Funky!Stuff! echo x - PascalStrings.MOD cat >PascalStrings.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE PascalStrings; PROCEDURE MakePascalString(VAR in: ARRAY OF CHAR; VAR out: ARRAY OF CHAR); VAR i:CARDINAL; (*$S-*) (*$T-*) BEGIN i := 0; WHILE ((i <= HIGH(in)) AND (i < HIGH(out)) AND (in[i] <> 0C)) DO out[i + 1]:=in[i]; INC(i) END; out[0] := CHAR(i); END MakePascalString; PROCEDURE MakeModulaString(VAR in: ARRAY OF CHAR; VAR out: ARRAY OF CHAR); VAR i:CARDINAL; (*$S-*) BEGIN i := 0; WHILE ((i < ORD(in[0])) AND (i <= HIGH(out))) DO out[i]:=in[i + 1]; INC(i) END; IF (i <= HIGH(out)) THEN out[i] := 0C; END END MakeModulaString; PROCEDURE emptyPascalString(VAR string:ARRAY OF CHAR); (*$S-*) BEGIN string[0] := 0C END emptyPascalString; END PascalStrings. !Funky!Stuff! echo x - Pictures.MOD cat >Pictures.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE Pictures; FROM SYSTEM IMPORT ADDRESS,CODE,ADR; FROM QuickDraw IMPORT Rect; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) (* Picture Routines *) PROCEDURE GetPicture(picID:INTEGER):PicHandle; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9BCH); CODE(RestoreA7); CODE(Return); END GetPicture; PROCEDURE OpenPicture (VAR picFrame:Rect):PicHandle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8F3H); CODE(RestoreA7);CODE(Return); END OpenPicture; PROCEDURE ClosePicture; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8F4H); CODE(RestoreA7);CODE(Return); END ClosePicture; PROCEDURE KillPicture (thePicture:PicHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8F5H); CODE(RestoreA7);CODE(Return); END KillPicture; PROCEDURE DrawPicture (thePicture:PicHandle;VAR inRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8F6H); CODE(RestoreA7);CODE(Return); END DrawPicture; PROCEDURE PicComment (kind,dataSize:INTEGER;data:PicHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8F2H); CODE(RestoreA7);CODE(Return); END PicComment; END Pictures. !Funky!Stuff! echo x - Regions.MOD cat >Regions.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE Regions; FROM SYSTEM IMPORT ADDRESS,WORD,CODE,ADR,REGISTER; FROM MacSYSTEM IMPORT LONGINT; FROM QuickDraw IMPORT RgnHandle,RgnPtr,Region,Point,Rect,Pattern; FROM PascalStrings IMPORT MakePascalString; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) (* Region Calculations *) PROCEDURE NewRgn():RgnHandle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8D8H); CODE(RestoreA7);CODE(Return); END NewRgn; PROCEDURE OpenRgn; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8DAH); CODE(RestoreA7);CODE(Return); END OpenRgn; PROCEDURE CloseRgn (theRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8DBH); CODE(RestoreA7);CODE(Return); END CloseRgn; PROCEDURE DisposeRgn (theRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8D9H); CODE(RestoreA7);CODE(Return); END DisposeRgn; PROCEDURE SetEmptyRgn (theRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8DDH); CODE(RestoreA7);CODE(Return); END SetEmptyRgn; PROCEDURE RectRgn (theRegion:RgnHandle;VAR theRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8DFH); CODE(RestoreA7);CODE(Return); END RectRgn; PROCEDURE SetRectRgn (theRegion:RgnHandle;left,top,right,bottom:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8DEH); CODE(RestoreA7);CODE(Return); END SetRectRgn; PROCEDURE CopyRgn (fromRegion,toRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8DCH); CODE(RestoreA7);CODE(Return); END CopyRgn; PROCEDURE xPtInRgn (thePoint:LONGINT;theRegion:RgnHandle):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8E8H); CODE(RestoreA7);CODE(Return); END xPtInRgn; PROCEDURE PtInRgn (thePoint:Point;theRegion:RgnHandle):BOOLEAN; (*$P+*)(*$S-*) BEGIN RETURN(xPtInRgn(thePoint.param,theRegion)) END PtInRgn; PROCEDURE RectInRgn (VAR theRect:Rect;theRegion:RgnHandle):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8E9H); CODE(RestoreA7);CODE(Return); END RectInRgn; PROCEDURE OffsetRgn (theRegion:RgnHandle;hOffset,vOffset:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8E0H); CODE(RestoreA7);CODE(Return); END OffsetRgn; PROCEDURE InsetRgn (theRegion:RgnHandle;hInset,vInset:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8E1H); CODE(RestoreA7);CODE(Return); END InsetRgn; PROCEDURE EmptyRgn (theRegion:RgnHandle):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8E2H); CODE(RestoreA7);CODE(Return); END EmptyRgn; PROCEDURE UnionRgn (region1,region2,resultRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8E5H); CODE(RestoreA7);CODE(Return); END UnionRgn; PROCEDURE SectRgn (region1,region2,resultRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8E4H); CODE(RestoreA7);CODE(Return); END SectRgn; PROCEDURE DiffRgn (region1,region2,resultRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8E6H); CODE(RestoreA7);CODE(Return); END DiffRgn; PROCEDURE XOrRgn (region1,region2,resultRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8E7H); CODE(RestoreA7);CODE(Return); END XOrRgn; PROCEDURE EqualRgn (region1,region2:RgnHandle):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8E3H); CODE(RestoreA7);CODE(Return); END EqualRgn; PROCEDURE MapRgn (theRegion:RgnHandle;VAR fromRect,toRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8FBH); CODE(RestoreA7);CODE(Return); END MapRgn; (* Drawing Regions *) PROCEDURE FrameRgn (theRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8D2H); CODE(RestoreA7);CODE(Return); END FrameRgn; PROCEDURE PaintRgn (theRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8D3H); CODE(RestoreA7);CODE(Return); END PaintRgn; PROCEDURE FillRgn (theRegion:RgnHandle;VAR fillPat:Pattern); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8D6H); CODE(RestoreA7);CODE(Return); END FillRgn; PROCEDURE EraseRgn (theRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8D4H); CODE(RestoreA7);CODE(Return); END EraseRgn; PROCEDURE InvertRgn (theRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8D5H); CODE(RestoreA7);CODE(Return); END InvertRgn; END Regions. !Funky!Stuff!
bobc@tikal.UUCP (Bob Campbell) (05/14/86)
# The rest of this file is a shell script which will extract: # QuickDraw.MOD ResourceManager.MOD SFPackage.MOD echo x - QuickDraw.MOD cat >QuickDraw.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE QuickDraw; FROM SYSTEM IMPORT ADDRESS,WORD,CODE,ADR,REGISTER; FROM MacSYSTEM IMPORT LONGINT; FROM PascalStrings IMPORT MakePascalString; (*EXPORT QUALIFIED...*) (* GrafPort Routines *) CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) PROCEDURE InitGraf (globalPtr: ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A86EH); CODE(RestoreA7);CODE(Return); END InitGraf; PROCEDURE OpenPort (port: GrafPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A86FH); CODE(RestoreA7);CODE(Return); END OpenPort; PROCEDURE InitPort (port:GrafPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A86DH); CODE(RestoreA7);CODE(Return); END InitPort; PROCEDURE ClosePort (port:GrafPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A87DH); CODE(RestoreA7);CODE(Return); END ClosePort; PROCEDURE SetPort (port: GrafPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A873H); CODE(RestoreA7);CODE(Return); END SetPort; PROCEDURE GetPort (VAR port: GrafPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A874H); CODE(RestoreA7);CODE(Return); END GetPort; PROCEDURE GrafDevice (device: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A872H); CODE(RestoreA7);CODE(Return); END GrafDevice; PROCEDURE SetPortBits(VAR bm: BitMap); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A875H); CODE(RestoreA7);CODE(Return); END SetPortBits; PROCEDURE PortSize (width,height: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A876H); CODE(RestoreA7);CODE(Return); END PortSize; PROCEDURE MovePortTo (leftGlobal,topGlobal: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A877H); CODE(RestoreA7);CODE(Return); END MovePortTo; PROCEDURE SetOrigin (h,v: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A878H); CODE(RestoreA7);CODE(Return); END SetOrigin; PROCEDURE SetClip (rgn:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A879H); CODE(RestoreA7);CODE(Return); END SetClip; PROCEDURE GetClip (rgn: RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A87AH); CODE(RestoreA7);CODE(Return); END GetClip; PROCEDURE ClipRect (VAR r:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A87BH); CODE(RestoreA7);CODE(Return); END ClipRect; PROCEDURE BackPat (VAR pat: Pattern); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A87CH); CODE(RestoreA7);CODE(Return); END BackPat; (* Line Routines *) PROCEDURE HidePen; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A896H); CODE(RestoreA7);CODE(Return); END HidePen; PROCEDURE ShowPen; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A897H); CODE(RestoreA7);CODE(Return); END ShowPen; PROCEDURE GetPen(VAR pt:Point); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A89AH); CODE(RestoreA7);CODE(Return); END GetPen; PROCEDURE GetPenState(VAR pnState:PenState); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A898H); CODE(RestoreA7);CODE(Return); END GetPenState; PROCEDURE SetPenState(VAR pnState: PenState); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A899H); CODE(RestoreA7);CODE(Return); END SetPenState; PROCEDURE PenSize (width,height: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A89BH); CODE(RestoreA7);CODE(Return); END PenSize; PROCEDURE PenMode (mode: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A89CH); CODE(RestoreA7);CODE(Return); END PenMode; PROCEDURE PenPat (VAR pat: Pattern); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A89DH); CODE(RestoreA7);CODE(Return); END PenPat; PROCEDURE PenNormal; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A89EH); CODE(RestoreA7);CODE(Return); END PenNormal; PROCEDURE MoveTo (h,v: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A893H); CODE(RestoreA7);CODE(Return); END MoveTo; PROCEDURE Move (dh,dv: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A894H); CODE(RestoreA7);CODE(Return); END Move; PROCEDURE LineTo (h,v: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A891H); CODE(RestoreA7);CODE(Return); END LineTo; PROCEDURE Line (dh,dv: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A892H); CODE(RestoreA7);CODE(Return); END Line; (* Text Routines *) PROCEDURE TextFont (font: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A887H); CODE(RestoreA7);CODE(Return); END TextFont; PROCEDURE TextFace (face: Style); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A888H); CODE(RestoreA7);CODE(Return); END TextFace; PROCEDURE TextMode (mode: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A889H); CODE(RestoreA7);CODE(Return); END TextMode; PROCEDURE TextSize (size: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A88AH); CODE(RestoreA7);CODE(Return); END TextSize; PROCEDURE SpaceExtra (extra: LONGINT); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A88EH); CODE(RestoreA7);CODE(Return); END SpaceExtra; PROCEDURE xDrawChar (ch: CARDINAL); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A883H); CODE(RestoreA7);CODE(Return); END xDrawChar; PROCEDURE DrawChar (ch: CHAR); (*$P+*)(*$S-*) BEGIN xDrawChar(ORD(ch)) END DrawChar; PROCEDURE xDrawString (s:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A884H); CODE(RestoreA7);CODE(Return); END xDrawString; PROCEDURE DrawString (VAR s:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR s1:ARRAY[0..255] OF CHAR; BEGIN MakePascalString(s,s1); xDrawString(ADR(s1)) END DrawString; PROCEDURE DrawText (textBuf: ADDRESS; firstByte,byteCount: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A885H); CODE(RestoreA7);CODE(Return); END DrawText; PROCEDURE xCharWidth (ch: CARDINAL):INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A88DH); CODE(RestoreA7);CODE(Return); END xCharWidth; PROCEDURE CharWidth (ch: CHAR): INTEGER; (*$P+*)(*$S-*) BEGIN RETURN(xCharWidth(ORD(ch))); END CharWidth; PROCEDURE xStringWidth (stringPtr:ADDRESS):INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A88CH); CODE(RestoreA7);CODE(Return); END xStringWidth; PROCEDURE StringWidth (VAR s:ARRAY OF CHAR):INTEGER; (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(s,Str); RETURN(xStringWidth(ADR(Str))); END StringWidth; PROCEDURE TextWidth(textBuf:ADDRESS;firstByte,byteCount:INTEGER):INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A886H); CODE(RestoreA7);CODE(Return); END TextWidth; (* Point Calculations *) PROCEDURE xAddPt (src:LONGINT;VAR dst:Point); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A87EH); CODE(RestoreA7);CODE(Return); END xAddPt; PROCEDURE AddPt (src:Point;VAR dst:Point); (*$P+*)(*$S-*) BEGIN xAddPt(src.param,dst) END AddPt; PROCEDURE xSubPt (src:LONGINT;VAR dst:Point); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A87FH); CODE(RestoreA7);CODE(Return); END xSubPt; PROCEDURE SubPt(src:Point;VAR dst:Point); (*$P+*)(*$S-*) BEGIN xSubPt(src.param,dst) END SubPt; PROCEDURE SetPt (VAR pt: Point;h,v:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A880H); CODE(RestoreA7);CODE(Return); END SetPt; PROCEDURE xEqualPt (pt1,pt2:LONGINT) :BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A881H); CODE(RestoreA7);CODE(Return); END xEqualPt; PROCEDURE EqualPt (pt1,pt2: Point) :BOOLEAN; (*$P+*)(*$S-*) BEGIN RETURN(xEqualPt(pt1.param,pt2.param)) END EqualPt; PROCEDURE ScalePt (VAR pt:Point;VAR fromRect,toRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8F8H); CODE(RestoreA7);CODE(Return); END ScalePt; PROCEDURE MapPt(VAR pt:Point;VAR fromRect,toRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8F9H); CODE(RestoreA7);CODE(Return); END MapPt; PROCEDURE LocalToGlobal(VAR pt:Point); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A870H); CODE(RestoreA7);CODE(Return); END LocalToGlobal; PROCEDURE GlobalToLocal(VAR pt:Point); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A871H); CODE(RestoreA7);CODE(Return); END GlobalToLocal; (* Rectangle Calculations *) PROCEDURE SetRect (VAR r:Rect;left,top,right,bottom:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8A7H); CODE(RestoreA7);CODE(Return); END SetRect; PROCEDURE EqualRect(VAR rect1,rect2:Rect):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8A6H); CODE(RestoreA7);CODE(Return); END EqualRect; PROCEDURE EmptyRect(VAR r:Rect):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8AEH); CODE(RestoreA7);CODE(Return); END EmptyRect; PROCEDURE OffsetRect(VAR r:Rect;dh,dv:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8A8H); CODE(RestoreA7);CODE(Return); END OffsetRect; PROCEDURE MapRect(VAR r:Rect;VAR fromRect,toRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8FAH); CODE(RestoreA7);CODE(Return); END MapRect; PROCEDURE InsetRect(VAR r:Rect;dh,dv:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8A9H); CODE(RestoreA7);CODE(Return); END InsetRect; PROCEDURE SectRect (VAR src1,src2:Rect;VAR dstRect:Rect):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8AAH); CODE(RestoreA7);CODE(Return); END SectRect; PROCEDURE UnionRect(VAR src1,src2:Rect;VAR dstRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8ABH); CODE(RestoreA7);CODE(Return); END UnionRect; PROCEDURE xPtInRect(pt: LONGINT;VAR dstRect:Rect):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8ADH); CODE(RestoreA7);CODE(Return); END xPtInRect; PROCEDURE PtInRect(pt: Point;dstRect:Rect):BOOLEAN; (*$P+*)(*$S-*) BEGIN RETURN(xPtInRect(pt.param,dstRect)); END PtInRect; PROCEDURE xPt2Rect (pt1,pt2:LONGINT;VAR dstRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8ACH); CODE(RestoreA7);CODE(Return); END xPt2Rect; PROCEDURE Pt2Rect (pt1,pt2:Point;VAR dstRect:Rect); (*$P+*)(*$S-*) BEGIN xPt2Rect(pt1.param,pt2.param,dstRect) END Pt2Rect; (* Graphical Operations on Rectangles *) PROCEDURE FrameRect (VAR r: Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8A1H); CODE(RestoreA7);CODE(Return); END FrameRect; PROCEDURE PaintRect (VAR r: Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8A2H); CODE(RestoreA7);CODE(Return); END PaintRect; PROCEDURE EraseRect (VAR r: Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8A3H); CODE(RestoreA7);CODE(Return); END EraseRect; PROCEDURE InvertRect (VAR r: Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8A4H); CODE(RestoreA7);CODE(Return); END InvertRect; PROCEDURE FillRect (VAR r: Rect;VAR pat: Pattern); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8A5H); CODE(RestoreA7);CODE(Return); END FillRect; (* RoundRect Routines *) PROCEDURE FrameRoundRect(VAR theRect:Rect;cornerWidth,cornerHeigth:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8B0H); CODE(RestoreA7);CODE(Return); END FrameRoundRect; PROCEDURE PaintRoundRect(VAR theRect:Rect;cornerWidth,cornerHeight:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8B1H); CODE(RestoreA7);CODE(Return); END PaintRoundRect; PROCEDURE FillRoundRect(VAR theRect:Rect; cornerWidth,cornerHeigth:INTEGER; VAR fillPat:Pattern); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8B4H); CODE(RestoreA7);CODE(Return); END FillRoundRect; PROCEDURE EraseRoundRect(VAR theRect:Rect;cornerWidth,cornerHeight:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8B2H); CODE(RestoreA7);CODE(Return); END EraseRoundRect; PROCEDURE InvertRoundRect(VAR theRect:Rect;cornerWidth,cornerHeigth:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8B3H); CODE(RestoreA7);CODE(Return); END InvertRoundRect; (* Drawing Ovals *) PROCEDURE FrameOval(VAR inRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8B7H); CODE(RestoreA7);CODE(Return); END FrameOval; PROCEDURE PaintOval(VAR inRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8B8H); CODE(RestoreA7);CODE(Return); END PaintOval; PROCEDURE EraseOval(VAR inRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8B9H); CODE(RestoreA7);CODE(Return); END EraseOval; PROCEDURE InvertOval(VAR inRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8BAH); CODE(RestoreA7);CODE(Return); END InvertOval; PROCEDURE FillOval(VAR inRect:Rect;VAR pat:Pattern); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8BBH); CODE(RestoreA7);CODE(Return); END FillOval; (* Arc Routines *) PROCEDURE FrameArc(VAR inRect:Rect;startAngle,arcAngle:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8BEH); CODE(RestoreA7);CODE(Return); END FrameArc; PROCEDURE PaintArc(VAR inRect:Rect;startAngle,arcAngle:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8BFH); CODE(RestoreA7);CODE(Return); END PaintArc; PROCEDURE FillArc(VAR inRect:Rect; startAngle,arcAngle:INTEGER; VAR fillpat:Pattern); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8C2H); CODE(RestoreA7);CODE(Return); END FillArc; PROCEDURE EraseArc(VAR inRect:Rect;startAngle,arcAngle:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8C0H); CODE(RestoreA7);CODE(Return); END EraseArc; PROCEDURE InvertArc(VAR inRect:Rect;startAngle,arcAngle:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8C1H); CODE(RestoreA7);CODE(Return); END InvertArc; PROCEDURE xPtToAngle(VAR inRect:Rect;P:LONGINT;VAR theAngle:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8C3H); CODE(RestoreA7);CODE(Return); END xPtToAngle; PROCEDURE PtToAngle (inRect:Rect;thePoint:Point;VAR theAngle:INTEGER); (*$P+*)(*$S-*) BEGIN xPtToAngle(inRect,thePoint.param,theAngle) END PtToAngle; (* Polygon Routines *) PROCEDURE OpenPoly():PolyHandle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8CBH); CODE(RestoreA7);CODE(Return); END OpenPoly; PROCEDURE ClosePoly; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8CCH); CODE(RestoreA7);CODE(Return); END ClosePoly; PROCEDURE KillPoly(thePolygon:PolyHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8CDH); CODE(RestoreA7);CODE(Return); END KillPoly; PROCEDURE OffsetPoly(thePolygon:PolyHandle;hOffset,vOffset:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8CEH); CODE(RestoreA7);CODE(Return); END OffsetPoly; PROCEDURE MapPoly (thePolygon:PolyHandle;VAR fromRect,toRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8FCH); CODE(RestoreA7);CODE(Return); END MapPoly; PROCEDURE FramePoly (thePolygon:PolyHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8C6H); CODE(RestoreA7);CODE(Return); END FramePoly; PROCEDURE PaintPoly (thePolygon:PolyHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8C7H); CODE(RestoreA7);CODE(Return); END PaintPoly; PROCEDURE FillPoly (thePolygon:PolyHandle;VAR fillPat:Pattern); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8CAH); CODE(RestoreA7);CODE(Return); END FillPoly; PROCEDURE ErasePoly (thePolygon:PolyHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8C8H); CODE(RestoreA7);CODE(Return); END ErasePoly; PROCEDURE InvertPoly (thePolygon:PolyHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8C9H); CODE(RestoreA7);CODE(Return); END InvertPoly; (* Graphical Operations on BitMaps *) PROCEDURE ScrollRect(VAR dstRect:Rect;dh,dv:INTEGER;updateRgn:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8EFH); CODE(RestoreA7);CODE(Return); END ScrollRect; PROCEDURE CopyBits (VAR srcBits,dstBits: BitMap; VAR srcRect,dstRect: Rect; mode: INTEGER; maskRgn: RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8ECH); CODE(RestoreA7);CODE(Return); END CopyBits; (* later... PROCEDURE SetStdProcs PROCEDURE StdText PROCEDURE StdLine PROCEDURE StdRect PROCEDURE StdRRect PROCEDURE StdOval PROCEDURE StdArc PROCEDURE StdPoly PROCEDURE StdRgn PROCEDURE StdBits PROCEDURE StdComment PROCEDURE StdTxMeas PROCEDURE StdGetPic PROCEDURE StdPutPic *) (* Misc Utility Routines *) PROCEDURE GetPixel(h,v:INTEGER):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A865H); CODE(RestoreA7);CODE(Return); END GetPixel; PROCEDURE ForeColor (color:LONGINT); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A862H); CODE(RestoreA7);CODE(Return); END ForeColor; PROCEDURE BackColor (color:LONGINT); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A863H); CODE(RestoreA7);CODE(Return); END BackColor; PROCEDURE ColorBit (whichBit:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A864H); CODE(RestoreA7);CODE(Return); END ColorBit; BEGIN InitGraf(ADR(thePort)); END QuickDraw. !Funky!Stuff! echo x - ResourceManager.MOD cat >ResourceManager.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE ResourceManager; FROM SYSTEM IMPORT ADDRESS,CODE,ADR; FROM MacSYSTEM IMPORT LONGINT,Handle; FROM PascalStrings IMPORT MakePascalString,MakeModulaString; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) (* Opening and Closing Resource Files *) PROCEDURE xCreateResFile(fileName:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9B1H); CODE(RestoreA7);CODE(Return); END xCreateResFile; PROCEDURE CreateResFile(VAR fileName:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(fileName,Str); xCreateResFile(ADR(Str)) END CreateResFile; PROCEDURE xOpenResFile(fileName:ADDRESS):INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A997H); CODE(RestoreA7);CODE(Return); END xOpenResFile; PROCEDURE OpenResFile(VAR fileName:ARRAY OF CHAR):INTEGER; (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(fileName,Str); RETURN(xOpenResFile(ADR(Str))) END OpenResFile; PROCEDURE CloseResFile(refNum:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A99AH); CODE(RestoreA7);CODE(Return); END CloseResFile; (* Checking for Errors *) PROCEDURE ResError():INTEGER; BEGIN RETURN(ResErr); END ResError; (* Setting the Current Resource File *) PROCEDURE CurResFile():INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A994H); CODE(RestoreA7);CODE(Return); END CurResFile; PROCEDURE HomeResFile(theResource:Handle):INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9A4H); CODE(RestoreA7);CODE(Return); END HomeResFile; PROCEDURE UseResFile(refNum:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A998H); CODE(RestoreA7);CODE(Return); END UseResFile; (* Getting Resource Types *) PROCEDURE CountTypes():INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A99EH); CODE(RestoreA7);CODE(Return); END CountTypes; PROCEDURE GetIndType(VAR theType:ResType;index:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A99FH); CODE(RestoreA7);CODE(Return); END GetIndType; (* Getting and Disposing of Resources *) PROCEDURE SetResLoad(load:BOOLEAN); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A99BH); CODE(RestoreA7);CODE(Return); END SetResLoad; PROCEDURE xCountResources(theType:LONGINT):INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A99CH); CODE(RestoreA7);CODE(Return); END xCountResources; PROCEDURE CountResources(theType:ResType):INTEGER; (*$P+*)(*$S-*) VAR x:ParamResType; BEGIN x.res := theType; RETURN(xCountResources(x.param)) END CountResources; PROCEDURE xGetIndResource(theType:LONGINT;index:INTEGER):Handle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A99DH); CODE(RestoreA7);CODE(Return); END xGetIndResource; PROCEDURE GetIndResource(theType:ResType;index:INTEGER):Handle; (*$P+*)(*$S-*) VAR x:ParamResType; BEGIN x.res := theType; RETURN(xGetIndResource(x.param,index)) END GetIndResource; PROCEDURE xGetResource(theType:LONGINT;theID:INTEGER):Handle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9A0H); CODE(RestoreA7);CODE(Return); END xGetResource; PROCEDURE GetResource(theType:ResType;theID:INTEGER):Handle; (*$P+*)(*$S-*) VAR x:ParamResType; BEGIN x.res := theType; RETURN(xGetResource(x.param,theID)) END GetResource; PROCEDURE xGetNamedResource(theType:LONGINT;name:ADDRESS):Handle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9A1H); CODE(RestoreA7);CODE(Return); END xGetNamedResource; PROCEDURE GetNamedResource(theType:ResType;VAR name:ARRAY OF CHAR):Handle; (*$P+*)(*$S-*) VAR x:ParamResType; Str:ARRAY [0..255] OF CHAR; BEGIN x.res := theType; MakePascalString(name,Str); RETURN(xGetNamedResource(x.param,ADR(Str))) END GetNamedResource; PROCEDURE LoadResource(theResource:Handle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9A2H); CODE(RestoreA7);CODE(Return); END LoadResource; PROCEDURE ReleaseResource(theResource:Handle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9A3H); CODE(RestoreA7);CODE(Return); END ReleaseResource; PROCEDURE DetachResource(theResource:Handle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A992H); CODE(RestoreA7);CODE(Return); END DetachResource; (* Getting Resource Information *) PROCEDURE xUniqueID(theType:LONGINT):INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9ABH); CODE(RestoreA7);CODE(Return); END xUniqueID; PROCEDURE UniqueID(theType:ResType):INTEGER; (*$P+*)(*$S-*) VAR x:ParamResType; BEGIN x.res := theType; RETURN(xUniqueID(x.param)) END UniqueID; PROCEDURE xGetResInfo(theResource:Handle;VAR theID:INTEGER; VAR theType:ResType; name:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9A8H); CODE(RestoreA7);CODE(Return); END xGetResInfo; PROCEDURE GetResInfo(theResource:Handle;VAR theID:INTEGER; VAR theType:ResType; VAR name:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN xGetResInfo(theResource,theID,theType,ADR(Str)); MakeModulaString(Str,name) END GetResInfo; PROCEDURE GetResAttrs(theResource:Handle):INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9A6H); CODE(RestoreA7);CODE(Return); END GetResAttrs; PROCEDURE SizeResource(theResource:Handle):LONGINT; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9A5H); CODE(RestoreA7);CODE(Return); END SizeResource; (* Modifying Resources *) PROCEDURE xSetResInfo(theResource:Handle; theID:INTEGER;name:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9A9H); CODE(RestoreA7);CODE(Return); END xSetResInfo; PROCEDURE SetResInfo(theResource:Handle; theID:INTEGER;VAR name:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(name,Str); xSetResInfo(theResource,theID,ADR(Str)) END SetResInfo; PROCEDURE SetResAttrs(theResource:Handle;attrs:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9A7H); CODE(RestoreA7);CODE(Return); END SetResAttrs; PROCEDURE ChangedResource(theResource:Handle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9AAH); CODE(RestoreA7);CODE(Return); END ChangedResource; PROCEDURE xAddResource(theData:Handle;theType:LONGINT;theID:INTEGER; name:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9ABH); CODE(RestoreA7);CODE(Return); END xAddResource; PROCEDURE AddResource(theData:Handle;theType:ResType;theID:INTEGER; VAR name:ARRAY OF CHAR); (*$P+*)(*$S+*) VAR Str:ARRAY [0..255] OF CHAR; x:ParamResType; BEGIN x.res := theType; MakePascalString(name,Str); xAddResource(theData,x.param,theID,ADR(Str)); END AddResource; PROCEDURE RmveResource(theResource:Handle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9ADH); CODE(RestoreA7);CODE(Return); END RmveResource; PROCEDURE UpdateResFile(refNum:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A999H); CODE(RestoreA7);CODE(Return); END UpdateResFile; PROCEDURE WriteResource(theResource:Handle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9B0H); CODE(RestoreA7);CODE(Return); END WriteResource; PROCEDURE SetResPurge(install:BOOLEAN); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A993H); CODE(RestoreA7);CODE(Return); END SetResPurge; (* Advanced Routines *) PROCEDURE GetResFileAttrs(refNum:INTEGER):INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9F6H); CODE(RestoreA7);CODE(Return); END GetResFileAttrs; PROCEDURE SetResFileAttrs(refNum:INTEGER;attrs:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9F7H); CODE(RestoreA7);CODE(Return); END SetResFileAttrs; END ResourceManager. !Funky!Stuff! echo x - SFPackage.MOD cat >SFPackage.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE SFPackage; FROM SYSTEM IMPORT ADDRESS,WORD,ADR,CODE,REGISTER,SETREG; FROM MacSYSTEM IMPORT LONGINT; FROM QuickDraw IMPORT Point; FROM FileTypes IMPORT OSType; FROM PascalStrings IMPORT MakePascalString,MakeModulaString; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) Pack3 = 0A9EAH; SFGetF = 2; SFPGetF = 4; SFPPutF = 3; SFPutF = 1; Push = 03F3CH; (* MOVE #VAL,-(A7) *) PROCEDURE NoDlg():ADDRESS; (*??*) BEGIN RETURN(ADDRESS(0)) END NoDlg; VAR ProcDlg : MyDlgType; PROCEDURE DlgInterface; (*$P-*) BEGIN CODE(04E56H);CODE(0); (* LINK A6,#0 *) CODE(048E7H);CODE(0FFFCH); (* MOVEM.L D0-D7/A0-A5,-(A7) *) CODE(02F2EH);CODE(0AH); (* MOVE.L 0A(A6),-(A7) *) CODE(03F2EH);CODE(08H); (* MOVE.W 08(A6),-(A7) *) SETREG(8,ProcDlg); CODE(04E90H); (* JSR (A6) *) CODE(05C8FH); (* ADDQ.L #6,A7 *) CODE(04CDFH);CODE(03FFFH); (* MOVEM.L (A7)+,D0-D7/A0-A4 *) CODE(04E5EH); (* UNLK A6 *) CODE(02F5FH);CODE(2H); (* MOVE.L (A7)+,2(A7) *) CODE(0548FH); (* ADDQ.L #2,A7 *) CODE(04E75H); (* RTS *) END DlgInterface; PROCEDURE UseDlg(Dlg:MyDlgType):ADDRESS; (*$P+*)(*$S-*) BEGIN ProcDlg := Dlg; SETREG(8,DlgInterface); RETURN(REGISTER(8)) END UseDlg; PROCEDURE NoFileFilter():ADDRESS; BEGIN RETURN(ADDRESS(0)) END NoFileFilter; VAR ProcFilter : MyFileFilterType; PROCEDURE FilterInterface; (*$P-*) BEGIN CODE(04E56H);CODE(0); (* LINK A6,#0 *) CODE(048E7H);CODE(0FFFCH); (* MOVEM.L D0-D7/A0-A5,-(A7) *) CODE(02F2EH);CODE(08H); (* MOVE.L 0A(A6),-(A7) *) SETREG(8,ProcFilter); CODE(04E90H); (* JSR (A6) *) CODE(0588FH); (* ADDQ.L #4,A7 *) CODE(04CDFH);CODE(03FFFH); (* MOVEM.L (A7)+,D0-D7/A0-A4 *) CODE(04E5EH); (* UNLK A6 *) CODE(02E9FH); (* MOVE.L (A7)+,(A7) *) CODE(04E75H); (* RTS *) END FilterInterface; PROCEDURE UseFileFilter(FileFilter:MyFileFilterType):ADDRESS; (*$P+*)(*$S-*) BEGIN ProcFilter := FileFilter; SETREG(8,FilterInterface); RETURN(REGISTER(8)) END UseFileFilter; PROCEDURE xSFPutFile(lefttop:LONGINT;prompt: ADDRESS; origName: ADDRESS;dlgHook: ADDRESS; VAR reply: SFReply); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(SFPutF); CODE(Pack3); CODE(RestoreA7); CODE(Return); END xSFPutFile; PROCEDURE SFPutFile(lefttop:Point;VAR prompt: ARRAY OF CHAR; VAR origName: ARRAY OF CHAR;dlgHook: ADDRESS; VAR reply: SFReply); (*$P+*)(*$S-*) VAR p:ARRAY [0..255] OF CHAR; name:ARRAY [0..63] OF CHAR; I:CARDINAL; BEGIN MakePascalString(prompt,p); MakePascalString(origName,name); xSFPutFile(lefttop.param,ADR(p),ADR(name),dlgHook,reply); MakeModulaString(reply.fName,name); FOR I := 0 TO 63 DO reply.fName[I] := name[I] END END SFPutFile; PROCEDURE xSFPPutFile(lefttop:LONGINT;prompt: ADDRESS; origName: ADDRESS;dlgHook: ADDRESS; VAR reply: SFReply; dlgID: INTEGER;filterProc: ADDRESS); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(SFPPutF); CODE(Pack3); CODE(RestoreA7); CODE(Return); END xSFPPutFile; PROCEDURE SFPPutFile(lefttop:Point;VAR prompt: ARRAY OF CHAR; VAR origName: ARRAY OF CHAR;dlgHook: ADDRESS; VAR reply: SFReply; dlgID: INTEGER;filterProc: ADDRESS); (*$P+*)(*$S-*) VAR p:ARRAY [0..255] OF CHAR; name:ARRAY [0..63] OF CHAR; I:INTEGER; BEGIN MakePascalString(prompt,p); MakePascalString(origName,name); xSFPPutFile(lefttop.param,ADR(p),ADR(name),dlgHook,reply,dlgID,filterProc); MakeModulaString(reply.fName,name); FOR I := 0 TO 63 DO reply.fName[I] := name[I] END END SFPPutFile; PROCEDURE xSFGetFile(lefttop:LONGINT;prompt: ADDRESS; fileFilter: ADDRESS;numTypes: INTEGER; VAR typeList: SFTypeList; dlgHook: ADDRESS; VAR reply: SFReply); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(SFGetF); CODE(Pack3); CODE(RestoreA7); CODE(Return); END xSFGetFile; PROCEDURE SFGetFile(lefttop:Point;VAR prompt: ARRAY OF CHAR; fileFilter: ADDRESS;numTypes: INTEGER; VAR typeList: SFTypeList; dlgHook: ADDRESS; VAR reply: SFReply); (*$P+*)(*$S-*) VAR p:ARRAY [0..255] OF CHAR; name : ARRAY [0..63] OF CHAR; I:INTEGER; BEGIN MakePascalString(prompt,p); xSFGetFile(lefttop.param,ADR(p),fileFilter,numTypes,typeList, dlgHook,reply); MakeModulaString(reply.fName,name); FOR I := 0 TO 63 DO reply.fName[I] := name[I] END END SFGetFile; PROCEDURE xSFPGetFile(lefttop:LONGINT;prompt: ADDRESS; fileFilter: ADDRESS;numTypes: INTEGER; VAR typeList: SFTypeList; dlgHook: ADDRESS; VAR reply: SFReply; dlgID: INTEGER; filterProc: ADDRESS); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(SFPGetF); CODE(Pack3); CODE(RestoreA7); CODE(Return); END xSFPGetFile; PROCEDURE SFPGetFile(lefttop:Point;VAR prompt: ARRAY OF CHAR; fileFilter: ADDRESS;numTypes: INTEGER; VAR typeList: SFTypeList; dlgHook: ADDRESS; VAR reply: SFReply; dlgID: INTEGER; filterProc: ADDRESS); (*$P+*)(*$S-*) VAR p:ARRAY [0..255] OF CHAR; name:ARRAY [0..63] OF CHAR; I:INTEGER; BEGIN MakePascalString(prompt,p); xSFPGetFile(lefttop.param,ADR(p),fileFilter,numTypes,typeList, dlgHook,reply,dlgID,filterProc); MakeModulaString(reply.fName,name); FOR I := 0 TO 63 DO reply.fName[I] := name[I] END END SFPGetFile; END SFPackage. !Funky!Stuff! # The rest of this file is a shell script which will extract: # QuickDraw.MOD ResourceManager.MOD SFPackage.MOD echo x - QuickDraw.MOD cat >QuickDraw.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE QuickDraw; FROM SYSTEM IMPORT ADDRESS,WORD,CODE,ADR,REGISTER; FROM MacSYSTEM IMPORT LONGINT; FROM PascalStrings IMPORT MakePascalString; (*EXPORT QUALIFIED...*) (* GrafPort Routines *) CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) PROCEDURE InitGraf (globalPtr: ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A86EH); CODE(RestoreA7);CODE(Return); END InitGraf; PROCEDURE OpenPort (port: GrafPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A86FH); CODE(RestoreA7);CODE(Return); END OpenPort; PROCEDURE InitPort (port:GrafPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A86DH); CODE(RestoreA7);CODE(Return); END InitPort; PROCEDURE ClosePort (port:GrafPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A87DH); CODE(RestoreA7);CODE(Return); END ClosePort; PROCEDURE SetPort (port: GrafPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A873H); CODE(RestoreA7);CODE(Return); END SetPort; PROCEDURE GetPort (VAR port: GrafPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A874H); CODE(RestoreA7);CODE(Return); END GetPort; PROCEDURE GrafDevice (device: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A872H); CODE(RestoreA7);CODE(Return); END GrafDevice; PROCEDURE SetPortBits(VAR bm: BitMap); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A875H); CODE(RestoreA7);CODE(Return); END SetPortBits; PROCEDURE PortSize (width,height: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A876H); CODE(RestoreA7);CODE(Return); END PortSize; PROCEDURE MovePortTo (leftGlobal,topGlobal: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A877H); CODE(RestoreA7);CODE(Return); END MovePortTo; PROCEDURE SetOrigin (h,v: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A878H); CODE(RestoreA7);CODE(Return); END SetOrigin; PROCEDURE SetClip (rgn:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A879H); CODE(RestoreA7);CODE(Return); END SetClip; PROCEDURE GetClip (rgn: RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A87AH); CODE(RestoreA7);CODE(Return); END GetClip; PROCEDURE ClipRect (VAR r:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A87BH); CODE(RestoreA7);CODE(Return); END ClipRect; PROCEDURE BackPat (VAR pat: Pattern); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A87CH); CODE(RestoreA7);CODE(Return); END BackPat; (* Line Routines *) PROCEDURE HidePen; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A896H); CODE(RestoreA7);CODE(Return); END HidePen; PROCEDURE ShowPen; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A897H); CODE(RestoreA7);CODE(Return); END ShowPen; PROCEDURE GetPen(VAR pt:Point); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A89AH); CODE(RestoreA7);CODE(Return); END GetPen; PROCEDURE GetPenState(VAR pnState:PenState); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A898H); CODE(RestoreA7);CODE(Return); END GetPenState; PROCEDURE SetPenState(VAR pnState: PenState); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A899H); CODE(RestoreA7);CODE(Return); END SetPenState; PROCEDURE PenSize (width,height: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A89BH); CODE(RestoreA7);CODE(Return); END PenSize; PROCEDURE PenMode (mode: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A89CH); CODE(RestoreA7);CODE(Return); END PenMode; PROCEDURE PenPat (VAR pat: Pattern); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A89DH); CODE(RestoreA7);CODE(Return); END PenPat; PROCEDURE PenNormal; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A89EH); CODE(RestoreA7);CODE(Return); END PenNormal; PROCEDURE MoveTo (h,v: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A893H); CODE(RestoreA7);CODE(Return); END MoveTo; PROCEDURE Move (dh,dv: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A894H); CODE(RestoreA7);CODE(Return); END Move; PROCEDURE LineTo (h,v: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A891H); CODE(RestoreA7);CODE(Return); END LineTo; PROCEDURE Line (dh,dv: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A892H); CODE(RestoreA7);CODE(Return); END Line; (* Text Routines *) PROCEDURE TextFont (font: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A887H); CODE(RestoreA7);CODE(Return); END TextFont; PROCEDURE TextFace (face: Style); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A888H); CODE(RestoreA7);CODE(Return); END TextFace; PROCEDURE TextMode (mode: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A889H); CODE(RestoreA7);CODE(Return); END TextMode; PROCEDURE TextSize (size: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A88AH); CODE(RestoreA7);CODE(Return); END TextSize; PROCEDURE SpaceExtra (extra: LONGINT); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A88EH); CODE(RestoreA7);CODE(Return); END SpaceExtra; PROCEDURE xDrawChar (ch: CARDINAL); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A883H); CODE(RestoreA7);CODE(Return); END xDrawChar; PROCEDURE DrawChar (ch: CHAR); (*$P+*)(*$S-*) BEGIN xDrawChar(ORD(ch)) END DrawChar; PROCEDURE xDrawString (s:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A884H); CODE(RestoreA7);CODE(Return); END xDrawString; PROCEDURE DrawString (VAR s:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR s1:ARRAY[0..255] OF CHAR; BEGIN MakePascalString(s,s1); xDrawString(ADR(s1)) END DrawString; PROCEDURE DrawText (textBuf: ADDRESS; firstByte,byteCount: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A885H); CODE(RestoreA7);CODE(Return); END DrawText; PROCEDURE xCharWidth (ch: CARDINAL):INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A88DH); CODE(RestoreA7);CODE(Return); END xCharWidth; PROCEDURE CharWidth (ch: CHAR): INTEGER; (*$P+*)(*$S-*) BEGIN RETURN(xCharWidth(ORD(ch))); END CharWidth; PROCEDURE xStringWidth (stringPtr:ADDRESS):INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A88CH); CODE(RestoreA7);CODE(Return); END xStringWidth; PROCEDURE StringWidth (VAR s:ARRAY OF CHAR):INTEGER; (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(s,Str); RETURN(xStringWidth(ADR(Str))); END StringWidth; PROCEDURE TextWidth(textBuf:ADDRESS;firstByte,byteCount:INTEGER):INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A886H); CODE(RestoreA7);CODE(Return); END TextWidth; (* Point Calculations *) PROCEDURE xAddPt (src:LONGINT;VAR dst:Point); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A87EH); CODE(RestoreA7);CODE(Return); END xAddPt; PROCEDURE AddPt (src:Point;VAR dst:Point); (*$P+*)(*$S-*) BEGIN xAddPt(src.param,dst) END AddPt; PROCEDURE xSubPt (src:LONGINT;VAR dst:Point); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A87FH); CODE(RestoreA7);CODE(Return); END xSubPt; PROCEDURE SubPt(src:Point;VAR dst:Point); (*$P+*)(*$S-*) BEGIN xSubPt(src.param,dst) END SubPt; PROCEDURE SetPt (VAR pt: Point;h,v:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A880H); CODE(RestoreA7);CODE(Return); END SetPt; PROCEDURE xEqualPt (pt1,pt2:LONGINT) :BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A881H); CODE(RestoreA7);CODE(Return); END xEqualPt; PROCEDURE EqualPt (pt1,pt2: Point) :BOOLEAN; (*$P+*)(*$S-*) BEGIN RETURN(xEqualPt(pt1.param,pt2.param)) END EqualPt; PROCEDURE ScalePt (VAR pt:Point;VAR fromRect,toRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8F8H); CODE(RestoreA7);CODE(Return); END ScalePt; PROCEDURE MapPt(VAR pt:Point;VAR fromRect,toRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8F9H); CODE(RestoreA7);CODE(Return); END MapPt; PROCEDURE LocalToGlobal(VAR pt:Point); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A870H); CODE(RestoreA7);CODE(Return); END LocalToGlobal; PROCEDURE GlobalToLocal(VAR pt:Point); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A871H); CODE(RestoreA7);CODE(Return); END GlobalToLocal; (* Rectangle Calculations *) PROCEDURE SetRect (VAR r:Rect;left,top,right,bottom:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8A7H); CODE(RestoreA7);CODE(Return); END SetRect; PROCEDURE EqualRect(VAR rect1,rect2:Rect):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8A6H); CODE(RestoreA7);CODE(Return); END EqualRect; PROCEDURE EmptyRect(VAR r:Rect):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8AEH); CODE(RestoreA7);CODE(Return); END EmptyRect; PROCEDURE OffsetRect(VAR r:Rect;dh,dv:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8A8H); CODE(RestoreA7);CODE(Return); END OffsetRect; PROCEDURE MapRect(VAR r:Rect;VAR fromRect,toRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8FAH); CODE(RestoreA7);CODE(Return); END MapRect; PROCEDURE InsetRect(VAR r:Rect;dh,dv:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8A9H); CODE(RestoreA7);CODE(Return); END InsetRect; PROCEDURE SectRect (VAR src1,src2:Rect;VAR dstRect:Rect):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8AAH); CODE(RestoreA7);CODE(Return); END SectRect; PROCEDURE UnionRect(VAR src1,src2:Rect;VAR dstRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8ABH); CODE(RestoreA7);CODE(Return); END UnionRect; PROCEDURE xPtInRect(pt: LONGINT;VAR dstRect:Rect):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8ADH); CODE(RestoreA7);CODE(Return); END xPtInRect; PROCEDURE PtInRect(pt: Point;dstRect:Rect):BOOLEAN; (*$P+*)(*$S-*) BEGIN RETURN(xPtInRect(pt.param,dstRect)); END PtInRect; PROCEDURE xPt2Rect (pt1,pt2:LONGINT;VAR dstRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8ACH); CODE(RestoreA7);CODE(Return); END xPt2Rect; PROCEDURE Pt2Rect (pt1,pt2:Point;VAR dstRect:Rect); (*$P+*)(*$S-*) BEGIN xPt2Rect(pt1.param,pt2.param,dstRect) END Pt2Rect; (* Graphical Operations on Rectangles *) PROCEDURE FrameRect (VAR r: Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8A1H); CODE(RestoreA7);CODE(Return); END FrameRect; PROCEDURE PaintRect (VAR r: Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8A2H); CODE(RestoreA7);CODE(Return); END PaintRect; PROCEDURE EraseRect (VAR r: Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8A3H); CODE(RestoreA7);CODE(Return); END EraseRect; PROCEDURE InvertRect (VAR r: Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8A4H); CODE(RestoreA7);CODE(Return); END InvertRect; PROCEDURE FillRect (VAR r: Rect;VAR pat: Pattern); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8A5H); CODE(RestoreA7);CODE(Return); END FillRect; (* RoundRect Routines *) PROCEDURE FrameRoundRect(VAR theRect:Rect;cornerWidth,cornerHeigth:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8B0H); CODE(RestoreA7);CODE(Return); END FrameRoundRect; PROCEDURE PaintRoundRect(VAR theRect:Rect;cornerWidth,cornerHeight:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8B1H); CODE(RestoreA7);CODE(Return); END PaintRoundRect; PROCEDURE FillRoundRect(VAR theRect:Rect; cornerWidth,cornerHeigth:INTEGER; VAR fillPat:Pattern); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8B4H); CODE(RestoreA7);CODE(Return); END FillRoundRect; PROCEDURE EraseRoundRect(VAR theRect:Rect;cornerWidth,cornerHeight:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8B2H); CODE(RestoreA7);CODE(Return); END EraseRoundRect; PROCEDURE InvertRoundRect(VAR theRect:Rect;cornerWidth,cornerHeigth:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8B3H); CODE(RestoreA7);CODE(Return); END InvertRoundRect; (* Drawing Ovals *) PROCEDURE FrameOval(VAR inRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8B7H); CODE(RestoreA7);CODE(Return); END FrameOval; PROCEDURE PaintOval(VAR inRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8B8H); CODE(RestoreA7);CODE(Return); END PaintOval; PROCEDURE EraseOval(VAR inRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8B9H); CODE(RestoreA7);CODE(Return); END EraseOval; PROCEDURE InvertOval(VAR inRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8BAH); CODE(RestoreA7);CODE(Return); END InvertOval; PROCEDURE FillOval(VAR inRect:Rect;VAR pat:Pattern); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8BBH); CODE(RestoreA7);CODE(Return); END FillOval; (* Arc Routines *) PROCEDURE FrameArc(VAR inRect:Rect;startAngle,arcAngle:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8BEH); CODE(RestoreA7);CODE(Return); END FrameArc; PROCEDURE PaintArc(VAR inRect:Rect;startAngle,arcAngle:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8BFH); CODE(RestoreA7);CODE(Return); END PaintArc; PROCEDURE FillArc(VAR inRect:Rect; startAngle,arcAngle:INTEGER; VAR fillpat:Pattern); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8C2H); CODE(RestoreA7);CODE(Return); END FillArc; PROCEDURE EraseArc(VAR inRect:Rect;startAngle,arcAngle:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8C0H); CODE(RestoreA7);CODE(Return); END EraseArc; PROCEDURE InvertArc(VAR inRect:Rect;startAngle,arcAngle:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8C1H); CODE(RestoreA7);CODE(Return); END InvertArc; PROCEDURE xPtToAngle(VAR inRect:Rect;P:LONGINT;VAR theAngle:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8C3H); CODE(RestoreA7);CODE(Return); END xPtToAngle; PROCEDURE PtToAngle (inRect:Rect;thePoint:Point;VAR theAngle:INTEGER); (*$P+*)(*$S-*) BEGIN xPtToAngle(inRect,thePoint.param,theAngle) END PtToAngle; (* Polygon Routines *) PROCEDURE OpenPoly():PolyHandle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8CBH); CODE(RestoreA7);CODE(Return); END OpenPoly; PROCEDURE ClosePoly; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8CCH); CODE(RestoreA7);CODE(Return); END ClosePoly; PROCEDURE KillPoly(thePolygon:PolyHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8CDH); CODE(RestoreA7);CODE(Return); END KillPoly; PROCEDURE OffsetPoly(thePolygon:PolyHandle;hOffset,vOffset:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8CEH); CODE(RestoreA7);CODE(Return); END OffsetPoly; PROCEDURE MapPoly (thePolygon:PolyHandle;VAR fromRect,toRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8FCH); CODE(RestoreA7);CODE(Return); END MapPoly; PROCEDURE FramePoly (thePolygon:PolyHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8C6H); CODE(RestoreA7);CODE(Return); END FramePoly; PROCEDURE PaintPoly (thePolygon:PolyHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8C7H); CODE(RestoreA7);CODE(Return); END PaintPoly; PROCEDURE FillPoly (thePolygon:PolyHandle;VAR fillPat:Pattern); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8CAH); CODE(RestoreA7);CODE(Return); END FillPoly; PROCEDURE ErasePoly (thePolygon:PolyHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8C8H); CODE(RestoreA7);CODE(Return); END ErasePoly; PROCEDURE InvertPoly (thePolygon:PolyHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8C9H); CODE(RestoreA7);CODE(Return); END InvertPoly; (* Graphical Operations on BitMaps *) PROCEDURE ScrollRect(VAR dstRect:Rect;dh,dv:INTEGER;updateRgn:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8EFH); CODE(RestoreA7);CODE(Return); END ScrollRect; PROCEDURE CopyBits (VAR srcBits,dstBits: BitMap; VAR srcRect,dstRect: Rect; mode: INTEGER; maskRgn: RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8ECH); CODE(RestoreA7);CODE(Return); END CopyBits; (* later... PROCEDURE SetStdProcs PROCEDURE StdText PROCEDURE StdLine PROCEDURE StdRect PROCEDURE StdRRect PROCEDURE StdOval PROCEDURE StdArc PROCEDURE StdPoly PROCEDURE StdRgn PROCEDURE StdBits PROCEDURE StdComment PROCEDURE StdTxMeas PROCEDURE StdGetPic PROCEDURE StdPutPic *) (* Misc Utility Routines *) PROCEDURE GetPixel(h,v:INTEGER):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A865H); CODE(RestoreA7);CODE(Return); END GetPixel; PROCEDURE ForeColor (color:LONGINT); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A862H); CODE(RestoreA7);CODE(Return); END ForeColor; PROCEDURE BackColor (color:LONGINT); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A863H); CODE(RestoreA7);CODE(Return); END BackColor; PROCEDURE ColorBit (whichBit:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A864H); CODE(RestoreA7);CODE(Return); END ColorBit; BEGIN InitGraf(ADR(thePort)); END QuickDraw. !Funky!Stuff! echo x - ResourceManager.MOD cat >ResourceManager.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE ResourceManager; FROM SYSTEM IMPORT ADDRESS,CODE,ADR; FROM MacSYSTEM IMPORT LONGINT,Handle; FROM PascalStrings IMPORT MakePascalString,MakeModulaString; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) (* Opening and Closing Resource Files *) PROCEDURE xCreateResFile(fileName:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9B1H); CODE(RestoreA7);CODE(Return); END xCreateResFile; PROCEDURE CreateResFile(VAR fileName:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(fileName,Str); xCreateResFile(ADR(Str)) END CreateResFile; PROCEDURE xOpenResFile(fileName:ADDRESS):INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A997H); CODE(RestoreA7);CODE(Return); END xOpenResFile; PROCEDURE OpenResFile(VAR fileName:ARRAY OF CHAR):INTEGER; (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(fileName,Str); RETURN(xOpenResFile(ADR(Str))) END OpenResFile; PROCEDURE CloseResFile(refNum:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A99AH); CODE(RestoreA7);CODE(Return); END CloseResFile; (* Checking for Errors *) PROCEDURE ResError():INTEGER; BEGIN RETURN(ResErr); END ResError; (* Setting the Current Resource File *) PROCEDURE CurResFile():INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A994H); CODE(RestoreA7);CODE(Return); END CurResFile; PROCEDURE HomeResFile(theResource:Handle):INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9A4H); CODE(RestoreA7);CODE(Return); END HomeResFile; PROCEDURE UseResFile(refNum:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A998H); CODE(RestoreA7);CODE(Return); END UseResFile; (* Getting Resource Types *) PROCEDURE CountTypes():INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A99EH); CODE(RestoreA7);CODE(Return); END CountTypes; PROCEDURE GetIndType(VAR theType:ResType;index:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A99FH); CODE(RestoreA7);CODE(Return); END GetIndType; (* Getting and Disposing of Resources *) PROCEDURE SetResLoad(load:BOOLEAN); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A99BH); CODE(RestoreA7);CODE(Return); END SetResLoad; PROCEDURE xCountResources(theType:LONGINT):INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A99CH); CODE(RestoreA7);CODE(Return); END xCountResources; PROCEDURE CountResources(theType:ResType):INTEGER; (*$P+*)(*$S-*) VAR x:ParamResType; BEGIN x.res := theType; RETURN(xCountResources(x.param)) END CountResources; PROCEDURE xGetIndResource(theType:LONGINT;index:INTEGER):Handle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A99DH); CODE(RestoreA7);CODE(Return); END xGetIndResource; PROCEDURE GetIndResource(theType:ResType;index:INTEGER):Handle; (*$P+*)(*$S-*) VAR x:ParamResType; BEGIN x.res := theType; RETURN(xGetIndResource(x.param,index)) END GetIndResource; PROCEDURE xGetResource(theType:LONGINT;theID:INTEGER):Handle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9A0H); CODE(RestoreA7);CODE(Return); END xGetResource; PROCEDURE GetResource(theType:ResType;theID:INTEGER):Handle; (*$P+*)(*$S-*) VAR x:ParamResType; BEGIN x.res := theType; RETURN(xGetResource(x.param,theID)) END GetResource; PROCEDURE xGetNamedResource(theType:LONGINT;name:ADDRESS):Handle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9A1H); CODE(RestoreA7);CODE(Return); END xGetNamedResource; PROCEDURE GetNamedResource(theType:ResType;VAR name:ARRAY OF CHAR):Handle; (*$P+*)(*$S-*) VAR x:ParamResType; Str:ARRAY [0..255] OF CHAR; BEGIN x.res := theType; MakePascalString(name,Str); RETURN(xGetNamedResource(x.param,ADR(Str))) END GetNamedResource; PROCEDURE LoadResource(theResource:Handle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9A2H); CODE(RestoreA7);CODE(Return); END LoadResource; PROCEDURE ReleaseResource(theResource:Handle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9A3H); CODE(RestoreA7);CODE(Return); END ReleaseResource; PROCEDURE DetachResource(theResource:Handle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A992H); CODE(RestoreA7);CODE(Return); END DetachResource; (* Getting Resource Information *) PROCEDURE xUniqueID(theType:LONGINT):INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9ABH); CODE(RestoreA7);CODE(Return); END xUniqueID; PROCEDURE UniqueID(theType:ResType):INTEGER; (*$P+*)(*$S-*) VAR x:ParamResType; BEGIN x.res := theType; RETURN(xUniqueID(x.param)) END UniqueID; PROCEDURE xGetResInfo(theResource:Handle;VAR theID:INTEGER; VAR theType:ResType; name:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9A8H); CODE(RestoreA7);CODE(Return); END xGetResInfo; PROCEDURE GetResInfo(theResource:Handle;VAR theID:INTEGER; VAR theType:ResType; VAR name:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN xGetResInfo(theResource,theID,theType,ADR(Str)); MakeModulaString(Str,name) END GetResInfo; PROCEDURE GetResAttrs(theResource:Handle):INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9A6H); CODE(RestoreA7);CODE(Return); END GetResAttrs; PROCEDURE SizeResource(theResource:Handle):LONGINT; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9A5H); CODE(RestoreA7);CODE(Return); END SizeResource; (* Modifying Resources *) PROCEDURE xSetResInfo(theResource:Handle; theID:INTEGER;name:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9A9H); CODE(RestoreA7);CODE(Return); END xSetResInfo; PROCEDURE SetResInfo(theResource:Handle; theID:INTEGER;VAR name:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(name,Str); xSetResInfo(theResource,theID,ADR(Str)) END SetResInfo; PROCEDURE SetResAttrs(theResource:Handle;attrs:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9A7H); CODE(RestoreA7);CODE(Return); END SetResAttrs; PROCEDURE ChangedResource(theResource:Handle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9AAH); CODE(RestoreA7);CODE(Return); END ChangedResource; PROCEDURE xAddResource(theData:Handle;theType:LONGINT;theID:INTEGER; name:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9ABH); CODE(RestoreA7);CODE(Return); END xAddResource; PROCEDURE AddResource(theData:Handle;theType:ResType;theID:INTEGER; VAR name:ARRAY OF CHAR); (*$P+*)(*$S+*) VAR Str:ARRAY [0..255] OF CHAR; x:ParamResType; BEGIN x.res := theType; MakePascalString(name,Str); xAddResource(theData,x.param,theID,ADR(Str)); END AddResource; PROCEDURE RmveResource(theResource:Handle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9ADH); CODE(RestoreA7);CODE(Return); END RmveResource; PROCEDURE UpdateResFile(refNum:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A999H); CODE(RestoreA7);CODE(Return); END UpdateResFile; PROCEDURE WriteResource(theResource:Handle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9B0H); CODE(RestoreA7);CODE(Return); END WriteResource; PROCEDURE SetResPurge(install:BOOLEAN); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A993H); CODE(RestoreA7);CODE(Return); END SetResPurge; (* Advanced Routines *) PROCEDURE GetResFileAttrs(refNum:INTEGER):INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9F6H); CODE(RestoreA7);CODE(Return); END GetResFileAttrs; PROCEDURE SetResFileAttrs(refNum:INTEGER;attrs:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9F7H); CODE(RestoreA7);CODE(Return); END SetResFileAttrs; END ResourceManager. !Funky!Stuff! echo x - SFPackage.MOD cat >SFPackage.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE SFPackage; FROM SYSTEM IMPORT ADDRESS,WORD,ADR,CODE,REGISTER,SETREG; FROM MacSYSTEM IMPORT LONGINT; FROM QuickDraw IMPORT Point; FROM FileTypes IMPORT OSType; FROM PascalStrings IMPORT MakePascalString,MakeModulaString; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) Pack3 = 0A9EAH; SFGetF = 2; SFPGetF = 4; SFPPutF = 3; SFPutF = 1; Push = 03F3CH; (* MOVE #VAL,-(A7) *) PROCEDURE NoDlg():ADDRESS; (*??*) BEGIN RETURN(ADDRESS(0)) END NoDlg; VAR ProcDlg : MyDlgType; PROCEDURE DlgInterface; (*$P-*) BEGIN CODE(04E56H);CODE(0); (* LINK A6,#0 *) CODE(048E7H);CODE(0FFFCH); (* MOVEM.L D0-D7/A0-A5,-(A7) *) CODE(02F2EH);CODE(0AH); (* MOVE.L 0A(A6),-(A7) *) CODE(03F2EH);CODE(08H); (* MOVE.W 08(A6),-(A7) *) SETREG(8,ProcDlg); CODE(04E90H); (* JSR (A6) *) CODE(05C8FH); (* ADDQ.L #6,A7 *) CODE(04CDFH);CODE(03FFFH); (* MOVEM.L (A7)+,D0-D7/A0-A4 *) CODE(04E5EH); (* UNLK A6 *) CODE(02F5FH);CODE(2H); (* MOVE.L (A7)+,2(A7) *) CODE(0548FH); (* ADDQ.L #2,A7 *) CODE(04E75H); (* RTS *) END DlgInterface; PROCEDURE UseDlg(Dlg:MyDlgType):ADDRESS; (*$P+*)(*$S-*) BEGIN ProcDlg := Dlg; SETREG(8,DlgInterface); RETURN(REGISTER(8)) END UseDlg; PROCEDURE NoFileFilter():ADDRESS; BEGIN RETURN(ADDRESS(0)) END NoFileFilter; VAR ProcFilter : MyFileFilterType; PROCEDURE FilterInterface; (*$P-*) BEGIN CODE(04E56H);CODE(0); (* LINK A6,#0 *) CODE(048E7H);CODE(0FFFCH); (* MOVEM.L D0-D7/A0-A5,-(A7) *) CODE(02F2EH);CODE(08H); (* MOVE.L 0A(A6),-(A7) *) SETREG(8,ProcFilter); CODE(04E90H); (* JSR (A6) *) CODE(0588FH); (* ADDQ.L #4,A7 *) CODE(04CDFH);CODE(03FFFH); (* MOVEM.L (A7)+,D0-D7/A0-A4 *) CODE(04E5EH); (* UNLK A6 *) CODE(02E9FH); (* MOVE.L (A7)+,(A7) *) CODE(04E75H); (* RTS *) END FilterInterface; PROCEDURE UseFileFilter(FileFilter:MyFileFilterType):ADDRESS; (*$P+*)(*$S-*) BEGIN ProcFilter := FileFilter; SETREG(8,FilterInterface); RETURN(REGISTER(8)) END UseFileFilter; PROCEDURE xSFPutFile(lefttop:LONGINT;prompt: ADDRESS; origName: ADDRESS;dlgHook: ADDRESS; VAR reply: SFReply); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(SFPutF); CODE(Pack3); CODE(RestoreA7); CODE(Return); END xSFPutFile; PROCEDURE SFPutFile(lefttop:Point;VAR prompt: ARRAY OF CHAR; VAR origName: ARRAY OF CHAR;dlgHook: ADDRESS; VAR reply: SFReply); (*$P+*)(*$S-*) VAR p:ARRAY [0..255] OF CHAR; name:ARRAY [0..63] OF CHAR; I:CARDINAL; BEGIN MakePascalString(prompt,p); MakePascalString(origName,name); xSFPutFile(lefttop.param,ADR(p),ADR(name),dlgHook,reply); MakeModulaString(reply.fName,name); FOR I := 0 TO 63 DO reply.fName[I] := name[I] END END SFPutFile; PROCEDURE xSFPPutFile(lefttop:LONGINT;prompt: ADDRESS; origName: ADDRESS;dlgHook: ADDRESS; VAR reply: SFReply; dlgID: INTEGER;filterProc: ADDRESS); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(SFPPutF); CODE(Pack3); CODE(RestoreA7); CODE(Return); END xSFPPutFile; PROCEDURE SFPPutFile(lefttop:Point;VAR prompt: ARRAY OF CHAR; VAR origName: ARRAY OF CHAR;dlgHook: ADDRESS; VAR reply: SFReply; dlgID: INTEGER;filterProc: ADDRESS); (*$P+*)(*$S-*) VAR p:ARRAY [0..255] OF CHAR; name:ARRAY [0..63] OF CHAR; I:INTEGER; BEGIN MakePascalString(prompt,p); MakePascalString(origName,name); xSFPPutFile(lefttop.param,ADR(p),ADR(name),dlgHook,reply,dlgID,filterProc); MakeModulaString(reply.fName,name); FOR I := 0 TO 63 DO reply.fName[I] := name[I] END END SFPPutFile; PROCEDURE xSFGetFile(lefttop:LONGINT;prompt: ADDRESS; fileFilter: ADDRESS;numTypes: INTEGER; VAR typeList: SFTypeList; dlgHook: ADDRESS; VAR reply: SFReply); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(SFGetF); CODE(Pack3); CODE(RestoreA7); CODE(Return); END xSFGetFile; PROCEDURE SFGetFile(lefttop:Point;VAR prompt: ARRAY OF CHAR; fileFilter: ADDRESS;numTypes: INTEGER; VAR typeList: SFTypeList; dlgHook: ADDRESS; VAR reply: SFReply); (*$P+*)(*$S-*) VAR p:ARRAY [0..255] OF CHAR; name : ARRAY [0..63] OF CHAR; I:INTEGER; BEGIN MakePascalString(prompt,p); xSFGetFile(lefttop.param,ADR(p),fileFilter,numTypes,typeList, dlgHook,reply); MakeModulaString(reply.fName,name); FOR I := 0 TO 63 DO reply.fName[I] := name[I] END END SFGetFile; PROCEDURE xSFPGetFile(lefttop:LONGINT;prompt: ADDRESS; fileFilter: ADDRESS;numTypes: INTEGER; VAR typeList: SFTypeList; dlgHook: ADDRESS; VAR reply: SFReply; dlgID: INTEGER; filterProc: ADDRESS); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(SFPGetF); CODE(Pack3); CODE(RestoreA7); CODE(Return); END xSFPGetFile; PROCEDURE SFPGetFile(lefttop:Point;VAR prompt: ARRAY OF CHAR; fileFilter: ADDRESS;numTypes: INTEGER; VAR typeList: SFTypeList; dlgHook: ADDRESS; VAR reply: SFReply; dlgID: INTEGER; filterProc: ADDRESS); (*$P+*)(*$S-*) VAR p:ARRAY [0..255] OF CHAR; name:ARRAY [0..63] OF CHAR; I:INTEGER; BEGIN MakePascalString(prompt,p); xSFPGetFile(lefttop.param,ADR(p),fileFilter,numTypes,typeList, dlgHook,reply,dlgID,filterProc); MakeModulaString(reply.fName,name); FOR I := 0 TO 63 DO reply.fName[I] := name[I] END END SFPGetFile; END SFPackage. !Funky!Stuff! # The rest of this file is a shell script which will extract: # QuickDraw.MOD ResourceManager.MOD SFPackage.MOD echo x - QuickDraw.MOD cat >QuickDraw.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE QuickDraw; FROM SYSTEM IMPORT ADDRESS,WORD,CODE,ADR,REGISTER; FROM MacSYSTEM IMPORT LONGINT; FROM PascalStrings IMPORT MakePascalString; (*EXPORT QUALIFIED...*) (* GrafPort Routines *) CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) PROCEDURE InitGraf (globalPtr: ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A86EH); CODE(RestoreA7);CODE(Return); END InitGraf; PROCEDURE OpenPort (port: GrafPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A86FH); CODE(RestoreA7);CODE(Return); END OpenPort; PROCEDURE InitPort (port:GrafPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A86DH); CODE(RestoreA7);CODE(Return); END InitPort; PROCEDURE ClosePort (port:GrafPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A87DH); CODE(RestoreA7);CODE(Return); END ClosePort; PROCEDURE SetPort (port: GrafPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A873H); CODE(RestoreA7);CODE(Return); END SetPort; PROCEDURE GetPort (VAR port: GrafPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A874H); CODE(RestoreA7);CODE(Return); END GetPort; PROCEDURE GrafDevice (device: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A872H); CODE(RestoreA7);CODE(Return); END GrafDevice; PROCEDURE SetPortBits(VAR bm: BitMap); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A875H); CODE(RestoreA7);CODE(Return); END SetPortBits; PROCEDURE PortSize (width,height: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A876H); CODE(RestoreA7);CODE(Return); END PortSize; PROCEDURE MovePortTo (leftGlobal,topGlobal: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A877H); CODE(RestoreA7);CODE(Return); END MovePortTo; PROCEDURE SetOrigin (h,v: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A878H); CODE(RestoreA7);CODE(Return); END SetOrigin; PROCEDURE SetClip (rgn:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A879H); CODE(RestoreA7);CODE(Return); END SetClip; PROCEDURE GetClip (rgn: RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A87AH); CODE(RestoreA7);CODE(Return); END GetClip; PROCEDURE ClipRect (VAR r:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A87BH); CODE(RestoreA7);CODE(Return); END ClipRect; PROCEDURE BackPat (VAR pat: Pattern); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A87CH); CODE(RestoreA7);CODE(Return); END BackPat; (* Line Routines *) PROCEDURE HidePen; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A896H); CODE(RestoreA7);CODE(Return); END HidePen; PROCEDURE ShowPen; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A897H); CODE(RestoreA7);CODE(Return); END ShowPen; PROCEDURE GetPen(VAR pt:Point); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A89AH); CODE(RestoreA7);CODE(Return); END GetPen; PROCEDURE GetPenState(VAR pnState:PenState); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A898H); CODE(RestoreA7);CODE(Return); END GetPenState; PROCEDURE SetPenState(VAR pnState: PenState); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A899H); CODE(RestoreA7);CODE(Return); END SetPenState; PROCEDURE PenSize (width,height: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A89BH); CODE(RestoreA7);CODE(Return); END PenSize; PROCEDURE PenMode (mode: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A89CH); CODE(RestoreA7);CODE(Return); END PenMode; PROCEDURE PenPat (VAR pat: Pattern); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A89DH); CODE(RestoreA7);CODE(Return); END PenPat; PROCEDURE PenNormal; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A89EH); CODE(RestoreA7);CODE(Return); END PenNormal; PROCEDURE MoveTo (h,v: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A893H); CODE(RestoreA7);CODE(Return); END MoveTo; PROCEDURE Move (dh,dv: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A894H); CODE(RestoreA7);CODE(Return); END Move; PROCEDURE LineTo (h,v: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A891H); CODE(RestoreA7);CODE(Return); END LineTo; PROCEDURE Line (dh,dv: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A892H); CODE(RestoreA7);CODE(Return); END Line; (* Text Routines *) PROCEDURE TextFont (font: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A887H); CODE(RestoreA7);CODE(Return); END TextFont; PROCEDURE TextFace (face: Style); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A888H); CODE(RestoreA7);CODE(Return); END TextFace; PROCEDURE TextMode (mode: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A889H); CODE(RestoreA7);CODE(Return); END TextMode; PROCEDURE TextSize (size: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A88AH); CODE(RestoreA7);CODE(Return); END TextSize; PROCEDURE SpaceExtra (extra: LONGINT); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A88EH); CODE(RestoreA7);CODE(Return); END SpaceExtra; PROCEDURE xDrawChar (ch: CARDINAL); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A883H); CODE(RestoreA7);CODE(Return); END xDrawChar; PROCEDURE DrawChar (ch: CHAR); (*$P+*)(*$S-*) BEGIN xDrawChar(ORD(ch)) END DrawChar; PROCEDURE xDrawString (s:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A884H); CODE(RestoreA7);CODE(Return); END xDrawString; PROCEDURE DrawString (VAR s:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR s1:ARRAY[0..255] OF CHAR; BEGIN MakePascalString(s,s1); xDrawString(ADR(s1)) END DrawString; PROCEDURE DrawText (textBuf: ADDRESS; firstByte,byteCount: INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A885H); CODE(RestoreA7);CODE(Return); END DrawText; PROCEDURE xCharWidth (ch: CARDINAL):INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A88DH); CODE(RestoreA7);CODE(Return); END xCharWidth; PROCEDURE CharWidth (ch: CHAR): INTEGER; (*$P+*)(*$S-*) BEGIN RETURN(xCharWidth(ORD(ch))); END CharWidth; PROCEDURE xStringWidth (stringPtr:ADDRESS):INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A88CH); CODE(RestoreA7);CODE(Return); END xStringWidth; PROCEDURE StringWidth (VAR s:ARRAY OF CHAR):INTEGER; (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(s,Str); RETURN(xStringWidth(ADR(Str))); END StringWidth; PROCEDURE TextWidth(textBuf:ADDRESS;firstByte,byteCount:INTEGER):INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A886H); CODE(RestoreA7);CODE(Return); END TextWidth; (* Point Calculations *) PROCEDURE xAddPt (src:LONGINT;VAR dst:Point); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A87EH); CODE(RestoreA7);CODE(Return); END xAddPt; PROCEDURE AddPt (src:Point;VAR dst:Point); (*$P+*)(*$S-*) BEGIN xAddPt(src.param,dst) END AddPt; PROCEDURE xSubPt (src:LONGINT;VAR dst:Point); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A87FH); CODE(RestoreA7);CODE(Return); END xSubPt; PROCEDURE SubPt(src:Point;VAR dst:Point); (*$P+*)(*$S-*) BEGIN xSubPt(src.param,dst) END SubPt; PROCEDURE SetPt (VAR pt: Point;h,v:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A880H); CODE(RestoreA7);CODE(Return); END SetPt; PROCEDURE xEqualPt (pt1,pt2:LONGINT) :BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A881H); CODE(RestoreA7);CODE(Return); END xEqualPt; PROCEDURE EqualPt (pt1,pt2: Point) :BOOLEAN; (*$P+*)(*$S-*) BEGIN RETURN(xEqualPt(pt1.param,pt2.param)) END EqualPt; PROCEDURE ScalePt (VAR pt:Point;VAR fromRect,toRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8F8H); CODE(RestoreA7);CODE(Return); END ScalePt; PROCEDURE MapPt(VAR pt:Point;VAR fromRect,toRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8F9H); CODE(RestoreA7);CODE(Return); END MapPt; PROCEDURE LocalToGlobal(VAR pt:Point); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A870H); CODE(RestoreA7);CODE(Return); END LocalToGlobal; PROCEDURE GlobalToLocal(VAR pt:Point); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A871H); CODE(RestoreA7);CODE(Return); END GlobalToLocal; (* Rectangle Calculations *) PROCEDURE SetRect (VAR r:Rect;left,top,right,bottom:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8A7H); CODE(RestoreA7);CODE(Return); END SetRect; PROCEDURE EqualRect(VAR rect1,rect2:Rect):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8A6H); CODE(RestoreA7);CODE(Return); END EqualRect; PROCEDURE EmptyRect(VAR r:Rect):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8AEH); CODE(RestoreA7);CODE(Return); END EmptyRect; PROCEDURE OffsetRect(VAR r:Rect;dh,dv:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8A8H); CODE(RestoreA7);CODE(Return); END OffsetRect; PROCEDURE MapRect(VAR r:Rect;VAR fromRect,toRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8FAH); CODE(RestoreA7);CODE(Return); END MapRect; PROCEDURE InsetRect(VAR r:Rect;dh,dv:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8A9H); CODE(RestoreA7);CODE(Return); END InsetRect; PROCEDURE SectRect (VAR src1,src2:Rect;VAR dstRect:Rect):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8AAH); CODE(RestoreA7);CODE(Return); END SectRect; PROCEDURE UnionRect(VAR src1,src2:Rect;VAR dstRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8ABH); CODE(RestoreA7);CODE(Return); END UnionRect; PROCEDURE xPtInRect(pt: LONGINT;VAR dstRect:Rect):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8ADH); CODE(RestoreA7);CODE(Return); END xPtInRect; PROCEDURE PtInRect(pt: Point;dstRect:Rect):BOOLEAN; (*$P+*)(*$S-*) BEGIN RETURN(xPtInRect(pt.param,dstRect)); END PtInRect; PROCEDURE xPt2Rect (pt1,pt2:LONGINT;VAR dstRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8ACH); CODE(RestoreA7);CODE(Return); END xPt2Rect; PROCEDURE Pt2Rect (pt1,pt2:Point;VAR dstRect:Rect); (*$P+*)(*$S-*) BEGIN xPt2Rect(pt1.param,pt2.param,dstRect) END Pt2Rect; (* Graphical Operations on Rectangles *) PROCEDURE FrameRect (VAR r: Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8A1H); CODE(RestoreA7);CODE(Return); END FrameRect; PROCEDURE PaintRect (VAR r: Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8A2H); CODE(RestoreA7);CODE(Return); END PaintRect; PROCEDURE EraseRect (VAR r: Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8A3H); CODE(RestoreA7);CODE(Return); END EraseRect; PROCEDURE InvertRect (VAR r: Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8A4H); CODE(RestoreA7);CODE(Return); END InvertRect; PROCEDURE FillRect (VAR r: Rect;VAR pat: Pattern); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8A5H); CODE(RestoreA7);CODE(Return); END FillRect; (* RoundRect Routines *) PROCEDURE FrameRoundRect(VAR theRect:Rect;cornerWidth,cornerHeigth:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8B0H); CODE(RestoreA7);CODE(Return); END FrameRoundRect; PROCEDURE PaintRoundRect(VAR theRect:Rect;cornerWidth,cornerHeight:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8B1H); CODE(RestoreA7);CODE(Return); END PaintRoundRect; PROCEDURE FillRoundRect(VAR theRect:Rect; cornerWidth,cornerHeigth:INTEGER; VAR fillPat:Pattern); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8B4H); CODE(RestoreA7);CODE(Return); END FillRoundRect; PROCEDURE EraseRoundRect(VAR theRect:Rect;cornerWidth,cornerHeight:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8B2H); CODE(RestoreA7);CODE(Return); END EraseRoundRect; PROCEDURE InvertRoundRect(VAR theRect:Rect;cornerWidth,cornerHeigth:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8B3H); CODE(RestoreA7);CODE(Return); END InvertRoundRect; (* Drawing Ovals *) PROCEDURE FrameOval(VAR inRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8B7H); CODE(RestoreA7);CODE(Return); END FrameOval; PROCEDURE PaintOval(VAR inRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8B8H); CODE(RestoreA7);CODE(Return); END PaintOval; PROCEDURE EraseOval(VAR inRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8B9H); CODE(RestoreA7);CODE(Return); END EraseOval; PROCEDURE InvertOval(VAR inRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8BAH); CODE(RestoreA7);CODE(Return); END InvertOval; PROCEDURE FillOval(VAR inRect:Rect;VAR pat:Pattern); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8BBH); CODE(RestoreA7);CODE(Return); END FillOval; (* Arc Routines *) PROCEDURE FrameArc(VAR inRect:Rect;startAngle,arcAngle:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8BEH); CODE(RestoreA7);CODE(Return); END FrameArc; PROCEDURE PaintArc(VAR inRect:Rect;startAngle,arcAngle:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8BFH); CODE(RestoreA7);CODE(Return); END PaintArc; PROCEDURE FillArc(VAR inRect:Rect; startAngle,arcAngle:INTEGER; VAR fillpat:Pattern); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8C2H); CODE(RestoreA7);CODE(Return); END FillArc; PROCEDURE EraseArc(VAR inRect:Rect;startAngle,arcAngle:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8C0H); CODE(RestoreA7);CODE(Return); END EraseArc; PROCEDURE InvertArc(VAR inRect:Rect;startAngle,arcAngle:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8C1H); CODE(RestoreA7);CODE(Return); END InvertArc; PROCEDURE xPtToAngle(VAR inRect:Rect;P:LONGINT;VAR theAngle:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8C3H); CODE(RestoreA7);CODE(Return); END xPtToAngle; PROCEDURE PtToAngle (inRect:Rect;thePoint:Point;VAR theAngle:INTEGER); (*$P+*)(*$S-*) BEGIN xPtToAngle(inRect,thePoint.param,theAngle) END PtToAngle; (* Polygon Routines *) PROCEDURE OpenPoly():PolyHandle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8CBH); CODE(RestoreA7);CODE(Return); END OpenPoly; PROCEDURE ClosePoly; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8CCH); CODE(RestoreA7);CODE(Return); END ClosePoly; PROCEDURE KillPoly(thePolygon:PolyHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8CDH); CODE(RestoreA7);CODE(Return); END KillPoly; PROCEDURE OffsetPoly(thePolygon:PolyHandle;hOffset,vOffset:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8CEH); CODE(RestoreA7);CODE(Return); END OffsetPoly; PROCEDURE MapPoly (thePolygon:PolyHandle;VAR fromRect,toRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8FCH); CODE(RestoreA7);CODE(Return); END MapPoly; PROCEDURE FramePoly (thePolygon:PolyHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8C6H); CODE(RestoreA7);CODE(Return); END FramePoly; PROCEDURE PaintPoly (thePolygon:PolyHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8C7H); CODE(RestoreA7);CODE(Return); END PaintPoly; PROCEDURE FillPoly (thePolygon:PolyHandle;VAR fillPat:Pattern); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8CAH); CODE(RestoreA7);CODE(Return); END FillPoly; PROCEDURE ErasePoly (thePolygon:PolyHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8C8H); CODE(RestoreA7);CODE(Return); END ErasePoly; PROCEDURE InvertPoly (thePolygon:PolyHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8C9H); CODE(RestoreA7);CODE(Return); END InvertPoly; (* Graphical Operations on BitMaps *) PROCEDURE ScrollRect(VAR dstRect:Rect;dh,dv:INTEGER;updateRgn:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8EFH); CODE(RestoreA7);CODE(Return); END ScrollRect; PROCEDURE CopyBits (VAR srcBits,dstBits: BitMap; VAR srcRect,dstRect: Rect; mode: INTEGER; maskRgn: RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A8ECH); CODE(RestoreA7);CODE(Return); END CopyBits; (* later... PROCEDURE SetStdProcs PROCEDURE StdText PROCEDURE StdLine PROCEDURE StdRect PROCEDURE StdRRect PROCEDURE StdOval PROCEDURE StdArc PROCEDURE StdPoly PROCEDURE StdRgn PROCEDURE StdBits PROCEDURE StdComment PROCEDURE StdTxMeas PROCEDURE StdGetPic PROCEDURE StdPutPic *) (* Misc Utility Routines *) PROCEDURE GetPixel(h,v:INTEGER):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A865H); CODE(RestoreA7);CODE(Return); END GetPixel; PROCEDURE ForeColor (color:LONGINT); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A862H); CODE(RestoreA7);CODE(Return); END ForeColor; PROCEDURE BackColor (color:LONGINT); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A863H); CODE(RestoreA7);CODE(Return); END BackColor; PROCEDURE ColorBit (whichBit:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A864H); CODE(RestoreA7);CODE(Return); END ColorBit; BEGIN InitGraf(ADR(thePort)); END QuickDraw. !Funky!Stuff! echo x - ResourceManager.MOD cat >ResourceManager.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE ResourceManager; FROM SYSTEM IMPORT ADDRESS,CODE,ADR; FROM MacSYSTEM IMPORT LONGINT,Handle; FROM PascalStrings IMPORT MakePascalString,MakeModulaString; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) (* Opening and Closing Resource Files *) PROCEDURE xCreateResFile(fileName:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9B1H); CODE(RestoreA7);CODE(Return); END xCreateResFile; PROCEDURE CreateResFile(VAR fileName:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(fileName,Str); xCreateResFile(ADR(Str)) END CreateResFile; PROCEDURE xOpenResFile(fileName:ADDRESS):INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A997H); CODE(RestoreA7);CODE(Return); END xOpenResFile; PROCEDURE OpenResFile(VAR fileName:ARRAY OF CHAR):INTEGER; (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(fileName,Str); RETURN(xOpenResFile(ADR(Str))) END OpenResFile; PROCEDURE CloseResFile(refNum:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A99AH); CODE(RestoreA7);CODE(Return); END CloseResFile; (* Checking for Errors *) PROCEDURE ResError():INTEGER; BEGIN RETURN(ResErr); END ResError; (* Setting the Current Resource File *) PROCEDURE CurResFile():INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A994H); CODE(RestoreA7);CODE(Return); END CurResFile; PROCEDURE HomeResFile(theResource:Handle):INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9A4H); CODE(RestoreA7);CODE(Return); END HomeResFile; PROCEDURE UseResFile(refNum:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A998H); CODE(RestoreA7);CODE(Return); END UseResFile; (* Getting Resource Types *) PROCEDURE CountTypes():INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A99EH); CODE(RestoreA7);CODE(Return); END CountTypes; PROCEDURE GetIndType(VAR theType:ResType;index:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A99FH); CODE(RestoreA7);CODE(Return); END GetIndType; (* Getting and Disposing of Resources *) PROCEDURE SetResLoad(load:BOOLEAN); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A99BH); CODE(RestoreA7);CODE(Return); END SetResLoad; PROCEDURE xCountResources(theType:LONGINT):INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A99CH); CODE(RestoreA7);CODE(Return); END xCountResources; PROCEDURE CountResources(theType:ResType):INTEGER; (*$P+*)(*$S-*) VAR x:ParamResType; BEGIN x.res := theType; RETURN(xCountResources(x.param)) END CountResources; PROCEDURE xGetIndResource(theType:LONGINT;index:INTEGER):Handle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A99DH); CODE(RestoreA7);CODE(Return); END xGetIndResource; PROCEDURE GetIndResource(theType:ResType;index:INTEGER):Handle; (*$P+*)(*$S-*) VAR x:ParamResType; BEGIN x.res := theType; RETURN(xGetIndResource(x.param,index)) END GetIndResource; PROCEDURE xGetResource(theType:LONGINT;theID:INTEGER):Handle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9A0H); CODE(RestoreA7);CODE(Return); END xGetResource; PROCEDURE GetResource(theType:ResType;theID:INTEGER):Handle; (*$P+*)(*$S-*) VAR x:ParamResType; BEGIN x.res := theType; RETURN(xGetResource(x.param,theID)) END GetResource; PROCEDURE xGetNamedResource(theType:LONGINT;name:ADDRESS):Handle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9A1H); CODE(RestoreA7);CODE(Return); END xGetNamedResource; PROCEDURE GetNamedResource(theType:ResType;VAR name:ARRAY OF CHAR):Handle; (*$P+*)(*$S-*) VAR x:ParamResType; Str:ARRAY [0..255] OF CHAR; BEGIN x.res := theType; MakePascalString(name,Str); RETURN(xGetNamedResource(x.param,ADR(Str))) END GetNamedResource; PROCEDURE LoadResource(theResource:Handle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9A2H); CODE(RestoreA7);CODE(Return); END LoadResource; PROCEDURE ReleaseResource(theResource:Handle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9A3H); CODE(RestoreA7);CODE(Return); END ReleaseResource; PROCEDURE DetachResource(theResource:Handle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A992H); CODE(RestoreA7);CODE(Return); END DetachResource; (* Getting Resource Information *) PROCEDURE xUniqueID(theType:LONGINT):INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9ABH); CODE(RestoreA7);CODE(Return); END xUniqueID; PROCEDURE UniqueID(theType:ResType):INTEGER; (*$P+*)(*$S-*) VAR x:ParamResType; BEGIN x.res := theType; RETURN(xUniqueID(x.param)) END UniqueID; PROCEDURE xGetResInfo(theResource:Handle;VAR theID:INTEGER; VAR theType:ResType; name:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9A8H); CODE(RestoreA7);CODE(Return); END xGetResInfo; PROCEDURE GetResInfo(theResource:Handle;VAR theID:INTEGER; VAR theType:ResType; VAR name:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN xGetResInfo(theResource,theID,theType,ADR(Str)); MakeModulaString(Str,name) END GetResInfo; PROCEDURE GetResAttrs(theResource:Handle):INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9A6H); CODE(RestoreA7);CODE(Return); END GetResAttrs; PROCEDURE SizeResource(theResource:Handle):LONGINT; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9A5H); CODE(RestoreA7);CODE(Return); END SizeResource; (* Modifying Resources *) PROCEDURE xSetResInfo(theResource:Handle; theID:INTEGER;name:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9A9H); CODE(RestoreA7);CODE(Return); END xSetResInfo; PROCEDURE SetResInfo(theResource:Handle; theID:INTEGER;VAR name:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(name,Str); xSetResInfo(theResource,theID,ADR(Str)) END SetResInfo; PROCEDURE SetResAttrs(theResource:Handle;attrs:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9A7H); CODE(RestoreA7);CODE(Return); END SetResAttrs; PROCEDURE ChangedResource(theResource:Handle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9AAH); CODE(RestoreA7);CODE(Return); END ChangedResource; PROCEDURE xAddResource(theData:Handle;theType:LONGINT;theID:INTEGER; name:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9ABH); CODE(RestoreA7);CODE(Return); END xAddResource; PROCEDURE AddResource(theData:Handle;theType:ResType;theID:INTEGER; VAR name:ARRAY OF CHAR); (*$P+*)(*$S+*) VAR Str:ARRAY [0..255] OF CHAR; x:ParamResType; BEGIN x.res := theType; MakePascalString(name,Str); xAddResource(theData,x.param,theID,ADR(Str)); END AddResource; PROCEDURE RmveResource(theResource:Handle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9ADH); CODE(RestoreA7);CODE(Return); END RmveResource; PROCEDURE UpdateResFile(refNum:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A999H); CODE(RestoreA7);CODE(Return); END UpdateResFile; PROCEDURE WriteResource(theResource:Handle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9B0H); CODE(RestoreA7);CODE(Return); END WriteResource; PROCEDURE SetResPurge(install:BOOLEAN); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A993H); CODE(RestoreA7);CODE(Return); END SetResPurge; (* Advanced Routines *) PROCEDURE GetResFileAttrs(refNum:INTEGER):INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9F6H); CODE(RestoreA7);CODE(Return); END GetResFileAttrs; PROCEDURE SetResFileAttrs(refNum:INTEGER;attrs:INTEGER); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9F7H); CODE(RestoreA7);CODE(Return); END SetResFileAttrs; END ResourceManager. !Funky!Stuff! echo x - SFPackage.MOD cat >SFPackage.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE SFPackage; FROM SYSTEM IMPORT ADDRESS,WORD,ADR,CODE,REGISTER,SETREG; FROM MacSYSTEM IMPORT LONGINT; FROM QuickDraw IMPORT Point; FROM FileTypes IMPORT OSType; FROM PascalStrings IMPORT MakePascalString,MakeModulaString; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) Pack3 = 0A9EAH; SFGetF = 2; SFPGetF = 4; SFPPutF = 3; SFPutF = 1; Push = 03F3CH; (* MOVE #VAL,-(A7) *) PROCEDURE NoDlg():ADDRESS; (*??*) BEGIN RETURN(ADDRESS(0)) END NoDlg; VAR ProcDlg : MyDlgType; PROCEDURE DlgInterface; (*$P-*) BEGIN CODE(04E56H);CODE(0); (* LINK A6,#0 *) CODE(048E7H);CODE(0FFFCH); (* MOVEM.L D0-D7/A0-A5,-(A7) *) CODE(02F2EH);CODE(0AH); (* MOVE.L 0A(A6),-(A7) *) CODE(03F2EH);CODE(08H); (* MOVE.W 08(A6),-(A7) *) SETREG(8,ProcDlg); CODE(04E90H); (* JSR (A6) *) CODE(05C8FH); (* ADDQ.L #6,A7 *) CODE(04CDFH);CODE(03FFFH); (* MOVEM.L (A7)+,D0-D7/A0-A4 *) CODE(04E5EH); (* UNLK A6 *) CODE(02F5FH);CODE(2H); (* MOVE.L (A7)+,2(A7) *) CODE(0548FH); (* ADDQ.L #2,A7 *) CODE(04E75H); (* RTS *) END DlgInterface; PROCEDURE UseDlg(Dlg:MyDlgType):ADDRESS; (*$P+*)(*$S-*) BEGIN ProcDlg := Dlg; SETREG(8,DlgInterface); RETURN(REGISTER(8)) END UseDlg; PROCEDURE NoFileFilter():ADDRESS; BEGIN RETURN(ADDRESS(0)) END NoFileFilter; VAR ProcFilter : MyFileFilterType; PROCEDURE FilterInterface; (*$P-*) BEGIN CODE(04E56H);CODE(0); (* LINK A6,#0 *) CODE(048E7H);CODE(0FFFCH); (* MOVEM.L D0-D7/A0-A5,-(A7) *) CODE(02F2EH);CODE(08H); (* MOVE.L 0A(A6),-(A7) *) SETREG(8,ProcFilter); CODE(04E90H); (* JSR (A6) *) CODE(0588FH); (* ADDQ.L #4,A7 *) CODE(04CDFH);CODE(03FFFH); (* MOVEM.L (A7)+,D0-D7/A0-A4 *) CODE(04E5EH); (* UNLK A6 *) CODE(02E9FH); (* MOVE.L (A7)+,(A7) *) CODE(04E75H); (* RTS *) END FilterInterface; PROCEDURE UseFileFilter(FileFilter:MyFileFilterType):ADDRESS; (*$P+*)(*$S-*) BEGIN ProcFilter := FileFilter; SETREG(8,FilterInterface); RETURN(REGISTER(8)) END UseFileFilter; PROCEDURE xSFPutFile(lefttop:LONGINT;prompt: ADDRESS; origName: ADDRESS;dlgHook: ADDRESS; VAR reply: SFReply); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(SFPutF); CODE(Pack3); CODE(RestoreA7); CODE(Return); END xSFPutFile; PROCEDURE SFPutFile(lefttop:Point;VAR prompt: ARRAY OF CHAR; VAR origName: ARRAY OF CHAR;dlgHook: ADDRESS; VAR reply: SFReply); (*$P+*)(*$S-*) VAR p:ARRAY [0..255] OF CHAR; name:ARRAY [0..63] OF CHAR; I:CARDINAL; BEGIN MakePascalString(prompt,p); MakePascalString(origName,name); xSFPutFile(lefttop.param,ADR(p),ADR(name),dlgHook,reply); MakeModulaString(reply.fName,name); FOR I := 0 TO 63 DO reply.fName[I] := name[I] END END SFPutFile; PROCEDURE xSFPPutFile(lefttop:LONGINT;prompt: ADDRESS; origName: ADDRESS;dlgHook: ADDRESS; VAR reply: SFReply; dlgID: INTEGER;filterProc: ADDRESS); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(SFPPutF); CODE(Pack3); CODE(RestoreA7); CODE(Return); END xSFPPutFile; PROCEDURE SFPPutFile(lefttop:Point;VAR prompt: ARRAY OF CHAR; VAR origName: ARRAY OF CHAR;dlgHook: ADDRESS; VAR reply: SFReply; dlgID: INTEGER;filterProc: ADDRESS); (*$P+*)(*$S-*) VAR p:ARRAY [0..255] OF CHAR; name:ARRAY [0..63] OF CHAR; I:INTEGER; BEGIN MakePascalString(prompt,p); MakePascalString(origName,name); xSFPPutFile(lefttop.param,ADR(p),ADR(name),dlgHook,reply,dlgID,filterProc); MakeModulaString(reply.fName,name); FOR I := 0 TO 63 DO reply.fName[I] := name[I] END END SFPPutFile; PROCEDURE xSFGetFile(lefttop:LONGINT;prompt: ADDRESS; fileFilter: ADDRESS;numTypes: INTEGER; VAR typeList: SFTypeList; dlgHook: ADDRESS; VAR reply: SFReply); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(SFGetF); CODE(Pack3); CODE(RestoreA7); CODE(Return); END xSFGetFile; PROCEDURE SFGetFile(lefttop:Point;VAR prompt: ARRAY OF CHAR; fileFilter: ADDRESS;numTypes: INTEGER; VAR typeList: SFTypeList; dlgHook: ADDRESS; VAR reply: SFReply); (*$P+*)(*$S-*) VAR p:ARRAY [0..255] OF CHAR; name : ARRAY [0..63] OF CHAR; I:INTEGER; BEGIN MakePascalString(prompt,p); xSFGetFile(lefttop.param,ADR(p),fileFilter,numTypes,typeList, dlgHook,reply); MakeModulaString(reply.fName,name); FOR I := 0 TO 63 DO reply.fName[I] := name[I] END END SFGetFile; PROCEDURE xSFPGetFile(lefttop:LONGINT;prompt: ADDRESS; fileFilter: ADDRESS;numTypes: INTEGER; VAR typeList: SFTypeList; dlgHook: ADDRESS; VAR reply: SFReply; dlgID: INTEGER; filterProc: ADDRESS); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(Push); CODE(SFPGetF); CODE(Pack3); CODE(RestoreA7); CODE(Return); END xSFPGetFile; PROCEDURE SFPGetFile(lefttop:Point;VAR prompt: ARRAY OF CHAR; fileFilter: ADDRESS;numTypes: INTEGER; VAR typeList: SFTypeList; dlgHook: ADDRESS; VAR reply: SFReply; dlgID: INTEGER; filterProc: ADDRESS); (*$P+*)(*$S-*) VAR p:ARRAY [0..255] OF CHAR; name:ARRAY [0..63] OF CHAR; I:INTEGER; BEGIN MakePascalString(prompt,p); xSFPGetFile(lefttop.param,ADR(p),fileFilter,numTypes,typeList, dlgHook,reply,dlgID,filterProc); MakeModulaString(reply.fName,name); FOR I := 0 TO 63 DO reply.fName[I] := name[I] END END SFPGetFile; END SFPackage. !Funky!Stuff!
bobc@tikal.UUCP (Bob Campbell) (05/15/86)
# The rest of this file is a shell script which will extract: # Terminal.MOD TextEdit.MOD Toolbox.MOD WindowManager.MOD echo x - Terminal.MOD cat >Terminal.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE Terminal; (* A.Wespisser, 20-NOV-84 * J.Wyttenbach 11-jan-85 * B.Campbell 29-Dec-85 * * NOTE: - The procedures "KeyPress" and "GotoXY" and "ClearTerminal" are not * contained in module "Terminal" on SMAKY8. * - "BusyRead", "ReadString", "KeyPress" and "GotoXY" and "ClearTerminal" * are not required by the compiler itself. *) FROM SYSTEM IMPORT ADR; FROM MacSYSTEM IMPORT LONGINT; FROM QuickDraw IMPORT Rect,Point,screenBits,thePort,GrafPtr,GrafPort, SetRect,SetPort,GetPort,EraseRect,RgnHandle,DrawChar, ScrollRect,MoveTo,SetOrigin,GetPen; FROM Regions IMPORT NewRgn,DisposeRgn; FROM WindowManager IMPORT WindowRecord,WindowPtr,SelectWindow, BeginUpdate,EndUpdate,FrontWindow,inMenuBar,inSysWindow, inDrag,inContent,NewWindow,noGrowDocProc; FROM FontManager IMPORT FontInfo,GetFontInfo; FROM EventManager IMPORT FlushEvents,everyEvent,GetNextEvent,EventRecord, mouseDown,keyDown,autoKey,activateEvt,updateEvt, activMask,charCodeMask,shiftKey,EventAvail,keyDownMask,autoKeyMask; CONST etx = 03C; bs = 10C; ht = 11C; eoln = 12C; cr = 15C; VAR Font:FontInfo; myWindow:WindowPtr; wRecord:WindowRecord; Width,Height:INTEGER; FontHeight:INTEGER; PROCEDURE DoWriteLn; VAR P:Point; theUpdateRgn:RgnHandle; BEGIN GetPen(P); P.h := 0; P.v := P.v + FontHeight; IF (P.v >= Height) THEN theUpdateRgn := NewRgn(); ScrollRect(myWindow^.portRect,0,-FontHeight,theUpdateRgn); DisposeRgn (theUpdateRgn); P.v := P.v - FontHeight END (*IF*); MoveTo(P.h,P.v); END DoWriteLn; PROCEDURE DoWrite(ch:CHAR); VAR P:Point; BEGIN IF (ch >= ' ') THEN DrawChar(ch); GetPen(P); IF ((P.h + Font.widMax) >= Width) THEN DoWriteLn END ELSIF (ch = eoln) THEN DoWriteLn; ELSIF (ch = cr) THEN MoveTo(0,P.v) ELSIF (ch = ht) THEN (* TAB *) DrawChar(' ') (* oh well this is easy *) END (*IF*) END DoWrite; PROCEDURE Write (ch: CHAR); VAR OldPort : GrafPtr; P : Point; BEGIN GetPort(OldPort); SetPort(myWindow); DoWrite(ch); SetPort(OldPort); END Write; PROCEDURE WriteString(VAR s:ARRAY OF CHAR); VAR I:CARDINAL; OldPort:GrafPtr; BEGIN GetPort(OldPort); SetPort(myWindow); I := 0; WHILE ((I <= HIGH(s)) AND (s[I] # 0C)) DO DoWrite(s[I]); INC(I) END (* FOR *); SetPort(OldPort); END WriteString; PROCEDURE WriteLn; (*terminate line*) VAR I:INTEGER; OldPort:GrafPtr; BEGIN GetPort(OldPort); SetPort(myWindow); DoWriteLn; SetPort(OldPort); END WriteLn; VAR LastChar : CHAR; RepeatChar : BOOLEAN; PROCEDURE DoRead(VAR ch:CHAR); VAR Event : EventRecord; BEGIN IF (RepeatChar) THEN RepeatChar := FALSE; ELSE WHILE (NOT GetNextEvent(keyDownMask+autoKeyMask,Event)) DO END; LastChar := Event.CharacterCode; END; ch := LastChar END DoRead; PROCEDURE Read(VAR ch:CHAR); BEGIN DoRead(ch); Write(ch) END Read; PROCEDURE ReadString(VAR S : ARRAY OF CHAR); VAR i : CARDINAL; BEGIN i := 0; (* Assert HIGH(S) >= 0 *) LOOP DoRead(S[i]); IF (S[i] < ' ') THEN IF (S[i] = bs) AND (i > 0) THEN Write('\'); Write(S[i]); DEC(i) ELSIF (S[i] # ht) THEN WriteLn; EXIT END ELSE Write(S[i]); IF (i < HIGH(S)) THEN INC(i) END; IF (i = HIGH(S)) THEN WriteLn; EXIT END; END END; IF (i < HIGH(S)) OR (S[i] < ' ') THEN S[i] := 0C (* Null Terminated *) END END ReadString; PROCEDURE ReadLn (VAR S:ARRAY OF CHAR); VAR i : CARDINAL; c : CHAR; BEGIN i := 0; LOOP DoRead(c); IF (c < ' ') THEN IF (c = bs) AND (i > 0) THEN Write('\'); Write(c); DEC(i) ELSIF (c = cr) OR (c = eoln) OR (c = etx) THEN IF (i <= HIGH(S)) THEN S[i] := 0C END; WriteLn; EXIT END ELSE Write(c); IF (i <= HIGH(S)) THEN S[i] := c; INC(i) END; END END; END ReadLn; PROCEDURE BusyRead(VAR ch:CHAR); BEGIN IF KeyPress() THEN DoRead(ch) ELSE ch := 0C END END BusyRead; PROCEDURE ReadAgain; (* causes the last character read to be returned again * upon the next call of Read *) BEGIN RepeatChar := TRUE END ReadAgain; PROCEDURE KeyPress():BOOLEAN; VAR Event : EventRecord; BEGIN RETURN(EventAvail(keyDownMask,Event)) END KeyPress; PROCEDURE GotoXY(C,R:CARDINAL); (* Move to column x, row y *) VAR OldPort:GrafPtr; X,Y:INTEGER; BEGIN WITH Font DO X := INTEGER(C) * widMax; Y := INTEGER(R) * FontHeight END; GetPort(OldPort); SetPort(myWindow); MoveTo(X,Y); SetPort(OldPort); END GotoXY; PROCEDURE ClearTerminal; VAR OldPort:GrafPtr; BEGIN GetPort(OldPort); SetPort(myWindow); EraseRect(myWindow^.portRect); MoveTo(0,0); SetPort(OldPort); END ClearTerminal; PROCEDURE InitTerminal; VAR WindowRect : Rect; BEGIN RepeatChar := FALSE; FlushEvents(everyEvent,0); WITH screenBits.bounds DO SetRect(WindowRect,4,40,right-4,bottom-4) END; myWindow := NewWindow(ADR(wRecord),WindowRect,'Terminal', TRUE,noGrowDocProc,WindowPtr(-1),FALSE,4); GetFontInfo(Font); WITH Font DO FontHeight := ascent + descent + leading END; SetPort(myWindow); WITH myWindow^.portRect DO Width := (right - left) - 3; Height:= (bottom - top) - (FontHeight + 3) END; SetOrigin(-2,-(2 + Font.ascent)); END InitTerminal; BEGIN InitTerminal END Terminal. !Funky!Stuff! echo x - TextEdit.MOD cat >TextEdit.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE TextEdit; FROM SYSTEM IMPORT ADDRESS,ADR,CODE; FROM MacSYSTEM IMPORT Handle,LONGINT,OSErr; FROM QuickDraw IMPORT Style,Rect,Point,GrafPtr; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) PROCEDURE TENew(VAR destRect,viewRect:Rect):TEHandle; (* VAR is for Modula is really by value *) (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9D2H); CODE(RestoreA7); CODE(Return); END TENew; PROCEDURE TEDispose(hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9CDH); CODE(RestoreA7); CODE(Return); END TEDispose; (* Accessing the Text of an Edit Record *) PROCEDURE TESetText (text:ADDRESS;length:LONGINT;hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9CFH); CODE(RestoreA7); CODE(Return); END TESetText; PROCEDURE TEGetText (hTE: TEHandle):CharsHandle; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9CBH); CODE(RestoreA7); CODE(Return); END TEGetText; (*Insertion Point and Selection Range*) PROCEDURE TEIdle (hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9DAH); CODE(RestoreA7); CODE(Return); END TEIdle; PROCEDURE xTEClick (pt:LONGINT;extend:BOOLEAN;hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9D4H); CODE(RestoreA7); CODE(Return); END xTEClick; PROCEDURE TEClick (pt:Point;extend:BOOLEAN;hTE:TEHandle); (*$P+*)(*$S-*) BEGIN xTEClick(pt.param,extend,hTE); END TEClick; PROCEDURE TESetSelect (selStart,selEnd: LONGINT; hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9D1H); CODE(RestoreA7); CODE(Return); END TESetSelect; PROCEDURE TEActivate (hTE: TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9D8H); CODE(RestoreA7); CODE(Return); END TEActivate; PROCEDURE TEDeactivate (hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9D9H); CODE(RestoreA7); CODE(Return); END TEDeactivate; (* Editing *) PROCEDURE xTEKey (key:CARDINAL;hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9DCH); CODE(RestoreA7); CODE(Return); END xTEKey; PROCEDURE TEKey (key:CHAR;hTE:TEHandle); (*$P+*)(*$S-*) BEGIN xTEKey(ORD(key),hTE); END TEKey; PROCEDURE TECut (hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9D6H); CODE(RestoreA7); CODE(Return); END TECut; PROCEDURE TECopy (hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9D5H); CODE(RestoreA7); CODE(Return); END TECopy; PROCEDURE TEPaste (hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9DBH); CODE(RestoreA7); CODE(Return); END TEPaste; PROCEDURE TEDelete (hTE: TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9D7H); CODE(RestoreA7); CODE(Return); END TEDelete; PROCEDURE TEInsert (text:ADDRESS;length:LONGINT;hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9DEH); CODE(RestoreA7); CODE(Return); END TEInsert; (* Text Display and Scrolling *) PROCEDURE TESetJust (just:INTEGER;hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9DFH); CODE(RestoreA7); CODE(Return); END TESetJust; PROCEDURE TEUpdate (VAR rUpdate: Rect; hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9D3H); CODE(RestoreA7); CODE(Return); END TEUpdate; PROCEDURE TextBox (text:ADDRESS; length:LONGINT; VAR box:Rect; just:INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9CEH); CODE(RestoreA7); CODE(Return); END TextBox; PROCEDURE TEScroll (dh,dv:INTEGER;hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9DDH); CODE(RestoreA7); CODE(Return); END TEScroll; (* Scrap Handling *) PROCEDURE TEFromScrap():OSErr; (*$P+*) (* [Not in ROM] * VAR * pss : PScrapStuff; * (*$P+*) * BEGIN * pss := InfoScrap(); * TEScrpLength := pss.scrapSize; * TEScrpHandle := pss.scrapHandle; * END TEFromScrap; *) BEGIN END TEFromScrap; PROCEDURE TEToScrap():OSErr; (*$P+*) BEGIN END TEToScrap; PROCEDURE TEScrapHandle():Handle; (*$P+*) (*$S-*) BEGIN RETURN(TEScrpHandle) END TEScrapHandle; PROCEDURE TEGetScrapLen():LONGINT; (*$P+*) (*$S-*) BEGIN RETURN(TEScrpLength) END TEGetScrapLen; PROCEDURE TESetScrapLen(length:LONGINT); (*$P+*)(*$S-*) BEGIN TEScrpLength := length END TESetScrapLen; (* Advanced Routine *) PROCEDURE SetWordBreak(wBrkProc:ADDRESS; hTE:TEHandle); (*[Not in ROM]*) (*$P+*)(*$S-*) BEGIN END SetWordBreak; PROCEDURE SetClikLoop(clikProc:ADDRESS; hTE:TEHandle); (*$P+*)(*$S-*) BEGIN END SetClikLoop; PROCEDURE TECalText (hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9D0H); CODE(RestoreA7); CODE(Return); END TECalText; BEGIN CODE(0A9CCH) END TextEdit. !Funky!Stuff! echo x - Toolbox.MOD cat >Toolbox.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE Toolbox; FROM SYSTEM IMPORT ADDRESS,CODE,ADR; FROM MacSYSTEM IMPORT Fixed,Int64Bit,LONGINT,StringHandle,Handle; FROM QuickDraw IMPORT Pattern,Point,Rect; FROM PascalStrings IMPORT MakePascalString; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) PROCEDURE FixRatio(numer,denom:INTEGER):Fixed; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A869H); CODE(RestoreA7); CODE(Return); END FixRatio; PROCEDURE FixMul(a,b:Fixed):Fixed; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A868H); CODE(RestoreA7); CODE(Return); END FixMul; PROCEDURE FixRound(x:Fixed):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A86CH); CODE(RestoreA7); CODE(Return); END FixRound; (*String*) PROCEDURE xNewString(theString:ADDRESS):StringHandle; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A906H); CODE(RestoreA7); CODE(Return); END xNewString; PROCEDURE NewString(VAR theString:ARRAY OF CHAR):StringHandle; (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(theString,Str); RETURN(xNewString(ADR(Str))) END NewString; PROCEDURE xSetString(h:StringHandle;theString:ADDRESS); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A907H); CODE(RestoreA7); CODE(Return); END xSetString; PROCEDURE SetString(h:StringHandle;VAR theString:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(theString,Str); xSetString(h,ADR(Str)) END SetString; PROCEDURE GetString(StringID:INTEGER):StringHandle; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9BAH); CODE(RestoreA7); CODE(Return); END GetString; PROCEDURE GetIndString(VAR theString:ARRAY OF CHAR;strListID:INTEGER; index:INTEGER); (* no trap macro *) (*$P+*)(*$S-*) BEGIN END GetIndString; (*byte manipulation*) PROCEDURE Munger(h:Handle;offset:LONGINT;ptrl:ADDRESS;len1:LONGINT; ptr2:ADDRESS;len2:LONGINT):LONGINT; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9E0H); CODE(RestoreA7); CODE(Return); END Munger; PROCEDURE PackBits(VAR srcPtr,dstPtr:ADDRESS; srcBytes:INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A8CFH); CODE(RestoreA7); CODE(Return); END PackBits; PROCEDURE UnpackBits(VAR srcPtr,dstPtr:ADDRESS; dstBytes:INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A8D0H); CODE(RestoreA7); CODE(Return); END UnpackBits; (*bit Manipulation*) PROCEDURE BitTst(bytePtr:ADDRESS;bitNum:LONGINT):BOOLEAN; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A85DH); CODE(RestoreA7); CODE(Return); END BitTst; PROCEDURE BitSet(bytePtr:ADDRESS;bitNum:LONGINT); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A85EH); CODE(RestoreA7); CODE(Return); END BitSet; PROCEDURE BitClr(bytePtr:ADDRESS;bitNum:LONGINT); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A85FH); CODE(RestoreA7); CODE(Return); END BitClr; (*Logical Operations*) PROCEDURE BitAnd(val1,val2:LONGINT):LONGINT; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A858H); CODE(RestoreA7); CODE(Return); END BitAnd; PROCEDURE BitOr (val1,val2:LONGINT):LONGINT; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A85BH); CODE(RestoreA7); CODE(Return); END BitOr; PROCEDURE BitXor(val1,val2:LONGINT):LONGINT; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A859H); CODE(RestoreA7); CODE(Return); END BitXor; PROCEDURE BitNot(val:LONGINT):LONGINT; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A85AH); CODE(RestoreA7); CODE(Return); END BitNot; PROCEDURE BitShift(value:LONGINT;count:INTEGER):LONGINT; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A85CH); CODE(RestoreA7); CODE(Return); END BitShift; (*Other Operations on Long Integers*) PROCEDURE HiWord(x:LONGINT):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A86AH); CODE(RestoreA7); CODE(Return); END HiWord; PROCEDURE LoWord(x:LONGINT):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A86BH); CODE(RestoreA7); CODE(Return); END LoWord; PROCEDURE LongMul(a,b:LONGINT;VAR dest:Int64Bit); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A867H); CODE(RestoreA7); CODE(Return); END LongMul; (* Graphics Utilities *) PROCEDURE ScreenRes(VAR scrnHRes,scrnVRes:INTEGER); (*$P+*)(*$S-*) BEGIN scrnHRes := ScrHRes; scrnVRes := ScrVRes END ScreenRes; PROCEDURE GetIcon(iconID:INTEGER):Handle; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9BBH); CODE(RestoreA7); CODE(Return); END GetIcon; PROCEDURE PlotIcon(theRect:Rect;theIcon:Handle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A94BH); CODE(RestoreA7); CODE(Return); END PlotIcon; PROCEDURE GetPattern(patID:INTEGER):PatHandle; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9B8H); CODE(RestoreA7); CODE(Return); END GetPattern; PROCEDURE GetIndPattern(VAR thePattern:Pattern;patListID:INTEGER; index:INTEGER); (* no trap macro *) (*$P+*)(*$S-*) BEGIN END GetIndPattern; (* Miscellaneous Utilities *) PROCEDURE Random():INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A861H); CODE(RestoreA7);CODE(Return); END Random; PROCEDURE xStuffHex (thingPtr:ADDRESS;s:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A866H); CODE(RestoreA7);CODE(Return); END xStuffHex; PROCEDURE StuffHex (thingPtr:ADDRESS;VAR s:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR s1:ARRAY[0..255] OF CHAR; BEGIN MakePascalString(s,s1); xStuffHex(thingPtr,ADR(s1)) END StuffHex; PROCEDURE xDeltaPoint(ptA,ptB:LONGINT):LONGINT; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A94FH); CODE(RestoreA7); CODE(Return); END xDeltaPoint; PROCEDURE DeltaPoint(ptA,ptB:Point):LONGINT; (*$P+*)(*$S-*) BEGIN RETURN(xDeltaPoint(ptA.param,ptB.param)) END DeltaPoint; PROCEDURE SlopeFromAngle(angle:INTEGER):Fixed; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A8BCH); CODE(RestoreA7); CODE(Return); END SlopeFromAngle; PROCEDURE AngleFromSlope(slope:Fixed):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A8C4H); CODE(RestoreA7); CODE(Return); END AngleFromSlope; END Toolbox. !Funky!Stuff! echo x - WindowManager.MOD cat >WindowManager.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE WindowManager; FROM SYSTEM IMPORT ADDRESS,WORD,CODE,ADR,REGISTER; FROM MacSYSTEM IMPORT LONGINT; FROM FontManager IMPORT FontInfo; (* Init Font Manager *) FROM QuickDraw IMPORT GrafPort,GrafPtr,Point,VHSelect, Rect,RgnHandle; FROM Pictures IMPORT PicHandle; FROM EventManager IMPORT EventRecord; FROM PascalStrings IMPORT MakePascalString,MakeModulaString; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) PROCEDURE InitWindows; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A912H); CODE(RestoreA7);CODE(Return); END InitWindows; PROCEDURE xNewWindow(wStorage:ADDRESS;VAR windowRect:Rect; title:ADDRESS;visible:BOOLEAN;windowType:INTEGER; behindWindow:WindowPtr;hasClose:BOOLEAN; refCon:LONGINT):WindowPtr; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A913H); CODE(RestoreA7);CODE(Return); END xNewWindow; PROCEDURE NewWindow(wStorage:ADDRESS;VAR windowRect:Rect; VAR title:ARRAY OF CHAR;visible:BOOLEAN;windowType:INTEGER; behindWindow:WindowPtr;hasClose:BOOLEAN; refCon:LONGINT):WindowPtr; VAR s1:ARRAY [0..255] OF CHAR; (*$P+*)(*$S-*) BEGIN MakePascalString(title,s1); RETURN(xNewWindow(wStorage,windowRect,ADR(s1),visible, windowType,behindWindow,hasClose,refCon)) END NewWindow; PROCEDURE GetNewWindow(templateID:INTEGER; wStorage:ADDRESS;behindWindow:WindowPtr):WindowPtr; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9BDH); CODE(RestoreA7);CODE(Return); END GetNewWindow; PROCEDURE CloseWindow(theWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A92DH); CODE(RestoreA7);CODE(Return); END CloseWindow; PROCEDURE DisposeWindow(theWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A914H); CODE(RestoreA7);CODE(Return); END DisposeWindow; PROCEDURE xSetWTitle(theWindow:WindowPtr;newTitle:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A91AH); CODE(RestoreA7);CODE(Return); END xSetWTitle; PROCEDURE SetWTitle(theWindow:WindowPtr;VAR newTitle:ARRAY OF CHAR); VAR s1:ARRAY [0..255] OF CHAR; (*$P+*)(*$S-*) BEGIN MakePascalString(newTitle,s1); xSetWTitle(theWindow,ADR(s1)); END SetWTitle; PROCEDURE xGetWTitle(theWindow:WindowPtr;theTitle:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A919H); CODE(RestoreA7);CODE(Return); END xGetWTitle; PROCEDURE GetWTitle(theWindow:WindowPtr;VAR theTitle:ARRAY OF CHAR); VAR s1:ARRAY [0..255] OF CHAR; (*$P+*)(*$S-*) BEGIN xGetWTitle(theWindow,ADR(s1)); MakeModulaString(s1,theTitle); END GetWTitle; PROCEDURE SetWRefCon(theWindow:WindowPtr;newRefCon:LONGINT); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A918H); CODE(RestoreA7);CODE(Return); END SetWRefCon; PROCEDURE GetWRefCon(theWindow:WindowPtr):LONGINT; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A917H); CODE(RestoreA7);CODE(Return); END GetWRefCon; PROCEDURE HideWindow(theWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A916H); CODE(RestoreA7);CODE(Return); END HideWindow; PROCEDURE ShowWindow(theWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A915H); CODE(RestoreA7);CODE(Return); END ShowWindow; PROCEDURE ShowHide(theWindow:WindowPtr;showFlag:BOOLEAN); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A908H); CODE(RestoreA7);CODE(Return); END ShowHide; PROCEDURE MoveWindow(theWindow: WindowPtr; hGlobal,vGlobal: INTEGER; active: BOOLEAN); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A91BH); CODE(RestoreA7);CODE(Return); END MoveWindow; PROCEDURE SizeWindow (theWindow: WindowPtr; newWidth,newHeight: INTEGER; update: BOOLEAN); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A91DH); CODE(RestoreA7);CODE(Return); END SizeWindow; PROCEDURE FrontWindow():WindowPtr; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A924H); CODE(RestoreA7);CODE(Return); END FrontWindow; PROCEDURE BringToFront(theWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A920H); CODE(RestoreA7);CODE(Return); END BringToFront; PROCEDURE SendBehind(theWindow:WindowPtr;behindWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A921H); CODE(RestoreA7);CODE(Return); END SendBehind; PROCEDURE HiliteWindow(theWindow:WindowPtr;onOrOff:BOOLEAN); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A91CH); CODE(RestoreA7);CODE(Return); END HiliteWindow; PROCEDURE DrawGrowIcon(theWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A904H); CODE(RestoreA7);CODE(Return); END DrawGrowIcon; PROCEDURE BeginUpdate(theWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A922H); CODE(RestoreA7);CODE(Return); END BeginUpdate; PROCEDURE EndUpdate(theWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A923H); CODE(RestoreA7);CODE(Return); END EndUpdate; PROCEDURE InvalRect(VAR badRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A928H); CODE(RestoreA7);CODE(Return); END InvalRect; PROCEDURE InvalRgn(badRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A927H); CODE(RestoreA7);CODE(Return); END InvalRgn; PROCEDURE ValidRect(VAR goodRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A92AH); CODE(RestoreA7);CODE(Return); END ValidRect; PROCEDURE ValidRgn(goodRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A929H); CODE(RestoreA7);CODE(Return); END ValidRgn; PROCEDURE SetWindowPic (theWindow:WindowPtr;thePicture:PicHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A92EH); CODE(RestoreA7);CODE(Return); END SetWindowPic; PROCEDURE GetWindowPic(theWindow:WindowPtr):PicHandle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A92FH); CODE(RestoreA7);CODE(Return); END GetWindowPic; PROCEDURE xFindWindow(mousePoint:LONGINT;VAR theWindow:WindowPtr):INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A92CH); CODE(RestoreA7);CODE(Return); END xFindWindow; PROCEDURE FindWindow (mousePoint:Point;VAR theWindow:WindowPtr):INTEGER; (*$P+*)(*$S-*) BEGIN RETURN(xFindWindow(mousePoint.param,theWindow)) END FindWindow; PROCEDURE SelectWindow(theWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A91FH); CODE(RestoreA7);CODE(Return); END SelectWindow; PROCEDURE xDragWindow (theWindow:WindowPtr; startPoint:LONGINT; VAR LimitRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A925H); CODE(RestoreA7);CODE(Return); END xDragWindow; PROCEDURE DragWindow (theWindow:WindowPtr; startPoint:Point; LimitRect:Rect); (*$P+*)(*$S-*) BEGIN xDragWindow(theWindow,startPoint.param,LimitRect) END DragWindow; PROCEDURE xGrowWindow (theWindow: WindowPtr; startPoint: LONGINT; VAR sizeRect: Rect):LONGINT; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A92BH); CODE(RestoreA7);CODE(Return); END xGrowWindow; PROCEDURE GrowWindow (theWindow: WindowPtr; startPoint: Point; sizeRect: Rect):LONGINT; (*$P+*)(*$S-*) BEGIN RETURN(xGrowWindow(theWindow,startPoint.param,sizeRect)) END GrowWindow; PROCEDURE xTrackGoAway(wind:WindowPtr;start:LONGINT):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A91EH); CODE(RestoreA7);CODE(Return); END xTrackGoAway; PROCEDURE TrackGoAway(wind:WindowPtr;start:Point):BOOLEAN; (*$P+*)(*$S-*) BEGIN RETURN(xTrackGoAway(wind,start.param)) END TrackGoAway; PROCEDURE GetWMgrPort(VAR wMgrPort:GrafPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A910H); CODE(RestoreA7);CODE(Return); END GetWMgrPort; BEGIN InitWindows END WindowManager. !Funky!Stuff! # The rest of this file is a shell script which will extract: # Terminal.MOD TextEdit.MOD Toolbox.MOD WindowManager.MOD echo x - Terminal.MOD cat >Terminal.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE Terminal; (* A.Wespisser, 20-NOV-84 * J.Wyttenbach 11-jan-85 * B.Campbell 29-Dec-85 * * NOTE: - The procedures "KeyPress" and "GotoXY" and "ClearTerminal" are not * contained in module "Terminal" on SMAKY8. * - "BusyRead", "ReadString", "KeyPress" and "GotoXY" and "ClearTerminal" * are not required by the compiler itself. *) FROM SYSTEM IMPORT ADR; FROM MacSYSTEM IMPORT LONGINT; FROM QuickDraw IMPORT Rect,Point,screenBits,thePort,GrafPtr,GrafPort, SetRect,SetPort,GetPort,EraseRect,RgnHandle,DrawChar, ScrollRect,MoveTo,SetOrigin,GetPen; FROM Regions IMPORT NewRgn,DisposeRgn; FROM WindowManager IMPORT WindowRecord,WindowPtr,SelectWindow, BeginUpdate,EndUpdate,FrontWindow,inMenuBar,inSysWindow, inDrag,inContent,NewWindow,noGrowDocProc; FROM FontManager IMPORT FontInfo,GetFontInfo; FROM EventManager IMPORT FlushEvents,everyEvent,GetNextEvent,EventRecord, mouseDown,keyDown,autoKey,activateEvt,updateEvt, activMask,charCodeMask,shiftKey,EventAvail,keyDownMask,autoKeyMask; CONST etx = 03C; bs = 10C; ht = 11C; eoln = 12C; cr = 15C; VAR Font:FontInfo; myWindow:WindowPtr; wRecord:WindowRecord; Width,Height:INTEGER; FontHeight:INTEGER; PROCEDURE DoWriteLn; VAR P:Point; theUpdateRgn:RgnHandle; BEGIN GetPen(P); P.h := 0; P.v := P.v + FontHeight; IF (P.v >= Height) THEN theUpdateRgn := NewRgn(); ScrollRect(myWindow^.portRect,0,-FontHeight,theUpdateRgn); DisposeRgn (theUpdateRgn); P.v := P.v - FontHeight END (*IF*); MoveTo(P.h,P.v); END DoWriteLn; PROCEDURE DoWrite(ch:CHAR); VAR P:Point; BEGIN IF (ch >= ' ') THEN DrawChar(ch); GetPen(P); IF ((P.h + Font.widMax) >= Width) THEN DoWriteLn END ELSIF (ch = eoln) THEN DoWriteLn; ELSIF (ch = cr) THEN MoveTo(0,P.v) ELSIF (ch = ht) THEN (* TAB *) DrawChar(' ') (* oh well this is easy *) END (*IF*) END DoWrite; PROCEDURE Write (ch: CHAR); VAR OldPort : GrafPtr; P : Point; BEGIN GetPort(OldPort); SetPort(myWindow); DoWrite(ch); SetPort(OldPort); END Write; PROCEDURE WriteString(VAR s:ARRAY OF CHAR); VAR I:CARDINAL; OldPort:GrafPtr; BEGIN GetPort(OldPort); SetPort(myWindow); I := 0; WHILE ((I <= HIGH(s)) AND (s[I] # 0C)) DO DoWrite(s[I]); INC(I) END (* FOR *); SetPort(OldPort); END WriteString; PROCEDURE WriteLn; (*terminate line*) VAR I:INTEGER; OldPort:GrafPtr; BEGIN GetPort(OldPort); SetPort(myWindow); DoWriteLn; SetPort(OldPort); END WriteLn; VAR LastChar : CHAR; RepeatChar : BOOLEAN; PROCEDURE DoRead(VAR ch:CHAR); VAR Event : EventRecord; BEGIN IF (RepeatChar) THEN RepeatChar := FALSE; ELSE WHILE (NOT GetNextEvent(keyDownMask+autoKeyMask,Event)) DO END; LastChar := Event.CharacterCode; END; ch := LastChar END DoRead; PROCEDURE Read(VAR ch:CHAR); BEGIN DoRead(ch); Write(ch) END Read; PROCEDURE ReadString(VAR S : ARRAY OF CHAR); VAR i : CARDINAL; BEGIN i := 0; (* Assert HIGH(S) >= 0 *) LOOP DoRead(S[i]); IF (S[i] < ' ') THEN IF (S[i] = bs) AND (i > 0) THEN Write('\'); Write(S[i]); DEC(i) ELSIF (S[i] # ht) THEN WriteLn; EXIT END ELSE Write(S[i]); IF (i < HIGH(S)) THEN INC(i) END; IF (i = HIGH(S)) THEN WriteLn; EXIT END; END END; IF (i < HIGH(S)) OR (S[i] < ' ') THEN S[i] := 0C (* Null Terminated *) END END ReadString; PROCEDURE ReadLn (VAR S:ARRAY OF CHAR); VAR i : CARDINAL; c : CHAR; BEGIN i := 0; LOOP DoRead(c); IF (c < ' ') THEN IF (c = bs) AND (i > 0) THEN Write('\'); Write(c); DEC(i) ELSIF (c = cr) OR (c = eoln) OR (c = etx) THEN IF (i <= HIGH(S)) THEN S[i] := 0C END; WriteLn; EXIT END ELSE Write(c); IF (i <= HIGH(S)) THEN S[i] := c; INC(i) END; END END; END ReadLn; PROCEDURE BusyRead(VAR ch:CHAR); BEGIN IF KeyPress() THEN DoRead(ch) ELSE ch := 0C END END BusyRead; PROCEDURE ReadAgain; (* causes the last character read to be returned again * upon the next call of Read *) BEGIN RepeatChar := TRUE END ReadAgain; PROCEDURE KeyPress():BOOLEAN; VAR Event : EventRecord; BEGIN RETURN(EventAvail(keyDownMask,Event)) END KeyPress; PROCEDURE GotoXY(C,R:CARDINAL); (* Move to column x, row y *) VAR OldPort:GrafPtr; X,Y:INTEGER; BEGIN WITH Font DO X := INTEGER(C) * widMax; Y := INTEGER(R) * FontHeight END; GetPort(OldPort); SetPort(myWindow); MoveTo(X,Y); SetPort(OldPort); END GotoXY; PROCEDURE ClearTerminal; VAR OldPort:GrafPtr; BEGIN GetPort(OldPort); SetPort(myWindow); EraseRect(myWindow^.portRect); MoveTo(0,0); SetPort(OldPort); END ClearTerminal; PROCEDURE InitTerminal; VAR WindowRect : Rect; BEGIN RepeatChar := FALSE; FlushEvents(everyEvent,0); WITH screenBits.bounds DO SetRect(WindowRect,4,40,right-4,bottom-4) END; myWindow := NewWindow(ADR(wRecord),WindowRect,'Terminal', TRUE,noGrowDocProc,WindowPtr(-1),FALSE,4); GetFontInfo(Font); WITH Font DO FontHeight := ascent + descent + leading END; SetPort(myWindow); WITH myWindow^.portRect DO Width := (right - left) - 3; Height:= (bottom - top) - (FontHeight + 3) END; SetOrigin(-2,-(2 + Font.ascent)); END InitTerminal; BEGIN InitTerminal END Terminal. !Funky!Stuff! echo x - TextEdit.MOD cat >TextEdit.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE TextEdit; FROM SYSTEM IMPORT ADDRESS,ADR,CODE; FROM MacSYSTEM IMPORT Handle,LONGINT,OSErr; FROM QuickDraw IMPORT Style,Rect,Point,GrafPtr; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) PROCEDURE TENew(VAR destRect,viewRect:Rect):TEHandle; (* VAR is for Modula is really by value *) (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9D2H); CODE(RestoreA7); CODE(Return); END TENew; PROCEDURE TEDispose(hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9CDH); CODE(RestoreA7); CODE(Return); END TEDispose; (* Accessing the Text of an Edit Record *) PROCEDURE TESetText (text:ADDRESS;length:LONGINT;hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9CFH); CODE(RestoreA7); CODE(Return); END TESetText; PROCEDURE TEGetText (hTE: TEHandle):CharsHandle; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9CBH); CODE(RestoreA7); CODE(Return); END TEGetText; (*Insertion Point and Selection Range*) PROCEDURE TEIdle (hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9DAH); CODE(RestoreA7); CODE(Return); END TEIdle; PROCEDURE xTEClick (pt:LONGINT;extend:BOOLEAN;hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9D4H); CODE(RestoreA7); CODE(Return); END xTEClick; PROCEDURE TEClick (pt:Point;extend:BOOLEAN;hTE:TEHandle); (*$P+*)(*$S-*) BEGIN xTEClick(pt.param,extend,hTE); END TEClick; PROCEDURE TESetSelect (selStart,selEnd: LONGINT; hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9D1H); CODE(RestoreA7); CODE(Return); END TESetSelect; PROCEDURE TEActivate (hTE: TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9D8H); CODE(RestoreA7); CODE(Return); END TEActivate; PROCEDURE TEDeactivate (hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9D9H); CODE(RestoreA7); CODE(Return); END TEDeactivate; (* Editing *) PROCEDURE xTEKey (key:CARDINAL;hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9DCH); CODE(RestoreA7); CODE(Return); END xTEKey; PROCEDURE TEKey (key:CHAR;hTE:TEHandle); (*$P+*)(*$S-*) BEGIN xTEKey(ORD(key),hTE); END TEKey; PROCEDURE TECut (hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9D6H); CODE(RestoreA7); CODE(Return); END TECut; PROCEDURE TECopy (hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9D5H); CODE(RestoreA7); CODE(Return); END TECopy; PROCEDURE TEPaste (hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9DBH); CODE(RestoreA7); CODE(Return); END TEPaste; PROCEDURE TEDelete (hTE: TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9D7H); CODE(RestoreA7); CODE(Return); END TEDelete; PROCEDURE TEInsert (text:ADDRESS;length:LONGINT;hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9DEH); CODE(RestoreA7); CODE(Return); END TEInsert; (* Text Display and Scrolling *) PROCEDURE TESetJust (just:INTEGER;hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9DFH); CODE(RestoreA7); CODE(Return); END TESetJust; PROCEDURE TEUpdate (VAR rUpdate: Rect; hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9D3H); CODE(RestoreA7); CODE(Return); END TEUpdate; PROCEDURE TextBox (text:ADDRESS; length:LONGINT; VAR box:Rect; just:INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9CEH); CODE(RestoreA7); CODE(Return); END TextBox; PROCEDURE TEScroll (dh,dv:INTEGER;hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9DDH); CODE(RestoreA7); CODE(Return); END TEScroll; (* Scrap Handling *) PROCEDURE TEFromScrap():OSErr; (*$P+*) (* [Not in ROM] * VAR * pss : PScrapStuff; * (*$P+*) * BEGIN * pss := InfoScrap(); * TEScrpLength := pss.scrapSize; * TEScrpHandle := pss.scrapHandle; * END TEFromScrap; *) BEGIN END TEFromScrap; PROCEDURE TEToScrap():OSErr; (*$P+*) BEGIN END TEToScrap; PROCEDURE TEScrapHandle():Handle; (*$P+*) (*$S-*) BEGIN RETURN(TEScrpHandle) END TEScrapHandle; PROCEDURE TEGetScrapLen():LONGINT; (*$P+*) (*$S-*) BEGIN RETURN(TEScrpLength) END TEGetScrapLen; PROCEDURE TESetScrapLen(length:LONGINT); (*$P+*)(*$S-*) BEGIN TEScrpLength := length END TESetScrapLen; (* Advanced Routine *) PROCEDURE SetWordBreak(wBrkProc:ADDRESS; hTE:TEHandle); (*[Not in ROM]*) (*$P+*)(*$S-*) BEGIN END SetWordBreak; PROCEDURE SetClikLoop(clikProc:ADDRESS; hTE:TEHandle); (*$P+*)(*$S-*) BEGIN END SetClikLoop; PROCEDURE TECalText (hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9D0H); CODE(RestoreA7); CODE(Return); END TECalText; BEGIN CODE(0A9CCH) END TextEdit. !Funky!Stuff! echo x - Toolbox.MOD cat >Toolbox.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE Toolbox; FROM SYSTEM IMPORT ADDRESS,CODE,ADR; FROM MacSYSTEM IMPORT Fixed,Int64Bit,LONGINT,StringHandle,Handle; FROM QuickDraw IMPORT Pattern,Point,Rect; FROM PascalStrings IMPORT MakePascalString; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) PROCEDURE FixRatio(numer,denom:INTEGER):Fixed; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A869H); CODE(RestoreA7); CODE(Return); END FixRatio; PROCEDURE FixMul(a,b:Fixed):Fixed; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A868H); CODE(RestoreA7); CODE(Return); END FixMul; PROCEDURE FixRound(x:Fixed):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A86CH); CODE(RestoreA7); CODE(Return); END FixRound; (*String*) PROCEDURE xNewString(theString:ADDRESS):StringHandle; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A906H); CODE(RestoreA7); CODE(Return); END xNewString; PROCEDURE NewString(VAR theString:ARRAY OF CHAR):StringHandle; (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(theString,Str); RETURN(xNewString(ADR(Str))) END NewString; PROCEDURE xSetString(h:StringHandle;theString:ADDRESS); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A907H); CODE(RestoreA7); CODE(Return); END xSetString; PROCEDURE SetString(h:StringHandle;VAR theString:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(theString,Str); xSetString(h,ADR(Str)) END SetString; PROCEDURE GetString(StringID:INTEGER):StringHandle; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9BAH); CODE(RestoreA7); CODE(Return); END GetString; PROCEDURE GetIndString(VAR theString:ARRAY OF CHAR;strListID:INTEGER; index:INTEGER); (* no trap macro *) (*$P+*)(*$S-*) BEGIN END GetIndString; (*byte manipulation*) PROCEDURE Munger(h:Handle;offset:LONGINT;ptrl:ADDRESS;len1:LONGINT; ptr2:ADDRESS;len2:LONGINT):LONGINT; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9E0H); CODE(RestoreA7); CODE(Return); END Munger; PROCEDURE PackBits(VAR srcPtr,dstPtr:ADDRESS; srcBytes:INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A8CFH); CODE(RestoreA7); CODE(Return); END PackBits; PROCEDURE UnpackBits(VAR srcPtr,dstPtr:ADDRESS; dstBytes:INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A8D0H); CODE(RestoreA7); CODE(Return); END UnpackBits; (*bit Manipulation*) PROCEDURE BitTst(bytePtr:ADDRESS;bitNum:LONGINT):BOOLEAN; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A85DH); CODE(RestoreA7); CODE(Return); END BitTst; PROCEDURE BitSet(bytePtr:ADDRESS;bitNum:LONGINT); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A85EH); CODE(RestoreA7); CODE(Return); END BitSet; PROCEDURE BitClr(bytePtr:ADDRESS;bitNum:LONGINT); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A85FH); CODE(RestoreA7); CODE(Return); END BitClr; (*Logical Operations*) PROCEDURE BitAnd(val1,val2:LONGINT):LONGINT; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A858H); CODE(RestoreA7); CODE(Return); END BitAnd; PROCEDURE BitOr (val1,val2:LONGINT):LONGINT; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A85BH); CODE(RestoreA7); CODE(Return); END BitOr; PROCEDURE BitXor(val1,val2:LONGINT):LONGINT; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A859H); CODE(RestoreA7); CODE(Return); END BitXor; PROCEDURE BitNot(val:LONGINT):LONGINT; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A85AH); CODE(RestoreA7); CODE(Return); END BitNot; PROCEDURE BitShift(value:LONGINT;count:INTEGER):LONGINT; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A85CH); CODE(RestoreA7); CODE(Return); END BitShift; (*Other Operations on Long Integers*) PROCEDURE HiWord(x:LONGINT):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A86AH); CODE(RestoreA7); CODE(Return); END HiWord; PROCEDURE LoWord(x:LONGINT):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A86BH); CODE(RestoreA7); CODE(Return); END LoWord; PROCEDURE LongMul(a,b:LONGINT;VAR dest:Int64Bit); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A867H); CODE(RestoreA7); CODE(Return); END LongMul; (* Graphics Utilities *) PROCEDURE ScreenRes(VAR scrnHRes,scrnVRes:INTEGER); (*$P+*)(*$S-*) BEGIN scrnHRes := ScrHRes; scrnVRes := ScrVRes END ScreenRes; PROCEDURE GetIcon(iconID:INTEGER):Handle; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9BBH); CODE(RestoreA7); CODE(Return); END GetIcon; PROCEDURE PlotIcon(theRect:Rect;theIcon:Handle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A94BH); CODE(RestoreA7); CODE(Return); END PlotIcon; PROCEDURE GetPattern(patID:INTEGER):PatHandle; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9B8H); CODE(RestoreA7); CODE(Return); END GetPattern; PROCEDURE GetIndPattern(VAR thePattern:Pattern;patListID:INTEGER; index:INTEGER); (* no trap macro *) (*$P+*)(*$S-*) BEGIN END GetIndPattern; (* Miscellaneous Utilities *) PROCEDURE Random():INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A861H); CODE(RestoreA7);CODE(Return); END Random; PROCEDURE xStuffHex (thingPtr:ADDRESS;s:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A866H); CODE(RestoreA7);CODE(Return); END xStuffHex; PROCEDURE StuffHex (thingPtr:ADDRESS;VAR s:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR s1:ARRAY[0..255] OF CHAR; BEGIN MakePascalString(s,s1); xStuffHex(thingPtr,ADR(s1)) END StuffHex; PROCEDURE xDeltaPoint(ptA,ptB:LONGINT):LONGINT; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A94FH); CODE(RestoreA7); CODE(Return); END xDeltaPoint; PROCEDURE DeltaPoint(ptA,ptB:Point):LONGINT; (*$P+*)(*$S-*) BEGIN RETURN(xDeltaPoint(ptA.param,ptB.param)) END DeltaPoint; PROCEDURE SlopeFromAngle(angle:INTEGER):Fixed; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A8BCH); CODE(RestoreA7); CODE(Return); END SlopeFromAngle; PROCEDURE AngleFromSlope(slope:Fixed):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A8C4H); CODE(RestoreA7); CODE(Return); END AngleFromSlope; END Toolbox. !Funky!Stuff! echo x - WindowManager.MOD cat >WindowManager.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE WindowManager; FROM SYSTEM IMPORT ADDRESS,WORD,CODE,ADR,REGISTER; FROM MacSYSTEM IMPORT LONGINT; FROM FontManager IMPORT FontInfo; (* Init Font Manager *) FROM QuickDraw IMPORT GrafPort,GrafPtr,Point,VHSelect, Rect,RgnHandle; FROM Pictures IMPORT PicHandle; FROM EventManager IMPORT EventRecord; FROM PascalStrings IMPORT MakePascalString,MakeModulaString; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) PROCEDURE InitWindows; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A912H); CODE(RestoreA7);CODE(Return); END InitWindows; PROCEDURE xNewWindow(wStorage:ADDRESS;VAR windowRect:Rect; title:ADDRESS;visible:BOOLEAN;windowType:INTEGER; behindWindow:WindowPtr;hasClose:BOOLEAN; refCon:LONGINT):WindowPtr; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A913H); CODE(RestoreA7);CODE(Return); END xNewWindow; PROCEDURE NewWindow(wStorage:ADDRESS;VAR windowRect:Rect; VAR title:ARRAY OF CHAR;visible:BOOLEAN;windowType:INTEGER; behindWindow:WindowPtr;hasClose:BOOLEAN; refCon:LONGINT):WindowPtr; VAR s1:ARRAY [0..255] OF CHAR; (*$P+*)(*$S-*) BEGIN MakePascalString(title,s1); RETURN(xNewWindow(wStorage,windowRect,ADR(s1),visible, windowType,behindWindow,hasClose,refCon)) END NewWindow; PROCEDURE GetNewWindow(templateID:INTEGER; wStorage:ADDRESS;behindWindow:WindowPtr):WindowPtr; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9BDH); CODE(RestoreA7);CODE(Return); END GetNewWindow; PROCEDURE CloseWindow(theWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A92DH); CODE(RestoreA7);CODE(Return); END CloseWindow; PROCEDURE DisposeWindow(theWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A914H); CODE(RestoreA7);CODE(Return); END DisposeWindow; PROCEDURE xSetWTitle(theWindow:WindowPtr;newTitle:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A91AH); CODE(RestoreA7);CODE(Return); END xSetWTitle; PROCEDURE SetWTitle(theWindow:WindowPtr;VAR newTitle:ARRAY OF CHAR); VAR s1:ARRAY [0..255] OF CHAR; (*$P+*)(*$S-*) BEGIN MakePascalString(newTitle,s1); xSetWTitle(theWindow,ADR(s1)); END SetWTitle; PROCEDURE xGetWTitle(theWindow:WindowPtr;theTitle:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A919H); CODE(RestoreA7);CODE(Return); END xGetWTitle; PROCEDURE GetWTitle(theWindow:WindowPtr;VAR theTitle:ARRAY OF CHAR); VAR s1:ARRAY [0..255] OF CHAR; (*$P+*)(*$S-*) BEGIN xGetWTitle(theWindow,ADR(s1)); MakeModulaString(s1,theTitle); END GetWTitle; PROCEDURE SetWRefCon(theWindow:WindowPtr;newRefCon:LONGINT); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A918H); CODE(RestoreA7);CODE(Return); END SetWRefCon; PROCEDURE GetWRefCon(theWindow:WindowPtr):LONGINT; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A917H); CODE(RestoreA7);CODE(Return); END GetWRefCon; PROCEDURE HideWindow(theWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A916H); CODE(RestoreA7);CODE(Return); END HideWindow; PROCEDURE ShowWindow(theWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A915H); CODE(RestoreA7);CODE(Return); END ShowWindow; PROCEDURE ShowHide(theWindow:WindowPtr;showFlag:BOOLEAN); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A908H); CODE(RestoreA7);CODE(Return); END ShowHide; PROCEDURE MoveWindow(theWindow: WindowPtr; hGlobal,vGlobal: INTEGER; active: BOOLEAN); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A91BH); CODE(RestoreA7);CODE(Return); END MoveWindow; PROCEDURE SizeWindow (theWindow: WindowPtr; newWidth,newHeight: INTEGER; update: BOOLEAN); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A91DH); CODE(RestoreA7);CODE(Return); END SizeWindow; PROCEDURE FrontWindow():WindowPtr; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A924H); CODE(RestoreA7);CODE(Return); END FrontWindow; PROCEDURE BringToFront(theWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A920H); CODE(RestoreA7);CODE(Return); END BringToFront; PROCEDURE SendBehind(theWindow:WindowPtr;behindWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A921H); CODE(RestoreA7);CODE(Return); END SendBehind; PROCEDURE HiliteWindow(theWindow:WindowPtr;onOrOff:BOOLEAN); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A91CH); CODE(RestoreA7);CODE(Return); END HiliteWindow; PROCEDURE DrawGrowIcon(theWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A904H); CODE(RestoreA7);CODE(Return); END DrawGrowIcon; PROCEDURE BeginUpdate(theWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A922H); CODE(RestoreA7);CODE(Return); END BeginUpdate; PROCEDURE EndUpdate(theWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A923H); CODE(RestoreA7);CODE(Return); END EndUpdate; PROCEDURE InvalRect(VAR badRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A928H); CODE(RestoreA7);CODE(Return); END InvalRect; PROCEDURE InvalRgn(badRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A927H); CODE(RestoreA7);CODE(Return); END InvalRgn; PROCEDURE ValidRect(VAR goodRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A92AH); CODE(RestoreA7);CODE(Return); END ValidRect; PROCEDURE ValidRgn(goodRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A929H); CODE(RestoreA7);CODE(Return); END ValidRgn; PROCEDURE SetWindowPic (theWindow:WindowPtr;thePicture:PicHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A92EH); CODE(RestoreA7);CODE(Return); END SetWindowPic; PROCEDURE GetWindowPic(theWindow:WindowPtr):PicHandle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A92FH); CODE(RestoreA7);CODE(Return); END GetWindowPic; PROCEDURE xFindWindow(mousePoint:LONGINT;VAR theWindow:WindowPtr):INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A92CH); CODE(RestoreA7);CODE(Return); END xFindWindow; PROCEDURE FindWindow (mousePoint:Point;VAR theWindow:WindowPtr):INTEGER; (*$P+*)(*$S-*) BEGIN RETURN(xFindWindow(mousePoint.param,theWindow)) END FindWindow; PROCEDURE SelectWindow(theWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A91FH); CODE(RestoreA7);CODE(Return); END SelectWindow; PROCEDURE xDragWindow (theWindow:WindowPtr; startPoint:LONGINT; VAR LimitRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A925H); CODE(RestoreA7);CODE(Return); END xDragWindow; PROCEDURE DragWindow (theWindow:WindowPtr; startPoint:Point; LimitRect:Rect); (*$P+*)(*$S-*) BEGIN xDragWindow(theWindow,startPoint.param,LimitRect) END DragWindow; PROCEDURE xGrowWindow (theWindow: WindowPtr; startPoint: LONGINT; VAR sizeRect: Rect):LONGINT; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A92BH); CODE(RestoreA7);CODE(Return); END xGrowWindow; PROCEDURE GrowWindow (theWindow: WindowPtr; startPoint: Point; sizeRect: Rect):LONGINT; (*$P+*)(*$S-*) BEGIN RETURN(xGrowWindow(theWindow,startPoint.param,sizeRect)) END GrowWindow; PROCEDURE xTrackGoAway(wind:WindowPtr;start:LONGINT):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A91EH); CODE(RestoreA7);CODE(Return); END xTrackGoAway; PROCEDURE TrackGoAway(wind:WindowPtr;start:Point):BOOLEAN; (*$P+*)(*$S-*) BEGIN RETURN(xTrackGoAway(wind,start.param)) END TrackGoAway; PROCEDURE GetWMgrPort(VAR wMgrPort:GrafPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A910H); CODE(RestoreA7);CODE(Return); END GetWMgrPort; BEGIN InitWindows END WindowManager. !Funky!Stuff! # The rest of this file is a shell script which will extract: # Terminal.MOD TextEdit.MOD Toolbox.MOD WindowManager.MOD echo x - Terminal.MOD cat >Terminal.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE Terminal; (* A.Wespisser, 20-NOV-84 * J.Wyttenbach 11-jan-85 * B.Campbell 29-Dec-85 * * NOTE: - The procedures "KeyPress" and "GotoXY" and "ClearTerminal" are not * contained in module "Terminal" on SMAKY8. * - "BusyRead", "ReadString", "KeyPress" and "GotoXY" and "ClearTerminal" * are not required by the compiler itself. *) FROM SYSTEM IMPORT ADR; FROM MacSYSTEM IMPORT LONGINT; FROM QuickDraw IMPORT Rect,Point,screenBits,thePort,GrafPtr,GrafPort, SetRect,SetPort,GetPort,EraseRect,RgnHandle,DrawChar, ScrollRect,MoveTo,SetOrigin,GetPen; FROM Regions IMPORT NewRgn,DisposeRgn; FROM WindowManager IMPORT WindowRecord,WindowPtr,SelectWindow, BeginUpdate,EndUpdate,FrontWindow,inMenuBar,inSysWindow, inDrag,inContent,NewWindow,noGrowDocProc; FROM FontManager IMPORT FontInfo,GetFontInfo; FROM EventManager IMPORT FlushEvents,everyEvent,GetNextEvent,EventRecord, mouseDown,keyDown,autoKey,activateEvt,updateEvt, activMask,charCodeMask,shiftKey,EventAvail,keyDownMask,autoKeyMask; CONST etx = 03C; bs = 10C; ht = 11C; eoln = 12C; cr = 15C; VAR Font:FontInfo; myWindow:WindowPtr; wRecord:WindowRecord; Width,Height:INTEGER; FontHeight:INTEGER; PROCEDURE DoWriteLn; VAR P:Point; theUpdateRgn:RgnHandle; BEGIN GetPen(P); P.h := 0; P.v := P.v + FontHeight; IF (P.v >= Height) THEN theUpdateRgn := NewRgn(); ScrollRect(myWindow^.portRect,0,-FontHeight,theUpdateRgn); DisposeRgn (theUpdateRgn); P.v := P.v - FontHeight END (*IF*); MoveTo(P.h,P.v); END DoWriteLn; PROCEDURE DoWrite(ch:CHAR); VAR P:Point; BEGIN IF (ch >= ' ') THEN DrawChar(ch); GetPen(P); IF ((P.h + Font.widMax) >= Width) THEN DoWriteLn END ELSIF (ch = eoln) THEN DoWriteLn; ELSIF (ch = cr) THEN MoveTo(0,P.v) ELSIF (ch = ht) THEN (* TAB *) DrawChar(' ') (* oh well this is easy *) END (*IF*) END DoWrite; PROCEDURE Write (ch: CHAR); VAR OldPort : GrafPtr; P : Point; BEGIN GetPort(OldPort); SetPort(myWindow); DoWrite(ch); SetPort(OldPort); END Write; PROCEDURE WriteString(VAR s:ARRAY OF CHAR); VAR I:CARDINAL; OldPort:GrafPtr; BEGIN GetPort(OldPort); SetPort(myWindow); I := 0; WHILE ((I <= HIGH(s)) AND (s[I] # 0C)) DO DoWrite(s[I]); INC(I) END (* FOR *); SetPort(OldPort); END WriteString; PROCEDURE WriteLn; (*terminate line*) VAR I:INTEGER; OldPort:GrafPtr; BEGIN GetPort(OldPort); SetPort(myWindow); DoWriteLn; SetPort(OldPort); END WriteLn; VAR LastChar : CHAR; RepeatChar : BOOLEAN; PROCEDURE DoRead(VAR ch:CHAR); VAR Event : EventRecord; BEGIN IF (RepeatChar) THEN RepeatChar := FALSE; ELSE WHILE (NOT GetNextEvent(keyDownMask+autoKeyMask,Event)) DO END; LastChar := Event.CharacterCode; END; ch := LastChar END DoRead; PROCEDURE Read(VAR ch:CHAR); BEGIN DoRead(ch); Write(ch) END Read; PROCEDURE ReadString(VAR S : ARRAY OF CHAR); VAR i : CARDINAL; BEGIN i := 0; (* Assert HIGH(S) >= 0 *) LOOP DoRead(S[i]); IF (S[i] < ' ') THEN IF (S[i] = bs) AND (i > 0) THEN Write('\'); Write(S[i]); DEC(i) ELSIF (S[i] # ht) THEN WriteLn; EXIT END ELSE Write(S[i]); IF (i < HIGH(S)) THEN INC(i) END; IF (i = HIGH(S)) THEN WriteLn; EXIT END; END END; IF (i < HIGH(S)) OR (S[i] < ' ') THEN S[i] := 0C (* Null Terminated *) END END ReadString; PROCEDURE ReadLn (VAR S:ARRAY OF CHAR); VAR i : CARDINAL; c : CHAR; BEGIN i := 0; LOOP DoRead(c); IF (c < ' ') THEN IF (c = bs) AND (i > 0) THEN Write('\'); Write(c); DEC(i) ELSIF (c = cr) OR (c = eoln) OR (c = etx) THEN IF (i <= HIGH(S)) THEN S[i] := 0C END; WriteLn; EXIT END ELSE Write(c); IF (i <= HIGH(S)) THEN S[i] := c; INC(i) END; END END; END ReadLn; PROCEDURE BusyRead(VAR ch:CHAR); BEGIN IF KeyPress() THEN DoRead(ch) ELSE ch := 0C END END BusyRead; PROCEDURE ReadAgain; (* causes the last character read to be returned again * upon the next call of Read *) BEGIN RepeatChar := TRUE END ReadAgain; PROCEDURE KeyPress():BOOLEAN; VAR Event : EventRecord; BEGIN RETURN(EventAvail(keyDownMask,Event)) END KeyPress; PROCEDURE GotoXY(C,R:CARDINAL); (* Move to column x, row y *) VAR OldPort:GrafPtr; X,Y:INTEGER; BEGIN WITH Font DO X := INTEGER(C) * widMax; Y := INTEGER(R) * FontHeight END; GetPort(OldPort); SetPort(myWindow); MoveTo(X,Y); SetPort(OldPort); END GotoXY; PROCEDURE ClearTerminal; VAR OldPort:GrafPtr; BEGIN GetPort(OldPort); SetPort(myWindow); EraseRect(myWindow^.portRect); MoveTo(0,0); SetPort(OldPort); END ClearTerminal; PROCEDURE InitTerminal; VAR WindowRect : Rect; BEGIN RepeatChar := FALSE; FlushEvents(everyEvent,0); WITH screenBits.bounds DO SetRect(WindowRect,4,40,right-4,bottom-4) END; myWindow := NewWindow(ADR(wRecord),WindowRect,'Terminal', TRUE,noGrowDocProc,WindowPtr(-1),FALSE,4); GetFontInfo(Font); WITH Font DO FontHeight := ascent + descent + leading END; SetPort(myWindow); WITH myWindow^.portRect DO Width := (right - left) - 3; Height:= (bottom - top) - (FontHeight + 3) END; SetOrigin(-2,-(2 + Font.ascent)); END InitTerminal; BEGIN InitTerminal END Terminal. !Funky!Stuff! echo x - TextEdit.MOD cat >TextEdit.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE TextEdit; FROM SYSTEM IMPORT ADDRESS,ADR,CODE; FROM MacSYSTEM IMPORT Handle,LONGINT,OSErr; FROM QuickDraw IMPORT Style,Rect,Point,GrafPtr; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) PROCEDURE TENew(VAR destRect,viewRect:Rect):TEHandle; (* VAR is for Modula is really by value *) (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9D2H); CODE(RestoreA7); CODE(Return); END TENew; PROCEDURE TEDispose(hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9CDH); CODE(RestoreA7); CODE(Return); END TEDispose; (* Accessing the Text of an Edit Record *) PROCEDURE TESetText (text:ADDRESS;length:LONGINT;hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9CFH); CODE(RestoreA7); CODE(Return); END TESetText; PROCEDURE TEGetText (hTE: TEHandle):CharsHandle; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9CBH); CODE(RestoreA7); CODE(Return); END TEGetText; (*Insertion Point and Selection Range*) PROCEDURE TEIdle (hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9DAH); CODE(RestoreA7); CODE(Return); END TEIdle; PROCEDURE xTEClick (pt:LONGINT;extend:BOOLEAN;hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9D4H); CODE(RestoreA7); CODE(Return); END xTEClick; PROCEDURE TEClick (pt:Point;extend:BOOLEAN;hTE:TEHandle); (*$P+*)(*$S-*) BEGIN xTEClick(pt.param,extend,hTE); END TEClick; PROCEDURE TESetSelect (selStart,selEnd: LONGINT; hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9D1H); CODE(RestoreA7); CODE(Return); END TESetSelect; PROCEDURE TEActivate (hTE: TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9D8H); CODE(RestoreA7); CODE(Return); END TEActivate; PROCEDURE TEDeactivate (hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9D9H); CODE(RestoreA7); CODE(Return); END TEDeactivate; (* Editing *) PROCEDURE xTEKey (key:CARDINAL;hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9DCH); CODE(RestoreA7); CODE(Return); END xTEKey; PROCEDURE TEKey (key:CHAR;hTE:TEHandle); (*$P+*)(*$S-*) BEGIN xTEKey(ORD(key),hTE); END TEKey; PROCEDURE TECut (hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9D6H); CODE(RestoreA7); CODE(Return); END TECut; PROCEDURE TECopy (hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9D5H); CODE(RestoreA7); CODE(Return); END TECopy; PROCEDURE TEPaste (hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9DBH); CODE(RestoreA7); CODE(Return); END TEPaste; PROCEDURE TEDelete (hTE: TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9D7H); CODE(RestoreA7); CODE(Return); END TEDelete; PROCEDURE TEInsert (text:ADDRESS;length:LONGINT;hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9DEH); CODE(RestoreA7); CODE(Return); END TEInsert; (* Text Display and Scrolling *) PROCEDURE TESetJust (just:INTEGER;hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9DFH); CODE(RestoreA7); CODE(Return); END TESetJust; PROCEDURE TEUpdate (VAR rUpdate: Rect; hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9D3H); CODE(RestoreA7); CODE(Return); END TEUpdate; PROCEDURE TextBox (text:ADDRESS; length:LONGINT; VAR box:Rect; just:INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9CEH); CODE(RestoreA7); CODE(Return); END TextBox; PROCEDURE TEScroll (dh,dv:INTEGER;hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9DDH); CODE(RestoreA7); CODE(Return); END TEScroll; (* Scrap Handling *) PROCEDURE TEFromScrap():OSErr; (*$P+*) (* [Not in ROM] * VAR * pss : PScrapStuff; * (*$P+*) * BEGIN * pss := InfoScrap(); * TEScrpLength := pss.scrapSize; * TEScrpHandle := pss.scrapHandle; * END TEFromScrap; *) BEGIN END TEFromScrap; PROCEDURE TEToScrap():OSErr; (*$P+*) BEGIN END TEToScrap; PROCEDURE TEScrapHandle():Handle; (*$P+*) (*$S-*) BEGIN RETURN(TEScrpHandle) END TEScrapHandle; PROCEDURE TEGetScrapLen():LONGINT; (*$P+*) (*$S-*) BEGIN RETURN(TEScrpLength) END TEGetScrapLen; PROCEDURE TESetScrapLen(length:LONGINT); (*$P+*)(*$S-*) BEGIN TEScrpLength := length END TESetScrapLen; (* Advanced Routine *) PROCEDURE SetWordBreak(wBrkProc:ADDRESS; hTE:TEHandle); (*[Not in ROM]*) (*$P+*)(*$S-*) BEGIN END SetWordBreak; PROCEDURE SetClikLoop(clikProc:ADDRESS; hTE:TEHandle); (*$P+*)(*$S-*) BEGIN END SetClikLoop; PROCEDURE TECalText (hTE:TEHandle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9D0H); CODE(RestoreA7); CODE(Return); END TECalText; BEGIN CODE(0A9CCH) END TextEdit. !Funky!Stuff! echo x - Toolbox.MOD cat >Toolbox.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE Toolbox; FROM SYSTEM IMPORT ADDRESS,CODE,ADR; FROM MacSYSTEM IMPORT Fixed,Int64Bit,LONGINT,StringHandle,Handle; FROM QuickDraw IMPORT Pattern,Point,Rect; FROM PascalStrings IMPORT MakePascalString; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) PROCEDURE FixRatio(numer,denom:INTEGER):Fixed; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A869H); CODE(RestoreA7); CODE(Return); END FixRatio; PROCEDURE FixMul(a,b:Fixed):Fixed; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A868H); CODE(RestoreA7); CODE(Return); END FixMul; PROCEDURE FixRound(x:Fixed):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A86CH); CODE(RestoreA7); CODE(Return); END FixRound; (*String*) PROCEDURE xNewString(theString:ADDRESS):StringHandle; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A906H); CODE(RestoreA7); CODE(Return); END xNewString; PROCEDURE NewString(VAR theString:ARRAY OF CHAR):StringHandle; (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(theString,Str); RETURN(xNewString(ADR(Str))) END NewString; PROCEDURE xSetString(h:StringHandle;theString:ADDRESS); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A907H); CODE(RestoreA7); CODE(Return); END xSetString; PROCEDURE SetString(h:StringHandle;VAR theString:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR Str:ARRAY [0..255] OF CHAR; BEGIN MakePascalString(theString,Str); xSetString(h,ADR(Str)) END SetString; PROCEDURE GetString(StringID:INTEGER):StringHandle; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9BAH); CODE(RestoreA7); CODE(Return); END GetString; PROCEDURE GetIndString(VAR theString:ARRAY OF CHAR;strListID:INTEGER; index:INTEGER); (* no trap macro *) (*$P+*)(*$S-*) BEGIN END GetIndString; (*byte manipulation*) PROCEDURE Munger(h:Handle;offset:LONGINT;ptrl:ADDRESS;len1:LONGINT; ptr2:ADDRESS;len2:LONGINT):LONGINT; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9E0H); CODE(RestoreA7); CODE(Return); END Munger; PROCEDURE PackBits(VAR srcPtr,dstPtr:ADDRESS; srcBytes:INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A8CFH); CODE(RestoreA7); CODE(Return); END PackBits; PROCEDURE UnpackBits(VAR srcPtr,dstPtr:ADDRESS; dstBytes:INTEGER); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A8D0H); CODE(RestoreA7); CODE(Return); END UnpackBits; (*bit Manipulation*) PROCEDURE BitTst(bytePtr:ADDRESS;bitNum:LONGINT):BOOLEAN; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A85DH); CODE(RestoreA7); CODE(Return); END BitTst; PROCEDURE BitSet(bytePtr:ADDRESS;bitNum:LONGINT); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A85EH); CODE(RestoreA7); CODE(Return); END BitSet; PROCEDURE BitClr(bytePtr:ADDRESS;bitNum:LONGINT); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A85FH); CODE(RestoreA7); CODE(Return); END BitClr; (*Logical Operations*) PROCEDURE BitAnd(val1,val2:LONGINT):LONGINT; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A858H); CODE(RestoreA7); CODE(Return); END BitAnd; PROCEDURE BitOr (val1,val2:LONGINT):LONGINT; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A85BH); CODE(RestoreA7); CODE(Return); END BitOr; PROCEDURE BitXor(val1,val2:LONGINT):LONGINT; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A859H); CODE(RestoreA7); CODE(Return); END BitXor; PROCEDURE BitNot(val:LONGINT):LONGINT; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A85AH); CODE(RestoreA7); CODE(Return); END BitNot; PROCEDURE BitShift(value:LONGINT;count:INTEGER):LONGINT; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A85CH); CODE(RestoreA7); CODE(Return); END BitShift; (*Other Operations on Long Integers*) PROCEDURE HiWord(x:LONGINT):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A86AH); CODE(RestoreA7); CODE(Return); END HiWord; PROCEDURE LoWord(x:LONGINT):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A86BH); CODE(RestoreA7); CODE(Return); END LoWord; PROCEDURE LongMul(a,b:LONGINT;VAR dest:Int64Bit); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A867H); CODE(RestoreA7); CODE(Return); END LongMul; (* Graphics Utilities *) PROCEDURE ScreenRes(VAR scrnHRes,scrnVRes:INTEGER); (*$P+*)(*$S-*) BEGIN scrnHRes := ScrHRes; scrnVRes := ScrVRes END ScreenRes; PROCEDURE GetIcon(iconID:INTEGER):Handle; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9BBH); CODE(RestoreA7); CODE(Return); END GetIcon; PROCEDURE PlotIcon(theRect:Rect;theIcon:Handle); (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A94BH); CODE(RestoreA7); CODE(Return); END PlotIcon; PROCEDURE GetPattern(patID:INTEGER):PatHandle; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A9B8H); CODE(RestoreA7); CODE(Return); END GetPattern; PROCEDURE GetIndPattern(VAR thePattern:Pattern;patListID:INTEGER; index:INTEGER); (* no trap macro *) (*$P+*)(*$S-*) BEGIN END GetIndPattern; (* Miscellaneous Utilities *) PROCEDURE Random():INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A861H); CODE(RestoreA7);CODE(Return); END Random; PROCEDURE xStuffHex (thingPtr:ADDRESS;s:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A866H); CODE(RestoreA7);CODE(Return); END xStuffHex; PROCEDURE StuffHex (thingPtr:ADDRESS;VAR s:ARRAY OF CHAR); (*$P+*)(*$S-*) VAR s1:ARRAY[0..255] OF CHAR; BEGIN MakePascalString(s,s1); xStuffHex(thingPtr,ADR(s1)) END StuffHex; PROCEDURE xDeltaPoint(ptA,ptB:LONGINT):LONGINT; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A94FH); CODE(RestoreA7); CODE(Return); END xDeltaPoint; PROCEDURE DeltaPoint(ptA,ptB:Point):LONGINT; (*$P+*)(*$S-*) BEGIN RETURN(xDeltaPoint(ptA.param,ptB.param)) END DeltaPoint; PROCEDURE SlopeFromAngle(angle:INTEGER):Fixed; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A8BCH); CODE(RestoreA7); CODE(Return); END SlopeFromAngle; PROCEDURE AngleFromSlope(slope:Fixed):INTEGER; (*$P-*) BEGIN CODE(GetRet); CODE(SaveA7); CODE(0A8C4H); CODE(RestoreA7); CODE(Return); END AngleFromSlope; END Toolbox. !Funky!Stuff! echo x - WindowManager.MOD cat >WindowManager.MOD <<'!Funky!Stuff!' IMPLEMENTATION MODULE WindowManager; FROM SYSTEM IMPORT ADDRESS,WORD,CODE,ADR,REGISTER; FROM MacSYSTEM IMPORT LONGINT; FROM FontManager IMPORT FontInfo; (* Init Font Manager *) FROM QuickDraw IMPORT GrafPort,GrafPtr,Point,VHSelect, Rect,RgnHandle; FROM Pictures IMPORT PicHandle; FROM EventManager IMPORT EventRecord; FROM PascalStrings IMPORT MakePascalString,MakeModulaString; CONST GetRet = 0285FH; (* MOVEA (A7)+,A4 *) Return = 04ED4H; (* JMP A4 *) SaveA7 = 0264FH; (* MOVEA A7,A3 *) RestoreA7 = 02E4BH; (* MOVEA A3,A7 *) PROCEDURE InitWindows; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A912H); CODE(RestoreA7);CODE(Return); END InitWindows; PROCEDURE xNewWindow(wStorage:ADDRESS;VAR windowRect:Rect; title:ADDRESS;visible:BOOLEAN;windowType:INTEGER; behindWindow:WindowPtr;hasClose:BOOLEAN; refCon:LONGINT):WindowPtr; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A913H); CODE(RestoreA7);CODE(Return); END xNewWindow; PROCEDURE NewWindow(wStorage:ADDRESS;VAR windowRect:Rect; VAR title:ARRAY OF CHAR;visible:BOOLEAN;windowType:INTEGER; behindWindow:WindowPtr;hasClose:BOOLEAN; refCon:LONGINT):WindowPtr; VAR s1:ARRAY [0..255] OF CHAR; (*$P+*)(*$S-*) BEGIN MakePascalString(title,s1); RETURN(xNewWindow(wStorage,windowRect,ADR(s1),visible, windowType,behindWindow,hasClose,refCon)) END NewWindow; PROCEDURE GetNewWindow(templateID:INTEGER; wStorage:ADDRESS;behindWindow:WindowPtr):WindowPtr; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A9BDH); CODE(RestoreA7);CODE(Return); END GetNewWindow; PROCEDURE CloseWindow(theWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A92DH); CODE(RestoreA7);CODE(Return); END CloseWindow; PROCEDURE DisposeWindow(theWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A914H); CODE(RestoreA7);CODE(Return); END DisposeWindow; PROCEDURE xSetWTitle(theWindow:WindowPtr;newTitle:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A91AH); CODE(RestoreA7);CODE(Return); END xSetWTitle; PROCEDURE SetWTitle(theWindow:WindowPtr;VAR newTitle:ARRAY OF CHAR); VAR s1:ARRAY [0..255] OF CHAR; (*$P+*)(*$S-*) BEGIN MakePascalString(newTitle,s1); xSetWTitle(theWindow,ADR(s1)); END SetWTitle; PROCEDURE xGetWTitle(theWindow:WindowPtr;theTitle:ADDRESS); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A919H); CODE(RestoreA7);CODE(Return); END xGetWTitle; PROCEDURE GetWTitle(theWindow:WindowPtr;VAR theTitle:ARRAY OF CHAR); VAR s1:ARRAY [0..255] OF CHAR; (*$P+*)(*$S-*) BEGIN xGetWTitle(theWindow,ADR(s1)); MakeModulaString(s1,theTitle); END GetWTitle; PROCEDURE SetWRefCon(theWindow:WindowPtr;newRefCon:LONGINT); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A918H); CODE(RestoreA7);CODE(Return); END SetWRefCon; PROCEDURE GetWRefCon(theWindow:WindowPtr):LONGINT; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A917H); CODE(RestoreA7);CODE(Return); END GetWRefCon; PROCEDURE HideWindow(theWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A916H); CODE(RestoreA7);CODE(Return); END HideWindow; PROCEDURE ShowWindow(theWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A915H); CODE(RestoreA7);CODE(Return); END ShowWindow; PROCEDURE ShowHide(theWindow:WindowPtr;showFlag:BOOLEAN); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A908H); CODE(RestoreA7);CODE(Return); END ShowHide; PROCEDURE MoveWindow(theWindow: WindowPtr; hGlobal,vGlobal: INTEGER; active: BOOLEAN); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A91BH); CODE(RestoreA7);CODE(Return); END MoveWindow; PROCEDURE SizeWindow (theWindow: WindowPtr; newWidth,newHeight: INTEGER; update: BOOLEAN); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A91DH); CODE(RestoreA7);CODE(Return); END SizeWindow; PROCEDURE FrontWindow():WindowPtr; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A924H); CODE(RestoreA7);CODE(Return); END FrontWindow; PROCEDURE BringToFront(theWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A920H); CODE(RestoreA7);CODE(Return); END BringToFront; PROCEDURE SendBehind(theWindow:WindowPtr;behindWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A921H); CODE(RestoreA7);CODE(Return); END SendBehind; PROCEDURE HiliteWindow(theWindow:WindowPtr;onOrOff:BOOLEAN); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A91CH); CODE(RestoreA7);CODE(Return); END HiliteWindow; PROCEDURE DrawGrowIcon(theWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A904H); CODE(RestoreA7);CODE(Return); END DrawGrowIcon; PROCEDURE BeginUpdate(theWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A922H); CODE(RestoreA7);CODE(Return); END BeginUpdate; PROCEDURE EndUpdate(theWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A923H); CODE(RestoreA7);CODE(Return); END EndUpdate; PROCEDURE InvalRect(VAR badRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A928H); CODE(RestoreA7);CODE(Return); END InvalRect; PROCEDURE InvalRgn(badRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A927H); CODE(RestoreA7);CODE(Return); END InvalRgn; PROCEDURE ValidRect(VAR goodRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A92AH); CODE(RestoreA7);CODE(Return); END ValidRect; PROCEDURE ValidRgn(goodRegion:RgnHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A929H); CODE(RestoreA7);CODE(Return); END ValidRgn; PROCEDURE SetWindowPic (theWindow:WindowPtr;thePicture:PicHandle); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A92EH); CODE(RestoreA7);CODE(Return); END SetWindowPic; PROCEDURE GetWindowPic(theWindow:WindowPtr):PicHandle; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A92FH); CODE(RestoreA7);CODE(Return); END GetWindowPic; PROCEDURE xFindWindow(mousePoint:LONGINT;VAR theWindow:WindowPtr):INTEGER; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A92CH); CODE(RestoreA7);CODE(Return); END xFindWindow; PROCEDURE FindWindow (mousePoint:Point;VAR theWindow:WindowPtr):INTEGER; (*$P+*)(*$S-*) BEGIN RETURN(xFindWindow(mousePoint.param,theWindow)) END FindWindow; PROCEDURE SelectWindow(theWindow:WindowPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A91FH); CODE(RestoreA7);CODE(Return); END SelectWindow; PROCEDURE xDragWindow (theWindow:WindowPtr; startPoint:LONGINT; VAR LimitRect:Rect); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A925H); CODE(RestoreA7);CODE(Return); END xDragWindow; PROCEDURE DragWindow (theWindow:WindowPtr; startPoint:Point; LimitRect:Rect); (*$P+*)(*$S-*) BEGIN xDragWindow(theWindow,startPoint.param,LimitRect) END DragWindow; PROCEDURE xGrowWindow (theWindow: WindowPtr; startPoint: LONGINT; VAR sizeRect: Rect):LONGINT; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A92BH); CODE(RestoreA7);CODE(Return); END xGrowWindow; PROCEDURE GrowWindow (theWindow: WindowPtr; startPoint: Point; sizeRect: Rect):LONGINT; (*$P+*)(*$S-*) BEGIN RETURN(xGrowWindow(theWindow,startPoint.param,sizeRect)) END GrowWindow; PROCEDURE xTrackGoAway(wind:WindowPtr;start:LONGINT):BOOLEAN; (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A91EH); CODE(RestoreA7);CODE(Return); END xTrackGoAway; PROCEDURE TrackGoAway(wind:WindowPtr;start:Point):BOOLEAN; (*$P+*)(*$S-*) BEGIN RETURN(xTrackGoAway(wind,start.param)) END TrackGoAway; PROCEDURE GetWMgrPort(VAR wMgrPort:GrafPtr); (*$P-*) BEGIN CODE(GetRet);CODE(SaveA7); CODE(0A910H); CODE(RestoreA7);CODE(Return); END GetWMgrPort; BEGIN InitWindows END WindowManager. !Funky!Stuff!
bobc@tikal.UUCP (Bob Campbell) (05/16/86)
Once again I have messed up my posting. Each of the source ended up being includes three times (All my had work to insure that each file would be less then 32K is loss, and in fact if I had used postnews instead of Pnews it would have notified me and I could have found the problem much sooner). Now I don't know what to do: 1) Cancel the articles (The have been gone upto three days would it do any good) and repost now that I have fixed the problem. 2) Repost the articles without canceling the previous articles. (would cause increased traffic for those parts of the net for which the cancel could catch up to the original). 3) Do nothing and send those people who's news gets truncated by notes (or what ever it is called) a corrected version. 4) Drop the whole thing as the rumor mill says that something better will be out within one month. I vote for 3 for now as it allows me to do some research into #4, and also if I wait a while I can have TRANSFER, and NEWPROCESS implemented before I do a repost. Bob Campbell Teltone Corp. P.O Box 657 Kirkland, WA 98033 (206) 827-9626 X577 {dataio,fluke,uw-beaver}!tikal
rec@mplvax.UUCP (05/19/86)
In article <442@tikal.UUCP> bobc@tikal.UUCP (Bob Campbell) writes: > >4) Drop the whole thing as the rumor mill says that something better > will be out within one month. > Please do 4). The net is breaking from volume and this will give those who would like to do away with the mac groups good reason to kill them. -- richard currier marine physical lab u.c. san diego {ihnp4|decvax|akgua|dcdwest|ucbvax} !sdcsvax!mplvax!rec