mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-03 14:34:32 +00:00
Updated to use latest version of ZAPD (#777)
* Updated config file * Added missing files * Temporarily removed asm_processor changes. * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "96ffc1e62" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "96ffc1e62" git-subrepo: version: "0.4.3" origin: "???" commit: "???" * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "179af7d11" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "179af7d11" git-subrepo: version: "0.4.3" origin: "???" commit: "???" * Cleanup and fixes. * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "50ad2fe78" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "50ad2fe78" git-subrepo: version: "0.4.3" origin: "???" commit: "???" * Makefile fix * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "b9120803e" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "b9120803e" git-subrepo: version: "0.4.3" origin: "???" commit: "???" Co-authored-by: Jack Walker <7463599+Jack-Walker@users.noreply.github.com>
This commit is contained in:
parent
6e58354c71
commit
0432011bd9
141 changed files with 7843 additions and 4338 deletions
2
Makefile
2
Makefile
|
@ -167,6 +167,8 @@ build/src/overlays/actors/%.o: CC := python3 tools/asm_processor/build.py $(CC)
|
|||
build/src/overlays/effects/%.o: CC := python3 tools/asm_processor/build.py $(CC) -- $(AS) $(ASFLAGS) --
|
||||
build/src/overlays/gamestates/%.o: CC := python3 tools/asm_processor/build.py $(CC) -- $(AS) $(ASFLAGS) --
|
||||
|
||||
build/assets/%.o: CC := python3 tools/asm_processor/build.py $(CC) -- $(AS) $(ASFLAGS) --
|
||||
|
||||
#### Main Targets ###
|
||||
|
||||
all: $(ROM)
|
||||
|
|
2
assets/.gitignore
vendored
2
assets/.gitignore
vendored
|
@ -2,3 +2,5 @@
|
|||
*.c
|
||||
*.h
|
||||
*.cfg
|
||||
*.vtx.inc
|
||||
*.dlist.inc
|
|
@ -6,25 +6,26 @@ from shutil import copyfile
|
|||
from multiprocessing import Pool
|
||||
from multiprocessing import cpu_count
|
||||
|
||||
def Extract(xmlPath, outputPath):
|
||||
ExtractFile(xmlPath, outputPath, 1, 0)
|
||||
def Extract(xmlPath, outputPath, outputSourcePath):
|
||||
ExtractFile(xmlPath, outputPath, outputSourcePath, 1, 0)
|
||||
|
||||
def ExtractScene(xmlPath, outputPath):
|
||||
ExtractFile(xmlPath, outputPath, 1, 1)
|
||||
def ExtractScene(xmlPath, outputPath, outputSourcePath):
|
||||
ExtractFile(xmlPath, outputPath, outputSourcePath, 1, 1)
|
||||
|
||||
def ExtractFile(xmlPath, outputPath, genSrcFile, incFilePrefix):
|
||||
execStr = "tools/ZAPD/ZAPD.out e -eh -i %s -b baserom/ -o %s -gsf %i -ifp %i -sm tools/ZAPD/SymbolMap_OoTMqDbg.txt" % (xmlPath, outputPath, genSrcFile, incFilePrefix)
|
||||
def ExtractFile(xmlPath, outputPath, outputSourcePath, genSrcFile, incFilePrefix):
|
||||
execStr = "tools/ZAPD/ZAPD.out e -eh -i %s -b baserom/ -o %s -osf %s -gsf %i -ifp %i -rconf tools/ZAPDConfigs/MqDbg/Config.xml" % (xmlPath, outputPath, outputSourcePath, genSrcFile, incFilePrefix)
|
||||
|
||||
print(execStr)
|
||||
os.system(execStr)
|
||||
|
||||
def ExtractFunc(fullPath):
|
||||
outPath = ("assets/" + fullPath.split("assets/xml/")[1]).split(".xml")[0]
|
||||
outSourcePath = ("assets/" + fullPath.split("assets/xml/")[1]).split(".xml")[0]
|
||||
|
||||
if (fullPath.startswith("assets/xml/scenes/")):
|
||||
ExtractScene(fullPath, outPath)
|
||||
ExtractScene(fullPath, outPath, outSourcePath)
|
||||
else:
|
||||
Extract(fullPath, outPath)
|
||||
Extract(fullPath, outPath, outSourcePath)
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="baserom asset extractor")
|
||||
|
@ -35,7 +36,7 @@ def main():
|
|||
if asset_path is not None:
|
||||
if asset_path.endswith("/"):
|
||||
asset_path = asset_path[0:-1]
|
||||
Extract(f"assets/xml/{asset_path}.xml", f"assets/{asset_path}/")
|
||||
Extract(f"assets/xml/{asset_path}.xml", f"assets/{asset_path}/", f"assets/{asset_path}/")
|
||||
else:
|
||||
xmlFiles = []
|
||||
for currentPath, folders, files in os.walk("assets"):
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
[subrepo]
|
||||
remote = https://github.com/zeldaret/ZAPD.git
|
||||
branch = master
|
||||
commit = c4773301a17a5a9f9c964a3e7ba6dfbf0730a94b
|
||||
parent = 97f80eeb3f79bafac383fa6dd17765ae291e05d7
|
||||
commit = b9120803e6094a54192ed67d9585ab046101c816
|
||||
parent = 81b43ba32e564a00c976dec7d520e6bcb0b122f8
|
||||
method = merge
|
||||
cmdver = 0.4.3
|
||||
|
|
|
@ -1,5 +1,16 @@
|
|||
OPTIMIZATION_ON ?= 1
|
||||
|
||||
CC := g++
|
||||
CFLAGS := -g -std=c++17 -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 -O2 -rdynamic
|
||||
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 := -g3 -fpic -Wl,-export-dynamic -std=c++17 -rdynamic -Wall
|
||||
ifeq ($(OPTIMIZATION_ON),1)
|
||||
CFLAGS += -O2
|
||||
else
|
||||
CFLAGS += -O0
|
||||
endif
|
||||
|
||||
LDFLAGS := -ldl
|
||||
UNAME := $(shell uname)
|
||||
|
||||
FS_INC =
|
||||
|
@ -13,22 +24,28 @@ CPP_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.cpp))
|
|||
CPP_FILES += lib/tinyxml2/tinyxml2.cpp
|
||||
O_FILES := $(CPP_FILES:.cpp=.o)
|
||||
|
||||
all: ZAPD.out
|
||||
all: ZAPD.out copycheck
|
||||
|
||||
genbuildinfo:
|
||||
python3 ZAPD/genbuildinfo.py
|
||||
|
||||
copycheck: ZAPD.out
|
||||
python3 copycheck.py
|
||||
|
||||
clean:
|
||||
rm -f $(O_FILES) ZAPD.out
|
||||
$(MAKE) -C lib/libgfxd clean
|
||||
|
||||
rebuild: clean all
|
||||
|
||||
%.o: %.cpp genbuildinfo
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
%.o: %.cpp
|
||||
$(CC) $(CFLAGS) $(INC) -c $< -o $@ $(LDFLAGS)
|
||||
|
||||
ZAPD/Main.o: genbuildinfo ZAPD/Main.cpp
|
||||
$(CC) $(CFLAGS) $(INC) -c ZAPD/Main.cpp -o $@ $(LDFLAGS)
|
||||
|
||||
lib/libgfxd/libgfxd.a:
|
||||
$(MAKE) -C lib/libgfxd -j
|
||||
|
||||
ZAPD.out: $(O_FILES) lib/libgfxd/libgfxd.a
|
||||
$(CC) $(CFLAGS) $(O_FILES) lib/libgfxd/libgfxd.a -o $@ $(FS_INC)
|
||||
$(CC) $(CFLAGS) $(INC) $(O_FILES) lib/libgfxd/libgfxd.a -o $@ $(FS_INC) $(LDFLAGS)
|
||||
|
|
|
@ -7,71 +7,71 @@
|
|||
class BitConverter
|
||||
{
|
||||
public:
|
||||
static inline int8_t ToInt8BE(const uint8_t* data, int offset)
|
||||
static inline int8_t ToInt8BE(const uint8_t* data, int32_t offset)
|
||||
{
|
||||
return (uint8_t)data[offset + 0];
|
||||
}
|
||||
|
||||
static inline int8_t ToInt8BE(const std::vector<uint8_t>& data, int offset)
|
||||
static inline int8_t ToInt8BE(const std::vector<uint8_t>& data, int32_t offset)
|
||||
{
|
||||
return (uint8_t)data[offset + 0];
|
||||
}
|
||||
|
||||
static inline uint8_t ToUInt8BE(const uint8_t* data, int offset)
|
||||
static inline uint8_t ToUInt8BE(const uint8_t* data, int32_t offset)
|
||||
{
|
||||
return (uint8_t)data[offset + 0];
|
||||
}
|
||||
|
||||
static inline uint8_t ToUInt8BE(const std::vector<uint8_t>& data, int offset)
|
||||
static inline uint8_t ToUInt8BE(const std::vector<uint8_t>& data, int32_t offset)
|
||||
{
|
||||
return (uint8_t)data[offset + 0];
|
||||
}
|
||||
|
||||
static inline int16_t ToInt16BE(const uint8_t* data, int offset)
|
||||
static inline int16_t ToInt16BE(const uint8_t* data, int32_t offset)
|
||||
{
|
||||
return ((uint16_t)data[offset + 0] << 8) + (uint16_t)data[offset + 1];
|
||||
}
|
||||
|
||||
static inline int16_t ToInt16BE(const std::vector<uint8_t>& data, int offset)
|
||||
static inline int16_t ToInt16BE(const std::vector<uint8_t>& data, int32_t offset)
|
||||
{
|
||||
return ((uint16_t)data[offset + 0] << 8) + (uint16_t)data[offset + 1];
|
||||
}
|
||||
|
||||
static inline uint16_t ToUInt16BE(const uint8_t* data, int offset)
|
||||
static inline uint16_t ToUInt16BE(const uint8_t* data, int32_t offset)
|
||||
{
|
||||
return ((uint16_t)data[offset + 0] << 8) + (uint16_t)data[offset + 1];
|
||||
}
|
||||
|
||||
static inline uint16_t ToUInt16BE(const std::vector<uint8_t>& data, int offset)
|
||||
static inline uint16_t ToUInt16BE(const std::vector<uint8_t>& data, int32_t offset)
|
||||
{
|
||||
return ((uint16_t)data[offset + 0] << 8) + (uint16_t)data[offset + 1];
|
||||
}
|
||||
|
||||
static inline int32_t ToInt32BE(const uint8_t* data, int offset)
|
||||
static inline int32_t ToInt32BE(const uint8_t* data, int32_t offset)
|
||||
{
|
||||
return ((uint32_t)data[offset + 0] << 24) + ((uint32_t)data[offset + 1] << 16) +
|
||||
((uint32_t)data[offset + 2] << 8) + (uint32_t)data[offset + 3];
|
||||
}
|
||||
|
||||
static inline int32_t ToInt32BE(const std::vector<uint8_t>& data, int offset)
|
||||
static inline int32_t ToInt32BE(const std::vector<uint8_t>& data, int32_t offset)
|
||||
{
|
||||
return ((uint32_t)data[offset + 0] << 24) + ((uint32_t)data[offset + 1] << 16) +
|
||||
((uint32_t)data[offset + 2] << 8) + (uint32_t)data[offset + 3];
|
||||
}
|
||||
|
||||
static inline uint32_t ToUInt32BE(const uint8_t* data, int offset)
|
||||
static inline uint32_t ToUInt32BE(const uint8_t* data, int32_t offset)
|
||||
{
|
||||
return ((uint32_t)data[offset + 0] << 24) + ((uint32_t)data[offset + 1] << 16) +
|
||||
((uint32_t)data[offset + 2] << 8) + (uint32_t)data[offset + 3];
|
||||
}
|
||||
|
||||
static inline uint32_t ToUInt32BE(const std::vector<uint8_t>& data, int offset)
|
||||
static inline uint32_t ToUInt32BE(const std::vector<uint8_t>& data, int32_t offset)
|
||||
{
|
||||
return ((uint32_t)data[offset + 0] << 24) + ((uint32_t)data[offset + 1] << 16) +
|
||||
((uint32_t)data[offset + 2] << 8) + (uint32_t)data[offset + 3];
|
||||
}
|
||||
|
||||
static inline int64_t ToInt64BE(const uint8_t* data, int offset)
|
||||
static inline int64_t ToInt64BE(const uint8_t* data, int32_t offset)
|
||||
{
|
||||
return ((uint64_t)data[offset + 0] << 56) + ((uint64_t)data[offset + 1] << 48) +
|
||||
((uint64_t)data[offset + 2] << 40) + ((uint64_t)data[offset + 3] << 32) +
|
||||
|
@ -79,7 +79,7 @@ public:
|
|||
((uint64_t)data[offset + 6] << 8) + ((uint64_t)data[offset + 7]);
|
||||
}
|
||||
|
||||
static inline int64_t ToInt64BE(const std::vector<uint8_t>& data, int offset)
|
||||
static inline int64_t ToInt64BE(const std::vector<uint8_t>& data, int32_t offset)
|
||||
{
|
||||
return ((uint64_t)data[offset + 0] << 56) + ((uint64_t)data[offset + 1] << 48) +
|
||||
((uint64_t)data[offset + 2] << 40) + ((uint64_t)data[offset + 3] << 32) +
|
||||
|
@ -87,7 +87,7 @@ public:
|
|||
((uint64_t)data[offset + 6] << 8) + ((uint64_t)data[offset + 7]);
|
||||
}
|
||||
|
||||
static inline uint64_t ToUInt64BE(const uint8_t* data, int offset)
|
||||
static inline uint64_t ToUInt64BE(const uint8_t* data, int32_t offset)
|
||||
{
|
||||
return ((uint64_t)data[offset + 0] << 56) + ((uint64_t)data[offset + 1] << 48) +
|
||||
((uint64_t)data[offset + 2] << 40) + ((uint64_t)data[offset + 3] << 32) +
|
||||
|
@ -95,7 +95,7 @@ public:
|
|||
((uint64_t)data[offset + 6] << 8) + ((uint64_t)data[offset + 7]);
|
||||
}
|
||||
|
||||
static inline uint64_t ToUInt64BE(const std::vector<uint8_t>& data, int offset)
|
||||
static inline uint64_t ToUInt64BE(const std::vector<uint8_t>& data, int32_t offset)
|
||||
{
|
||||
return ((uint64_t)data[offset + 0] << 56) + ((uint64_t)data[offset + 1] << 48) +
|
||||
((uint64_t)data[offset + 2] << 40) + ((uint64_t)data[offset + 3] << 32) +
|
||||
|
@ -103,7 +103,7 @@ public:
|
|||
((uint64_t)data[offset + 6] << 8) + ((uint64_t)data[offset + 7]);
|
||||
}
|
||||
|
||||
static inline float ToFloatBE(const uint8_t* data, int offset)
|
||||
static inline float ToFloatBE(const uint8_t* data, int32_t offset)
|
||||
{
|
||||
float value;
|
||||
uint32_t floatData = ((uint32_t)data[offset + 0] << 24) +
|
||||
|
@ -114,7 +114,7 @@ public:
|
|||
return value;
|
||||
}
|
||||
|
||||
static inline float ToFloatBE(const std::vector<uint8_t>& data, int offset)
|
||||
static inline float ToFloatBE(const std::vector<uint8_t>& data, int32_t offset)
|
||||
{
|
||||
float value;
|
||||
uint32_t floatData = ((uint32_t)data[offset + 0] << 24) +
|
||||
|
@ -125,7 +125,7 @@ public:
|
|||
return value;
|
||||
}
|
||||
|
||||
static inline double ToDoubleBE(const uint8_t* data, int offset)
|
||||
static inline double ToDoubleBE(const uint8_t* data, int32_t offset)
|
||||
{
|
||||
double value;
|
||||
uint64_t floatData =
|
||||
|
@ -141,7 +141,7 @@ public:
|
|||
return value;
|
||||
}
|
||||
|
||||
static inline double ToDoubleBE(const std::vector<uint8_t>& data, int offset)
|
||||
static inline double ToDoubleBE(const std::vector<uint8_t>& data, int32_t offset)
|
||||
{
|
||||
double value;
|
||||
uint64_t floatData =
|
||||
|
|
23
tools/ZAPD/ZAPD/CRC32.h
Normal file
23
tools/ZAPD/ZAPD/CRC32.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
#pragma once
|
||||
|
||||
static uint32_t CRC32B(unsigned char* message, int32_t size)
|
||||
{
|
||||
int32_t byte, crc;
|
||||
int32_t mask;
|
||||
|
||||
crc = 0xFFFFFFFF;
|
||||
|
||||
for (int32_t i = 0; i < size; i++)
|
||||
{
|
||||
byte = message[i];
|
||||
crc = crc ^ byte;
|
||||
|
||||
for (int32_t j = 7; j >= 0; j--)
|
||||
{
|
||||
mask = -(crc & 1);
|
||||
crc = (crc >> 1) ^ (0xEDB88320 & mask);
|
||||
}
|
||||
}
|
||||
|
||||
return ~(uint32_t)(crc);
|
||||
}
|
|
@ -20,7 +20,7 @@ public:
|
|||
static std::vector<uint8_t> ReadAllBytes(const std::string& filePath)
|
||||
{
|
||||
std::ifstream file(filePath, std::ios::in | std::ios::binary | std::ios::ate);
|
||||
int fileSize = (int)file.tellg();
|
||||
int32_t fileSize = (int32_t)file.tellg();
|
||||
file.seekg(0);
|
||||
char* data = new char[fileSize];
|
||||
file.read(data, fileSize);
|
||||
|
@ -33,7 +33,7 @@ public:
|
|||
static std::string ReadAllText(const std::string& filePath)
|
||||
{
|
||||
std::ifstream file(filePath, std::ios::in | std::ios::binary | std::ios::ate);
|
||||
int fileSize = (int)file.tellg();
|
||||
int32_t fileSize = (int32_t)file.tellg();
|
||||
file.seekg(0);
|
||||
char* data = new char[fileSize + 1];
|
||||
memset(data, 0, fileSize + 1);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "Globals.h"
|
||||
#include <algorithm>
|
||||
#include "File.h"
|
||||
#include "Path.h"
|
||||
#include "tinyxml2.h"
|
||||
|
||||
using namespace tinyxml2;
|
||||
|
@ -13,21 +14,22 @@ Globals::Globals()
|
|||
Instance = this;
|
||||
|
||||
files = std::vector<ZFile*>();
|
||||
segments = std::vector<int>();
|
||||
segments = std::vector<int32_t>();
|
||||
symbolMap = std::map<uint32_t, std::string>();
|
||||
segmentRefs = map<int, string>();
|
||||
segmentRefFiles = map<int, ZFile*>();
|
||||
segmentRefs = map<int32_t, string>();
|
||||
segmentRefFiles = map<int32_t, ZFile*>();
|
||||
game = ZGame::OOT_RETAIL;
|
||||
genSourceFile = true;
|
||||
testMode = false;
|
||||
profile = false;
|
||||
includeFilePrefix = false;
|
||||
useLegacyZDList = false;
|
||||
useExternalResources = true;
|
||||
lastScene = nullptr;
|
||||
verbosity = VERBOSITY_SILENT;
|
||||
}
|
||||
|
||||
string Globals::FindSymbolSegRef(int segNumber, uint32_t symbolAddress)
|
||||
string Globals::FindSymbolSegRef(int32_t segNumber, uint32_t symbolAddress)
|
||||
{
|
||||
if (segmentRefs.find(segNumber) != segmentRefs.end())
|
||||
{
|
||||
|
@ -52,7 +54,7 @@ string Globals::FindSymbolSegRef(int segNumber, uint32_t symbolAddress)
|
|||
{
|
||||
if (string(child->Name()) == "File")
|
||||
{
|
||||
ZFile* file = new ZFile(fileMode, child, "", "", "", true);
|
||||
ZFile* file = new ZFile(fileMode, child, "", "", "", "", true);
|
||||
file->GeneratePlaceholderDeclarations();
|
||||
segmentRefFiles[segNumber] = file;
|
||||
break;
|
||||
|
@ -72,7 +74,10 @@ void Globals::ReadConfigFile(const std::string& configFilePath)
|
|||
XMLError eResult = doc.LoadFile(configFilePath.c_str());
|
||||
|
||||
if (eResult != tinyxml2::XML_SUCCESS)
|
||||
{
|
||||
throw std::runtime_error("Error: Unable to read config file.");
|
||||
return;
|
||||
}
|
||||
|
||||
XMLNode* root = doc.FirstChild();
|
||||
|
||||
|
@ -85,14 +90,74 @@ void Globals::ReadConfigFile(const std::string& configFilePath)
|
|||
if (string(child->Name()) == "SymbolMap")
|
||||
{
|
||||
string fileName = string(child->Attribute("File"));
|
||||
GenSymbolMap(fileName);
|
||||
GenSymbolMap(Path::GetDirectoryName(configFilePath) + "/" + fileName);
|
||||
}
|
||||
else if (string(child->Name()) == "Segment")
|
||||
{
|
||||
string fileName = string(child->Attribute("File"));
|
||||
int segNumber = child->IntAttribute("Number");
|
||||
int32_t segNumber = child->IntAttribute("Number");
|
||||
segmentRefs[segNumber] = fileName;
|
||||
}
|
||||
else if (string(child->Name()) == "ActorList")
|
||||
{
|
||||
string fileName = string(child->Attribute("File"));
|
||||
std::vector<std::string> lines =
|
||||
File::ReadAllLines(Path::GetDirectoryName(configFilePath) + "/" + fileName);
|
||||
|
||||
for (std::string line : lines)
|
||||
cfg.actorList.push_back(StringHelper::Strip(line, "\r"));
|
||||
}
|
||||
else if (string(child->Name()) == "ObjectList")
|
||||
{
|
||||
string fileName = string(child->Attribute("File"));
|
||||
std::vector<std::string> lines =
|
||||
File::ReadAllLines(Path::GetDirectoryName(configFilePath) + "/" + fileName);
|
||||
|
||||
for (std::string line : lines)
|
||||
cfg.objectList.push_back(StringHelper::Strip(line, "\r"));
|
||||
}
|
||||
else if (string(child->Name()) == "TexturePool")
|
||||
{
|
||||
string fileName = string(child->Attribute("File"));
|
||||
ReadTexturePool(Path::GetDirectoryName(configFilePath) + "/" + fileName);
|
||||
}
|
||||
else if (string(child->Name()) == "BGConfig")
|
||||
{
|
||||
cfg.bgScreenWidth = child->IntAttribute("ScreenWidth", 320);
|
||||
cfg.bgScreenHeight = child->IntAttribute("ScreenHeight", 240);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Globals::ReadTexturePool(const std::string& texturePoolXmlPath)
|
||||
{
|
||||
XMLDocument doc;
|
||||
XMLError eResult = doc.LoadFile(texturePoolXmlPath.c_str());
|
||||
|
||||
if (eResult != tinyxml2::XML_SUCCESS)
|
||||
{
|
||||
fprintf(stderr, "Warning: Unable to read texture pool XML with error code %i\n", eResult);
|
||||
return;
|
||||
}
|
||||
|
||||
XMLNode* root = doc.FirstChild();
|
||||
|
||||
if (root == nullptr)
|
||||
return;
|
||||
|
||||
for (XMLElement* child = root->FirstChildElement(); child != NULL;
|
||||
child = child->NextSiblingElement())
|
||||
{
|
||||
if (string(child->Name()) == "Texture")
|
||||
{
|
||||
string crcStr = string(child->Attribute("CRC"));
|
||||
string texPath = string(child->Attribute("Path"));
|
||||
string texName = "";
|
||||
|
||||
uint32_t crc = strtoul(crcStr.c_str(), NULL, 16);
|
||||
|
||||
cfg.texturePool[crc].path = texPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,22 +175,13 @@ void Globals::GenSymbolMap(const std::string& symbolMapPath)
|
|||
}
|
||||
}
|
||||
|
||||
void Globals::AddSegment(int segment)
|
||||
void Globals::AddSegment(int32_t segment)
|
||||
{
|
||||
if (std::find(segments.begin(), segments.end(), segment) == segments.end())
|
||||
segments.push_back(segment);
|
||||
}
|
||||
|
||||
bool Globals::HasSegment(int segment)
|
||||
bool Globals::HasSegment(int32_t segment)
|
||||
{
|
||||
return std::find(segments.begin(), segments.end(), segment) != segments.end();
|
||||
}
|
||||
|
||||
GameConfig::GameConfig()
|
||||
{
|
||||
segmentRefs = map<int, string>();
|
||||
segmentRefFiles = map<int, ZFile*>();
|
||||
symbolMap = std::map<uint32_t, std::string>();
|
||||
actorList = std::vector<std::string>();
|
||||
objectList = std::vector<std::string>();
|
||||
}
|
||||
|
|
|
@ -7,14 +7,33 @@
|
|||
#include "ZRoom/ZRoom.h"
|
||||
#include "ZTexture.h"
|
||||
|
||||
typedef enum VerbosityLevel
|
||||
enum VerbosityLevel
|
||||
{
|
||||
VERBOSITY_SILENT,
|
||||
VERBOSITY_INFO,
|
||||
VERBOSITY_DEBUG
|
||||
} VerbosityLevel;
|
||||
};
|
||||
|
||||
class GameConfig;
|
||||
struct TexturePoolEntry
|
||||
{
|
||||
fs::path path = ""; // Path to Shared Texture
|
||||
};
|
||||
|
||||
class GameConfig
|
||||
{
|
||||
public:
|
||||
std::map<int32_t, std::string> segmentRefs;
|
||||
std::map<int32_t, ZFile*> segmentRefFiles;
|
||||
std::map<uint32_t, std::string> symbolMap;
|
||||
std::vector<std::string> actorList;
|
||||
std::vector<std::string> objectList;
|
||||
std::map<uint32_t, TexturePoolEntry> texturePool; // Key = CRC
|
||||
|
||||
// ZBackground
|
||||
uint32_t bgScreenWidth = 320, bgScreenHeight = 240;
|
||||
|
||||
GameConfig() = default;
|
||||
};
|
||||
|
||||
class Globals
|
||||
{
|
||||
|
@ -26,39 +45,29 @@ public:
|
|||
bool testMode; // Enables certain experimental features
|
||||
bool profile; // Measure performance of certain operations
|
||||
bool includeFilePrefix; // Include the file prefix in symbols
|
||||
bool useLegacyZDList;
|
||||
VerbosityLevel verbosity; // ZAPD outputs additional information
|
||||
ZFileMode fileMode;
|
||||
std::string baseRomPath, inputPath, outputPath, cfgPath;
|
||||
fs::path baseRomPath, inputPath, outputPath, sourceOutputPath, cfgPath;
|
||||
TextureType texType;
|
||||
ZGame game;
|
||||
GameConfig cfg;
|
||||
bool warnUnaccounted = false;
|
||||
|
||||
std::vector<ZFile*> files;
|
||||
std::vector<int> segments;
|
||||
std::map<int, std::string> segmentRefs;
|
||||
std::map<int, ZFile*> segmentRefFiles;
|
||||
std::vector<int32_t> segments;
|
||||
std::map<int32_t, std::string> segmentRefs;
|
||||
std::map<int32_t, ZFile*> segmentRefFiles;
|
||||
ZRoom* lastScene;
|
||||
std::map<uint32_t, std::string> symbolMap;
|
||||
|
||||
Globals();
|
||||
std::string FindSymbolSegRef(int segNumber, uint32_t symbolAddress);
|
||||
std::string FindSymbolSegRef(int32_t segNumber, uint32_t symbolAddress);
|
||||
void ReadConfigFile(const std::string& configFilePath);
|
||||
void ReadTexturePool(const std::string& texturePoolXmlPath);
|
||||
void GenSymbolMap(const std::string& symbolMapPath);
|
||||
void AddSegment(int segment);
|
||||
bool HasSegment(int segment);
|
||||
};
|
||||
|
||||
class GameConfig
|
||||
{
|
||||
public:
|
||||
std::map<int, std::string> segmentRefs;
|
||||
std::map<int, ZFile*> segmentRefFiles;
|
||||
std::map<uint32_t, std::string> symbolMap;
|
||||
std::vector<std::string> actorList;
|
||||
std::vector<std::string> objectList;
|
||||
|
||||
GameConfig();
|
||||
|
||||
private:
|
||||
void AddSegment(int32_t segment);
|
||||
bool HasSegment(int32_t segment);
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
@ -58,30 +58,12 @@ HLAnimationIntermediette* HLAnimationIntermediette::FromZAnimation(ZAnimation* z
|
|||
{
|
||||
HLAnimationIntermediette* anim = new HLAnimationIntermediette();
|
||||
|
||||
/*anim->limit = zAnim->limit;
|
||||
anim->frameCount = zAnim->frameCount;
|
||||
|
||||
for (uint16_t item : zAnim->rotationValues)
|
||||
anim->rotationValues.push_back(item);
|
||||
|
||||
for (RotationIndex item : zAnim->rotationIndices)
|
||||
anim->rotationIndices.push_back(item);*/
|
||||
|
||||
return anim;
|
||||
}
|
||||
|
||||
ZAnimation* HLAnimationIntermediette::ToZAnimation()
|
||||
{
|
||||
ZAnimation* zAnim = new ZAnimation();
|
||||
|
||||
/*zAnim->limit = limit;
|
||||
zAnim->frameCount = frameCount;
|
||||
|
||||
for (uint16_t item : rotationValues)
|
||||
zAnim->rotationValues.push_back(item);
|
||||
|
||||
for (RotationIndex item : rotationIndices)
|
||||
zAnim->rotationIndices.push_back(item);*/
|
||||
ZAnimation* zAnim = new ZAnimation(nullptr);
|
||||
|
||||
return zAnim;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ HLModelIntermediette::HLModelIntermediette()
|
|||
startIndex = 0;
|
||||
meshStartIndex = 0;
|
||||
hasSkeleton = false;
|
||||
lastTrans = Vec3s(0, 0, 0);
|
||||
}
|
||||
|
||||
HLModelIntermediette::~HLModelIntermediette()
|
||||
|
@ -61,7 +62,6 @@ HLModelIntermediette* HLModelIntermediette::FromXML(tinyxml2::XMLElement* root)
|
|||
|
||||
void HLModelIntermediette::FromZDisplayList(HLModelIntermediette* model, ZDisplayList* zDisplayList)
|
||||
{
|
||||
// HLModelIntermediette* model = new HLModelIntermediette();
|
||||
HLLimbIntermediette* limb = new HLLimbIntermediette();
|
||||
limb->name = zDisplayList->GetName();
|
||||
|
||||
|
@ -97,15 +97,15 @@ void HLModelIntermediette::FromZDisplayList(HLModelIntermediette* model, ZDispla
|
|||
// Analyze display lists to determine components
|
||||
HLDisplayListIntermediette* dList = new HLDisplayListIntermediette();
|
||||
dList->address = zDisplayList->GetRawDataIndex();
|
||||
int startIndex = 0;
|
||||
int32_t startIndex = 0;
|
||||
|
||||
// Go through the display lists and setup commands
|
||||
int meshCnt = 0;
|
||||
int32_t meshCnt = 0;
|
||||
|
||||
HLMeshIntermediette* mesh = new HLMeshIntermediette();
|
||||
mesh->name = StringHelper::Sprintf("%s_%i", zDisplayList->GetName().c_str(), meshCnt);
|
||||
|
||||
int matCnt = 0;
|
||||
int32_t matCnt = 0;
|
||||
HLMaterialIntermediette* lastMat = new HLMaterialIntermediette();
|
||||
lastMat->name = StringHelper::Sprintf("Material_%i", matCnt);
|
||||
|
||||
|
@ -120,26 +120,15 @@ void HLModelIntermediette::FromZDisplayList(HLModelIntermediette* model, ZDispla
|
|||
|
||||
if (opcode == F3DZEXOpcode::G_SETOTHERMODE_L)
|
||||
{
|
||||
int ss = (data & 0x0000FF0000000000) >> 40;
|
||||
int nn = (data & 0x000000FF00000000) >> 32;
|
||||
// int dd = (data & 0xFFFFFFFF);
|
||||
|
||||
int sft = 32 - (nn + 1) - ss;
|
||||
|
||||
if (sft == 3)
|
||||
{
|
||||
// int mode1 = (dd & 0xCCCC0000) >> 0;
|
||||
// int mode2 = (dd & 0x33330000) >> 0;
|
||||
}
|
||||
}
|
||||
else if (opcode == F3DZEXOpcode::G_SETPRIMCOLOR)
|
||||
{
|
||||
int mm = (data & 0x0000FF0000000000) >> 40;
|
||||
int ff = (data & 0x000000FF00000000) >> 32;
|
||||
int rr = (data & 0x00000000FF000000) >> 24;
|
||||
int gg = (data & 0x0000000000FF0000) >> 16;
|
||||
int bb = (data & 0x000000000000FF00) >> 8;
|
||||
int aa = (data & 0x00000000000000FF) >> 0;
|
||||
int32_t mm = (data & 0x0000FF0000000000) >> 40;
|
||||
int32_t ff = (data & 0x000000FF00000000) >> 32;
|
||||
int32_t rr = (data & 0x00000000FF000000) >> 24;
|
||||
int32_t gg = (data & 0x0000000000FF0000) >> 16;
|
||||
int32_t bb = (data & 0x000000000000FF00) >> 8;
|
||||
int32_t aa = (data & 0x00000000000000FF) >> 0;
|
||||
|
||||
lastClrR = rr;
|
||||
lastClrG = gg;
|
||||
|
@ -159,33 +148,17 @@ void HLModelIntermediette::FromZDisplayList(HLModelIntermediette* model, ZDispla
|
|||
(F3DZEXOpcode)(zDisplayList->instructions[i - 1] >> 56) !=
|
||||
F3DZEXOpcode::G_RDPPIPESYNC)
|
||||
{
|
||||
// int fff = (data & 0b0000000011100000000000000000000000000000000000000000000000000000)
|
||||
// >> 53; int ii = (data &
|
||||
// 0b0000000000011000000000000000000000000000000000000000000000000000) >> 51; int
|
||||
// nnnnnnnnn = (data &
|
||||
// 0b0000000000000011111111100000000000000000000000000000000000000000) >> 41; int
|
||||
// mmmmmmmmm = (data &
|
||||
// 0b0000000000000000000000011111111100000000000000000000000000000000) >> 32; int ttt =
|
||||
// (data & 0b0000000000000000000000000000000000000111000000000000000000000000) >> 24; int
|
||||
// pppp = (data & 0b0000000000000000000000000000000000000000111100000000000000000000) >>
|
||||
// 20;
|
||||
int cc =
|
||||
int32_t cc =
|
||||
(data & 0b0000000000000000000000000000000000000000000011000000000000000000) >> 18;
|
||||
// int aaaa = (data &
|
||||
// 0b0000000000000000000000000000000000000000000000111100000000000000) >> 14; int ssss =
|
||||
// (data & 0b0000000000000000000000000000000000000000000000000011110000000000) >> 10;
|
||||
int dd =
|
||||
int32_t dd =
|
||||
(data & 0b0000000000000000000000000000000000000000000000000000001100000000) >> 8;
|
||||
// int bbbb = (data &
|
||||
// 0b0000000000000000000000000000000000000000000000000000000011110000) >> 4; int uuuu =
|
||||
// (data & 0b0000000000000000000000000000000000000000000000000000000000001111);
|
||||
|
||||
lastMat->cmtH = (HLMaterialCmt)cc;
|
||||
lastMat->cmtV = (HLMaterialCmt)dd;
|
||||
|
||||
matCnt++;
|
||||
|
||||
if (matCnt > 1)
|
||||
if (matCnt > 1 && mesh->commands.size() > 0)
|
||||
{
|
||||
model->blocks.push_back(lastMat);
|
||||
limb->commands.push_back(new HLLimbCommand(mesh->name, lastMat->name));
|
||||
|
@ -223,9 +196,9 @@ void HLModelIntermediette::FromZDisplayList(HLModelIntermediette* model, ZDispla
|
|||
}
|
||||
else if (opcode == F3DZEXOpcode::G_VTX)
|
||||
{
|
||||
int nn = (data & 0x000FF00000000000ULL) >> 44;
|
||||
int aa = (data & 0x000000FF00000000ULL) >> 32;
|
||||
int startIndex = ((aa >> 1) - nn);
|
||||
int32_t nn = (data & 0x000FF00000000000ULL) >> 44;
|
||||
int32_t aa = (data & 0x000000FF00000000ULL) >> 32;
|
||||
int32_t startIndex = ((aa >> 1) - nn);
|
||||
uint32_t vtxAddr = data & 0x00FFFFFF;
|
||||
uint32_t diff = vtxAddr - vStart;
|
||||
|
||||
|
@ -235,46 +208,59 @@ void HLModelIntermediette::FromZDisplayList(HLModelIntermediette* model, ZDispla
|
|||
}
|
||||
else if (opcode == F3DZEXOpcode::G_TRI1)
|
||||
{
|
||||
int aa = ((data & 0x00FF000000000000ULL) >> 48) / 2;
|
||||
int bb = ((data & 0x0000FF0000000000ULL) >> 40) / 2;
|
||||
int cc = ((data & 0x000000FF00000000ULL) >> 32) / 2;
|
||||
int32_t aa = ((data & 0x00FF000000000000ULL) >> 48) / 2;
|
||||
int32_t bb = ((data & 0x0000FF0000000000ULL) >> 40) / 2;
|
||||
int32_t cc = ((data & 0x000000FF00000000ULL) >> 32) / 2;
|
||||
|
||||
mesh->commands.push_back(new HLMeshCmdTriangle1(aa, bb, cc, 0));
|
||||
}
|
||||
else if (opcode == F3DZEXOpcode::G_TRI2)
|
||||
{
|
||||
int aa = ((data & 0x00FF000000000000ULL) >> 48) / 2;
|
||||
int bb = ((data & 0x0000FF0000000000ULL) >> 40) / 2;
|
||||
int cc = ((data & 0x000000FF00000000ULL) >> 32) / 2;
|
||||
int dd = ((data & 0x00000000FF0000ULL) >> 16) / 2;
|
||||
int ee = ((data & 0x0000000000FF00ULL) >> 8) / 2;
|
||||
int ff = ((data & 0x000000000000FFULL) >> 0) / 2;
|
||||
int32_t aa = ((data & 0x00FF000000000000ULL) >> 48) / 2;
|
||||
int32_t bb = ((data & 0x0000FF0000000000ULL) >> 40) / 2;
|
||||
int32_t cc = ((data & 0x000000FF00000000ULL) >> 32) / 2;
|
||||
int32_t dd = ((data & 0x00000000FF0000ULL) >> 16) / 2;
|
||||
int32_t ee = ((data & 0x0000000000FF00ULL) >> 8) / 2;
|
||||
int32_t ff = ((data & 0x000000000000FFULL) >> 0) / 2;
|
||||
|
||||
mesh->commands.push_back(new HLMeshCmdTriangle2(aa, bb, cc, 0, dd, ee, ff, 0));
|
||||
}
|
||||
|
||||
// int bp = 0;
|
||||
// int32_t bp = 0;
|
||||
}
|
||||
|
||||
limb->commands.push_back(new HLLimbCommand(mesh->name, lastMat->name));
|
||||
model->blocks.push_back(lastMat);
|
||||
model->blocks.push_back(mesh);
|
||||
model->blocks.push_back(limb);
|
||||
|
||||
// return model;
|
||||
}
|
||||
|
||||
void HLModelIntermediette::FromZSkeleton(HLModelIntermediette* model, ZSkeleton* zSkeleton)
|
||||
{
|
||||
model->hasSkeleton = true;
|
||||
|
||||
for (size_t i = 0; i < zSkeleton->limbs.size(); i++)
|
||||
{
|
||||
// ZLimb* limb = zSkeleton->limbs[i];
|
||||
|
||||
for (size_t j = 0; j < model->blocks.size(); j++)
|
||||
{
|
||||
// Start at the root skeleton node, go down...
|
||||
ProcessZSkeletonLimb(model, zSkeleton, zSkeleton->limbs[0]);
|
||||
}
|
||||
|
||||
void HLModelIntermediette::ProcessZSkeletonLimb(HLModelIntermediette* model, ZSkeleton* zSkeleton,
|
||||
ZLimb* limb)
|
||||
{
|
||||
if (limb->dList == nullptr && limb->dListPtr != 0)
|
||||
limb->dList = (ZDisplayList*)zSkeleton->parent->FindResource(limb->dListPtr);
|
||||
|
||||
if (limb->dList != nullptr)
|
||||
{
|
||||
auto cmdTrans = new HLSetTranslation(limb->transX, limb->transY, limb->transZ);
|
||||
cmdTrans->parent = model;
|
||||
model->blocks.push_back(cmdTrans);
|
||||
|
||||
FromZDisplayList(model, limb->dList);
|
||||
}
|
||||
|
||||
for (ZLimb* childLimb : limb->children)
|
||||
{
|
||||
ProcessZSkeletonLimb(model, zSkeleton, childLimb);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -296,7 +282,7 @@ string HLModelIntermediette::ToOBJFile()
|
|||
return output;
|
||||
}
|
||||
|
||||
string HLModelIntermediette::ToFBXFile()
|
||||
string HLModelIntermediette::ToAssimpFile()
|
||||
{
|
||||
#ifdef USE_ASSIMP
|
||||
Assimp::Exporter exporter;
|
||||
|
@ -307,22 +293,30 @@ string HLModelIntermediette::ToFBXFile()
|
|||
|
||||
std::vector<aiVector3D> vertices;
|
||||
|
||||
int32_t idx = 0;
|
||||
|
||||
for (HLIntermediette* block : blocks)
|
||||
{
|
||||
block->parent = this;
|
||||
block->OutputAssimp(newScene, &vertices);
|
||||
|
||||
idx++;
|
||||
}
|
||||
|
||||
newScene->mRootNode->mNumChildren += newScene->mNumMeshes;
|
||||
newScene->mRootNode->mChildren = new aiNode*[newScene->mRootNode->mNumChildren];
|
||||
|
||||
for (int i = 0; i < newScene->mNumMeshes; i++)
|
||||
for (size_t i = 0; i < newScene->mNumMeshes; i++)
|
||||
{
|
||||
aiNode* child = new aiNode();
|
||||
child->mName = StringHelper::Sprintf("OBJ_%i", i);
|
||||
child->mNumMeshes = 1;
|
||||
child->mMeshes = new unsigned int[1];
|
||||
child->mMeshes = new uint32_t[1];
|
||||
child->mMeshes[0] = i;
|
||||
child->mTransformation.Translation(aiVector3D(meshTranslations[i].x * 10,
|
||||
meshTranslations[i].y * 10,
|
||||
meshTranslations[i].z * 10),
|
||||
child->mTransformation);
|
||||
newScene->mRootNode->mChildren[i] = child;
|
||||
}
|
||||
|
||||
|
@ -485,8 +479,8 @@ string HLVerticesIntermediette::OutputCode(HLModelIntermediette* parent)
|
|||
|
||||
for (Vertex v : vertices)
|
||||
{
|
||||
output += StringHelper::Sprintf("\t{ %i, %i, %i, %i, %i, %i, %i, %i, %i, %i },\n", v.x, v.y,
|
||||
v.z, v.flag, v.s, v.t, v.r, v.g, v.b, v.a);
|
||||
output += StringHelper::Sprintf(" { %i, %i, %i, %i, %i, %i, %i, %i, %i, %i },\n", v.x,
|
||||
v.y, v.z, v.flag, v.s, v.t, v.r, v.g, v.b, v.a);
|
||||
}
|
||||
|
||||
output += StringHelper::Sprintf("};\n");
|
||||
|
@ -502,32 +496,19 @@ std::string HLVerticesIntermediette::OutputOBJ()
|
|||
{
|
||||
output += StringHelper::Sprintf("v %f %f %f %i %i %i %i\n", (float)v.x * 0.1f,
|
||||
(float)v.y * 0.1f, (float)v.z * 0.1f, v.r, v.g, v.b, v.a);
|
||||
// output += StringHelper::Sprintf("v %f %f %f\n", (float)v.x * 0.1f, (float)v.y * 0.1f,
|
||||
// (float)v.z * 0.1f);
|
||||
}
|
||||
|
||||
// for (Vertex v : vertices)
|
||||
// output += StringHelper::Sprintf("vt %i %i\n", v.s, v.t);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
void HLVerticesIntermediette::OutputAssimp(aiScene* scene, std::vector<aiVector3D>* verts)
|
||||
{
|
||||
// aiVector3D* verts = new aiVector3D[vertices.size()];
|
||||
// aiVector3D* normals = new aiVector3D[vertices.size()];
|
||||
|
||||
verts->clear();
|
||||
|
||||
for (size_t i = 0; i < vertices.size(); i++)
|
||||
{
|
||||
verts->push_back(aiVector3D(vertices[i].x, vertices[i].y, vertices[i].z));
|
||||
// normals[i] = aiVector3D(vertices[i].x, vertices[i].y, vertices[i].z);
|
||||
}
|
||||
|
||||
// mesh->mVertices = verts;
|
||||
// mesh->mNormals = normals;
|
||||
// mesh->mNumVertices += vertices.size();
|
||||
}
|
||||
|
||||
void HLVerticesIntermediette::OutputXML(tinyxml2::XMLDocument* doc, tinyxml2::XMLElement* root)
|
||||
|
@ -615,7 +596,7 @@ void HLMeshCmdTriangle1::OutputAssimp(HLModelIntermediette* parent, aiScene* sce
|
|||
{
|
||||
aiFace* face = new aiFace();
|
||||
face->mNumIndices = 3;
|
||||
face->mIndices = new unsigned int[3];
|
||||
face->mIndices = new uint32_t[3];
|
||||
face->mIndices[0] = parent->startIndex + v0;
|
||||
face->mIndices[1] = parent->startIndex + v1;
|
||||
face->mIndices[2] = parent->startIndex + v2;
|
||||
|
@ -680,10 +661,9 @@ string HLMeshCmdTriangle2::OutputCode(HLModelIntermediette* parent)
|
|||
|
||||
std::string HLMeshCmdTriangle2::OutputOBJ(HLModelIntermediette* parent)
|
||||
{
|
||||
// HLVerticesIntermediette* verts = parent->FindByName<HLVerticesIntermediette>("");
|
||||
string output = "";
|
||||
|
||||
int startIndex = parent->startIndex;
|
||||
int32_t startIndex = parent->startIndex;
|
||||
|
||||
output += StringHelper::Sprintf("f %i %i %i\n", startIndex + v0 + 1, startIndex + v1 + 1,
|
||||
startIndex + v2 + 1);
|
||||
|
@ -698,7 +678,7 @@ void HLMeshCmdTriangle2::OutputAssimp(HLModelIntermediette* parent, aiScene* sce
|
|||
{
|
||||
aiFace* face = new aiFace();
|
||||
face->mNumIndices = 3;
|
||||
face->mIndices = new unsigned int[3];
|
||||
face->mIndices = new uint32_t[3];
|
||||
face->mIndices[0] = parent->startIndex + v0;
|
||||
face->mIndices[1] = parent->startIndex + v1;
|
||||
face->mIndices[2] = parent->startIndex + v2;
|
||||
|
@ -709,7 +689,7 @@ void HLMeshCmdTriangle2::OutputAssimp(HLModelIntermediette* parent, aiScene* sce
|
|||
{
|
||||
aiFace* face = new aiFace();
|
||||
face->mNumIndices = 3;
|
||||
face->mIndices = new unsigned int[3];
|
||||
face->mIndices = new uint32_t[3];
|
||||
face->mIndices[0] = parent->startIndex + v10;
|
||||
face->mIndices[1] = parent->startIndex + v11;
|
||||
face->mIndices[2] = parent->startIndex + v12;
|
||||
|
@ -783,18 +763,12 @@ string HLMeshCmdLoadVertices::OutputCode(HLModelIntermediette* parent)
|
|||
HLMaterialIntermediette::HLMaterialIntermediette()
|
||||
{
|
||||
textureName = "";
|
||||
// repeatH = false;
|
||||
// repeatV = false;
|
||||
clrR = 0;
|
||||
clrG = 0;
|
||||
clrB = 0;
|
||||
clrA = 0;
|
||||
clrM = 0;
|
||||
clrL = 0;
|
||||
// clampH = false;
|
||||
// clampV = false;
|
||||
// mirrorH = false;
|
||||
// mirrorV = false;
|
||||
cmtH = HLMaterialCmt::Wrap;
|
||||
cmtV = HLMaterialCmt::Wrap;
|
||||
}
|
||||
|
@ -803,12 +777,6 @@ void HLMaterialIntermediette::InitFromXML(tinyxml2::XMLElement* xmlElement)
|
|||
{
|
||||
name = xmlElement->Attribute("Name");
|
||||
textureName = xmlElement->Attribute("TextureName");
|
||||
// repeatH = xmlElement->BoolAttribute("RepeatH");
|
||||
// repeatV = xmlElement->BoolAttribute("RepeatV");
|
||||
// clampH = xmlElement->BoolAttribute("ClampH");
|
||||
// clampV = xmlElement->BoolAttribute("ClampV");
|
||||
// mirrorH = xmlElement->BoolAttribute("MirrorH");
|
||||
// mirrorV = xmlElement->BoolAttribute("MirrorV");
|
||||
clrR = xmlElement->IntAttribute("ClrR");
|
||||
clrG = xmlElement->IntAttribute("ClrG");
|
||||
clrB = xmlElement->IntAttribute("ClrB");
|
||||
|
@ -834,8 +802,8 @@ void HLMaterialIntermediette::OutputXML(tinyxml2::XMLDocument* doc, tinyxml2::XM
|
|||
elem->SetAttribute("ClrA", clrA);
|
||||
elem->SetAttribute("ClrL", clrL);
|
||||
elem->SetAttribute("ClrM", clrM);
|
||||
elem->SetAttribute("CmtH", (int)cmtH);
|
||||
elem->SetAttribute("CmtV", (int)cmtV);
|
||||
elem->SetAttribute("CmtH", (int32_t)cmtH);
|
||||
elem->SetAttribute("CmtV", (int32_t)cmtV);
|
||||
|
||||
parent->InsertEndChild(elem);
|
||||
}
|
||||
|
@ -997,19 +965,19 @@ string HLMeshIntermediette::OutputCode(string materialName)
|
|||
HLMaterialIntermediette* mat = parent->FindByName<HLMaterialIntermediette>(materialName);
|
||||
HLTextureIntermediette* tex = parent->FindByName<HLTextureIntermediette>(mat->textureName);
|
||||
|
||||
output += StringHelper::Sprintf("\tgsDPPipeSync(),\n");
|
||||
output += StringHelper::Sprintf("\tgsDPSetPrimColor(%i, %i, %i, %i, %i, %i),\n", mat->clrL,
|
||||
output += StringHelper::Sprintf(" gsDPPipeSync(),\n");
|
||||
output += StringHelper::Sprintf(" gsDPSetPrimColor(%i, %i, %i, %i, %i, %i),\n", mat->clrL,
|
||||
mat->clrM, mat->clrR, mat->clrG, mat->clrB, mat->clrA);
|
||||
output += StringHelper::Sprintf("\tgsDPPipeSync(),\n");
|
||||
output += StringHelper::Sprintf("\tgsSPTexture(65535, 65535, 0, 0, G_ON),\n");
|
||||
output += StringHelper::Sprintf(" gsDPPipeSync(),\n");
|
||||
output += StringHelper::Sprintf(" gsSPTexture(65535, 65535, 0, 0, G_ON),\n");
|
||||
|
||||
output += StringHelper::Sprintf(
|
||||
"\tgsDPLoadMultiBlock(%s, 0, 0, %s, %s, %i, %i, 0, 0, 0, 5, 5, 0, 0),\n",
|
||||
" gsDPLoadMultiBlock(%s, 0, 0, %s, %s, %i, %i, 0, 0, 0, 5, 5, 0, 0),\n",
|
||||
mat->textureName.c_str(), tex->tex->GetIMFmtFromType().c_str(),
|
||||
tex->tex->GetIMSizFromType().c_str(), tex->tex->GetWidth(), tex->tex->GetHeight());
|
||||
|
||||
for (HLMeshCommand* cmd : commands)
|
||||
output += "\t" + cmd->OutputCode(parent) + "\n";
|
||||
output += " " + cmd->OutputCode(parent) + "\n";
|
||||
|
||||
return output;
|
||||
}
|
||||
|
@ -1041,6 +1009,9 @@ void HLMeshIntermediette::OutputAssimp(aiScene* scene, std::vector<aiVector3D>*
|
|||
cmd->OutputAssimp(parent, scene, mesh);
|
||||
}
|
||||
|
||||
parent->meshTranslations.push_back(parent->lastTrans);
|
||||
// parent->objects.push_back(new HLModelObj(parent->lastTransX, ))
|
||||
|
||||
scene->mMeshes[scene->mNumMeshes++] = mesh;
|
||||
}
|
||||
|
||||
|
@ -1094,7 +1065,7 @@ std::string HLLimbIntermediette::OutputCode()
|
|||
for (HLLimbCommand* cmd : commands)
|
||||
output += cmd->OutputCode(parent);
|
||||
|
||||
output += StringHelper::Sprintf("\tgsSPEndDisplayList(),\n");
|
||||
output += StringHelper::Sprintf(" gsSPEndDisplayList(),\n");
|
||||
output += StringHelper::Sprintf("};\n");
|
||||
|
||||
return output;
|
||||
|
@ -1146,8 +1117,6 @@ std::string HLLimbCommand::OutputCode(HLModelIntermediette* parent)
|
|||
|
||||
// Time to generate the display list...
|
||||
HLMeshIntermediette* mesh = parent->FindByName<HLMeshIntermediette>(meshName);
|
||||
// HLMaterialIntermediette* mat = parent->FindByName<HLMaterialIntermediette>(materialName);
|
||||
// HLTextureIntermediette* tex = parent->FindByName<HLTextureIntermediette>(mat->textureName);
|
||||
|
||||
output += mesh->OutputCode(materialName);
|
||||
|
||||
|
@ -1176,3 +1145,31 @@ void HLTerminator::OutputAssimp(aiScene* scene, std::vector<aiVector3D>* verts)
|
|||
|
||||
verts->clear();
|
||||
}
|
||||
|
||||
HLSetTranslation::HLSetTranslation()
|
||||
{
|
||||
transX = 0;
|
||||
transY = 0;
|
||||
transZ = 0;
|
||||
}
|
||||
|
||||
HLSetTranslation::HLSetTranslation(float nTransX, float nTransY, float nTransZ)
|
||||
{
|
||||
transX = nTransX;
|
||||
transY = nTransY;
|
||||
transZ = nTransZ;
|
||||
}
|
||||
|
||||
void HLSetTranslation::OutputAssimp(aiScene* scene, std::vector<aiVector3D>* verts)
|
||||
{
|
||||
parent->lastTrans = Vec3s(transX, transY, transZ);
|
||||
}
|
||||
|
||||
HLModelObj::HLModelObj(Vec3s nPos, Vec3s nRot, std::vector<aiVector3D> nVerts,
|
||||
std::vector<int32_t> nIndices)
|
||||
{
|
||||
pos = nPos;
|
||||
rot = nRot;
|
||||
vertices = nVerts;
|
||||
indices = nIndices;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <Vec3s.h>
|
||||
#include <assimp/scene.h>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
|
@ -8,7 +9,6 @@
|
|||
#include "../ZDisplayList.h"
|
||||
#include "../ZSkeleton.h"
|
||||
#include "HLFileIntermediette.h"
|
||||
#include "HLTexture.h"
|
||||
|
||||
/*
|
||||
* An intermediette format for models. Goes from FBX<-->Intermediette<-->Display List C Code.
|
||||
|
@ -32,10 +32,26 @@ public:
|
|||
virtual void InitFromXML(tinyxml2::XMLElement* xmlElement);
|
||||
};
|
||||
|
||||
class HLModelObj
|
||||
{
|
||||
public:
|
||||
Vec3s pos;
|
||||
Vec3s rot;
|
||||
std::vector<aiVector3D> vertices;
|
||||
std::vector<int32_t> indices;
|
||||
|
||||
HLModelObj() = default;
|
||||
HLModelObj(Vec3s nPos, Vec3s nRot, std::vector<aiVector3D> nVerts,
|
||||
std::vector<int32_t> nIndices);
|
||||
};
|
||||
|
||||
class HLModelIntermediette : public HLFileIntermediette
|
||||
{
|
||||
public:
|
||||
std::vector<HLIntermediette*> blocks;
|
||||
std::vector<Vec3s> meshTranslations;
|
||||
std::vector<HLModelObj*> objects;
|
||||
Vec3s lastTrans;
|
||||
|
||||
bool hasSkeleton;
|
||||
|
||||
|
@ -52,8 +68,10 @@ public:
|
|||
static HLModelIntermediette* FromXML(tinyxml2::XMLElement* root);
|
||||
static void FromZDisplayList(HLModelIntermediette* model, ZDisplayList* zDisplayList);
|
||||
static void FromZSkeleton(HLModelIntermediette* model, ZSkeleton* zSkeleton);
|
||||
static void ProcessZSkeletonLimb(HLModelIntermediette* model, ZSkeleton* zSkeleton,
|
||||
ZLimb* limb);
|
||||
std::string ToOBJFile();
|
||||
std::string ToFBXFile();
|
||||
std::string ToAssimpFile();
|
||||
|
||||
std::string OutputCode();
|
||||
std::string OutputXML();
|
||||
|
@ -78,6 +96,17 @@ public:
|
|||
virtual void OutputXML(tinyxml2::XMLDocument* doc, tinyxml2::XMLElement* root);
|
||||
};
|
||||
|
||||
class HLSetTranslation : public HLIntermediette
|
||||
{
|
||||
public:
|
||||
float transX, transY, transZ;
|
||||
|
||||
HLSetTranslation();
|
||||
HLSetTranslation(float nTransX, float nTransY, float nTransZ);
|
||||
|
||||
virtual void OutputAssimp(aiScene* scene, std::vector<aiVector3D>* verts);
|
||||
};
|
||||
|
||||
class HLTerminator : public HLIntermediette
|
||||
{
|
||||
public:
|
||||
|
@ -249,7 +278,7 @@ class HLDisplayListIntermediette : public HLIntermediette
|
|||
{
|
||||
public:
|
||||
std::vector<HLDisplayListCommand*> commands;
|
||||
int address;
|
||||
uint32_t address;
|
||||
|
||||
HLDisplayListIntermediette();
|
||||
|
||||
|
|
|
@ -6,11 +6,11 @@ using namespace std;
|
|||
|
||||
HLTexture* HLTexture::FromPNG(std::string pngFilePath, HLTextureType texType)
|
||||
{
|
||||
int comp;
|
||||
int32_t comp;
|
||||
HLTexture* tex = new HLTexture();
|
||||
tex->type = texType;
|
||||
tex->bmpRgba = (uint8_t*)stbi_load((pngFilePath).c_str(), (int*)&tex->width, (int*)&tex->height,
|
||||
&comp, STBI_rgb_alpha);
|
||||
tex->bmpRgba = (uint8_t*)stbi_load((pngFilePath).c_str(), (int32_t*)&tex->width,
|
||||
(int32_t*)&tex->height, &comp, STBI_rgb_alpha);
|
||||
|
||||
return tex;
|
||||
}
|
||||
|
|
|
@ -7,13 +7,16 @@
|
|||
#include "Overlays/ZOverlay.h"
|
||||
#include "Path.h"
|
||||
#include "ZAnimation.h"
|
||||
#include "ZBackground.h"
|
||||
#include "ZBlob.h"
|
||||
#include "ZFile.h"
|
||||
#include "ZTexture.h"
|
||||
|
||||
#if !defined(_MSC_VER) && !defined(__CYGWIN__)
|
||||
#include <csignal>
|
||||
#include <cxxabi.h> // for __cxa_demangle
|
||||
#include <dlfcn.h> // for dladdr
|
||||
#include <execinfo.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
@ -23,62 +26,77 @@
|
|||
using namespace tinyxml2;
|
||||
using namespace std;
|
||||
|
||||
bool Parse(const std::string& xmlFilePath, const std::string& basePath, const std::string& outPath,
|
||||
bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, const fs::path& outPath,
|
||||
ZFileMode fileMode);
|
||||
|
||||
void BuildAssetTexture(const std::string& pngFilePath, TextureType texType,
|
||||
const std::string& outPath);
|
||||
void BuildAssetBlob(const std::string& blobFilePath, const std::string& outPath);
|
||||
void BuildAssetModelIntermediette(const std::string& mdlPath, const std::string& outPath);
|
||||
void BuildAssetAnimationIntermediette(const std::string& animPath, const std::string& outPath);
|
||||
|
||||
int NewMain(int argc, char* argv[]);
|
||||
void BuildAssetTexture(const fs::path& pngFilePath, TextureType texType, const fs::path& outPath);
|
||||
void BuildAssetBackground(const fs::path& imageFilePath, const fs::path& outPath);
|
||||
void BuildAssetBlob(const fs::path& blobFilePath, const fs::path& outPath);
|
||||
void BuildAssetModelIntermediette(const fs::path& outPath);
|
||||
void BuildAssetAnimationIntermediette(const fs::path& animPath, const fs::path& outPath);
|
||||
|
||||
#if !defined(_MSC_VER) && !defined(__CYGWIN__)
|
||||
void ErrorHandler(int sig)
|
||||
{
|
||||
void* array[4096];
|
||||
char** symbols;
|
||||
size_t size;
|
||||
size = backtrace(array, 4096);
|
||||
symbols = backtrace_symbols(array, 4096);
|
||||
const size_t nMaxFrames = sizeof(array) / sizeof(array[0]);
|
||||
size_t size = backtrace(array, nMaxFrames);
|
||||
char** symbols = backtrace_symbols(array, nMaxFrames);
|
||||
|
||||
// To prevent unused parameter warning
|
||||
(void)sig;
|
||||
|
||||
for (size_t i = 1; i < size; i++)
|
||||
{
|
||||
// size_t len = strlen(symbols[i]);
|
||||
cout << symbols[i] << "\n";
|
||||
Dl_info info;
|
||||
uint32_t gotAddress = dladdr(array[i], &info);
|
||||
string functionName(symbols[i]);
|
||||
|
||||
if (gotAddress != 0 && info.dli_sname != nullptr)
|
||||
{
|
||||
int32_t status;
|
||||
char* demangled = abi::__cxa_demangle(info.dli_sname, nullptr, nullptr, &status);
|
||||
const char* nameFound = info.dli_sname;
|
||||
|
||||
if (status == 0)
|
||||
{
|
||||
nameFound = demangled;
|
||||
}
|
||||
|
||||
// cout << "Error: signal " << sig << ":\n";
|
||||
backtrace_symbols_fd(array, size, STDERR_FILENO);
|
||||
functionName = StringHelper::Sprintf("%s (+0x%X)", nameFound,
|
||||
(char*)array[i] - (char*)info.dli_saddr);
|
||||
free(demangled);
|
||||
}
|
||||
|
||||
fprintf(stderr, "%-3zd %s\n", i, functionName.c_str());
|
||||
}
|
||||
|
||||
// backtrace_symbols_fd(array, size, STDERR_FILENO);
|
||||
free(symbols);
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
Globals* g = new Globals();
|
||||
return NewMain(argc, argv);
|
||||
}
|
||||
|
||||
int NewMain(int argc, char* argv[])
|
||||
{
|
||||
// Syntax: ZAPD.exe [mode (b/btex/bovl/e)] (Arbritrary Number of Arguments)
|
||||
// Syntax: ZAPD.exe [mode (btex/bovl/e)] (Arbritrary Number of Arguments)
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
printf("ZAPD.exe [mode (b/btex/bovl/bsf/bblb/bmdlintr/bamnintr/e)] ...\n");
|
||||
printf("ZAPD.exe (%s) [mode (btex/bovl/bsf/bblb/bmdlintr/bamnintr/e)] ...\n", gBuildHash);
|
||||
return 1;
|
||||
}
|
||||
|
||||
Globals* g = new Globals();
|
||||
|
||||
// Parse File Mode
|
||||
string buildMode = argv[1];
|
||||
ZFileMode fileMode = ZFileMode::Invalid;
|
||||
|
||||
if (buildMode == "b")
|
||||
fileMode = ZFileMode::Build;
|
||||
else if (buildMode == "btex")
|
||||
if (buildMode == "btex")
|
||||
fileMode = ZFileMode::BuildTexture;
|
||||
else if (buildMode == "bren")
|
||||
fileMode = ZFileMode::BuildBackground;
|
||||
else if (buildMode == "bovl")
|
||||
fileMode = ZFileMode::BuildOverlay;
|
||||
else if (buildMode == "bsf")
|
||||
|
@ -99,13 +117,17 @@ int NewMain(int argc, char* argv[])
|
|||
}
|
||||
|
||||
// Parse other "commands"
|
||||
for (int i = 2; i < argc; i++)
|
||||
for (int32_t i = 2; i < argc; i++)
|
||||
{
|
||||
string arg = argv[i];
|
||||
|
||||
if (arg == "-o" || arg == "--outputpath") // Set output path
|
||||
{
|
||||
Globals::Instance->outputPath = argv[i + 1];
|
||||
|
||||
if (Globals::Instance->sourceOutputPath == "")
|
||||
Globals::Instance->sourceOutputPath = Globals::Instance->outputPath;
|
||||
|
||||
i++;
|
||||
}
|
||||
else if (arg == "-i" || arg == "--inputpath") // Set input path
|
||||
|
@ -118,6 +140,11 @@ int NewMain(int argc, char* argv[])
|
|||
Globals::Instance->baseRomPath = argv[i + 1];
|
||||
i++;
|
||||
}
|
||||
else if (arg == "-osf") // Set source output path
|
||||
{
|
||||
Globals::Instance->sourceOutputPath = argv[i + 1];
|
||||
i++;
|
||||
}
|
||||
else if (arg == "-gsf") // Generate source file during extraction
|
||||
{
|
||||
Globals::Instance->genSourceFile = string(argv[i + 1]) == "1";
|
||||
|
@ -128,18 +155,24 @@ int NewMain(int argc, char* argv[])
|
|||
Globals::Instance->includeFilePrefix = string(argv[i + 1]) == "1";
|
||||
i++;
|
||||
}
|
||||
else if (arg == "-tm") // Test Mode
|
||||
else if (arg == "-tm") // Test Mode (enables certain experimental features)
|
||||
{
|
||||
Globals::Instance->testMode = string(argv[i + 1]) == "1";
|
||||
i++;
|
||||
}
|
||||
else if (arg == "-profile") // Profile
|
||||
else if (arg == "-ulzdl") // Use Legacy ZDisplay List
|
||||
{
|
||||
Globals::Instance->useLegacyZDList = string(argv[i + 1]) == "1";
|
||||
i++;
|
||||
}
|
||||
else if (arg == "-profile") // Enable profiling
|
||||
{
|
||||
Globals::Instance->profile = string(argv[i + 1]) == "1";
|
||||
i++;
|
||||
}
|
||||
else if (arg ==
|
||||
"-uer") // Split resources into their individual components (enabled by default)
|
||||
// TODO: We may wish to make this a part of the config file...
|
||||
{
|
||||
Globals::Instance->useExternalResources = string(argv[i + 1]) == "1";
|
||||
i++;
|
||||
|
@ -149,73 +182,67 @@ int NewMain(int argc, char* argv[])
|
|||
Globals::Instance->texType = ZTexture::GetTextureTypeFromString(argv[i + 1]);
|
||||
i++;
|
||||
}
|
||||
else if (arg == "-cfg") // Set cfg path
|
||||
else if (arg == "-cfg") // Set cfg path (for overlays)
|
||||
// TODO: Change the name of this to something else so it doesn't get confused with XML config files.
|
||||
{
|
||||
Globals::Instance->cfgPath = argv[i + 1];
|
||||
i++;
|
||||
}
|
||||
else if (arg == "-sm") // Set symbol map path
|
||||
{
|
||||
Globals::Instance->GenSymbolMap(argv[i + 1]);
|
||||
i++;
|
||||
}
|
||||
else if (arg == "-rconf") // Read Config File
|
||||
{
|
||||
Globals::Instance->ReadConfigFile(argv[i + 1]);
|
||||
i++;
|
||||
}
|
||||
else if (arg == "-al") // Set actor list
|
||||
{
|
||||
i++;
|
||||
}
|
||||
else if (arg == "-ol") // Set object list
|
||||
{
|
||||
i++;
|
||||
}
|
||||
else if (arg == "-eh") // Enable Error Handler
|
||||
{
|
||||
#if !defined(_MSC_VER) && !defined(__CYGWIN__)
|
||||
signal(SIGSEGV, ErrorHandler);
|
||||
signal(SIGABRT, ErrorHandler);
|
||||
#else
|
||||
printf("Warning: Tried to set error handler, but this build lacks support for one.\n");
|
||||
#endif
|
||||
}
|
||||
else if (arg == "-v") // Verbose
|
||||
{
|
||||
Globals::Instance->verbosity = (VerbosityLevel)strtol(argv[++i], NULL, 16);
|
||||
}
|
||||
else if (arg == "-wu" || arg == "--warn-unaccounted") // Warn unaccounted
|
||||
{
|
||||
Globals::Instance->warnUnaccounted = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (Globals::Instance->verbosity >= VERBOSITY_INFO)
|
||||
printf("ZAPD: Zelda Asset Processor For Decomp: %s\n", gBuildHash);
|
||||
|
||||
if (fileMode == ZFileMode::Build || fileMode == ZFileMode::Extract ||
|
||||
fileMode == ZFileMode::BuildSourceFile)
|
||||
try
|
||||
{
|
||||
bool parseSuccessful = Parse(Globals::Instance->inputPath, Globals::Instance->baseRomPath,
|
||||
if (fileMode == ZFileMode::Extract || fileMode == ZFileMode::BuildSourceFile)
|
||||
{
|
||||
bool parseSuccessful =
|
||||
Parse(Globals::Instance->inputPath, Globals::Instance->baseRomPath,
|
||||
Globals::Instance->outputPath, fileMode);
|
||||
|
||||
if (!parseSuccessful)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (fileMode == ZFileMode::BuildTexture)
|
||||
{
|
||||
TextureType texType = Globals::Instance->texType;
|
||||
string pngFilePath = Globals::Instance->inputPath;
|
||||
string outFilePath = Globals::Instance->outputPath;
|
||||
|
||||
BuildAssetTexture(pngFilePath, texType, outFilePath);
|
||||
BuildAssetTexture(Globals::Instance->inputPath, texType, Globals::Instance->outputPath);
|
||||
}
|
||||
else if (fileMode == ZFileMode::BuildBackground)
|
||||
{
|
||||
BuildAssetBackground(Globals::Instance->inputPath, Globals::Instance->outputPath);
|
||||
}
|
||||
else if (fileMode == ZFileMode::BuildBlob)
|
||||
{
|
||||
string blobFilePath = Globals::Instance->inputPath;
|
||||
string outFilePath = Globals::Instance->outputPath;
|
||||
|
||||
BuildAssetBlob(blobFilePath, outFilePath);
|
||||
BuildAssetBlob(Globals::Instance->inputPath, Globals::Instance->outputPath);
|
||||
}
|
||||
else if (fileMode == ZFileMode::BuildModelIntermediette)
|
||||
{
|
||||
BuildAssetModelIntermediette(Globals::Instance->inputPath, Globals::Instance->outputPath);
|
||||
BuildAssetModelIntermediette(Globals::Instance->outputPath);
|
||||
}
|
||||
else if (fileMode == ZFileMode::BuildAnimationIntermediette)
|
||||
{
|
||||
|
@ -231,11 +258,16 @@ int NewMain(int argc, char* argv[])
|
|||
if (overlay)
|
||||
File::WriteAllText(Globals::Instance->outputPath, overlay->GetSourceOutputCode(""));
|
||||
}
|
||||
|
||||
}
|
||||
catch (std::runtime_error& e)
|
||||
{
|
||||
printf("Exception occurred: %s\n", e.what());
|
||||
}
|
||||
delete g;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Parse(const std::string& xmlFilePath, const std::string& basePath, const std::string& outPath,
|
||||
bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, const fs::path& outPath,
|
||||
ZFileMode fileMode)
|
||||
{
|
||||
XMLDocument doc;
|
||||
|
@ -260,16 +292,21 @@ bool Parse(const std::string& xmlFilePath, const std::string& basePath, const st
|
|||
{
|
||||
if (string(child->Name()) == "File")
|
||||
{
|
||||
ZFile* file = new ZFile(fileMode, child, basePath, outPath, "", false);
|
||||
ZFile* file = new ZFile(fileMode, child, basePath, outPath, "", xmlFilePath, false);
|
||||
Globals::Instance->files.push_back(file);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error(
|
||||
StringHelper::Sprintf("Parse: Fatal error in '%s'.\n\t Found a resource outside of "
|
||||
"a File element: '%s'\n",
|
||||
xmlFilePath.c_str(), child->Name()));
|
||||
}
|
||||
}
|
||||
|
||||
for (ZFile* file : Globals::Instance->files)
|
||||
{
|
||||
if (fileMode == ZFileMode::Build)
|
||||
file->BuildResources();
|
||||
else if (fileMode == ZFileMode::BuildSourceFile)
|
||||
if (fileMode == ZFileMode::BuildSourceFile)
|
||||
file->BuildSourceFile(outPath);
|
||||
else
|
||||
file->ExtractResources(outPath);
|
||||
|
@ -284,19 +321,16 @@ bool Parse(const std::string& xmlFilePath, const std::string& basePath, const st
|
|||
return true;
|
||||
}
|
||||
|
||||
void BuildAssetTexture(const std::string& pngFilePath, TextureType texType,
|
||||
const std::string& outPath)
|
||||
void BuildAssetTexture(const fs::path& pngFilePath, TextureType texType, const fs::path& outPath)
|
||||
{
|
||||
vector<string> split = StringHelper::Split(outPath, "/");
|
||||
string name = StringHelper::Split(split[split.size() - 1], ".")[0];
|
||||
string name = outPath.stem();
|
||||
|
||||
ZTexture* tex = ZTexture::FromPNG(pngFilePath, texType);
|
||||
string cfgPath = StringHelper::Split(pngFilePath, ".")[0] + ".cfg";
|
||||
|
||||
if (File::Exists(cfgPath))
|
||||
name = File::ReadAllText(cfgPath);
|
||||
|
||||
// string src = StringHelper::Sprintf("u64 %s[] = \n{\n", name.c_str()) +
|
||||
// tex->GetSourceOutputCode(name) + "};\n";
|
||||
string src = tex->GetSourceOutputCode(name);
|
||||
|
||||
File::WriteAllText(outPath, src);
|
||||
|
@ -304,14 +338,19 @@ void BuildAssetTexture(const std::string& pngFilePath, TextureType texType,
|
|||
delete tex;
|
||||
}
|
||||
|
||||
void BuildAssetBlob(const std::string& blobFilePath, const std::string& outPath)
|
||||
void BuildAssetBackground(const fs::path& imageFilePath, const fs::path& outPath)
|
||||
{
|
||||
vector<string> split = StringHelper::Split(outPath, "/");
|
||||
ZBlob* blob = ZBlob::FromFile(blobFilePath);
|
||||
string name = StringHelper::Split(split[split.size() - 1], ".")[0];
|
||||
ZBackground background(nullptr);
|
||||
background.ParseBinaryFile(imageFilePath, false);
|
||||
|
||||
File::WriteAllText(outPath, background.GetBodySourceCode());
|
||||
}
|
||||
|
||||
void BuildAssetBlob(const fs::path& blobFilePath, const fs::path& outPath)
|
||||
{
|
||||
ZBlob* blob = ZBlob::FromFile(blobFilePath);
|
||||
string name = outPath.stem(); // filename without extension
|
||||
|
||||
// string src = StringHelper::Sprintf("u8 %s[] = \n{\n", name.c_str()) +
|
||||
// blob->GetSourceOutputCode(name) + "};\n";
|
||||
string src = blob->GetSourceOutputCode(name);
|
||||
|
||||
File::WriteAllText(outPath, src);
|
||||
|
@ -319,12 +358,10 @@ void BuildAssetBlob(const std::string& blobFilePath, const std::string& outPath)
|
|||
delete blob;
|
||||
}
|
||||
|
||||
void BuildAssetModelIntermediette(const std::string& mdlPath, const std::string& outPath)
|
||||
void BuildAssetModelIntermediette(const fs::path& outPath)
|
||||
{
|
||||
XMLDocument doc;
|
||||
// XMLError eResult = doc.LoadFile(mdlPath.c_str());
|
||||
|
||||
vector<string> split = StringHelper::Split(outPath, "/");
|
||||
HLModelIntermediette* mdl = HLModelIntermediette::FromXML(doc.RootElement());
|
||||
string output = mdl->OutputCode();
|
||||
|
||||
|
@ -333,7 +370,7 @@ void BuildAssetModelIntermediette(const std::string& mdlPath, const std::string&
|
|||
delete mdl;
|
||||
}
|
||||
|
||||
void BuildAssetAnimationIntermediette(const std::string& animPath, const std::string& outPath)
|
||||
void BuildAssetAnimationIntermediette(const fs::path& animPath, const fs::path& outPath)
|
||||
{
|
||||
vector<string> split = StringHelper::Split(outPath, "/");
|
||||
ZFile* file = new ZFile("", split[split.size() - 2]);
|
||||
|
@ -341,8 +378,6 @@ void BuildAssetAnimationIntermediette(const std::string& animPath, const std::st
|
|||
ZAnimation* zAnim = anim->ToZAnimation();
|
||||
zAnim->SetName(Path::GetFileNameWithoutExtension(split[split.size() - 1]));
|
||||
zAnim->parent = file;
|
||||
// zAnim->rotationIndicesSeg = 1;
|
||||
// zAnim->rotationValuesSeg = 2;
|
||||
|
||||
zAnim->GetSourceOutputCode(split[split.size() - 2]);
|
||||
string output = "";
|
||||
|
|
|
@ -1,94 +1,116 @@
|
|||
#include "OutputFormatter.h"
|
||||
|
||||
int OutputFormatter::write(const char* buf, int count)
|
||||
void OutputFormatter::Flush()
|
||||
{
|
||||
if (col > lineLimit)
|
||||
{
|
||||
str.append(1, '\n');
|
||||
str.append(currentIndent, ' ');
|
||||
|
||||
uint32_t newCol = currentIndent + (wordP - word);
|
||||
|
||||
for (uint32_t i = 0; i < wordNests; i++)
|
||||
nestIndent[nest - i] -= col - newCol;
|
||||
|
||||
col = newCol;
|
||||
}
|
||||
else
|
||||
{
|
||||
str.append(space, spaceP - space);
|
||||
}
|
||||
spaceP = space;
|
||||
|
||||
str.append(word, wordP - word);
|
||||
wordP = word;
|
||||
wordNests = 0;
|
||||
}
|
||||
|
||||
int OutputFormatter::Write(const char* buf, int count)
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
char c = buf[i];
|
||||
|
||||
if (c == ' ' || c == '\t' || c == '\n')
|
||||
{
|
||||
if (wordP - word != 0)
|
||||
{
|
||||
Flush();
|
||||
}
|
||||
|
||||
if (c == '\n')
|
||||
{
|
||||
col = 0;
|
||||
current_indent = nest_indent[nest];
|
||||
*spaceP++ = c;
|
||||
}
|
||||
else if (c == '\t')
|
||||
{
|
||||
int n = tab_size - (col % tab_size);
|
||||
for (int j = 0; j < n - 1; j++)
|
||||
*space_p++ = ' ';
|
||||
c = ' ';
|
||||
int n = tabSize - (col % tabSize);
|
||||
col += n;
|
||||
for (int j = 0; j < n; j++)
|
||||
*spaceP++ = ' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
col++;
|
||||
*spaceP++ = c;
|
||||
}
|
||||
|
||||
currentIndent = nestIndent[nest];
|
||||
}
|
||||
else
|
||||
{
|
||||
col++;
|
||||
|
||||
if (c == '(')
|
||||
{
|
||||
nest++;
|
||||
nest_indent[nest] = col;
|
||||
current_indent = col;
|
||||
nestIndent[nest] = col;
|
||||
wordNests++;
|
||||
}
|
||||
else if (c == ')')
|
||||
{
|
||||
if (nest > 0)
|
||||
nest--;
|
||||
if (wordNests > 0)
|
||||
wordNests--;
|
||||
}
|
||||
|
||||
if (c == ' ' || c == '\t' || c == '\n')
|
||||
{
|
||||
str.append(word, word_p - word);
|
||||
word_p = word;
|
||||
|
||||
*space_p++ = c;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (col > line_limit)
|
||||
{
|
||||
str.append(1, '\n');
|
||||
str.append(current_indent, ' ');
|
||||
col = current_indent + 1 + (word_p - word);
|
||||
}
|
||||
else
|
||||
{
|
||||
str.append(space, space_p - space);
|
||||
}
|
||||
space_p = space;
|
||||
|
||||
*word_p++ = c;
|
||||
*wordP++ = c;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
OutputFormatter* OutputFormatter::static_instance;
|
||||
|
||||
int OutputFormatter::write_static(const char* buf, int count)
|
||||
int OutputFormatter::Write(const std::string& buf)
|
||||
{
|
||||
return static_instance->write(buf, count);
|
||||
return Write(buf.data(), buf.size());
|
||||
}
|
||||
|
||||
int (*OutputFormatter::static_writer())(const char* buf, int count)
|
||||
OutputFormatter* OutputFormatter::Instance;
|
||||
|
||||
int OutputFormatter::WriteStatic(const char* buf, int count)
|
||||
{
|
||||
static_instance = this;
|
||||
return &write_static;
|
||||
return Instance->Write(buf, count);
|
||||
}
|
||||
|
||||
OutputFormatter::OutputFormatter(int tab_size, int default_indent, int line_limit)
|
||||
: tab_size{tab_size}, default_indent{default_indent}, line_limit{line_limit}, col{0}, nest{0},
|
||||
nest_indent{default_indent}, current_indent{default_indent}, word_p{word}, space_p{space}
|
||||
int (*OutputFormatter::StaticWriter())(const char* buf, int count)
|
||||
{
|
||||
Instance = this;
|
||||
return &WriteStatic;
|
||||
}
|
||||
|
||||
OutputFormatter::OutputFormatter(uint32_t tabSize, uint32_t defaultIndent, uint32_t lineLimit)
|
||||
: tabSize{tabSize}, defaultIndent{defaultIndent}, lineLimit{lineLimit}, col{0}, nest{0},
|
||||
nestIndent{defaultIndent}, currentIndent{defaultIndent},
|
||||
wordNests(0), wordP{word}, spaceP{space}
|
||||
{
|
||||
}
|
||||
|
||||
std::string OutputFormatter::get_output()
|
||||
std::string OutputFormatter::GetOutput()
|
||||
{
|
||||
str.append(space, space_p - space);
|
||||
space_p = space;
|
||||
|
||||
str.append(word, word_p - word);
|
||||
word_p = word;
|
||||
Flush();
|
||||
|
||||
return std::move(str);
|
||||
}
|
||||
|
|
|
@ -7,31 +7,35 @@
|
|||
class OutputFormatter
|
||||
{
|
||||
private:
|
||||
const int tab_size;
|
||||
const int default_indent;
|
||||
const int line_limit;
|
||||
const uint32_t tabSize;
|
||||
const uint32_t defaultIndent;
|
||||
const uint32_t lineLimit;
|
||||
|
||||
int col;
|
||||
int nest;
|
||||
int nest_indent[8];
|
||||
int current_indent;
|
||||
uint32_t col;
|
||||
uint32_t nest;
|
||||
uint32_t nestIndent[8];
|
||||
uint32_t currentIndent;
|
||||
uint32_t wordNests;
|
||||
|
||||
char word[128];
|
||||
char space[128];
|
||||
char* word_p;
|
||||
char* space_p;
|
||||
char* wordP;
|
||||
char* spaceP;
|
||||
|
||||
std::string str;
|
||||
|
||||
int write(const char* buf, int count);
|
||||
void Flush();
|
||||
|
||||
static OutputFormatter* static_instance;
|
||||
static int write_static(const char* buf, int count);
|
||||
static OutputFormatter* Instance;
|
||||
static int WriteStatic(const char* buf, int count);
|
||||
|
||||
public:
|
||||
OutputFormatter(int tab_size = 4, int default_indent = 4, int line_limit = 120);
|
||||
OutputFormatter(uint32_t tabSize = 4, uint32_t defaultIndent = 4, uint32_t lineLimit = 120);
|
||||
|
||||
int (*static_writer())(const char* buf, int count);
|
||||
int (*StaticWriter())(const char* buf, int count); // Must be `int` due to libgfxd
|
||||
|
||||
std::string get_output();
|
||||
int Write(const char* buf, int count);
|
||||
int Write(const std::string& buf);
|
||||
|
||||
std::string GetOutput();
|
||||
};
|
|
@ -36,7 +36,7 @@ ZOverlay* ZOverlay::FromBuild(string buildPath, string cfgFolderPath)
|
|||
vector<string> relSections = {".rel.text", ".rel.data", ".rel.rodata"};
|
||||
vector<string> sections = {".text", ".data", ".rodata"};
|
||||
|
||||
int sectionOffs[5] = {0};
|
||||
int32_t sectionOffs[5] = {0};
|
||||
vector<RelocationEntry*> textRelocs;
|
||||
vector<RelocationEntry*> dataRelocs;
|
||||
vector<RelocationEntry*> rodataRelocs;
|
||||
|
@ -65,7 +65,7 @@ ZOverlay* ZOverlay::FromBuild(string buildPath, string cfgFolderPath)
|
|||
for (auto curReader : readers)
|
||||
{
|
||||
Elf_Half sec_num = curReader->sections.size();
|
||||
for (int i = 0; i < sec_num; i++)
|
||||
for (int32_t i = 0; i < sec_num; i++)
|
||||
{
|
||||
section* pSec = curReader->sections[i];
|
||||
|
||||
|
@ -75,16 +75,16 @@ ZOverlay* ZOverlay::FromBuild(string buildPath, string cfgFolderPath)
|
|||
SectionType sectionType = GetSectionTypeFromStr(pSec->get_name());
|
||||
|
||||
if (sectionType == SectionType::ERROR)
|
||||
printf("WARNING: One of the section types returned ERROR\n");
|
||||
fprintf(stderr, "WARNING: One of the section types returned ERROR\n");
|
||||
|
||||
relocation_section_accessor relocs(*curReader, pSec);
|
||||
for (Elf_Xword j = 0; j < relocs.get_entries_num(); j++)
|
||||
{
|
||||
Elf64_Addr offset;
|
||||
Elf_Word symbol;
|
||||
Elf_Word type;
|
||||
Elf64_Addr offset = 0;
|
||||
Elf_Word symbol = 0;
|
||||
Elf_Word type = 0;
|
||||
{
|
||||
Elf_Sxword addend;
|
||||
Elf_Sxword addend = 0;
|
||||
relocs.get_entry(j, offset, symbol, type, addend);
|
||||
}
|
||||
|
||||
|
@ -163,7 +163,7 @@ ZOverlay* ZOverlay::FromBuild(string buildPath, string cfgFolderPath)
|
|||
}
|
||||
|
||||
// increase section offsets
|
||||
for (int i = 0; i < sec_num; i++)
|
||||
for (int32_t i = 0; i < sec_num; i++)
|
||||
{
|
||||
section* pSec = curReader->sections[i];
|
||||
if (pSec->get_type() == SHT_PROGBITS &&
|
||||
|
@ -208,7 +208,7 @@ string ZOverlay::GetSourceOutputCode(const std::string& prefix)
|
|||
output += StringHelper::Sprintf(".word 0x%08X\n", reloc->CalcRelocationWord());
|
||||
}
|
||||
|
||||
int offset = ((int)entries.size() * 4) + 20;
|
||||
size_t offset = (entries.size() * 4) + 20;
|
||||
|
||||
while (offset % 16 != 12)
|
||||
{
|
||||
|
@ -220,11 +220,6 @@ string ZOverlay::GetSourceOutputCode(const std::string& prefix)
|
|||
return output;
|
||||
}
|
||||
|
||||
ZResourceType ZOverlay::GetResourceType()
|
||||
{
|
||||
return ZResourceType::Overlay;
|
||||
}
|
||||
|
||||
SectionType ZOverlay::GetSectionTypeFromStr(string sectionName)
|
||||
{
|
||||
if (sectionName == ".rel.text" || sectionName == ".text")
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class ZOverlay : public ZResource
|
||||
class ZOverlay
|
||||
{
|
||||
public:
|
||||
std::string name;
|
||||
|
@ -55,8 +55,7 @@ public:
|
|||
ZOverlay(std::string nName);
|
||||
~ZOverlay();
|
||||
static ZOverlay* FromBuild(std::string buildPath, std::string cfgFolderPath);
|
||||
std::string GetSourceOutputCode(const std::string& prefix) override;
|
||||
ZResourceType GetResourceType() override;
|
||||
std::string GetSourceOutputCode(const std::string& prefix);
|
||||
|
||||
private:
|
||||
std::vector<RelocationEntry*> entries;
|
||||
|
|
|
@ -15,10 +15,16 @@ namespace fs = std::experimental::filesystem;
|
|||
class Path
|
||||
{
|
||||
public:
|
||||
static std::string GetFileName(const std::string& input)
|
||||
{
|
||||
std::vector<std::string> split = StringHelper::Split(input, "/");
|
||||
return split[split.size() - 1];
|
||||
};
|
||||
|
||||
static std::string GetFileNameWithoutExtension(const std::string& input)
|
||||
{
|
||||
std::vector<std::string> split = StringHelper::Split(input, "/");
|
||||
return split[split.size() - 1].substr(0, input.find_last_of("."));
|
||||
return split[split.size() - 1].substr(0, split[split.size() - 1].find_last_of("."));
|
||||
};
|
||||
|
||||
static std::string GetFileNameExtension(const std::string& input)
|
||||
|
|
|
@ -43,6 +43,17 @@ public:
|
|||
return s;
|
||||
}
|
||||
|
||||
static std::string Replace(std::string str, const std::string& from, const std::string& to)
|
||||
{
|
||||
size_t start_pos = str.find(from);
|
||||
|
||||
if (start_pos == std::string::npos)
|
||||
return str;
|
||||
|
||||
str.replace(start_pos, from.length(), to);
|
||||
return str;
|
||||
}
|
||||
|
||||
static bool StartsWith(const std::string& s, const std::string& input)
|
||||
{
|
||||
return s.rfind(input, 0) == 0;
|
||||
|
@ -55,7 +66,7 @@ public:
|
|||
|
||||
static bool EndsWith(const std::string& s, const std::string& input)
|
||||
{
|
||||
int inputLen = strlen(input.c_str());
|
||||
int32_t inputLen = strlen(input.c_str());
|
||||
return s.rfind(input) == (s.size() - inputLen);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,12 @@ struct Vec3s
|
|||
{
|
||||
int16_t x, y, z;
|
||||
|
||||
Vec3s()
|
||||
{
|
||||
x = 0;
|
||||
y = 0;
|
||||
z = 0;
|
||||
};
|
||||
Vec3s(int16_t nX, int16_t nY, int16_t nZ)
|
||||
{
|
||||
x = nX;
|
||||
|
|
|
@ -71,8 +71,8 @@
|
|||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<IncludePath>$(SolutionDir)lib\tinyxml2;$(SolutionDir)lib\elfio;$(SolutionDir)lib\assimp\include;$(SolutionDir)lib\stb;$(ProjectDir);$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(SolutionDir)lib\assimp-built;$(LibraryPath)</LibraryPath>
|
||||
<IncludePath>$(SolutionDir)lib\tinyxml2;$(SolutionDir)lib\libgfxd;$(SolutionDir)lib\elfio;$(SolutionDir)lib\assimp\include;$(SolutionDir)lib\stb;$(ProjectDir);$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(SolutionDir)lib\libgfxd;$(SolutionDir)lib\assimp-built;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<IncludePath>$(IncludePath)</IncludePath>
|
||||
|
@ -98,6 +98,7 @@
|
|||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;USE_ASSIMP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<LanguageStandard_C>stdc11</LanguageStandard_C>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<Profile>true</Profile>
|
||||
|
@ -139,14 +140,33 @@ python3 ZAPD/genbuildinfo.py</Command>
|
|||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\lib\libgfxd\gfxd.c" />
|
||||
<ClCompile Include="..\lib\libgfxd\uc.c" />
|
||||
<ClCompile Include="..\lib\libgfxd\uc_f3d.c" />
|
||||
<ClCompile Include="..\lib\libgfxd\uc_f3db.c" />
|
||||
<ClCompile Include="..\lib\libgfxd\uc_f3dex.c" />
|
||||
<ClCompile Include="..\lib\libgfxd\uc_f3dex2.c" />
|
||||
<ClCompile Include="..\lib\libgfxd\uc_f3dexb.c" />
|
||||
<ClCompile Include="..\lib\tinyxml2\tinyxml2.cpp" />
|
||||
<ClCompile Include="Globals.cpp" />
|
||||
<ClCompile Include="HighLevel\HLAnimationIntermediette.cpp" />
|
||||
<ClCompile Include="HighLevel\HLModelIntermediette.cpp" />
|
||||
<ClCompile Include="HighLevel\HLTexture.cpp" />
|
||||
<ClCompile Include="Main.cpp" />
|
||||
<ClCompile Include="OutputFormatter.cpp" />
|
||||
<ClCompile Include="Overlays\ZOverlay.cpp" />
|
||||
<ClCompile Include="ZArray.cpp" />
|
||||
<ClCompile Include="ZBackground.cpp" />
|
||||
<ClCompile Include="ZCutsceneMM.cpp" />
|
||||
<ClCompile Include="ZLimb.cpp" />
|
||||
<ClCompile Include="ZMtx.cpp" />
|
||||
<ClCompile Include="ZRoom\Commands\SetActorCutsceneList.cpp" />
|
||||
<ClCompile Include="ZRoom\Commands\SetAnimatedTextureList.cpp" />
|
||||
<ClCompile Include="ZRoom\Commands\SetCsCamera.cpp" />
|
||||
<ClCompile Include="ZRoom\Commands\SetMinimapChests.cpp" />
|
||||
<ClCompile Include="ZRoom\Commands\SetMinimapList.cpp" />
|
||||
<ClCompile Include="ZRoom\Commands\SetWorldMapVisited.cpp" />
|
||||
<ClCompile Include="ZRoom\Commands\Unused1D.cpp" />
|
||||
<ClCompile Include="ZScalar.cpp" />
|
||||
<ClCompile Include="ZAnimation.cpp" />
|
||||
<ClCompile Include="ZBlob.cpp" />
|
||||
|
@ -184,6 +204,7 @@ python3 ZAPD/genbuildinfo.py</Command>
|
|||
<ClCompile Include="ZRoom\Commands\ZRoomCommandUnk.cpp" />
|
||||
<ClCompile Include="ZRoom\ZRoom.cpp" />
|
||||
<ClCompile Include="ZRoom\ZRoomCommand.cpp" />
|
||||
<ClCompile Include="ZSymbol.cpp" />
|
||||
<ClCompile Include="ZTexture.cpp" />
|
||||
<ClCompile Include="ZVector.cpp" />
|
||||
<ClCompile Include="ZVtx.cpp" />
|
||||
|
@ -202,11 +223,15 @@ python3 ZAPD/genbuildinfo.py</Command>
|
|||
<ClInclude Include="..\lib\elfio\elfio\elfio_utils.hpp" />
|
||||
<ClInclude Include="..\lib\elfio\elfio\elf_types.hpp" />
|
||||
<ClInclude Include="..\lib\json\include\nlohmann\json.hpp" />
|
||||
<ClInclude Include="..\lib\libgfxd\gbi.h" />
|
||||
<ClInclude Include="..\lib\libgfxd\gfxd.h" />
|
||||
<ClInclude Include="..\lib\libgfxd\priv.h" />
|
||||
<ClInclude Include="..\lib\stb\stb_image.h" />
|
||||
<ClInclude Include="..\lib\stb\stb_image_write.h" />
|
||||
<ClInclude Include="..\lib\stb\tinyxml2.h" />
|
||||
<ClInclude Include="..\lib\tinygtlf\tiny_gltf.h" />
|
||||
<ClInclude Include="BitConverter.h" />
|
||||
<ClInclude Include="CRC32.h" />
|
||||
<ClInclude Include="Directory.h" />
|
||||
<ClInclude Include="File.h" />
|
||||
<ClInclude Include="Globals.h" />
|
||||
|
@ -215,17 +240,29 @@ python3 ZAPD/genbuildinfo.py</Command>
|
|||
<ClInclude Include="HighLevel\HLFileIntermediette.h" />
|
||||
<ClInclude Include="HighLevel\HLModelIntermediette.h" />
|
||||
<ClInclude Include="HighLevel\HLTexture.h" />
|
||||
<ClInclude Include="OutputFormatter.h" />
|
||||
<ClInclude Include="Overlays\ZOverlay.h" />
|
||||
<ClInclude Include="Path.h" />
|
||||
<ClInclude Include="StringHelper.h" />
|
||||
<ClInclude Include="Vec3s.h" />
|
||||
<ClInclude Include="ZAnimation.h" />
|
||||
<ClInclude Include="ZArray.h" />
|
||||
<ClInclude Include="ZBackground.h" />
|
||||
<ClInclude Include="ZBlob.h" />
|
||||
<ClInclude Include="ZCollision.h" />
|
||||
<ClInclude Include="ZCutscene.h" />
|
||||
<ClInclude Include="ZCutsceneMM.h" />
|
||||
<ClInclude Include="ZDisplayList.h" />
|
||||
<ClInclude Include="ZFile.h" />
|
||||
<ClInclude Include="ZLimb.h" />
|
||||
<ClInclude Include="ZMtx.h" />
|
||||
<ClInclude Include="ZRoom\Commands\SetActorCutsceneList.h" />
|
||||
<ClInclude Include="ZRoom\Commands\SetAnimatedTextureList.h" />
|
||||
<ClInclude Include="ZRoom\Commands\SetCsCamera.h" />
|
||||
<ClInclude Include="ZRoom\Commands\SetMinimapChests.h" />
|
||||
<ClInclude Include="ZRoom\Commands\SetMinimapList.h" />
|
||||
<ClInclude Include="ZRoom\Commands\SetWorldMapVisited.h" />
|
||||
<ClInclude Include="ZRoom\Commands\Unused1D.h" />
|
||||
<ClInclude Include="ZScalar.h" />
|
||||
<ClInclude Include="ZSkeleton.h" />
|
||||
<ClInclude Include="ZResource.h" />
|
||||
|
@ -259,6 +296,7 @@ python3 ZAPD/genbuildinfo.py</Command>
|
|||
<ClInclude Include="ZRoom\ObjectList.h" />
|
||||
<ClInclude Include="ZRoom\ZRoom.h" />
|
||||
<ClInclude Include="ZRoom\ZRoomCommand.h" />
|
||||
<ClInclude Include="ZSymbol.h" />
|
||||
<ClInclude Include="ZTexture.h" />
|
||||
<ClInclude Include="ZVector.h" />
|
||||
<ClInclude Include="ZVtx.h" />
|
||||
|
|
|
@ -55,6 +55,12 @@
|
|||
<Filter Include="Header Files\Libraries\fbx">
|
||||
<UniqueIdentifier>{be9a5be0-ec6a-4200-8e39-bb58c7da7aa8}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\Libraries\libgfxd">
|
||||
<UniqueIdentifier>{7ee79d97-c6a8-4e82-93ef-37981f4d7838}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\Libraries\libgfxd">
|
||||
<UniqueIdentifier>{85600275-99fe-491d-8189-bcc3dc1a8903}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Main.cpp">
|
||||
|
@ -201,6 +207,66 @@
|
|||
<ClCompile Include="ZVtx.cpp">
|
||||
<Filter>Source Files\Z64</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZLimb.cpp">
|
||||
<Filter>Source Files\Z64</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="OutputFormatter.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZSymbol.cpp">
|
||||
<Filter>Source Files\Z64</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\lib\libgfxd\gfxd.c">
|
||||
<Filter>Source Files\Libraries\libgfxd</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\lib\libgfxd\uc.c">
|
||||
<Filter>Source Files\Libraries\libgfxd</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\lib\libgfxd\uc_f3d.c">
|
||||
<Filter>Source Files\Libraries\libgfxd</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\lib\libgfxd\uc_f3db.c">
|
||||
<Filter>Source Files\Libraries\libgfxd</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\lib\libgfxd\uc_f3dex.c">
|
||||
<Filter>Source Files\Libraries\libgfxd</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\lib\libgfxd\uc_f3dex2.c">
|
||||
<Filter>Source Files\Libraries\libgfxd</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\lib\libgfxd\uc_f3dexb.c">
|
||||
<Filter>Source Files\Libraries\libgfxd</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZMtx.cpp">
|
||||
<Filter>Source Files\Z64</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZRoom\Commands\SetWorldMapVisited.cpp">
|
||||
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZRoom\Commands\Unused1D.cpp">
|
||||
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZRoom\Commands\SetActorCutsceneList.cpp">
|
||||
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZRoom\Commands\SetAnimatedTextureList.cpp">
|
||||
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZRoom\Commands\SetCsCamera.cpp">
|
||||
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZRoom\Commands\SetMinimapChests.cpp">
|
||||
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZRoom\Commands\SetMinimapList.cpp">
|
||||
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZCutsceneMM.cpp">
|
||||
<Filter>Source Files\Z64</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZBackground.cpp">
|
||||
<Filter>Source Files\Z64</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Path.h">
|
||||
|
@ -422,6 +488,57 @@
|
|||
<ClInclude Include="ZVtx.h">
|
||||
<Filter>Header Files\Z64</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CRC32.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZLimb.h">
|
||||
<Filter>Header Files\Z64</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="OutputFormatter.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZSymbol.h">
|
||||
<Filter>Header Files\Z64</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\lib\libgfxd\gbi.h">
|
||||
<Filter>Header Files\Libraries\libgfxd</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\lib\libgfxd\gfxd.h">
|
||||
<Filter>Header Files\Libraries\libgfxd</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\lib\libgfxd\priv.h">
|
||||
<Filter>Header Files\Libraries\libgfxd</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZMtx.h">
|
||||
<Filter>Header Files\Z64</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\Commands\SetWorldMapVisited.h">
|
||||
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\Commands\SetActorCutsceneList.h">
|
||||
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\Commands\Unused1D.h">
|
||||
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\Commands\SetAnimatedTextureList.h">
|
||||
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\Commands\SetCsCamera.h">
|
||||
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\Commands\SetMinimapChests.h">
|
||||
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\Commands\SetMinimapList.h">
|
||||
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZCutsceneMM.h">
|
||||
<Filter>Header Files\Z64</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZBackground.h">
|
||||
<Filter>Header Files\Z64</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="..\SymbolMap_OoTMqDbg.txt">
|
||||
|
|
|
@ -9,7 +9,11 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
ZAnimation::ZAnimation() : ZResource()
|
||||
REGISTER_ZFILENODE(Animation, ZNormalAnimation);
|
||||
REGISTER_ZFILENODE(PlayerAnimation, ZLinkAnimation);
|
||||
REGISTER_ZFILENODE(CurveAnimation, ZCurveAnimation);
|
||||
|
||||
ZAnimation::ZAnimation(ZFile* nParent) : ZResource(nParent)
|
||||
{
|
||||
frameCount = 0;
|
||||
}
|
||||
|
@ -49,7 +53,7 @@ ZResourceType ZAnimation::GetResourceType()
|
|||
return ZResourceType::Animation;
|
||||
}
|
||||
|
||||
ZNormalAnimation::ZNormalAnimation() : ZAnimation()
|
||||
ZNormalAnimation::ZNormalAnimation(ZFile* nParent) : ZAnimation(nParent)
|
||||
{
|
||||
rotationValues = vector<uint16_t>();
|
||||
rotationIndices = vector<RotationIndex>();
|
||||
|
@ -63,16 +67,18 @@ std::string ZNormalAnimation::GetSourceOutputCode(const std::string& prefix)
|
|||
string defaultPrefix = name.c_str();
|
||||
defaultPrefix.replace(0, 1, "s"); // replace g prefix with s for local variables
|
||||
|
||||
string headerStr =
|
||||
StringHelper::Sprintf("{ %i }, %sFrameData, %sJointIndices, %i", frameCount,
|
||||
defaultPrefix.c_str(), defaultPrefix.c_str(), limit);
|
||||
parent->AddDeclaration(rawDataIndex, DeclarationAlignment::None, GetRawDataSize(), GetSourceTypeName(),
|
||||
StringHelper::Sprintf("%s", name.c_str()), headerStr);
|
||||
string headerStr = StringHelper::Sprintf("\n\t{ %i },\n", frameCount);
|
||||
headerStr += StringHelper::Sprintf("\t%sFrameData,\n", defaultPrefix.c_str());
|
||||
headerStr += StringHelper::Sprintf("\t%sJointIndices,\n", defaultPrefix.c_str());
|
||||
headerStr += StringHelper::Sprintf("\t%i\n", limit);
|
||||
parent->AddDeclaration(rawDataIndex, DeclarationAlignment::None, GetRawDataSize(),
|
||||
GetSourceTypeName(), StringHelper::Sprintf("%s", name.c_str()),
|
||||
headerStr);
|
||||
|
||||
string indicesStr = "";
|
||||
string valuesStr = " ";
|
||||
const int lineLength = 14;
|
||||
const int offset = 0;
|
||||
const uint8_t lineLength = 14;
|
||||
const uint8_t offset = 0;
|
||||
|
||||
for (size_t i = 0; i < rotationValues.size(); i++)
|
||||
{
|
||||
|
@ -93,12 +99,12 @@ std::string ZNormalAnimation::GetSourceOutputCode(const std::string& prefix)
|
|||
}
|
||||
|
||||
parent->AddDeclarationArray(rotationValuesSeg, DeclarationAlignment::Align16,
|
||||
(int)rotationValues.size() * 2, "static s16",
|
||||
rotationValues.size() * 2, "static s16",
|
||||
StringHelper::Sprintf("%sFrameData", defaultPrefix.c_str()),
|
||||
rotationValues.size(), valuesStr);
|
||||
|
||||
parent->AddDeclarationArray(rotationIndicesSeg, DeclarationAlignment::Align16,
|
||||
(int)rotationIndices.size() * 6, "static JointIndex",
|
||||
rotationIndices.size() * 6, "static JointIndex",
|
||||
StringHelper::Sprintf("%sJointIndices", defaultPrefix.c_str()),
|
||||
rotationIndices.size(), indicesStr);
|
||||
}
|
||||
|
@ -106,7 +112,7 @@ std::string ZNormalAnimation::GetSourceOutputCode(const std::string& prefix)
|
|||
return "";
|
||||
}
|
||||
|
||||
int ZNormalAnimation::GetRawDataSize()
|
||||
size_t ZNormalAnimation::GetRawDataSize()
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
|
@ -116,17 +122,14 @@ std::string ZNormalAnimation::GetSourceTypeName()
|
|||
return "AnimationHeader";
|
||||
}
|
||||
|
||||
ZNormalAnimation* ZNormalAnimation::ExtractFromXML(tinyxml2::XMLElement* reader,
|
||||
std::vector<uint8_t> nRawData, int rawDataIndex,
|
||||
const std::string& nRelPath)
|
||||
void ZNormalAnimation::ExtractFromXML(tinyxml2::XMLElement* reader,
|
||||
const std::vector<uint8_t>& nRawData,
|
||||
const uint32_t nRawDataIndex, const std::string& nRelPath)
|
||||
{
|
||||
ZNormalAnimation* anim = new ZNormalAnimation();
|
||||
anim->rawData = std::move(nRawData);
|
||||
anim->rawDataIndex = rawDataIndex;
|
||||
anim->ParseXML(reader);
|
||||
anim->ParseRawData();
|
||||
|
||||
return anim;
|
||||
rawData = std::move(nRawData);
|
||||
rawDataIndex = nRawDataIndex;
|
||||
ParseXML(reader);
|
||||
ParseRawData();
|
||||
}
|
||||
|
||||
void ZNormalAnimation::ParseRawData()
|
||||
|
@ -160,7 +163,7 @@ void ZNormalAnimation::ParseRawData()
|
|||
}
|
||||
}
|
||||
|
||||
ZLinkAnimation::ZLinkAnimation() : ZAnimation()
|
||||
ZLinkAnimation::ZLinkAnimation(ZFile* nParent) : ZAnimation(nParent)
|
||||
{
|
||||
segmentAddress = 0;
|
||||
}
|
||||
|
@ -174,15 +177,17 @@ std::string ZLinkAnimation::GetSourceOutputCode(const std::string& prefix)
|
|||
parent->GetDeclarationName(
|
||||
segmentAddress, StringHelper::Sprintf("%sSeg%06X", name.c_str(),
|
||||
segmentAddress));
|
||||
string headerStr = StringHelper::Sprintf("{ %i }, 0x%08X", frameCount, segmentAddress);
|
||||
parent->AddDeclaration(rawDataIndex, DeclarationAlignment::None, GetRawDataSize(), GetSourceTypeName(),
|
||||
StringHelper::Sprintf("%s", name.c_str()), headerStr);
|
||||
string headerStr =
|
||||
StringHelper::Sprintf("\n\t{ %i },\n\t0x%08X\n", frameCount, segmentAddress);
|
||||
parent->AddDeclaration(rawDataIndex, DeclarationAlignment::None, GetRawDataSize(),
|
||||
GetSourceTypeName(), StringHelper::Sprintf("%s", name.c_str()),
|
||||
headerStr);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
int ZLinkAnimation::GetRawDataSize()
|
||||
size_t ZLinkAnimation::GetRawDataSize()
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
@ -192,17 +197,14 @@ std::string ZLinkAnimation::GetSourceTypeName()
|
|||
return "LinkAnimationHeader";
|
||||
}
|
||||
|
||||
ZLinkAnimation* ZLinkAnimation::ExtractFromXML(tinyxml2::XMLElement* reader,
|
||||
std::vector<uint8_t> nRawData, int rawDataIndex,
|
||||
const std::string& nRelPath)
|
||||
void ZLinkAnimation::ExtractFromXML(tinyxml2::XMLElement* reader,
|
||||
const std::vector<uint8_t>& nRawData,
|
||||
const uint32_t nRawDataIndex, const std::string& nRelPath)
|
||||
{
|
||||
ZLinkAnimation* anim = new ZLinkAnimation();
|
||||
anim->rawData = std::move(nRawData);
|
||||
anim->rawDataIndex = rawDataIndex;
|
||||
anim->ParseXML(reader);
|
||||
anim->ParseRawData();
|
||||
|
||||
return anim;
|
||||
rawData = std::move(nRawData);
|
||||
rawDataIndex = nRawDataIndex;
|
||||
ParseXML(reader);
|
||||
ParseRawData();
|
||||
}
|
||||
|
||||
void ZLinkAnimation::ParseRawData()
|
||||
|
@ -210,8 +212,6 @@ void ZLinkAnimation::ParseRawData()
|
|||
ZAnimation::ParseRawData();
|
||||
|
||||
const uint8_t* data = rawData.data();
|
||||
|
||||
// segmentAddress = GETSEGOFFSET(BitConverter::ToInt32BE(data, rawDataIndex + 4));
|
||||
segmentAddress = (BitConverter::ToInt32BE(data, rawDataIndex + 4));
|
||||
}
|
||||
|
||||
|
@ -250,56 +250,8 @@ std::string TransformData::GetSourceTypeName()
|
|||
return "TransformData";
|
||||
}
|
||||
|
||||
ZCurveAnimation::ZCurveAnimation(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData,
|
||||
int nRawDataIndex, ZFile* nParent)
|
||||
ZCurveAnimation::ZCurveAnimation(ZFile* nParent) : ZAnimation(nParent)
|
||||
{
|
||||
rawData.assign(nRawData.begin(), nRawData.end());
|
||||
rawDataIndex = nRawDataIndex;
|
||||
parent = nParent;
|
||||
|
||||
ParseXML(reader);
|
||||
ParseRawData();
|
||||
|
||||
skel = new ZSkeleton(ZSkeletonType::Curve, ZLimbType::Curve, "CurveAnim", nRawData,
|
||||
Seg2Filespace(skelOffset, parent->baseAddress), nParent);
|
||||
|
||||
size_t transformDataSize = 0;
|
||||
size_t copyValuesSize = 0;
|
||||
if (refIndex != 0)
|
||||
{
|
||||
uint32_t refIndexOffset = Seg2Filespace(refIndex, parent->baseAddress);
|
||||
for (size_t i = 0; i < 3 * 3 * skel->GetLimbCount(); i++)
|
||||
{
|
||||
uint8_t ref = BitConverter::ToUInt8BE(nRawData, refIndexOffset + i);
|
||||
if (ref == 0)
|
||||
{
|
||||
copyValuesSize++;
|
||||
}
|
||||
else
|
||||
{
|
||||
transformDataSize += ref;
|
||||
}
|
||||
refIndexArr.emplace_back(ref);
|
||||
}
|
||||
}
|
||||
|
||||
if (transformData != 0)
|
||||
{
|
||||
uint32_t transformDataOffset = Seg2Filespace(transformData, parent->baseAddress);
|
||||
for (size_t i = 0; i < transformDataSize; i++)
|
||||
{
|
||||
transformDataArr.emplace_back(parent, nRawData, transformDataOffset, i);
|
||||
}
|
||||
}
|
||||
|
||||
if (copyValues != 0)
|
||||
{
|
||||
uint32_t copyValuesOffset = Seg2Filespace(copyValues, parent->baseAddress);
|
||||
for (size_t i = 0; i < copyValuesSize; i++)
|
||||
{
|
||||
copyValuesArr.emplace_back(BitConverter::ToInt16BE(nRawData, copyValuesOffset + i * 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ZCurveAnimation::~ZCurveAnimation()
|
||||
|
@ -314,9 +266,10 @@ void ZCurveAnimation::ParseXML(tinyxml2::XMLElement* reader)
|
|||
const char* skelOffsetXml = reader->Attribute("SkelOffset");
|
||||
if (skelOffsetXml == nullptr)
|
||||
{
|
||||
throw std::runtime_error(
|
||||
throw std::runtime_error(StringHelper::Sprintf(
|
||||
"ZCurveAnimation::ParseXML: Fatal error in '%s'. Missing 'SkelOffset' attribute in "
|
||||
"xml. You need to provide the offset of the curve skeleton.");
|
||||
"ZCurveAnimation. You need to provide the offset of the curve skeleton.",
|
||||
name.c_str()));
|
||||
}
|
||||
skelOffset = std::strtoul(skelOffsetXml, nullptr, 0);
|
||||
}
|
||||
|
@ -332,19 +285,50 @@ void ZCurveAnimation::ParseRawData()
|
|||
unk_10 = BitConverter::ToInt16BE(rawData, rawDataIndex + 14);
|
||||
}
|
||||
|
||||
ZCurveAnimation* ZCurveAnimation::ExtractFromXML(tinyxml2::XMLElement* reader,
|
||||
void ZCurveAnimation::ExtractFromXML(tinyxml2::XMLElement* reader,
|
||||
const std::vector<uint8_t>& nRawData,
|
||||
int nRawDataIndex, std::string nRelPath,
|
||||
ZFile* nParent)
|
||||
const uint32_t nRawDataIndex, const std::string& nRelPath)
|
||||
{
|
||||
ZCurveAnimation* curve = new ZCurveAnimation(reader, nRawData, nRawDataIndex, nParent);
|
||||
curve->relativePath = std::move(nRelPath);
|
||||
ZResource::ExtractFromXML(reader, nRawData, nRawDataIndex, nRelPath);
|
||||
|
||||
curve->parent->AddDeclaration(curve->rawDataIndex, DeclarationAlignment::Align16,
|
||||
curve->GetRawDataSize(), curve->GetSourceTypeName(), curve->name,
|
||||
"");
|
||||
skel = new ZSkeleton(ZSkeletonType::Curve, ZLimbType::Curve, "CurveAnim", nRawData,
|
||||
Seg2Filespace(skelOffset, parent->baseAddress), parent);
|
||||
|
||||
return curve;
|
||||
size_t transformDataSize = 0;
|
||||
size_t copyValuesSize = 0;
|
||||
if (refIndex != 0)
|
||||
{
|
||||
uint32_t refIndexOffset = Seg2Filespace(refIndex, parent->baseAddress);
|
||||
for (size_t i = 0; i < 3 * 3 * skel->GetLimbCount(); i++)
|
||||
{
|
||||
uint8_t ref = BitConverter::ToUInt8BE(nRawData, refIndexOffset + i);
|
||||
if (ref == 0)
|
||||
copyValuesSize++;
|
||||
else
|
||||
transformDataSize += ref;
|
||||
|
||||
refIndexArr.emplace_back(ref);
|
||||
}
|
||||
}
|
||||
|
||||
if (transformData != 0)
|
||||
{
|
||||
uint32_t transformDataOffset = Seg2Filespace(transformData, parent->baseAddress);
|
||||
|
||||
for (size_t i = 0; i < transformDataSize; i++)
|
||||
transformDataArr.emplace_back(parent, nRawData, transformDataOffset, i);
|
||||
}
|
||||
|
||||
if (copyValues != 0)
|
||||
{
|
||||
uint32_t copyValuesOffset = Seg2Filespace(copyValues, parent->baseAddress);
|
||||
|
||||
for (size_t i = 0; i < copyValuesSize; i++)
|
||||
copyValuesArr.emplace_back(BitConverter::ToInt16BE(nRawData, copyValuesOffset + i * 2));
|
||||
}
|
||||
|
||||
parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align16, GetRawDataSize(),
|
||||
GetSourceTypeName(), name, "");
|
||||
}
|
||||
|
||||
void ZCurveAnimation::PreGenValues(const std::string& prefix)
|
||||
|
@ -443,7 +427,7 @@ void ZCurveAnimation::PreGenValues(const std::string& prefix)
|
|||
}
|
||||
}
|
||||
|
||||
int ZCurveAnimation::GetRawDataSize()
|
||||
size_t ZCurveAnimation::GetRawDataSize()
|
||||
{
|
||||
return 0x10;
|
||||
}
|
||||
|
|
|
@ -26,13 +26,13 @@ class ZAnimation : public ZResource
|
|||
public:
|
||||
int16_t frameCount;
|
||||
|
||||
ZAnimation();
|
||||
ZAnimation(ZFile* nParent);
|
||||
|
||||
std::string GetSourceOutputCode(const std::string& prefix) override;
|
||||
ZResourceType GetResourceType() override;
|
||||
|
||||
protected:
|
||||
virtual void ParseRawData() override;
|
||||
void ParseRawData() override;
|
||||
void Save(const std::string& outFolder) override;
|
||||
void ParseXML(tinyxml2::XMLElement* reader) override;
|
||||
};
|
||||
|
@ -46,16 +46,14 @@ public:
|
|||
uint32_t rotationIndicesSeg;
|
||||
int16_t limit;
|
||||
|
||||
ZNormalAnimation();
|
||||
ZNormalAnimation(ZFile* nParent);
|
||||
|
||||
std::string GetSourceOutputCode(const std::string& prefix) override;
|
||||
int GetRawDataSize() override;
|
||||
|
||||
size_t GetRawDataSize() override;
|
||||
std::string GetSourceTypeName() override;
|
||||
|
||||
static ZNormalAnimation* ExtractFromXML(tinyxml2::XMLElement* reader,
|
||||
std::vector<uint8_t> nRawData, int rawDataIndex,
|
||||
const std::string& nRelPath);
|
||||
void ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData,
|
||||
const uint32_t nRawDataIndex, const std::string& nRelPath) override;
|
||||
|
||||
protected:
|
||||
virtual void ParseRawData() override;
|
||||
|
@ -64,18 +62,16 @@ protected:
|
|||
class ZLinkAnimation : public ZAnimation
|
||||
{
|
||||
public:
|
||||
uint32_t segmentAddress;
|
||||
segptr_t segmentAddress;
|
||||
|
||||
ZLinkAnimation();
|
||||
ZLinkAnimation(ZFile* nParent);
|
||||
|
||||
std::string GetSourceOutputCode(const std::string& prefix) override;
|
||||
int GetRawDataSize() override;
|
||||
|
||||
size_t GetRawDataSize() override;
|
||||
std::string GetSourceTypeName() override;
|
||||
|
||||
static ZLinkAnimation* ExtractFromXML(tinyxml2::XMLElement* reader,
|
||||
std::vector<uint8_t> nRawData, int rawDataIndex,
|
||||
const std::string& nRelPath);
|
||||
void ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData,
|
||||
const uint32_t nRawDataIndex, const std::string& nRelPath) override;
|
||||
|
||||
protected:
|
||||
virtual void ParseRawData() override;
|
||||
|
@ -132,18 +128,16 @@ protected:
|
|||
std::vector<int16_t> copyValuesArr;
|
||||
|
||||
public:
|
||||
ZCurveAnimation() = default;
|
||||
ZCurveAnimation(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData,
|
||||
int nRawDataIndex, ZFile* nParent);
|
||||
ZCurveAnimation();
|
||||
ZCurveAnimation(ZFile* nParent);
|
||||
~ZCurveAnimation();
|
||||
void ParseXML(tinyxml2::XMLElement* reader) override;
|
||||
void ParseRawData() override;
|
||||
static ZCurveAnimation* ExtractFromXML(tinyxml2::XMLElement* reader,
|
||||
const std::vector<uint8_t>& nRawData, int nRawDataIndex,
|
||||
std::string nRelPath, ZFile* nParent);
|
||||
void ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData,
|
||||
const uint32_t nRawDataIndex, const std::string& nRelPath) override;
|
||||
|
||||
void PreGenValues(const std::string& prefix);
|
||||
int GetRawDataSize() override;
|
||||
size_t GetRawDataSize() override;
|
||||
std::string GetSourceOutputCode(const std::string& prefix) override;
|
||||
|
||||
std::string GetSourceTypeName() override;
|
||||
|
|
|
@ -3,8 +3,16 @@
|
|||
#include "StringHelper.h"
|
||||
#include "ZFile.h"
|
||||
|
||||
ZArray::ZArray()
|
||||
REGISTER_ZFILENODE(Array, ZArray);
|
||||
|
||||
ZArray::ZArray(ZFile* nParent) : ZResource(nParent)
|
||||
{
|
||||
canHaveInner = true;
|
||||
}
|
||||
|
||||
ZArray::~ZArray()
|
||||
{
|
||||
delete testFile;
|
||||
}
|
||||
|
||||
void ZArray::ParseXML(tinyxml2::XMLElement* reader)
|
||||
|
@ -13,7 +21,7 @@ void ZArray::ParseXML(tinyxml2::XMLElement* reader)
|
|||
|
||||
arrayCnt = reader->IntAttribute("Count", 0);
|
||||
testFile = new ZFile(ZFileMode::Extract, reader, Globals::Instance->baseRomPath, "",
|
||||
parent->GetName(), true);
|
||||
parent->GetName(), "ZArray subfile", true);
|
||||
}
|
||||
|
||||
// TODO: This is a bit hacky, but until we refactor how ZFile parses the XML, it'll have to do.
|
||||
|
@ -22,12 +30,11 @@ std::string ZArray::GetSourceOutputCode(const std::string& prefix)
|
|||
std::string output = "";
|
||||
|
||||
if (testFile->resources.size() <= 0)
|
||||
{
|
||||
throw StringHelper::Sprintf("Error! Array needs at least one sub-element.\n");
|
||||
}
|
||||
throw std::runtime_error(
|
||||
StringHelper::Sprintf("Error! Array needs at least one sub-element.\n"));
|
||||
|
||||
ZResource* res = testFile->resources[0];
|
||||
int resSize = res->GetRawDataSize();
|
||||
size_t resSize = res->GetRawDataSize();
|
||||
|
||||
if (!res->DoesSupportArray())
|
||||
{
|
||||
|
@ -36,9 +43,9 @@ std::string ZArray::GetSourceOutputCode(const std::string& prefix)
|
|||
res->GetName().c_str()));
|
||||
}
|
||||
|
||||
for (int i = 0; i < arrayCnt; i++)
|
||||
for (size_t i = 0; i < arrayCnt; i++)
|
||||
{
|
||||
int childIndex = rawDataIndex + (i * resSize);
|
||||
size_t childIndex = rawDataIndex + (i * resSize);
|
||||
res->SetRawDataIndex(childIndex);
|
||||
res->ParseRawData();
|
||||
std::string test = res->GetSourceOutputCode("");
|
||||
|
@ -56,20 +63,16 @@ std::string ZArray::GetSourceOutputCode(const std::string& prefix)
|
|||
return "";
|
||||
}
|
||||
|
||||
int ZArray::GetRawDataSize()
|
||||
size_t ZArray::GetRawDataSize()
|
||||
{
|
||||
return arrayCnt * testFile->resources[0]->GetRawDataSize();
|
||||
}
|
||||
|
||||
ZArray* ZArray::ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData,
|
||||
const int rawDataIndex, const std::string& nRelPath, ZFile* nParent)
|
||||
void ZArray::ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData,
|
||||
const uint32_t nRawDataIndex, const std::string& nRelPath)
|
||||
{
|
||||
ZArray* arr = new ZArray();
|
||||
arr->rawData = nRawData;
|
||||
arr->rawDataIndex = rawDataIndex;
|
||||
arr->parent = nParent;
|
||||
arr->ParseXML(reader);
|
||||
rawData = nRawData;
|
||||
rawDataIndex = nRawDataIndex;
|
||||
ParseXML(reader);
|
||||
// arr->ParseRawData();
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
|
|
@ -9,19 +9,19 @@
|
|||
class ZArray : public ZResource
|
||||
{
|
||||
public:
|
||||
ZArray();
|
||||
ZArray(ZFile* nParent);
|
||||
~ZArray();
|
||||
|
||||
void ParseXML(tinyxml2::XMLElement* reader) override;
|
||||
std::string GetSourceOutputCode(const std::string& prefix) override;
|
||||
int GetRawDataSize() override;
|
||||
size_t GetRawDataSize() override;
|
||||
|
||||
static ZArray* ExtractFromXML(tinyxml2::XMLElement* reader,
|
||||
const std::vector<uint8_t>& nRawData, const int rawDataIndex,
|
||||
const std::string& nRelPath, ZFile* nParent);
|
||||
void ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData,
|
||||
const uint32_t nRawDataIndex, const std::string& nRelPath) override;
|
||||
|
||||
protected:
|
||||
int arrayCnt;
|
||||
size_t arrayCnt;
|
||||
ZFile* testFile;
|
||||
|
||||
// void ParseRawData(const std::vector<uint8_t>& data, const int offset);
|
||||
// void ParseRawData(const std::vector<uint8_t>& data, const int32_t offset);
|
||||
};
|
209
tools/ZAPD/ZAPD/ZBackground.cpp
Normal file
209
tools/ZAPD/ZAPD/ZBackground.cpp
Normal file
|
@ -0,0 +1,209 @@
|
|||
#include "ZBackground.h"
|
||||
#include "BitConverter.h"
|
||||
#include "File.h"
|
||||
#include "Globals.h"
|
||||
#include "Path.h"
|
||||
#include "StringHelper.h"
|
||||
#include "ZFile.h"
|
||||
|
||||
REGISTER_ZFILENODE(Background, ZBackground);
|
||||
|
||||
#define JPEG_MARKER 0xFFD8FFE0
|
||||
#define MARKER_DQT 0xFFDB
|
||||
|
||||
ZBackground::ZBackground(ZFile* nParent) : ZResource(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
ZBackground::ZBackground(const std::string& prefix, const std::vector<uint8_t>& nRawData,
|
||||
uint32_t nRawDataIndex, ZFile* nParent)
|
||||
: ZResource(nParent)
|
||||
{
|
||||
rawData.assign(nRawData.begin(), nRawData.end());
|
||||
rawDataIndex = nRawDataIndex;
|
||||
name = GetDefaultName(prefix.c_str(), rawDataIndex);
|
||||
outName = name;
|
||||
|
||||
ParseRawData();
|
||||
}
|
||||
|
||||
void ZBackground::ParseRawData()
|
||||
{
|
||||
ZResource::ParseRawData();
|
||||
|
||||
size_t i = 0;
|
||||
while (true)
|
||||
{
|
||||
uint8_t val = rawData.at(rawDataIndex + i);
|
||||
data.push_back(val);
|
||||
|
||||
if (BitConverter::ToUInt16BE(rawData, rawDataIndex + i) == 0xFFD9)
|
||||
{
|
||||
data.push_back(rawData.at(rawDataIndex + i + 1));
|
||||
break;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void ZBackground::ParseBinaryFile(const std::string& inFolder, bool appendOutName)
|
||||
{
|
||||
fs::path filepath(inFolder);
|
||||
if (appendOutName)
|
||||
{
|
||||
filepath = filepath / (outName + "." + GetExternalExtension());
|
||||
}
|
||||
data = File::ReadAllBytes(filepath.string());
|
||||
|
||||
// Add padding.
|
||||
data.insert(data.end(), GetRawDataSize() - data.size(), 0x00);
|
||||
CheckValidJpeg(filepath.generic_string());
|
||||
}
|
||||
|
||||
void ZBackground::ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData,
|
||||
uint32_t nRawDataIndex, const std::string& nRelPath)
|
||||
{
|
||||
ZResource::ExtractFromXML(reader, nRawData, nRawDataIndex, nRelPath);
|
||||
DeclareVar("", "");
|
||||
}
|
||||
|
||||
void ZBackground::CheckValidJpeg(const std::string& filepath)
|
||||
{
|
||||
std::string filename = outName;
|
||||
if (filepath != "")
|
||||
{
|
||||
filename = filepath;
|
||||
}
|
||||
|
||||
uint32_t jpegMarker = BitConverter::ToUInt32BE(data, 0);
|
||||
if (jpegMarker != JPEG_MARKER)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"ZBackground::CheckValidJpeg: Warning.\n"
|
||||
"\t Missing jpeg marker at the beginning of file: '%s'.\n"
|
||||
"\t The game will skip this jpeg.\n",
|
||||
filename.c_str());
|
||||
}
|
||||
if (data.at(6) != 'J' || data.at(7) != 'F' || data.at(8) != 'I' || data.at(9) != 'F' ||
|
||||
data.at(10) != '\0')
|
||||
{
|
||||
std::string jfifIdentifier(data.begin() + 6, data.begin() + 6 + 5);
|
||||
fprintf(stderr,
|
||||
"ZBackground::CheckValidJpeg: Warning.\n"
|
||||
"\t Missing 'JFIF' identifier. File: '%s'.\n"
|
||||
"\t This image may be corrupted or not be a jpeg iamge.\n"
|
||||
"\t The identifier found was '%s'.\n",
|
||||
filename.c_str(), jfifIdentifier.c_str());
|
||||
}
|
||||
uint8_t majorVersion = data.at(11);
|
||||
uint8_t minorVersion = data.at(12);
|
||||
if (majorVersion != 0x01 || minorVersion != 0x01)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"ZBackground::CheckValidJpeg: Warning.\n"
|
||||
"\t Wrong JFIF version '%i.%02i'. File: '%s'.\n"
|
||||
"\t The expected version is '1.01'. The game may not be able to decode this image "
|
||||
"properly.\n",
|
||||
majorVersion, minorVersion, filename.c_str());
|
||||
}
|
||||
if (BitConverter::ToUInt16BE(data, 20) != MARKER_DQT)
|
||||
{
|
||||
// This may happen when creating a custom image with Exif, XMP, thumbnail, progressive, etc.
|
||||
// enabled.
|
||||
fprintf(stderr,
|
||||
"ZBackground::CheckValidJpeg: Warning.\n"
|
||||
"\t There seems to be extra data before the image data in file: '%s'.\n"
|
||||
"\t The game may not be able to decode this image properly.\n",
|
||||
filename.c_str());
|
||||
}
|
||||
if (data.size() > GetRawDataSize())
|
||||
{
|
||||
fprintf(stderr,
|
||||
"ZBackground::CheckValidJpeg: Warning.\n"
|
||||
"\t The image is bigger than the screen buffer. File: '%s'.\n"
|
||||
"\t Image size: %zu bytes.\n"
|
||||
"\t Screen buffer size: %zu bytes.\n",
|
||||
filename.c_str(), data.size(), GetRawDataSize());
|
||||
}
|
||||
}
|
||||
|
||||
size_t ZBackground::GetRawDataSize()
|
||||
{
|
||||
// Jpgs use the whole sceen buffer, which is a u16 matrix.
|
||||
return Globals::Instance->cfg.bgScreenHeight * Globals::Instance->cfg.bgScreenWidth * 2;
|
||||
}
|
||||
|
||||
void ZBackground::DeclareVar(const std::string& prefix, const std::string& bodyStr)
|
||||
{
|
||||
std::string auxName = name;
|
||||
|
||||
if (name == "")
|
||||
auxName = GetDefaultName(prefix, rawDataIndex);
|
||||
|
||||
parent->AddDeclarationArray(rawDataIndex, DeclarationAlignment::Align8, GetRawDataSize(),
|
||||
GetSourceTypeName(), auxName, 0, bodyStr);
|
||||
}
|
||||
|
||||
bool ZBackground::IsExternalResource()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string ZBackground::GetExternalExtension()
|
||||
{
|
||||
return "jpg";
|
||||
}
|
||||
|
||||
void ZBackground::Save(const std::string& outFolder)
|
||||
{
|
||||
fs::path folder(outFolder);
|
||||
fs::path filepath = folder / (outName + "." + GetExternalExtension());
|
||||
File::WriteAllBytes(filepath.string(), data);
|
||||
}
|
||||
|
||||
std::string ZBackground::GetBodySourceCode()
|
||||
{
|
||||
std::string bodyStr = " ";
|
||||
|
||||
for (size_t i = 0; i < data.size() / 8; ++i)
|
||||
{
|
||||
bodyStr += StringHelper::Sprintf("0x%016llX, ", BitConverter::ToUInt64BE(data, i * 8));
|
||||
|
||||
if (i % 8 == 7)
|
||||
bodyStr += "\n ";
|
||||
}
|
||||
|
||||
bodyStr += "\n";
|
||||
|
||||
return bodyStr;
|
||||
}
|
||||
|
||||
std::string ZBackground::GetSourceOutputCode(const std::string& prefix)
|
||||
{
|
||||
std::string bodyStr = GetBodySourceCode();
|
||||
|
||||
Declaration* decl = parent->GetDeclaration(rawDataIndex);
|
||||
|
||||
if (decl == nullptr)
|
||||
DeclareVar(prefix, bodyStr);
|
||||
else
|
||||
decl->text = bodyStr;
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string ZBackground::GetDefaultName(const std::string& prefix, uint32_t address)
|
||||
{
|
||||
return StringHelper::Sprintf("%sBackground_%06X", prefix.c_str(), address);
|
||||
}
|
||||
|
||||
std::string ZBackground::GetSourceTypeName()
|
||||
{
|
||||
return "u64";
|
||||
}
|
||||
|
||||
ZResourceType ZBackground::GetResourceType()
|
||||
{
|
||||
return ZResourceType::Background;
|
||||
}
|
37
tools/ZAPD/ZAPD/ZBackground.h
Normal file
37
tools/ZAPD/ZAPD/ZBackground.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
#include "ZResource.h"
|
||||
|
||||
class ZBackground : public ZResource
|
||||
{
|
||||
protected:
|
||||
std::vector<uint8_t> data;
|
||||
|
||||
public:
|
||||
ZBackground(ZFile* nParent);
|
||||
ZBackground(const std::string& prefix, const std::vector<uint8_t>& nRawData,
|
||||
uint32_t nRawDataIndex, ZFile* nParent);
|
||||
void ParseRawData() override;
|
||||
void ParseBinaryFile(const std::string& inFolder, bool appendOutName);
|
||||
void ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData,
|
||||
uint32_t nRawDataIndex, const std::string& nRelPath) override;
|
||||
|
||||
void CheckValidJpeg(const std::string& filepath);
|
||||
|
||||
size_t GetRawDataSize() override;
|
||||
|
||||
void DeclareVar(const std::string& prefix, const std::string& bodyStr);
|
||||
|
||||
bool IsExternalResource() override;
|
||||
std::string GetExternalExtension() override;
|
||||
void Save(const std::string& outFolder) override;
|
||||
|
||||
std::string GetBodySourceCode();
|
||||
std::string GetSourceOutputCode(const std::string& prefix) override;
|
||||
static std::string GetDefaultName(const std::string& prefix, uint32_t address);
|
||||
|
||||
std::string GetSourceTypeName() override;
|
||||
ZResourceType GetResourceType() override;
|
||||
};
|
|
@ -8,12 +8,15 @@
|
|||
using namespace tinyxml2;
|
||||
using namespace std;
|
||||
|
||||
ZBlob::ZBlob() : ZResource()
|
||||
REGISTER_ZFILENODE(Blob, ZBlob);
|
||||
|
||||
ZBlob::ZBlob(ZFile* nParent) : ZResource(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
ZBlob::ZBlob(const std::vector<uint8_t>& nRawData, int nRawDataIndex, int size, std::string nName)
|
||||
: ZBlob()
|
||||
ZBlob::ZBlob(const std::vector<uint8_t>& nRawData, uint32_t nRawDataIndex, size_t size,
|
||||
std::string nName, ZFile* nParent)
|
||||
: ZBlob(nParent)
|
||||
{
|
||||
rawDataIndex = nRawDataIndex;
|
||||
rawData =
|
||||
|
@ -21,25 +24,22 @@ ZBlob::ZBlob(const std::vector<uint8_t>& nRawData, int nRawDataIndex, int size,
|
|||
name = std::move(nName);
|
||||
}
|
||||
|
||||
ZBlob* ZBlob::ExtractFromXML(XMLElement* reader, const vector<uint8_t>& nRawData, int nRawDataIndex,
|
||||
string nRelPath)
|
||||
void ZBlob::ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData,
|
||||
const uint32_t nRawDataIndex, const std::string& nRelPath)
|
||||
{
|
||||
ZBlob* blob = new ZBlob();
|
||||
rawDataIndex = nRawDataIndex;
|
||||
|
||||
blob->rawDataIndex = nRawDataIndex;
|
||||
|
||||
blob->ParseXML(reader);
|
||||
int size = strtol(reader->Attribute("Size"), NULL, 16);
|
||||
blob->rawData = vector<uint8_t>(nRawData.data() + blob->rawDataIndex,
|
||||
nRawData.data() + blob->rawDataIndex + size);
|
||||
blob->relativePath = std::move(nRelPath);
|
||||
|
||||
return blob;
|
||||
ParseXML(reader);
|
||||
long size = strtol(reader->Attribute("Size"), NULL, 16);
|
||||
rawData =
|
||||
vector<uint8_t>(nRawData.data() + rawDataIndex, nRawData.data() + rawDataIndex + size);
|
||||
relativePath = std::move(nRelPath);
|
||||
}
|
||||
|
||||
// Build Source File Mode
|
||||
ZBlob* ZBlob::BuildFromXML(XMLElement* reader, const std::string& inFolder, bool readFile)
|
||||
{
|
||||
ZBlob* blob = new ZBlob();
|
||||
ZBlob* blob = new ZBlob(nullptr);
|
||||
|
||||
blob->ParseXML(reader);
|
||||
|
||||
|
@ -51,7 +51,7 @@ ZBlob* ZBlob::BuildFromXML(XMLElement* reader, const std::string& inFolder, bool
|
|||
|
||||
ZBlob* ZBlob::FromFile(const std::string& filePath)
|
||||
{
|
||||
ZBlob* blob = new ZBlob();
|
||||
ZBlob* blob = new ZBlob(nullptr);
|
||||
blob->name = StringHelper::Split(Path::GetFileNameWithoutExtension(filePath), ".")[0];
|
||||
blob->rawData = File::ReadAllBytes(filePath);
|
||||
|
||||
|
@ -61,12 +61,11 @@ ZBlob* ZBlob::FromFile(const std::string& filePath)
|
|||
string ZBlob::GetSourceOutputCode(const std::string& prefix)
|
||||
{
|
||||
sourceOutput = "";
|
||||
// sourceOutput += StringHelper::Sprintf("u8 %s_%s[] = \n{\n", prefix.c_str(), name.c_str());
|
||||
|
||||
for (uint32_t i = 0; i < rawData.size(); i += 1)
|
||||
for (size_t i = 0; i < rawData.size(); i += 1)
|
||||
{
|
||||
if (i % 16 == 0)
|
||||
sourceOutput += "\t";
|
||||
sourceOutput += " ";
|
||||
|
||||
sourceOutput += StringHelper::Sprintf("0x%02X, ", rawData[i]);
|
||||
|
||||
|
@ -75,10 +74,10 @@ string ZBlob::GetSourceOutputCode(const std::string& prefix)
|
|||
}
|
||||
|
||||
// Ensure there's always a trailing line feed to prevent dumb warnings.
|
||||
// Please don't remove this line, unless you somehow made a way to prevent
|
||||
// that warning when building the OoT repo.
|
||||
sourceOutput += "\n";
|
||||
|
||||
// sourceOutput += "};\n";
|
||||
|
||||
return sourceOutput;
|
||||
}
|
||||
|
||||
|
@ -89,7 +88,6 @@ string ZBlob::GetSourceOutputHeader(const std::string& prefix)
|
|||
|
||||
void ZBlob::Save(const std::string& outFolder)
|
||||
{
|
||||
// printf("NAME = %s\n", name.c_str());
|
||||
File::WriteAllBytes(outFolder + "/" + name + ".bin", rawData);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,10 +6,14 @@
|
|||
class ZBlob : public ZResource
|
||||
{
|
||||
public:
|
||||
ZBlob(const std::vector<uint8_t>& nRawData, int rawDataIndex, int size, std::string nName);
|
||||
ZBlob(ZFile* nParent);
|
||||
ZBlob(const std::vector<uint8_t>& nRawData, uint32_t rawDataIndex, size_t size,
|
||||
std::string nName, ZFile* nParent);
|
||||
|
||||
void ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData,
|
||||
const uint32_t nRawDataIndex,
|
||||
const std::string& nRelPath) override; // Extract Mode
|
||||
|
||||
static ZBlob* ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData,
|
||||
int rawDataIndex, std::string nRelPath);
|
||||
static ZBlob* BuildFromXML(tinyxml2::XMLElement* reader, const std::string& inFolder,
|
||||
bool readFile);
|
||||
static ZBlob* FromFile(const std::string& filePath);
|
||||
|
@ -20,7 +24,4 @@ public:
|
|||
std::string GetExternalExtension() override;
|
||||
std::string GetSourceTypeName() override;
|
||||
ZResourceType GetResourceType() override;
|
||||
|
||||
private:
|
||||
ZBlob();
|
||||
};
|
||||
|
|
|
@ -7,12 +7,33 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
ZCollisionHeader::ZCollisionHeader()
|
||||
REGISTER_ZFILENODE(Collision, ZCollisionHeader);
|
||||
|
||||
ZCollisionHeader::ZCollisionHeader(ZFile* nParent) : ZResource(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
ZCollisionHeader::ZCollisionHeader(ZFile* parent, const std::string& prefix,
|
||||
const std::vector<uint8_t>& rawData, int rawDataIndex)
|
||||
ZCollisionHeader::~ZCollisionHeader()
|
||||
{
|
||||
for (WaterBoxHeader* waterBox : waterBoxes)
|
||||
delete waterBox;
|
||||
|
||||
delete camData;
|
||||
}
|
||||
|
||||
ZResourceType ZCollisionHeader::GetResourceType()
|
||||
{
|
||||
return ZResourceType::CollisionHeader;
|
||||
}
|
||||
|
||||
void ZCollisionHeader::ExtractFromXML(tinyxml2::XMLElement* reader,
|
||||
const std::vector<uint8_t>& nRawData,
|
||||
const uint32_t nRawDataIndex, const std::string& nRelPath)
|
||||
{
|
||||
ZResource::ExtractFromXML(reader, nRawData, nRawDataIndex, nRelPath);
|
||||
}
|
||||
|
||||
void ZCollisionHeader::ParseRawData()
|
||||
{
|
||||
const uint8_t* data = rawData.data();
|
||||
|
||||
|
@ -24,80 +45,71 @@ ZCollisionHeader::ZCollisionHeader(ZFile* parent, const std::string& prefix,
|
|||
absMaxY = BitConverter::ToInt16BE(data, rawDataIndex + 8);
|
||||
absMaxZ = BitConverter::ToInt16BE(data, rawDataIndex + 10);
|
||||
|
||||
numVerts = BitConverter::ToInt16BE(data, rawDataIndex + 12);
|
||||
numVerts = BitConverter::ToUInt16BE(data, rawDataIndex + 12);
|
||||
vtxAddress = BitConverter::ToInt32BE(data, rawDataIndex + 16);
|
||||
|
||||
numPolygons = BitConverter::ToInt16BE(data, rawDataIndex + 20);
|
||||
numPolygons = BitConverter::ToUInt16BE(data, rawDataIndex + 20);
|
||||
polyAddress = BitConverter::ToInt32BE(data, rawDataIndex + 24);
|
||||
polyTypeDefAddress = BitConverter::ToInt32BE(data, rawDataIndex + 28);
|
||||
camDataAddress = BitConverter::ToInt32BE(data, rawDataIndex + 32);
|
||||
|
||||
numWaterBoxes = BitConverter::ToInt16BE(data, rawDataIndex + 36);
|
||||
numWaterBoxes = BitConverter::ToUInt16BE(data, rawDataIndex + 36);
|
||||
waterBoxAddress = BitConverter::ToInt32BE(data, rawDataIndex + 40);
|
||||
|
||||
uint32_t vtxSegmentOffset = Seg2Filespace(vtxAddress, parent->baseAddress);
|
||||
uint32_t polySegmentOffset = Seg2Filespace(polyAddress, parent->baseAddress);
|
||||
uint32_t polyTypeDefSegmentOffset = Seg2Filespace(polyTypeDefAddress, parent->baseAddress);
|
||||
uint32_t camDataSegmentOffset = Seg2Filespace(camDataAddress, parent->baseAddress);
|
||||
uint32_t waterBoxSegmentOffset = Seg2Filespace(waterBoxAddress, parent->baseAddress);
|
||||
vtxSegmentOffset = Seg2Filespace(vtxAddress, parent->baseAddress);
|
||||
polySegmentOffset = Seg2Filespace(polyAddress, parent->baseAddress);
|
||||
polyTypeDefSegmentOffset = Seg2Filespace(polyTypeDefAddress, parent->baseAddress);
|
||||
camDataSegmentOffset = Seg2Filespace(camDataAddress, parent->baseAddress);
|
||||
waterBoxSegmentOffset = Seg2Filespace(waterBoxAddress, parent->baseAddress);
|
||||
|
||||
vertices.reserve(numVerts);
|
||||
polygons.reserve(numPolygons);
|
||||
|
||||
// HOTSPOT
|
||||
for (uint16_t i = 0; i < numVerts; i++)
|
||||
vertices.push_back(new VertexEntry(rawData, vtxSegmentOffset + (i * 6)));
|
||||
vertices.push_back(VertexEntry(rawData, vtxSegmentOffset + (i * 6)));
|
||||
|
||||
// HOTSPOT
|
||||
for (uint16_t i = 0; i < numPolygons; i++)
|
||||
polygons.push_back(new PolygonEntry(rawData, polySegmentOffset + (i * 16)));
|
||||
polygons.push_back(PolygonEntry(rawData, polySegmentOffset + (i * 16)));
|
||||
|
||||
uint16_t highestPolyType = 0;
|
||||
|
||||
for (PolygonEntry* poly : polygons)
|
||||
for (PolygonEntry poly : polygons)
|
||||
{
|
||||
if (poly->type > highestPolyType)
|
||||
highestPolyType = poly->type;
|
||||
if (poly.type > highestPolyType)
|
||||
highestPolyType = poly.type;
|
||||
}
|
||||
|
||||
// if (highestPolyType > 0)
|
||||
{
|
||||
for (uint16_t i = 0; i < highestPolyType + 1; i++)
|
||||
polygonTypes.push_back(
|
||||
BitConverter::ToUInt64BE(data, polyTypeDefSegmentOffset + (i * 8)));
|
||||
}
|
||||
// else
|
||||
//{
|
||||
// int polyTypesSize = abs(polyTypeDefSegmentOffset - camDataSegmentOffset) / 8;
|
||||
|
||||
// for (int i = 0; i < polyTypesSize; i++)
|
||||
// polygonTypes.push_back(BitConverter::ToUInt64BE(data, polyTypeDefSegmentOffset + (i * 8)));
|
||||
//}
|
||||
polygonTypes.push_back(BitConverter::ToUInt64BE(data, polyTypeDefSegmentOffset + (i * 8)));
|
||||
|
||||
if (camDataAddress != 0)
|
||||
camData = new CameraDataList(parent, prefix, rawData, camDataSegmentOffset,
|
||||
camData = new CameraDataList(parent, name, rawData, camDataSegmentOffset,
|
||||
polyTypeDefSegmentOffset, polygonTypes.size());
|
||||
|
||||
for (int i = 0; i < numWaterBoxes; i++)
|
||||
for (uint16_t i = 0; i < numWaterBoxes; i++)
|
||||
waterBoxes.push_back(new WaterBoxHeader(
|
||||
rawData,
|
||||
waterBoxSegmentOffset + (i * (Globals::Instance->game == ZGame::OOT_SW97 ? 12 : 16))));
|
||||
|
||||
string declaration = "";
|
||||
char line[2048];
|
||||
|
||||
if (waterBoxes.size() > 0)
|
||||
{
|
||||
for (size_t i = 0; i < waterBoxes.size(); i++)
|
||||
{
|
||||
sprintf(line, " { %i, %i, %i, %i, %i, 0x%08X },\n", waterBoxes[i]->xMin,
|
||||
waterBoxes[i]->ySurface, waterBoxes[i]->zMin, waterBoxes[i]->xLength,
|
||||
declaration += StringHelper::Sprintf("\t{ %i, %i, %i, %i, %i, 0x%08X },",
|
||||
waterBoxes[i]->xMin, waterBoxes[i]->ySurface,
|
||||
waterBoxes[i]->zMin, waterBoxes[i]->xLength,
|
||||
waterBoxes[i]->zLength, waterBoxes[i]->properties);
|
||||
declaration += line;
|
||||
if (i + 1 < waterBoxes.size())
|
||||
declaration += "\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (waterBoxAddress != 0)
|
||||
parent->AddDeclarationArray(
|
||||
waterBoxSegmentOffset, DeclarationAlignment::None, 16 * waterBoxes.size(), "WaterBox",
|
||||
StringHelper::Sprintf("%s_waterBoxes_%08X", prefix.c_str(), waterBoxSegmentOffset), 0,
|
||||
StringHelper::Sprintf("%s_waterBoxes_%06X", name.c_str(), waterBoxSegmentOffset), 0,
|
||||
declaration);
|
||||
|
||||
if (polygons.size() > 0)
|
||||
|
@ -106,12 +118,12 @@ ZCollisionHeader::ZCollisionHeader(ZFile* parent, const std::string& prefix,
|
|||
|
||||
for (size_t i = 0; i < polygons.size(); i++)
|
||||
{
|
||||
sprintf(
|
||||
line, " { 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X },\n",
|
||||
(uint16_t)polygons[i]->type, (uint16_t)polygons[i]->vtxA,
|
||||
(uint16_t)polygons[i]->vtxB, (uint16_t)polygons[i]->vtxC, (uint16_t)polygons[i]->a,
|
||||
(uint16_t)polygons[i]->b, (uint16_t)polygons[i]->c, (uint16_t)polygons[i]->d);
|
||||
declaration += line;
|
||||
declaration += StringHelper::Sprintf(
|
||||
"\t{ 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X },",
|
||||
polygons[i].type, polygons[i].vtxA, polygons[i].vtxB, polygons[i].vtxC,
|
||||
polygons[i].a, polygons[i].b, polygons[i].c, polygons[i].d);
|
||||
if (i + 1 < polygons.size())
|
||||
declaration += "\n";
|
||||
}
|
||||
|
||||
if (polyAddress != 0)
|
||||
|
@ -119,7 +131,7 @@ ZCollisionHeader::ZCollisionHeader(ZFile* parent, const std::string& prefix,
|
|||
parent->AddDeclarationArray(
|
||||
polySegmentOffset, DeclarationAlignment::None, polygons.size() * 16,
|
||||
"CollisionPoly",
|
||||
StringHelper::Sprintf("%s_polygons_%08X", prefix.c_str(), polySegmentOffset), 0,
|
||||
StringHelper::Sprintf("%s_polygons_%08X", name.c_str(), polySegmentOffset), 0,
|
||||
declaration);
|
||||
}
|
||||
}
|
||||
|
@ -127,7 +139,7 @@ ZCollisionHeader::ZCollisionHeader(ZFile* parent, const std::string& prefix,
|
|||
declaration = "";
|
||||
for (size_t i = 0; i < polygonTypes.size(); i++)
|
||||
{
|
||||
declaration += StringHelper::Sprintf(" { 0x%08lX, 0x%08lX },", polygonTypes[i] >> 32,
|
||||
declaration += StringHelper::Sprintf("\t{ 0x%08lX, 0x%08lX },", polygonTypes[i] >> 32,
|
||||
polygonTypes[i] & 0xFFFFFFFF);
|
||||
|
||||
if (i < polygonTypes.size() - 1)
|
||||
|
@ -138,8 +150,8 @@ ZCollisionHeader::ZCollisionHeader(ZFile* parent, const std::string& prefix,
|
|||
parent->AddDeclarationArray(
|
||||
polyTypeDefSegmentOffset, DeclarationAlignment::None, polygonTypes.size() * 8,
|
||||
"SurfaceType",
|
||||
StringHelper::Sprintf("%s_surfaceType_%08X", prefix.c_str(), polyTypeDefSegmentOffset),
|
||||
0, declaration);
|
||||
StringHelper::Sprintf("%s_surfaceType_%08X", name.c_str(), polyTypeDefSegmentOffset), 0,
|
||||
declaration);
|
||||
|
||||
declaration = "";
|
||||
|
||||
|
@ -149,8 +161,8 @@ ZCollisionHeader::ZCollisionHeader(ZFile* parent, const std::string& prefix,
|
|||
|
||||
for (size_t i = 0; i < vertices.size(); i++)
|
||||
{
|
||||
declaration += StringHelper::Sprintf(" { %i, %i, %i },", vertices[i]->x,
|
||||
vertices[i]->y, vertices[i]->z);
|
||||
declaration += StringHelper::Sprintf("\t{ %6i, %6i, %6i },", vertices[i].x,
|
||||
vertices[i].y, vertices[i].z);
|
||||
|
||||
if (i < vertices.size() - 1)
|
||||
declaration += "\n";
|
||||
|
@ -159,7 +171,7 @@ ZCollisionHeader::ZCollisionHeader(ZFile* parent, const std::string& prefix,
|
|||
if (vtxAddress != 0)
|
||||
parent->AddDeclarationArray(
|
||||
vtxSegmentOffset, DeclarationAlignment::None, vertices.size() * 6, "Vec3s",
|
||||
StringHelper::Sprintf("%s_vtx_%08X", prefix.c_str(), vtxSegmentOffset), 0,
|
||||
StringHelper::Sprintf("%s_vtx_%08X", name.c_str(), vtxSegmentOffset), 0,
|
||||
declaration);
|
||||
|
||||
declaration = "";
|
||||
|
@ -169,7 +181,7 @@ ZCollisionHeader::ZCollisionHeader(ZFile* parent, const std::string& prefix,
|
|||
char waterBoxStr[2048];
|
||||
|
||||
if (waterBoxAddress != 0)
|
||||
sprintf(waterBoxStr, "%s_waterBoxes_%08X", prefix.c_str(), waterBoxSegmentOffset);
|
||||
sprintf(waterBoxStr, "%s_waterBoxes_%06X", name.c_str(), waterBoxSegmentOffset);
|
||||
else
|
||||
sprintf(waterBoxStr, "NULL");
|
||||
|
||||
|
@ -181,55 +193,30 @@ ZCollisionHeader::ZCollisionHeader(ZFile* parent, const std::string& prefix,
|
|||
declaration += StringHelper::Sprintf(
|
||||
" %i,\n %s_vtx_%08X,\n %i,\n %s_polygons_%08X,\n %s_surfaceType_%08X,\n "
|
||||
"%s_camDataList_%08X,\n %i,\n %s\n",
|
||||
numVerts, prefix.c_str(), vtxSegmentOffset, numPolygons, prefix.c_str(), polySegmentOffset,
|
||||
prefix.c_str(), polyTypeDefSegmentOffset, prefix.c_str(), camDataSegmentOffset,
|
||||
numWaterBoxes, waterBoxStr);
|
||||
numVerts, name.c_str(), vtxSegmentOffset, numPolygons, name.c_str(), polySegmentOffset,
|
||||
name.c_str(), polyTypeDefSegmentOffset, name.c_str(), camDataSegmentOffset, numWaterBoxes,
|
||||
waterBoxStr);
|
||||
|
||||
parent->AddDeclaration(rawDataIndex, DeclarationAlignment::None, DeclarationPadding::Pad16, 44,
|
||||
"CollisionHeader",
|
||||
StringHelper::Sprintf("%s", prefix.c_str(), rawDataIndex), declaration);
|
||||
StringHelper::Sprintf("%s", name.c_str(), rawDataIndex), declaration);
|
||||
}
|
||||
|
||||
ZCollisionHeader::~ZCollisionHeader()
|
||||
{
|
||||
for (VertexEntry* vtx : vertices)
|
||||
delete vtx;
|
||||
|
||||
for (PolygonEntry* poly : polygons)
|
||||
delete poly;
|
||||
|
||||
for (WaterBoxHeader* waterBox : waterBoxes)
|
||||
delete waterBox;
|
||||
}
|
||||
|
||||
ZResourceType ZCollisionHeader::GetResourceType()
|
||||
{
|
||||
return ZResourceType::CollisionHeader;
|
||||
}
|
||||
|
||||
ZCollisionHeader* ZCollisionHeader::ExtractFromXML(tinyxml2::XMLElement* reader,
|
||||
vector<uint8_t> nRawData, int rawDataIndex)
|
||||
{
|
||||
ZCollisionHeader* col = new ZCollisionHeader();
|
||||
|
||||
return col;
|
||||
}
|
||||
|
||||
PolygonEntry::PolygonEntry(const std::vector<uint8_t>& rawData, int rawDataIndex)
|
||||
PolygonEntry::PolygonEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex)
|
||||
{
|
||||
const uint8_t* data = rawData.data();
|
||||
|
||||
type = BitConverter::ToInt16BE(data, rawDataIndex + 0);
|
||||
vtxA = BitConverter::ToInt16BE(data, rawDataIndex + 2);
|
||||
vtxB = BitConverter::ToInt16BE(data, rawDataIndex + 4);
|
||||
vtxC = BitConverter::ToInt16BE(data, rawDataIndex + 6);
|
||||
a = BitConverter::ToInt16BE(data, rawDataIndex + 8);
|
||||
b = BitConverter::ToInt16BE(data, rawDataIndex + 10);
|
||||
c = BitConverter::ToInt16BE(data, rawDataIndex + 12);
|
||||
d = BitConverter::ToInt16BE(data, rawDataIndex + 14);
|
||||
type = BitConverter::ToUInt16BE(data, rawDataIndex + 0);
|
||||
vtxA = BitConverter::ToUInt16BE(data, rawDataIndex + 2);
|
||||
vtxB = BitConverter::ToUInt16BE(data, rawDataIndex + 4);
|
||||
vtxC = BitConverter::ToUInt16BE(data, rawDataIndex + 6);
|
||||
a = BitConverter::ToUInt16BE(data, rawDataIndex + 8);
|
||||
b = BitConverter::ToUInt16BE(data, rawDataIndex + 10);
|
||||
c = BitConverter::ToUInt16BE(data, rawDataIndex + 12);
|
||||
d = BitConverter::ToUInt16BE(data, rawDataIndex + 14);
|
||||
}
|
||||
|
||||
VertexEntry::VertexEntry(const std::vector<uint8_t>& rawData, int rawDataIndex)
|
||||
VertexEntry::VertexEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex)
|
||||
{
|
||||
const uint8_t* data = rawData.data();
|
||||
|
||||
|
@ -238,7 +225,7 @@ VertexEntry::VertexEntry(const std::vector<uint8_t>& rawData, int rawDataIndex)
|
|||
z = BitConverter::ToInt16BE(data, rawDataIndex + 4);
|
||||
}
|
||||
|
||||
WaterBoxHeader::WaterBoxHeader(const std::vector<uint8_t>& rawData, int rawDataIndex)
|
||||
WaterBoxHeader::WaterBoxHeader(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex)
|
||||
{
|
||||
const uint8_t* data = rawData.data();
|
||||
|
||||
|
@ -247,27 +234,23 @@ WaterBoxHeader::WaterBoxHeader(const std::vector<uint8_t>& rawData, int rawDataI
|
|||
zMin = BitConverter::ToInt16BE(data, rawDataIndex + 4);
|
||||
xLength = BitConverter::ToInt16BE(data, rawDataIndex + 6);
|
||||
zLength = BitConverter::ToInt16BE(data, rawDataIndex + 8);
|
||||
|
||||
if (Globals::Instance->game == ZGame::OOT_SW97)
|
||||
{
|
||||
properties = BitConverter::ToInt16BE(data, rawDataIndex + 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
properties = BitConverter::ToInt32BE(data, rawDataIndex + 12);
|
||||
}
|
||||
}
|
||||
|
||||
CameraDataList::CameraDataList(ZFile* parent, const std::string& prefix,
|
||||
const std::vector<uint8_t>& rawData, int rawDataIndex,
|
||||
int polyTypeDefSegmentOffset, int polygonTypesCnt)
|
||||
const std::vector<uint8_t>& rawData, uint32_t rawDataIndex,
|
||||
uint32_t polyTypeDefSegmentOffset, uint32_t polygonTypesCnt)
|
||||
{
|
||||
string declaration = "";
|
||||
|
||||
// Parse CameraDataEntries
|
||||
int numElements = abs(polyTypeDefSegmentOffset - (rawDataIndex)) / 8;
|
||||
// int numElements = polygonTypesCnt;
|
||||
int32_t numElements = (polyTypeDefSegmentOffset - rawDataIndex) / 8;
|
||||
uint32_t cameraPosDataSeg = rawDataIndex;
|
||||
for (int i = 0; i < numElements; i++)
|
||||
for (int32_t i = 0; i < numElements; i++)
|
||||
{
|
||||
CameraDataEntry* entry = new CameraDataEntry();
|
||||
|
||||
|
@ -289,7 +272,7 @@ CameraDataList::CameraDataList(ZFile* parent, const std::string& prefix,
|
|||
entries.push_back(entry);
|
||||
}
|
||||
|
||||
// setting cameraPosDataAddr to rawDataIndex give a pos list length of 0
|
||||
// Setting cameraPosDataAddr to rawDataIndex give a pos list length of 0
|
||||
uint32_t cameraPosDataOffset = cameraPosDataSeg & 0xFFFFFF;
|
||||
for (size_t i = 0; i < entries.size(); i++)
|
||||
{
|
||||
|
@ -297,7 +280,8 @@ CameraDataList::CameraDataList(ZFile* parent, const std::string& prefix,
|
|||
|
||||
if (entries[i]->cameraPosDataSeg != 0)
|
||||
{
|
||||
int index = ((entries[i]->cameraPosDataSeg & 0x00FFFFFF) - cameraPosDataOffset) / 0x6;
|
||||
int32_t index =
|
||||
((entries[i]->cameraPosDataSeg & 0x00FFFFFF) - cameraPosDataOffset) / 0x6;
|
||||
sprintf(camSegLine, "&%s_camPosData_%08X[%i]", prefix.c_str(), cameraPosDataOffset,
|
||||
index);
|
||||
}
|
||||
|
@ -317,23 +301,24 @@ CameraDataList::CameraDataList(ZFile* parent, const std::string& prefix,
|
|||
StringHelper::Sprintf("%s_camDataList_%08X", prefix.c_str(), rawDataIndex), entries.size(),
|
||||
declaration);
|
||||
|
||||
int numDataTotal = abs(rawDataIndex - (int)cameraPosDataOffset) / 0x6;
|
||||
uint32_t numDataTotal = (rawDataIndex - cameraPosDataOffset) / 0x6;
|
||||
|
||||
if (numDataTotal > 0)
|
||||
{
|
||||
declaration = "";
|
||||
for (int i = 0; i < numDataTotal; i++)
|
||||
for (uint32_t i = 0; i < numDataTotal; i++)
|
||||
{
|
||||
CameraPositionData* data =
|
||||
new CameraPositionData(rawData, cameraPosDataOffset + (i * 6));
|
||||
cameraPositionData.push_back(data);
|
||||
|
||||
declaration +=
|
||||
StringHelper::Sprintf(" { %6i, %6i, %6i },\n", data->x, data->y, data->z);
|
||||
declaration += StringHelper::Sprintf("\t{ %6i, %6i, %6i },", data->x, data->y, data->z);
|
||||
if (i + 1 < numDataTotal)
|
||||
declaration += "\n";
|
||||
}
|
||||
|
||||
int cameraPosDataIndex = cameraPosDataSeg & 0x00FFFFFF;
|
||||
int entrySize = numDataTotal * 0x6;
|
||||
int32_t cameraPosDataIndex = GETSEGOFFSET(cameraPosDataSeg);
|
||||
uint32_t entrySize = numDataTotal * 0x6;
|
||||
parent->AddDeclarationArray(
|
||||
cameraPosDataIndex, DeclarationAlignment::None, entrySize, "Vec3s",
|
||||
StringHelper::Sprintf("%s_camPosData_%08X", prefix.c_str(), cameraPosDataIndex),
|
||||
|
@ -341,7 +326,7 @@ CameraDataList::CameraDataList(ZFile* parent, const std::string& prefix,
|
|||
}
|
||||
}
|
||||
|
||||
CameraPositionData::CameraPositionData(const std::vector<uint8_t>& rawData, int rawDataIndex)
|
||||
CameraPositionData::CameraPositionData(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex)
|
||||
{
|
||||
x = BitConverter::ToInt16BE(rawData, rawDataIndex + 0);
|
||||
y = BitConverter::ToInt16BE(rawData, rawDataIndex + 2);
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
class PolygonEntry
|
||||
{
|
||||
public:
|
||||
int16_t type;
|
||||
int16_t vtxA, vtxB, vtxC;
|
||||
int16_t a, b, c, d;
|
||||
uint16_t type;
|
||||
uint16_t vtxA, vtxB, vtxC;
|
||||
uint16_t a, b, c, d;
|
||||
|
||||
PolygonEntry(const std::vector<uint8_t>& rawData, int rawDataIndex);
|
||||
PolygonEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
};
|
||||
|
||||
class VertexEntry
|
||||
|
@ -19,7 +19,7 @@ class VertexEntry
|
|||
public:
|
||||
int16_t x, y, z;
|
||||
|
||||
VertexEntry(const std::vector<uint8_t>& rawData, int rawDataIndex);
|
||||
VertexEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
};
|
||||
|
||||
class WaterBoxHeader
|
||||
|
@ -33,7 +33,7 @@ public:
|
|||
int16_t pad;
|
||||
int32_t properties;
|
||||
|
||||
WaterBoxHeader(const std::vector<uint8_t>& rawData, int rawDataIndex);
|
||||
WaterBoxHeader(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
};
|
||||
|
||||
class CameraPositionData
|
||||
|
@ -41,7 +41,7 @@ class CameraPositionData
|
|||
public:
|
||||
int16_t x, y, z;
|
||||
|
||||
CameraPositionData(const std::vector<uint8_t>& rawData, int rawDataIndex);
|
||||
CameraPositionData(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
};
|
||||
|
||||
class CameraDataEntry
|
||||
|
@ -59,7 +59,8 @@ public:
|
|||
std::vector<CameraPositionData*> cameraPositionData;
|
||||
|
||||
CameraDataList(ZFile* parent, const std::string& prefix, const std::vector<uint8_t>& rawData,
|
||||
int rawDataIndex, int polyTypeDefSegmentOffset, int polygonTypesCnt);
|
||||
uint32_t rawDataIndex, uint32_t polyTypeDefSegmentOffset,
|
||||
uint32_t polygonTypesCnt);
|
||||
};
|
||||
|
||||
class ZCollisionHeader : public ZResource
|
||||
|
@ -77,20 +78,21 @@ public:
|
|||
int32_t numWaterBoxes;
|
||||
segptr_t waterBoxAddress;
|
||||
|
||||
std::vector<VertexEntry*> vertices;
|
||||
std::vector<PolygonEntry*> polygons;
|
||||
uint32_t vtxSegmentOffset, polySegmentOffset, polyTypeDefSegmentOffset, camDataSegmentOffset,
|
||||
waterBoxSegmentOffset;
|
||||
|
||||
std::vector<VertexEntry> vertices;
|
||||
std::vector<PolygonEntry> polygons;
|
||||
std::vector<uint64_t> polygonTypes;
|
||||
std::vector<WaterBoxHeader*> waterBoxes;
|
||||
CameraDataList* camData;
|
||||
|
||||
ZCollisionHeader();
|
||||
// ZCollisionHeader(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
ZCollisionHeader(ZFile* parent, const std::string& prefix, const std::vector<uint8_t>& rawData,
|
||||
int rawDataIndex);
|
||||
ZCollisionHeader(ZFile* nParent);
|
||||
~ZCollisionHeader();
|
||||
|
||||
ZResourceType GetResourceType() override;
|
||||
|
||||
static ZCollisionHeader* ExtractFromXML(tinyxml2::XMLElement* reader,
|
||||
std::vector<uint8_t> nRawData, int rawDataIndex);
|
||||
void ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData,
|
||||
const uint32_t nRawDataIndex, const std::string& nRelPath) override;
|
||||
void ParseRawData() override;
|
||||
};
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -3,6 +3,7 @@
|
|||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "ZFile.h"
|
||||
#include "ZResource.h"
|
||||
#include "tinyxml2.h"
|
||||
|
||||
|
@ -52,7 +53,7 @@ public:
|
|||
int16_t posX, posY, posZ;
|
||||
int16_t unused;
|
||||
|
||||
CutsceneCameraPoint(const std::vector<uint8_t>& rawData, int rawDataIndex);
|
||||
CutsceneCameraPoint(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
};
|
||||
|
||||
class CutsceneCommand
|
||||
|
@ -60,10 +61,10 @@ class CutsceneCommand
|
|||
public:
|
||||
uint32_t commandID;
|
||||
uint32_t commandIndex;
|
||||
|
||||
CutsceneCommand(const std::vector<uint8_t>& rawData, int rawDataIndex);
|
||||
virtual std::string GetCName(const std::string& prefix);
|
||||
virtual std::string GenerateSourceCode(const std::string& roomName, int baseAddress);
|
||||
virtual ~CutsceneCommand();
|
||||
CutsceneCommand(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
virtual std::string GetCName();
|
||||
virtual std::string GenerateSourceCode(uint32_t baseAddress);
|
||||
virtual size_t GetCommandSize();
|
||||
};
|
||||
|
||||
|
@ -76,10 +77,10 @@ public:
|
|||
uint16_t unused;
|
||||
|
||||
std::vector<CutsceneCameraPoint*> entries;
|
||||
|
||||
CutsceneCommandSetCameraPos(const std::vector<uint8_t>& rawData, int rawDataIndex);
|
||||
std::string GetCName(const std::string& prefix);
|
||||
std::string GenerateSourceCode(const std::string& roomName, int baseAddress);
|
||||
~CutsceneCommandSetCameraPos();
|
||||
CutsceneCommandSetCameraPos(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
std::string GetCName();
|
||||
std::string GenerateSourceCode(uint32_t baseAddress);
|
||||
size_t GetCommandSize();
|
||||
};
|
||||
|
||||
|
@ -101,7 +102,7 @@ public:
|
|||
uint32_t unused9;
|
||||
uint32_t unused10;
|
||||
|
||||
SpecialActionEntry(const std::vector<uint8_t>& rawData, int rawDataIndex);
|
||||
SpecialActionEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
};
|
||||
|
||||
class CutsceneCommandSpecialAction : public CutsceneCommand
|
||||
|
@ -109,9 +110,10 @@ class CutsceneCommandSpecialAction : public CutsceneCommand
|
|||
public:
|
||||
std::vector<SpecialActionEntry*> entries;
|
||||
|
||||
CutsceneCommandSpecialAction(const std::vector<uint8_t>& rawData, int rawDataIndex);
|
||||
std::string GetCName(const std::string& prefix);
|
||||
std::string GenerateSourceCode(const std::string& roomName, int baseAddress);
|
||||
CutsceneCommandSpecialAction(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
~CutsceneCommandSpecialAction();
|
||||
std::string GetCName();
|
||||
std::string GenerateSourceCode(uint32_t baseAddress);
|
||||
size_t GetCommandSize();
|
||||
};
|
||||
|
||||
|
@ -133,7 +135,7 @@ public:
|
|||
uint32_t unknown9;
|
||||
uint32_t unknown10;
|
||||
|
||||
MusicFadeEntry(const std::vector<uint8_t>& rawData, int rawDataIndex);
|
||||
MusicFadeEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
};
|
||||
|
||||
class CutsceneCommandFadeBGM : public CutsceneCommand
|
||||
|
@ -141,9 +143,10 @@ class CutsceneCommandFadeBGM : public CutsceneCommand
|
|||
public:
|
||||
std::vector<MusicFadeEntry*> entries;
|
||||
|
||||
CutsceneCommandFadeBGM(const std::vector<uint8_t>& rawData, int rawDataIndex);
|
||||
std::string GetCName(const std::string& prefix);
|
||||
std::string GenerateSourceCode(const std::string& roomName, int baseAddress);
|
||||
CutsceneCommandFadeBGM(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
~CutsceneCommandFadeBGM();
|
||||
std::string GetCName();
|
||||
std::string GenerateSourceCode(uint32_t baseAddress);
|
||||
size_t GetCommandSize();
|
||||
};
|
||||
|
||||
|
@ -162,7 +165,7 @@ public:
|
|||
uint32_t unknown6;
|
||||
uint32_t unknown7;
|
||||
|
||||
MusicChangeEntry(const std::vector<uint8_t>& rawData, int rawDataIndex);
|
||||
MusicChangeEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
};
|
||||
|
||||
class CutsceneCommandPlayBGM : public CutsceneCommand
|
||||
|
@ -170,9 +173,10 @@ class CutsceneCommandPlayBGM : public CutsceneCommand
|
|||
public:
|
||||
std::vector<MusicChangeEntry*> entries;
|
||||
|
||||
CutsceneCommandPlayBGM(const std::vector<uint8_t>& rawData, int rawDataIndex);
|
||||
std::string GetCName(const std::string& prefix);
|
||||
std::string GenerateSourceCode(const std::string& roomName, int baseAddress);
|
||||
CutsceneCommandPlayBGM(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
~CutsceneCommandPlayBGM();
|
||||
std::string GetCName();
|
||||
std::string GenerateSourceCode(uint32_t baseAddress);
|
||||
size_t GetCommandSize();
|
||||
};
|
||||
|
||||
|
@ -181,9 +185,10 @@ class CutsceneCommandStopBGM : public CutsceneCommand
|
|||
public:
|
||||
std::vector<MusicChangeEntry*> entries;
|
||||
|
||||
CutsceneCommandStopBGM(const std::vector<uint8_t>& rawData, int rawDataIndex);
|
||||
std::string GetCName(const std::string& prefix);
|
||||
std::string GenerateSourceCode(const std::string& roomName, int baseAddress);
|
||||
CutsceneCommandStopBGM(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
~CutsceneCommandStopBGM();
|
||||
std::string GetCName();
|
||||
std::string GenerateSourceCode(uint32_t baseAddress);
|
||||
size_t GetCommandSize();
|
||||
};
|
||||
|
||||
|
@ -202,7 +207,7 @@ public:
|
|||
uint32_t unused6;
|
||||
uint32_t unused7;
|
||||
|
||||
EnvLightingEntry(const std::vector<uint8_t>& rawData, int rawDataIndex);
|
||||
EnvLightingEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
};
|
||||
|
||||
class CutsceneCommandEnvLighting : public CutsceneCommand
|
||||
|
@ -210,9 +215,10 @@ class CutsceneCommandEnvLighting : public CutsceneCommand
|
|||
public:
|
||||
std::vector<EnvLightingEntry*> entries;
|
||||
|
||||
CutsceneCommandEnvLighting(const std::vector<uint8_t>& rawData, int rawDataIndex);
|
||||
std::string GetCName(const std::string& prefix);
|
||||
std::string GenerateSourceCode(const std::string& roomName, int baseAddress);
|
||||
CutsceneCommandEnvLighting(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
~CutsceneCommandEnvLighting();
|
||||
std::string GetCName();
|
||||
std::string GenerateSourceCode(uint32_t baseAddress);
|
||||
size_t GetCommandSize();
|
||||
};
|
||||
|
||||
|
@ -222,10 +228,10 @@ public:
|
|||
uint16_t base;
|
||||
uint16_t startFrame;
|
||||
uint16_t endFrame;
|
||||
|
||||
CutsceneCommandSceneTransFX(const std::vector<uint8_t>& rawData, int rawDataIndex);
|
||||
std::string GetCName(const std::string& prefix);
|
||||
std::string GenerateSourceCode(const std::string& roomName, int baseAddress);
|
||||
~CutsceneCommandSceneTransFX();
|
||||
CutsceneCommandSceneTransFX(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
std::string GetCName();
|
||||
std::string GenerateSourceCode(uint32_t baseAddress);
|
||||
size_t GetCommandSize();
|
||||
};
|
||||
|
||||
|
@ -241,7 +247,7 @@ public:
|
|||
uint8_t unused0;
|
||||
uint8_t unused1;
|
||||
|
||||
Unknown9Entry(const std::vector<uint8_t>& rawData, int rawDataIndex);
|
||||
Unknown9Entry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
};
|
||||
|
||||
class CutsceneCommandUnknown9 : public CutsceneCommand
|
||||
|
@ -249,9 +255,10 @@ class CutsceneCommandUnknown9 : public CutsceneCommand
|
|||
public:
|
||||
std::vector<Unknown9Entry*> entries;
|
||||
|
||||
CutsceneCommandUnknown9(const std::vector<uint8_t>& rawData, int rawDataIndex);
|
||||
std::string GetCName(const std::string& prefix);
|
||||
std::string GenerateSourceCode(const std::string& roomName, int baseAddress);
|
||||
CutsceneCommandUnknown9(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
~CutsceneCommandUnknown9();
|
||||
std::string GetCName();
|
||||
std::string GenerateSourceCode(uint32_t baseAddress);
|
||||
size_t GetCommandSize();
|
||||
};
|
||||
|
||||
|
@ -271,7 +278,7 @@ public:
|
|||
uint32_t unused10;
|
||||
uint32_t unused11;
|
||||
|
||||
UnkEntry(const std::vector<uint8_t>& rawData, int rawDataIndex);
|
||||
UnkEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
};
|
||||
|
||||
class CutsceneCommandUnknown : public CutsceneCommand
|
||||
|
@ -279,9 +286,10 @@ class CutsceneCommandUnknown : public CutsceneCommand
|
|||
public:
|
||||
std::vector<UnkEntry*> entries;
|
||||
|
||||
CutsceneCommandUnknown(const std::vector<uint8_t>& rawData, int rawDataIndex);
|
||||
std::string GetCName(const std::string& prefix);
|
||||
std::string GenerateSourceCode(const std::string& roomName, int baseAddress);
|
||||
CutsceneCommandUnknown(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
~CutsceneCommandUnknown();
|
||||
std::string GetCName();
|
||||
std::string GenerateSourceCode(uint32_t baseAddress);
|
||||
size_t GetCommandSize();
|
||||
};
|
||||
|
||||
|
@ -295,7 +303,7 @@ public:
|
|||
uint8_t minute;
|
||||
uint8_t unused;
|
||||
|
||||
DayTimeEntry(const std::vector<uint8_t>& rawData, int rawDataIndex);
|
||||
DayTimeEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
};
|
||||
|
||||
class CutsceneCommandDayTime : public CutsceneCommand
|
||||
|
@ -303,9 +311,10 @@ class CutsceneCommandDayTime : public CutsceneCommand
|
|||
public:
|
||||
std::vector<DayTimeEntry*> entries;
|
||||
|
||||
CutsceneCommandDayTime(const std::vector<uint8_t>& rawData, int rawDataIndex);
|
||||
std::string GetCName(const std::string& prefix);
|
||||
std::string GenerateSourceCode(const std::string& roomName, int baseAddress);
|
||||
CutsceneCommandDayTime(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
~CutsceneCommandDayTime();
|
||||
std::string GetCName();
|
||||
std::string GenerateSourceCode(uint32_t baseAddress);
|
||||
size_t GetCommandSize();
|
||||
};
|
||||
|
||||
|
@ -319,7 +328,7 @@ public:
|
|||
uint16_t textID1;
|
||||
uint16_t textID2;
|
||||
|
||||
TextboxEntry(const std::vector<uint8_t>& rawData, int rawDataIndex);
|
||||
TextboxEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
};
|
||||
|
||||
class CutsceneCommandTextbox : public CutsceneCommand
|
||||
|
@ -327,9 +336,10 @@ class CutsceneCommandTextbox : public CutsceneCommand
|
|||
public:
|
||||
std::vector<TextboxEntry*> entries;
|
||||
|
||||
CutsceneCommandTextbox(const std::vector<uint8_t>& rawData, int rawDataIndex);
|
||||
std::string GetCName(const std::string& prefix);
|
||||
std::string GenerateSourceCode(const std::string& roomName, int baseAddress);
|
||||
CutsceneCommandTextbox(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
~CutsceneCommandTextbox();
|
||||
std::string GetCName();
|
||||
std::string GenerateSourceCode(uint32_t baseAddress);
|
||||
size_t GetCommandSize();
|
||||
};
|
||||
|
||||
|
@ -344,7 +354,7 @@ public:
|
|||
int32_t endPosX, endPosY, endPosZ;
|
||||
int32_t normalX, normalY, normalZ;
|
||||
|
||||
ActorAction(const std::vector<uint8_t>& rawData, int rawDataIndex);
|
||||
ActorAction(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
};
|
||||
|
||||
class CutsceneCommandActorAction : public CutsceneCommand
|
||||
|
@ -352,9 +362,10 @@ class CutsceneCommandActorAction : public CutsceneCommand
|
|||
public:
|
||||
std::vector<ActorAction*> entries;
|
||||
|
||||
CutsceneCommandActorAction(const std::vector<uint8_t>& rawData, int rawDataIndex);
|
||||
std::string GetCName(const std::string& prefix);
|
||||
std::string GenerateSourceCode(const std::string& roomName, int baseAddress);
|
||||
CutsceneCommandActorAction(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
~CutsceneCommandActorAction();
|
||||
std::string GetCName();
|
||||
std::string GenerateSourceCode(uint32_t baseAddress);
|
||||
size_t GetCommandSize();
|
||||
};
|
||||
|
||||
|
@ -366,9 +377,9 @@ public:
|
|||
uint16_t endFrame;
|
||||
uint16_t unknown;
|
||||
|
||||
CutsceneCommandTerminator(const std::vector<uint8_t>& rawData, int rawDataIndex);
|
||||
std::string GetCName(const std::string& prefix);
|
||||
std::string GenerateSourceCode(const std::string& roomName, int baseAddress);
|
||||
CutsceneCommandTerminator(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
std::string GetCName();
|
||||
std::string GenerateSourceCode(uint32_t baseAddress);
|
||||
size_t GetCommandSize();
|
||||
};
|
||||
|
||||
|
@ -379,9 +390,9 @@ public:
|
|||
uint16_t startFrame;
|
||||
uint16_t endFrame;
|
||||
|
||||
CutsceneCommandEnd(const std::vector<uint8_t>& rawData, int rawDataIndex);
|
||||
std::string GetCName(const std::string& prefix);
|
||||
std::string GenerateSourceCode(const std::string& roomName, int baseAddress);
|
||||
CutsceneCommandEnd(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
std::string GetCName();
|
||||
std::string GenerateSourceCode(uint32_t baseAddress);
|
||||
size_t GetCommandSize();
|
||||
};
|
||||
|
||||
|
@ -392,32 +403,41 @@ public:
|
|||
uint16_t startFrame;
|
||||
uint16_t endFrame;
|
||||
|
||||
CutsceneCommandNop(const std::vector<uint8_t>& rawData, int rawDataIndex);
|
||||
std::string GetCName(const std::string& prefix);
|
||||
CutsceneCommandNop(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
|
||||
std::string GetCName();
|
||||
size_t GetCommandSize();
|
||||
};
|
||||
|
||||
class ZCutscene : public ZResource
|
||||
class ZCutsceneBase : public ZResource
|
||||
{
|
||||
public:
|
||||
uint32_t segmentOffset;
|
||||
ZCutsceneBase(ZFile* nParent);
|
||||
virtual std::string GetBodySourceCode() = 0;
|
||||
virtual void DeclareVar(const std::string& prefix, const std::string& bodyStr) = 0;
|
||||
virtual uint32_t getSegmentOffset() = 0;
|
||||
};
|
||||
|
||||
ZCutscene(std::vector<uint8_t> nRawData, int rawDataIndex, int rawDataSize);
|
||||
class ZCutscene : public ZCutsceneBase
|
||||
{
|
||||
public:
|
||||
ZCutscene(ZFile* nParent);
|
||||
~ZCutscene();
|
||||
|
||||
std::string GetBodySourceCode() override;
|
||||
void DeclareVar(const std::string& prefix, const std::string& bodyStr) override;
|
||||
std::string GetSourceOutputCode(const std::string& prefix) override;
|
||||
int GetRawDataSize() override;
|
||||
CutsceneCommands GetCommandFromID(int id);
|
||||
size_t GetRawDataSize() override;
|
||||
CutsceneCommands GetCommandFromID(int32_t id);
|
||||
uint32_t getSegmentOffset() override { return rawDataIndex; }
|
||||
|
||||
ZResourceType GetResourceType() override;
|
||||
|
||||
static ZCutscene* ExtractFromXML(tinyxml2::XMLElement* reader,
|
||||
const std::vector<uint8_t>& nRawData, const int rawDataIndex,
|
||||
const std::string& nRelPath);
|
||||
void ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData,
|
||||
const uint32_t nRawDataIndex, const std::string& nRelPath) override;
|
||||
|
||||
protected:
|
||||
int numCommands;
|
||||
int endFrame;
|
||||
int32_t numCommands;
|
||||
int32_t endFrame;
|
||||
std::vector<CutsceneCommand*> commands;
|
||||
|
||||
void ParseRawData() override;
|
||||
|
|
95
tools/ZAPD/ZAPD/ZCutsceneMM.cpp
Normal file
95
tools/ZAPD/ZAPD/ZCutsceneMM.cpp
Normal file
|
@ -0,0 +1,95 @@
|
|||
#include "ZCutsceneMM.h"
|
||||
#include "BitConverter.h"
|
||||
#include "StringHelper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
ZCutsceneMM::ZCutsceneMM(ZFile* nParent) : ZCutsceneBase(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
ZCutsceneMM::~ZCutsceneMM()
|
||||
{
|
||||
for (CutsceneCommand* cmd : commands)
|
||||
delete cmd;
|
||||
}
|
||||
|
||||
string ZCutsceneMM::GetBodySourceCode()
|
||||
{
|
||||
string output = "";
|
||||
|
||||
output += StringHelper::Sprintf(" CS_BEGIN_CUTSCENE(%i, %i),", numCommands, endFrame);
|
||||
|
||||
for (size_t i = 0; i < data.size(); i++)
|
||||
{
|
||||
if ((i % 4) == 0)
|
||||
output += "\n ";
|
||||
output += StringHelper::Sprintf("0x%08X,", data[i]);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
string ZCutsceneMM::GetSourceOutputCode(const std::string& prefix)
|
||||
{
|
||||
std::string bodyStr = GetBodySourceCode();
|
||||
|
||||
Declaration* decl = parent->GetDeclaration(rawDataIndex);
|
||||
|
||||
if (decl == nullptr)
|
||||
DeclareVar(prefix, bodyStr);
|
||||
else
|
||||
decl->text = bodyStr;
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
void ZCutsceneMM::DeclareVar(const std::string& prefix, const std::string& bodyStr)
|
||||
{
|
||||
std::string auxName = name;
|
||||
|
||||
if (auxName == "")
|
||||
auxName = StringHelper::Sprintf("%sCutsceneData0x%06X", prefix.c_str(), rawDataIndex);
|
||||
// auxName = GetDefaultName(prefix, getSegmentOffset());
|
||||
|
||||
parent->AddDeclarationArray(getSegmentOffset(), DeclarationAlignment::Align4, GetRawDataSize(),
|
||||
"s32", auxName, 0, bodyStr);
|
||||
}
|
||||
|
||||
size_t ZCutsceneMM::GetRawDataSize()
|
||||
{
|
||||
return 8 + data.size() * 4;
|
||||
}
|
||||
|
||||
void ZCutsceneMM::ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData,
|
||||
const uint32_t nRawDataIndex, const std::string& nRelPath)
|
||||
{
|
||||
ZResource::ExtractFromXML(reader, nRawData, nRawDataIndex, nRelPath);
|
||||
DeclareVar(parent->GetName(), "");
|
||||
}
|
||||
|
||||
void ZCutsceneMM::ParseRawData()
|
||||
{
|
||||
segmentOffset = rawDataIndex;
|
||||
|
||||
numCommands = BitConverter::ToInt32BE(rawData, rawDataIndex + 0);
|
||||
commands = vector<CutsceneCommand*>();
|
||||
|
||||
endFrame = BitConverter::ToInt32BE(rawData, rawDataIndex + 4);
|
||||
uint32_t currentPtr = rawDataIndex + 8;
|
||||
uint32_t lastData = 0;
|
||||
|
||||
// TODO currently cutscenes aren't being parsed, so just consume words until we see an end
|
||||
// marker.
|
||||
do
|
||||
{
|
||||
lastData = BitConverter::ToInt32BE(rawData, currentPtr);
|
||||
data.push_back(lastData);
|
||||
currentPtr += 4;
|
||||
} while (lastData != 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
ZResourceType ZCutsceneMM::GetResourceType()
|
||||
{
|
||||
return ZResourceType::Cutscene;
|
||||
}
|
36
tools/ZAPD/ZAPD/ZCutsceneMM.h
Normal file
36
tools/ZAPD/ZAPD/ZCutsceneMM.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "ZCutscene.h"
|
||||
#include "ZFile.h"
|
||||
#include "tinyxml2.h"
|
||||
|
||||
class ZCutsceneMM : public ZCutsceneBase
|
||||
{
|
||||
public:
|
||||
uint32_t segmentOffset;
|
||||
|
||||
ZCutsceneMM(ZFile* nParent);
|
||||
virtual ~ZCutsceneMM();
|
||||
|
||||
std::string GetBodySourceCode() override;
|
||||
void DeclareVar(const std::string& prefix, const std::string& bodyStr) override;
|
||||
std::string GetSourceOutputCode(const std::string& prefix) override;
|
||||
size_t GetRawDataSize() override;
|
||||
uint32_t getSegmentOffset() override { return segmentOffset; }
|
||||
|
||||
void ParseRawData() override;
|
||||
ZResourceType GetResourceType() override;
|
||||
|
||||
void ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData,
|
||||
const uint32_t nRawDataIndex, const std::string& nRelPath) override;
|
||||
|
||||
protected:
|
||||
int32_t numCommands;
|
||||
int32_t endFrame;
|
||||
std::vector<CutsceneCommand*> commands;
|
||||
|
||||
std::vector<uint32_t> data;
|
||||
};
|
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "ZMtx.h"
|
||||
#include "ZResource.h"
|
||||
#include "ZRoom/ZRoom.h"
|
||||
#include "ZTexture.h"
|
||||
|
@ -292,7 +293,7 @@ public:
|
|||
Vertex();
|
||||
Vertex(int16_t nX, int16_t nY, int16_t nZ, uint16_t nFlag, int16_t nS, int16_t nT, uint8_t nR,
|
||||
uint8_t nG, uint8_t nB, uint8_t nA);
|
||||
Vertex(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
Vertex(std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
};
|
||||
|
||||
class ZDisplayList : public ZResource
|
||||
|
@ -301,37 +302,39 @@ protected:
|
|||
static TextureType TexFormatToTexType(F3DZEXTexFormats fmt, F3DZEXTexSizes siz);
|
||||
void ParseRawData() override;
|
||||
|
||||
void ParseF3DZEX(F3DZEXOpcode opcode, uint64_t data, int i, std::string prefix, char* line);
|
||||
void ParseF3DEX(F3DEXOpcode opcode, uint64_t data, int i, std::string prefix, char* line);
|
||||
void ParseF3DZEX(F3DZEXOpcode opcode, uint64_t data, int32_t i, std::string prefix, char* line);
|
||||
void ParseF3DEX(F3DEXOpcode opcode, uint64_t data, std::string prefix, char* line);
|
||||
|
||||
// Various Instruction Optimizations
|
||||
bool SequenceCheck(std::vector<F3DZEXOpcode> sequence, int startIndex);
|
||||
int OptimizationChecks(int startIndex, std::string& output, std::string prefix);
|
||||
int OptimizationCheck_LoadTextureBlock(int startIndex, std::string& output, std::string prefix);
|
||||
int OptimizationCheck_LoadMultiBlock(int startIndex, std::string& output, std::string prefix);
|
||||
bool SequenceCheck(std::vector<F3DZEXOpcode> sequence, int32_t startIndex);
|
||||
int32_t OptimizationChecks(int32_t startIndex, std::string& output, std::string prefix);
|
||||
int32_t OptimizationCheck_LoadTextureBlock(int32_t startIndex, std::string& output,
|
||||
std::string prefix);
|
||||
// int32_t OptimizationCheck_LoadMultiBlock(int32_t startIndex, std::string& output, std::string
|
||||
// prefix);
|
||||
|
||||
// F3DEX Specific Opcode Values
|
||||
void Opcode_F3DEX_G_SETOTHERMODE_L(uint64_t data, int i, std::string prefix, char* line);
|
||||
void Opcode_F3DEX_G_SETOTHERMODE_L(uint64_t data, char* line);
|
||||
|
||||
// Shared Opcodes between F3DZEX and F3DEX
|
||||
void Opcode_G_DL(uint64_t data, int i, std::string prefix, char* line);
|
||||
void Opcode_G_MODIFYVTX(uint64_t data, int i, std::string prefix, char* line);
|
||||
void Opcode_G_CULLDL(uint64_t data, int i, std::string prefix, char* line);
|
||||
void Opcode_G_TRI1(uint64_t data, int i, std::string prefix, char* line);
|
||||
void Opcode_G_TRI2(uint64_t data, int i, std::string prefix, char* line);
|
||||
void Opcode_G_MTX(uint64_t data, int i, std::string prefix, char* line);
|
||||
void Opcode_G_VTX(uint64_t data, int i, std::string prefix, char* line);
|
||||
void Opcode_G_TEXTURE(uint64_t data, int i, std::string prefix, char* line);
|
||||
void Opcode_G_SETTIMG(uint64_t data, int i, std::string prefix, char* line);
|
||||
void Opcode_G_SETTILE(uint64_t data, int i, std::string prefix, char* line);
|
||||
void Opcode_G_SETTILESIZE(uint64_t data, int i, std::string prefix, char* line);
|
||||
void Opcode_G_LOADBLOCK(uint64_t data, int i, std::string prefix, char* line);
|
||||
void Opcode_G_SETCOMBINE(uint64_t data, int i, std::string prefix, char* line);
|
||||
void Opcode_G_SETPRIMCOLOR(uint64_t data, int i, std::string prefix, char* line);
|
||||
void Opcode_G_SETOTHERMODE_L(uint64_t data, int i, std::string prefix, char* line);
|
||||
void Opcode_G_SETOTHERMODE_H(uint64_t data, int i, std::string prefix, char* line);
|
||||
void Opcode_G_LOADTLUT(uint64_t data, int i, std::string prefix, char* line);
|
||||
void Opcode_G_ENDDL(uint64_t data, int i, std::string prefix, char* line);
|
||||
void Opcode_G_DL(uint64_t data, std::string prefix, char* line);
|
||||
void Opcode_G_MODIFYVTX(uint64_t data, char* line);
|
||||
void Opcode_G_CULLDL(uint64_t data, char* line);
|
||||
void Opcode_G_TRI1(uint64_t data, char* line);
|
||||
void Opcode_G_TRI2(uint64_t data, char* line);
|
||||
void Opcode_G_MTX(uint64_t data, char* line);
|
||||
void Opcode_G_VTX(uint64_t data, char* line);
|
||||
void Opcode_G_TEXTURE(uint64_t data, char* line);
|
||||
void Opcode_G_SETTIMG(uint64_t data, std::string prefix, char* line);
|
||||
void Opcode_G_SETTILE(uint64_t data, char* line);
|
||||
void Opcode_G_SETTILESIZE(uint64_t data, std::string prefix, char* line);
|
||||
void Opcode_G_LOADBLOCK(uint64_t data, char* line);
|
||||
void Opcode_G_SETCOMBINE(uint64_t data, char* line);
|
||||
void Opcode_G_SETPRIMCOLOR(uint64_t data, char* line);
|
||||
void Opcode_G_SETOTHERMODE_L(uint64_t data, char* line);
|
||||
void Opcode_G_SETOTHERMODE_H(uint64_t data, char* line);
|
||||
void Opcode_G_LOADTLUT(uint64_t data, std::string prefix, char* line);
|
||||
void Opcode_G_ENDDL(std::string prefix, char* line);
|
||||
|
||||
public:
|
||||
std::string sceneSegName;
|
||||
|
@ -339,7 +342,7 @@ public:
|
|||
std::vector<uint64_t> instructions;
|
||||
std::string curPrefix;
|
||||
|
||||
uint32_t lastTexWidth, lastTexHeight, lastTexAddr, lastTexSeg;
|
||||
int32_t lastTexWidth, lastTexHeight, lastTexAddr, lastTexSeg;
|
||||
F3DZEXTexFormats lastTexFmt;
|
||||
F3DZEXTexSizes lastTexSiz, lastTexSizTest, lastCISiz;
|
||||
bool lastTexLoaded;
|
||||
|
@ -347,7 +350,7 @@ public:
|
|||
|
||||
DListType dListType;
|
||||
|
||||
// int dListAddress;
|
||||
// int32_t dListAddress;
|
||||
|
||||
std::map<uint32_t, std::vector<Vertex>> vertices;
|
||||
std::map<uint32_t, std::string> vtxDeclarations;
|
||||
|
@ -360,31 +363,39 @@ public:
|
|||
|
||||
std::string defines; // Hack for special cases where vertex arrays intersect...
|
||||
std::vector<uint8_t> fileData;
|
||||
std::vector<ZMtx> mtxList;
|
||||
|
||||
ZDisplayList();
|
||||
ZDisplayList(std::vector<uint8_t> nRawData, int rawDataIndex, int rawDataSize);
|
||||
ZDisplayList(ZFile* nParent);
|
||||
ZDisplayList(std::vector<uint8_t> nRawData, uint32_t rawDataIndex, int32_t rawDataSize,
|
||||
ZFile* nParent);
|
||||
~ZDisplayList();
|
||||
|
||||
static ZDisplayList* static_instance;
|
||||
static ZDisplayList* ExtractFromXML(tinyxml2::XMLElement* reader, std::vector<uint8_t> nRawData,
|
||||
int rawDataIndex, int rawDataSize, std::string nRelPath);
|
||||
static ZDisplayList* BuildFromXML(tinyxml2::XMLElement* reader, std::string inFolder,
|
||||
bool readFile);
|
||||
void ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData,
|
||||
const uint32_t nRawDataIndex, const std::string& nRelPath) override;
|
||||
// static ZDisplayList* BuildFromXML(tinyxml2::XMLElement* reader, std::string inFolder, bool
|
||||
// readFile, ZFile* nParent);
|
||||
|
||||
void TextureGenCheck(std::string prefix);
|
||||
static bool TextureGenCheck(std::vector<uint8_t> fileData,
|
||||
std::map<uint32_t, ZTexture*>& textures, ZRoom* scene,
|
||||
ZFile* parent, std::string prefix, uint32_t texWidth,
|
||||
uint32_t texHeight, uint32_t texAddr, uint32_t texSeg,
|
||||
ZFile* parent, std::string prefix, int32_t texWidth,
|
||||
int32_t texHeight, uint32_t texAddr, uint32_t texSeg,
|
||||
F3DZEXTexFormats texFmt, F3DZEXTexSizes texSiz, bool texLoaded,
|
||||
bool texIsPalette);
|
||||
static int GetDListLength(std::vector<uint8_t> rawData, int rawDataIndex, DListType dListType);
|
||||
static int32_t GetDListLength(std::vector<uint8_t> rawData, uint32_t rawDataIndex,
|
||||
DListType dListType);
|
||||
|
||||
std::vector<uint8_t> GetRawData() override;
|
||||
int GetRawDataSize() override;
|
||||
size_t GetRawDataSize() override;
|
||||
std::string GetSourceOutputHeader(const std::string& prefix) override;
|
||||
std::string GetSourceOutputCode(const std::string& prefix) override;
|
||||
std::string ProcessLegacy(const std::string& prefix);
|
||||
std::string ProcessGfxDis(const std::string& prefix);
|
||||
|
||||
void Save(const std::string& outFolder) override;
|
||||
virtual void GenerateHLIntermediette(HLFileIntermediette& hlFile) override;
|
||||
bool IsExternalResource() override;
|
||||
virtual std::string GetExternalExtension() override;
|
||||
std::string GetSourceTypeName() override;
|
||||
|
||||
ZResourceType GetResourceType() override;
|
||||
};
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2,18 +2,19 @@
|
|||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "Directory.h"
|
||||
#include "ZResource.h"
|
||||
#include "tinyxml2.h"
|
||||
|
||||
enum class ZFileMode
|
||||
{
|
||||
Build,
|
||||
BuildTexture,
|
||||
BuildOverlay,
|
||||
BuildModelIntermediette,
|
||||
BuildAnimationIntermediette,
|
||||
BuildBlob,
|
||||
BuildSourceFile,
|
||||
BuildBackground,
|
||||
Extract,
|
||||
Invalid
|
||||
};
|
||||
|
@ -33,36 +34,41 @@ public:
|
|||
std::vector<ZResource*> resources;
|
||||
uint32_t baseAddress, rangeStart, rangeEnd;
|
||||
|
||||
ZFile(std::string nOutPath, std::string nName);
|
||||
ZFile(ZFileMode mode, tinyxml2::XMLElement* reader, std::string nBasePath, std::string nOutPath,
|
||||
std::string filename, bool placeholderMode);
|
||||
ZFile(const fs::path& nOutPath, std::string nName);
|
||||
ZFile(ZFileMode mode, tinyxml2::XMLElement* reader, const fs::path& nBasePath,
|
||||
const fs::path& nOutPath, std::string filename, const fs::path& nXmlFilePath,
|
||||
bool placeholderMode);
|
||||
~ZFile();
|
||||
|
||||
std::string GetVarName(int address);
|
||||
std::string GetVarName(uint32_t address);
|
||||
std::string GetName();
|
||||
void ExtractResources(std::string outputDir);
|
||||
void BuildResources();
|
||||
void BuildSourceFile(std::string outputDir);
|
||||
void ExtractResources(fs::path outputDir);
|
||||
void BuildSourceFile(fs::path outputDir);
|
||||
void AddResource(ZResource* res);
|
||||
ZResource* FindResource(uint32_t rawDataIndex);
|
||||
std::vector<ZResource*> GetResourcesOfType(ZResourceType resType);
|
||||
|
||||
Declaration* AddDeclaration(uint32_t address, DeclarationAlignment alignment, uint32_t size,
|
||||
Declaration* AddDeclaration(uint32_t address, DeclarationAlignment alignment, size_t size,
|
||||
std::string varType, std::string varName, std::string body);
|
||||
Declaration* AddDeclaration(uint32_t address, DeclarationAlignment alignment,
|
||||
DeclarationPadding padding, uint32_t size, std::string varType,
|
||||
DeclarationPadding padding, size_t size, std::string varType,
|
||||
std::string varName, std::string body);
|
||||
Declaration* AddDeclarationArray(uint32_t address, DeclarationAlignment alignment, size_t size,
|
||||
std::string varType, std::string varName, size_t arrayItemCnt,
|
||||
std::string body);
|
||||
Declaration* AddDeclarationArray(uint32_t address, DeclarationAlignment alignment, size_t size,
|
||||
std::string varType, std::string varName, size_t arrayItemCnt,
|
||||
std::string body, bool isExternal);
|
||||
Declaration* AddDeclarationArray(uint32_t address, DeclarationAlignment alignment,
|
||||
uint32_t size, std::string varType, std::string varName,
|
||||
int arrayItemCnt, std::string body);
|
||||
Declaration* AddDeclarationArray(uint32_t address, DeclarationAlignment alignment,
|
||||
DeclarationPadding padding, uint32_t size, std::string varType,
|
||||
std::string varName, int arrayItemCnt, std::string body);
|
||||
DeclarationPadding padding, size_t size, std::string varType,
|
||||
std::string varName, size_t arrayItemCnt, std::string body);
|
||||
Declaration* AddDeclarationPlaceholder(uint32_t address);
|
||||
Declaration* AddDeclarationPlaceholder(uint32_t address, std::string varName);
|
||||
Declaration* AddDeclarationInclude(uint32_t address, std::string includePath, uint32_t size,
|
||||
Declaration* AddDeclarationInclude(uint32_t address, std::string includePath, size_t size,
|
||||
std::string varType, std::string varName);
|
||||
Declaration* AddDeclarationIncludeArray(uint32_t address, std::string includePath,
|
||||
uint32_t size, std::string varType, std::string varName,
|
||||
int arrayItemCnt);
|
||||
Declaration* AddDeclarationIncludeArray(uint32_t address, std::string includePath, size_t size,
|
||||
std::string varType, std::string varName,
|
||||
size_t arrayItemCnt);
|
||||
std::string GetDeclarationName(uint32_t address);
|
||||
std::string GetDeclarationName(uint32_t address, std::string defaultResult);
|
||||
Declaration* GetDeclaration(uint32_t address);
|
||||
|
@ -72,17 +78,21 @@ public:
|
|||
std::string GetHeaderInclude();
|
||||
void GeneratePlaceholderDeclarations();
|
||||
|
||||
static std::map<std::string, ZResourceFactoryFunc*>* GetNodeMap();
|
||||
static void RegisterNode(std::string nodeName, ZResourceFactoryFunc* nodeFunc);
|
||||
|
||||
protected:
|
||||
std::vector<uint8_t> rawData;
|
||||
std::string name;
|
||||
std::string basePath;
|
||||
std::string outputPath;
|
||||
std::string sourceOutput;
|
||||
fs::path basePath;
|
||||
fs::path outputPath;
|
||||
fs::path xmlFilePath;
|
||||
|
||||
ZFile();
|
||||
void ParseXML(ZFileMode mode, tinyxml2::XMLElement* reader, std::string filename,
|
||||
bool placeholderMode);
|
||||
void GenerateSourceFiles(std::string outputDir);
|
||||
void GenerateSourceFiles(fs::path outputDir);
|
||||
void GenerateSourceHeaderFiles();
|
||||
void GenerateHLIntermediette();
|
||||
void AddDeclarationDebugChecks(uint32_t address);
|
||||
std::string ProcessDeclarations();
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
REGISTER_ZFILENODE(Limb, ZLimb);
|
||||
|
||||
Struct_800A57C0::Struct_800A57C0(const std::vector<uint8_t>& rawData, uint32_t fileOffset)
|
||||
{
|
||||
unk_0 = BitConverter::ToUInt16BE(rawData, fileOffset + 0x00);
|
||||
|
@ -115,6 +117,7 @@ void Struct_800A598C::PreGenSourceFiles(const std::string& prefix)
|
|||
size_t arrayItemCnt = unk_8_arr.size();
|
||||
entryStr = "";
|
||||
size_t i = 0;
|
||||
|
||||
for (auto& child : unk_8_arr)
|
||||
{
|
||||
entryStr += StringHelper::Sprintf(" { %s },%s", child.GetSourceOutputCode().c_str(),
|
||||
|
@ -122,6 +125,7 @@ void Struct_800A598C::PreGenSourceFiles(const std::string& prefix)
|
|||
}
|
||||
|
||||
Declaration* decl = parent->GetDeclaration(unk_8_Offset);
|
||||
|
||||
if (decl == nullptr)
|
||||
{
|
||||
parent->AddDeclarationArray(unk_8_Offset, DeclarationAlignment::None,
|
||||
|
@ -145,6 +149,7 @@ void Struct_800A598C::PreGenSourceFiles(const std::string& prefix)
|
|||
size_t arrayItemCnt = unk_C_arr.size();
|
||||
entryStr = "";
|
||||
size_t i = 0;
|
||||
|
||||
for (auto& child : unk_C_arr)
|
||||
{
|
||||
entryStr += StringHelper::Sprintf(" { %s },%s", child.GetSourceOutputCode().c_str(),
|
||||
|
@ -171,6 +176,7 @@ std::string Struct_800A598C::GetSourceOutputCode(const std::string& prefix) cons
|
|||
string entryStr;
|
||||
|
||||
string unk_8_Str = "NULL";
|
||||
|
||||
if (unk_8 != 0)
|
||||
{
|
||||
uint32_t unk_8_Offset = Seg2Filespace(unk_8, parent->baseAddress);
|
||||
|
@ -180,6 +186,7 @@ std::string Struct_800A598C::GetSourceOutputCode(const std::string& prefix) cons
|
|||
}
|
||||
|
||||
string unk_C_Str = "NULL";
|
||||
|
||||
if (unk_C != 0)
|
||||
{
|
||||
uint32_t unk_C_Offset = Seg2Filespace(unk_C, parent->baseAddress);
|
||||
|
@ -188,6 +195,10 @@ std::string Struct_800A598C::GetSourceOutputCode(const std::string& prefix) cons
|
|||
Struct_800A598C_2::GetSourceTypeName().c_str(), unk_C_Offset);
|
||||
}
|
||||
|
||||
entryStr = StringHelper::Sprintf("\n ARRAY_COUNTU(%s), ARRAY_COUNTU(%s),\n",
|
||||
unk_8_Str.c_str(), unk_C_Str.c_str());
|
||||
entryStr += StringHelper::Sprintf(" %i, %s, %s\n ", unk_4, unk_8_Str.c_str(),
|
||||
unk_C_Str.c_str());
|
||||
entryStr = StringHelper::Sprintf("\n ARRAY_COUNTU(%s), ARRAY_COUNTU(%s),\n",
|
||||
unk_8_Str.c_str(), unk_C_Str.c_str());
|
||||
entryStr += StringHelper::Sprintf(" %i, %s, %s\n ", unk_4, unk_8_Str.c_str(),
|
||||
|
@ -218,23 +229,25 @@ Struct_800A5E28::Struct_800A5E28(ZFile* parent, const std::vector<uint8_t>& nRaw
|
|||
if (unk_4 != 0)
|
||||
{
|
||||
uint32_t unk_4_Offset = Seg2Filespace(unk_4, parent->baseAddress);
|
||||
|
||||
for (size_t i = 0; i < unk_2; i++)
|
||||
{
|
||||
unk_4_arr.emplace_back(parent, nRawData, unk_4_Offset, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
Struct_800A5E28::Struct_800A5E28(ZFile* parent, const std::vector<uint8_t>& rawData,
|
||||
uint32_t fileOffset, size_t index)
|
||||
: Struct_800A5E28(parent, rawData, fileOffset + index * GetRawDataSize())
|
||||
{
|
||||
}
|
||||
|
||||
Struct_800A5E28::~Struct_800A5E28()
|
||||
{
|
||||
delete unk_8_dlist;
|
||||
}
|
||||
|
||||
ZLimb::~ZLimb()
|
||||
{
|
||||
for (auto DL : dLists)
|
||||
delete DL;
|
||||
}
|
||||
|
||||
void Struct_800A5E28::PreGenSourceFiles(const std::string& prefix)
|
||||
{
|
||||
if (unk_4 != 0)
|
||||
|
@ -248,16 +261,17 @@ void Struct_800A5E28::PreGenSourceFiles(const std::string& prefix)
|
|||
uint16_t arrayItemCnt = unk_4_arr.size();
|
||||
|
||||
size_t i = 0;
|
||||
|
||||
for (auto& child : unk_4_arr)
|
||||
{
|
||||
child.PreGenSourceFiles(prefix);
|
||||
|
||||
entryStr +=
|
||||
StringHelper::Sprintf(" { %s },%s", child.GetSourceOutputCode(prefix).c_str(),
|
||||
(++i < arrayItemCnt) ? "\n" : "");
|
||||
}
|
||||
|
||||
Declaration* decl = parent->GetDeclaration(unk_4_Offset);
|
||||
|
||||
if (decl == nullptr)
|
||||
{
|
||||
parent->AddDeclarationArray(unk_4_Offset, DeclarationAlignment::None,
|
||||
|
@ -275,11 +289,10 @@ void Struct_800A5E28::PreGenSourceFiles(const std::string& prefix)
|
|||
{
|
||||
uint32_t unk_8_Offset = Seg2Filespace(unk_8, parent->baseAddress);
|
||||
|
||||
int dlistLength = ZDisplayList::GetDListLength(
|
||||
int32_t dlistLength = ZDisplayList::GetDListLength(
|
||||
rawData, unk_8_Offset,
|
||||
Globals::Instance->game == ZGame::OOT_SW97 ? DListType::F3DEX : DListType::F3DZEX);
|
||||
unk_8_dlist = new ZDisplayList(rawData, unk_8_Offset, dlistLength);
|
||||
unk_8_dlist->parent = parent;
|
||||
unk_8_dlist = new ZDisplayList(rawData, unk_8_Offset, dlistLength, parent);
|
||||
|
||||
string dListStr = StringHelper::Sprintf("%sSkinLimbDL_%06X", prefix.c_str(), unk_8_Offset);
|
||||
unk_8_dlist->SetName(dListStr);
|
||||
|
@ -292,10 +305,12 @@ std::string Struct_800A5E28::GetSourceOutputCode(const std::string& prefix) cons
|
|||
string entryStr = "";
|
||||
|
||||
string unk_4_Str = "NULL";
|
||||
|
||||
if (unk_4 != 0)
|
||||
{
|
||||
uint32_t unk_4_Offset = Seg2Filespace(unk_4, parent->baseAddress);
|
||||
Declaration* decl = parent->GetDeclaration(unk_4_Offset);
|
||||
|
||||
if (decl == nullptr)
|
||||
{
|
||||
unk_4_Str =
|
||||
|
@ -338,30 +353,15 @@ std::string Struct_800A5E28::GetSourceTypeName()
|
|||
return "Struct_800A5E28";
|
||||
}
|
||||
|
||||
ZLimb::ZLimb(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData, int nRawDataIndex,
|
||||
ZFile* nParent)
|
||||
ZLimb::ZLimb(ZFile* nParent) : ZResource(nParent)
|
||||
{
|
||||
rawData.assign(nRawData.begin(), nRawData.end());
|
||||
rawDataIndex = nRawDataIndex;
|
||||
parent = nParent;
|
||||
|
||||
segAddress = nRawDataIndex;
|
||||
|
||||
ParseXML(reader);
|
||||
ParseRawData();
|
||||
|
||||
if (type == ZLimbType::Skin)
|
||||
{
|
||||
if (skinSegmentType == ZLimbSkinType::SkinType_4 && skinSegment != 0)
|
||||
{
|
||||
uint32_t skinSegmentOffset = Seg2Filespace(skinSegment, parent->baseAddress);
|
||||
segmentStruct = Struct_800A5E28(parent, rawData, skinSegmentOffset);
|
||||
}
|
||||
}
|
||||
dListPtr = 0;
|
||||
dList2Ptr = 0;
|
||||
}
|
||||
|
||||
ZLimb::ZLimb(ZLimbType limbType, const std::string& prefix, const std::vector<uint8_t>& nRawData,
|
||||
int nRawDataIndex, ZFile* nParent)
|
||||
uint32_t nRawDataIndex, ZFile* nParent)
|
||||
: ZResource(nParent)
|
||||
{
|
||||
rawData.assign(nRawData.begin(), nRawData.end());
|
||||
rawDataIndex = nRawDataIndex;
|
||||
|
@ -380,11 +380,8 @@ void ZLimb::ParseXML(tinyxml2::XMLElement* reader)
|
|||
|
||||
// Reading from a <Skeleton/>
|
||||
const char* limbType = reader->Attribute("LimbType");
|
||||
if (limbType == nullptr)
|
||||
{
|
||||
// Reading from a <Limb/>
|
||||
if (limbType == nullptr) // Reading from a <Limb/>
|
||||
limbType = reader->Attribute("Type");
|
||||
}
|
||||
|
||||
if (limbType == nullptr)
|
||||
{
|
||||
|
@ -397,6 +394,7 @@ void ZLimb::ParseXML(tinyxml2::XMLElement* reader)
|
|||
else
|
||||
{
|
||||
string limbTypeStr(limbType);
|
||||
|
||||
if (limbTypeStr == "Standard")
|
||||
{
|
||||
type = ZLimbType::Standard;
|
||||
|
@ -449,28 +447,39 @@ void ZLimb::ParseRawData()
|
|||
dList2Ptr = BitConverter::ToUInt32BE(rawData, rawDataIndex + 12);
|
||||
case ZLimbType::Standard:
|
||||
dListPtr = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8);
|
||||
|
||||
break;
|
||||
case ZLimbType::Skin:
|
||||
skinSegmentType =
|
||||
static_cast<ZLimbSkinType>(BitConverter::ToInt32BE(rawData, rawDataIndex + 8));
|
||||
skinSegment = BitConverter::ToUInt32BE(rawData, rawDataIndex + 12);
|
||||
break;
|
||||
default:
|
||||
throw std::runtime_error("Invalid ZLimb type");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ZLimb* ZLimb::FromXML(tinyxml2::XMLElement* reader, vector<uint8_t> nRawData, int rawDataIndex,
|
||||
string nRelPath, ZFile* parent)
|
||||
void ZLimb::ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData,
|
||||
const uint32_t nRawDataIndex, const std::string& nRelPath)
|
||||
{
|
||||
ZLimb* limb = new ZLimb(reader, nRawData, rawDataIndex, parent);
|
||||
limb->relativePath = std::move(nRelPath);
|
||||
ZResource::ExtractFromXML(reader, nRawData, nRawDataIndex, nRelPath);
|
||||
segAddress = nRawDataIndex;
|
||||
|
||||
limb->parent->AddDeclaration(limb->GetFileAddress(), DeclarationAlignment::None,
|
||||
limb->GetRawDataSize(), limb->GetSourceTypeName(), limb->name, "");
|
||||
parent->AddDeclaration(GetFileAddress(), DeclarationAlignment::None, GetRawDataSize(),
|
||||
GetSourceTypeName(), name, "");
|
||||
|
||||
return limb;
|
||||
if (type == ZLimbType::Skin)
|
||||
{
|
||||
if (skinSegmentType == ZLimbSkinType::SkinType_4 && skinSegment != 0)
|
||||
{
|
||||
uint32_t skinSegmentOffset = Seg2Filespace(skinSegment, parent->baseAddress);
|
||||
segmentStruct = Struct_800A5E28(parent, rawData, skinSegmentOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int ZLimb::GetRawDataSize()
|
||||
size_t ZLimb::GetRawDataSize()
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
|
@ -481,6 +490,7 @@ int ZLimb::GetRawDataSize()
|
|||
case ZLimbType::Skin:
|
||||
return 0x10;
|
||||
}
|
||||
|
||||
return 0x0C;
|
||||
}
|
||||
|
||||
|
@ -523,15 +533,12 @@ string ZLimb::GetSourceOutputCode(const std::string& prefix)
|
|||
}
|
||||
|
||||
Declaration* decl = parent->GetDeclaration(GetFileAddress());
|
||||
|
||||
if (decl == nullptr)
|
||||
{
|
||||
parent->AddDeclaration(GetFileAddress(), DeclarationAlignment::None, GetRawDataSize(),
|
||||
GetSourceTypeName(), name, entryStr);
|
||||
}
|
||||
else
|
||||
{
|
||||
decl->text = entryStr;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
@ -551,6 +558,11 @@ ZLimbType ZLimb::GetLimbType()
|
|||
return type;
|
||||
}
|
||||
|
||||
void ZLimb::SetLimbType(ZLimbType value)
|
||||
{
|
||||
type = value;
|
||||
}
|
||||
|
||||
const char* ZLimb::GetSourceTypeName(ZLimbType limbType)
|
||||
{
|
||||
switch (limbType)
|
||||
|
@ -563,9 +575,10 @@ const char* ZLimb::GetSourceTypeName(ZLimbType limbType)
|
|||
return "SkinLimb";
|
||||
case ZLimbType::Curve:
|
||||
return "SkelCurveLimb";
|
||||
}
|
||||
default:
|
||||
return "StandardLimb";
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t ZLimb::GetFileAddress()
|
||||
{
|
||||
|
@ -576,12 +589,9 @@ std::string ZLimb::GetLimbDListSourceOutputCode(const std::string& prefix,
|
|||
const std::string& limbPrefix, segptr_t dListPtr)
|
||||
{
|
||||
if (dListPtr == 0)
|
||||
{
|
||||
return "NULL";
|
||||
}
|
||||
|
||||
uint32_t dListOffset = Seg2Filespace(dListPtr, parent->baseAddress);
|
||||
|
||||
string dListStr;
|
||||
Declaration* decl = parent->GetDeclaration(dListOffset);
|
||||
if (decl == nullptr)
|
||||
|
@ -589,13 +599,13 @@ std::string ZLimb::GetLimbDListSourceOutputCode(const std::string& prefix,
|
|||
dListStr = StringHelper::Sprintf("%s%sLimbDL_%06X", prefix.c_str(), limbPrefix.c_str(),
|
||||
dListOffset);
|
||||
|
||||
int dlistLength = ZDisplayList::GetDListLength(
|
||||
int32_t dlistLength = ZDisplayList::GetDListLength(
|
||||
rawData, dListOffset,
|
||||
Globals::Instance->game == ZGame::OOT_SW97 ? DListType::F3DEX : DListType::F3DZEX);
|
||||
auto& dList = dLists.emplace_back(rawData, dListOffset, dlistLength);
|
||||
dList.parent = parent;
|
||||
dList.SetName(dListStr);
|
||||
dList.GetSourceOutputCode(prefix);
|
||||
auto dList = new ZDisplayList(rawData, dListOffset, dlistLength, parent);
|
||||
dLists.push_back(dList);
|
||||
dList->SetName(dListStr);
|
||||
dList->GetSourceOutputCode(prefix);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -611,9 +621,7 @@ std::string ZLimb::GetSourceOutputCodeSkin_Type_4(const std::string& prefix)
|
|||
assert(skinSegmentType == ZLimbSkinType::SkinType_4);
|
||||
|
||||
if (skinSegment == 0)
|
||||
{
|
||||
return "NULL";
|
||||
}
|
||||
|
||||
uint32_t skinSegmentOffset = Seg2Filespace(skinSegment, parent->baseAddress);
|
||||
|
||||
|
@ -661,6 +669,7 @@ std::string ZLimb::GetSourceOutputCodeSkin(const std::string& prefix)
|
|||
"ZLimb::GetSourceOutputCodeSkinType: Error in '%s'.\n\t Unknown segment type "
|
||||
"for SkinLimb: '%i'. \n\tPlease report this.\n",
|
||||
name.c_str(), static_cast<int32_t>(skinSegmentType));
|
||||
break;
|
||||
case ZLimbSkinType::SkinType_0:
|
||||
case ZLimbSkinType::SkinType_5:
|
||||
fprintf(stderr,
|
||||
|
|
|
@ -123,17 +123,10 @@ protected:
|
|||
segptr_t segAddress;
|
||||
ZLimbType type = ZLimbType::Standard;
|
||||
|
||||
int16_t transX, transY, transZ;
|
||||
uint8_t childIndex, siblingIndex;
|
||||
segptr_t dListPtr = 0;
|
||||
|
||||
std::vector<ZDisplayList> dLists;
|
||||
|
||||
segptr_t dList2Ptr = 0; // LOD and Curve only
|
||||
|
||||
ZLimbSkinType skinSegmentType = ZLimbSkinType::SkinType_0; // Skin only
|
||||
segptr_t skinSegment = 0; // Skin only
|
||||
Struct_800A5E28 segmentStruct; // Skin only
|
||||
segptr_t dList2Ptr; // LOD and Curve Only
|
||||
|
||||
std::string GetLimbDListSourceOutputCode(const std::string& prefix,
|
||||
const std::string& limbPrefix, segptr_t dListPtr);
|
||||
|
@ -142,22 +135,32 @@ protected:
|
|||
std::string GetSourceOutputCodeSkin_Type_4(const std::string& prefix);
|
||||
|
||||
public:
|
||||
ZLimb(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData, int nRawDataIndex,
|
||||
ZFile* nParent);
|
||||
ZDisplayList* dList;
|
||||
segptr_t dListPtr = 0;
|
||||
segptr_t farDListPtr = 0; // LOD only
|
||||
int16_t transX, transY, transZ;
|
||||
uint8_t childIndex, siblingIndex;
|
||||
std::vector<ZDisplayList*> dLists;
|
||||
std::vector<ZLimb*> children;
|
||||
|
||||
ZLimb(ZFile* nParent);
|
||||
ZLimb(ZLimbType limbType, const std::string& prefix, const std::vector<uint8_t>& nRawData,
|
||||
int nRawDataIndex, ZFile* nParent);
|
||||
uint32_t nRawDataIndex, ZFile* nParent);
|
||||
~ZLimb();
|
||||
|
||||
void ParseXML(tinyxml2::XMLElement* reader) override;
|
||||
void ParseRawData() override;
|
||||
static ZLimb* FromXML(tinyxml2::XMLElement* reader, std::vector<uint8_t> nRawData,
|
||||
int rawDataIndex, std::string nRelPath, ZFile* parent);
|
||||
int GetRawDataSize() override;
|
||||
void ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData,
|
||||
const uint32_t nRawDataIndex, const std::string& nRelPath) override;
|
||||
size_t GetRawDataSize() override;
|
||||
std::string GetSourceOutputCode(const std::string& prefix) override;
|
||||
std::string GetSourceTypeName() override;
|
||||
ZResourceType GetResourceType() override;
|
||||
|
||||
ZLimbType GetLimbType();
|
||||
void SetLimbType(ZLimbType value);
|
||||
static const char* GetSourceTypeName(ZLimbType limbType);
|
||||
|
||||
uint32_t GetFileAddress();
|
||||
void SetFileAddress(uint32_t nAddress);
|
||||
};
|
||||
|
|
97
tools/ZAPD/ZAPD/ZMtx.cpp
Normal file
97
tools/ZAPD/ZAPD/ZMtx.cpp
Normal file
|
@ -0,0 +1,97 @@
|
|||
#include "ZMtx.h"
|
||||
#include "BitConverter.h"
|
||||
#include "StringHelper.h"
|
||||
#include "ZFile.h"
|
||||
|
||||
REGISTER_ZFILENODE(Mtx, ZMtx);
|
||||
|
||||
ZMtx::ZMtx(ZFile* nParent) : ZResource(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
ZMtx::ZMtx(const std::string& prefix, const std::vector<uint8_t>& nRawData, uint32_t nRawDataIndex,
|
||||
ZFile* nParent)
|
||||
: ZResource(nParent)
|
||||
{
|
||||
name = GetDefaultName(prefix.c_str(), rawDataIndex);
|
||||
ExtractFromFile(nRawData, nRawDataIndex, "");
|
||||
DeclareVar("", "");
|
||||
}
|
||||
|
||||
void ZMtx::ParseRawData()
|
||||
{
|
||||
ZResource::ParseRawData();
|
||||
|
||||
for (size_t i = 0; i < 4; ++i)
|
||||
for (size_t j = 0; j < 4; ++j)
|
||||
mtx[i][j] = BitConverter::ToInt32BE(rawData, rawDataIndex + (i * 4 + j) * 4);
|
||||
}
|
||||
|
||||
void ZMtx::ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData,
|
||||
uint32_t nRawDataIndex, const std::string& nRelPath)
|
||||
{
|
||||
ZResource::ExtractFromXML(reader, nRawData, nRawDataIndex, nRelPath);
|
||||
DeclareVar("", "");
|
||||
}
|
||||
|
||||
size_t ZMtx::GetRawDataSize()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
void ZMtx::DeclareVar(const std::string& prefix, const std::string& bodyStr)
|
||||
{
|
||||
std::string auxName = name;
|
||||
|
||||
if (name == "")
|
||||
auxName = GetDefaultName(prefix, rawDataIndex);
|
||||
|
||||
parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align8, GetRawDataSize(),
|
||||
GetSourceTypeName(), auxName, bodyStr);
|
||||
}
|
||||
|
||||
std::string ZMtx::GetBodySourceCode()
|
||||
{
|
||||
std::string bodyStr = "\n";
|
||||
|
||||
for (const auto& row : mtx)
|
||||
{
|
||||
bodyStr += " ";
|
||||
|
||||
for (int32_t val : row)
|
||||
bodyStr += StringHelper::Sprintf("%-11i, ", val);
|
||||
|
||||
bodyStr += "\n";
|
||||
}
|
||||
|
||||
return bodyStr;
|
||||
}
|
||||
|
||||
std::string ZMtx::GetSourceOutputCode(const std::string& prefix)
|
||||
{
|
||||
std::string bodyStr = GetBodySourceCode();
|
||||
|
||||
Declaration* decl = parent->GetDeclaration(rawDataIndex);
|
||||
|
||||
if (decl == nullptr)
|
||||
DeclareVar(prefix, bodyStr);
|
||||
else
|
||||
decl->text = bodyStr;
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string ZMtx::GetDefaultName(const std::string& prefix, uint32_t address)
|
||||
{
|
||||
return StringHelper::Sprintf("%sMtx_%06X", prefix.c_str(), address);
|
||||
}
|
||||
|
||||
std::string ZMtx::GetSourceTypeName()
|
||||
{
|
||||
return "Mtx";
|
||||
}
|
||||
|
||||
ZResourceType ZMtx::GetResourceType()
|
||||
{
|
||||
return ZResourceType::Mtx;
|
||||
}
|
31
tools/ZAPD/ZAPD/ZMtx.h
Normal file
31
tools/ZAPD/ZAPD/ZMtx.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include "ZResource.h"
|
||||
|
||||
class ZMtx : public ZResource
|
||||
{
|
||||
protected:
|
||||
std::array<std::array<int32_t, 4>, 4> mtx;
|
||||
|
||||
public:
|
||||
// ZMtx() = default;
|
||||
ZMtx(ZFile* nParent);
|
||||
ZMtx(const std::string& prefix, const std::vector<uint8_t>& nRawData, uint32_t nRawDataIndex,
|
||||
ZFile* nParent);
|
||||
void ParseRawData() override;
|
||||
void ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData,
|
||||
uint32_t nRawDataIndex, const std::string& nRelPath) override;
|
||||
|
||||
size_t GetRawDataSize() override;
|
||||
|
||||
void DeclareVar(const std::string& prefix, const std::string& bodyStr);
|
||||
|
||||
std::string GetBodySourceCode();
|
||||
std::string GetSourceOutputCode(const std::string& prefix) override;
|
||||
static std::string GetDefaultName(const std::string& prefix, uint32_t address);
|
||||
|
||||
std::string GetSourceTypeName() override;
|
||||
ZResourceType GetResourceType() override;
|
||||
};
|
|
@ -1,10 +1,13 @@
|
|||
#include "ZResource.h"
|
||||
|
||||
#include <regex>
|
||||
#include "StringHelper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
ZResource::ZResource()
|
||||
ZResource::ZResource(ZFile* nParent)
|
||||
{
|
||||
parent = nullptr;
|
||||
parent = nParent;
|
||||
name = "";
|
||||
outName = "";
|
||||
relativePath = "";
|
||||
|
@ -14,10 +17,47 @@ ZResource::ZResource()
|
|||
outputDeclaration = true;
|
||||
}
|
||||
|
||||
void ZResource::ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData,
|
||||
const uint32_t nRawDataIndex, const std::string& nRelPath)
|
||||
{
|
||||
rawData = nRawData;
|
||||
rawDataIndex = nRawDataIndex;
|
||||
relativePath = nRelPath;
|
||||
|
||||
if (reader != nullptr)
|
||||
ParseXML(reader);
|
||||
|
||||
ParseRawData();
|
||||
}
|
||||
|
||||
void ZResource::ExtractFromFile(const std::vector<uint8_t>& nRawData, uint32_t nRawDataIndex,
|
||||
const std::string& nRelPath)
|
||||
{
|
||||
rawData = nRawData;
|
||||
rawDataIndex = nRawDataIndex;
|
||||
relativePath = nRelPath;
|
||||
|
||||
ParseRawData();
|
||||
}
|
||||
|
||||
void ZResource::ParseXML(tinyxml2::XMLElement* reader)
|
||||
{
|
||||
if (reader != nullptr)
|
||||
{
|
||||
if (reader->Attribute("Name") != nullptr)
|
||||
{
|
||||
name = reader->Attribute("Name");
|
||||
static std::regex r("[a-zA-Z_]+[a-zA-Z0-9_]*",
|
||||
std::regex::icase | std::regex::optimize);
|
||||
|
||||
if (!std::regex_match(name, r))
|
||||
{
|
||||
throw std::domain_error(
|
||||
StringHelper::Sprintf("ZResource::ParseXML: Fatal error in '%s'.\n\t Resource "
|
||||
"with invalid 'Name' attribute.\n",
|
||||
name.c_str()));
|
||||
}
|
||||
}
|
||||
else
|
||||
name = "";
|
||||
|
||||
|
@ -25,6 +65,20 @@ void ZResource::ParseXML(tinyxml2::XMLElement* reader)
|
|||
outName = reader->Attribute("OutName");
|
||||
else
|
||||
outName = name;
|
||||
|
||||
if (reader->Attribute("Custom") != nullptr)
|
||||
isCustomAsset = true;
|
||||
else
|
||||
isCustomAsset = false;
|
||||
|
||||
if (!canHaveInner && !reader->NoChildren())
|
||||
{
|
||||
throw std::runtime_error(
|
||||
StringHelper::Sprintf("ZResource::ParseXML: Fatal error in '%s'.\n\t Resource '%s' "
|
||||
"with inner element/child detected.\n",
|
||||
name.c_str(), reader->Name()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ZResource::Save(const std::string& outFolder)
|
||||
|
@ -45,6 +99,11 @@ std::string ZResource::GetOutName()
|
|||
return outName;
|
||||
}
|
||||
|
||||
void ZResource::SetOutName(std::string nName)
|
||||
{
|
||||
outName = nName;
|
||||
}
|
||||
|
||||
void ZResource::SetName(string nName)
|
||||
{
|
||||
name = std::move(nName);
|
||||
|
@ -75,17 +134,22 @@ vector<uint8_t> ZResource::GetRawData()
|
|||
return rawData;
|
||||
}
|
||||
|
||||
int ZResource::GetRawDataIndex()
|
||||
void ZResource::SetRawData(std::vector<uint8_t> nData)
|
||||
{
|
||||
rawData = nData;
|
||||
}
|
||||
|
||||
uint32_t ZResource::GetRawDataIndex()
|
||||
{
|
||||
return rawDataIndex;
|
||||
}
|
||||
|
||||
int ZResource::GetRawDataSize()
|
||||
size_t ZResource::GetRawDataSize()
|
||||
{
|
||||
return rawData.size();
|
||||
}
|
||||
|
||||
void ZResource::SetRawDataIndex(int value)
|
||||
void ZResource::SetRawDataIndex(uint32_t value)
|
||||
{
|
||||
rawDataIndex = value;
|
||||
}
|
||||
|
@ -110,7 +174,7 @@ void ZResource::GenerateHLIntermediette(HLFileIntermediette& hlFile)
|
|||
|
||||
std::string ZResource::GetSourceTypeName()
|
||||
{
|
||||
return "";
|
||||
return "u8";
|
||||
}
|
||||
|
||||
ZResourceType ZResource::GetResourceType()
|
||||
|
@ -132,3 +196,7 @@ uint32_t Seg2Filespace(segptr_t segmentedAddress, uint32_t parentBaseAddress)
|
|||
|
||||
return currentPtr;
|
||||
}
|
||||
|
||||
ZResource::~ZResource()
|
||||
{
|
||||
}
|
|
@ -31,7 +31,6 @@ enum class ZResourceType
|
|||
Texture,
|
||||
DisplayList,
|
||||
Room,
|
||||
Overlay,
|
||||
Animation,
|
||||
Cutscene,
|
||||
Blob,
|
||||
|
@ -42,6 +41,8 @@ enum class ZResourceType
|
|||
Vertex,
|
||||
CollisionHeader,
|
||||
Symbol,
|
||||
Mtx,
|
||||
Background,
|
||||
};
|
||||
|
||||
class ZResource
|
||||
|
@ -49,38 +50,57 @@ class ZResource
|
|||
public:
|
||||
ZFile* parent;
|
||||
bool outputDeclaration;
|
||||
uint32_t hash;
|
||||
|
||||
ZResource();
|
||||
ZResource(ZFile* nParent);
|
||||
virtual ~ZResource();
|
||||
|
||||
// Parsing from File
|
||||
virtual void ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData,
|
||||
const uint32_t nRawDataIndex,
|
||||
const std::string& nRelPath); // Extract Mode
|
||||
virtual void ExtractFromFile(const std::vector<uint8_t>& nRawData, uint32_t nRawDataIndex,
|
||||
const std::string& nRelPath);
|
||||
|
||||
// Misc
|
||||
virtual void ParseXML(tinyxml2::XMLElement* reader);
|
||||
virtual void Save(const std::string& outFolder);
|
||||
virtual void PreGenSourceFiles();
|
||||
std::string GetName();
|
||||
std::string GetOutName();
|
||||
void SetName(std::string nName);
|
||||
std::string GetRelativePath();
|
||||
virtual std::vector<uint8_t> GetRawData();
|
||||
virtual bool IsExternalResource();
|
||||
virtual bool DoesSupportArray(); // Can this type be wrapped in an <Array> node?
|
||||
virtual std::string GetExternalExtension();
|
||||
virtual int GetRawDataIndex();
|
||||
virtual int GetRawDataSize();
|
||||
virtual void SetRawDataIndex(int value);
|
||||
virtual void ParseRawData();
|
||||
virtual std::string GetSourceOutputCode(const std::string& prefix);
|
||||
virtual std::string GetSourceOutputHeader(const std::string& prefix);
|
||||
virtual void ParseRawData();
|
||||
virtual void PreGenSourceFiles();
|
||||
virtual void GenerateHLIntermediette(HLFileIntermediette& hlFile);
|
||||
virtual void CalcHash();
|
||||
virtual void Save(const std::string& outFolder);
|
||||
|
||||
// Properties
|
||||
virtual bool IsExternalResource();
|
||||
virtual bool DoesSupportArray(); // Can this type be wrapped in an <Array> node?
|
||||
virtual std::string GetSourceTypeName();
|
||||
virtual ZResourceType GetResourceType();
|
||||
virtual void CalcHash();
|
||||
virtual std::string GetExternalExtension();
|
||||
|
||||
// Getters/Setters
|
||||
std::string GetName();
|
||||
void SetName(std::string nName);
|
||||
std::string GetOutName();
|
||||
void SetOutName(std::string nName);
|
||||
std::string GetRelativePath();
|
||||
virtual uint32_t GetRawDataIndex();
|
||||
virtual void SetRawDataIndex(uint32_t value);
|
||||
virtual size_t GetRawDataSize();
|
||||
virtual std::vector<uint8_t> GetRawData();
|
||||
virtual void SetRawData(std::vector<uint8_t> nData);
|
||||
|
||||
protected:
|
||||
std::string name;
|
||||
std::string outName;
|
||||
std::string relativePath;
|
||||
std::vector<uint8_t> rawData;
|
||||
int rawDataIndex;
|
||||
uint32_t rawDataIndex;
|
||||
std::string sourceOutput;
|
||||
uint64_t hash;
|
||||
bool canHaveInner = false; // Can this type have an inner node?
|
||||
bool isCustomAsset; // If set to true, create a reference for the asset in the file, but don't
|
||||
// actually try to extract it from the file
|
||||
};
|
||||
|
||||
enum class DeclarationAlignment
|
||||
|
@ -104,7 +124,7 @@ class Declaration
|
|||
public:
|
||||
DeclarationAlignment alignment;
|
||||
DeclarationPadding padding;
|
||||
uint32_t size;
|
||||
size_t size;
|
||||
std::string preText;
|
||||
std::string text;
|
||||
std::string rightText;
|
||||
|
@ -114,25 +134,47 @@ public:
|
|||
std::string varType;
|
||||
std::string varName;
|
||||
std::string includePath;
|
||||
bool isExternal;
|
||||
bool isArray;
|
||||
int arrayItemCnt;
|
||||
size_t arrayItemCnt;
|
||||
std::vector<uint32_t> references;
|
||||
bool isUnaccounted = false;
|
||||
|
||||
Declaration(DeclarationAlignment nAlignment, uint32_t nSize, std::string nVarType,
|
||||
Declaration(DeclarationAlignment nAlignment, size_t nSize, std::string nVarType,
|
||||
std::string nVarName, bool nIsArray, std::string nText);
|
||||
Declaration(DeclarationAlignment nAlignment, DeclarationPadding nPadding, uint32_t nSize,
|
||||
Declaration(DeclarationAlignment nAlignment, DeclarationPadding nPadding, size_t nSize,
|
||||
std::string nVarType, std::string nVarName, bool nIsArray, std::string nText);
|
||||
Declaration(DeclarationAlignment nAlignment, uint32_t nSize, std::string nVarType,
|
||||
std::string nVarName, bool nIsArray, int nArrayItemCnt, std::string nText);
|
||||
Declaration(DeclarationAlignment nAlignment, DeclarationPadding nPadding, uint32_t nSize,
|
||||
std::string nVarType, std::string nVarName, bool nIsArray, int nArrayItemCnt,
|
||||
Declaration(DeclarationAlignment nAlignment, size_t nSize, std::string nVarType,
|
||||
std::string nVarName, bool nIsArray, size_t nArrayItemCnt, std::string nText);
|
||||
Declaration(DeclarationAlignment nAlignment, size_t nSize, std::string nVarType,
|
||||
std::string nVarName, bool nIsArray, size_t nArrayItemCnt, std::string nText,
|
||||
bool nIsExternal);
|
||||
Declaration(DeclarationAlignment nAlignment, DeclarationPadding nPadding, size_t nSize,
|
||||
std::string nVarType, std::string nVarName, bool nIsArray, size_t nArrayItemCnt,
|
||||
std::string nText);
|
||||
Declaration(std::string nIncludePath, uint32_t nSize, std::string nVarType,
|
||||
std::string nVarName);
|
||||
Declaration(std::string nIncludePath, size_t nSize, std::string nVarType, std::string nVarName);
|
||||
|
||||
protected:
|
||||
Declaration(DeclarationAlignment nAlignment, DeclarationPadding nPadding, uint32_t nSize,
|
||||
Declaration(DeclarationAlignment nAlignment, DeclarationPadding nPadding, size_t nSize,
|
||||
std::string nText);
|
||||
};
|
||||
|
||||
uint32_t Seg2Filespace(segptr_t segmentedAddress, uint32_t parentBaseAddress);
|
||||
|
||||
typedef ZResource*(ZResourceFactoryFunc)();
|
||||
|
||||
#define REGISTER_ZFILENODE(nodeName, zResClass) \
|
||||
static ZResource* ZResourceFactory_##zResClass_##nodeName() \
|
||||
{ \
|
||||
return static_cast<ZResource*>(new zResClass(nullptr)); \
|
||||
} \
|
||||
\
|
||||
class ZRes_##nodeName \
|
||||
{ \
|
||||
public: \
|
||||
ZRes_##nodeName() \
|
||||
{ \
|
||||
ZFile::RegisterNode(#nodeName, &ZResourceFactory_##zResClass_##nodeName); \
|
||||
} \
|
||||
}; \
|
||||
static ZRes_##nodeName inst_ZRes_##nodeName;
|
||||
|
|
|
@ -1,478 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
static const std::string ActorList[] = {
|
||||
/* 0x0000 */ "ACTOR_PLAYER",
|
||||
/* 0x0001 */ "ACTOR_UNSET_1",
|
||||
/* 0x0002 */ "ACTOR_EN_TEST",
|
||||
/* 0x0003 */ "ACTOR_UNSET_3",
|
||||
/* 0x0004 */ "ACTOR_EN_GIRLA",
|
||||
/* 0x0005 */ "ACTOR_UNSET_5",
|
||||
/* 0x0006 */ "ACTOR_UNSET_6",
|
||||
/* 0x0007 */ "ACTOR_EN_PART",
|
||||
/* 0x0008 */ "ACTOR_EN_LIGHT",
|
||||
/* 0x0009 */ "ACTOR_EN_DOOR",
|
||||
/* 0x000A */ "ACTOR_EN_BOX", // Treasure Chest
|
||||
/* 0x000B */ "ACTOR_BG_DY_YOSEIZO",
|
||||
/* 0x000C */ "ACTOR_BG_HIDAN_FIREWALL",
|
||||
/* 0x000D */ "ACTOR_EN_POH",
|
||||
/* 0x000E */ "ACTOR_EN_OKUTA",
|
||||
/* 0x000F */ "ACTOR_BG_YDAN_SP",
|
||||
/* 0x0010 */ "ACTOR_EN_BOM",
|
||||
/* 0x0011 */ "ACTOR_EN_WALLMAS",
|
||||
/* 0x0012 */ "ACTOR_EN_DODONGO",
|
||||
/* 0x0013 */ "ACTOR_EN_FIREFLY",
|
||||
/* 0x0014 */ "ACTOR_EN_HORSE",
|
||||
/* 0x0015 */ "ACTOR_EN_ITEM00",
|
||||
/* 0x0016 */ "ACTOR_EN_ARROW",
|
||||
/* 0x0017 */ "ACTOR_UNSET_17",
|
||||
/* 0x0018 */ "ACTOR_EN_ELF",
|
||||
/* 0x0019 */ "ACTOR_EN_NIW",
|
||||
/* 0x001A */ "ACTOR_UNSET_1A",
|
||||
/* 0x001B */ "ACTOR_EN_TITE",
|
||||
/* 0x001C */ "ACTOR_EN_REEBA",
|
||||
/* 0x001D */ "ACTOR_EN_PEEHAT",
|
||||
/* 0x001E */ "ACTOR_EN_BUTTE",
|
||||
/* 0x001F */ "ACTOR_UNSET_1F",
|
||||
/* 0x0020 */ "ACTOR_EN_INSECT",
|
||||
/* 0x0021 */ "ACTOR_EN_FISH",
|
||||
/* 0x0022 */ "ACTOR_UNSET_22",
|
||||
/* 0x0023 */ "ACTOR_EN_HOLL",
|
||||
/* 0x0024 */ "ACTOR_EN_SCENE_CHANGE",
|
||||
/* 0x0025 */ "ACTOR_EN_ZF",
|
||||
/* 0x0026 */ "ACTOR_EN_HATA",
|
||||
/* 0x0027 */ "ACTOR_BOSS_DODONGO",
|
||||
/* 0x0028 */ "ACTOR_BOSS_GOMA",
|
||||
/* 0x0029 */ "ACTOR_EN_ZL1",
|
||||
/* 0x002A */ "ACTOR_EN_VIEWER",
|
||||
/* 0x002B */ "ACTOR_EN_GOMA",
|
||||
/* 0x002C */ "ACTOR_BG_PUSHBOX",
|
||||
/* 0x002D */ "ACTOR_EN_BUBBLE",
|
||||
/* 0x002E */ "ACTOR_DOOR_SHUTTER",
|
||||
/* 0x002F */ "ACTOR_EN_DODOJR",
|
||||
/* 0x0030 */ "ACTOR_EN_BDFIRE",
|
||||
/* 0x0031 */ "ACTOR_UNSET_31",
|
||||
/* 0x0032 */ "ACTOR_EN_BOOM",
|
||||
/* 0x0033 */ "ACTOR_EN_TORCH2",
|
||||
/* 0x0034 */ "ACTOR_EN_BILI",
|
||||
/* 0x0035 */ "ACTOR_EN_TP",
|
||||
/* 0x0036 */ "ACTOR_UNSET_36",
|
||||
/* 0x0037 */ "ACTOR_EN_ST",
|
||||
/* 0x0038 */ "ACTOR_EN_BW",
|
||||
/* 0x0039 */ "ACTOR_EN_A_OBJ",
|
||||
/* 0x003A */ "ACTOR_EN_EIYER",
|
||||
/* 0x003B */ "ACTOR_EN_RIVER_SOUND",
|
||||
/* 0x003C */ "ACTOR_EN_HORSE_NORMAL",
|
||||
/* 0x003D */ "ACTOR_EN_OSSAN",
|
||||
/* 0x003E */ "ACTOR_BG_TREEMOUTH",
|
||||
/* 0x003F */ "ACTOR_BG_DODOAGO",
|
||||
/* 0x0040 */ "ACTOR_BG_HIDAN_DALM",
|
||||
/* 0x0041 */ "ACTOR_BG_HIDAN_HROCK",
|
||||
/* 0x0042 */ "ACTOR_EN_HORSE_GANON",
|
||||
/* 0x0043 */ "ACTOR_BG_HIDAN_ROCK",
|
||||
/* 0x0044 */ "ACTOR_BG_HIDAN_RSEKIZOU",
|
||||
/* 0x0045 */ "ACTOR_BG_HIDAN_SEKIZOU",
|
||||
/* 0x0046 */ "ACTOR_BG_HIDAN_SIMA",
|
||||
/* 0x0047 */ "ACTOR_BG_HIDAN_SYOKU",
|
||||
/* 0x0048 */ "ACTOR_EN_XC",
|
||||
/* 0x0049 */ "ACTOR_BG_HIDAN_CURTAIN",
|
||||
/* 0x004A */ "ACTOR_BG_SPOT00_HANEBASI",
|
||||
/* 0x004B */ "ACTOR_EN_MB",
|
||||
/* 0x004C */ "ACTOR_EN_BOMBF",
|
||||
/* 0x004D */ "ACTOR_EN_ZL2",
|
||||
/* 0x004E */ "ACTOR_BG_HIDAN_FSLIFT",
|
||||
/* 0x004F */ "ACTOR_EN_OE2",
|
||||
/* 0x0050 */ "ACTOR_BG_YDAN_HASI",
|
||||
/* 0x0051 */ "ACTOR_BG_YDAN_MARUTA",
|
||||
/* 0x0052 */ "ACTOR_BOSS_GANONDROF",
|
||||
/* 0x0053 */ "ACTOR_UNSET_53",
|
||||
/* 0x0054 */ "ACTOR_EN_AM",
|
||||
/* 0x0055 */ "ACTOR_EN_DEKUBABA",
|
||||
/* 0x0056 */ "ACTOR_EN_M_FIRE1",
|
||||
/* 0x0057 */ "ACTOR_EN_M_THUNDER",
|
||||
/* 0x0058 */ "ACTOR_BG_DDAN_JD",
|
||||
/* 0x0059 */ "ACTOR_BG_BREAKWALL",
|
||||
/* 0x005A */ "ACTOR_EN_JJ",
|
||||
/* 0x005B */ "ACTOR_EN_HORSE_ZELDA",
|
||||
/* 0x005C */ "ACTOR_BG_DDAN_KD",
|
||||
/* 0x005D */ "ACTOR_DOOR_WARP1",
|
||||
/* 0x005E */ "ACTOR_OBJ_SYOKUDAI",
|
||||
/* 0x005F */ "ACTOR_ITEM_B_HEART",
|
||||
/* 0x0060 */ "ACTOR_EN_DEKUNUTS",
|
||||
/* 0x0061 */ "ACTOR_BG_MENKURI_KAITEN",
|
||||
/* 0x0062 */ "ACTOR_BG_MENKURI_EYE",
|
||||
/* 0x0063 */ "ACTOR_EN_VALI",
|
||||
/* 0x0064 */ "ACTOR_BG_MIZU_MOVEBG",
|
||||
/* 0x0065 */ "ACTOR_BG_MIZU_WATER",
|
||||
/* 0x0066 */ "ACTOR_ARMS_HOOK",
|
||||
/* 0x0067 */ "ACTOR_EN_FHG",
|
||||
/* 0x0068 */ "ACTOR_BG_MORI_HINERI",
|
||||
/* 0x0069 */ "ACTOR_EN_BB",
|
||||
/* 0x006A */ "ACTOR_BG_TOKI_HIKARI",
|
||||
/* 0x006B */ "ACTOR_EN_YUKABYUN",
|
||||
/* 0x006C */ "ACTOR_BG_TOKI_SWD",
|
||||
/* 0x006D */ "ACTOR_EN_FHG_FIRE",
|
||||
/* 0x006E */ "ACTOR_BG_MJIN",
|
||||
/* 0x006F */ "ACTOR_BG_HIDAN_KOUSI",
|
||||
/* 0x0070 */ "ACTOR_DOOR_TOKI",
|
||||
/* 0x0071 */ "ACTOR_BG_HIDAN_HAMSTEP",
|
||||
/* 0x0072 */ "ACTOR_EN_BIRD",
|
||||
/* 0x0073 */ "ACTOR_UNSET_73",
|
||||
/* 0x0074 */ "ACTOR_UNSET_74",
|
||||
/* 0x0075 */ "ACTOR_UNSET_75",
|
||||
/* 0x0076 */ "ACTOR_UNSET_76",
|
||||
/* 0x0077 */ "ACTOR_EN_WOOD02",
|
||||
/* 0x0078 */ "ACTOR_UNSET_78",
|
||||
/* 0x0079 */ "ACTOR_UNSET_79",
|
||||
/* 0x007A */ "ACTOR_UNSET_7A",
|
||||
/* 0x007B */ "ACTOR_UNSET_7B",
|
||||
/* 0x007C */ "ACTOR_EN_LIGHTBOX",
|
||||
/* 0x007D */ "ACTOR_EN_PU_BOX",
|
||||
/* 0x007E */ "ACTOR_UNSET_7E",
|
||||
/* 0x007F */ "ACTOR_UNSET_7F",
|
||||
/* 0x0080 */ "ACTOR_EN_TRAP",
|
||||
/* 0x0081 */ "ACTOR_EN_AROW_TRAP",
|
||||
/* 0x0082 */ "ACTOR_EN_VASE",
|
||||
/* 0x0083 */ "ACTOR_UNSET_83",
|
||||
/* 0x0084 */ "ACTOR_EN_TA",
|
||||
/* 0x0085 */ "ACTOR_EN_TK",
|
||||
/* 0x0086 */ "ACTOR_BG_MORI_BIGST",
|
||||
/* 0x0087 */ "ACTOR_BG_MORI_ELEVATOR",
|
||||
/* 0x0088 */ "ACTOR_BG_MORI_KAITENKABE",
|
||||
/* 0x0089 */ "ACTOR_BG_MORI_RAKKATENJO",
|
||||
/* 0x008A */ "ACTOR_EN_VM",
|
||||
/* 0x008B */ "ACTOR_DEMO_EFFECT",
|
||||
/* 0x008C */ "ACTOR_DEMO_KANKYO",
|
||||
/* 0x008D */ "ACTOR_BG_HIDAN_FWBIG",
|
||||
/* 0x008E */ "ACTOR_EN_FLOORMAS",
|
||||
/* 0x008F */ "ACTOR_EN_HEISHI1",
|
||||
/* 0x0090 */ "ACTOR_EN_RD",
|
||||
/* 0x0091 */ "ACTOR_EN_PO_SISTERS",
|
||||
/* 0x0092 */ "ACTOR_BG_HEAVY_BLOCK",
|
||||
/* 0x0093 */ "ACTOR_BG_PO_EVENT",
|
||||
/* 0x0094 */ "ACTOR_OBJ_MURE",
|
||||
/* 0x0095 */ "ACTOR_EN_SW",
|
||||
/* 0x0096 */ "ACTOR_BOSS_FD",
|
||||
/* 0x0097 */ "ACTOR_OBJECT_KANKYO",
|
||||
/* 0x0098 */ "ACTOR_EN_DU",
|
||||
/* 0x0099 */ "ACTOR_EN_FD",
|
||||
/* 0x009A */ "ACTOR_EN_HORSE_LINK_CHILD",
|
||||
/* 0x009B */ "ACTOR_DOOR_ANA",
|
||||
/* 0x009C */ "ACTOR_BG_SPOT02_OBJECTS",
|
||||
/* 0x009D */ "ACTOR_BG_HAKA",
|
||||
/* 0x009E */ "ACTOR_MAGIC_WIND",
|
||||
/* 0x009F */ "ACTOR_MAGIC_FIRE",
|
||||
/* 0x00A0 */ "ACTOR_UNSET_A0",
|
||||
/* 0x00A1 */ "ACTOR_EN_RU1",
|
||||
/* 0x00A2 */ "ACTOR_BOSS_FD2",
|
||||
/* 0x00A3 */ "ACTOR_EN_FD_FIRE",
|
||||
/* 0x00A4 */ "ACTOR_EN_DH",
|
||||
/* 0x00A5 */ "ACTOR_EN_DHA",
|
||||
/* 0x00A6 */ "ACTOR_EN_RL",
|
||||
/* 0x00A7 */ "ACTOR_EN_ENCOUNT1",
|
||||
/* 0x00A8 */ "ACTOR_DEMO_DU",
|
||||
/* 0x00A9 */ "ACTOR_DEMO_IM",
|
||||
/* 0x00AA */ "ACTOR_DEMO_TRE_LGT",
|
||||
/* 0x00AB */ "ACTOR_EN_FW",
|
||||
/* 0x00AC */ "ACTOR_BG_VB_SIMA",
|
||||
/* 0x00AD */ "ACTOR_EN_VB_BALL",
|
||||
/* 0x00AE */ "ACTOR_BG_HAKA_MEGANE",
|
||||
/* 0x00AF */ "ACTOR_BG_HAKA_MEGANEBG",
|
||||
/* 0x00B0 */ "ACTOR_BG_HAKA_SHIP",
|
||||
/* 0x00B1 */ "ACTOR_BG_HAKA_SGAMI",
|
||||
/* 0x00B2 */ "ACTOR_UNSET_B2",
|
||||
/* 0x00B3 */ "ACTOR_EN_HEISHI2",
|
||||
/* 0x00B4 */ "ACTOR_EN_ENCOUNT2",
|
||||
/* 0x00B5 */ "ACTOR_EN_FIRE_ROCK",
|
||||
/* 0x00B6 */ "ACTOR_EN_BROB",
|
||||
/* 0x00B7 */ "ACTOR_MIR_RAY",
|
||||
/* 0x00B8 */ "ACTOR_BG_SPOT09_OBJ",
|
||||
/* 0x00B9 */ "ACTOR_BG_SPOT18_OBJ",
|
||||
/* 0x00BA */ "ACTOR_BOSS_VA",
|
||||
/* 0x00BB */ "ACTOR_BG_HAKA_TUBO",
|
||||
/* 0x00BC */ "ACTOR_BG_HAKA_TRAP",
|
||||
/* 0x00BD */ "ACTOR_BG_HAKA_HUTA",
|
||||
/* 0x00BE */ "ACTOR_BG_HAKA_ZOU",
|
||||
/* 0x00BF */ "ACTOR_BG_SPOT17_FUNEN",
|
||||
/* 0x00C0 */ "ACTOR_EN_SYATEKI_ITM",
|
||||
/* 0x00C1 */ "ACTOR_EN_SYATEKI_MAN",
|
||||
/* 0x00C2 */ "ACTOR_EN_TANA",
|
||||
/* 0x00C3 */ "ACTOR_EN_NB",
|
||||
/* 0x00C4 */ "ACTOR_BOSS_MO",
|
||||
/* 0x00C5 */ "ACTOR_EN_SB",
|
||||
/* 0x00C6 */ "ACTOR_EN_BIGOKUTA",
|
||||
/* 0x00C7 */ "ACTOR_EN_KAREBABA",
|
||||
/* 0x00C8 */ "ACTOR_BG_BDAN_OBJECTS",
|
||||
/* 0x00C9 */ "ACTOR_DEMO_SA",
|
||||
/* 0x00CA */ "ACTOR_DEMO_GO",
|
||||
/* 0x00CB */ "ACTOR_EN_IN",
|
||||
/* 0x00CC */ "ACTOR_EN_TR",
|
||||
/* 0x00CD */ "ACTOR_BG_SPOT16_BOMBSTONE",
|
||||
/* 0x00CE */ "ACTOR_UNSET_CE",
|
||||
/* 0x00CF */ "ACTOR_BG_HIDAN_KOWARERUKABE",
|
||||
/* 0x00D0 */ "ACTOR_BG_BOMBWALL",
|
||||
/* 0x00D1 */ "ACTOR_BG_SPOT08_ICEBLOCK",
|
||||
/* 0x00D2 */ "ACTOR_EN_RU2",
|
||||
/* 0x00D3 */ "ACTOR_OBJ_DEKUJR",
|
||||
/* 0x00D4 */ "ACTOR_BG_MIZU_UZU",
|
||||
/* 0x00D5 */ "ACTOR_BG_SPOT06_OBJECTS",
|
||||
/* 0x00D6 */ "ACTOR_BG_ICE_OBJECTS",
|
||||
/* 0x00D7 */ "ACTOR_BG_HAKA_WATER",
|
||||
/* 0x00D8 */ "ACTOR_UNSET_D8",
|
||||
/* 0x00D9 */ "ACTOR_EN_MA2",
|
||||
/* 0x00DA */ "ACTOR_EN_BOM_CHU",
|
||||
/* 0x00DB */ "ACTOR_EN_HORSE_GAME_CHECK",
|
||||
/* 0x00DC */ "ACTOR_BOSS_TW",
|
||||
/* 0x00DD */ "ACTOR_EN_RR",
|
||||
/* 0x00DE */ "ACTOR_EN_BA",
|
||||
/* 0x00DF */ "ACTOR_EN_BX",
|
||||
/* 0x00E0 */ "ACTOR_EN_ANUBICE",
|
||||
/* 0x00E1 */ "ACTOR_EN_ANUBICE_FIRE",
|
||||
/* 0x00E2 */ "ACTOR_BG_MORI_HASHIGO",
|
||||
/* 0x00E3 */ "ACTOR_BG_MORI_HASHIRA4",
|
||||
/* 0x00E4 */ "ACTOR_BG_MORI_IDOMIZU",
|
||||
/* 0x00E5 */ "ACTOR_BG_SPOT16_DOUGHNUT",
|
||||
/* 0x00E6 */ "ACTOR_BG_BDAN_SWITCH",
|
||||
/* 0x00E7 */ "ACTOR_EN_MA1",
|
||||
/* 0x00E8 */ "ACTOR_BOSS_GANON",
|
||||
/* 0x00E9 */ "ACTOR_BOSS_SST",
|
||||
/* 0x00EA */ "ACTOR_UNSET_EA",
|
||||
/* 0x00EB */ "ACTOR_UNSET_EB",
|
||||
/* 0x00EC */ "ACTOR_EN_NY",
|
||||
/* 0x00ED */ "ACTOR_EN_FR",
|
||||
/* 0x00EE */ "ACTOR_ITEM_SHIELD",
|
||||
/* 0x00EF */ "ACTOR_BG_ICE_SHELTER",
|
||||
/* 0x00F0 */ "ACTOR_EN_ICE_HONO",
|
||||
/* 0x00F1 */ "ACTOR_ITEM_OCARINA",
|
||||
/* 0x00F2 */ "ACTOR_UNSET_F2",
|
||||
/* 0x00F3 */ "ACTOR_UNSET_F3",
|
||||
/* 0x00F4 */ "ACTOR_MAGIC_DARK",
|
||||
/* 0x00F5 */ "ACTOR_DEMO_6K",
|
||||
/* 0x00F6 */ "ACTOR_EN_ANUBICE_TAG",
|
||||
/* 0x00F7 */ "ACTOR_BG_HAKA_GATE",
|
||||
/* 0x00F8 */ "ACTOR_BG_SPOT15_SAKU",
|
||||
/* 0x00F9 */ "ACTOR_BG_JYA_GOROIWA",
|
||||
/* 0x00FA */ "ACTOR_BG_JYA_ZURERUKABE",
|
||||
/* 0x00FB */ "ACTOR_UNSET_FB",
|
||||
/* 0x00FC */ "ACTOR_BG_JYA_COBRA",
|
||||
/* 0x00FD */ "ACTOR_BG_JYA_KANAAMI",
|
||||
/* 0x00FE */ "ACTOR_FISHING",
|
||||
/* 0x00FF */ "ACTOR_OBJ_OSHIHIKI",
|
||||
/* 0x0100 */ "ACTOR_BG_GATE_SHUTTER",
|
||||
/* 0x0101 */ "ACTOR_EFF_DUST",
|
||||
/* 0x0102 */ "ACTOR_BG_SPOT01_FUSYA",
|
||||
/* 0x0103 */ "ACTOR_BG_SPOT01_IDOHASHIRA",
|
||||
/* 0x0104 */ "ACTOR_BG_SPOT01_IDOMIZU",
|
||||
/* 0x0105 */ "ACTOR_BG_PO_SYOKUDAI",
|
||||
/* 0x0106 */ "ACTOR_BG_GANON_OTYUKA",
|
||||
/* 0x0107 */ "ACTOR_BG_SPOT15_RRBOX",
|
||||
/* 0x0108 */ "ACTOR_BG_UMAJUMP",
|
||||
/* 0x0109 */ "ACTOR_UNSET_109",
|
||||
/* 0x010A */ "ACTOR_ARROW_FIRE",
|
||||
/* 0x010B */ "ACTOR_ARROW_ICE",
|
||||
/* 0x010C */ "ACTOR_ARROW_LIGHT",
|
||||
/* 0x010D */ "ACTOR_UNSET_10D",
|
||||
/* 0x010E */ "ACTOR_UNSET_10E",
|
||||
/* 0x010F */ "ACTOR_ITEM_ETCETERA",
|
||||
/* 0x0110 */ "ACTOR_OBJ_KIBAKO",
|
||||
/* 0x0111 */ "ACTOR_OBJ_TSUBO",
|
||||
/* 0x0112 */ "ACTOR_EN_WONDER_ITEM",
|
||||
/* 0x0113 */ "ACTOR_EN_IK",
|
||||
/* 0x0114 */ "ACTOR_DEMO_IK",
|
||||
/* 0x0115 */ "ACTOR_EN_SKJ",
|
||||
/* 0x0116 */ "ACTOR_EN_SKJNEEDLE",
|
||||
/* 0x0117 */ "ACTOR_EN_G_SWITCH",
|
||||
/* 0x0118 */ "ACTOR_DEMO_EXT",
|
||||
/* 0x0119 */ "ACTOR_DEMO_SHD",
|
||||
/* 0x011A */ "ACTOR_EN_DNS",
|
||||
/* 0x011B */ "ACTOR_ELF_MSG",
|
||||
/* 0x011C */ "ACTOR_EN_HONOTRAP",
|
||||
/* 0x011D */ "ACTOR_EN_TUBO_TRAP",
|
||||
/* 0x011E */ "ACTOR_OBJ_ICE_POLY",
|
||||
/* 0x011F */ "ACTOR_BG_SPOT03_TAKI",
|
||||
/* 0x0120 */ "ACTOR_BG_SPOT07_TAKI",
|
||||
/* 0x0121 */ "ACTOR_EN_FZ",
|
||||
/* 0x0122 */ "ACTOR_EN_PO_RELAY",
|
||||
/* 0x0123 */ "ACTOR_BG_RELAY_OBJECTS",
|
||||
/* 0x0124 */ "ACTOR_EN_DIVING_GAME",
|
||||
/* 0x0125 */ "ACTOR_EN_KUSA",
|
||||
/* 0x0126 */ "ACTOR_OBJ_BEAN",
|
||||
/* 0x0127 */ "ACTOR_OBJ_BOMBIWA",
|
||||
/* 0x0128 */ "ACTOR_UNSET_128",
|
||||
/* 0x0129 */ "ACTOR_UNSET_129",
|
||||
/* 0x012A */ "ACTOR_OBJ_SWITCH",
|
||||
/* 0x012B */ "ACTOR_OBJ_ELEVATOR",
|
||||
/* 0x012C */ "ACTOR_OBJ_LIFT",
|
||||
/* 0x012D */ "ACTOR_OBJ_HSBLOCK",
|
||||
/* 0x012E */ "ACTOR_EN_OKARINA_TAG",
|
||||
/* 0x012F */ "ACTOR_EN_YABUSAME_MARK",
|
||||
/* 0x0130 */ "ACTOR_EN_GOROIWA",
|
||||
/* 0x0131 */ "ACTOR_EN_EX_RUPPY",
|
||||
/* 0x0132 */ "ACTOR_EN_TORYO",
|
||||
/* 0x0133 */ "ACTOR_EN_DAIKU",
|
||||
/* 0x0134 */ "ACTOR_UNSET_134",
|
||||
/* 0x0135 */ "ACTOR_EN_NWC",
|
||||
/* 0x0136 */ "ACTOR_EN_BLKOBJ",
|
||||
/* 0x0137 */ "ACTOR_ITEM_INBOX",
|
||||
/* 0x0138 */ "ACTOR_EN_GE1",
|
||||
/* 0x0139 */ "ACTOR_OBJ_BLOCKSTOP",
|
||||
/* 0x013A */ "ACTOR_EN_SDA",
|
||||
/* 0x013B */ "ACTOR_EN_CLEAR_TAG",
|
||||
/* 0x013C */ "ACTOR_EN_NIW_LADY",
|
||||
/* 0x013D */ "ACTOR_EN_GM",
|
||||
/* 0x013E */ "ACTOR_EN_MS",
|
||||
/* 0x013F */ "ACTOR_EN_HS",
|
||||
/* 0x0140 */ "ACTOR_BG_INGATE",
|
||||
/* 0x0141 */ "ACTOR_EN_KANBAN",
|
||||
/* 0x0142 */ "ACTOR_EN_HEISHI3",
|
||||
/* 0x0143 */ "ACTOR_EN_SYATEKI_NIW",
|
||||
/* 0x0144 */ "ACTOR_EN_ATTACK_NIW",
|
||||
/* 0x0145 */ "ACTOR_BG_SPOT01_IDOSOKO",
|
||||
/* 0x0146 */ "ACTOR_EN_SA",
|
||||
/* 0x0147 */ "ACTOR_EN_WONDER_TALK",
|
||||
/* 0x0148 */ "ACTOR_BG_GJYO_BRIDGE",
|
||||
/* 0x0149 */ "ACTOR_EN_DS",
|
||||
/* 0x014A */ "ACTOR_EN_MK",
|
||||
/* 0x014B */ "ACTOR_EN_BOM_BOWL_MAN",
|
||||
/* 0x014C */ "ACTOR_EN_BOM_BOWL_PIT",
|
||||
/* 0x014D */ "ACTOR_EN_OWL",
|
||||
/* 0x014E */ "ACTOR_EN_ISHI",
|
||||
/* 0x014F */ "ACTOR_OBJ_HANA",
|
||||
/* 0x0150 */ "ACTOR_OBJ_LIGHTSWITCH",
|
||||
/* 0x0151 */ "ACTOR_OBJ_MURE2",
|
||||
/* 0x0152 */ "ACTOR_EN_GO",
|
||||
/* 0x0153 */ "ACTOR_EN_FU",
|
||||
/* 0x0154 */ "ACTOR_UNSET_154",
|
||||
/* 0x0155 */ "ACTOR_EN_CHANGER",
|
||||
/* 0x0156 */ "ACTOR_BG_JYA_MEGAMI",
|
||||
/* 0x0157 */ "ACTOR_BG_JYA_LIFT",
|
||||
/* 0x0158 */ "ACTOR_BG_JYA_BIGMIRROR",
|
||||
/* 0x0159 */ "ACTOR_BG_JYA_BOMBCHUIWA",
|
||||
/* 0x015A */ "ACTOR_BG_JYA_AMISHUTTER",
|
||||
/* 0x015B */ "ACTOR_BG_JYA_BOMBIWA",
|
||||
/* 0x015C */ "ACTOR_BG_SPOT18_BASKET",
|
||||
/* 0x015D */ "ACTOR_UNSET_15D",
|
||||
/* 0x015E */ "ACTOR_EN_GANON_ORGAN",
|
||||
/* 0x015F */ "ACTOR_EN_SIOFUKI",
|
||||
/* 0x0160 */ "ACTOR_EN_STREAM",
|
||||
/* 0x0161 */ "ACTOR_UNSET_161",
|
||||
/* 0x0162 */ "ACTOR_EN_MM",
|
||||
/* 0x0163 */ "ACTOR_EN_KO",
|
||||
/* 0x0164 */ "ACTOR_EN_KZ",
|
||||
/* 0x0165 */ "ACTOR_EN_WEATHER_TAG",
|
||||
/* 0x0166 */ "ACTOR_BG_SST_FLOOR",
|
||||
/* 0x0167 */ "ACTOR_EN_ANI",
|
||||
/* 0x0168 */ "ACTOR_EN_EX_ITEM",
|
||||
/* 0x0169 */ "ACTOR_BG_JYA_IRONOBJ",
|
||||
/* 0x016A */ "ACTOR_EN_JS",
|
||||
/* 0x016B */ "ACTOR_EN_JSJUTAN",
|
||||
/* 0x016C */ "ACTOR_EN_CS",
|
||||
/* 0x016D */ "ACTOR_EN_MD",
|
||||
/* 0x016E */ "ACTOR_EN_HY",
|
||||
/* 0x016F */ "ACTOR_EN_GANON_MANT",
|
||||
/* 0x0170 */ "ACTOR_EN_OKARINA_EFFECT",
|
||||
/* 0x0171 */ "ACTOR_EN_MAG",
|
||||
/* 0x0172 */ "ACTOR_DOOR_GERUDO",
|
||||
/* 0x0173 */ "ACTOR_ELF_MSG2",
|
||||
/* 0x0174 */ "ACTOR_DEMO_GT",
|
||||
/* 0x0175 */ "ACTOR_EN_PO_FIELD",
|
||||
/* 0x0176 */ "ACTOR_EFC_ERUPC",
|
||||
/* 0x0177 */ "ACTOR_BG_ZG",
|
||||
/* 0x0178 */ "ACTOR_EN_HEISHI4",
|
||||
/* 0x0179 */ "ACTOR_EN_ZL3",
|
||||
/* 0x017A */ "ACTOR_BOSS_GANON2",
|
||||
/* 0x017B */ "ACTOR_EN_KAKASI",
|
||||
/* 0x017C */ "ACTOR_EN_TAKARA_MAN",
|
||||
/* 0x017D */ "ACTOR_OBJ_MAKEOSHIHIKI",
|
||||
/* 0x017E */ "ACTOR_OCEFF_SPOT",
|
||||
/* 0x017F */ "ACTOR_END_TITLE",
|
||||
/* 0x0180 */ "ACTOR_UNSET_180",
|
||||
/* 0x0181 */ "ACTOR_EN_TORCH",
|
||||
/* 0x0182 */ "ACTOR_DEMO_EC",
|
||||
/* 0x0183 */ "ACTOR_SHOT_SUN",
|
||||
/* 0x0184 */ "ACTOR_EN_DY_EXTRA",
|
||||
/* 0x0185 */ "ACTOR_EN_WONDER_TALK2",
|
||||
/* 0x0186 */ "ACTOR_EN_GE2",
|
||||
/* 0x0187 */ "ACTOR_OBJ_ROOMTIMER",
|
||||
/* 0x0188 */ "ACTOR_EN_SSH",
|
||||
/* 0x0189 */ "ACTOR_EN_STH",
|
||||
/* 0x018A */ "ACTOR_OCEFF_WIPE",
|
||||
/* 0x018B */ "ACTOR_OCEFF_STORM",
|
||||
/* 0x018C */ "ACTOR_EN_WEIYER",
|
||||
/* 0x018D */ "ACTOR_BG_SPOT05_SOKO",
|
||||
/* 0x018E */ "ACTOR_BG_JYA_1FLIFT",
|
||||
/* 0x018F */ "ACTOR_BG_JYA_HAHENIRON",
|
||||
/* 0x0190 */ "ACTOR_BG_SPOT12_GATE",
|
||||
/* 0x0191 */ "ACTOR_BG_SPOT12_SAKU",
|
||||
/* 0x0192 */ "ACTOR_EN_HINTNUTS",
|
||||
/* 0x0193 */ "ACTOR_EN_NUTSBALL",
|
||||
/* 0x0194 */ "ACTOR_BG_SPOT00_BREAK",
|
||||
/* 0x0195 */ "ACTOR_EN_SHOPNUTS",
|
||||
/* 0x0196 */ "ACTOR_EN_IT",
|
||||
/* 0x0197 */ "ACTOR_EN_GELDB",
|
||||
/* 0x0198 */ "ACTOR_OCEFF_WIPE2",
|
||||
/* 0x0199 */ "ACTOR_OCEFF_WIPE3",
|
||||
/* 0x019A */ "ACTOR_EN_NIW_GIRL",
|
||||
/* 0x019B */ "ACTOR_EN_DOG",
|
||||
/* 0x019C */ "ACTOR_EN_SI",
|
||||
/* 0x019D */ "ACTOR_BG_SPOT01_OBJECTS2",
|
||||
/* 0x019E */ "ACTOR_OBJ_COMB",
|
||||
/* 0x019F */ "ACTOR_BG_SPOT11_BAKUDANKABE",
|
||||
/* 0x01A0 */ "ACTOR_OBJ_KIBAKO2",
|
||||
/* 0x01A1 */ "ACTOR_EN_DNT_DEMO",
|
||||
/* 0x01A2 */ "ACTOR_EN_DNT_JIJI",
|
||||
/* 0x01A3 */ "ACTOR_EN_DNT_NOMAL",
|
||||
/* 0x01A4 */ "ACTOR_EN_GUEST",
|
||||
/* 0x01A5 */ "ACTOR_BG_BOM_GUARD",
|
||||
/* 0x01A6 */ "ACTOR_EN_HS2",
|
||||
/* 0x01A7 */ "ACTOR_DEMO_KEKKAI",
|
||||
/* 0x01A8 */ "ACTOR_BG_SPOT08_BAKUDANKABE",
|
||||
/* 0x01A9 */ "ACTOR_BG_SPOT17_BAKUDANKABE",
|
||||
/* 0x01AA */ "ACTOR_UNSET_1AA",
|
||||
/* 0x01AB */ "ACTOR_OBJ_MURE3",
|
||||
/* 0x01AC */ "ACTOR_EN_TG",
|
||||
/* 0x01AD */ "ACTOR_EN_MU",
|
||||
/* 0x01AE */ "ACTOR_EN_GO2",
|
||||
/* 0x01AF */ "ACTOR_EN_WF",
|
||||
/* 0x01B0 */ "ACTOR_EN_SKB",
|
||||
/* 0x01B1 */ "ACTOR_DEMO_GJ",
|
||||
/* 0x01B2 */ "ACTOR_DEMO_GEFF",
|
||||
/* 0x01B3 */ "ACTOR_BG_GND_FIREMEIRO",
|
||||
/* 0x01B4 */ "ACTOR_BG_GND_DARKMEIRO",
|
||||
/* 0x01B5 */ "ACTOR_BG_GND_SOULMEIRO",
|
||||
/* 0x01B6 */ "ACTOR_BG_GND_NISEKABE",
|
||||
/* 0x01B7 */ "ACTOR_BG_GND_ICEBLOCK",
|
||||
/* 0x01B8 */ "ACTOR_EN_GB",
|
||||
/* 0x01B9 */ "ACTOR_EN_GS",
|
||||
/* 0x01BA */ "ACTOR_BG_MIZU_BWALL",
|
||||
/* 0x01BB */ "ACTOR_BG_MIZU_SHUTTER",
|
||||
/* 0x01BC */ "ACTOR_EN_DAIKU_KAKARIKO",
|
||||
/* 0x01BD */ "ACTOR_BG_BOWL_WALL",
|
||||
/* 0x01BE */ "ACTOR_EN_WALL_TUBO",
|
||||
/* 0x01BF */ "ACTOR_EN_PO_DESERT",
|
||||
/* 0x01C0 */ "ACTOR_EN_CROW",
|
||||
/* 0x01C1 */ "ACTOR_DOOR_KILLER",
|
||||
/* 0x01C2 */ "ACTOR_BG_SPOT11_OASIS",
|
||||
/* 0x01C3 */ "ACTOR_BG_SPOT18_FUTA",
|
||||
/* 0x01C4 */ "ACTOR_BG_SPOT18_SHUTTER",
|
||||
/* 0x01C5 */ "ACTOR_EN_MA3",
|
||||
/* 0x01C6 */ "ACTOR_EN_COW",
|
||||
/* 0x01C7 */ "ACTOR_BG_ICE_TURARA",
|
||||
/* 0x01C8 */ "ACTOR_BG_ICE_SHUTTER",
|
||||
/* 0x01C9 */ "ACTOR_EN_KAKASI2",
|
||||
/* 0x01CA */ "ACTOR_EN_KAKASI3",
|
||||
/* 0x01CB */ "ACTOR_OCEFF_WIPE4",
|
||||
/* 0x01CC */ "ACTOR_EN_EG",
|
||||
/* 0x01CD */ "ACTOR_BG_MENKURI_NISEKABE",
|
||||
/* 0x01CE */ "ACTOR_EN_ZO",
|
||||
/* 0x01CF */ "ACTOR_OBJ_MAKEKINSUTA",
|
||||
/* 0x01D0 */ "ACTOR_EN_GE3",
|
||||
/* 0x01D1 */ "ACTOR_OBJ_TIMEBLOCK",
|
||||
/* 0x01D2 */ "ACTOR_OBJ_HAMISHI",
|
||||
/* 0x01D3 */ "ACTOR_EN_ZL4",
|
||||
/* 0x01D4 */ "ACTOR_EN_MM2",
|
||||
/* 0x01D5 */ "ACTOR_BG_JYA_BLOCK",
|
||||
/* 0x01D6 */ "ACTOR_OBJ_WARP2BLOCK",
|
||||
/* 0x01D7 */ "ACTOR_ID_MAX" // originally "ACTOR_DLF_MAX"
|
||||
};
|
|
@ -3,12 +3,12 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
EndMarker::EndMarker(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex)
|
||||
EndMarker::EndMarker(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex)
|
||||
: ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
}
|
||||
|
||||
string EndMarker::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
string EndMarker::GenerateSourceCodePass1(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
return StringHelper::Sprintf(
|
||||
"%s 0x00, 0x00", ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str());
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
class EndMarker : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
EndMarker(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
EndMarker(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GetCommandCName();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, uint32_t baseAddress) override;
|
||||
virtual std::string GetCommandCName() override;
|
||||
virtual RoomCommand GetRoomCommand() override;
|
||||
|
||||
private:
|
||||
};
|
95
tools/ZAPD/ZAPD/ZRoom/Commands/SetActorCutsceneList.cpp
Normal file
95
tools/ZAPD/ZAPD/ZRoom/Commands/SetActorCutsceneList.cpp
Normal file
|
@ -0,0 +1,95 @@
|
|||
#include "SetActorCutsceneList.h"
|
||||
#include "../../BitConverter.h"
|
||||
#include "../../Globals.h"
|
||||
#include "../../StringHelper.h"
|
||||
#include "../../ZFile.h"
|
||||
#include "../ZRoom.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SetActorCutsceneList::SetActorCutsceneList(ZRoom* nZRoom, std::vector<uint8_t> rawData,
|
||||
uint32_t rawDataIndex)
|
||||
: ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
int32_t numCutscenes = rawData[rawDataIndex + 1];
|
||||
segmentOffset = BitConverter::ToInt32BE(rawData, rawDataIndex + 4) & 0x00FFFFFF;
|
||||
|
||||
cutscenes = vector<ActorCutsceneEntry*>();
|
||||
|
||||
int32_t currentPtr = segmentOffset;
|
||||
|
||||
for (int32_t i = 0; i < numCutscenes; i++)
|
||||
{
|
||||
ActorCutsceneEntry* entry = new ActorCutsceneEntry(rawData, currentPtr);
|
||||
cutscenes.push_back(entry);
|
||||
|
||||
currentPtr += 16;
|
||||
}
|
||||
|
||||
string declaration = "";
|
||||
|
||||
for (ActorCutsceneEntry* entry : cutscenes)
|
||||
{
|
||||
declaration += StringHelper::Sprintf(
|
||||
" { %i, %i, %i, %i, %i, %i, %i, %i, %i, %i },\n", entry->priority, entry->length,
|
||||
entry->unk4, entry->unk6, entry->additionalCutscene, entry->sound, entry->unkB,
|
||||
entry->unkC, entry->unkE, entry->letterboxSize);
|
||||
}
|
||||
|
||||
zRoom->parent->AddDeclarationArray(
|
||||
segmentOffset, DeclarationAlignment::None, cutscenes.size() * 16, "ActorCutscene",
|
||||
StringHelper::Sprintf("%sActorCutsceneList0x%06X", zRoom->GetName().c_str(), segmentOffset),
|
||||
0, declaration);
|
||||
}
|
||||
|
||||
SetActorCutsceneList::~SetActorCutsceneList()
|
||||
{
|
||||
for (ActorCutsceneEntry* entry : cutscenes)
|
||||
delete entry;
|
||||
}
|
||||
|
||||
string SetActorCutsceneList::GenerateSourceCodePass1(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
return StringHelper::Sprintf(
|
||||
"%s 0x%02X, (u32)&%sActorCutsceneList0x%06X",
|
||||
ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(), cutscenes.size(),
|
||||
zRoom->GetName().c_str(), segmentOffset);
|
||||
}
|
||||
|
||||
string SetActorCutsceneList::GenerateSourceCodePass2(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
size_t SetActorCutsceneList::GetRawDataSize()
|
||||
{
|
||||
return ZRoomCommand::GetRawDataSize() + (cutscenes.size() * 16);
|
||||
}
|
||||
|
||||
string SetActorCutsceneList::GenerateExterns()
|
||||
{
|
||||
return StringHelper::Sprintf("extern ActorCutscene %sActorCutsceneList0x%06X[];\n",
|
||||
zRoom->GetName().c_str(), segmentOffset);
|
||||
}
|
||||
|
||||
string SetActorCutsceneList::GetCommandCName()
|
||||
{
|
||||
return "SCmdCutsceneActorList";
|
||||
}
|
||||
|
||||
RoomCommand SetActorCutsceneList::GetRoomCommand()
|
||||
{
|
||||
return RoomCommand::SetActorCutsceneList;
|
||||
}
|
||||
|
||||
ActorCutsceneEntry::ActorCutsceneEntry(std::vector<uint8_t> rawData, uint32_t rawDataIndex)
|
||||
: priority(BitConverter::ToInt16BE(rawData, rawDataIndex + 0)),
|
||||
length(BitConverter::ToInt16BE(rawData, rawDataIndex + 2)),
|
||||
unk4(BitConverter::ToInt16BE(rawData, rawDataIndex + 4)),
|
||||
unk6(BitConverter::ToInt16BE(rawData, rawDataIndex + 6)),
|
||||
additionalCutscene(BitConverter::ToInt16BE(rawData, rawDataIndex + 8)),
|
||||
sound(rawData[rawDataIndex + 0xA]), unkB(rawData[rawDataIndex + 0xB]),
|
||||
unkC(BitConverter::ToInt16BE(rawData, rawDataIndex + 0xC)), unkE(rawData[rawDataIndex + 0xE]),
|
||||
letterboxSize(rawData[rawDataIndex + 0xF])
|
||||
{
|
||||
}
|
38
tools/ZAPD/ZAPD/ZRoom/Commands/SetActorCutsceneList.h
Normal file
38
tools/ZAPD/ZAPD/ZRoom/Commands/SetActorCutsceneList.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
#pragma once
|
||||
|
||||
#include "../ZRoomCommand.h"
|
||||
|
||||
class ActorCutsceneEntry
|
||||
{
|
||||
public:
|
||||
int16_t priority;
|
||||
int16_t length;
|
||||
int16_t unk4;
|
||||
int16_t unk6;
|
||||
int16_t additionalCutscene;
|
||||
uint8_t sound;
|
||||
uint8_t unkB;
|
||||
int16_t unkC;
|
||||
uint8_t unkE;
|
||||
uint8_t letterboxSize;
|
||||
|
||||
ActorCutsceneEntry(std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
};
|
||||
|
||||
class SetActorCutsceneList : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetActorCutsceneList(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
~SetActorCutsceneList();
|
||||
|
||||
std::string GenerateSourceCodePass1(std::string roomName, uint32_t baseAddress) override;
|
||||
std::string GenerateSourceCodePass2(std::string roomName, uint32_t baseAddress) override;
|
||||
std::string GetCommandCName() override;
|
||||
std::string GenerateExterns() override;
|
||||
RoomCommand GetRoomCommand() override;
|
||||
size_t GetRawDataSize() override;
|
||||
|
||||
private:
|
||||
std::vector<ActorCutsceneEntry*> cutscenes;
|
||||
uint32_t segmentOffset;
|
||||
};
|
|
@ -3,12 +3,12 @@
|
|||
#include "../../Globals.h"
|
||||
#include "../../StringHelper.h"
|
||||
#include "../../ZFile.h"
|
||||
#include "../ActorList.h"
|
||||
#include "../ZNames.h"
|
||||
#include "../ZRoom.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SetActorList::SetActorList(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex)
|
||||
SetActorList::SetActorList(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex)
|
||||
: ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
numActors = rawData[rawDataIndex + 1];
|
||||
|
@ -26,7 +26,6 @@ SetActorList::~SetActorList()
|
|||
for (ActorSpawnEntry* entry : actors)
|
||||
delete entry;
|
||||
|
||||
actors.clear();
|
||||
}
|
||||
|
||||
string SetActorList::GetSourceOutputCode(std::string prefix)
|
||||
|
@ -34,12 +33,12 @@ string SetActorList::GetSourceOutputCode(std::string prefix)
|
|||
return "";
|
||||
}
|
||||
|
||||
string SetActorList::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
string SetActorList::GenerateSourceCodePass1(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
string SetActorList::GenerateSourceCodePass2(string roomName, int baseAddress)
|
||||
string SetActorList::GenerateSourceCodePass2(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
string sourceOutput = "";
|
||||
size_t numActorsReal = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 16;
|
||||
|
@ -55,7 +54,7 @@ string SetActorList::GenerateSourceCodePass2(string roomName, int baseAddress)
|
|||
}
|
||||
|
||||
sourceOutput +=
|
||||
StringHelper::Sprintf("%s 0x%02X, (u32)%sActorList0x%06X };",
|
||||
StringHelper::Sprintf("\n %s 0x%02X, (u32)%sActorList0x%06X \n};",
|
||||
ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(),
|
||||
numActors, roomName.c_str(), segmentOffset);
|
||||
|
||||
|
@ -70,50 +69,50 @@ string SetActorList::GenerateSourceCodePass2(string roomName, int baseAddress)
|
|||
{
|
||||
uint16_t actorNum = entry->actorNum;
|
||||
|
||||
// SW97 Actor 0x22 was removed, so we want to not output a working actor.
|
||||
if (actorNum == 0x22 && Globals::Instance->game == ZGame::OOT_SW97)
|
||||
if (Globals::Instance->game == ZGame::MM_RETAIL)
|
||||
{
|
||||
declaration += StringHelper::Sprintf(
|
||||
"\t//{ %s, %i, %i, %i, %i, %i, %i, 0x%04X }, //0x%06X",
|
||||
/*StringHelper::Sprintf("SW_REMOVED_0x%04X", actorNum).c_str()*/
|
||||
"ACTOR_DUNGEON_KEEP", entry->posX, entry->posY, entry->posZ, entry->rotX,
|
||||
entry->rotY, entry->rotZ, (uint16_t)entry->initVar, segmentOffset + (index * 16));
|
||||
" { %s, %i, %i, %i, SPAWN_ROT_FLAGS(%i, 0x%04X), SPAWN_ROT_FLAGS(%i, 0x%04X), "
|
||||
"SPAWN_ROT_FLAGS(%i, 0x%04X), 0x%04X }, //0x%06X",
|
||||
ZNames::GetActorName(actorNum).c_str(), entry->posX, entry->posY, entry->posZ,
|
||||
(entry->rotX >> 7) & 0b111111111, entry->rotX & 0b1111111,
|
||||
(entry->rotY >> 7) & 0b111111111, entry->rotY & 0b1111111,
|
||||
(entry->rotZ >> 7) & 0b111111111, entry->rotZ & 0b1111111, (uint16_t)entry->initVar,
|
||||
segmentOffset + (index * 16));
|
||||
}
|
||||
else
|
||||
{
|
||||
// SW97 Actor 0x23 and above are shifted up by one because 0x22 was removed between SW97
|
||||
// and retail. We need to shift down by one
|
||||
if (Globals::Instance->game == ZGame::OOT_SW97 && actorNum >= 0x23)
|
||||
actorNum--;
|
||||
|
||||
if (actorNum < sizeof(ActorList) / sizeof(ActorList[0]))
|
||||
declaration +=
|
||||
StringHelper::Sprintf("\t{ %s, %i, %i, %i, %i, %i, %i, 0x%04X }, //0x%06X",
|
||||
ActorList[actorNum].c_str(), entry->posX, entry->posY,
|
||||
entry->posZ, entry->rotX, entry->rotY, entry->rotZ,
|
||||
(uint16_t)entry->initVar, segmentOffset + (index * 16));
|
||||
else
|
||||
declaration += StringHelper::Sprintf(
|
||||
"\t{ 0x%04X, %i, %i, %i, %i, %i, %i, 0x%04X }, //0x%06X", actorNum, entry->posX,
|
||||
entry->posY, entry->posZ, entry->rotX, entry->rotY, entry->rotZ,
|
||||
(uint16_t)entry->initVar, segmentOffset + (index * 16));
|
||||
" { %s, %i, %i, %i, %i, %i, %i, 0x%04X }, //0x%06X",
|
||||
ZNames::GetActorName(actorNum).c_str(), entry->posX, entry->posY, entry->posZ,
|
||||
entry->rotX, entry->rotY, entry->rotZ, (uint16_t)entry->initVar,
|
||||
segmentOffset + (index * 16));
|
||||
|
||||
if (index < actors.size() - 1)
|
||||
declaration += "\n";
|
||||
}
|
||||
|
||||
if (index < actors.size() - 1)
|
||||
declaration += "\n";
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
DeclarationPadding padding = DeclarationPadding::Pad16;
|
||||
if (Globals::Instance->game == ZGame::MM_RETAIL)
|
||||
padding = DeclarationPadding::None;
|
||||
|
||||
zRoom->parent->AddDeclarationArray(
|
||||
segmentOffset, DeclarationAlignment::None, DeclarationPadding::Pad16, actors.size() * 16,
|
||||
"ActorEntry", StringHelper::Sprintf("%sActorList0x%06X", roomName.c_str(), segmentOffset),
|
||||
segmentOffset, DeclarationAlignment::None, padding, actors.size() * 16, "ActorEntry",
|
||||
StringHelper::Sprintf("%sActorList0x%06X", roomName.c_str(), segmentOffset),
|
||||
GetActorListArraySize(), declaration);
|
||||
|
||||
return sourceOutput;
|
||||
}
|
||||
|
||||
int32_t SetActorList::GetRawDataSize()
|
||||
size_t SetActorList::GetRawDataSize()
|
||||
{
|
||||
return ZRoomCommand::GetRawDataSize() + ((int)actors.size() * 16);
|
||||
return ZRoomCommand::GetRawDataSize() + ((int32_t)actors.size() * 16);
|
||||
}
|
||||
|
||||
size_t SetActorList::GetActorListArraySize()
|
||||
|
@ -155,7 +154,7 @@ RoomCommand SetActorList::GetRoomCommand()
|
|||
return RoomCommand::SetActorList;
|
||||
}
|
||||
|
||||
ActorSpawnEntry::ActorSpawnEntry(std::vector<uint8_t> rawData, int rawDataIndex)
|
||||
ActorSpawnEntry::ActorSpawnEntry(std::vector<uint8_t> rawData, uint32_t rawDataIndex)
|
||||
{
|
||||
const uint8_t* data = rawData.data();
|
||||
|
||||
|
|
|
@ -14,28 +14,28 @@ public:
|
|||
int16_t rotZ;
|
||||
uint16_t initVar;
|
||||
|
||||
ActorSpawnEntry(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
ActorSpawnEntry(std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
};
|
||||
|
||||
class SetActorList : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetActorList(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
SetActorList(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
~SetActorList();
|
||||
|
||||
std::string GetSourceOutputCode(std::string prefix);
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GenerateSourceCodePass2(std::string roomName, int baseAddress);
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
virtual int32_t GetRawDataSize();
|
||||
virtual std::string GetCommandCName();
|
||||
virtual std::string GenerateExterns();
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, uint32_t baseAddress) override;
|
||||
virtual std::string GenerateSourceCodePass2(std::string roomName, uint32_t baseAddress) override;
|
||||
virtual RoomCommand GetRoomCommand() override;
|
||||
virtual size_t GetRawDataSize() override;
|
||||
virtual std::string GetCommandCName() override;
|
||||
virtual std::string GenerateExterns() override;
|
||||
|
||||
private:
|
||||
size_t GetActorListArraySize();
|
||||
int numActors;
|
||||
int32_t numActors;
|
||||
std::vector<ActorSpawnEntry*> actors;
|
||||
uint32_t segmentOffset;
|
||||
std::vector<uint8_t> _rawData;
|
||||
int _rawDataIndex;
|
||||
uint32_t _rawDataIndex;
|
||||
};
|
|
@ -6,7 +6,7 @@
|
|||
using namespace std;
|
||||
|
||||
SetAlternateHeaders::SetAlternateHeaders(ZRoom* nZRoom, std::vector<uint8_t> rawData,
|
||||
int rawDataIndex)
|
||||
uint32_t rawDataIndex)
|
||||
: ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
segmentOffset = GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 4));
|
||||
|
@ -18,12 +18,12 @@ SetAlternateHeaders::SetAlternateHeaders(ZRoom* nZRoom, std::vector<uint8_t> raw
|
|||
_rawDataIndex = rawDataIndex;
|
||||
}
|
||||
|
||||
string SetAlternateHeaders::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
string SetAlternateHeaders::GenerateSourceCodePass1(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
string sourceOutput = "";
|
||||
int numHeaders = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 4;
|
||||
int32_t numHeaders = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 4;
|
||||
|
||||
for (int i = 0; i < numHeaders; i++)
|
||||
for (int32_t i = 0; i < numHeaders; i++)
|
||||
{
|
||||
int32_t address = BitConverter::ToInt32BE(_rawData, segmentOffset + (i * 4));
|
||||
headers.push_back(address);
|
||||
|
@ -39,14 +39,14 @@ string SetAlternateHeaders::GenerateSourceCodePass1(string roomName, int baseAdd
|
|||
|
||||
string declaration = "";
|
||||
|
||||
for (int i = 0; i < numHeaders; i++)
|
||||
for (int32_t i = 0; i < numHeaders; i++)
|
||||
{
|
||||
// sprintf(line, "\t0x%06X,\n", headers[i]);
|
||||
// sprintf(line, " 0x%06X,\n", headers[i]);
|
||||
|
||||
if (headers[i] == 0)
|
||||
declaration += StringHelper::Sprintf("\t0,\n");
|
||||
declaration += StringHelper::Sprintf(" 0,\n");
|
||||
else
|
||||
declaration += StringHelper::Sprintf("\t(u32)&%sSet%04XCmd00,\n", roomName.c_str(),
|
||||
declaration += StringHelper::Sprintf(" (u32)&%sSet%04XCmd00,\n", roomName.c_str(),
|
||||
headers[i] & 0x00FFFFFF);
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ string SetAlternateHeaders::GenerateSourceCodePass1(string roomName, int baseAdd
|
|||
return sourceOutput;
|
||||
}
|
||||
|
||||
int32_t SetAlternateHeaders::GetRawDataSize()
|
||||
size_t SetAlternateHeaders::GetRawDataSize()
|
||||
{
|
||||
return ZRoomCommand::GetRawDataSize() + 0;
|
||||
}
|
||||
|
|
|
@ -6,16 +6,16 @@
|
|||
class SetAlternateHeaders : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetAlternateHeaders(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
SetAlternateHeaders(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual int32_t GetRawDataSize();
|
||||
virtual std::string GetCommandCName();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, uint32_t baseAddress) override;
|
||||
virtual size_t GetRawDataSize() override;
|
||||
virtual std::string GetCommandCName() override;
|
||||
virtual RoomCommand GetRoomCommand() override;
|
||||
|
||||
private:
|
||||
int32_t segmentOffset;
|
||||
std::vector<uint32_t> headers;
|
||||
std::vector<uint8_t> _rawData;
|
||||
int _rawDataIndex;
|
||||
int32_t _rawDataIndex;
|
||||
};
|
432
tools/ZAPD/ZAPD/ZRoom/Commands/SetAnimatedTextureList.cpp
Normal file
432
tools/ZAPD/ZAPD/ZRoom/Commands/SetAnimatedTextureList.cpp
Normal file
|
@ -0,0 +1,432 @@
|
|||
#include "SetAnimatedTextureList.h"
|
||||
#include "../../BitConverter.h"
|
||||
#include "../../Globals.h"
|
||||
#include "../../StringHelper.h"
|
||||
#include "../../ZFile.h"
|
||||
#include "../ZRoom.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SetAnimatedTextureList::SetAnimatedTextureList(ZRoom* nZRoom, std::vector<uint8_t> rawData,
|
||||
uint32_t rawDataIndex)
|
||||
: ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
segmentOffset = GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 4));
|
||||
|
||||
{
|
||||
string declaration = "";
|
||||
|
||||
int32_t currentPtr = segmentOffset;
|
||||
|
||||
AnimatedTexture* lastTexture = nullptr;
|
||||
|
||||
do
|
||||
{
|
||||
if (textures.size() > 0)
|
||||
declaration += "\n";
|
||||
|
||||
lastTexture = new AnimatedTexture(rawData, currentPtr);
|
||||
currentPtr += 8;
|
||||
textures.push_back(lastTexture);
|
||||
|
||||
string textureName =
|
||||
(lastTexture->segmentOffset != 0) ?
|
||||
StringHelper::Sprintf("&%sAnimatedTextureParams0x%06X",
|
||||
zRoom->GetName().c_str(), lastTexture->segmentOffset) :
|
||||
"NULL";
|
||||
|
||||
declaration += StringHelper::Sprintf(" { %i, %i, (u32)%s },", lastTexture->segment,
|
||||
lastTexture->type, textureName.c_str());
|
||||
} while ((lastTexture->segment != 0) && (lastTexture->segment > -1));
|
||||
|
||||
zRoom->parent->AddDeclarationArray(
|
||||
segmentOffset, DeclarationAlignment::None, DeclarationPadding::Pad16,
|
||||
textures.size() * 8, "AnimatedTexture",
|
||||
StringHelper::Sprintf("%sAnimatedTextureList0x%06X", zRoom->GetName().c_str(),
|
||||
segmentOffset),
|
||||
textures.size(), declaration);
|
||||
}
|
||||
|
||||
for (AnimatedTexture* texture : textures)
|
||||
{
|
||||
string declaration = "";
|
||||
size_t index = 0;
|
||||
|
||||
switch (texture->type)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
for (AnitmatedTextureParams* param : texture->params)
|
||||
{
|
||||
declaration += param->GenerateSourceCode(zRoom, texture->segmentOffset);
|
||||
|
||||
if (index < texture->params.size() - 1)
|
||||
declaration += "\n";
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
zRoom->parent->AddDeclarationArray(
|
||||
texture->segmentOffset, DeclarationAlignment::None, DeclarationPadding::None,
|
||||
texture->params.size() * 4, "ScrollingTextureParams",
|
||||
StringHelper::Sprintf("%sAnimatedTextureParams0x%06X", zRoom->GetName().c_str(),
|
||||
texture->segmentOffset),
|
||||
texture->params.size(), declaration);
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
zRoom->parent->AddDeclaration(
|
||||
texture->segmentOffset, DeclarationAlignment::Align4, DeclarationPadding::None, 16,
|
||||
"FlashingTextureParams",
|
||||
StringHelper::Sprintf("%sAnimatedTextureParams0x%06X", zRoom->GetName().c_str(),
|
||||
texture->segmentOffset),
|
||||
texture->params[0]->GenerateSourceCode(zRoom, texture->segmentOffset));
|
||||
break;
|
||||
case 5:
|
||||
zRoom->parent->AddDeclaration(
|
||||
texture->segmentOffset, DeclarationAlignment::Align4, DeclarationPadding::None, 12,
|
||||
"CyclingTextureParams",
|
||||
StringHelper::Sprintf("%sAnimatedTextureParams0x%06X", zRoom->GetName().c_str(),
|
||||
texture->segmentOffset),
|
||||
texture->params[0]->GenerateSourceCode(zRoom, texture->segmentOffset));
|
||||
break;
|
||||
case 6:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SetAnimatedTextureList::~SetAnimatedTextureList()
|
||||
{
|
||||
for (AnimatedTexture* texture : textures)
|
||||
delete texture;
|
||||
}
|
||||
|
||||
AnitmatedTextureParams::~AnitmatedTextureParams()
|
||||
{
|
||||
}
|
||||
|
||||
string SetAnimatedTextureList::GenerateSourceCodePass1(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
return StringHelper::Sprintf(
|
||||
"%s 0, (u32)%sAnimatedTextureList0x%06X",
|
||||
ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(),
|
||||
zRoom->GetName().c_str(), segmentOffset);
|
||||
}
|
||||
|
||||
size_t SetAnimatedTextureList::GetRawDataSize()
|
||||
{
|
||||
size_t paramsSize = 0;
|
||||
for (AnimatedTexture* texture : textures)
|
||||
{
|
||||
for (AnitmatedTextureParams* param : texture->params)
|
||||
{
|
||||
paramsSize += param->GetParamsSize();
|
||||
}
|
||||
}
|
||||
|
||||
return ZRoomCommand::GetRawDataSize() + paramsSize;
|
||||
}
|
||||
|
||||
string SetAnimatedTextureList::GenerateExterns()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
string SetAnimatedTextureList::GetCommandCName()
|
||||
{
|
||||
return "SCmdTextureAnimations";
|
||||
}
|
||||
|
||||
RoomCommand SetAnimatedTextureList::GetRoomCommand()
|
||||
{
|
||||
return RoomCommand::SetAnimatedTextureList;
|
||||
}
|
||||
|
||||
string SetAnimatedTextureList::GetSourceOutputCode(std::string prefix)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
AnimatedTexture::AnimatedTexture(std::vector<uint8_t> rawData, uint32_t rawDataIndex)
|
||||
: segment(rawData[rawDataIndex]), type(BitConverter::ToInt16BE(rawData, rawDataIndex + 2)),
|
||||
segmentOffset(GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 4)))
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
params.push_back(new ScrollingTexture(rawData, segmentOffset));
|
||||
break;
|
||||
case 1:
|
||||
params.push_back(new ScrollingTexture(rawData, segmentOffset));
|
||||
params.push_back(new ScrollingTexture(rawData, segmentOffset + 4));
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
params.push_back(new FlashingTexture(rawData, segmentOffset, type));
|
||||
break;
|
||||
case 5:
|
||||
params.push_back(new CyclingTextureParams(rawData, segmentOffset));
|
||||
break;
|
||||
case 6: // Some terminator when there are no animated textures?
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
AnimatedTexture::~AnimatedTexture()
|
||||
{
|
||||
for (AnitmatedTextureParams* param : params)
|
||||
delete param;
|
||||
}
|
||||
|
||||
ScrollingTexture::ScrollingTexture(std::vector<uint8_t> rawData, uint32_t rawDataIndex)
|
||||
: xStep(rawData[rawDataIndex + 0]), yStep(rawData[rawDataIndex + 1]),
|
||||
width(rawData[rawDataIndex + 2]), height(rawData[rawDataIndex + 3])
|
||||
{
|
||||
}
|
||||
|
||||
std::string ScrollingTexture::GenerateSourceCode(ZRoom* zRoom, uint32_t baseAddress)
|
||||
{
|
||||
return StringHelper::Sprintf(" { %i, %i, 0x%02X, 0x%02X },", xStep, yStep, width, height);
|
||||
}
|
||||
|
||||
size_t ScrollingTexture::GetParamsSize()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
FlashingTexturePrimColor::FlashingTexturePrimColor(std::vector<uint8_t> rawData, uint32_t rawDataIndex)
|
||||
: r(rawData[rawDataIndex + 0]), g(rawData[rawDataIndex + 1]), b(rawData[rawDataIndex + 2]),
|
||||
a(rawData[rawDataIndex + 3]), lodFrac(rawData[rawDataIndex + 4])
|
||||
{
|
||||
}
|
||||
|
||||
FlashingTextureEnvColor::FlashingTextureEnvColor(std::vector<uint8_t> rawData, uint32_t rawDataIndex)
|
||||
: r(rawData[rawDataIndex + 0]), g(rawData[rawDataIndex + 1]), b(rawData[rawDataIndex + 2]),
|
||||
a(rawData[rawDataIndex + 3])
|
||||
{
|
||||
}
|
||||
|
||||
FlashingTexture::FlashingTexture(std::vector<uint8_t> rawData, uint32_t rawDataIndex, int32_t type)
|
||||
: cycleLength(BitConverter::ToUInt16BE(rawData, rawDataIndex + 0)),
|
||||
numKeyFrames(BitConverter::ToUInt16BE(rawData, rawDataIndex + 2)),
|
||||
primColorSegmentOffset(GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 4))),
|
||||
envColorSegmentOffset(GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 8))),
|
||||
keyFrameSegmentOffset(GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 12)))
|
||||
{
|
||||
uint16_t length = (type == 2) ? cycleLength : numKeyFrames;
|
||||
|
||||
int32_t currentPtr = primColorSegmentOffset;
|
||||
for (uint16_t i = 0; i < length; i++)
|
||||
{
|
||||
primColors.push_back(FlashingTexturePrimColor(rawData, currentPtr));
|
||||
currentPtr += 5;
|
||||
}
|
||||
|
||||
currentPtr = envColorSegmentOffset;
|
||||
for (uint16_t i = 0; i < length; i++)
|
||||
{
|
||||
envColors.push_back(FlashingTextureEnvColor(rawData, currentPtr));
|
||||
currentPtr += 4;
|
||||
}
|
||||
|
||||
currentPtr = keyFrameSegmentOffset;
|
||||
for (uint16_t i = 0; i < length; i++)
|
||||
{
|
||||
keyFrames.push_back(BitConverter::ToUInt16BE(rawData, currentPtr));
|
||||
currentPtr += 2;
|
||||
}
|
||||
}
|
||||
|
||||
std::string FlashingTexture::GenerateSourceCode(ZRoom* zRoom, uint32_t baseAddress)
|
||||
{
|
||||
if (primColorSegmentOffset != 0)
|
||||
{
|
||||
string declaration = "";
|
||||
size_t index = 0;
|
||||
|
||||
for (FlashingTexturePrimColor& color : primColors)
|
||||
{
|
||||
declaration += StringHelper::Sprintf(" { 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X },",
|
||||
color.r, color.g, color.b, color.a, color.lodFrac);
|
||||
|
||||
if (index < primColors.size() - 1)
|
||||
declaration += "\n";
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
zRoom->parent->AddDeclarationArray(
|
||||
primColorSegmentOffset, DeclarationAlignment::Align4, DeclarationPadding::None,
|
||||
primColors.size() * 5, "FlashingTexturePrimColor",
|
||||
StringHelper::Sprintf("%sAnimatedTexturePrimColor0x%06X", zRoom->GetName().c_str(),
|
||||
primColorSegmentOffset),
|
||||
primColors.size(), declaration);
|
||||
}
|
||||
|
||||
if (envColorSegmentOffset != 0)
|
||||
{
|
||||
string declaration = "";
|
||||
size_t index = 0;
|
||||
|
||||
for (FlashingTextureEnvColor& color : envColors)
|
||||
{
|
||||
declaration += StringHelper::Sprintf(" { 0x%02X, 0x%02X, 0x%02X, 0x%02X },", color.r,
|
||||
color.g, color.b, color.a);
|
||||
|
||||
if (index < envColors.size() - 1)
|
||||
declaration += "\n";
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
zRoom->parent->AddDeclarationArray(
|
||||
envColorSegmentOffset, DeclarationAlignment::Align4, DeclarationPadding::None,
|
||||
envColors.size() * 4, "Color_RGBA8",
|
||||
StringHelper::Sprintf("%sAnimatedTextureEnvColors0x%06X", zRoom->GetName().c_str(),
|
||||
envColorSegmentOffset),
|
||||
envColors.size(), declaration);
|
||||
}
|
||||
|
||||
if (keyFrameSegmentOffset != 0)
|
||||
{
|
||||
string declaration = "";
|
||||
size_t index = 0;
|
||||
|
||||
for (uint16_t keyFrame : keyFrames)
|
||||
{
|
||||
declaration += StringHelper::Sprintf(" 0x%02X,", keyFrame);
|
||||
|
||||
if (index < keyFrames.size() - 1)
|
||||
declaration += "\n";
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
zRoom->parent->AddDeclarationArray(keyFrameSegmentOffset, DeclarationAlignment::Align4,
|
||||
DeclarationPadding::None, keyFrames.size() * 2, "u16",
|
||||
StringHelper::Sprintf("%sAnimatedTextureKeyFrames0x%06X",
|
||||
zRoom->GetName().c_str(),
|
||||
keyFrameSegmentOffset),
|
||||
keyFrames.size(), declaration);
|
||||
}
|
||||
|
||||
return StringHelper::Sprintf(
|
||||
"%i, %i, (u32)%s, (u32)%s, (u32)%s", cycleLength, numKeyFrames,
|
||||
(primColorSegmentOffset != 0) ?
|
||||
StringHelper::Sprintf("%sAnimatedTexturePrimColor0x%06X", zRoom->GetName().c_str(),
|
||||
primColorSegmentOffset)
|
||||
.c_str() :
|
||||
"NULL",
|
||||
(envColorSegmentOffset != 0) ?
|
||||
StringHelper::Sprintf("%sAnimatedTextureEnvColors0x%06X", zRoom->GetName().c_str(),
|
||||
envColorSegmentOffset)
|
||||
.c_str() :
|
||||
"NULL",
|
||||
(keyFrameSegmentOffset != 0) ?
|
||||
StringHelper::Sprintf("%sAnimatedTextureKeyFrames0x%06X", zRoom->GetName().c_str(),
|
||||
keyFrameSegmentOffset)
|
||||
.c_str() :
|
||||
"NULL");
|
||||
}
|
||||
|
||||
size_t FlashingTexture::GetParamsSize()
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
|
||||
CyclingTextureParams::CyclingTextureParams(std::vector<uint8_t> rawData, uint32_t rawDataIndex)
|
||||
: cycleLength(BitConverter::ToUInt16BE(rawData, rawDataIndex + 0)),
|
||||
textureSegmentOffsetsSegmentOffset(
|
||||
GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 4))),
|
||||
textureIndicesSegmentOffset(GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 8)))
|
||||
{
|
||||
int32_t currentPtr = textureIndicesSegmentOffset;
|
||||
int32_t maxIndex = 0;
|
||||
|
||||
for (uint16_t i = 0; i < cycleLength; i++)
|
||||
{
|
||||
int32_t newIndex = rawData[currentPtr];
|
||||
textureIndices.push_back(newIndex);
|
||||
currentPtr++;
|
||||
if (newIndex > maxIndex)
|
||||
maxIndex = newIndex;
|
||||
}
|
||||
|
||||
currentPtr = textureSegmentOffsetsSegmentOffset;
|
||||
for (int32_t i = 0; i < maxIndex + 1; i++)
|
||||
{
|
||||
textureSegmentOffsets.push_back(GETSEGOFFSET(BitConverter::ToInt32BE(rawData, currentPtr)));
|
||||
currentPtr += 4;
|
||||
}
|
||||
}
|
||||
|
||||
std::string CyclingTextureParams::GenerateSourceCode(ZRoom* zRoom, uint32_t baseAddress)
|
||||
{
|
||||
if (textureSegmentOffsetsSegmentOffset != 0)
|
||||
{
|
||||
string declaration = "";
|
||||
size_t index = 0;
|
||||
|
||||
for (uint32_t offset : textureSegmentOffsets)
|
||||
{
|
||||
declaration +=
|
||||
StringHelper::Sprintf(" %sTex_%06X,", zRoom->GetName().c_str(), offset);
|
||||
|
||||
if (index < textureSegmentOffsets.size() - 1)
|
||||
declaration += "\n";
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
zRoom->parent->AddDeclarationArray(
|
||||
textureSegmentOffsetsSegmentOffset, DeclarationAlignment::Align4,
|
||||
DeclarationPadding::None, textureSegmentOffsets.size() * 4, "u64*",
|
||||
StringHelper::Sprintf("%sAnimatedTextureTexSegOffsets0x%06X", zRoom->GetName().c_str(),
|
||||
textureSegmentOffsetsSegmentOffset),
|
||||
textureSegmentOffsets.size(), declaration);
|
||||
}
|
||||
|
||||
if (textureIndicesSegmentOffset != 0)
|
||||
{
|
||||
string declaration = "";
|
||||
size_t index = 0;
|
||||
|
||||
for (uint8_t textureIndex : textureIndices)
|
||||
{
|
||||
declaration += StringHelper::Sprintf(" 0x%02X,", textureIndex);
|
||||
|
||||
if (index < textureIndices.size() - 1)
|
||||
declaration += "\n";
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
zRoom->parent->AddDeclarationArray(
|
||||
textureIndicesSegmentOffset, DeclarationAlignment::Align4, DeclarationPadding::None,
|
||||
textureIndices.size(), "u8",
|
||||
StringHelper::Sprintf("%sAnimatedTextureTexIndices0x%06X", zRoom->GetName().c_str(),
|
||||
textureIndicesSegmentOffset),
|
||||
textureIndices.size(), declaration);
|
||||
}
|
||||
|
||||
return StringHelper::Sprintf(
|
||||
"%i, (u32)%s, (u32)%s", cycleLength,
|
||||
(textureSegmentOffsetsSegmentOffset != 0) ?
|
||||
StringHelper::Sprintf("%sAnimatedTextureTexSegOffsets0x%06X", zRoom->GetName().c_str(),
|
||||
textureSegmentOffsetsSegmentOffset)
|
||||
.c_str() :
|
||||
"NULL",
|
||||
(textureIndicesSegmentOffset != 0) ?
|
||||
StringHelper::Sprintf("%sAnimatedTextureTexIndices0x%06X", zRoom->GetName().c_str(),
|
||||
textureIndicesSegmentOffset)
|
||||
.c_str() :
|
||||
"NULL");
|
||||
}
|
||||
|
||||
size_t CyclingTextureParams::GetParamsSize()
|
||||
{
|
||||
return 12;
|
||||
}
|
113
tools/ZAPD/ZAPD/ZRoom/Commands/SetAnimatedTextureList.h
Normal file
113
tools/ZAPD/ZAPD/ZRoom/Commands/SetAnimatedTextureList.h
Normal file
|
@ -0,0 +1,113 @@
|
|||
#pragma once
|
||||
|
||||
#include "../ZRoomCommand.h"
|
||||
|
||||
// TODO move into header and add all types
|
||||
class AnitmatedTextureParams
|
||||
{
|
||||
public:
|
||||
virtual ~AnitmatedTextureParams();
|
||||
virtual std::string GenerateSourceCode(ZRoom* zRoom, uint32_t baseAddress) = 0;
|
||||
virtual size_t GetParamsSize() = 0;
|
||||
};
|
||||
|
||||
class ScrollingTexture : public AnitmatedTextureParams
|
||||
{
|
||||
public:
|
||||
ScrollingTexture(std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
std::string GenerateSourceCode(ZRoom* zRoom, uint32_t baseAddress) override;
|
||||
size_t GetParamsSize() override;
|
||||
|
||||
int8_t xStep;
|
||||
int8_t yStep;
|
||||
uint8_t width;
|
||||
uint8_t height;
|
||||
};
|
||||
|
||||
class FlashingTexturePrimColor
|
||||
{
|
||||
public:
|
||||
FlashingTexturePrimColor(std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
|
||||
uint8_t r;
|
||||
uint8_t g;
|
||||
uint8_t b;
|
||||
uint8_t a;
|
||||
uint8_t lodFrac;
|
||||
};
|
||||
|
||||
class FlashingTextureEnvColor
|
||||
{
|
||||
public:
|
||||
FlashingTextureEnvColor(std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
|
||||
uint8_t r;
|
||||
uint8_t g;
|
||||
uint8_t b;
|
||||
uint8_t a;
|
||||
};
|
||||
|
||||
class FlashingTexture : public AnitmatedTextureParams
|
||||
{
|
||||
public:
|
||||
FlashingTexture(std::vector<uint8_t> rawData, uint32_t rawDataIndex, int32_t type);
|
||||
std::string GenerateSourceCode(ZRoom* zRoom, uint32_t baseAddress) override;
|
||||
size_t GetParamsSize() override;
|
||||
|
||||
uint16_t cycleLength;
|
||||
uint16_t numKeyFrames;
|
||||
uint32_t primColorSegmentOffset;
|
||||
uint32_t envColorSegmentOffset;
|
||||
uint32_t keyFrameSegmentOffset;
|
||||
|
||||
std::vector<FlashingTexturePrimColor> primColors;
|
||||
std::vector<FlashingTextureEnvColor> envColors;
|
||||
std::vector<uint16_t> keyFrames;
|
||||
};
|
||||
|
||||
class CyclingTextureParams : public AnitmatedTextureParams
|
||||
{
|
||||
public:
|
||||
CyclingTextureParams(std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
std::string GenerateSourceCode(ZRoom* zRoom, uint32_t baseAddress) override;
|
||||
size_t GetParamsSize() override;
|
||||
|
||||
uint16_t cycleLength;
|
||||
uint32_t textureSegmentOffsetsSegmentOffset;
|
||||
uint32_t textureIndicesSegmentOffset;
|
||||
|
||||
std::vector<uint32_t> textureSegmentOffsets;
|
||||
std::vector<uint8_t> textureIndices;
|
||||
};
|
||||
|
||||
class AnimatedTexture
|
||||
{
|
||||
public:
|
||||
AnimatedTexture(std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
virtual ~AnimatedTexture();
|
||||
|
||||
int8_t segment;
|
||||
int16_t type;
|
||||
uint32_t segmentOffset;
|
||||
std::vector<AnitmatedTextureParams*> params;
|
||||
};
|
||||
|
||||
class SetAnimatedTextureList : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetAnimatedTextureList(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
~SetAnimatedTextureList();
|
||||
|
||||
std::string GetSourceOutputCode(std::string prefix);
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, uint32_t baseAddress) override;
|
||||
virtual RoomCommand GetRoomCommand() override;
|
||||
virtual size_t GetRawDataSize() override;
|
||||
virtual std::string GetCommandCName() override;
|
||||
virtual std::string GenerateExterns() override;
|
||||
|
||||
private:
|
||||
uint32_t segmentOffset;
|
||||
std::vector<AnimatedTexture*> textures;
|
||||
std::vector<uint8_t> _rawData;
|
||||
int32_t _rawDataIndex;
|
||||
};
|
|
@ -4,14 +4,14 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
SetCameraSettings::SetCameraSettings(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex)
|
||||
SetCameraSettings::SetCameraSettings(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex)
|
||||
: ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
cameraMovement = rawData[rawDataIndex + 0x01];
|
||||
mapHighlight = BitConverter::ToInt32BE(rawData, rawDataIndex + 4);
|
||||
}
|
||||
|
||||
string SetCameraSettings::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
string SetCameraSettings::GenerateSourceCodePass1(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
return StringHelper::Sprintf(
|
||||
"%s 0x%02X, 0x%08X", ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(),
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
class SetCameraSettings : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetCameraSettings(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
SetCameraSettings(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GetCommandCName();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, uint32_t baseAddress) override;
|
||||
virtual std::string GetCommandCName() override;
|
||||
virtual RoomCommand GetRoomCommand() override;
|
||||
|
||||
private:
|
||||
uint8_t cameraMovement;
|
||||
|
|
|
@ -7,17 +7,19 @@
|
|||
using namespace std;
|
||||
|
||||
SetCollisionHeader::SetCollisionHeader(ZRoom* nZRoom, std::vector<uint8_t> rawData,
|
||||
int rawDataIndex)
|
||||
uint32_t rawDataIndex)
|
||||
: ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
segmentOffset = GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 4));
|
||||
collisionHeader = ZCollisionHeader(
|
||||
nZRoom->parent,
|
||||
StringHelper::Sprintf("%sCollisionHeader0x%06X", nZRoom->GetName().c_str(), segmentOffset),
|
||||
rawData, segmentOffset);
|
||||
collisionHeader = new ZCollisionHeader(nZRoom->parent);
|
||||
collisionHeader->SetRawData(rawData);
|
||||
collisionHeader->SetRawDataIndex(segmentOffset);
|
||||
collisionHeader->SetName(
|
||||
StringHelper::Sprintf("%sCollisionHeader0x%06X", nZRoom->GetName().c_str(), segmentOffset));
|
||||
collisionHeader->ParseRawData();
|
||||
}
|
||||
|
||||
string SetCollisionHeader::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
string SetCollisionHeader::GenerateSourceCodePass1(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
return StringHelper::Sprintf(
|
||||
"%s 0x00, (u32)&%sCollisionHeader0x%06X",
|
||||
|
@ -25,7 +27,7 @@ string SetCollisionHeader::GenerateSourceCodePass1(string roomName, int baseAddr
|
|||
zRoom->GetName().c_str(), segmentOffset);
|
||||
}
|
||||
|
||||
string SetCollisionHeader::GenerateSourceCodePass2(string roomName, int baseAddress)
|
||||
string SetCollisionHeader::GenerateSourceCodePass2(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -6,15 +6,15 @@
|
|||
class SetCollisionHeader : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetCollisionHeader(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
SetCollisionHeader(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GenerateSourceCodePass2(std::string roomName, int baseAddress);
|
||||
virtual std::string GetCommandCName();
|
||||
virtual std::string GenerateExterns();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, uint32_t baseAddress) override;
|
||||
virtual std::string GenerateSourceCodePass2(std::string roomName, uint32_t baseAddress) override;
|
||||
virtual std::string GetCommandCName() override;
|
||||
virtual std::string GenerateExterns() override;
|
||||
virtual RoomCommand GetRoomCommand() override;
|
||||
|
||||
private:
|
||||
ZCollisionHeader collisionHeader;
|
||||
ZCollisionHeader* collisionHeader;
|
||||
uint32_t segmentOffset;
|
||||
};
|
153
tools/ZAPD/ZAPD/ZRoom/Commands/SetCsCamera.cpp
Normal file
153
tools/ZAPD/ZAPD/ZRoom/Commands/SetCsCamera.cpp
Normal file
|
@ -0,0 +1,153 @@
|
|||
#include "SetCsCamera.h"
|
||||
#include "../../BitConverter.h"
|
||||
#include "../../StringHelper.h"
|
||||
#include "../../ZFile.h"
|
||||
#include "../ZRoom.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SetCsCamera::SetCsCamera(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex)
|
||||
: ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
_rawData = rawData;
|
||||
_rawDataIndex = rawDataIndex;
|
||||
|
||||
segmentOffset = 0;
|
||||
|
||||
int32_t numCameras = rawData[rawDataIndex + 1];
|
||||
segmentOffset = GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 4));
|
||||
|
||||
uint32_t currentPtr = segmentOffset;
|
||||
int32_t numPoints = 0;
|
||||
|
||||
for (int32_t i = 0; i < numCameras; i++)
|
||||
{
|
||||
CsCameraEntry* entry = new CsCameraEntry(_rawData, currentPtr);
|
||||
|
||||
cameras.push_back(entry);
|
||||
numPoints += entry->numPoints;
|
||||
|
||||
currentPtr += 8;
|
||||
}
|
||||
|
||||
if (numPoints > 0)
|
||||
{
|
||||
uint32_t currentPtr = cameras[0]->segmentOffset;
|
||||
|
||||
for (int32_t i = 0; i < numPoints; i++)
|
||||
{
|
||||
int16_t x = BitConverter::ToInt16BE(rawData, currentPtr + 0);
|
||||
int16_t y = BitConverter::ToInt16BE(rawData, currentPtr + 2);
|
||||
int16_t z = BitConverter::ToInt16BE(rawData, currentPtr + 4);
|
||||
Vec3s p = {x, y, z};
|
||||
points.push_back(p);
|
||||
currentPtr += 6;
|
||||
}
|
||||
}
|
||||
|
||||
if (segmentOffset != 0)
|
||||
zRoom->parent->AddDeclarationPlaceholder(segmentOffset);
|
||||
}
|
||||
|
||||
SetCsCamera::~SetCsCamera()
|
||||
{
|
||||
for (CsCameraEntry* entry : cameras)
|
||||
delete entry;
|
||||
}
|
||||
|
||||
string SetCsCamera::GetSourceOutputCode(std::string prefix)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
string SetCsCamera::GenerateSourceCodePass1(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
string SetCsCamera::GenerateSourceCodePass2(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
string sourceOutput = "";
|
||||
|
||||
sourceOutput +=
|
||||
StringHelper::Sprintf("%s %i, (u32)&%sCsCameraList0x%06X };",
|
||||
ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(),
|
||||
cameras.size(), roomName.c_str(), segmentOffset);
|
||||
|
||||
if (points.size() > 0)
|
||||
{
|
||||
string declaration = "";
|
||||
size_t index = 0;
|
||||
for (Vec3s point : points)
|
||||
{
|
||||
declaration += StringHelper::Sprintf(" { %i, %i, %i }, //0x%06X", point.x, point.y,
|
||||
point.z, cameras[0]->segmentOffset + (index * 6));
|
||||
|
||||
if (index < points.size() - 1)
|
||||
declaration += "\n";
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
zRoom->parent->AddDeclarationArray(cameras[0]->segmentOffset, DeclarationAlignment::None,
|
||||
DeclarationPadding::None, points.size() * 6, "Vec3s",
|
||||
StringHelper::Sprintf("%sCsCameraPoints0x%06X",
|
||||
roomName.c_str(),
|
||||
cameras[0]->segmentOffset),
|
||||
points.size(), declaration);
|
||||
}
|
||||
|
||||
{
|
||||
string declaration = "";
|
||||
|
||||
size_t index = 0;
|
||||
size_t pointsIndex = 0;
|
||||
for (CsCameraEntry* entry : cameras)
|
||||
{
|
||||
declaration += StringHelper::Sprintf(" %i, %i, (u32)&%sCsCameraPoints0x%06X[%i],",
|
||||
entry->type, entry->numPoints, roomName.c_str(),
|
||||
cameras[0]->segmentOffset, pointsIndex);
|
||||
|
||||
if (index < cameras.size() - 1)
|
||||
declaration += "\n";
|
||||
|
||||
index++;
|
||||
pointsIndex += entry->numPoints;
|
||||
}
|
||||
|
||||
zRoom->parent->AddDeclarationArray(
|
||||
segmentOffset, DeclarationAlignment::Align4, DeclarationPadding::Pad16,
|
||||
cameras.size() * 8, "CsCameraEntry",
|
||||
StringHelper::Sprintf("%sCsCameraList0x%06X", roomName.c_str(), segmentOffset),
|
||||
cameras.size(), declaration);
|
||||
}
|
||||
|
||||
return sourceOutput;
|
||||
}
|
||||
|
||||
size_t SetCsCamera::GetRawDataSize()
|
||||
{
|
||||
return ZRoomCommand::GetRawDataSize() + (cameras.size() * 8) + (points.size() * 6);
|
||||
}
|
||||
|
||||
string SetCsCamera::GenerateExterns()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
string SetCsCamera::GetCommandCName()
|
||||
{
|
||||
return "SCmdCsCameraList";
|
||||
}
|
||||
|
||||
RoomCommand SetCsCamera::GetRoomCommand()
|
||||
{
|
||||
return RoomCommand::SetCsCamera;
|
||||
}
|
||||
|
||||
CsCameraEntry::CsCameraEntry(std::vector<uint8_t> rawData, uint32_t rawDataIndex)
|
||||
: baseOffset(rawDataIndex), type(BitConverter::ToInt16BE(rawData, rawDataIndex + 0)),
|
||||
numPoints(BitConverter::ToInt16BE(rawData, rawDataIndex + 2)),
|
||||
segmentOffset(GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 4)))
|
||||
{
|
||||
}
|
37
tools/ZAPD/ZAPD/ZRoom/Commands/SetCsCamera.h
Normal file
37
tools/ZAPD/ZAPD/ZRoom/Commands/SetCsCamera.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
#pragma once
|
||||
|
||||
#include "../../Vec3s.h"
|
||||
#include "../ZRoomCommand.h"
|
||||
|
||||
class CsCameraEntry
|
||||
{
|
||||
public:
|
||||
CsCameraEntry(std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
|
||||
int32_t baseOffset;
|
||||
int32_t type;
|
||||
int32_t numPoints;
|
||||
uint32_t segmentOffset;
|
||||
};
|
||||
|
||||
class SetCsCamera : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetCsCamera(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
~SetCsCamera();
|
||||
|
||||
std::string GetSourceOutputCode(std::string prefix);
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, uint32_t baseAddress) override;
|
||||
virtual std::string GenerateSourceCodePass2(std::string roomName, uint32_t baseAddress) override;
|
||||
virtual RoomCommand GetRoomCommand() override;
|
||||
virtual size_t GetRawDataSize() override;
|
||||
virtual std::string GetCommandCName() override;
|
||||
virtual std::string GenerateExterns() override;
|
||||
|
||||
private:
|
||||
uint32_t segmentOffset;
|
||||
std::vector<CsCameraEntry*> cameras;
|
||||
std::vector<Vec3s> points;
|
||||
std::vector<uint8_t> _rawData;
|
||||
int32_t _rawDataIndex;
|
||||
};
|
|
@ -1,69 +1,118 @@
|
|||
#include "SetCutscenes.h"
|
||||
#include "../../BitConverter.h"
|
||||
#include "../../Globals.h"
|
||||
#include "../../StringHelper.h"
|
||||
#include "../../ZFile.h"
|
||||
#include "../ZRoom.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SetCutscenes::SetCutscenes(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex)
|
||||
SetCutscenes::SetCutscenes(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex)
|
||||
: ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
segmentOffset = BitConverter::ToInt32BE(rawData, rawDataIndex + 4) & 0x00FFFFFF;
|
||||
numCutscenes = rawData[rawDataIndex + 1];
|
||||
segmentOffset = GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 4));
|
||||
|
||||
string output = "";
|
||||
|
||||
cutscene = new ZCutscene(rawData, segmentOffset, 9999);
|
||||
|
||||
output += cutscene->GetSourceOutputCode(zRoom->GetName());
|
||||
|
||||
if (segmentOffset != 0)
|
||||
if (Globals::Instance->game == ZGame::OOT_RETAIL || Globals::Instance->game == ZGame::OOT_SW97)
|
||||
{
|
||||
Declaration* decl = zRoom->parent->GetDeclaration(segmentOffset);
|
||||
ZCutscene* cutscene = new ZCutscene(nZRoom->parent);
|
||||
cutscene->ExtractFromFile(rawData, segmentOffset, "");
|
||||
|
||||
auto decl = nZRoom->parent->GetDeclaration(segmentOffset);
|
||||
if (decl == nullptr)
|
||||
{
|
||||
cutscene->DeclareVar(zRoom->GetName().c_str(), "");
|
||||
}
|
||||
|
||||
cutscenes.push_back(cutscene);
|
||||
}
|
||||
else
|
||||
{
|
||||
int32_t currentPtr = segmentOffset;
|
||||
string declaration = "";
|
||||
|
||||
for (uint8_t i = 0; i < numCutscenes; i++)
|
||||
{
|
||||
CutsceneEntry* entry = new CutsceneEntry(rawData, currentPtr);
|
||||
cutsceneEntries.push_back(entry);
|
||||
currentPtr += 8;
|
||||
|
||||
declaration += StringHelper::Sprintf(
|
||||
" { %sCutsceneData0x%06X, 0x%04X, 0x%02X, 0x%02X },", zRoom->GetName().c_str(),
|
||||
entry->segmentOffset, entry->exit, entry->entrance, entry->flag);
|
||||
|
||||
if (i < numCutscenes - 1)
|
||||
declaration += "\n";
|
||||
|
||||
ZCutsceneMM* cutscene = new ZCutsceneMM(nZRoom->parent);
|
||||
cutscene->ExtractFromXML(
|
||||
nullptr, rawData, entry->segmentOffset,
|
||||
""); // TODO: Use ExtractFromFile() here when that gets implemented
|
||||
cutscenes.push_back(cutscene);
|
||||
}
|
||||
|
||||
zRoom->parent->AddDeclarationArray(
|
||||
segmentOffset, DeclarationAlignment::None, DeclarationPadding::Pad16,
|
||||
cutscene->GetRawDataSize(), "s32",
|
||||
StringHelper::Sprintf("%sCutsceneData0x%06X", zRoom->GetName().c_str(),
|
||||
segmentOffset, DeclarationAlignment::None, DeclarationPadding::None,
|
||||
cutsceneEntries.size() * 8, "CutsceneEntry",
|
||||
StringHelper::Sprintf("%sCutsceneEntryList0x%06X", zRoom->GetName().c_str(),
|
||||
segmentOffset),
|
||||
0, output);
|
||||
cutsceneEntries.size(), declaration);
|
||||
}
|
||||
|
||||
for (ZCutsceneBase* cutscene : cutscenes)
|
||||
{
|
||||
if (cutscene->getSegmentOffset() != 0)
|
||||
{
|
||||
Declaration* decl = zRoom->parent->GetDeclaration(cutscene->getSegmentOffset());
|
||||
if (decl == nullptr)
|
||||
{
|
||||
cutscene->GetSourceOutputCode(zRoom->GetName());
|
||||
}
|
||||
else if (decl->text == "")
|
||||
{
|
||||
decl->text = output;
|
||||
decl->text = cutscene->GetBodySourceCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SetCutscenes::~SetCutscenes()
|
||||
{
|
||||
if (cutscene != nullptr)
|
||||
{
|
||||
for (ZCutsceneBase* cutscene : cutscenes)
|
||||
delete cutscene;
|
||||
cutscene = nullptr;
|
||||
}
|
||||
|
||||
for (CutsceneEntry* entry : cutsceneEntries)
|
||||
delete entry;
|
||||
}
|
||||
|
||||
string SetCutscenes::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
string SetCutscenes::GenerateSourceCodePass1(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
string pass1 = ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress);
|
||||
Declaration* decl = zRoom->parent->GetDeclaration(segmentOffset);
|
||||
if (decl != nullptr)
|
||||
{
|
||||
return StringHelper::Sprintf("%s 0, (u32)%s", pass1.c_str(), decl->varName.c_str());
|
||||
return StringHelper::Sprintf("%s %i, (u32)%s", pass1.c_str(), numCutscenes,
|
||||
decl->varName.c_str());
|
||||
}
|
||||
return StringHelper::Sprintf("%s 0, (u32)%sCutsceneData0x%06X", pass1.c_str(),
|
||||
return StringHelper::Sprintf("%s %i, (u32)%sCutsceneData0x%06X", pass1.c_str(), numCutscenes,
|
||||
zRoom->GetName().c_str(), segmentOffset);
|
||||
}
|
||||
|
||||
int32_t SetCutscenes::GetRawDataSize()
|
||||
size_t SetCutscenes::GetRawDataSize()
|
||||
{
|
||||
return ZRoomCommand::GetRawDataSize() + (0);
|
||||
}
|
||||
|
||||
string SetCutscenes::GenerateExterns()
|
||||
{
|
||||
if (Globals::Instance->game == ZGame::MM_RETAIL)
|
||||
{
|
||||
return StringHelper::Sprintf("extern CutsceneEntry %sCutsceneEntryList0x%06X[];\n",
|
||||
zRoom->GetName().c_str(), segmentOffset);
|
||||
}
|
||||
|
||||
Declaration* decl = zRoom->parent->GetDeclaration(segmentOffset);
|
||||
if (decl != nullptr && decl->varName != "")
|
||||
{
|
||||
|
@ -87,3 +136,10 @@ string SetCutscenes::GetSourceOutputCode(std::string prefix)
|
|||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
CutsceneEntry::CutsceneEntry(std::vector<uint8_t> rawData, uint32_t rawDataIndex)
|
||||
: segmentOffset(BitConverter::ToInt32BE(rawData, rawDataIndex + 0) & 0x00FFFFFF),
|
||||
exit(BitConverter::ToInt16BE(rawData, rawDataIndex + 4)), entrance(rawData[rawDataIndex + 6]),
|
||||
flag(rawData[rawDataIndex + 7])
|
||||
{
|
||||
}
|
||||
|
|
|
@ -1,24 +1,38 @@
|
|||
#pragma once
|
||||
|
||||
#include "../../ZCutscene.h"
|
||||
#include "../../ZCutsceneMM.h"
|
||||
#include "../ZRoomCommand.h"
|
||||
|
||||
class CutsceneEntry
|
||||
{
|
||||
public:
|
||||
CutsceneEntry(std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
|
||||
uint32_t segmentOffset;
|
||||
uint16_t exit;
|
||||
uint8_t entrance;
|
||||
uint8_t flag;
|
||||
};
|
||||
|
||||
class SetCutscenes : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetCutscenes(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
SetCutscenes(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
~SetCutscenes();
|
||||
|
||||
std::string GetSourceOutputCode(std::string prefix);
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
virtual int32_t GetRawDataSize();
|
||||
virtual std::string GetCommandCName();
|
||||
virtual std::string GenerateExterns();
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, uint32_t baseAddress) override;
|
||||
virtual RoomCommand GetRoomCommand() override;
|
||||
virtual size_t GetRawDataSize() override;
|
||||
virtual std::string GetCommandCName() override;
|
||||
virtual std::string GenerateExterns() override;
|
||||
|
||||
private:
|
||||
ZCutscene* cutscene;
|
||||
std::vector<ZCutsceneBase*> cutscenes;
|
||||
std::vector<CutsceneEntry*> cutsceneEntries; // (MM Only)
|
||||
uint32_t segmentOffset;
|
||||
uint8_t numCutscenes; // (MM Only)
|
||||
std::vector<uint8_t> _rawData;
|
||||
int _rawDataIndex;
|
||||
int32_t _rawDataIndex;
|
||||
};
|
|
@ -3,13 +3,13 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
SetEchoSettings::SetEchoSettings(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex)
|
||||
SetEchoSettings::SetEchoSettings(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex)
|
||||
: ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
echo = rawData[rawDataIndex + 0x07];
|
||||
}
|
||||
|
||||
string SetEchoSettings::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
string SetEchoSettings::GenerateSourceCodePass1(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
return StringHelper::Sprintf(
|
||||
"%s 0, { 0 }, 0x%02X", ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(),
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
class SetEchoSettings : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetEchoSettings(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
SetEchoSettings(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GetCommandCName();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, uint32_t baseAddress) override;
|
||||
virtual std::string GetCommandCName() override;
|
||||
virtual RoomCommand GetRoomCommand() override;
|
||||
|
||||
private:
|
||||
uint8_t echo;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
SetEntranceList::SetEntranceList(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex)
|
||||
SetEntranceList::SetEntranceList(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex)
|
||||
: ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
segmentOffset = BitConverter::ToInt32BE(rawData, rawDataIndex + 4) & 0x00FFFFFF;
|
||||
|
@ -23,7 +23,7 @@ SetEntranceList::~SetEntranceList()
|
|||
delete entry;
|
||||
}
|
||||
|
||||
string SetEntranceList::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
string SetEntranceList::GenerateSourceCodePass1(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
string sourceOutput =
|
||||
StringHelper::Sprintf("%s 0x00, (u32)&%sEntranceList0x%06X",
|
||||
|
@ -32,10 +32,10 @@ string SetEntranceList::GenerateSourceCodePass1(string roomName, int baseAddress
|
|||
|
||||
// Parse Entrances and Generate Declaration
|
||||
zRoom->parent->AddDeclarationPlaceholder(segmentOffset); // Make sure this segment is defined
|
||||
int numEntrances = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 2;
|
||||
int32_t numEntrances = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 2;
|
||||
uint32_t currentPtr = segmentOffset;
|
||||
|
||||
for (int i = 0; i < numEntrances; i++)
|
||||
for (int32_t i = 0; i < numEntrances; i++)
|
||||
{
|
||||
EntranceEntry* entry = new EntranceEntry(_rawData, currentPtr);
|
||||
entrances.push_back(entry);
|
||||
|
@ -45,12 +45,12 @@ string SetEntranceList::GenerateSourceCodePass1(string roomName, int baseAddress
|
|||
|
||||
string declaration = "";
|
||||
|
||||
int index = 0;
|
||||
int32_t index = 0;
|
||||
|
||||
for (EntranceEntry* entry : entrances)
|
||||
{
|
||||
declaration +=
|
||||
StringHelper::Sprintf("\t{ 0x%02X, 0x%02X }, //0x%06X \n", entry->startPositionIndex,
|
||||
StringHelper::Sprintf(" { 0x%02X, 0x%02X }, //0x%06X \n", entry->startPositionIndex,
|
||||
entry->roomToLoad, segmentOffset + (index * 2));
|
||||
index++;
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ RoomCommand SetEntranceList::GetRoomCommand()
|
|||
return RoomCommand::SetEntranceList;
|
||||
}
|
||||
|
||||
EntranceEntry::EntranceEntry(std::vector<uint8_t> rawData, int rawDataIndex)
|
||||
EntranceEntry::EntranceEntry(std::vector<uint8_t> rawData, uint32_t rawDataIndex)
|
||||
{
|
||||
startPositionIndex = rawData[rawDataIndex + 0];
|
||||
roomToLoad = rawData[rawDataIndex + 1];
|
||||
|
|
|
@ -8,19 +8,19 @@ public:
|
|||
uint8_t startPositionIndex;
|
||||
uint8_t roomToLoad;
|
||||
|
||||
EntranceEntry(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
EntranceEntry(std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
};
|
||||
|
||||
class SetEntranceList : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetEntranceList(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
SetEntranceList(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
~SetEntranceList();
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GenerateExterns();
|
||||
virtual std::string GetCommandCName();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, uint32_t baseAddress) override;
|
||||
virtual std::string GenerateExterns() override;
|
||||
virtual std::string GetCommandCName() override;
|
||||
virtual RoomCommand GetRoomCommand() override;
|
||||
|
||||
private:
|
||||
std::vector<EntranceEntry*> entrances;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
SetExitList::SetExitList(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex)
|
||||
SetExitList::SetExitList(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex)
|
||||
: ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
segmentOffset = GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 4));
|
||||
|
@ -19,7 +19,7 @@ SetExitList::SetExitList(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDat
|
|||
_rawDataIndex = rawDataIndex;
|
||||
}
|
||||
|
||||
string SetExitList::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
string SetExitList::GenerateSourceCodePass1(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
string sourceOutput =
|
||||
StringHelper::Sprintf("%s 0x00, (u32)&%sExitList0x%06X",
|
||||
|
@ -28,10 +28,10 @@ string SetExitList::GenerateSourceCodePass1(string roomName, int baseAddress)
|
|||
|
||||
// Parse Entrances and Generate Declaration
|
||||
zRoom->parent->AddDeclarationPlaceholder(segmentOffset); // Make sure this segment is defined
|
||||
int numEntrances = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 2;
|
||||
int32_t numEntrances = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 2;
|
||||
uint32_t currentPtr = segmentOffset;
|
||||
|
||||
for (int i = 0; i < numEntrances; i++)
|
||||
for (int32_t i = 0; i < numEntrances; i++)
|
||||
{
|
||||
uint16_t exit = BitConverter::ToInt16BE(_rawData, currentPtr);
|
||||
exits.push_back(exit);
|
||||
|
@ -42,7 +42,7 @@ string SetExitList::GenerateSourceCodePass1(string roomName, int baseAddress)
|
|||
string declaration = "";
|
||||
|
||||
for (uint16_t exit : exits)
|
||||
declaration += StringHelper::Sprintf("\t0x%04X,\n", exit);
|
||||
declaration += StringHelper::Sprintf(" 0x%04X,\n", exit);
|
||||
;
|
||||
|
||||
zRoom->parent->AddDeclarationArray(
|
||||
|
|
|
@ -5,12 +5,12 @@
|
|||
class SetExitList : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetExitList(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
SetExitList(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GenerateExterns();
|
||||
virtual std::string GetCommandCName();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, uint32_t baseAddress) override;
|
||||
virtual std::string GenerateExterns() override;
|
||||
virtual std::string GetCommandCName() override;
|
||||
virtual RoomCommand GetRoomCommand() override;
|
||||
|
||||
private:
|
||||
std::vector<uint16_t> exits;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
SetLightList::SetLightList(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex)
|
||||
SetLightList::SetLightList(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex)
|
||||
: ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
this->ptrRoom = nZRoom;
|
||||
|
@ -15,23 +15,28 @@ SetLightList::SetLightList(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawD
|
|||
// this->ptrRoom->GetName().c_str(), this->segment);
|
||||
string declarations = "";
|
||||
|
||||
for (int i = 0; i < this->numLights; i++)
|
||||
int32_t currentPtr = this->segment;
|
||||
for (int32_t i = 0; i < this->numLights; i++)
|
||||
{
|
||||
uint8_t type = rawData[this->segment + ((0xE * i) + 0)];
|
||||
std::vector<uint16_t> params;
|
||||
uint8_t type = rawData[currentPtr + 0];
|
||||
int16_t x = BitConverter::ToInt16BE(rawData, currentPtr + 2);
|
||||
int16_t y = BitConverter::ToInt16BE(rawData, currentPtr + 4);
|
||||
int16_t z = BitConverter::ToInt16BE(rawData, currentPtr + 6);
|
||||
uint8_t r = rawData[currentPtr + 8];
|
||||
uint8_t g = rawData[currentPtr + 9];
|
||||
uint8_t b = rawData[currentPtr + 10];
|
||||
uint8_t drawGlow = rawData[currentPtr + 11];
|
||||
int16_t radius = BitConverter::ToInt16BE(rawData, currentPtr + 12);
|
||||
|
||||
for (int y = 0; y < 6; y++)
|
||||
{
|
||||
params.push_back(
|
||||
BitConverter::ToInt16BE(rawData, this->segment + ((0xE * i) + 2 + (y * 2))));
|
||||
}
|
||||
currentPtr += 14;
|
||||
|
||||
declarations += StringHelper::Sprintf(
|
||||
"\t{ 0x%02X, { 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X } },\n", type, params[0],
|
||||
params[1], params[2], params[3], params[4], params[5]);
|
||||
}
|
||||
" { 0x%02X, { %i, %i, %i, { 0x%02X, 0x%02X, 0x%02X }, 0x%02X, 0x%04X } },", type, x,
|
||||
y, z, r, g, b, drawGlow, radius);
|
||||
|
||||
declarations += "};\n";
|
||||
if (i < this->numLights - 1)
|
||||
declarations += "\n";
|
||||
}
|
||||
|
||||
this->ptrRoom->parent->AddDeclarationArray(
|
||||
this->segment, DeclarationAlignment::None, this->numLights * 0xE, "LightInfo",
|
||||
|
@ -39,10 +44,10 @@ SetLightList::SetLightList(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawD
|
|||
this->numLights, declarations);
|
||||
}
|
||||
|
||||
string SetLightList::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
string SetLightList::GenerateSourceCodePass1(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
return StringHelper::Sprintf(
|
||||
"%s %i, &%sLightInfo0x%06X};",
|
||||
"%s %i, &%sLightInfo0x%06X",
|
||||
ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(), this->numLights,
|
||||
this->ptrRoom->GetName().c_str(), this->segment);
|
||||
}
|
||||
|
|
|
@ -9,15 +9,14 @@
|
|||
class SetLightList : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetLightList(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
SetLightList(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GetCommandCName();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
virtual std::string GenerateExterns();
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, uint32_t baseAddress) override;
|
||||
virtual std::string GetCommandCName() override;
|
||||
virtual RoomCommand GetRoomCommand() override;
|
||||
virtual std::string GenerateExterns() override;
|
||||
|
||||
private:
|
||||
uint8_t code;
|
||||
uint8_t numLights;
|
||||
uint32_t segment;
|
||||
|
||||
|
|
|
@ -7,25 +7,25 @@
|
|||
using namespace std;
|
||||
|
||||
SetLightingSettings::SetLightingSettings(ZRoom* nZRoom, std::vector<uint8_t> rawData,
|
||||
int rawDataIndex)
|
||||
uint32_t rawDataIndex)
|
||||
: ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
uint8_t numLights = rawData[rawDataIndex + 1];
|
||||
segmentOffset = GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 4));
|
||||
|
||||
for (int i = 0; i < numLights; i++)
|
||||
for (int32_t i = 0; i < numLights; i++)
|
||||
settings.push_back(new LightingSettings(rawData, segmentOffset + (i * 22)));
|
||||
|
||||
if (numLights > 0)
|
||||
{
|
||||
string declaration = "";
|
||||
|
||||
for (int i = 0; i < numLights; i++)
|
||||
for (int32_t i = 0; i < numLights; i++)
|
||||
{
|
||||
declaration += StringHelper::Sprintf(
|
||||
"\t{ 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, "
|
||||
"0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%04X, "
|
||||
"0x%04X }, // 0x%06X \n",
|
||||
"0x%04X }, // 0x%06X",
|
||||
settings[i]->ambientClrR, settings[i]->ambientClrG, settings[i]->ambientClrB,
|
||||
settings[i]->diffuseClrA_R, settings[i]->diffuseClrA_G, settings[i]->diffuseClrA_B,
|
||||
settings[i]->diffuseDirA_X, settings[i]->diffuseDirA_Y, settings[i]->diffuseDirA_Z,
|
||||
|
@ -33,12 +33,14 @@ SetLightingSettings::SetLightingSettings(ZRoom* nZRoom, std::vector<uint8_t> raw
|
|||
settings[i]->diffuseDirB_X, settings[i]->diffuseDirB_Y, settings[i]->diffuseDirB_Z,
|
||||
settings[i]->fogClrR, settings[i]->fogClrG, settings[i]->fogClrB, settings[i]->unk,
|
||||
settings[i]->drawDistance, segmentOffset + (i * 22));
|
||||
if (i + 1 < numLights)
|
||||
declaration += "\n";
|
||||
}
|
||||
|
||||
zRoom->parent->AddDeclarationArray(
|
||||
segmentOffset, DeclarationAlignment::None, DeclarationPadding::None, numLights * 22,
|
||||
"LightSettings",
|
||||
StringHelper::Sprintf("%sLightSettings0x%06X", zRoom->GetName().c_str(), segmentOffset),
|
||||
StringHelper::Sprintf("%sLightSettings_%06X", zRoom->GetName().c_str(), segmentOffset),
|
||||
numLights, declaration);
|
||||
}
|
||||
}
|
||||
|
@ -49,15 +51,15 @@ SetLightingSettings::~SetLightingSettings()
|
|||
delete setting;
|
||||
}
|
||||
|
||||
string SetLightingSettings::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
string SetLightingSettings::GenerateSourceCodePass1(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
return StringHelper::Sprintf(
|
||||
"%s %i, (u32)&%sLightSettings0x%06X",
|
||||
"%s %i, (u32)&%sLightSettings_%06X",
|
||||
ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(), settings.size(),
|
||||
zRoom->GetName().c_str(), segmentOffset);
|
||||
}
|
||||
|
||||
string SetLightingSettings::GenerateSourceCodePass2(string roomName, int baseAddress)
|
||||
string SetLightingSettings::GenerateSourceCodePass2(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
@ -69,7 +71,7 @@ string SetLightingSettings::GetCommandCName()
|
|||
|
||||
string SetLightingSettings::GenerateExterns()
|
||||
{
|
||||
return StringHelper::Sprintf("extern LightSettings %sLightSettings0x%06X[];\n",
|
||||
return StringHelper::Sprintf("extern LightSettings %sLightSettings_%06X[];\n",
|
||||
zRoom->GetName().c_str(), segmentOffset);
|
||||
}
|
||||
|
||||
|
@ -78,7 +80,7 @@ RoomCommand SetLightingSettings::GetRoomCommand()
|
|||
return RoomCommand::SetLightingSettings;
|
||||
}
|
||||
|
||||
LightingSettings::LightingSettings(vector<uint8_t> rawData, int rawDataIndex)
|
||||
LightingSettings::LightingSettings(vector<uint8_t> rawData, uint32_t rawDataIndex)
|
||||
{
|
||||
const uint8_t* data = rawData.data();
|
||||
|
||||
|
|
|
@ -14,20 +14,20 @@ public:
|
|||
uint16_t unk;
|
||||
uint16_t drawDistance;
|
||||
|
||||
LightingSettings(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
LightingSettings(std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
};
|
||||
|
||||
class SetLightingSettings : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetLightingSettings(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
SetLightingSettings(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
~SetLightingSettings();
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GenerateSourceCodePass2(std::string roomName, int baseAddress);
|
||||
virtual std::string GetCommandCName();
|
||||
virtual std::string GenerateExterns();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, uint32_t baseAddress) override;
|
||||
virtual std::string GenerateSourceCodePass2(std::string roomName, uint32_t baseAddress) override;
|
||||
virtual std::string GetCommandCName() override;
|
||||
virtual std::string GenerateExterns() override;
|
||||
virtual RoomCommand GetRoomCommand() override;
|
||||
|
||||
private:
|
||||
uint32_t segmentOffset;
|
||||
|
|
|
@ -5,210 +5,111 @@
|
|||
#include "../../StringHelper.h"
|
||||
#include "../../ZFile.h"
|
||||
#include "../ZRoom.h"
|
||||
#include "ZBackground.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SetMesh::SetMesh(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex,
|
||||
int segAddressOffset)
|
||||
SetMesh::SetMesh(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex,
|
||||
int32_t segAddressOffset)
|
||||
: ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
data = rawData[rawDataIndex + 1];
|
||||
segmentOffset = GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 4));
|
||||
|
||||
string declaration = "";
|
||||
int8_t meshHeaderType = rawData[segmentOffset + 0];
|
||||
meshHeaderType = rawData[segmentOffset + 0];
|
||||
|
||||
if (meshHeaderType == 0)
|
||||
{
|
||||
MeshHeader0* meshHeader0 = new MeshHeader0();
|
||||
meshHeader0->headerType = 0;
|
||||
meshHeader0->entries = vector<MeshEntry0*>();
|
||||
|
||||
meshHeader0->dListStart = GETSEGOFFSET(BitConverter::ToInt32BE(rawData, segmentOffset + 4));
|
||||
meshHeader0->dListEnd = GETSEGOFFSET(BitConverter::ToInt32BE(rawData, segmentOffset + 8));
|
||||
uint32_t dListStart = Seg2Filespace(BitConverter::ToInt32BE(rawData, segmentOffset + 4),
|
||||
zRoom->parent->baseAddress);
|
||||
uint32_t dListEnd = Seg2Filespace(BitConverter::ToInt32BE(rawData, segmentOffset + 8),
|
||||
zRoom->parent->baseAddress);
|
||||
|
||||
int8_t numEntries = rawData[segmentOffset + 1];
|
||||
uint32_t currentPtr = meshHeader0->dListStart;
|
||||
uint32_t currentPtr = dListStart;
|
||||
|
||||
// Hack for Syotes
|
||||
for (int i = 0; i < abs(segAddressOffset); i++)
|
||||
for (int32_t i = 0; i < abs(segAddressOffset); i++)
|
||||
{
|
||||
rawData.erase(rawData.begin());
|
||||
segmentOffset--;
|
||||
}
|
||||
|
||||
for (int i = 0; i < numEntries; i++)
|
||||
if (numEntries > 0)
|
||||
{
|
||||
MeshEntry0* entry = new MeshEntry0();
|
||||
entry->opaqueDListAddr = GETSEGOFFSET(BitConverter::ToInt32BE(rawData, currentPtr + 0));
|
||||
entry->translucentDListAddr =
|
||||
GETSEGOFFSET(BitConverter::ToInt32BE(rawData, currentPtr + 4));
|
||||
std::string polyGfxBody = "";
|
||||
std::string polyGfxType = "";
|
||||
int32_t polyGfxSize = 0;
|
||||
|
||||
if (entry->opaqueDListAddr != 0)
|
||||
for (int32_t i = 0; i < numEntries; i++)
|
||||
{
|
||||
entry->opaqueDList = new ZDisplayList(
|
||||
rawData, entry->opaqueDListAddr,
|
||||
ZDisplayList::GetDListLength(rawData, entry->opaqueDListAddr,
|
||||
Globals::Instance->game == ZGame::OOT_SW97 ?
|
||||
DListType::F3DEX :
|
||||
DListType::F3DZEX));
|
||||
entry->opaqueDList->scene = zRoom->scene;
|
||||
entry->opaqueDList->parent = zRoom->parent;
|
||||
GenDListDeclarations(rawData, entry->opaqueDList);
|
||||
PolygonDlist polyGfxList(zRoom->GetName(), rawData, currentPtr, zRoom->parent,
|
||||
zRoom);
|
||||
if (polyGfxList.opaDList != nullptr)
|
||||
{
|
||||
GenDListDeclarations(rawData, polyGfxList.opaDList);
|
||||
}
|
||||
if (polyGfxList.xluDList != nullptr)
|
||||
{
|
||||
GenDListDeclarations(rawData, polyGfxList.xluDList);
|
||||
}
|
||||
polyGfxBody += polyGfxList.GetBodySourceCode(true);
|
||||
polyGfxType = polyGfxList.GetSourceTypeName();
|
||||
polyGfxSize = polyGfxList.GetRawDataSize();
|
||||
|
||||
currentPtr += polyGfxList.GetRawDataSize();
|
||||
}
|
||||
|
||||
if (entry->translucentDListAddr != 0)
|
||||
zRoom->parent->AddDeclarationArray(
|
||||
dListStart, DeclarationAlignment::Align4, numEntries * polyGfxSize, polyGfxType,
|
||||
StringHelper::Sprintf("%s%s0x%06X", zRoom->GetName().c_str(), polyGfxType.c_str(),
|
||||
dListStart),
|
||||
numEntries, polyGfxBody);
|
||||
}
|
||||
|
||||
declaration = "\n ";
|
||||
declaration += StringHelper::Sprintf("{ 0 }, 0x%02X, ", numEntries);
|
||||
declaration += "\n ";
|
||||
|
||||
std::string entriesStr = "NULL";
|
||||
|
||||
if (dListStart != 0)
|
||||
{
|
||||
entry->translucentDList = new ZDisplayList(
|
||||
rawData, entry->translucentDListAddr,
|
||||
ZDisplayList::GetDListLength(rawData, entry->translucentDListAddr,
|
||||
Globals::Instance->game == ZGame::OOT_SW97 ?
|
||||
DListType::F3DEX :
|
||||
DListType::F3DZEX));
|
||||
entry->translucentDList->scene = zRoom->scene;
|
||||
entry->translucentDList->parent = zRoom->parent;
|
||||
GenDListDeclarations(rawData, entry->translucentDList);
|
||||
entriesStr = zRoom->parent->GetDeclaration(dListStart)->varName;
|
||||
}
|
||||
declaration += StringHelper::Sprintf("%s, ", entriesStr.c_str());
|
||||
declaration += "\n ";
|
||||
|
||||
meshHeader0->entries.push_back(entry);
|
||||
|
||||
currentPtr += 8;
|
||||
}
|
||||
|
||||
declaration += StringHelper::Sprintf("{ 0 }, 0x%02X, ", meshHeader0->entries.size());
|
||||
|
||||
if (meshHeader0->dListStart != 0)
|
||||
declaration += StringHelper::Sprintf("(u32)&%sMeshDListEntry0x%06X, ",
|
||||
zRoom->GetName().c_str(), meshHeader0->dListStart);
|
||||
if (dListEnd != 0)
|
||||
declaration += StringHelper::Sprintf("%s + ARRAY_COUNT(%s), ", entriesStr.c_str(),
|
||||
entriesStr.c_str());
|
||||
else
|
||||
declaration += "0, ";
|
||||
|
||||
if (meshHeader0->dListEnd != 0)
|
||||
declaration += StringHelper::Sprintf(
|
||||
"(u32)&(%sMeshDListEntry0x%06X) + sizeof(%sMeshDListEntry0x%06X)",
|
||||
zRoom->GetName().c_str(), meshHeader0->dListStart, zRoom->GetName().c_str(),
|
||||
meshHeader0->dListStart);
|
||||
else
|
||||
declaration += "0";
|
||||
declaration += "NULL, ";
|
||||
declaration += "\n";
|
||||
|
||||
zRoom->parent->AddDeclaration(
|
||||
segmentOffset, DeclarationAlignment::Align16, 12, "MeshHeader0",
|
||||
StringHelper::Sprintf("%sMeshHeader0x%06X", zRoom->GetName().c_str(), segmentOffset),
|
||||
declaration);
|
||||
|
||||
declaration = "";
|
||||
|
||||
for (size_t i = 0; i < meshHeader0->entries.size(); i++)
|
||||
{
|
||||
if (meshHeader0->entries[i]->opaqueDListAddr != 0)
|
||||
declaration +=
|
||||
StringHelper::Sprintf("\t{ (u32)%sDL_%06X, ", zRoom->GetName().c_str(),
|
||||
meshHeader0->entries[i]->opaqueDListAddr);
|
||||
else
|
||||
declaration += "\t{ 0, ";
|
||||
|
||||
if (meshHeader0->entries[i]->translucentDListAddr != 0)
|
||||
declaration +=
|
||||
StringHelper::Sprintf("(u32)%sDL_%06X },\n", zRoom->GetName().c_str(),
|
||||
meshHeader0->entries[i]->translucentDListAddr);
|
||||
else
|
||||
declaration += "0 },\n";
|
||||
}
|
||||
|
||||
zRoom->parent->AddDeclarationArray(
|
||||
meshHeader0->dListStart, DeclarationAlignment::None, DeclarationPadding::None,
|
||||
(meshHeader0->entries.size() * 8) + 0, "MeshEntry0",
|
||||
StringHelper::Sprintf("%sMeshDListEntry0x%06X", zRoom->GetName().c_str(),
|
||||
meshHeader0->dListStart),
|
||||
meshHeader0->entries.size(), declaration);
|
||||
|
||||
zRoom->parent->AddDeclaration(meshHeader0->dListStart + (meshHeader0->entries.size() * 8) +
|
||||
0,
|
||||
DeclarationAlignment::None, DeclarationPadding::Pad16, 4,
|
||||
"static s32", "terminatorMaybe", " 0x01000000 ");
|
||||
|
||||
meshHeader = meshHeader0;
|
||||
zRoom->parent->AddDeclaration(dListStart + (numEntries * 8), DeclarationAlignment::None,
|
||||
DeclarationPadding::Pad16, 4, "static s32", "terminatorMaybe",
|
||||
"0x01000000");
|
||||
}
|
||||
else if (meshHeaderType == 1)
|
||||
{
|
||||
MeshHeader1Base* meshHeader1 = nullptr;
|
||||
|
||||
uint8_t fmt = rawData[segmentOffset + 1];
|
||||
|
||||
if (fmt == 1) // Single Format
|
||||
PolygonType1 polygon1(zRoom->GetName().c_str(), rawData, segmentOffset, zRoom->parent,
|
||||
zRoom);
|
||||
if (polygon1.polyGfxList.opaDList != nullptr)
|
||||
{
|
||||
MeshHeader1Single* headerSingle = new MeshHeader1Single();
|
||||
|
||||
headerSingle->headerType = 1;
|
||||
headerSingle->format = fmt;
|
||||
headerSingle->entryRecord =
|
||||
BitConverter::ToInt32BE(rawData, segmentOffset + 4); // &0x00FFFFFF;
|
||||
|
||||
headerSingle->imagePtr =
|
||||
BitConverter::ToInt32BE(rawData, segmentOffset + 8); // &0x00FFFFFF;
|
||||
headerSingle->unknown = BitConverter::ToInt32BE(rawData, segmentOffset + 12);
|
||||
headerSingle->unknown2 = BitConverter::ToInt32BE(rawData, segmentOffset + 16);
|
||||
headerSingle->bgWidth = BitConverter::ToInt16BE(rawData, segmentOffset + 20);
|
||||
headerSingle->bgHeight = BitConverter::ToInt16BE(rawData, segmentOffset + 22);
|
||||
headerSingle->imageFormat = rawData[segmentOffset + 24];
|
||||
headerSingle->imageSize = rawData[segmentOffset + 25];
|
||||
headerSingle->imagePal = BitConverter::ToInt16BE(rawData, segmentOffset + 26);
|
||||
headerSingle->imageFlip = BitConverter::ToInt16BE(rawData, segmentOffset + 28);
|
||||
|
||||
declaration += StringHelper::Sprintf("{ { 1 }, 1, 0x%06X }, 0x%06X, ",
|
||||
headerSingle->entryRecord, headerSingle->imagePtr);
|
||||
|
||||
declaration += StringHelper::Sprintf("0x%06X, 0x%06X, %i, %i, %i, %i, %i, %i\n",
|
||||
headerSingle->unknown, headerSingle->unknown2,
|
||||
headerSingle->bgWidth, headerSingle->bgHeight,
|
||||
headerSingle->imageFormat, headerSingle->imageSize,
|
||||
headerSingle->imagePal, headerSingle->imageFlip);
|
||||
|
||||
zRoom->parent->AddDeclaration(segmentOffset, DeclarationAlignment::None,
|
||||
DeclarationPadding::Pad16, 0x1E, "MeshHeader1Single",
|
||||
StringHelper::Sprintf("%sMeshHeader0x%06X",
|
||||
zRoom->GetName().c_str(),
|
||||
segmentOffset),
|
||||
declaration);
|
||||
|
||||
meshHeader1 = headerSingle;
|
||||
GenDListDeclarations(rawData, polygon1.polyGfxList.opaDList);
|
||||
}
|
||||
else if (fmt == 2) // Multi-Format
|
||||
if (polygon1.polyGfxList.xluDList != nullptr)
|
||||
{
|
||||
MeshHeader1Multi* headerMulti = new MeshHeader1Multi();
|
||||
|
||||
headerMulti->headerType = 1;
|
||||
headerMulti->format = fmt;
|
||||
headerMulti->entryRecord =
|
||||
BitConverter::ToInt32BE(rawData, segmentOffset + 4); // &0x00FFFFFF;
|
||||
|
||||
headerMulti->bgCnt = rawData[segmentOffset + 8];
|
||||
headerMulti->bgRecordPtr = BitConverter::ToInt32BE(rawData, segmentOffset + 12);
|
||||
|
||||
declaration += StringHelper::Sprintf("{ { 1 }, 2, 0x%06X }, 0x%06X, 0x%06X",
|
||||
headerMulti->entryRecord, headerMulti->bgCnt,
|
||||
headerMulti->bgRecordPtr);
|
||||
|
||||
zRoom->parent->AddDeclaration(segmentOffset, DeclarationAlignment::None,
|
||||
DeclarationPadding::Pad16, 16, "MeshHeader1Multi",
|
||||
StringHelper::Sprintf("%sMeshHeader0x%06X",
|
||||
zRoom->GetName().c_str(),
|
||||
segmentOffset),
|
||||
declaration);
|
||||
|
||||
meshHeader1 = headerMulti;
|
||||
GenDListDeclarations(rawData, polygon1.polyGfxList.xluDList);
|
||||
}
|
||||
else // UH OH
|
||||
{
|
||||
if (Globals::Instance->verbosity >= VERBOSITY_INFO)
|
||||
printf("WARNING: MeshHeader FMT %i not implemented!\n", fmt);
|
||||
}
|
||||
|
||||
meshHeader1->headerType = 1;
|
||||
meshHeader1->format = fmt;
|
||||
meshHeader1->entryRecord = BitConverter::ToInt32BE(rawData, segmentOffset + 4) & 0x00FFFFFF;
|
||||
|
||||
meshHeader = meshHeader1;
|
||||
polygon1.DeclareAndGenerateOutputCode();
|
||||
}
|
||||
else if (meshHeaderType == 2)
|
||||
{
|
||||
|
@ -222,8 +123,7 @@ SetMesh::SetMesh(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex,
|
|||
int8_t numEntries = rawData[segmentOffset + 1];
|
||||
uint32_t currentPtr = meshHeader2->dListStart;
|
||||
|
||||
// HOTSPOT
|
||||
for (int i = 0; i < numEntries; i++)
|
||||
for (int32_t i = 0; i < numEntries; i++)
|
||||
{
|
||||
MeshEntry2* entry = new MeshEntry2();
|
||||
entry->playerXMax = BitConverter::ToInt16BE(rawData, currentPtr + 0);
|
||||
|
@ -231,9 +131,9 @@ SetMesh::SetMesh(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex,
|
|||
entry->playerXMin = BitConverter::ToInt16BE(rawData, currentPtr + 4);
|
||||
entry->playerZMin = BitConverter::ToInt16BE(rawData, currentPtr + 6);
|
||||
|
||||
entry->opaqueDListAddr = BitConverter::ToInt32BE(rawData, currentPtr + 8) & 0x00FFFFFF;
|
||||
entry->opaqueDListAddr = GETSEGOFFSET(BitConverter::ToInt32BE(rawData, currentPtr + 8));
|
||||
entry->translucentDListAddr =
|
||||
BitConverter::ToInt32BE(rawData, currentPtr + 12) & 0x00FFFFFF;
|
||||
GETSEGOFFSET(BitConverter::ToInt32BE(rawData, currentPtr + 12));
|
||||
|
||||
if (entry->opaqueDListAddr != 0)
|
||||
{
|
||||
|
@ -242,10 +142,10 @@ SetMesh::SetMesh(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex,
|
|||
ZDisplayList::GetDListLength(rawData, entry->opaqueDListAddr,
|
||||
Globals::Instance->game == ZGame::OOT_SW97 ?
|
||||
DListType::F3DEX :
|
||||
DListType::F3DZEX));
|
||||
DListType::F3DZEX),
|
||||
zRoom->parent);
|
||||
entry->opaqueDList->scene = zRoom->scene;
|
||||
entry->opaqueDList->parent = zRoom->parent;
|
||||
GenDListDeclarations(rawData, entry->opaqueDList); // HOTSPOT
|
||||
GenDListDeclarations(rawData, entry->opaqueDList);
|
||||
}
|
||||
|
||||
if (entry->translucentDListAddr != 0)
|
||||
|
@ -255,10 +155,10 @@ SetMesh::SetMesh(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex,
|
|||
ZDisplayList::GetDListLength(rawData, entry->translucentDListAddr,
|
||||
Globals::Instance->game == ZGame::OOT_SW97 ?
|
||||
DListType::F3DEX :
|
||||
DListType::F3DZEX));
|
||||
DListType::F3DZEX),
|
||||
zRoom->parent);
|
||||
entry->translucentDList->scene = zRoom->scene;
|
||||
entry->translucentDList->parent = zRoom->parent;
|
||||
GenDListDeclarations(rawData, entry->translucentDList); // HOTSPOT
|
||||
GenDListDeclarations(rawData, entry->translucentDList);
|
||||
}
|
||||
|
||||
meshHeader2->entries.push_back(entry);
|
||||
|
@ -281,6 +181,7 @@ SetMesh::SetMesh(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex,
|
|||
meshHeader2->dListStart);
|
||||
else
|
||||
declaration += "0";
|
||||
declaration += "\n";
|
||||
|
||||
zRoom->parent->AddDeclaration(
|
||||
segmentOffset, DeclarationAlignment::None, 12, "MeshHeader2",
|
||||
|
@ -292,7 +193,7 @@ SetMesh::SetMesh(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex,
|
|||
for (size_t i = 0; i < meshHeader2->entries.size(); i++)
|
||||
{
|
||||
declaration += StringHelper::Sprintf(
|
||||
"\t{ %i, %i, %i, %i, ", meshHeader2->entries[i]->playerXMax,
|
||||
" { %i, %i, %i, %i, ", meshHeader2->entries[i]->playerXMax,
|
||||
meshHeader2->entries[i]->playerZMax, meshHeader2->entries[i]->playerXMin,
|
||||
meshHeader2->entries[i]->playerZMin);
|
||||
|
||||
|
@ -336,27 +237,22 @@ SetMesh::~SetMesh()
|
|||
|
||||
void SetMesh::GenDListDeclarations(std::vector<uint8_t> rawData, ZDisplayList* dList)
|
||||
{
|
||||
string srcVarName = "";
|
||||
|
||||
// if (Globals::Instance->includeFilePrefix)
|
||||
srcVarName = StringHelper::Sprintf("%s%s", zRoom->GetName().c_str(), dList->GetName().c_str());
|
||||
// else
|
||||
// srcVarName = StringHelper::Sprintf("%s", dList->GetName().c_str());
|
||||
string srcVarName =
|
||||
StringHelper::Sprintf("%s%s", zRoom->GetName().c_str(), dList->GetName().c_str());
|
||||
|
||||
dList->SetName(srcVarName);
|
||||
string sourceOutput = dList->GetSourceOutputCode(zRoom->GetName()); // HOTSPOT
|
||||
|
||||
// zRoom->parent->AddDeclarationArray(dList->GetRawDataIndex(), DeclarationAlignment::None,
|
||||
// dList->GetRawDataSize(), "static Gfx", srcVarName, dList->GetRawDataSize() / 8, sourceOutput);
|
||||
string sourceOutput = dList->GetSourceOutputCode(zRoom->GetName());
|
||||
|
||||
for (ZDisplayList* otherDList : dList->otherDLists)
|
||||
GenDListDeclarations(rawData, otherDList);
|
||||
|
||||
for (pair<uint32_t, string> vtxEntry : dList->vtxDeclarations)
|
||||
{
|
||||
DeclarationAlignment alignment = DeclarationAlignment::Align8;
|
||||
if (Globals::Instance->game == ZGame::MM_RETAIL)
|
||||
alignment = DeclarationAlignment::None;
|
||||
zRoom->parent->AddDeclarationArray(
|
||||
vtxEntry.first, DeclarationAlignment::Align8,
|
||||
dList->vertices[vtxEntry.first].size() * 16, "static Vtx",
|
||||
vtxEntry.first, alignment, dList->vertices[vtxEntry.first].size() * 16, "static Vtx",
|
||||
StringHelper::Sprintf("%sVtx_%06X", zRoom->GetName().c_str(), vtxEntry.first),
|
||||
dList->vertices[vtxEntry.first].size(), vtxEntry.second);
|
||||
}
|
||||
|
@ -364,23 +260,6 @@ void SetMesh::GenDListDeclarations(std::vector<uint8_t> rawData, ZDisplayList* d
|
|||
for (pair<uint32_t, string> texEntry : dList->texDeclarations)
|
||||
{
|
||||
zRoom->textures[texEntry.first] = dList->textures[texEntry.first];
|
||||
|
||||
if (Globals::Instance->verbosity >= VERBOSITY_DEBUG)
|
||||
printf("SAVING IMAGE TO %s\n", Globals::Instance->outputPath.c_str());
|
||||
|
||||
zRoom->textures[texEntry.first]->Save(Globals::Instance->outputPath);
|
||||
|
||||
zRoom->parent->AddDeclarationIncludeArray(
|
||||
texEntry.first,
|
||||
StringHelper::Sprintf(
|
||||
"%s/%s.%s.inc.c", Globals::Instance->outputPath.c_str(),
|
||||
Path::GetFileNameWithoutExtension(zRoom->textures[texEntry.first]->GetName())
|
||||
.c_str(),
|
||||
zRoom->textures[texEntry.first]->GetExternalExtension().c_str()),
|
||||
zRoom->textures[texEntry.first]->GetRawDataSize(), "u64",
|
||||
StringHelper::Sprintf("%s", zRoom->textures[texEntry.first]->GetName().c_str(),
|
||||
texEntry.first),
|
||||
0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -406,90 +285,25 @@ std::string SetMesh::GenDListExterns(ZDisplayList* dList)
|
|||
return sourceOutput;
|
||||
}
|
||||
|
||||
string SetMesh::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
string SetMesh::GenerateSourceCodePass1(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
string sourceOutput = "";
|
||||
|
||||
sourceOutput +=
|
||||
StringHelper::Sprintf("%s %i, (u32)&%sMeshHeader0x%06X",
|
||||
ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(),
|
||||
data, zRoom->GetName().c_str(), segmentOffset);
|
||||
Declaration* decl = zRoom->parent->GetDeclaration(segmentOffset);
|
||||
|
||||
/*if (meshHeader->headerType == 0)
|
||||
{
|
||||
MeshHeader0* meshHeader0 = (MeshHeader0*)meshHeader;
|
||||
sourceOutput += StringHelper::Sprintf(
|
||||
"%s %i, &%s", ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(), data,
|
||||
decl->varName.c_str());
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
sourceOutput += "// SetMesh UNIMPLEMENTED HEADER TYPE!\n";
|
||||
}
|
||||
*/
|
||||
return sourceOutput;
|
||||
}
|
||||
|
||||
string SetMesh::GenerateExterns()
|
||||
{
|
||||
string sourceOutput = "";
|
||||
|
||||
if (meshHeader->headerType == 0)
|
||||
{
|
||||
MeshHeader0* meshHeader0 = (MeshHeader0*)meshHeader;
|
||||
|
||||
sourceOutput += StringHelper::Sprintf("extern MeshHeader0 %sMeshHeader0x%06X;\n",
|
||||
zRoom->GetName().c_str(), segmentOffset);
|
||||
sourceOutput += StringHelper::Sprintf("extern MeshEntry0 %sMeshDListEntry0x%06X[%i];\n",
|
||||
zRoom->GetName().c_str(), meshHeader0->dListStart,
|
||||
meshHeader0->entries.size());
|
||||
|
||||
for (MeshEntry0* entry : meshHeader0->entries)
|
||||
{
|
||||
if (entry->opaqueDList != nullptr)
|
||||
sourceOutput += GenDListExterns(entry->opaqueDList);
|
||||
|
||||
if (entry->translucentDList != nullptr)
|
||||
sourceOutput += GenDListExterns(entry->translucentDList);
|
||||
}
|
||||
}
|
||||
else if (meshHeader->headerType == 1)
|
||||
{
|
||||
MeshHeader1Base* meshHeader1 = (MeshHeader1Base*)meshHeader;
|
||||
|
||||
if (meshHeader1->format == 1)
|
||||
sourceOutput += StringHelper::Sprintf("extern MeshHeader1Single %sMeshHeader0x%06X;\n",
|
||||
zRoom->GetName().c_str(), segmentOffset);
|
||||
else if (meshHeader1->format == 2)
|
||||
sourceOutput += StringHelper::Sprintf("extern MeshHeader1Multi %sMeshHeader0x%06X;\n",
|
||||
zRoom->GetName().c_str(), segmentOffset);
|
||||
}
|
||||
else if (meshHeader->headerType == 2)
|
||||
{
|
||||
MeshHeader2* meshHeader2 = (MeshHeader2*)meshHeader;
|
||||
|
||||
sourceOutput += StringHelper::Sprintf("extern MeshHeader2 %sMeshHeader0x%06X;\n",
|
||||
zRoom->GetName().c_str(), segmentOffset);
|
||||
sourceOutput += StringHelper::Sprintf("extern MeshEntry2 %sMeshDListEntry0x%06X[%i];\n",
|
||||
zRoom->GetName().c_str(), meshHeader2->dListStart,
|
||||
meshHeader2->entries.size());
|
||||
|
||||
for (MeshEntry2* entry : meshHeader2->entries)
|
||||
{
|
||||
if (entry->opaqueDList != nullptr)
|
||||
sourceOutput += GenDListExterns(entry->opaqueDList);
|
||||
|
||||
if (entry->translucentDList != nullptr)
|
||||
sourceOutput += GenDListExterns(entry->translucentDList);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// sourceOutput += "// SetMesh UNIMPLEMENTED HEADER TYPE!\n";
|
||||
return "";
|
||||
}
|
||||
|
||||
return sourceOutput;
|
||||
}
|
||||
|
||||
int32_t SetMesh::GetRawDataSize()
|
||||
size_t SetMesh::GetRawDataSize()
|
||||
{
|
||||
return ZRoomCommand::GetRawDataSize();
|
||||
}
|
||||
|
@ -503,3 +317,487 @@ RoomCommand SetMesh::GetRoomCommand()
|
|||
{
|
||||
return RoomCommand::SetMesh;
|
||||
}
|
||||
|
||||
PolygonDlist::PolygonDlist(const std::string& prefix, const std::vector<uint8_t>& nRawData,
|
||||
uint32_t nRawDataIndex, ZFile* nParent, ZRoom* nRoom)
|
||||
{
|
||||
rawData.assign(nRawData.begin(), nRawData.end());
|
||||
rawDataIndex = nRawDataIndex;
|
||||
parent = nParent;
|
||||
room = nRoom;
|
||||
|
||||
name = GetDefaultName(prefix.c_str(), rawDataIndex);
|
||||
|
||||
ParseRawData();
|
||||
|
||||
opaDList = MakeDlist(opa, prefix);
|
||||
xluDList = MakeDlist(xlu, prefix);
|
||||
}
|
||||
|
||||
void PolygonDlist::ParseRawData()
|
||||
{
|
||||
opa = BitConverter::ToUInt32BE(rawData, rawDataIndex);
|
||||
xlu = BitConverter::ToUInt32BE(rawData, rawDataIndex + 4);
|
||||
}
|
||||
|
||||
ZDisplayList* PolygonDlist::MakeDlist(segptr_t ptr, const std::string& prefix)
|
||||
{
|
||||
if (ptr == 0)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32_t dlistAddress = Seg2Filespace(ptr, parent->baseAddress);
|
||||
|
||||
int32_t dlistLength = ZDisplayList::GetDListLength(
|
||||
rawData, dlistAddress,
|
||||
Globals::Instance->game == ZGame::OOT_SW97 ? DListType::F3DEX : DListType::F3DZEX);
|
||||
ZDisplayList* dlist = new ZDisplayList(rawData, dlistAddress, dlistLength, parent);
|
||||
|
||||
string dListStr = StringHelper::Sprintf("%sPolygonDlist_%06X", prefix.c_str(), dlistAddress);
|
||||
dlist->SetName(dListStr);
|
||||
dlist->scene = room->scene;
|
||||
dlist->GetSourceOutputCode(prefix);
|
||||
|
||||
return dlist;
|
||||
}
|
||||
|
||||
size_t PolygonDlist::GetRawDataSize()
|
||||
{
|
||||
return 0x08;
|
||||
}
|
||||
|
||||
void PolygonDlist::DeclareVar(const std::string& prefix, const std::string& bodyStr)
|
||||
{
|
||||
std::string auxName = name;
|
||||
if (name == "")
|
||||
{
|
||||
auxName = GetDefaultName(prefix, rawDataIndex);
|
||||
}
|
||||
parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align4, GetRawDataSize(),
|
||||
GetSourceTypeName(), auxName, bodyStr);
|
||||
}
|
||||
|
||||
std::string PolygonDlist::GetBodySourceCode(bool arrayElement)
|
||||
{
|
||||
std::string bodyStr = "";
|
||||
std::string opaStr = "NULL";
|
||||
std::string xluStr = "NULL";
|
||||
if (arrayElement)
|
||||
{
|
||||
bodyStr += " { \n ";
|
||||
}
|
||||
else
|
||||
{
|
||||
bodyStr += "\n";
|
||||
}
|
||||
|
||||
if (opa != 0)
|
||||
{
|
||||
Declaration* decl = parent->GetDeclaration(Seg2Filespace(opa, parent->baseAddress));
|
||||
if (decl != nullptr)
|
||||
{
|
||||
opaStr = decl->varName;
|
||||
}
|
||||
else
|
||||
{
|
||||
opaStr = StringHelper::Sprintf("0x%08X", opa);
|
||||
}
|
||||
}
|
||||
if (xlu != 0)
|
||||
{
|
||||
Declaration* decl = parent->GetDeclaration(Seg2Filespace(xlu, parent->baseAddress));
|
||||
if (decl != nullptr)
|
||||
{
|
||||
xluStr = decl->varName;
|
||||
}
|
||||
else
|
||||
{
|
||||
xluStr = StringHelper::Sprintf("0x%08X", xlu);
|
||||
}
|
||||
}
|
||||
|
||||
bodyStr += StringHelper::Sprintf(" %s, \n", opaStr.c_str());
|
||||
if (arrayElement)
|
||||
{
|
||||
bodyStr += " ";
|
||||
}
|
||||
|
||||
bodyStr += StringHelper::Sprintf(" %s, \n", xluStr.c_str());
|
||||
|
||||
if (arrayElement)
|
||||
{
|
||||
bodyStr += " },";
|
||||
}
|
||||
|
||||
return bodyStr;
|
||||
}
|
||||
|
||||
void PolygonDlist::DeclareAndGenerateOutputCode()
|
||||
{
|
||||
std::string bodyStr = GetBodySourceCode(false);
|
||||
|
||||
Declaration* decl = parent->GetDeclaration(rawDataIndex);
|
||||
if (decl == nullptr)
|
||||
{
|
||||
DeclareVar("", bodyStr);
|
||||
}
|
||||
else
|
||||
{
|
||||
decl->text = bodyStr;
|
||||
}
|
||||
}
|
||||
|
||||
std::string PolygonDlist::GetDefaultName(const std::string& prefix, uint32_t address)
|
||||
{
|
||||
return StringHelper::Sprintf("%sPolyDlist_%06X", prefix.c_str(), address);
|
||||
}
|
||||
|
||||
std::string PolygonDlist::GetSourceTypeName()
|
||||
{
|
||||
return "PolygonDlist";
|
||||
}
|
||||
|
||||
std::string PolygonDlist::GetName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
BgImage::BgImage(bool nIsSubStruct, const std::string& prefix, const std::vector<uint8_t>& nRawData,
|
||||
uint32_t nRawDataIndex, ZFile* nParent)
|
||||
{
|
||||
rawData.assign(nRawData.begin(), nRawData.end());
|
||||
rawDataIndex = nRawDataIndex;
|
||||
parent = nParent;
|
||||
isSubStruct = nIsSubStruct;
|
||||
|
||||
name = GetDefaultName(prefix.c_str(), rawDataIndex);
|
||||
|
||||
ParseRawData();
|
||||
sourceBackground = MakeBackground(source, prefix);
|
||||
}
|
||||
|
||||
void BgImage::ParseRawData()
|
||||
{
|
||||
size_t pad = 0x00;
|
||||
if (!isSubStruct)
|
||||
{
|
||||
pad = 0x04;
|
||||
|
||||
unk_00 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x00);
|
||||
id = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x02);
|
||||
}
|
||||
source = BitConverter::ToUInt32BE(rawData, rawDataIndex + pad + 0x00);
|
||||
unk_0C = BitConverter::ToUInt32BE(rawData, rawDataIndex + pad + 0x04);
|
||||
tlut = BitConverter::ToUInt32BE(rawData, rawDataIndex + pad + 0x08);
|
||||
width = BitConverter::ToUInt16BE(rawData, rawDataIndex + pad + 0x0C);
|
||||
height = BitConverter::ToUInt16BE(rawData, rawDataIndex + pad + 0x0E);
|
||||
fmt = BitConverter::ToUInt8BE(rawData, rawDataIndex + pad + 0x10);
|
||||
siz = BitConverter::ToUInt8BE(rawData, rawDataIndex + pad + 0x11);
|
||||
mode0 = BitConverter::ToUInt16BE(rawData, rawDataIndex + pad + 0x12);
|
||||
tlutCount = BitConverter::ToUInt16BE(rawData, rawDataIndex + pad + 0x14);
|
||||
}
|
||||
|
||||
ZBackground* BgImage::MakeBackground(segptr_t ptr, const std::string& prefix)
|
||||
{
|
||||
if (ptr == 0)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32_t backAddress = Seg2Filespace(ptr, parent->baseAddress);
|
||||
|
||||
ZBackground* background = new ZBackground(prefix, rawData, backAddress, parent);
|
||||
background->DeclareVar(prefix, "");
|
||||
parent->resources.push_back(background);
|
||||
|
||||
return background;
|
||||
}
|
||||
|
||||
size_t BgImage::GetRawDataSize()
|
||||
{
|
||||
return 0x1C;
|
||||
}
|
||||
|
||||
std::string BgImage::GetBodySourceCode(bool arrayElement)
|
||||
{
|
||||
std::string bodyStr = "";
|
||||
if (arrayElement)
|
||||
{
|
||||
bodyStr += " { \n ";
|
||||
}
|
||||
|
||||
if (!isSubStruct)
|
||||
{
|
||||
bodyStr += StringHelper::Sprintf("0x%04X, ", unk_00);
|
||||
bodyStr += StringHelper::Sprintf("%i, ", id);
|
||||
bodyStr += "\n ";
|
||||
if (arrayElement)
|
||||
{
|
||||
bodyStr += " ";
|
||||
}
|
||||
}
|
||||
|
||||
std::string backgroundName = "NULL";
|
||||
if (source != 0)
|
||||
{
|
||||
uint32_t address = Seg2Filespace(source, parent->baseAddress);
|
||||
Declaration* decl = parent->GetDeclaration(address);
|
||||
|
||||
if (decl == nullptr)
|
||||
{
|
||||
backgroundName += StringHelper::Sprintf("0x%08X, ", source);
|
||||
}
|
||||
else
|
||||
{
|
||||
backgroundName = decl->varName;
|
||||
}
|
||||
}
|
||||
bodyStr += StringHelper::Sprintf("%s, ", backgroundName.c_str());
|
||||
bodyStr += "\n ";
|
||||
if (arrayElement)
|
||||
{
|
||||
bodyStr += " ";
|
||||
}
|
||||
|
||||
bodyStr += StringHelper::Sprintf("0x%08X, ", unk_0C);
|
||||
bodyStr += StringHelper::Sprintf("0x%08X, ", tlut);
|
||||
bodyStr += "\n ";
|
||||
if (arrayElement)
|
||||
{
|
||||
bodyStr += " ";
|
||||
}
|
||||
|
||||
bodyStr += StringHelper::Sprintf("%i, ", width);
|
||||
bodyStr += StringHelper::Sprintf("%i, ", height);
|
||||
bodyStr += "\n ";
|
||||
if (arrayElement)
|
||||
{
|
||||
bodyStr += " ";
|
||||
}
|
||||
|
||||
bodyStr += StringHelper::Sprintf("%i, ", fmt);
|
||||
bodyStr += StringHelper::Sprintf("%i, ", siz);
|
||||
bodyStr += "\n ";
|
||||
if (arrayElement)
|
||||
{
|
||||
bodyStr += " ";
|
||||
}
|
||||
|
||||
bodyStr += StringHelper::Sprintf("0x%04X, ", mode0);
|
||||
bodyStr += StringHelper::Sprintf("0x%04X, ", tlutCount);
|
||||
if (arrayElement)
|
||||
{
|
||||
bodyStr += " \n }, ";
|
||||
}
|
||||
|
||||
return bodyStr;
|
||||
}
|
||||
|
||||
std::string BgImage::GetDefaultName(const std::string& prefix, uint32_t address)
|
||||
{
|
||||
return StringHelper::Sprintf("%sBgImage_%06X", prefix.c_str(), address);
|
||||
}
|
||||
|
||||
std::string BgImage::GetSourceTypeName()
|
||||
{
|
||||
return "BgImage";
|
||||
}
|
||||
|
||||
std::string BgImage::GetName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
PolygonType1::PolygonType1(const std::string& prefix, const std::vector<uint8_t>& nRawData,
|
||||
uint32_t nRawDataIndex, ZFile* nParent, ZRoom* nRoom)
|
||||
{
|
||||
rawData.assign(nRawData.begin(), nRawData.end());
|
||||
rawDataIndex = nRawDataIndex;
|
||||
parent = nParent;
|
||||
|
||||
name = GetDefaultName(prefix.c_str(), rawDataIndex);
|
||||
|
||||
ParseRawData();
|
||||
|
||||
if (dlist != 0)
|
||||
{
|
||||
polyGfxList =
|
||||
PolygonDlist(prefix, rawData, Seg2Filespace(dlist, parent->baseAddress), parent, nRoom);
|
||||
}
|
||||
|
||||
uint32_t listAddress;
|
||||
std::string bgImageArrayBody = "";
|
||||
switch (format)
|
||||
{
|
||||
case 1:
|
||||
single = BgImage(true, prefix, nRawData, nRawDataIndex + 0x08, parent);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (list != 0)
|
||||
{
|
||||
listAddress = Seg2Filespace(list, parent->baseAddress);
|
||||
for (size_t i = 0; i < count; ++i)
|
||||
{
|
||||
BgImage bg(false, prefix, rawData, listAddress + i * BgImage::GetRawDataSize(),
|
||||
parent);
|
||||
multiList.push_back(bg);
|
||||
bgImageArrayBody += bg.GetBodySourceCode(true);
|
||||
if (i + 1 < count)
|
||||
{
|
||||
bgImageArrayBody += "\n";
|
||||
}
|
||||
}
|
||||
|
||||
Declaration* decl = parent->GetDeclaration(listAddress);
|
||||
if (decl == nullptr)
|
||||
{
|
||||
parent->AddDeclarationArray(
|
||||
listAddress, DeclarationAlignment::Align4, count * BgImage::GetRawDataSize(),
|
||||
BgImage::GetSourceTypeName(), multiList.at(0).GetName().c_str(), count,
|
||||
bgImageArrayBody);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
throw std::runtime_error(StringHelper::Sprintf(
|
||||
"Error in PolygonType1::PolygonType1\n\t Unknown format: %i\n", format));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void PolygonType1::ParseRawData()
|
||||
{
|
||||
type = BitConverter::ToUInt8BE(rawData, rawDataIndex);
|
||||
format = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x01);
|
||||
dlist = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x04);
|
||||
|
||||
if (format == 2)
|
||||
{
|
||||
count = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x08);
|
||||
list = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x0C);
|
||||
}
|
||||
}
|
||||
|
||||
size_t PolygonType1::GetRawDataSize()
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case 1:
|
||||
return 0x20;
|
||||
|
||||
case 2:
|
||||
return 0x10;
|
||||
}
|
||||
return 0x20;
|
||||
}
|
||||
|
||||
void PolygonType1::DeclareVar(const std::string& prefix, const std::string& bodyStr)
|
||||
{
|
||||
std::string auxName = name;
|
||||
if (name == "")
|
||||
{
|
||||
auxName = GetDefaultName(prefix, rawDataIndex);
|
||||
}
|
||||
parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align4, GetRawDataSize(),
|
||||
GetSourceTypeName(), auxName, bodyStr);
|
||||
}
|
||||
|
||||
std::string PolygonType1::GetBodySourceCode()
|
||||
{
|
||||
std::string bodyStr = "\n ";
|
||||
|
||||
bodyStr += "{ ";
|
||||
bodyStr += StringHelper::Sprintf("%i, %i, ", type, format);
|
||||
|
||||
std::string dlistStr = "NULL";
|
||||
if (dlist != 0)
|
||||
{
|
||||
uint32_t entryRecordAddress = Seg2Filespace(dlist, parent->baseAddress);
|
||||
Declaration* decl = parent->GetDeclaration(entryRecordAddress);
|
||||
|
||||
if (decl == nullptr)
|
||||
{
|
||||
polyGfxList.DeclareAndGenerateOutputCode();
|
||||
dlistStr = "&" + polyGfxList.GetName();
|
||||
}
|
||||
else
|
||||
{
|
||||
dlistStr = "&" + decl->varName;
|
||||
}
|
||||
}
|
||||
bodyStr += StringHelper::Sprintf("%s, ", dlistStr.c_str());
|
||||
bodyStr += "}, \n";
|
||||
|
||||
std::string listStr = "NULL";
|
||||
// bodyStr += " { \n";
|
||||
switch (format)
|
||||
{
|
||||
case 1:
|
||||
bodyStr += " " + single.GetBodySourceCode(false) + "\n";
|
||||
break;
|
||||
case 2:
|
||||
if (list != 0)
|
||||
{
|
||||
uint32_t listAddress = Seg2Filespace(list, parent->baseAddress);
|
||||
Declaration* decl = parent->GetDeclaration(listAddress);
|
||||
if (decl != nullptr)
|
||||
{
|
||||
listStr = decl->varName;
|
||||
}
|
||||
else
|
||||
{
|
||||
listStr = StringHelper::Sprintf("0x%08X", list);
|
||||
}
|
||||
}
|
||||
bodyStr += StringHelper::Sprintf(" %i, %s, \n", count, listStr.c_str());
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// bodyStr += " } \n";
|
||||
|
||||
return bodyStr;
|
||||
}
|
||||
|
||||
void PolygonType1::DeclareAndGenerateOutputCode()
|
||||
{
|
||||
std::string bodyStr = GetBodySourceCode();
|
||||
|
||||
Declaration* decl = parent->GetDeclaration(rawDataIndex);
|
||||
if (decl == nullptr)
|
||||
{
|
||||
DeclareVar("", bodyStr);
|
||||
}
|
||||
else
|
||||
{
|
||||
decl->text = bodyStr;
|
||||
}
|
||||
}
|
||||
|
||||
std::string PolygonType1::GetDefaultName(const std::string& prefix, uint32_t address)
|
||||
{
|
||||
return StringHelper::Sprintf("%sPolygonType1_%06X", prefix.c_str(), address);
|
||||
}
|
||||
|
||||
std::string PolygonType1::GetSourceTypeName()
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case 1:
|
||||
return "MeshHeader1Single";
|
||||
|
||||
case 2:
|
||||
return "MeshHeader1Multi";
|
||||
}
|
||||
return "ERROR";
|
||||
// return "PolygonType1";
|
||||
}
|
||||
|
||||
std::string PolygonType1::GetName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "../../ZDisplayList.h"
|
||||
#include "../ZRoomCommand.h"
|
||||
#include "ZBackground.h"
|
||||
|
||||
class MeshHeaderBase
|
||||
{
|
||||
|
@ -9,74 +10,6 @@ public:
|
|||
int8_t headerType; // 0x00
|
||||
};
|
||||
|
||||
class MeshEntry0
|
||||
{
|
||||
public:
|
||||
int32_t opaqueDListAddr;
|
||||
int32_t translucentDListAddr;
|
||||
|
||||
ZDisplayList* opaqueDList;
|
||||
ZDisplayList* translucentDList;
|
||||
};
|
||||
|
||||
class MeshHeader0 : public MeshHeaderBase
|
||||
{
|
||||
public:
|
||||
std::vector<MeshEntry0*> entries;
|
||||
uint32_t dListStart;
|
||||
uint32_t dListEnd;
|
||||
};
|
||||
|
||||
class MeshHeader1Base : public MeshHeaderBase
|
||||
{
|
||||
public:
|
||||
int8_t format; // 0x01
|
||||
uint32_t entryRecord; // 0x04
|
||||
};
|
||||
|
||||
class MeshHeader1Single : public MeshHeader1Base
|
||||
{
|
||||
public:
|
||||
uint32_t imagePtr; // 0x08
|
||||
|
||||
uint32_t unknown; // 0x0C
|
||||
uint32_t unknown2; // 0x10
|
||||
|
||||
uint16_t bgWidth; // 0x14
|
||||
uint16_t bgHeight; // 0x16
|
||||
|
||||
uint8_t imageFormat; // 0x18
|
||||
uint8_t imageSize; // 0x19
|
||||
uint16_t imagePal; // 0x1A
|
||||
uint16_t imageFlip; // 0x1C
|
||||
};
|
||||
|
||||
class MeshHeader1Multi : public MeshHeader1Base
|
||||
{
|
||||
public:
|
||||
uint8_t bgCnt; // 0x08
|
||||
uint32_t bgRecordPtr; // 0x0C
|
||||
};
|
||||
|
||||
class BackgroundRecord
|
||||
{
|
||||
public:
|
||||
uint16_t unknown; // 0x00
|
||||
int8_t bgID; // 0x02
|
||||
|
||||
uint32_t imagePtr; // 0x04
|
||||
uint32_t unknown2; // 0x08
|
||||
uint32_t unknown3; // 0x0C
|
||||
|
||||
uint16_t bgWidth; // 0x10
|
||||
uint16_t bgHeight; // 0x12
|
||||
|
||||
uint8_t imageFmt; // 0x14
|
||||
uint8_t imageSize; // 0x15
|
||||
uint16_t imagePal; // 0x16
|
||||
uint16_t imageFlip; // 0x18
|
||||
};
|
||||
|
||||
class MeshEntry2
|
||||
{
|
||||
public:
|
||||
|
@ -98,24 +31,138 @@ public:
|
|||
uint32_t dListEnd;
|
||||
};
|
||||
|
||||
class PolygonDlist
|
||||
{
|
||||
protected:
|
||||
segptr_t opa = 0; // Gfx*
|
||||
segptr_t xlu = 0; // Gfx*
|
||||
|
||||
std::vector<uint8_t> rawData;
|
||||
uint32_t rawDataIndex;
|
||||
ZFile* parent;
|
||||
ZRoom* room;
|
||||
std::string name;
|
||||
|
||||
void ParseRawData();
|
||||
ZDisplayList* MakeDlist(segptr_t ptr, const std::string& prefix);
|
||||
|
||||
public:
|
||||
PolygonDlist() = default;
|
||||
PolygonDlist(const std::string& prefix, const std::vector<uint8_t>& nRawData, uint32_t nRawDataIndex,
|
||||
ZFile* nParent, ZRoom* nRoom);
|
||||
|
||||
size_t GetRawDataSize();
|
||||
|
||||
void DeclareVar(const std::string& prefix, const std::string& bodyStr);
|
||||
|
||||
std::string GetBodySourceCode(bool arrayElement);
|
||||
void DeclareAndGenerateOutputCode();
|
||||
|
||||
static std::string GetDefaultName(const std::string& prefix, uint32_t address);
|
||||
std::string GetSourceTypeName();
|
||||
std::string GetName();
|
||||
|
||||
ZDisplayList* opaDList = nullptr; // Gfx*
|
||||
ZDisplayList* xluDList = nullptr; // Gfx*
|
||||
};
|
||||
|
||||
class BgImage
|
||||
{
|
||||
protected:
|
||||
uint16_t unk_00;
|
||||
uint8_t id;
|
||||
segptr_t source;
|
||||
uint32_t unk_0C;
|
||||
uint32_t tlut;
|
||||
uint16_t width;
|
||||
uint16_t height;
|
||||
uint8_t fmt;
|
||||
uint8_t siz;
|
||||
uint16_t mode0;
|
||||
uint16_t tlutCount;
|
||||
|
||||
ZBackground* sourceBackground;
|
||||
|
||||
std::vector<uint8_t> rawData;
|
||||
uint32_t rawDataIndex;
|
||||
ZFile* parent;
|
||||
std::string name;
|
||||
bool isSubStruct;
|
||||
|
||||
void ParseRawData();
|
||||
ZBackground* MakeBackground(segptr_t ptr, const std::string& prefix);
|
||||
|
||||
public:
|
||||
BgImage() = default;
|
||||
BgImage(bool nIsSubStruct, const std::string& prefix, const std::vector<uint8_t>& nRawData,
|
||||
uint32_t nRawDataIndex, ZFile* nParent);
|
||||
|
||||
static size_t GetRawDataSize() ;
|
||||
|
||||
std::string GetBodySourceCode(bool arrayElement);
|
||||
|
||||
static std::string GetDefaultName(const std::string& prefix, uint32_t address);
|
||||
static std::string GetSourceTypeName();
|
||||
std::string GetName();
|
||||
};
|
||||
|
||||
class PolygonType1
|
||||
{
|
||||
protected:
|
||||
uint8_t type;
|
||||
uint8_t format;
|
||||
segptr_t dlist;
|
||||
|
||||
// single
|
||||
BgImage single;
|
||||
|
||||
// multi
|
||||
uint8_t count;
|
||||
segptr_t list; // BgImage*
|
||||
std::vector<BgImage> multiList;
|
||||
|
||||
std::vector<uint8_t> rawData;
|
||||
uint32_t rawDataIndex;
|
||||
ZFile* parent;
|
||||
std::string name;
|
||||
|
||||
void ParseRawData();
|
||||
|
||||
public:
|
||||
PolygonType1(const std::string& prefix, const std::vector<uint8_t>& nRawData, uint32_t nRawDataIndex,
|
||||
ZFile* nParent, ZRoom* nRoom);
|
||||
|
||||
size_t GetRawDataSize() ;
|
||||
|
||||
void DeclareVar(const std::string& prefix, const std::string& bodyStr);
|
||||
|
||||
std::string GetBodySourceCode();
|
||||
void DeclareAndGenerateOutputCode();
|
||||
|
||||
static std::string GetDefaultName(const std::string& prefix, uint32_t address);
|
||||
std::string GetSourceTypeName();
|
||||
std::string GetName();
|
||||
|
||||
PolygonDlist polyGfxList;
|
||||
};
|
||||
|
||||
class SetMesh : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetMesh(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex, int segAddressOffset);
|
||||
SetMesh(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex, int32_t segAddressOffset);
|
||||
~SetMesh();
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
// virtual std::string GenerateSourceCodePass2(std::string roomName, int baseAddress);
|
||||
// virtual std::string GenerateSourceCodePass3(std::string roomName);
|
||||
virtual std::string GenerateExterns();
|
||||
virtual std::string GetCommandCName();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
virtual int32_t GetRawDataSize();
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, uint32_t baseAddress) override;
|
||||
virtual std::string GenerateExterns() override;
|
||||
virtual std::string GetCommandCName() override;
|
||||
virtual RoomCommand GetRoomCommand() override;
|
||||
virtual size_t GetRawDataSize() override;
|
||||
|
||||
private:
|
||||
MeshHeaderBase* meshHeader;
|
||||
MeshHeaderBase* meshHeader = nullptr;
|
||||
uint32_t segmentOffset;
|
||||
uint8_t data;
|
||||
uint8_t meshHeaderType;
|
||||
|
||||
void GenDListDeclarations(std::vector<uint8_t> rawData, ZDisplayList* dList);
|
||||
std::string GenDListExterns(ZDisplayList* dList);
|
||||
|
|
101
tools/ZAPD/ZAPD/ZRoom/Commands/SetMinimapChests.cpp
Normal file
101
tools/ZAPD/ZAPD/ZRoom/Commands/SetMinimapChests.cpp
Normal file
|
@ -0,0 +1,101 @@
|
|||
#include "SetMinimapChests.h"
|
||||
#include "../../BitConverter.h"
|
||||
#include "../../Globals.h"
|
||||
#include "../../StringHelper.h"
|
||||
#include "../../ZFile.h"
|
||||
#include "../ZRoom.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SetMinimapChests::SetMinimapChests(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex)
|
||||
: ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
int32_t numChests = rawData[rawDataIndex + 1];
|
||||
segmentOffset = GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 4));
|
||||
|
||||
int32_t currentPtr = segmentOffset;
|
||||
|
||||
for (int32_t i = 0; i < numChests; i++)
|
||||
{
|
||||
MinimapChest* chest = new MinimapChest(rawData, currentPtr);
|
||||
chests.push_back(chest);
|
||||
|
||||
currentPtr += 10;
|
||||
}
|
||||
}
|
||||
|
||||
SetMinimapChests::~SetMinimapChests()
|
||||
{
|
||||
for (MinimapChest* chest : chests)
|
||||
delete chest;
|
||||
}
|
||||
|
||||
string SetMinimapChests::GenerateSourceCodePass1(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
return std::string();
|
||||
}
|
||||
|
||||
string SetMinimapChests::GenerateSourceCodePass2(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
string sourceOutput = "";
|
||||
|
||||
sourceOutput +=
|
||||
StringHelper::Sprintf("%s 0x%02X, (u32)%sMinimapChests0x%06X };",
|
||||
ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(),
|
||||
chests.size(), roomName.c_str(), segmentOffset);
|
||||
|
||||
{
|
||||
string declaration = "";
|
||||
|
||||
size_t index = 0;
|
||||
for (MinimapChest* chest : chests)
|
||||
{
|
||||
declaration += StringHelper::Sprintf(" { 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X },",
|
||||
chest->unk0, chest->unk2, chest->unk4, chest->unk6,
|
||||
chest->unk8);
|
||||
|
||||
if (index < chests.size() - 1)
|
||||
declaration += "\n";
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
zRoom->parent->AddDeclarationArray(
|
||||
segmentOffset, DeclarationAlignment::None, DeclarationPadding::None, chests.size() * 10,
|
||||
"MinimapChest",
|
||||
StringHelper::Sprintf("%sMinimapChests0x%06X", roomName.c_str(), segmentOffset),
|
||||
chests.size(), declaration);
|
||||
}
|
||||
|
||||
return sourceOutput;
|
||||
}
|
||||
|
||||
string SetMinimapChests::GenerateExterns()
|
||||
{
|
||||
return StringHelper::Sprintf("extern MinimapChest %sMinimapChests0x%06X[%i];\n",
|
||||
zRoom->GetName().c_str(), segmentOffset, chests.size());
|
||||
}
|
||||
|
||||
string SetMinimapChests::GetCommandCName()
|
||||
{
|
||||
return "SCmdMinimapChests";
|
||||
}
|
||||
|
||||
RoomCommand SetMinimapChests::GetRoomCommand()
|
||||
{
|
||||
return RoomCommand::SetMinimapChests;
|
||||
}
|
||||
|
||||
size_t SetMinimapChests::GetRawDataSize()
|
||||
{
|
||||
return ZRoomCommand::GetRawDataSize() + (chests.size() * 10);
|
||||
}
|
||||
|
||||
MinimapChest::MinimapChest(std::vector<uint8_t> rawData, uint32_t rawDataIndex)
|
||||
: unk0(BitConverter::ToUInt16BE(rawData, rawDataIndex + 0)),
|
||||
unk2(BitConverter::ToUInt16BE(rawData, rawDataIndex + 2)),
|
||||
unk4(BitConverter::ToUInt16BE(rawData, rawDataIndex + 4)),
|
||||
unk6(BitConverter::ToUInt16BE(rawData, rawDataIndex + 6)),
|
||||
unk8(BitConverter::ToUInt16BE(rawData, rawDataIndex + 8))
|
||||
{
|
||||
}
|
33
tools/ZAPD/ZAPD/ZRoom/Commands/SetMinimapChests.h
Normal file
33
tools/ZAPD/ZAPD/ZRoom/Commands/SetMinimapChests.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
#pragma once
|
||||
|
||||
#include "../ZRoomCommand.h"
|
||||
|
||||
class MinimapChest
|
||||
{
|
||||
public:
|
||||
uint16_t unk0;
|
||||
uint16_t unk2;
|
||||
uint16_t unk4;
|
||||
uint16_t unk6;
|
||||
uint16_t unk8;
|
||||
|
||||
MinimapChest(std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
};
|
||||
|
||||
class SetMinimapChests : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetMinimapChests(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
~SetMinimapChests();
|
||||
|
||||
std::string GenerateSourceCodePass1(std::string roomName, uint32_t baseAddress) override;
|
||||
std::string GenerateSourceCodePass2(std::string roomName, uint32_t baseAddress) override;
|
||||
std::string GetCommandCName() override;
|
||||
std::string GenerateExterns() override;
|
||||
RoomCommand GetRoomCommand() override;
|
||||
size_t GetRawDataSize() override;
|
||||
|
||||
private:
|
||||
std::vector<MinimapChest*> chests;
|
||||
uint32_t segmentOffset;
|
||||
};
|
117
tools/ZAPD/ZAPD/ZRoom/Commands/SetMinimapList.cpp
Normal file
117
tools/ZAPD/ZAPD/ZRoom/Commands/SetMinimapList.cpp
Normal file
|
@ -0,0 +1,117 @@
|
|||
#include "SetMinimapList.h"
|
||||
#include "../../BitConverter.h"
|
||||
#include "../../Globals.h"
|
||||
#include "../../StringHelper.h"
|
||||
#include "../../ZFile.h"
|
||||
#include "../ZRoom.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SetMinimapList::SetMinimapList(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex)
|
||||
: ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
segmentOffset = GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 4));
|
||||
listSegmentOffset = GETSEGOFFSET(BitConverter::ToInt32BE(rawData, segmentOffset + 0));
|
||||
unk4 = BitConverter::ToInt32BE(rawData, segmentOffset + 4);
|
||||
|
||||
minimaps = vector<MinimapEntry*>();
|
||||
|
||||
int32_t currentPtr = listSegmentOffset;
|
||||
|
||||
for (int32_t i = 0; i < zRoom->roomCount; i++)
|
||||
{
|
||||
MinimapEntry* entry = new MinimapEntry(rawData, currentPtr);
|
||||
minimaps.push_back(entry);
|
||||
|
||||
currentPtr += 10;
|
||||
}
|
||||
}
|
||||
|
||||
SetMinimapList::~SetMinimapList()
|
||||
{
|
||||
for (MinimapEntry* entry : minimaps)
|
||||
delete entry;
|
||||
}
|
||||
|
||||
string SetMinimapList::GenerateSourceCodePass1(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
return StringHelper::Sprintf(
|
||||
"%s 0x%02X, (u32)&%sMinimapList0x%06X",
|
||||
ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(), minimaps.size(),
|
||||
zRoom->GetName().c_str(), segmentOffset);
|
||||
}
|
||||
|
||||
string SetMinimapList::GenerateSourceCodePass2(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
string sourceOutput = "";
|
||||
|
||||
sourceOutput +=
|
||||
StringHelper::Sprintf("%s 0, (u32)&%sMinimapList0x%06X };",
|
||||
ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(),
|
||||
roomName.c_str(), segmentOffset, unk4);
|
||||
|
||||
{
|
||||
string declaration = StringHelper::Sprintf("(u32)%sMinimapEntryList0x%06X, 0x%08X",
|
||||
roomName.c_str(), listSegmentOffset, unk4);
|
||||
|
||||
zRoom->parent->AddDeclaration(
|
||||
segmentOffset, DeclarationAlignment::Align4, DeclarationPadding::None, 8, "MinimapList",
|
||||
StringHelper::Sprintf("%sMinimapList0x%06X", roomName.c_str(), segmentOffset),
|
||||
declaration);
|
||||
}
|
||||
|
||||
{
|
||||
string declaration = "";
|
||||
|
||||
size_t index = 0;
|
||||
for (MinimapEntry* entry : minimaps)
|
||||
{
|
||||
declaration += StringHelper::Sprintf(" { 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X },",
|
||||
entry->unk0, entry->unk2, entry->unk4, entry->unk6,
|
||||
entry->unk8);
|
||||
|
||||
if (index < minimaps.size() - 1)
|
||||
declaration += "\n";
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
zRoom->parent->AddDeclarationArray(
|
||||
listSegmentOffset, DeclarationAlignment::None, DeclarationPadding::None,
|
||||
minimaps.size() * 10, "MinimapEntry",
|
||||
StringHelper::Sprintf("%sMinimapEntryList0x%06X", roomName.c_str(), listSegmentOffset),
|
||||
minimaps.size(), declaration);
|
||||
}
|
||||
|
||||
return sourceOutput;
|
||||
}
|
||||
|
||||
string SetMinimapList::GenerateExterns()
|
||||
{
|
||||
return StringHelper::Sprintf("extern MinimapList %sMinimapList0x%06X;\n",
|
||||
zRoom->GetName().c_str(), listSegmentOffset);
|
||||
}
|
||||
|
||||
string SetMinimapList::GetCommandCName()
|
||||
{
|
||||
return "SCmdMinimapSettings";
|
||||
}
|
||||
|
||||
RoomCommand SetMinimapList::GetRoomCommand()
|
||||
{
|
||||
return RoomCommand::SetMinimapList;
|
||||
}
|
||||
|
||||
size_t SetMinimapList::GetRawDataSize()
|
||||
{
|
||||
return ZRoomCommand::GetRawDataSize() + (minimaps.size() * 10);
|
||||
}
|
||||
|
||||
MinimapEntry::MinimapEntry(std::vector<uint8_t> rawData, uint32_t rawDataIndex)
|
||||
: unk0(BitConverter::ToUInt16BE(rawData, rawDataIndex + 0)),
|
||||
unk2(BitConverter::ToUInt16BE(rawData, rawDataIndex + 2)),
|
||||
unk4(BitConverter::ToUInt16BE(rawData, rawDataIndex + 4)),
|
||||
unk6(BitConverter::ToUInt16BE(rawData, rawDataIndex + 6)),
|
||||
unk8(BitConverter::ToUInt16BE(rawData, rawDataIndex + 8))
|
||||
{
|
||||
}
|
36
tools/ZAPD/ZAPD/ZRoom/Commands/SetMinimapList.h
Normal file
36
tools/ZAPD/ZAPD/ZRoom/Commands/SetMinimapList.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
#pragma once
|
||||
|
||||
#include "../ZRoomCommand.h"
|
||||
|
||||
class MinimapEntry
|
||||
{
|
||||
public:
|
||||
uint16_t unk0;
|
||||
uint16_t unk2;
|
||||
uint16_t unk4;
|
||||
uint16_t unk6;
|
||||
uint16_t unk8;
|
||||
|
||||
MinimapEntry(std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
};
|
||||
|
||||
class SetMinimapList : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetMinimapList(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
~SetMinimapList();
|
||||
|
||||
std::string GenerateSourceCodePass1(std::string roomName, uint32_t baseAddress) override;
|
||||
std::string GenerateSourceCodePass2(std::string roomName, uint32_t baseAddress) override;
|
||||
std::string GetCommandCName() override;
|
||||
std::string GenerateExterns() override;
|
||||
RoomCommand GetRoomCommand() override;
|
||||
size_t GetRawDataSize() override;
|
||||
|
||||
private:
|
||||
std::vector<MinimapEntry*> minimaps;
|
||||
uint32_t segmentOffset;
|
||||
|
||||
uint32_t listSegmentOffset;
|
||||
uint32_t unk4;
|
||||
};
|
|
@ -1,13 +1,14 @@
|
|||
#include "SetObjectList.h"
|
||||
#include "../../BitConverter.h"
|
||||
#include "../../Globals.h"
|
||||
#include "../../StringHelper.h"
|
||||
#include "../../ZFile.h"
|
||||
#include "../ObjectList.h"
|
||||
#include "../ZNames.h"
|
||||
#include "../ZRoom.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SetObjectList::SetObjectList(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex)
|
||||
SetObjectList::SetObjectList(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex)
|
||||
: ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
objects = vector<uint16_t>();
|
||||
|
@ -32,7 +33,7 @@ string SetObjectList::GenerateExterns()
|
|||
segmentOffset);
|
||||
}
|
||||
|
||||
string SetObjectList::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
string SetObjectList::GenerateSourceCodePass1(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
string sourceOutput = "";
|
||||
|
||||
|
@ -46,7 +47,7 @@ string SetObjectList::GenerateSourceCodePass1(string roomName, int baseAddress)
|
|||
for (size_t i = 0; i < objects.size(); i++)
|
||||
{
|
||||
uint16_t objectIndex = objects[i];
|
||||
declaration += StringHelper::Sprintf("\t%s,", ObjectList[objectIndex].c_str());
|
||||
declaration += StringHelper::Sprintf(" %s,", ZNames::GetObjectName(objectIndex).c_str());
|
||||
|
||||
if (i < objects.size() - 1)
|
||||
declaration += "\n";
|
||||
|
@ -60,7 +61,7 @@ string SetObjectList::GenerateSourceCodePass1(string roomName, int baseAddress)
|
|||
return sourceOutput;
|
||||
}
|
||||
|
||||
int32_t SetObjectList::GetRawDataSize()
|
||||
size_t SetObjectList::GetRawDataSize()
|
||||
{
|
||||
return ZRoomCommand::GetRawDataSize() + (objects.size() * 2);
|
||||
}
|
||||
|
|
|
@ -5,13 +5,13 @@
|
|||
class SetObjectList : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetObjectList(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
SetObjectList(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GetCommandCName();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
virtual int32_t GetRawDataSize();
|
||||
virtual std::string GenerateExterns();
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, uint32_t baseAddress) override;
|
||||
virtual std::string GetCommandCName() override;
|
||||
virtual RoomCommand GetRoomCommand() override;
|
||||
virtual size_t GetRawDataSize() override;
|
||||
virtual std::string GenerateExterns() override;
|
||||
|
||||
private:
|
||||
std::vector<uint16_t> objects;
|
||||
|
|
|
@ -1,101 +1,183 @@
|
|||
#include "SetPathways.h"
|
||||
#include "../../BitConverter.h"
|
||||
#include "../../Globals.h"
|
||||
#include "../../StringHelper.h"
|
||||
#include "../../ZFile.h"
|
||||
#include "../ZRoom.h"
|
||||
|
||||
REGISTER_ZFILENODE(Path, ZSetPathways);
|
||||
|
||||
using namespace std;
|
||||
|
||||
SetPathways::SetPathways(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex)
|
||||
: ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
ZSetPathways::ZSetPathways(ZFile* nParent) : ZResource(nParent)
|
||||
{
|
||||
_rawData = rawData;
|
||||
_rawDataIndex = rawDataIndex;
|
||||
|
||||
segmentOffset = 0;
|
||||
listSegmentOffset = 0;
|
||||
|
||||
InitList(GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 4)));
|
||||
|
||||
if (segmentOffset != 0)
|
||||
zRoom->parent->AddDeclarationPlaceholder(segmentOffset);
|
||||
}
|
||||
|
||||
SetPathways::~SetPathways()
|
||||
ZSetPathways::ZSetPathways(ZRoom* nZRoom, const std::vector<uint8_t>& nRawData, uint32_t nRawDataIndex,
|
||||
bool nIsFromHeader)
|
||||
: ZResource(nZRoom->parent), ZRoomCommand(nZRoom, nRawData, nRawDataIndex)
|
||||
{
|
||||
for (PathwayEntry* entry : pathways)
|
||||
delete entry;
|
||||
rawData = nRawData;
|
||||
rawDataIndex = nRawDataIndex;
|
||||
isFromHeader = nIsFromHeader;
|
||||
}
|
||||
|
||||
void SetPathways::InitList(uint32_t address)
|
||||
ZSetPathways::~ZSetPathways()
|
||||
{
|
||||
segmentOffset = address;
|
||||
listSegmentOffset = GETSEGOFFSET(BitConverter::ToInt32BE(_rawData, address + 4));
|
||||
numPoints = _rawData[address + 0];
|
||||
delete pathwayList;
|
||||
}
|
||||
|
||||
string SetPathways::GetSourceOutputCode(std::string prefix)
|
||||
void ZSetPathways::DeclareVar(const std::string& prefix, const std::string& bodyStr)
|
||||
{
|
||||
parent->AddDeclaration(cmdAddress, DeclarationAlignment::None, 8,
|
||||
StringHelper::Sprintf("static %s", GetCommandCName().c_str()),
|
||||
StringHelper::Sprintf("%sSet%04XCmd%02X", name.c_str(),
|
||||
commandSet & 0x00FFFFFF, cmdIndex, cmdID),
|
||||
StringHelper::Sprintf("%s // 0x%04X", bodyStr.c_str(), cmdAddress));
|
||||
}
|
||||
|
||||
string ZSetPathways::GetSourceOutputCode(const std::string& prefix)
|
||||
{
|
||||
if (pathwayList != nullptr)
|
||||
pathwayList->GetSourceOutputCode(parent->GetName());
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
string SetPathways::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
void ZSetPathways::ParseRawData()
|
||||
{
|
||||
if (isFromHeader)
|
||||
segmentOffset = GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 4));
|
||||
else
|
||||
segmentOffset = rawDataIndex;
|
||||
|
||||
if (segmentOffset != 0)
|
||||
parent->AddDeclarationPlaceholder(segmentOffset);
|
||||
|
||||
int32_t numPaths = (Globals::Instance->game != ZGame::MM_RETAIL) ?
|
||||
1 :
|
||||
zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 8;
|
||||
|
||||
pathwayList = new PathwayList(parent, rawData, segmentOffset, numPaths);
|
||||
}
|
||||
|
||||
string ZSetPathways::GenerateSourceCodePass1(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
ParseRawData();
|
||||
return "";
|
||||
}
|
||||
|
||||
string ZSetPathways::GenerateSourceCodePass2(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
string sourceOutput = "";
|
||||
|
||||
sourceOutput += StringHelper::Sprintf("\n\t%s 0, (u32)%sPathway0x%06X\n};",
|
||||
ZRoomCommand::GenerateSourceCodePass1("", 0).c_str(),
|
||||
parent->GetName().c_str(), segmentOffset);
|
||||
|
||||
if (pathwayList != nullptr)
|
||||
pathwayList->GetSourceOutputCode(parent->GetName());
|
||||
|
||||
return sourceOutput;
|
||||
}
|
||||
|
||||
size_t ZSetPathways::GetRawDataSize()
|
||||
{
|
||||
size_t size = 0;
|
||||
if (pathwayList != nullptr)
|
||||
size += pathwayList->GetRawDataSize();
|
||||
|
||||
return ZRoomCommand::GetRawDataSize() + size;
|
||||
}
|
||||
|
||||
string ZSetPathways::GenerateExterns()
|
||||
{
|
||||
if (pathwayList != nullptr)
|
||||
return pathwayList->GenerateExterns(parent->GetName());
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
string ZSetPathways::GetCommandCName()
|
||||
{
|
||||
return "SCmdPathList";
|
||||
}
|
||||
|
||||
RoomCommand ZSetPathways::GetRoomCommand()
|
||||
{
|
||||
return RoomCommand::SetPathways;
|
||||
}
|
||||
|
||||
PathwayEntry::PathwayEntry(std::vector<uint8_t> rawData, uint32_t rawDataIndex)
|
||||
: numPoints(rawData[rawDataIndex + 0]), unk1(rawData[rawDataIndex + 1]),
|
||||
unk2(BitConverter::ToInt16BE(rawData, rawDataIndex + 2)),
|
||||
listSegmentOffset(GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 4)))
|
||||
{
|
||||
// int numPathsReal = zRoom->GetDeclarationSizeFromNeighbor(listSegmentOffset) / 6;
|
||||
uint32_t currentPtr = listSegmentOffset;
|
||||
uint8_t* data = rawData.data();
|
||||
|
||||
uint8_t* data = _rawData.data();
|
||||
|
||||
for (int i = 0; i < numPoints; i++)
|
||||
for (int32_t i = 0; i < numPoints; i++)
|
||||
{
|
||||
PathwayEntry* entry = new PathwayEntry();
|
||||
entry->x = BitConverter::ToInt16BE(data, currentPtr + 0);
|
||||
entry->y = BitConverter::ToInt16BE(data, currentPtr + 2);
|
||||
entry->z = BitConverter::ToInt16BE(data, currentPtr + 4);
|
||||
x = BitConverter::ToInt16BE(data, currentPtr + 0);
|
||||
y = BitConverter::ToInt16BE(data, currentPtr + 2);
|
||||
z = BitConverter::ToInt16BE(data, currentPtr + 4);
|
||||
|
||||
pathways.push_back(entry);
|
||||
Vec3s point = Vec3s(x, y, z);
|
||||
points.push_back(point);
|
||||
|
||||
currentPtr += 6;
|
||||
}
|
||||
|
||||
if (numPoints == 0) // Hack for SharpOcarina
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int32_t i = 0; i < 3; i++)
|
||||
{
|
||||
PathwayEntry* entry = new PathwayEntry();
|
||||
pathways.push_back(entry);
|
||||
Vec3s point = Vec3s(0, 0, 0);
|
||||
points.push_back(point);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
string SetPathways::GenerateSourceCodePass2(string roomName, int baseAddress)
|
||||
PathwayList::PathwayList(ZFile* nParent, std::vector<uint8_t> rawData, uint32_t rawDataIndex, int32_t length)
|
||||
{
|
||||
string sourceOutput = "";
|
||||
parent = nParent;
|
||||
_rawDataIndex = rawDataIndex;
|
||||
|
||||
sourceOutput +=
|
||||
StringHelper::Sprintf("%s 0, (u32)&%sPathway0x%06X };",
|
||||
ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(),
|
||||
roomName.c_str(), segmentOffset);
|
||||
uint32_t currentPtr = rawDataIndex;
|
||||
|
||||
for (int32_t pathIndex = 0; pathIndex < length; pathIndex++)
|
||||
{
|
||||
string declaration = StringHelper::Sprintf("%i, (u32)%sPathwayList0x%06X", numPoints,
|
||||
roomName.c_str(), listSegmentOffset);
|
||||
PathwayEntry* path = new PathwayEntry(rawData, currentPtr);
|
||||
currentPtr += 8;
|
||||
|
||||
zRoom->parent->AddDeclaration(
|
||||
segmentOffset, DeclarationAlignment::None, DeclarationPadding::None, 8, "Path",
|
||||
StringHelper::Sprintf("%sPathway0x%06X", roomName.c_str(), segmentOffset), declaration);
|
||||
if (path->listSegmentOffset == 0)
|
||||
break;
|
||||
|
||||
pathways.push_back(path);
|
||||
}
|
||||
}
|
||||
|
||||
PathwayList::~PathwayList()
|
||||
{
|
||||
for (PathwayEntry* path : pathways)
|
||||
delete path;
|
||||
}
|
||||
|
||||
void PathwayList::GetSourceOutputCode(const std::string& prefix)
|
||||
{
|
||||
{
|
||||
string declaration = "";
|
||||
|
||||
size_t index = 0;
|
||||
for (PathwayEntry* entry : pathways)
|
||||
{
|
||||
declaration += StringHelper::Sprintf(" { %i, %i, %i }, //0x%06X", entry->x, entry->y,
|
||||
entry->z, listSegmentOffset + (index * 6));
|
||||
if (Globals::Instance->game == ZGame::MM_RETAIL)
|
||||
declaration += StringHelper::Sprintf(" { %i, %i, %i, (u32)%sPathwayList0x%06X },",
|
||||
entry->numPoints, entry->unk1, entry->unk2,
|
||||
prefix.c_str(), entry->listSegmentOffset);
|
||||
else
|
||||
declaration +=
|
||||
StringHelper::Sprintf(" { %i, (u32)%sPathwayList0x%06X },", entry->numPoints,
|
||||
prefix.c_str(), entry->listSegmentOffset);
|
||||
|
||||
if (index < pathways.size() - 1)
|
||||
declaration += "\n";
|
||||
|
@ -103,40 +185,57 @@ string SetPathways::GenerateSourceCodePass2(string roomName, int baseAddress)
|
|||
index++;
|
||||
}
|
||||
|
||||
zRoom->parent->AddDeclarationArray(
|
||||
listSegmentOffset, DeclarationAlignment::None, DeclarationPadding::None,
|
||||
pathways.size() * 6, "Vec3s",
|
||||
StringHelper::Sprintf("%sPathwayList0x%06X", roomName.c_str(), listSegmentOffset),
|
||||
parent->AddDeclarationArray(
|
||||
_rawDataIndex, DeclarationAlignment::None, DeclarationPadding::None,
|
||||
pathways.size() * 8, "Path",
|
||||
StringHelper::Sprintf("%sPathway0x%06X", prefix.c_str(), _rawDataIndex),
|
||||
pathways.size(), declaration);
|
||||
}
|
||||
|
||||
return sourceOutput;
|
||||
for (PathwayEntry* entry : pathways)
|
||||
{
|
||||
string declaration = "";
|
||||
|
||||
size_t index = 0;
|
||||
for (Vec3s& point : entry->points)
|
||||
{
|
||||
declaration += StringHelper::Sprintf(" { %i, %i, %i }, //0x%06X", point.x, point.y,
|
||||
point.z, entry->listSegmentOffset + (index * 6));
|
||||
|
||||
if (index < entry->points.size() - 1)
|
||||
declaration += "\n";
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
int32_t SetPathways::GetRawDataSize()
|
||||
{
|
||||
return ZRoomCommand::GetRawDataSize() + (pathways.size() * 6);
|
||||
parent->AddDeclarationArray(
|
||||
entry->listSegmentOffset, DeclarationAlignment::Align4, DeclarationPadding::Pad4,
|
||||
entry->points.size() * 6, "Vec3s",
|
||||
StringHelper::Sprintf("%sPathwayList0x%06X", prefix.c_str(), entry->listSegmentOffset),
|
||||
entry->points.size(), declaration);
|
||||
}
|
||||
}
|
||||
|
||||
string SetPathways::GenerateExterns()
|
||||
size_t PathwayList::GetRawDataSize()
|
||||
{
|
||||
return StringHelper::Sprintf("extern Vec3s %sPathwayList0x%06X[];\n", zRoom->GetName().c_str(),
|
||||
segmentOffset);
|
||||
size_t pointsSize = 0;
|
||||
|
||||
for (PathwayEntry* entry : pathways)
|
||||
{
|
||||
pointsSize += entry->points.size() * 6;
|
||||
}
|
||||
|
||||
string SetPathways::GetCommandCName()
|
||||
{
|
||||
return "SCmdPathList";
|
||||
return pathways.size() * 8 + pointsSize;
|
||||
}
|
||||
|
||||
RoomCommand SetPathways::GetRoomCommand()
|
||||
string PathwayList::GenerateExterns(const std::string& prefix)
|
||||
{
|
||||
return RoomCommand::SetPathways;
|
||||
string declaration = "";
|
||||
for (PathwayEntry* entry : pathways)
|
||||
{
|
||||
declaration += StringHelper::Sprintf("extern Vec3s %sPathwayList0x%06X[];\n",
|
||||
prefix.c_str(), entry->listSegmentOffset);
|
||||
}
|
||||
|
||||
PathwayEntry::PathwayEntry()
|
||||
{
|
||||
x = 0;
|
||||
y = 0;
|
||||
z = 0;
|
||||
return declaration;
|
||||
}
|
||||
|
|
|
@ -2,35 +2,61 @@
|
|||
|
||||
#include "../../Vec3s.h"
|
||||
#include "../ZRoomCommand.h"
|
||||
#include "ZResource.h"
|
||||
|
||||
class PathwayEntry
|
||||
{
|
||||
public:
|
||||
int16_t x, y, z;
|
||||
|
||||
PathwayEntry();
|
||||
PathwayEntry(std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
|
||||
int32_t numPoints;
|
||||
int8_t unk1; // (MM Only)
|
||||
int16_t unk2; // (MM Only)
|
||||
uint32_t listSegmentOffset;
|
||||
std::vector<Vec3s> points;
|
||||
};
|
||||
|
||||
class SetPathways : public ZRoomCommand
|
||||
struct PathwayList
|
||||
{
|
||||
public:
|
||||
SetPathways(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
~SetPathways();
|
||||
PathwayList(ZFile* nParent, std::vector<uint8_t> rawData, uint32_t rawDataIndex, int32_t length);
|
||||
~PathwayList();
|
||||
|
||||
std::string GetSourceOutputCode(std::string prefix);
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GenerateSourceCodePass2(std::string roomName, int baseAddress);
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
virtual int32_t GetRawDataSize();
|
||||
virtual std::string GetCommandCName();
|
||||
virtual std::string GenerateExterns();
|
||||
void InitList(uint32_t address);
|
||||
void GetSourceOutputCode(const std::string& prefix) ;
|
||||
size_t GetRawDataSize();
|
||||
std::string GenerateExterns(const std::string& prefix);
|
||||
|
||||
private:
|
||||
ZFile* parent;
|
||||
std::vector<PathwayEntry*> pathways;
|
||||
std::vector<uint8_t> _rawData;
|
||||
uint32_t _rawDataIndex;
|
||||
};
|
||||
|
||||
class ZSetPathways : public ZResource, public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
ZSetPathways(ZFile* nParent);
|
||||
ZSetPathways(ZRoom* nZRoom, const std::vector<uint8_t>& nRawData, uint32_t nRawDataIndex,
|
||||
bool nIsFromHeader);
|
||||
~ZSetPathways();
|
||||
|
||||
void ParseRawData() override;
|
||||
|
||||
void DeclareVar(const std::string& prefix, const std::string& bodyStr);
|
||||
std::string GetSourceOutputCode(const std::string& prefix) override;
|
||||
|
||||
std::string GenerateSourceCodePass1(std::string roomName, uint32_t baseAddress) override;
|
||||
std::string GenerateSourceCodePass2(std::string roomName, uint32_t baseAddress) override;
|
||||
RoomCommand GetRoomCommand() override;
|
||||
size_t GetRawDataSize() override;
|
||||
std::string GetCommandCName() override;
|
||||
std::string GenerateExterns() override;
|
||||
|
||||
private:
|
||||
uint32_t segmentOffset;
|
||||
uint32_t listSegmentOffset;
|
||||
int numPoints;
|
||||
std::vector<PathwayEntry*> pathways;
|
||||
std::vector<uint8_t> _rawData;
|
||||
int _rawDataIndex;
|
||||
PathwayList* pathwayList;
|
||||
bool isFromHeader = false;
|
||||
};
|
|
@ -4,14 +4,14 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
SetRoomBehavior::SetRoomBehavior(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex)
|
||||
SetRoomBehavior::SetRoomBehavior(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex)
|
||||
: ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
gameplayFlags = rawData[rawDataIndex + 0x01];
|
||||
gameplayFlags2 = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x04);
|
||||
}
|
||||
|
||||
string SetRoomBehavior::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
string SetRoomBehavior::GenerateSourceCodePass1(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
return StringHelper::Sprintf(
|
||||
"%s 0x%02X, 0x%08X", ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(),
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
class SetRoomBehavior : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetRoomBehavior(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
SetRoomBehavior(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GetCommandCName();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, uint32_t baseAddress) override;
|
||||
virtual std::string GetCommandCName() override;
|
||||
virtual RoomCommand GetRoomCommand() override;
|
||||
|
||||
private:
|
||||
uint8_t gameplayFlags;
|
||||
|
|
|
@ -7,23 +7,25 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
SetRoomList::SetRoomList(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex)
|
||||
SetRoomList::SetRoomList(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex)
|
||||
: ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
int numRooms = rawData[rawDataIndex + 1];
|
||||
int32_t numRooms = rawData[rawDataIndex + 1];
|
||||
segmentOffset = BitConverter::ToInt32BE(rawData, rawDataIndex + 4) & 0x00FFFFFF;
|
||||
|
||||
rooms = vector<RoomEntry*>();
|
||||
|
||||
int32_t currentPtr = segmentOffset;
|
||||
|
||||
for (int i = 0; i < numRooms; i++)
|
||||
for (int32_t i = 0; i < numRooms; i++)
|
||||
{
|
||||
RoomEntry* entry = new RoomEntry(rawData, currentPtr);
|
||||
rooms.push_back(entry);
|
||||
|
||||
currentPtr += 8;
|
||||
}
|
||||
|
||||
zRoom->roomCount = numRooms;
|
||||
}
|
||||
|
||||
SetRoomList::~SetRoomList()
|
||||
|
@ -32,7 +34,7 @@ SetRoomList::~SetRoomList()
|
|||
delete entry;
|
||||
}
|
||||
|
||||
string SetRoomList::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
string SetRoomList::GenerateSourceCodePass1(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
return StringHelper::Sprintf(
|
||||
"%s 0x%02X, (u32)&%sRoomList0x%06X",
|
||||
|
@ -40,7 +42,7 @@ string SetRoomList::GenerateSourceCodePass1(string roomName, int baseAddress)
|
|||
zRoom->GetName().c_str(), segmentOffset);
|
||||
}
|
||||
|
||||
string SetRoomList::GenerateSourceCodePass2(string roomName, int baseAddress)
|
||||
string SetRoomList::GenerateSourceCodePass2(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
@ -72,9 +74,9 @@ std::string SetRoomList::PreGenSourceFiles()
|
|||
if (res->GetResourceType() == ZResourceType::Room && res != zRoom)
|
||||
{
|
||||
string roomName = res->GetName();
|
||||
declaration +=
|
||||
StringHelper::Sprintf("\t{ (u32)_%sSegmentRomStart, (u32)_%sSegmentRomEnd },\n",
|
||||
roomName.c_str(), roomName.c_str());
|
||||
declaration += StringHelper::Sprintf(
|
||||
" { (u32)_%sSegmentRomStart, (u32)_%sSegmentRomEnd },\n", roomName.c_str(),
|
||||
roomName.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +100,7 @@ RoomEntry::RoomEntry(int32_t nVAS, int32_t nVAE)
|
|||
virtualAddressEnd = nVAE;
|
||||
}
|
||||
|
||||
RoomEntry::RoomEntry(std::vector<uint8_t> rawData, int rawDataIndex)
|
||||
RoomEntry::RoomEntry(std::vector<uint8_t> rawData, uint32_t rawDataIndex)
|
||||
: RoomEntry(BitConverter::ToInt32BE(rawData, rawDataIndex + 0),
|
||||
BitConverter::ToInt32BE(rawData, rawDataIndex + 4))
|
||||
{
|
||||
|
|
|
@ -9,22 +9,22 @@ public:
|
|||
int32_t virtualAddressEnd;
|
||||
|
||||
RoomEntry(int32_t nVAS, int32_t nVAE);
|
||||
RoomEntry(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
RoomEntry(std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
};
|
||||
|
||||
class SetRoomList : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetRoomList(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
SetRoomList(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
~SetRoomList();
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GenerateSourceCodePass2(std::string roomName, int baseAddress);
|
||||
virtual std::string GetCommandCName();
|
||||
virtual std::string GenerateExterns();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
virtual std::string PreGenSourceFiles();
|
||||
virtual std::string Save();
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, uint32_t baseAddress) override;
|
||||
virtual std::string GenerateSourceCodePass2(std::string roomName, uint32_t baseAddress) override;
|
||||
virtual std::string GetCommandCName() override;
|
||||
virtual std::string GenerateExterns() override;
|
||||
virtual RoomCommand GetRoomCommand() override;
|
||||
virtual std::string PreGenSourceFiles() override;
|
||||
virtual std::string Save() override;
|
||||
|
||||
private:
|
||||
std::vector<RoomEntry*> rooms;
|
||||
|
|
|
@ -3,14 +3,14 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
SetSkyboxModifier::SetSkyboxModifier(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex)
|
||||
SetSkyboxModifier::SetSkyboxModifier(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex)
|
||||
: ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
disableSky = rawData[rawDataIndex + 0x04];
|
||||
disableSunMoon = rawData[rawDataIndex + 0x05];
|
||||
}
|
||||
|
||||
string SetSkyboxModifier::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
string SetSkyboxModifier::GenerateSourceCodePass1(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
return StringHelper::Sprintf(
|
||||
"%s 0, 0, 0, 0x%02X, 0x%02X",
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
class SetSkyboxModifier : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetSkyboxModifier(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
SetSkyboxModifier(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GetCommandCName();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, uint32_t baseAddress) override;
|
||||
virtual std::string GetCommandCName() override;
|
||||
virtual RoomCommand GetRoomCommand() override;
|
||||
|
||||
private:
|
||||
uint8_t disableSky;
|
||||
|
|
|
@ -1,21 +1,23 @@
|
|||
#include "SetSkyboxSettings.h"
|
||||
#include "../../Globals.h"
|
||||
#include "../../StringHelper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SetSkyboxSettings::SetSkyboxSettings(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex)
|
||||
SetSkyboxSettings::SetSkyboxSettings(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex)
|
||||
: ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
unk1 = rawData[rawDataIndex + 0x01];
|
||||
skyboxNumber = rawData[rawDataIndex + 0x04];
|
||||
cloudsType = rawData[rawDataIndex + 0x05];
|
||||
lightingSettingsControl = rawData[rawDataIndex + 0x06];
|
||||
}
|
||||
|
||||
string SetSkyboxSettings::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
string SetSkyboxSettings::GenerateSourceCodePass1(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
return StringHelper::Sprintf(
|
||||
"%s 0x00, 0x00, 0x00, 0x%02X, 0x%02X, 0x%02X",
|
||||
ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(), skyboxNumber,
|
||||
"%s 0x%02X, 0x00, 0x00, 0x%02X, 0x%02X, 0x%02X",
|
||||
ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(), unk1, skyboxNumber,
|
||||
cloudsType, lightingSettingsControl);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,13 +5,14 @@
|
|||
class SetSkyboxSettings : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetSkyboxSettings(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
SetSkyboxSettings(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GetCommandCName();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, uint32_t baseAddress) override;
|
||||
virtual std::string GetCommandCName() override;
|
||||
virtual RoomCommand GetRoomCommand() override;
|
||||
|
||||
private:
|
||||
uint8_t unk1; // (MM Only)
|
||||
uint8_t skyboxNumber;
|
||||
uint8_t cloudsType;
|
||||
uint8_t lightingSettingsControl;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
SetSoundSettings::SetSoundSettings(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex)
|
||||
SetSoundSettings::SetSoundSettings(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex)
|
||||
: ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
reverb = rawData[rawDataIndex + 0x01];
|
||||
|
@ -11,7 +11,7 @@ SetSoundSettings::SetSoundSettings(ZRoom* nZRoom, std::vector<uint8_t> rawData,
|
|||
musicSequence = rawData[rawDataIndex + 0x07];
|
||||
}
|
||||
|
||||
string SetSoundSettings::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
string SetSoundSettings::GenerateSourceCodePass1(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
return StringHelper::Sprintf(
|
||||
"%s 0x%02X, 0x00, 0x00, 0x00, 0x00, 0x%02X, 0x%02X",
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
class SetSoundSettings : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetSoundSettings(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
SetSoundSettings(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GetCommandCName();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, uint32_t baseAddress) override;
|
||||
virtual std::string GetCommandCName() override;
|
||||
virtual RoomCommand GetRoomCommand() override;
|
||||
|
||||
private:
|
||||
uint8_t reverb;
|
||||
|
|
|
@ -4,14 +4,14 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
SetSpecialObjects::SetSpecialObjects(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex)
|
||||
SetSpecialObjects::SetSpecialObjects(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex)
|
||||
: ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
elfMessage = rawData[rawDataIndex + 0x01];
|
||||
globalObject = BitConverter::ToInt16BE(rawData, rawDataIndex + 6);
|
||||
}
|
||||
|
||||
string SetSpecialObjects::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
string SetSpecialObjects::GenerateSourceCodePass1(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
return StringHelper::Sprintf(
|
||||
"%s 0x%02X, 0x%04X", ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(),
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
class SetSpecialObjects : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetSpecialObjects(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
SetSpecialObjects(ZRoom* nZRoom, std::vector<uint8_t> rawData, uint32_t rawDataIndex);
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GetCommandCName();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, uint32_t baseAddress) override;
|
||||
virtual std::string GetCommandCName() override;
|
||||
virtual RoomCommand GetRoomCommand() override;
|
||||
|
||||
private:
|
||||
uint8_t elfMessage;
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
#include "SetStartPositionList.h"
|
||||
#include "../../BitConverter.h"
|
||||
#include "../../Globals.h"
|
||||
#include "../../StringHelper.h"
|
||||
#include "../../ZFile.h"
|
||||
#include "../ActorList.h"
|
||||
#include "../ZNames.h"
|
||||
#include "../ZRoom.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SetStartPositionList::SetStartPositionList(ZRoom* nZRoom, std::vector<uint8_t> rawData,
|
||||
int rawDataIndex)
|
||||
uint32_t rawDataIndex)
|
||||
: ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
uint8_t numActors = rawData[rawDataIndex + 1];
|
||||
|
@ -21,7 +22,7 @@ SetStartPositionList::SetStartPositionList(ZRoom* nZRoom, std::vector<uint8_t> r
|
|||
|
||||
uint32_t currentPtr = segmentOffset;
|
||||
|
||||
for (int i = 0; i < numActors; i++)
|
||||
for (int32_t i = 0; i < numActors; i++)
|
||||
{
|
||||
actors.push_back(new ActorSpawnEntry(rawData, currentPtr));
|
||||
currentPtr += 16;
|
||||
|
@ -34,7 +35,7 @@ SetStartPositionList::~SetStartPositionList()
|
|||
delete entry;
|
||||
}
|
||||
|
||||
string SetStartPositionList::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
string SetStartPositionList::GenerateSourceCodePass1(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
string sourceOutput = "";
|
||||
|
||||
|
@ -47,10 +48,10 @@ string SetStartPositionList::GenerateSourceCodePass1(string roomName, int baseAd
|
|||
|
||||
for (ActorSpawnEntry* entry : actors)
|
||||
{
|
||||
declaration += StringHelper::Sprintf("\t{ %s, %i, %i, %i, %i, %i, %i, 0x%04X },\n",
|
||||
ActorList[entry->actorNum].c_str(), entry->posX,
|
||||
entry->posY, entry->posZ, entry->rotX, entry->rotY,
|
||||
entry->rotZ, entry->initVar);
|
||||
declaration += StringHelper::Sprintf(" { %s, %i, %i, %i, %i, %i, %i, 0x%04X },\n",
|
||||
ZNames::GetActorName(entry->actorNum).c_str(),
|
||||
entry->posX, entry->posY, entry->posZ, entry->rotX,
|
||||
entry->rotY, entry->rotZ, entry->initVar);
|
||||
}
|
||||
|
||||
zRoom->parent->AddDeclarationArray(
|
||||
|
@ -61,7 +62,7 @@ string SetStartPositionList::GenerateSourceCodePass1(string roomName, int baseAd
|
|||
return sourceOutput;
|
||||
}
|
||||
|
||||
string SetStartPositionList::GenerateSourceCodePass2(string roomName, int baseAddress)
|
||||
string SetStartPositionList::GenerateSourceCodePass2(string roomName, uint32_t baseAddress)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue