From 18e739e0fe9c749450b74f73343429a437f3f11e Mon Sep 17 00:00:00 2001 From: Treeki Date: Sat, 5 Nov 2011 05:30:11 +0100 Subject: U8 archive stuff ported from LayoutStudio which may or may not work --- src/wii/common.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/wii/common.py (limited to 'src/wii/common.py') diff --git a/src/wii/common.py b/src/wii/common.py new file mode 100644 index 0000000..40c3954 --- /dev/null +++ b/src/wii/common.py @@ -0,0 +1,25 @@ +class WiiStringTableBuilder(object): + def __init__(self): + self.nextOffset = 0 + self.data = '' + self.lookup = {} + + def add(self, string): + if string in self.lookup: + return self.lookup[string] + + offset = self.nextOffset + self.lookup[string] = offset + + self.data = "%s%s\0" % (self.data, string.encode('Shift-JIS')) + self.nextOffset = len(self.data) + + return offset + + +def alignUp(value, alignTo): + return (value + alignTo - 1) & ~(alignTo - 1) + +def alignDown(value, alignTo): + return value & ~(alignTo - 1) + -- cgit v1.2.3