home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 6 / Sonderheft_6-96.iso / pd / libraries / patchlibv4 / examples / snf / snf.asm < prev   
Assembly Source File  |  1996-11-03  |  7KB  |  328 lines

  1. ;1993/95 Copyright by Stefan Fuchs
  2. ;SNF is Freeware
  3.  
  4.     incdir Include:
  5.     include "ASMMacros.i"
  6.     include dos/dosextens.i
  7.     include "patchtags.i"
  8.  
  9. execbase    equ    4
  10. _DOSBase        equr    A5
  11. _PATCHBase      equr    A4
  12.  
  13. _LVOOpenLibrary        equ    -552    ;exec.library
  14. _LVOCloseLibrary    equ    -414
  15. _LVOWait        equ    -318
  16. _LVOFindTask        equ    -294
  17.  
  18. _LVOLoadSeg        equ    -150    ;dos.library
  19. _LVOOpen        equ    -30
  20. _LVOOutPut        equ    -60
  21. _LVOLock        equ    -84
  22. _LVOIOErr        equ    -132
  23.  
  24. _LVOInstallPatchTagsA    equ    -54    ;patch.library
  25. _LVORemovePatchProjectA    equ    -90
  26. _LVOCreatePatchProjectA    equ    -96
  27.  
  28.  
  29. Main:
  30.     sub.l    _DOSBase,_DOSBase
  31.     sub.l    _PATCHBase,_PATCHBase
  32.  
  33.     lea.l    dosname(pc),a1        ;Open Dos Library
  34.     moveq.l    #0,d0
  35.     CALL    _LVOOpenLibrary,execbase
  36.     tst.l    d0
  37.     beq    DosFailed
  38.     move.l    d0,_DOSBase
  39.  
  40.     CALL    _LVOOutPut,d0
  41.     move.l    d0,OutPutHandle
  42.     beq    NoOutPutExit
  43.  
  44.  
  45.     lea.l    Header(pc),a0        ;Print Title Text
  46.     bsr    TextOutput
  47.  
  48.     lea.l    patchname(pc),a1    ;Open Patch Library Version 4
  49.     moveq.l    #4,d0
  50.     CALL    _LVOOpenLibrary,execbase
  51.     tst.l    d0
  52.     beq    PatchFailed
  53.     move.l    d0,_PATCHBase
  54.  
  55.  
  56.     lea.l ProjectName(pc),a0
  57.     sub.l a1,a1
  58.     CALL _LVOCreatePatchProjectA,_PATCHBase
  59.     tst.l d0
  60.     beq ProjectFailed
  61.     move.l d0,a3
  62.  
  63.     lea.l    InstallTags(pc),a1
  64.     move.l    _DOSBase,4(a1)        ;Pointer to Library
  65.     lea.l    IDString(pc),a0        ;ID for PatchList
  66.     move.l    a0,12(a1)
  67.     move.l    #5,20(a1)        ;Priority 5: before original
  68.     move.l  d0,28(a1)        ;ProjectID
  69.  
  70.  
  71.     lea.l    PreLoadSeg(pc),a0
  72.     move.l    #_LVOLoadSeg,d0
  73.     CALL    _LVOInstallPatchTagsA
  74.     lea.l    PreLoadSegFailed(pc),a0
  75.     tst.l    d0
  76.     BSREQ    TextOutput
  77.  
  78.     lea.l    InstallTags(pc),a1
  79.     lea.l    PreOpen(pc),a0
  80.     move.l    #_LVOOpen,d0
  81.     CALL    _LVOInstallPatchTagsA
  82.     lea.l    PreOpenFailed(pc),a0
  83.     tst.l    d0
  84.     BSREQ TextOutput
  85.  
  86.     lea.l    InstallTags(pc),a1
  87.     lea.l    PreLock(pc),a0
  88.     move.l    #_LVOLock,d0
  89.     CALL    _LVOInstallPatchTagsA
  90.     lea.l    PreLockFailed(pc),a0
  91.     tst.l    d0
  92.     BSREQ TextOutput
  93.  
  94.     lea.l    InstallTags(pc),a1
  95.     move.l    #-5,20(a1)        ;Priority -5: after original
  96.     lea.l    AfterLoadSeg(pc),a0
  97.     move.l    #_LVOLoadSeg,d0
  98.     CALL    _LVOInstallPatchTagsA
  99.     lea.l    AfterLoadSegFailed(pc),a0
  100.     tst.l    d0
  101.     BSREQ TextOutput
  102.  
  103.     lea.l    InstallTags(pc),a1
  104.     lea.l    AfterOpen(pc),a0
  105.     move.l    #_LVOOpen,d0
  106.     CALL    _LVOInstallPatchTagsA
  107.     lea.l    AfterOpenFailed(pc),a0
  108.     tst.l    d0
  109.     BSREQ TextOutput
  110.  
  111.     lea.l    InstallTags(pc),a1
  112.     lea.l    AfterLock(pc),a0
  113.     move.l    #_LVOLock,d0
  114.     CALL    _LVOInstallPatchTagsA
  115.     lea.l    AfterLockFailed(pc),a0
  116.     tst.l    d0
  117.     BSREQ TextOutput
  118.  
  119.  
  120. MainLoop:
  121.     moveq.l #0,d0
  122.     bset.l #12,d0
  123.     CALL _LVOWait,execbase
  124.  
  125.  
  126.     move.l    _PATCHBase,a6
  127.  
  128.     move.l    a3,a0
  129.     lea.l    RemoveTags(pc),a1
  130.     CALL    _LVORemovePatchProjectA,_PATCHBase
  131.     lea.l    RemFailed(pc),a0
  132.     tst.l    d0
  133.     BSRNE    TextOutput,MainLoop
  134.  
  135. ProjectFailed:
  136.     move.l    _PATCHBase,a1
  137.     CALL    _LVOCloseLibrary,execbase    ;Close patch Library
  138.  
  139. PatchFailed:
  140.     cmp.l    #0,_PATCHBase
  141.     bne    PatchFailedSkip
  142.     lea.l    ReqPatchLib(pc),a0
  143.     bsr    TextOutput
  144.  
  145. PatchFailedSkip:
  146. NoOutPutExit:
  147.     move.l    _DOSBase,a1
  148.     CALL    _LVOCloseLibrary,execbase    ;Close dos Library
  149.  
  150. DosFailed:
  151.     rts
  152. ;----------------------------
  153. PreLoadSeg:
  154.     movem.l a0,-(sp)
  155.     lea.l LoadSegText(pc),a0
  156.     bsr TextOutputPatch
  157.     move.l d1,a0
  158.     bsr TextOutputPatch
  159.     move.l (sp)+,a0
  160.     rts
  161. ;------
  162. AfterLoadSeg:
  163. AfterOpen:
  164. AfterLock:
  165.     movem.l a0/d7,-(sp)
  166.     lea.l SuccessfulText(pc),a0
  167.     tst.l d0
  168.     bne.s AfterLoadsegSkip
  169.     lea.l FailedText(pc),a0
  170. AfterLoadsegSkip:
  171.     bsr GetIOErr
  172.     bsr TextOutputPatch
  173.     lea.l ReturnText(pc),a0
  174.     bsr TextOutputPatch
  175.     bsr SetIOErr
  176.     movem.l (sp)+,a0/d7
  177.     rts
  178. ;-------
  179. PreOpen:
  180.     move.l a0,-(sp)
  181.     lea.l OpenText(pc),a0
  182.     bsr TextOutputPatch
  183.     move.l d1,a0
  184.     bsr TextOutputPatch
  185.     move.l (sp)+,a0
  186.     rts
  187. ;-------
  188. PreLock:
  189.     move.l a0,-(sp)
  190.     lea.l LockText(pc),a0
  191.     bsr TextOutputPatch
  192.     move.l d1,a0
  193.     bsr TextOutputPatch
  194.     move.l (sp)+,a0
  195.     rts
  196. ;------------------------------------
  197. GetIOErr:
  198. ;a6 = DosBase
  199. ;Result: d7 = errorcode
  200.     movem.l d0/d1/a0/a1,-(sp)
  201.     CALL _LVOIOErr
  202.     move.l d0,d7
  203.     movem.l (sp)+,d0/d1/a0/a1
  204.     rts
  205. ;--------------
  206. SetIOErr:
  207. ;d7 = old errorcode
  208.     movem.l d0/d1/a0/a1/a6,-(sp)
  209.     sub.l a1,a1
  210.     CALL _LVOFindTask,execbase
  211.     move.l d0,a0
  212.     move.l d7,pr_Result2(a0)
  213.     move.l pr_CLI(a0),d0
  214.     beq SetIOExit
  215.     lsl.l #2,d0
  216.     move.l d0,a0
  217.     move.l d7,cli_Result2(a0)
  218.  
  219. SetIOExit:
  220.     movem.l (sp)+,d0/d1/a0/a1/a6
  221.     rts
  222. ******************************************************************V1.3*
  223. * Name:        TextOutputPatch
  224. * Function:    Writes a C-string to std output (CLI,PRT,...)
  225. * Version:    V1.2b    (works)
  226. * Assembler:    MasterSeka V1.75 & OMA V1.81
  227. * Copyright:    1991 Unicorn
  228. *
  229. * Inputs:    a0 = Pointer to a C-string
  230. *        a6 = DosBase
  231. * Assumptions:    DosBase
  232. * Results:
  233. * Destroyed registers:
  234. * Code:        pc-relative
  235. * Known bugs:
  236. * See also:
  237. * Notes:    Exits without any output, a0 is null
  238. *        SPECIAL VERSION FOR SHOWNEEDEDFILES
  239. ***********************************************************************
  240. TextOutputPatch:
  241.     movem.l d0-d3/a0/a1,-(sp)
  242.     moveq.l #50,d0
  243.     moveq.l #0,d3
  244.     move.l a0,d2
  245.     beq.s TextOutputPatchExit
  246. TextOutputPatchLoop:
  247.     addq.l #1,d3
  248.     tst.b (a0)+
  249.     dbeq d0,TextOutputPatchLoop
  250.     move.l OutPutHandle,d1
  251.     jsr -48(a6)    ;Write
  252. TextOutputPatchExit:
  253.     movem.l (sp)+,d0-d3/a0/a1
  254.     rts
  255. ******************************************************************V1.3*
  256. * Name:        TextOutput
  257. * Function:    Writes a C-string to std output (CLI,PRT,...)
  258. * Version:    V1.2    (works)
  259. * Assembler:    MasterSeka V1.75 & OMA V1.81
  260. * Copyright:    1991 Stefan Fuchs
  261. *
  262. * Inputs:    a0 = Pointer to a C-string
  263. * Assumptions:    DosBase
  264. * Results:    
  265. * Destroyed registers:
  266. * Code:        pc-relative
  267. * Known bugs:    
  268. * See also:    
  269. * Notes:    Exits without any output,
  270. *        if the Outputhandle or a0 is null
  271. ***********************************************************************
  272. TextOutput:
  273.     movem.l d0-d3/a0/a1/a6,-(sp)
  274.     moveq.l #0,d3
  275.     move.l a0,d2
  276.     beq.s TextOutputExit
  277. TextOutputLoop:
  278.     addq.l #1,d3
  279.     tst.b (a0)+
  280.     bne.S TextOutputLoop
  281.     move.l _DOSBase,a6
  282.     jsr -60(a6)    ;OutPut
  283.     move.l d0,d1
  284.     beq.s TextOutputExit
  285.     jsr -48(a6)    ;Write
  286. TextOutputExit:
  287.     movem.l (sp)+,d0-d3/a0/a1/a6
  288.     rts
  289. ;--------------------------------------
  290. OutPutHandle:        dc.l 0
  291.  
  292. PreLoadSegFailed:    dc.b "Can't install 1. LoadSeg() patch",10,0
  293. PreOpenFailed:        dc.b "Can't install 1. Open() patch",10,0
  294. PreLockFailed:        dc.b "Can't install 1. Lock() patch",10,0
  295. AfterLoadSegFailed:    dc.b "Can't install 2. LoadSeg() patch",10,0
  296. AfterOpenFailed:    dc.b "Can't install 2. Open() patch",10,0
  297. AfterLockFailed:    dc.b "Can't install 2. Lock() patch",10,0
  298. RemFailed:        dc.b "Can't remove patches - CTRL-C to retry",10,0
  299. ReturnText:    dc.b 10,0
  300. FailedText:    dc.b "        FAILED",0
  301. SuccessfulText:    dc.b "        OK",0
  302. LoadSegText:    dc.b "Loadseg    : ",0
  303. OpenText:    dc.b "Open       : ",0
  304. LockText:    dc.b "Lock       : ",0
  305.  
  306.     even
  307.  
  308. InstallTags:    dc.l PATT_LibraryBase,0
  309.         dc.l PATT_PatchName,0
  310.         dc.l PATT_Priority,0
  311.         dc.l PATT_ProjectID,0
  312.         dc.l 0
  313. RemoveTags:    dc.l PATT_TimeOut,50
  314.         dc.l 0
  315.  
  316.         dc.b "$VER: ShowNeededFiles 2.0 (05.11.95)",0
  317. dosname:    dc.b "dos.library",0
  318. patchname:    dc.b "patch.library",0
  319. Header:        dc.b $9B,"1;33",$6D
  320.         dc.b "SNF - Show Needed Files V2.0"
  321.         dc.b $9B,$6D
  322.         dc.b " by Stefan Fuchs",10,0
  323. ReqPatchLib:    dc.b "*** Requires patch.library V4+ in libs:",10,0
  324. IDString:    dc.b "SNF",0
  325. ProjectName:    dc.b "ShowNeededFiles",0
  326.  
  327.                 END
  328.