shebanow@ernie.BERKELEY.EDU (Mike Shebanow) (11/28/85)
(beware the line eater) =========================PrLinkage.Asm============================== ; ; PrLinkage.asm Andrew G. Shebanow 9/24/85 ; ; C linkage to printing routines. Designed to interface ; to APPLE's (not Consulair's) PrLink.REL (as distributed with ; the software supplement) ; ; Portions of this code are Copyright 1984 Consulair Corp ; ; external routines: XREF PrOpen XREF PrClose XREF PrintDefault XREF PrValidate XREF PrStlDialog XREF PrJobDialog XREF PrJobMerge XREF PrOpenDoc XREF PrOpenPage XREF PrClosePage XREF PrCloseDoc XREF PrPicFile XREF PrError XREF PrSetError XREF PrDrvrOpen XREF PrDrvrClose XREF PrCtlCall ; XREF PrDrvrDCE ; XREF PrDrvrVers ; defined here: XDEF CPrOpen XDEF CPrClose XDEF CPrValidate XDEF CPrintDefault XDEF CPrStlDialog XDEF CPrJobDialog XDEF CPrJobMerge XDEF CPrOpenDoc XDEF CPrOpenPage XDEF CPrClosePage XDEF CPrCloseDoc XDEF CPrPicFile XDEF CPrError XDEF CPrSetError XDEF CPrDrvrOpen XDEF CPrDrvrClose XDEF CPrCtlCall ; XDEF CPrDrvrDCE ; XDEF CPrDrvrVers ; VOID CPrOpen() CPrOpen JSR PrOpen RTS ; VOID CPrOpen() CPrClose JSR PrClose RTS ; VOID CPrintDefault(hPrint) ; THPrint hPrint; (D0.L) CPrintDefault MOVE.L D0,-(SP) JSR PrintDefault RTS ; BYTE CPrValidate(hPrint) ; THPrint hPrint; (D0.L) CPrValidate CLR.B -(SP) MOVE.L D0,-(SP) JSR PrValidate MOVE.B (SP)+,D0 RTS ; BYTE CPrStlDialog(hPrint) ; THPrint hPrint; (D0.L) CPrStlDialog CLR.B -(SP) MOVE.L D0,-(SP) JSR PrStlDialog MOVE.B (SP)+,D0 RTS ; BYTE CPrJobDialog(hPrint) ; THPrint hPrint; (D0.L) CPrJobDialog CLR.B -(SP) MOVE.L D0,-(SP) JSR PrJobDialog MOVE.B (SP)+,D0 RTS ; VOID CPrJobMerge(hPrintSrc,hPrintDst) ; THPrint hPrintSrc; (D0.L) ; THPrint hPrintDst; (D1.L) CPrJobMerge MOVE.L D0,-(SP) MOVE.L D1,-(SP) JSR PrJobMerge RTS ; TPPrPort CPrOpenDoc(hPrint,pPrPort,pIOBuf) ; THPrint hPrint; (D0.L) ; TPPrPort pPrPort; (D1.L) ; Ptr pIOBuf; (D2.L) CPrOpenDoc CLR.L -(SP) MOVE.L D0,-(SP) MOVE.L D1,-(SP) MOVE.L D2,-(SP) JSR PrOpenDoc MOVE.L (SP)+,A0 RTS ; VOID CPrOpenPage(pPrPort,pPageFrame) ; TPPrPort pPrPort; (D0.L) ; Rect *pPageFrame; (D1.L) CPrOpenPage MOVE.L D0,-(SP) MOVE.L D1,-(SP) JSR PrOpenPage RTS ; VOID CPrClosePage(pPrPort) ; TPPrPort pPrPort; (D0.L) CPrClosePage MOVE.L D0,-(SP) JSR PrClosePage RTS ; VOID CPrCloseDoc(pPrPort) ; TPPrPort pPrPort; (D0.L) CPrCloseDoc MOVE.L D0,-(SP) JSR PrCloseDoc RTS ; VOID CPrPicFile(hPrint,pPrPort,pIOBuf,pDevBuf,status) ; THPrint hPrint; (D0.L) ; TPPrPort pPrPort; (D1.L) ; Ptr pIOBuf; (D2.L) ; Ptr pDevBuf; (D3.L) ; TPrStatus *status; (D4.L) CPrPicFile MOVE.L D0,-(SP) MOVE.L D1,-(SP) MOVE.L D2,-(SP) MOVE.L D3,-(SP) MOVE.L D4,-(SP) JSR PrPicFile RTS ; WORD CPrError() CPrError CLR.W -(SP) JSR PrError MOVE.W (SP)+,D0 RTS ; VOID CPrSetError(iErr) ; WORD iErr; (DO.W) CPrSetError MOVE.W D0,-(SP) JSR PrSetError RTS ; VOID CPrDrvrOpen() CPrDrvrOpen JSR PrDrvrOpen RTS ; VOID CPrDrvrClose() CPrDrvrClose JSR PrDrvrClose RTS ; VOID PrCtlCall(iWhichCtl,lParam1,lParam2,lParam3) ; WORD iWhichCtl; (D0.L) ; LONG lParam1; (D1.L) ; LONG lParam2; (D2.L) ; LONG lParam3; (D3.L) CPrCtlCall MOVE.W D0,-(SP) MOVE.L D1,-(SP) MOVE.L D2,-(SP) MOVE.L D3,-(SP) JSR PrCtlCall RTS ; Handle CPrDrvrDCE() ;CPrDrvrDCE ; CLR.L -(SP) ; JSR PrDrvrDCE ; MOVE.L (SP)+,A0 ; RTS ; WORD CPrDrvrVers() ;CPrDrvrVers ; CLR.W -(SP) ; JSR PrDrvrVers ; MOVE.W (SP)+,D0 ; RTS END =========================FileMgr.Asm============================== ;------------------------------------------------------------------------------ ; FileManager.ASM ;------------------------------------------------------------------------------ ; Emulation of Lisa Pascal interface for high-level file ; manager routines. ; ; Russ Wetmore for Star Systems Software, Inc. ; ; Version 2.3 29 September 1985 ; ; Added the three Queue related [ Pascal Only ] calls from Inside ; Mac. Changed self-modifying code. Added module declarations for ; MacC 4.0. Hacked up comments, to reduce disk space (Lets hear ; it for floppies!) ; Andrew Shebanow of Hypersoft ;------------------------------------------------------------------------------ ; NOTE: This code has some problems still, but only minor ones. ; For instance, since the program allocates data off A5, it is unusable ; with desk accessories. (does anyone care?). Also, HFS compatibility ; is still a question mark. ;------------------------------------------------------------------------------ ; the MacC include file M68KLIB.D requires these EQU statements ; for floating point compilers (version 2.x and 4.0) usefloat equ 0 usebitfields equ 0 ;------------------------------------------------------------------------------ ; Include support files ;------------------------------------------------------------------------------ Include SysEqu.D ; I need system equates Include MacTraps.D ; I need (want) trap macros Include FSEqu.D ; Need File Manager Equates Include M68KLIB.D ; (Consulair C macros) ;------------------------------------------------------------------------------ ; Global variables ;------------------------------------------------------------------------------ XDEF paramBlock .ALIGN 2 paramBlock ds.L 20,0 ;Globally accessable parameter block ;------------------------------------------------------------------------------ ; Support subroutines ;------------------------------------------------------------------------------ ; Clear parameter block to zeroes XDEF clearPB clearPB move #20-1,D6 ;max size of ioParam/FileParam/VolumeParam (in longs) lea paramBlock(A5),A0 ;Fetch => to start of block @1 clr.L (A0)+ dbra D6,@1 rts ; Common subroutine to plug ioNamePtr and ioVRefNum fields ; (and sets up parameter block for trap call to boot) XDEF NameAndVref NameAndVref move.L D0,paramBlock+ioFileName(A5) move D1,paramBlock+ioVRefNum(A5) lea paramBlock(A5),A0 rts ; Common subroutine to return volume name to user from parameter block ; Assumes A1 points to user supplied Str255 struct XDEF retvolName retvolName move.L paramBlock+ioFileName(A5),A0 ; A1 already equals target address (volName) clr.L D0 move.B (A0),D0 ;fetch Pascal string length addq.L #1,D0 ;Plus 1 to offset for length byte _BlockMove rts ;------------------------------------------------------------------------------ ; OSErr GetVInfo(drvNum, volName, vRefNum, freeBytes) ; short drvNum; (D0.W) ; char *volName; (D1.L) ; short *vRefNum; (D2.L) ; long *freeBytes; (D3.L) ;------------------------------------------------------------------------------ Module 'GetVInfo' XDEF GetVInfo GetVInfo jsr clearPB ;clear out parameter block movem.L D1-D3,-(SP) ;save volName, vRefNum, freeBytes tst D0 ;drvNum given? bne.S @1 ;Yes ; drvNum = 0, so we use vRefNum to determine volume move.L D2,A2 ;Gotta go indirect move (A2),paramBlock+ioVRefNum(A5) bra.S @2 @1 ; if drvNum is negative, only use volName to determine volume bmi.S @2 ;Go if drvNum is negative ; drvNum is positive, so use it to determine volume move D0,paramBlock+ioVolIndex(A5) @2 ; In any case, stuff volName into parameter block move.L D1,paramBlock+ioFileName(A5) lea paramBlock(A5),A0 ;Set up trap call _GetVolInfo movem.L (SP)+,A1-A3 ;fetch saved params move D0,D4 ;Save returned error move.L A1,D0 ;Was volName supplied? beq.S @4 ;Nope, go on jsr retvolName @4 move paramBlock+ioVRefNum(A5),(A2) ;return volume reference number move.L paramBlock+ioVAlBlkSiz(A5),D0 ;freeBytes = size of alloc block move paramBlock+ioVFrBlk(A5),D1 ;...times number of free blocks ext.L D1 MULS.L D0,D1 ;(CONSULAIR MACRO) move.L D1,(A3) @3 move D4,D0 ;Fetch saved error code rts ;------------------------------------------------------------------------------ ; OSErr GetVol(volName, vRefNum) ; char *volName; (D0.L) ; short *vRefNum; (D1.L) ;------------------------------------------------------------------------------ Module 'GetVol' XDEF GetVol GetVol jsr clearPB movem.L D0-D1,-(SP) ;Save params lea paramBlock(A5),A0 ;Set up trap call _GetVol movem.L (SP)+,A1-A2 ;Fetch saved params move D0,D4 ;Save returned error move.L A1,D0 ;volName supplied? beq.S @1 ;Nope, go on jsr retvolName @1 move paramBlock+ioVRefNum(A5),(A2) ;return VRefNum move.l D4,D0 rts ;------------------------------------------------------------------------------ ; OSErr SetVol(volName, vRefNum) ; char *volName; (D0.L) ; short vRefNum; (D1.W) ;------------------------------------------------------------------------------ Module 'SetVol' XDEF SetVol SetVol jsr clearPB tst D1 ;vRefNum supplied? beq.S @1 ;Nope, go on ; if vRefNum is non-zero, use it to determine volume move D1,paramBlock+ioVRefNum(A5) bra.S @2 @1: ; else, use volName to determine volume move.L D0,paramBlock+ioFileName(A5) @2: lea paramBlock(A5),A0 _SetVol rts ;------------------------------------------------------------------------------ ; OSErr FlushVol(volName, vRefNum) ; char *volName; (D0.L) ; short vRefNum; (D1.W) ;------------------------------------------------------------------------------ Module 'FlushVol' XDEF FlushVol FlushVol move #$A013,D2 ; (_FlushVol) jsr clearPB tst D1 ;vRefNum supplied? beq.S @1 ;Nope, go on ; if vRefNum is non-zero, use it to determine volume move D1,paramBlock+ioVRefNum(A5) bra.S @2 @1: ; else, use volName to determine volume move.L D0,paramBlock+ioFileName(A5) @2: lea paramBlock(A5),A0 _FlushVol rts ;------------------------------------------------------------------------------ ; OSErr UnmountVol(volName, vRefNum) ; char *volName; (D0.L) ; short vRefNum; (D1.W) ;------------------------------------------------------------------------------ Module 'UnmountVol' XDEF UnmountVol UnmountVol jsr clearPB tst D1 ;vRefNum supplied? beq.S @1 ;Nope, go on ; if vRefNum is non-zero, use it to determine volume move D1,paramBlock+ioVRefNum(A5) bra.S @2 @1: ; else, use volName to determine volume move.L D0,paramBlock+ioFileName(A5) @2: lea paramBlock(A5),A0 _UnmountVol rts ;------------------------------------------------------------------------------ ; OSErr Eject(volName, vRefNum) ; char *volName; (D0.L) ; short vRefNum; (D1.W) ;------------------------------------------------------------------------------ Module 'Eject' XDEF Eject Eject jsr clearPB tst D1 ;vRefNum supplied? beq.S @1 ;Nope, go on ; if vRefNum is non-zero, use it to determine volume move D1,paramBlock+ioVRefNum(A5) bra.S @2 @1: ; else, use volName to determine volume move.L D0,paramBlock+ioFileName(A5) @2: lea paramBlock(A5),A0 _Eject rts ;------------------------------------------------------------------------------ ; OSErr Create(fileName, vRefNum, creator, fileType) ; Str255 *fileName; (D0.L) ; short vRefNum; (D1.W) ; OSType creator; (D2.L) ; OSType fileType; (D3.L) ;------------------------------------------------------------------------------ Module 'Create' XDEF Create Create: jsr clearPB movem.L D2-D3,-(SP) ;Save OSTypes jsr NameAndVref _Create movem.L (SP)+,D2-D3 ;Fetch saved OSTypes tst D0 ;Error occurred? bne.S @1 ;Yes, make like a tree and leaf move.L D2,D0 ;Test to see if either creator or.L D3,D0 ;...or fileType supplied beq.S @1 ;Nope, just exit quietly move.L D3,paramBlock+ioFlUsrWds(A5) ;Set creator move.L D2,paramBlock+ioFlUsrWds+4(A5) ;Set type lea paramBlock(A5),A0 _SetFileInfo @1: rts ;------------------------------------------------------------------------------ ; OSErr OpenRF(fileName, vRefNum, refNum) ; Str255 *fileName; (D0.L) ; short vRefNum; (D1.W) ; short *refNum; (D2.L) ;------------------------------------------------------------------------------ Module 'OpenRF' XDEF OpenRF OpenRF jsr clearPB move.L D2,A3 ;Save => to refNum jsr NameAndVref _OpenRF move paramBlock+ioRefNum(A5),(A3) ;Pass back refNum rts ;------------------------------------------------------------------------------ ; OSErr FSOpen(fileName, vRefNum, refNum) ; Str255 *fileName; (D0.L) ; short vRefNum; (D1.W) ; short *refNum; (D2.L) ;------------------------------------------------------------------------------ Module 'FSOpen' XDEF FSOpen FSOpen jsr clearPB move.L D2,A3 ;Save address of refNum jsr NameAndVref _Open move paramBlock+ioRefNum(A5),(A3) ;Pass back refNum rts ;------------------------------------------------------------------------------ ; OSErr FSRead(refNum, count, buffPtr) ; short refNum; (D0.W) ; long *count; (D1.L) ; char *buffPtr; (D2.L) ;------------------------------------------------------------------------------ Module 'FSRead' XDEF FSRead FSRead: jsr clearPB move.L D1,A3 ;Gotta go indirect to get to count move D0,paramBlock+ioRefNum(A5) ;Set up refNum move.L (A3),paramBlock+ioReqCount(A5) ;Set up count move.L D2,paramBlock+ioBuffer(A5) ;Set up buffPtr lea paramBlock(A5),A0 ;Set up trap call _Read move.L paramBlock+ioActCount(A5),(A3) ;Return count rts ;------------------------------------------------------------------------------ ; OSErr FSWrite(refNum, count, buffPtr) ; short refNum; (D0.W) ; long *count; (D1.L) ; char *buffPtr; (D2.L) ;------------------------------------------------------------------------------ Module 'FSWrite' XDEF FSWrite FSWrite: jsr clearPB move.L D1,A3 ;Gotta go indirect to get to count move D0,paramBlock+ioRefNum(A5) ;Set up refNum move.L (A3),paramBlock+ioReqCount(A5) ;Set up count move.L D2,paramBlock+ioBuffer(A5) ;Set up buffPtr lea paramBlock(A5),A0 ;Set up trap call _Write move.L paramBlock+ioActCount(A5),(A3) ;Return count rts ;------------------------------------------------------------------------------ ; OSErr GetFPos(refNum, filePos) ; short refNum; (D0.W) ; long *filePos; (D1.L) ;------------------------------------------------------------------------------ Module 'GetFPos' XDEF GetFPos GetFPos jsr clearPB move.L D1,A3 move D0,paramBlock+ioRefNum(A5) ;Set up refNum lea paramBlock(A5),A0 _GetFPos move.L paramBlock+ioPosOffset(A5),(A3) ;Return filePos rts ;------------------------------------------------------------------------------ ; OSErr SetFPos(refNum, posMode, posOff) ; short refNum; (D0.W) ; short posMode; (D1.W) ; long posOff; (D2.L) ;------------------------------------------------------------------------------ Module 'SetFPos' XDEF SetFPos SetFPos jsr clearPB move D0,paramBlock+ioRefNum(A5) move D1,paramBlock+ioPosMode(A5) move.L D2,paramBlock+ioPosOffset(A5) lea paramBlock(A5),A0 _SetFPos rts ;------------------------------------------------------------------------------ ; OSErr GetEOF(refNum, logEOF) ; short refNum; (D0.W) ; long *logEOF; (D1.L) ;------------------------------------------------------------------------------ Module 'GetEOF' XDEF GetEOF GetEOF jsr clearPB move.L D1,A3 move D0,paramBlock+ioRefNum(A5) lea paramBlock(A5),A0 _GetEOF move.L paramBlock+ioLEOF(A5),(A3) ;Return logEOF rts ;------------------------------------------------------------------------------ ; OSErr SetEOF(refNum, filePos) ; short refNum; (D0.W) ; long logEOF; (D1.L) ;------------------------------------------------------------------------------ Module 'SetEOF' XDEF SetEOF SetEOF jsr clearPB move D0,paramBlock+ioRefNum(A5) move.L D1,paramBlock+ioLEOF(A5) lea paramBlock(A5),A0 _SetEOF rts ;------------------------------------------------------------------------------ ; OSErr FSAllocate(refNum, count) ; short refNum; (D0.W) ; long count; (D1.L) ;------------------------------------------------------------------------------ Module 'Allocate' XDEF Allocate Allocate jsr clearPB move D0,paramBlock+ioRefNum(A5) move.L D1,paramBlock+ioReqCount(A5) lea paramBlock(A5),A0 _Allocate rts ;------------------------------------------------------------------------------ ; OSErr FSClose(refNum) ; short refNum; (D0.W) ;------------------------------------------------------------------------------ Module 'FSClose' XDEF FSClose FSClose jsr clearPB move D0,paramBlock+ioRefNum(A5) lea paramBlock(A5),A0 _Close rts ;------------------------------------------------------------------------------ ; OSErr GetFInfo(fileName, vRefNum, fndrInfo) ; Str255 *fileName; (D0.L) ; short vRefNum; (D1.W) ; FInfo *fndrInfo; (D2.L) ;------------------------------------------------------------------------------ Module 'GetFInfo' XDEF GetFInfo GetFInfo jsr clearPB move.L D2,A3 jsr NameAndVref _GetFileInfo lea paramBlock+ioFlUsrWds(A5),A2 move.L (A2)+,(A3)+ ; (faster than _BlockMove) move.L (A2)+,(A3)+ move.L (A2)+,(A3)+ move.L (A2),(A3) rts ;------------------------------------------------------------------------------ ; OSErr SetFInfo(fileName, vRefNum, fndrInfo) ; Str255 *fileName; (D0.L) ; short vRefNum; (D1.W) ; FInfo *fndrInfo; (D2.L) ;------------------------------------------------------------------------------ Module 'SetFInfo' XDEF SetFInfo SetFInfo jsr clearPB jsr NameAndVref move.L D2,A1 lea paramBlock+ioFlUsrWds(A5),A2 move.L (A1)+,(A2)+ ; (faster than _BlockMove) move.L (A1)+,(A2)+ move.L (A1)+,(A2)+ move.L (A1),(A2) _SetFileInfo rts ;------------------------------------------------------------------------------ ; OSErr SetFLock(fileName, vRefNum) ; Str255 *fileName; (D0.L) ; short vRefNum; (D1.W) ;------------------------------------------------------------------------------ Module 'SetFLock' XDEF SetFLock SetFLock jsr clearPB jsr NameAndVref _SetFilLock rts ;------------------------------------------------------------------------------ ; OSErr RstFLock(fileName, vRefNum) ; Str255 *fileName; (D0.L) ; short vRefNum; (D1.W) ;------------------------------------------------------------------------------ Module 'RstFLock' XDEF RstFLock RstFLock jsr clearPB jsr NameAndVref _RstFilLock rts ;------------------------------------------------------------------------------ ; OSErr FSDelete(fileName, vRefNum) ; Str255 *fileName; (D0.L) ; short vRefNum; (D1.W) ;------------------------------------------------------------------------------ Module 'FSDelete' XDEF FSDelete FSDelete jsr clearPB jsr NameAndVref _Delete rts ;------------------------------------------------------------------------------ ; OSErr Rename(oldName, vRefNum, newName) ; Str255 *oldName; (D0.L) ; short vRefNum; (D1.W) ; Str255 *newName; (D2.L) ;------------------------------------------------------------------------------ Module 'Rename' XDEF Rename Rename jsr clearPB jsr NameAndVref move.L D2,paramBlock+ioNewName(A5) _Rename rts ;------------------------------------------------------------------------------ ; QHdrPtr GetFSQHdr() ;------------------------------------------------------------------------------ Module 'FSQueueCalls' XDEF GetFSQHdr GetFSQHdr move.l fsQHdr,A0 rts ;------------------------------------------------------------------------------ ; QHdrPtr GetVCBQHdr() ;------------------------------------------------------------------------------ XDEF GetVCBQHdr GetVCBQHdr move.l vcbQHdr,A0 rts ;------------------------------------------------------------------------------ ; QHdrPtr GetDrvQHdr() ;------------------------------------------------------------------------------ XDEF GetDrvQHdr GetDrvQHdr move.l drvQHdr,A0 rts END =========================finis==============================