home *** CD-ROM | disk | FTP | other *** search
- 11-May-88 21:28:03-MDT,6233;000000000000
- Return-Path: <u-lchoqu%sunset@cs.utah.edu>
- Received: from cs.utah.edu by SIMTEL20.ARPA with TCP; Wed, 11 May 88 21:27:54 MDT
- Received: by cs.utah.edu (5.54/utah-2.0-cs)
- id AA04143; Wed, 11 May 88 21:28:24 MDT
- Received: by sunset.utah.edu (5.54/utah-2.0-leaf)
- id AA29319; Wed, 11 May 88 21:28:22 MDT
- Date: Wed, 11 May 88 21:28:22 MDT
- From: u-lchoqu%sunset@cs.utah.edu (Lee Choquette)
- Message-Id: <8805120328.AA29319@sunset.utah.edu>
- To: rthum@simtel20.arpa
- Subject: Teleport.asm.c
-
- TELEPORT 4
- ~~~~~~~~~~
-
- The Teleport 4.1 is an application launcher that is compatible with
- MultiFinder.
-
- If you are using it under Finder, I recommend keeping this FKEY in the
- Finder using ResEdit (or ask your local Mac guru if you donUt know how
- to !). This is because some programs like HyperCard 1.0.1 only do
- cleaning up when you select QUIT from the File Menu. If you use this
- FKEY, because you have not explicitly selected QUIT from the FILE MENU,
- this cleanup might be not performed and you might crash.
-
- Launching from the Finder is ok in general as the Finder is very robust
- and cleans up everything even if you use this FKEY. This caveat does not
- apply to MultiFinder as under MultiFinder the current application is not
- closed when you launch another program using Teleport 4.1.
-
- Source code in LSC assembly is included. Portions (c) THINK
- Technologies. This FKEY can be distributed freely provided no commercial
- use is made of it without my permission. Enjoy.
-
- John Lim
- 18 Nottingwood St.,
- Doncaster East 3109,
- Victoria,
- Australia.
-
- /*
-
- Teleport Version 4.1 FKEY (c) 1986,1987 by John Lim
- ------------------------------------------------
- * Version I was written in TML Pascal.
- * Version ][ was rewritten in assembly language to reduce its size then
- ported to LSC.
- * Version 3 patches AppParmHandle so that PackIt and ResEdit work properly.
- * Version 4 makes it compatible with all Systems including MultiFinder;
- Refer to TN126 on sublaunching and TN180 on MultiFinder.
- (27th December 1987).
- * Version 4.1 uses PBGetFInfo instead of PBGetCatInfo to get the
- Finder Flags and fixes the warning from THINK (enclosed below).
- (5th January 1988).
-
- This code can be freely used/modified by anyone provided that my
- contribution is acknowledged.
-
- Set tabs to 8.
-
- ============================================================================
-
- WARNING from THIMK :
-
- If bit 6 (0x0040) is set in "fdFlags", MultiFinder will ignore
- the various flag bits in the application's SIZE resource. These bits
- determine whether the application is "MultiFinder-aware" and whether it
- is to receive suspend/resume events and background null events. Apple
- has acknowledged this as a bug in MultiFinder 1.0. We recommend always
- passing 0 for "fdFlags".
-
- MY SOLUTION :
- I pass (fdFlags & ffbf) to Launch; that is I clear bit 6.
-
- */
-
- #include "HFS.h"
- #include "StdFilePkg.h"
- #include "SegmentLdr.h"
- #include "asm.h"
-
- #define KeyMapAddress 0x174
- #define thePoint 0x550064
- #define NumTypes 1
-
- typedef struct
- {
- StringPtr pfName;
- int param;
- int LC; /* Refer to TN126 on Sublaunching */
- long ExtBlockLen;
- int fFlags;
- long LaunchFlags;
- } LaunchStruct;
-
- main()
- {
- SFReply theReply;
- ParamBlockRec pB;
- LaunchStruct launchRec;
- Ptr saveAddress;
-
- /*Debugger();*/
-
- asm
- {
- MOVE.L #thePoint,-(A7) ; Push Pt
- PEA @promptstring ; push promptstring (length = 0)
- CLR.L -(A7) ; filefilter = Nil
-
- ; SUBQ.L #2,A7 ; If (Button()) display all files
- ; Button
- ; TST.W (A7)+
- ; BEQ.S @APPL_only
-
- BTST #1,KeyMapAddress+7 ; Check for CapsLock key
- BEQ.S @APPL_only
-
-
- MOVE.W #-1,-(A7) ; If (CapsLock) display all files
- BRA.S @cont
- APPL_only :
- MOVE.W #NumTypes,-(A7) ; NumTypes in typelist
- cont :
- PEA @TypeList ; push typelist
- CLR.L -(A7) ; dialoghook = Nil
- PEA theReply ; Reply Record to be returned
- MOVE.W #2,-(A7) ; SFGetFile routine selector
- Pack3
- TST.B theReply.good ; if cancel pressed...
- BEQ @endit ; bye-bye
- ;
- ; Clear Finder Parameters so no documents are opened accidentally.
- ;
- MOVE.L AppParmHandle,A0 ; Set the Finder Parameters...
- MOVE.L (A0),A1
- CLR.L (A1) ; to zero.
- MOVEQ #4,D0
- SetHandleSize
- ;
- ; Check to see if HFS system. If not under HFS, then we assume
- ; that no juggling can occur. We clear launchRec.LC to ensure
- ; that patched 64K Roms handle sublaunching properly.
- ;
- CLR.W launchRec.LC ; This might not be neccessary ?
- TST.W FSFCBLen
- BLT.S @Not_HFS
- ;
- ; Get the Finder Attributes of the application...
- ;
-
- LEA pB,A0
- LEA theReply.fName,A1
- MOVE.L A1,pB.fileParam.ioNamePtr
- MOVE.W theReply.vRefNum,pB.fileParam.ioVRefNum
- CLR.W pB.fileParam.ioFDirIndex
-
- PBGetFInfo
- ;
- ; Prepare extensions to launchRec...
- ;
- MOVE.W #'LC',launchRec.LC ; Signature
- MOVE.L #6,launchRec.ExtBlockLen ; Length of extensions
- MOVE.W pB.fileParam.ioFlFndrInfo.fdFlags,launchRec.fFlags
- ANDI.W #0xffbf,launchRec.fFlags ; To remedy MultiFinder1.0 bug,
- ; as noted by THINK.
-
- ;
- ; Check if WaitNextEvent implemented...
- ;
- MOVE.W #0x9F,D0 ; 0x9F = UnImplemented Trap
- GetTrapAddress NEWTOOL
- MOVE.L A0,saveAddress
- MOVE.W #0xA860,D0 ; 0xA860 = WaitNextEvent
- GetTrapAddress NEWTOOL
- CMP.L saveAddress,a0
- BNE.S @WNE_Exists
-
- CLR.L launchRec.LaunchFlags ; WaitNextEvent not implemented which
- ; means we want ordinary launching
- BRA.S @Not_HFS
-
- WNE_Exists:
- MOVE.L #0xC0000000,launchRec.LaunchFlags
- ; Both highbits must be set when
- ; sublaunching in MultiFinder.
- ; Refer to TN180.
-
- Not_HFS :
- ;
- ; Set the correct volume.
- ;
- LEA pB,A0 ;prepare ParamBlock
- CLR.L pB.volumeParam.ioNamePtr
- MOVE.W theReply.vRefNum,pB.volumeParam.ioVRefNum
- PBSetVol
- ;
- ;
- ;
- LEA launchRec,A0
- LEA theReply.fName,A1
- MOVE.L A1,launchRec.pfName ; pointer to name of application
- CLR.W launchRec.param ; 0 = use main screen/sound buffers
- Launch ; Beam us up, Scottie...
- BRA.S @endit
- TypeList:
- dc.l 'APPL'
- promptstring:
- dc.w 0
- dc.l ')198','6-88','John',' Lim'
- endit:
- }
- }
-