home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 28 / amigaformatcd28.iso / +system+ / tools / workbench / multicx2 / handlecx.asm < prev    next >
Assembly Source File  |  1998-02-02  |  8KB  |  250 lines

  1. ; HandleCX 1.3 (19.3.95)
  2. ; (c) 1995 by Martin Berndt
  3. ;
  4. ; for DevPac v3 assembler using system.gs
  5.  
  6. _LVOCopyBrokerList  equ       -186
  7. _LVOFreeBrokerList  equ       -192
  8. _LVOBrokerCommand   equ       -198
  9.  
  10.           STRUCTURE BrokerCopy,LN_SIZE
  11.                     STRUCT bc_Name,CBD_NAMELEN
  12.                     STRUCT bc_Title,CBD_TITLELEN
  13.                     STRUCT bc_Descr,CBD_DESCRLEN
  14.                     ULONG bc_Task
  15.                     ULONG bc_Dummy1
  16.                     ULONG bc_Dummy2
  17.                     UWORD bc_Flags
  18.                     LABEL BrokerCopy_SIZEOF
  19.  
  20.           move.l    $4.w,a6
  21.           lea       VarBase,a4
  22.           lea       cxname(pc),a1
  23.           moveq     #37,d0
  24.           jsr       _LVOOpenLibrary(a6)
  25.           move.l    d0,_CXBase(a4)
  26.           beq.s     quit
  27.           lea       dosname(pc),a1
  28.           moveq     #0,d0
  29.           jsr       _LVOOpenLibrary(a6)
  30.           move.l    d0,_DOSBase(a4)
  31.           beq.s     quit
  32.           lea       _CXList(a4),a0
  33.           move.l    a0,LH_TAILPRED(a0)
  34.           addq.w    #4,a0
  35.           clr.l     (a0)
  36.           move.l    a0,-(a0)
  37.           move.l    _CXBase(a4),a6
  38.           jsr       _LVOCopyBrokerList(a6)
  39.           move.l    _DOSBase(a4),a6
  40.           move.l    #template,d1
  41.           lea       Argument(a4),a5
  42.           move.l    a5,d2
  43.           moveq     #0,d3
  44.           jsr       _LVOReadArgs(a6)
  45.           move.l    d0,_Args(a4)
  46.           bne.s     ArgsOK
  47.           jsr       _LVOIoErr(a6)
  48.           move.l    d0,d1
  49.           move.l    d3,d2
  50.           jsr       _LVOPrintFault(a6)
  51. quit      lea       _CXList(a4),a0
  52.           tst.l     LH_TAILPRED(a0)
  53.           beq.s     quit0
  54.           move.l    _CXBase(a4),a6
  55.           jsr       _LVOFreeBrokerList(a6)
  56. quit0     move.l    $4.w,a6
  57.           move.l    _DOSBase(a4),d0
  58.           beq.s     quit1
  59.           bsr.s     quit2
  60. quit1     move.l    _CXBase(a4),d0
  61.           beq.s     quit3
  62. quit2     move.l    d0,a1
  63.           jsr       _LVOCloseLibrary(a6)
  64. quit3     moveq     #0,d0
  65.           rts
  66.  
  67.  
  68. Error     moveq     #ERROR_REQUIRED_ARG_MISSING,d1
  69.           moveq     #0,d2
  70.           move.l    _DOSBase(a4),a6
  71.           jsr       _LVOPrintFault(a6)
  72.  
  73. NoCMD     move.l    _Args(a4),d1
  74.           move.l    _DOSBase(a4),a6
  75.           jsr       _LVOFreeArgs(a6)
  76.           bra.s     quit
  77.  
  78. ArgsOK    move.l    (a5)+,a2
  79.           movem.l   (a5)+,d4-d5
  80.           moveq     #0,d7
  81.           lea       CXCMD_Table(pc),a1
  82.           moveq     #5,d1
  83. .loop     move.w    (a1)+,d7
  84.           tst.l     (a5)+
  85.           bne.s     DoCMD
  86.           dbf       d1,.loop
  87.           move.w    d4,d0
  88.           or.w      d5,d0
  89.           beq.s     Error
  90.           move.l    a2,d0
  91.           beq       ListCXA
  92.           moveq     #-1,d7
  93. DoCMD     move.l    $4.w,a6
  94.           move.l    _Parsed(a4),d0
  95.           beq.s     .cont
  96.           move.l    d0,a1
  97.           jsr       _LVOFreeVec(a6)
  98.           clr.l     _Parsed(a4)
  99. .cont     move.l    (a2)+,d6
  100.           beq.s     NoCMD
  101.           lea       _CXList(a4),a3
  102.           move.l    d6,a0
  103.           moveq     #-1,d0
  104. .count    addq.l    #1,d0
  105.           tst.b     (a0)+
  106.           bne.s     .count
  107.           move.l    d0,d3
  108.           add.l     d3,d3
  109.           add.l     d0,d3
  110.           move.l    d3,d0
  111.           moveq     #MEMF_PUBLIC,d1
  112.           jsr       _LVOAllocVec(a6)
  113.           move.l    d0,_Parsed(a4)
  114.           beq.s     .cont
  115.           move.l    _DOSBase(a4),a6
  116.           move.l    d6,d1
  117.           move.l    d0,d2
  118.           jsr       _LVOParsePatternNoCase(a6)
  119.           tst.l     d0
  120.           bmi.s     DoCMD
  121. .loop     move.l    LN_SUCC(a3),d0
  122.           beq.s     DoCMD
  123.           move.l    d0,a3
  124.           tst.l     LN_SUCC(a3)
  125.           beq.s     DoCMD
  126.           move.l    _Parsed(a4),d1
  127.           lea       bc_Name(a3),a0
  128.           move.l    a0,d2
  129.           jsr       _LVOMatchPatternNoCase(a6)
  130.           tst.l     d0
  131.           beq.s     .loop
  132.           tst.l     d7
  133.           bmi.s     .skip3
  134.           tst.w     d7
  135.           bpl.s     .skip0
  136.           moveq     #CXCMD_ENABLE,d7
  137.           btst      #1,bc_Flags+1(a3)
  138.           beq.s     .skip0
  139.           moveq     #CXCMD_DISABLE,d7
  140. .skip0    move.l    d7,d0
  141.           lea       bc_Name(a3),a0
  142.           move.l    _CXBase(a4),a6
  143.           jsr       _LVOBrokerCommand(a6)
  144.           move.l    _DOSBase(a4),a6
  145.           tst.w     d5
  146.           bne.s     .skip1
  147.           tst.w     d4
  148.           beq.s     .loop
  149. .skip1    cmpi.w    #CXCMD_DISABLE,d7
  150.           bne.s     .skip2
  151.           bclr      #1,bc_Flags+1(a3)
  152.           bra.s     .skip3
  153. .skip2    cmpi.w    #CXCMD_ENABLE,d7
  154.           bne.s     .skip3
  155.           bset      #1,bc_Flags+1(a3)
  156. .skip3    move.l    a3,a5
  157.           bsr.s     ListCX
  158.           bra.s     .loop
  159.  
  160. ListCXA   moveq     #0,d7
  161.           lea       _CXList(a4),a5
  162. prtloop   move.l    LN_SUCC(a5),d0
  163.           beq       NoCMD
  164.           move.l    d0,a5
  165.           tst.l     LN_SUCC(a5)
  166.           beq       NoCMD
  167.           bsr.s     ListCX
  168.           bra.s     prtloop
  169.  
  170. ListCX    cmpi.w    #CXCMD_KILL,d7
  171.           bne.s     .skip0
  172.           pea       NullStr(pc)
  173.           pea       KillStr(pc)
  174.           bra.s     .skip3
  175. .skip0    move.w    bc_Flags(a5),d0
  176.           lea       GuiStr(pc),a0
  177.           btst      #2,d0
  178.           bne.s     .skip1
  179.           lea       NoGuiStr(pc),a0
  180. .skip1    move.l    a0,-(sp)
  181.           lea       ActiveStr(pc),a0
  182.           btst      #1,d0
  183.           bne.s     .skip2
  184.           lea       InactiveStr(pc),a0
  185. .skip2    move.l    a0,-(sp)
  186. .skip3    pea       bc_Name(a5)
  187.           move.l    a5,-(sp)
  188.           lea       StringFmt1(pc),a0
  189.           move.l    a0,d1
  190.           move.l    sp,d2
  191.           jsr       _LVOVPrintf(a6)
  192.           addq.w    #8,sp
  193.           addq.w    #8,sp
  194.           tst.w     d5
  195.           beq.s     .exit
  196.           pea       bc_Descr(a5)
  197.           pea       bc_Title(a5)
  198.           lea       StringFmt2(pc),a0
  199.           move.l    a0,d1
  200.           move.l    sp,d2
  201.           jsr       _LVOVPrintf(a6)
  202.           addq.w    #8,sp
  203. .exit     rts
  204.  
  205.  
  206. CXCMD_Table         dc.w      CXCMD_APPEAR
  207.                     dc.w      CXCMD_DISAPPEAR
  208.                     dc.w      CXCMD_ENABLE
  209.                     dc.w      CXCMD_DISABLE
  210.                     dc.w      CXCMD_KILL
  211.                     dc.w      -1
  212. dosname             dc.b      "dos.library",0
  213.                     even
  214. cxname              dc.b      "commodities.library",0
  215.                     even
  216. template            dc.b      "CX_NAME/M,L=LIST/S,V=VERBOSE/S,P=POPUP/S,H=HIDE/S,E=ENABLE/S,D=DISABLE/S,R=REMOVE/S,T=TOGGLE/S",0
  217.                     even
  218.                     dc.b      "$VER: HandleCX 1.3 (19.3.95) by Martin Berndt",0
  219.                     even
  220. StringFmt1          dc.b      "$%08lx: %-24s %-8s %s",10,0
  221.                     even
  222. StringFmt2          dc.b      ": %s (%s)",10,0
  223.                     even
  224. ActiveStr           dc.b      "ACTIVE",0
  225.                     even
  226. InactiveStr         dc.b      "INACTIVE",0
  227.                     even
  228. GuiStr              dc.b      "GUI",0
  229.                     even
  230. NoGuiStr            dc.b      "NOGUI",0
  231.                     even
  232. KillStr             dc.b      "KILLED"
  233. NullStr             dc.b      0
  234.                     even
  235.  
  236.                     section   Vars,BSS
  237.  
  238.                     rsreset
  239. _DOSBase            rs.l      1
  240. _CXBase             rs.l      1
  241. _Args               rs.l      1
  242. _CXList             rs.b      LH_SIZE
  243. _Parsed             rs.l      1
  244. Argument            rs.l      9
  245. SIZEOF_Vars         rs.w      0
  246.  
  247. VarBase             ds.b      SIZEOF_Vars
  248.  
  249.                     end
  250.