summaryrefslogtreecommitdiff
path: root/src/wii/common.py
diff options
context:
space:
mode:
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)
+