new U8 API, needs adding to other shit in archive.py

This commit is contained in:
Xuzz 2009-07-12 13:07:53 -07:00
parent 085c1a96fd
commit c3a4330a94
2 changed files with 11 additions and 8 deletions

View File

@ -89,6 +89,7 @@ class U8(WiiArchive):
def _dumpDir(self, dir):
if(not os.path.isdir(dir)):
os.mkdir(dir)
old = os.getcwd()
os.chdir(dir)
for item, data in self.files:
if(data == None):
@ -96,12 +97,13 @@ class U8(WiiArchive):
os.mkdir(item)
else:
open(item, "wb").write(data)
os.chdir("..")
os.chdir(old)
def _loadDir(self, dir):
try:
self._tmpPath += ''
except:
self._tmpPath = ''
old = os.getcwd()
os.chdir(dir)
entries = os.listdir(".")
for entry in entries:
@ -112,7 +114,7 @@ class U8(WiiArchive):
elif(os.path.isfile(entry)):
data = open(entry, "rb").read()
self.files.append((self._tmpPath + entry, data))
os.chdir("..")
os.chdir(old)
self._tmpPath = self._tmpPath[:self._tmpPath.find('/') + 1]
def _load(self, data):
offset = 0
@ -148,7 +150,7 @@ class U8(WiiArchive):
if(node.type == 0x0100): # folder
recursion.append(node.size)
recursiondir.append(name)
assert len(recursion) == node.data_offset + 2 #bad idea?
assert len(recursion) == node.data_offset + 2 # haxx
self.files.append(('/'.join(recursiondir), None))
elif(node.type == 0): # file
self.files.append(('/'.join(recursiondir) + '/' + name, data[node.data_offset:node.data_offset + node.size]))
@ -179,10 +181,11 @@ class U8(WiiArchive):
return val
raise KeyError
def __setitem__(self, key, val):
for i in self.files:
for i in range(len(self.files)):
if(self.files[i][0] == key):
self.files[i][1] = val
raise KeyError
self.files[i] = (self.files[i][0], val)
return
self.files.append((key, val))
class WAD:

View File

@ -541,11 +541,11 @@ class TPL():
if k == 0:
a = (texel >> 8) & 0xff
r = (texel >> 0) & 0xff
out[m + (l * x)] = out[m + (l * x)] | ((r<<0) | (a<<24))
out[m + (l * x)] |= ((r << 0) | (a << 24))
else:
g = (texel >> 8) & 0xff
b = (texel >> 0) & 0xff
out[m + (l * x)] = out[m + (l * x)] | ((g<<8) | (b<<16))
out[m + (l * x)] |= ((g << 8) | (b << 16))
return ''.join(Struct.uint32(p) for p in out)
def RGB5A3(self, (w, h), jar):
out = [0 for i in range(w * h)]