module Sound.MED.Raw.MMDARexx where

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

import Sound.MED.Basic.Amiga

data MMDARexx = MMDARexx
  { reserved   :: UWORD
  , trigcmdlen :: UWORD
  , trigcmd    :: Maybe MMDARexxTrigCmd
  }
  deriving (Show)

peek :: MEM -> PTR -> IO MMDARexx
peek m p = do
  reserved'   <- peekUWORD m (p+0)
  trigcmdlen' <- peekUWORD m (p+2)
  trigcmd'''  <- peekPTR   m (p+4)
  trigcmd'    <- MMDARexxTrigCmd.peek m $? trigcmd'''
  return $ MMDARexx
    reserved' trigcmdlen' trigcmd'