Skip to content

Commit a033bbf

Browse files
committed
Parse the “media flags” section
as described in https://github.com/entropia/tip-toi-reveng/wiki/GME-Media-flag-table No exposure in YAML yet, but at least `tttool explain` will show it. And `tttool lint` will report if we find entries that are not 0 or 1.
1 parent fd1a6e0 commit a033bbf

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

src/GMEParser.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,9 @@ getRealGame gGameType = do
409409
getInitialRegs :: SGet [Word16]
410410
getInitialRegs = getArray getWord16 getWord16
411411

412+
getMediaFlags :: Int -> SGet [Word16]
413+
getMediaFlags size = getArray (return size) getWord16
414+
412415
getSpecials :: SGet (Word16, Word16)
413416
getSpecials = (,) <$> getWord16 <*> getWord16
414417

@@ -431,7 +434,8 @@ getTipToiFile = getSegAt 0x00 "Header" $ do
431434
jumpTo 0x0071
432435
ttWelcome <- indirection "initial play lists" getPlayListList
433436

434-
jumpTo 0x0090
437+
jumpTo 0x008C
438+
ttMediaFlags <- maybeIndirection "Mediaflags" (getMediaFlags (length ttAudioFiles))
435439
ttBinaries1 <- fromMaybe [] <$> maybeIndirection "Binaries 1" getBinaries
436440
ttSpecialOIDs <- maybeIndirection "special symbols" getSpecials
437441
ttBinaries2 <- fromMaybe [] <$> maybeIndirection "Binaries 2" getBinaries

src/Lint.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ lintTipToi tt segments = do
2323
forM_ wrong $ \line -> do
2424
printf " %s\n" (ppLine M.empty line)
2525

26+
forM_ (fromMaybe [] (ttMediaFlags tt)) $ \f ->
27+
when (f > 1) $ printf "Media flag >1: %d" f
28+
2629
let overlapping_segments =
2730
filter (\((o1,l1,_),(o2,l2,_)) -> o1+l1 > o2) $
2831
zip segments (tail segments)

src/TipToiYaml.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,7 @@ ttYaml2tt no_date dir (TipToiYAML {..}) extCodes = do
885885
, ttAudioFiles = files
886886
, ttAudioXor = knownXOR
887887
, ttAudioFilesDoubles = False
888+
, ttMediaFlags = Nothing
888889
, ttChecksum = 0x00
889890
, ttChecksumCalc = 0x00
890891
, ttBinaries1 = []

src/Types.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ data TipToiFile = TipToiFile
7878
, ttAudioFiles :: [B.ByteString]
7979
, ttAudioFilesDoubles :: Bool
8080
, ttAudioXor :: Word8
81+
, ttMediaFlags :: Maybe [Word16]
8182
, ttBinaries1 :: [(B.ByteString, B.ByteString)]
8283
, ttBinaries2 :: [(B.ByteString, B.ByteString)]
8384
, ttBinaries3 :: [(B.ByteString, B.ByteString)]

0 commit comments

Comments
 (0)