home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1991 …esperately Seeking Seven / Desperately Seeking Seven.2mg / Dev.CD.8 / Essentials / Tools / DTS.Samples / SC01Shell / Asm.Shell / Shell.aii < prev    next >
Encoding:
Text File  |  1990-05-25  |  26.2 KB  |  725 lines  |  [04] ASCII Text (0x0000)

  1. *
  2. *   Standard Application Shell  - Assembly Version
  3. *   By: Apple II Developer Technical Support
  4. *
  5. *     v3.0    Mensch & Rollin, Deatherage & Luther
  6. *
  7. *    Developer Technical Support Apple II Sample Code
  8. *
  9. *    Copyright (c) Apple Computer, Inc. 1988-1990
  10. *               All Rights Reserved
  11. *
  12. *   ------------------------------------------------------
  13. *
  14. *   This program and its derivatives are licensed only for
  15. *   use on Apple computers.
  16. *
  17. *   Works based on this program must contain and
  18. *   conspicuously display this notice.
  19. *
  20. *   This software is provided for your evaluation and to
  21. *   assist you in developing software for the Apple IIGS
  22. *   computer.
  23. *
  24. *   DISCLAIMER OF WARRANTY
  25. *
  26. *   THE SOFTWARE IS PROVIDED "AS IS" WITHOUT
  27. *   WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  28. *   WITH RESPECT TO ITS MERCHANTABILITY OR ITS FITNESS
  29. *   FOR ANY PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO
  30. *   THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
  31. *   YOU.  SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU (AND
  32. *   NOT APPLE OR AN APPLE AUTHORIZED REPRESENTATIVE)
  33. *   ASSUME THE ENTIRE COST OF ALL NECESSARY SERVICING,
  34. *   REPAIR OR CORRECTION.
  35. *
  36. *   Apple does not warrant that the functions
  37. *   contained in the Software will meet your requirements
  38. *   or that the operation of the Software will be
  39. *   uninterrupted or error free or that defects in the
  40. *   Software will be corrected.
  41. *
  42. *   SOME STATES DO NOT ALLOW THE EXCLUSION
  43. *   OF IMPLIED WARRANTIES, SO THE ABOVE EXCLUSION MAY
  44. *   NOT APPLY TO YOU.  THIS WARRANTY GIVES YOU SPECIFIC
  45. *   LEGAL RIGHTS AND YOU MAY ALSO HAVE OTHER RIGHTS
  46. *   WHICH VARY FROM STATE TO STATE.
  47. *
  48.                     EJECT
  49.  
  50.                     mcopy shell.macros
  51.                     copy 2/ainclude/E16.Types
  52.                     copy 2/ainclude/E16.GSOS
  53.                     copy 2/ainclude/E16.Locator
  54. ;                   copy 2/ainclude/E16.ADB
  55.                     copy 2/ainclude/E16.IntMath
  56.                     copy 2/ainclude/E16.TextTool
  57.                     copy 2/ainclude/E16.Memory
  58. ;                   copy 2/ainclude/E16.SANE
  59. ;                   copy 2/ainclude/E16.ACE
  60. ;                   copy 2/ainclude/E16.Resources
  61.                     copy 2/ainclude/E16.MiscTool
  62. ;                   copy 2/ainclude/E16.Scheduler
  63. ;                   copy 2/ainclude/E16.Loader
  64.                     copy 2/ainclude/E16.Quickdraw
  65. ;                   copy 2/ainclude/E16.QDAux
  66.                     copy 2/ainclude/E16.Event
  67. ;                   copy 2/ainclude/E16.Control
  68.                     copy 2/ainclude/E16.Window
  69.                     copy 2/ainclude/E16.Menu
  70. ;                   copy 2/ainclude/E16.LineEdit
  71. ;                   copy 2/ainclude/E16.Dialog
  72. ;                   copy 2/ainclude/E16.Sound
  73. ;                   copy 2/ainclude/E16.NoteSyn
  74. ;                   copy 2/ainclude/E16.NoteSeq
  75. ;                   copy 2/ainclude/E16.MIDI
  76. ;                   copy 2/ainclude/E16.StdFile
  77. ;                   copy 2/ainclude/E16.Scrap
  78.                     copy 2/ainclude/E16.Desk
  79. ;                   copy 2/ainclude/E16.List
  80. ;                   copy 2/ainclude/E16.Font
  81. ;                   copy 2/ainclude/E16.Print
  82. ;                   copy 2/ainclude/E16.TextEdit
  83. ;                   copy 2/ainclude/E16.Video
  84.  
  85. *******************************************************************************
  86. *
  87. *    Equates used in this program.
  88. *
  89.  
  90. ; Offsets into direct page
  91. Deref               gequ 0              ; for temporary dereferencing
  92.  
  93. ; menu item numbers for standard DA menu items
  94. UndoID              gequ 250
  95. CutID               gequ 251
  96. CopyID              gequ 252
  97. PasteID             gequ 253
  98. ClearID             gequ 254
  99. CloseID             gequ 255
  100.  
  101. ; application menu item numbers
  102. AboutID             gequ $1101           ; 1st item of 1st menu of 1st menu bar
  103. QuitID              gequ $1202           ; 2nd item of 2nd menu of 1st menu bar
  104.  
  105. ; application menu numbers
  106. AppleMenuID         gequ $1100           ; 1st menu of 1st menu bar
  107. FileMenuID          gequ $1200           ; 2nd menu of 1st menu bar
  108. EditMenuID          gequ $1300           ; 3rd menu of 1st menu bar
  109.  
  110. ; resource ID numbers
  111. BaseResID           gequ $00000000       ; start of resource ID numbers
  112. MenuBarOneRID       gequ $00001000       ; resource ID of menu bar
  113.  
  114. MyTaskMask          gequ $001FFFFF       ; Handle all events possible
  115.  
  116.                     EJECT
  117. *******************************************************************************
  118. *
  119. main                START
  120. *
  121. * Description:      This is the main routine. It calls procedures to startup
  122. *                   the tools, initialize application specific data, run the
  123. *                   main eventLoop, close the application, and shutdown the
  124. *                   tools.  Then it calls the GS/OS Quit command.
  125. *
  126. * Inputs:           NONE
  127. * Outputs:          NONE
  128. * External Refs:
  129. *                   import initTools
  130. *                   import initApp
  131. *                   import eventLoop
  132. *                   import closeApp
  133. *                   import closeTools
  134. *                   import QuitParms
  135. * Entry Points:     NONE
  136. *
  137.                     using globals
  138.  
  139.                     jsr initTools       ; Initialize tools.
  140.                     jsr initApp         ; Initialize application specific
  141. ;                                         stuff.
  142.  
  143.                     jsr eventLoop       ; Do application stuff until user 
  144. ;                                         wants to do something else!
  145.                     
  146.                     jsr closeApp        ; ShutDown application specific things.
  147.                     jsr closeTools      ; ShutDown the tools.
  148.  
  149.                     _QuitGS QuitParms   ; and Quit
  150.                     END
  151.  
  152.                     EJECT
  153. *******************************************************************************
  154. *
  155. Globals             DATA
  156. *
  157. * Description:      Holder of all of our data.
  158. *
  159. * Inputs:           N/A
  160. * Outputs:          N/A
  161. * External Refs:    NONE
  162. * Entry Points:
  163. *                   export QuitParms    ; used by main
  164. *
  165.  
  166. ; Standard global variables here
  167. MyMemoryID          ds  2               ; Application's memory ID
  168. Done                ds  2               ; flag to show when to quit application
  169. ToolRecRef          ds  4               ; StartStopRec from StartUpTools
  170. WindowKind          ds  2               ; type of top window from GetWKind call
  171. MenuHeight          ds  2               ; Stored height of menu bar
  172. QuitParms           dc  i2'$00'         ; pCount = 0
  173.  
  174. ; The following is the record that is used by TaskMaster to return
  175. ; events. It is similar to a regular event record, except that there are
  176. ; additional fields at the end. The first additional field is used to convey
  177. ; some TaskMaster specific data back to the application. The second additional
  178. ; field is called the TaskMask and is used to tell TaskMaster what situations
  179. ; to handle.  In this shell, we tell TaskMaster to handle everything by
  180. ; setting all currently defined bits to 1 (MyTaskMask) in the initApp
  181. ; routine.
  182.  
  183. MyEvent             anop
  184. EventWhat           ds  2
  185. EventMessage        ds  4
  186. EventWhen           ds  4
  187. EventWhere          ds  4
  188. EventModifiers      ds  2
  189. TaskData            ds  4
  190. TaskMask            dc  i4'MyTaskMask'
  191. LastClickTick       ds  4
  192. ClickCount          ds  2
  193. TaskData2           ds  4
  194. TaskData3           ds  4
  195. TaskData4           ds  4
  196. LastClickPtY        ds  2
  197. LastClickPtX        ds  2
  198.  
  199.                     END
  200.  
  201.                     EJECT
  202. *******************************************************************************
  203. *
  204. initTools           START
  205. *
  206. * Description:      Load and startup the tools needed. Errors are detected
  207. *                   and fatalError is called if any occur.
  208. *
  209. * Inputs:           NONE
  210. * Outputs:          NONE
  211. * External Refs:
  212. *                   import fatalError
  213. * Entry Points:     NONE
  214. *
  215.                     using Globals
  216.  
  217.                     phk                 ; save program bank register and
  218.                     plb                 ; load it as the data bank register
  219.  
  220.                     _TLStartup          ; start up Tool Locator
  221.                     bcc initMM
  222.                     ldx #$1             ; if error, then set the error
  223. ;                                         reference number
  224.                     jmp fatalError      ; and jump to fatal routine
  225.  
  226. initMM              pha                 ; space for result
  227.                     _MMStartup          ; start up memory manager
  228.                     bcc getMMID
  229.                     ldx #$2             ; if error, then set the error
  230. ;                                         reference number
  231.                     jmp fatalError      ; and jump to fatal routine
  232.  
  233. getMMID             PullWord MyMemoryID ; Get the Memory ID returned
  234.  
  235.                     PushLong #$0        ; space for the Record returned
  236.                     PushWord MyMemoryID ; our User ID
  237.                     PushWord #refIsResource ; the StartStopRec is a resource
  238.                     PushLong #BaseResID+1 ; the actual resource ID
  239.                     _StartUpTools
  240.                     bcc getToolRecRef
  241.                     ldx #$3             ; if error, then set the error
  242. ;                                         reference number
  243.                     jmp fatalError      ; and jump to fatal routine
  244.  
  245. getToolRecRef       PullLong ToolRecRef ; Store the reference returned
  246.  
  247.                     rts
  248.                     END
  249.  
  250.                     EJECT
  251. *******************************************************************************
  252. *
  253. fatalError          START
  254. *
  255. * Description:      Routine that is called whenever an error is detected
  256. *                   that can not be recovered from. This routine prints an
  257. *                   error message, waits for a keypress, then quits back
  258. *                   to whoever started this application up!
  259. *
  260. * Inputs:           A = Error number
  261. *                   X = the reference number that tells you where in
  262. *                   initTools the error happened.
  263. * Outputs:          NONE (program exits)
  264. * External Refs:
  265. *                   import closeTools
  266. * Entry Points:     NONE
  267. *
  268.                     using Globals
  269.  
  270.                     phx                 ; save the "where" reference number
  271.                     
  272.                     pha                 ; Push the error code
  273.                     PushLong #errNumStr ; Address of storage area
  274.                     PushWord #$4        ; Length of string
  275.                     _Int2Hex
  276.  
  277.                     pla                 ; get the "where" reference number
  278.                     pha                 ; and push it
  279.                     PushLong #errWhereStr ; Address of storage area
  280.                     PushWord #$4        ; Length of string
  281.                     _Int2Hex
  282.                     
  283.                     _GrafOff            ; If QD Started, shut off graphics
  284.  
  285.                     PushLong #ErrStr    ; Write error message to the screen
  286.                     _WriteCString
  287.                     
  288.                     _SysBeep            ; ring the bell
  289.  
  290.                     pha                 ; Space for result
  291.                     PushWord #noEcho    ; No echo
  292.                     _ReadChar           ; Wait for a key to be pressed
  293.                     pla                 ; Discard the key
  294.  
  295.                     jsr closeTools      ; Shut down all the tools in case
  296. ;                                         any got started up
  297.  
  298.                     _QuitGS QuitParms   ; Quit back to where we came from.
  299.  
  300. ; Quit can only fail with GS/OS busy, so we never come back from the quit call.
  301.                     
  302. ErrStr              dc  c'Fatal error $'
  303. ErrNumStr           dc  c'xxxx has occured at '
  304. ErrWhereStr         dc  c'xxxx. Press any key to exit:',i1'0'
  305.  
  306.                     END
  307.  
  308.                     EJECT
  309. *******************************************************************************
  310. *
  311. initApp             START
  312. *
  313. * Description:      Perform any application specific initialization. For this
  314. *                   app, we initialize the Done to false, set WindowKind to
  315. *                   an application window kind, and initialize all of the
  316. *                   menus.
  317. *
  318. *                   You might use this procedure to create windows, initialize
  319. *                   variables and allocate memory needed for the entire
  320. *                   program.
  321. *
  322. * Inputs:           NONE
  323. * Outputs:          NONE
  324. * External Refs:    NONE
  325. * Entry Points:     NONE
  326. *
  327.                     using Globals
  328.  
  329.                     stz Done            ; we aren't done yet
  330.                     stz WindowKind      ; window kind = application
  331.  
  332. ;
  333. ; create default system menu bar from a resource and make it the
  334. ; current menu bar
  335. ;
  336.                     pha
  337.                     pha                 ; space for result
  338.                     PushWord #refIsResource ; reference is resource
  339.                     PushLong #MenuBarOneRID ; menu bar resource ID
  340.                     PushLong #$0        ; system menu bar
  341.                     _NewMenuBar2
  342.                                         
  343.                     _SetSysBar          ; and this is the system bar
  344.                     
  345.                     PushLong #$0        ; zero means use the system menu bar
  346.                     _SetMenuBar
  347.                     
  348.                     PushLong #$0        ; refresh the whole desktop
  349.                     _RefreshDeskTop
  350.  
  351.                     _InitCursor         ; normal arrow cursor
  352.  
  353.                     PushWord #AppleMenuID ; Add NDA's
  354.                     _FixAppleMenu
  355.  
  356.                     pha                 ; Call FixMenuBar to cause the menu
  357.                     _FixMenuBar         ; Compute standard menu sizes
  358.                     PullWord MenuHeight ; and store the menu height for later
  359.  
  360.                     _DrawMenuBar        ; Finally, draw it.
  361.  
  362.                     rts
  363.                     END
  364.  
  365.                     EJECT
  366. *******************************************************************************
  367. *
  368. eventLoop           START
  369. *
  370. * Description:      The Event Loop. Handle things until user selects Quit.
  371. *
  372. * Inputs:           NONE
  373. * Outputs:          NONE
  374. * External Refs:
  375. *                   import doMenu
  376. *                   import testTopWindow
  377. * Entry Points:     NONE
  378. *
  379.                     using Globals
  380.  
  381.                     jsr testTopWindow   ; test to see if top window is a DA
  382.                     
  383.                     pha                 ; Push on space for TaskMaster result
  384.                     PushWord #EveryEvent ; GetNextEvent mask
  385.                     PushLong #MyEvent   ; Pointer to Event Record
  386.                     _TaskMaster
  387.                     pla                 ; Get TaskMaster result
  388.                     
  389. ; Now we have the task type
  390.  
  391.                     ldx #endTaskTable-taskTable-4
  392. checkNextItem       cmp taskTable,x     ; are we handling this event?
  393.                     beq doRoutine       ; yes, then call a routine
  394.                     dex                 ; no, then keep checking
  395.                     dex
  396.                     dex
  397.                     dex
  398.                     bpl checkNextItem   ; keep scanning table
  399.  
  400.                     bra eventLoop       ; event not handled, so get another
  401.  
  402. doRoutine           jsr (taskTable+2,x) ; call the routine
  403.  
  404.                     lda Done            ; Quit selected?
  405.                     beq eventLoop       ; no - keep looping
  406.  
  407.                     rts                 ; yes- leave the program
  408.  
  409. ; With most of these events, we do nothing (in fact, most applications will
  410. ; never see some of these events). You should cut or comment out the lines
  411. ; for events your application does not use out of this table (as we've done).
  412. ; Any of these events your application does use should call a routine to
  413. ; handle the event.
  414.  
  415. taskTable           anop
  416. ;                   dc  i2'nullEvt,doNullEvt'
  417. ;                   dc  i2'mouseDownEvt,doMouseDownEvt'
  418. ;                   dc  i2'mouseUpEvt,doMouseUpEvt'
  419. ;                   dc  i2'keyDownEvt,doKeyDownEvt'
  420. ;                   dc  i2'autoKeyEvt,doAutoKeyEvt'
  421. ;                   dc  i2'updateEvt,doUpdateEvt'
  422. ;                   dc  i2'activateEvt,doActivateEvt'
  423. ;                   dc  i2'switchEvt,doSwitchEvt'
  424. ;                   dc  i2'deskAccEvt,doDeskAccEvt'
  425. ;                   dc  i2'driverEvt,doDriverEvt'
  426. ;                   dc  i2'app1Evt,doApp1Evt'
  427. ;                   dc  i2'app2Evt,doApp2Evt'
  428. ;                   dc  i2'app3Evt,doApp3Evt'
  429. ;                   dc  i2'app4Evt,doApp4Evt'
  430. ;                   dc  i2'wInDesk,doWInDesk'
  431.                     dc  i2'wInMenuBar,doMenu'
  432. ;                   dc  i2'wClickCalled,doWClickCalled'
  433. ;                   dc  i2'wInContent,doWInContent'
  434. ;                   dc  i2'wInDrag,doWInDrag'
  435. ;                   dc  i2'wInGrow,doWInGrow'
  436. ;                   dc  i2'wInGoAway,doWInGoAway'
  437. ;                   dc  i2'wInZoom,doWInZoom'
  438. ;                   dc  i2'wInInfo,doWInInfo'
  439.                     dc  i2'wInSpecial,doMenu'
  440. ;                   dc  i2'wInDeskItem,doWInDeskItem'
  441. ;                   dc  i2'wInFrame,doWInFrame'
  442. ;                   dc  i2'wInactMenu,doWInactMenu'
  443. ;                   dc  i2'wClosedNDA,doWClosedNDA'
  444. ;                   dc  i2'wCalledSysEdit,doWCalledSysEdit'
  445. ;                   dc  i2'wTrackZoom,doWTrackZoom'
  446. ;                   dc  i2'wHitFrame,doWHitFrame'
  447. ;                   dc  i2'wInControl,doWInControl'
  448. ;                   dc  i2'wInControlMenu,doWInControlMenu'
  449. endTaskTable        anop
  450.                     END
  451.  
  452.                     EJECT
  453. *******************************************************************************
  454. *
  455. closeApp            START
  456. *
  457. * Description:      Close down things. This disposes of all items and memory
  458. *                   that we allocated. Usually undoes what was done in
  459. *                   initApp.  We don't close our window since _WindShutDown
  460. *                   does it for us.
  461. *
  462. * Inputs:           NONE
  463. * Outputs:          NONE
  464. * External Refs:    NONE
  465. * Entry Points:     NONE
  466. *
  467.                     using Globals
  468.                     
  469. ; do nothing in this shell
  470.  
  471.                     rts
  472.                     END
  473.  
  474.                     EJECT
  475. *******************************************************************************
  476. *
  477. closeTools          START
  478. *
  479. * Description:      Shut down the tools I started.
  480. *
  481. * Inputs:           NONE
  482. * Outputs:          NONE
  483. * External Refs:    NONE
  484. * Entry Points:     NONE
  485. *
  486.                     using Globals
  487.  
  488.                     PushWord #refIsHandle ; A handle (since StartUp returned it)
  489.                     PushLong ToolRecRef ; The value returned by StartUpTools
  490.                     _ShutDownTools
  491.                     
  492.                     PushWord MyMemoryID
  493.                     _MMShutDown
  494.                     _TLShutDown
  495.  
  496.                     rts
  497.                     END
  498.  
  499.                     EJECT
  500. *******************************************************************************
  501. *
  502. testTopWindow       START
  503. *
  504. * Description:      This routine is called on every NULL event. It checks the
  505. *                   type of the top window, if it has changed from App window
  506. *                   to system window or back, this routine will call
  507. *                   doSysChange.
  508. *
  509. * Inputs:           NONE
  510. * Outputs:          NONE
  511. * External Refs:
  512. *                   import doSysChange
  513. * Entry Points:     NONE
  514. *
  515.                     using Globals
  516.                     
  517.                     PushLong #$0        ; first get a pointer to the frontmost
  518.                     _FrontWindow        ; window
  519.                     PullLong Deref      ; store it in deref temporarily
  520.                     
  521.                     lda Deref           ; first test for a NIL pointer. If its
  522.                     ora Deref+2         ; NIL then we do not have to do the 
  523.                     beq checkKind       ; getWKind call
  524.                     
  525.                     PushWord #$0        ; if not a NIL pointer then get the
  526.                     PushLong Deref      ; Kind of window
  527.                     _getWKind
  528.                     pla
  529.                     
  530. checkKind           cmp WindowKind      ; Now test the window kind to see if it
  531.                     beq noChange        ; has changed, if not then ignore it
  532.                     
  533.                     sta WindowKind      ; if the window kind has changed, then
  534.                     jsr doSysChange     ; save the new value and change menus
  535.  
  536. noChange            rts
  537.                     End
  538.  
  539.                     EJECT
  540. *******************************************************************************
  541. *
  542. doSysChange         START
  543. *
  544. * Description:      Called by eventLoop when the upper most window
  545. *                   has changed to or from a system window.
  546. *
  547. * Inputs:           <A> Bit 15 of WindowKind is 0 if top window is an
  548. *                   application window, 1 if top window is a system window.
  549. * Outputs:          NONE
  550. * External Refs:    NONE
  551. * Entry Points:     NONE
  552. *
  553.                     using Globals
  554.  
  555.                     and #%1000000000000000
  556.                     bpl SysDeact        ; if high bit clear then App Window
  557.  
  558. ; This routine enables the edit menu when a system window becomes active
  559.  
  560. SysActivate         PushWord #UndoID    ; its an activate event so go thru and
  561.                     _EnableMItem        ; enable all the edit items and the
  562.                     
  563.                     PushWord #CutID     ; close Item
  564.                     _EnableMItem
  565.                     
  566.                     PushWord #CopyID
  567.                     _EnableMItem
  568.                     
  569.                     PushWord #PasteID
  570.                     _EnableMItem
  571.                     
  572.                     PushWord #ClearID
  573.                     _EnableMItem
  574.                     
  575.                     PushWord #CloseID
  576.                     _EnableMItem
  577.                     
  578. ; If your edit menu has items that are selectable when a DA is not front-most,
  579. ; remove the next six lines.
  580.                     PushWord #enableMenu
  581.                     PushWord #EditMenuID
  582.                     _SetMenuFlag
  583.                     pea $0000           ; FALSE
  584.                     PushWord #EditMenuID
  585.                     _HiliteMenu
  586.                     
  587.                     rts
  588.  
  589. ; This routine disables the edit menu when an system window is not active
  590.  
  591. SysDeact            PushWord #UndoID    ; its an deactivate event so go thru 
  592.                     _DisableMItem       ; and disable all the edit items and 
  593.                     
  594.                     PushWord #CutID     
  595.                     _DisableMItem
  596.                     
  597.                     PushWord #CopyID
  598.                     _DisableMItem
  599.                     
  600.                     PushWord #PasteID
  601.                     _DisableMItem
  602.                     
  603.                     PushWord #ClearID
  604.                     _DisableMItem
  605.  
  606.                     PushWord #CloseID   ; the close Item
  607.                     _DisableMItem
  608.  
  609. ; If your edit menu has items that are selectable when a DA is not front-most,
  610. ; remove the next six lines.
  611.                     PushWord #disableMenu
  612.                     PushWord #EditMenuID
  613.                     _SetMenuFlag
  614.                     pea $0000           ; FALSE
  615.                     PushWord #EditMenuID
  616.                     _HiliteMenu
  617.                     
  618.                     rts
  619.                     END
  620.  
  621.                     EJECT
  622. *******************************************************************************
  623. *
  624. doMenu              START
  625. *
  626. * Description:      This routine is called when TaskMaster returns a menu
  627. *                   event. It takes the menu item that was hit and calls the
  628. *                   proper routine, and then unhilites the menu when it is
  629. *                   done. 
  630. *
  631. * Inputs:           TaskData holds menu item selected.
  632. * Outputs:          NONE
  633. * External Refs:
  634. *                   import doAbout
  635. *                   import doQuit
  636. * Entry Points:     NONE
  637. *
  638.                     using Globals
  639.                     
  640.                     lda TaskData        ; get ID of selected menu item
  641.  
  642.                     ldx #endMenuTable-menuTable-4
  643. checkNextItem       cmp menuTable,x
  644.                     beq doRoutine
  645.                     dex
  646.                     dex
  647.                     dex
  648.                     dex
  649.                     bpl checkNextItem
  650.  
  651.                     pha                 ; space for result
  652.                     PushWord #$4        ; reference is resource
  653.                     PushLong #$0        ; no substitution strings currently
  654.                     PushLong #BaseResID+2 ; alertString resource ID
  655.                     _AlertWindow
  656.                     pla                 ; get the button number and dispose
  657.                     bra finishUp
  658.  
  659. doRoutine           jsr (menuTable+2,x) ; and call the routine
  660.  
  661. finishUp            PushWord #$0        ; Routine done - unhilite the menubar.
  662.                     PushWord taskData+2 ; the menu number
  663.                     _HiLiteMenu
  664.  
  665.                     rts
  666.  
  667. ; Menu items that are ignored in this shell are included, but commented out.
  668.  
  669. menuTable           anop
  670. ;                   dc  i2'UndoID,doUndo'
  671. ;                   dc  i2'CutID,doCut'
  672. ;                   dc  i2'CopyID,doCopy'
  673. ;                   dc  i2'PasteID,doPaste'
  674. ;                   dc  i2'ClearID,doClear'
  675. ;                   dc  i2'CloseID,doClose' ; close handled by TaskMaster
  676.                     dc  i2'AboutID,doAbout' ; show about dialog
  677.                     dc  i2'QuitID,doQuit'   ; set Done flag
  678. endMenuTable        anop
  679.  
  680.                     END
  681.  
  682.                     EJECT
  683. *******************************************************************************
  684. *
  685. doAbout             START
  686. *
  687. * Description:      Bring up an Alert Dialog box with our about message in it.
  688. *
  689. * Inputs:           NONE
  690. * Outputs:          NONE
  691. * External Refs:    NONE
  692. * Entry Points:     NONE
  693. *
  694.                     using Globals
  695.  
  696.                     pha                 ; space for result
  697.                     PushWord #$4        ; reference is resource
  698.                     PushLong #$0        ; no substitution strings currently
  699.                     PushLong #BaseResID+1 ; alertString resource ID
  700.                     _AlertWindow
  701.                     pla                 ; get the button number and dispose
  702.  
  703.                     rts
  704.                     END
  705.  
  706.                     EJECT
  707. *******************************************************************************
  708. *
  709. doQuit              START
  710. *
  711. * Description:      Set the Done flag to true. This tells the Event loop to
  712. *                   exit.
  713. *
  714. * Inputs:           NONE
  715. * Outputs:          Done set to $FFFF (true)
  716. * External Refs:    NONE
  717. * Entry Points:     NONE
  718. *
  719.                     using Globals
  720.  
  721.                     lda #$FFFF          ; load any non-zero value
  722.                     sta Done            ; and save it in the Done
  723.                     rts
  724.                     END
  725.