equal
deleted
inserted
replaced
|
1 module Main where |
|
2 |
|
3 import qualified Data.ByteString.Lazy as BL |
|
4 import Data.Word |
|
5 import Data.Int |
|
6 import Data.Binary |
|
7 import Data.Bits |
|
8 import Control.Monad |
|
9 |
|
10 data LineType = Solid | Erasing |
|
11 deriving Eq |
|
12 |
|
13 data Chunk = Line LineType Word8 [(Int16, Int16)] |
|
14 |
|
15 instance Binary Chunk where |
|
16 put (Line lt r ((x1, y1):ps)) = do |
|
17 let flags = r .|. (if lt == Solid then 0 else (1 `shift` 6)) |
|
18 putWord8 $ flags .|. (1 `shift` 7) |
|
19 put x1 |
|
20 put y1 |
|
21 forM_ ps $ \(x, y) -> do |
|
22 putWord8 flags |
|
23 put x |
|
24 put y |
|
25 get = undefined |
|
26 |
|
27 mapString = BL.drop 8 . encode $ |
|
28 [ |
|
29 Line Solid 7 [(0, 0), (2048, 1024), (1024, 768)] |
|
30 ] |
|
31 |
|
32 main = BL.writeFile "out.hwmap" mapString |