home *** CD-ROM | disk | FTP | other *** search
- ;1993 Copyright by Stefan Fuchs
- ;SNF is Freeware
-
- include "ASMMacros.i"
- include "dos/dosextens.i"
- include "patch/patchtags.i"
-
- execbase equ 4
- _DOSBase equr A5
- _PATCHBase equr A4
-
- _LVOOpenLibrary equ -552 ;exec.library
- _LVOCloseLibrary equ -414
- _LVOWait equ -318
- _LVOFindTask equ -294
-
- _LVOLoadSeg equ -150 ;dos.library
- _LVOOpen equ -30
- _LVOOutPut equ -60
- _LVOLock equ -84
- _LVOIOErr equ -132
-
- _LVOInstallPatchTagsA equ -54 ;patch.library
- _LVORemovePatchTagsA equ -60
-
- REVISION MACRO
- dc.b "1.5"
- ENDM
- REVDATE MACRO
- dc.b "31-Dez-93"
- ENDM
-
-
- Main:
- sub.l _DOSBase,_DOSBase
- sub.l _PATCHBase,_PATCHBase
- move.l execbase,a6
-
- lea.l dosname(pc),a1 ;Open Dos Library
- moveq.l #0,d0
- jsr _LVOOpenLibrary(a6)
- tst.l d0
- beq DosFailed
- move.l d0,_DOSBase
-
- move.l d0,a6
- jsr _LVOOutPut(a6)
- move.l d0,OutPutHandle
- beq NoOutPutExit
-
-
- lea.l Header(pc),a0 ;Print Title Text
- bsr TextOutput
-
- move.l execbase,a6
- lea.l patchname(pc),a1 ;Open Patch Library Version 2
- moveq.l #2,d0
- jsr _LVOOpenLibrary(a6)
- tst.l d0
- beq PatchFailed
- move.l d0,_PATCHBase
-
-
- move.l _PATCHBase,a6
- lea.l InstallTags(pc),a1
- move.l _DOSBase,4(a1) ;Pointer to Library
- lea.l IDString(pc),a0 ;ID for PatchList
- move.l a0,12(a1)
- move.l #5,20(a1) ;Priority 5: before original
-
-
- lea.l PreLoadSeg(pc),a0
- move.l #_LVOLoadSeg,d0
- jsr _LVOInstallPatchTagsA(a6)
- lea.l PreLoadSegFailed(pc),a0
- move.l d0,PreLoadSegPatch
- BSREQ TextOutput
-
- lea.l InstallTags(pc),a1
- lea.l PreOpen(pc),a0
- move.l #_LVOOpen,d0
- jsr _LVOInstallPatchTagsA(a6)
- lea.l PreOpenFailed(pc),a0
- move.l d0,PreOpenPatch
- BSREQ TextOutput
-
- lea.l InstallTags(pc),a1
- lea.l PreLock(pc),a0
- move.l #_LVOLock,d0
- jsr _LVOInstallPatchTagsA(a6)
- lea.l PreLockFailed(pc),a0
- move.l d0,PreLockPatch
- BSREQ TextOutput
-
- lea.l InstallTags(pc),a1
- move.l #-5,20(a1) ;Priority -5: after original
- lea.l AfterLoadSeg(pc),a0
- move.l #_LVOLoadSeg,d0
- jsr _LVOInstallPatchTagsA(a6)
- lea.l AfterLoadSegFailed(pc),a0
- move.l d0,AfterLoadSegPatch
- BSREQ TextOutput
-
- lea.l InstallTags(pc),a1
- lea.l AfterOpen(pc),a0
- move.l #_LVOOpen,d0
- jsr _LVOInstallPatchTagsA(a6)
- lea.l AfterOpenFailed(pc),a0
- move.l d0,AfterOpenPatch
- BSREQ TextOutput
-
- lea.l InstallTags(pc),a1
- lea.l AfterLock(pc),a0
- move.l #_LVOLock,d0
- jsr _LVOInstallPatchTagsA(a6)
- lea.l AfterLockFailed(pc),a0
- move.l d0,AfterLockPatch
- BSREQ TextOutput
-
-
- MainLoop:
- moveq.l #0,d0
- bset.l #12,d0
- CALL _LVOWait,execbase
-
-
- move.l _PATCHBase,a6
-
- move.l PreLoadSegPatch,a0
- lea.l RemoveTags(pc),a1
- jsr _LVORemovePatchTagsA(a6)
- lea.l PreLoadSegRemFailed(pc),a0
- tst.l d0
- BSRNE TextOutput,MainLoop
- move.l d0,PreLoadSegPatch
-
- move.l PreOpenPatch,a0
- lea.l RemoveTags(pc),a1
- jsr _LVORemovePatchTagsA(a6)
- lea.l PreOpenRemFailed(pc),a0
- tst.l d0
- BSRNE TextOutput,MainLoop
- move.l d0,PreOpenPatch
-
- move.l PreLockPatch,a0
- lea.l RemoveTags(pc),a1
- jsr _LVORemovePatchTagsA(a6)
- lea.l PreLockRemFailed(pc),a0
- tst.l d0
- BSRNE TextOutput,MainLoop
- move.l d0,PreLockPatch
-
- move.l AfterLoadSegPatch,a0
- lea.l RemoveTags(pc),a1
- jsr _LVORemovePatchTagsA(a6)
- lea.l AfterLoadSegRemFailed(pc),a0
- tst.l d0
- BSRNE TextOutput,MainLoop
- move.l d0,AfterLoadSegPatch
-
- move.l AfterOpenPatch,a0
- lea.l RemoveTags(pc),a1
- jsr _LVORemovePatchTagsA(a6)
- lea.l AfterOpenRemFailed(pc),a0
- tst.l d0
- BSRNE TextOutput,MainLoop
- move.l d0,AfterOpenPatch
-
- move.l AfterLockPatch,a0
- lea.l RemoveTags(pc),a1
- jsr _LVORemovePatchTagsA(a6)
- lea.l AfterLockRemFailed(pc),a0
- tst.l d0
- BSRNE TextOutput,MainLoop
- move.l d0,AfterLockPatch
-
-
- move.l execbase,a6
- move.l _PATCHBase,a1
- jsr _LVOCloseLibrary(a6) ;Close patch Library
-
- PatchFailed:
- cmp.l #0,_PATCHBase
- bne PatchFailedSkip
- lea.l ReqPatchLib(pc),a0
- bsr TextOutput
-
- PatchFailedSkip:
- NoOutPutExit:
- move.l execbase,a6
- move.l _DOSBase,a1
- jsr _LVOCloseLibrary(a6) ;Close dos Library
-
- DosFailed:
- rts
- ;----------------------------
- PreLoadSeg:
- movem.l a0,-(sp)
- lea.l LoadSegText(pc),a0
- bsr TextOutputPatch
- move.l d1,a0
- bsr TextOutputPatch
- move.l (sp)+,a0
- rts
- ;------
- AfterLoadSeg:
- AfterOpen:
- AfterLock:
- movem.l a0/d7,-(sp)
- lea.l SuccessfulText(pc),a0
- tst.l d0
- bne.s AfterLoadsegSkip
- lea.l FailedText(pc),a0
- AfterLoadsegSkip:
- bsr GetIOErr
- bsr TextOutputPatch
- lea.l ReturnText(pc),a0
- bsr TextOutputPatch
- bsr SetIOErr
- movem.l (sp)+,a0/d7
- rts
- ;-------
- PreOpen:
- move.l a0,-(sp)
- lea.l OpenText(pc),a0
- bsr TextOutputPatch
- move.l d1,a0
- bsr TextOutputPatch
- move.l (sp)+,a0
- rts
- ;-------
- PreLock:
- move.l a0,-(sp)
- lea.l LockText(pc),a0
- bsr TextOutputPatch
- move.l d1,a0
- bsr TextOutputPatch
- move.l (sp)+,a0
- rts
- ;------------------------------------
- GetIOErr:
- ;a6 = DosBase
- ;Result: d7 = errorcode
- movem.l d0/d1/a0/a1,-(sp)
- CALL _LVOIOErr
- move.l d0,d7
- movem.l (sp)+,d0/d1/a0/a1
- rts
- ;--------------
- SetIOErr:
- ;d7 = old errorcode
- movem.l d0/d1/a0/a1/a6,-(sp)
- sub.l a1,a1
- CALL _LVOFindTask,execbase
- move.l d0,a0
- move.l d7,pr_Result2(a0)
- move.l pr_CLI(a0),d0
- beq SetIOExit
- lsl.l #2,d0
- move.l d0,a0
- move.l d7,cli_Result2(a0)
-
- SetIOExit:
- movem.l (sp)+,d0/d1/a0/a1/a6
- rts
- ******************************************************************V1.3*
- * Name: TextOutputPatch
- * Function: Writes a C-string to std output (CLI,PRT,...)
- * Version: V1.2b (works)
- * Assembler: OMA V2.00
- * Copyright: 1991 Stefan Fuchs
- *
- * Inputs: a0 = Pointer to a C-string
- * a6 = DosBase
- * Assumptions: DosBase
- * Results:
- * Destroyed registers:
- * Code: pc-relative
- * Known bugs:
- * See also:
- * Notes: Exits without any output, a0 is null
- * SPECIAL VERSION FOR SHOWNEEDEDFILES
- ***********************************************************************
- TextOutputPatch:
- movem.l d0-d3/a0/a1,-(sp)
- moveq.l #50,d0
- moveq.l #0,d3
- move.l a0,d2
- beq.s TextOutputPatchExit
- TextOutputPatchLoop:
- addq.l #1,d3
- tst.b (a0)+
- dbeq d0,TextOutputPatchLoop
- move.l OutPutHandle,d1
- jsr -48(a6) ;Write
- TextOutputPatchExit:
- movem.l (sp)+,d0-d3/a0/a1
- rts
- ******************************************************************V1.3*
- * Name: TextOutput
- * Function: Writes a C-string to std output (CLI,PRT,...)
- * Version: V1.2 (works)
- * Assembler: OMA V2.00
- * Copyright: 1991 Stefan Fuchs
- *
- * Inputs: a0 = Pointer to a C-string
- * Assumptions: DosBase
- * Results:
- * Destroyed registers:
- * Code: pc-relative
- * Known bugs:
- * See also:
- * Notes: Exits without any output,
- * if the Outputhandle or a0 is null
- ***********************************************************************
- TextOutput:
- movem.l d0-d3/a0/a1/a6,-(sp)
- moveq.l #0,d3
- move.l a0,d2
- beq.s TextOutputExit
- TextOutputLoop:
- addq.l #1,d3
- tst.b (a0)+
- bne.S TextOutputLoop
- move.l _DOSBase,a6
- jsr -60(a6) ;OutPut
- move.l d0,d1
- beq.s TextOutputExit
- jsr -48(a6) ;Write
- TextOutputExit:
- movem.l (sp)+,d0-d3/a0/a1/a6
- rts
- ;--------------------------------------
- OutPutHandle: dc.l 0
- PreLoadSegPatch: dc.l 0
- PreOpenPatch: dc.l 0
- PreLockPatch: dc.l 0
- AfterLoadSegPatch: dc.l 0
- AfterOpenPatch: dc.l 0
- AfterLockPatch: dc.l 0
-
- DosName: dc.b "dos.library",0
- PatchName: dc.b "patch.library",0
- PreLoadSegFailed: dc.b "Can't install 1. LoadSeg() patch",10,0
- PreOpenFailed: dc.b "Can't install 1. Open() patch",10,0
- PreLockFailed: dc.b "Can't install 1. Lock() patch",10,0
- AfterLoadSegFailed: dc.b "Can't install 2. LoadSeg() patch",10,0
- AfterOpenFailed: dc.b "Can't install 2. Open() patch",10,0
- AfterLockFailed: dc.b "Can't install 2. Lock() patch",10,0
- PreLoadSegRemFailed: dc.b "Can't remove 1. LoadSeg() patch - CTRL-C to retry",10,0
- PreOpenRemFailed: dc.b "Can't remove 1. Open() patch - CTRL-C to retry",10,0
- PreLockRemFailed: dc.b "Can't remove 1. Lock() patch - CTRL-C to retry",10,0
- AfterLoadSegRemFailed: dc.b "Can't remove 2. LoadSeg() patch - CTRL-C to retry",10,0
- AfterOpenRemFailed: dc.b "Can't remove 2. Open() patch - CTRL-C to retry",10,0
- AfterLockRemFailed: dc.b "Can't remove 2. Lock() patch - CTRL-C to retry",10,0
- ReturnText: dc.b 10,0
- FailedText: dc.b " FAILED",0
- SuccessfulText: dc.b " OK",0
- LoadSegText: dc.b "Loadseg : ",0
- OpenText: dc.b "Open : ",0
- LockText: dc.b "Lock : ",0
-
- even
-
- InstallTags: dc.l PATT_LibraryBase,0
- dc.l PATT_PatchName,0
- dc.l PATT_Priority,0
- dc.l 0
- RemoveTags: dc.l PATT_TimeOut,50
- dc.l 0
-
- dosname dc.b "dos.library",0
- patchname dc.b "patch.library",0
- Header dc.b $9B,"1;33",$6D
- dc.b "$VER: SNF - Show Needed Files"
- dc.b " "
- REVISION
- dc.b " ("
- REVDATE
- dc.b ")"
- dc.b $9B,$6D
- dc.b " by Stefan Fuchs",10,0
- ReqPatchLib: dc.b "*** Requires patch.library V2+ in libs:",10,0
- IDString: dc.b "SNF",0
-
- END
-