home *** CD-ROM | disk | FTP | other *** search
/ World of A1200 / World_Of_A1200.iso / programs / develop / gadtoolsbox / nofraglib / source / library.s next >
Text File  |  1995-02-27  |  5KB  |  179 lines

  1.         opt     l+,o+,ow-,inconce
  2.  
  3. *-- AutoRev header do NOT edit!
  4. *
  5. *   Program         :   library.s
  6. *   Copyright       :   © Copyright 1991-92 Jaba Development
  7. *   Author          :   Jan van den Baard
  8. *   Creation Date   :   06-Apr-91
  9. *   Current version :   2.2
  10. *   Translator      :   Devpac version 3.01
  11. *
  12. *   REVISION HISTORY
  13. *
  14. *   Date          Version         Comment
  15. *   ---------     -------         ------------------------------------------
  16. *   12-Apr-92     2.2             Hopefully enforcer and mungwall free.
  17. *   19-May-91     2.1             Added 'Vec' routines.
  18. *   06-Apr-91     1.1             Initial version!
  19. *
  20. *-- REV_END --*
  21.  
  22.         incdir      'sys:Asm20/'
  23.         include     'exec/types.i'
  24.         include     'exec/initializers.i'
  25.         include     'exec/alerts.i'
  26.         include     'exec/io.i'
  27.         include     'exec/libraries.i'
  28.         include     'exec/resident.i'
  29.         include     'exec/strings.i'
  30.         include     'exec/exec_lib.i'
  31.         include     'dos/dos.i'
  32.         include     'dos/dos_lib.i'
  33.         include     'mymacros.i'
  34.  
  35.         STRUCTURE   NoFragBase,LIB_SIZE
  36.         LABEL       nfb_SIZEOF
  37.  
  38. VERSION             EQU     2
  39. REVISION            EQU     2
  40.  
  41. _SysBase            EQU     $0004
  42.  
  43.         xref        GetMemoryChain
  44.         xref        AllocItem
  45.         xref        FreeItem
  46.         xref        FreeMemoryChain
  47.  
  48.         xref        AllocVecItem
  49.         xref        FreeVecItem
  50.  
  51.         SECTION     "LIB_SKELL",CODE
  52.  
  53.         lea         dosname(pc),a1
  54.         cldat       d0
  55.         move.l      (_SysBase).w,a6
  56.         libcall     OpenLibrary
  57.         move.l      d0,a6
  58.         tst.l       d0
  59.         beq.s       nolib
  60.         libcall     Output
  61.         move.l      d0,d1
  62.         beq.s       noout
  63.         move.l      #idString,d2
  64.         move.l      idSize,d3
  65.         libcall     Write
  66. noout:  move.l      a6,a1
  67.         move.l      (_SysBase).w,a6
  68.         libcall     CloseLibrary
  69. nolib:  moveq       #RETURN_FAIL,d0
  70.         rts
  71.  
  72. ROMTag:
  73.         dc.w        RTC_MATCHWORD
  74.         dc.l        ROMTag
  75.         dc.l        EndCode
  76.         dc.b        RTF_AUTOINIT
  77.         dc.b        VERSION
  78.         dc.b        NT_LIBRARY
  79.         dc.b        0
  80.         dc.l        libraryName
  81.         dc.l        idString
  82.         dc.l        Init
  83.  
  84. libraryName:
  85.         dc.b        'nofrag.library',0
  86.         even
  87. idString:
  88.         dc.b        ' NOFRAG_LIB 2.2 (12.4.92)',CR,LF
  89.         dc.b        ' © Copyright 1991-92 Jaba Development.',CR,LF
  90.         dc.b        ' Written with the Devpac Assembler'
  91.         dc.b        ' version 3.01 by Jan van den Baard.',CR,LF,CR,LF,0
  92. idEnd:  even
  93. idSize: dc.l        (idEnd-idString-1)
  94. dosname:
  95.         dc.b        'dos.library',0
  96.         even
  97.  
  98. Init:
  99.         dc.l        nfb_SIZEOF
  100.         dc.l        funcTable
  101.         dc.l        dataTable
  102.         dc.l        InitLib
  103.  
  104. funcTable:
  105.         dc.l        OpenLib
  106.         dc.l        CloseLib
  107.         dc.l        ExpungeLib
  108.         dc.l        ExtFuncLib
  109.  
  110.         dc.l        GetMemoryChain
  111.         dc.l        AllocItem
  112.         dc.l        FreeItem
  113.         dc.l        FreeMemoryChain
  114.  
  115.         dc.l        AllocVecItem
  116.         dc.l        FreeVecItem
  117.  
  118.         dc.l        -1
  119.  
  120. dataTable:
  121.         INITBYTE    LH_TYPE,NT_LIBRARY
  122.         INITLONG    LN_NAME,libraryName
  123.         INITBYTE    LIB_FLAGS,LIBF_SUMUSED!LIBF_CHANGED
  124.         INITWORD    LIB_VERSION,VERSION
  125.         INITWORD    LIB_REVISION,REVISION
  126.         INITLONG    LIB_IDSTRING,idString
  127.         dc.l        0
  128.  
  129. InitLib:
  130.         move.l      a0,_SegList
  131. Done:   rts
  132.  
  133. OpenLib:
  134.         inc.w       LIB_OPENCNT(a6)
  135.         bclr        #LIBB_DELEXP,LIB_FLAGS(a6)
  136.         move.l      a6,d0
  137.         rts
  138.  
  139. CloseLib:
  140.         cldat       d0
  141.         dec.w       LIB_OPENCNT(a6)
  142.         bne.s       ret
  143.         btst        #LIBB_DELEXP,LIB_FLAGS(a6)
  144.         beq.s       ret
  145.         bsr.s       ExpungeLib
  146. ret:    rts
  147.  
  148. ExpungeLib:
  149.         movem.l     d2/a5/a6,-(sp)
  150.         tst.w       LIB_OPENCNT(a6)
  151.         beq.s       NDLex
  152.         bset        #LIBB_DELEXP,LIB_FLAGS(a6)
  153.         cldat       d0
  154.         bra.s       DLex
  155. NDLex:  move.l      a6,a5
  156.         move.l      (_SysBase).w,a6
  157.         move.l      a5,a1
  158.         libcall     Remove
  159.         move.l      _SegList,d2
  160.         movea.l     a5,a1
  161.         cldat       d0
  162.         move.w      LIB_NEGSIZE(a5),d0
  163.         suba.l      d0,a1
  164.         add.w       LIB_POSSIZE(a5),d0
  165.         libcall     FreeMem
  166.         move.l      d2,d0
  167. DLex:   movem.l     (sp)+,d2/a5/a6
  168.         rts
  169.  
  170. ExtFuncLib:
  171.         cldat       d0
  172.         rts
  173.  
  174. _SegList:
  175.         dc.l        0
  176.  
  177. EndCode:
  178.         end
  179.