+ actlist (DTF_Define _ _ _) = next
+ actlist (DTF_Fill rep val code l c) = if state == InData then
+ (DTF_Data datacnt val code l c):[(DTF_Data dc val "" "" "") | i<-[2..repi], let dc = [(datacnt+0x4),(datacnt+0x8)..]!!(i-2)] ++ next
+ else
+ (DTF_Instr instrcnt val code l c):[(DTF_Instr ic val "" "" "") | i<-[2..repi], let ic = [(instrcnt+0x4),(instrcnt+0x8)..]!!(i-2)] ++ next
+ where
+ repi :: Int
+ repi = fromInteger (toInteger rep)
+ actlist (DTF_Ascii str lab code comment) =
+ (DTF_Data datacnt (strval!!0) code lab comment):
+ [(DTF_Data ic (strval!!i) code lab comment)
+ | i<-[1..len]
+ , let ic = [datacnt,(datacnt+0x4)..]!!i
+ ]
+ ++ next
+ where
+ len = ((length str)`div`4)
+ strval :: [Word32]
+ strval = pf $ map (\x -> fromIntegral $ ord x :: Word8) str
+ pf :: [Word8] -> [Word32]
+ pf [] = []
+ pf xs@(_:[]) = pf (xs ++ [0,0,0])
+ pf xs@(_:_:[]) = pf (xs ++ [0,0])
+ pf xs@(_:_:_:[]) = pf (xs ++ [0])
+ pf (a:b:c:d:xs) = (foldl' accum 0 [d,c,b,a]):(pf xs)
+ where
+ accum x o = (x `shiftL` 8) .|. fromIntegral o