module Sound.MED.Raw.MMDDumpData where

import qualified Sound.MED.Raw.MMDDump as MMDDump
import Sound.MED.Raw.MMDDump(MMDDump)

import Sound.MED.Basic.Amiga

data MMDDumpData = MMDDumpData
  { numdumps :: UWORD
  , reserved :: [ UWORD ]
  , dumps    :: [ MMDDump ]
  }
  deriving (Show)

peek :: MEM -> PTR -> IO MMDDumpData
peek m p = do
  numdumps' <- peekUWORD m p
  reserved' <- mapM (peekUWORD m) $ pointerRange (p+2) 2 3
  dumps''   <- mapM (peekPTR m) $ pointerRangeGen (p+8) 4 numdumps'
  dumps'    <- mapM (MMDDump.peek m) dumps''
  return $ MMDDumpData
    numdumps' reserved' dumps'