Skip to content

Commit dfd0f58

Browse files
committed
libstage.py
1 parent e7a6eb1 commit dfd0f58

File tree

5 files changed

+1295
-21
lines changed

5 files changed

+1295
-21
lines changed

tools/extract_game_assets.py

+14-13
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import libarc
44
from pathlib import Path
55
import libyaz0
6+
import libstage
67

78
"""
89
Extracts the game assets and stores them in the game folder
@@ -133,14 +134,18 @@ def writeFolder(parsedFstBin, i):
133134
Use the parsed fst.bin contents to write assets to file
134135
"""
135136

136-
convertDefinitions = [
137-
{
138-
"extension": ".arc",
137+
convertDefinitions = {
138+
".arc": {
139139
"function": libarc.extract_to_directory,
140140
"exceptions": ["archive/dat/speakerse.arc"],
141+
},
142+
".dzs": {
143+
"function": libstage.extract_to_json
144+
},
145+
".dzr": {
146+
"function": libstage.extract_to_json
141147
}
142-
]
143-
148+
}
144149

145150
def writeFile(name, data):
146151
if data[0:4] == bytes("Yaz0", "ascii"):
@@ -151,14 +156,10 @@ def writeFile(name, data):
151156
extractDef = None
152157
splitName = os.path.splitext(name)
153158
ext = splitName[1]
154-
for extractData in convertDefinitions:
155-
if ext == extractData["extension"]:
156-
extractDef = extractData
157-
if extractData["exceptions"] != None:
158-
for exception in extractData["exceptions"]:
159-
if str(name) == exception:
160-
extractDef = None
161-
break
159+
if ext in convertDefinitions:
160+
extractDef = convertDefinitions[ext]
161+
if "exceptions" in extractDef and str(name) in extractDef["exceptions"]:
162+
extractDef = None
162163

163164
if extractDef == None:
164165
file = open(name, "wb")

tools/libarc/arc.py

+2
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,8 @@ def convert_dir_to_arc(sourceDir, convertFunction):
431431
dirOffset = dirOffset + dirOffsetPadding
432432
stringTableOffset = dirOffset + (len(dirs) * 20)
433433
stringTablePadding = 0x20 - (stringTableOffset % 0x20)
434+
if stringTablePadding == 0x20:
435+
stringTablePadding = 0
434436
stringTableOffset = stringTableOffset + stringTablePadding
435437
stringTableLen = len(bytearray(stringTable, "shift-jis"))
436438
fileOffset = stringTableOffset + stringTableLen

tools/libstage/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .libstage import *

0 commit comments

Comments
 (0)