home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / dev / tbsource.lha / TBSource / NBBS / SetProg / SetProg.bak next >
Text File  |  1993-12-21  |  26KB  |  1,246 lines

  1. ***********************************************
  2. *                                             *
  3. *              (C)opyright 1991               *
  4. *                                             *
  5. *             by  Tomi Blinnikka              *
  6. *                                             *
  7. *      Don´t try to understand the code       *
  8. *                                             *
  9. *          NBBS IISUP              *
  10. *    (Intuition Interfaced SetUp Program)     *
  11. *                                             *
  12. ***********************************************
  13.  
  14.     INCLUDE    "JMPLibs.i"
  15.     INCLUDE    "exec/types.i"
  16.     INCLUDE    "exec/io.i"
  17.     INCLUDE    "libraries/dos.i"
  18.     INCLUDE    "libraries/reqbase.i"
  19.     INCLUDE    "devices/serial.i"
  20.     INCLUDE    "intuition/intuition.i"
  21.  
  22.     INCLUDE    "XREF:dos.xref"
  23.     INCLUDE    "XREF:gfx.xref"
  24.     INCLUDE    "XREF:intuition.xref"
  25.     INCLUDE    "XREF:exec.xref"
  26.  
  27.     XREF    _CreatePort
  28.     XREF    _DeletePort
  29.     XREF    _CreateExtIO
  30.     XREF    _DeleteExtIO
  31.     XREF    _printf
  32.  
  33.     XDEF    _DOSBase
  34.     XDEF    _SysBase
  35.     XDEF    _stdout
  36.  
  37. DReq        set    1
  38.  
  39.         section    NBBS,CODE
  40.     
  41. Start:        move.l    a0,ConfigAddress    ;Get Config filename
  42.         clr.b    -1(a0,d0.l)        ;add null to end of filename
  43.         openlib    Dos,ShutDown
  44.         move.l    _DosBase,_DOSBase
  45.         move.l    $4,_SysBase
  46.  
  47.         lib    Dos,Output
  48.         move.l    d0,_stdout
  49.  
  50.         move.l    ConfigAddress,a0
  51.         tst.b    (a0)
  52.         bne    GotFileName
  53.         jmp    StartMain
  54.  
  55. GotFileName:
  56.  
  57. ;Move filename to FRPathName so if user saves straight away it goes into
  58. ;the correct file, and not the default one.
  59.  
  60.         move.l    ConfigAddress,a0
  61.         lea.l    FRPathName,a1
  62.         cmp.b    #"?",(a0)
  63.         beq    CommandLineHelp
  64. CopyFName:    move.b    (a0)+,(a1)+
  65.         cmp.b    #$00,(a0)
  66.         bne    CopyFName
  67.         clr.b    (a1)
  68.  
  69.         move.l    ConfigAddress,a0
  70.         lea.l    FRFile,a1
  71. CopyFName1:    move.b    (a0)+,(a1)+
  72.         cmp.b    #$00,(a0)
  73.         bne    CopyFName1
  74.         clr.b    (a1)
  75.  
  76.         move.l    ConfigAddress,d1
  77.         move.l    #MODE_OLDFILE,d2
  78.         lib    Dos,Open
  79.         move.l    d0,ConfigFile
  80.         beq    ConfigNotOpen
  81.  
  82.         move.l    ConfigFile,d1
  83.         lea.l    CONFIG,a0
  84.         move.l    a0,d2
  85.         lea.l    CONFIG,a1
  86.         lea.l    CONFIG_END,a2
  87.         sub.l    a1,a2
  88.         move.l    a2,d3
  89.         lib    Dos,Read
  90.  
  91.         jsr    SetGads
  92.  
  93. ;Close config file, we've got what we want
  94.  
  95.         move.l    ConfigFile,d1
  96.         lib    Dos,Close
  97.         move.l    #$00,ConfigFile
  98.         move.l    #$01,CheckSum
  99.  
  100. StartMain:    move.l    #2,d0
  101.         move.l    $4,a6
  102.         lea.l    _ReqLib,a1
  103.         jsr    _LVOOpenLibrary(a6)
  104.         move.l    d0,_ReqBase
  105.         beq    NoShutDown
  106.  
  107. ;Reset checksum so we can tell if the user has played with any of the
  108. ;gadgets, and later if (s)he has, warn him/her about it before quitting
  109.  
  110.         move.l    #$00,CheckSum
  111.     
  112.         openlib    Intuition,ShutDown
  113.         openlib    Gfx,ShutDown
  114.  
  115. ;Find our task
  116.  
  117.         move.l    #$00,a1
  118.         lib    Exec,FindTask
  119.         move.l    d0,OurTask
  120.         move.l    d0,a0
  121.         move.l    $b8(a0),OldTaskWinPtr
  122.  
  123. ;Open Screen
  124.         lea.l    NewScreen1,a0
  125.         lib    Intuition,OpenScreen
  126.         move.l    d0,Screen1
  127.         beq    ShutDown
  128.         move.l    d0,SToW1
  129.         move.l    d0,SToW2
  130.         move.l    d0,SToW3
  131.         move.l    d0,SToW4
  132.         move.l    d0,SToW5
  133.         move.l    d0,SToW6
  134.         move.l    d0,SToW7
  135.         add.l    #$2c,d0
  136.         move.l    d0,ViewPort1
  137.  
  138. ;Open Window1
  139.  
  140. StartWin1:    lea.l    NewWindow1,a0
  141.         lib    Intuition,OpenWindow
  142.         move.l    d0,Window1
  143.         beq    ShutDown
  144.         move.l    d0,a0
  145.         move.l    $32(a0),RP1
  146.  
  147. ;Close the second, third or fourth window
  148.  
  149.         move.l    Window2,a0
  150.         jsr    ClearMSGs
  151.         move.l    #$00,Window2
  152.         move.l    Window3,a0
  153.         jsr    ClearMSGs
  154.         move.l    #$00,Window3
  155.         move.l    Window4,a0
  156.         jsr    ClearMSGs
  157.         move.l    #$00,Window4
  158.  
  159. ;move requesters to Window1
  160.  
  161.         move.l    OurTask,a0
  162.         move.l    Window1,$b8(a0)
  163.  
  164. ;Add Menus to Window1
  165.  
  166.         move.l    Window1,a0
  167.         lea.l    Menu1,a1
  168.         lib    Intuition,SetMenuStrip
  169.  
  170. ;Add all the texts to Window1 of course
  171.  
  172.         move.l    RP1,a0
  173.         lea.l    Win1Txt1,a1
  174.         move.l    #$00,d0
  175.         move.l    #$00,d1
  176.         lib    Intuition,PrintIText
  177.  
  178. ;Read page 215 Paragraph 3 of the RKRM L&D, activate string 1st Gad!
  179.  
  180.         lea.l    SerBRKTGad,a0
  181.         move.l    Window1,a1
  182.         move.l    #$00,a2
  183.         lib    Intuition,ActivateGadget
  184.  
  185. ;Reset ActiveWinNum
  186.  
  187.         move.w    #$01,ActiveWinNum
  188.  
  189. Window1IDCMP:    cmp.w    #$01,ActiveWinNum
  190.         beq    Window1IDCMP1
  191.         cmp.w    #$02,ActiveWinNum
  192.         beq    Window2IDCMP1
  193.         cmp.w    #$03,ActiveWinNum
  194.         beq    Window3IDCMP1
  195.         cmp.w    #$04,ActiveWinNum
  196.         beq    Window4IDCMP1
  197.  
  198.         INCLUDE    "LWF:NBBS/SetProg/SPWin1IDCMP.i"
  199.         INCLUDE "LWF:NBBS/SetProg/SPSetGads.i"
  200.         INCLUDE    "LWF:NBBS/SetProg/SPSetSer.i"
  201.  
  202. StartWin2:
  203.  
  204. ;Open Window2
  205.  
  206.         lea.l    NewWindow2,a0
  207.         lib    Intuition,OpenWindow
  208.         move.l    d0,Window2
  209.         beq    ShutDown
  210.         move.l    d0,a0
  211.         move.l    $32(a0),RP2
  212.  
  213. ;Move the requesters to the window now active
  214.  
  215.         move.l    OurTask,a0
  216.         move.l    Window2,$b8(a0)
  217.  
  218. ;Close the first, third or fourth window
  219.  
  220.         move.l    Window1,a0
  221.         jsr    ClearMSGs
  222.         move.l    #$00,Window1
  223.         move.l    Window3,a0
  224.         jsr    ClearMSGs
  225.         move.l    #$00,Window3
  226.         move.l    Window4,a0
  227.         jsr    ClearMSGs
  228.         move.l    #$00,Window4
  229.  
  230. Win2Start1:
  231.  
  232. ;Add Menus to Window2
  233.  
  234.         move.l    Window2,a0
  235.         lea.l    Menu1,a1
  236.         lib    Intuition,SetMenuStrip
  237.         move.w    #$02,ActiveWinNum
  238.  
  239. ;Activate 1st string gad.
  240.  
  241. ;        lea.l    Gad,a0
  242.         move.l    Window2,a1
  243.         move.l    #$00,a2
  244. ;        lib    Intuition,ActivateGadget
  245.         jmp    Window1IDCMP
  246.  
  247. StartWin3:
  248.  
  249. ;Open Window3
  250.  
  251.         lea.l    NewWindow3,a0
  252.         lib    Intuition,OpenWindow
  253.         move.l    d0,Window3
  254.         beq    ShutDown
  255.         move.l    d0,a0
  256.         move.l    $32(a0),RP3
  257.  
  258. ;Move the requesters to the window now active
  259.  
  260.         move.l    OurTask,a0
  261.         move.l    Window3,$b8(a0)
  262.  
  263. ;Close the first, second or fourth window
  264.  
  265.         move.l    Window1,a0
  266.         jsr    ClearMSGs
  267.         move.l    #$00,Window1
  268.         move.l    Window2,a0
  269.         jsr    ClearMSGs
  270.         move.l    #$00,Window2
  271.         move.l    Window4,a0
  272.         jsr    ClearMSGs
  273.         move.l    #$00,Window4
  274.  
  275. Win3Start1:
  276.  
  277. ;Add Menus to Window3
  278.  
  279.         move.l    Window3,a0
  280.         lea.l    Menu1,a1
  281.         lib    Intuition,SetMenuStrip
  282.         move.w    #$03,ActiveWinNum
  283.  
  284. ;Activate 1st string gad.
  285.  
  286. ;        lea.l    Gad,a0
  287.         move.l    Window3,a1
  288.         move.l    #$00,a2
  289. ;        lib    Intuition,ActivateGadget
  290.         jmp    Window1IDCMP
  291.  
  292. StartWin4:
  293.  
  294. ;Open Window4
  295.  
  296.         lea.l    NewWindow4,a0
  297.         lib    Intuition,OpenWindow
  298.         move.l    d0,Window4
  299.         beq    ShutDown
  300.         move.l    d0,a0
  301.         move.l    $32(a0),RP4
  302.  
  303. ;Move the requesters to the window now active
  304.  
  305.         move.l    OurTask,a0
  306.         move.l    Window4,$b8(a0)
  307.  
  308. ;Close the first, second or third window
  309.  
  310.         move.l    Window1,a0
  311.         jsr    ClearMSGs
  312.         move.l    #$00,Window1
  313.         move.l    Window2,a0
  314.         jsr    ClearMSGs
  315.         move.l    #$00,Window2
  316.         move.l    Window3,a0
  317.         jsr    ClearMSGs
  318.         move.l    #$00,Window3
  319.  
  320. Win4Start1:
  321.  
  322. ;Add Menus to Window4
  323.  
  324.         move.l    Window4,a0
  325.         lea.l    Menu1,a1
  326.         lib    Intuition,SetMenuStrip
  327.         move.w    #$04,ActiveWinNum
  328.  
  329. ;Activate 1st string gad.
  330.  
  331. ;        lea.l    Gad,a0
  332.         move.l    Window4,a1
  333.         move.l    #$00,a2
  334. ;        lib    Intuition,ActivateGadget
  335.         jmp    Window1IDCMP
  336.  
  337. NoReq:        print    <"You need req.library ver.2.5 or higher!",13,10>,_stdout
  338.         jmp    ShutDown
  339.  
  340. ShutDown:    move.l    OurTask,a0
  341.         move.l    OldTaskWinPtr,$b8(a0)
  342.  
  343.         tst.l    ConfigFile
  344.         beq    ShutDown9000
  345.         move.l    ConfigFile,d1
  346.         lib    Dos,Close
  347.         move.l    #$00,ConfigFile
  348.  
  349. ShutDown9000:
  350. ShutDown5000:    tst.l    Window1
  351.         beq    ShutDown4900
  352.         move.l    Window1,a0
  353.         lib    Intuition,ClearMenuStrip
  354.         move.l    Window1,a0
  355.         jsr    ClearMSGs
  356. ShutDown4900:    move.l    Window2,a0
  357.         jsr    ClearMSGs
  358.         move.l    Window3,a0
  359.         jsr    ClearMSGs
  360.         move.l    Window4,a0
  361.         jsr    ClearMSGs
  362.         move.l    AbWin,a0
  363.         jsr    ClearMSGs
  364.         move.l    QuitWin1,a0
  365.         jsr    ClearMSGs
  366.         move.l    HelpWin1,a0
  367.         jsr    ClearMSGs
  368.  
  369. ShutDown4500:    tst.l    Screen1
  370.         beq    ShutDown3000
  371.         move.l    Screen1,a0
  372.         lib    Intuition,CloseScreen
  373.  
  374. ShutDown3000:    tst.l    _ReqBase
  375.         beq    ShutDown2000
  376.         lea.l    FileRequest1,a0
  377.         lib    Req,PurgeFiles
  378.  
  379. ShutDown2000:
  380. ShutDown1100:    tst.l    _IntuitionBase
  381.         beq    ShutDown1000
  382.         lib    Intuition,OpenWorkBench        ;For that xtra touch
  383. ShutDown1000:    closlib    Intuition
  384.         closlib    Gfx
  385.         closlib    Dos
  386.         closlib    Req
  387. ShutDownOut:    move.l    #RETURN_OK,d0
  388.         rts
  389.  
  390.         INCLUDE    "LWF:NBBS/DosError.i"
  391.         INCLUDE    "LWF:NBBS/SetProg/SPCommandLineHelp.i"
  392.     
  393. MenusOn:    lea.l    Menu1,a1
  394.         cmp.w    #$01,ActiveWinNum
  395.         beq    MenusOn1
  396.         cmp.w    #$02,ActiveWinNum
  397.         beq    MenusOn2
  398.         cmp.w    #$03,ActiveWinNum
  399.         beq    MenusOn3
  400.         cmp.w    #$04,ActiveWinNum
  401.         beq    MenusOn4
  402.         rts
  403. MenusOn1:    move.l    Window1,a0
  404.         lib    Intuition,SetMenuStrip
  405.         rts
  406. MenusOn2:    move.l    Window2,a0
  407.         lib    Intuition,SetMenuStrip
  408.         rts
  409. MenusOn3:    move.l    Window3,a0
  410.         lib    Intuition,SetMenuStrip
  411.         rts
  412. MenusOn4:    move.l    Window4,a0
  413.         lib    Intuition,SetMenuStrip
  414.         rts
  415.  
  416.  
  417. MenusOff:    cmp.w    #$01,ActiveWinNum
  418.         beq    MenusOff1
  419.         cmp.w    #$02,ActiveWinNum
  420.         beq    MenusOff2
  421.         cmp.w    #$03,ActiveWinNum
  422.         beq    MenusOff3
  423.         cmp.w    #$04,ActiveWinNum
  424.         beq    MenusOff4
  425.         rts
  426. MenusOff1:    move.l    Window1,a0
  427.         lib    Intuition,ClearMenuStrip
  428.         rts
  429. MenusOff2:    move.l    Window2,a0
  430.         lib    Intuition,ClearMenuStrip
  431.         rts
  432. MenusOff3:    move.l    Window3,a0
  433.         lib    Intuition,ClearMenuStrip
  434.         rts
  435. MenusOff4:    move.l