summaryrefslogtreecommitdiff
path: root/src/wii/common.py
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2011-11-05 05:30:11 +0100
committerTreeki <treeki@gmail.com>2011-11-05 05:30:11 +0100
commit18e739e0fe9c749450b74f73343429a437f3f11e (patch)
tree34b5ca6c892a1d1c6a2016fd8b3b73d1ddedd287 /src/wii/common.py
parenta8d9f1a2ccfb412af8b9d0a9398247204bfc05d1 (diff)
downloadkoopatlas-18e739e0fe9c749450b74f73343429a437f3f11e.tar.gz
koopatlas-18e739e0fe9c749450b74f73343429a437f3f11e.zip
U8 archive stuff ported from LayoutStudio which may or may not work
Diffstat (limited to '')
-rw-r--r--src/wii/common.py25
1 files changed, 25 insertions, 0 deletions
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)
+