home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 514b.lha / ToolLib_v8.1 / Source / library.s < prev    next >
Text File  |  1991-06-08  |  7KB  |  311 lines

  1.         opt     l+,o+,ow-
  2. *
  3. *   library.s version 8.1 - © Copyright 1990 Jaba Development
  4. *
  5. *   Author    : Jan van den Baard
  6. *   Assembler : Devpac version 2.14
  7. *
  8.         incdir  'sys:devpac_inc/'
  9.         include 'exec/types.i'
  10.         include 'exec/initializers.i'
  11.         include 'exec/alerts.i'
  12.         include 'exec/io.i'
  13.         include 'exec/libraries.i'
  14.         include 'exec/resident.i'
  15.         include 'exec/strings.i'
  16.         include 'exec/exec_lib.i'
  17.         include 'libraries/dos.i'
  18.         include 'libraries/dos_lib.i'
  19.         include 'mymacros.i'
  20.  
  21.         STRUCTURE   ToolBase,LIB_SIZE
  22.         APTR        tb_SysBase
  23.         APTR        tb_DOSBase
  24.         APTR        tb_IntuitionBase
  25.         APTR        tb_GfxBase
  26.         ULONG       tb_SegList
  27.         LABEL       tb_SIZEOF
  28.  
  29. VERSION     EQU     8
  30. REVISION    EQU     1
  31.  
  32.         xref    CreatePort
  33.         xref    DeletePort
  34.         xref    CreateExtIO
  35.         xref    DeleteExtIO
  36.         xref    CreateStdIO
  37.         xref    DeleteStdIO
  38.         xref    CreateTimeDelay
  39.         xref    DoTimeDelay
  40.         xref    DeleteTimeDelay
  41.  
  42.         xref    QuickSort
  43.         xref    SwapMem
  44.  
  45.         xref    TestBits
  46.         xref    SelectGadget
  47.         xref    DeSelectGadget
  48.         xref    MutualExclude
  49.         xref    MutualInclude
  50.         xref    EraseGadget
  51.         xref    GadgetOn
  52.         xref    GadgetOff
  53.         xref    SelectTest
  54.         xref    ShadowGadget
  55.         xref    OnGList
  56.         xref    OffGList
  57.         xref    SelectGList
  58.         xref    DeSelectGList
  59.         xref    ShadowGList
  60.         xref    EraseGList
  61.  
  62.         xref    InitMemoryChain
  63.         xref    AllocItem
  64.         xref    FreeItem
  65.         xref    FreeMemoryChain
  66.  
  67.         xref    Format
  68.         xref    WriteFormat
  69.         xref    MatchPattern
  70.         xref    Isolate
  71.         xref    BstrToCstr
  72.         xref    GetDate
  73.  
  74.         xref    OpenDir
  75.         xref    GetEntry
  76.         xref    CloseDir
  77.         xref    FreeDir
  78.         xref    IoErrToStr
  79.  
  80.         xref    AllocFreq
  81.         xref    FreeFreq
  82.         xref    FileRequest
  83.  
  84.         xref    FormatText
  85.  
  86.         xdef    _DOSBase
  87.         xdef    _IntuitionBase
  88.         xdef    _GfxBase
  89.  
  90.         SECTION  "LIB_SKELL",CODE
  91.  
  92.         lea     dosname(pc),a1
  93.         cldat   d0
  94.         move.l  (_SysBase).w,a6
  95.         libcall OpenLibrary
  96.         tst.l   d0
  97.         beq.s   nolib
  98.         move.l  d0,a6
  99.         libcall Output
  100.         move.l  d0,d1
  101.         move.l  #idString,d2
  102.         move.l  idSize,d3
  103.         libcall Write
  104.         move.l  a6,a1
  105.         move.l  (_SysBase).w,a6
  106.         libcall CloseLibrary
  107. nolib:  moveq   #RETURN_FAIL,d0
  108.         rts
  109.  
  110. ROMTag:
  111.         dc.w    RTC_MATCHWORD
  112.         dc.l    ROMTag
  113.         dc.l    EndCode
  114.         dc.b    RTF_AUTOINIT
  115.         dc.b    VERSION
  116.         dc.b    NT_LIBRARY
  117.         dc.b    0
  118.         dc.l    libraryName
  119.         dc.l    idString
  120.         dc.l    Init
  121. EndCode:
  122.         dc.w    0
  123.  
  124. libraryName:
  125.         dc.b    'tool.library',0
  126.         even
  127. idString:
  128.         dc.b    CR,LF,' tool.library 8.1 (20-Jan-1991) © Copyright 1990-91 Jaba Development.',CR,LF
  129.         dc.b    ' Written with the Devpac Assembler version 2.14 by Jan van den Baard.',CR,LF,CR,LF,0
  130. idEnd:  even
  131. idSize: dc.l    (idEnd-idString-1)
  132. dosname:
  133.         dc.b    'dos.library',0
  134.         even
  135. intname:
  136.         dc.b    'intuition.library',0
  137.         even
  138. graname:
  139.         dc.b    'graphics.library',0
  140.         even
  141. Init:
  142.         dc.l    tb_SIZEOF
  143.         dc.l    funcTable
  144.         dc.l    dataTable
  145.         dc.l    InitLib
  146.  
  147. funcTable:
  148.         dc.l    OpenLib
  149.         dc.l    CloseLib
  150.         dc.l    ExpungeLib
  151.         dc.l    ExtFuncLib
  152.  
  153.         dc.l    CreatePort
  154.         dc.l    DeletePort
  155.         dc.l    CreateExtIO
  156.         dc.l    DeleteExtIO
  157.         dc.l    CreateStdIO
  158.         dc.l    DeleteStdIO
  159.         dc.l    CreateTimeDelay
  160.         dc.l    DoTimeDelay
  161.         dc.l    DeleteTimeDelay
  162.  
  163.         dc.l    QuickSort
  164.         dc.l    SwapMem
  165.  
  166.         dc.l    TestBits
  167.         dc.l    SelectGadget
  168.         dc.l    DeSelectGadget
  169.         dc.l    MutualExclude
  170.         dc.l    MutualInclude
  171.         dc.l    EraseGadget
  172.         dc.l    GadgetOn
  173.         dc.l    GadgetOff
  174.         dc.l    SelectTest
  175.         dc.l    ShadowGadget
  176.         dc.l    OnGList
  177.         dc.l    OffGList
  178.         dc.l    SelectGList
  179.         dc.l    DeSelectGList
  180.         dc.l    ShadowGList
  181.         dc.l    EraseGList
  182.  
  183.         dc.l    InitMemoryChain
  184.         dc.l    AllocItem
  185.         dc.l    FreeItem
  186.         dc.l    FreeMemoryChain
  187.  
  188.         dc.l    Format
  189.         dc.l    WriteFormat
  190.         dc.l    MatchPattern
  191.         dc.l    Isolate
  192.         dc.l    BstrToCstr
  193.         dc.l    GetDate
  194.  
  195.         dc.l    OpenDir
  196.         dc.l    GetEntry
  197.         dc.l    CloseDir
  198.         dc.l    FreeDir
  199.         dc.l    IoErrToStr
  200.  
  201.         dc.l    AllocFreq
  202.         dc.l    FreeFreq
  203.         dc.l    FileRequest
  204.  
  205.         dc.l    FormatText
  206.  
  207.         dc.l    -1
  208.  
  209. dataTable:
  210.         INITBYTE LH_TYPE,NT_LIBRARY
  211.         INITLONG LN_NAME,libraryName
  212.         INITBYTE LIB_FLAGS,LIBF_SUMUSED!LIBF_CHANGED
  213.         INITWORD LIB_VERSION,VERSION
  214.         INITWORD LIB_REVISION,REVISION
  215.         INITLONG LIB_IDSTRING,idString
  216.         dc.l     0
  217.  
  218. InitLib
  219.         move.l  a5,-(sp)
  220.         movea.l d0,a5
  221.         move.l  a0,tb_SegList(a5)
  222.         move.l  a6,tb_SysBase(a5)
  223.         lea     dosname(pc),a1
  224.         cldat   d0
  225.         libcall OpenLibrary
  226.         move.l  d0,_DOSBase
  227.         move.l  d0,tb_DOSBase(a5)
  228.         beq.s   NoDOS
  229.         lea     intname(pc),a1
  230.         cldat   d0
  231.         libcall OpenLibrary
  232.         move.l  d0,_IntuitionBase
  233.         move.l  d0,tb_IntuitionBase(a5)
  234.         beq.s   NoINT
  235.         lea     graname(pc),a1
  236.         cldat   d0
  237.         libcall OpenLibrary
  238.         move.l  d0,_GfxBase
  239.         move.l  d0,tb_GfxBase(a5)
  240.         beq.s   NoGFX
  241.         move.l  a5,d0
  242.         bra.s   Done
  243. NoDOS:  ALERT   AG_OpenLib!AN_DOSLib
  244.         bra.s   Error
  245. NoINT:  move.l  tb_DOSBase(a5),a1
  246.         libcall CloseLibrary
  247.         ALERT   AG_OpenLib!AN_Intuition
  248.         bra.s   Error
  249. NoGFX:  move.l  tb_DOSBase(a5),a1
  250.         libcall CloseLibrary
  251.         move.l  tb_IntuitionBase(a5),a1
  252.         libcall CloseLibrary
  253.         ALERT   AG_OpenLib!AN_GraphicsLib
  254. Error:  cldat   d0
  255. Done:   movea.l (sp)+,a5
  256.         rts
  257.  
  258. OpenLib:
  259.         inc.w   LIB_OPENCNT(a6)
  260.         bclr    #LIBB_DELEXP,LIB_FLAGS(a6)
  261.         move.l  a6,d0
  262.         rts
  263.  
  264. CloseLib:
  265.         cldat   d0
  266.         dec.w   LIB_OPENCNT(a6)
  267.         bne.s   ret
  268.         btst    #LIBB_DELEXP,LIB_FLAGS(a6)
  269.         beq.s   ret
  270.         bsr.s   ExpungeLib
  271. ret:    rts
  272.  
  273. ExpungeLib:
  274.         movem.l d2/a5/a6,-(sp)
  275.         tst.w   LIB_OPENCNT(a6)
  276.         beq.s   NDLex
  277.         bset    #LIBB_DELEXP,LIB_FLAGS(a6)
  278.         cldat   d0
  279.         bra.s   DLex
  280. NDLex:  move.l  a6,a5
  281.         move.l  tb_SysBase(a5),a6
  282.         movea.l tb_DOSBase(a5),a1
  283.         libcall CloseLibrary
  284.         movea.l tb_IntuitionBase(a5),a1
  285.         libcall CloseLibrary
  286.         movea.l tb_GfxBase(a5),a1
  287.         libcall CloseLibrary
  288.         move.l  a5,a1
  289.         libcall Remove
  290.         move.l  tb_SegList(a5),d2
  291.         movea.l a5,a1
  292.         cldat   d0
  293.         move.w  LIB_NEGSIZE(a5),d0
  294.         suba.l  d0,a1
  295.         add.w   LIB_POSSIZE(a5),d0
  296.         libcall FreeMem
  297.         move.l  d2,d0
  298. DLex:   movem.l (sp)+,d2/a5/a6
  299.         rts
  300.  
  301. ExtFuncLib:
  302.         cldat   d0
  303.         rts
  304.  
  305. _DOSBase:       dc.l    0
  306. _IntuitionBase: dc.l    0
  307. _GfxBase:       dc.l    0
  308.  
  309.         end
  310.  
  311.