home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / skipfind.txt < prev    next >
Encoding:
Text File  |  1992-11-05  |  55.8 KB  |  1,866 lines

  1. ;SkipFinder, version 6.1
  2. ;
  3. ;Copyright 1986 Darin Adler
  4. ;
  5. ;Permission is given to distribute or modify
  6. ;this code for non-commercial purposes.
  7.  
  8.  
  9.                 INCLUDE SysEquX.D
  10.                 INCLUDE ToolEquX.D
  11.                 INCLUDE QuickEquX.D
  12.                 INCLUDE MacTraps.D
  13.  
  14.  
  15. ;----------
  16. ;SkipFinder equates
  17. ;----------
  18.  
  19. stashed         EQU     $AE4            ;(a secret place to stash this stuff)
  20.  
  21. FBit            EQU     1                       ;option bits
  22. HBit            EQU     0
  23.  
  24. ;Dialog filter equates
  25.  
  26. itemHit         EQU     8
  27. theEvent        EQU     12
  28. theDialog       EQU     16
  29. filtered        EQU     20
  30.  
  31. ;Macros
  32.  
  33.                 MACRO   LONG    value   =
  34.                 DC      {value}>>16,{value}&$FFFF
  35.                 |
  36.  
  37.  
  38. ;----------
  39. ;SkipFinder desk accessory (SkipLoader)
  40. ;----------
  41.  
  42.                 RESOURCE 'DRVR' 12 'SkipFinder' 32
  43.  
  44. Skip
  45.                 DC.W    0                       ;need nothing
  46.                 DC.W    0                       ;doesn't need time
  47.                 DC.W    0                       ;no events
  48.                 DC.W    0                       ;no menu
  49.  
  50.                 DC.W    DoIt-Skip               ;open
  51.                 DC.W    Done-Skip               ;prime
  52.                 DC.W    Done-Skip               ;control
  53.                 DC.W    Done-Skip               ;status
  54.                 DC.W    Done-Skip               ;close
  55.  
  56. DoIt
  57.                 MOVE.W  dCtlRefNum(A1),D3       ;get the refNum
  58.                 EOR.W   #$FFFF,D3               ;convert it to a resource ID
  59.                 LSL.W   #5,D3                   ;adjust it
  60.                 OR.W    #$C000,D3               ;make it an owned resource
  61.  
  62.                 MOVE.L  stashed,D0              ;stashed?
  63.                 BCLR    #31,D0
  64.                 MOVE.L  D0,A0
  65.  
  66.                 MOVE.L  SysZone,A1
  67.                 CMP.L   A1,A0                   ;is it already installed?
  68.                 BLO     NotInAlready
  69.                 CMP.L   bkLim(A1),A0
  70.                 BHS     NotInAlready
  71.  
  72.                 ADDQ.W  #1,D3                   ;#1 is "this is in already"
  73.  
  74.                 SUBQ    #4,SP                   ;room for return
  75.                 MOVE.L  #'DLOG',-(SP)           ;get the dialog template in here
  76.                 MOVE.W  D3,-(SP)
  77.                 _GetResource
  78.                 MOVE.L  (SP)+,A0                ;get the resource handle
  79.                 _HNoPurge
  80.                 MOVE.L  (A0),A0                 ;dereference
  81.                 MOVE.W  D3,dItems(A0)           ;fix itemList ID
  82.  
  83.                 TST.L   dBounds+topLeft(A0)     ;if topLeft is 0,0 then center it
  84.                 BNE.S   DontCenter
  85.  
  86.                 MOVE.L  (A5),A1                 ;get QuickDraw globals
  87.  
  88.                 MOVEQ   #0,D0                   ;set up for centering (menu bar)
  89.                 ADD.W   screenBits+bounds+bottom(A1),D0 ;calculate centering info
  90.                 SUB.W   dBounds+bottom(A0),D0   ;by subtracting (ignore the menu bar)
  91.                 ADD.W   #20,D0
  92.                 ASR.W   #1,D0                   ;and shifting
  93.  
  94.                 SWAP    D0                      ;move the Y coordinate to high word
  95.  
  96.                 MOVE.W  screenBits+bounds+right(A1),D0 ;do the same for X
  97.                 SUB.W   dBounds+right(A0),D0
  98.                 ASR.W   #1,D0
  99.  
  100.                 PEA     dBounds(A0)
  101.                 MOVE.L  D0,-(SP)                ;ready for an _OffsetRect
  102.                 _OffsetRect
  103.  
  104. DontCenter
  105.                 SUBQ    #4,SP                   ;reserve room for port ptr
  106.                 PEA     (SP)                    ;push pointer
  107.                 _GetPort
  108.  
  109.                 SUBQ    #4,SP
  110.                 MOVE.W  D3,-(SP)                ;put on the resource ID
  111.  
  112.                 SUBQ    #4,SP                   ;make room
  113.                 MOVE.L  #'SKIP',-(SP)           ;ask for resource
  114.                 MOVE.W  #1,-(SP)
  115.                 _GetIndResource
  116.                 MOVE.L  (SP)+,A4                ;get resource handle
  117.                 MOVE.L  (A4),A0                 ;de-ref it
  118.                 MOVE.W  2(A0),D4                ;get bits
  119.  
  120.                 CLR.L   -(SP)                   ;allocate storage on heap
  121.                 MOVE.L  #-1,-(SP)               ;put window on top
  122.                 _GetNewDialog                   ;get the dialog
  123.  
  124.                 MOVE.L  (SP),-(SP)
  125.                 MOVE.W  #2,-(SP)
  126.                 PEA     scratch20
  127.                 PEA     scratch20+2
  128.                 PEA     scratch8
  129.                 _GetDItem
  130.                 MOVE.L  scratch20+2,A2          ;get the handle for control #2
  131.  
  132.                 MOVE.L  (SP),-(SP)
  133.                 MOVE.W  #3,-(SP)
  134.                 PEA     scratch20
  135.                 PEA     scratch20+2
  136.                 PEA     scratch8
  137.                 _GetDItem
  138.                 MOVE.L  scratch20+2,A3          ;get the handle for control #3
  139.  
  140.                 MOVEQ   #0,D0
  141.                 BTST    #FBit,D4                ;test F bit
  142.                 BEQ.S   @1
  143.                 ADDQ.W  #1,D0
  144. @1
  145.                 MOVE.L  A2,-(SP)
  146.                 MOVE.W  D0,-(SP)
  147.                 _SetCtlValue
  148.  
  149.                 MOVEQ   #0,D0
  150.                 BTST    #HBit,D4                ;test H bit
  151.                 BEQ.S   @2
  152.                 ADDQ.W  #1,D0
  153. @2
  154.                 MOVE.L  A3,-(SP)
  155.                 MOVE.W  D0,-(SP)
  156.                 _SetCtlValue
  157.  
  158.                 BTST    #7,stashed
  159.                 BEQ.S   ModalDialogLoop
  160.  
  161.                 MOVE.L  A2,-(SP)
  162.                 MOVE.W  #255,-(SP)
  163.                 _HiliteControl
  164.  
  165.                 MOVE.L  A3,-(SP)
  166.                 MOVE.W  #255,-(SP)
  167.                 _HiliteControl
  168.  
  169. ModalDialogLoop
  170.                 MOVE.L  (SP),-(SP)
  171.                 _ShowWindow
  172.  
  173.                 SUBQ    #2,SP
  174.                 PEA     FilterProc
  175.                 PEA     4(SP)                   ;pass an address for the item number
  176.                 _ModalDialog
  177.                 MOVE.W  (SP)+,D0                ;get the item number
  178.  
  179.                 CMP.W   #2,D0                   ;the F check box
  180.                 BNE.S   NotF
  181.  
  182.                 MOVEQ   #0,D0
  183.                 BCHG    #FBit,D4                ;flip F bit
  184.                 BNE.S   @1
  185.                 ADDQ.W  #1,D0
  186. @1
  187.                 MOVE.L  A2,-(SPj
  188.                 MOVE.W  D0,-(SP)
  189.                 _SetCtlValue
  190.                 BRA.S   ModalDialogLoop
  191. NotF
  192.  
  193.                 CMP.W   #3,D0                   ;the H check box
  194.                 BNE.S   NotH
  195.  
  196.                 MOVEQ   #0,D0
  197.                 BCHG    #HBit,D4                ;flip H bit
  198.                 BNE.S   @1
  199.                 ADDQ.W  #1,D0
  200. @1
  201.                 MOVE.L  A3,-(SP)
  202.                 MOVE.W  D0,-(SP)
  203.                 _SetCtlValue
  204.                 BRA.S   ModalDialogLoop
  205. NotH
  206.  
  207.                 _DisposDialog                   ;get rid of the dialog
  208.  
  209.                 SUBQ    #4,SP                   ;room for return
  210.                 MOVE.L  #'DLOG',-(SP)           ;get the dialog template in here
  211.                 MOVE.W  D3,-(SP)
  212.                 _GetResource
  213.                 MOVE.L  (SP)+,A0                ;get the resource handle
  214.                 _HPurge
  215.  
  216.                 MOVE.L  (A4),A0                 ;de-ref the handle
  217.                 CMP.W   2(A0),D4                ;changed?
  218.                 BEQ.S   NoChange
  219.                 MOVE.W  D4,2(A0)
  220.                 MOVE.L  A4,-(SP)
  221.                 _ChangedResource
  222.                 MOVE.L  A4,-(SP)
  223.                 _WriteResource
  224. NoChange
  225.                 MOVE.L  A4,A0
  226.                 _HPurge
  227.  
  228.                 _SetPort
  229.  
  230. Done
  231.                 MOVEQ   #0,D0                   ;return no error
  232.                 RTS
  233.  
  234. ;----------
  235. ;FilterProc - fancy filtering for the SkipFinder dialog
  236. ;----------
  237.  
  238. FilterProc
  239.                 LINK    A6,#0
  240.  
  241.                 CLR.B   filtered(A6)
  242.  
  243.                 MOVE.L  theEvent(A6),A0
  244.  
  245.                 CMP.W   #updatEvt,(A0)
  246.                 BNE.S   NotUpdateEvent
  247.  
  248.                 MOVE.L  theDialog(A6),D0
  249.  
  250.                 MOVE.L  D0,-(SP)
  251.                 MOVE.L  D0,-(SP)
  252.                 MOVE.L  D0,-(SP)
  253.                 MOVE.L  D0,-(SP)
  254.                 MOVE.L  D0,-(SP)
  255.  
  256.                 _BeginUpdate
  257.                 _DrawDialog
  258.                 _SetPort
  259.  
  260.                 MOVE.W  #1,-(SP)                ;item 1 is always default
  261.                 PEA     scratch20
  262.                 PEA     scratch20+2
  263.                 PEA     scratch8
  264.                 _GetDItem
  265.  
  266.                 LEA     scratch8,A0             ;rectangle
  267.                 MOVEQ   #3,D0                   ;width of outline
  268.                 MOVEQ   #16,D1                  ;rounding factor of outline
  269.                 MOVEQ   #-4,D2                  ;inset of outline
  270.  
  271.                 MOVE.L  A0,-(SP)                ;FrameRoundRect
  272.                 MOVE.W  D1,-(SP)
  273.                 MOVE.W  D1,-(SP)
  274.  
  275.                 MOVE.L  A0,-(SP)                ;InsetRect
  276.                 MOVE.W  D2,-(SP)
  277.                 MOVE.W  D2,-(SP)
  278.  
  279.                 MOVE.W  D0,-(SP)                ;PenSize
  280.                 MOVE.W  D0,-(SP)
  281.  
  282.                 _PenSize
  283.                 _InsetRect
  284.                 _FrameRoundRect
  285.  
  286.                 _EndUpdate
  287.  
  288.                 MOVE.L  theEvent(A6),A0
  289.                 CLR.W   (A0)
  290.                 BRA.S   DoneFilterProc
  291.  
  292. NotUpdateEvent
  293.                 CMP.W   #keyDwnEvt,(A0)
  294.                 BNE.S   DoneFilterProc
  295.  
  296.                 CMP.B   #3,evtMessage+3(A0)
  297.                 BEQ.S   HitButton
  298.  
  299.                 CMP.B   #13,evtMessage+3(A0)
  300.                 BNE.S   DoneFilterProc
  301. HitButton
  302.                 MOVE.L  theDialog(A6),-(SP)
  303.                 MOVE.W  #1,-(SP)
  304.                 PEA     scratch20
  305.                 PEA     scratch20+2
  306.                 PEA     scratch8
  307.                 _GetDItem
  308.  
  309.                 MOVE.L  scratch20+2,-(SP)
  310.                 MOVE.W  #1,-(SP)
  311.                 _HiliteControl
  312.  
  313.                 MOVE.W  #8,A0
  314.                 _Delay
  315.  
  316.                 MOVE.L  scratch20+2,-(SP)
  317.                 CLR.W   -(SP)
  318.                 _HiliteControl                  ;UnHilite the control
  319.  
  320.                 MOVE.L  itemHit(A6),A0
  321.                 MOVE.W  #1,(A0)
  322.                 ADDQ.B  #1,filtered(A6)
  323.  
  324. DoneFilterProc
  325.                 UNLK    A6
  326.                 MOVE.L  (SP)+,A0                ;get return address
  327.                 ADD     #12,SP                  ;pop off parameters
  328.                 JMP     (A0)
  329.  
  330.  
  331. ;----------
  332. ;NotInAlready - installs SkipFinder since it is not in yet
  333. ;----------
  334.  
  335. OpenResFile     EQU     $197                    ;_OpenResFile trap number
  336.  
  337. NotInAlready
  338.                 MOVE.L  #PatchEnd-PatchStart+4,D1       ;figure a size for the handle
  339.  
  340.                 MOVE.L  D1,D0
  341.                 _NewPtr ,SYS
  342.  
  343.                 MOVE.L  A0,stashed
  344.  
  345.                 MOVE.L  A0,A1
  346.  
  347.                 MOVE.W  #OpenResFile,D0         ;get the old trap address
  348.                 _GetTrapAddress
  349.                 MOVE.L  A0,(A1)+                ;put this pointer on there
  350.  
  351.                 LEA     PatchStart,A0           ;into the new handle
  352.                 MOVE.L  #PatchEnd-PatchStart,D0 ;figure a size for the patch
  353.                 _BlockMove
  354.  
  355.                 MOVE.L  A1,A0                   ;set the new trap address
  356.                 MOVE.W  #OpenResFile,D0         ;for _InitApplZone
  357.                 _SetTrapAddress
  358.  
  359.                 BRA     Done                    ;that's all folks
  360.  
  361.  
  362. ;----------
  363. ;PatchStart - this (until PatchEnd) sits on the system heap
  364. ;----------
  365.  
  366. PatchStart
  367.                 MOVE.L  (A7),A0
  368.                 CMP.L   ROMBase,A0              ;are we in ROM now?
  369.                 BHS.S   SkipTheFinder
  370.  
  371. DontSkip
  372.                 MOVE.L  PatchStart-4,-(SP)      ;old OpenResFile address
  373.                 RTS
  374.  
  375. SkipTheFinder
  376.                 LEA     CurApName,A0
  377.                 CMP.L   4(A7),A0
  378.                 BNE.S   DontSkip                ;Launch?
  379.  
  380.                 MOVEQ   #0,D0
  381.                 LEA     FinderName,A0
  382.                 LEA     CurApName,A1
  383.                 MOVE.B  (A0)+,D0
  384.                 SWAP    D0
  385.                 MOVE.B  (A1)+,D0
  386.                 _CmpString                      ;Finder launch?
  387.                 BNE.S   DontSkip
  388.  
  389.                 BCLR    #7,stashed              ;is this a special skip?
  390.                 BNE.S   DontSkip
  391.  
  392.                 BTST    #2,$17B                 ;This is the Option key!
  393.                 BNE.S   DontSkip
  394.  
  395.                 SUBQ    #4,SP                   ;make room
  396.                 MOVE.L  #'SKIP',-(SP)           ;ask for resource
  397.                 MOVE.W  #1,-(SP)
  398.                 _GetIndResource
  399.                 MOVE.L  (SP)+,D0                ;get the result
  400.                 BEQ.S   DontSkip
  401.  
  402.                 TST.W   ResErr
  403.                 BNE.S   DontSkip                ;uh oh!
  404.  
  405.                 MOVE.L  D0,A0
  406.                 MOVE.L  (A0),D0                 ;dereference it
  407.                 AND.L   Lo3Bytes,D0
  408.                 MOVE.L  D0,A0
  409.                 JMP     (A0)
  410. PatchEnd
  411.  
  412.  
  413. ;-------------------------------------------------------------------------
  414.  
  415.  
  416.                 RESOURCE 'SKIP' 65536-16000 '' 0
  417.  
  418.                 INCLUDE Corvus:MDS:.D:FSEqu.D
  419.                 INCLUDE Corvus:MDS:.Txt:PackMacs.Txt
  420.  
  421. ;----------
  422. ;New Equates - not yet in equate files
  423. ;----------
  424.  
  425. ROM85           EQU     $28E
  426. FSFCBLen        EQU     $3F6
  427.  
  428.   .TRAP _HOpen          $A200+0
  429.   .TRAP _HGetVInfo      $A200+7
  430.   .TRAP _HCreate        $A200+8
  431.   .TRAP _HDelete        $A200+9
  432.   .TRAP _HOpenRF        $A200+10
  433.   .TRAP _HRename        $A200+11
  434.   .TRAP _HGetFileInfo   $A200+12
  435.   .TRAP _HSetFileInfo   $A200+13
  436.   .TRAP _AllocContig    $A200+16
  437.   .TRAP _SetPEOF        $A200+18
  438.   .TRAP _HGetVol        $A200+20
  439.   .TRAP _HSetVol        $A200+21
  440.   .TRAP _HSetFLock      $A200+65
  441.   .TRAP _HRstFLock      $A200+66
  442.   .TRAP _HFSDispatch    $A200+96
  443.   .TRAP _MoveHHi        $A000+100
  444.  
  445.         MACRO   _OpenWD         =
  446.         MOVEQ   #1,D0
  447.         _HFSDispatch
  448.         |
  449.  
  450.         MACRO   _GetWDInfo      =
  451.         MOVEQ   #7,D0
  452.         _HFSDispatch
  453.         |
  454.  
  455. ;New fields for _GetWDInfo:
  456. ioWDIndex       EQU     $1A                     ;Working Directory index for _GetWDInfo
  457. ioWDProcID      EQU     $1C                     ;WD's ProcID (long)
  458. ioWDVRefNum     EQU     $20                     ;WD's Volume RefNum (word)
  459. ioWDDirID       EQU     $30                     ;WD's DirID (long)
  460.  
  461. ;New field for _HGetVolInfo:
  462. ioVFndrInfo     EQU     $5A                     ;Finder information for volume
  463.  
  464.  
  465. ;----------
  466. ;SkipFinder equates
  467. ;----------
  468.  
  469. ;menu constants
  470.  
  471. AppleMenuID     EQU     128
  472. EditMenuID      EQU     129
  473.  
  474. ;get file dialog constants
  475.  
  476. getSetup        EQU     -1                      ;setup number
  477. ;getOpen        EQU     1                       ;open button
  478. getOpenDoc      EQU     2                       ;open doc button
  479. ;getCancel      EQU     3                       ;cancel button
  480. ;getEject       EQU     5                       ;eject button
  481. ;getDrive       EQU     6                       ;drive button
  482. getShutDown     EQU     12                      ;shut down button
  483. getStop         EQU     13                      ;stop skipping button
  484. getNothing      EQU     100                     ;null event number
  485. getRebuild      EQU     101                     ;rebuild list number
  486. getOpenFolder   EQU     103                     ;open folder number
  487.  
  488. ;trap constants
  489.  
  490. Pack3           EQU     $A9EA                   ;trap number for _Pack3
  491. MoveWindow      EQU     $A91B                   ;trap number for _MoveWindow
  492.  
  493. ;globals
  494.  
  495. quickGlobals    EQU     -4
  496. endQuickGlobals EQU     -grafSize               ;QuickDraw globals
  497.  
  498. currentReply    EQU     endQuickGlobals-4       ;current reply record
  499. applicationReply EQU    currentReply-rName-64   ;application reply record
  500. documentReply   EQU     applicationReply-rName-64 ;document reply record
  501.  
  502. Pack3Address    EQU     documentReply-4         ;old address of trap for Pack3
  503. MoveAddress     EQU     Pack3Address-4          ;old address of trap for MoveWindow
  504. returnAddress   EQU     MoveAddress-4           ;old return address for Pack3
  505.  
  506. owned           EQU     returnAddress-2         ;id of first owned resource
  507.  
  508. AppleMenuHandle EQU     owned-4                 ;handles to the two menus
  509. EditMenuHandle  EQU     AppleMenuHandle-4
  510.  
  511. dismissButton   EQU     EditMenuHandle-2        ;button used to dismiss the last SFPPutFile Dialog
  512. dormant         EQU     dismissButton-4         ;saving place for dormant dialogs
  513. signature       EQU     dormant-4               ;signature of chosen application
  514. stopSkipping    EQU     signature-1             ;stop skipping the Finder?
  515. allFiles        EQU     stopSkipping-1          ;option key shenanigans
  516.  
  517. totalGlobals    EQU     -allFiles
  518.  
  519. ;----------
  520. ;SkipFinder - branch right into the skipping code
  521. ;----------
  522.  
  523. FirstThingsFirst
  524.                 BRA.S   DoTheSkipping
  525.  
  526. Options         DC.W    %0000000000000010       ;flags word
  527.  
  528. ;----------
  529. ;constants
  530. ;----------
  531.  
  532. AppleMenu       DC.B    1,appleMark             ;title of Apple menu
  533. vowels          DC.B    'AEIOUaeiou'            ;list of vowels, terminated by ...
  534. nullString      DC.B    0                       ;zero byte (also for use as a null string '')
  535.                 .ALIGN  2
  536.  
  537. ;----------
  538. ;DoTheSkipping - code starts here
  539. ;----------
  540.  
  541. DoTheSkipping
  542.                 MOVE.L  BufPtr,SP
  543.                 SUB     #32,SP                  ;make room for above A5
  544.                 MOVE.L  SP,A5                   ;set up A5
  545.                 SUB     #totalGlobals,SP        ;make room for below A5
  546.                 MOVE.L  A5,CurrentA5
  547.                 MOVE.L  SP,CurStackBase
  548.                 MOVE.L  SP,StkLowPt
  549.                 MOVE.L  SP,A0
  550.                 SUB.L   DefltStack,A0
  551.                 _SetApplLimit
  552.  
  553.                 CLR.B   CurApName               ;current application has no name
  554.  
  555.                 LEA     FirstThingsFirst,A0
  556.                 _RecoverHandle                  ;get the handle to this resource
  557.                 _HLock                          ;lock us in for the duration
  558.                 MOVE.L  A0,-(SP)                ;and detach things
  559.                 MOVE.L  A0,-(SP)
  560.                 PEA     applicationReply(A5)    ;point to place for returned values
  561.                 PEA     applicationReply+2(A5)
  562.                 PEA     documentReply(A5)
  563.                 _GetResInfo
  564.                 MOVE.W  applicationReply(A5),owned(A5)
  565.                 _DetachResource
  566.  
  567. ;----------
  568. ;now that basic setup is done, initialize the "application"
  569. ;----------
  570.  
  571.                 PEA     quickGlobals(A5)
  572.                 _InitGraf
  573.                 _InitFonts
  574.                 _InitWindows
  575.                 _InitMenus
  576.                 CLR.L   -(SP)
  577.                 _InitDialogs
  578.                 _TEInit
  579.  
  580.                 SUBQ    #4,SP
  581.                 MOVE.W  #watchCursor,-(SP)      ;get the watch
  582.                 _GetCursor
  583.                 MOVE.L  (SP)+,A0                ;keep it in memory
  584.                 _HNoPurge
  585.                 MOVE.L  (A0),-(SP)
  586.                 _InitCursor                     ;clear off the cursor
  587.                 _SetCursor
  588.  
  589.                 CLR.L   dormant(A5)
  590.                 CLR.B   stopSkipping(A5)
  591.  
  592.                 SUBQ    #4,SP
  593.                 MOVE.W  #AppleMenuID,-(SP)      ;menu ID
  594.                 PEA     AppleMenu               ;point to string
  595.                 _NewMenu
  596.                 MOVE.L  (SP)+,A2
  597.  
  598.                 SUBQ    #4,SP
  599.                 MOVEQ   #4,D0
  600.                 ADD.W   owned(A5),D0
  601.                 MOVE.W  D0,-(SP)
  602.                 _GetString
  603.                 MOVE.L  (SP)+,A3
  604.  
  605.                 MOVE.L  A2,-(SP)
  606.                 MOVE.L  (A3),-(SP)
  607.                 _AppendMenu
  608.  
  609.                 MOVE.L  A3,-(SP)
  610.                 _ReleaseResource
  611.  
  612.                 MOVE.L  A2,-(SP)
  613.                 MOVE.L  #'DRVR',-(SP)
  614.                 _AddResMenu
  615.  
  616.                 MOVE.L  A2,-(SP)
  617.                 CLR.W   -(SP)
  618.                 _InsertMenu
  619.  
  620.                 MOVE.L  A2,AppleMenuHandle(A5)
  621.  
  622.                 SUBQ    #4,SP
  623.                 MOVEQ   #2,D0
  624.                 ADD.W   owned(A5),D0
  625.                 MOVE.W  D0,-(SP)
  626.                 _GetString
  627.                 MOVE.L  (SP)+,A3
  628.  
  629.                 SUBQ    #4,SP
  630.                 MOVE.W  #EditMenuID,-(SP)
  631.                 MOVE.L  (A3),-(SP)
  632.                 _NewMenu
  633.                 MOVE.L  (SP)+,A2
  634.  
  635.                 MOVE.L  A3,-(SP)
  636.                 _ReleaseResource
  637.  
  638.                 SUBQ    #4,SP
  639.                 MOVEQ   #3,D0
  640.                 ADD.W   owned(A5),D0
  641.                 MOVE.W  D0,-(SP)
  642.                 _GetString
  643.                 MOVE.L  (SP)+,A3
  644.  
  645.                 MOVE.L  A2,-(SP)
  646.                 MOVE.L  (A3),-(SP)
  647.                 _AppendMenu
  648.  
  649.                 MOVE.L  A3,-(SP)
  650.                 _ReleaseResource
  651.  
  652.                 MOVE.L  A2,-(SP)
  653.                 CLR.W   -(SP)
  654.                 _InsertMenu
  655.  
  656.                 MOVE.L  A2,-(SP)
  657.                 CLR.W   -(SP)
  658.                 _DisableItem                    ;disable Edit menu
  659.  
  660.                 MOVE.L  A2,EditMenuHandle(A5)
  661.  
  662.                 _DrawMenuBar
  663.  
  664. ;----------
  665. ;now that the application is set up and the menu is drawn, set up the files
  666. ;----------
  667.  
  668. longestQElSize  EQU     $80                     ;no param block is longer than $80
  669.  
  670.                 MOVEQ   #(longestQElSize/2)-1,D0 ;clear off a param block
  671. @1              CLR.W   -(SP)
  672.                 DBRA    D0,@1
  673.  
  674.                 MOVE.L  SP,A0
  675.  
  676. StartOver
  677.                 MOVE.L  VCBQHdr+qHead,A1        ;point to queue
  678.                 CLR.L   ioFileName(A0)
  679. NextVolume
  680.                 MOVE.W  VCBVRefNum(A1),ioVRefNum(A0)    ;put the refNum in the block
  681.  
  682.                 TST.W   VCBDrvNum(A1)           ;if in a drive, just flush
  683.                 BNE.S   @1
  684.  
  685.                 TST.W   VCBDRefNum(A1)          ;if not off line, just flush
  686.                 BMI.S   @1
  687.  
  688.                 _UnmountVol
  689.                 BRA.S   StartOver
  690. @1
  691.                 _FlushVol
  692.                 MOVE.L  (A1),A1                 ;advance through the queue
  693.                 MOVE.L  A1,D0
  694.                 BNE.S   NextVolume
  695.  
  696. ;----------
  697. ;DoDialog - load in the standard file dialogs and do the stuff
  698. ;----------
  699.  
  700. DoDialog
  701.                 MOVE.W  owned(A5),-(SP)
  702.                 _CouldDialog
  703.  
  704.                 MOVE.W  owned(A5),D0            ;get the other ID (for the second dialog)
  705.                 ADDQ.W  #2,D0
  706.                 MOVE.W  D0,-(SP)
  707.                 _CouldDialog
  708.  
  709.                 CLR.L   -(SP)                   ;offset 0,0
  710.                 PEA     nullString              ;no prompt
  711.                 PEA     ApplicationFilter       ;no file filter
  712.                 MOVE.W  #-1,-(SP)               ;all file types allowed
  713.                 CLR.L   -(SP)
  714.                 PEA     ButtonHook              ;hook for extra controls
  715.                 PEA     applicationReply(A5)    ;put the reply area
  716.                 MOVE.L  (SP),currentReply(A5)   ;remind the reply
  717.                 MOVE.W  owned(A5),-(SP)         ;id for the dialog
  718.                 PEA     MenuFilter              ;menu filter procedure
  719.                 BSR     CheckAllFiles
  720.                 BSR     .SFPGetFile
  721.  
  722.                 MOVE.W  dismissButton(A5),D0    ;shut down?
  723.                 CMP.W   #getShutDown,D0
  724.                 BEQ     PowerDown
  725.  
  726.                 TST.B   stopSkipping(A5)        ;stop skipping?
  727.                 BNE.S   NoMoreSkipping
  728.  
  729.                 MOVE.W  dismissButton(A5),D0    ;Finder button?
  730.                 CMP.W   #getCancel,D0
  731.                 BNE.S   KeepSkipping
  732.  
  733.                 BTST    #FBit,Options+1         ;keep skipping after Finder?
  734.                 BEQ.S   NoMoreSkipping
  735.  
  736.                 BSET    #7,stashed              ;keep skipping, go to Finder
  737.                 BRA.S   KeepSkipping
  738.  
  739. NoMoreSkipping
  740.                 MOVE.L  stashed,A0
  741.                 MOVE.L  (A0),A0                 ;get the old trap address
  742.                 MOVE.W  #OpenResFile,D0         ;for _OpenResFile
  743.                 _SetTrapAddress
  744.  
  745.                 MOVE.L  stashed,A0
  746.                 _DisposPtr
  747.                 CLR.L   stashed
  748.  
  749. KeepSkipping
  750.                 CLR.B   documentReply+rGood(A5) ;documentReply is not good if we never do it
  751.  
  752.                 MOVE.W  dismissButton(A5),D0    ;check if we need a document
  753.                 CMP.W   #getOpenDoc,D0
  754.                 BNE     ContinueSkipping
  755.  
  756. ;----------
  757. ;if a document is needed, find the application signature and bring up the second dialog
  758. ;----------
  759.  
  760.                 MOVE.L  SP,A0
  761.  
  762.                 MOVE.W  applicationReply+rVolume(A5),ioVRefNum(A0)
  763.                 CLR.W   ioRefNum(A0)
  764.                 LEA     applicationReply+rName(A5),A1
  765.                 MOVE.L  A1,ioFileName(A0)
  766.                 _GetFileInfo
  767.                 MOVE.L  ioFlUsrWds+4(A0),signature(A5) ;store the signature
  768.  
  769.                 PEA     applicationReply+rName(A5) ;put the application's name
  770.  
  771.                 MOVE.B  applicationReply+rName+1(A5),D0 ;get a character
  772.                 LEA     vowels,A0
  773. NextVowel
  774.                 MOVE.B  (A0)+,D1
  775.                 BEQ.S   NotAVowel
  776.                 CMP.B   D0,D1
  777.                 BNE.S   NextVowel
  778. IsAVowel
  779.                 PEA     'n'
  780.                 BRA.S   FinishVowel
  781. NotAVowel
  782.                 CLR.L   -(SP)
  783. FinishVowel
  784.                 CLR.L   -(SP)
  785.                 CLR.L   -(SP)
  786.                 _ParamText
  787.  
  788.                 CLR.L   -(SP)                   ;move onto the stack
  789.                 PEA     nullString              ;no prompt
  790.                 PEA     DocumentFilter          ;document only filter
  791.                 MOVE.W  #-1,-(SP)               ;all file types allowed
  792.                 CLR.L   -(SP)
  793.                 PEA     ButtonHook              ;hook for check box
  794.                 PEA     documentReply(A5)       ;put the reply area
  795.                 MOVE.L  (SP),currentReply(A5)   ;remember the reply
  796.                 MOVE.W  owned(A5),D0
  797.                 ADDQ.W  #2,D0
  798.                 MOVE.W  D0,-(SP)                ;id for the dialog
  799.                 PEA     MenuFilter              ;no filter procedure
  800.                 BSR     CheckAllFiles
  801.                 BSR     .SFPGetFile
  802.  
  803.                 TST.B   documentReply+rGood(A5) ;check the result
  804.                 BEQ     DoDialog
  805.  
  806. ;----------
  807. ;ContinueSkipping - now, build the Finder information and do the skip
  808. ;----------
  809.  
  810. ContinueSkipping
  811.                 SUBQ    #4,SP
  812.                 MOVE.W  #watchCursor,-(SP)      ;get the watch
  813.                 _GetCursor
  814.                 MOVE.L  (SP)+,A0                ;deref it onto stack
  815.                 MOVE.L  (A0),-(SP)
  816.                 _SetCursor
  817.  
  818.                 MOVE.L  AppParmHandle,A0        ;get the handle
  819.  
  820.                 MOVEQ   #4,D0                   ;size it down to indicate no parameters
  821.                 TST.B   documentReply+rGood(A5) ;check if there are parameters
  822.                 BEQ.S   NoDocument
  823.                 MOVE.B  documentReply+rName(A5),D0 ;get the size
  824.                 ADD.W   #13,D0                  ;+13
  825. NoDocument
  826.                 _SetHandleSize
  827.                 BNE.S   DidFinderInfo           ;if no error:
  828.                 TST.W   ROM85
  829.                 BMI.S   @1
  830.                 _MoveHHi
  831. @1
  832.                 MOVE.L  (A0),A0                 ;dereference and
  833.                 CLR.L   (A0)                    ;clear it
  834.                 TST.B   documentReply+rGood(A5) ;was it good?
  835.                 BEQ.S   DidFinderInfo
  836.                 MOVE.W  dismissButton(A5),D0
  837.                 CMP.W   #getOpenDoc,D0          ;was it a print?
  838.                 BNE.S   NotPrint
  839.                 ADDQ.W  #1,(A0)                 ;set for print
  840. NotPrint
  841.                 ADDQ.L  #1,(A0)+                ;set for 1 file
  842.                 MOVE.W  documentReply+rVolume(A5),(A0)+
  843.                 MOVE.L  documentReply+rType(A5),(A0)+
  844.                 MOVE.W  documentReply+rVersion(A5),(A0)+
  845.                 MOVEQ   #0,D0
  846.                 LEA     documentReply+rName(A5),A1
  847.                 MOVE.B  (A1),D0
  848. @1
  849.                 MOVE.B  (A1)+,(A0)+             ;move the name in
  850.                 DBRA    D0,@1
  851. DidFinderInfo
  852.  
  853. ;----------
  854. ;now that the finder info is built, switch systems if we want to
  855. ;----------
  856.  
  857.                 MOVE.W  applicationReply+rVolume(A5),D3
  858.                 CMP.W   BootDrive,D3            ;boot disk is already OK
  859.                 BEQ     DontSwitchSystems
  860.  
  861.                 BTST    #HBit,Options+1         ;options say don't switch
  862.                 BEQ     DontSwitchSystems
  863.  
  864.                 MOVE.L  SP,A0                   ;point to param block
  865.                 MOVE.W  applicationReply+rVolume(A5),ioVRefNum(A0)
  866.                 _SetVol
  867.  
  868.                 TST.W   FSFCBLen
  869.                 BMI.S   GotVRefNum
  870.  
  871.                 CLR.W   ioWDIndex(A0)
  872.                 _GetWDInfo                      ;get the volume ID
  873.                 BMI.S   GotVRefNum
  874.  
  875.                 CLR.L   ioFileName(A0)
  876.                 CLR.W   ioVolIndex(A0)
  877.                 _HGetVInfo                      ;get the system volume
  878.                 BMI.S   GotVRefNum
  879.  
  880.                 MOVE.L  ioVFndrInfo(A0),ioWDDirID(A0)
  881.                 _HSetVol
  882. GotVRefNum
  883.                 CLR.W   ioVRefNum(A0)
  884.  
  885.                 MOVE.L  #SysResName,ioFileName(A0)
  886.                 _GetFileInfo
  887.                 BNE.S   DontSwitchSystems       ;doesn't exist, don't switch
  888.  
  889.                 TST.W   ioRefNum(A0)            ;check if already open
  890.                 BNE.S   DontSwitchSystems
  891.  
  892.                 MOVE.L  #FinderName,ioFileName(A0)
  893.                 _GetFileInfo
  894.                 BNE.S   DontSwitchSystems
  895.  
  896.                 SUBQ    #4,SP
  897.                 _LodeScrap
  898.                 ADDQ    #4,SP
  899.  
  900.                 CLR.W   -(SP)
  901.                 _CloseResFile                   ;close all the resource files
  902.  
  903.                 MOVE.L  SP,A0
  904.  
  905.                 CLR.L   ioFileName(A0)
  906.                 _GetVol                         ;find the boot volume
  907.  
  908.                 TST.W   FSFCBLen
  909.                 BMI.S   SetBootDrive
  910.  
  911.                 _HGetVol                        ;get that volume
  912.  
  913.                 CLR.L   ioFileName(A0)
  914.                 MOVE.L  #'SKIP',ioWDProcID(A0)
  915.                 _OpenWD                         ;open it as a WD
  916.  
  917.                 _SetVol                         ;point to it
  918. SetBootDrive
  919.                 MOVE.W  ioVRefNum(A0),BootDrive ;set the boot drive correctly
  920.  
  921.                 SUBQ    #2,SP                   ;open the new system file
  922.                 _InitResources
  923.                 ADDQ    #2,SP                   ;discard returned integer
  924.  
  925.                 _InitFonts
  926. DontSwitchSystems
  927.  
  928. ;----------
  929. ;now that we have switched systems if desired do a Finder launch or other launch
  930. ;----------
  931.  
  932.                 MOVE.W  dismissButton(A5),D0
  933.                 CMP.W   #getCancel,D0           ;did he press the Finder button?
  934.                 BNE.S   NotFinder
  935.  
  936. ;----------
  937. ;Finder launch
  938. ;----------
  939.  
  940.                 MOVE.L  SP,A0
  941.                 MOVE.W  BootDrive,ioVRefNum(A0)
  942.                 _SetVol                         ;run the Finder on the correct volume
  943.  
  944.                 CLR.W   -(SP)
  945.                 PEA     FinderName
  946.                 MOVE.L  SP,A0
  947.                 _Launch                         ;Launch away!
  948.  
  949. ;----------
  950. ;other application launch
  951. ;----------
  952.  
  953. NotFinder
  954.                 MOVE.L  SP,A0
  955.                 MOVE.W  applicationReply+rVolume(A5),ioVRefNum(A0)
  956.                 _SetVol                         ;run the application on the correct volume
  957.  
  958.                 CLR.W   -(SP)
  959.                 PEA     applicationReply+rName(A5)
  960.                 MOVE.L  SP,A0
  961.                 _Launch                         ;Launch away!
  962.  
  963. ;----------
  964. ;PowerDown - shut down the Mac
  965. ;----------
  966.  
  967. PowerDown
  968.                 CLR.W   -(SP)                   ;close all resource files
  969.                 _CloseResFile
  970.  
  971.                 MOVE.L  SP,A0                   ;point to the io block
  972. EjectVolume
  973.                 MOVE.L  VCBQHdr+qHead,A1        ;get the first VCB Queue entry
  974.                 MOVE.L  A1,D0                   ;check A1
  975.                 BEQ.S   Restart
  976.  
  977.                 MOVE.W  VCBVRefNum(A1),ioVRefNum(A0)    ;eject a volume
  978.                 _Eject
  979.                 _UnmountVol
  980.  
  981.                 BRA.S   EjectVolume
  982. Restart
  983.                 MOVE.L  ROMBase,A0
  984.                 RESET
  985.                 JMP     10(A0)
  986.  
  987.  
  988. ;----------
  989. ;ApplicationFilter - selects only applications, or all documents if we are not as picky
  990. ;----------
  991.  
  992. ApplicationFilter
  993.                 MOVE.L  (SP)+,A0                ;get the return address
  994.  
  995.                 MOVE.L  (SP)+,A1                ;get the param block pointer
  996.                 CLR.W   (SP)                    ;clear the result by default
  997.  
  998.                 MOVE.B  allFiles(A5),D0         ;if all files, bypass APPL check
  999.                 BNE.S   IsApplication
  1000.  
  1001.                 CMP.L   #'APPL',ioFlUsrWds(A1)  ;check file type = APPL
  1002.                 BEQ.S   IsApplication
  1003.                 ST      (SP)                    ;an non application shouldn't be
  1004. IsApplication
  1005.                 JMP     (A0)
  1006.  
  1007.  
  1008. ;----------
  1009. ;DocumentFilter - selects only documents with the right creator, unless we are not very picky
  1010. ;----------
  1011.  
  1012. DocumentFilter
  1013.                 MOVE.L  (SP)+,A0                ;get the return address
  1014.  
  1015.                 MOVE.L  (SP)+,A1                ;get the param block pointer
  1016.                 CLR.W   (SP)                    ;clear the result by default
  1017.  
  1018.                 CMP.L   #'APPL',ioFlUsrWds(A1)  ;check file type = APPL
  1019.                 BEQ.S   NotDocument
  1020.  
  1021.                 MOVE.B  allFiles(A5),D0         ;if all files, bypass signature check
  1022.                 BNE.S   IsDocument
  1023.  
  1024.                 MOVE.L  ioFlUsrWds+4(A1),D0     ;get the creator
  1025.                 CMP.L   signature(A5),D0        ;is it equal?
  1026.                 BEQ.S   IsDocument
  1027. NotDocument
  1028.                 ST      (SP)                    ;an application shouldn't be
  1029. IsDocument
  1030.                 JMP     (A0)
  1031.  
  1032.  
  1033. ;----------
  1034. ;ButtonHook - handle all the niceties of the standard file dialog
  1035. ;----------
  1036.  
  1037. dialogPtr       EQU     8
  1038. item            EQU     12
  1039. result          EQU     14
  1040.  
  1041. type            EQU     -2
  1042. box             EQU     type-8
  1043. controlHandle   EQU     box-4
  1044.  
  1045. needed          EQU     controlHandle
  1046.  
  1047. TrackButton
  1048.                 MOVE.W  D0,result(A6)
  1049.  
  1050.                 MOVE.L  dialogPtr(A6),-(SP)
  1051.                 MOVE.W  D0,-(SP)
  1052.                 PEA     type(A6)
  1053.                 PEA     controlHandle(A6)
  1054.                 PEA     box(A6)
  1055.                 _GetDItem
  1056.  
  1057.                 MOVE.L  controlHandle(A6),A0
  1058.                 MOVE.L  (A0),A0
  1059.                 MOVE.B  contrlHilite(A0),D0
  1060.                 CMP.B   #254,D0
  1061.                 BLO.S   FlashButton
  1062.  
  1063.                 CLR.W   result(A6)
  1064.                 BRA.S   AlmostDone
  1065. FlashButton
  1066.                 MOVE.L  controlHandle(A6),-(SP)
  1067.                 BSR     FlashControl            ;flash the control
  1068.  
  1069. AlmostDone
  1070.                 MOVE.W  result(A6),D0
  1071.                 BRA     RescanButton
  1072.  
  1073. EnterKey
  1074.                 MOVEQ   #getOpenDoc,D0          ;Open.../Print
  1075.                 BRA.S   TrackButton
  1076.  
  1077. BackspaceKey
  1078.                 MOVEQ   #getCancel,D0           ;Finder/Cancel
  1079.                 BRA.S   TrackButton
  1080.  
  1081. TabKey
  1082. CmdDKey
  1083.                 MOVEQ   #getDrive,D0            ;Drive
  1084.                 BRA.S   TrackButton
  1085.  
  1086. ReturnKey
  1087.                 MOVEQ   #getOpen,D0             ;Open
  1088.                 BRA     TrackButton
  1089.  
  1090. CmdTabKey
  1091. CmdEKey
  1092.                 MOVEQ   #getEject,D0            ;Eject
  1093.                 BSR     TrackButton
  1094.  
  1095. Cmd.Key
  1096. CmdQKey
  1097.                 MOVEQ   #getShutDown,D0         ;Shut Down
  1098.                 BSR     TrackButton
  1099.  
  1100. ButtonHook
  1101.                 LINK    A6,#needed
  1102.  
  1103.                 MOVE.W  item(A6),D0
  1104. RescanButton
  1105.                 MOVE.W  D0,dismissButton(A5)
  1106.                 LEA     ButtonTable,A0
  1107. NextButton
  1108.                 TST.W   (A0)
  1109.                 BEQ.S   StuffResult
  1110.                 MOVE.L  (A0)+,D1
  1111.                 SWAP    D1
  1112.                 CMP.W   D1,D0
  1113.                 BNE     NextButton
  1114.                 SWAP    D1
  1115.                 JMP     ButtonTable(D1.W)
  1116.  
  1117. ButtonTable
  1118.                 DC.W    $1003,EnterKey-ButtonTable
  1119.                 DC.W    $1008,BackspaceKey-ButtonTable
  1120.                 DC.W    $1009,TabKey-ButtonTable
  1121.                 DC.W    $1109,CmdTabKey-ButtonTable
  1122.                 DC.W    $100D,ReturnKey-ButtonTable
  1123.                 DC.W    $112E,Cmd.Key-ButtonTable
  1124.                 DC.W    $1144,CmdDKey-ButtonTable
  1125.                 DC.W    $1164,CmdDKey-ButtonTable
  1126.                 DC.W    $1145,CmdEKey-ButtonTable
  1127.                 DC.W    $1165,CmdEKey-ButtonTable
  1128.                 DC.W    $1151,CmdQKey-ButtonTable
  1129.                 DC.W    $1171,CmdQKey-ButtonTable
  1130.  
  1131.                 DC.W    getOpen,OpenButton-ButtonTable
  1132.                 DC.W    getOpenDoc,OpenDocButton-ButtonTable
  1133.                 DC.W    getShutDown,ShutDownButton-ButtonTable
  1134.                 DC.W    getStop,StopButton-ButtonTable
  1135.                 DC.W    getNothing,Nothing-ButtonTable
  1136.  
  1137.                 DC.W    0
  1138.  
  1139. StuffResult
  1140.                 CMP.W   #$1100,D0               ;it does not understand>1100!
  1141.                 BLO.S   @1
  1142.                 MOVEQ   #0,D0
  1143. @1
  1144.                 MOVE.W  D0,result(A6)
  1145. DoneButton
  1146.                 UNLK    A6
  1147.                 MOVE.L  (SP)+,A0                ;get return address
  1148.                 ADDQ    #6,SP                   ;pop off parameters
  1149.                 JMP     (A0)
  1150.  
  1151. OpenButton
  1152.                 MOVE.L  currentReply(A5),A0
  1153.                 TST.B   rName(A0)
  1154.                 BNE.S   StuffResult
  1155.                 MOVEQ   #getOpenFolder,D0       ;Open folder
  1156.                 BRA.S   StuffResult
  1157.  
  1158. OpenDocButton
  1159.                 MOVE.L  dialogPtr(A6),-(SP)
  1160.                 MOVE.W  #getOpen,-(SP)
  1161.                 PEA     type(A6)
  1162.                 PEA     controlHandle(A6)
  1163.                 PEA     box(A6)
  1164.                 _GetDItem
  1165.  
  1166.                 MOVE.L  controlHandle(A6),A0
  1167.                 MOVE.L  (A0),A0
  1168.                 MOVE.B  contrlHilite(A0),D0
  1169.                 CMP.B   #254,D0
  1170.                 BHS.S   NoButton
  1171.  
  1172. ;               BRA.S   FakeOpenButton
  1173.  
  1174. ShutDownButton
  1175. ;               BRA.S   FakeOpenButton
  1176.  
  1177. FakeOpenButton
  1178.                 MOVEQ   #getOpen,D0             ;simulate an open
  1179.                 BRA.S   StuffResult
  1180.  
  1181. StopButton
  1182.                 MOVE.L  dialogPtr(A6),-(SP)
  1183.                 MOVE.W  D0,-(SP)                ;item number
  1184.                 PEA     type(A6)
  1185.                 PEA     controlHandle(A6)
  1186.                 PEA     box(A6)
  1187.                 _GetDItem
  1188.  
  1189.                 SUBQ    #4,SP
  1190.                 MOVE.W  owned(A5),D0
  1191.  
  1192.                 LEA     stopSkipping(A5),A0
  1193.                 TST.B   (A0)
  1194.                 SEQ     (A0)
  1195.                 BNE.S   @1
  1196.                 ADDQ.W  #1,D0
  1197. @1
  1198.                 MOVE.W  D0,-(SP)
  1199.                 _GetString
  1200.                 MOVE.L  (SP),A0
  1201.                 MOVE.L  controlHandle(A6),-(SP)
  1202.                 MOVE.L  (A0),-(SP)
  1203.                 _SetCTitle
  1204.                 _ReleaseResource
  1205. ;               BRA.S   NoButton
  1206.  
  1207. NoButton
  1208.                 MOVE.W  #getNothing,D0
  1209.                 BRA     StuffResult
  1210.  
  1211. Nothing
  1212.                 BSR.S   CheckAllFiles
  1213.                 BEQ     StuffResult
  1214.                 MOVE.W  #getRebuild,D0
  1215.                 BRA     StuffResult
  1216.  
  1217. CheckAllFiles
  1218.                 LEA     allFiles(A5),A0
  1219.                 MOVEQ   #0,D0
  1220.                 BTST    #2,$17B                 ;This is the Option key!
  1221.                 BEQ.S   NotAllFIles
  1222.                 MOVEQ   #-1,D0
  1223. NotAllFiles
  1224.                 MOVE.B  (A0),D1
  1225.                 MOVE.B  D0,(A0)
  1226.                 CMP.B   D0,D1
  1227.                 RTS
  1228.  
  1229.  
  1230. ;----------
  1231. ;MenuFiler - handle all the things associated with the menu and the Open.../Print button
  1232. ;----------
  1233.  
  1234. MenuFilter
  1235.                 LINK    A6,#0
  1236.  
  1237.                 ;before we start the menu, fix the Open.../Print button
  1238.  
  1239.                 MOVE.L  theDialog(A6),-(SP)
  1240.                 MOVE.W  #getOpen,-(SP)
  1241.                 PEA     scratch20
  1242.                 PEA     scratch20+2             ;getOpen in scratch20+2
  1243.                 PEA     scratch8
  1244.                 _GetDItem
  1245.  
  1246.                 MOVE.L  theDialog(A6),-(SP)
  1247.                 MOVE.W  #getOpenDoc,-(SP)
  1248.                 PEA     scratch20
  1249.                 PEA     scratch20+6             ;getOpenDoc in scratch20+6
  1250.                 PEA     scratch8
  1251.                 _GetDItem
  1252.  
  1253.                 MOVEQ   #0,D0
  1254.  
  1255.                 MOVE.L  scratch20+2,A0
  1256.                 MOVE.L  (A0),A0
  1257.                 TST.B   contrlHilite(A0)
  1258.                 BNE.S   DoUnHilite              ;decide whether to hilite
  1259.  
  1260.                 MOVE.L  currentReply(A5),A0
  1261.                 TST.B   rName(A0)
  1262.                 BNE.S   DoHilite                ;decide whether to hilite
  1263. DoUnHilite
  1264.                 MOVE.B  #255,D0
  1265. DoHilite
  1266.                 MOVE.L  scratch20+6,A0
  1267.                 MOVE.L  (A0),A0
  1268.                 CMP.B   contrlHilite(A0),D0
  1269.                 BEQ.S   DontHiliteOpenDoc
  1270.  
  1271.                 MOVE.L  scratch20+6,-(SP)
  1272.                 MOVE.W  D0,-(SP)
  1273.                 _HiliteControl
  1274. DontHiliteOpenDoc
  1275.  
  1276. NextFilter
  1277.                 CLR.B   filtered(A6)
  1278.  
  1279.                 MOVE.L  theEvent(A6),A0
  1280.  
  1281.                 CMP.W   #mButDwnEvt,(A0)
  1282.                 BNE.S   NotMouseDown
  1283.  
  1284.                 SUBQ    #2,SP
  1285.                 MOVE.L  evtMouse(A0),-(SP)
  1286.                 PEA     scratch20
  1287.                 _FindWindow
  1288.                 MOVE.W  (SP)+,D0
  1289.  
  1290.                 CMP.W   #inMenuBar,D0
  1291.                 BNE.S   NotMouseMenu
  1292.  
  1293.                 MOVE.L  theEvent(A6),A0
  1294.  
  1295.                 SUBQ    #4,SP
  1296.                 MOVE.L  evtMouse(A0),-(SP)
  1297.                 _MenuSelect
  1298.  
  1299.                 BSR     DoMenuItem
  1300.  
  1301.                 BRA.S   DoneMouseDown
  1302. NotMouseMenu
  1303.                 CMP.W   #inSysWindow,D0
  1304.                 BNE.S   NotMouseDA
  1305.  
  1306.                 MOVE.L  theEvent(A6),-(SP)
  1307.                 MOVE.L  scratch20,-(SP)
  1308.                 _SystemClick
  1309.                 BRA.S   DoneMouseDown
  1310. NotMouseDA
  1311.                 CMP.W   #inDesk,D0
  1312.                 BNE     DoneMenuFilter
  1313. DoneMouseDown
  1314. DoneKeyDown
  1315. DoneUpdate
  1316.                 MOVE.L  theEvent(A6),A0
  1317.                 CLR.W   (A0)
  1318.                 BRA     DoneMenuFilter
  1319. NotMouseDown
  1320.                 CMP.W   #keyDwnEvt,(A0)
  1321.                 BNE.S   NotKeyDown
  1322.  
  1323.                 MOVE.L  evtMessage(A0),D0
  1324.                 AND.W   #$FF,D0
  1325.  
  1326.                 BTST    #cmdKey-8,evtMeta(A0)
  1327.                 BEQ.S   NotCmdKey
  1328.  
  1329.                 SUBQ    #4,SP
  1330.                 MOVE.W  D0,-(SP)
  1331.                 _MenuKey
  1332.  
  1333.                 TST.W   (SP)
  1334.                 BEQ.S   IsCmdKey
  1335.  
  1336.                 BSR     DoMenuItem
  1337.                 BRA.S   DoneKeyDown
  1338. IsCmdKey
  1339.                 ADDQ    #4,SP
  1340.                 MOVE.L  theEvent(A6),A0
  1341.                 MOVE.L  evtMessage(A0),D0
  1342.                 AND.W   #$FF,D0
  1343.  
  1344.                 CMP.W   #9,D0
  1345.                 BEQ.S   @1
  1346.  
  1347.                 CMP.W   #$20,D0
  1348.                 BLO.S   DoneMenuFilter
  1349. @1
  1350.                 ADD.W   #$1100,D0
  1351.                 BRA.S   FilterKey
  1352. NotCmdKey
  1353.                 CMP.W   #$20,D0
  1354.                 BHS.S   DoneMenuFilter
  1355.  
  1356.                 ADD.W   #$1000,D0
  1357. FilterKey
  1358.                 MOVE.L  itemHit(A6),A0
  1359.                 MOVE.W  D0,(A0)
  1360.                 ADDQ.B  #1,filtered(A6)
  1361.                 BRA.S   DoneKeyDown
  1362. NotKeyDown
  1363.                 CMP.W   #updatEvt,(A0)
  1364.                 BNE.S   DoneMenuFilter
  1365.  
  1366.                 MOVE.L  theDialog(A6),D0
  1367.  
  1368.                 MOVE.L  D0,-(SP)
  1369.                 MOVE.L  D0,-(SP)
  1370.                 MOVE.L  D0,-(SP)
  1371.                 MOVE.L  D0,-(SP)
  1372.  
  1373.                 _BeginUpdate
  1374.                 _DrawDialog
  1375.                 BSR     OutlineButton
  1376.  
  1377.                 TST.L   dormant(A5)
  1378.                 BEQ.S   @1
  1379.  
  1380.                 MOVE.L  (SP),-(SP)
  1381.                 BSR     DimWindow
  1382. @1
  1383.                 _EndUpdate
  1384.  
  1385.                 BRA     DoneUpdate
  1386.  
  1387. DoneMenuFilter
  1388.                 SUBQ    #4,SP
  1389.                 _FrontWindow
  1390.                 LEA     dormant(A5),A1
  1391.                 MOVE.L  (SP)+,D0
  1392.  
  1393.                 CMP.L   theDialog(A6),D0
  1394.                 BEQ.S   BringBackDialog
  1395.                 TST.L   (A1)
  1396.                 BEQ.S   DimDownDialog
  1397.                 BRA.S   NextEvent
  1398.  
  1399. DimDownDialog
  1400.                 MOVE.L  theDialog(A6),A0
  1401.                 MOVE.L  A0,(A1)
  1402.                 MOVE.L  A0,-(SP)
  1403.                 BSR     DimWindow
  1404.  
  1405.                 MOVE.L  EditMenuHandle(A5),-(SP)
  1406.                 CLR.W   -(SP)
  1407.                 _EnableItem
  1408.                 _DrawMenuBar
  1409.  
  1410. NextEvent
  1411.                 _SystemTask
  1412.  
  1413.                 SUBQ    #2,SP
  1414.                 MOVE.W  #-1,-(SP)
  1415.                 MOVE.L  theEvent(A6),-(SP)
  1416.                 _GetNextEvent
  1417.                 TST.B   (SP)+
  1418.                 BEQ.S   NextEvent
  1419.  
  1420.                 BRA     NextFilter
  1421.  
  1422. BringBackDialog
  1423.                 MOVE.L  (A1),D0
  1424.                 BEQ.S   @1
  1425.                 CLR.L   (A1)
  1426.  
  1427.                 MOVE.L  D0,-(SP)
  1428.                 MOVE.L  D0,-(SP)
  1429.                 MOVE.L  D0,-(SP)
  1430.  
  1431.                 _DrawDialog
  1432.                 BSR     OutlineButton
  1433.  
  1434.                 MOVE.L  (SP)+,A0
  1435.                 MOVE.L  visRgn(A0),-(SP)
  1436.                 _ValidRgn
  1437.  
  1438.                 MOVE.L  EditMenuHandle(A5),-(SP)
  1439.                 CLR.W   -(SP)
  1440.                 _DisableItem
  1441.                 _DrawMenuBar
  1442. @1
  1443.                 UNLK    A6
  1444.                 MOVE.L  (SP)+,A0                ;get return address
  1445.                 ADD     #12,SP                  ;pop off parameters
  1446.                 JMP     (A0)
  1447.  
  1448.  
  1449. DoMenuItem
  1450.                 MOVE.L  (SP)+,A0
  1451.                 MOVE.W  (SP)+,D0                ;get the menu number
  1452.                 MOVE.W  (SP)+,D1                ;get the item number
  1453.                 MOVE.L  A0,-(SP)
  1454.  
  1455.                 CMP.W   #AppleMenuID,D0
  1456.                 BNE     NotAppleMenu
  1457.  
  1458.                 CMP.W   #2,D1
  1459.                 BHI     OpenDeskAccessory
  1460.  
  1461. ;----------
  1462. ;AboutScreen - bring up the about screen
  1463. ;----------
  1464.  
  1465. AboutScreen
  1466.                 SUBQ    #4,SP
  1467.                 MOVE.W  owned(A5),-(SP)
  1468.                 _GetPicture
  1469.                 MOVE.L  (SP),A0                 ;get the resource handle
  1470.                 MOVE.L  (A0),A0                 ;dereference
  1471.  
  1472.                 MOVE.L  picFrame+topLeft(A0),scratch20+topLeft
  1473.                 MOVE.L  picFrame+botRight(A0),scratch20+botRight
  1474.  
  1475.                 SUBQ    #4,SP
  1476.                 CLR.L   -(SP)
  1477.                 PEA     scratch20
  1478.                 PEA     nullString
  1479.                 MOVE.B  #0,-(SP)
  1480.                 MOVE.W  #dBoxProc,-(SP)
  1481.                 MOVE.L  MinusOne,-(SP)
  1482.                 CLR.B   -(SP)
  1483.                 CLR.L   -(SP)
  1484.                 _NewWindow
  1485.  
  1486.                 MOVE.L  (SP)+,A0                ;get window
  1487.                 MOVE.L  (SP)+,A1                ;get picture
  1488.  
  1489.                 MOVE.L  A0,-(SP)                ;put window
  1490.                 MOVE.L  A1,-(SP)                ;put picture
  1491.                 MOVE.L  A1,-(SP)                ;put picture
  1492.                 MOVE.L  A0,-(SP)                ;put window
  1493.                 MOVE.L  A0,-(SP)                ;put window
  1494.                 MOVE.L  A0,-(SP)                ;put window
  1495.  
  1496.                 BSR     CenterWindow            ;use window
  1497.                 _ShowWindow                     ;use window
  1498.                 _SetPort                        ;use window
  1499.                 PEA     scratch20
  1500.                 _DrawPicture                    ;use picture
  1501.                 _ReleaseResource                ;use picture
  1502. AboutLoop
  1503.                 SUBQ    #2,SP
  1504.                 MOVE.W  #$003F,-(SP)
  1505.                 PEA     scratch20
  1506.                 _GetNextEvent
  1507.                 TST.B   (SP)+
  1508.                 BEQ.S   AboutLoop
  1509.  
  1510.                 CMP.W   #mButDwnEvt,scratch20+evtNum
  1511.                 BEQ.S   DoneAbout
  1512.  
  1513.                 CMP.W   #keyDwnEvt,scratch20+evtNum
  1514.                 BNE.S   AboutLoop
  1515.  
  1516.                 CMP.B   #3,scratch20+evtMessage+3
  1517.                 BEQ.S   DoneAbout
  1518.  
  1519.                 CMP.B   #13,scratch20+evtMessage+3
  1520.                 BNE.S   AboutLoop
  1521.  
  1522. DoneAbout
  1523.                 _DisposWindow                   ;use window
  1524.  
  1525.                 BRA.S   DoneMenuItem
  1526.  
  1527. ;----------
  1528. ;OpenDeskAccessory - open a desk accessory
  1529. ;----------
  1530.  
  1531. OpenDeskAccessory
  1532.                 SUB     #256,SP
  1533.                 MOVE.L  AppleMenuHandle(A5),-(SP)
  1534.                 MOVE.W  D1,-(SP)
  1535.                 PEA     6(SP)
  1536.                 _GetItem
  1537.  
  1538.                 BSET    #7,stashed
  1539.                 SUBQ    #2,SP
  1540.                 PEA     2(SP)
  1541.                 _OpenDeskAcc
  1542.                 ADD     #256+2,SP
  1543.                 BCLR    #7,stashed
  1544.  
  1545.                 CLR.W   -(SP)
  1546.                 _HiliteMenu
  1547.                 _DrawMenuBar
  1548.                 RTS
  1549.  
  1550.  
  1551. NotAppleMenu
  1552.                 CMP.W   #EditMenuID,D0
  1553.                 BNE.S   DoneMenuItem
  1554.  
  1555.                 SUBQ.W  #1,D1
  1556.                 SUBQ    #2,SP
  1557.                 MOVE.W  D1,-(SP)
  1558.                 _SysEdit
  1559.                 ADDQ    #2,SP
  1560. DoneMenuItem
  1561.                 CLR.W   -(SP)
  1562.                 _HiliteMenu
  1563.                 RTS
  1564.  
  1565.  
  1566. ;----------
  1567. ;DimWindow - dim down the contents of a window
  1568. ;----------
  1569.  
  1570. DimWindow
  1571.                 MOVE.L  (SP)+,A1
  1572.                 MOVE.L  (SP)+,A0
  1573.                 MOVE.L  A1,-(SP)
  1574.  
  1575.                 PEA     portRect(A0)
  1576.                 MOVE.L  A0,-(SP)
  1577.                 _SetPort
  1578.                 MOVE.L  (A5),A0
  1579.                 PEA     gray(A0)
  1580.                 _PenPat
  1581.                 MOVE.W  #patBic,-(SP)
  1582.                 _PenMode
  1583.                 _PaintRect
  1584.                 _PenNormal
  1585.                 RTS
  1586.  
  1587.  
  1588. ;----------
  1589. ;OutlineButton - outline the button that is default (button #1)
  1590. ;----------
  1591.  
  1592. OutlineButton
  1593.                 MOVE.L  4(SP),-(SP)
  1594.                 _SetPort
  1595.  
  1596.                 MOVE.L  4(SP),-(SP)
  1597.                 MOVE.W  #1,-(SP)                ;item 1 is always default
  1598.                 PEA     scratch20
  1599.                 PEA     scratch20+2
  1600.                 PEA     scratch8
  1601.                 _GetDItem
  1602.  
  1603.                 LEA     scratch8,A0             ;rectangle
  1604.                 MOVEQ   #3,D0                   ;width of outline
  1605.                 MOVEQ   #16,D1                  ;rounding factor of outline
  1606.                 MOVEQ   #-4,D2                  ;inset of outline
  1607.  
  1608.                 MOVE.L  A0,-(SP)                ;FrameRoundRect
  1609.                 MOVE.W  D1,-(SP)
  1610.                 MOVE.W  D1,-(SP)
  1611.  
  1612.                 MOVE.L  A0,-(SP)                ;InsetRect
  1613.                 MOVE.W  D2,-(SP)
  1614.                 MOVE.W  D2,-(SP)
  1615.  
  1616.                 MOVE.W  D0,-(SP)                ;PenSize
  1617.                 MOVE.W  D0,-(SP)
  1618.  
  1619.                 _PenSize
  1620.                 _InsetRect
  1621.                 _FrameRoundRect
  1622.  
  1623.                 MOVE.L  (SP)+,(SP)
  1624.                 RTS
  1625.  
  1626.  
  1627. ;----------
  1628. ;.SFPGetFile - this is the substitute _SFPGetFile that prevents anything
  1629. ;              from calling standard file while it is running
  1630. ;----------
  1631.  
  1632. .SFPGetFile
  1633.                 MOVE.L  (SP)+,returnAddress(A5)
  1634.  
  1635.                 MOVE.W  #Pack3,D0
  1636.                 _GetTrapAddress
  1637.                 MOVE.L  A0,Pack3Address(A5)
  1638.                 MOVE.L  A0,A1
  1639.  
  1640.                 MOVE.W  #MoveWindow,D0
  1641.                 _GetTrapAddress
  1642.                 MOVE.L  A0,MoveAddress(A5)
  1643.  
  1644.                 MOVEQ   #6,D0
  1645.                 _NewPtr ,SYS
  1646.                 MOVE.W  #Pack3,D0
  1647.                 _SetTrapAddress
  1648.                 MOVE.W  #$4EF9,(A0)+            ;JMP ABS.L
  1649.                 PEA     PatchStdFile
  1650.                 MOVE.L  (SP)+,(A0)+
  1651.  
  1652.                 MOVEQ   #6,D0
  1653.                 _NewPtr ,SYS
  1654.                 MOVE.W  #MoveWindow,D0
  1655.                 _SetTrapAddress
  1656.                 MOVE.W  #$4EF9,(A0)+            ;JMP ABS.L
  1657.                 PEA     PatchMoveWindow
  1658.                 MOVE.L  (SP)+,(A0)+
  1659.  
  1660.                 MOVE.W  #sfPGetFile,-(SP)       ;put selector on stack
  1661.                 JSR     (A1)
  1662.  
  1663.                 MOVE.W  #Pack3,D0
  1664.                 _GetTrapAddress
  1665.                 _DisposPtr
  1666.  
  1667.                 MOVE.W  #Pack3,D0
  1668.                 MOVE.L  Pack3Address(A5),A0
  1669.                 _SetTrapAddress
  1670.  
  1671.                 MOVE.L  returnAddress(A5),-(SP)
  1672.                 RTS
  1673.  
  1674.  
  1675. ;----------
  1676. ;PatchStdFile - what PACK 3 calls while .SFPGetFile is working
  1677. ;----------
  1678.  
  1679. PatchStdFile
  1680.                 MOVE.L  (SP)+,A0
  1681.  
  1682.                 MOVE.W  (SP)+,D0                ;get the selector
  1683.                 CMP.W   #sfPutFile,D0
  1684.                 BEQ.S   SFPutFile.
  1685.                 CMP.W   #sfPPutFile,D0
  1686.                 BEQ.S   SFPPutFile.
  1687.                 CMP.W   #sfGetFile,D0
  1688.                 BEQ.S   SFGetFile.
  1689.                 CMP.W   #sfPGetFile,D0
  1690.                 BEQ.S   SFPGetFile.
  1691.                 MOVEQ   #20,D0                  ;dsNoPk3
  1692.                 _SysError
  1693. SFPPutFile.
  1694.                 ADDQ    #6,SP
  1695. SFPutFile.
  1696.                 MOVE.L  (SP)+,A1
  1697.                 ADD     #16,SP
  1698.                 BRA.S   FinishStdFile
  1699. SFPGetFile.
  1700.                 ADDQ    #6,SP
  1701. SFGetFile.
  1702.                 MOVE.L  (SP)+,A1
  1703.                 ADD     #22,SP
  1704. ;               BRA.S   FinishStdFile
  1705. FinishStdFile
  1706.                 CLR.B   (A1)
  1707.                 MOVE.L  A0,-(SP)
  1708.  
  1709.                 MOVE.W  owned(A5),D0
  1710.                 ADDQ.W  #3,D0
  1711.  
  1712.                 SUBQ    #4,SP
  1713.                 MOVE.W  D0,-(SP)
  1714.                 CLR.L   -(SP)
  1715.                 MOVE.L  #-1,-(SP)
  1716.                 _GetNewDialog
  1717.  
  1718.                 MOVE.L  (SP),-(SP)
  1719.                 BSR     CenterWindow
  1720.  
  1721.                 MOVE.L  (SP),-(SP)
  1722.                 _ShowWindow
  1723.  
  1724.                 PEA     SFFilter
  1725.                 PEA     scratch20
  1726.                 _ModalDialog
  1727.  
  1728.                 _DisposDialog
  1729.  
  1730.                 RTS
  1731.  
  1732.  
  1733. ;----------
  1734. ;PatchMoveWindow - what MoveWindow calls the first time after SF is called
  1735. ;----------
  1736.  
  1737. PatchMoveWindow
  1738.                 MOVE.W  #MoveWindow,D0
  1739.                 _GetTrapAddress
  1740.                 _DisposPtr
  1741.  
  1742.                 MOVE.W  #MoveWindow,D0
  1743.                 MOVE.L  MoveAddress(A5),A0
  1744.                 _SetTrapAddress
  1745.  
  1746.                 MOVE.L  (SP)+,A0
  1747.                 ADDQ    #6,SP
  1748.                 MOVE.L  A0,-(SP)
  1749. ;               BRA.S   CenterWindow
  1750.  
  1751.  
  1752. ;----------
  1753. ;CenterWindow - center a window on the screen
  1754. ;----------
  1755.  
  1756. CenterWindow
  1757.                 MOVE.L  (SP)+,A1                ;get the return address
  1758.                 MOVE.L  (SP)+,A0
  1759.                 MOVE.L  A1,-(SP)
  1760.  
  1761.                 MOVEQ   #0,D1                   ;get ready for centering
  1762.  
  1763.                 MOVE.W  quickGlobals+screenBits+bounds+bottom(A5),D1 ;calculate centering info
  1764.                 SUB.W   portRect+bottom(A0),D1  ;by subtracting (ignore the menu bar)
  1765.                 ADD.W   #20,D1
  1766.                 ASR.W   #1,D1                   ;and shifting
  1767.  
  1768.                 SWAP    D1                      ;move the Y coordinate to high word
  1769.  
  1770.                 MOVE.W  quickGlobals+screenBits+bounds+right(A5),D1 ;do the same for X
  1771.                 SUB.W   portRect+right(A0),D1
  1772.                 ASR.W   #1,D1
  1773.  
  1774.                 MOVE.L  A0,-(SP)
  1775.                 MOVE.L  D1,-(SP)
  1776.                 MOVE.B  #1,-(SP)
  1777.                 _MoveWindow                     ;move the window into position
  1778.  
  1779.                 RTS
  1780.  
  1781.  
  1782. ;----------
  1783. ;SFFilter - fancy filtering for the SF nastiness dialog
  1784. ;----------
  1785.  
  1786. SFFilter
  1787.                 LINK    A6,#0
  1788.  
  1789.                 CLR.B   filtered(A6)
  1790.  
  1791.                 MOVE.L  theEvent(A6),A0
  1792.  
  1793.                 CMP.W   #updatEvt,(A0)
  1794.                 BNE.S   SFNotUpdate
  1795.  
  1796.                 MOVE.L  theDialog(A6),D0
  1797.  
  1798.                 MOVE.L  D0,-(SP)
  1799.                 MOVE.L  D0,-(SP)
  1800.                 MOVE.L  D0,-(SP)
  1801.                 MOVE.L  D0,-(SP)
  1802.  
  1803.                 _BeginUpdate
  1804.                 _DrawDialog
  1805.                 BSR     OutlineButton
  1806.                 _EndUpdate
  1807.  
  1808.                 MOVE.L  theEvent(A6),A0
  1809.                 CLR.W   (A0)
  1810.                 BRA.S   SFDoneFilter
  1811.  
  1812. SFNotUpdate
  1813.                 CMP.W   #keyDwnEvt,(A0)
  1814.                 BNE.S   SFDoneFilter
  1815.  
  1816.                 CMP.B   #3,evtMessage+3(A0)
  1817.                 BEQ.S   SFHitButton
  1818.  
  1819.                 CMP.B   #13,evtMessage+3(A0)
  1820.                 BNE.S   SFDoneFilter
  1821. SFHitButton
  1822.                 MOVE.L  theDialog(A6),-(SP)
  1823.                 MOVE.W  #1,-(SP)
  1824.                 PEA     scratch20
  1825.                 PEA     scratch20+2
  1826.                 PEA     scratch8
  1827.                 _GetDItem
  1828.  
  1829.                 MOVE.L  scratch20+2,-(SP)
  1830.                 BSR     FlashControl
  1831.  
  1832.                 MOVE.L  itemHit(A6),A0
  1833.                 MOVE.W  #1,(A0)
  1834.                 ADDQ.B  #1,filtered(A6)
  1835.  
  1836. SFDoneFilter
  1837.                 UNLK    A6
  1838.                 MOVE.L  (SP)+,A0                ;get return address
  1839.                 ADD     #12,SP                  ;pop off parameters
  1840.                 JMP     (A0)
  1841.  
  1842.  
  1843. ;----------
  1844. ;FlashControl - blink a control for 8 ticks
  1845. ;----------
  1846.  
  1847. FlashControl
  1848.                 MOVE.L  (SP)+,A0
  1849.                 MOVE.L  (SP)+,A1
  1850.                 MOVE.L  A0,-(SP)
  1851.  
  1852.                 MOVE.L  A1,-(SP)
  1853.                 MOVE.L  A1,-(SP)
  1854.  
  1855.                 MOVE.W  #1,-(SP)
  1856.                 _HiliteControl
  1857.  
  1858.                 MOVE.W  #8,A0
  1859.                 CLR.W   -(SP)
  1860.                 _HiliteControl                  ;Un-hilite the control
  1861.  
  1862.                 RTS
  1863.  
  1864.                 END
  1865.  
  1866.