home *** CD-ROM | disk | FTP | other *** search
- 18-Jun-88 14:46:20-MDT,5220;000000000000
- Return-Path: <u-lchoqu%sunset@cs.utah.edu>
- Received: from cs.utah.edu by SIMTEL20.ARPA with TCP; Sat, 18 Jun 88 14:46:12 MDT
- Received: by cs.utah.edu (5.54/utah-2.0-cs)
- id AA22698; Sat, 18 Jun 88 14:46:14 MDT
- Received: by sunset.utah.edu (5.54/utah-2.0-leaf)
- id AA24821; Sat, 18 Jun 88 14:46:10 MDT
- Date: Sat, 18 Jun 88 14:46:10 MDT
- From: u-lchoqu%sunset@cs.utah.edu (Lee Choquette)
- Message-Id: <8806182046.AA24821@sunset.utah.edu>
- To: rthum@simtel20.arpa
- Subject: Transfer.c
-
- /*
-
- Transfer Function written in Megamax C by N. Fukaya August 31, 1986
-
-
- This is a self-contained source code that implements the Transfer action.
- When called, it displays a standard get file dialog with files of type
- APPL for selection. If the user cancels, it'll return to the caller
- immediately. If the user selects an application, a SetVol is done on
- the vRefNum or the WDRefNum. Regardless of the result of the SetVol
- operation, CallerHook is called with the result code in D0. Upon return
- from CallerHook, it'll test D0. If D0 is zero, it'll execute a Launch
- to the selected application. If D0 is nonzero, it'll return to the
- caller immediately. Registers D0 and A0 are used by this function
- without care.
-
- CallerHook is specified below as a dummy function. It may be replaced by
- any processing that is felt appropriate. For example, it could display
- a dialog informing the user that an error occurred or do the necessary
- cleanup before Launch is executed if there were no errors.
-
- -------------------------------------------------------------------------
- This source is not copyrighted.
- You do not owe me anything should you wish to use or modify this source.
- I would appreciate it if you do not turn around and sell this to an
- uninformed soul. However, there's nothing I can do about it if you're
- that
- low.
- But really, this isn't worth paying for is it?
- ( If you would pay for this, I have a solar energy idea for Seattle... )
- -------------------------------------------------------------------------
-
-
- ***** Notes to Megamax Users:
-
- This function has been compiled and tested using the Beta 3.0 release.
- It should compile without any problems with version 2.1b release.
-
-
- ***** Notes to Non-Megamax Users:
-
- As with most C compilers, Megamax C allows inline assembly. Some of
- the nicer features have been exploited for readability's sake.
-
- - Inline assembly starts with the keyword 'asm' and a '{'. It ends
- with a closing '}'.
-
- - The C function declaration like
-
- transfer()
- {
- SFReply Reply;
- ParamBlockRec PBRec;
- .
- . C and inline assembly instructions
- .
- }
-
- are replaced by
-
- LINK A6, #-TempVarSize
- .
- . Compiled C and inline assembly instructions
- .
- UNLK A6
- RTS
-
- - #define statements work within inline assembly. Thus Launch is replaced
- by DC.W 0xA9F2, etc.
-
- - Declared temporary (automatic) C variables are accessed by name within
- inline assembly as offsets from A6. Thus a statement like
-
- MOVE.B Reply.good(A6), D0
-
- is replaced by
-
- MOVE.B -74(A6), D0
-
-
- Finally, I would appreciate comments from you, really.
-
- Enjoy, Nobuo Fukaya
- (72777,772 on Compuserve)
- */
-
-
- typedef short BOOLEAN;
- typedef char OSType[4];
- typedef int INTEGER;
- typedef char STRING;
-
- typedef struct {
- BOOLEAN good;
- BOOLEAN copy;
- OSType fType;
- INTEGER vRefNum;
- INTEGER version;
- STRING fName[64]; } SFReply;
-
- typedef long int LongInt;
- typedef char *StringPtr;
- typedef char *Ptr;
- typedef char *QElemPtr;
- typedef int (*ProcPtr)();
- typedef int OSErr;
-
- typedef struct {
- QElemPtr qLink;
- INTEGER qType;
- INTEGER ioTrap;
- Ptr ioCmdAddr;
- ProcPtr ioCompletion;
- INTEGER ioResult;
- StringPtr ioNamePtr;
- INTEGER ioVRefNum;
- LongInt filler2;
- INTEGER ioVolIndex;
- LongInt ioVCrDate;
- LongInt ioVLsBkUp;
- INTEGER ioVAtrb;
- INTEGER ioVNmFls;
- INTEGER ioVDirSt;
- INTEGER ioVBlLn;
- INTEGER ioVNmAlBlks;
- LongInt ioVAlBlkSiz;
- LongInt ioVClpSiz;
- INTEGER ioAlBlSt;
- LongInt ioVNxtFNum;
- INTEGER ioVFrBlk; } ParamBlockRec;
-
-
- #define SFGet_Position #0x460050
- #define SFGetFile DC.W 0xA9EA
- #define PBSetVol DC.W 0xA215
- #define Launch DC.W 0xA9F2
-
- extern int CallerHook();
-
- transfer()
- {
- SFReply Reply;
- ParamBlockRec PBRec;
-
- asm {
- MOVE.L SFGet_Position, -(A7)
- CLR.L -(A7)
- CLR.L -(A7)
- MOVE.W #1, -(A7)
- PEA TYPE(PC)
- CLR.L -(A7)
- PEA Reply(A6)
- MOVE.W #2, -(A7)
- SFGetFile
- MOVE.B Reply.good(A6), D0
- BEQ.S DONE(PC)
- CLR.L PBRec.ioNamePtr(A6)
- MOVE.W Reply.vRefNum(A6), PBRec.ioVRefNum(A6)
- LEA PBRec(A6), A0
- PBSetVol
- JSR CallerHook(PC)
- TST.W D0
- BNE.S DONE(PC)
- LEA Reply.fName(A6), A0
- MOVE.L A0, Reply.vRefNum(A6)
- LEA Reply.vRefNum(A6), A0
- Launch
- DONE:
- }
- }
-
- asm {
- TYPE: DC.B 'A'
- DC.B 'P'
- DC.B 'P'
- DC.B 'L'
- }
-
- int CallerHook()
- {
- }
-