home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 607.lha / PopUpMenu_v4.3 / Source.LZH / Source / SelOptions.a < prev   
Text File  |  1992-01-29  |  13KB  |  515 lines

  1.          opt        l+,c+,d+,y+
  2.          opt        ow1+,ow2+,ow3+,ow4+,ow5+,ow6+
  3.  
  4.            INCDIR      ":pspråk/asm/include/"
  5.            INCLUDE      "exec/types.i"
  6.            INCLUDE      "PopUpMenu.i"
  7.  
  8.            xref     @Mystrlen     * In overlay root
  9.  
  10.            xdef     @GetCommandLine
  11.            xdef     @GetWBCommandLine
  12.            xdef     @MyWrite
  13.  
  14.            section     text,code
  15. ***********************************************************
  16. * UWORD  GetCommandLine(OldOptions, CommandLine, Length)  *
  17. *                D3          A5      D2      *
  18. * Input:                          *
  19. *   CommandLine    - Pointer to command line          *
  20. *   Length       - Length of Command line          *
  21. * Output:                          *
  22. *   Selected options                      *
  23. *                              *
  24. ***********************************************************
  25. @GetCommandLine:
  26.            MOVEM.L     D2-D4/A5/A6,-(SP)
  27. ****************************************
  28. * D2 = Length        A5 = Command line  *
  29. * D3.W = Selected               *
  30. ****************************************
  31. Start:           TST.L     D2
  32.            BEQ.W     Done
  33.            MOVEQ.L     #0,D0
  34.  
  35. * ------------ Find first non blank
  36. 1$           MOVE.B     (A5)+,D0
  37.            SUBQ.L     #1,D2
  38.            BEQ.W     Done
  39.            CMP.B     #' ',D0
  40.            BLE.B     1$
  41.  
  42. * ------------ Is it a '-' ?
  43.            CMP.B     #'-',D0
  44.            BNE.B     Help           * No
  45.  
  46. * ------------ Get option
  47.            MOVEQ.L     #' ',D1
  48.            MOVE.B     (A5)+,D0
  49.            SUBQ.L     #1,D2
  50.            BEQ.B     2$
  51.  
  52. * ------------ Is it followed by a '-'
  53.            MOVE.B     (A5)+,D1
  54.            SUBQ.L     #1,D2
  55.  
  56. * ------------ make option lowercase
  57. 2$           OR.B     #$20,D0   * Make small char
  58.  
  59.            SUB.B     #'c',D0
  60.            BNE.B     optH
  61.  
  62. * ------------ Option: ClickMenues
  63.            MOVEQ.L     #CLICKMENUES+8,D0
  64.            BRA.B     SetOption
  65.  
  66. optH:           SUBQ.L     #'h'-'c',D0
  67.            BNE.B     optI
  68.  
  69. * ------------ Output Helptext
  70. Help:           MOVEQ.L     #4,D2
  71.            JSR     @MyWrite
  72.  
  73.            MOVEQ.L     #0,D3
  74.            BRA.W     Done
  75.  
  76. optI:           SUBQ.L     #'i'-'h',D0
  77.            BNE.B     optK
  78.  
  79. * ------------ Option: ITEMCENTERED
  80.            MOVEQ.L     #ITEMSCENTERED+8,D0
  81.            BRA.B     SetOption
  82.  
  83. optK:           SUBQ.L     #'k'-'i',D0
  84.            BNE.B     optN
  85.  
  86. * ------------ Option: HotKey
  87. * ------------ convert first digit
  88.            MOVE.B     D1,D0
  89.            BSR.B     Hex2Bin
  90.            MOVE.B     D0,D4
  91.            BMI.B     Help           * Not hex
  92.            LSL.L     #4,D4
  93.  
  94. * ------------ is there more digits ?
  95.            SUBQ.L     #1,D2
  96.            BMI.B     Help           * No
  97.  
  98.            MOVE.B     (A5)+,D0
  99.            BSR.B     Hex2Bin
  100.            OR.W     D0,D4           * Must be word to set flags
  101.            BMI.B     Help
  102.  
  103. * ------------ Save new HotKey
  104.            MOVE.B     D4,D3
  105.            BRA.B     Start
  106.  
  107. * ------------ Code to convert hex characters
  108. Hex2Bin:       OR.B     #$20,D0
  109.            LEA     HexChars(PC),A0
  110.            MOVEQ.L     #15,D1
  111. 1$           CMP.B     (A0)+,D0
  112.            DBEQ     D1,1$
  113.            MOVE.W     D1,D0
  114.            RTS
  115.  
  116. optN:           SUBQ.L     #'n'-'k',D0
  117.            BNE.B     optO
  118.  
  119. * ------------ Option: POPUPNOQUAL
  120.            MOVEQ.L     #POPUPNOQUAL+8,D0
  121.            BRA.B     SetOption
  122.  
  123. optO:           SUBQ.L     #'o'-'n',D0
  124.            BNE.B     optP
  125.  
  126. * ------------ Option: OPENWINDOW
  127.            MOVEQ.L     #OPENWINDOW+8,D0
  128.            BRA.B     SetOption
  129.  
  130. optP:           SUBQ.L     #'p'-'o',D0
  131.            BNE.B     optQ
  132.  
  133. * ------------ Option: SUBITEMPOINTER
  134.            MOVEQ.L     #SUBITEMPOINTER+8,D0
  135.            BRA.B     SetOption
  136.  
  137. optQ:           SUBQ.L     #'q'-'p',D0
  138.            BNE.B     optS
  139.  
  140. * ------------ Option: POPUPWITHQUAL
  141.            MOVEQ.L     #POPUPWITHQUAL+8,D0
  142.            BRA.B     SetOption
  143.  
  144. optS:           SUBQ.L     #'s'-'q',D0
  145.            BNE.B     optX
  146.  
  147. * ------------ Option: SHOWSINGLEMENU
  148.            MOVEQ.L     #SHOWSINGLEMENU+8,D0
  149.            BRA.B     SetOption
  150.  
  151. optX:           SUBQ.L     #'x'-'s',D0
  152.            BNE.B     Help
  153.  
  154. * ------------ Option: EXIT
  155.            MOVEQ.L     #EXIT+8,D0
  156.  
  157. SetOption:     MOVEQ.L     #1,D4
  158.            ASL.L     D0,D4
  159.            NOT.L     D4
  160.            AND.L     D4,D3
  161.            CMP.B     #' ',D1
  162.            BGT.B     1$
  163.            NOT.L     D4
  164.            OR.L     D4,D3
  165.            BRA.W     Start
  166. 1$           CMP.B     #'-',D1
  167.            BNE.W     Help
  168.            BRA.W     Start
  169.  
  170. Done:           MOVE.W     D3,D0
  171.            MOVEM.L     (SP)+,D2-D4/A5/A6
  172.            RTS
  173.  
  174. ****************************************
  175. * UWORD  GetWBCommandLine(OldOptions)  *
  176. *                D3           *
  177. * Input:                   *
  178. * Output:                   *
  179. *   Selected options               *
  180. ****************************************
  181. @GetWBCommandLine:
  182.            MOVEM.L     D2-D3/D5-D6/A2-A3/A6,-(SP)
  183.            MOVEA.L     (A4),A6
  184.  
  185. * ------------ Open icon.library
  186.            LEA     ICONNAME(PC),A1
  187.            MOVEQ.L     #LIBVERSION,D0
  188.            JSR     _LVOOpenLibrary(A6)
  189.            MOVE.L     D0,D6
  190.            BEQ.W     NoIconLib
  191.  
  192. ************************************
  193. * D3 = Old Options   A6 = ExecBase *
  194. * D6 = IconBase            *
  195. ************************************
  196. * ------------ Set current directory { CurrentDir(WBenchMsg->sm_ArgList[0].wa_Lock) }
  197.            MOVEA.L     _DOSBase(A4),A6
  198.            MOVE.L     _WBenchMsg(A4),A0
  199.            MOVE.L     sm_ArgList(A0),A2
  200.            MOVE.L     A2,D0
  201.            BEQ.W     NoArgList
  202.            MOVE.L     wa_Lock(A2),D1
  203.            JSR     _LVOCurrentDir(A6)
  204.  
  205. * ------------ Save old directory
  206.            MOVE.L     D0,D5
  207.  
  208. ***************************************
  209. * D3 = Old options     A2 = ArgList *
  210. * D5 = old currentdir     A6 = DOSbase *
  211. * D6 = IconBase               *
  212. ***************************************
  213. * ------------ Get the icon.  { GetDiskObject(WbenchMsg->sm_ArgList[0].wa_Name) }
  214.            MOVE.L     wa_Name(A2),A0
  215.            MOVE.L      D6,A6
  216.            JSR     _LVOGetDiskObject(A6)
  217.            MOVE.L     D0,A3
  218.            TST.L     D0
  219.            BEQ.W     NoDiskObject
  220.  
  221. *****************************************
  222. * D3 = Old options    A2 = ArgList    *
  223. * D5 = Old current dir    A3 = DiskObject *
  224. * D6 = DOSBase        A6 = IconBase    *
  225. *****************************************
  226. * ------------ Find the 'ARG=' string
  227.            MOVE.L     do_ToolTypes(A3),A0
  228.            LEA     ARGTEXT(PC),A1
  229.            JSR     _LVOFindToolTypes(A6)
  230.            TST.L     D0
  231.            BNE.B     GetArgs
  232.  
  233. * ------------ Look for all Workbench commands
  234.            MOVE.L     A4,-(SP)
  235.            MOVE.L     A5,-(SP)
  236.            LEA     WBArgList(PC),A4
  237.            MOVE.L     do_ToolTypes(A3),A5
  238.  
  239. * ------------ FindToolTypes
  240. 0$           MOVEA.L     (A4)+,A1
  241.            MOVEA.L     A5,A0
  242.            JSR     _LVOFindToolTypes(A6)
  243.            MOVE.W     (A4)+,D1
  244.            TST.L     D0
  245.            BEQ.B     1$
  246.            OR.W     D1,D3
  247.  
  248. 1$           MOVEA.L     (A4)+,A1
  249.            MOVEA.L     A5,A0
  250.            JSR     _LVOFindToolTypes(A6)
  251.            MOVE.W     (A4)+,D1
  252.            TST.L     D0
  253.            BEQ.B     2$
  254.            AND.W     D1,D3
  255. 2$           TST.W     (A4)
  256.            BNE.B     0$
  257.  
  258. * ------------ Find the HotKey
  259.            LEA     HOTKEYTEXT(PC),A1
  260.            MOVEA.L     A5,A0
  261.            JSR     _LVOFindToolTypes(A6)
  262.            TST.L     D0
  263.            BEQ.B     NoHotKey
  264.  
  265. * ------------ Convert hotkey
  266.            MOVE.L     D0,A1
  267.            MOVE.B     (A1)+,D0       * First digit
  268.            BEQ.B     NoHotKey    * empty string ?
  269.            BSR.W     Hex2Bin
  270.            MOVE.B     D0,D2
  271.            BMI.B     NoHotKey    * Not hex
  272.            LSL.L     #4,D2        * First hex OK
  273.  
  274.            MOVE.B     (A1),D0        * Second digit
  275.            BEQ.B     NoHotKey    * no more digits ?
  276.            BSR.W     Hex2Bin
  277.            OR.W     D0,D2        * Must be word to set flags
  278.            BMI.B     NoHotKey    * Not hex
  279.            MOVE.B     D2,D3        * Save into options
  280.  
  281. NoHotKey:      MOVEA.L     (SP)+,A5
  282.            MOVEA.L     (SP)+,A4
  283.            BRA.B     NoArgs
  284.  
  285. * ------------ GetCommandLine(OldOptions, CommandLine, strlen(CommandLine))
  286. GetArgs:       MOVE.L     D0,A5
  287.            MOVE.L     D0,A0
  288.            JSR     @Mystrlen
  289.            MOVE.L     D0,D2
  290.            JSR     @GetCommandLine(PC)
  291.            TST.W     D0
  292.            BEQ.B     WrongOptions
  293.            MOVE.L     D0,D3
  294.  
  295. *******************************************
  296. * D5 = Old currentdir     A2 = ArgList      *
  297. * D6 = DOSBase         A3 = DiskObject  *
  298. * D3 = New options     A6 = IconBase      *
  299. *******************************************
  300. * ------------ Return the disk object
  301. WrongOptions:
  302. NoArgs:        MOVEA.L     A3,A0
  303.            JSR     _LVOFreeDiskObject(A6)
  304.  
  305. * ------------ Restore current directory
  306. NoDiskObject:  MOVE.L      _DOSBase(A4),A6
  307.            MOVE.L     D5,D1
  308.            BEQ.B     NoCurrentDir
  309.            JSR     _LVOCurrentDir(A6)
  310.  
  311. * ------------ Close library
  312. NoCurrentDir:
  313. NoArgList:     MOVE.L     D6,A1
  314.            MOVEA.L     (A4),A6
  315.            JSR     _LVOCloseLibrary(A6)
  316.  
  317. NoIconLib:     MOVE.L     D3,D0
  318.            MOVEM.L     (SP)+,D2-D3/D5-D6/A2-A3/A6
  319.            RTS
  320.  
  321. ***********************************************************
  322. * VOID MyWrite(TextNumber, Options)  print text to stdout *
  323. *         D2        D3                  *
  324. *  Input:                          *
  325. *    TextNumber    0 - Install                  *
  326. *           1 - Options                  *
  327. *           2 - Quit                  *
  328. *           3 - Error                  *
  329. *           4 - Help                  *
  330. *    Options       only used if TextNumber = 1          *
  331. ***********************************************************
  332. @MyWrite:      MOVEM.L      D2-D6/A6,-(SP)
  333.            MOVE.L      D2,D4
  334.            MOVE.L      D3,D5
  335.  
  336. * ------------ Find stdout
  337.            MOVEA.L      _DOSBase(A4),A6
  338.            JSR      _LVOOutput(A6)
  339.            MOVE.L      D0,D6
  340.            BEQ.W      NoStdout
  341.  
  342. * ------------ Output PopUpMenu text
  343.            MOVE.L      D6,D1
  344.            LEA      POPUPMSG(PC),A0
  345.            MOVE.L      A0,D2
  346.            MOVEQ.L      #POPUPMSG_sizeof,D3
  347.            JSR      _LVOWrite(A6)
  348.  
  349. * ------------ Find what to print
  350.            SUBQ.L      #1,D4
  351.            BMI.B      InstallText      * 0
  352.            BEQ.B      OptionsText      * 1
  353.            SUBQ.B      #2,D4
  354.            BMI.W      QuitText      * 2
  355.            BEQ.W      FailedText      * 3
  356.  
  357. * ------------ print helptext
  358. HelpText:      LEA      HELPMSG(PC),A0
  359.            MOVE.L      #HELPMSG_sizeof,D3
  360.            BRA.W      Print
  361.  
  362. * ------------ print installed
  363. InstallText:   LEA      INSTALLMSG(PC),A0
  364.            MOVEQ.L      #INSTALLMSG_sizeof,D3
  365.            BRA.W      Print
  366.  
  367. * ------------ Build option string
  368. OptionsText:   LEA      OptionBuffer2(PC),A0
  369.            MOVEQ.L      #OptionBuffer2-OptionBuffer+1,D3   * 'Current options: ...  \n'
  370.            BTST      #CLICKMENUES+8,D5
  371.            BEQ.B      1$
  372.            MOVE.L      #' -C ',(A0)+
  373.            ADDQ.L      #4,D3
  374. 1$           BTST      #SUBITEMPOINTER+8,D5
  375.            BEQ.B      2$
  376.            MOVE.L      #' -P ',(A0)+
  377.            ADDQ.L      #4,D3
  378. 2$           BTST      #POPUPNOQUAL+8,D5
  379.            BEQ.B      3$
  380.            MOVE.L      #' -N ',(A0)+
  381.            ADDQ.L      #4,D3
  382. 3$           BTST      #POPUPWITHQUAL+8,D5
  383.            BEQ.B      4$
  384.            MOVE.L      #' -Q ',(A0)+
  385.            ADDQ.L      #4,D3
  386. 4$           BTST      #SHOWSINGLEMENU+8,D5
  387.            BEQ.B      5$
  388.            MOVE.L      #' -S ',(A0)+
  389.            ADDQ.L      #4,D3
  390. 5$           BTST      #ITEMSCENTERED+8,D5
  391.            BEQ.B      6$
  392.            MOVE.L      #' -I ',(A0)+
  393.            ADDQ.L      #4,D3
  394. 6$           MOVE.W      #'-K',(A0)+
  395.  
  396.            LEA      HexChars(PC),A1
  397.            MOVEQ.L      #0,D0
  398.            MOVE.B      D5,D0
  399.            LSR.B      #4,D0
  400.            NEG.W      D0
  401.            MOVE.B      $0f(A1,D0.W),(A0)+
  402.            AND.W      #$0f,D5
  403.            NEG.W      D5
  404.            MOVE.B      $0f(A1,D5.W),(A0)+
  405.            ADDQ.L      #4,D3
  406.  
  407.            MOVE.B      #$0a,(A0)
  408.  
  409.            LEA      OptionBuffer(PC),A0
  410.            BRA.B      Print
  411.  
  412. * ------------ print removed message
  413. QuitText:      LEA      QUITMSG(PC),A0
  414.            MOVEQ.L      #QUITMSG_sizeof,D3
  415.            BRA.B      Print
  416.  
  417. * ------------ print failed message
  418. FailedText:    LEA      ERRORMSG(PC),A0
  419.            MOVEQ.L      #ERRORMSG_sizeof,D3
  420.  
  421. Print:           MOVE.L      D6,D1
  422.            MOVE.L      A0,D2
  423.            JSR      _LVOWrite(A6)
  424.  
  425. NoStdout:      MOVEM.L      (SP)+,D2-D6/A6
  426.            RTS
  427.  
  428. ICONNAME       dc.b      "icon.library",0
  429.            EVEN
  430. ARGTEXT        dc.b      "ARG",0
  431.            EVEN
  432. HexChars:      dc.b      "fedcba9876543210"
  433.  
  434.            EVEN      *0 2 4 6 8 0 2 4 6
  435. OptionBuffer:  dc.b      " Current options ="
  436. OptionBuffer2: dc.b      " -C  -S  -N  -Q  -S  -T -K##\n"
  437.  
  438.            EVEN
  439. POPUPMSG:      dc.b      $0a,$9b,"0;33m","PopUpMenu",$9b,"0m "
  440. POPUPMSG_sizeof:   EQU      *-POPUPMSG
  441.            EVEN
  442. INSTALLMSG:    dc.b      "ver 4.3 installed.",$0a,$a9," Martin Adrian 1992",$0a
  443. INSTALLMSG_sizeof: EQU      *-INSTALLMSG
  444.            EVEN
  445. QUITMSG:       dc.b      "removed.",$0a
  446. QUITMSG_sizeof:    EQU      *-QUITMSG
  447.            EVEN
  448. ERRORMSG:      dc.b      "failed !!",$0a
  449. ERRORMSG_sizeof:   EQU      *-ERRORMSG
  450.  
  451.            EVEN
  452. HELPMSG:       dc.b     " ver 4.3",$0a,$0a
  453.            dc.b     "Usage: [Run] PopUpMenu [Options]",$0a
  454.            dc.b     " -H     Help (this text).",$0a
  455.            dc.b     " -C[-]  Clickmenues.",$0a
  456.            dc.b     " -P[-]  show sub-item Pointer.  (default)",$0a
  457.            dc.b     " -S[-]  Show single menu.",$0a
  458.            dc.b     " -I[-]  display Items centered around menu.",$0a
  459.            dc.b     " -N[-]  pop-up menues when No qualifier pressed.  (default)",$0a
  460.            dc.b     " -Q[-]  pop-up menues when Qualifier pressed.",$0a
  461.            dc.b     " -O[-]  Open options window.  (default)",$0a
  462.            dc.b     " -K##   set hot-Key [Hex].  (default 19 = 'P')",$0a
  463.            dc.b     " -X     eXit PopUpMenu.",$0a
  464.            dc.b     " '-' after option will disable it",$0a
  465. HELPMSG_sizeof:  EQU     *-HELPMSG
  466.  
  467. CLICKTEXT:     dc.b     "CLICKMENUES",0
  468. STDTEXT:       dc.b     "STDMENUES",0
  469. DSHOWSUBTEXT:  dc.b     "DONT"
  470. SHOWSUBTEXT:   dc.b     "SHOWSUB",0
  471. DSHOWSINGTEXT: dc.b     "DONT"
  472. SHOWSINGTEXT:  dc.b     "SHOWSINGLE",0
  473. ITEMSCENTTEXT: dc.b     "ITEMSCENTERED",0
  474. ITEMSTOPTEXT:  dc.b     "ITEMSTOP",0
  475. DPOPWITHTEXT   dc.b     "DONT"
  476. POPWITHTEXT    dc.b     "POPWITHQUAL",0
  477. DPOPNOTEXT:    dc.b     "DONT"
  478. POPNOTEXT:     dc.b     "POPNOQUAL",0
  479. NOOPTWINTEXT:  dc.b     "NO"
  480. OPTWINTEXT:    dc.b     "OPTIONWINDOW",0
  481. HOTKEYTEXT:    dc.b     "HOTKEY",0
  482.  
  483. WBArgList:     dc.l     CLICKTEXT
  484.            dc.w     $2000
  485.            dc.l     STDTEXT
  486.            dc.w     $dfff
  487.            dc.l     SHOWSUBTEXT
  488.            dc.w     $0200
  489.            dc.l     DSHOWSUBTEXT
  490.            dc.w     $fdff
  491.            dc.l     SHOWSINGTEXT
  492.            dc.w     $0100
  493.            dc.l     DSHOWSINGTEXT
  494.            dc.w     $feff
  495.            dc.l     ITEMSCENTTEXT
  496.            dc.w     $0400
  497.            dc.l     ITEMSTOPTEXT
  498.            dc.w     $fbff
  499.            dc.l     POPWITHTEXT
  500.            dc.w     $0800
  501.            dc.l     DPOPWITHTEXT
  502.            dc.w     $f7ff
  503.            dc.l     POPNOTEXT
  504.            dc.w     $1000
  505.            dc.l     DPOPNOTEXT
  506.            dc.w     $efff
  507.            dc.l     OPTWINTEXT
  508.            dc.w     $4000
  509.            dc.l     NOOPTWINTEXT
  510.            dc.w     $bfff
  511.            dc.w     0
  512.  
  513.            END
  514.  
  515.