From 5089b4a5cd8b40a02187b4969bd97fba81f9d8f1 Mon Sep 17 00:00:00 2001 From: comex Date: Tue, 17 Feb 2009 23:46:31 -0500 Subject: Helpfulness. --- ethyl.py | 2 ++ parse-brlan.py | 6 +++++ parse-brlyt.py | 5 ++++ test.rlan.py | 39 ++++++++++++++++++++++++++++ test.rlyt.py | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ testrlan.py | 39 ---------------------------- testrlyt.py | 82 ---------------------------------------------------------- write-brlan.py | 6 +++++ write-brlyt.py | 6 +++++ 9 files changed, 146 insertions(+), 121 deletions(-) create mode 100644 test.rlan.py create mode 100644 test.rlyt.py delete mode 100644 testrlan.py delete mode 100644 testrlyt.py diff --git a/ethyl.py b/ethyl.py index 2e01409..0d283b4 100644 --- a/ethyl.py +++ b/ethyl.py @@ -356,3 +356,5 @@ def put_opt(var, flags, bit, size, item_type=None): else: raise Exception('unhandled') return ret, flags +def i2f(int): + return struct.unpack('>f', struct.pack('>I', int))[0] \ No newline at end of file diff --git a/parse-brlan.py b/parse-brlan.py index 2320e42..a2e57e9 100644 --- a/parse-brlan.py +++ b/parse-brlan.py @@ -1,6 +1,10 @@ import sys, struct, re from ethyl import * +if len(sys.argv) != 2: + print 'Usage: python parse-brlan.py something.brlan' + sys.exit(1) + f = open(sys.argv[1], 'rb') rlan = f.read() f.close() @@ -35,7 +39,9 @@ for typ, chunk in ch: offs = struct.unpack('>I', chunk[pos:pos+4])[0] - 8 name = chunk[offs:offs + 0x14].rstrip('\0') + aunk, aoffs = struct.unpack('>II', chunk[offs + 0x14:offs + 0x1c]) + print name, hex(aoffs) aoffs += offs atyp = chunk[aoffs:aoffs+4] #print hex(aoffs), hex(offs), name diff --git a/parse-brlyt.py b/parse-brlyt.py index 694cc12..44a0da0 100644 --- a/parse-brlyt.py +++ b/parse-brlyt.py @@ -1,6 +1,11 @@ import sys, struct, re from ethyl import * +if len(sys.argv) != 2: + print 'Usage: python parse-brlyt.py something.brlyt' + sys.exit(1) + + f = open(sys.argv[1], 'rb') rlyt = f.read() f.close() diff --git a/test.rlan.py b/test.rlan.py new file mode 100644 index 0000000..2abec49 --- /dev/null +++ b/test.rlan.py @@ -0,0 +1,39 @@ +{ +'framesize': 70, +'flags': 1, +'anims': [ + ('RLPA', 'pic', CAT_COORDS, [ + #(COORD_X, [ + #(20.0, 0.0, 1.0), + #(40.0, 15.0, 1.0) + #]), + #(COORD_Y, [ + #(10.0, 0.0, 1.0), + #(30.0, 15.0, 1.0) + #]), + #(COORD_ANGLE, [ + #(0.0, 0.0, 1.0), + #(70.0, 360.0, 1.0), + #]), + (COORD_XMAG, [ + (0.0, 0.5, 0.0), + (70.0, 0.5, 0.0), + ]), + (COORD_YMAG, [ + (0.0, 3.5, 0.0), # Interpolation is weird. If I specify the same value for the two points and factor = 1, I get a HUGE increase in the middle. + (70.0, 0.5, 0.0), + ]), + + + ]), + ('RLVC', 'pic', CAT_COORDS, [ + (0x10, [ + (20.0, 50.0, 1.0), + (40.0, 200.0, 1.0), + (60.0, 100.0, 1.0), + ]), + ]), + + +] +} \ No newline at end of file diff --git a/test.rlyt.py b/test.rlyt.py new file mode 100644 index 0000000..b260f49 --- /dev/null +++ b/test.rlyt.py @@ -0,0 +1,82 @@ +[ + ('lyt1', { + 'a': 1, + 'width': 608.0, + 'height': 456.0 + }), + ('txl1', { + 'textures': [ + {'unk': 0, 'name': 'smiley.tpl'}, + ] + }), + ('fnl1', { + 'files': [ + {'unk': 0, 'name': 'wbf1.brfna'}, + {'unk': 0, 'name': 'wbf2.brfna'}, + ] + }), + ('mat1', { + 'materials': [ + { + 'name': 'textmat', + 'tev_color': [0x0, 0x0, 0x0, 0x0], # Possibly background color + 'tev_kcolor': [0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, ], + 'unk_color': [0xff, 0xff, 0xff, 0xff], # Possibly the color of the thing itself + 'unk_color_2': [0xff, 0xff, 0xff, 0xff], + 'texref': [ { 'tex': 'smiley.tpl', 'wrap_s': 0, 'wrap_t': 0 } ], # screwed up with wrap on + 'ua2': [ (0.0, 0.0, 0.0, 1.0, 1.0) ], + 'ua3': [ (1, 4, 0x1e, 0) ], # Changing this --> image disappears (not text, though) + 'ua4': None, + 'ua5': None, + 'ua6': None, + 'ua7': [], + 'ua8': [], + 'ua9': [], + 'uaa': [0x77, 0, 0, 0], # was: [0x77, 0, 0, 0] + 'uab': None, + + + } + + ] + }), + ('pan1', { + 'alpha': 0xff, + 'alpha_2': 0x0, + 'angle': 0, + 'flags_1': 1, + 'flags_2': 4, + 'width': 608, + 'height': 456, + 'name': 'RootPane', + 'x': 0, + 'y': 0, + 'xmag': 1, + 'ymag': 1, + 'z': 0 + }), + 'pas1', + ('pic1', { + 'alpha': 0xff, + 'alpha_2': 0x0, + 'angle': 0, + 'flags_1': 1, # Black if omitted + 'flags_2': 4, # "X, Y at center?" + 'width': 152, + 'height': 152, + 'name': 'pic', + 'x': 0, + 'y': 0, + 'xmag': 1, + 'ymag': 1, + 'z': 0, + '~pic.material': 'textmat', + '~pic.texcoords': [(0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0)], + }), + 'pae1', + ('grp1', { + 'name': 'RootGroup', + 'subs': [], + 'unk': 0 + }), +] \ No newline at end of file diff --git a/testrlan.py b/testrlan.py deleted file mode 100644 index 2abec49..0000000 --- a/testrlan.py +++ /dev/null @@ -1,39 +0,0 @@ -{ -'framesize': 70, -'flags': 1, -'anims': [ - ('RLPA', 'pic', CAT_COORDS, [ - #(COORD_X, [ - #(20.0, 0.0, 1.0), - #(40.0, 15.0, 1.0) - #]), - #(COORD_Y, [ - #(10.0, 0.0, 1.0), - #(30.0, 15.0, 1.0) - #]), - #(COORD_ANGLE, [ - #(0.0, 0.0, 1.0), - #(70.0, 360.0, 1.0), - #]), - (COORD_XMAG, [ - (0.0, 0.5, 0.0), - (70.0, 0.5, 0.0), - ]), - (COORD_YMAG, [ - (0.0, 3.5, 0.0), # Interpolation is weird. If I specify the same value for the two points and factor = 1, I get a HUGE increase in the middle. - (70.0, 0.5, 0.0), - ]), - - - ]), - ('RLVC', 'pic', CAT_COORDS, [ - (0x10, [ - (20.0, 50.0, 1.0), - (40.0, 200.0, 1.0), - (60.0, 100.0, 1.0), - ]), - ]), - - -] -} \ No newline at end of file diff --git a/testrlyt.py b/testrlyt.py deleted file mode 100644 index b260f49..0000000 --- a/testrlyt.py +++ /dev/null @@ -1,82 +0,0 @@ -[ - ('lyt1', { - 'a': 1, - 'width': 608.0, - 'height': 456.0 - }), - ('txl1', { - 'textures': [ - {'unk': 0, 'name': 'smiley.tpl'}, - ] - }), - ('fnl1', { - 'files': [ - {'unk': 0, 'name': 'wbf1.brfna'}, - {'unk': 0, 'name': 'wbf2.brfna'}, - ] - }), - ('mat1', { - 'materials': [ - { - 'name': 'textmat', - 'tev_color': [0x0, 0x0, 0x0, 0x0], # Possibly background color - 'tev_kcolor': [0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, ], - 'unk_color': [0xff, 0xff, 0xff, 0xff], # Possibly the color of the thing itself - 'unk_color_2': [0xff, 0xff, 0xff, 0xff], - 'texref': [ { 'tex': 'smiley.tpl', 'wrap_s': 0, 'wrap_t': 0 } ], # screwed up with wrap on - 'ua2': [ (0.0, 0.0, 0.0, 1.0, 1.0) ], - 'ua3': [ (1, 4, 0x1e, 0) ], # Changing this --> image disappears (not text, though) - 'ua4': None, - 'ua5': None, - 'ua6': None, - 'ua7': [], - 'ua8': [], - 'ua9': [], - 'uaa': [0x77, 0, 0, 0], # was: [0x77, 0, 0, 0] - 'uab': None, - - - } - - ] - }), - ('pan1', { - 'alpha': 0xff, - 'alpha_2': 0x0, - 'angle': 0, - 'flags_1': 1, - 'flags_2': 4, - 'width': 608, - 'height': 456, - 'name': 'RootPane', - 'x': 0, - 'y': 0, - 'xmag': 1, - 'ymag': 1, - 'z': 0 - }), - 'pas1', - ('pic1', { - 'alpha': 0xff, - 'alpha_2': 0x0, - 'angle': 0, - 'flags_1': 1, # Black if omitted - 'flags_2': 4, # "X, Y at center?" - 'width': 152, - 'height': 152, - 'name': 'pic', - 'x': 0, - 'y': 0, - 'xmag': 1, - 'ymag': 1, - 'z': 0, - '~pic.material': 'textmat', - '~pic.texcoords': [(0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0)], - }), - 'pae1', - ('grp1', { - 'name': 'RootGroup', - 'subs': [], - 'unk': 0 - }), -] \ No newline at end of file diff --git a/write-brlan.py b/write-brlan.py index e9fa710..c2a2ce4 100644 --- a/write-brlan.py +++ b/write-brlan.py @@ -1,6 +1,12 @@ import sys, struct, re from ethyl import * +if len(sys.argv) != 2: + print 'Usage: python write-brlan.py input.rlan.py output.brlan' + print '(for example, see test.rlan.py)' + sys.exit(1) + + CAT_COORDS = 0x1000000 CAT_2_UNK = 0x2000000 # alpha and stuff COORD_X = 0 diff --git a/write-brlyt.py b/write-brlyt.py index 3ff94bc..b0119bb 100644 --- a/write-brlyt.py +++ b/write-brlyt.py @@ -1,6 +1,12 @@ import sys, struct, re, random from ethyl import * +if len(sys.argv) != 2: + print 'Usage: python write-brlyt.py input.rlyt.py output.brlyt' + print '(for example, see test.rlyt.py)' + sys.exit(1) + + f = open(sys.argv[1], 'r') chunks = eval(f.read()) f.close() -- cgit v1.3.1