diff options
Diffstat (limited to '')
-rw-r--r-- | src/exporter.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/exporter.py b/src/exporter.py index 5233cdd..4026929 100644 --- a/src/exporter.py +++ b/src/exporter.py @@ -3,7 +3,7 @@ import array import sys from ctypes import create_string_buffer -def RGB4A3Encode(tex): +def RGB5A3Encode(tex): tex = tex.toImage() w, h = tex.width(), tex.height() padW = (w + 3) & ~3 @@ -301,7 +301,7 @@ class KPMapExporter: # textures texHeaderStartOffset = len(data) - texHeaderEndOffset = texHeaderStartOffset + (len(textures) * 8) + texHeaderEndOffset = texHeaderStartOffset + (len(textures) * 0x20) texDataStartOffset = (texHeaderEndOffset + 0x1F) & ~0x1F texPadding = texDataStartOffset - texHeaderEndOffset @@ -312,9 +312,9 @@ class KPMapExporter: for tex in textures: offsets[tex] = len(data) - data += struct.pack('>hhi', tex.width(), tex.height(), currentTexOffset) + data += self._buildGXTexObjRGB5A3(tex.width(), tex.height(), currentTexOffset) - converted = RGB4A3Encode(tex) + converted = RGB5A3Encode(tex) imageData.append(converted) currentTexOffset += len(converted) @@ -363,6 +363,18 @@ class KPMapExporter: self._findUnlocksForNode(destNode, checked, affected, False, secret) + def _buildGXTexObjRGB5A3(self, width, height, imgOffset): + # Format: RGB5A3 (5) + # Wrap: CLAMP (0) + return struct.pack('>IIIIIIIHH', + 0x10, 0, + (0x20000 | ((height - 1) << 10) | (width - 1)), + imgOffset, # (imgptr >> 5) + 0, 0, 0, + (((width + 3) / 4) * ((height + 3) / 4)) & 0x1FFFF, + 0x0202 + ) + def _packSectorData(self, sectors): rowStruct = struct.Struct('>16h') |