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

  1.         opt     l+,o+,ow-
  2. *
  3. * freqmem.s version 8.1 - © Copyright 1990 Jaba Development
  4. *
  5. * Author    : Jan van den Baard
  6. * Assembler : Devpac vesion 2.14
  7. *
  8.         incdir  'sys:devpac_inc/'
  9.         include 'tool.i'
  10.         include 'mymacros.i'
  11.         include 'exec/exec_lib.i'
  12.  
  13.         xdef    AllocFreq
  14.         xdef    FreeFreq
  15.  
  16.         xref    InitMemoryChain
  17.         xref    CloseDir
  18.         xref    FreeDir
  19. *
  20. * special definition so the filerequester buffers are allocated in one call
  21. *
  22.  STRUCTURE  BigFreq,fr_SIZEOF
  23.     STRUCT  fr_HeadPtr,28
  24.     STRUCT  fr_FilePtr,32
  25.     STRUCT  fr_DirPtr,256
  26.     STRUCT  fr_PatPtr,32
  27.     STRUCT  fr_MemPtr,dr_SIZEOF
  28.     LABEL   fr_BIGSIZEOF
  29.  
  30. *
  31. * allocate and initialize a filerequester structure
  32. *
  33. AllocFreq:      movem.l a2/a6,-(sp)
  34.                 move.l  #fr_BIGSIZEOF,d0
  35.                 move.l  #MEMF_PUBLIC+MEMF_CLEAR,d1
  36.                 move.l  (_SysBase).w,a6         ; allocate the structure &
  37.                 libcall AllocMem                ; buffers
  38.                 move.l  d0,a2
  39.                 bne.s   FreqOK
  40.                 cldat   d0
  41. EndAF:          movem.l (sp)+,a2/a6
  42.                 rts
  43. FreqOK:         lea.l   fr_HeadPtr(a2),a0       ; initialize the structure
  44.                 clr.b   (a0)
  45.                 move.l  a0,fr_HeadLine(a2)
  46.                 lea.l   fr_FilePtr(a2),a0
  47.                 clr.b   (a0)
  48.                 move.l  a0,fr_FileName(a2)
  49.                 lea.l   fr_DirPtr(a2),a0
  50.                 clr.b   (a0)
  51.                 move.l  a0,fr_DirName(a2)
  52.                 lea.l   fr_PatPtr(a2),a0
  53.                 clr.b   (a0)
  54.                 move.l  a0,fr_DontShow(a2)
  55.                 lea.l   fr_MemPtr(a2),a0
  56.                 move.l  a0,fr_Directory(a2)
  57.                 lea.l   dr_DirMem(a0),a0
  58.                 move.l  #DIRBLOCK,d0
  59.                 bsr     InitMemoryChain
  60.                 move.l  fr_Directory(a2),a0
  61.                 clr.l   dr_NumEntries(a0)
  62.                 NEWLIST a0
  63.                 move.w  #10,fr_LeftEdge(a2)
  64.                 move.w  #15,fr_TopEdge(a2)
  65.                 clr.l   fr_Caller(a2)
  66.                 clr.l   fr_Screen(a2)
  67.                 clr.l   fr_Reserved(a2)
  68.                 move.l  a2,d0
  69.                 bra.s   EndAF
  70.  
  71. *
  72. * free a filerequester structure
  73. *
  74. FreeFreq:       movem.l a2/a6,-(sp)
  75.                 move.l  a0,a2
  76.                 move.l  fr_Directory(a2),a0
  77.                 bsr     CloseDir           ; close the directory
  78.                 move.l  fr_Directory(a2),a0
  79.                 bsr     FreeDir            ; Free the directory
  80.                 move.l  #fr_BIGSIZEOF,d0
  81.                 move.l  a2,a1
  82.                 move.l  (_SysBase).w,a6
  83.                 libcall FreeMem                 ; free struct & buffers
  84.                 movem.l (sp)+,a2/a6
  85.                 rts
  86.  
  87.