home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 2 / FFMCD02.bin / new / dev / asm / tbsource / selfdestruct / sd.s < prev    next >
Encoding:
Text File  |  1993-12-21  |  8.1 KB  |  429 lines

  1. *************************************************
  2. *                        *
  3. *         (C)opyright 1991-92        *
  4. *                        *
  5. *        by  Tomi Blinnikka        *
  6. *                        *
  7. *    DonĀ“t try to understand the code    *
  8. *                        *
  9. *  SelfDestruct. Intuition version, of course    *
  10. *                        *
  11. * Version 1.00    19/09/1991            *
  12. *                        *
  13. * - Made for private use            *
  14. *                        *
  15. * Version 1.01    25/12/1991            *
  16. *                        *
  17. * - Others wanted it!                *
  18. *                        *
  19. * Version 1.02    01/01/1992            *
  20. *                        *
  21. * - Release version                *
  22. *                        *
  23. * BUGS:    Version string incompatible.        *
  24. *                        *
  25. * Version 1.03    05/06/1992            *
  26. *                        *
  27. * - Bug fixes, minor optimization        *
  28. *                        *
  29. * BUGS:    What?                    *
  30. *                        *
  31. *************************************************
  32.     
  33.     INCLUDE    "JMPLibs.i"
  34.     INCLUDE    "exec/types.i"
  35.     INCLUDE    "libraries/dos.i"
  36.     INCLUDE    "intuition/intuition.i"
  37.  
  38.     INCLUDE    "XREF:dos.xref"
  39.     INCLUDE    "XREF:intuition.xref"
  40.     INCLUDE    "XREF:exec.xref"
  41.     INCLUDE    "XREF:2.0.xref"
  42.  
  43. DIntuition:    set    1
  44.  
  45. Win1Width:    EQU    18
  46. Placebo:    EQU    5+Win1Width
  47. MaxSDLength:    EQU    32
  48.  
  49.         section    SD,CODE
  50.  
  51.         push    d2-d7/a2-a6
  52.  
  53.         push    d0-a0
  54.         openlib    Dos,ShutDown
  55.         pull    d0-a0
  56.  
  57.         cmp.b    #"?",(a0)
  58.         beq    Usage
  59.         cmp.w    #'-?',(a0)
  60.         beq    Usage
  61.         cmp.w    #'-h',(a0)
  62.         beq    Usage
  63.  
  64. Cont1:        clr.b    -1(a0,d0.l)
  65.         bsr    ConvASCII
  66.         tst.w    d0
  67.         beq    Cont1.1
  68.         move.w    d0,ClickAmount
  69.         add.l    #1,a0
  70. Cont1.1:    tst.b    (a0)
  71.         beq    Cont1.2
  72.         move.l    a0,SDText1
  73. Cont1.2:    move.l    #37,d0
  74.         lea.l    _IntuitionLib,a1
  75.         jsr    _LVOOpenLibrary(a6)
  76.         move.l    d0,_IntuitionBase
  77.         beq    NoKS20
  78.  
  79. ;Have to be under 2.0 to use this
  80.  
  81.         sub.l    a0,a0
  82.         lib    Intuition,LockPubScreen
  83.         move.l    d0,PubScreen
  84.         beq    NoPub
  85.  
  86.         move.l    d0,a3
  87.         move.l    sc_Font(a3),Font
  88.         move.w    sc_Width(a3),d2
  89.         move.b    sc_BarHeight(a3),W1Height+1
  90.         add.w    #1,W1Height
  91.  
  92.         lea.l    SDTxt1,a0
  93.         move.l    a0,d0
  94.         flib    Intuition,IntuiTextLength
  95.  
  96.         add.w    #6,d0
  97.         move.w    d0,W1Width
  98.         sub.w    d0,d2
  99.         sub.w    #Placebo,d2
  100.         move.w    d2,NewWin1
  101.  
  102.         add.l    #sc_BitMap,a3
  103.         cmp.b    #$01,$5(a3)
  104.         bne    Cont1.3
  105.         move.b    #$1,BorderPen1
  106.         move.b    #$1,BorderPen2
  107.         move.w    #GADGHCOMP,FGadFlags
  108.         clr.l    FGadRender1
  109.         clr.l    FGadRender2
  110.  
  111.         add.w    #1,NewWin1+2
  112.         sub.w    #2,W1Height
  113.         sub.w    #1,SDTxtLeft+2
  114. ;        sub.w    #1,W1Width
  115.  
  116. Cont1.3:    move.w    W1Height,FGadHeight
  117.         move.w    W1Width,FGadWidth
  118.  
  119.         move.w    W1Height,Y1.1
  120.         sub.w    #2,Y1.1
  121.         move.w    W1Height,Y3.1
  122.         sub.w    #2,Y3.1
  123.  
  124.         move.w    W1Width,X1.3
  125.         move.w    W1Width,X3.3
  126.  
  127.         sub.w    #1,W1Width
  128.         move.w    W1Width,X2.2
  129.         move.w    W1Width,X2.2
  130.         move.w    W1Width,X4.2
  131.         move.w    W1Width,X2.3
  132.         move.w    W1Width,X4.3
  133.         sub.w    #1,W1Height
  134.         move.w    W1Height,Y2.1
  135.         move.w    W1Height,Y4.1
  136.         move.w    W1Height,Y2.2
  137.         move.w    W1Height,Y4.2
  138.         add.w    #1,W1Width
  139.         add.w    #1,W1Height
  140.  
  141.         lea.l    NewWin1,a0
  142.         flib    Intuition,OpenWindow
  143.         move.l    d0,Win1
  144.         beq    NoWin1
  145.  
  146.         sub.l    a0,a0
  147.         move.l    PubScreen,a1
  148.         flib    Intuition,UnlockPubScreen
  149.         clr.l    PubScreen
  150.  
  151.         move.l    Win1,a0
  152.         flib    Intuition,WindowToFront
  153.  
  154. Win1IDCMP:    move.l    Win1,a0
  155.         bsr    CheckIDCMP
  156.         tst.l    d0
  157.         beq    ShutDown
  158.         cmp.l    #VANILLAKEY,d2
  159.         beq    VKeys
  160.         cmp.l    #GADGETUP,d2
  161.         beq    AddCount
  162.         cmp.l    #REFRESHWINDOW,d2
  163.         beq    ToFront
  164.         cmp.l    #INACTIVEWINDOW,d2
  165.         bne    Win1IDCMP
  166.         clr.w    Counter
  167.         bra    Win1IDCMP
  168.  
  169. ToFront:    add.w    #1,Ticker
  170.         cmp.w    #2,Ticker
  171.         bne    Win1IDCMP
  172.         clr.w    Ticker
  173.         move.l    Win1,a0
  174.         lib    Intuition,WindowToFront
  175.         lea.l    FakeGad1,a0
  176.         move.l    Win1,a1
  177.         sub.l    a2,a2
  178.         flib    Intuition,RefreshGadgets
  179. ToFront_OUT:    bra    Win1IDCMP
  180.  
  181. VKeys:        cmp.w    #"q",d3
  182.         beq    ShutDown
  183.         cmp.w    #"Q",d3
  184.         beq    ShutDown
  185.         clr.w    Counter
  186.         bra    Win1IDCMP
  187.  
  188. AddCount:    add.w    #1,Counter
  189.         move.w    Counter,d0
  190.         cmp.w    ClickAmount,d0
  191.         beq    SelfDestruct
  192.         bra    Win1IDCMP
  193.  
  194. SelfDestruct:    lea.l    KillerName,a0
  195.         move.l    a0,d1
  196.         clr.l    d2
  197.         clr.l    d3
  198.         lib    Dos,Execute
  199.  
  200. ;        print    <"Dead-oh-la!",10>
  201.  
  202. ;Whaz 'is for? We're dead!
  203.  
  204. ShutDown:    tst.l    Win1
  205.         beq    ShutDown9000
  206.         move.l    Win1,a0
  207.         lea.l    FakeGad1,a1
  208.         lib    Intuition,RemoveGadget
  209.         bsr    ClearMSGs
  210.  
  211. ShutDown9000:    tst.l    PubScreen
  212.         beq    ShutDown8000
  213.         sub.l    a0,a0
  214.         move.l    PubScreen,a1
  215.         lib    Intuition,UnlockPubScreen
  216.         clr.l    PubScreen
  217.  
  218. ShutDown8000:    closlib    Intuition
  219.         closlib    Dos
  220.         pull    d2-d7/a2-a6
  221.         clr.l    d0
  222.         rts
  223.  
  224. Usage:        lea.l    UsageETCText1,a0
  225.         bsr    Printer
  226.         bra    ShutDown
  227.  
  228. NoKS20:        lea.l    NoKS20Text1,a0
  229.         bsr    Printer
  230.         bra    ShutDown
  231.  
  232. NoPub:        lea.l    NoPubText1,a0
  233.         bsr    Printer
  234.         bra    ShutDown
  235.  
  236. NoWin1:        lea.l    NoWin1Text1,a0
  237.         bsr    Printer
  238.         bra    ShutDown
  239.  
  240. Printer:    printa    a0
  241.         rts
  242.  
  243. ConvASCII:    clr.l    d0
  244.         clr.l    d1
  245. ConvASCII2:    move.b    (a0),d1
  246.         cmp.b    #'0',d1
  247.         bcs    ConvASCII_OUT
  248.         cmp.b    #'9',d1
  249.         bhi    ConvASCII_OUT
  250.         sub.b    #'0',d1
  251.         mulu.w    #10,d0
  252.         add.l    d1,d0
  253.         add.l    #1,a0
  254.         bra    ConvASCII2
  255. ConvASCII_OUT:    rts
  256.  
  257. CheckIDCMP:    move.l    $4,a6            ;made this a SubRoutine...
  258.         move.l    $56(a0),a2        ;Give it the window structure in a0
  259.         clr.l    d1
  260.         move.b    $0f(a2),d1
  261.         clr.l    d0
  262.         bset.l    d1,d0
  263.         bset.l    #SIGBREAKB_CTRL_C,d0
  264.         jsr    _LVOWait(a6)    
  265.  
  266.         cmp.l    #SIGBREAKF_CTRL_C,d0
  267.         bne    GetMsg1
  268.         clr.l    d0
  269.         rts
  270.     
  271. GetMsg1:    move.l    a2,a0    
  272.         jsr    _LVOGetMsg(a6)
  273.         tst.l    d0
  274.         beq    GetMsg2
  275.     
  276.         move.l    d0,a1 
  277.         move.l    $14(a1),d2        ;answers with Class in d2,
  278.         move.w    $18(a1),d3        ;Code in d3 and
  279.         jsr    _LVOReplyMsg(a6)
  280.         bra    GetMsg1
  281. GetMsg2:    move.l    #-1,d0
  282.         rts
  283.  
  284. ClearMSGs:    lib    Exec,Forbid
  285.         move.l    Win1,a3
  286.         move.l    $56(a3),a2        ;Give it the window structure in a0
  287. ClearMsg1:    move.l    a2,a0    
  288.         flib    Exec,GetMsg
  289.         tst.l    d0
  290.         beq    ClearMsg2
  291.         move.l    d0,a1 
  292.         flib    Exec,ReplyMsg
  293.         bra    ClearMsg1
  294. ClearMsg2:    move.l    a3,a0
  295.         lib    Intuition,CloseWindow
  296.         lib    Exec,Permit
  297. ClearMsg3:    rts
  298.  
  299. ;Reservations
  300.  
  301. Ticker:        dc.w    0
  302. ClickAmount:    dc.w    3
  303. PubScreen:    dc.l    0
  304. Win1:        dc.l    0
  305.  
  306. Counter:    dc.w    0
  307. SDTxt1:        dc.b    1,2        ;PENS
  308.         dc.w    0        ;DRAW MODE
  309. SDTxtLeft:    dc.w    3,2        ;LEFT & TOP EDGE
  310. Font:        dc.l    0        ;FONT
  311. SDText1:    dc.l    SDText2        ;TEXT
  312.         dc.l    0        ;NEXT TEXT
  313.  
  314. Borders1:    dc.w    0        ;Initial offsets from the origin
  315.         dc.w    0        ;LeftEdge and TopEdge
  316. BorderPen1:    dc.b    2,0        ;Pens
  317.         dc.b    1        ;Draw Mode
  318.         dc.b    3        ;Line Count (XY)
  319.         dc.l    BorderXY1    ;XY's
  320.         dc.l    Borders2    ;Next Border
  321.  
  322. Borders2:    dc.w    0        ;Initial offsets from the origin
  323.         dc.w    0        ;LeftEdge and TopEdge
  324.         dc.b    1,0        ;Pens
  325.         dc.b    1        ;Draw Mode
  326.         dc.b    3        ;Line Count (XY)
  327.         dc.l    BorderXY2    ;XY's
  328.         dc.l    0        ;Next Border
  329.  
  330. Borders3:    dc.w    0        ;Initial offsets from the origin
  331.         dc.w    0        ;LeftEdge and TopEdge
  332.         dc.b    1,0        ;Pens
  333.         dc.b    1        ;Draw Mode
  334.         dc.b    3        ;Line Count (XY)
  335.         dc.l    BorderXY3    ;XY's
  336.         dc.l    Borders4    ;Next Border
  337.  
  338. Borders4:    dc.w    0        ;Initial offsets from the origin
  339.         dc.w    0        ;LeftEdge and TopEdge
  340. BorderPen2:    dc.b    2,0        ;Pens
  341.         dc.b    1        ;Draw Mode
  342.         dc.b    3        ;Line Count (XY)
  343.         dc.l    BorderXY4    ;XY's
  344.         dc.l    0        ;Next Border
  345.  
  346. KillerName:    dc.b    "KillLKick",0
  347.         dc.b    "$VER: "
  348. UsageETCText1:    dc.b    "SelfDestruct 1.03 (5.6.92). (C)opyright Tomi Blinnikka.",13,10,13,10
  349.         dc.b    "USAGE: SelfDestruct [Number] [String]",13,10
  350.         dc.b    "       Where: [Number] is a number from 1 to 4096",13,10
  351.         dc.b    "              [String] is the text to be displayed",13,10,13,10
  352.         dc.b    "Defaults are: NN = 3, XXX = SD",13,10,0
  353. NoPubText1:    dc.b    "ERROR: Couldn't lock on PublicScreen!",13,10,0
  354. NoKS20Text1:    dc.b    "ERROR: This program requires Kickstart 2.0 or higher!",13,10,0
  355. NoWin1Text1:    dc.b    "ERROR: Couldn't open window!",13,10,0
  356. SDText2:    dc.b    "SD",0
  357.         ds.w    0
  358.  
  359. ;Library stuff
  360.  
  361.         libnames
  362.  
  363. ;Structures
  364.  
  365. NewWin1:    dc.w    0,0            ;X,Y POS
  366. W1Width:    dc.w    0            ;WIDTH
  367. W1Height:    dc.w    0            ;HEIGHT
  368.         dc.b    0,0            ;PENS
  369.         dc.l    REFRESHWINDOW!GADGETUP!VANILLAKEY!INACTIVEWINDOW    ;IDCMP FLAGS
  370.         dc.l    BACKDROP!BORDERLESS!SIMPLE_REFRESH    ;FLAGS
  371.         dc.l    FakeGad1,0        ;GADGETS, CHECKMARK
  372.         dc.l    0            ;TITLE
  373.         dc.l    0            ;SCREEN ADDRESS
  374.         dc.l    0            ;BITMAP            
  375.         dc.w    18,10,18,10        ;MINIMUM SIZE
  376.         dc.w    WBENCHSCREEN        ;TYPE
  377.  
  378. FakeGad1:    dc.l    0        ;Next Gadget
  379. FGadLeft:    dc.w    0        ;"hit-box" left edge
  380. FGadTop:    dc.w    0        ;"hit-box" top  edge
  381. FGadWidth:    dc.w    0        ;"hit-box" Width
  382. FGadHeight:    dc.w    0        ;"hit-box" Height
  383. FGadFlags:    dc.w    GADGHIMAGE
  384.         dc.w    RELVERIFY    ;activation
  385.         dc.w    BOOLGADGET    ;gadget type
  386. FGadRender1:    dc.l    Borders1    ;gadget rendering
  387. FGadRender2:    dc.l    Borders3    ;select rendering
  388.         dc.l    SDTxt1        ;gadget text
  389.         dc.l    0        ;mutual exclude
  390.         dc.l    0        ;special info
  391.         dc.w    0        ;gadget ID (user definable)
  392.         dc.l    0        ;ptr to general purpose user data
  393.  
  394.         section    SD,BSS
  395.  
  396. BorderXY1:
  397. X1.1:        ds.w    1
  398. Y1.1:        ds.w    1
  399. X1.2:        ds.w    1
  400. Y1.2:        ds.w    1
  401. X1.3:        ds.w    1
  402. Y1.3:        ds.w    1
  403.  
  404. BorderXY2:
  405. X2.1:        ds.w    1
  406. Y2.1:        ds.w    1
  407. X2.2:        ds.w    1
  408. Y2.2:        ds.w    1
  409. X2.3:        dc.w    1
  410. Y2.3:        dc.w    1
  411.  
  412. BorderXY3:
  413. X3.1:        ds.w    1
  414. Y3.1:        ds.w    1
  415. X3.2:        ds.w    1
  416. Y3.2:        ds.w    1
  417. X3.3:        ds.w    1
  418. Y3.3:        ds.w    1
  419.  
  420. BorderXY4:
  421. X4.1:        ds.w    1
  422. Y4.1:        ds.w    1
  423. X4.2:        ds.w    1
  424. Y4.2:        ds.w    1
  425. X4.3:        ds.w    1
  426. Y4.3:        ds.w    1
  427.  
  428.         end
  429.