module IPS.Types (Patch, Chunk (..), ChunkBody (..), Word8, Word16, Word24, Bytes, makeBytes) where import Data.ByteString (ByteString) import qualified Data.ByteString as ByteString import Data.Vector (Vector) import qualified Data.Vector.Storable as S import Data.Word import IPS.Word24 type Patch = Vector Chunk data Chunk = Chunk { offset :: {-# UNPACK #-} !Word24, body :: !ChunkBody } deriving (Show, Eq) data ChunkBody = Normal {-# UNPACK #-} !Bytes | RLE { size :: {-# UNPACK #-} !Word16, value :: {-# UNPACK #-} !Word8 } deriving (Show, Eq) type Bytes = S.Vector Word8 makeBytes :: ByteString -> Bytes makeBytes bs = S.generate (ByteString.length bs) (ByteString.index bs)