home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Elysian Archive
/
AmigaElysianArchive.iso
/
commod
/
screense.lha
/
ScreenSelect
/
AutoUpdate
/
SS_AutoUpdate.asm
< prev
next >
Wrap
Assembly Source File
|
1992-12-08
|
4KB
|
202 lines
*
* SS_AutoUpdate.asm
* -------------------
*
* Version: 1.2
*
* (c) 1992 Markus Aalto
*
* Patches OpenScreen, OpenScreenTagList, CloseScreen and
* SetDefaultPubScreen routines to signal ScreenSelect's port if screen
* was opened or closed or new default public screen was set.
*
*
INCLUDE "exec/types.i"
INCLUDE "exec/ports.i"
INCLUDE "exec/memory.i"
INCLUDE "dos/dosextens.i"
XREF _LVOFindPort
XREF _LVOSetFunction
XREF _LVOAllocMem
XREF _LVOCopyMem
XREF _LVOForbid
XREF _LVOPermit
XREF _LVOFreeMem
XREF _LVOOpenLibrary
XREF _LVOOpenScreenTagList
XREF _LVOOpenScreen
XREF _LVOCloseScreen
XREF _LVOSetDefaultPubScreen
XREF _LVOCacheClearU
XREF _LVOCloseLibrary
XREF _LVOSignal
XREF _LVOFindTask
XREF _LVOWaitPort
XREF _LVOGetMsg
XREF _LVOReplyMsg
main:
move.l $4,SysBase
move.l SysBase(PC),a6
suba.l a1,a1
jsr _LVOFindTask(a6)
move.l d0,a4
tst.l pr_CLI(a4)
bne.s main_normal
* ;-------------------------- We started from WB!
lea pr_MsgPort(a4),a3
move.l a3,a0
jsr _LVOWaitPort(a6)
move.l a3,a0
jsr _LVOGetMsg(a6)
move.l d0,WBenchMsg
main_normal:
lea Patch(PC),a0
lea Patch_END(PC),a1
suba.l a0,a1
move.l a1,d0
move.l d0,patch_size
move.l #MEMF_PUBLIC,d1
jsr _LVOAllocMem(a6)
tst.l d0
beq main_end
move.l d0,patch_address
move.l d0,a1
lea Patch(PC),a0
move.l patch_size(PC),d0
jsr _LVOCopyMem(a6)
* ;---------------------------- Block copied *
lea IntuitionName(PC),a1
move.l #37,d0
jsr _LVOOpenLibrary(a6)
move.l d0,IntuitionBase
bne.s main_continue1
move.l patch_address(PC),a1
move.l patch_size(PC),d0
jsr _LVOFreeMem(a6)
bra main_end
main_continue1:
jsr _LVOForbid(a6)
* ;------------------------------- Patch OpenScreen
move.l IntuitionBase(PC),a1
move.l #_LVOOpenScreen,a0
move.l patch_address(PC),d0
jsr _LVOSetFunction(a6)
move.l patch_address(PC),a1
adda.l #2,a1
move.l d0,(a1)
* ;------------------------------- Patch OpenScreenTagList
move.l IntuitionBase(PC),a1
move.l #_LVOOpenScreenTagList,a0
move.l patch_address(PC),d0
add.l #Patch_TagList-Patch,d0
jsr _LVOSetFunction(a6)
move.l patch_address(PC),a1
adda.l #Patch_TagList-Patch+2,a1
move.l d0,(a1)
* ;------------------------------- Patch CloseScreen
move.l IntuitionBase(PC),a1
move.l #_LVOCloseScreen,a0
move.l patch_address(PC),d0
add.l #Patch_Close-Patch,d0
jsr _LVOSetFunction(a6)
move.l patch_address(PC),a1
adda.l #Patch_Close-Patch+2,a1
move.l d0,(a1)
* ;------------------------------- Patch SetDefaultPubScreen
move.l IntuitionBase(PC),a1
move.l #_LVOSetDefaultPubScreen,a0
move.l patch_address(PC),d0
add.l #Patch_SetDefault-Patch,d0
jsr _LVOSetFunction(a6)
move.l patch_address(PC),a1
adda.l #Patch_SetDefault-Patch+2,a1
move.l d0,(a1)
jsr _LVOCacheClearU(a6)
jsr _LVOPermit(a6)
move.l IntuitionBase(PC),a1
jsr _LVOCloseLibrary(a6)
main_end:
tst.l pr_CLI(a4)
bne.s main_end_normal
* ;------------------------ From WB
jsr _LVOForbid(a6)
move.l WBenchMsg(PC),a1
jsr _LVOReplyMsg(a6)
main_end_normal:
moveq #0,d0
rts
Patch:
jsr patch_foo
bra.s Patch_continue
Patch_TagList:
jsr patch_foo
bra.s Patch_continue
Patch_Close:
jsr patch_foo
bra.s Patch_continue
Patch_SetDefault:
jsr patch_foo
Patch_continue
movem.l d0-d7/a0-a6,-(sp)
move.l $4,a6
* ;----------------------- Well, This isn't actually my port so
* we can't trust it won't go away.
* So we forbid for a while.
jsr _LVOForbid(a6)
lea UpdatePort(PC),a1
jsr _LVOFindPort(a6)
move.l d0,a5
tst.l d0
beq.s patch_noport
move.l MP_SIGTASK(a5),a1
moveq #0,d1
move.b MP_SIGBIT(a5),d1
moveq #1,d0
lsl.l d1,d0
patch_signal:
jsr _LVOSignal(a6)
patch_noport:
jsr _LVOPermit(a6)
movem.l (sp)+,d0-d7/a0-a6
patch_foo:
rts
UpdatePort: dc.b 'ScreenSelectUpdate',0
Patch_END:
SysBase: dc.l 0
patch_address: dc.l 0
patch_size: dc.l 0
IntuitionBase: dc.l 0
WBenchMsg: dc.l 0
IntuitionName: dc.b 'intuition.library',0
END