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 / SC08ListLineEd / Lists.Inits.asm < prev    next >
Encoding:
Assembly Source File  |  1990-05-19  |  12.5 KB  |  354 lines  |  [04] ASCII Text (0x0000)

  1. *******************************************************************************
  2. *
  3. InitTools           start
  4. *
  5. * Description:      Load and initialize the tools needed. Errors are detected
  6. *                   and FatalError is called if any occur. If there aren't any
  7. *                   errors, the list of menu templates is read and the menu-
  8. *                   bar is created.
  9. *
  10. *
  11. * Inputs:           NONE
  12. *
  13. * Outputs:          NONE
  14. *
  15. * External Refs:
  16. *                   Import FatalError
  17. *
  18. * Entry Points:     NONE
  19. *
  20. *******************************************************************************
  21.                     using Globals
  22.  
  23. ;
  24. ;   Tool Direct page offsets here
  25. ;
  26. QDDPage             equ $0000
  27. EMDPage             equ QDDPage+$0300
  28. CtlDPage            equ EMDPage+$0100
  29. MenuDPage           equ CtlDPage+$0100
  30. LEDPage             equ MenuDPage+$0100
  31. ToolDPSize          equ LEDPage+$0100
  32.  
  33.                     phk                 ; Save program bank register and
  34.                     plb                 ; load it as the data bank register
  35.  
  36.                     tdc
  37.                     sta MyDP            ; Save direct register
  38.  
  39.                     _TLStartup          ; Start Tool Locator
  40.  
  41.                     pha                 ; Space for result
  42.                     _MMStartup          ; Start memory manager
  43.                     PullWord MyID       ; Save it for later use
  44.  
  45.                     _MTStartup          ; Start up Misc Tools
  46.  
  47.                     _IMStartup          ; Start integer math toolset
  48.  
  49.                     PushLong #ToolTable ; Pointer to Tool table
  50.                     _LoadTools          ; Load all RAM based tools
  51.                     bcc IT0005          ; Carry clear means no error
  52.                     brl FatalError      ; Tools can't be loaded. Fatal error!
  53.  
  54. IT0005              ANOP
  55.  
  56. ; Get memory for Tool Direct pages
  57.  
  58.                     pha                 ; Room for result
  59.                     pha
  60.                     PushLong #ToolDPSize ; Number of bytes needed
  61.                     PushWord MyID       ; ID of this application
  62.                     PushWord #attrLocked+attrFixed+attrPage+attrBank
  63.                     PushLong #0         ; Allocate them in bank 0
  64.                     _NewHandle
  65.                     bcc IT0010          ; Test carry for error
  66.                     brl FatalError      ; If no memory we got a fatal error!
  67.  
  68. IT0010              PullLong DPHandle   ; Retrieve handle to our DPage area
  69.  
  70.                     lda [DPHandle]      ; Dereference the handle to get a ptr
  71.                     sta DPPointer       ; to our direct page area and save it.
  72.  
  73.                     PushWord DPPointer  ; QuickDraw uses 3 pages of Dpage
  74.                     PushWord #ScreenMode ; Used to set all master SCB's
  75.                     PushWord #0         ; Zero means use default buf size
  76.                     PushWord MyID       ; Application ID for allocating data
  77.                     _QDStartup          ; Start QuickDraw, turn on SHR Screen
  78.                     bcc IT0015
  79.                     brl FatalError      ; If it can't be started then bomb
  80.  
  81. IT0015              ANOP
  82.                     lda DPPointer       ; Create address for Event Mgr DPage by
  83.                     clc                 ; loading in the pointer to the start
  84.                     adc #EMDPage        ; of DPage and adding Evt Mgr offset.
  85.                     pha                 ; Now push it on the stack.
  86.                     PushWord #20        ; Size of event queue.
  87.                     PushWord #0         ; MouseClamp values.
  88.                     PushWord #ScreenWidth ; These will clamp mouse to screen
  89.                     PushWord #0         ; area only.
  90.                     PushWord #200
  91.                     PushWord MyID
  92.                     _EMStartup          ; Start the event manager
  93.                     bcc IT0020
  94.                     brl FatalError      ; Event manager is also a must
  95. IT0020              ANOP
  96.                     PushWord MyID
  97.                     _WindStartup
  98.                     bcc IT0025
  99.                     brl FatalError
  100. IT0025              ANOP
  101.                     PushWord MyID
  102.                     lda DPPointer
  103.                     clc
  104.                     adc #CtlDPage
  105.                     pha
  106.                     _CtlStartup
  107.                     bcc IT0030
  108.                     brl FatalError
  109. IT0030              ANOP
  110.  
  111.                     PushWord MyID
  112.                     lda DPPointer
  113.                     clc
  114.                     adc #MenuDPage
  115.                     pha
  116.                     _MenuStartUp
  117.                     bcc IT0035
  118.                     brl FatalError
  119. IT0035              ANOP
  120.                     PushWord MyID
  121.                     lda DPPointer
  122.                     clc
  123.                     adc #LEDPage
  124.                     pha
  125.                     _LEStartUp
  126.                     bcc IT0040
  127.                     brl FatalError
  128. IT0040              ANOP
  129.                     PushWord MyID
  130.                     _DialogStartup
  131.                     bcc IT0045
  132.                     brl FatalError
  133. IT0045              ANOP
  134.                     _ScrapStartup       ; No errors possible for this call
  135.  
  136.                     _DeskStartup        ; No error possible for this call
  137.  
  138. ; insert application specific tools here
  139.  
  140.                     _ListStartup
  141.  
  142.                     PushLong #0
  143.                     _RefreshDeskTop
  144.  
  145. ;
  146. ; Create the menus I need
  147. ;
  148.  
  149.                     ldx #MenuPtrLen-4   ; Get a pointer to the last menu        
  150. loop                phx                 ; Save menu table index on the stack
  151.                     pha                 ; Push on space for the menu handle
  152.                     pha                 ;   returned by NewMenu
  153.                     lda MenuPtr+2,x     ; Push on the pointer to the template
  154.                     pha                 ;   to be used by NewMenu when
  155.                     lda MenuPtr,x       ;   creating the menu
  156.                     pha
  157.                     _NewMenu            ; Create a new menu
  158.                     PushWord #0         ; Tell InsertMenu where to put it
  159.                     _InsertMenu         ; Insert it.
  160.                     plx                 ; Get our index back off the stack
  161.                     dex                 ; Point to the next template pointer
  162.                     dex
  163.                     dex
  164.                     dex
  165.                     bpl loop            ; Go back up if not done yet.
  166.  
  167.                     PushWord #1         ; Add NDA's
  168.                     _FixAppleMenu
  169.  
  170.                     pha                 ; Now call CalcMenuSize for all menus
  171.                     _FixMenuBar
  172.                     PullWord MenuHeight
  173.  
  174.                     _DrawMenuBar        ; Finally, draw it.
  175.  
  176.                     RTS
  177.  
  178. ToolTable           dc i2'7'            ; Data Block for LoadTools call
  179.                     dc i2'14,$0100'     ; Window Manager
  180.                     dc i2'15,$0100'     ; Menu Manager
  181.                     dc i2'16,$0100'     ; Control Manager
  182.                     dc i2'20,$0100'     ; LineEdit tool set
  183.                     dc i2'21,$0100'     ; Dialog Manager
  184.                     dc i2'22,$0100'     ; Scrap manager
  185.                     dc i2'28,$0100'     ; List Manager
  186.  
  187.                     end
  188.  
  189.                     EJECT
  190. *******************************************************************************
  191. *
  192. FatalError          start
  193. *
  194. * Description:      Routine that is called whenever a tool sends back an error
  195. *                   that can not be recovered from. This routine prints the
  196. *                   error on the screen, waits for a keypress then quits back
  197. *                   to whoever started this application up!
  198. *
  199. *
  200. * Inputs:           A = Error number
  201. *
  202. * Outputs:          NONE (program exits)
  203. *
  204. * External Refs:
  205. *                   Import CloseTools
  206. *
  207. * Entry Points:     NONE
  208. *
  209. *******************************************************************************
  210.                     using Globals
  211.  
  212.                     pha                 ; Push the error code
  213.                     PushLong #ErrNumStr ; Address of storage area
  214.                     PushWord #4         ; Length of string
  215.                     _Int2Hex
  216.  
  217.                     _GrafOff            ; If QD Started, shut off graphics
  218.  
  219.                     PushLong #ErrStr    ; Write error message to the screen
  220.                     _WriteCString
  221.  
  222.                     pha                 ; Space for result
  223.                     PushWord #0         ; No echo
  224.                     _ReadChar           ; Wait for a key to be pressed
  225.                     pla                 ; Discard the key
  226.  
  227.                     jsr CloseTools      ; Shut down all the tools in case
  228. ;                                         any got started up
  229.  
  230.                     _Quit QuitParms     ; Quit back to where we came from.
  231.  
  232.                     brk $FF             ; If the quit fails then just break
  233.                     
  234. ErrStr              dc c'A fatal error has occured $'
  235. ErrNumStr           dc c'xxxx   press any key to exit',i1'0'
  236.  
  237.                     end
  238.  
  239.                     EJECT
  240. *******************************************************************************
  241. *
  242. CloseTools          start
  243. *
  244. * Description:      Shut down the tools I started.
  245. *
  246. *
  247. * Inputs:           NONE
  248. *
  249. * Outputs:          NONE
  250. *
  251. * External Refs:    NONE
  252. *
  253. * Entry Points:     NONE
  254. *
  255. *******************************************************************************
  256.                     using Globals
  257.  
  258.                     _ListShutdown
  259.                     _DeskShutDown
  260.                     _ScrapShutDown
  261.                     _DialogShutDown
  262.                     _LEShutDown
  263.                     _MenuShutDown
  264.                     _CtlShutDown
  265.                     _WindShutDown
  266.                     _EMShutDown
  267.                     _QDShutDown
  268.                     _MTShutDown
  269.  
  270.                     PushLong DPHandle   ; Dispose of all that DP memory
  271.                     _DisposeHandle
  272.  
  273.                     PushWord MyID
  274.                     _MMShutDown
  275.                     _TLShutDown
  276.  
  277.                     rts
  278.                     end
  279.  
  280.                     EJECT
  281. *******************************************************************************
  282. *
  283. doAbout             start
  284. *
  285. * Description:      Bring up an Alert Dialog box with our name in it.
  286. *
  287. * Inputs:           NONE
  288. *
  289. * Outputs:          NONE
  290. *
  291. * External Refs:    NONE
  292. *
  293. * Entry Points:     NONE
  294. *
  295. *******************************************************************************
  296.                     using Globals
  297.  
  298.                     pha                 ; space for result
  299.                     PushLong #AboutBox  ; pointer to alert template
  300.                     PushLong #0         ; pointer to a filter proc (0=none)
  301.                     _NoteAlert
  302.                     pla                 ; get the item hit and dispose
  303.  
  304.                     rts
  305.  
  306. ; About Box alert template
  307.  
  308. AboutBox            dc i2'30,30,100,590'                    ; for 320 use 30,30,100,290
  309.                     dc i2'1'            ; this is alert # 1
  310.                     dc i1'$80'          ; draw for this stage
  311.                     dc i1'$81'          ; draw for this stage
  312.                     dc i1'$82'          ; draw for this stage
  313.                     dc i1'$83'          ; draw for this stage
  314.                     dc i4'OKButton'     ; ok button for the alert
  315.                     dc i4'AboutTitle'   ; title of the program
  316.                     dc i4'AboutAut'     ; author
  317.                     dc i4'AboutVers'    ; version number string
  318.                     dc i4'0'            ; nil to end the list
  319.  
  320. OKBTitle            dc i1'2',c'OK'
  321. OKButton            dc i2'1'
  322.                     dc i2'50,500,65,550'
  323.                     dc i2'buttonItem'
  324.                     dc i4'OKBTitle'
  325.                     dc i2'0'
  326.                     dc i2'0'            ; item flag
  327.                     dc i4'0'            ; no color table
  328.  
  329. AboutTitle          dc i2'2'
  330.                     dc i2'10,100,20,550'
  331.                     dc i2'statText+itemDisable'
  332.                     dc i4'TitleString'
  333.                     dc i2'0'
  334.                     dc i2'0'            ; item flag
  335.                     dc i4'0'            ; no color table
  336.  
  337. AboutAut            dc i2'3'
  338.                     dc i2'25,100,35,550'
  339.                     dc i2'statText+itemDisable'
  340.                     dc i4'AutString'
  341.                     dc i2'0'
  342.                     dc i2'0'            ; item flag
  343.                     dc i4'0'            ; no color table
  344.  
  345. AboutVers           dc i2'4'
  346.                     dc i2'40,100,50,550'
  347.                     dc i2'statText+itemDisable'
  348.                     dc i4'VersString'
  349.                     dc i2'0'
  350.                     dc i2'0'            ; item flag
  351.                     dc i4'0'            ; no color table
  352.  
  353.                     end
  354.