Skip to content

Commit 64e9c70

Browse files
committed
Tools: update packageISO and move yaz0 function to config
1 parent ab7d0b8 commit 64e9c70

File tree

6 files changed

+218
-115
lines changed

6 files changed

+218
-115
lines changed

Makefile

+3-24
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,7 @@ tools: dirs $(ELF2DOL) $(YAZ0)
156156

157157
assets:
158158
@mkdir -p game
159-
$(PYTHON) tools/extract_game_assets.py $(IMAGENAME) game native asset_config.json
160-
161-
assets-fast:
162-
@mkdir -p game
163-
$(PYTHON) tools/extract_game_assets.py $(IMAGENAME) game oead asset_config.json
159+
$(PYTHON) tools/extract_game_assets.py $(IMAGENAME) game asset_config.json
164160

165161
docs:
166162
$(DOXYGEN) Doxyfile
@@ -193,40 +189,23 @@ shiftedrels: shift $(RELS)
193189

194190
game: shiftedrels
195191
@mkdir -p game
196-
@$(PYTHON) tools/package_game_assets.py ./game $(BUILD_PATH) copyCode native asset_config.json
197-
198-
game-fast: shiftedrels
199-
@mkdir -p game
200-
@$(PYTHON) tools/package_game_assets.py ./game $(BUILD_PATH) copyCode oead asset_config.json
192+
@$(PYTHON) tools/package_game_assets.py ./game $(BUILD_PATH) copyCode asset_config.json
201193

202194
game-nocompile:
203195
@mkdir -p game
204-
@$(PYTHON) tools/package_game_assets.py ./game $(BUILD_PATH) noCopyCode native asset_config.json
205-
206-
game-nocompile-fast:
207-
@mkdir -p game
208-
@$(PYTHON) tools/package_game_assets.py ./game $(BUILD_PATH) noCopyCode oead asset_config.json
196+
@$(PYTHON) tools/package_game_assets.py ./game $(BUILD_PATH) noCopyCode asset_config.json
209197

210198
rungame-nocompile: game-nocompile
211199
@echo If you are playing on a shifted game make sure Hyrule Field Speed hack is disabled in dolphin!
212200
dolphin-emu $(BUILD_DIR)/game/sys/main.dol
213201

214-
rungame-nocompile-fast: game-nocompile-fast
215-
@echo If you are playing on a shifted game make sure Hyrule Field Speed hack is disabled in dolphin!
216-
dolphin-emu $(BUILD_DIR)/game/sys/main.dol
217-
218-
rungame-fast: game-fast
219-
@echo If you are playing on a shifted game make sure Hyrule Field Speed hack is disabled in dolphin!
220-
dolphin-emu $(BUILD_DIR)/game/sys/main.dol
221-
222202
rungame: game
223203
@echo If you are playing on a shifted game make sure Hyrule Field Speed hack is disabled in dolphin!
224204
dolphin-emu $(BUILD_DIR)/game/sys/main.dol
225205

226206
iso: game
227207
@$(PYTHON) tools/packageISO.py $(BUILD_DIR)/game/ $(TARGET_ISO)
228208

229-
230209
$(BUILD_DIR)/%.o: %.c $(BUILD_DIR)/%.d
231210
@mkdir -p $(@D)
232211
@echo building... $<

tools/assets_config.py

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from os import path
55

66
CONFIG_DESCRIPTIONS = {
7+
"oead_yaz0": "Use oead (pip install oead) for asset (de)compression (faster)",
78
"decompress_assets": "Decompress Yaz0 compressed assets (appends .c to the filename)",
89
"extract_arc": "Extract archive (.arc) files",
910
"convert_stages": "Convert Stage Files (.dzs and .dzr) to json",
@@ -13,6 +14,7 @@
1314
}
1415

1516
CONFIG_DEFAULTS = {
17+
"oead_yaz0": False,
1618
"decompress_assets": True,
1719
"extract_arc": True,
1820
"convert_stages": True,

tools/extract_game_assets.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def writeFile(name, data):
170170
if ("exceptions" in extractDef and str(name) in extractDef["exceptions"]) or ("config_key" in extractDef and config[extractDef["config_key"]] == False):
171171
extractDef = None
172172

173-
if config["decompress_assets"] == None:
173+
if config["decompress_assets"] == False:
174174
extractDef = None # If assets aren't being decompressed, just write the raw file
175175

176176
if extractDef == None:
@@ -245,16 +245,16 @@ def getDolInfo(disc):
245245

246246
return dolOffset, dolSize
247247

248-
def extract(isoPath: Path, gamePath: Path, yaz0Encoder: str, config_file: str):
249-
if yaz0Encoder == "oead":
248+
def extract(isoPath: Path, gamePath: Path, config_file: str):
249+
global config
250+
config = assets_config.getConfig(config_file,update=True)
251+
if config["oead_yaz0"]:
250252
try:
251253
from oead import yaz0
252254
global yaz0DecompressFunction
253255
yaz0DecompressFunction = yaz0.decompress
254256
except:
255257
print("Extract: oead isn't installed, falling back to native yaz0")
256-
global config
257-
config = assets_config.getConfig(config_file,update=True)
258258
isoPath = isoPath.absolute()
259259
cwd = os.getcwd()
260260
os.chdir(gamePath)
@@ -302,7 +302,7 @@ def extract(isoPath: Path, gamePath: Path, yaz0Encoder: str, config_file: str):
302302

303303

304304
def main():
305-
extract(Path(sys.argv[1]), Path(sys.argv[2]), sys.argv[3], sys.argv[4])
305+
extract(Path(sys.argv[1]), Path(sys.argv[2]), sys.argv[3])
306306

307307

308308
if __name__ == "__main__":

0 commit comments

Comments
 (0)