home *** CD-ROM | disk | FTP | other *** search
/ Carousel Volume 2 #1 / carousel.iso / mactosh / code / casm_tel.sit < prev    next >
Encoding:
Text File  |  1988-05-14  |  5.9 KB  |  215 lines

  1. 11-May-88 21:28:03-MDT,6233;000000000000
  2. Return-Path: <u-lchoqu%sunset@cs.utah.edu>
  3. Received: from cs.utah.edu by SIMTEL20.ARPA with TCP; Wed, 11 May 88 21:27:54 MDT
  4. Received: by cs.utah.edu (5.54/utah-2.0-cs)
  5.     id AA04143; Wed, 11 May 88 21:28:24 MDT
  6. Received: by sunset.utah.edu (5.54/utah-2.0-leaf)
  7.     id AA29319; Wed, 11 May 88 21:28:22 MDT
  8. Date: Wed, 11 May 88 21:28:22 MDT
  9. From: u-lchoqu%sunset@cs.utah.edu (Lee Choquette)
  10. Message-Id: <8805120328.AA29319@sunset.utah.edu>
  11. To: rthum@simtel20.arpa
  12. Subject: Teleport.asm.c
  13.  
  14.                                      TELEPORT 4
  15.                                      ~~~~~~~~~~
  16.  
  17. The Teleport 4.1 is an application launcher that is compatible with
  18. MultiFinder.
  19.  
  20. If you are using it under Finder, I recommend keeping this FKEY in the
  21. Finder using ResEdit (or ask your local Mac guru if you donUt know how
  22. to !). This is because some programs like HyperCard 1.0.1 only do
  23. cleaning up when you select QUIT from the File Menu. If you use this
  24. FKEY, because you have not explicitly selected QUIT from the FILE MENU,
  25. this cleanup might be not performed and you might crash.
  26.  
  27. Launching from the Finder is ok in general as the Finder is very robust
  28. and cleans up everything even if you use this FKEY. This caveat does not
  29. apply to MultiFinder as under MultiFinder the current application is not
  30. closed when you launch another program using Teleport 4.1.
  31.  
  32. Source code in LSC assembly is included. Portions (c) THINK
  33. Technologies. This FKEY can be distributed freely provided no commercial
  34. use is made of it without my permission. Enjoy.
  35.  
  36.     John Lim
  37.     18 Nottingwood St.,
  38.     Doncaster East 3109,
  39.     Victoria,
  40.     Australia.
  41.  
  42. /*
  43.  
  44.            Teleport Version 4.1 FKEY (c) 1986,1987 by John Lim
  45.            ------------------------------------------------
  46.   * Version I was written in TML Pascal.
  47.   * Version ][ was rewritten in assembly language to reduce its size then
  48.     ported to LSC.
  49.   * Version 3 patches AppParmHandle so that PackIt and ResEdit work properly.
  50.   * Version 4 makes it compatible with all Systems including MultiFinder;
  51.     Refer to TN126 on sublaunching and TN180 on MultiFinder.
  52.     (27th December 1987).
  53.   * Version 4.1 uses PBGetFInfo instead of PBGetCatInfo to get the
  54.     Finder Flags and fixes the warning from THINK (enclosed below).
  55.     (5th January 1988).    
  56.  
  57.  This code can be freely used/modified by anyone provided that my 
  58.  contribution is acknowledged.
  59.  
  60.  Set tabs to 8.
  61.  
  62. ============================================================================
  63.  
  64. WARNING from THIMK :
  65.     
  66. If bit 6 (0x0040) is set in "fdFlags", MultiFinder will ignore
  67. the various flag bits in the application's SIZE resource.  These bits
  68. determine whether the application is "MultiFinder-aware" and whether it
  69. is to receive suspend/resume events and background null events.  Apple
  70. has acknowledged this as a bug in MultiFinder 1.0.  We recommend always
  71. passing 0 for "fdFlags".
  72.     
  73. MY SOLUTION :
  74.     I pass (fdFlags & ffbf) to Launch; that is I clear bit 6.
  75.  
  76. */
  77.  
  78. #include "HFS.h"
  79. #include "StdFilePkg.h"
  80. #include "SegmentLdr.h"
  81. #include "asm.h"
  82.  
  83. #define     KeyMapAddress     0x174
  84. #define        thePoint    0x550064    
  85. #define        NumTypes    1
  86.  
  87. typedef struct
  88.     {
  89.     StringPtr    pfName;
  90.     int        param;
  91.     int        LC;        /* Refer to TN126 on Sublaunching */
  92.     long        ExtBlockLen;
  93.     int        fFlags;
  94.     long        LaunchFlags;
  95.     } LaunchStruct;
  96.     
  97. main()
  98. {
  99. SFReply     theReply;
  100. ParamBlockRec     pB;
  101. LaunchStruct    launchRec;
  102. Ptr        saveAddress;
  103.  
  104. /*Debugger();*/
  105.  
  106. asm
  107.     {
  108.     MOVE.L    #thePoint,-(A7)        ; Push Pt
  109.     PEA    @promptstring        ; push promptstring (length = 0)
  110.     CLR.L    -(A7)            ; filefilter = Nil
  111.     
  112. ;    SUBQ.L    #2,A7            ; If (Button()) display all files
  113. ;    Button
  114. ;    TST.W    (A7)+
  115. ;    BEQ.S    @APPL_only
  116.         
  117.     BTST     #1,KeyMapAddress+7     ; Check for CapsLock key
  118.     BEQ.S    @APPL_only
  119.         
  120.     
  121.     MOVE.W    #-1,-(A7)        ; If (CapsLock) display all files
  122.     BRA.S    @cont
  123. APPL_only :
  124.     MOVE.W    #NumTypes,-(A7)        ; NumTypes in typelist
  125. cont :
  126.     PEA    @TypeList        ; push typelist
  127.     CLR.L    -(A7)            ; dialoghook = Nil
  128.     PEA    theReply        ; Reply Record to be returned
  129.     MOVE.W    #2,-(A7)        ; SFGetFile routine selector
  130.     Pack3    
  131.     TST.B    theReply.good        ; if cancel pressed...
  132.     BEQ    @endit            ; bye-bye
  133. ;
  134. ;    Clear Finder Parameters so no documents are opened accidentally.
  135. ;
  136.     MOVE.L    AppParmHandle,A0    ; Set the Finder Parameters...
  137.     MOVE.L    (A0),A1
  138.     CLR.L    (A1)            ; to zero.
  139.     MOVEQ    #4,D0
  140.     SetHandleSize
  141. ;
  142. ;    Check to see if HFS system. If not under HFS, then we assume
  143. ;    that no juggling can occur. We clear launchRec.LC to ensure
  144. ;    that patched 64K Roms handle sublaunching properly.
  145. ;
  146.     CLR.W    launchRec.LC        ; This might not be neccessary ?
  147.     TST.W    FSFCBLen
  148.     BLT.S    @Not_HFS
  149. ;
  150. ;    Get the Finder Attributes of the application...
  151. ;
  152.  
  153.     LEA    pB,A0
  154.     LEA    theReply.fName,A1
  155.     MOVE.L    A1,pB.fileParam.ioNamePtr
  156.     MOVE.W    theReply.vRefNum,pB.fileParam.ioVRefNum
  157.     CLR.W    pB.fileParam.ioFDirIndex
  158.     
  159.     PBGetFInfo
  160. ;
  161. ;    Prepare extensions to launchRec...
  162. ;
  163.     MOVE.W    #'LC',launchRec.LC        ; Signature
  164.     MOVE.L    #6,launchRec.ExtBlockLen    ; Length of extensions
  165.     MOVE.W    pB.fileParam.ioFlFndrInfo.fdFlags,launchRec.fFlags
  166.     ANDI.W    #0xffbf,launchRec.fFlags    ; To remedy MultiFinder1.0 bug,
  167.                         ; as noted by THINK.
  168.     
  169. ;
  170. ;    Check if WaitNextEvent implemented...
  171. ;    
  172.     MOVE.W    #0x9F,D0        ; 0x9F = UnImplemented Trap
  173.     GetTrapAddress NEWTOOL
  174.     MOVE.L    A0,saveAddress
  175.     MOVE.W    #0xA860,D0        ; 0xA860 = WaitNextEvent
  176.     GetTrapAddress NEWTOOL
  177.     CMP.L    saveAddress,a0
  178.     BNE.S    @WNE_Exists
  179.  
  180.     CLR.L    launchRec.LaunchFlags    ; WaitNextEvent not implemented which
  181.                     ; means we want ordinary launching
  182.     BRA.S    @Not_HFS
  183.     
  184. WNE_Exists:
  185.     MOVE.L    #0xC0000000,launchRec.LaunchFlags
  186.                     ; Both highbits must be set when
  187.                     ; sublaunching in MultiFinder.
  188.                     ; Refer to TN180.
  189.     
  190. Not_HFS :
  191. ;
  192. ;    Set the correct volume.
  193. ;
  194.     LEA    pB,A0            ;prepare ParamBlock
  195.     CLR.L    pB.volumeParam.ioNamePtr
  196.     MOVE.W    theReply.vRefNum,pB.volumeParam.ioVRefNum
  197.     PBSetVol
  198. ;
  199. ;
  200. ;
  201.     LEA    launchRec,A0
  202.     LEA    theReply.fName,A1
  203.     MOVE.L    A1,launchRec.pfName    ; pointer to name of application
  204.     CLR.W    launchRec.param        ; 0 = use main screen/sound buffers
  205.     Launch                ; Beam us up, Scottie...
  206.     BRA.S    @endit
  207. TypeList:
  208.     dc.l    'APPL'
  209. promptstring:
  210.     dc.w    0
  211.     dc.l    ')198','6-88','John',' Lim'
  212. endit:
  213.     }
  214. }
  215.