Skip to content

Commit

Permalink
lib.games.sierra: Init
Browse files Browse the repository at this point in the history
  • Loading branch information
moralrecordings committed Jul 10, 2021
1 parent 0551ba9 commit 59f6334
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Unreleased
- blocks.Block: Add option to delay caching refs
- utils.find_iter: Fix binary searching
- lib.platforms.director.unlock_dir_file: Improve robustness, remove dependency on parser
- lib.games.sierra: Init

0.9.0 - 2021-01-14
==================
Expand Down
43 changes: 43 additions & 0 deletions mrcrowbar/lib/games/sierra.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from mrcrowbar import models as mrc


class TIMFile( mrc.Block ):
file_name = mrc.Bytes( length=13 )
size = mrc.UInt32_LE()
data = mrc.Bytes( length=mrc.Ref( 'size' ) )

@property
def repr( self ):
return self.file_name.split(b'\x00')[0].decode('utf8')


class ResourceTIM( mrc.Block ):
raw_data = mrc.Bytes()

def __init__( self, *args, **kwargs ):
super().__init__( *args, **kwargs )
self.store = mrc.Store( self, mrc.Ref( 'raw_data' ) )


class TIMFileEntry( mrc.Block ):
_file = mrc.StoreRef( TIMFile, mrc.Ref( '_parent._resource.store' ), mrc.Ref( 'offset' ) )

name_hash = mrc.Int32_LE()
offset = mrc.UInt32_LE()


class TIMFileStruct( mrc.Block ):
_resource = None # replace with the ResourceTIM object

file_name = mrc.Bytes( length=13 )
entry_count = mrc.UInt16_LE()
entries = mrc.BlockField( TIMFileEntry, count=mrc.Ref( 'entry_count' ) )


class ResourceMapTIM( mrc.Block ):
hash_index = mrc.Bytes( length=4 )
file_count = mrc.UInt16_LE()
files = mrc.BlockField( TIMFileStruct, count=mrc.Ref( 'file_count' ) )



0 comments on commit 59f6334

Please sign in to comment.