@@ -23,7 +23,9 @@ data LongLinDiff = LongLinDiff Axis Int8
2323 deriving (Eq , Show )
2424
2525data NearDiff = NearDiff Int8 Int8 Int8
26+ deriving (Eq , Show )
2627
28+ data FarDiff = FarDiff Int8 Int8 Int8
2729 deriving (Eq , Show )
2830
2931data Command =
@@ -36,6 +38,8 @@ data Command =
3638 | Fill NearDiff
3739 | FusionP NearDiff
3840 | FusionS NearDiff
41+ | GFill NearDiff FarDiff
42+ | GVoid NearDiff FarDiff
3943 deriving (Eq , Show )
4044
4145instance Coded Axis where
@@ -85,6 +89,21 @@ instance Coded NearDiff where
8589 x = xy `div` 3
8690 return $ NearDiff (x- 1 ) (y- 1 ) (z- 1 )
8791
92+ instance Coded FarDiff where
93+ encode (FarDiff dx dy dz) = do
94+ putBits 7 0 ((dx + 30 ) :: Word8 )
95+ putBits 7 0 ((dy + 30 ) :: Word8 )
96+ putBits 7 0 ((dz + 30 ) :: Word8 )
97+
98+ decode = do
99+ dx <- getWord8
100+ dy <- getWord8
101+ dz <- getWord8
102+ FarDiff
103+ <$> ((fromIntegral dx)- 30 )
104+ <*> ((fromIntegral dy)- 30 )
105+ <*> ((fromIntegral dz)- 30 )
106+
88107instance Coded Command where
89108 encode Halt = putBits 7 0 (0b11111111 :: Word8 )
90109 encode Wait = putBits 7 0 (0b11111110 :: Word8 )
@@ -121,6 +140,10 @@ instance Coded Command where
121140 encode nd
122141 putBits 2 0 (0b011 :: Int )
123142
143+ encode (GFill nd fd) = undefined
144+
145+ encode (GVoid nd fd) = undefined
146+
124147 decode = parseOpcode =<< getWord8
125148 where
126149 parseOpcode :: MonadGet m => Word8 -> Coding m Command
0 commit comments