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

  1. ***********************************************
  2. *                          *
  3. *              (C)opyright 1991               *
  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. ***********************************************
  32.     
  33.  
  34.         INCLUDE    "JMPLibs.i"
  35.         INCLUDE    "exec/types.i"
  36.         INCLUDE    "exec/ports.i"
  37.         INCLUDE    "exec/memory.i"
  38.         INCLUDE    "intuition.xref"
  39.         INCLUDE    "exec.xref"
  40.  
  41. _LVOEasyRequestArgs:    EQU    -$024c
  42. _LVOAutoRequest:    EQU    -$015c
  43. _LVOSetFunction:    EQU    -$01a4
  44. _LVOOpenLibrary:    EQU    -$0228
  45. _LVOCloseLibrary:    EQU    -$019e
  46. _LVOAllocMem:        EQU    -$00c6
  47. _LVOCopyMem:        EQU    -$0270
  48. _LVOOutput:        EQU    -$003c
  49. _LVOWrite:        EQU    -$0030
  50.  
  51. ;a4 = Port address, when available
  52.  
  53. Start:        move.l    a0,a2
  54.         openlib    Dos
  55.         tst.l    d0
  56.         bne    Start1
  57.         moveq    #20,d0
  58.         rts
  59. Start1:        lib    Dos,Output
  60.         move.l    d0,_stdout
  61.  
  62.         cmp.b    #"?",(a2)
  63.         beq    CommandLineHelp
  64.  
  65.         print    <"NoReq20 v1.01",13,10>,_stdout
  66.         print    <"(C)opyright 1991 Tomi Blinnikka",13,10>,_stdout
  67.  
  68.         move.l    #36,d0
  69.         move.l    $4,a6
  70.         lea.l    _IntuitionLib(pc),a1
  71.         jsr    _LVOOpenLibrary(a6)
  72.         move.l    d0,_IntuitionBase
  73.         bne    CheckInstalled
  74.         print    <"ERROR: Couldn't open intuition.library.",13,10>,_stdout
  75.         print    <"       This program requires Kickstart 2.0 or higher.",13,10>,_stdout
  76.         jmp    ShutDown
  77.  
  78. ;See if already installed
  79.  
  80. CheckInstalled:    flib    Exec,Forbid
  81.         lea.l    PublicPortName(pc),a1
  82.         flib    Exec,FindPort
  83.         move.l    d0,a4
  84.         beq    NotInstalled
  85.         cmp.b    #"q",(a2)
  86.         beq    RemoveNoReq
  87.         cmp.w    #'-q',(a2)
  88.         beq    RemoveNoReq
  89.         cmp.b    #"Q",(a2)
  90.         beq    RemoveNoReq
  91.         cmp.w    #'-Q',(a2)
  92.         beq    RemoveNoReq
  93.         print    <"ERROR: NoReq20 already installed!",13,10>,_stdout
  94.         jmp    ShutDown
  95.  
  96. RemoveNoReq:    flib    Exec,Forbid
  97.         lea.l    NewCodeAdd(a4),a0
  98.         move.l    _IntuitionBase(pc),a1
  99.         cmp.l    _LVOEasyRequestArgs+2(a1),a0
  100.         bne    ErrorCantQuit
  101.         cmp.l    _LVOAutoRequest+2(a1),a0
  102.         bne    ErrorCantQuit        
  103.         flib    Exec,Enable
  104.  
  105.         move.l    _IntuitionBase(pc),a1
  106.         move.l    OldEasyReq(a4),d0
  107.         move.l    #_LVOEasyRequestArgs,a0
  108.         flib    Exec,SetFunction
  109.         move.l    _IntuitionBase(pc),a1
  110.         move.l    OldAutoReq(a4),d0
  111.         move.l    #_LVOAutoRequest,a0
  112.         flib    Exec,SetFunction
  113.  
  114. ;remove port
  115.         flib    Exec,Forbid
  116.         move.l    a4,a1
  117.         flib    Exec,RemPort
  118.         flib    Exec,Enable
  119.         move.l    a4,a1
  120.         move.l    #PublicPort_SIZE,d0
  121.         flib    Exec,FreeMem
  122.  
  123.         print    <"NoReq20 removed.",13,10>,_stdout
  124.         jmp    ShutDown
  125.  
  126. NotInstalled:    cmp.b    #"q",(a2)
  127.         beq    ErrorNotIns
  128.         cmp.w    #'-q',(a2)
  129.         beq    ErrorNotIns
  130.         cmp.b    #"Q",(a2)
  131.         beq    ErrorNotIns
  132.         cmp.w    #'-Q',(a2)
  133.         beq    ErrorNotIns
  134.  
  135. AllocingPort:    move.l    #PublicPort_SIZE,d0
  136.         move.l    #MEMF_CLEAR!MEMF_PUBLIC,d1
  137.         jsr    _LVOAllocMem(a6)
  138.         tst.l    d0
  139.         beq    ErrorNoMem
  140.         move.l    d0,a4
  141.  
  142.         lea.l    PublicPortName-NewCode+NewCodeAdd(a4),a0
  143.         move.l    a0,LN_NAME(a4)
  144.         move.b    #PA_IGNORE,MP_FLAGS(a4)
  145.  
  146.         lea.l    MP_MSGLIST(a4),a0
  147.         NEWLIST    a0
  148.  
  149.         lea.l    NewCode(pc),a0
  150.         lea.l    NewCodeAdd(a4),a1
  151.         move.l    a1,d6
  152.         move.l    #CODE_SIZE,d0
  153.         lib    Exec,CopyMem
  154.  
  155.         move.l    a4,a1
  156.         flib    Exec,AddPort
  157.  
  158.         move.l    _IntuitionBase(pc),a1
  159.         move.l    d6,d0
  160.         move.l    #_LVOEasyRequestArgs,a0
  161.         flib    Exec,SetFunction
  162.         move.l    d0,OldEasyReq(a4)
  163.         move.l    _IntuitionBase(pc),a1
  164.         move.l    d6,d0
  165.         move.l    #_LVOAutoRequest,a0
  166.         flib    Exec,SetFunction
  167.         move.l    d0,OldAutoReq(a4)
  168.         print    <"NoReq20 installed.",13,10>,_stdout
  169. ShutDown:    closlib    Intuition
  170.         closlib    Dos
  171.         move.l    #$00,d0
  172.         rts
  173.  
  174.         INCLUDE    "FH1:Language/WF/NoReq20/NRCommandLineHelp.i"
  175.  
  176. ErrorNotIns:    print    <"ERROR: NoReq20 not installed!",13,10>,_stdout
  177.         jmp    ShutDown
  178. ErrorNoMem:    print    <"ERROR: Couldn't get memory!",13,10>,_stdout
  179.         jmp    ShutDown
  180.  
  181. ErrorCantQuit:    flib    Exec,Enable
  182.         print    <"ERROR: NoReq20 can NOT quit!",13,10>,_stdout
  183.         print    <'Due to: Vectors have been changed afterwards.',13,10>,_stdout
  184.         jmp    ShutDown
  185.  
  186. ;All other library stuff needed
  187.  
  188. DIntuition    set    1
  189.  
  190.         libnames
  191.  
  192. ;File stuff
  193.  
  194. _stdout:    dc.l    0
  195.  
  196. ;new code and other stuff here
  197.  
  198. NewCode:    move.l    #$00,d0
  199.         rts
  200. PublicPortName:    dc.b    "NoReq20_Port",0
  201. NewCode_END:    ds.l    0
  202.  
  203. CODE_SIZE:        EQU    NewCode_END-NewCode
  204.  
  205. ;Our port structure and other port stuff
  206.  
  207.         STRUCTURE PublicPort,0
  208.         STRUCT    MessagePort,MP_SIZE
  209.         APTR    OldEasyReq
  210.         APTR    OldAutoReq
  211.         STRUCT    NewCodeAdd,CODE_SIZE
  212.         LABEL PublicPort_SIZE
  213.  
  214.         END
  215.