home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / commod / screense.lha / ScreenSelect / AutoUpdate / SS_AutoUpdate.asm < prev    next >
Assembly Source File  |  1992-12-08  |  4KB  |  202 lines

  1. *
  2. *    SS_AutoUpdate.asm
  3. *    -------------------
  4. *
  5. *    Version: 1.2
  6. *
  7. *    (c) 1992 Markus Aalto
  8. *
  9. *    Patches OpenScreen, OpenScreenTagList, CloseScreen and
  10. *    SetDefaultPubScreen routines to signal ScreenSelect's port if screen
  11. *    was opened or closed or new default public screen was set.
  12. *
  13. *
  14.  
  15.     INCLUDE        "exec/types.i"
  16.     INCLUDE        "exec/ports.i"
  17.     INCLUDE        "exec/memory.i"
  18.     INCLUDE        "dos/dosextens.i"
  19.  
  20.     XREF    _LVOFindPort
  21.     XREF    _LVOSetFunction
  22.     XREF    _LVOAllocMem
  23.     XREF    _LVOCopyMem
  24.     XREF    _LVOForbid
  25.     XREF    _LVOPermit
  26.     XREF    _LVOFreeMem
  27.     XREF    _LVOOpenLibrary
  28.     XREF    _LVOOpenScreenTagList
  29.     XREF    _LVOOpenScreen
  30.     XREF    _LVOCloseScreen
  31.     XREF    _LVOSetDefaultPubScreen
  32.     XREF    _LVOCacheClearU
  33.     XREF    _LVOCloseLibrary
  34.     XREF    _LVOSignal
  35.     XREF    _LVOFindTask
  36.     XREF    _LVOWaitPort
  37.     XREF    _LVOGetMsg
  38.     XREF    _LVOReplyMsg
  39.  
  40. main:
  41.     move.l    $4,SysBase
  42.     move.l    SysBase(PC),a6
  43.     suba.l    a1,a1
  44.     jsr        _LVOFindTask(a6)
  45.     move.l    d0,a4
  46.     tst.l    pr_CLI(a4)
  47.     bne.s    main_normal
  48.  
  49. *    ;--------------------------    We started from WB!
  50.     lea        pr_MsgPort(a4),a3
  51.     move.l    a3,a0
  52.     jsr        _LVOWaitPort(a6)
  53.     move.l    a3,a0
  54.     jsr        _LVOGetMsg(a6)
  55.     move.l    d0,WBenchMsg
  56.  
  57. main_normal:
  58.     lea        Patch(PC),a0
  59.     lea        Patch_END(PC),a1
  60.     suba.l    a0,a1
  61.     move.l    a1,d0
  62.     move.l    d0,patch_size
  63.     move.l    #MEMF_PUBLIC,d1
  64.     jsr        _LVOAllocMem(a6)
  65.     tst.l    d0
  66.     beq        main_end
  67.     move.l    d0,patch_address
  68.     move.l    d0,a1
  69.     lea        Patch(PC),a0
  70.     move.l    patch_size(PC),d0
  71.     jsr        _LVOCopyMem(a6)
  72.  
  73. *    ;----------------------------    Block copied    *
  74.  
  75.     lea        IntuitionName(PC),a1
  76.     move.l    #37,d0
  77.     jsr        _LVOOpenLibrary(a6)
  78.     move.l    d0,IntuitionBase
  79.     bne.s    main_continue1
  80.  
  81.     move.l    patch_address(PC),a1
  82.     move.l    patch_size(PC),d0
  83.     jsr        _LVOFreeMem(a6)
  84.     bra        main_end
  85.  
  86. main_continue1:
  87.     jsr        _LVOForbid(a6)
  88.  
  89. *    ;-------------------------------     Patch OpenScreen
  90.     move.l    IntuitionBase(PC),a1
  91.     move.l    #_LVOOpenScreen,a0
  92.     move.l    patch_address(PC),d0
  93.     jsr        _LVOSetFunction(a6)
  94.     move.l    patch_address(PC),a1
  95.     adda.l    #2,a1
  96.     move.l    d0,(a1)
  97.  
  98. *    ;-------------------------------    Patch OpenScreenTagList
  99.     move.l    IntuitionBase(PC),a1
  100.     move.l    #_LVOOpenScreenTagList,a0
  101.     move.l    patch_address(PC),d0
  102.     add.l    #Patch_TagList-Patch,d0
  103.     jsr        _LVOSetFunction(a6)
  104.     move.l    patch_address(PC),a1
  105.     adda.l    #Patch_TagList-Patch+2,a1
  106.     move.l    d0,(a1)
  107.  
  108. *    ;-------------------------------    Patch CloseScreen
  109.     move.l    IntuitionBase(PC),a1
  110.     move.l    #_LVOCloseScreen,a0
  111.     move.l    patch_address(PC),d0
  112.     add.l    #Patch_Close-Patch,d0
  113.     jsr        _LVOSetFunction(a6)
  114.     move.l    patch_address(PC),a1
  115.     adda.l    #Patch_Close-Patch+2,a1
  116.     move.l    d0,(a1)
  117.  
  118. *     ;-------------------------------    Patch SetDefaultPubScreen
  119.     move.l    IntuitionBase(PC),a1
  120.     move.l    #_LVOSetDefaultPubScreen,a0
  121.     move.l    patch_address(PC),d0
  122.     add.l    #Patch_SetDefault-Patch,d0
  123.     jsr        _LVOSetFunction(a6)
  124.     move.l    patch_address(PC),a1
  125.     adda.l    #Patch_SetDefault-Patch+2,a1
  126.     move.l    d0,(a1)
  127.  
  128.     jsr        _LVOCacheClearU(a6)
  129.     jsr        _LVOPermit(a6)
  130.  
  131.     move.l    IntuitionBase(PC),a1
  132.     jsr        _LVOCloseLibrary(a6)
  133.  
  134. main_end:
  135.     tst.l    pr_CLI(a4)
  136.     bne.s    main_end_normal
  137.  
  138. *    ;------------------------ From WB
  139.     jsr        _LVOForbid(a6)
  140.     move.l    WBenchMsg(PC),a1
  141.     jsr        _LVOReplyMsg(a6)
  142.  
  143. main_end_normal:
  144.     moveq    #0,d0
  145.     rts
  146.  
  147. Patch:
  148.     jsr        patch_foo
  149.     bra.s    Patch_continue
  150. Patch_TagList:
  151.     jsr        patch_foo
  152.     bra.s    Patch_continue
  153. Patch_Close:
  154.     jsr        patch_foo
  155.     bra.s    Patch_continue
  156. Patch_SetDefault:
  157.     jsr        patch_foo
  158.  
  159. Patch_continue
  160.     movem.l    d0-d7/a0-a6,-(sp)
  161.  
  162.     move.l    $4,a6
  163.  
  164. *    ;-----------------------    Well, This isn't actually my port so
  165. *                                we can't trust it won't go away.
  166. *                                So we forbid for a while.
  167.     jsr        _LVOForbid(a6)
  168.     lea        UpdatePort(PC),a1
  169.     jsr        _LVOFindPort(a6)
  170.     move.l    d0,a5
  171.     tst.l    d0
  172.     beq.s    patch_noport
  173.  
  174.     move.l    MP_SIGTASK(a5),a1
  175.     moveq    #0,d1
  176.     move.b    MP_SIGBIT(a5),d1
  177.     moveq    #1,d0
  178.     lsl.l    d1,d0
  179.  
  180. patch_signal:
  181.     jsr        _LVOSignal(a6)
  182.  
  183. patch_noport:
  184.     jsr        _LVOPermit(a6)
  185.     movem.l    (sp)+,d0-d7/a0-a6
  186. patch_foo:
  187.     rts
  188.  
  189. UpdatePort:        dc.b    'ScreenSelectUpdate',0
  190.  
  191. Patch_END:
  192.  
  193. SysBase:        dc.l    0
  194. patch_address:  dc.l    0
  195. patch_size:        dc.l    0
  196. IntuitionBase:    dc.l    0
  197. WBenchMsg:        dc.l    0
  198.  
  199. IntuitionName:    dc.b    'intuition.library',0
  200.  
  201.     END
  202.