home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 563.lha / ChangeDefaultTool / CDT.s < prev    next >
Text File  |  1991-10-28  |  18KB  |  776 lines

  1.     opt o-,x-
  2.  
  3.     Incdir    "Include:"
  4.     Include    "Misc/DevPacMacros.i"
  5.     Include    "Exec/Exec.i"
  6.     Include    "Intuition/Intuition.i"
  7.     Include    "Graphics/GfxBase.i"
  8.     Include    "DOS/DOS.i"
  9.     Include "DOS/DOSExtens.i"
  10.     Include "WorkBench/Startup.i"
  11.     Include "WorkBench/WorkBench.i"
  12.  
  13. ******************************************************************************
  14. *                                         *
  15. *    © by Peter Kunath and Frank Riffel $Release 1.0 /24.10.1991/$           *
  16. *                                         *
  17. ******************************************************************************
  18. *                                         *
  19. *                                         *
  20. *    THIS TOOL REQUIRES KICKSTART V37.175 OR HIGHER !!!             *
  21. *                                         *
  22. *    ChangeDefaultTool (CDT) changes the DEFAULT TOOL entry of a project  *
  23. *    icon. CDT opens a AppWin so you can simply drop the icon on it and   *
  24. *    the Tooltype of this icon is magicaly changed to the specified one.  *
  25. *                                         *
  26. *    TOOLTYPES:                                 *  
  27. *            POSITION=    ; default 0/0                  *
  28. *            SIZE=        ; default 110/100+Screenfontheight   *
  29. *            DEFAULTTOOL=    ; default C:MuchMore             *
  30. *                                         *
  31. *    The tooltypes are not case sensitive. The CLI qualifier can be       *
  32. *    derived from the first letter of the tooltypes (e.g. -s).          * 
  33. *                                         *
  34. *    DISCLAIMER                                 *
  35. *                                         *
  36. *    This program is FREELY DISTRIBUTABLE, but COPYRIGHTED. This means    *
  37. *    that you can copy it freely as long as you don't ask for any more    *
  38. *    money than a nominal fee for copying. This program may be put on PD  *
  39. *       disks, especially on Fred Fish's AmigaLibDisks. If you want to       *
  40. *       distribute this program you MUST keep the source code with it.       *
  41. *       Program, document and source code must be distributed in their       *
  42. *       original UNMODIFIED form. Of course you can use an archiver like     *
  43. *       LHarc to make it available on mailboxes and FTP sites. This program  *
  44. *    cannot be used for commercial purposes without written permission    *
  45. *    from the authors. The authors can not be made responsible for any    *
  46. *       damage which is caused by using this program.                 *
  47. *                                         *
  48. ******************************************************************************
  49.  
  50.  
  51.  
  52. ;
  53. ;
  54.     SECTION ChangeDefautToolStart,Code
  55. ;
  56. ;
  57.  
  58. Startup
  59.     move.l    4.w,a6                ; ^ExecBase
  60.     move.l    ThisTask(a6),a2            ; ExecBase->ThisTask
  61.  
  62.     tst.l    pr_CLI(a2)            ; are we running under WB?
  63.     beq.s    FromWB                ; yes !
  64.     
  65. ;--------------------------------------------------------------------------
  66. ;
  67. ; CLI start
  68.  
  69. FromCLI
  70.     clr.b    -1(a0,d0.l)            ; clear linefeed
  71.     move.l    a0,d7
  72.     bra.s    OpenDOS
  73. FromWB
  74.     lea    pr_MsgPort(a2),a0            
  75.     jsr    _LVOWaitPort(a6)        ; wait for StartMsg
  76.     lea    pr_MsgPort(a2),a0
  77.     jsr    _LVOGetMsg(a6)            ; get the msg and
  78.     move.l    d0,WBMsg            ; store it
  79.  
  80. ;-------------
  81.  
  82. OpenDOS
  83.     lea    dosname(pc),a1            ; open dos.library
  84.     jsr    _LVOOldOpenLibrary(a6)         
  85.     move.l    d0,_DOSBase            
  86.     beq    Exit_Err            ; this should never occour!!!
  87.  
  88.     lea    No2.0TextS(pc),a0        ; error text
  89.     cmpi.w    #37,LIB_VERSION(a6)        ; check execversion
  90.     blt    Write_Err            ; no Kick 2.0
  91.  
  92.  
  93.     lea    intuitionname(pc),a1        ; open intuition.libray
  94.     CALLEXEC OldOpenLibrary
  95.     move.l    d0,_IntuitionBase
  96.     beq    Exit_Err
  97.  
  98.     lea    iconname(pc),a1            ; open icon.library
  99.     CALLEXEC OldOpenLibrary
  100.     move.l    d0,_IconBase
  101.     beq    Exit_Err
  102.  
  103.     lea    wbname(pc),a1            ; open workbench.library
  104.     CALLEXEC OldOpenLibrary
  105.     move.l    d0,_WorkbenchBase
  106.     beq    Exit_Err
  107.  
  108.  
  109.     tst.l    pr_CLI(a2)            ; WB launch ?
  110.     beq.s    HandleWB            ; yes
  111.  
  112. ;--------------------------------------------------------------------------
  113. ;
  114. ; CLI stuff
  115.  
  116. HandleCLI
  117.     bsr    ParseCLI
  118.     tst.b    d0                ; print help ?
  119.     beq.s    NoHelp                ; yes
  120.  
  121.     CALLDOS Output                ; get handle
  122.     move.l    d0,d1
  123.     move.l    #HelpTextS,d2
  124.     move.l    #HelpTextE-HelpTextS,d3
  125.     jsr    _LVOWrite(a6)            ; print help text
  126.  
  127.     bra    Exit_Err            ; return with error
  128. NoHelp
  129.     bra    StartProggy            ; do the background start
  130.  
  131. ;--------------------------------------------------------------------------
  132. ;
  133. ; WB stuff 
  134.  
  135. HandleWB
  136.     move.l    WBMsg,a0            ; ArgList
  137.     move.l    sm_ArgList(a0),a2        ; ptr to Arglist
  138.     move.l    sm_NumArgs(a0),d0        ; number of elements in ArgList
  139.     beq     WB_End                ; no ArgList
  140.  
  141.     move.l    wa_Lock(a2),d1            ; get Lock
  142.     beq.s    WB_End                ; no Lock
  143.     CALLDOS CurrentDir
  144.     move.l    d0,MyLock            ; remember old Lock
  145.  
  146.     move.l    wa_Name(a2),a0            ; get DiskObj-Name
  147.     move.l    _IconBase,a6            ; get Disk-Object
  148.     jsr    _LVOGetDiskObjectNew(a6)
  149.     move.l    d0,MyDiskObject
  150.     beq.s    WB_End                ; no object
  151.  
  152.     move.l    d0,a0                ; make sure that you 
  153.     move.l    do_ToolTypes(a0),d7            ; USE 2.04 INCLUDES !!!
  154.  
  155.     bsr    ParseWB
  156.  
  157.     move.l    MyDiskObject,a0            ; free Disk-Object
  158.     move.l    _IconBase,a6
  159.     jsr    _LVOFreeDiskObject(a6)
  160. WB_End
  161.  
  162. ;--------------------------------------------------------------------------
  163. ;
  164. ; start the tool as process
  165.  
  166. StartProggy
  167.     move.l    4.w,a6                ; ^ExecBase
  168.     move.l    ThisTask(a6),a0            ; ExecBase->ThisTask
  169.     move.l    pr_CurrentDir(a0),d1        ; get Lock
  170.     CALLDOS    DupLock                ; copy Lock
  171.     move.l    d0,a3
  172.  
  173.     lea    Startup-4(pc),a0        ; SegList
  174.     move.l    (a0),d3                ; BPTR to 2. segment (Prog)
  175.     clr.l    (a0)                ; clear from Seglist
  176.  
  177.     CALLEXEC Forbid
  178.     move.l    #ProcessName,d1            ; Name
  179.     moveq    #0,d2                ; Pri
  180.     move.l    #4096,d4            ; Stack
  181.     CALLDOS CreateProc            ; start new process
  182.     tst.l    d0
  183.     beq.s    Exit_Err            ; error
  184.     move.l    d0,a0
  185.     move.l    a3,pr_CurrentDir-pr_MsgPort(a0)    ; set Lock
  186.     CALLEXEC Permit
  187.  
  188.     moveq    #0,d7                ; no error
  189.     bra.s    SetOldLock
  190.  
  191. ;--------------------------------------------------------------------------
  192. ;
  193. ; write error message
  194.  
  195. Write_Err
  196.     move.l    #ConName,d1            ; open a console
  197.     move.l    #MODE_NEWFILE,d2        ; window for
  198.     CALLDOS Open                ; output
  199.     move.l    d0,_FileHandle
  200.     beq.s    Exit_Err            ; open err
  201.  
  202.     move.l    d0,d1
  203.  
  204.     move.l    #No2.0TextS,d2
  205.     moveq    #No2.0TextE-No2.0TextS,d3
  206.     jsr    _LVOWrite(a6)            ; Write to CON:
  207.  
  208.     move.l    #5*50,d1            ; wait 5 secs
  209.     jsr    _LVODelay(a6)
  210.  
  211.     move.l    _FileHandle,d1            ; close File
  212.     jsr    _LVOClose(a6)
  213.  
  214.     jsr    CloseLibs            ; close all libs
  215.  
  216. Exit_Err
  217.     moveq    #20,d7                ; error
  218.  
  219. ;--------------------------------------------------------------------------
  220. ;
  221. ; End
  222.  
  223. SetOldLock                    ; restore old Lock
  224.     move.l    MyLock,d1
  225.     beq.s    NoLock
  226.     CALLDOS CurrentDir            
  227.  
  228. NoLock    move.l    WBMsg,d2            ; from wb?
  229.     beq.s    Ende                ; no then just exit
  230.  
  231.     CALLEXEC Forbid                ; we forbid so workbench can't
  232.                         ; UnLoadSeg() us before we are done
  233.     move.l    d2,a1
  234.     jsr    _LVOReplyMsg(a6)        ; reply the msg
  235.  
  236. Ende    move.l    d7,d0                ; set error level
  237.     rts
  238.  
  239. ;--------------------------------------------------------------------------
  240.  
  241. ParseCLI
  242.     move.l    d7,a0
  243. Space    move.b    (a0)+,d0            ; get one char
  244.  
  245.     beq.s    CLIEnd                ; end of commandstring
  246.  
  247.     cmp.b    #" ",d0                ; space ?
  248.     beq.s     Space                ; yes, skip it!
  249.  
  250.     cmp.b    #"-",d0                ; switch ?
  251.     bne.s     CLIHelp                ; not found -> error !
  252.  
  253.     move.b    (a0)+,d0            ; get character
  254.     beq.s    CLIHelp                ; help output
  255.     bset    #5,d0                ; make lowercase
  256.  
  257.     lea    ToolTypesTab(pc),a1        ; ToolTypesTab
  258. CLIloop
  259.     move.l    (a1)+,d1            ; ptr to ToolTypesText 
  260.     beq.s    CLIHelp                ; help output
  261.     move.l    d1,a4
  262.     cmp.b    (a4),d0
  263.     beq.s    CLIfound
  264.     addq.l    #4,a1
  265.     bra.s    CLIloop
  266. CLIfound
  267.     move.l    (a1),a1                ; get functionptr from ToolTypesTab
  268.     jsr    (a1)                ; excute function (a0:^CommandString)
  269.     bra.s    Space                ; search for next switch
  270. CLIHelp
  271.     moveq    #-1,d0                ; help flag (d0 <> 0 (!))
  272. CLIEnd
  273.     rts
  274.  
  275. ;--------------------------------------------------------------------------
  276.  
  277. ParseWB
  278.     tst.l    d7                ; any ToolTypes?
  279.     beq.s    FWB_End                ; no
  280.  
  281.     move.l    d7,a4
  282. FWB_Loop
  283.     move.l    (a4)+,d2            ; get ptr to ToolType
  284.     beq.s    FWB_End                ; exit if no more ToolType
  285.  
  286.     lea    ToolTypesTab(pc),a3        ; ToolTypesTab
  287. FWB_CompLoop
  288.     move.l    d2,a0
  289.     move.l    (a3)+,d0            ; prt to ToolTypesText 
  290.     beq.s    FWB_Loop            ; next ToolType
  291.     move.l    d0,a1
  292. FWB_Comp
  293.     tst.b    (a1)                ; are we at the end?
  294.     beq.s    FWB_CompOk            ; 
  295.     move.b    (a0)+,d0            ; get next char
  296.     beq.s    FWB_CompNext            ; the ToolTypestring is done
  297.     bset    #5,d0                ; make lowercase
  298.     cmp.b    (a1)+,d0            ; compare 
  299.     beq.s    FWB_Comp
  300. FWB_CompNext
  301.     addq.l    #4,a3                ; next func in ToolTypesTab
  302.     bra.s    FWB_CompLoop
  303. FWB_CompOk
  304.     move.l    (a3),a1                ; get Func from ToolTypesTab
  305.     jsr    (a1)                ; execute it (a0:^ToolTypesText)
  306.     bra.s    FWB_Loop            ; next ToolType
  307. FWB_End
  308.     rts
  309.  
  310. ;--------------------------------------------------------------------------
  311.  
  312. PositionFunc                    ; set WindowPos
  313.     lea    MyWindow,a1
  314.     bra.s    SetXY
  315.  
  316. SizeFunc                    ; set WindowSize 
  317.     lea    MyWindow+4,a1
  318.  
  319. SetXY    jsr    GetDez
  320.     move.w    d0,(a1)+
  321.     tst.b    (a0)
  322.     beq.s    SetXYEnd
  323.     addq.l    #1,a0
  324.     jsr    GetDez
  325.     move.w    d0,(a1)
  326. SetXYEnd
  327.     rts    
  328.  
  329. ;--------------------------------------------------------------------------
  330.  
  331. DefaultToolFunc                    ; copy DefTool
  332.     lea    DefaultToolStr,a1
  333.  
  334. Copyinput                    
  335.     moveq    #' ',d0
  336.     cmpi.b    #'"',(a0)            ; " ?
  337.     beq.s    CI_Hoch
  338.     cmpi.b    #"'",(a0)            ; ' ?
  339.     bne.s    CI_Loop
  340. CI_Hoch
  341.     move.b    (a0)+,d0
  342. CI_Loop
  343.     move.b    (a0),(a1)+            ; copy char
  344.     beq.s    CI_End
  345.     cmp.b    (a0)+,d0            ; termiantion char?
  346.     bne.s    CI_Loop                ; no  !
  347.     clr.b    -(a1)                ; clear the char 
  348. CI_End
  349.     rts
  350.  
  351. ;--------------------------------------------------------------------------
  352. ;
  353. ;    Data
  354. ;
  355.  
  356. ToolTypesTab
  357.     dc.l    PositionText,PositionFunc
  358.     dc.l    SizeText,SizeFunc
  359.     dc.l    DefaultToolText,DefaultToolFunc
  360.     dc.l    0,0
  361.  
  362.  
  363. ConName        dc.b 'CON:20/20/350/50/CDT',0
  364. ProcessName    dc.b 'Defaut Tool Changer',0
  365.  
  366. intuitionname    dc.b 'intuition.library',0
  367. dosname        dc.b 'dos.library',0
  368. iconname    dc.b 'icon.library',0
  369. wbname        dc.b 'workbench.library',0
  370.  
  371. HelpTextS
  372.     dc.b 10,27,"[33mChangeDefaultTool Version 1.00",27,"[31m © 11/10/91 by Peter Kunath and Frank Riffel",10,10
  373.     dc.b "Usage: CDT [-dDefault_Tool] [-pPosX/PosY] [-sSizeX/SizeY]",10,10
  374.     dc.b "This Tool opens a AppWin. If you drop a project icon into this window it",10
  375.     dc.b "changes the defaut tool to the specified one (default is <C:Muchmore>).",10,10
  376. HelpTextE
  377.  
  378. No2.0TextS
  379.         dc.b "I need Kickstart V37 to run !!!",10
  380.         dc.b '... exiting',10,0
  381. No2.0TextE
  382.  
  383.  
  384. PositionText    dc.b 'position=',0
  385. SizeText    dc.b 'size=',0
  386. DefaultToolText    dc.b 'defaulttool=',0
  387.  
  388.  
  389.  
  390.     ;-----------------------------------
  391.     ;-------- Here starts the real tool
  392.     ;-----------------------------------
  393.  
  394. ;
  395. ;
  396.     SECTION DefTool,Code
  397. ;
  398. ;
  399.  
  400. Begin
  401.     moveq    #-1,d0                
  402.     CALLEXEC AllocSignal            ; allocate one signalbit 
  403.     lea    _AppPort(pc),a1            
  404.     move.b    d0,MP_SIGBIT(a1)    
  405.     move.l    ThisTask(a6),MP_SIGTASK(a1)    ; copy ^ThisTask
  406.     CALLEXEC AddPort            ; MsgPort for AppWindow
  407.  
  408.     bsr    MainWinOpen            ; open MainWindow
  409.  
  410. ;--------------------------------------------------------------------------
  411. ;
  412. ; Hauptschleife
  413.  
  414. MainLoop
  415.     moveq    #0,d0                ; clear Mask
  416.     lea    _AppPort(pc),a0
  417.     move.b    MP_SIGBIT(a0),d1        
  418.     bset.l    d1,d0                ; build waitmask
  419.  
  420.     move.l    _MyWin(pc),a0            
  421.     move.l    a0,d1
  422.     beq.s    NoMainWin
  423.     move.l    wd_UserPort(a0),a0
  424.     move.b    MP_SIGBIT(a0),d1
  425.     bset.l    d1,d0                ; build waitmask
  426. NoMainWin
  427.     CALLEXEC Wait                ; sleep well ;-)
  428.  
  429.  
  430. Collect0
  431.     lea    _AppPort(pc),a0            ; AppWindowPort
  432.     CALLEXEC GetMsg
  433.     tst.l    d0                ; no more msg?
  434.     beq.s    CollMainWin            
  435.     move.l    d0,-(sp)
  436.     move.l    d0,a1
  437.     tst.w    am_Version(a1)            ; test Version
  438.     beq.s    AppReply            ; to low !
  439.     bsr    AppWinSelect
  440. AppReply
  441.     move.l    (sp)+,a1
  442.     CALLEXEC ReplyMsg            ; back with greetings
  443.     bra.s    Collect0
  444.  
  445.  
  446. CollMainWin
  447.     moveq    #0,d7                ; no Class
  448. Collect1
  449.     move.l    _MyWin(pc),a0            ; MainWindowPort
  450.     move.l    a0,d1
  451.     beq.s    MainLoop            ; no win -> loop
  452.     move.l    wd_UserPort(a0),a0
  453.     CALLEXEC GetMsg
  454.     tst.l    d0                ; last Msg ?
  455.     beq.s    MainSelect            ; yes !
  456.     move.l    d0,a1                ; for ReplyMsg
  457.     move.l    im_Class(a1),d7            ; Class (used later)
  458.     move.w    im_Code(a1),d6            ; Code
  459.     move.l    im_IAddress(a1),a2        ; Intuitionobjekt
  460.  
  461.     CALLEXEC ReplyMsg            ; back with greetings
  462.     bra.s    Collect1
  463.  
  464. MainSelect
  465.     cmpi.l    #CLOSEWINDOW,d7            ; close event ?
  466.     bne    MainLoop            ; no
  467.  
  468. ;--------------------------------------------------------------------------
  469. ;
  470. ; Programmende
  471.  
  472. Quit
  473.     bsr    MainWinQuit            ; close MainWindow if open 
  474.  
  475.     lea    _AppPort(pc),a1            ; remove port
  476.     CALLEXEC RemPort
  477.  
  478.     lea    _AppPort(pc),a1            ; free signal
  479.     move.b    MP_SIGBIT(a1),d0
  480.     CALLEXEC FreeSignal
  481.  
  482.     CALLEXEC Forbid                ; attention !!!
  483.     bsr.s    CloseLibs            ; close all libs
  484.  
  485.     move.l    4.w,a6                ; ^ExecBase
  486.     move.l    ThisTask(a6),a0            ; ExecBase->ThisTask
  487.     move.l    pr_CurrentDir(a0),d1        ; get lock
  488.     CALLDOS    UnLock                ; free lock
  489.  
  490.     lea    Begin-4(pc),a0            ; start segment
  491.     move.l    a0,d1
  492.     lsr.l    #2,d1                ; APTR->BPTR
  493.     CALLDOS UnLoadSeg            ; unload us from memory
  494.  
  495.     moveq    #0,d1                ; no error
  496.     CALLDOS Exit                ; kill 0 -9
  497.  
  498. ;--------------------------------------------------------------------------
  499.  
  500. CloseLibs                    ; close all open libs
  501.     moveq    #3,d2                ; there are 4 libs
  502.     lea    _IconBase(pc),a2        ; address of first libptr
  503.  
  504. CL_Loop    move.l    (a2)+,d0            ; get lib ptr
  505.     beq.s    CL_Skip                ; is it open?
  506.     move.l    d0,a1                ; yes !
  507.     CALLEXEC CloseLibrary            ; then close it
  508. CL_Skip    dbra    d2,CL_Loop            ; next lib
  509.  
  510.     rts
  511.  
  512. ;--------------------------------------------------------------------------
  513.  
  514. AppWinSelect
  515.     cmpi.w    #MTYPE_APPWINDOW,am_Type(a1)    ; Type
  516.     bne    AWS_End
  517.  
  518.     tst.l    am_NumArgs(a1)            ; the number of elements in ArgList
  519.     beq     AWS_End                ; no ArgList
  520.     move.l    am_ArgList(a1),a2        ; argumentpointer
  521.  
  522.     move.l    wa_Lock(a2),d1            ; get Lock 
  523.     CALLDOS DupLock                ; and duplicate it
  524.     move.l    d0,d1
  525.     beq    AWS_End                ; no Lock
  526.  
  527.     CALLDOS CurrentDir            ; change Dir
  528.  
  529.     move.l    d0,d1
  530.     CALLDOS    UnLock                ; rem old Lock
  531.  
  532.     move.l    wa_Name(a2),d2            ; get DiskObj-Namen
  533.     beq.s    AWS_End                ; no name !
  534.  
  535.     move.l    d2,a0                ; name
  536.     move.l    _IconBase,a6            ; get Disk-Object
  537.     jsr    _LVOGetDiskObjectNew(a6)    ; for compatibility with 
  538.     move.l    d0,MyDiskObject            ; default icons!
  539.     beq.s    AWS_End                ; no object
  540.  
  541.     move.l    MyDiskObject,a0
  542.     cmpi.b    #WBPROJECT,do_Type(a0)        ; PROJECT TYPE ?
  543.     bne.s    AWS_Free            ; no!
  544.  
  545.     move.l    MyDiskObject,a0
  546.     move.l    do_DefaultTool(a0),_DefaultTool    ; save old ^DefaultTool
  547.  
  548.     move.l    #DefaultToolStr,do_DefaultTool(a0) ; use new string
  549.  
  550.     move.l    d2,a0                ; name
  551.     move.l    MyDiskObject,a1
  552.     move.l    _IconBase,a6            ; write Disk-Object
  553.     jsr    _LVOPutDiskObject(a6)
  554.  
  555.     move.l    MyDiskObject,a0
  556.     move.l    _DefaultTool,do_DefaultTool(a0)    ; restore old ^DefaultTool 
  557. AWS_Free
  558.     move.l    MyDiskObject,a0            ; and finaly free it
  559.     move.l    _IconBase,a6
  560.     jsr    _LVOFreeDiskObject(a6)
  561. AWS_End
  562.     rts
  563.  
  564.  
  565. ;--------------------------------------------------------------------------
  566. ;
  567. ; open MainWindow
  568.  
  569. MainWinOpen
  570.     tst.l    _MyWin                ; is the window open?
  571.     bne.s    AWS_End                ; yes !
  572.  
  573.     CALLEXEC Forbid                
  574.     bsr    GetBarHeight            ; get fontheigth
  575.     add.w    d0,WHeight            ; correct windowsize
  576.     add.w    d0,ZHeight            ; correct zoomsize
  577.     CALLEXEC Permit
  578.  
  579.     lea    MyWindow,a0            ; Window
  580.     CALLINT OpenWindow
  581.     move.l    d0,d2
  582.     bne.s    MainWinOpend
  583.  
  584.     lea    MyWindow,a0            ; Window
  585.     clr.w    nw_LeftEdge(a0)            ; try 0/0 for the windoworgin
  586.     clr.w    nw_TopEdge(a0)
  587.     CALLINT OpenWindow
  588.     move.l    d0,d2
  589.  
  590. MainWinOpend
  591.     
  592.     move.l    d2,_MyWin            ; no win -> exit
  593.     beq.s    MainWinOpenEnd
  594.  
  595.     move.l    d0,a0                ; Show the Tool
  596.     lea    -1.w,a1        
  597.     lea    ScreenTitle(pc),a2
  598.     CALLINT SetWindowTitles        
  599.     
  600.     moveq    #0,d0                ; id
  601.     moveq    #0,d1                ; userdata
  602.     move.l    d2,a0                ; windowptr
  603.     lea    _AppPort(pc),a1            ; msgport
  604.     sub.l    a2,a2                ; taglist (always NULL)
  605.     CALLWB    AddAppWindowA            ; Window -> AppWindow
  606.     move.l    d0,_MyAppWin
  607.  
  608. MainWinOpenEnd
  609.     rts
  610.  
  611. ;--------------------------------------------------------------------------
  612. ;
  613. ; MainWindow schließen
  614.  
  615. MainWinQuit
  616.     move.l    _MyAppWin,d0            ; AppWindow -> Window
  617.     beq.s    MainWinNoApp
  618.     move.l    d0,a0
  619.     CALLWB    RemoveAppWindow            
  620.  
  621. MainWinNoApp
  622.  
  623.     move.l    _MyWin(pc),d0            ; close Window
  624.     beq.s    MainWinQuitEnd
  625.     move.l    d0,a0
  626.     CALLINT CloseWindow            
  627.  
  628. MainWinQuitEnd
  629.     rts
  630.  
  631. ;--------------------------------------------------------------------------
  632. ;
  633. ; (output: d0:Barheight)
  634.  
  635. GetBarHeight
  636.     moveq    #10,d0                ; default BarHeight
  637.     move.l    _IntuitionBase,a1        ; search WBenchScreen 
  638.     move.l    ib_FirstScreen(a1),d1
  639. FindWBScr
  640.     beq.s    GetBarHeightEnd            ; not found !
  641.     move.l    d1,a1
  642.     move.w    sc_Flags(a1),d1
  643.     andi.w    #SCREENTYPE,d1
  644.     cmpi.w    #WBENCHSCREEN,d1
  645.     beq.s    GetFontHeight            ; found !
  646.     move.l    sc_NextScreen(a1),d1
  647.     bra.s    FindWBScr
  648. GetFontHeight
  649.     move.b    sc_BarHeight(a1),d0        ; Bar size for this Screen
  650. GetBarHeightEnd
  651.     rts
  652.  
  653. ;--------------------------------------------------------------------------
  654. ;
  655. ; convert string to hexword 
  656. ; (a0:^Eingabestring/d0.w:Zahl/d1.l=-1 => Fehler)
  657.  
  658. GetDez                        
  659.     move.b    (a0),-(sp)            ; first char
  660.     moveq    #0,d0
  661.     moveq    #-1,d1
  662.     cmpi.b    #"+",(a0)+            ; plus ?
  663.     beq.s    GetDLoop            ; yes !
  664.     subq.l    #1,a0
  665.     cmpi.b    #"-",(a0)+            ; minus ?
  666.     beq.s    GetDLoop            ; yes !
  667.     subq.l    #1,a0
  668. GetDLoop
  669.     cmpi.b    #"0",(a0)            ; 
  670.     blt.s    GetDEnd                ; out of range !
  671.     cmpi.b    #"9",(a0)            ; 
  672.     bgt.s    GetDEnd                ; out of range !
  673.     cmpi.w    #3276,d0            ; old value to big ?
  674.     bgt.s    GetDErr                ; yes !
  675.     mulu    #10,d0                ; old value * 10
  676.     moveq    #0,d1
  677.     move.b    (a0)+,d1            ; get next char
  678.     sub.b    #"0",d1
  679.     add.w    d1,d0                ; old value + digit => new value
  680.     bpl.s    GetDLoop            ; do it again
  681. GetDErr
  682.     moveq    #-1,d1                ; error flag
  683. GetDEnd
  684.     cmpi.b    #"-",(sp)+            ; is it negative ?
  685.     bne.s    GetDEnde            ; no !
  686.     neg.w    d0                
  687. GetDEnde
  688.     rts
  689.  
  690. ;--------------------------------------------------------------------------
  691. ;
  692. ;         Datas
  693. ;
  694.  
  695. ;--------------------------------------------------------------------------
  696. ;
  697. ; Pointer
  698.  
  699. _IconBase    dc.l 0
  700. _WorkbenchBase    dc.l 0
  701. _IntuitionBase    dc.l 0
  702. _DOSBase    dc.l 0
  703.  
  704. _MyWin        dc.l 0
  705. _MyAppWin    dc.l 0
  706. _FileHandle    dc.l 0
  707. _DefaultTool    dc.l 0
  708.  
  709. ;--------------------------------------------------------------------------
  710. ;
  711. ; Daten
  712.  
  713. MyLock        dc.l 0
  714. WBMsg        dc.l 0
  715. MyDiskObject    dc.l 0
  716.  
  717. ;--------------------------------------------------------------------------
  718. ;
  719. ; Window
  720.  
  721. MyWindow
  722.     dc.w    0,0                ; LeftEdge, TopEdge
  723. WWidth    dc.w    110                ; Breite
  724. WHeight    dc.w    100                ; +BHeight
  725.     dc.b    0,1
  726.     dc.l    CLOSEWINDOW
  727.     dc.l    WFLG_CLOSEGADGET+WFLG_DRAGBAR+WFLG_DEPTHGADGET+WFLG_ACTIVATE+WFLG_RMBTRAP+WFLG_NW_EXTENDED
  728.     dc.l    0
  729.     dc.l    0
  730.     dc.l    AppWinName
  731.     dc.l    0
  732.     dc.l    0
  733.     dc.w    80,80
  734.     dc.w    -1,-1
  735.     dc.w    WBENCHSCREEN
  736.     dc.l MyTags                ; ^TagItemArray
  737.  
  738. MyTags
  739.     dc.l WA_Zoom                ; zoomgadget
  740.     dc.l Zoomed                ; ti_Data
  741.     dc.l TAG_DONE                ; end of TagItemArray
  742.     dc.l 0                    ; not used
  743. Zoomed    dc.w 0,0                ; left/top in zoomed mode
  744. ZWidth    dc.w 110                ; width in zoomed mode
  745. ZHeight dc.w 0                    ; height in zoomed mode
  746.  
  747. ;--------------------------------------------------------------------------
  748. ;
  749. ; AppWindowPort
  750.  
  751. _AppPort
  752.         dc.l 0                ; LN_SUCC
  753.         dc.l 0                ; LN_PRED
  754.         dc.b NT_MSGPORT            ; LN_TYPE
  755.         dc.b 0                ; LN_PRI
  756.         dc.l AppPortName        ; LN_NAME
  757.         dc.b PA_SIGNAL            ; MP_FLAGS
  758.         dc.b 0                ; MP_SIGBIT
  759.         dc.l 0                ; MP_SIGTASK
  760.         dc.l 0                ; LH_HEAD
  761.         dc.l 0                ; LH_TAIL
  762.         dc.l 0                ; LH_TAILPRED
  763.         dc.b NT_MSGPORT            ; LH_TYPE
  764.         dc.b 0                ; LH_pad
  765.  
  766.  
  767. ;--------------------------------------------------------------------------
  768. ;
  769. ; Strings
  770.  
  771. AppPortName        dc.b 'CDT_AppWindow',0
  772. AppWinName        dc.b 'CDT',0
  773. ScreenTitle        dc.b 'DefautTool='
  774. DefaultToolStr        dc.b 'C:MuchMore',0
  775.             dcb.b 256,0
  776.