ZAPD update: Gotta go fast! (#226)

* update extract_assets script

* git subrepo pull --force tools/ZAPD

subrepo:
  subdir:   "tools/ZAPD"
  merged:   "820678b4"
upstream:
  origin:   "https://github.com/zeldaret/ZAPD.git"
  branch:   "master"
  commit:   "820678b4"
git-subrepo:
  version:  "0.4.3"
  origin:   "???"
  commit:   "???"

* fixes and rgba16 format change

* git subrepo pull --force tools/ZAPD

subrepo:
  subdir:   "tools/ZAPD"
  merged:   "6be9af65d"
upstream:
  origin:   "https://github.com/zeldaret/ZAPD.git"
  branch:   "master"
  commit:   "6be9af65d"
git-subrepo:
  version:  "0.4.3"
  origin:   "???"
  commit:   "???"

* Update warning counts
This commit is contained in:
Anghelo Carvajal
2021-07-28 21:55:02 -04:00
committed by GitHub
parent df1fd4adc1
commit b292647ea2
68 changed files with 1198 additions and 564 deletions
+1
View File
@@ -35,6 +35,7 @@ graphs/
*.png
*.jpg
!*_custom*
.extracted-assets.json
# Per-user configuration
.python-version
@@ -3,7 +3,7 @@
<!-- Debris from explosion -->
<DList Name="gClearTagDebrisEffectMaterialDL" Offset="0x3130"/>
<Texture Name="gClearTagDebrisEffectTex" OutName="clear_tag_debris_effect" Format="rgb5a1" Width="16" Height="16" Offset="0x2F00"/>
<Texture Name="gClearTagDebrisEffectTex" OutName="clear_tag_debris_effect" Format="rgba16" Width="16" Height="16" Offset="0x2F00"/>
<DList Name="gClearTagDebrisEffectDL" Offset="0x31B0"/>
<Array Name="gClearTagDebrisEffectVtx" Count="3" Offset="0x3100">
<Vtx/>
@@ -15,7 +15,7 @@
<Room Name="Z2_BANDROOM_room_03" Offset="0x0"/>
</File>
<File Name="Z2_BANDROOM_room_04" Segment="3" Game="MM">
<Texture Name="Z2_BANDROOM_room_04Tex_005A38" Format="rgb5a1" Width="64" Height="64" Offset="0x5A38"/>
<Texture Name="Z2_BANDROOM_room_04Tex_005A38" Format="rgba16" Width="64" Height="64" Offset="0x5A38"/>
<Room Name="Z2_BANDROOM_room_04" Offset="0x0"/>
</File>
+3 -3
View File
@@ -3,8 +3,8 @@
<Scene Name="Z2_CASTLE" Offset="0x0"/>
</File>
<File Name="Z2_CASTLE_room_00" Segment="3" Game="MM">
<Texture Name="Z2_CASTLE_room_00Tex_00FFB8" Format="rgb5a1" Width="64" Height="64" Offset="0xFFB8"/>
<Texture Name="Z2_CASTLE_room_00Tex_0127B8" Format="rgb5a1" Width="32" Height="128" Offset="0x127B8"/>
<Texture Name="Z2_CASTLE_room_00Tex_00FFB8" Format="rgba16" Width="64" Height="64" Offset="0xFFB8"/>
<Texture Name="Z2_CASTLE_room_00Tex_0127B8" Format="rgba16" Width="32" Height="128" Offset="0x127B8"/>
<Room Name="Z2_CASTLE_room_00" Offset="0x0"/>
</File>
@@ -18,7 +18,7 @@
<Room Name="Z2_CASTLE_room_03" Offset="0x0"/>
</File>
<File Name="Z2_CASTLE_room_04" Segment="3" Game="MM">
<Texture Name="Z2_CASTLE_room_04Tex_004AC0" Format="rgb5a1" Width="64" Height="64" Offset="0x4AC0"/>
<Texture Name="Z2_CASTLE_room_04Tex_004AC0" Format="rgba16" Width="64" Height="64" Offset="0x4AC0"/>
<Room Name="Z2_CASTLE_room_04" Offset="0x0"/>
</File>
@@ -1,7 +1,7 @@
<Root>
<File Name="Z2_GORONSHOP" Segment="2" Game="MM">
<Texture Name="Z2_GORONSHOPTex_004630" Format="i8" Width="128" Height="64" Offset="0x4630"/>
<Texture Name="Z2_GORONSHOPTex_009230" Format="rgb5a1" Width="64" Height="64" Offset="0x9230"/>
<Texture Name="Z2_GORONSHOPTex_009230" Format="rgba16" Width="64" Height="64" Offset="0x9230"/>
<Scene Name="Z2_GORONSHOP" Offset="0x0"/>
</File>
+1 -1
View File
@@ -3,7 +3,7 @@
<Scene Name="Z2_IKANA" Offset="0x0"/>
</File>
<File Name="Z2_IKANA_room_00" Segment="3" Game="MM">
<Texture Name="Z2_IKANA_room_00Tex_020A40" Format="rgb5a1" Width="64" Height="64" Offset="0x20A40"/>
<Texture Name="Z2_IKANA_room_00Tex_020A40" Format="rgba16" Width="64" Height="64" Offset="0x20A40"/>
<Room Name="Z2_IKANA_room_00" Offset="0x0"/>
</File>
@@ -1,6 +1,6 @@
<Root>
<File Name="Z2_KONPEKI_ENT" Segment="2" Game="MM">
<Texture Name="Z2_KONPEKI_ENTTex_005020" Format="rgb5a1" Width="64" Height="64" Offset="0x5020"/>
<Texture Name="Z2_KONPEKI_ENTTex_005020" Format="rgba16" Width="64" Height="64" Offset="0x5020"/>
<Scene Name="Z2_KONPEKI_ENT" Offset="0x0"/>
</File>
+61 -28
View File
@@ -1,15 +1,18 @@
#!/usr/bin/env python3
import argparse
from multiprocessing import Pool, cpu_count, Event
from multiprocessing import Pool, cpu_count, Event, Manager
import os
import json
import time
import signal
# Returns True if outFile doesn't exists
# or if inFile has been modified after the last modification of outFile
def checkTouchedFile(inFile: str, outFile: str) -> bool:
if not os.path.exists(outFile):
return True
return os.path.getmtime(inFile) > os.path.getmtime(outFile)
EXTRACTED_ASSETS_NAMEFILE = ".extracted-assets.json"
def SignalHandler(sig, frame):
print(f'Signal {sig} received. Aborting...')
mainAbort.set()
# Don't exit immediately to update the extracted assets file.
def ExtractFile(xmlPath, basromPath, outputPath, outputSourcePath):
if globalAbort.is_set():
@@ -17,6 +20,7 @@ def ExtractFile(xmlPath, basromPath, outputPath, outputSourcePath):
return
execStr = "tools/ZAPD/ZAPD.out e -eh -i %s -b %s -o %s -osf %s -gsf 1 -rconf tools/ZAPDConfigs/MM/Config.xml" % (xmlPath, basromPath, outputPath, outputSourcePath)
# execStr = "tools/ZAPD/ZAPD.out e -eh -i %s -b baserom/ -o %s -osf %s -gsf 1 -rconf tools/ZAPDConfigs/MM/Config.xml" % (xmlPath, outputPath, outputSourcePath)
if globalUnaccounted:
execStr += " -wu"
@@ -33,34 +37,43 @@ def ExtractFunc(fullPath):
*pathList, xmlName = fullPath.split(os.sep)
objectName = os.path.splitext(xmlName)[0]
outPath = os.path.join("assets", *pathList[2:-1], objectName)
if "scenes" in pathList:
outPath = os.path.join("assets", *pathList[2:])
else:
outPath = os.path.join("assets", *pathList[2:], objectName)
outSourcePath = outPath
# TODO: remove condition when NBS is merged
if "overlays" in pathList:
basromPath = os.path.join("baserom", *pathList[2:-1])
basromPath = os.path.join("baserom", *pathList[2:])
else:
basromPath = os.path.join("baserom", "assets", *pathList[2:-1])
## MM doesn't have _scene prefixed files, so this check is not necessary.
## This _may_ change in the future, so I wont delete this for now.
#isScene = fullPath.startswith("assets/xml/scenes/")
#if isScene:
# objectName += "_scene"
if not globalForce:
cFile = os.path.join(outPath, objectName + ".c")
hFile = os.path.join(outPath, objectName + ".h")
if not checkTouchedFile(fullPath, cFile) and not checkTouchedFile(fullPath, hFile):
if fullPath in globalExtractedAssetsTracker:
timestamp = globalExtractedAssetsTracker[fullPath]["timestamp"]
modificationTime = int(os.path.getmtime(fullPath))
if modificationTime < timestamp:
# XML has not been modified since last extraction.
return
currentTimeStamp = int(time.time())
ExtractFile(fullPath, basromPath, outPath, outSourcePath)
def initializeWorker(force: bool, abort, unaccounted: bool):
global globalForce
if not globalAbort.is_set():
# Only update timestamp on succesful extractions
if fullPath not in globalExtractedAssetsTracker:
globalExtractedAssetsTracker[fullPath] = globalManager.dict()
globalExtractedAssetsTracker[fullPath]["timestamp"] = currentTimeStamp
def initializeWorker(abort, unaccounted: bool, extractedAssetsTracker: dict, manager):
global globalAbort
global globalUnaccounted
globalForce = force
global globalExtractedAssetsTracker
global globalManager
globalAbort = abort
globalUnaccounted = unaccounted
globalExtractedAssetsTracker = extractedAssetsTracker
globalManager = manager
def main():
parser = argparse.ArgumentParser(description="baserom asset extractor")
@@ -69,17 +82,31 @@ def main():
parser.add_argument("-u", "--unaccounted", help="Enables ZAPD unaccounted detector warning system.", action="store_true")
args = parser.parse_args()
abort = Event()
global mainAbort
mainAbort = Event()
manager = Manager()
signal.signal(signal.SIGINT, SignalHandler)
extractedAssetsTracker = manager.dict()
if os.path.exists(EXTRACTED_ASSETS_NAMEFILE) and not args.force:
with open(EXTRACTED_ASSETS_NAMEFILE, encoding='utf-8') as f:
extractedAssetsTracker.update(json.load(f, object_hook=manager.dict))
asset_path = args.single
if asset_path is not None:
# Always force if -s is used.
initializeWorker(True, abort, args.unaccounted)
fullPath = os.path.join("assets", "xml", asset_path + ".xml")
if not os.path.exists(fullPath):
print(f"Error. File {fullPath} doesn't exists.", file=os.sys.stderr)
exit(1)
initializeWorker(mainAbort, args.unaccounted, extractedAssetsTracker, manager)
# Always extract if -s is used.
if fullPath in extractedAssetsTracker:
del extractedAssetsTracker[fullPath]
ExtractFunc(fullPath)
else:
xmlFiles = []
for currentPath, folders, files in os.walk(os.path.join("assets", "xml")):
for currentPath, _, files in os.walk(os.path.join("assets", "xml")):
for file in files:
fullPath = os.path.join(currentPath, file)
if file.endswith(".xml"):
@@ -87,10 +114,16 @@ def main():
numCores = cpu_count()
print("Extracting assets with " + str(numCores) + " CPU cores.")
with Pool(numCores, initializer=initializeWorker, initargs=(args.force, abort, args.unaccounted)) as p:
with Pool(numCores, initializer=initializeWorker, initargs=(mainAbort, args.unaccounted, extractedAssetsTracker, manager)) as p:
p.map(ExtractFunc, xmlFiles)
if abort.is_set():
with open(EXTRACTED_ASSETS_NAMEFILE, 'w', encoding='utf-8') as f:
serializableDict = dict()
for xml, data in extractedAssetsTracker.items():
serializableDict[xml] = dict(data)
json.dump(dict(serializableDict), f, ensure_ascii=False, indent=4)
if mainAbort.is_set():
exit(1)
if __name__ == "__main__":
+2 -2
View File
@@ -6,7 +6,7 @@
[subrepo]
remote = https://github.com/zeldaret/ZAPD.git
branch = master
commit = ca229f19b991c613c29afade3d70b100522cece1
parent = 6ab539cda1870420d07e38e25db09208fd7b21a8
commit = 6be9af65d39a1608ef854efbaf0bf9399aac5da1
parent = 83546045c55d692e45ec25d3f2aac76b48945075
method = merge
cmdver = 0.4.3
+30
View File
@@ -38,6 +38,36 @@ pipeline {
}
}
}
stage('Checkout mm') {
steps {
dir('mm') {
git url: 'https://github.com/zeldaret/mm.git'
}
}
}
stage('Set up mm') {
steps {
dir('mm') {
sh 'cp /usr/local/etc/roms/mm.us.rev1.z64 baserom.mm.us.rev1.z64'
// Identical to `make setup` except for copying our newer ZAPD.out into mm
sh 'git submodule update --init --recursive'
sh 'make -C tools'
sh 'cp ../ZAPD.out tools/ZAPD/'
sh 'python3 tools/extract_rom.py baserom.mm.us.rev1.z64'
sh 'python3 extract_assets.py'
}
}
}
stage('Build mm') {
steps {
dir('mm') {
sh 'make assembly -j'
sh 'make -j'
}
}
}
}
post {
always {
+19 -19
View File
@@ -1,41 +1,41 @@
OPTIMIZATION_ON ?= 1
ASAN ?= 0
DEPRECATION_OFF ?= 0
DEPRECATION_ON ?= 1
DEBUG ?= 0
CFLAGS ?=
CXXFLAGS ?=
COPYCHECK_ARGS ?=
CC := g++
CXX := g++
INC := -I ZAPD -I lib/assimp/include -I lib/elfio -I lib/json/include -I lib/stb -I lib/tinygltf -I lib/libgfxd -I lib/tinyxml2
CFLAGS += -fpic -std=c++17 -rdynamic -Wall -fno-omit-frame-pointer
CXXFLAGS += -fpic -std=c++17 -Wall -fno-omit-frame-pointer
ifneq ($(DEBUG),0)
OPTIMIZATION_ON = 0
DEPRECATION_OFF = 1
CFLAGS += -g3 -DDEVELOPMENT
CXXFLAGS += -g3 -DDEVELOPMENT
COPYCHECK_ARGS += --devel
DEPRECATION_ON = 0
endif
ifeq ($(OPTIMIZATION_ON),0)
CFLAGS += -O0
CXXFLAGS += -O0
else
CFLAGS += -O2
CXXFLAGS += -O2 -march=native -mtune=native
endif
ifneq ($(ASAN),0)
CFLAGS += -fsanitize=address
CXXFLAGS += -fsanitize=address
endif
ifneq ($(DEPRECATION_OFF),0)
CFLAGS += -DDEPRECATION_OFF
ifneq ($(DEPRECATION_ON),0)
CXXFLAGS += -DDEPRECATION_ON
endif
# CFLAGS += -DTEXTURE_DEBUG
# CXXFLAGS += -DTEXTURE_DEBUG
LDFLAGS := -lstdc++ -lm -ldl -lpng
LDFLAGS := -ldl -lpng
UNAME := $(shell uname)
FS_INC ?=
ifneq ($(UNAME), Darwin)
FS_INC += -lstdc++fs
CFLAGS += -Wl,-export-dynamic
LDFLAGS += -Wl,-export-dynamic -lstdc++fs
endif
SRC_DIRS := ZAPD ZAPD/ZRoom ZAPD/ZRoom/Commands ZAPD/Overlays ZAPD/HighLevel
@@ -66,13 +66,13 @@ format:
.PHONY: all genbuildinfo copycheck clean rebuild format
%.o: %.cpp
$(CC) $(CFLAGS) $(INC) -c $< -o $@ $(LDFLAGS)
$(CXX) $(CXXFLAGS) $(INC) -c $< -o $@
ZAPD/Main.o: genbuildinfo ZAPD/Main.cpp
$(CC) $(CFLAGS) $(INC) -c ZAPD/Main.cpp -o $@ $(LDFLAGS)
$(CXX) $(CXXFLAGS) $(INC) -c ZAPD/Main.cpp -o $@
lib/libgfxd/libgfxd.a:
$(MAKE) -C lib/libgfxd
ZAPD.out: $(O_FILES) lib/libgfxd/libgfxd.a
$(CC) $(CFLAGS) $(INC) $(O_FILES) lib/libgfxd/libgfxd.a -o $@ $(FS_INC) $(LDFLAGS)
$(CXX) $(CXXFLAGS) $(INC) $(O_FILES) lib/libgfxd/libgfxd.a -o $@ $(FS_INC) $(LDFLAGS)
+6 -1
View File
@@ -26,7 +26,7 @@ You can configure a bit your ZAPD build with the following options:
- `OPTIMIZATION_ON`: If set to `0` optimizations will be disabled (compile with `-O0`). Any other value compiles with `-O2`. Defaults to `1`.
- `ASAN`: If it is set to a non-zero then ZAPD will be compiled with Address Sanitizer enabled (`-fsanitize=address`). Defaults to `0`.
- `DEPRECATION_OFF`: If it is set to a non-zero then deprecation warnings will be disabled. Defaults to `0`.
- `DEPRECATION_ON`: If it is set to a zero then deprecation warnings will be disabled. Defaults to `1`.
- `DEBUG`: If non-zero, ZAPD will be compiled in _development mode_. This implies the following:
- Debugging symbols enabled (`-g3`). They are disabled by default.
- `OPTIMIZATION_ON=0`: Disables optimizations (`-O0`).
@@ -104,6 +104,11 @@ ZAPD also accepts the following list of extra parameters:
- `2` (and higher): Debug.
- `-wu` / `--warn-unaccounted`: Enable warnings for each unaccounted block of data found.
- Can be used only in `e` or `bsf` modes.
- `-vu` / `--verbose-unaccounted`: Changes how unaccounteds are outputted. Max 4 bytes per line (a word) and add a comment with the offset of each of those lines.
- Could be useful for looking at raw data or testing.
- Can be used only in `e` or `bsf` modes.
- `-tm MODE`: Test Mode (enables certain experimental features). To enable it, set `MODE` to `1`.
- `-wno` / `--warn-no-offsets` : Enable warnings for nodes that dont have offsets specified. Takes priority over `-eno`/ `--error-no-offsets`.
- `-eno`/ `--error-no-offsets` : Enable errors for nodes that dont have offsets specified.
Additionally, you can pass the flag `--version` to see the current ZAPD version. If that flag is passed, ZAPD will ignore any other parameter passed.
+6 -6
View File
@@ -109,7 +109,7 @@ public:
uint32_t floatData = ((uint32_t)data[offset + 0] << 24) +
((uint32_t)data[offset + 1] << 16) +
((uint32_t)data[offset + 2] << 8) + (uint32_t)data[offset + 3];
static_assert(sizeof(uint32_t) == sizeof(float));
static_assert(sizeof(uint32_t) == sizeof(float), "expected 32-bit float");
std::memcpy(&value, &floatData, sizeof(value));
return value;
}
@@ -120,7 +120,7 @@ public:
uint32_t floatData = ((uint32_t)data[offset + 0] << 24) +
((uint32_t)data[offset + 1] << 16) +
((uint32_t)data[offset + 2] << 8) + (uint32_t)data[offset + 3];
static_assert(sizeof(uint32_t) == sizeof(float));
static_assert(sizeof(uint32_t) == sizeof(float), "expected 32-bit float");
std::memcpy(&value, &floatData, sizeof(value));
return value;
}
@@ -133,10 +133,10 @@ public:
((uint64_t)data[offset + 2] << 40) + ((uint64_t)data[offset + 3] << 32) +
((uint64_t)data[offset + 4] << 24) + ((uint64_t)data[offset + 5] << 16) +
((uint64_t)data[offset + 6] << 8) + ((uint64_t)data[offset + 7]);
static_assert(sizeof(uint64_t) == sizeof(double));
static_assert(sizeof(uint64_t) == sizeof(double), "expected 64-bit double");
// Checks if the float format on the platform the ZAPD binary is running on supports the
// same float format as the object file.
static_assert(std::numeric_limits<float>::is_iec559);
static_assert(std::numeric_limits<float>::is_iec559, "expected IEC559 floats on host machine");
std::memcpy(&value, &floatData, sizeof(value));
return value;
}
@@ -149,10 +149,10 @@ public:
((uint64_t)data[offset + 2] << 40) + ((uint64_t)data[offset + 3] << 32) +
((uint64_t)data[offset + 4] << 24) + ((uint64_t)data[offset + 5] << 16) +
((uint64_t)data[offset + 6] << 8) + ((uint64_t)data[offset + 7]);
static_assert(sizeof(uint64_t) == sizeof(double));
static_assert(sizeof(uint64_t) == sizeof(double), "expected 64-bit double");
// Checks if the float format on the platform the ZAPD binary is running on supports the
// same float format as the object file.
static_assert(std::numeric_limits<double>::is_iec559);
static_assert(std::numeric_limits<double>::is_iec559, "expected IEC559 doubles on host machine");
std::memcpy(&value, &floatData, sizeof(value));
return value;
}
+1 -1
View File
@@ -19,7 +19,7 @@ class Directory
public:
static std::string GetCurrentDirectory() { return fs::current_path().u8string(); }
static bool Exists(const std::string& path) { return fs::exists(fs::path(path)); }
static bool Exists(const fs::path& path) { return fs::exists(path); }
static void CreateDirectory(const std::string& path)
{
+7 -6
View File
@@ -5,18 +5,19 @@
#include <stdio.h>
#include <string>
#include <vector>
#include "Directory.h"
#include "StringHelper.h"
class File
{
public:
static bool Exists(const std::string& filePath)
static bool Exists(const fs::path& filePath)
{
std::ifstream file(filePath, std::ios::in | std::ios::binary | std::ios::ate);
return file.good();
}
static std::vector<uint8_t> ReadAllBytes(const std::string& filePath)
static std::vector<uint8_t> ReadAllBytes(const fs::path& filePath)
{
std::ifstream file(filePath, std::ios::in | std::ios::binary | std::ios::ate);
int32_t fileSize = (int32_t)file.tellg();
@@ -29,7 +30,7 @@ public:
return result;
};
static std::string ReadAllText(const std::string& filePath)
static std::string ReadAllText(const fs::path& filePath)
{
std::ifstream file(filePath, std::ios::in | std::ios::binary | std::ios::ate);
int32_t fileSize = (int32_t)file.tellg();
@@ -43,7 +44,7 @@ public:
return str;
};
static std::vector<std::string> ReadAllLines(const std::string& filePath)
static std::vector<std::string> ReadAllLines(const fs::path& filePath)
{
std::string text = ReadAllText(filePath);
std::vector<std::string> lines = StringHelper::Split(text, "\n");
@@ -51,13 +52,13 @@ public:
return lines;
};
static void WriteAllBytes(const std::string& filePath, const std::vector<uint8_t>& data)
static void WriteAllBytes(const fs::path& filePath, const std::vector<uint8_t>& data)
{
std::ofstream file(filePath, std::ios::binary);
file.write((char*)data.data(), data.size());
};
static void WriteAllText(const std::string& filePath, const std::string& text)
static void WriteAllText(const fs::path& filePath, const std::string& text)
{
std::ofstream file(filePath, std::ios::out);
file.write(text.c_str(), text.size());
+2 -1
View File
@@ -25,6 +25,7 @@ Globals::Globals()
useExternalResources = true;
lastScene = nullptr;
verbosity = VerbosityLevel::VERBOSITY_SILENT;
outputPath = Directory::GetCurrentDirectory();
}
std::string Globals::FindSymbolSegRef(int32_t segNumber, uint32_t symbolAddress)
@@ -50,7 +51,7 @@ std::string Globals::FindSymbolSegRef(int32_t segNumber, uint32_t symbolAddress)
{
if (std::string(child->Name()) == "File")
{
ZFile* file = new ZFile(fileMode, child, "", "", "", filePath, true);
ZFile* file = new ZFile(fileMode, child, "", "", filePath, true);
file->GeneratePlaceholderDeclarations();
segmentRefFiles[segNumber] = file;
break;
+3
View File
@@ -53,6 +53,9 @@ public:
ZGame game;
GameConfig cfg;
bool warnUnaccounted = false;
bool warnNoOffset = false;
bool errorNoOffset = false;
bool verboseUnaccounted = false;
std::vector<ZFile*> files;
std::vector<int32_t> segments;
@@ -244,7 +244,7 @@ void HLModelIntermediette::FromZSkeleton(HLModelIntermediette* model, ZSkeleton*
model->hasSkeleton = true;
// Start at the root skeleton node, go down...
ProcessZSkeletonLimb(model, zSkeleton, zSkeleton->limbs[0]);
// ProcessZSkeletonLimb(model, zSkeleton, zSkeleton->limbs[0]);
}
void HLModelIntermediette::ProcessZSkeletonLimb(HLModelIntermediette* model, ZSkeleton* zSkeleton,
@@ -879,7 +879,7 @@ void HLTextureIntermediette::InitFromXML(tinyxml2::XMLElement* xmlElement)
fileName = xmlElement->Attribute("TextureName");
// std::string format = xmlElement->Attribute("Format");
std::string format = "rgb5a1"; // TEST
std::string format = "rgba16"; // TEST
// tex = HLTexture::FromPNG(fileName,
// (HLTextureType)ZTexture::GetTextureTypeFromString(format));
+20 -11
View File
@@ -27,8 +27,7 @@
using namespace tinyxml2;
bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, const fs::path& outPath,
ZFileMode fileMode);
bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, ZFileMode fileMode);
void BuildAssetTexture(const fs::path& pngFilePath, TextureType texType, const fs::path& outPath);
void BuildAssetBackground(const fs::path& imageFilePath, const fs::path& outPath);
@@ -242,6 +241,18 @@ int main(int argc, char* argv[])
{
Globals::Instance->warnUnaccounted = true;
}
else if (arg == "-wno" || arg == "--warn-no-offset")
{
Globals::Instance->warnNoOffset = true;
}
else if (arg == "-eno" || arg == "--error-no-offset")
{
Globals::Instance->errorNoOffset = true;
}
else if (arg == "-vu" || arg == "--verbose-unaccounted") // Verbose unaccounted
{
Globals::Instance->verboseUnaccounted = true;
}
}
if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_INFO)
@@ -249,8 +260,8 @@ int main(int argc, char* argv[])
if (fileMode == ZFileMode::Extract || fileMode == ZFileMode::BuildSourceFile)
{
bool parseSuccessful = Parse(Globals::Instance->inputPath, Globals::Instance->baseRomPath,
Globals::Instance->outputPath, fileMode);
bool parseSuccessful =
Parse(Globals::Instance->inputPath, Globals::Instance->baseRomPath, fileMode);
if (!parseSuccessful)
return 1;
@@ -287,13 +298,11 @@ int main(int argc, char* argv[])
File::WriteAllText(Globals::Instance->outputPath.string(),
overlay->GetSourceOutputCode(""));
}
delete g;
return 0;
}
bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, const fs::path& outPath,
ZFileMode fileMode)
bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, ZFileMode fileMode)
{
XMLDocument doc;
XMLError eResult = doc.LoadFile(xmlFilePath.string().c_str());
@@ -317,7 +326,7 @@ bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, const fs::path
{
if (std::string(child->Name()) == "File")
{
ZFile* file = new ZFile(fileMode, child, basePath, outPath, "", xmlFilePath, false);
ZFile* file = new ZFile(fileMode, child, basePath, "", xmlFilePath, false);
Globals::Instance->files.push_back(file);
}
else
@@ -332,9 +341,9 @@ bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, const fs::path
for (ZFile* file : Globals::Instance->files)
{
if (fileMode == ZFileMode::BuildSourceFile)
file->BuildSourceFile(outPath);
file->BuildSourceFile();
else
file->ExtractResources(outPath);
file->ExtractResources();
}
// All done, free files
@@ -397,7 +406,7 @@ void BuildAssetModelIntermediette(const fs::path& outPath)
void BuildAssetAnimationIntermediette(const fs::path& animPath, const fs::path& outPath)
{
std::vector<std::string> split = StringHelper::Split(outPath.string(), "/");
ZFile* file = new ZFile("", split[split.size() - 2]);
ZFile* file = new ZFile(split[split.size() - 2]);
HLAnimationIntermediette* anim = HLAnimationIntermediette::FromXML(animPath.string());
ZAnimation* zAnim = anim->ToZAnimation();
zAnim->SetName(Path::GetFileNameWithoutExtension(split[split.size() - 1]));
+10 -2
View File
@@ -1,11 +1,19 @@
#pragma once
#include <algorithm>
#include <cstring>
#include <numeric>
#include <stdarg.h>
#include <string>
#include <vector>
#include <algorithm>
#ifndef __PRETTY_FUNCTION__
#ifdef _MSC_VER
#define __PRETTY_FUNCTION__ __FUNCSIG__
#else
#define __PRETTY_FUNCTION__ __func__
#endif
#endif
class StringHelper
{
@@ -101,7 +109,7 @@ public:
static std::string BoolStr(bool b) { return b ? "true" : "false"; }
static bool HasOnlyDigits(const std::string &str)
static bool HasOnlyDigits(const std::string& str)
{
return std::all_of(str.begin(), str.end(), ::isdigit);
}

Some files were not shown because too many files have changed in this diff Show More