home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / dev / tbsource.lha / TBSource / ShellBench / SB.S < prev   
Text File  |  1993-12-21  |  23KB  |  1,127 lines

  1. *************************************************
  2. *                        *
  3. *         (C)opyright 1991        *
  4. *                        *
  5. *        by  Tomi Blinnikka        *
  6. *                        *
  7. *    Don´t try to understand the code    *
  8. *                        *
  9. * Version 0.01    11/01/1992            *
  10. *                        *
  11. * BUGS:    Version string incompatible.        *
  12. *                        *
  13. * Version 0.02    05/06/1992            *
  14. *                        *
  15. * BUGS:    Freezes machine sometimes when quit    *
  16. *                        *
  17. * Version 0.03    07/12/1992            *
  18. *                        *
  19. * BUGS:                        *
  20. *                        *
  21. *************************************************
  22.  
  23. ;add prefs and config file
  24.  
  25.     INCLUDE    "JMPLibs.i"
  26.     INCLUDE    "libraries/dos.i"
  27.     INCLUDE    "libraries/dosextens.i"
  28.     INCLUDE    "intuition/intuition.i"
  29.     INCLUDE    "intuition/gadgetclass.i"
  30.     INCLUDE    "libraries/gadtools.i"
  31.  
  32.     INCLUDE    "XREF:2.0.xref"
  33.  
  34.     INCLUDE    "XREF:gfx.xref"
  35.     INCLUDE    "XREF:intuition.xref"
  36.     INCLUDE    "XREF:exec.xref"
  37.     INCLUDE    "XREF:dos.xref"
  38.  
  39. TRUE:        EQU    1
  40. DGadTools:    set    1
  41.  
  42.         section    SB,CODE
  43.  
  44. Start:        push    d2-d7/a2-a6
  45.         push    a0
  46.  
  47.         sub.l    a1,a1            ;Find our task
  48.         lib    Exec,FindTask
  49.         move.l    d0,OurTask
  50.         move.l    d0,a4
  51.         move.l    $b8(a4),OldTaskWinPtr
  52.  
  53.         move.l    pr_CLI(a4),d0
  54.         bne    OpenDos
  55.  
  56.         lea.l    pr_MsgPort(a4),a0
  57.         lib    Exec,WaitPort
  58.         lea.l    pr_MsgPort(a4),a0
  59.         flib    Exec,GetMsg
  60.         move.l    d0,WBMsg
  61.  
  62. OpenDos:    openlib    Dos,NoDos
  63.  
  64.         move.l    pr_CLI(a4),d0
  65.         bne    CLIStart
  66.  
  67.         add.l    #4,sp
  68.         lea.l    NILName,a0
  69.         move.l    a0,d1
  70.         move.l    #MODE_NEWFILE,d2
  71.         lib    Dos,Open
  72.         move.l    d0,NILFile
  73.         beq    ShutDown
  74.         move.l    NILFile,_stdout
  75.         bra    MainStart
  76.  
  77. CLIStart:    lib    Dos,Output
  78.         move.l    d0,_stdout
  79.         beq    ShutDown
  80.  
  81.         pull    a0
  82.         cmp.b    #'?',(a0)
  83.         beq    Usage
  84.         cmp.w    #'-?',(a0)
  85.         beq    Usage
  86.         cmp.w    #'-h',(a0)
  87.         beq    Usage
  88.  
  89. ;To see if we have ks2.0 we'll try to open the gadtools.library
  90.  
  91. MainStart:    move.l    #37,d0
  92.         lea.l    _GadToolsLib,a1
  93.         lib    Exec,OpenLibrary
  94.         move.l    d0,_GadToolsBase
  95.         beq    NoKS20
  96.  
  97.         openlib    Intuition,NoInt
  98.  
  99. ;Open screen and main window
  100.  
  101.         lea.l    NewScreen1,a0
  102.         lea.l    Screen1TagList,a1
  103.         lib    Intuition,OpenScreenTagList
  104.         move.l    d0,Screen1
  105.         beq    NoScreen
  106.  
  107.         move.l    Screen1,d0
  108.         lea.l    NewWindow1,a0            ;do stuff for win1
  109.         move.l    d0,nw_Screen(a0)
  110.         move.l    d0,a1
  111.         move.b    sc_BarHeight(a1),BHeight+1
  112.         add.w    #1,BHeight
  113.         move.l    sc_Width(a1),nw_Width(a0)
  114.         move.w    BHeight,d2
  115.         move.w    d2,nw_TopEdge(a0)
  116.         sub.w    d2,nw_Height(a0)
  117.  
  118.         lea.l    NewWindow2,a0            ;do stuff for win2
  119.         move.l    d0,nw_Screen(a0)
  120.         add.w    d2,nw_Height(a0)
  121.  
  122.         lea.l    NewWindow3,a0            ;do stuff for win3
  123.         move.l    d0,nw_Screen(a0)
  124.         add.w    d2,nw_Height(a0)
  125.  
  126.         add.w    d2,PubGad1Top
  127.  
  128.         add.l    #$2c,d0                ;get ViewPort
  129.         move.l    d0,VP1
  130.  
  131.         move.l    Screen1,a0
  132.         clr.l    d0
  133.         lib    Intuition,PubScreenStatus
  134.  
  135.         lea.l    PubName,a0
  136.         lib    Intuition,SetDefaultPubScreen
  137.  
  138.         move.w    #SHANGHAI!POPPUBSCREEN,d0
  139.         lib    Intuition,SetPubScreenModes
  140.         move.l    d0,OldPubModes
  141.  
  142. ;Do GadTools preparations, gadgets and menus
  143.  
  144.         lea.l    glist,a0
  145.         lib    GadTools,CreateContext
  146.         move.l    d0,ContextGad
  147.         beq    NoContextGad
  148.  
  149.         move.l    Screen1,a0
  150.         lea.l    Screen1TagList,a1
  151.         lib    GadTools,GetVisualInfoA
  152.         move.l    d0,vi
  153.  
  154.         move.l    glist,a0
  155.         lea.l    NGExecuteGad1,a1
  156.         move.l    #TEXT_KIND,d0
  157.         move.l    vi,gng_VisualInfo(a1)
  158.         sub.l    a2,a2
  159.         lib    GadTools,CreateGadgetA
  160.         move.l    d0,a0
  161.  
  162.         add.w    #GRELBOTTOM,$c(a0)
  163.  
  164.         lea.l    NGCommandGad1,a1
  165.         move.l    #STRING_KIND,d0
  166.         move.l    vi,gng_VisualInfo(a1)
  167.         lea.l    CommandGadTagList,a2
  168.         lib    GadTools,CreateGadgetA
  169.  
  170.         move.l    d0,CommandGad1
  171.         move.l    d0,a0
  172.         move.l    $22(a0),a1
  173.         move.l    (a1),CommandGadBuf
  174.         add.w    #GRELBOTTOM,$c(a0)
  175.  
  176.         lea.l    NGOKGad,a1
  177.         move.l    #BUTTON_KIND,d0
  178.         move.l    vi,gng_VisualInfo(a1)
  179.         lea.l    GadTagList,a2
  180.         lib    GadTools,CreateGadgetA
  181.         move.l    d0,a0
  182.  
  183.         add.w    #GRELBOTTOM,$c(a0)
  184.  
  185.         lea.l    NGCancelGad,a1
  186.         move.l    #BUTTON_KIND,d0
  187.         move.l    vi,gng_VisualInfo(a1)
  188.         lea.l    GadTagList,a2
  189.         lib    GadTools,CreateGadgetA
  190.         move.l    d0,a0
  191.  
  192.         add.w    #GRELBOTTOM+GRELRIGHT,$c(a0)
  193.  
  194.         lea.l    MNProjectMenu1,a0
  195.         lea.l    MenuTagList,a1
  196.         lib    GadTools,CreateMenusA
  197.         move.l    d0,mlist
  198.         beq    NoMenus
  199.  
  200.         move.l    mlist,a0
  201.         move.l    vi,a1
  202.         lea.l    MenuTagList,a2
  203.         lib    GadTools,LayoutMenusA
  204.  
  205.         lea.l    MNProjectMenu2,a0
  206.         lea.l    MenuTagList,a1
  207.         lib    GadTools,CreateMenusA
  208.         move.l    d0,mlist2
  209.         beq    NoMenus
  210.  
  211.         move.l    mlist2,a0
  212.         move.l    vi,a1
  213.         lea.l    MenuTagList2,a2
  214.         lib    GadTools,LayoutMenusA
  215.  
  216.         bsr    OpenWin1
  217.         tst.l    d0
  218.         beq    NoWindow
  219.  
  220. ;move requesters to Window1
  221.  
  222.         move.l    OurTask,a0
  223.         move.l    Window1,$b8(a0)
  224.  
  225.         move.l    Window1,a0
  226.         lib    Intuition,WindowToFront
  227.  
  228. ;Start of main loop
  229.  
  230. Window1IDCMP:    move.l    Window1,a0
  231.         bsr    CheckIDCMP
  232.         cmp.l    #CLOSEWINDOW,d2
  233.         beq    Quit
  234.         cmp.l    #REFRESHWINDOW,d2
  235.         beq    Refresher
  236.         cmp.l    #VANILLAKEY,d2
  237.         beq    VanillaKeys
  238.         cmp.l    #MENUPICK,d2
  239.         beq    Win1Menus
  240.         cmp.l    #RAWKEY,d2
  241. ;        beq    RawKeys
  242.         cmp.l    #GADGETUP,d2
  243.         beq    GadgetSelect
  244.         cmp.l    #ACTIVEWINDOW,d2
  245. ;        beq    ActivateGads
  246.         bra    Window1IDCMP
  247.  
  248. GadgetSelect:    cmp.w    #51,$26(a5)
  249.         beq    DoPubState
  250.         bra    Window1IDCMP
  251.  
  252. DoPubState:    move.w    gg_Flags(a5),d0
  253.         and.w    #SELECTED,d0
  254.         cmp.w    #SELECTED,d0
  255.         bne    DoPubState1
  256.         lea.l    PubName,a0
  257.         lib    Intuition,SetDefaultPubScreen
  258.         bra    Window1IDCMP
  259. DoPubState1:    sub.l    a0,a0
  260.         lib    Intuition,SetDefaultPubScreen
  261.         bra    Window1IDCMP
  262.  
  263. Refresher:    move.l    Window1,a0
  264.         lib    GadTools,GT_BeginRefresh
  265.         move.l    Window1,a0
  266.         move.l    #TRUE,d0
  267.         lib    GadTools,GT_EndRefresh
  268.         bra    Window1IDCMP
  269.  
  270. VanillaKeys:    cmp.w    #$1b,d3
  271.         beq    Quit
  272.         bra    Window1IDCMP
  273. RawKeys:    cmp.w    #$5f,d3
  274.         beq    Help
  275.         bra    Window1IDCMP
  276.  
  277. Win1Menus:    bsr    MenuNull
  278.         cmp.w    #$00,d6
  279.         beq    Win1Menus1
  280.         cmp.w    #$01,d6
  281.         beq    Win1Menus2
  282.         bra    Window1IDCMP
  283. Win1Menus1:    cmp.w    #$00,d5
  284.         beq    DoBackDrop
  285.         cmp.w    #$01,d5
  286.         beq    ExecuteCommand
  287.         cmp.w    #$02,d5
  288.         beq    About
  289.         cmp.w    #$04,d5
  290.         beq    Quit
  291.         bra    Window1IDCMP
  292. Win1Menus2:    bra    Window1IDCMP
  293.  
  294. ExecuteCommand:    bsr    MenusOff
  295.         bsr    SleepPointer
  296.  
  297.         bsr    OpenWin2
  298.         tst.l    d0
  299.         beq    NoWindow
  300.  
  301. Window2IDCMP:    move.l    Window2,a0
  302.         bsr    CheckIDCMP
  303.         cmp.l    #CLOSEWINDOW,d2
  304.         beq    ExecuteQuit
  305.         cmp.l    #VANILLAKEY,d2
  306.         beq    ExecuteVKeys
  307.         cmp.l    #MENUPICK,d2
  308.         beq    Win2Menus
  309.         cmp.l    #GADGETUP,d2
  310.         beq    ExecuteGads
  311.         bra    Window2IDCMP
  312.  
  313. ExecuteGads:    cmp.w    #10,$26(a5)
  314.         beq    DoExecute
  315.         cmp.w    #98,$26(a5)
  316.         beq    DoExecute
  317.         cmp.w    #99,$26(a5)
  318.         beq    ExecuteQuit
  319.         bra    Window2IDCMP
  320.  
  321. Win2Menus:    bsr    MenuNull
  322.         cmp.w    #$00,d6
  323.         beq    Win2Menus1
  324.         bra    Window2IDCMP
  325. Win2Menus1:    cmp.w    #$00,d5
  326.         beq    DoExecute
  327.         cmp.w    #$02,d5
  328.         beq    ExecuteQuit
  329.         bra    Window2IDCMP
  330.  
  331. ExecuteVKeys:    cmp.w    #$1b,d3
  332.         beq    ExecuteQuit
  333.         bra    Window2IDCMP
  334.  
  335. DoExecute:    lea.l    CONName,a0
  336.         move.l    a0,d1
  337.         move.l    #MODE_OLDFILE,d2
  338.         lib    Dos,Open
  339.         move.l    d0,CONFile
  340.         beq    NoCON
  341.  
  342.         move.l    CommandGadBuf,d1
  343.         clr.l    d2
  344.         move.l    CONFile,d3
  345.         lib    Dos,Execute
  346.  
  347.         tst.l    CONFile
  348.         beq    ShutDown2000
  349.         move.l    CONFile,d1
  350.         lib    Dos,Close
  351.         clr.l    CONFile
  352.         bra    ExecuteQuit
  353.  
  354. ExecuteQuit:    bsr    CloseWin2
  355.  
  356.         bsr    MenusOn
  357.         bsr    NormalPointer
  358.         bra    Window1IDCMP
  359.  
  360. About:        bsr    SleepPointer
  361.         bsr    MenusOff
  362.  
  363.         move.l    Window1,a0
  364.         lea.l    AboutTxt1,a1
  365.         move.l    #$00,a2        ;positive text
  366.         lea.l    OKTxt,a3    ;a bit the wrong way around but...
  367.         move.l    #$00,d0
  368.         move.l    #$00,d1
  369.         move.l    #320,d2
  370.         move.l    #$50,d3
  371.         lib    Intuition,AutoRequest
  372.         bsr    MenusOn
  373.         bsr    NormalPointer
  374.         bra    Window1IDCMP
  375.  
  376. DoBackDrop:    move.l    mlist,a0
  377.         move.l    #$F800,d0
  378.         lib    Intuition,ItemAddress
  379.         move.l    d0,a0
  380.         move.w    mu_Flags(a0),d0
  381.         and.w    #CHECKED,d0
  382.         cmp.w    #CHECKED,d0
  383.         beq    DoBackDrop1
  384.         bsr    CloseWin1
  385.         lea.l    NewWindow1,a0
  386.         and.l    #~BACKDROP!BORDERLESS,nw_Flags(a0)
  387.         or.l    #WINDOWDEPTH!WINDOWCLOSE!WINDOWDRAG!WINDOWSIZING,nw_Flags(a0)
  388.         lea.l    SBName1,a1
  389.         move.l    a1,nw_Title(a0)
  390.         bra    DoBD_OUT
  391. DoBackDrop1:    bsr    CloseWin1
  392.         lea.l    NewWindow1,a0
  393.         or.l    #BACKDROP!BORDERLESS,nw_Flags(a0)
  394.         and.l    #~WINDOWDEPTH!WINDOWCLOSE!WINDOWDRAG!WINDOWSIZING,nw_Flags(a0)
  395.         clr.l    nw_Title(a0)
  396.         move.l    Screen1,a1
  397.         move.l    sc_Width(a1),nw_Width(a0)
  398.         move.w    BHeight,d2
  399.         move.w    d2,nw_TopEdge(a0)
  400.         sub.w    d2,nw_Height(a0)
  401. DoBD_OUT:    bsr    OpenWin1
  402.         tst.l    d0
  403.         beq    NoWindow
  404.         bra    Window1IDCMP
  405.  
  406. Help:        bra    Window1IDCMP
  407.  
  408. Quit:        bsr    CloseWin1
  409. Quit1:        bsr    CloseScreen1
  410.         tst.l    d0
  411.         beq    Quit2
  412. ;        move.l    OldPubModes,d0
  413. ;        lib    Intuition,SetPubScreenModes
  414.         sub.l    a0,a0
  415.         lib    Intuition,SetDefaultPubScreen
  416.         bra    ShutDown
  417.  
  418. Quit2:        bsr    OpenWin1
  419.         tst.l    d0
  420.         beq    Quit1
  421.         bsr    VisitorsOpen
  422.         bra    Window1IDCMP
  423.  
  424. OpenWin1:    lea.l    NewWindow1,a0
  425.         lib    Intuition,OpenWindow
  426.         move.l    d0,Window1
  427.         beq    OpenWin1_ERR1
  428.         move.l    d0,a0
  429.         move.l    $32(a0),RP1
  430. ;        move.l    Window1,a0
  431.         move.l    mlist,a1
  432.         lib    Intuition,SetMenuStrip
  433.         move.l    #-1,d0
  434.         rts
  435. OpenWin1_ERR1:    clr.l    d0
  436.         rts
  437.  
  438. CloseW