home *** CD-ROM | disk | FTP | other *** search
/ World of A1200 / World_Of_A1200.iso / programs / develop / gadtoolsbox / nofraglib / hspascal / source / nofrag.pas next >
Pascal/Delphi Source File  |  1995-02-27  |  3KB  |  190 lines

  1. unit nofrag;
  2.  
  3. INTERFACE
  4. uses Exec;
  5.  
  6.  
  7. { ------------------------------------------------------------------------
  8.   :Program.       NoFrag
  9.   :Contents.      Interface to Jan van den Baard's Library
  10.   :Author.        Richard Waspe
  11.   :Address.       FIDO     :   2:255/72.2
  12.   :Address.       INTERNET :   waspy@cix.compulink.co.uk
  13.   :Address.       UUCP     :   rwaspe@hamlet.adsp.sub.org
  14.   :History.       v1.0 28-Feb-93 (translated from C and Oberon)
  15.   :Copyright.     Freely Distributable
  16.   :Language.      PASCAL
  17.   :Translator.    Hisoft HSPascal V1.1
  18.   :Warning.            First translation, compiles OK, but untested
  19. ------------------------------------------------------------------------ }
  20.  
  21.  
  22. TYPE
  23.  
  24.     tNoFragBase    =    RECORD
  25.         LibNode    :    pLibrary;
  26.     END;
  27.  
  28. CONST
  29.     NOFRAG_VERSION        =    2;
  30.     NOFRAG_REVISION    =    2;
  31.  
  32.  
  33.     {    ALL structures following are PRIVATE! DO NOT USE THEM! }
  34.  
  35. TYPE
  36.  
  37.     pMemoryBlock    =    ^tMemoryBlock;
  38.     tMemoryBlock    =    RECORD
  39.         Next                :    pMemoryBlock;
  40.         Previous            :    pMemoryBlock;
  41.         Requirements    :    LONGINT;
  42.         BytesUsed        :    LONGINT;
  43.     END;
  44.  
  45.     pMemoryItem        =    ^tMemoryItem;
  46.     tMemoryItem        =    RECORD
  47.         Next        :    pMemoryItem;
  48.         Previous    :    pMemoryItem;
  49.         Block        :    pMemoryBlock;
  50.         Size        :    LONGINT;
  51.     END;
  52.  
  53.     pBlockList    =    ^tBlockList;
  54.     tBlockList    =    RECORD
  55.         bl_First        :    pMemoryBlock;
  56.         bl_End        :    pMemoryBlock;
  57.         bl_Last        :    pMemoryBlock;
  58.     END;
  59.  
  60.     pItemList    =    ^tItemList;
  61.     tItemList    =    RECORD
  62.         il_First        :    pMemoryItem;
  63.         il_End        :    pMemoryItem;
  64.         il_Last        :    pMemoryItem;
  65.     END;
  66.  
  67.  
  68.     { This structure may only be used to pass on to the library  }
  69.     { routines!                                                  }
  70.      { It may ONLY be obtained by a call to "GetMemoryChain()"    }
  71.  
  72.  
  73.     pMemoryChain    =    ^tMemoryChain;
  74.     tMemoryChain    =    RECORD
  75.         Blocks        :    tBlockList;
  76.         Items            :    tItemList;
  77.         BlockSize    :    LONGINT;
  78.     END;
  79.  
  80.  
  81. CONST
  82.     MINALLOC        =    16;
  83.  
  84.  
  85.  
  86.  
  87. function GetMemoryChain (blocksize: longint): longint;
  88. function AllocItem
  89.         (chain: pointer;
  90.         size,
  91.         requirements: longint): longint;
  92.  
  93. function FreeItem
  94.         (chain,
  95.         memptr: pointer;
  96.         size: longint): longint;
  97.  
  98. function FreeMemoryChain
  99.         (chain: pointer;
  100.         all: longint): longint;
  101.  
  102. function AllocVecItem
  103.         (chain: pointer;
  104.         size,
  105.         requirements: longint): longint;
  106.  
  107. function FreeVecItem
  108.         (chain,
  109.         memptr: pointer): longint;
  110.  
  111.  
  112.  
  113. var
  114.   NoFragBase: pLibrary;
  115.  
  116.  
  117. IMPLEMENTATION
  118. function GetMemoryChain; xassembler;
  119. asm
  120.     move.l    a6,-(sp)
  121.     move.l    8(sp),d0
  122.     move.l    NoFragBase,a6
  123.     jsr        -$1E(a6)
  124.     move.l    d0,$C(sp)
  125.     move.l    (sp)+,a6
  126. end;
  127.  
  128. function AllocItem; xassembler;
  129. asm
  130.     move.l    a6,-(sp)
  131.     lea        8(sp),a6
  132.     move.l    (a6)+,d1
  133.     move.l    (a6)+,d0
  134.     move.l    (a6)+,a0
  135.     move.l    NoFragBase,a6
  136.     jsr        -$24(a6)
  137.     move.l    d0,$14(sp)
  138.     move.l    (sp)+,a6
  139. end;
  140.  
  141. function FreeItem; xassembler;
  142. asm
  143.     move.l    a6,-(sp)
  144.     lea        8(sp),a6
  145.     move.l    (a6)+,d0
  146.     move.l    (a6)+,a1
  147.     move.l    (a6)+,a0
  148.     move.l    NoFragBase,a6
  149.     jsr        -$2A(a6)
  150.     move.l    d0,$14(sp)
  151.     move.l    (sp)+,a6
  152. end;
  153.  
  154. function FreeMemoryChain; xassembler;
  155. asm
  156.     move.l    a6,-(sp)
  157.     movem.l    8(sp),d0/a0
  158.     move.l    NoFragBase,a6
  159.     jsr        -$30(a6)
  160.     move.l    d0,$10(sp)
  161.     move.l    (sp)+,a6
  162. end;
  163.  
  164. function AllocVecItem; xassembler;
  165. asm
  166.     move.l    a6,-(sp)
  167.     lea        8(sp),a6
  168.     move.l    (a6)+,d1
  169.     move.l    (a6)+,d0
  170.     move.l    (a6)+,a0
  171.     move.l    NoFragBase,a6
  172.     jsr        -$36(a6)
  173.     move.l    d0,$14(sp)
  174.     move.l    (sp)+,a6
  175. end;
  176.  
  177. function FreeVecItem; xassembler;
  178. asm
  179.     move.l    a6,-(sp)
  180.     lea        8(sp),a6
  181.     move.l    (a6)+,a1
  182.     move.l    (a6)+,a0
  183.     move.l    NoFragBase,a6
  184.     jsr        -$3C(a6)
  185.     move.l    d0,$10(sp)
  186.     move.l    (sp)+,a6
  187. end;
  188.  
  189. end.
  190.