# HG changeset patch # User unc0rr # Date 1403098606 -14400 # Node ID 72e6df962cb63a24100d2fdbc6df65bdb8849281 # Parent 6f1f8515181c21aad2ec1dca3701ab333ab960e0 Code drawn map in haskell \o/ (not finished, todo: compressing and base64 encoding) diff -r 6f1f8515181c -r 72e6df962cb6 tools/hwmap.hs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/hwmap.hs Wed Jun 18 17:36:46 2014 +0400 @@ -0,0 +1,32 @@ +module Main where + +import qualified Data.ByteString.Lazy as BL +import Data.Word +import Data.Int +import Data.Binary +import Data.Bits +import Control.Monad + +data LineType = Solid | Erasing + deriving Eq + +data Chunk = Line LineType Word8 [(Int16, Int16)] + +instance Binary Chunk where + put (Line lt r ((x1, y1):ps)) = do + let flags = r .|. (if lt == Solid then 0 else (1 `shift` 6)) + putWord8 $ flags .|. (1 `shift` 7) + put x1 + put y1 + forM_ ps $ \(x, y) -> do + putWord8 flags + put x + put y + get = undefined + +mapString = BL.drop 8 . encode $ + [ + Line Solid 7 [(0, 0), (2048, 1024), (1024, 768)] + ] + +main = BL.writeFile "out.hwmap" mapString