home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus Special 6
/
Sonderheft_6-96.iso
/
pd
/
libraries
/
patchlibv4
/
examples
/
snf
/
snf.asm
< prev
Wrap
Assembly Source File
|
1996-11-03
|
7KB
|
328 lines
;1993/95 Copyright by Stefan Fuchs
;SNF is Freeware
incdir Include:
include "ASMMacros.i"
include dos/dosextens.i
include "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
_LVORemovePatchProjectA equ -90
_LVOCreatePatchProjectA equ -96
Main:
sub.l _DOSBase,_DOSBase
sub.l _PATCHBase,_PATCHBase
lea.l dosname(pc),a1 ;Open Dos Library
moveq.l #0,d0
CALL _LVOOpenLibrary,execbase
tst.l d0
beq DosFailed
move.l d0,_DOSBase
CALL _LVOOutPut,d0
move.l d0,OutPutHandle
beq NoOutPutExit
lea.l Header(pc),a0 ;Print Title Text
bsr TextOutput
lea.l patchname(pc),a1 ;Open Patch Library Version 4
moveq.l #4,d0
CALL _LVOOpenLibrary,execbase
tst.l d0
beq PatchFailed
move.l d0,_PATCHBase
lea.l ProjectName(pc),a0
sub.l a1,a1
CALL _LVOCreatePatchProjectA,_PATCHBase
tst.l d0
beq ProjectFailed
move.l d0,a3
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
move.l d0,28(a1) ;ProjectID
lea.l PreLoadSeg(pc),a0
move.l #_LVOLoadSeg,d0
CALL _LVOInstallPatchTagsA
lea.l PreLoadSegFailed(pc),a0
tst.l d0
BSREQ TextOutput
lea.l InstallTags(pc),a1
lea.l PreOpen(pc),a0
move.l #_LVOOpen,d0
CALL _LVOInstallPatchTagsA
lea.l PreOpenFailed(pc),a0
tst.l d0
BSREQ TextOutput
lea.l InstallTags(pc),a1
lea.l PreLock(pc),a0
move.l #_LVOLock,d0
CALL _LVOInstallPatchTagsA
lea.l PreLockFailed(pc),a0
tst.l d0
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
CALL _LVOInstallPatchTagsA
lea.l AfterLoadSegFailed(pc),a0
tst.l d0
BSREQ TextOutput
lea.l InstallTags(pc),a1
lea.l AfterOpen(pc),a0
move.l #_LVOOpen,d0
CALL _LVOInstallPatchTagsA
lea.l AfterOpenFailed(pc),a0
tst.l d0
BSREQ TextOutput
lea.l InstallTags(pc),a1
lea.l AfterLock(pc),a0
move.l #_LVOLock,d0
CALL _LVOInstallPatchTagsA
lea.l AfterLockFailed(pc),a0
tst.l d0
BSREQ TextOutput
MainLoop:
moveq.l #0,d0
bset.l #12,d0
CALL _LVOWait,execbase
move.l _PATCHBase,a6
move.l a3,a0
lea.l RemoveTags(pc),a1
CALL _LVORemovePatchProjectA,_PATCHBase
lea.l RemFailed(pc),a0
tst.l d0
BSRNE TextOutput,MainLoop
ProjectFailed:
move.l _PATCHBase,a1
CALL _LVOCloseLibrary,execbase ;Close patch Library
PatchFailed:
cmp.l #0,_PATCHBase
bne PatchFailedSkip
lea.l ReqPatchLib(pc),a0
bsr TextOutput
PatchFailedSkip:
NoOutPutExit:
move.l _DOSBase,a1
CALL _LVOCloseLibrary,execbase ;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: MasterSeka V1.75 & OMA V1.81
* Copyright: 1991 Unicorn
*
* 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: MasterSeka V1.75 & OMA V1.81
* 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
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
RemFailed: dc.b "Can't remove patches - 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 PATT_ProjectID,0
dc.l 0
RemoveTags: dc.l PATT_TimeOut,50
dc.l 0
dc.b "$VER: ShowNeededFiles 2.0 (05.11.95)",0
dosname: dc.b "dos.library",0
patchname: dc.b "patch.library",0
Header: dc.b $9B,"1;33",$6D
dc.b "SNF - Show Needed Files V2.0"
dc.b $9B,$6D
dc.b " by Stefan Fuchs",10,0
ReqPatchLib: dc.b "*** Requires patch.library V4+ in libs:",10,0
IDString: dc.b "SNF",0
ProjectName: dc.b "ShowNeededFiles",0
END