home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / dirs / popupmenu_422.lzh / PopUpMenu / Source / Startup.a < prev    next >
Text File  |  1990-12-31  |  3KB  |  125 lines

  1.            INCLUDE      "exec/types.i"
  2.            INCLUDE      "libraries/dos.i"
  3.            INCLUDE      "libraries/dosextens.i"
  4.            INCLUDE      "exec/execbase.i"
  5.            INCLUDE      "exec/funcdef.i"
  6.            INCLUDE      "exec/exec_lib.i"
  7.            INCLUDE      "libraries/dos_lib.i"
  8.  
  9. AbsExecBase    EQU      4
  10. POPUPPRI       EQU      5
  11. POPUPSTACK     EQU      2000
  12. * Must use Kickstart 1.2 or higher
  13. LIBVERSION     EQU      33
  14.  
  15.            xref      _LinkerDB
  16.            xref      @InitPopUpMenu
  17.  
  18.            section      Startup,code
  19.  
  20. Startup:       MOVEM.L      D2-D4/A2-A4/A6,-(SP)
  21.            LEA      _LinkerDB,A4
  22.  
  23. * ------------ Open dos.
  24.            LEA      DosName(PC),A1
  25.            MOVEQ.L      #LIBVERSION,D0
  26.            MOVEA.L      AbsExecBase.W,A6
  27.            JSR      _LVOOpenLibrary(A6)
  28.            MOVE.L      D0,_DOSBase(A4)
  29.  
  30.            BEQ.W      NoDos
  31.  
  32. * ------------ Get pointer to our Process.
  33.            MOVEA.L      ThisTask(A6),A3
  34.  
  35. * ------------ Run from Workbench ?
  36.            TST.L      pr_CLI(A3)
  37.            BEQ.B      FromWorkbench
  38.  
  39. * ------------ Get address to this segment.
  40.            LEA      Startup-4(PC),A2
  41.  
  42. * ------------ Get address to PopUpMenu code segment.
  43.            MOVE.L      #@InitPopUpMenu-4,D3
  44.  
  45. * ------------ Convert to BCPL.
  46.            ASR.L      #2,D3
  47.  
  48. * ------------ Find current output window.
  49.            LEA      CurrWindow(PC),A0
  50.            MOVE.L      #MODE_OLDFILE,D2
  51.            BSR.B      GetStdOut
  52.  
  53.            BEQ.B      NoStdOut
  54.  
  55. * ------------ Save start of segments.
  56.            MOVE.L      (A2),_PopUpSeg(A4)
  57.  
  58. * ------------ Remove this segment.
  59.            CLR.L      (A2)
  60.  
  61. * ------------ Create PopUpMenu process.
  62.            LEA      PopUpTaskName(PC),A0
  63.            MOVE.L      A0,D1
  64.            MOVEQ.L      #POPUPPRI,D2
  65.            MOVE.L      #POPUPSTACK,D4
  66.            JSR      _LVOCreateProc(A6)
  67.            BRA.B      Done
  68.  
  69. * ------------ Wait for Workbench startup-message.
  70. FromWorkbench: LEA      pr_MsgPort(A3),A0
  71.            JSR      _LVOWaitPort(A6)
  72.            LEA      pr_MsgPort(A3),A0
  73.            JSR      _LVOGetMsg(A6)
  74.            MOVE.L      D0,D3
  75.  
  76. * ------------ Open window on Workbench screen.
  77.            LEA      WbWindow(PC),A0
  78.            MOVE.L      #MODE_NEWFILE,D2
  79.            BSR.B      GetStdOut
  80.  
  81.            MOVEA.L      AbsExecBase.W,A6
  82.            BEQ.B      NoWbStdOut
  83.  
  84. * ------------ No need to unload segments (Workbench takes care of that).
  85.            CLR.L      _PopUpSeg(A4)
  86.  
  87. * ------------ Set task priority.
  88.            MOVEA.L      A3,A1
  89.            MOVEQ      #POPUPPRI,D0
  90.            JSR      _LVOSetTaskPri(A6)
  91.  
  92. * ------------ Start PopUpMenu-program.
  93.            JSR      @InitPopUpMenu
  94.  
  95. * ------------ Forbid so Workbench can't unload us before we are done.
  96. NoWbStdOut:    JSR      _LVOForbid(A6)
  97.            MOVEA.L      D3,A1
  98.            JSR      _LVOReplyMsg(A6)
  99. Done:
  100. NoStdOut:
  101. NoDos:           MOVEQ      #00,D0
  102.            MOVEM.L      (SP)+,D2-D4/A2-A4/A6
  103.            RTS
  104.  
  105. GetStdOut:     MOVE.L      A0,D1
  106.            MOVEA.L      _DOSBase(A4),A6
  107.            JSR      _LVOOpen(A6)
  108.            MOVE.L      D0,_StdOut(A4)
  109.            RTS
  110.  
  111. * Put these data in our code-segment.
  112. CurrWindow:    dc.b      '*',0
  113. WbWindow:      dc.b      'CON:200/75/310/45/'
  114. PopUpTaskName: dc.b      'PopUpMenu',0
  115. DosName:       dc.b      'dos.library',0
  116.  
  117.            section      __MERGED,bss
  118.  
  119.            xref      _DOSBase
  120.            xref      _StdOut
  121.            xref      _PopUpSeg
  122.  
  123.            END
  124.  
  125.