tttool 1.6.0.1 → 1.6.1
raw patch · 6 files changed
+26/−18 lines, 6 files
Files
- src/GMEParser.hs +4/−4
- src/GMEWriter.hs +4/−4
- src/PrettyPrint.hs +5/−3
- src/TipToiYaml.hs +10/−4
- src/Types.hs +2/−2
- tttool.cabal +1/−1
src/GMEParser.hs view
@@ -196,12 +196,12 @@ actions = [ (B.pack [0xE0,0xFF], \r -> do unless (r == 0) $ fail "Non-zero register for RandomVariant command"- Const 0x0000 <- getTVal- return RandomVariant)+ v <- getTVal+ return (RandomVariant v)) , (B.pack [0xE1,0xFF], \r -> do unless (r == 0) $ fail "Non-zero register for PlayAllVariant command"- Const 0x0000 <- getTVal- return PlayAllVariant)+ v <- getTVal+ return (PlayAllVariant v)) , (B.pack [0xE8,0xFF], \r -> do unless (r == 0) $ fail "Non-zero register for Play command" Const n <- getTVal
src/GMEWriter.hs view
@@ -314,14 +314,14 @@ putWord16 r mapM_ putWord8 [0xF8, 0xFF] putTVal (Const 0)-putCommand RandomVariant = do+putCommand (RandomVariant v) = do putWord16 0 mapM_ putWord8 [0xE0, 0xFF]- putTVal (Const 0)-putCommand PlayAllVariant = do+ putTVal v+putCommand (PlayAllVariant v) = do putWord16 0 mapM_ putWord8 [0xE1, 0xFF]- putTVal (Const 0)+ putTVal v putCommand (Play n) = do putWord16 0 mapM_ putWord8 [0xE8, 0xFF]
src/PrettyPrint.hs view
@@ -47,7 +47,7 @@ r -> Right [x] : r ppPlayList :: Transscript -> PlayList -> String-ppPlayList t xs = "[" ++ commas (map go (groupRuns (flip M.lookup t) xs)) ++ "]"+ppPlayList t xs = "[" ++ commas (map go (groupRuns (`M.lookup` t) xs)) ++ "]" where go (Left s) = quote s go (Right []) = error "Empty list in groupRuns result" go (Right l) | length l > 3 = show (head l) ++ ".." ++ show (last l)@@ -111,8 +111,10 @@ ppCommand _ t xs (Play n) = printf "P(%s)" $ ppPlayIndex t xs (fromIntegral n) ppCommand _ t xs (Random a b) = printf "P(%s)" $ ppPlayRange t xs [b..a] ppCommand _ t xs (PlayAll a b) = printf "PA(%s)" $ ppPlayRange t xs [b..a]-ppCommand _ t xs PlayAllVariant = printf "PA*(%s)" $ ppPlayAll t xs-ppCommand _ t xs RandomVariant = printf "P*(%s)" $ ppPlayAll t xs+ppCommand _ t xs (PlayAllVariant (Const 0)) = printf "PA*(%s)" (ppPlayAll t xs)+ppCommand _ t xs (PlayAllVariant v) = printf "PA*(%s)(%s)" (ppPlayAll t xs) (ppTVal v)+ppCommand _ t xs (RandomVariant (Const 0)) = printf "P*(%s)" (ppPlayAll t xs)+ppCommand _ t xs (RandomVariant v) = printf "P*(%s)(%s)" (ppPlayAll t xs) (ppTVal v) ppCommand _ t xs Cancel = printf "C" ppCommand _ t xs (Jump v) = printf "J(%s)" (ppTVal v) ppCommand _ t xs (Timer r v) = printf "T(%s,%s)" (ppReg r) (ppTVal v)
src/TipToiYaml.hs view
@@ -10,6 +10,7 @@ import qualified Data.ByteString.Lazy as B import qualified Data.ByteString.Lazy.Char8 as BC+import qualified Data.ByteString as SB import qualified Data.ByteString.Char8 as SBC import System.Exit import System.FilePath@@ -798,7 +799,7 @@ -- it were in base, and not fixed to String. files_with_errors <- forM filenames $ \fn -> case M.lookup fn ttySpeakMap of Just (lang, txt) -> do- Right <$> B.readFile (ttsFileName lang txt)+ Right <$> readFile' (ttsFileName lang txt) Nothing -> do let paths = [ combine dir relpath | ext <- map snd fileMagics@@ -811,7 +812,7 @@ return $ Left $ unlines $ "Could not find any of these files:" : paths- [f] -> Right <$> B.readFile f+ [f] -> Right <$> readFile' f _ -> do return $ Left $ unlines $ "Multiple matching files found:" :@@ -962,13 +963,14 @@ withStar <- optionBool (char '*') return (withA, withStar) fns <- P.parens lexer $ P.commaSep1 lexer parseAudioRef+ playAllUnknownArgument <- option (Const 0) $ P.parens lexer $ parseTVal let n = length fns let c = case (withA, withStar, fns) of (False, False, [fn]) -> Play (fromIntegral i) (False, False, _) -> Random (fromIntegral (i + n - 1)) (fromIntegral i) (True, False, _) -> PlayAll (fromIntegral (i + n - 1)) (fromIntegral i)- (False, True, _) -> RandomVariant- (True, True, _) -> PlayAllVariant+ (False, True, _) -> RandomVariant playAllUnknownArgument+ (True, True, _) -> PlayAllVariant playAllUnknownArgument (cmds, filenames) <- parseCommands (i+n) return (c : cmds, fns ++ filenames) , descP "Cancel" $@@ -1004,6 +1006,10 @@ encodeFileCommented :: ToJSON a => FilePath -> String -> a -> IO () encodeFileCommented fn c v = do SBC.writeFile fn $ SBC.pack c <> encode v++readFile' :: String -> IO B.ByteString+readFile' filename =+ B.fromStrict <$> SB.readFile filename readTipToiYaml :: FilePath -> IO (TipToiYAML, CodeMap) readTipToiYaml inf = do
src/Types.hs view
@@ -46,8 +46,8 @@ = Play Word16 | Random Word8 Word8 | PlayAll Word8 Word8- | PlayAllVariant- | RandomVariant+ | PlayAllVariant (TVal r)+ | RandomVariant (TVal r) | Cancel | Game Word16 | ArithOp ArithOp r (TVal r)
tttool.cabal view
@@ -1,5 +1,5 @@ name: tttool-version: 1.6.0.1+version: 1.6.1 synopsis: Working with files for the Tiptoi® pen description: The Ravensburger Tiptoi® pen is programmed via special files. Their file format has been reverse engineered; this