home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / dev / tbsource.lha / TBSource / NoReq20 / NoReq.S < prev    next >
Text File  |  1993-12-21  |  5KB  |  226 lines

  1. *************************************************
  2. *                        *
  3. *              (C)opyright 1991-92        *
  4. *                        *
  5. *        by Tomi Blinnikka        *
  6. *                        *
  7. *      Don´t try to understand the code        *
  8. *                        *
  9. *                        *
  10. *      Get those requesters outta here!        *
  11. *                        *
  12. * Version 0.00a    20/05/1991            *
  13. *                        *
  14. * BUGS: Didn't open intuition.library version    *
  15. *       36 and up only.                *
  16. *                        *
  17. * Version 0.00b    05/06/1991            *
  18. *                        *
  19. * BUGS: If wrong kickstart, made change any-    *
  20. *    way.                    *
  21. *                        *
  22. * Version 1.00    05/06/1991            *
  23. *                        *
  24. * BUGS: Port name got messed up by other pro-    *
  25. *    grams                    *
  26. *                        *
  27. * Version 1.01    06,08/06/1991            *
  28. * (I was riding my bike on 7th, got 1000km    *
  29. * on the meter...)                *
  30. *                        *
  31. * Version 1.02    05/10/1991            *
  32. *                        *
  33. * Added $VER: stuff                *
  34. *                        *
  35. * Version 1.03    28/05/1992            *
  36. *                        *
  37. * Removed ",13," from prints            *
  38. *                        *
  39. * Version 1.04    05/06/1992            *
  40. *                        *
  41. * Fixed $VER: stuff, minor optimization.    *
  42. *                        *
  43. * Version 1.05    09/06/1992            *
  44. *                        *
  45. * Added ",13," back                *
  46. *                        *
  47. *************************************************
  48.     
  49.  
  50.         INCLUDE    "JMPLibs.i"
  51.         INCLUDE    "exec/types.i"
  52.         INCLUDE    "exec/ports.i"
  53.         INCLUDE    "exec/memory.i"
  54.         INCLUDE    "XREF:intuition.xref"
  55.         INCLUDE    "XREF:exec.xref"
  56.  
  57. _LVOEasyRequestArgs:    EQU    -$024c
  58. _LVOAutoRequest:    EQU    -$015c
  59. _LVOSetFunction:    EQU    -$01a4
  60. _LVOOpenLibrary:    EQU    -$0228
  61. _LVOCloseLibrary:    EQU    -$019e
  62. _LVOAllocMem:        EQU    -$00c6
  63. _LVOCopyMem:        EQU    -$0270
  64. _LVOOutput:        EQU    -$003c
  65. _LVOWrite:        EQU    -$0030
  66.  
  67. ;a4 = Port address, when available
  68.  
  69. Start:        move.l    a0,a2
  70.         openlib    Dos
  71.         tst.l    d0
  72.         bne    Start1
  73.         moveq    #20,d0
  74.         rts
  75. Start1:        print    <"NoReq20 v1.05",10,"(C)opyright 1991 Tomi Blinnikka",13,10>
  76.  
  77.         cmp.b    #'?',(a2)
  78.         beq    Usage
  79.         cmp.w    #'-?',(a2)
  80.         beq    Usage
  81.         cmp.w    #'-h',(a2)
  82.         beq    Usage
  83.         bra    Start2
  84.  
  85. Usage:        print    <"Program cancels requesters automatically.",13,10,"NoReq20 not installed.",13,10>
  86.         bra    ShutDown
  87.  
  88. Start2:        move.l    #36,d0
  89.         move.l    $4,a6
  90.         lea.l    _IntuitionLib(pc),a1
  91.         jsr    _LVOOpenLibrary(a6)
  92.         move.l    d0,_IntuitionBase
  93.         bne    CheckInstalled
  94.         print    <"ERROR: Couldn't open intuition.library.",13,10>
  95.         print    <"       This program requires Kickstart 2.0 or higher.",13,10>
  96.         bra    ShutDown
  97.  
  98. ;See if already installed
  99.  
  100. CheckInstalled:    flib    Exec,Forbid
  101.         lea.l    PublicPortName(pc),a1
  102.         flib    Exec,FindPort
  103.         move.l    d0,a4
  104.         cmp.b    #"q",(a2)
  105.         beq    RemoveNoReq
  106.         cmp.w    #'-q',(a2)
  107.         beq    RemoveNoReq
  108.         cmp.b    #"Q",(a2)
  109.         beq    RemoveNoReq
  110.         cmp.w    #'-Q',(a2)
  111.         beq    RemoveNoReq
  112.         tst.l    d0
  113.         beq    NotInstalled
  114.         flib    Exec,Enable
  115.         print    <"ERROR: NoReq20 already installed!",13,10>
  116.         bra    ShutDown
  117.  
  118. ;d0 = Port address
  119.  
  120. RemoveNoReq:    tst.l    d0
  121.         beq    ErrorNotIns
  122.         lea.l    NewCodeAdd(a4),a0
  123.         move.l    _IntuitionBase(pc),a1
  124.         cmp.l    _LVOEasyRequestArgs+2(a1),a0
  125.         bne    ErrorCantQuit
  126.         cmp.l    _LVOAutoRequest+2(a1),a0
  127.         bne    ErrorCantQuit        
  128.  
  129.         move.l    _IntuitionBase(pc),a1
  130.         move.l    OldEasyReq(a4),d0
  131.         move.l    #_LVOEasyRequestArgs,a0
  132.         flib    Exec,SetFunction
  133.         move.l    _IntuitionBase(pc),a1
  134.         move.l    OldAutoReq(a4),d0
  135.         move.l    #_LVOAutoRequest,a0
  136.         flib    Exec,SetFunction
  137.  
  138. ;remove port
  139.         move.l    a4,a1
  140.         flib    Exec,RemPort
  141.         flib    Exec,Enable
  142.         move.l    a4,a1
  143.         move.l    #PublicPort_SIZE,d0
  144.         flib    Exec,FreeMem
  145.  
  146.         print    <"NoReq20 removed.",13,10>
  147.         bra    ShutDown
  148.  
  149. NotInstalled:    flib    Exec,Enable
  150.         move.l    #PublicPort_SIZE,d0
  151.         move.l    #MEMF_CLEAR!MEMF_PUBLIC,d1
  152.         jsr    _LVOAllocMem(a6)
  153.         tst.l    d0
  154.         beq    ErrorNoMem
  155.         move.l    d0,a4
  156.  
  157.         lea.l    PublicPortName-NewCode+NewCodeAdd(a4),a0
  158.         move.l    a0,LN_NAME(a4)
  159.         move.b    #PA_IGNORE,MP_FLAGS(a4)
  160.  
  161.         lea.l    MP_MSGLIST(a4),a0
  162.         NEWLIST    a0
  163.  
  164.         lea.l    NewCode(pc),a0
  165.         lea.l    NewCodeAdd(a4),a1
  166.         move.l    a1,d6
  167.         move.l    #CODE_SIZE,d0
  168.         lib    Exec,CopyMem
  169.  
  170.         move.l    a4,a1
  171.         flib    Exec,AddPort
  172.  
  173.         move.l    _IntuitionBase(pc),a1
  174.         move.l    d6,d0
  175.         move.l    #_LVOEasyRequestArgs,a0
  176.         flib    Exec,SetFunction
  177.         move.l    d0,OldEasyReq(a4)
  178.         move.l    _IntuitionBase(pc),a1
  179.         move.l    d6,d0
  180.         move.l    #_LVOAutoRequest,a0
  181.         flib    Exec,SetFunction
  182.         move.l    d0,OldAutoReq(a4)
  183.         print    <"NoReq20 installed.",13,10>
  184. ShutDown:    closlib    Intuition
  185.         closlib    Dos
  186.         move.l    #$00,d0
  187.         rts
  188.  
  189. ErrorNotIns:    print    <"ERROR: NoReq20 not installed!",13,10>
  190.         bra    ShutDown
  191. ErrorNoMem:    print    <"ERROR: Couldn't get memory!",13,10>
  192.         bra    ShutDown
  193.         dc.b    "$VER: NoReq20 1.05 (9.6.92)",0
  194.         ds.l    0
  195.  
  196. ErrorCantQuit:    flib    Exec,Enable
  197.         print    <"ERROR: NoReq20 can NOT quit!",13,10>
  198.         print    <'Due to: Vectors have been changed afterwards.',13,10>
  199.         bra    ShutDown
  200.  
  201. ;All other library stuff needed
  202.  
  203. DIntuition    set    1
  204.  
  205.         libnames
  206.  
  207. ;new code and other stuff here
  208.  
  209. NewCode:    move.l    #$00,d0
  210.         rts
  211. PublicPortName:    dc.b    "NoReq20_Port",0
  212. NewCode_END:    ds.l    0
  213.  
  214. CODE_SIZE:        EQU    NewCode_END-NewCode
  215.  
  216. ;Our port structure and other port stuff
  217.  
  218.         STRUCTURE PublicPort,0
  219.         STRUCT    MessagePort,MP_SIZE
  220.         APTR    OldEasyReq
  221.         APTR    OldAutoReq
  222.         STRUCT    NewCodeAdd,CODE_SIZE
  223.         LABEL PublicPort_SIZE
  224.  
  225.         END
  226.