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

  1.            opt      l+,c+,d+,y+
  2.            opt      ow1+,ow2+,ow3+,ow4+,ow5+,ow6+
  3.  
  4.            INCLUDE      "exec/types.i"
  5.            INCLUDE      "PopUpMenu.i"
  6.  
  7.            xdef      @PopUpMenu
  8.            xdef      @FindMenuPtr
  9.            xdef      @FindItemNr
  10.            xdef      @QueTimer
  11.            xdef      @HighLightCurrItemBehind
  12.            xdef      @FindMouseItem
  13.            xdef      @MouseInWindow
  14.            xdef      @OpenItemWindow
  15.            xdef      @CloseItemWindow
  16.            xdef      @DrawAllItems
  17.            xdef      @SwapBits
  18.            xdef      @HighLightItem
  19.            xdef      @ToggleMenu
  20.            xdef      @MySetMenuStrip
  21.            xdef      @MyClearMenuStrip
  22.            xdef      @MyOnMenu
  23.            xdef      @MyOffMenu
  24.            xdef      @SelectItem
  25.            xdef      @FinalSelect
  26.  
  27.            xref      _AmigaKeyHighRes
  28.            xref      _AmigaKeyLoRes
  29.            xref      _SubItemPointerH
  30.            xref      _SubItemPointerL
  31.  
  32. BORDERSIZE     EQU      2
  33. OVERLAP        EQU      7
  34.  
  35.            section      text,code
  36. **********************************************
  37. * PopUpMenu(InputSignals)                    *
  38. *                         *
  39. * Input:                     *
  40. *   InputSignals  - Inputhandler signals.    *
  41. * Output:                     *
  42. *   none                     *
  43. * Functions:                     *
  44. *   FindWindow, InitGlobals, OpenMenuWindow, *
  45. *   QueTimer, SelectItem, FinalSelect,         *
  46. *   SwapBits, FindWindow, RemoveBitMap,      *
  47. *   CloseItemWindow, TellWindow          *
  48. **********************************************
  49. @PopUpMenu:    MOVEM.L     D2-D7/A2-A3/A5-A6,-(SP)
  50.            MOVEA.L     A0,A3
  51.  
  52. * ------------ ObtainSemaphore(&PopUpSemaphore)
  53.            LEA     _PopUpSemaphore(A4),A0
  54.            MOVEA.L     (AbsExecBase).W,A6
  55.            JSR     _LVOObtainSemaphore(A6)
  56.  
  57. * ------------ Is Window still open ?
  58.            JSR     @FindWindow(PC)
  59.            TST.W     D0
  60.            BEQ.W     Abort
  61.  
  62. * ------------ Lock the screen.
  63.            MOVEA.L     _Screen(A4),A2
  64.            ADDA.W     #sc_LayerInfo,A2
  65.            MOVEA.L     A2,A0
  66.            MOVEA.L     _LayersBase(A4),A6
  67.            JSR     _LVOLockLayers(A6)
  68.  
  69. * ------------ Init the global variables
  70. * ------------ ItemWindow.BitMapOk = FALSE
  71.            MOVEQ.L     #0,D0
  72.            MOVE.W     D0,_ItemWindow(A4)
  73.  
  74. * ------------ SubWindow.BitMapOk = FALSE
  75.            MOVE.W     D0,(A4)       * _SubWindow
  76.  
  77. * ------------ MenuWindow.BitMapOk = FALSE
  78.            MOVE.W     D0,_MenuWindow(A4)
  79.  
  80. * ------------ CurrentMenuNr = 0
  81.            MOVE.W     D0,_CurrentMenuNr(A4)
  82.  
  83. * ------------ CurrentMenuPtr = NULL
  84.            MOVE.L     D0,_CurrentMenuPtr(A4)
  85.  
  86. * ------------ CurrentItem = NULL
  87.            MOVE.L     D0,_CurrentItem(A4)
  88.  
  89. * ------------ CurrentSubItem = NULL
  90.            MOVE.L     D0,_CurrentSubItem(A4)
  91.  
  92. * ------------ ScreenType = (Screen->ViewPort.Modes & HIRES) == 0
  93.            MOVEA.L     _Screen(A4),A5
  94.            BTST     #7,sc_ViewPort+vp_Modes(A5)
  95.            BNE.B     1$
  96.            MOVEQ.L     #1,D0
  97. 1$           MOVE.W     D0,_ScreenType(A4)
  98.  
  99. * ------------ Menues = ActiveWindow->MenuStrip
  100.            MOVEA.L     _ActiveWindow(A4),A0
  101.            MOVE.L     wd_MenuStrip(A0),_Menues(A4)
  102.  
  103. * ------------ InitRastPort(&Rp)
  104.            LEA     _Rp(A4),A1
  105.            MOVEA.L     _GfxBase(A4),A6
  106.            JSR     _LVOInitRastPort(A6)
  107.  
  108. * ------------ SetFont(&Rp,Screen->RastPort.Font)
  109.            LEA     _Rp(A4),A1
  110.            MOVEA.L     sc_RastPort+rp_Font(A5),A0
  111.            JSR     _LVOSetFont(A6)
  112.  
  113. * ------------ Rp.BitMap = &Screen->BitMap
  114.            ADDA.W     #sc_BitMap,A5
  115.            MOVE.L     A5,_Rp+rp_BitMap(A4)
  116.  
  117. * ------------ MenuFontSize = Rp.TxHeight + 2
  118.            MOVE.W     _Rp+rp_TxHeight(A4),D0
  119.            ADDQ.W     #2,D0
  120.            MOVE.W     D0,_MenuFontSize(A4)
  121.  
  122. * ------------ Any menues at all ?
  123.            TST.L     _Menues(A4)
  124.            BEQ.W     NoMenues
  125.  
  126. * ------------ Same menues as last time ?
  127.            MOVEQ.L     #0,D0
  128.            MOVEA.L     _ActiveWindow(A4),A0
  129.            CMPA.L     _LastWindow(A4),A0
  130.            BNE.B     OpenMenues
  131.  
  132. * ------------ Yes: Start at last menu selection.
  133.            MOVE.W     _LastSelectedNum(A4),D0
  134.            SUBQ.W     #1,D0
  135.            MULU.W     _MenuFontSize(A4),D0
  136.  
  137. * ------------ Open the menues.
  138. OpenMenues:    JSR     @OpenMenuWindow(PC)
  139.            TST.W     D0
  140.            BEQ.W     NoMenues
  141.  
  142. * ------------ MenuButtonSignals = MenuUpSig | MenuDownSig
  143.            MOVE.L     sd_MenuUpSig(A3),D6
  144.            OR.L     sd_MenuDownSig(A3),D6
  145.  
  146. * ------------ MouseMovedSignal = MouseMovedSig
  147.            MOVE.L     sd_MouseMovedSig(A3),D5
  148.  
  149. * ------------ ButtonSignals = MenuButtonSignals | SelectDownSig
  150.            MOVE.L     D6,D4
  151.            OR.L     sd_SelectDownSig(A3),D4
  152.  
  153. * ------------ Waiting = FALSE
  154.            MOVEQ.L     #0,D3
  155.  
  156. * ------------ No selections done so far.
  157. * ------------ MenuNumber = LastSelected = MENUNULL;
  158.            MOVEQ.L     #-1,D7
  159.            MOVE.W     D7,_LastSelected(A4)
  160.  
  161. * ------------ Clear old timermessages and set mousemoved signal.
  162. * ------------ SetSignal(MouseMovedSignal,TimerSignal | MouseMovedSignal)
  163.            MOVE.L     D5,D0
  164.            MOVE.L     _TimerSignal(A4),D1
  165.            OR.L     D5,D1
  166.            MOVEA.L     (AbsExecBase).W,A6
  167.            JSR     _LVOSetSignal(A6)
  168.  
  169. * ------------ Is the timer already running.
  170. * ------------ CheckIO(TimerReqBlock)
  171.            MOVEA.L     _TimerReqBlock(A4),A1
  172.            JSR     _LVOCheckIO(A6)
  173.            TST.L     D0
  174.            BNE.B     IOReady
  175.  
  176. * ------------ Yes: wait for the time.
  177. * ------------ WaitIO(TimerReqBlock)
  178.            MOVEA.L     _TimerReqBlock(A4),A1
  179.            JSR     _LVOWaitIO(A6)
  180.  
  181. * ------------ Remove the message.
  182.            MOVEA.L     _TimerPort(A4),A0
  183.            JSR     _LVOGetMsg(A6)
  184.  
  185. * ------------ Start up the timer.
  186. IOReady:       JSR     @QueTimer(PC)
  187.  
  188. * ------------ Main loop starts here.
  189. * ------------ SignalBits = Wait(MouseMovedSignal | ButtonSignals | TimerSignal)
  190. WaitNextSig:   MOVE.L     D5,D0
  191.            OR.L     D4,D0
  192.            OR.L     _TimerSignal(A4),D0
  193.            MOVEA.L     (AbsExecBase).W,A6
  194.            JSR     _LVOWait(A6)
  195.            MOVE.L     D0,D2
  196.  
  197. *********************************************
  198. * D0 = SignalBits      A2 = LayerInfo    *
  199. * D2 = SignalBits      A3 = InputSignals *
  200. * D3 = Waiting          A6 = ExecBase     *
  201. * D4 = ButtonSignals                *
  202. * D5 = MouseMovedSignal             *
  203. * D6 = MenuButtonSignal             *
  204. * D7 = MenuNumber                *
  205. *********************************************
  206. * ------------ Mouse moved ?
  207.            AND.L     D5,D0
  208.            BEQ.B     NotMoved
  209.  
  210. * ------------ Waiting = FALSE
  211.            MOVEQ.L     #0,D3
  212.  
  213. * ------------ Get new coordinates for the mouse.
  214.            MOVEA.L     _Screen(A4),A0
  215.            MOVE.W     sc_MouseX(A0),D0
  216.            MOVE.W     sc_MouseY(A0),D1
  217.            CMP.W     _MouseX(A4),D0
  218.            BNE.B     Moved
  219.            CMP.W     _MouseY(A4),D1
  220.            BEQ.B     NotMoved
  221.  
  222. * ------------ MouseX = Screen->MouseX
  223. * ------------ MouseY = Screen->MouseY
  224. Moved:           MOVE.W     D0,_MouseX(A4)
  225.            MOVE.W     D1,_MouseY(A4)
  226.  
  227. * ------------ Select the item under the mousepointer.
  228.            JSR     @SelectItem(PC)
  229.  
  230. * ------------ Any button pressed ?
  231. NotMoved:      MOVE.L     D2,D0
  232.            AND.L     D4,D0
  233.            BEQ.B     NoButton
  234.  
  235. * ------------ Find MENUPICK value for selected item.
  236.            JSR     @FinalSelect(PC)
  237.  
  238. * ------------ Waiting = FALSE
  239.            MOVEQ.L     #0,D3
  240.  
  241.            MOVE.W     D4,-(SP)
  242.            MOVE.W     D0,D4
  243.  
  244.            MOVE.W     _LastSelected(A4),D1
  245. **********************************************
  246. * D0 = Selected        A2 = LayerInfo    *
  247. * D1 = LastSelected       A3 = InputSignals *
  248. * D2 = SignalBits       A6 = ExecBase     *
  249. * D3 = Waiting                     *
  250. * D4 = Selected                  *
  251. * D5 = MouseMovedSignal              *
  252. * D6 = MenuButtonSignal              *
  253. * D7 = MenuNumber                 *
  254. **********************************************
  255. * ------------ Same item selected as last time ?
  256.            CMP.W     D0,D1
  257.            BEQ.B     SameItem
  258.  
  259. * ------------ First selection ?
  260.            MOVEQ.L     #-1,D0
  261.            CMP.W     D0,D7
  262.            BNE.B     MultipSelect
  263.  
  264. * ------------ MenuNumber = Selected
  265.            MOVE.W     D4,D7
  266.            BRA.B     SelectionDone
  267.  
  268. * ------------ ItemAddress(Menues,LastSelected)->NextSelect = Selected
  269. MultipSelect:  MOVEQ.L     #0,D0
  270.            MOVE.W     D1,D0
  271.            MOVEA.L     _Menues(A4),A0
  272.            MOVEA.L     _IntuitionBase(A4),A6
  273.            JSR     _LVOItemAddress(A6)
  274.            MOVEA.L     D0,A0
  275.            MOVE.W     D4,mi_NextSelect(A0)
  276.  
  277. * ------------ LastSelected = Selected
  278. SelectionDone: MOVE.W     D4,_LastSelected(A4)
  279. SameItem:      MOVE.W     (SP)+,D4
  280.  
  281. * ------------ Selected with menubutton ?
  282.            MOVE.L     D2,D0
  283.            AND.L     D6,D0
  284.            BNE.W     NoMoreSel
  285.  
  286. ********************************************
  287. * D2 = SignalBits     A2 = LayerInfo    *
  288. * D3 = Waiting         A3 = InputSignals *
  289. * D4 = ButtonSignals               *
  290. * D5 = MouseMovedSignal            *
  291. * D6 = MenuButtonSignal            *
  292. * D7 = MenuNumber               *
  293. ********************************************
  294. * ------------ Timer ?
  295. NoButton:      MOVE.L     D2,D0
  296.            AND.L     _TimerSignal(A4),D0
  297.            BEQ.W     WaitNextSig
  298.  
  299. * ------------ Remove the message.
  300.            MOVEA.L     _TimerPort(A4),A0
  301.            MOVEA.L     (AbsExecBase).W,A6
  302.            JSR     _LVOGetMsg(A6)
  303.  
  304. * ------------ 2 TimerSignals in a row ?
  305.            TST.W     D3
  306.            BEQ.B     NoLockUp
  307.  
  308. * ------------ The input.device has stopped.
  309. * ------------ Remove everything from the screen.
  310.            MOVEA.L     A4,A0           * _SubWindow
  311.            JSR     @SwapBits(PC)
  312.            LEA     _ItemWindow(A4),A0
  313.            JSR     @SwapBits(PC)
  314.            LEA     _MenuWindow(A4),A0
  315.            JSR     @SwapBits(PC)
  316.  
  317. * ------------ Unlock the screen.
  318.            MOVEA.L     A2,A0
  319.            MOVEA.L     _LayersBase(A4),A6
  320.            JSR     _LVOUnlockLayers(A6)
  321.  
  322. * ------------ Wait for the input.device.
  323.            MOVE.L     D5,D0
  324.            MOVEA.L     (AbsExecBase).W,A6
  325.            JSR     _LVOWait(A6)
  326.  
  327. * ------------ Is the window still open ?
  328.            JSR     @FindWindow(PC)
  329.            TST.W     D0
  330.            BNE.B     OKToLock
  331.  
  332. * ------------ No: the window is gone. Abort.
  333.            MOVEA.L     A4,A0           * _SubWindow
  334.            JSR     @RemoveBitMap(PC)
  335.            LEA     _ItemWindow(A4),A0
  336.            JSR     @RemoveBitMap(PC)
  337.            LEA     _MenuWindow(A4),A0
  338.            JSR     @RemoveBitMap(PC)
  339.            BRA.B     Abort
  340.  
  341. * ------------ Lock the screen again.
  342. OKToLock:      MOVEA.L     A2,A0
  343.            MOVEA.L     _LayersBase(A4),A6
  344.            JSR     _LVOLockLayers(A6)
  345.  
  346. * ------------ Put everything back on the screen.
  347.            LEA     _MenuWindow(A4),A0
  348.            JSR     @SwapBits(PC)
  349.            LEA     _ItemWindow(A4),A0
  350.            JSR     @SwapBits(PC)
  351.            MOVEA.L     A4,A0           * _SubWindow
  352.            JSR     @SwapBits(PC)
  353.  
  354. * ------------ Start a new timer.
  355. NoLockUp:      JSR     @QueTimer(PC)
  356.  
  357. * ------------ Waiting = !Waiting
  358.            MOVEQ.L     #1,D0
  359.            SUB.W     D3,D0
  360.            MOVE.W     D0,D3
  361.            BRA.W     WaitNextSig
  362.  
  363. * ------------ Selections done.
  364. * ------------ Close all windows.
  365. NoMoreSel:     MOVEA.L     A4,A0           * _SubWindow
  366.            JSR     @CloseItemWindow(PC)
  367.            LEA     _ItemWindow(A4),A0
  368.            JSR     @CloseItemWindow(PC)
  369.            LEA     _MenuWindow(A4),A0
  370.            JSR     @CloseItemWindow(PC)
  371.  
  372. * ------------ Remember the selection for next time.
  373. NoMenues:      MOVE.L     _ActiveWindow(A4),_LastWindow(A4)
  374.  
  375. * ------------ Unlock the screen.
  376.            MOVEA.L     A2,A0
  377.            MOVEA.L     _LayersBase(A4),A6
  378.            JSR     _LVOUnlockLayers(A6)
  379.  
  380. * ------------ Tell the window the good news (MENUPICK).
  381.            MOVE.L     D7,D0
  382.            JSR     @TellWindow(PC)
  383.  
  384. * ------------ ReleaseSemaphore(&PopUpSemaphore);
  385. Abort:           LEA     _PopUpSemaphore(A4),A0
  386.            MOVEA.L     (AbsExecBase).W,A6
  387.            JSR     _LVOReleaseSemaphore(A6)
  388.  
  389. * ------------ Free the sorted menulist      * New 3.42
  390.            LEA     _SortRemember(A4),A0
  391.            MOVEQ.L     #TRUE,D0
  392.            MOVEA.L     _IntuitionBase(A4),A6
  393.            JSR     _LVOFreeRemember(A6)
  394.  
  395.            MOVEM.L     (SP)+,D2-D7/A2-A3/A5-A6
  396.            RTS
  397.  
  398. ************************************************
  399. * FindMenuPtr(Number) - Find Menu structure.   *
  400. *                           *
  401. * Input:                       *
  402. *   Number.W - Number of the menu to look for. *
  403. * Output:                       *
  404. *   return - Ptr to the Menu structure.        *
  405. ************************************************
  406. @FindMenuPtr:    MOVEA.L   _MenuSorted+ms_Next(A4),A0
  407.  
  408. 1$        SUBQ.W      #1,D0
  409.         BEQ.B      2$
  410.  
  411.         MOVEA.L   (A0),A0     * ms_Next
  412.         MOVE.L      A0,D1
  413.         BNE.B      1$
  414.         MOVEQ.L   #0,D0
  415.         RTS
  416.  
  417. 2$        MOVE.L      ms_MenuPtr(A0),D0
  418.         RTS
  419.  
  420. ************************************************
  421. * FindItemNr(Item,ItemList) - Find nr of item. *
  422. *                           *
  423. * Input:                       *
  424. *   Item - Item to look for.               *
  425. *   ItemList - all items on same level.        *
  426. * Output:                       *
  427. *   return - Nr of Item.               *
  428. ************************************************
  429. * ------------ Count = 0
  430. @FindItemNr:   MOVEQ.L     #00,D0
  431.  
  432. * ------------ ItemList == NULL ?
  433. 1$           MOVE.L     A1,D1
  434.            BEQ.B     2$
  435.  
  436. * ------------ ItemList == Item ?
  437.            CMPA.L     A0,A1
  438.            BEQ.B     3$
  439.  
  440. * ------------ Count++
  441.            ADDQ.W     #1,D0
  442.  
  443. * ------------ ItemList = ItemList->NextItem
  444.            MOVEA.L     (A1),A1
  445.            BRA.B     1$
  446.  
  447. 2$           MOVEQ.L     #NOITEM,D0
  448. 3$           RTS
  449.  
  450. ******************************************************
  451. * QueTimer() - Queue the timer to go of after 0.2s   *
  452. *                             *
  453. * Input:                         *
  454. *   none                         *
  455. * Output:                         *
  456. *   none:                         *
  457. ******************************************************/
  458. @QueTimer:     MOVE.L     A6,-(SP)
  459.  
  460. * ------------ TimerReqBlock->tr_node.io_Command = TR_ADDREQUEST
  461.            MOVEA.L     _TimerReqBlock(A4),A1
  462.            MOVE.W     #TR_ADDREQUEST,IO_COMMAND(A1)
  463.  
  464. * ------------ TimerReqBlock->tr_time.tv_secs = 0
  465.            CLR.L     IOTV_TIME+TV_SECS(A1)
  466.  
  467. * ------------ TimerReqBlock->tr_time.tv_micro = 200000
  468.            MOVE.L     #200000,IOTV_TIME+TV_MICRO(A1)
  469.  
  470. * ------------ SendIO(TimerReqBlock)
  471.            MOVEA.L     (AbsExecBase).W,A6
  472.            JSR     _LVOSendIO(A6)
  473.  
  474.            MOVEA.L     (SP)+,A6
  475.            RTS
  476.  
  477. *************************************************
  478. * FindWindow() - Check if window is still open. *
  479. *                        *
  480. * Input:                    *
  481. *   none                    *
  482. * Output:                    *
  483. *   return  - TRUE if window is open.        *
  484. *************************************************
  485. @FindWindow:   MOVE.L    D2,-(SP)
  486.            MOVE.L    A6,-(SP)
  487.  
  488.            MOVEQ.L     #0,D0
  489.            MOVEA.L     _IntuitionBase(A4),A6
  490.            JSR     _LVOLockIBase(A6)
  491.  
  492. * ------------ TestScreen = IntuitionBase->FirstScreen
  493.            MOVEA.L     ib_FirstScreen(A6),A0
  494.  
  495. * ------------ TestScreen == NULL ?
  496. 1$           MOVE.L     A0,D1
  497.            BEQ.B     5$
  498.  
  499. * ------------ TestScreen == Screen ?
  500.            CMPA.L     _Screen(A4),A0
  501.            BNE.B     4$
  502.  
  503. * ------------ TestWindow = TestScreen->FirstWindow
  504.            MOVEA.L     sc_FirstWindow(A0),A1
  505.  
  506. * ------------ TestWindow == NULL ?
  507. 2$           MOVE.L     A1,D1
  508.            BEQ.B     5$
  509.  
  510. * ------------ TestWindow == ActiveWindow ?
  511.            CMPA.L     _ActiveWindow(A4),A1
  512.            BNE.B     3$
  513.  
  514.            MOVEQ.L     #TRUE,D2
  515.            BRA.B     6$
  516.  
  517. * ------------ TestWindow = TestWindow->NextWindow
  518. 3$           MOVEA.L     (A1),A1
  519.            BRA.B     2$
  520.  
  521. * ------------ TestScreen = TestScreen->NextScreen
  522. 4$           MOVEA.L     (A0),A0
  523.            BRA.B     1$
  524.  
  525. 5$           MOVEQ.L     #FALSE,D2
  526.  
  527. * ------------ UnlockIBase(Lock)
  528. 6$           MOVEA.L     D0,A0
  529.            JSR     _LVOUnlockIBase(A6)
  530.  
  531.            MOVE.L     D2,D0
  532.  
  533.            MOVEA.L     (SP)+,A6
  534.            MOVE.L     (SP)+,D2
  535.            RTS
  536.  
  537. ***************************************************
  538. * MouseInWindow(Window) - Is mouse inside window. *
  539. *                          *
  540. * Input:                      *
  541. *   Window    - Window to check.          *
  542. * Output:                      *
  543. *   return    - TRUE if mouse inside.          *
  544. ***************************************************
  545. @MouseInWindow:
  546.            MOVEQ.L     #FALSE,D0
  547.  
  548. * ------------ MouseX > Window->LeftEdge ?
  549.            MOVE.W     _MouseX(A4),D1
  550.            CMP.W     wwd_LeftEdge(A0),D1
  551.            BLE.B     1$
  552.  
  553. * ------------ MouseX < Window->RightEdge ?
  554.            CMP.W     wwd_RightEdge(A0),D1
  555.            BGE.B     1$
  556.  
  557. * ------------ MouseY > Window->TopEdge ?
  558.            MOVE.W     _MouseY(A4),D1
  559.            CMP.W     wwd_TopEdge(A0),D1
  560.            BLE.B     1$
  561.  
  562. * ------------ MouseY < Window->Bottom ?
  563.            CMP.W     wwd_Bottom(A0),D1
  564.            BGE.B     1$
  565.  
  566.            MOVEQ.L     #TRUE,D0
  567. 1$           RTS
  568. ****************************************************************
  569. * FindMouseItem(ItemWindow) - Check if mouse inside an item.   *
  570. *                                   *
  571. * Input:                               *
  572. *   ItemWindow - Window with items                   *
  573. * Output:                               *
  574. *   return - Pointer to item under the mousepointer (or NULL). *
  575. ****************************************************************/
  576. @FindMouseItem:
  577.            MOVE.W     D2,-(SP)
  578.  
  579. * ------------ MouseWinX = MouseX + ItemWindow->LeftValue
  580.            MOVE.W     _MouseX(A4),D1
  581.            ADD.W     wwd_LeftValue(A0),D1
  582.  
  583. * ------------ MouseWinY = MouseY + ItemWindow->TopValue
  584.            MOVE.W     _MouseY(A4),D2
  585.            ADD.W     wwd_TopValue(A0),D2
  586.  
  587. * ------------ Item = ItemWindow->Items
  588.            MOVEA.L     wwd_Items(A0),A0
  589.  
  590. * ------------ MouseWinY >= Item->TopEdge ?
  591. 1$           MOVE.W     mi_TopEdge(A0),D0
  592.            CMP.W     D0,D2
  593.            BLT.B     2$
  594.  
  595. * ------------ MouseWinY <= Item->TopEdge + Item->Height ?
  596.            ADD.W     mi_Height(A0),D0
  597.            CMP.W     D0,D2
  598.            BGT.B     2$
  599.  
  600. * ------------ MouseWinX >= Item->LeftEdge ?
  601.            MOVE.W     mi_LeftEdge(A0),D0
  602.            CMP.W     D0,D1
  603.            BLT.B     2$
  604.  
  605. * ------------ MouseWinX <= Item->LeftEdge + Item->Width ?
  606.            ADD.W     mi_Width(A0),D0
  607.            CMP.W     D0,D1
  608.            BGT.B     2$
  609.  
  610. * ------------ return Item.
  611.            MOVE.L     A0,D0
  612.            BRA.B     3$
  613.  
  614. * ------------ Try next item.
  615. 2$           MOVEA.L     (A0),A0
  616.            MOVE.L     A0,D0
  617.            BNE.B     1$
  618.  
  619. 3$           MOVE.W    (SP)+,D2
  620.            RTS
  621.  
  622. *********************************************************
  623. * HighLightCurrItemBehind(Mode) - Highlight currentitem *
  624. *                   behind subwindow.    *
  625. * Input:                        *
  626. *   Mode.W - HIGHLIGHTON or HIGHLIGHTOFF.        *
  627. * Output:                        *
  628. *   none                        *
  629. * Functions:                        *
  630. *   SwapBits, HighLightItem                *
  631. *********************************************************
  632. @HighLightCurrItemBehind:
  633.            MOVE.W     D2,-(SP)
  634.            MOVE.W     D0,D2
  635.  
  636. * ------------ SwapBits(SubWindow)
  637.            MOVEA.L     A4,A0           * _SubWindow
  638.            JSR     @SwapBits(PC)
  639.  
  640. * ------------ HighLightItem(CurrentItem,&ItemWindow,Mode)
  641.            MOVE.W     D2,D0
  642.            MOVEA.L     _CurrentItem(A4),A0
  643.            LEA     _ItemWindow(A4),A1
  644.            JSR     @HighLightItem(PC)
  645.  
  646. * ------------ SwapBits(SubWindow)
  647.            MOVEA.L     A4,A0           * _SubWindow
  648.            JSR     @SwapBits(PC)
  649.  
  650.            MOVE.W     (SP)+,D2
  651.            RTS
  652.  
  653. ******************************************
  654. * OpenMenuWindow(StartPos)               *
  655. *                     *
  656. * Input:                 *
  657. *   StartPos  - Position from menutop.     *
  658. * Output:                 *
  659. *   return    - TRUE if window opened.     *
  660. * Functions:                 *
  661. *   Mystrlen, BuildBitMap, DrawAllMenues *
  662. ******************************************
  663. @OpenMenuWindow:
  664.            MOVEM.L     D5-D7/A3/A5,-(SP)
  665.            MOVE.W     D0,D7
  666.  
  667. * ------------ Sort menues after their LeftEdge
  668.            JSR     @SortMenues(PC)
  669.            TST.L     D0
  670.            BEQ.W     OpenMenuDone
  671.  
  672. * ------------ MenuWidth = 0
  673.            MOVEQ.L     #0,D6
  674.  
  675. * ------------ MenuHeight    = BORDERSIZE + 1
  676.            MOVEQ.L     #3,D5
  677. ****************************************
  678. * Find width & height of window needed *
  679. ****************************************
  680. FindWidthHeight:
  681.            MOVEA.L     _Menues(A4),A3
  682.            MOVEA.L     _GfxBase(A4),A6
  683. ***********************************
  684. * D5 = MenuHeight    A3 = Menues  *
  685. * D6 = MenuWidth     A6 = GfxBase *
  686. * D7 = MenuTop              *
  687. ***********************************
  688. * ------------ Length = TextLength(&Rp,MenuPtr->MenuName,Mystrlen(MenuPtr->MenuName))
  689. 1$           MOVEA.L     mu_MenuName(A3),A0
  690.            JSR     @Mystrlen(PC)
  691.            LEA     _Rp(A4),A1
  692.            MOVEA.L     mu_MenuName(A3),A0
  693.            JSR     _LVOTextLength(A6)
  694.  
  695. * ------------ MenuPtr->Width > Length ?
  696.            MOVE.W     mu_Width(A3),D1
  697.            CMP.W     D0,D1
  698.            BLS.B     2$           * No
  699.  
  700. * ------------ Length = MenuPtr->Width
  701.            MOVE.L     D1,D0
  702.  
  703. * ------------ Length > MenuWidth ?
  704. 2$           CMP.W     D6,D0
  705.            BLS.B     3$           * No
  706.  
  707. * ------------ MenuWidth = Length
  708.            MOVE.W     D0,D6
  709.  
  710. * ------------ MenuHeight += MenuFontSize
  711. 3$           ADD.W     _MenuFontSize(A4),D5
  712.  
  713. * ------------ Check next menu.
  714.            MOVEA.L     (A3),A3
  715.            MOVE.L     A3,D0
  716.            BNE.B     1$
  717.  
  718. * ------------ MenuWidth  += (2 * BORDERSIZE + 1)
  719.            ADDQ.W     #5,D6
  720.  
  721. ************************************
  722. * Position window on screen (Left) *
  723. ************************************
  724. ***********************************
  725. * D5 = MenuHeight    A6 = GfxBase *
  726. * D6 = MenuWidth          *
  727. * D7 = MenuTop              *
  728. ***********************************
  729. * ------------ MenuLeft = Screen->MouseX - MenuWidth / 2
  730. PosLeft:       MOVE.W     D6,D0
  731.            LSR.W     #1,D0
  732.            MOVEA.L     _Screen(A4),A0
  733.            MOVE.W     sc_MouseX(A0),D1
  734.            SUB.W     D0,D1
  735.  
  736. * ------------ MenuLeft < 0 ?
  737.            BGE.B     1$           * No
  738.  
  739. * ------------ MenuLeft = 0
  740.            MOVEQ.L     #0,D1
  741.  
  742. * ------------ MenuLeft > Screen->Width - MenuWidth ?
  743. 1$           MOVE.W     sc_Width(A0),D0
  744.            SUB.W     D6,D0
  745.            CMP.W     D0,D1
  746.            BLE.B     2$           * No
  747.  
  748. * ------------ MenuLeft = Screen->Width - MenuWidth
  749.            MOVE.W     D0,D1
  750.  
  751. * ------------ MenuWindow.LeftEdge = MenuLeft
  752. 2$           MOVE.W     D1,_MenuWindow+wwd_LeftEdge(A4)
  753.  
  754. * ------------ MenuWindow.Width = MenuWidth;
  755.            MOVE.W     D6,_MenuWindow+wwd_Width(A4)
  756.  
  757. ***********************************
  758. * Position window on screen (Top) *
  759. ***********************************
  760. ***********************************
  761. * D5 = MenuHeight    A0 = Screen  *
  762. * D6 = MenuWidth     A6 = GfxBase *
  763. * D7 = MenuTop              *
  764. ***********************************
  765. * ------------ MenuTop > MenuHeight ? (Menues has changed)
  766. PosTop:        CMP.W     D5,D7
  767.            BLE.B     1$           * No
  768.  
  769. * ------------ MenuTop = 0
  770.            MOVEQ     #0,D7
  771.  
  772. * ------------ MenuTop    = Screen->MouseY - MenuFontSize/2 - MenuTop
  773. 1$           MOVE.W     _MenuFontSize(A4),D0
  774.            LSR.W     #1,D0
  775.            ADD.W     D0,D7
  776.            SUB.W     sc_MouseY(A0),D7
  777.            NEG.W     D7
  778.  
  779. * ------------ MenuTop < 0 ?
  780.            BPL.B     2$           * No
  781.  
  782. * ------------ MenuTop = 0
  783.            MOVEQ.L     #0,D7
  784.  
  785. * ------------ MenuTop > Screen->Height - MenuHeight ?
  786. 2$           MOVE.W     sc_Height(A0),D0
  787.            SUB.W     D5,D0
  788.            CMP.W     D0,D7
  789.            BLE.B     3$           * No
  790.  
  791. * ------------ MenuTop = Screen->Height - MenuHeight
  792.            MOVE.L     D0,D7
  793.  
  794. * ------------ MenuWindow.TopEdge = MenuTop
  795. 3$           MOVE.W     D7,_MenuWindow+wwd_TopEdge(A4)
  796.  
  797. * ------------ MenuWindow.Height = MenuHeight
  798.            MOVE.W     D5,_MenuWindow+wwd_Height(A4)
  799. *******************************
  800. * Open window with right size *
  801. *******************************
  802. * ------------ BuildBitMap(MenuWindow)
  803. Open:           LEA     _MenuWindow(A4),A0
  804.            JSR     @BuildBitMap(PC)
  805.  
  806. * ------------ Window open ?
  807.            TST.W     D0
  808.            BEQ.B     OpenMenuDone  * No
  809.  
  810. * ------------ Draw all menues
  811.            JSR     @DrawAllMenues(PC)
  812.  
  813. * ------------ return (TRUE)
  814.            MOVEQ.L     #TRUE,D0
  815.  
  816. OpenMenuDone:  MOVEM.L     (SP)+,D5-D7/A3/A6
  817.            RTS
  818.  
  819. **********************************
  820. * BOOL SortMenues()              *
  821. *                 *
  822. * Input:             *
  823. *   none.             *
  824. * Output:             *
  825. *   TRUE    if everything is ok. *
  826. **********************************
  827. @SortMenues:   MOVEM.L     A2-A3/A5-A6,-(SP)
  828.            MOVEA.L     _IntuitionBase(A4),A6
  829.            MOVEQ.L     #0,D1
  830.            MOVE.L     D1,_SortRemember(A4)
  831.            MOVE.L     D1,_MenuSorted+ms_Next(A4)
  832.  
  833.            MOVEA.L     _Menues(A4),A5
  834.  
  835. 0$           LEA     _SortRemember(A4),A0
  836.            MOVEQ.L     #ms_SIZEOF,D0
  837.            MOVEQ.L     #0,D1
  838.            JSR     _LVOAllocRemember(A6)
  839.            TST.L     D0
  840.            BEQ.B     3$
  841.            MOVE.L     D0,A0
  842.            MOVE.L     A5,ms_MenuPtr(A0)
  843.  
  844.            MOVE.W     mu_LeftEdge(A5),D1
  845.            LEA     _MenuSorted(A4),A3
  846.  
  847. **************************************************
  848. * D1 = LeftEdge for TestMenu  A3 = MenuSorted     *
  849. *                  A5 = TestMenu     *
  850. *                  A6 = IntuitionBase *
  851. **************************************************
  852. 1$           MOVEA.L     (A3),A1        * ms_Next(A3)
  853.            MOVE.L     A1,D0
  854.            BEQ.B     2$
  855.  
  856.            MOVEA.L     ms_MenuPtr(A1),A2
  857.            CMP.W     mu_LeftEdge(A2),D1
  858.            BLE.B     2$
  859.  
  860.            MOVEA.L     A1,A3
  861.            BRA.B     1$
  862.  
  863. 2$           MOVE.L     A1,(A0)        * ms_Next(A0)
  864.            MOVE.L     A0,(A3)        * ms_Next(A3)
  865.  
  866.            MOVEA.L     (A5),A5        * mu_NextMenu
  867.            MOVE.L     A5,D0
  868.            BNE.B     0$
  869.            MOVEQ.L     #TRUE,D0
  870.  
  871. 3$           MOVEM.L     (SP)+,A2-A3/A5-A6
  872.            RTS
  873.  
  874. **************************************************************
  875. * OpenItemWindow(ItemWindow,ParentWindow,TopPos,WindowType)  *
  876. *                                 *
  877. * Input:                             *
  878. *   ItemWindow     - Window to open.                 *
  879. *   ParentWindow -                         *
  880. *   TopPos.W     - Top position for new window.         *
  881. *   WindowType.W - ITEMWINDOW or SUBWINDOW             *
  882. * Output:                             *
  883. *   none                             *
  884. * Functions:                             *
  885. *   FindItemWinSize, PosItemWinLeft, PosItemWinTop,         *
  886. *   BuildBitMap, DrawAllItems                     *
  887. **************************************************************
  888. @OpenItemWindow:
  889.            MOVEM.L     D6-D7/A2-A3,-(SP)
  890.            MOVEA.L     A0,A3
  891.            MOVEA.L     A1,A2
  892.            MOVE.W     D0,D7
  893.            MOVE.W     D1,D6
  894.  
  895. * ------------ FindItemWinSize(ItemWindow,WindowType)
  896.            MOVE.W     D6,D0
  897.            JSR     @FindItemWinSize(PC)
  898.  
  899. * ------------ PosItemWinLeft(ItemWindow,ParentWindow,WindowType)
  900.            MOVE.W     D6,D0
  901.            MOVEA.L     A3,A0
  902.            MOVEA.L     A2,A1
  903.            BSR.B     @PosItemWinLeft
  904.  
  905. * ------------ PosItemWinTop(ItemWindow,TopPos)
  906.            MOVE.W     D7,D0
  907.            MOVEA.L     A3,A0
  908.            JSR     @PosItemWinTop(PC)
  909.  
  910. * ------------ BuildBitMap(ItemWindow)
  911.            MOVEA.L     A3,A0
  912.            JSR     @BuildBitMap(PC)
  913.  
  914.            TST.W     D0
  915.            BEQ.B     1$
  916.  
  917. * ------------ DrawAllItems(ItemWindow)
  918.            MOVEA.L     A3,A0
  919.            JSR     @DrawAllItems(PC)
  920.  
  921. 1$           MOVEM.L     (SP)+,D6-D7/A2-A3
  922.            RTS
  923.  
  924. ******************************************************
  925. * PosItemWinLeft(ItemWindow,ParentWindow,WindowType) *
  926. * - Position window on screen (left)                 *
  927. *                             *
  928. * Input:                         *
  929. *   ItemWindow     - Window to position.             *
  930. *   ParentWindow - Window to position next to.         *
  931. *   WindowType.W - ITEMWINDOW or SUBWINDOW.         *
  932. *                             *
  933. * Possible positions:                     *
  934. *   1. At real position (a'la intuition).            *
  935. *   2. At right side of parent.              *
  936. *   3. At left side of parent.                 *
  937. *   4. On the side that covers parent least.         *
  938. ******************************************************
  939. @PosItemWinLeft:
  940.            MOVEM.L     D3-D7/A2,-(SP)
  941.  
  942. * ------------ LeftValue = Size.Left - BORDERSIZE
  943.            MOVE.W     _Size+ws_Left(A4),D6
  944.            SUBQ.W     #BORDERSIZE,D6
  945.  
  946. * ------------ WindowWidth = Size.Right - LeftValue + BORDERSIZE
  947.            MOVE.W     _Size+ws_Right(A4),D5
  948.            SUB.W     D6,D5
  949.            ADDQ.W     #BORDERSIZE,D5
  950.  
  951. * ------------ LeftPos2 = ParentWindow->LeftEdge - WindowWidth + OVERLAP
  952.            MOVE.W     wwd_LeftEdge(A1),D1
  953.            MOVE.W     D1,D4
  954.            SUB.W     D5,D4
  955.            ADDQ.W     #OVERLAP,D4
  956.  
  957. * ------------ MaxLeft = Screen->Width - WindowWidth
  958.            MOVEA.L     _Screen(A4),A2
  959.            MOVE.W     sc_Width(A2),D3
  960.            SUB.W     D5,D3
  961. **********************************************
  962. * D0 = WindowType      A0 = ItemWindow    *
  963. * D1 = Parent->LeftEdge   A1 = ParentWindow  *
  964. * D2 =              A2 = Screen         *
  965. * D3 = MaxLeft                     *
  966. * D4 = LeftPos2                  *
  967. * D5 = WindowWidth                 *
  968. * D6 = LeftValue                 *
  969. * D7 = WindowLeft                 *
  970. **********************************************
  971. * ------------ WindowType == ITEMWINDOW ?
  972.            TST.W     D0
  973.            BEQ.B     1$    * Yes
  974.  
  975. * ------------ WindowLeft = ParentWindow->LeftEdge + LeftValue
  976.            MOVE.W     D1,D7
  977.            ADD.W     D6,D7
  978.  
  979. * ------------ WindowLeft > MaxLeft ?
  980.            CMP.W     D7,D3
  981.            BLT.B     1$    * Yes
  982.  
  983. * ------------ WindowLeft < 0 ?
  984.            TST.W     D7
  985.            BPL.B     2$    * No
  986.  
  987. * ------------ WindowLeft = ParentWindow->RightEdge - OVERLAP
  988. 1$           MOVE.W     wwd_RightEdge(A1),D7
  989.            SUBQ.W     #OVERLAP,D7
  990.  
  991. * ------------ WindowLeft > MaxLeft ?
  992. 2$           CMP.W     D7,D3
  993.            BGE.B     4$    * No
  994.  
  995. * ------------ LeftPos2 > MaxLeft - WindowLeft ?
  996.            MOVE.W     D3,D0
  997.            SUB.W     D7,D0
  998.            CMP.W     D4,D0
  999.            BGE.B     3$    * No
  1000.  
  1001. * ------------ WindowLeft = (LeftPos2 > 0) ? LeftPos2 : 0
  1002.            MOVE.W     D4,D7
  1003.            BGT.B     4$
  1004.            MOVEQ.L     #0,D7
  1005.            BRA.B     4$
  1006.  
  1007. * ------------ WindowLeft = MaxLeft
  1008. 3$           MOVE.W     D3,D7
  1009.  
  1010. * ------------ WindowWidth < ParentWindow->LeftEdge + OVERLAP - WindowLeft ?
  1011. 4$           MOVE.W     D1,D0
  1012.            ADDQ.W     #OVERLAP,D0
  1013.            SUB.W     D7,D0
  1014.            CMP.W     D5,D0
  1015.            BLE.B     5$           * No
  1016.  
  1017. * ------------ WindowWidth = ParentWindow->LeftEdge + OVERLAP - WindowLeft
  1018.            MOVE.W     D0,D5
  1019.  
  1020. * ------------ ItemWindow->LeftEdge = WindowLeft
  1021. 5$           MOVE.W     D7,wwd_LeftEdge(A0)
  1022.  
  1023. * ------------ ItemWindow->LeftValue = LeftValue - WindowLeft
  1024.            SUB.W     D7,D6
  1025.            MOVE.W     D6,wwd_LeftValue(A0)
  1026.  
  1027. * ------------ ItemWindow->Width = WindowWidth
  1028.            MOVE.W     D5,wwd_Width(A0)
  1029.  
  1030.            MOVEM.L     (SP)+,D3-D7/A2
  1031.            RTS
  1032.  
  1033. **************************************
  1034. * PosItemWinTop(ItemWindow,TopPos)   *
  1035. * - Position Window on screen (Top). *
  1036. *                     *
  1037. * Input:                 *
  1038. *   ItemWindow - Window to position. *
  1039. *   TopPos.W   -             *
  1040. **************************************
  1041. @PosItemWinTop:
  1042.            MOVEM.L     D4-D7,-(SP)
  1043.  
  1044. * ------------ TopValue = Size.Top - BORDERSIZE
  1045.            MOVE.W     _Size+ws_Top(A4),D6
  1046.            SUBQ.W     #BORDERSIZE,D6
  1047.  
  1048. * ------------ WindowTop = TopPos + TopValue
  1049.            MOVE.W     D0,D5
  1050.            ADD.W     D6,D5
  1051.  
  1052. * ------------ WindowHeight = Size.Bottom - TopValue + BORDERSIZE
  1053.            MOVE.W     _Size+ws_Bottom(A4),D4
  1054.            SUB.W     D6,D4
  1055.            ADDQ.W     #BORDERSIZE,D4
  1056.            MOVEA.L     _Screen(A4),A1
  1057.  
  1058. ***************************************
  1059. * D0 = TopPos         A0 = ItemWindow  *
  1060. * D4 = WindowHeight  A1 = Screen      *
  1061. * D5 = WindowTop              *
  1062. * D6 = TopValue               *
  1063. ***************************************
  1064. * ------------ WindowTop > Screen->Height - WindowHeight ?
  1065.            MOVE.W     sc_Height(A1),D0
  1066.            SUB.W     D4,D0
  1067.            CMP.W     D5,D0
  1068.            BGE.B     1$           * No
  1069.  
  1070. * ------------ WindowTop = Screen->Height - WindowHeight
  1071.            MOVE.W     D0,D5
  1072.  
  1073. * ------------ WindowTop < 0 ?
  1074. 1$           TST.W     D5
  1075.            BPL.B     2$           * No
  1076.  
  1077. * ------------ WindowTop = 0
  1078.            MOVEQ.L     #0,D5
  1079.  
  1080. * ------------ ItemWindow->TopEdge = WindowTop
  1081. 2$           MOVE.W     D5,wwd_TopEdge(A0)
  1082.  
  1083. * ------------ ItemWindow->TopValue = TopValue - WindowTop
  1084.            SUB.W     D5,D6
  1085.            MOVE.W     D6,wwd_TopValue(A0)
  1086.  
  1087. * ------------ ItemWindow->Height = WindowHeight
  1088.            MOVE.W     D4,wwd_Height(A0)
  1089.  
  1090.            MOVEM.L     (SP)+,D4-D7
  1091.            RTS
  1092.  
  1093. ************************************************
  1094. *  TellWindow(MenuNum) - Send Fake Menu Event. *
  1095. *                           *
  1096. * Input:                       *
  1097. *   MenuNum -    Menu nimber to send.           *
  1098. * Output:                       *
  1099. *   none                       *
  1100. * Functions:                       *
  1101. *   FindWindow                       *
  1102. ************************************************
  1103. @TellWindow:   MOVE.L    A2,-(SP)
  1104.            MOVE.L    A6,-(SP)
  1105.            LEA     -ie_SIZEOF(SP),SP
  1106.  
  1107. * ------------ MyFakeEvent.ie_Class = IECLASS_MENULIST
  1108.            MOVE.B     #IECLASS_MENULIST,ie_Class(SP)
  1109.  
  1110. * ------------ MyFakeEvent.ie_Code = MenuNumber
  1111.            MOVE.W     D0,ie_Code(SP)
  1112.  
  1113. * ------------ MyFakeEvent.ie_Qualifier = 0
  1114.            CLR.W     ie_Qualifier(SP)
  1115.  
  1116. * ------------ MyFakeEvent.ie_NextEvent = NULL
  1117.            CLR.L     (SP)
  1118.  
  1119. * ------------ MyFakeEvent.ie_EventAddress = NULL
  1120.            CLR.L     ie_EventAddress(SP)
  1121.  
  1122. * ------------ Get current time.
  1123.            LEA     ie_TimeStamp+TV_SECS(SP),A0
  1124.            LEA     ie_TimeStamp+TV_MICRO(SP),A1
  1125.            MOVEA.L     _IntuitionBase(A4),A6
  1126.            JSR     _LVOCurrentTime(A6)
  1127.  
  1128. * ------------ InputReqBlock->io_Command = IND_WRITEEVENT
  1129.            MOVEA.L     _InputReqBlock(A4),A2
  1130.            MOVE.W     #IND_WRITEEVENT,IO_COMMAND(A2)
  1131.  
  1132. * ------------ InputReqBlock->io_Flags     = 0
  1133.            CLR.B     IO_FLAGS(A2)
  1134.  
  1135. * ------------ InputReqBlock->io_Length = sizeof(struct InputEvent)
  1136.            MOVEQ.L     #ie_SIZEOF,D0
  1137.            MOVE.L     D0,IO_LENGTH(A2)
  1138.  
  1139. * ------------ InputReqBlock->io_Data = &MyFakeEvent
  1140.            MOVE.L     SP,IO_DATA(A2)
  1141.  
  1142. * ------------ Be sure the right window will get the message.
  1143.            JSR     @FindWindow(PC)
  1144.            TST.W     D0
  1145.            BEQ.B     1$
  1146.  
  1147.            MOVEA.L     _ActiveWindow(A4),A0
  1148.            JSR     _LVOActivateWindow(A6)
  1149.  
  1150. * ------------ DoIO(InputReqBlock)
  1151.            MOVEA.L     A2,A1
  1152.            MOVEA.L     (AbsExecBase).W,A6
  1153.            JSR     _LVODoIO(A6)
  1154.  
  1155. 1$           LEA     ie_SIZEOF(SP),SP
  1156.            MOVEA.L     (SP)+,A6
  1157.            MOVEA.L     (SP)+,A2
  1158.            RTS
  1159.  
  1160. ****************************************
  1161. * DrawAllItems(ItemWindow)             *
  1162. *                       *
  1163. * Input:                   *
  1164. *   ItemWindow    - Window to draw into. *
  1165. *                       *
  1166. * Output:                   *
  1167. *   none                   *
  1168. * Functions:                   *
  1169. *   ClearWindow, DrawMenuItem           *
  1170. ****************************************
  1171. @DrawAllItems: MOVE.L     A2,-(SP)
  1172.            MOVE.L     A3,-(SP)
  1173.  
  1174.            MOVEA.L     A0,A3
  1175.  
  1176. * ------------ Item = ItemWindow->Items
  1177.            MOVEA.L     wwd_Items(A3),A2
  1178.  
  1179. * ------------ ClearWindow(ItemWindow)
  1180.            BSR.B     @ClearWindow
  1181.  
  1182. * ------------ DrawMenuItem(Item, ItemWindow, ITEMFILL)
  1183. 1$           MOVEQ.L     #0,D0
  1184.            MOVEA.L     A2,A0
  1185.            MOVEA.L     A3,A1
  1186.            JSR     @DrawMenuItem(PC)
  1187.  
  1188. * ------------ Item = Item->NextItem
  1189.            MOVEA.L     (A2),A2
  1190.            MOVE.L     A2,D0
  1191.            BNE.B     1$
  1192.  
  1193.            MOVEA.L     (SP)+,A3
  1194.            MOVEA.L     (SP)+,A2
  1195.            RTS
  1196.  
  1197. *********************************
  1198. * ClearWindow(window)           *
  1199. *                *
  1200. * Input:            *
  1201. *   Window   - Window to clear. *
  1202. * Output:            *
  1203. *   none            *
  1204. *********************************
  1205. @ClearWindow:  MOVEM.L     D2-D3/A2-A3/A5-A6,-(SP)
  1206.            MOVEA.L     A0,A3
  1207.  
  1208.            LEA     _Rp(A4),A2
  1209.            MOVEA.L     _ActiveWindow(A4),A5
  1210.            MOVEA.L     _GfxBase(A4),A6
  1211.  
  1212. *********************
  1213. * A2 = Rp        *
  1214. * A3 = Window        *
  1215. * A5 = ActiveWindow *
  1216. * A6 = GfxBase        *
  1217. *********************
  1218.  
  1219. * ------------ SetDrMd(Rp, JAM1)
  1220.            MOVEA.L     A2,A1
  1221.            MOVEQ.L     #RP_JAM1,D0
  1222.            JSR     _LVOSetDrMd(A6)
  1223.  
  1224. * ------------ SetAPen(Rp,ActiveWindow->BlockPen)
  1225.            MOVEA.L     A2,A1
  1226.            MOVEQ.L     #0,D0
  1227.            MOVE.B     wd_BlockPen(A5),D0
  1228.            JSR     _LVOSetAPen(A6)
  1229.  
  1230. * ------------ SetOPen(Rp,ActiveWindow->DetailPen)
  1231.            MOVE.B     wd_DetailPen(A5),_Rp+rp_AOlPen(A4)
  1232.            BSET     #3,_Rp+rp_Flags+1(A4)   * AREAOUTLINE
  1233.  
  1234. * ------------ RectFill(Rp,Window->LeftEdge,Window->TopEdge,
  1235. * ------------           Window->RightEdge,Window->Bottom)
  1236.            MOVE.W     wwd_LeftEdge(A3),D0
  1237.            EXT.L     D0
  1238.            MOVE.W     wwd_TopEdge(A3),D1
  1239.            EXT.L     D1
  1240.            MOVE.W     wwd_RightEdge(A3),D2
  1241.            EXT.L     D2
  1242.            MOVE.W     wwd_Bottom(A3),D3
  1243.            EXT.L     D3
  1244.            MOVEA.L     A2,A1
  1245.            JSR     _LVORectFill(A6)
  1246.  
  1247. * ------------ BNDRYOFF(Rp)
  1248.            BCLR     #3,_Rp+rp_Flags+1(A4)
  1249.  
  1250.            MOVEM.L     (SP)+,D2-D3/A2-A3/A5-A6
  1251.            RTS
  1252.  
  1253. *******************************
  1254. * CloseItemWindow(Window)     *
  1255. *                  *
  1256. * Input:              *
  1257. *   Window - Window to close. *
  1258. * Output:              *
  1259. *   none              *
  1260. * Functions:              *
  1261. *   SwapBits, RemoveBitMap    *
  1262. *******************************
  1263. @CloseItemWindow:
  1264.            MOVE.L     A3,-(SP)
  1265.            MOVEA.L     A0,A3
  1266.  
  1267. * ------------ Remove window from screen.
  1268.            JSR     @SwapBits(PC)
  1269.  
  1270. * ------------ Remove all bitplanes.
  1271.            MOVEA.L     A3,A0
  1272.            JSR     @RemoveBitMap(PC)
  1273.  
  1274.            MOVEA.L     (SP)+,A3
  1275.            RTS
  1276.  
  1277.  
  1278. ****************************************
  1279. * BuildBitMap(Window)  - OpenWindow    *
  1280. *                       *
  1281. * Input:                   *
  1282. *   Window    - Window to open.        *
  1283. * Output:                   *
  1284. *   return    - TRUE if window opened. *
  1285. ****************************************
  1286.  
  1287. @BuildBitMap:  MOVEM.L     D2-D5/A2-A3/A6,-(SP)
  1288.            MOVEA.L     A0,A3
  1289.  
  1290. * ------------ WindowWidth = Window->Width
  1291.            MOVE.W     wwd_Width(A3),D3
  1292.            EXT.L     D3
  1293.  
  1294. * ------------ WindowHeight = Window->Height
  1295.            MOVE.W     wwd_Height(A3),D2
  1296.            EXT.L     D2
  1297.  
  1298.            MOVEA.L     _Screen(A4),A0
  1299.  
  1300. **************************************
  1301. * D2 = WindowHeight     A0 = Screen *
  1302. * D3 = WindowWidth     A3 = Window *
  1303. **************************************
  1304.  
  1305. * ------------ Is window to big for screen ?
  1306. * ------------ WindowWidth > Screen->Width
  1307.            CMP.W     sc_Width(A0),D3
  1308.            BGT.B     Fail           * Yes
  1309.  
  1310. * ------------ WindowHeight > Screen->Height
  1311.            CMP.W     sc_Height(A0),D2
  1312.            BGT.B     Fail           * Yes
  1313.  
  1314. * ------------ Window->RightEdge = Window->LeftEdge + WindowWidth  - 1
  1315.            MOVE.L     D3,D0
  1316.            ADD.W     wwd_LeftEdge(A3),D0
  1317.            SUBQ.L     #1,D0
  1318.            MOVE.W     D0,wwd_RightEdge(A3)
  1319.  
  1320. * ------------ Window->Bottom     = Window->TopEdge  + WindowHeight - 1
  1321.            MOVE.L     D2,D0
  1322.            ADD.W     wwd_TopEdge(A3),D0
  1323.            SUBQ.L     #1,D0
  1324.            MOVE.W     D0,wwd_Bottom(A3)
  1325.  
  1326. * ------------ Depth = Screen->BitMap.Depth
  1327.            MOVEQ.L     #0,D5
  1328.            MOVE.B     sc_BitMap+bm_Depth(A0),D5
  1329.  
  1330.            MOVEA.L     _GfxBase(A4),A6
  1331.  
  1332. ***************************************
  1333. * D2 = WindowHeight     A0 = Screen  *
  1334. * D3 = WindowWidth     A3 = Window  *
  1335. * D5 = Depth         A6 = GfxBase *
  1336. ***************************************
  1337.  
  1338. * ------------ InitBitMap(&Window->Bm,Depth,WindowWidth,WindowHeight)
  1339.            LEA     wwd_Bm(A3),A0
  1340.            MOVE.L     D5,D0
  1341.            MOVE.L     D3,D1
  1342.            JSR     _LVOInitBitMap(A6)
  1343.  
  1344. * ------------ Window->BitMapOk = TRUE
  1345.            MOVE.W     #TRUE,(A3)
  1346.  
  1347.            MOVEQ.L     #0,D4
  1348.  
  1349. * ------------ Plane = &Window->Bm.Planes[0]
  1350.            LEA     wwd_Bm+bm_Planes(A3),A2
  1351.  
  1352. ***************************************
  1353. * D2 = WindowHeight     A2 = Planen  *
  1354. * D3 = WindowWidth     A3 = Window  *
  1355. * D4 = Counter         A6 = GfxBase *
  1356. * D5 = Depth                  *
  1357. ***************************************
  1358.  
  1359. * ------------ More planes to allocate ?
  1360. BuildNextPl:   CMP.W     D4,D5
  1361.            BEQ.B     AllRastersOK
  1362.            ADDQ.W     #1,D4
  1363.  
  1364. * ------------ Plane++ = AllocRaster(WindowWidth,WindowHeight)
  1365.            MOVE.L     D3,D0
  1366.            MOVE.L     D2,D1
  1367.            JSR     _LVOAllocRaster(A6)
  1368.            MOVE.L     D0,(A2)+
  1369.  
  1370. * ------------ Out of ChipRam ?
  1371.            BNE.B     BuildNextPl   * No
  1372.  
  1373. * ------------ RemoveBitMap(Window)
  1374.            MOVEA.L     A3,A0
  1375.            BSR.B     @RemoveBitMap
  1376.  
  1377. * ------------ return FALSE
  1378. Fail:           MOVEQ.L     #FALSE,D0
  1379.            BRA.B     BuildDone
  1380.  
  1381. * ------------ Make window visible.
  1382. AllRastersOK:  MOVEA.L     A3,A0
  1383.            BSR.B     @SwapBits
  1384.  
  1385. * ------------ ClearWindow(Window)
  1386.            MOVEA.L     A3,A0
  1387.            JSR     @ClearWindow(PC)
  1388.  
  1389. * ------------ return TRUE
  1390.            MOVEQ.L     #TRUE,D0
  1391.  
  1392. BuildDone:     MOVEM.L     (SP)+,D2-D5/A2-A3/A6
  1393.            RTS
  1394.  
  1395. ****************************************************************************
  1396. * RemoveBitMap(Window) - Remove allocated rasters in the BitMap structure. *
  1397. *                                       *
  1398. * Input:                                   *
  1399. *   Window   - Window with bitmap.                       *
  1400. * Output:                                   *
  1401. *   none                                   *
  1402. ****************************************************************************
  1403. @RemoveBitMap: MOVEM.L     D4-D7/A2/A6,-(SP)
  1404.  
  1405. * ------------ Anything to remove ?
  1406.            TST.W     (A0)          * BitMapOK
  1407.            BEQ.B     RemoveDone
  1408.            CLR.W     (A0)          * BitMapOK
  1409.  
  1410. * ------------ Remove all allocated rasters.
  1411.            MOVEQ.L     #0,D7
  1412.            LEA     wwd_Bm(A0),A2
  1413.            MOVE.B     bm_Depth(A2),D7
  1414.  
  1415.            MOVE.W     wwd_Width(A0),D6
  1416.            EXT.L     D6
  1417.  
  1418.            MOVE.W     wwd_Height(A0),D5
  1419.            EXT.L     D5
  1420.  
  1421.            ADDQ.L     #bm_Planes,A2
  1422.  
  1423.            MOVEA.L     _GfxBase(A4),A6
  1424.  
  1425.            MOVEQ.L     #0,D4
  1426. *************************************
  1427. * D4 = Counter           A2 = Planes  *
  1428. * D5 = WindowHeight    A0 = Window  *
  1429. * D6 = WindowWidth     A6 = GfxBase *
  1430. * D7 = Depth                *
  1431. *************************************
  1432. RemoveNextPl:  CMP.W     D4,D7
  1433.            BEQ.B     RemoveDone
  1434.            ADDQ.W     #1,D4
  1435.  
  1436. * ------------ This raster allocated ?
  1437.            MOVEA.L     (A2)+,A0
  1438.            MOVE.L     A0,D0
  1439.            BEQ.B     RemoveDone
  1440.  
  1441. * ------------ FreeRaster(Planes++,Width,Height);
  1442.  
  1443.            MOVE.L     D6,D0
  1444.            MOVE.L     D5,D1
  1445.            JSR     _LVOFreeRaster(A6)
  1446.            BRA.B     RemoveNextPl
  1447.  
  1448. RemoveDone:    MOVEM.L     (SP)+,D4-D7/A2/A6
  1449.            RTS
  1450.  
  1451. *****************************************************************************
  1452. * SwapBits(Window) - Works like SwapBitsRastPortClipRect() without bugs :-) *
  1453. *                                        *
  1454. *****************************************************************************
  1455. ALLPLANES      EQU     -1
  1456. B_XOR_C        EQU     ABNC+ANBC
  1457.  
  1458. * ------------ Check to see that window is open
  1459. @SwapBits:     TST.W      (A0)
  1460.            BEQ.B      NoWindow
  1461.  
  1462.            MOVEM.L      D2-D7/A2/A6,-(SP)
  1463.  
  1464. * ------------ SrcX
  1465.            MOVEQ.L      #0,D0
  1466.            MOVE.W      wwd_LeftEdge(A0),D0
  1467.  
  1468. * ------------ SrcY
  1469.            MOVEQ.L      #0,D1
  1470.            MOVE.W      wwd_TopEdge(A0),D1
  1471.  
  1472. * ------------ SizeX
  1473.            MOVEQ.L      #0,D4
  1474.            MOVE.W      wwd_Width(A0),D4
  1475.  
  1476. * ------------ SizeY
  1477.            MOVEQ.L      #0,D5
  1478.            MOVE.W      wwd_Height(A0),D5
  1479.  
  1480. * ------------ MinTerm
  1481.            MOVEQ.L      #B_XOR_C,D6
  1482.  
  1483. * ------------ Mask
  1484.            MOVEQ.L      #ALLPLANES,D7
  1485.  
  1486. * ------------ TempA
  1487.            SUB.L      A2,A2
  1488.  
  1489.            MOVE.L      _GfxBase(A4),A6
  1490.  
  1491. * ------------ Off-screen bitmap
  1492.            LEA      wwd_Bm(A0),A1
  1493.  
  1494. * ------------ On-screen bitmap
  1495.            MOVE.L      _Rp+rp_BitMap(A4),A0
  1496.  
  1497. * ------------ DestX
  1498.            MOVEQ.L      #0,D2
  1499. * ------------ DestY
  1500.            MOVEQ.L      #0,D3
  1501.  
  1502. * ------------ OffScreen = OffScreen XOR OnScreen
  1503.            BSR.B      Swap
  1504. * ------------ OnScreen = OnScreen XOR OffScreen  (= OffScreen)
  1505.            BSR.B      Swap
  1506. * ------------ OffScreen = OffScreen XOR OnScreen  (= OnScreen)
  1507.            BSR.B      Swap
  1508.  
  1509.            MOVEM.L      (SP)+,D2-D7/A2/A6
  1510. NoWindow:      RTS
  1511.  
  1512.  
  1513. Swap:           MOVEM.L      D0/D1/A0/A1,-(SP)
  1514.            JSR      _LVOBltBitMap(A6)
  1515.            MOVEM.L      (SP)+,D0/D1/A0/A1
  1516.  
  1517.            EXG.L      A0,A1
  1518.            EXG.L      D0,D2
  1519.            EXG.L      D1,D3
  1520.  
  1521.            RTS
  1522.  
  1523. ********************************************
  1524. * FindItemWinSize(ItemWindow,WindowType)   *
  1525. *                       *
  1526. * Find with and hight needed for all items *
  1527. ********************************************
  1528. @FindItemWinSize:
  1529.            MOVE.L    A2,-(SP)
  1530.  
  1531. * ------------ Item = ItemWindow->Items
  1532.            MOVEA.L     wwd_Items(A0),A2
  1533.  
  1534. * ------------ Size.Left  = WORD_MAX
  1535.            MOVE.W     #$7FFF,_Size(A4)
  1536.  
  1537. * ------------ Size.Top   = WindowType (ITEMWINDOW -> TopPos >= 0), SUBWINDOW -> no limit */
  1538.            MOVE.W     D0,_Size+ws_Top(A4)
  1539.  
  1540. * ------------ Size.Right = Size.Bottom = WORD_MIN
  1541.            MOVE.W     #$8000,D0
  1542.            MOVE.W     D0,_Size+ws_Right(A4)
  1543.            MOVE.W     D0,_Size+ws_Bottom(A4)
  1544.  
  1545. * ------------ CheckItemSize(Item,Item->ItemFill)
  1546. 1$           MOVEA.L     A2,A0
  1547.            MOVEA.L     mi_ItemFill(A0),A1
  1548.            BSR.B     @CheckItemSize
  1549.  
  1550. * ------------ Item->Flags & HIGHFLAGS == HIGHIMAGE ?
  1551.            MOVE.W     #HIGHFLAGS,D0
  1552.            AND.W     mi_Flags(A2),D0
  1553.            BNE.B     2$
  1554.  
  1555. * ------------ CheckItemSize(Item,Item->SelectFill)
  1556.            MOVEA.L     A2,A0
  1557.            MOVEA.L     mi_SelectFill(A0),A1
  1558.            BSR.B     @CheckItemSize
  1559.  
  1560. * ------------ Check next item.
  1561. 2$           MOVEA.L     (A2),A2
  1562.            MOVE.L     A2,D0
  1563.            BNE.B     1$
  1564.  
  1565.            MOVE.L     (SP)+,A2
  1566.            RTS
  1567.  
  1568. *********************************************************
  1569. * CheckItemSize(Item,Contents) -                        *
  1570. *  find the size needed to include Item in window.    *
  1571. *                            *
  1572. * Input:                        *
  1573. *   Item      (A0)  Item to check.                      *
  1574. *   Contents  (A1)  What to fill (ItemFill/SelectFill). *
  1575. * Output:                        *
  1576. *   Size        New size of window            *
  1577. *********************************************************
  1578. @CheckItemSize:
  1579.            MOVEM.L      D2-D7/A2-A3/A5-A6,-(SP)
  1580.  
  1581.            MOVEA.L      A0,A2           * A2 = Item to check
  1582.            MOVEA.L      A1,A5           * A5 = What to check
  1583.            LEA      _Size(A4),A3        * A3 = SizeSoFar
  1584.  
  1585. * ------------ Anything to check ?
  1586. Check:           MOVE.L      A5,D0
  1587.            BEQ.W      CheckDone
  1588.  
  1589.            MOVE.W      mi_LeftEdge(A2),D3  * D3 = LeftEdge
  1590.            MOVE.W      mi_TopEdge(A2),D2   * D2 = TopEdge
  1591.            MOVE.W      D3,D7           * D7 = Left
  1592.            MOVE.W      D2,D6           * D6 = Top
  1593.  
  1594. * ------------ ITEMTEXT or ITEMIMAGE ?
  1595.            MOVEQ.L      #ITEMTEXT,D0
  1596.            AND.W      mi_Flags(A2),D0
  1597.            BEQ.B      ItemImage
  1598.  
  1599. * ------------ Add IText position to left and top.
  1600.            ADD.W      it_LeftEdge(A5),D7
  1601.            ADD.W      it_TopEdge(A5),D6
  1602.  
  1603.            MOVE.W      D7,D5           * D5 = Right
  1604.            MOVE.W      D6,D4           * D4 = Bottom
  1605. * ------------ What font to use ?
  1606.            MOVE.L      it_ITextFont(A5),D0
  1607.            BEQ.B      DefaultFont
  1608.  
  1609. * ------------ Find hight of string in pixels and add to top.
  1610.            MOVEA.L      D0,A0
  1611.            ADD.W      ta_YSize(A0),D4     * D4 = Bottom
  1612.  
  1613. * ------------ Find length of string in pixels.
  1614.            MOVEA.L      A5,A0
  1615.            MOVEA.L      _IntuitionBase(A4),A6
  1616.            JSR      _LVOIntuiTextLength(A6)
  1617.  
  1618. * ------------ Add to LeftEdge.
  1619.            ADD.W      D0,D5           * D5 = Right
  1620.  
  1621.            BRA.B      NextText
  1622.  
  1623. * ------------ Find length of string with default font.
  1624. DefaultFont:   MOVEA.L      it_IText(A5),A0
  1625.            JSR      @Mystrlen(PC)
  1626.            LEA      _Rp(A4),A1
  1627.            MOVEA.L      it_IText(A5),A0
  1628.            MOVEA.L      _GfxBase(A4),A6
  1629.            JSR      _LVOTextLength(A6)
  1630.  
  1631. * ------------ Add to LeftEdge to get rightedge.
  1632.            ADD.W      D0,D5
  1633.  
  1634. * ------------ Find hight of string in pixels and add to top to get bottom.
  1635.            MOVE.W      _Rp+rp_TxHeight(A4),D4
  1636.            ADD.W      D6,D4
  1637.  
  1638. * ------------ Move to next text.
  1639. NextText:      MOVEA.L      it_NextText(A5),A5
  1640.            BRA.B      CheckLeft
  1641.  
  1642. * ------------ Add Image position to left and top.
  1643. ItemImage:     ADD.W      (A5),D7
  1644.            ADD.W      ig_TopEdge(A5),D6
  1645.  
  1646. * ------------ Add Image width and height to right and bottom.
  1647.            MOVE.W      D7,D5
  1648.            MOVE.W      D6,D4
  1649.  
  1650.            ADD.W      ig_Width(A5),D5     * D5 = Right
  1651.            ADD.W      ig_Height(A5),D4    * D4 = Bottom
  1652.  
  1653. * ------------ Move to next image
  1654.            MOVE.L      ig_NextImage(A5),A5
  1655.  
  1656. * ------------ Find lowest leftedge.
  1657. CheckLeft:     CMP.W      D7,D3           * D3 = LeftEdge
  1658.            BGE.B      1$
  1659.            MOVE.W      D3,D7
  1660. 1$:           CMP.W      (A3),D7
  1661.            BGE.B      CheckRight
  1662.            MOVE.W      D7,(A3)
  1663.  
  1664. * ------------ Find Biggest RightEdge
  1665. CheckRight:    ADD.W      mi_Width(A2),D3     * D3 = RightEdge
  1666.            CMP.W      D5,D3
  1667.            BLE.B      1$
  1668.            MOVE.W      D3,D5
  1669. * ------------ If item has subitem make room for pointer.
  1670. 1$:           TST.L      mi_SubItem(A2)
  1671.            BEQ.B      2$
  1672.            ADDQ.W      #6,D5
  1673. * ------------ If screentype is HIRESSCREEN make pointer bigger.
  1674.            TST.W      _ScreenType(A4)
  1675.            BNE.B      2$
  1676.            ADDQ.W      #4,D5
  1677. 2$:           CMP.W      ws_Right(A3),D5
  1678.            BLE.B      CheckTop
  1679.            MOVE.W      D5,ws_Right(A3)
  1680.  
  1681. * ------------ Find lowest Topedge.
  1682. CheckTop:      CMP.W      D6,D2           * D2 = TopEdge
  1683.            BGE.B      1$
  1684.            MOVE.W      D2,D6
  1685. 1$:           CMP.W      ws_Top(A3),D6
  1686.            BGE.B      CheckBottom
  1687.            MOVE.W      D6,ws_Top(A3)
  1688.  
  1689. * ------------ Find biggest bottompos.
  1690. CheckBottom:   ADD.W      mi_Height(A2),D2    * D2 = BottomEdge
  1691.            CMP.W      D4,D2
  1692.            BLE.B      1$
  1693.            MOVE.W      D2,D4
  1694. 1$:           CMP.W      ws_Bottom(A3),D4
  1695.            BLE.B      2$              * Size comes before speed.
  1696.            MOVE.W      D4,ws_Bottom(A3)
  1697. 2$           BRA.W      Check
  1698.  
  1699. CheckDone:     MOVEM.L      (SP)+,D2-D7/A2-A3/A5-A6
  1700.            RTS
  1701.  
  1702. **********************************************************
  1703. * Select() - Do selection                                *
  1704. **********************************************************
  1705. @SelectItem:   MOVEM.L     D2-D3/A2-A3/A5,-(SP)
  1706. ********************
  1707. * Check subwindow. *
  1708. ********************
  1709. * ------------ SubWindow.BitMapOk == TRUE ?
  1710.            MOVEA.L     A4,A2           * _SubWindow
  1711.            TST.W     (A2)
  1712.            BEQ.B     CheckItem     * No
  1713.  
  1714. * ------------ NewSubItem = FindMouseItem(&SubWindow)
  1715.            MOVEA.L     A2,A0
  1716.            JSR     @FindMouseItem(PC)
  1717.            MOVEA.L     D0,A3
  1718.  
  1719. ********************
  1720. * A2 = SubWindow   *
  1721. * A3 = NewSubItem  *
  1722. ********************
  1723. * ------------ NewSubItem == CurrentSubItem ?
  1724.            MOVEA.L     _CurrentSubItem(A4),A0
  1725.            CMPA.L     A0,A3
  1726.            BEQ.B     4$           * Yes
  1727.  
  1728. ***********************
  1729. * A0 = CurrentSubItem *
  1730. * A2 = SubWindow      *
  1731. * A3 = NewSubItem     *
  1732. ***********************
  1733.  
  1734. * ------------ CurrentSubItem == NULL ?
  1735.            MOVE.L     A0,D0
  1736.            BEQ.B     1$           * Yes
  1737.  
  1738. * ------------ HighLightItem(CurrentSubItem,&SubWindow,HIGHLIGHTOFF)
  1739.            MOVEQ.L     #1,D0
  1740.            MOVEA.L     A2,A1
  1741.            JSR     @HighLightItem(PC)
  1742.            BRA.B     2$
  1743.  
  1744. * ------------ TempItem == NULL ?
  1745. 1$           MOVE.L     _TempItem(A4),D2
  1746.            BEQ.B     2$           * Yes
  1747.  
  1748. * ------------ CurrentItem = TempItem.
  1749.            MOVE.L     D2,_CurrentItem(A4)
  1750.  
  1751. * ------------ TempItem = NULL.
  1752.            CLR.L     _TempItem(A4)
  1753.  
  1754. * ------------ HighLightCurrItemBehind(HIGHLIGHTON)
  1755.            MOVEQ.L     #0,D0
  1756.            JSR     @HighLightCurrItemBehind(PC)
  1757.  
  1758. * ------------ CurrentSubItem = NewSubItem.
  1759. 2$           MOVE.L     A3,_CurrentSubItem(A4)
  1760.  
  1761. * ------------ CurrentSubItem == NULL ?
  1762.            BEQ.B     3$           * Yes
  1763.  
  1764. * ------------ HighLightItem(NewSubItem,&SubWindow,HIGHLIGHTON)
  1765.            MOVEQ.L     #0,D0
  1766.            MOVEA.L     A3,A0
  1767.            MOVEA.L     A2,A1
  1768.            JSR     @HighLightItem(PC)
  1769.            BRA.B     4$
  1770.  
  1771. * ------------ HighLightCurrItemBehind(HIGHLIGHTOFF)
  1772. 3$           MOVEQ.L     #1,D0
  1773.            JSR     @HighLightCurrItemBehind(PC)
  1774.  
  1775. * ------------ TempItem = CurrentItem.
  1776.            MOVE.L     _CurrentItem(A4),_TempItem(A4)
  1777.  
  1778. * ------------ CurrentItem = NULL.
  1779.            CLR.L     _CurrentItem(A4)
  1780.  
  1781. * ------------ Mouse in SubWindow ?
  1782. 4$           MOVEA.L     A2,A0
  1783.            JSR     @MouseInWindow(PC)
  1784.            TST.W     D0
  1785.            BNE.W     SelectDone    * Yes
  1786.  
  1787. *********************
  1788. * Check itemwindow. *
  1789. *********************
  1790. * ------------ ItemWindow.BitMapOk == TRUE ?
  1791. CheckItem:     LEA     _ItemWindow(A4),A3
  1792.            TST.W     (A3)
  1793.            BEQ.W     CheckMenu     * No
  1794.  
  1795. * ------------ Mouse in ItemWindow ?
  1796.            MOVEA.L     A3,A0
  1797.            JSR     @MouseInWindow(PC)
  1798.            TST.W     D0
  1799.            BEQ.B     3$           * No
  1800.  
  1801. * ------------ NewItem = FindMouseItem(&ItemWindow).
  1802.            MOVEA.L     A3,A0
  1803.            JSR     @FindMouseItem(PC)
  1804.            MOVEA.L     D0,A5
  1805.  
  1806.            MOVE.L     _CurrentItem(A4),D2
  1807.  
  1808. ***************************************
  1809. * A2 = SubWindow     D2 = CurrentItem *
  1810. * A3 = ItemWindow              *
  1811. * A5 = NewItem                  *
  1812. ***************************************
  1813.  
  1814. * ------------ NewItem != CurrentItem
  1815.            CMPA.L      _CurrentItem(A4),A5
  1816.            BEQ.W     SelectDone    * No
  1817.  
  1818. * ------------ SubWindow open ?
  1819.            TST.W     (A2)
  1820.            BEQ.B     1$           * No
  1821.  
  1822. * ------------ Close it.
  1823.            MOVEA.L     A2,A0
  1824.            JSR     @CloseItemWindow(PC)
  1825.  
  1826. * ------------ TempItem = NULL.
  1827.            CLR.L     _TempItem(A4)
  1828.  
  1829. * ------------ CurrentItem != NULL ?
  1830. 1$           TST.L     D2
  1831.            BEQ.B     2$           * No
  1832.  
  1833. * ------------ HighLightItem(CurrentItem,&ItemWindow,HIGHLIGHTOFF)
  1834.            MOVEQ.L     #1,D0
  1835.            MOVE.L     D2,A0
  1836.            MOVEA.L     A3,A1
  1837.            JSR     @HighLightItem(PC)
  1838.  
  1839. * ------------ CurrentItem = NewItem.
  1840. 2$           MOVE.L     A5,_CurrentItem(A4)
  1841.            MOVE.L     A5,D2
  1842.  
  1843. * ------------ NewItem != NULL ?
  1844.            BEQ.W     SelectDone    * Yes
  1845.  
  1846. * ------------ HighLightItem(NewItem,&ItemWindow,HIGHLIGHTON)
  1847.            MOVEQ     #0,D0
  1848.            MOVEA.L     A5,A0
  1849.            MOVEA.L     A3,A1
  1850.            JSR     @HighLightItem(PC)
  1851.  
  1852. * ------------ SubWindow.ItemsEnabled = ItemWindow.ItemsEnabled ?
  1853. * ------------    (NewItem->Flags & ITEMENABLED) : 0
  1854.            MOVE.W     _ItemWindow+wwd_ItemsEnabled(A4),D0
  1855.            BEQ.B     25$
  1856.            MOVEQ.L     #ITEMENABLED,D0
  1857.            AND.W     mi_Flags(A5),D0
  1858. 25$           MOVE.W     D0,_SubWindow+wwd_ItemsEnabled(A4)
  1859.  
  1860. * ------------ SubWindow.Items = NewItem->SubItem.
  1861.            MOVE.L     mi_SubItem(A5),_SubWindow+wwd_Items(A4)
  1862.  
  1863. * ------------ SubItem.Window != NULL ?
  1864.            BEQ.W     SelectDone    * No
  1865.  
  1866. * ------------ Open item window
  1867.            MOVE.L     D2,A0
  1868.            MOVE.W     mi_TopEdge(A0),D0
  1869.            SUB.W     _ItemWindow+wwd_TopValue(A4),D0
  1870.            MOVE.W     #$7FFF,D1
  1871.            MOVEA.L     A2,A0
  1872.            MOVEA.L     A3,A1
  1873.            JSR     @OpenItemWindow(PC)
  1874.            BRA.W     SelectDone
  1875.  
  1876. * ------------ CurrentItem != NULL ?
  1877. 3$           TST.L     _CurrentItem(A4)
  1878.            BEQ.B     CheckMenu
  1879.  
  1880. * ------------ SubWindow open ?
  1881.            TST.W     (A2)
  1882.            BEQ.B     4$           * No
  1883.  
  1884. * ------------ HighLightCurrItemBehind(HIGHLIGHTOFF)
  1885.            MOVEQ.L     #1,D0
  1886.            JSR     @HighLightCurrItemBehind(PC)
  1887.  
  1888. * ------------ TempItem = CurrentItem.
  1889.            MOVE.L     _CurrentItem(A4),_TempItem(A4)
  1890.            BRA.B     5$
  1891.  
  1892. * ------------ HighLightItem(CurrentItem,&ItemWindow,HIGHLIGHTOFF)
  1893. 4$           MOVEQ.L     #1,D0
  1894.            MOVEA.L     _CurrentItem(A4),A0
  1895.            MOVEA.L     A3,A1
  1896.            JSR     @HighLightItem(PC)
  1897.  
  1898. * ------------ CurrentItem = NULL.
  1899. 5$           CLR.L     _CurrentItem(A4)
  1900.  
  1901. *********************
  1902. * Check menuwindow. *
  1903. *********************
  1904.  
  1905. **********************
  1906. * A2 = SubWindow     *
  1907. * A3 = ItemWindow    *
  1908. **********************
  1909. * ------------ MouseInWindow(MenuWindow) ?
  1910. CheckMenu:     LEA     _MenuWindow(A4),A5
  1911.            MOVEA.L     A5,A0
  1912.            JSR     @MouseInWindow(PC)
  1913.            TST.W     D0
  1914.            BEQ.W     SelectDone    * No
  1915.  
  1916. * ------------ NewMenuNr = (MouseY - MenuWindow.TopEdge - BORDERSIZE)/MenuFontSize + 1
  1917.            MOVE.W     _MouseY(A4),D2
  1918.            SUB.W     wwd_TopEdge(A5),D2
  1919.            SUBQ.W     #2,D2
  1920.            ANDI.L     #$0000FFFF,D2
  1921.            DIVU.W     _MenuFontSize(A4),D2
  1922.            ADDQ.W     #1,D2
  1923.  
  1924. * ------------ NewMenuNr == CurrentMenuNr ?
  1925.            MOVE.W     _CurrentMenuNr(A4),D3
  1926.            CMP.W     D3,D2
  1927.            BEQ.B     SelectDone    * Yes
  1928.  
  1929. ****************************************
  1930. * A2 = SubWindow    D2 = NewMenuNr     *
  1931. * A3 = ItemWindow   D3 = CurrentMenuNr *
  1932. * A5 = MenuWindow               *
  1933. ****************************************
  1934.  
  1935. * ------------ CurrentMenuNr == 0 ?
  1936.            TST.W     D3
  1937.            BEQ.B     2$           * Yes
  1938.  
  1939. * ------------ ItemWindow.BitMapOk
  1940.            TST.W     (A3)
  1941.            BEQ.B     1$           * No
  1942.  
  1943. * ------------ CloseItemWindow(SubWindow)
  1944.            MOVEA.L     A2,A0
  1945.            JSR     @CloseItemWindow(PC)
  1946.  
  1947. * ------------ CloseItemWindow(&ItemWindow);
  1948.            MOVEA.L     A3,A0
  1949.            JSR     @CloseItemWindow(PC)
  1950.  
  1951. * ------------ TempItem = NULL
  1952.            CLR.L     _TempItem(A4)
  1953.  
  1954. * ------------ ToggleMenu(CurrentMenuNr,CurrentMenuPtr) - HIGHLIGHTOFF -
  1955. 1$           MOVE.W     D3,D0
  1956.            MOVEA.L     _CurrentMenuPtr(A4),A0
  1957.            JSR     @ToggleMenu(PC)
  1958.  
  1959. * ------------ CurrentMenuPtr = FindMenuPtr(NewMenuNr)
  1960. 2$           MOVE.W     D2,D0
  1961.            JSR     @FindMenuPtr(PC)
  1962.            MOVE.L     D0,_CurrentMenuPtr(A4)
  1963.  
  1964. * ------------ CurrentMenuPtr == NULL ?
  1965.            TST.L     D0
  1966.            BNE.B     3$           * No
  1967.  
  1968. * ------------ CurrentMenuNr = 0
  1969.            CLR.W     _CurrentMenuNr(A4)
  1970.            BRA.B     SelectDone
  1971.  
  1972. * ------------ CurrentMenuNr = NewMenuNr
  1973. 3$           MOVE.W     D2,_CurrentMenuNr(A4)
  1974.            MOVE.W     D2,_LastSelectedNum(A4)
  1975.            MOVE.W     D2,D3
  1976.  
  1977. * ------------ ItemWindow.ItemsEnabled = CurrentMenuPtr->Flags & MENUENABLED
  1978.            MOVEA.L     _CurrentMenuPtr(A4),A0
  1979.            MOVEQ.L     #MENUENABLED,D0
  1980.            AND.W     mu_Flags(A0),D0
  1981.            MOVE.W     D0,_ItemWindow+wwd_ItemsEnabled(A4)
  1982.  
  1983. * ------------ ItemWindow.Items = CurrentMenuPtr->FirstItem
  1984.            MOVE.L     mu_FirstItem(A0),_ItemWindow+wwd_Items(A4)
  1985.  
  1986. * ------------ ToggleMenu(NewMenuNr,CurrentMenuPtr)  - HIGHLIGHTON -
  1987.            MOVE.W     D2,D0
  1988.            JSR     @ToggleMenu(PC)
  1989.  
  1990. * ------------ ItemWindow->Items == NULL ?
  1991.            TST.L     _ItemWindow+wwd_Items(A4)
  1992.            BEQ.B     SelectDone    * Yes
  1993.  
  1994. * ------------ ItemsTopPos = (CurrentMenuNr - 1) * MenuFontSize + MenuWindow.TopEdge
  1995.            MOVE.W     D3,D0
  1996.            SUBQ.W     #1,D0
  1997.            MULU.W     _MenuFontSize(A4),D0
  1998.            ADD.W     _MenuWindow+wwd_TopEdge(A4),D0
  1999.  
  2000. * ------------ OpenItemWindow(ItemWindow,MenuWindow,ItemsTopPos,ITEMWINDOW)
  2001.            MOVEA.L     A3,A0
  2002.            MOVEA.L     A5,A1
  2003.            MOVEQ.L     #0,D1
  2004.            JSR     @OpenItemWindow(PC)
  2005.  
  2006. SelectDone:    MOVEM.L     (SP)+,D2-D3/A2-A3/A5
  2007.            RTS
  2008.  
  2009. *****************************************************************
  2010. * FinalSelect() - Do checkmarking and calculate Menupick value. *
  2011. *                                *
  2012. * Input:                            *
  2013. *   none                            *
  2014. * Output:                            *
  2015. *   return  - MenuPick-value or MENUNULL.            *
  2016. *****************************************************************
  2017. @FinalSelect:  MOVEM.L     D6-D7/A2-A3,-(SP)
  2018.  
  2019. * ------------ SubItemNr = NOSUB
  2020.            MOVEQ     #$1F,D7
  2021.  
  2022.            MOVEA.L     _CurrentSubItem(A4),A2
  2023.            MOVEA.L     _CurrentItem(A4),A3
  2024.  
  2025. * ------------ CurrentSubItem == NULL ?
  2026.            MOVE.L     A2,D0
  2027.            BEQ.B     1$           * Yes
  2028.  
  2029. * ------------ CurrentSubItem->Flags & SubWindow.ItemsEnabled & ITEMENABLED
  2030.            MOVEQ.L     #ITEMENABLED,D0
  2031.            AND.W     mi_Flags(A2),D0
  2032.            AND.W     _SubWindow+wwd_ItemsEnabled(A4),D0
  2033.            BEQ.B     1$           * No
  2034.  
  2035. * ------------ Subitem selected -> checkmark and draw all subitems again.
  2036. * ------------ CheckMark(CurrentSubItem,SubWindow.Items)
  2037.            MOVEA.L     A2,A0
  2038.            MOVEA.L     _SubWindow+wwd_Items(A4),A1
  2039.            JSR     @CheckMark(PC)
  2040.  
  2041. * ------------ DrawAllItems(&SubWindow)
  2042.            MOVEA.L     A4,A0           * _SubWindow
  2043.            JSR     @DrawAllItems(PC)
  2044.  
  2045. * ------------ HighLightItem(CurrentSubItem,&SubWindow,HIGHLIGHTON)
  2046.            MOVEQ.L     #0,D0
  2047.            MOVEA.L     A2,A0
  2048.            MOVEA.L     A4,A1           * _SubWindow
  2049.            JSR     @HighLightItem(PC)
  2050.  
  2051. * ------------ CurrentSubItem->NextSelect = MENUNULL
  2052.            MOVE.W     #$FFFF,mi_NextSelect(A2)
  2053.  
  2054. * ------------ Find the number of the selected subitem
  2055.            MOVEA.L     A2,A0
  2056.            MOVEA.L     _SubWindow+wwd_Items(A4),A1
  2057.            JSR     @FindItemNr(PC)
  2058.            MOVE.L     D0,D7
  2059.  
  2060. * ------------ Remove the subitem-window so we can checkmark the items
  2061.            MOVEA.L     A4,A0           * _SubWindow
  2062.            JSR     @SwapBits(PC)
  2063.            BRA.B     3$
  2064.  
  2065. * ------------ CurrentItem == NULL ?
  2066. 1$           MOVE.L     A3,D0
  2067.            BEQ.B     2$
  2068.  
  2069. * ------------ CurrentItem->Flags & ITEMENABLED ?
  2070.            MOVEQ.L     #ITEMENABLED,D0
  2071.            AND.W     mi_Flags(A3),D0
  2072.            BEQ.B     2$           * No
  2073.  
  2074. * ------------ ItemWindow.ItemsEnabled & MENUENABLED ?
  2075.            TST.W     _ItemWindow+wwd_ItemsEnabled(A4)
  2076.            BEQ.B     2$           * No
  2077.  
  2078. * ------------ CurrentItem->SubItem == NULL ?
  2079.            TST.L     mi_SubItem(A3)
  2080.            BNE.B     2$           * No
  2081.  
  2082. * ------------ CurrentItem->NextSelect = MENUNULL
  2083.            MOVE.W     #$FFFF,mi_NextSelect(A3)
  2084.            BRA.B     3$
  2085.  
  2086. * ------------ Nothing is selected -> exit
  2087. 2$           MOVEQ.L     #-1,D0
  2088.            BRA.B     6$
  2089.  
  2090. * ------------ CheckMark(CurrentItem,ItemWindow.Items)
  2091. 3$           MOVEA.L     A3,A0
  2092.            MOVEA.L     _ItemWindow+wwd_Items(A4),A1
  2093.            BSR.B     @CheckMark
  2094.  
  2095. * ------------ Find number of selected item,
  2096.            MOVEA.L     A3,A0
  2097.            MOVEA.L     _ItemWindow+wwd_Items(A4),A1
  2098.            JSR     @FindItemNr(PC)
  2099.            MOVE.L     D0,D6
  2100.  
  2101. * ------------ DrawAllItems(&ItemWindow)
  2102.            LEA     _ItemWindow(A4),A0
  2103.            JSR     @DrawAllItems(PC)
  2104.  
  2105. * ------------ HighLightItem(CurrentItem,&ItemWindow,HIGHLIGHTON)
  2106.            MOVEQ.L     #0,D0
  2107.            MOVEA.L     A3,A0
  2108.            LEA     _ItemWindow(A4),A1
  2109.            JSR     @HighLightItem(PC)
  2110.  
  2111. * ------------ Restore subwindow.
  2112.            MOVEA.L     A4,A0           * _SubWindow
  2113.            JSR     @SwapBits(PC)
  2114.  
  2115. * ------------ MenuNum = SHIFTMENU(FindRealMenuNum(CurrentMenuNr)) |
  2116. * ------------         SHIFTITEM(ItemNr) |
  2117. * ------------         SHIFTSUB(SubItemNr)
  2118.            MOVE.W     _CurrentMenuNr(A4),D0
  2119.  
  2120.            JSR     @FindMenuPtr(PC)
  2121.            MOVEA.L     D0,A1
  2122.            MOVEA.L     _Menues(A4),A0
  2123.  
  2124.            MOVEQ.L     #0,D0
  2125.  
  2126. 4$           CMPA.L     A0,A1
  2127.            BEQ.B     5$
  2128.  
  2129.            MOVEA.L     (A0),A0        * mu_NextMenu(A0)
  2130.            ADDQ.L     #1,D0
  2131.            BRA.B     4$
  2132.  
  2133. * ------------ SHIFTITEM(ItemNr)
  2134. 5$           ANDI.W     #$3F,D6
  2135.            ASL.W     #5,D6
  2136.            OR.W     D6,D0
  2137.  
  2138. * ------------ SHIFTSUB(SubItemNr)
  2139.            ANDI.W     #$1F,D7
  2140.            ASL.W     #8,D7
  2141.            ASL.W     #3,D7
  2142.            OR.W     D7,D0
  2143.  
  2144. 6$           MOVEM.L     (SP)+,D6-D7/A2-A3
  2145.            RTS
  2146.  
  2147. ********************************************************
  2148. * CheckMark(Selected,Items) - Checkmark selected item. *
  2149. *                               *
  2150. * Input:                           *
  2151. *   Selected - The selected item.               *
  2152. *   Items    - All items on the same level.           *
  2153. * Output:                           *
  2154. *   none                           *
  2155. ********************************************************
  2156. @CheckMark:    MOVE.W     mi_Flags(A0),D1
  2157.  
  2158. * ------------ Selected->Flags & CHECKIT ?
  2159.            MOVEQ.L     #CHECKIT,D0
  2160.            AND.W     D1,D0
  2161.            BEQ.B     4$           * No
  2162.  
  2163. * ------------ Selected->Flags & CHECKED ?
  2164.            MOVE.W     #CHECKED,D0
  2165.            AND.W     D1,D0
  2166.            BEQ.B     1$           * No
  2167.  
  2168. * ------------ Selected->Flags & MENUTOGGLE ?
  2169.            MOVEQ.L     #MENUTOGGLE,D0
  2170.            AND.W     D1,D0
  2171.            BEQ.B     4$           * No
  2172.  
  2173. * ------------ Selected->Flags &= ~CHECKED   - Togglemenu -
  2174.            BCLR     #0,mi_Flags(A0)
  2175.            BRA.B     4$
  2176.  
  2177. * ------------ Selected->Flags |= CHECKED
  2178. 1$           BSET     #0,mi_Flags(A0)
  2179.  
  2180. * ------------ Handle mutual exclusion.
  2181. * ------------ Exclude = Selected->MutualExclude
  2182.            MOVE.L     mi_MutualExclude(A0),D1
  2183.            BEQ.B     4$
  2184.  
  2185. * ------------ Exclude >>= 1
  2186. 2$           LSR.L     #1,D1
  2187.            BCC.B     3$
  2188.  
  2189. * ------------ Items->Flags &= ~CHECKED
  2190.            BCLR     #0,mi_Flags(A1)
  2191.  
  2192. * ------------ Items = Items->NextItem
  2193. 3$           MOVEA.L     (A1),A1
  2194.  
  2195. * ------------ More items ?
  2196.            MOVE.L     A1,D0
  2197.            BNE.B     2$           * Yes
  2198.  
  2199. 4$           RTS
  2200.  
  2201. ************************************************************
  2202. * DrawMenuItem(Item, ItemWindow, Mode)                     *
  2203. *                               *
  2204. * Input:                           *
  2205. *   Item -      Item to draw.                *
  2206. *   ItemWindow - Data about window to draw item into.       *
  2207. *   Mode.W -      ITEMFILL = Draw Item.            *
  2208. *          SELECTFILL = Draw selected item (if any).*
  2209. * OUTPUT                           *
  2210. *   none                           *
  2211. ************************************************************
  2212. @DrawMenuItem: MOVEM.L     D2-D7/A2-A3/A5-A6,-(SP)
  2213.            MOVEA.L     A0,A3
  2214.  
  2215.            MOVE.L     A1,-(SP)
  2216. ***************************************
  2217. * D0 = Mode          A0 = Item       *
  2218. *              A1 = ItemWindow *
  2219. *              A3 = Item       *
  2220. ***************************************
  2221.  
  2222. * ------------ Left = Item->LeftEdge - ItemWindow->LeftValue
  2223.            MOVE.W     mi_LeftEdge(A3),D7
  2224.            SUB.W     wwd_LeftValue(A1),D7
  2225.            EXT.L     D7
  2226.  
  2227. * ------------ Right = Left + Item->Width - 1
  2228.            MOVE.L     D7,D2
  2229.            ADD.W     mi_Width(A3),D2
  2230.            SUBQ.L     #1,D2
  2231.  
  2232. * ------------ Top = Item->TopEdge - ItemWindow->TopValue
  2233.            MOVE.W     mi_TopEdge(A3),D6
  2234.            SUB.W     wwd_TopValue(A1),D6
  2235.            EXT.L     D6
  2236.  
  2237. * ------------ Bottom = Top + Item->Height - 1
  2238.            MOVE.L     D6,D3
  2239.            ADD.W     mi_Height(A3),D3
  2240.            SUBQ.L     #1,D3
  2241.  
  2242.            LEA     _Rp(A4),A5
  2243.            MOVEA.L     _IntuitionBase(A4),A6
  2244.  
  2245. * ------------ Find what to Draw.
  2246.            MOVEA.L     mi_ItemFill(A3),A2
  2247.  
  2248.            TST.W     D0          * Mode == ITEMFILL ?
  2249.            BEQ.B     CheckDraw
  2250.  
  2251. * ------------ Use selectfill.
  2252.            MOVEA.L     mi_SelectFill(A3),A2
  2253.  
  2254. *************************************************
  2255. * D0 = Mode             A0 = Item        *
  2256. * D2 = Right             A2 = Fill        *
  2257. * D3 = Bottom             A3 = Item        *
  2258. * D6 = Top             A5 = Rp        *
  2259. * D7 = Left             A6 = IntuitionBase *
  2260. *************************************************
  2261.  
  2262. * ------------ Anything to draw ?
  2263. CheckDraw:     MOVE.L     A2,D0
  2264.            BEQ.W     DrawDone
  2265.  
  2266. * ------------ Draw the item.
  2267. DrawItem:      MOVE.L     D6,D4
  2268.  
  2269.            MOVEA.L     A5,A0           * Rp
  2270.            MOVEA.L     A2,A1           * Fill
  2271.            MOVE.L     D7,D0           * Left
  2272.            MOVE.L     D6,D1           * Top
  2273.  
  2274.            MOVEQ.L     #ITEMTEXT,D5
  2275.            AND.W     mi_Flags(A3),D5
  2276.            BEQ.B     DrawImage
  2277.  
  2278. * ------------ PrintIText(Fill, Left, Top)
  2279.            JSR     _LVOPrintIText(A6)
  2280.  
  2281.            ADD.W     it_TopEdge(A2),D4
  2282.            BRA.B     DrawCheckMark
  2283.  
  2284. * ------------ DrawImage(Fill, Left, Top)
  2285. DrawImage:     JSR     _LVODrawImage(A6)
  2286.  
  2287.            ADD.W     ig_TopEdge(A2),D4
  2288.  
  2289. *********************************************
  2290. * D2 = Right         A2 = Fill        *
  2291. * D3 = Bottom         A3 = Item        *
  2292. * D4 = ItemTop         A5 = Rp        *
  2293. * D6 = Top         A6 = IntuitionBase *
  2294. * D7 = Left                    *
  2295. *********************************************
  2296. * ------------ Draw CheckMark ?
  2297. DrawCheckMark: MOVE.W     #CHECKIT+CHECKED,D0
  2298.            AND.W     mi_Flags(A3),D0
  2299.            CMPI.W     #CHECKIT+CHECKED,D0
  2300.            BNE.B     DrawCommKey
  2301.  
  2302. * ------------ DrawImage(ActiveWindow->CheckMark, Left, Top)
  2303.            MOVEA.L     _ActiveWindow(A4),A0
  2304.            MOVEA.L     wd_CheckMark(A0),A1   * CheckMark
  2305.            MOVE.L     D7,D0               * Left
  2306.            MOVE.L     D6,D1               * Top
  2307.            MOVEA.L     A5,A0               * Rp
  2308.            JSR     _LVODrawImage(A6)
  2309.  
  2310. *********************************************
  2311. * D2 = Right         A2 = Fill        *
  2312. * D3 = Bottom         A3 = Item        *
  2313. * D4 = ItemTop         A5 = Rp        *
  2314. * D6 = Top         A6 = IntuitionBase *
  2315. * D7 = Left                    *
  2316. *********************************************
  2317.  
  2318. * ------------ SetDrMd(JAM1)
  2319. DrawCommKey:   MOVEA.L     _GfxBase(A4),A6
  2320.            MOVEA.L     A5,A1               * Rp
  2321.            MOVEQ.L     #RP_JAM1,D0           * JAM1
  2322.            JSR     _LVOSetDrMd(A6)
  2323.  
  2324. * ------------ Has item CommadKey ?
  2325.            MOVEQ.L     #COMMSEQ,D0
  2326.            AND.W     mi_Flags(A3),D0
  2327.            BEQ.B     GhostItem
  2328.  
  2329. * ------------ KeyLeft = Right - Rp.TxWidth
  2330.            MOVE.L     D2,D5
  2331.            SUB.W     _Rp+rp_TxWidth(A4),D5
  2332.  
  2333. *******************************************
  2334. * D2 = Right             A2 = Fill      *
  2335. * D3 = Bottom             A3 = Item      *
  2336. * D4 = ItemTop             A5 = Rp      *
  2337. * D5 = KeyLeft             A6 = GfxBase *
  2338. * D6 = Top                  *
  2339. * D7 = Left                  *
  2340. *******************************************
  2341. * ------------ Move(KeyLeft, ItemTop + Rp.TxHeight - 2);
  2342.            MOVE.L     D5,D0
  2343.            MOVE.L     D4,D1
  2344.            ADD.W     _Rp+rp_TxHeight(A4),D1
  2345.            SUBQ.L     #2,D1
  2346.            MOVEA.L     A5,A1
  2347.            JSR     _LVOMove(A6)
  2348.  
  2349. * ------------ SetAPen(ActiveWindow->DetailPen)
  2350.            MOVEQ     #00,D0
  2351.            MOVEA.L     _ActiveWindow(A4),A0
  2352.            MOVE.B     wd_DetailPen(A0),D0
  2353.            MOVEA.L     A5,A1
  2354.            JSR     _LVOSetAPen(A6)
  2355.  
  2356. * ------------ Text(&Item->Command,1);
  2357.            LEA     mi_Command(A3),A0
  2358.            MOVEA.L     A5,A1
  2359.            MOVEQ     #1,D0
  2360.            JSR     _LVOText(A6)
  2361.  
  2362. * ------------ DrawImage(&MyAmigaKeyImage[ScreenType],KeyLeft, ItemTop);
  2363.            LEA     _MyAmigaKeyImage(PC),A1
  2364.            MOVE.L     D5,D0
  2365.            BSR.B     DrawMyImage
  2366.  
  2367.            MOVEA.L     _GfxBase(A4),A6
  2368.  
  2369. *******************************************
  2370. * D2 = Right             A2 = Fill      *
  2371. * D3 = Bottom             A3 = Item      *
  2372. * D4 = ItemTop             A5 = Rp      *
  2373. * D6 = Top             A6 = GfxBase *
  2374. * D7 = Left                  *
  2375. *******************************************
  2376. * ------------ Ghost Item ?
  2377. GhostItem:     MOVEQ.L     #ITEMENABLED,D0
  2378.            AND.W     mi_Flags(A3),D0
  2379.            BEQ.B     1$
  2380.  
  2381.            MOVEA.L     (SP),A2
  2382.            TST.W     wwd_ItemsEnabled(A2)
  2383.            BNE.B     SubItem
  2384.  
  2385. * ------------ SetAfPt(&Rp, GhostPattern, 1)
  2386. 1$           LEA     _GhostPattern(PC),A0
  2387.            MOVE.L     A0,_Rp+rp_AreaPtrn(A4)
  2388.  
  2389.            MOVE.B     #01,_Rp+rp_AreaPtSz(A4)
  2390.  
  2391. * ------------ SetAPen(ActiveWindow->BlockPen)
  2392.            MOVEQ     #0,D0
  2393.            MOVEA.L     _ActiveWindow(A4),A0
  2394.            MOVE.B     wd_BlockPen(A0),D0
  2395.            MOVEA.L     A5,A1
  2396.            JSR     _LVOSetAPen(A6)
  2397.  
  2398. * ------------ RectFill(Left, Top, Right, Bottom)
  2399.            MOVEA.L     A5,A1
  2400.            MOVE.L     D7,D0
  2401.            MOVE.L     D6,D1
  2402.            JSR     _LVORectFill(A6)
  2403.  
  2404. * ------------ SetAfPt(NormalPattern, 1)
  2405.            LEA     _NormalPattern(PC),A0
  2406.            MOVE.L     A0,_Rp+rp_AreaPtrn(A4)
  2407.  
  2408. *******************************************
  2409. * D2 = Right                  *
  2410. * D3 = Bottom             A3 = Item      *
  2411. * D4 = ItemTop             A5 = Rp      *
  2412. * D6 = Top             A6 = GfxBase *
  2413. * D7 = Left                  *
  2414. *******************************************
  2415.  
  2416. * ------------ SubItem ?
  2417. SubItem:       TST.L     mi_SubItem(A3)
  2418.            BEQ.B     DrawDone
  2419.  
  2420. * ------------ DrawImage(&MySubItemImage[ScreenType],Right,ItemTop);
  2421.            LEA     _MySubItemImage(PC),A1
  2422.            MOVE.L     D2,D0
  2423.            BSR.B     DrawMyImage
  2424.  
  2425. DrawDone:      ADDQ.L     #4,A7
  2426.  
  2427.            MOVEM.L     (SP)+,D2-D7/A2-A3/A5-A6
  2428.            RTS
  2429.  
  2430. ******************************
  2431. * DrawMyImage             *
  2432. * A1 - What to draw         *
  2433. * A5 - Rp             *
  2434. * D0 - Left             *
  2435. * D4 - Top             *
  2436. *                 *
  2437. * Destroyed: D0-D1/A0-A1/A6  *
  2438. ******************************
  2439. DrawMyImage:   TST.W     _ScreenType(A4)
  2440.            BEQ.B     1$
  2441.            MOVEQ.L     #ig_SIZEOF,D1
  2442.            ADDA.L     D1,A1
  2443.  
  2444. 1$           MOVEA.L     A5,A0
  2445.            MOVE.L     D4,D1
  2446.            MOVEA.L     _IntuitionBase(A4),A6
  2447.            JMP     _LVODrawImage(A6)
  2448.  
  2449. ***************************************************
  2450. * HighLightItem(Item, ItemWindow, Mode)           *
  2451. *                          *
  2452. * Input:                      *
  2453. *   Item  -      Item to highlight.          *
  2454. *   ItemWindow -  Data for the window to draw in. *
  2455. *   Mode.W -      HIGHLIGHTON or HIGHLIGHTOFF.      *
  2456. * Output:                      *
  2457. *   none                      *
  2458. ***************************************************
  2459. @HighLightItem:
  2460.            MOVEM.L     D2-D7/A2-A3/A5-A6,-(SP)
  2461.            MOVEA.L     A0,A3
  2462.            MOVEA.L     A1,A2
  2463.  
  2464. * ------------ Possible to highlight item ?
  2465.            MOVEQ.L     #ITEMENABLED,D1
  2466.            AND.W     mi_Flags(A3),D1
  2467.            BEQ.B     HighlightDone
  2468.  
  2469.            TST.W     wwd_ItemsEnabled(A2)
  2470.            BEQ.B     HighlightDone
  2471.  
  2472. * ------------ Start highlighting.
  2473.            LEA     _Rp(A4),A5
  2474.            MOVEA.L     _GfxBase(A4),A6
  2475.  
  2476.            MOVE.W     #HIGHFLAGS,D7
  2477.            AND.W     mi_Flags(A3),D7
  2478.            BNE.B     NotHighImage
  2479.  
  2480. * ------------ Invert Mode and call DrawMenuItem.
  2481. * ------------ DrawMenuItem(Item, ItemWindow, !Mode);
  2482. HighImage:     MOVEQ.L     #1,D1
  2483.            ADDQ.W     #1,D0
  2484.            AND.W     D1,D0
  2485.            JSR     @DrawMenuItem(PC)
  2486.            BRA.B     HighlightDone
  2487.  
  2488. * ------------ Left   = Item->LeftEdge - ItemWindow->LeftValue
  2489. NotHighImage:  MOVE.W     mi_LeftEdge(A3),D6
  2490.            SUB.W     wwd_LeftValue(A2),D6
  2491.            EXT.L     D6
  2492.  
  2493. * ------------ Right  = Left + Item->Width
  2494.            MOVE.W     mi_Width(A3),D5
  2495.            EXT.L     D5
  2496.            ADD.L     D6,D5
  2497.  
  2498. * ------------ Top    = Item->TopEdge - ItemWindow->TopValue
  2499.            MOVE.W     mi_TopEdge(A3),D4
  2500.            SUB.W     wwd_TopValue(A2),D4
  2501.            EXT.L     D4
  2502.  
  2503. * ------------ Bottom = Top + Item->Height
  2504.            MOVE.W     mi_Height(A3),D3
  2505.            EXT.L     D3
  2506.            ADD.L     D4,D3
  2507.  
  2508. * ------------ Set drawmode = COMPLEMENT.
  2509.            MOVEQ.L     #RP_COMPLEMENT,D0
  2510.            MOVEA.L     A5,A1
  2511.            JSR     _LVOSetDrMd(A6)
  2512.  
  2513. * ------------ Check out kind of highlighting.
  2514.            CMPI.W     #HIGHBOX,D7
  2515.            BEQ.B     HighBox
  2516.            CMPI.W     #HIGHCOMP,D7
  2517.            BNE.B     HighlightDone
  2518.  
  2519. * ------------ RectFill(Left, Top, Right - 1, Bottom - 1)
  2520. HighComp:      MOVE.L     D6,D0
  2521.            MOVE.L     D4,D1
  2522.            MOVEA.L     A5,A1
  2523.            MOVE.L     D5,D2
  2524.            SUBQ.L     #1,D2
  2525.            SUBQ.L     #1,D3
  2526.            JSR     _LVORectFill(A6)
  2527.            BRA.B     HighlightDone
  2528.  
  2529. * ------------ DrawRect(Left, Top, Right, Bottom)
  2530. HighBox:       BSR.B     DrawRect
  2531.  
  2532. * ------------ DrawRect(Left - 1, Top - 1, Right + 1, Bottom + 1)
  2533.            ADDQ.L     #1,D5
  2534.            ADDQ.L     #1,D3
  2535.            BSR.B     DrawRect
  2536.  
  2537. HighlightDone: MOVEM.L     (SP)+,D2-D7/A2-A3/A5-A6
  2538.            RTS
  2539.  
  2540. * ------------ Draw a rectangle.
  2541. * ------------ Move(--Left,Top).
  2542. DrawRect:      SUBQ.L     #1,D6
  2543.            MOVE.L     D6,D0
  2544.            MOVE.L     D4,D1
  2545.            MOVEA.L     A5,A1
  2546.            JSR     _LVOMove(A6)
  2547.  
  2548. * ------------ Draw(Left,Bottom).
  2549.            MOVE.L     D6,D0
  2550.            MOVE.L     D3,D1
  2551.            BSR.B     Draw
  2552.  
  2553. * ------------ Draw(Right,Bottom).
  2554.            MOVE.L     D5,D0
  2555.            MOVE.L     D3,D1
  2556.            BSR.B     Draw
  2557.  
  2558. * ------------ Draw(Right,--Top).
  2559.            SUBQ.L     #1,D4
  2560.            MOVE.L     D5,D0
  2561.            MOVE.L     D4,D1
  2562.            BSR.B     Draw
  2563.  
  2564. * ------------ Draw(Left,Top).
  2565.            MOVE.L     D6,D0
  2566.            MOVE.L     D4,D1
  2567.  
  2568. Draw:           MOVEA.L     A5,A1           * Get RastPort
  2569.            JMP     _LVODraw(A6)
  2570.  
  2571. *********************************************
  2572. * ToggleMenu(Number,Menu)                   *
  2573. *                        *
  2574. * Input:                    *
  2575. *   Number.W -    Menu to highlight.        *
  2576. *   Menu   - Pointer to the Menu structure. *
  2577. * Output:                    *
  2578. *   none                    *
  2579. *********************************************
  2580. @ToggleMenu:   MOVEM.L     D2-D3/A6,-(A7)
  2581.  
  2582. * ------------ Menu enabled ?
  2583.            MOVEQ.L     #MENUENABLED,D2
  2584.            AND.W     mu_Flags(A0),D2
  2585.            BEQ.B     ToggleDone
  2586.  
  2587.            MOVE.W     D0,D3
  2588.  
  2589. * ------------ Set drawmode = COMPLEMENT.
  2590.            LEA     _Rp(A4),A1
  2591.            MOVEQ     #RP_COMPLEMENT,D0
  2592.            MOVEA.L     _GfxBase(A4),A6
  2593.            JSR     _LVOSetDrMd(A6)
  2594.  
  2595. * ------------ Invert menu.
  2596. * ------------ Bottom = Number * MenuFontSize + MenuWindow.TopEdge.
  2597.            MOVE.W     _MenuFontSize(A4),D2
  2598.            MULU.W     D2,D3
  2599.            ADD.W     _MenuWindow+wwd_TopEdge(A4),D3
  2600.  
  2601. * ------------ Top = Bottom - MenuFontSize + BORDERSIZE.
  2602.            MOVE.L     D3,D1
  2603.            SUB.L     D2,D1
  2604.            ADDQ.L     #BORDERSIZE,D1
  2605.  
  2606. * ------------ Left = MenuWindow.LeftEdge + BORDERSIZE.
  2607.            MOVEQ.L     #BORDERSIZE,D0
  2608.            ADD.W     _MenuWindow+wwd_LeftEdge(A4),D0
  2609.  
  2610. * ------------ Right = MenuWindow.RightEdge - BORDERSIZE.
  2611.            MOVE.W     _MenuWindow+wwd_RightEdge(A4),D2
  2612.            SUBQ.L     #BORDERSIZE,D2
  2613.  
  2614.            LEA     _Rp(A4),A1
  2615.            JSR     _LVORectFill(A6)
  2616.  
  2617. ToggleDone:    MOVEM.L     (A7)+,D2-D3/A6
  2618.            RTS
  2619.  
  2620. ******************
  2621. * DrawAllMenus() *
  2622. *         *
  2623. ******************
  2624. @DrawAllMenues:
  2625.            MOVEM.L     D2-D4/D7/A2-A3/A5-A6,-(SP)
  2626.  
  2627. * ------------ MenuLeft = MenuWindow.LeftEdge + BORDERSIZE
  2628.            MOVE.W     _MenuWindow+wwd_LeftEdge(A4),D7
  2629.            ADDQ.W     #BORDERSIZE,D7
  2630.            EXT.L     D7
  2631.  
  2632. * ------------ MenuTop = MenuWindow.TopEdge
  2633.            MOVE.W     _MenuWindow+wwd_TopEdge(A4),D3
  2634.            EXT.L     D3
  2635.  
  2636. * ------------ MenuRight = MenuWindow.RightEdge - BORDERSIZE
  2637.            MOVE.W     _MenuWindow+wwd_RightEdge(A4),D2
  2638.            SUBQ.W     #BORDERSIZE,D2
  2639.            EXT.L     D2
  2640.  
  2641. * ------------ MenuPtr = MenuSorted;
  2642.            MOVEA.L     _ActiveWindow(A4),A2
  2643.            MOVEA.L     _MenuSorted(A4),A3
  2644.            LEA     _Rp(A4),A5
  2645.            MOVEA.L     _GfxBase(A4),A6
  2646.  
  2647. ****************************************
  2648. * D2 = MenuRight     A2 = ActiveWindow *
  2649. * D3 = MenuTop         A3 = Menues       *
  2650. * D7 = MenuLeft      A5 = Rp           *
  2651. *             A6 = GfxBase      *
  2652. ****************************************
  2653. * ------------ MenuTopOld = MenuTop;
  2654. NextMenu:      MOVE.L     D3,D4
  2655.  
  2656. * ------------ MenuTop += MenuFontSize;
  2657.            ADD.W     _MenuFontSize(A4),D3
  2658.  
  2659. * ------------ SetAPen(Rp,ActiveWindow->DetailPen)
  2660.            MOVEQ.L     #0,D0
  2661.            MOVE.B     wd_DetailPen(A2),D0
  2662.            MOVEA.L     A5,A1
  2663.            JSR     _LVOSetAPen(A6)
  2664.  
  2665. * ------------ Move(Rp, MenuLeft, MenuTop - 1)
  2666.            MOVE.L     D7,D0
  2667.            MOVE.L     D3,D1
  2668.            SUBQ.L     #1,D1
  2669.            MOVEA.L     A5,A1
  2670.            JSR     _LVOMove(A6)
  2671.  
  2672. * ------------ Text(Rp,MenuSorted->MenuPtr->MenuName,Mystrlen(MenuSorted->MenuPtr->MenuName))
  2673.            MOVE.L     ms_MenuPtr(A3),A0
  2674.            MOVEA.L     mu_MenuName(A0),A0
  2675.            MOVE.L     A0,-(SP)
  2676.            JSR     @Mystrlen(PC)
  2677.            MOVEA.L     A5,A1
  2678.            MOVEA.L     (SP)+,A0
  2679.            JSR     _LVOText(A6)
  2680.  
  2681. * ------------ GhostItem ?
  2682.            MOVEQ.L     #MENUENABLED,D0
  2683.            MOVE.L     ms_MenuPtr(A3),A0
  2684.            AND.W     mu_Flags(A0),D0
  2685.            BNE.B     NoMenuGhost
  2686.  
  2687. * ------------ SetAfPt(Rp, GhostPattern, 1)
  2688.            LEA     _GhostPattern(PC),A0
  2689.            MOVE.L     A0,_Rp+rp_AreaPtrn(A4)
  2690.  
  2691.            MOVE.B     #1,_Rp+rp_AreaPtSz(A4)
  2692.  
  2693. * ------------ SetAPen(Rp,ActiveWindow->BlockPen)
  2694.            MOVE.B     wd_BlockPen(A2),D0
  2695.            MOVEA.L     A5,A1
  2696.            JSR     _LVOSetAPen(A6)
  2697.  
  2698. * ------------ RectFill(Rp,MenuLeft,MenuTopOld + BORDERSIZE,MenuRight,MenuTop)
  2699.            MOVE.L     D7,D0
  2700.  
  2701.            MOVE.L     D4,D1
  2702.            ADDQ.W     #2,D1
  2703.            MOVEA.L     A5,A1
  2704.            JSR     _LVORectFill(A6)
  2705.  
  2706. * ------------ SetAfPt(&Rp,NormalPattern,1);
  2707.            LEA     _NormalPattern(PC),A0
  2708.            MOVE.L     A0,_Rp+rp_AreaPtrn(A4)
  2709.  
  2710. * ------------ MenuSaved = MenuSaved->Next
  2711. NoMenuGhost:   MOVEA.L     (A3),A3        * ms_Next(A3)
  2712.  
  2713. * ------------ More menues ?
  2714.            MOVE.L     A3,D0
  2715.            BNE.B     NextMenu
  2716.  
  2717.            MOVEM.L     (SP)+,D2-D4/D7/A2-A3/A5-A6
  2718.            RTS
  2719.  
  2720. ********************************************
  2721. * MySetMenuStrip, MyClearMenuStrip,       *
  2722. * MyOnMenu, MyOffMenu               *
  2723. *                       *
  2724. * My replacements for intuition functions. *
  2725. ********************************************
  2726. @MySetMenuStrip:
  2727.            MOVE.L      A2,-(SP)
  2728.            MOVEA.L      _OldSetMenuStrip,A2
  2729.            BRA.B      CallOldFunction
  2730.  
  2731. @MyClearMenuStrip:
  2732.            MOVE.L      A2,-(SP)
  2733.            MOVEA.L      _OldClearMenuStrip,A2
  2734.            BRA.B      CallOldFunction
  2735.  
  2736. @MyOnMenu:     MOVE.L      A2,-(SP)
  2737.            MOVEA.L      _OldOnMenu,A2
  2738.            BRA.B      CallOldFunction
  2739.  
  2740. @MyOffMenu:    MOVE.L       A2,-(SP)
  2741.            MOVEA.L      _OldOffMenu,A2
  2742.  
  2743. * ------------ Obtain semaphore and then call the intuition function.
  2744. CallOldFunction:
  2745.            MOVE.L      A6,-(SP)
  2746.            MOVEM.L      D0/A0-A1/A6,-(SP)
  2747.            LEA      _PopUpSemaphore,A0
  2748.            MOVE.L      (AbsExecBase).W,A6
  2749.            JSR      _LVOObtainSemaphore(A6)
  2750.            MOVEM.L      (SP)+,D0/A0-A1/A6
  2751.            JSR      (A2)
  2752.            LEA      _PopUpSemaphore,A0
  2753.            MOVE.L      (AbsExecBase).W,A6
  2754.            JSR      _LVOReleaseSemaphore(A6)
  2755.            MOVE.L      (SP)+,A6
  2756.            MOVE.L      (SP)+,A2
  2757.            RTS
  2758.  
  2759. * ------------ This is the shortest strlen (I think).
  2760. @Mystrlen:     MOVEQ.L      #-1,D0
  2761. 1$:           ADDQ.L      #1,D0
  2762.            TST.B      (A0)+
  2763.            BNE.B      1$
  2764.            RTS
  2765.  
  2766. * Put these images in the code segment
  2767.  
  2768. _MyAmigaKeyImage:
  2769.            dc.w     -25,0,23,8,1
  2770.            dc.l     _AmigaKeyHighRes
  2771.            dc.b     1,0
  2772.            dc.l     0
  2773.            dc.w     -16,0,14,8,1
  2774.            dc.l     _AmigaKeyLoRes
  2775.            dc.b     1,0
  2776.            dc.l     0
  2777. _MySubItemImage:
  2778.            dc.w     2,0,8,7,1
  2779.            dc.l     _SubItemPointerH
  2780.            dc.b     1,0
  2781.            dc.l     0
  2782.            dc.w     1,0,4,7,1
  2783.            dc.l     _SubItemPointerL
  2784.            dc.b     1,0
  2785.            dc.l     0
  2786.  
  2787. _GhostPattern:    dc.w      $1111,$4444
  2788. _NormalPattern: dc.w      $ffff,$ffff
  2789.  
  2790.            section     __MERGED,bss
  2791.            xref     _PopUpSemaphore
  2792.            xref     _Screen
  2793.            xref     _LayersBase
  2794.            xref     _Menues
  2795.            xref     _ActiveWindow
  2796.            xref     _LastWindow
  2797.            xref     _LastSelected
  2798.            xref     _MenuFontSize
  2799.            xref     _TimerSignal
  2800.            xref     _TimerReqBlock
  2801.            xref     _TimerPort
  2802.            xref     _MouseX
  2803.            xref     _MouseY
  2804.            xref     _IntuitionBase
  2805.            xref     _SubWindow
  2806.            xref     _ItemWindow
  2807.            xref     _MenuWindow
  2808.            xref     _CurrentMenuNr
  2809.            xref     _CurrentMenuPtr
  2810.            xref     _CurrentItem
  2811.            xref     _CurrentSubItem
  2812.            xref     _TempItem
  2813.            xref     _ScreenType
  2814.            xref     _Rp
  2815.            xref     _GfxBase
  2816.            xref     _Size
  2817.            xref     _InputReqBlock
  2818.            xref     _OldSetMenuStrip
  2819.            xref     _OldClearMenuStrip
  2820.            xref     _OldOffMenu
  2821.            xref     _OldOnMenu
  2822.            xref     _SortRemember
  2823.            xref     _MenuSorted
  2824.            xref     _LastSelectedNum
  2825.  
  2826.            END
  2827.