Update subrepos (#281)

* git subrepo pull tools/ZAPD --force

subrepo:
  subdir:   "tools/ZAPD"
  merged:   "e02e151c"
upstream:
  origin:   "https://github.com/zeldaret/ZAPD.git"
  branch:   "master"
  commit:   "e02e151c"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "2f68596"

* git subrepo pull tools/decomp-permuter --force

subrepo:
  subdir:   "tools/decomp-permuter"
  merged:   "86b1975e"
upstream:
  origin:   "https://github.com/simonlindholm/decomp-permuter.git"
  branch:   "main"
  commit:   "86b1975e"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "2f68596"

* git subrepo pull tools/graphovl --force

subrepo:
  subdir:   "tools/graphovl"
  merged:   "eb25be94"
upstream:
  origin:   "https://github.com/AngheloAlf/graphovl.git"
  branch:   "master"
  commit:   "eb25be94"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "2f68596"

* git subrepo pull (merge) tools/z64compress --force

subrepo:
  subdir:   "tools/z64compress"
  merged:   "98ef0ac2"
upstream:
  origin:   "https://github.com/z64me/z64compress.git"
  branch:   "main"
  commit:   "98ef0ac2"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "2f68596"

* git subrepo pull tools/ZAPD --force

subrepo:
  subdir:   "tools/ZAPD"
  merged:   "45cb0d6b"
upstream:
  origin:   "https://github.com/zeldaret/ZAPD.git"
  branch:   "master"
  commit:   "45cb0d6b"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "2f68596"

* git subrepo pull tools/asm-differ --force

subrepo:
  subdir:   "tools/asm-differ"
  merged:   "48e675ff"
upstream:
  origin:   "https://github.com/simonlindholm/asm-differ.git"
  branch:   "main"
  commit:   "48e675ff"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "2f68596"

* git subrepo pull tools/ZAPD --force

subrepo:
  subdir:   "tools/ZAPD"
  merged:   "3c00dcb3"
upstream:
  origin:   "https://github.com/zeldaret/ZAPD.git"
  branch:   "master"
  commit:   "3c00dcb3"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "2f68596"

* git subrepo pull tools/asm-differ --force

subrepo:
  subdir:   "tools/asm-differ"
  merged:   "47c94c99"
upstream:
  origin:   "https://github.com/simonlindholm/asm-differ.git"
  branch:   "main"
  commit:   "47c94c99"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "2f68596"

* Declare required textures

* Name texture, add decomp.me permuter settings

* git subrepo pull tools/ZAPD --force

subrepo:
  subdir:   "tools/ZAPD"
  merged:   "913810fc"
upstream:
  origin:   "https://github.com/zeldaret/ZAPD.git"
  branch:   "master"
  commit:   "913810fc"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "2f68596"

* git subrepo pull tools/asm-differ --force

subrepo:
  subdir:   "tools/asm-differ"
  merged:   "97197f2a"
upstream:
  origin:   "https://github.com/simonlindholm/asm-differ.git"
  branch:   "main"
  commit:   "97197f2a"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "2f68596"

* git subrepo pull tools/ZAPD --force

subrepo:
  subdir:   "tools/ZAPD"
  merged:   "623d779f"
upstream:
  origin:   "https://github.com/zeldaret/ZAPD.git"
  branch:   "master"
  commit:   "623d779f"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "2f68596"

* git subrepo pull tools/asm-differ --force

subrepo:
  subdir:   "tools/asm-differ"
  merged:   "55bba23a"
upstream:
  origin:   "https://github.com/simonlindholm/asm-differ.git"
  branch:   "main"
  commit:   "55bba23a"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "2f68596"

* git subrepo pull tools/decomp-permuter --force

subrepo:
  subdir:   "tools/decomp-permuter"
  merged:   "a20bac94"
upstream:
  origin:   "https://github.com/simonlindholm/decomp-permuter.git"
  branch:   "main"
  commit:   "a20bac94"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "2f68596"
This commit is contained in:
EllipticEllipsis
2021-09-22 01:13:03 +01:00
committed by GitHub
parent 0ebd082592
commit 01a6dea813
309 changed files with 8041 additions and 57041 deletions
+2
View File
@@ -1,6 +1,8 @@
<Root>
<File Name="Z2_SECOM" Segment="2" Game="MM">
<Scene Name="Z2_SECOM" Offset="0x0"/>
<!-- This texture is used in an "AnimatedMaterial", and must be declared to use the proper symbol -->
<Texture Name="gSakonsHidoutConveyorBeltTex" OutName="sakons_hideout_conveyor_belt" Height="32" Width="32" Format="rgba16" Offset="0x47F0"/>
</File>
<File Name="Z2_SECOM_room_00" Segment="3" Game="MM">
<Room Name="Z2_SECOM_room_00" Offset="0x0"/>
+4 -1
View File
@@ -333,5 +333,8 @@ ASALocalRun/
*.o
*.d
lib/libgfxd/libgfxd.a
ExporterTest/ExporterTest.a
ZAPDUtils/ZAPDUtils.a
.vscode/
ZAPD/BuildInfo.h
build/
ZAPDUtils/build/
+2 -2
View File
@@ -6,7 +6,7 @@
[subrepo]
remote = https://github.com/zeldaret/ZAPD.git
branch = master
commit = 6be9af65d39a1608ef854efbaf0bf9399aac5da1
parent = 83546045c55d692e45ec25d3f2aac76b48945075
commit = 623d779f8ea111cb8cbb78a218c8454e819c4c13
parent = 9f2368dd710e740ced0f8086de91228b87f41512
method = merge
cmdver = 0.4.3
@@ -0,0 +1,72 @@
#include "CollisionExporter.h"
void ExporterExample_Collision::Save(ZResource* res, [[maybe_unused]]fs::path outPath, BinaryWriter* writer)
{
ZCollisionHeader* col = (ZCollisionHeader*)res;
writer->Write(col->absMinX);
writer->Write(col->absMinY);
writer->Write(col->absMinZ);
writer->Write(col->absMaxX);
writer->Write(col->absMaxY);
writer->Write(col->absMaxZ);
writer->Write(col->numVerts);
writer->Write(col->vtxAddress);
writer->Write(col->numPolygons);
writer->Write(col->polyAddress);
writer->Write(col->polyTypeDefAddress);
writer->Write(col->camDataAddress);
writer->Write(col->numWaterBoxes);
writer->Write(col->waterBoxAddress);
writer->Write(col->vtxSegmentOffset);
writer->Write(col->polySegmentOffset);
writer->Write(col->polyTypeDefSegmentOffset);
writer->Write(col->camDataSegmentOffset);
writer->Write(col->waterBoxSegmentOffset);
uint32_t oldOffset = writer->GetBaseAddress();
writer->Seek(col->vtxSegmentOffset, SeekOffsetType::Start);
for (uint16_t i = 0; i < col->vertices.size(); i++)
{
writer->Write(col->vertices[i].x);
writer->Write(col->vertices[i].y);
writer->Write(col->vertices[i].z);
}
writer->Seek(col->polySegmentOffset, SeekOffsetType::Start);
for (uint16_t i = 0; i < col->polygons.size(); i++)
{
writer->Write(col->polygons[i].type);
writer->Write(col->polygons[i].vtxA);
writer->Write(col->polygons[i].vtxB);
writer->Write(col->polygons[i].vtxC);
writer->Write(col->polygons[i].a);
writer->Write(col->polygons[i].b);
writer->Write(col->polygons[i].c);
writer->Write(col->polygons[i].d);
}
writer->Seek(col->polyTypeDefSegmentOffset, SeekOffsetType::Start);
for (uint16_t i = 0; i < col->polygonTypes.size(); i++)
writer->Write(col->polygonTypes[i]);
writer->Seek(col->camDataSegmentOffset, SeekOffsetType::Start);
for (auto entry : col->camData->entries)
{
writer->Write(entry->cameraSType);
writer->Write(entry->numData);
writer->Write(entry->cameraPosDataSeg);
}
writer->Seek(oldOffset, SeekOffsetType::Start);
}
@@ -0,0 +1,10 @@
#pragma once
#include "ZResource.h"
#include "ZCollision.h"
class ExporterExample_Collision : public ZResourceExporter
{
public:
void Save(ZResource* res, fs::path outPath, BinaryWriter* writer) override;
};
@@ -0,0 +1,159 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{65608eb0-1a47-45ad-ab66-192fb64c762c}</ProjectGuid>
<RootNamespace>ExporterTest</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>ExporterExample</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(SolutionDir)\ZAPD\;$(SolutionDir)ZAPDUtils;$(SolutionDir)lib\tinyxml2;$(SolutionDir)lib\libgfxd;$(SolutionDir)lib\elfio;$(SolutionDir)lib\stb;$(ProjectDir);$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc11</LanguageStandard_C>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="CollisionExporter.h" />
<ClInclude Include="TextureExporter.h" />
<ClInclude Include="RoomExporter.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="CollisionExporter.cpp" />
<ClCompile Include="TextureExporter.cpp" />
<ClCompile Include="Main.cpp" />
<ClCompile Include="RoomExporter.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="TextureExporter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="RoomExporter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="CollisionExporter.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="TextureExporter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="RoomExporter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="CollisionExporter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
+79
View File
@@ -0,0 +1,79 @@
#include <TextureExporter.h>
#include <RoomExporter.h>
#include <CollisionExporter.h>
#include <Globals.h>
enum class ExporterFileMode
{
ModeExample1 = (int)ZFileMode::Custom + 1,
ModeExample2 = (int)ZFileMode::Custom + 2,
ModeExample3 = (int)ZFileMode::Custom + 3,
};
static void ExporterParseFileMode(std::string buildMode, ZFileMode& fileMode)
{
if (buildMode == "me1")
fileMode = (ZFileMode)ExporterFileMode::ModeExample1;
else if (buildMode == "me2")
fileMode = (ZFileMode)ExporterFileMode::ModeExample2;
else if (buildMode == "me3")
fileMode = (ZFileMode)ExporterFileMode::ModeExample3;
}
static void ExporterParseArgs([[maybe_unused]]int argc, char* argv[], int& i)
{
std::string arg = argv[i];
if (arg == "--do-x")
{
}
else if (arg == "--do-y")
{
}
}
static bool ExporterProcessFileMode(ZFileMode fileMode)
{
// Do whatever work is associated with these custom file modes...
// Return true to indicate one of our own file modes is being processed
if (fileMode == (ZFileMode)ExporterFileMode::ModeExample1)
return true;
else if (fileMode == (ZFileMode)ExporterFileMode::ModeExample2)
return true;
else if (fileMode == (ZFileMode)ExporterFileMode::ModeExample3)
return true;
return false;
}
static void ExporterFileBegin(ZFile* file)
{
printf("ExporterFileBegin() called on ZFile %s.\n", file->GetName().c_str());
}
static void ExporterFileEnd(ZFile* file)
{
printf("ExporterFileEnd() called on ZFile %s.\n", file->GetName().c_str());
}
static void ImportExporters()
{
// In this example we set up a new exporter called "EXAMPLE".
// By running ZAPD with the argument -se EXAMPLE, we tell it that we want to use this exporter for our resources.
ExporterSet* exporterSet = new ExporterSet();
exporterSet->processFileModeFunc = ExporterProcessFileMode;
exporterSet->parseFileModeFunc = ExporterParseFileMode;
exporterSet->parseArgsFunc = ExporterParseArgs;
exporterSet->beginFileFunc = ExporterFileBegin;
exporterSet->endFileFunc = ExporterFileEnd;
exporterSet->exporters[ZResourceType::Texture] = new ExporterExample_Texture();
exporterSet->exporters[ZResourceType::Room] = new ExporterExample_Room();
exporterSet->exporters[ZResourceType::CollisionHeader] = new ExporterExample_Collision();
Globals::AddExporter("EXAMPLE", exporterSet);
}
// When ZAPD starts up, it will automatically call the below function, which in turn sets up our exporters.
REGISTER_EXPORTER(ImportExporters)
+28
View File
@@ -0,0 +1,28 @@
# Only used for standalone compilation, usually inherits these from the main makefile
CXXFLAGS ?= -Wall -Wextra -O2 -g -std=c++17
SRC_DIRS := $(shell find -type d -not -path "*build*")
CPP_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.cpp))
H_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.h))
O_FILES := $(foreach f,$(CPP_FILES:.cpp=.o),build/$f)
LIB := ExporterTest.a
# create build directories
$(shell mkdir -p $(foreach dir,$(SRC_DIRS),build/$(dir)))
all: $(LIB)
clean:
rm -rf build $(LIB)
format:
clang-format-11 -i $(CPP_FILES) $(H_FILES)
.PHONY: all clean format
build/%.o: %.cpp
$(CXX) $(CXXFLAGS) $(OPTFLAGS) -I ./ -I ../ZAPD -I ../ZAPDUtils -I ../lib/tinyxml2 -c $(OUTPUT_OPTION) $<
$(LIB): $(O_FILES)
$(AR) rcs $@ $^
+373
View File
@@ -0,0 +1,373 @@
#include "RoomExporter.h"
#include <Utils/BinaryWriter.h>
#include <Utils/MemoryStream.h>
#include <Utils/File.h>
#include <ZRoom/Commands/SetWind.h>
#include <ZRoom/Commands/SetTimeSettings.h>
#include <ZRoom/Commands/SetSkyboxModifier.h>
#include <ZRoom/Commands/SetSoundSettings.h>
#include <ZRoom/Commands/SetCameraSettings.h>
#include <ZRoom/Commands/SetMesh.h>
#include <ZRoom/Commands/SetRoomBehavior.h>
#include <ZRoom/Commands/SetCsCamera.h>
#include <ZRoom/Commands/SetRoomList.h>
#include <ZRoom/Commands/SetCollisionHeader.h>
#include <ZRoom/Commands/SetEntranceList.h>
#include <ZRoom/Commands/SetSpecialObjects.h>
#include <ZRoom/Commands/SetStartPositionList.h>
#include <ZRoom/Commands/SetSkyboxSettings.h>
#include <ZRoom/Commands/SetLightingSettings.h>
#include <ZRoom/Commands/SetEchoSettings.h>
#include <CollisionExporter.h>
void ExporterExample_Room::Save(ZResource* res, fs::path outPath, BinaryWriter* writer)
{
ZRoom* room = (ZRoom*)res;
//MemoryStream* memStream = new MemoryStream();
//BinaryWriter* writer = new BinaryWriter(memStream);
for (uint i = 0; i < room->commands.size() * 8; i++)
writer->Write((uint8_t)0);
for (uint i = 0; i < room->commands.size(); i++)
{
ZRoomCommand* cmd = room->commands[i];
writer->Seek(i * 8, SeekOffsetType::Start);
writer->Write((uint8_t)cmd->cmdID);
switch (cmd->cmdID)
{
case RoomCommand::SetWind:
{
SetWind* cmdSetWind = (SetWind*)cmd;
writer->Write((uint8_t)0); // 0x01
writer->Write((uint8_t)0); // 0x02
writer->Write((uint8_t)0); // 0x03
writer->Write(cmdSetWind->windWest); // 0x04
writer->Write(cmdSetWind->windVertical); // 0x05
writer->Write(cmdSetWind->windSouth); // 0x06
writer->Write(cmdSetWind->clothFlappingStrength); // 0x07
}
break;
case RoomCommand::SetTimeSettings:
{
SetTimeSettings* cmdTime = (SetTimeSettings*)cmd;
writer->Write((uint8_t)0); // 0x01
writer->Write((uint8_t)0); // 0x02
writer->Write((uint8_t)0); // 0x03
writer->Write(cmdTime->hour); // 0x04
writer->Write(cmdTime->min); // 0x05
writer->Write(cmdTime->unk); // 0x06
writer->Write((uint8_t)0); // 0x07
}
break;
case RoomCommand::SetSkyboxModifier:
{
SetSkyboxModifier* cmdSkybox = (SetSkyboxModifier*)cmd;
writer->Write((uint8_t)0); // 0x01
writer->Write((uint8_t)0); // 0x02
writer->Write((uint8_t)0); // 0x03
writer->Write(cmdSkybox->disableSky); // 0x04
writer->Write(cmdSkybox->disableSunMoon); // 0x05
writer->Write((uint8_t)0); // 0x06
writer->Write((uint8_t)0); // 0x07
}
break;
case RoomCommand::SetEchoSettings:
{
SetEchoSettings* cmdEcho = (SetEchoSettings*)cmd;
writer->Write((uint8_t)0); // 0x01
writer->Write((uint8_t)0); // 0x02
writer->Write((uint8_t)0); // 0x03
writer->Write((uint8_t)0); // 0x04
writer->Write((uint8_t)0); // 0x05
writer->Write((uint8_t)0); // 0x06
writer->Write((uint8_t)cmdEcho->echo); // 0x07
}
break;
case RoomCommand::SetSoundSettings:
{
SetSoundSettings* cmdSound = (SetSoundSettings*)cmd;
writer->Write((uint8_t)cmdSound->reverb); // 0x01
writer->Write((uint8_t)0); // 0x02
writer->Write((uint8_t)0); // 0x03
writer->Write((uint8_t)0); // 0x04
writer->Write((uint8_t)0); // 0x05
writer->Write(cmdSound->nightTimeSFX); // 0x06
writer->Write(cmdSound->musicSequence); // 0x07
}
break;
case RoomCommand::SetSkyboxSettings:
{
SetSkyboxSettings* cmdSkybox = (SetSkyboxSettings*)cmd;
writer->Write((uint8_t)cmdSkybox->unk1); // 0x01
writer->Write((uint8_t)0); // 0x02
writer->Write((uint8_t)0); // 0x03
writer->Write((uint8_t)cmdSkybox->skyboxNumber); // 0x04
writer->Write((uint8_t)cmdSkybox->cloudsType); // 0x05
writer->Write((uint8_t)cmdSkybox->isIndoors); // 0x06
}
break;
case RoomCommand::SetRoomBehavior:
{
SetRoomBehavior* cmdRoom = (SetRoomBehavior*)cmd;
writer->Write((uint8_t)cmdRoom->gameplayFlags); // 0x01
writer->Write((uint8_t)0); // 0x02
writer->Write((uint8_t)0); // 0x03
writer->Write(cmdRoom->gameplayFlags2); // 0x04
}
break;
case RoomCommand::SetCsCamera:
{
SetCsCamera* cmdCsCam = (SetCsCamera*)cmd;
writer->Write((uint8_t)cmdCsCam->cameras.size()); // 0x01
writer->Write((uint8_t)0); // 0x02
writer->Write((uint8_t)0); // 0x03
writer->Write(cmdCsCam->segmentOffset); // 0x04
}
break;
case RoomCommand::SetMesh:
{
SetMesh* cmdMesh = (SetMesh*)cmd;
int baseStreamEnd = writer->GetStream().get()->GetLength();
writer->Write((uint8_t)cmdMesh->data); // 0x01
writer->Write((uint8_t)0); // 0x02
writer->Write((uint8_t)0); // 0x03
writer->Write(baseStreamEnd); // 0x04
uint32_t oldOffset = writer->GetBaseAddress();
writer->Seek(baseStreamEnd, SeekOffsetType::Start);
// TODO: NOT DONE
writer->Write(cmdMesh->meshHeaderType);
if (cmdMesh->meshHeaderType == 0)
{
//writer->Write(cmdMesh->)
}
else if (cmdMesh->meshHeaderType == 1)
{
}
else if (cmdMesh->meshHeaderType == 2)
{
}
writer->Seek(oldOffset, SeekOffsetType::Start);
}
break;
case RoomCommand::SetCameraSettings:
{
SetCameraSettings* cmdCam = (SetCameraSettings*)cmd;
writer->Write((uint8_t)cmdCam->cameraMovement); // 0x01
writer->Write((uint8_t)0); // 0x02
writer->Write((uint8_t)0); // 0x03
writer->Write(cmdCam->mapHighlight); // 0x04
}
break;
case RoomCommand::SetLightingSettings:
{
SetLightingSettings* cmdLight = (SetLightingSettings*)cmd;
writer->Write((uint8_t)cmdLight->settings.size()); // 0x01
writer->Write((uint8_t)0); // 0x02
writer->Write((uint8_t)0); // 0x03
writer->Write(cmdLight->segmentOffset); // 0x04
uint32_t oldOffset = writer->GetBaseAddress();
writer->Seek(cmdLight->segmentOffset, SeekOffsetType::Start);
for (LightingSettings setting : cmdLight->settings)
{
writer->Write(setting.ambientClrR);
writer->Write(setting.ambientClrG);
writer->Write(setting.ambientClrB);
writer->Write(setting.diffuseClrA_R);
writer->Write(setting.diffuseClrA_G);
writer->Write(setting.diffuseClrA_B);
writer->Write(setting.diffuseDirA_X);
writer->Write(setting.diffuseDirA_Y);
writer->Write(setting.diffuseDirA_Z);
writer->Write(setting.diffuseClrB_R);
writer->Write(setting.diffuseClrB_G);
writer->Write(setting.diffuseClrB_B);
writer->Write(setting.diffuseDirB_X);
writer->Write(setting.diffuseDirB_Y);
writer->Write(setting.diffuseDirB_Z);
writer->Write(setting.fogClrR);
writer->Write(setting.fogClrG);
writer->Write(setting.fogClrB);
writer->Write(setting.unk);
writer->Write(setting.drawDistance);
}
writer->Seek(oldOffset, SeekOffsetType::Start);
}
break;
case RoomCommand::SetRoomList:
{
SetRoomList* cmdRoom = (SetRoomList*)cmd;
writer->Write((uint8_t)cmdRoom->rooms.size()); // 0x01
writer->Write((uint8_t)0); // 0x02
writer->Write((uint8_t)0); // 0x03
int baseStreamEnd = writer->GetLength();
writer->Write(baseStreamEnd); // 0x04
uint32_t oldOffset = writer->GetBaseAddress();
writer->Seek(baseStreamEnd, SeekOffsetType::Start);
for (RoomEntry entry : cmdRoom->rooms)
{
writer->Write(entry.virtualAddressStart);
writer->Write(entry.virtualAddressEnd);
}
writer->Seek(oldOffset, SeekOffsetType::Start);
}
break;
case RoomCommand::SetCollisionHeader:
{
SetCollisionHeader* cmdCollHeader = (SetCollisionHeader*)cmd;
int streamEnd = writer->GetStream().get()->GetLength();
writer->Write((uint8_t)0); // 0x01
writer->Write((uint8_t)0); // 0x02
writer->Write((uint8_t)0); // 0x03
writer->Write(streamEnd); // 0x04
// TODO: NOT DONE
uint32_t oldOffset = writer->GetBaseAddress();
writer->Seek(streamEnd, SeekOffsetType::Start);
ExporterExample_Collision colExp = ExporterExample_Collision();
colExp.Save(cmdCollHeader->collisionHeader, outPath, writer);
writer->Seek(oldOffset, SeekOffsetType::Start);
}
break;
case RoomCommand::SetEntranceList:
{
SetEntranceList* cmdEntrance = (SetEntranceList*)cmd;
uint32_t baseStreamEnd = writer->GetStream().get()->GetLength();
writer->Write((uint8_t)0); // 0x01
writer->Write((uint8_t)0); // 0x02
writer->Write((uint8_t)0); // 0x03
writer->Write(baseStreamEnd); // 0x04
uint32_t oldOffset = writer->GetBaseAddress();
writer->Seek(baseStreamEnd, SeekOffsetType::Start);
for (EntranceEntry entry : cmdEntrance->entrances)
{
writer->Write((uint8_t)entry.startPositionIndex);
writer->Write((uint8_t)entry.roomToLoad);
}
writer->Seek(oldOffset, SeekOffsetType::Start);
}
break;
case RoomCommand::SetSpecialObjects:
{
SetSpecialObjects* cmdSpecObj = (SetSpecialObjects*)cmd;
writer->Write((uint8_t)cmdSpecObj->elfMessage); // 0x01
writer->Write((uint8_t)0); // 0x02
writer->Write((uint8_t)0); // 0x03
writer->Write((uint8_t)0); // 0x04
writer->Write((uint8_t)0); // 0x05
writer->Write((uint16_t)cmdSpecObj->globalObject); // 0x06
}
break;
case RoomCommand::SetStartPositionList:
{
SetStartPositionList* cmdStartPos = (SetStartPositionList*)cmd;
uint32_t baseStreamEnd = writer->GetStream().get()->GetLength();
writer->Write((uint8_t)cmdStartPos->actors.size()); // 0x01
writer->Write((uint8_t)0); // 0x02
writer->Write((uint8_t)0); // 0x03
writer->Write(baseStreamEnd); // 0x04
uint32_t oldOffset = writer->GetBaseAddress();
writer->Seek(baseStreamEnd, SeekOffsetType::Start);
for (ActorSpawnEntry entry : cmdStartPos->actors)
{
writer->Write(entry.actorNum);
writer->Write(entry.posX);
writer->Write(entry.posY);
writer->Write(entry.posZ);
writer->Write(entry.rotX);
writer->Write(entry.rotY);
writer->Write(entry.rotZ);
writer->Write(entry.initVar);
}
writer->Seek(oldOffset, SeekOffsetType::Start);
}
break;
case RoomCommand::EndMarker:
{
writer->Write((uint8_t)0); // 0x01
writer->Write((uint8_t)0); // 0x02
writer->Write((uint8_t)0); // 0x03
writer->Write((uint8_t)0); // 0x04
writer->Write((uint8_t)0); // 0x05
writer->Write((uint8_t)0); // 0x06
writer->Write((uint8_t)0); // 0x07
}
break;
default:
printf("UNIMPLEMENTED COMMAND: %i\n", (int)cmd->cmdID);
writer->Write((uint8_t)0); // 0x01
writer->Write((uint8_t)0); // 0x02
writer->Write((uint8_t)0); // 0x03
writer->Write((uint8_t)0); // 0x04
writer->Write((uint8_t)0); // 0x05
writer->Write((uint8_t)0); // 0x06
writer->Write((uint8_t)0); // 0x07
break;
}
}
//writer->Close();
//File::WriteAllBytes(StringHelper::Sprintf("%s", res->GetName().c_str()), memStream->ToVector());
}
+10
View File
@@ -0,0 +1,10 @@
#pragma once
#include "ZResource.h"
#include "ZRoom/ZRoom.h"
class ExporterExample_Room : public ZResourceExporter
{
public:
void Save(ZResource* res, fs::path outPath, BinaryWriter* writer) override;
};
@@ -0,0 +1,12 @@
#include "TextureExporter.h"
#include "../ZAPD/ZFile.h"
void ExporterExample_Texture::Save(ZResource* res, [[maybe_unused]]fs::path outPath, BinaryWriter* writer)
{
ZTexture* tex = (ZTexture*)res;
auto data = tex->parent->GetRawData();
for (uint i = tex->GetRawDataIndex(); i < tex->GetRawDataIndex() + tex->GetRawDataSize(); i++)
writer->Write(data[i]);
}
+11
View File
@@ -0,0 +1,11 @@
#pragma once
#include "ZResource.h"
#include "ZTexture.h"
#include <Utils/BinaryWriter.h>
class ExporterExample_Texture : public ZResourceExporter
{
public:
void Save(ZResource* res, fs::path outPath, BinaryWriter* writer) override;
};
+67 -47
View File
@@ -1,70 +1,90 @@
pipeline {
agent {
label "ZAPD"
label 'ZAPD'
}
stages {
// Non-parallel ZAPD stage
stage('Build ZAPD') {
steps {
sh 'make -j'
}
}
stage('Checkout oot') {
steps {
dir('oot') {
git url: 'https://github.com/zeldaret/oot.git'
}
}
}
stage('Set up oot') {
steps {
dir('oot') {
sh 'cp /usr/local/etc/roms/baserom_oot.z64 baserom_original.z64'
// Identical to `make setup` except for copying our newer ZAPD.out into oot
sh 'git submodule update --init --recursive'
sh 'make -C tools'
sh 'cp ../ZAPD.out tools/ZAPD/'
sh 'python3 fixbaserom.py'
sh 'python3 extract_baserom.py'
sh 'python3 extract_assets.py'
// CHECKOUT THE REPOS
stage('Checkout Repos') {
parallel {
stage('Checkout oot') {
steps {
dir('oot') {
git url: 'https://github.com/zeldaret/oot.git'
}
}
}
}
}
stage('Build oot') {
steps {
dir('oot') {
sh 'make -j'
stage('Checkout mm') {
steps{
dir('mm') {
git url: 'https://github.com/zeldaret/mm.git'
}
}
}
}
}
stage('Checkout mm') {
steps {
dir('mm') {
git url: 'https://github.com/zeldaret/mm.git'
}
}
}
stage('Set up mm') {
steps {
dir('mm') {
sh 'cp /usr/local/etc/roms/mm.us.rev1.z64 baserom.mm.us.rev1.z64'
// SETUP THE REPOS
stage('Set up repos') {
parallel {
stage('Setup OOT') {
steps {
dir('oot') {
sh 'cp /usr/local/etc/roms/baserom_oot.z64 baserom_original.z64'
// Identical to `make setup` except for copying our newer ZAPD.out into mm
sh 'git submodule update --init --recursive'
sh 'make -C tools'
sh 'cp ../ZAPD.out tools/ZAPD/'
sh 'python3 tools/extract_rom.py baserom.mm.us.rev1.z64'
sh 'python3 extract_assets.py'
// Identical to `make setup` except for copying our newer ZAPD.out into oot
sh 'git submodule update --init --recursive'
sh 'make -C tools'
sh 'cp ../ZAPD.out tools/ZAPD/'
sh 'python3 fixbaserom.py'
sh 'python3 extract_baserom.py'
sh 'python3 extract_assets.py'
}
}
}
stage('Setup MM') {
steps {
dir('mm') {
sh 'cp /usr/local/etc/roms/mm.us.rev1.z64 baserom.mm.us.rev1.z64'
// Identical to `make setup` except for copying our newer ZAPD.out into mm
sh 'make -C tools'
sh 'cp ../ZAPD.out tools/ZAPD/'
sh 'python3 tools/fixbaserom.py'
sh 'python3 tools/extract_baserom.py'
sh 'python3 extract_assets.py -t 4'
}
}
}
}
}
stage('Build mm') {
steps {
dir('mm') {
sh 'make assembly -j'
sh 'make -j'
// BUILD THE REPOS
stage('Build repos') {
parallel {
stage('Build oot') {
steps {
dir('oot') {
sh 'make -j'
}
}
}
stage('Build mm') {
steps {
dir('mm') {
sh 'make -j disasm'
sh 'make -j all'
}
}
}
}
}
+51 -21
View File
@@ -1,26 +1,31 @@
# use variables in submakes
export
OPTIMIZATION_ON ?= 1
ASAN ?= 0
DEPRECATION_ON ?= 1
DEBUG ?= 0
CXXFLAGS ?=
COPYCHECK_ARGS ?=
COPYCHECK_ARGS ?=
# Set LLD=1 to use ld.lld as the linker
LLD ?= 0
CXX := g++
INC := -I ZAPD -I lib/assimp/include -I lib/elfio -I lib/json/include -I lib/stb -I lib/tinygltf -I lib/libgfxd -I lib/tinyxml2
CXXFLAGS += -fpic -std=c++17 -Wall -fno-omit-frame-pointer
INC := -I ZAPD -I lib/elfio -I lib/libgfxd -I lib/tinyxml2 -I ZAPDUtils
CXXFLAGS := -fpic -std=c++17 -Wall -Wextra -fno-omit-frame-pointer
OPTFLAGS :=
ifneq ($(DEBUG),0)
OPTIMIZATION_ON = 0
DEPRECATION_OFF = 1
CXXFLAGS += -g3 -DDEVELOPMENT
COPYCHECK_ARGS += --devel
DEPRECATION_ON = 0
else
CXXFLAGS += -Werror
endif
ifeq ($(OPTIMIZATION_ON),0)
CXXFLAGS += -O0
OPTFLAGS := -O0
else
CXXFLAGS += -O2 -march=native -mtune=native
OPTFLAGS := -O2 -march=native -mtune=native
endif
ifneq ($(ASAN),0)
@@ -31,48 +36,73 @@ ifneq ($(DEPRECATION_ON),0)
endif
# CXXFLAGS += -DTEXTURE_DEBUG
LDFLAGS := -lstdc++ -lm -ldl -lpng
LDFLAGS := -lm -ldl -lpng
ifneq ($(LLD),0)
LDFLAGS += -fuse-ld=lld
endif
UNAME := $(shell uname)
ifneq ($(UNAME), Darwin)
LDFLAGS += -Wl,-export-dynamic -lstdc++fs
endif
SRC_DIRS := ZAPD ZAPD/ZRoom ZAPD/ZRoom/Commands ZAPD/Overlays ZAPD/HighLevel
ZAPD_SRC_DIRS := $(shell find ZAPD -type d)
SRC_DIRS = $(ZAPD_SRC_DIRS) lib/tinyxml2
ZAPD_CPP_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.cpp))
ZAPD_H_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.h))
ZAPD_CPP_FILES := $(foreach dir,$(ZAPD_SRC_DIRS),$(wildcard $(dir)/*.cpp))
ZAPD_H_FILES := $(foreach dir,$(ZAPD_SRC_DIRS),$(wildcard $(dir)/*.h))
CPP_FILES += $(ZAPD_CPP_FILES) lib/tinyxml2/tinyxml2.cpp
O_FILES := $(CPP_FILES:.cpp=.o)
O_FILES := $(foreach f,$(CPP_FILES:.cpp=.o),build/$f)
O_FILES += build/ZAPD/BuildInfo.o
# create build directories
$(shell mkdir -p $(foreach dir,$(SRC_DIRS),build/$(dir)))
# Main targets
all: ZAPD.out copycheck
genbuildinfo:
build/ZAPD/BuildInfo.o:
python3 ZAPD/genbuildinfo.py $(COPYCHECK_ARGS)
$(CXX) $(CXXFLAGS) $(OPTFLAGS) $(INC) -c $(OUTPUT_OPTION) build/ZAPD/BuildInfo.cpp
copycheck: ZAPD.out
python3 copycheck.py
clean:
rm -f $(O_FILES) ZAPD.out
rm -rf build ZAPD.out
$(MAKE) -C lib/libgfxd clean
$(MAKE) -C ZAPDUtils clean
$(MAKE) -C ExporterTest clean
rebuild: clean all
format:
clang-format-11 -i $(ZAPD_CPP_FILES) $(ZAPD_H_FILES)
$(MAKE) -C ZAPDUtils format
$(MAKE) -C ExporterTest format
.PHONY: all genbuildinfo copycheck clean rebuild format
.PHONY: all build/ZAPD/BuildInfo.o copycheck clean rebuild format
%.o: %.cpp
$(CXX) $(CXXFLAGS) $(INC) -c $< -o $@
build/%.o: %.cpp
$(CXX) $(CXXFLAGS) $(OPTFLAGS) $(INC) -c $(OUTPUT_OPTION) $<
ZAPD/Main.o: genbuildinfo ZAPD/Main.cpp
$(CXX) $(CXXFLAGS) $(INC) -c ZAPD/Main.cpp -o $@
# Submakes
lib/libgfxd/libgfxd.a:
$(MAKE) -C lib/libgfxd
ZAPD.out: $(O_FILES) lib/libgfxd/libgfxd.a
$(CXX) $(CXXFLAGS) $(INC) $(O_FILES) lib/libgfxd/libgfxd.a -o $@ $(FS_INC) $(LDFLAGS)
.PHONY: ExporterTest
ExporterTest:
$(MAKE) -C ExporterTest
.PHONY: ZAPDUtils
ZAPDUtils:
$(MAKE) -C ZAPDUtils
# Linking
ZAPD.out: $(O_FILES) lib/libgfxd/libgfxd.a ExporterTest ZAPDUtils
$(CXX) $(O_FILES) lib/libgfxd/libgfxd.a ZAPDUtils/ZAPDUtils.a -Wl,--whole-archive ExporterTest/ExporterTest.a -Wl,--no-whole-archive $(LDFLAGS) $(OUTPUT_OPTION)
+3
View File
@@ -31,6 +31,7 @@ You can configure a bit your ZAPD build with the following options:
- Debugging symbols enabled (`-g3`). They are disabled by default.
- `OPTIMIZATION_ON=0`: Disables optimizations (`-O0`).
- `DEPRECATION_OFF=1`: Disables deprecation warnings.
- `LLD=1`: builds with the LLVM linker `ld.lld` instead of the system default.
As an example, if you want to build ZAPD with optimizations disabled and use the address sanitizer, you could use the following command:
@@ -110,5 +111,7 @@ ZAPD also accepts the following list of extra parameters:
- `-tm MODE`: Test Mode (enables certain experimental features). To enable it, set `MODE` to `1`.
- `-wno` / `--warn-no-offsets` : Enable warnings for nodes that dont have offsets specified. Takes priority over `-eno`/ `--error-no-offsets`.
- `-eno`/ `--error-no-offsets` : Enable errors for nodes that dont have offsets specified.
- `-se` / `--set-exporter` : Sets which exporter to use.
- `--gcc-compat` : Enables GCC compatible mode. Slower.
Additionally, you can pass the flag `--version` to see the current ZAPD version. If that flag is passed, ZAPD will ignore any other parameter passed.
+36
View File
@@ -5,6 +5,10 @@ VisualStudioVersion = 16.0.30320.27
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZAPD", "ZAPD\ZAPD.vcxproj", "{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ExporterExample", "ExporterTest\ExporterTest.vcxproj", "{65608EB0-1A47-45AD-AB66-192FB64C762C}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZAPDUtils", "ZAPDUtils\ZAPDUtils.vcxproj", "{A2E01C3E-D647-45D1-9788-043DEBC1A908}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@@ -33,6 +37,38 @@ Global
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.RelWithDebInfo|x64.Build.0 = Release|x64
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.RelWithDebInfo|x86.ActiveCfg = Release|Win32
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.RelWithDebInfo|x86.Build.0 = Release|Win32
{65608EB0-1A47-45AD-AB66-192FB64C762C}.Debug|x64.ActiveCfg = Debug|x64
{65608EB0-1A47-45AD-AB66-192FB64C762C}.Debug|x64.Build.0 = Debug|x64
{65608EB0-1A47-45AD-AB66-192FB64C762C}.Debug|x86.ActiveCfg = Debug|Win32
{65608EB0-1A47-45AD-AB66-192FB64C762C}.Debug|x86.Build.0 = Debug|Win32
{65608EB0-1A47-45AD-AB66-192FB64C762C}.MinSizeRel|x64.ActiveCfg = Debug|x64
{65608EB0-1A47-45AD-AB66-192FB64C762C}.MinSizeRel|x64.Build.0 = Debug|x64
{65608EB0-1A47-45AD-AB66-192FB64C762C}.MinSizeRel|x86.ActiveCfg = Debug|Win32
{65608EB0-1A47-45AD-AB66-192FB64C762C}.MinSizeRel|x86.Build.0 = Debug|Win32
{65608EB0-1A47-45AD-AB66-192FB64C762C}.Release|x64.ActiveCfg = Release|x64
{65608EB0-1A47-45AD-AB66-192FB64C762C}.Release|x64.Build.0 = Release|x64
{65608EB0-1A47-45AD-AB66-192FB64C762C}.Release|x86.ActiveCfg = Release|Win32
{65608EB0-1A47-45AD-AB66-192FB64C762C}.Release|x86.Build.0 = Release|Win32
{65608EB0-1A47-45AD-AB66-192FB64C762C}.RelWithDebInfo|x64.ActiveCfg = Release|x64
{65608EB0-1A47-45AD-AB66-192FB64C762C}.RelWithDebInfo|x64.Build.0 = Release|x64
{65608EB0-1A47-45AD-AB66-192FB64C762C}.RelWithDebInfo|x86.ActiveCfg = Release|Win32
{65608EB0-1A47-45AD-AB66-192FB64C762C}.RelWithDebInfo|x86.Build.0 = Release|Win32
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.Debug|x64.ActiveCfg = Debug|x64
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.Debug|x64.Build.0 = Debug|x64
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.Debug|x86.ActiveCfg = Debug|Win32
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.Debug|x86.Build.0 = Debug|Win32
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.MinSizeRel|x64.ActiveCfg = Debug|x64
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.MinSizeRel|x64.Build.0 = Debug|x64
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.MinSizeRel|x86.ActiveCfg = Debug|Win32
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.MinSizeRel|x86.Build.0 = Debug|Win32
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.Release|x64.ActiveCfg = Release|x64
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.Release|x64.Build.0 = Release|x64
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.Release|x86.ActiveCfg = Release|Win32
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.Release|x86.Build.0 = Release|Win32
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.RelWithDebInfo|x64.ActiveCfg = Release|x64
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.RelWithDebInfo|x64.Build.0 = Release|x64
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.RelWithDebInfo|x86.ActiveCfg = Release|Win32
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.RelWithDebInfo|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
+12 -12
View File
@@ -24,20 +24,20 @@ class Declaration
public:
DeclarationAlignment alignment;
DeclarationPadding padding;
size_t size = 0;
std::string preText;
std::string text;
std::string rightText;
std::string postText;
std::string preComment;
std::string postComment;
std::string varType;
std::string varName;
std::string includePath;
size_t size;
std::string preText = "";
std::string text = "";
std::string rightText = "";
std::string postText = "";
std::string preComment = "";
std::string postComment = "";
std::string varType = "";
std::string varName = "";
std::string includePath = "";
bool isExternal = false;
bool isArray = false;
size_t arrayItemCnt = 0;
std::string arrayItemCntStr;
std::string arrayItemCntStr = "";
std::vector<uint32_t> references;
bool isUnaccounted = false;
bool isPlaceholder = false;
@@ -62,4 +62,4 @@ public:
protected:
Declaration(DeclarationAlignment nAlignment, DeclarationPadding nPadding, size_t nSize,
std::string nText);
};
};
+46 -12
View File
@@ -1,7 +1,7 @@
#include "Globals.h"
#include <Utils/File.h>
#include <Utils/Path.h>
#include <algorithm>
#include "File.h"
#include "Path.h"
#include "tinyxml2.h"
using namespace tinyxml2;
@@ -25,6 +25,7 @@ Globals::Globals()
useExternalResources = true;
lastScene = nullptr;
verbosity = VerbosityLevel::VERBOSITY_SILENT;
currentExporter = "";
outputPath = Directory::GetCurrentDirectory();
}
@@ -41,7 +42,7 @@ std::string Globals::FindSymbolSegRef(int32_t segNumber, uint32_t symbolAddress)
if (eResult != tinyxml2::XML_SUCCESS)
return "ERROR";
XMLNode* root = doc.FirstChild();
tinyxml2::XMLNode* root = doc.FirstChild();
if (root == nullptr)
return "ERROR";
@@ -67,8 +68,8 @@ std::string Globals::FindSymbolSegRef(int32_t segNumber, uint32_t symbolAddress)
void Globals::ReadConfigFile(const std::string& configFilePath)
{
XMLDocument doc;
XMLError eResult = doc.LoadFile(configFilePath.c_str());
tinyxml2::XMLDocument doc;
tinyxml2::XMLError eResult = doc.LoadFile(configFilePath.c_str());
if (eResult != tinyxml2::XML_SUCCESS)
{
@@ -76,12 +77,12 @@ void Globals::ReadConfigFile(const std::string& configFilePath)
return;
}
XMLNode* root = doc.FirstChild();
tinyxml2::XMLNode* root = doc.FirstChild();
if (root == nullptr)
return;
for (XMLElement* child = root->FirstChildElement(); child != NULL;
for (tinyxml2::XMLElement* child = root->FirstChildElement(); child != NULL;
child = child->NextSiblingElement())
{
if (std::string(child->Name()) == "SymbolMap")
@@ -128,8 +129,8 @@ void Globals::ReadConfigFile(const std::string& configFilePath)
void Globals::ReadTexturePool(const std::string& texturePoolXmlPath)
{
XMLDocument doc;
XMLError eResult = doc.LoadFile(texturePoolXmlPath.c_str());
tinyxml2::XMLDocument doc;
tinyxml2::XMLError eResult = doc.LoadFile(texturePoolXmlPath.c_str());
if (eResult != tinyxml2::XML_SUCCESS)
{
@@ -137,12 +138,12 @@ void Globals::ReadTexturePool(const std::string& texturePoolXmlPath)
return;
}
XMLNode* root = doc.FirstChild();
tinyxml2::XMLNode* root = doc.FirstChild();
if (root == nullptr)
return;
for (XMLElement* child = root->FirstChildElement(); child != NULL;
for (tinyxml2::XMLElement* child = root->FirstChildElement(); child != NULL;
child = child->NextSiblingElement())
{
if (std::string(child->Name()) == "Texture")
@@ -177,7 +178,7 @@ void Globals::AddSegment(int32_t segment, ZFile* file)
if (std::find(segments.begin(), segments.end(), segment) == segments.end())
segments.push_back(segment);
segmentRefs[segment] = file->GetXmlFilePath();
segmentRefs[segment] = file->GetXmlFilePath().string();
segmentRefFiles[segment] = file;
}
@@ -185,3 +186,36 @@ bool Globals::HasSegment(int32_t segment)
{
return std::find(segments.begin(), segments.end(), segment) != segments.end();
}
std::map<std::string, ExporterSet*>* Globals::GetExporterMap()
{
static std::map<std::string, ExporterSet*> exporters;
return &exporters;
}
void Globals::AddExporter(std::string exporterName, ExporterSet* exporterSet)
{
auto exporters = GetExporterMap();
(*exporters)[exporterName] = exporterSet;
}
ZResourceExporter* Globals::GetExporter(ZResourceType resType)
{
auto exporters = *GetExporterMap();
if (currentExporter != "" && exporters[currentExporter]->exporters.find(resType) !=
exporters[currentExporter]->exporters.end())
return exporters[currentExporter]->exporters[resType];
else
return nullptr;
}
ExporterSet* Globals::GetExporterSet()
{
auto exporters = *GetExporterMap();
if (currentExporter != "")
return exporters[currentExporter];
else
return nullptr;
}
+29 -19
View File
@@ -4,8 +4,8 @@
#include <string>
#include <vector>
#include "ZFile.h"
#include "ZRoom/ZRoom.h"
#include "ZTexture.h"
class ZRoom;
enum class VerbosityLevel
{
@@ -35,6 +35,25 @@ public:
GameConfig() = default;
};
typedef void (*ExporterSetFunc)(ZFile*);
typedef bool (*ExporterSetFuncBool)(ZFileMode fileMode);
typedef void (*ExporterSetFuncVoid)(int argc, char* argv[], int& i);
typedef void (*ExporterSetFuncVoid2)(std::string buildMode, ZFileMode& fileMode);
typedef void (*ExporterSetFuncVoid3)();
class ExporterSet
{
public:
std::map<ZResourceType, ZResourceExporter*> exporters;
ExporterSetFuncVoid parseArgsFunc = nullptr;
ExporterSetFuncVoid2 parseFileModeFunc = nullptr;
ExporterSetFuncBool processFileModeFunc = nullptr;
ExporterSetFunc beginFileFunc = nullptr;
ExporterSetFunc endFileFunc = nullptr;
ExporterSetFuncVoid3 beginXMLFunc = nullptr;
ExporterSetFuncVoid3 endXMLFunc = nullptr;
};
class Globals
{
public:
@@ -56,6 +75,7 @@ public:
bool warnNoOffset = false;
bool errorNoOffset = false;
bool verboseUnaccounted = false;
bool gccCompat = false;
std::vector<ZFile*> files;
std::vector<int32_t> segments;
@@ -64,6 +84,10 @@ public:
ZRoom* lastScene;
std::map<uint32_t, std::string> symbolMap;
std::string currentExporter;
static std::map<std::string, ExporterSet*>* GetExporterMap();
static void AddExporter(std::string exporterName, ExporterSet* exporterSet);
Globals();
std::string FindSymbolSegRef(int32_t segNumber, uint32_t symbolAddress);
void ReadConfigFile(const std::string& configFilePath);
@@ -71,20 +95,6 @@ public:
void GenSymbolMap(const std::string& symbolMapPath);
void AddSegment(int32_t segment, ZFile* file);
bool HasSegment(int32_t segment);
};
/*
* Note: In being able to track references across files, there are a few major files that make use
* of segments...
* Segment 1: nintendo_rogo_static/title_static
* Segment 2: parameter_static
* Segment 4: gameplay_keep
* Segment 5: gameplay_field_keep, gameplay_dangeon_keep
* Segment 7: link_animetion
* Segment 8: icon_item_static
* Segment 9: icon_item_24_static
* Segment 12: icon_item_field_static, icon_item_dungeon_static
* Segment 13: icon_item_nes_static
*
* I'm thinking a config file could be usable, but I'll have to experiment...
*/
ZResourceExporter* GetExporter(ZResourceType resType);
ExporterSet* GetExporterSet();
};
-12
View File
@@ -1,12 +0,0 @@
#pragma once
#include <stdint.h>
/*
* The high level format for animations.
*/
class HLAnimation
{
public:
};
@@ -1,110 +0,0 @@
#include "HLAnimationIntermediette.h"
using namespace tinyxml2;
HLAnimationIntermediette::HLAnimationIntermediette()
{
limit = 0;
limbCount = 0;
frameCount = 0;
rotationValues = std::vector<uint16_t>();
rotationIndices = std::vector<RotationIndex>();
}
HLAnimationIntermediette::~HLAnimationIntermediette()
{
}
HLAnimationIntermediette* HLAnimationIntermediette::FromXML(std::string xmlPath)
{
HLAnimationIntermediette* anim = new HLAnimationIntermediette();
XMLDocument doc;
doc.LoadFile(xmlPath.c_str());
XMLElement* root = doc.RootElement();
anim->limit = root->IntAttribute("Limit");
anim->limbCount = root->IntAttribute("LimbCount");
anim->frameCount = root->IntAttribute("FrameCount");
for (XMLElement* child = root->FirstChildElement(); child != NULL;
child = child->NextSiblingElement())
{
if (std::string(child->Name()) == "RotationValues")
{
for (XMLElement* child2 = child->FirstChildElement(); child2 != NULL;
child2 = child2->NextSiblingElement())
{
std::string value = child2->GetText();
anim->rotationValues.push_back(atoi(value.c_str()));
}
}
else if (std::string(child->Name()) == "RotationIndices")
{
for (XMLElement* child2 = child->FirstChildElement(); child2 != NULL;
child2 = child2->NextSiblingElement())
anim->rotationIndices.push_back(RotationIndex(child2->IntAttribute("X"),
child2->IntAttribute("Y"),
child2->IntAttribute("Z")));
}
}
return anim;
}
HLAnimationIntermediette* HLAnimationIntermediette::FromZAnimation(ZAnimation* zAnim)
{
HLAnimationIntermediette* anim = new HLAnimationIntermediette();
return anim;
}
ZAnimation* HLAnimationIntermediette::ToZAnimation()
{
ZAnimation* zAnim = new ZNormalAnimation(nullptr);
return zAnim;
}
std::string HLAnimationIntermediette::OutputXML()
{
std::string output = "";
XMLDocument doc;
XMLElement* root = doc.NewElement("HLAnimationIntermediette");
root->SetAttribute("Limit", limit);
root->SetAttribute("LimbCount", limbCount);
root->SetAttribute("FrameCount", frameCount);
doc.InsertFirstChild(root);
XMLElement* rotValues = doc.NewElement("RotationValues");
for (size_t i = 0; i < rotationValues.size(); i++)
{
XMLElement* rotValue = doc.NewElement("Value");
rotValue->SetText(rotationValues[i]);
rotValues->InsertEndChild(rotValue);
}
root->InsertEndChild(rotValues);
XMLElement* rotIndices = doc.NewElement("RotationIndices");
for (size_t i = 0; i < rotationIndices.size(); i++)
{
XMLElement* rotIndex = doc.NewElement("Value");
rotIndex->SetAttribute("X", rotationIndices[i].x);
rotIndex->SetAttribute("Y", rotationIndices[i].y);
rotIndex->SetAttribute("Z", rotationIndices[i].z);
rotIndices->InsertEndChild(rotIndex);
}
root->InsertEndChild(rotIndices);
XMLPrinter printer;
doc.Accept(&printer);
return printer.CStr();
}
@@ -1,32 +0,0 @@
#pragma once
#include <stdint.h>
#include "../ZAnimation.h"
#include "HLFileIntermediette.h"
#include "tinyxml2.h"
/*
* An intermediette format for animations. Going to use XML.
* Goes from FBX->XML->C
* Note: At the moment this is a very direct representation of the output format.
* Optimally we can determine where the keyframes are and remove redundant information.
*/
class HLAnimationIntermediette
{
public:
int16_t frameCount;
int16_t limit;
int16_t limbCount;
std::vector<uint16_t> rotationValues;
std::vector<RotationIndex> rotationIndices;
HLAnimationIntermediette();
~HLAnimationIntermediette();
std::string OutputXML();
ZAnimation* ToZAnimation();
static HLAnimationIntermediette* FromXML(std::string xmlPath);
static HLAnimationIntermediette* FromZAnimation(ZAnimation* zAnim);
};
@@ -1,5 +0,0 @@
#pragma once
class HLFileIntermediette
{
};
File diff suppressed because it is too large Load Diff
@@ -1,312 +0,0 @@
#pragma once
#include <Vec3s.h>
#include <assimp/scene.h>
#include <stdint.h>
#include <string>
#include <vector>
#include "../ZDisplayList.h"
#include "../ZSkeleton.h"
#include "HLFileIntermediette.h"
#include "tinyxml2.h"
/*
* An intermediette format for models. Goes from FBX<-->Intermediette<-->Display List C Code.
*/
class HLModelIntermediette;
class HLIntermediette
{
public:
std::string name;
HLModelIntermediette* parent;
HLIntermediette();
~HLIntermediette();
virtual std::string OutputCode();
virtual std::string OutputOBJ();
virtual void OutputAssimp(aiScene* scene, std::vector<aiVector3D>* verts);
virtual void OutputXML(tinyxml2::XMLDocument* doc, tinyxml2::XMLElement* root);
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;
bool startsWithPipeSync;
bool startsWithClearGeometryMode;
bool lerpBeforeTextureBlock;
uint32_t startIndex;
uint32_t meshStartIndex;
HLModelIntermediette();
~HLModelIntermediette();
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 ToAssimpFile();
std::string OutputCode();
std::string OutputXML();
template <typename T>
T* FindByName(std::string name);
template <typename T>
T* FindByType();
};
class HLTextureIntermediette : public HLIntermediette
{
public:
ZTexture* tex;
std::string fileName;
HLTextureIntermediette();
virtual void InitFromXML(tinyxml2::XMLElement* xmlElement);
virtual std::string OutputCode();
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:
HLTerminator();
~HLTerminator();
virtual void OutputAssimp(aiScene* scene, std::vector<aiVector3D>* verts);
};
enum class HLMaterialCmt
{
Wrap,
Mirror,
Clamp
};
class HLMaterialIntermediette : public HLIntermediette
{
public:
std::string textureName;
// int32_t repeatH, repeatV;
uint8_t clrR, clrG, clrB, clrA, clrM, clrL;
// bool clampH, clampV;
// bool mirrorH, mirrorV;
HLMaterialCmt cmtH, cmtV;
// TODO: Remember to add lerp params here...
HLMaterialIntermediette();
virtual std::string OutputCode();
virtual void OutputXML(tinyxml2::XMLDocument* doc, tinyxml2::XMLElement* parent);
virtual void InitFromXML(tinyxml2::XMLElement* xmlElement);
};
class HLMeshCommand
{
public:
virtual void InitFromXML(tinyxml2::XMLElement* xmlElement);
virtual std::string OutputCode(HLModelIntermediette* parent);
virtual std::string OutputOBJ(HLModelIntermediette* parent);
virtual void OutputAssimp(HLModelIntermediette* parent, aiScene* scene, aiMesh* mesh);
virtual void OutputXML(tinyxml2::XMLElement* parent);
};
class HLVerticesIntermediette : public HLIntermediette
{
public:
std::vector<ZVtx> vertices;
HLVerticesIntermediette();
virtual void InitFromXML(tinyxml2::XMLElement* verticesElement);
void InitFromVertices(std::vector<ZVtx> dispListVertices);
virtual std::string OutputCode(HLModelIntermediette* parent);
virtual std::string OutputOBJ();
virtual void OutputAssimp(aiScene* scene, std::vector<aiVector3D>* verts);
virtual void OutputXML(tinyxml2::XMLDocument* doc, tinyxml2::XMLElement* root);
};
class HLMeshCmdTriangle1 : public HLMeshCommand
{
public:
int32_t v0, v1, v2, flag;
HLMeshCmdTriangle1();
HLMeshCmdTriangle1(int32_t nV0, int32_t nV1, int32_t nV2, int32_t nFlag);
virtual void InitFromXML(tinyxml2::XMLElement* xmlElement);
virtual std::string OutputCode(HLModelIntermediette* parent);
virtual void OutputAssimp(HLModelIntermediette* parent, aiScene* scene, aiMesh* mesh);
virtual void OutputXML(tinyxml2::XMLElement* parent);
};
class HLMeshCmdTriangle2 : public HLMeshCommand
{
public:
int32_t v0, v1, v2, flag0, v10, v11, v12, flag1;
HLMeshCmdTriangle2();
HLMeshCmdTriangle2(int32_t nV0, int32_t nV1, int32_t nV2, int32_t nFlag0, int32_t nV10,
int32_t nV11, int32_t nV12, int32_t nFlag1);
virtual void InitFromXML(tinyxml2::XMLElement* xmlElement);
virtual std::string OutputCode(HLModelIntermediette* parent);
virtual std::string OutputOBJ(HLModelIntermediette* parent);
virtual void OutputAssimp(HLModelIntermediette* parent, aiScene* scene, aiMesh* mesh);
virtual void OutputXML(tinyxml2::XMLElement* parent);
};
class HLMeshCmdLoadVertices : public HLMeshCommand
{
public:
uint8_t numVerts;
uint8_t startIndex;
HLMeshCmdLoadVertices();
HLMeshCmdLoadVertices(uint8_t nNumVerts, uint8_t nStartIndex);
virtual void OutputXML(tinyxml2::XMLElement* parent);
virtual void InitFromXML(tinyxml2::XMLElement* xmlElement);
virtual std::string OutputOBJ(HLModelIntermediette* parent);
virtual void OutputAssimp(HLModelIntermediette* parent, aiScene* scene, aiMesh* mesh);
virtual std::string OutputCode(HLModelIntermediette* parent);
};
class HLMeshCmdCull : public HLMeshCommand
{
public:
uint8_t indexStart;
uint8_t indexEnd;
HLMeshCmdCull();
virtual void InitFromXML(tinyxml2::XMLElement* xmlElement);
virtual std::string OutputCode(HLModelIntermediette* parent);
};
class HLMeshCmdGeoSettings : public HLMeshCommand
{
public:
std::string on, off;
HLMeshCmdGeoSettings();
virtual void InitFromXML(tinyxml2::XMLElement* xmlElement);
virtual std::string OutputCode(HLModelIntermediette* parent);
};
class HLMeshIntermediette : public HLIntermediette
{
public:
std::vector<HLMeshCommand*> commands;
HLMeshIntermediette();
void InitFromXML(tinyxml2::XMLElement* xmlElement);
std::string OutputCode(std::string materialName);
virtual std::string OutputOBJ();
virtual void OutputAssimp(aiScene* scene, std::vector<aiVector3D>* verts);
virtual void OutputXML(tinyxml2::XMLDocument* doc, tinyxml2::XMLElement* root);
};
class HLDisplayListCommand
{
public:
virtual void InitFromXML(tinyxml2::XMLElement* xmlElement);
virtual std::string OutputCode();
};
class HLDisplayListCmdDrawMesh : public HLDisplayListCommand
{
public:
std::string meshName, materialName;
virtual void InitFromXML(tinyxml2::XMLElement* xmlElement);
virtual std::string OutputCode();
};
class HLDisplayListCmdPipeSync : public HLDisplayListCommand
{
public:
virtual void InitFromXML(tinyxml2::XMLElement* xmlElement);
virtual std::string OutputCode();
};
class HLDisplayListIntermediette : public HLIntermediette
{
public:
std::vector<HLDisplayListCommand*> commands;
uint32_t address;
HLDisplayListIntermediette();
virtual std::string OutputCode();
virtual void InitFromXML(tinyxml2::XMLElement* xmlElement);
};
class HLLimbCommand
{
public:
std::string meshName, materialName;
HLLimbCommand();
HLLimbCommand(std::string nMeshName, std::string nMaterialName);
virtual void InitFromXML(tinyxml2::XMLElement* xmlElement);
virtual void OutputXML(tinyxml2::XMLElement* parent);
virtual std::string OutputCode(HLModelIntermediette* parent);
};
class HLLimbIntermediette : public HLIntermediette
{
public:
std::vector<HLLimbCommand*> commands;
HLLimbIntermediette();
void InitFromXML(tinyxml2::XMLElement* xmlElement);
std::string OutputCode();
virtual void OutputXML(tinyxml2::XMLDocument* doc, tinyxml2::XMLElement* root);
};
-13
View File
@@ -1,13 +0,0 @@
#include "HLTexture.h"
#include "../StringHelper.h"
HLTexture* HLTexture::FromPNG(std::string pngFilePath, HLTextureType texType)
{
// int32_t comp;
HLTexture* tex = new HLTexture();
tex->type = texType;
// tex->bmpRgba = (uint8_t*)stbi_load((pngFilePath).c_str(), (int32_t*)&tex->width,
// (int32_t*)&tex->height, &comp, STBI_rgb_alpha);
return tex;
}
-31
View File
@@ -1,31 +0,0 @@
#pragma once
#include <stdint.h>
#include <string>
#include <vector>
// TODO: This was duplicated from ZTexture. It's probably going to be modified to differentiate from
// ZTexture but if not, we're going to need to have the two share an enum.
enum class HLTextureType
{
RGBA32bpp,
RGBA16bpp,
Palette4bpp,
Palette8bpp,
Grayscale4bpp,
Grayscale8bpp,
GrayscaleAlpha4bpp,
GrayscaleAlpha8bpp,
GrayscaleAlpha16bpp,
Error
};
class HLTexture
{
public:
static HLTexture* FromPNG(std::string pngFilePath, HLTextureType texType);
HLTextureType type;
uint32_t width, height;
uint8_t* bmpRgba;
};
+4 -2
View File
@@ -5,7 +5,7 @@
#include <png.h>
#include <stdexcept>
#include "StringHelper.h"
#include "Utils/StringHelper.h"
/* ImageBackend */
@@ -216,7 +216,9 @@ void ImageBackend::WritePng(const char* filename)
void ImageBackend::WritePng(const fs::path& filename)
{
WritePng(filename.c_str());
// Note: The .string() is necessary for MSVC, due to the implementation of std::filesystem
// differing from GCC. Do not remove!
WritePng(filename.string().c_str());
}
void ImageBackend::SetTextureData(const std::vector<std::vector<RGBAPixel>>& texData,
+1 -1
View File
@@ -3,7 +3,7 @@
#include <cstdint>
#include <vector>
#include "Directory.h"
#include "Utils/Directory.h"
class RGBAPixel
{
+110 -109
View File
@@ -1,11 +1,8 @@
#include "BuildInfo.h"
#include "Directory.h"
#include "File.h"
#include <Utils/Directory.h>
#include <Utils/File.h>
#include <Utils/Path.h>
#include "Globals.h"
#include "HighLevel/HLAnimationIntermediette.h"
#include "HighLevel/HLModelIntermediette.h"
#include "Overlays/ZOverlay.h"
#include "Path.h"
#include "ZAnimation.h"
#include "ZBackground.h"
#include "ZBlob.h"
@@ -27,13 +24,13 @@
using namespace tinyxml2;
extern const char gBuildHash[];
bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, ZFileMode fileMode);
void BuildAssetTexture(const fs::path& pngFilePath, TextureType texType, const fs::path& outPath);
void BuildAssetBackground(const fs::path& imageFilePath, const fs::path& outPath);
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__)
#define ARRAY_COUNT(arr) (sizeof(arr) / sizeof(arr[0]))
@@ -118,33 +115,6 @@ int main(int argc, char* argv[])
Globals* g = new Globals();
// Parse File Mode
std::string buildMode = argv[1];
ZFileMode fileMode = ZFileMode::Invalid;
if (buildMode == "btex")
fileMode = ZFileMode::BuildTexture;
else if (buildMode == "bren")
fileMode = ZFileMode::BuildBackground;
else if (buildMode == "bovl")
fileMode = ZFileMode::BuildOverlay;
else if (buildMode == "bsf")
fileMode = ZFileMode::BuildSourceFile;
else if (buildMode == "bblb")
fileMode = ZFileMode::BuildBlob;
else if (buildMode == "bmdlintr")
fileMode = ZFileMode::BuildModelIntermediette;
else if (buildMode == "bamnintr")
fileMode = ZFileMode::BuildAnimationIntermediette;
else if (buildMode == "e")
fileMode = ZFileMode::Extract;
if (fileMode == ZFileMode::Invalid)
{
printf("Error: Invalid file mode '%s'\n", buildMode.c_str());
return 1;
}
// Parse other "commands"
for (int32_t i = 2; i < argc; i++)
{
@@ -152,76 +122,63 @@ int main(int argc, char* argv[])
if (arg == "-o" || arg == "--outputpath") // Set output path
{
Globals::Instance->outputPath = argv[i + 1];
Globals::Instance->outputPath = argv[++i];
if (Globals::Instance->sourceOutputPath == "")
Globals::Instance->sourceOutputPath = Globals::Instance->outputPath;
i++;
}
else if (arg == "-i" || arg == "--inputpath") // Set input path
{
Globals::Instance->inputPath = argv[i + 1];
i++;
Globals::Instance->inputPath = argv[++i];
}
else if (arg == "-b" || arg == "--baserompath") // Set baserom path
{
Globals::Instance->baseRomPath = argv[i + 1];
i++;
Globals::Instance->baseRomPath = argv[++i];
}
else if (arg == "-osf") // Set source output path
{
Globals::Instance->sourceOutputPath = argv[i + 1];
i++;
Globals::Instance->sourceOutputPath = argv[++i];
}
else if (arg == "-gsf") // Generate source file during extraction
{
Globals::Instance->genSourceFile = std::string(argv[i + 1]) == "1";
i++;
Globals::Instance->genSourceFile = std::string(argv[++i]) == "1";
}
else if (arg == "-tm") // Test Mode (enables certain experimental features)
{
Globals::Instance->testMode = std::string(argv[i + 1]) == "1";
i++;
Globals::Instance->testMode = std::string(argv[++i]) == "1";
}
else if (arg == "-crc" ||
arg == "--output-crc") // Outputs a CRC file for each extracted texture.
{
Globals::Instance->outputCrc = true;
Globals::Instance->testMode = std::string(argv[++i]) == "1";
}
else if (arg == "-ulzdl") // Use Legacy ZDisplay List
{
Globals::Instance->useLegacyZDList = std::string(argv[i + 1]) == "1";
i++;
Globals::Instance->useLegacyZDList = std::string(argv[++i]) == "1";
}
else if (arg == "-profile") // Enable profiling
{
Globals::Instance->profile = std::string(argv[i + 1]) == "1";
i++;
Globals::Instance->profile = std::string(argv[++i]) == "1";
}
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 = std::string(argv[i + 1]) == "1";
i++;
Globals::Instance->useExternalResources = std::string(argv[++i]) == "1";
}
else if (arg == "-tt") // Set texture type
{
Globals::Instance->texType = ZTexture::GetTextureTypeFromString(argv[i + 1]);
i++;
Globals::Instance->texType = ZTexture::GetTextureTypeFromString(argv[++i]);
}
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++;
Globals::Instance->cfgPath = argv[++i];
}
else if (arg == "-rconf") // Read Config File
{
Globals::Instance->ReadConfigFile(argv[i + 1]);
i++;
Globals::Instance->ReadConfigFile(argv[++i]);
}
else if (arg == "-eh") // Enable Error Handler
{
@@ -253,6 +210,49 @@ int main(int argc, char* argv[])
{
Globals::Instance->verboseUnaccounted = true;
}
else if (arg == "-se" || arg == "--set-exporter") // Set Current Exporter
{
Globals::Instance->currentExporter = argv[++i];
}
else if (arg == "--gcc-compat") // GCC compatibility
{
Globals::Instance->gccCompat = true;
}
}
// Parse File Mode
ExporterSet* exporterSet = Globals::Instance->GetExporterSet();
std::string buildMode = argv[1];
ZFileMode fileMode = ZFileMode::Invalid;
if (buildMode == "btex")
fileMode = ZFileMode::BuildTexture;
else if (buildMode == "bren")
fileMode = ZFileMode::BuildBackground;
else if (buildMode == "bovl")
fileMode = ZFileMode::BuildOverlay;
else if (buildMode == "bsf")
fileMode = ZFileMode::BuildSourceFile;
else if (buildMode == "bblb")
fileMode = ZFileMode::BuildBlob;
else if (buildMode == "e")
fileMode = ZFileMode::Extract;
else if (exporterSet != nullptr && exporterSet->parseFileModeFunc != nullptr)
exporterSet->parseFileModeFunc(buildMode, fileMode);
if (fileMode == ZFileMode::Invalid)
{
printf("Error: Invalid file mode '%s'\n", buildMode.c_str());
return 1;
}
// We've parsed through our commands once. If an exporter exists, it's been set by now.
// Now we'll parse through them again but pass them on to our exporter if one is available.
if (exporterSet != nullptr && exporterSet->parseArgsFunc != nullptr)
{
for (int32_t i = 2; i < argc; i++)
exporterSet->parseArgsFunc(argc, argv, i);
}
if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_INFO)
@@ -260,11 +260,47 @@ int main(int argc, char* argv[])
if (fileMode == ZFileMode::Extract || fileMode == ZFileMode::BuildSourceFile)
{
bool parseSuccessful =
Parse(Globals::Instance->inputPath, Globals::Instance->baseRomPath, fileMode);
bool procFileModeSuccess = false;
if (!parseSuccessful)
return 1;
if (exporterSet != nullptr && exporterSet->processFileModeFunc != nullptr)
procFileModeSuccess = exporterSet->processFileModeFunc(fileMode);
if (!procFileModeSuccess)
{
if (fileMode == ZFileMode::Extract || fileMode == ZFileMode::BuildSourceFile)
{
bool parseSuccessful =
Parse(Globals::Instance->inputPath, Globals::Instance->baseRomPath, fileMode);
if (!parseSuccessful)
return 1;
}
else if (fileMode == ZFileMode::BuildTexture)
{
TextureType texType = Globals::Instance->texType;
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)
{
BuildAssetBlob(Globals::Instance->inputPath, Globals::Instance->outputPath);
}
else if (fileMode == ZFileMode::BuildOverlay)
{
ZOverlay* overlay = ZOverlay::FromBuild(
Path::GetDirectoryName(Globals::Instance->inputPath.string()),
Path::GetDirectoryName(Globals::Instance->cfgPath.string()));
if (overlay)
File::WriteAllText(Globals::Instance->outputPath.string(),
overlay->GetSourceOutputCode(""));
}
}
}
else if (fileMode == ZFileMode::BuildTexture)
{
@@ -279,15 +315,6 @@ int main(int argc, char* argv[])
{
BuildAssetBlob(Globals::Instance->inputPath, Globals::Instance->outputPath);
}
else if (fileMode == ZFileMode::BuildModelIntermediette)
{
BuildAssetModelIntermediette(Globals::Instance->outputPath);
}
else if (fileMode == ZFileMode::BuildAnimationIntermediette)
{
BuildAssetAnimationIntermediette(Globals::Instance->inputPath,
Globals::Instance->outputPath);
}
else if (fileMode == ZFileMode::BuildOverlay)
{
ZOverlay* overlay =
@@ -338,6 +365,11 @@ bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, ZFileMode file
}
}
ExporterSet* exporterSet = Globals::Instance->GetExporterSet();
if (exporterSet != nullptr && exporterSet->beginXMLFunc != nullptr)
exporterSet->beginXMLFunc();
for (ZFile* file : Globals::Instance->files)
{
if (fileMode == ZFileMode::BuildSourceFile)
@@ -346,6 +378,9 @@ bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, ZFileMode file
file->ExtractResources();
}
if (exporterSet != nullptr && exporterSet->endXMLFunc != nullptr)
exporterSet->endXMLFunc();
// All done, free files
for (ZFile* file : Globals::Instance->files)
delete file;
@@ -360,7 +395,7 @@ void BuildAssetTexture(const fs::path& pngFilePath, TextureType texType, const f
std::string name = outPath.stem().string();
ZTexture tex(nullptr);
tex.FromPNG(pngFilePath, texType);
tex.FromPNG(pngFilePath.string(), texType);
std::string cfgPath = StringHelper::Split(pngFilePath.string(), ".")[0] + ".cfg";
if (File::Exists(cfgPath))
@@ -390,37 +425,3 @@ void BuildAssetBlob(const fs::path& blobFilePath, const fs::path& outPath)
delete blob;
}
void BuildAssetModelIntermediette(const fs::path& outPath)
{
XMLDocument doc;
HLModelIntermediette* mdl = HLModelIntermediette::FromXML(doc.RootElement());
std::string output = mdl->OutputCode();
File::WriteAllText(outPath.string(), output);
delete mdl;
}
void BuildAssetAnimationIntermediette(const fs::path& animPath, const fs::path& outPath)
{
std::vector<std::string> split = StringHelper::Split(outPath.string(), "/");
ZFile* file = new ZFile(split[split.size() - 2]);
HLAnimationIntermediette* anim = HLAnimationIntermediette::FromXML(animPath.string());
ZAnimation* zAnim = anim->ToZAnimation();
zAnim->SetName(Path::GetFileNameWithoutExtension(split[split.size() - 1]));
zAnim->parent = file;
zAnim->GetSourceOutputCode(split[split.size() - 2]);
std::string output = "";
output += file->declarations[2]->text + "\n";
output += file->declarations[1]->text + "\n";
output += file->declarations[0]->text + "\n";
File::WriteAllText(outPath.string(), output);
delete zAnim;
delete file;
}
+2 -3
View File
@@ -102,9 +102,8 @@ int (*OutputFormatter::StaticWriter())(const char* buf, int count)
}
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}
: tabSize{tabSize}, lineLimit{lineLimit}, col{0}, nest{0}, nestIndent{defaultIndent},
currentIndent{defaultIndent}, wordNests(0), wordP{word}, spaceP{space}
{
}
-1
View File
@@ -8,7 +8,6 @@ class OutputFormatter
{
private:
const uint32_t tabSize;
const uint32_t defaultIndent;
const uint32_t lineLimit;
uint32_t col;
+206 -93
View File
@@ -1,11 +1,50 @@
#include "ZOverlay.h"
#include "../Directory.h"
#include "../File.h"
#include "../Path.h"
#include "../StringHelper.h"
#include <assert.h>
#include <unordered_set>
#include <Utils/Directory.h>
#include <Utils/File.h>
#include <Utils/Path.h>
#include <Utils/StringHelper.h>
#include "Globals.h"
using namespace ELFIO;
const char* RelocationEntry::GetSectionName() const
{
switch (sectionType)
{
case SectionType::Text:
return ".text";
case SectionType::Data:
return ".data";
case SectionType::RoData:
return ".rodata";
case SectionType::Bss:
return ".bss";
case SectionType::ERROR:
return ".ERROR";
}
assert(!"Oh no :c");
}
const char* RelocationEntry::GetRelocTypeName() const
{
switch (relocationType)
{
case RelocationType::R_MIPS_32:
return "R_MIPS_32";
case RelocationType::R_MIPS_26:
return "R_MIPS_26";
case RelocationType::R_MIPS_HI16:
return "R_MIPS_HI16";
case RelocationType::R_MIPS_LO16:
return "R_MIPS_LO16";
}
assert(!"Oh no :c");
}
ZOverlay::ZOverlay()
{
name = "";
@@ -25,15 +64,22 @@ ZOverlay::~ZOverlay()
entries.clear();
}
ZOverlay* ZOverlay::FromBuild(std::string buildPath, std::string cfgFolderPath)
static const std::unordered_set<std::string> sRelSections = {
".rel.text",
".rel.data",
".rel.rodata",
};
static const std::unordered_set<std::string> sSections = {
".text", ".data", ".symtab", ".rodata", ".rodata.str1.4", ".rodata.cst4", ".rodata.cst8",
};
ZOverlay* ZOverlay::FromBuild(fs::path buildPath, fs::path cfgFolderPath)
{
std::string cfgText = File::ReadAllText(cfgFolderPath + "/overlay.cfg");
std::string cfgText = File::ReadAllText(cfgFolderPath / "overlay.cfg");
std::vector<std::string> cfgLines = StringHelper::Split(cfgText, "\n");
ZOverlay* ovl = new ZOverlay(StringHelper::Strip(cfgLines[0], "\r"));
std::vector<std::string> relSections = {".rel.text", ".rel.data", ".rel.rodata"};
std::vector<std::string> sections = {".text", ".data", ".rodata"};
ovl->cfgLines = cfgLines;
int32_t sectionOffs[5] = {0};
std::vector<RelocationEntry*> textRelocs;
@@ -44,8 +90,7 @@ ZOverlay* ZOverlay::FromBuild(std::string buildPath, std::string cfgFolderPath)
std::vector<elfio*> readers;
for (size_t i = 1; i < cfgLines.size(); i++)
{
std::string elfPath =
buildPath + "/" + cfgLines[i].substr(0, cfgLines[i].size() - 2) + ".o";
std::string elfPath = buildPath / (cfgLines[i].substr(0, cfgLines[i].size() - 2) + ".o");
elfio* reader = new elfio();
if (!reader->load(elfPath))
@@ -62,102 +107,119 @@ ZOverlay* ZOverlay::FromBuild(std::string buildPath, std::string cfgFolderPath)
readers.push_back(reader);
}
for (auto curReader : readers)
for (size_t curReaderId = 0; curReaderId < readers.size(); curReaderId++)
{
auto& curReader = readers[curReaderId];
Elf_Half sec_num = curReader->sections.size();
for (int32_t i = 0; i < sec_num; i++)
{
section* pSec = curReader->sections[i];
if (pSec->get_type() == SHT_REL && std::find(relSections.begin(), relSections.end(),
pSec->get_name()) != relSections.end())
if (pSec->get_type() != SHT_REL ||
sRelSections.find(pSec->get_name()) == sRelSections.end())
{
SectionType sectionType = GetSectionTypeFromStr(pSec->get_name());
continue;
}
if (sectionType == SectionType::ERROR)
fprintf(stderr, "WARNING: One of the section types returned ERROR\n");
symbol_section_accessor currentSymbols(*curReader,
curReader->sections[(Elf_Half)pSec->get_link()]);
relocation_section_accessor relocs(*curReader, pSec);
for (Elf_Xword j = 0; j < relocs.get_entries_num(); j++)
SectionType sectionType = GetSectionTypeFromStr(pSec->get_name());
if (sectionType == SectionType::ERROR)
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 = 0;
Elf_Word symbol = 0;
Elf_Word type = 0;
{
Elf64_Addr offset = 0;
Elf_Word symbol = 0;
Elf_Word type = 0;
Elf_Sxword addend = 0;
relocs.get_entry(j, offset, symbol, type, addend);
}
std::string curSymName;
Elf_Half curSymShndx = SHN_UNDEF;
{
Elf64_Addr value;
Elf_Xword size;
unsigned char bind;
unsigned char type;
unsigned char other;
currentSymbols.get_symbol(symbol, curSymName, value, size, bind, type,
curSymShndx, other);
}
// check symbols outside the elf but within the overlay
if (curSymShndx == SHN_UNDEF)
{
if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG)
{
Elf_Sxword addend = 0;
relocs.get_entry(j, offset, symbol, type, addend);
printf("Symbol '%s' doesn't exist in current .o file (%s). Searching...\n",
curSymName.c_str(), cfgLines[curReaderId + 1].c_str());
}
std::string curSymName;
Elf_Half curSymShndx = SHN_UNDEF;
for (size_t readerId = 0; readerId < readers.size(); readerId++)
{
symbol_section_accessor symbols(
*curReader, curReader->sections[(Elf_Half)pSec->get_link()]);
Elf64_Addr value;
Elf_Xword size;
unsigned char bind;
unsigned char type;
unsigned char other;
symbols.get_symbol(symbol, curSymName, value, size, bind, type, curSymShndx,
other);
}
auto& reader = readers[readerId];
// check symbols outside the elf but within the overlay
if (curSymShndx == SHN_UNDEF)
{
for (auto reader : readers)
if (curSymShndx != SHN_UNDEF)
break;
if (reader == curReader)
continue;
auto sectionData = reader->sections[(Elf_Half)pSec->get_link()];
curSymShndx =
ovl->FindSymbolInSection(curSymName, sectionData, *reader, readerId);
if (curSymShndx != SHN_UNDEF)
break;
if (Globals::Instance->gccCompat)
{
if (curSymShndx != SHN_UNDEF)
break;
if (reader == curReader)
continue;
auto sectionData = reader->sections[(Elf_Half)pSec->get_link()];
if (sectionData == nullptr)
continue;
symbol_section_accessor symbols(*reader, sectionData);
for (Elf_Xword symIdx = 0; symIdx < symbols.get_symbols_num(); symIdx++)
// Symbol wasn't found, try checking every section
Elf_Half sec_num = reader->sections.size();
for (int32_t otherSectionIdx = 0; otherSectionIdx < sec_num;
otherSectionIdx++)
{
Elf_Half shndx = SHN_UNDEF;
Elf64_Addr value;
std::string name;
Elf_Xword size;
unsigned char bind;
unsigned char type;
unsigned char other;
symbols.get_symbol(symIdx, name, value, size, bind, type, shndx,
other);
if (name == curSymName)
if (curSymShndx != SHN_UNDEF)
{
curSymShndx = shndx;
break;
}
auto sectionDataIter = reader->sections[otherSectionIdx];
curSymShndx = ovl->FindSymbolInSection(curSymName, sectionDataIter,
*reader, readerId);
}
}
}
}
if (curSymShndx != SHN_UNDEF)
if (curSymShndx != SHN_UNDEF)
{
RelocationType typeConverted = (RelocationType)type;
offset += sectionOffs[static_cast<size_t>(sectionType)];
RelocationEntry* reloc =
new RelocationEntry(sectionType, typeConverted, offset);
if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG)
{
RelocationType typeConverted = (RelocationType)type;
offset += sectionOffs[sectionType];
RelocationEntry* reloc =
new RelocationEntry(sectionType, typeConverted, offset);
// this is to keep the correct reloc entry order
if (sectionType == SectionType::Text)
textRelocs.push_back(reloc);
if (sectionType == SectionType::Data)
dataRelocs.push_back(reloc);
if (sectionType == SectionType::RoData)
rodataRelocs.push_back(reloc);
printf(".word 0x%08X # %s %s 0x%04X\n", reloc->CalcRelocationWord(),
reloc->GetSectionName(), reloc->GetRelocTypeName(), reloc->offset);
}
// this is to keep the correct reloc entry order
if (sectionType == SectionType::Text)
textRelocs.push_back(reloc);
if (sectionType == SectionType::Data)
dataRelocs.push_back(reloc);
if (sectionType == SectionType::RoData)
rodataRelocs.push_back(reloc);
}
}
}
@@ -167,20 +229,18 @@ ZOverlay* ZOverlay::FromBuild(std::string buildPath, std::string cfgFolderPath)
{
section* pSec = curReader->sections[i];
if (pSec->get_type() == SHT_PROGBITS &&
std::find(sections.begin(), sections.end(), pSec->get_name()) != sections.end())
sSections.find(pSec->get_name()) != sSections.end())
{
SectionType sectionType = GetSectionTypeFromStr(pSec->get_name());
sectionOffs[sectionType] += pSec->get_size();
sectionOffs[static_cast<size_t>(sectionType)] += pSec->get_size();
}
}
}
for (auto reloc : textRelocs)
ovl->entries.push_back(reloc);
for (auto reloc : dataRelocs)
ovl->entries.push_back(reloc);
for (auto reloc : rodataRelocs)
ovl->entries.push_back(reloc);
ovl->entries.reserve(textRelocs.size() + dataRelocs.size() + rodataRelocs.size());
ovl->entries.insert(ovl->entries.end(), textRelocs.begin(), textRelocs.end());
ovl->entries.insert(ovl->entries.end(), dataRelocs.begin(), dataRelocs.end());
ovl->entries.insert(ovl->entries.end(), rodataRelocs.begin(), rodataRelocs.end());
for (auto r : readers)
delete r;
@@ -189,23 +249,27 @@ ZOverlay* ZOverlay::FromBuild(std::string buildPath, std::string cfgFolderPath)
return ovl;
}
std::string ZOverlay::GetSourceOutputCode(const std::string& prefix)
std::string ZOverlay::GetSourceOutputCode([[maybe_unused]] const std::string& prefix)
{
std::string output = "";
output += ".section .ovl\n";
output += StringHelper::Sprintf("# %sOverlayInfo\n", name.c_str());
output += StringHelper::Sprintf(".word _%sSegmentTextSize\n", name.c_str());
output += StringHelper::Sprintf(".word _%sSegmentDataSize\n", name.c_str());
output += StringHelper::Sprintf(".word _%sSegmentRoDataSize\n", name.c_str());
output += StringHelper::Sprintf(".word _%sSegmentBssSize\n", name.c_str());
output += "\n";
output += StringHelper::Sprintf(".word %i\n", entries.size());
output += StringHelper::Sprintf(".word %i # reloc_count\n", entries.size());
for (size_t i = 0; i < entries.size(); i++)
{
RelocationEntry* reloc = entries[i];
output += StringHelper::Sprintf(".word 0x%08X\n", reloc->CalcRelocationWord());
output += StringHelper::Sprintf(".word 0x%08X # %s %s 0x%04X\n",
reloc->CalcRelocationWord(), reloc->GetSectionName(),
reloc->GetRelocTypeName(), reloc->offset);
}
size_t offset = (entries.size() * 4) + 20;
@@ -216,7 +280,9 @@ std::string ZOverlay::GetSourceOutputCode(const std::string& prefix)
offset += 4;
}
output += StringHelper::Sprintf(".word 0x%08X\n", offset + 4);
output += "\n";
output +=
StringHelper::Sprintf(".word 0x%08X # %sOverlayInfoOffset\n", offset + 4, name.c_str());
return output;
}
@@ -234,3 +300,50 @@ SectionType ZOverlay::GetSectionTypeFromStr(std::string sectionName)
return SectionType::ERROR;
}
ELFIO::Elf_Half ZOverlay::FindSymbolInSection(const std::string& curSymName,
ELFIO::section* sectionData, ELFIO::elfio& reader,
size_t readerId)
{
if (sectionData == nullptr)
return SHN_UNDEF;
auto sectionDataName = sectionData->get_name();
if (sSections.find(sectionDataName) == sSections.end())
return SHN_UNDEF;
#ifdef DEVELOPMENT
if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG)
{
printf("\t File '%s' section: %s \n", cfgLines[readerId + 1].c_str(),
sectionDataName.c_str());
}
#endif
symbol_section_accessor symbols(reader, sectionData);
Elf_Xword symbolNum = symbols.get_symbols_num();
for (Elf_Xword symIdx = 0; symIdx < symbolNum; symIdx++)
{
Elf_Half shndx = SHN_UNDEF;
Elf64_Addr value;
std::string name;
Elf_Xword size;
unsigned char bind;
unsigned char type;
unsigned char other;
symbols.get_symbol(symIdx, name, value, size, bind, type, shndx, other);
if (name == curSymName)
{
if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG)
{
printf("\t Symbol '%s' found in '%s' '%s' \n", curSymName.c_str(),
cfgLines[readerId + 1].c_str(), sectionDataName.c_str());
}
return shndx;
}
}
return SHN_UNDEF;
}
+15 -7
View File
@@ -1,10 +1,11 @@
#pragma once
#include <elfio/elfio.hpp>
#include "../ZResource.h"
#include "Utils/Directory.h"
#include "ZResource.h"
#include "elfio/elfio.hpp"
#include "tinyxml2.h"
enum SectionType
enum class SectionType
{
Text = 1,
Data = 2,
@@ -13,7 +14,7 @@ enum SectionType
ERROR = 255
};
enum RelocationType
enum class RelocationType
{
R_MIPS_32 = 2,
R_MIPS_26 = 4,
@@ -39,12 +40,15 @@ public:
{
uint32_t relocationWord = 0;
relocationWord |= sectionType << 30;
relocationWord |= relocationType << 24;
relocationWord |= static_cast<uint32_t>(sectionType) << 30;
relocationWord |= static_cast<uint32_t>(relocationType) << 24;
relocationWord |= offset;
return relocationWord;
}
const char* GetSectionName() const;
const char* GetRelocTypeName() const;
};
class ZOverlay
@@ -54,14 +58,18 @@ public:
ZOverlay(std::string nName);
~ZOverlay();
static ZOverlay* FromBuild(std::string buildPath, std::string cfgFolderPath);
static ZOverlay* FromBuild(fs::path buildPath, fs::path cfgFolderPath);
std::string GetSourceOutputCode(const std::string& prefix);
private:
std::vector<RelocationEntry*> entries;
std::vector<std::string> cfgLines;
ZOverlay();
static SectionType GetSectionTypeFromStr(std::string sectionName);
// static std::string GetOverlayNameFromElf(ELFIO::elfio& reader);
ELFIO::Elf_Half FindSymbolInSection(const std::string& curSymName, ELFIO::section* sectionData,
ELFIO::elfio& reader, size_t readerId);
};
+36 -28
View File
@@ -71,12 +71,16 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<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>
<LibraryPath>$(SolutionDir)lib\libgfxd;$(SolutionDir)x64\Debug;$(SolutionDir)packages\libpng.1.6.28.1\build\native\lib\x64\v140\dynamic\Debug;$(LibraryPath)</LibraryPath>
<IncludePath>$(SolutionDir)ZAPDUtils;$(SolutionDir)lib\tinyxml2;$(SolutionDir)lib\libgfxd;$(SolutionDir)lib\elfio;$(SolutionDir)lib\stb;$(ProjectDir);$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<IncludePath>$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IncludePath>$(SolutionDir)ZAPD\lib\tinyxml2;$(SolutionDir)ZAPD\lib\libgfxd;$(SolutionDir)ZAPD\lib\elfio;$(SolutionDir)ZAPD\lib\stb;$(ProjectDir);$(IncludePath)</IncludePath>
<LibraryPath>$(SolutionDir)ZAPD\lib\libgfxd;$(SolutionDir)x64\Debug;$(SolutionDir)packages\libpng.1.6.28.1\build\native\lib\x64\v140\dynamic\Debug;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
@@ -84,6 +88,8 @@
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc11</LanguageStandard_C>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<Profile>true</Profile>
@@ -96,13 +102,13 @@
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;USE_ASSIMP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<LanguageStandard_C>stdc11</LanguageStandard_C>
</ClCompile>
<Link>
<Profile>true</Profile>
<AdditionalDependencies>assimp-vc142-mt.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>libpng16.lib;ZAPDUtils.lib;/WHOLEARCHIVE:ExporterExample.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PreBuildEvent>
<Command>cd ..
@@ -148,10 +154,9 @@ python3 ZAPD/genbuildinfo.py</Command>
<ClCompile Include="..\lib\libgfxd\uc_f3dex2.c" />
<ClCompile Include="..\lib\libgfxd\uc_f3dexb.c" />
<ClCompile Include="..\lib\tinyxml2\tinyxml2.cpp" />
<ClCompile Include="Declaration.cpp" />
<ClCompile Include="Globals.cpp" />
<ClCompile Include="HighLevel\HLAnimationIntermediette.cpp" />
<ClCompile Include="HighLevel\HLModelIntermediette.cpp" />
<ClCompile Include="HighLevel\HLTexture.cpp" />
<ClCompile Include="ImageBackend.cpp" />
<ClCompile Include="Main.cpp" />
<ClCompile Include="OutputFormatter.cpp" />
<ClCompile Include="Overlays\ZOverlay.cpp" />
@@ -160,8 +165,9 @@ python3 ZAPD/genbuildinfo.py</Command>
<ClCompile Include="ZCutsceneMM.cpp" />
<ClCompile Include="ZLimb.cpp" />
<ClCompile Include="ZMtx.cpp" />
<ClCompile Include="ZPath.cpp" />
<ClCompile Include="ZRoom\Commands\SetActorCutsceneList.cpp" />
<ClCompile Include="ZRoom\Commands\SetAnimatedTextureList.cpp" />
<ClCompile Include="ZRoom\Commands\SetAnimatedMaterialList.cpp" />
<ClCompile Include="ZRoom\Commands\SetCsCamera.cpp" />
<ClCompile Include="ZRoom\Commands\SetMinimapChests.cpp" />
<ClCompile Include="ZRoom\Commands\SetMinimapList.cpp" />
@@ -204,6 +210,7 @@ python3 ZAPD/genbuildinfo.py</Command>
<ClCompile Include="ZRoom\Commands\ZRoomCommandUnk.cpp" />
<ClCompile Include="ZRoom\ZRoom.cpp" />
<ClCompile Include="ZRoom\ZRoomCommand.cpp" />
<ClCompile Include="ZString.cpp" />
<ClCompile Include="ZSymbol.cpp" />
<ClCompile Include="ZTexture.cpp" />
<ClCompile Include="ZVector.cpp" />
@@ -222,29 +229,18 @@ python3 ZAPD/genbuildinfo.py</Command>
<ClInclude Include="..\lib\elfio\elfio\elfio_symbols.hpp" />
<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="Declaration.h" />
<ClInclude Include="Globals.h" />
<ClInclude Include="HighLevel\HLAnimation.h" />
<ClInclude Include="HighLevel\HLAnimationIntermediette.h" />
<ClInclude Include="HighLevel\HLFileIntermediette.h" />
<ClInclude Include="HighLevel\HLModelIntermediette.h" />
<ClInclude Include="HighLevel\HLTexture.h" />
<ClInclude Include="ImageBackend.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" />
@@ -256,8 +252,9 @@ python3 ZAPD/genbuildinfo.py</Command>
<ClInclude Include="ZFile.h" />
<ClInclude Include="ZLimb.h" />
<ClInclude Include="ZMtx.h" />
<ClInclude Include="ZPath.h" />
<ClInclude Include="ZRoom\Commands\SetActorCutsceneList.h" />
<ClInclude Include="ZRoom\Commands\SetAnimatedTextureList.h" />
<ClInclude Include="ZRoom\Commands\SetAnimatedMaterialList.h" />
<ClInclude Include="ZRoom\Commands\SetCsCamera.h" />
<ClInclude Include="ZRoom\Commands\SetMinimapChests.h" />
<ClInclude Include="ZRoom\Commands\SetMinimapList.h" />
@@ -266,7 +263,6 @@ python3 ZAPD/genbuildinfo.py</Command>
<ClInclude Include="ZScalar.h" />
<ClInclude Include="ZSkeleton.h" />
<ClInclude Include="ZResource.h" />
<ClInclude Include="ZRoom\ActorList.h" />
<ClInclude Include="ZRoom\Commands\EndMarker.h" />
<ClInclude Include="ZRoom\Commands\SetActorList.h" />
<ClInclude Include="ZRoom\Commands\SetAlternateHeaders.h" />
@@ -293,9 +289,9 @@ python3 ZAPD/genbuildinfo.py</Command>
<ClInclude Include="ZRoom\Commands\SetWind.h" />
<ClInclude Include="ZRoom\Commands\Unused09.h" />
<ClInclude Include="ZRoom\Commands\ZRoomCommandUnk.h" />
<ClInclude Include="ZRoom\ObjectList.h" />
<ClInclude Include="ZRoom\ZRoom.h" />
<ClInclude Include="ZRoom\ZRoomCommand.h" />
<ClInclude Include="ZString.h" />
<ClInclude Include="ZSymbol.h" />
<ClInclude Include="ZTexture.h" />
<ClInclude Include="ZVector.h" />
@@ -307,10 +303,22 @@ python3 ZAPD/genbuildinfo.py</Command>
</Text>
</ItemGroup>
<ItemGroup>
<CopyFileToFolders Include="..\lib\assimp-built\assimp-vc142-mt.dll">
<FileType>Document</FileType>
</CopyFileToFolders>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\packages\libpng.redist.1.6.28.1\build\native\libpng.redist.targets" Condition="Exists('..\packages\libpng.redist.1.6.28.1\build\native\libpng.redist.targets')" />
<Import Project="..\packages\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.targets" Condition="Exists('..\packages\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.targets')" />
<Import Project="..\packages\zlib.v140.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v140.windesktop.msvcstl.dyn.rt-dyn.targets" Condition="Exists('..\packages\zlib.v140.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v140.windesktop.msvcstl.dyn.rt-dyn.targets')" />
<Import Project="..\packages\libpng.1.6.28.1\build\native\libpng.targets" Condition="Exists('..\packages\libpng.1.6.28.1\build\native\libpng.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\libpng.redist.1.6.28.1\build\native\libpng.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\libpng.redist.1.6.28.1\build\native\libpng.redist.targets'))" />
<Error Condition="!Exists('..\packages\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.targets'))" />
<Error Condition="!Exists('..\packages\zlib.v140.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v140.windesktop.msvcstl.dyn.rt-dyn.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\zlib.v140.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v140.windesktop.msvcstl.dyn.rt-dyn.targets'))" />
<Error Condition="!Exists('..\packages\libpng.1.6.28.1\build\native\libpng.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\libpng.1.6.28.1\build\native\libpng.targets'))" />
</Target>
</Project>
+31 -75
View File
@@ -40,18 +40,6 @@
<Filter Include="Header Files\Z64\ZRoom\Commands">
<UniqueIdentifier>{73db0879-6df8-4f6a-8cc2-a1f836e9e796}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\HighLevel">
<UniqueIdentifier>{9464ff21-96af-4b7d-a57b-f62bd9b7389a}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\HighLevel\Model">
<UniqueIdentifier>{e9865c34-fd69-413c-8cce-3f51331c3503}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\HighLevel">
<UniqueIdentifier>{0f9980bb-ae46-4891-a39e-275bf255f010}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\HighLevel\Room">
<UniqueIdentifier>{11dbd8e6-d97a-42a5-b40c-e1350389544d}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Libraries\fbx">
<UniqueIdentifier>{be9a5be0-ec6a-4200-8e39-bb58c7da7aa8}</UniqueIdentifier>
</Filter>
@@ -174,15 +162,6 @@
<ClCompile Include="Overlays\ZOverlay.cpp">
<Filter>Source Files\Z64</Filter>
</ClCompile>
<ClCompile Include="HighLevel\HLAnimationIntermediette.cpp">
<Filter>Source Files\HighLevel</Filter>
</ClCompile>
<ClCompile Include="HighLevel\HLModelIntermediette.cpp">
<Filter>Source Files\HighLevel</Filter>
</ClCompile>
<ClCompile Include="HighLevel\HLTexture.cpp">
<Filter>Source Files\HighLevel</Filter>
</ClCompile>
<ClCompile Include="ZSkeleton.cpp">
<Filter>Source Files\Z64</Filter>
</ClCompile>
@@ -249,9 +228,6 @@
<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>
@@ -267,17 +243,23 @@
<ClCompile Include="ZBackground.cpp">
<Filter>Source Files\Z64</Filter>
</ClCompile>
<ClCompile Include="ZRoom\Commands\SetAnimatedMaterialList.cpp">
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
</ClCompile>
<ClCompile Include="ZPath.cpp">
<Filter>Source Files\Z64</Filter>
</ClCompile>
<ClCompile Include="Declaration.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ImageBackend.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ZString.cpp">
<Filter>Source Files\Z64</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Path.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="File.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Directory.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ZRoom\ZRoom.h">
<Filter>Header Files\Z64\ZRoom</Filter>
</ClInclude>
@@ -296,9 +278,6 @@
<ClInclude Include="ZRoom\Commands\SetTimeSettings.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="BitConverter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\SetSpecialObjects.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
@@ -359,9 +338,6 @@
<ClInclude Include="..\lib\elfio\elfio\elfio_utils.hpp">
<Filter>Header Files\Libraries\elfio</Filter>
</ClInclude>
<ClInclude Include="StringHelper.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Globals.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -389,12 +365,6 @@
<ClInclude Include="ZRoom\Commands\Unused09.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="ZRoom\ObjectList.h">
<Filter>Header Files\Z64\ZRoom</Filter>
</ClInclude>
<ClInclude Include="ZRoom\ActorList.h">
<Filter>Header Files\Z64\ZRoom</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\SetLightingSettings.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
@@ -407,21 +377,12 @@
<ClInclude Include="ZRoom\Commands\SetCutscenes.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="Vec3s.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\lib\json\include\nlohmann\json.hpp">
<Filter>Header Files\Libraries</Filter>
</ClInclude>
<ClInclude Include="..\lib\stb\stb_image.h">
<Filter>Header Files\Libraries</Filter>
</ClInclude>
<ClInclude Include="..\lib\stb\stb_image_write.h">
<Filter>Header Files\Libraries</Filter>
</ClInclude>
<ClInclude Include="..\lib\tinygtlf\tiny_gltf.h">
<Filter>Header Files\Libraries</Filter>
</ClInclude>
<ClInclude Include="Overlays\ZOverlay.h">
<Filter>Header Files\Z64</Filter>
</ClInclude>
@@ -446,24 +407,9 @@
<ClInclude Include="ZResource.h">
<Filter>Header Files\Z64</Filter>
</ClInclude>
<ClInclude Include="HighLevel\HLTexture.h">
<Filter>Header Files\HighLevel</Filter>
</ClInclude>
<ClInclude Include="HighLevel\HLAnimation.h">
<Filter>Header Files\HighLevel</Filter>
</ClInclude>
<ClInclude Include="HighLevel\HLAnimationIntermediette.h">
<Filter>Header Files\HighLevel</Filter>
</ClInclude>
<ClInclude Include="HighLevel\HLModelIntermediette.h">
<Filter>Header Files\HighLevel</Filter>
</ClInclude>
<ClInclude Include="ZSkeleton.h">
<Filter>Header Files\Z64</Filter>
</ClInclude>
<ClInclude Include="HighLevel\HLFileIntermediette.h">
<Filter>Header Files\HighLevel</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\SetLightList.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
@@ -521,9 +467,6 @@
<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>
@@ -539,6 +482,21 @@
<ClInclude Include="ZBackground.h">
<Filter>Header Files\Z64</Filter>
</ClInclude>
<ClInclude Include="ZRoom\Commands\SetAnimatedMaterialList.h">
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
</ClInclude>
<ClInclude Include="ImageBackend.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ZPath.h">
<Filter>Header Files\Z64</Filter>
</ClInclude>
<ClInclude Include="Declaration.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ZString.h">
<Filter>Header Files\Z64</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Text Include="..\SymbolMap_OoTMqDbg.txt">
@@ -546,8 +504,6 @@
</Text>
</ItemGroup>
<ItemGroup>
<CopyFileToFolders Include="..\lib\assimp-built\assimp-vc142-mt.dll">
<Filter>Resource Files</Filter>
</CopyFileToFolders>
<None Include="packages.config" />
</ItemGroup>
</Project>
+10 -23
View File
@@ -1,10 +1,9 @@
#include "ZAnimation.h"
#include <utility>
#include "BitConverter.h"
#include "File.h"
#include "Globals.h"
#include "HighLevel/HLAnimationIntermediette.h"
#include "StringHelper.h"
#include "Utils/BitConverter.h"
#include "Utils/File.h"
#include "Utils/StringHelper.h"
#include "ZFile.h"
REGISTER_ZFILENODE(Animation, ZNormalAnimation);
@@ -24,19 +23,7 @@ void ZAnimation::ParseRawData()
frameCount = BitConverter::ToInt16BE(parent->GetRawData(), rawDataIndex + 0);
}
void ZAnimation::Save(const fs::path& outFolder)
{
if (Globals::Instance->testMode)
{
HLAnimationIntermediette* anim = HLAnimationIntermediette::FromZAnimation(this);
std::string xml = anim->OutputXML();
File::WriteAllText(outFolder / (name + ".anmi"), xml);
delete anim;
}
}
std::string ZAnimation::GetSourceOutputCode(const std::string& prefix)
std::string ZAnimation::GetSourceOutputCode([[maybe_unused]] const std::string& prefix)
{
return "";
}
@@ -53,7 +40,7 @@ ZNormalAnimation::ZNormalAnimation(ZFile* nParent) : ZAnimation(nParent)
limit = 0;
}
std::string ZNormalAnimation::GetSourceOutputCode(const std::string& prefix)
std::string ZNormalAnimation::GetSourceOutputCode([[maybe_unused]] const std::string& prefix)
{
if (parent != nullptr)
{
@@ -151,7 +138,7 @@ ZLinkAnimation::ZLinkAnimation(ZFile* nParent) : ZAnimation(nParent)
segmentAddress = 0;
}
std::string ZLinkAnimation::GetSourceOutputCode(const std::string& prefix)
std::string ZLinkAnimation::GetSourceOutputCode([[maybe_unused]] const std::string& prefix)
{
if (parent != nullptr)
{
@@ -208,7 +195,7 @@ TransformData::TransformData(ZFile* parent, const std::vector<uint8_t>& rawData,
{
}
std::string TransformData::GetBody(const std::string& prefix) const
std::string TransformData::GetBody([[maybe_unused]] const std::string& prefix) const
{
return StringHelper::Sprintf("0x%04X, 0x%04X, %i, %i, %ff", unk_00, unk_02, unk_04, unk_06,
unk_08);
@@ -256,8 +243,8 @@ void ZCurveAnimation::ParseRawData()
unk_0C = BitConverter::ToInt16BE(rawData, rawDataIndex + 12);
unk_10 = BitConverter::ToInt16BE(rawData, rawDataIndex + 14);
limbCount =
BitConverter::ToUInt8BE(rawData, Seg2Filespace(skelOffset, parent->baseAddress) + 4);
uint32_t limbCountAddress = Seg2Filespace(skelOffset, parent->baseAddress) + 4;
limbCount = BitConverter::ToUInt8BE(rawData, limbCountAddress);
size_t transformDataSize = 0;
size_t copyValuesSize = 0;
@@ -590,7 +577,7 @@ std::string ZLegacyAnimation::GetBodySourceCode() const
return body;
}
std::string ZLegacyAnimation::GetSourceOutputCode(const std::string& prefix)
std::string ZLegacyAnimation::GetSourceOutputCode([[maybe_unused]] const std::string& prefix)
{
std::string body = GetBodySourceCode();
+3 -9
View File
@@ -13,12 +13,7 @@ struct RotationIndex
// uint16_t transX, transY, transZ;
uint16_t x, y, z;
RotationIndex(uint16_t nX, uint16_t nY, uint16_t nZ)
{
x = nX;
y = nY;
z = nZ;
};
RotationIndex(uint16_t nX, uint16_t nY, uint16_t nZ) : x(nX), y(nY), z(nZ) {}
};
class ZAnimation : public ZResource
@@ -33,7 +28,6 @@ public:
protected:
void ParseRawData() override;
void Save(const fs::path& outFolder) override;
};
class ZNormalAnimation : public ZAnimation
@@ -52,7 +46,7 @@ public:
std::string GetSourceTypeName() const override;
protected:
virtual void ParseRawData() override;
void ParseRawData() override;
};
class ZLinkAnimation : public ZAnimation
@@ -67,7 +61,7 @@ public:
std::string GetSourceTypeName() const override;
protected:
virtual void ParseRawData() override;
void ParseRawData() override;
};
class TransformData
+7 -2
View File
@@ -1,7 +1,7 @@
#include "ZArray.h"
#include <cassert>
#include "Globals.h"
#include "StringHelper.h"
#include "Utils/StringHelper.h"
#include "ZFile.h"
REGISTER_ZFILENODE(Array, ZArray);
@@ -53,7 +53,7 @@ void ZArray::ParseXML(tinyxml2::XMLElement* reader)
}
}
std::string ZArray::GetSourceOutputCode(const std::string& prefix)
std::string ZArray::GetSourceOutputCode([[maybe_unused]] const std::string& prefix)
{
std::string output = "";
@@ -72,6 +72,11 @@ std::string ZArray::GetSourceOutputCode(const std::string& prefix)
return "";
}
std::string ZArray::GetSourceTypeName() const
{
return resList.at(0)->GetSourceTypeName();
}
size_t ZArray::GetRawDataSize() const
{
size_t size = 0;
+3
View File
@@ -15,6 +15,9 @@ public:
void ParseXML(tinyxml2::XMLElement* reader) override;
std::string GetSourceOutputCode(const std::string& prefix) override;
std::string GetSourceTypeName() const override;
size_t GetRawDataSize() const override;
ZResourceType GetResourceType() const override;
+5 -5
View File
@@ -1,9 +1,9 @@
#include "ZBackground.h"
#include "BitConverter.h"
#include "File.h"
#include "Globals.h"
#include "Path.h"
#include "StringHelper.h"
#include "Utils/BitConverter.h"
#include "Utils/File.h"
#include "Utils/Path.h"
#include "Utils/StringHelper.h"
#include "ZFile.h"
REGISTER_ZFILENODE(Background, ZBackground);
@@ -160,7 +160,7 @@ void ZBackground::Save(const fs::path& outFolder)
File::WriteAllBytes(filepath.string(), data);
}
std::string ZBackground::GetBodySourceCode()
std::string ZBackground::GetBodySourceCode() const
{
std::string bodyStr = " ";
+1 -1
View File
@@ -26,7 +26,7 @@ public:
bool IsExternalResource() const override;
std::string GetExternalExtension() const override;
void Save(const fs::path& outFolder) override;
std::string GetBodySourceCode();
std::string GetBodySourceCode() const override;
std::string GetSourceOutputCode(const std::string& prefix) override;
static std::string GetDefaultName(const std::string& prefix, uint32_t address);
+8 -8
View File
@@ -1,8 +1,8 @@
#include "ZBlob.h"
#include "BitConverter.h"
#include "File.h"
#include "Path.h"
#include "StringHelper.h"
#include "Utils/BitConverter.h"
#include "Utils/File.h"
#include "Utils/Path.h"
#include "Utils/StringHelper.h"
#include "ZFile.h"
using namespace tinyxml2;
@@ -49,9 +49,9 @@ void ZBlob::ParseRawData()
parent->GetRawData().begin() + rawDataIndex + blobSize);
}
std::string ZBlob::GetSourceOutputCode(const std::string& prefix)
std::string ZBlob::GetSourceOutputCode([[maybe_unused]] const std::string& prefix)
{
sourceOutput = "";
std::string sourceOutput = "";
for (size_t i = 0; i < blobData.size(); i += 1)
{
@@ -72,14 +72,14 @@ std::string ZBlob::GetSourceOutputCode(const std::string& prefix)
return sourceOutput;
}
std::string ZBlob::GetSourceOutputHeader(const std::string& prefix)
std::string ZBlob::GetSourceOutputHeader([[maybe_unused]] const std::string& prefix)
{
return StringHelper::Sprintf("extern u8 %s[];\n", name.c_str());
}
void ZBlob::Save(const fs::path& outFolder)
{
File::WriteAllBytes(outFolder / (name + ".bin"), blobData);
File::WriteAllBytes((outFolder / (name + ".bin")).string(), blobData);
}
bool ZBlob::IsExternalResource() const
+12 -7
View File
@@ -1,9 +1,9 @@
#include "ZCollision.h"
#include <stdint.h>
#include <string>
#include "BitConverter.h"
#include "Globals.h"
#include "StringHelper.h"
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
REGISTER_ZFILENODE(Collision, ZCollisionHeader);
@@ -184,9 +184,13 @@ void ZCollisionHeader::ParseRawData()
name.c_str(), polyTypeDefSegmentOffset, name.c_str(), camDataSegmentOffset, numWaterBoxes,
waterBoxStr);
parent->AddDeclaration(rawDataIndex, DeclarationAlignment::None, DeclarationPadding::Pad16,
GetRawDataSize(), "CollisionHeader",
StringHelper::Sprintf("%s", name.c_str(), rawDataIndex), declaration);
parent->AddDeclaration(rawDataIndex, DeclarationAlignment::None, DeclarationPadding::Pad16, 44,
GetSourceTypeName(), name, declaration);
}
std::string ZCollisionHeader::GetSourceTypeName() const
{
return "CollisionHeader";
}
ZResourceType ZCollisionHeader::GetResourceType() const
@@ -240,7 +244,8 @@ WaterBoxHeader::WaterBoxHeader(const std::vector<uint8_t>& rawData, uint32_t raw
CameraDataList::CameraDataList(ZFile* parent, const std::string& prefix,
const std::vector<uint8_t>& rawData, uint32_t rawDataIndex,
uint32_t polyTypeDefSegmentOffset, uint32_t polygonTypesCnt)
uint32_t polyTypeDefSegmentOffset,
[[maybe_unused]] uint32_t polygonTypesCnt)
{
std::string declaration = "";
@@ -257,7 +262,7 @@ CameraDataList::CameraDataList(ZFile* parent, const std::string& prefix,
entry->cameraPosDataSeg =
BitConverter::ToInt32BE(rawData, rawDataIndex + (entries.size() * 8) + 4);
if (entry->cameraPosDataSeg != 0 && GETSEGNUM(entry->cameraPosDataSeg) != 2)
if (entry->cameraPosDataSeg != 0 && GETSEGNUM(entry->cameraPosDataSeg) != SEGMENT_SCENE)
{
cameraPosDataSeg = rawDataIndex + (entries.size() * 8);
break;
+1
View File
@@ -92,6 +92,7 @@ public:
void ParseRawData() override;
std::string GetSourceTypeName() const override;
ZResourceType GetResourceType() const override;
size_t GetRawDataSize() const override;
+44 -35
View File
@@ -1,6 +1,7 @@
#include "ZCutscene.h"
#include "BitConverter.h"
#include "StringHelper.h"
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
#include "ZResource.h"
REGISTER_ZFILENODE(Cutscene, ZCutscene);
@@ -84,7 +85,7 @@ CutsceneCommandSceneTransFX::~CutsceneCommandSceneTransFX()
{
}
std::string ZCutscene::GetBodySourceCode()
std::string ZCutscene::GetBodySourceCode() const
{
std::string output = "";
size_t size = 0;
@@ -127,8 +128,8 @@ void ZCutscene::DeclareVar(const std::string& prefix, const std::string& bodyStr
auxName = StringHelper::Sprintf("%sCutsceneData0x%06X", prefix.c_str(), rawDataIndex);
parent->AddDeclarationArray(getSegmentOffset(), DeclarationAlignment::Align4,
DeclarationPadding::Pad16, GetRawDataSize(), "s32", auxName, 0,
bodyStr);
DeclarationPadding::Pad16, GetRawDataSize(), GetSourceTypeName(),
auxName, 0, bodyStr);
}
size_t ZCutscene::GetRawDataSize() const
@@ -447,7 +448,8 @@ ZResourceType ZCutscene::GetResourceType() const
return ZResourceType::Cutscene;
}
CutsceneCommand::CutsceneCommand(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex)
CutsceneCommand::CutsceneCommand([[maybe_unused]] const std::vector<uint8_t>& rawData,
[[maybe_unused]] uint32_t rawDataIndex)
{
}
@@ -478,7 +480,7 @@ CutsceneCameraPoint::CutsceneCameraPoint(const std::vector<uint8_t>& rawData, ui
continueFlag = data[rawDataIndex + 0];
cameraRoll = data[rawDataIndex + 1];
nextPointFrame = BitConverter::ToInt16BE(data, rawDataIndex + 2);
viewAngle = BitConverter::ToInt32BE(data, rawDataIndex + 4);
viewAngle = BitConverter::ToFloatBE(data, rawDataIndex + 4);
posX = BitConverter::ToInt16BE(data, rawDataIndex + 8);
posY = BitConverter::ToInt16BE(data, rawDataIndex + 10);
@@ -522,7 +524,7 @@ std::string CutsceneCommandSetCameraPos::GetCName()
return "";
}
std::string CutsceneCommandSetCameraPos::GenerateSourceCode(uint32_t baseAddress)
std::string CutsceneCommandSetCameraPos::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress)
{
std::string result = "";
@@ -554,11 +556,14 @@ std::string CutsceneCommandSetCameraPos::GenerateSourceCode(uint32_t baseAddress
for (size_t i = 0; i < entries.size(); i++)
{
result += StringHelper::Sprintf(" %s(%i, %i, %i, 0x%06X, %i, %i, %i, %i),\n",
posStr.c_str(), entries[i]->continueFlag,
std::string continueMacro = "CS_CMD_CONTINUE";
if (entries[i]->continueFlag != 0)
continueMacro = "CS_CMD_STOP";
result += StringHelper::Sprintf(" %s(%s, 0x%02X, %i, %ff, %i, %i, %i, 0x%04X),\n",
posStr.c_str(), continueMacro.c_str(),
entries[i]->cameraRoll, entries[i]->nextPointFrame,
*(uint32_t*)&entries[i]->viewAngle, entries[i]->posX,
entries[i]->posY, entries[i]->posZ, entries[i]->unused);
entries[i]->viewAngle, entries[i]->posX, entries[i]->posY,
entries[i]->posZ, entries[i]->unused);
}
return result;
@@ -610,7 +615,7 @@ std::string CutsceneCommandFadeBGM::GetCName()
return "CsCmdMusicFade";
}
std::string CutsceneCommandFadeBGM::GenerateSourceCode(uint32_t baseAddress)
std::string CutsceneCommandFadeBGM::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress)
{
std::string result = "";
@@ -663,7 +668,7 @@ CutsceneCommandPlayBGM::CutsceneCommandPlayBGM(const std::vector<uint8_t>& rawDa
}
}
std::string CutsceneCommandPlayBGM::GenerateSourceCode(uint32_t baseAddress)
std::string CutsceneCommandPlayBGM::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress)
{
std::string result = "";
@@ -706,7 +711,7 @@ CutsceneCommandStopBGM::CutsceneCommandStopBGM(const std::vector<uint8_t>& rawDa
}
}
std::string CutsceneCommandStopBGM::GenerateSourceCode(uint32_t baseAddress)
std::string CutsceneCommandStopBGM::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress)
{
std::string result = "";
@@ -764,7 +769,7 @@ CutsceneCommandEnvLighting::CutsceneCommandEnvLighting(const std::vector<uint8_t
}
}
std::string CutsceneCommandEnvLighting::GenerateSourceCode(uint32_t baseAddress)
std::string CutsceneCommandEnvLighting::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress)
{
std::string result = "";
@@ -820,7 +825,7 @@ CutsceneCommandUnknown9::CutsceneCommandUnknown9(const std::vector<uint8_t>& raw
}
}
std::string CutsceneCommandUnknown9::GenerateSourceCode(uint32_t baseAddress)
std::string CutsceneCommandUnknown9::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress)
{
std::string result = "";
@@ -878,7 +883,7 @@ CutsceneCommandUnknown::CutsceneCommandUnknown(const std::vector<uint8_t>& rawDa
}
}
std::string CutsceneCommandUnknown::GenerateSourceCode(uint32_t baseAddress)
std::string CutsceneCommandUnknown::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress)
{
std::string result = "";
@@ -936,7 +941,7 @@ std::string CutsceneCommandDayTime::GetCName()
return "CsCmdDayTime";
}
std::string CutsceneCommandDayTime::GenerateSourceCode(uint32_t baseAddress)
std::string CutsceneCommandDayTime::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress)
{
std::string result = "";
@@ -987,7 +992,7 @@ std::string CutsceneCommandTextbox::GetCName()
return "CsCmdTextbox";
}
std::string CutsceneCommandTextbox::GenerateSourceCode(uint32_t baseAddress)
std::string CutsceneCommandTextbox::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress)
{
std::string result = "";
@@ -1033,9 +1038,9 @@ ActorAction::ActorAction(const std::vector<uint8_t>& rawData, uint32_t rawDataIn
endPosX = BitConverter::ToInt32BE(data, rawDataIndex + 24);
endPosY = BitConverter::ToInt32BE(data, rawDataIndex + 28);
endPosZ = BitConverter::ToInt32BE(data, rawDataIndex + 32);
normalX = BitConverter::ToInt32BE(data, rawDataIndex + 36);
normalY = BitConverter::ToInt32BE(data, rawDataIndex + 40);
normalZ = BitConverter::ToInt32BE(data, rawDataIndex + 44);
normalX = BitConverter::ToFloatBE(data, rawDataIndex + 36);
normalY = BitConverter::ToFloatBE(data, rawDataIndex + 40);
normalZ = BitConverter::ToFloatBE(data, rawDataIndex + 44);
}
CutsceneCommandActorAction::CutsceneCommandActorAction(const std::vector<uint8_t>& rawData,
@@ -1053,7 +1058,7 @@ CutsceneCommandActorAction::CutsceneCommandActorAction(const std::vector<uint8_t
}
}
std::string CutsceneCommandActorAction::GenerateSourceCode(uint32_t baseAddress)
std::string CutsceneCommandActorAction::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress)
{
std::string result = "";
std::string subCommand = "";
@@ -1072,13 +1077,12 @@ std::string CutsceneCommandActorAction::GenerateSourceCode(uint32_t baseAddress)
for (size_t i = 0; i < entries.size(); i++)
{
result += StringHelper::Sprintf(
" CS_NPC_ACTION(0x%04X, %i, %i, 0x%04X, 0x%04X, 0x%04X, %i, %i, %i, %i, %i, %i, %i, "
"%i, %i),\n",
entries[i]->action, entries[i]->startFrame, entries[i]->endFrame, entries[i]->rotX,
entries[i]->rotY, entries[i]->rotZ, entries[i]->startPosX, entries[i]->startPosY,
entries[i]->startPosZ, entries[i]->endPosX, entries[i]->endPosY, entries[i]->endPosZ,
*(int32_t*)&entries[i]->normalX, *(int32_t*)&entries[i]->normalY,
*(int32_t*)&entries[i]->normalZ);
"\t\t%s(0x%04X, %i, %i, 0x%04X, 0x%04X, 0x%04X, %i, %i, %i, %i, %i, %i, %.11ef, "
"%.11ef, %.11ef),\n",
subCommand.c_str(), entries[i]->action, entries[i]->startFrame, entries[i]->endFrame,
entries[i]->rotX, entries[i]->rotY, entries[i]->rotZ, entries[i]->startPosX,
entries[i]->startPosY, entries[i]->startPosZ, entries[i]->endPosX, entries[i]->endPosY,
entries[i]->endPosZ, entries[i]->normalX, entries[i]->normalY, entries[i]->normalZ);
}
return result;
@@ -1111,7 +1115,7 @@ std::string CutsceneCommandTerminator::GetCName()
return "CsCmdBase";
}
std::string CutsceneCommandTerminator::GenerateSourceCode(uint32_t baseAddress)
std::string CutsceneCommandTerminator::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress)
{
std::string result = "";
@@ -1133,7 +1137,7 @@ CutsceneCommandEnd::CutsceneCommandEnd(const std::vector<uint8_t>& rawData, uint
endFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 4);
}
std::string CutsceneCommandEnd::GenerateSourceCode(uint32_t baseAddress)
std::string CutsceneCommandEnd::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress)
{
std::string result = "";
@@ -1187,7 +1191,7 @@ CutsceneCommandSpecialAction::CutsceneCommandSpecialAction(const std::vector<uin
}
}
std::string CutsceneCommandSpecialAction::GenerateSourceCode(uint32_t baseAddress)
std::string CutsceneCommandSpecialAction::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress)
{
std::string result = "";
@@ -1246,7 +1250,7 @@ CutsceneCommandSceneTransFX::CutsceneCommandSceneTransFX(const std::vector<uint8
endFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 4);
}
std::string CutsceneCommandSceneTransFX::GenerateSourceCode(uint32_t baseAddress)
std::string CutsceneCommandSceneTransFX::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress)
{
return StringHelper::Sprintf("CS_SCENE_TRANS_FX(%i, %i, %i),\n", base, startFrame, endFrame);
}
@@ -1264,3 +1268,8 @@ size_t CutsceneCommandSceneTransFX::GetCommandSize()
ZCutsceneBase::ZCutsceneBase(ZFile* nParent) : ZResource(nParent)
{
}
std::string ZCutsceneBase::GetSourceTypeName() const
{
return "CutsceneData";
}
+9 -4
View File
@@ -49,7 +49,7 @@ public:
int8_t continueFlag;
int8_t cameraRoll;
int16_t nextPointFrame;
uint32_t viewAngle;
float viewAngle;
int16_t posX, posY, posZ;
int16_t unused;
@@ -352,7 +352,7 @@ public:
int16_t rotX, rotY, rotZ;
int32_t startPosX, startPosY, startPosZ;
int32_t endPosX, endPosY, endPosZ;
int32_t normalX, normalY, normalZ;
float normalX, normalY, normalZ;
ActorAction(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
};
@@ -412,8 +412,13 @@ class ZCutsceneBase : public ZResource
{
public:
ZCutsceneBase(ZFile* nParent);
virtual std::string GetBodySourceCode() = 0;
std::string GetBodySourceCode() const override = 0;
virtual void DeclareVar(const std::string& prefix, const std::string& bodyStr) const = 0;
std::string GetSourceTypeName() const override;
virtual uint32_t getSegmentOffset() const = 0;
};
@@ -425,7 +430,7 @@ public:
void ParseRawData() override;
std::string GetBodySourceCode() override;
std::string GetBodySourceCode() const override;
void DeclareVar(const std::string& prefix, const std::string& bodyStr) const override;
std::string GetSourceOutputCode(const std::string& prefix) override;
size_t GetRawDataSize() const override;
+3 -3
View File
@@ -1,6 +1,6 @@
#include "ZCutsceneMM.h"
#include "BitConverter.h"
#include "StringHelper.h"
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
ZCutsceneMM::ZCutsceneMM(ZFile* nParent) : ZCutsceneBase(nParent)
{
@@ -12,7 +12,7 @@ ZCutsceneMM::~ZCutsceneMM()
delete cmd;
}
std::string ZCutsceneMM::GetBodySourceCode()
std::string ZCutsceneMM::GetBodySourceCode() const
{
std::string output = "";
+1 -1
View File
@@ -15,7 +15,7 @@ public:
ZCutsceneMM(ZFile* nParent);
virtual ~ZCutsceneMM();
std::string GetBodySourceCode() override;
std::string GetBodySourceCode() const override;
void DeclareVar(const std::string& prefix, const std::string& bodyStr) const override;
std::string GetSourceOutputCode(const std::string& prefix) override;
size_t GetRawDataSize() const override;
+71 -72
View File
@@ -1,19 +1,17 @@
#include "ZDisplayList.h"
#include <File.h>
#include <Path.h>
#include <algorithm>
#include <cassert>
#include <chrono>
#include <math.h>
#include "BitConverter.h"
#include "Globals.h"
#include "HighLevel/HLModelIntermediette.h"
#include "OutputFormatter.h"
#include "StringHelper.h"
#include "gfxd.h"
using namespace tinyxml2;
#include "Globals.h"
#include "OutputFormatter.h"
#include "Utils/BitConverter.h"
#include "Utils/File.h"
#include "Utils/Path.h"
#include "Utils/StringHelper.h"
#include "gfxd.h"
REGISTER_ZFILENODE(DList, ZDisplayList);
@@ -30,7 +28,6 @@ ZDisplayList::ZDisplayList(ZFile* nParent) : ZResource(nParent)
lastTexLoaded = false;
lastTexIsPalette = false;
name = "";
scene = nullptr;
dListType = Globals::Instance->game == ZGame::OOT_SW97 ? DListType::F3DEX : DListType::F3DZEX;
}
@@ -79,10 +76,14 @@ void ZDisplayList::ParseRawData()
}
}
Declaration* ZDisplayList::DeclareVar(const std::string& prefix, const std::string& bodyStr)
Declaration* ZDisplayList::DeclareVar([[maybe_unused]] const std::string& prefix,
const std::string& bodyStr)
{
return parent->AddDeclarationArray(rawDataIndex, DeclarationAlignment::Align8, GetRawDataSize(),
GetSourceTypeName(), name, 0, bodyStr, true);
Declaration* decl =
parent->AddDeclarationArray(rawDataIndex, DeclarationAlignment::Align8, GetRawDataSize(),
GetSourceTypeName(), name, 0, bodyStr);
decl->isExternal = true;
return decl;
}
void ZDisplayList::ParseF3DZEX(F3DZEXOpcode opcode, uint64_t data, int32_t i, std::string prefix,
@@ -261,7 +262,6 @@ void ZDisplayList::ParseF3DZEX(F3DZEXOpcode opcode, uint64_t data, int32_t i, st
ZDisplayList* nList = new ZDisplayList(
h & 0x00FFFFFF, GetDListLength(parent->GetRawData(), h & 0x00FFFFFF, dListType),
parent);
nList->scene = scene;
otherDLists.push_back(nList);
i++;
@@ -411,11 +411,18 @@ int32_t ZDisplayList::GetDListLength(const std::vector<uint8_t>& rawData, uint32
DListType dListType)
{
uint8_t endDLOpcode;
uint8_t branchListOpcode;
if (dListType == DListType::F3DZEX)
endDLOpcode = (uint8_t)F3DZEXOpcode::G_ENDDL;
{
endDLOpcode = static_cast<uint8_t>(F3DZEXOpcode::G_ENDDL);
branchListOpcode = static_cast<uint8_t>(F3DZEXOpcode::G_DL);
}
else
endDLOpcode = (uint8_t)F3DEXOpcode::G_ENDDL;
{
endDLOpcode = static_cast<uint8_t>(F3DEXOpcode::G_ENDDL);
branchListOpcode = static_cast<uint8_t>(F3DEXOpcode::G_DL);
}
uint32_t ptr = rawDataIndex;
size_t rawDataSize = rawData.size();
@@ -423,19 +430,21 @@ int32_t ZDisplayList::GetDListLength(const std::vector<uint8_t>& rawData, uint32
{
if (ptr > rawDataSize)
{
throw std::runtime_error(
StringHelper::Sprintf("%s: Fatal error.\n"
"\t End of file found when trying to find the end of the "
"DisplayList at offset: '0x%X'.\n",
__PRETTY_FUNCTION__, rawDataIndex));
throw std::runtime_error("");
throw std::runtime_error(StringHelper::Sprintf(
"%s: Fatal error.\n"
"\t End of file found when trying to find the end of the "
"DisplayList at offset: '0x%X'.\n",
"Raw data size: 0x%zX.\n", __PRETTY_FUNCTION__, rawDataIndex, rawDataSize));
}
uint8_t opcode = rawData.at(ptr);
bool dlNoPush = rawData.at(ptr + 1) == 1;
ptr += 8;
if (opcode == endDLOpcode)
if (opcode == endDLOpcode || (opcode == branchListOpcode && dlNoPush))
{
return ptr - rawDataIndex;
}
}
}
@@ -476,7 +485,7 @@ int32_t ZDisplayList::OptimizationChecks(int32_t startIndex, std::string& output
int32_t ZDisplayList::OptimizationCheck_LoadTextureBlock(int32_t startIndex, std::string& output,
std::string prefix)
{
if (scene == nullptr)
if (Globals::Instance->lastScene == nullptr)
{
return -1;
}
@@ -708,16 +717,7 @@ void ZDisplayList::Opcode_G_DL(uint64_t data, std::string prefix, char* line)
GETSEGOFFSET(data), GetDListLength(parent->GetRawData(), GETSEGOFFSET(data), dListType),
parent);
// if (scene != nullptr)
{
nList->scene = scene;
otherDLists.push_back(nList);
}
// else
//{
// nList->SetName(StringHelper::Sprintf("%sDlist0x%06lX", prefix.c_str(),
// SEG2FILESPACE(data))); nList->GetSourceOutputCode(prefix);
//}
otherDLists.push_back(nList);
}
}
@@ -951,7 +951,8 @@ void ZDisplayList::Opcode_G_SETTIMG(uint64_t data, std::string prefix, char* lin
else
{
sprintf(line, "gsDPSetTextureImage(%s, %s, %i, %sTex_%06lX),", fmtTbl[fmt].c_str(),
sizTbl[siz].c_str(), www + 1, scene->GetName().c_str(), GETSEGOFFSET(data));
sizTbl[siz].c_str(), www + 1, Globals::Instance->lastScene->GetName().c_str(),
GETSEGOFFSET(data));
}
}
@@ -1538,12 +1539,12 @@ void ZDisplayList::Opcode_G_ENDDL(std::string prefix, char* line)
TextureGenCheck(prefix);
}
std::string ZDisplayList::GetSourceOutputHeader(const std::string& prefix)
std::string ZDisplayList::GetSourceOutputHeader([[maybe_unused]] const std::string& prefix)
{
return "";
}
static int32_t GfxdCallback_FormatSingleEntry(void)
static int32_t GfxdCallback_FormatSingleEntry()
{
ZDisplayList* self = static_cast<ZDisplayList*>(gfxd_udata_get());
gfxd_puts("\t");
@@ -1580,9 +1581,15 @@ static int32_t GfxdCallback_FormatSingleEntry(void)
}
// dont print a new line after the last command
if (macroId != gfxd_SPEndDisplayList)
switch (macroId)
{
case gfxd_SPEndDisplayList:
case gfxd_SPBranchList:
break;
default:
gfxd_puts("\n");
break;
}
return 0;
@@ -1656,7 +1663,7 @@ static int32_t GfxdCallback_Vtx(uint32_t seg, int32_t count)
}
static int32_t GfxdCallback_Texture(segptr_t seg, int32_t fmt, int32_t siz, int32_t width,
int32_t height, int32_t pal)
int32_t height, [[maybe_unused]] int32_t pal)
{
ZDisplayList* self = static_cast<ZDisplayList*>(gfxd_udata_get());
uint32_t texOffset = Seg2Filespace(seg, self->parent->baseAddress);
@@ -1692,7 +1699,7 @@ static int32_t GfxdCallback_Texture(segptr_t seg, int32_t fmt, int32_t siz, int3
return 1;
}
static int32_t GfxdCallback_Palette(uint32_t seg, int32_t idx, int32_t count)
static int32_t GfxdCallback_Palette(uint32_t seg, [[maybe_unused]] int32_t idx, int32_t count)
{
ZDisplayList* self = static_cast<ZDisplayList*>(gfxd_udata_get());
uint32_t palOffset = Seg2Filespace(seg, self->parent->baseAddress);
@@ -1740,7 +1747,6 @@ static int32_t GfxdCallback_DisplayList(uint32_t seg)
dListOffset,
self->GetDListLength(self->parent->GetRawData(), dListOffset, self->dListType),
self->parent);
newDList->scene = self->scene;
newDList->parent = self->parent;
self->otherDLists.push_back(newDList);
}
@@ -1823,7 +1829,7 @@ std::string ZDisplayList::GetSourceOutputCode(const std::string& prefix)
}
}
if (scene == nullptr) // TODO: Bit of a hack but it works for now...
if (Globals::Instance->lastScene == nullptr) // TODO: Bit of a hack but it works for now...
parent->defines += defines;
// Generate Vertex Declarations
@@ -1835,12 +1841,9 @@ std::string ZDisplayList::GetSourceOutputCode(const std::string& prefix)
for (auto vtx : item.second)
{
if (curAddr != item.first)
declaration += "\n";
declaration += StringHelper::Sprintf("\t%s,\n", vtx.GetBodySourceCode().c_str());
declaration += vtx.GetBodySourceCode();
curAddr += 16;
curAddr += vtx.GetRawDataSize();
}
vtxDeclarations[item.first] = declaration;
@@ -1856,8 +1859,8 @@ std::string ZDisplayList::GetSourceOutputCode(const std::string& prefix)
}
}
if (scene != nullptr)
defines += scene->extDefines;
if (Globals::Instance->lastScene != nullptr)
defines += Globals::Instance->lastScene->extDefines;
if (parent != nullptr)
{
@@ -1894,7 +1897,7 @@ std::string ZDisplayList::GetSourceOutputCode(const std::string& prefix)
}
}
if (scene == nullptr) // TODO: Bit of a hack but it works for now...
if (Globals::Instance->lastScene == nullptr) // TODO: Bit of a hack but it works for now...
parent->defines += defines;
// Generate Vertex Declarations
@@ -1917,9 +1920,7 @@ std::string ZDisplayList::GetSourceOutputCode(const std::string& prefix)
if (curAddr != vtxKeys[i])
declaration += "\n";
declaration +=
StringHelper::Sprintf(" VTX(%i, %i, %i, %i, %i, %i, %i, %i, %i),", vtx.x,
vtx.y, vtx.z, vtx.s, vtx.t, vtx.r, vtx.g, vtx.b, vtx.a);
declaration += StringHelper::Sprintf("\t%s,", vtx.GetBodySourceCode().c_str());
curAddr += 16;
}
@@ -1933,8 +1934,13 @@ std::string ZDisplayList::GetSourceOutputCode(const std::string& prefix)
if (parent != nullptr)
{
std::string vtxName =
StringHelper::Sprintf("%sVtx_%06X", prefix.c_str(), vtxKeys[i]);
std::string vtxName;
ZResource* vtxRes = parent->FindResource(vtxKeys[i]);
if (vtxRes != nullptr)
vtxName = vtxRes->GetName();
else
vtxName = StringHelper::Sprintf("%sVtx_%06X", prefix.c_str(), vtxKeys[i]);
auto filepath = Globals::Instance->outputPath / vtxName;
std::string incStr = StringHelper::Sprintf("%s.%s.inc", filepath.c_str(), "vtx");
@@ -2036,7 +2042,7 @@ std::string ZDisplayList::ProcessGfxDis(const std::string& prefix)
void ZDisplayList::TextureGenCheck(std::string prefix)
{
if (TextureGenCheck(scene, parent, prefix, lastTexWidth, lastTexHeight, lastTexAddr, lastTexSeg,
if (TextureGenCheck(parent, prefix, lastTexWidth, lastTexHeight, lastTexAddr, lastTexSeg,
lastTexFmt, lastTexSiz, lastTexLoaded, lastTexIsPalette, this))
{
lastTexAddr = 0;
@@ -2045,7 +2051,7 @@ void ZDisplayList::TextureGenCheck(std::string prefix)
}
}
bool ZDisplayList::TextureGenCheck(ZRoom* scene, ZFile* parent, std::string prefix,
bool ZDisplayList::TextureGenCheck(ZFile* parent, [[maybe_unused]] std::string prefix,
int32_t texWidth, int32_t texHeight, uint32_t texAddr,
uint32_t texSeg, F3DZEXTexFormats texFmt, F3DZEXTexSizes texSiz,
bool texLoaded, bool texIsPalette, ZDisplayList* self)
@@ -2087,20 +2093,20 @@ bool ZDisplayList::TextureGenCheck(ZRoom* scene, ZFile* parent, std::string pref
return true;
}
}
else if (scene != nullptr)
else if (Globals::Instance->lastScene != nullptr)
{
if (scene->parent->GetDeclaration(texAddr) == nullptr)
if (Globals::Instance->lastScene->parent->GetDeclaration(texAddr) == nullptr)
{
ZTexture* tex = scene->parent->GetTextureResource(texAddr);
ZTexture* tex = Globals::Instance->lastScene->parent->GetTextureResource(texAddr);
if (tex != nullptr)
tex->isPalette = texIsPalette;
else
{
tex = new ZTexture(scene->parent);
tex = new ZTexture(Globals::Instance->lastScene->parent);
tex->FromBinary(texAddr, texWidth, texHeight,
TexFormatToTexType(texFmt, texSiz), texIsPalette);
scene->parent->AddTextureResource(texAddr, tex);
Globals::Instance->lastScene->parent->AddTextureResource(texAddr, tex);
}
if (!texIsPalette)
@@ -2112,9 +2118,9 @@ bool ZDisplayList::TextureGenCheck(ZRoom* scene, ZFile* parent, std::string pref
Path::GetFileNameWithoutExtension(tex->GetName());
auto filename = StringHelper::Sprintf("%s.%s.inc.c", filepath.c_str(),
tex->GetExternalExtension().c_str());
scene->parent->AddDeclarationIncludeArray(texAddr, filename, tex->GetRawDataSize(),
tex->GetSourceTypeName(), tex->GetName(),
0);
Globals::Instance->lastScene->parent->AddDeclarationIncludeArray(
texAddr, filename, tex->GetRawDataSize(), tex->GetSourceTypeName(),
tex->GetName(), 0);
}
return true;
}
@@ -2166,13 +2172,6 @@ TextureType ZDisplayList::TexFormatToTexType(F3DZEXTexFormats fmt, F3DZEXTexSize
return TextureType::RGBA16bpp;
}
void ZDisplayList::GenerateHLIntermediette(HLFileIntermediette& hlFile)
{
HLModelIntermediette* mdl = (HLModelIntermediette*)&hlFile;
HLModelIntermediette::FromZDisplayList(mdl, this);
mdl->blocks.push_back(new HLTerminator());
}
bool ZDisplayList::IsExternalResource() const
{
return false;
+2 -4
View File
@@ -324,7 +324,6 @@ protected:
public:
std::string sceneSegName;
ZRoom* scene;
std::vector<uint64_t> instructions;
std::string curPrefix;
@@ -359,7 +358,7 @@ public:
Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr);
void TextureGenCheck(std::string prefix);
static bool TextureGenCheck(ZRoom* scene, ZFile* parent, std::string prefix, int32_t texWidth,
static bool TextureGenCheck(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, ZDisplayList* self);
@@ -372,9 +371,8 @@ public:
std::string ProcessLegacy(const std::string& prefix);
std::string ProcessGfxDis(const std::string& prefix);
virtual void GenerateHLIntermediette(HLFileIntermediette& hlFile) override;
bool IsExternalResource() const override;
virtual std::string GetExternalExtension() const override;
std::string GetExternalExtension() const override;
std::string GetSourceTypeName() const override;
ZResourceType GetResourceType() const override;
+67 -53
View File
@@ -1,13 +1,14 @@
#include "ZFile.h"
#include <Utils/BinaryWriter.h>
#include <Utils/MemoryStream.h>
#include <algorithm>
#include <cassert>
#include <unordered_set>
#include "Directory.h"
#include "File.h"
#include "Globals.h"
#include "HighLevel/HLModelIntermediette.h"
#include "OutputFormatter.h"
#include "Path.h"
#include "Utils/Directory.h"
#include "Utils/File.h"
#include "Utils/Path.h"
#include "ZAnimation.h"
#include "ZArray.h"
#include "ZBackground.h"
@@ -70,7 +71,8 @@ ZFile::~ZFile()
}
}
void ZFile::ParseXML(ZFileMode mode, XMLElement* reader, std::string filename, bool placeholderMode)
void ZFile::ParseXML(ZFileMode mode, XMLElement* reader, std::string filename,
[[maybe_unused]] bool placeholderMode)
{
if (filename == "")
name = reader->Attribute("Name");
@@ -235,7 +237,7 @@ void ZFile::DeclareResourceSubReferences()
void ZFile::BuildSourceFile()
{
if (!Directory::Exists(Globals::Instance->outputPath))
Directory::CreateDirectory(Globals::Instance->outputPath);
Directory::CreateDirectory(Globals::Instance->outputPath.string());
GenerateSourceFiles(Globals::Instance->outputPath);
}
@@ -269,27 +271,54 @@ const std::vector<uint8_t>& ZFile::GetRawData() const
void ZFile::ExtractResources()
{
if (!Directory::Exists(Globals::Instance->outputPath))
Directory::CreateDirectory(Globals::Instance->outputPath);
Directory::CreateDirectory(Globals::Instance->outputPath.string());
if (!Directory::Exists(GetSourceOutputFolderPath().string()))
Directory::CreateDirectory(GetSourceOutputFolderPath().string());
for (ZResource* res : resources)
res->PreGenSourceFiles();
for (size_t i = 0; i < resources.size(); i++)
resources[i]->ParseRawDataLate();
for (size_t i = 0; i < resources.size(); i++)
resources[i]->DeclareReferencesLate(name);
if (Globals::Instance->genSourceFile)
GenerateSourceFiles(Globals::Instance->outputPath);
MemoryStream* memStream = new MemoryStream();
BinaryWriter writer = BinaryWriter(memStream);
ExporterSet* exporterSet = Globals::Instance->GetExporterSet();
if (exporterSet != nullptr && exporterSet->beginFileFunc != nullptr)
exporterSet->beginFileFunc(this);
for (ZResource* res : resources)
{
if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_INFO)
printf("Saving resource %s\n", res->GetName().c_str());
res->Save(Globals::Instance->outputPath);
res->CalcHash();
res->Save(Globals::Instance->outputPath.string());
// Check if we have an exporter "registered" for this resource type
ZResourceExporter* exporter = Globals::Instance->GetExporter(res->GetResourceType());
if (exporter != nullptr)
exporter->Save(res, Globals::Instance->outputPath.string(), &writer);
}
if (Globals::Instance->testMode)
GenerateHLIntermediette();
if (memStream->GetLength() > 0)
{
File::WriteAllBytes(StringHelper::Sprintf("%s%s.bin",
Globals::Instance->outputPath.string().c_str(),
GetName().c_str()),
memStream->ToVector());
}
writer.Close();
if (exporterSet != nullptr && exporterSet->endFileFunc != nullptr)
exporterSet->endFileFunc(this);
}
void ZFile::AddResource(ZResource* res)
@@ -348,12 +377,8 @@ Declaration* ZFile::AddDeclarationArray(uint32_t address, DeclarationAlignment a
size_t size, std::string varType, std::string varName,
size_t arrayItemCnt, std::string body)
{
assert(GETSEGNUM(address) == 0);
AddDeclarationDebugChecks(address);
declarations[address] =
new Declaration(alignment, size, varType, varName, true, arrayItemCnt, body);
return declarations[address];
return AddDeclarationArray(address, alignment, DeclarationPadding::None, size, varType, varName,
arrayItemCnt, body);
}
Declaration* ZFile::AddDeclarationArray(uint32_t address, DeclarationAlignment alignment,
@@ -368,18 +393,6 @@ Declaration* ZFile::AddDeclarationArray(uint32_t address, DeclarationAlignment a
return declarations[address];
}
Declaration* ZFile::AddDeclarationArray(uint32_t address, DeclarationAlignment alignment,
size_t size, std::string varType, std::string varName,
size_t arrayItemCnt, std::string body, bool isExternal)
{
assert(GETSEGNUM(address) == 0);
AddDeclarationDebugChecks(address);
declarations[address] =
new Declaration(alignment, size, varType, varName, true, arrayItemCnt, body, isExternal);
return declarations[address];
}
Declaration* ZFile::AddDeclarationArray(uint32_t address, DeclarationAlignment alignment,
DeclarationPadding padding, size_t size,
std::string varType, std::string varName,
@@ -388,9 +401,28 @@ Declaration* ZFile::AddDeclarationArray(uint32_t address, DeclarationAlignment a
assert(GETSEGNUM(address) == 0);
AddDeclarationDebugChecks(address);
declarations[address] =
new Declaration(alignment, padding, size, varType, varName, true, arrayItemCnt, body);
return declarations[address];
Declaration* decl = GetDeclaration(address);
if (decl == nullptr)
{
decl =
new Declaration(alignment, padding, size, varType, varName, true, arrayItemCnt, body);
declarations[address] = decl;
}
else
{
if (decl->isPlaceholder)
decl->varName = varName;
decl->alignment = alignment;
decl->padding = padding;
decl->size = size;
decl->varType = varType;
decl->isArray = true;
decl->arrayItemCnt = arrayItemCnt;
if (body != "" && decl->text == "")
decl->text = body;
}
return decl;
}
Declaration* ZFile::AddDeclarationPlaceholder(uint32_t address)
@@ -598,7 +630,7 @@ void ZFile::GenerateSourceFiles(fs::path outputDir)
Globals::Instance->cfg.texturePool.end())
{
incStr = Globals::Instance->cfg.texturePool[tex->hash].path.string() + "." +
res->GetExternalExtension() + ".inc";
res->GetExternalExtension() + ".inc";
}
}
@@ -660,22 +692,6 @@ void ZFile::GenerateSourceHeaderFiles()
File::WriteAllText(headerFilename, formatter.GetOutput());
}
void ZFile::GenerateHLIntermediette()
{
// This is kinda hacky but it gets the job done for now...
HLModelIntermediette* mdl = new HLModelIntermediette();
for (ZResource* res : resources)
{
if (res->GetResourceType() == ZResourceType::DisplayList ||
res->GetResourceType() == ZResourceType::Skeleton)
res->GenerateHLIntermediette(*mdl);
}
// std::string test = mdl->ToOBJFile();
// std::string test2 = mdl->ToAssimpFile();
}
std::string ZFile::GetHeaderInclude()
{
return StringHelper::Sprintf("#include \"%s\"\n\n",
@@ -1029,9 +1045,7 @@ std::string ZFile::ProcessDeclarations()
for (std::pair<uint32_t, Declaration*> item : declarations)
{
if (item.first < rangeStart || item.first >= rangeEnd)
{
continue;
}
if (item.second->includePath != "")
{
@@ -1219,7 +1233,7 @@ std::string ZFile::ProcessExterns()
return output;
}
std::string ZFile::ProcessTextureIntersections(std::string prefix)
std::string ZFile::ProcessTextureIntersections([[maybe_unused]] std::string prefix)
{
if (texturesResources.empty())
return "";
+4 -9
View File
@@ -1,9 +1,8 @@
#pragma once
#include <Utils/Directory.h>
#include <string>
#include <vector>
#include "Directory.h"
#include "ZResource.h"
#include "ZTexture.h"
#include "tinyxml2.h"
@@ -11,13 +10,12 @@ enum class ZFileMode
{
BuildTexture,
BuildOverlay,
BuildModelIntermediette,
BuildAnimationIntermediette,
BuildBlob,
BuildSourceFile,
BuildBackground,
Extract,
Invalid
Invalid,
Custom = 1000 // Used for exporter file modes
};
enum class ZGame
@@ -59,9 +57,6 @@ public:
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, size_t size,
std::string varType, std::string varName,
std::string arrayItemCntStr, std::string body);
@@ -99,6 +94,7 @@ protected:
fs::path outName = "";
fs::path basePath;
fs::path xmlFilePath;
// Keep track of every texture of this ZFile.
// The pointers declared here are "borrowed" (somebody else is the owner),
// so ZFile shouldn't delete/free those textures.
@@ -110,7 +106,6 @@ protected:
void DeclareResourceSubReferences();
void GenerateSourceFiles(fs::path outputDir);
void GenerateSourceHeaderFiles();
void GenerateHLIntermediette();
void AddDeclarationDebugChecks(uint32_t address);
std::string ProcessDeclarations();
void ProcessDeclarationText(Declaration* decl);
+7 -7
View File
@@ -1,8 +1,8 @@
#include "ZLimb.h"
#include <cassert>
#include "BitConverter.h"
#include "Globals.h"
#include "StringHelper.h"
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
REGISTER_ZFILENODE(Limb, ZLimb);
@@ -101,7 +101,7 @@ Struct_800A598C::Struct_800A598C(ZFile* parent, const std::vector<uint8_t>& rawD
{
}
void Struct_800A598C::PreGenSourceFiles(const std::string& prefix)
void Struct_800A598C::DeclareReferences(const std::string& prefix)
{
std::string entryStr;
@@ -240,7 +240,7 @@ Struct_800A5E28::~Struct_800A5E28()
delete unk_8_dlist;
}
void Struct_800A5E28::PreGenSourceFiles(const std::string& prefix)
void Struct_800A5E28::DeclareReferences(const std::string& prefix)
{
if (unk_4 != 0)
{
@@ -256,7 +256,7 @@ void Struct_800A5E28::PreGenSourceFiles(const std::string& prefix)
for (auto& child : unk_4_arr)
{
child.PreGenSourceFiles(prefix);
child.DeclareReferences(prefix);
entryStr +=
StringHelper::Sprintf(" { %s },%s", child.GetSourceOutputCode(prefix).c_str(),
(++i < arrayItemCnt) ? "\n" : "");
@@ -446,7 +446,7 @@ void ZLimb::ParseRawData()
{
case ZLimbType::LOD:
dList2Ptr = BitConverter::ToUInt32BE(rawData, rawDataIndex + 12);
// Intended fallthrough
[[fallthrough]];
case ZLimbType::Standard:
dListPtr = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8);
break;
@@ -733,7 +733,7 @@ std::string ZLimb::GetSourceOutputCodeSkin_Type_4(const std::string& prefix)
StringHelper::Sprintf("%sSkinLimb_%s_%06X", prefix.c_str(),
Struct_800A5E28::GetSourceTypeName().c_str(), skinSegmentOffset);
segmentStruct.PreGenSourceFiles(prefix);
segmentStruct.DeclareReferences(prefix);
std::string entryStr = segmentStruct.GetSourceOutputCode(prefix);
parent->AddDeclaration(skinSegmentOffset, DeclarationAlignment::None,
+2 -2
View File
@@ -84,7 +84,7 @@ public:
Struct_800A598C(ZFile* parent, const std::vector<uint8_t>& rawData, uint32_t fileOffset,
size_t index);
void PreGenSourceFiles(const std::string& prefix);
void DeclareReferences(const std::string& prefix);
[[nodiscard]] std::string GetSourceOutputCode(const std::string& prefix) const;
static size_t GetRawDataSize();
@@ -111,7 +111,7 @@ public:
size_t index);
~Struct_800A5E28();
void PreGenSourceFiles(const std::string& prefix);
void DeclareReferences(const std::string& prefix);
[[nodiscard]] std::string GetSourceOutputCode(const std::string& prefix) const;
static size_t GetRawDataSize();
+3 -3
View File
@@ -1,6 +1,6 @@
#include "ZMtx.h"
#include "BitConverter.h"
#include "StringHelper.h"
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
#include "ZFile.h"
REGISTER_ZFILENODE(Mtx, ZMtx);
@@ -48,7 +48,7 @@ void ZMtx::DeclareVar(const std::string& prefix, const std::string& bodyStr) con
GetSourceTypeName(), auxName, bodyStr);
}
std::string ZMtx::GetBodySourceCode()
std::string ZMtx::GetBodySourceCode() const
{
std::string bodyStr = "\n";
+1 -1
View File
@@ -17,7 +17,7 @@ public:
void DeclareVar(const std::string& prefix, const std::string& bodyStr) const;
std::string GetBodySourceCode();
std::string GetBodySourceCode() const override;
std::string GetSourceOutputCode(const std::string& prefix) override;
static std::string GetDefaultName(const std::string& prefix, uint32_t address);
+3 -3
View File
@@ -1,8 +1,8 @@
#include "ZPath.h"
#include "BitConverter.h"
#include "Globals.h"
#include "StringHelper.h"
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
#include "ZFile.h"
REGISTER_ZFILENODE(Path, ZPath);
@@ -80,7 +80,7 @@ std::string ZPath::GetBodySourceCode() const
return declaration;
}
std::string ZPath::GetSourceOutputCode(const std::string& prefix)
std::string ZPath::GetSourceOutputCode([[maybe_unused]] const std::string& prefix)
{
std::string declaration = GetBodySourceCode();
+4 -4
View File
@@ -11,12 +11,12 @@ public:
void ParseRawData() override;
void DeclareReferences(const std::string& prefix) override;
std::string GetBodySourceCode() const;
std::string GetBodySourceCode() const override;
std::string GetSourceTypeName() const override;
ZResourceType GetResourceType() const override;
size_t GetRawDataSize() const;
size_t GetRawDataSize() const override;
segptr_t GetListAddress() const;
protected:
@@ -32,13 +32,13 @@ class ZPath : public ZResource
public:
ZPath(ZFile* nParent);
void ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex);
void ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) override;
void ParseXML(tinyxml2::XMLElement* reader) override;
void ParseRawData() override;
void DeclareReferences(const std::string& prefix) override;
std::string GetBodySourceCode() const;
std::string GetBodySourceCode() const override;
std::string GetSourceOutputCode(const std::string& prefix) override;
std::string GetSourceTypeName() const override;
+17 -22
View File
@@ -2,7 +2,7 @@
#include <cassert>
#include <regex>
#include "StringHelper.h"
#include "Utils/StringHelper.h"
#include "ZFile.h"
ZResource::ZResource(ZFile* nParent)
@@ -114,11 +114,23 @@ void ZResource::ParseXML(tinyxml2::XMLElement* reader)
}
}
void ZResource::Save(const fs::path& outFolder)
void ZResource::ParseRawData()
{
}
void ZResource::PreGenSourceFiles()
void ZResource::DeclareReferences([[maybe_unused]] const std::string& prefix)
{
}
void ZResource::ParseRawDataLate()
{
}
void ZResource::DeclareReferencesLate([[maybe_unused]] const std::string& prefix)
{
}
void ZResource::Save([[maybe_unused]] const fs::path& outFolder)
{
}
@@ -177,33 +189,16 @@ std::string ZResource::GetBodySourceCode() const
return "ERROR";
}
std::string ZResource::GetSourceOutputCode(const std::string& prefix)
std::string ZResource::GetSourceOutputCode([[maybe_unused]] const std::string& prefix)
{
return "";
}
std::string ZResource::GetSourceOutputHeader(const std::string& prefix)
std::string ZResource::GetSourceOutputHeader([[maybe_unused]] const std::string& prefix)
{
return "";
}
void ZResource::ParseRawData()
{
}
void ZResource::DeclareReferences(const std::string& prefix)
{
}
void ZResource::GenerateHLIntermediette(HLFileIntermediette& hlFile)
{
}
std::string ZResource::GetSourceTypeName() const
{
return "u8";
}
ZResourceType ZResource::GetResourceType() const
{
return ZResourceType::Error;
+25 -5
View File
@@ -1,5 +1,6 @@
#pragma once
#include <Utils/BinaryWriter.h>
#include <map>
#include <stdexcept>
#include <stdint.h>
@@ -8,7 +9,7 @@
#include "Declaration.h"
#include "tinyxml2.h"
#include "Directory.h"
#include <Utils/Directory.h>
#define SEGMENT_SCENE 2
#define SEGMENT_ROOM 3
@@ -23,13 +24,13 @@
typedef uint32_t segptr_t;
class ZFile;
class HLFileIntermediette;
enum class ZResourceType
{
Error,
Animation,
Array,
AltHeader,
Background,
Blob,
CollisionHeader,
@@ -42,10 +43,13 @@ enum class ZResourceType
Room,
RoomCommand,
Scalar,
Scene,
Skeleton,
String,
Symbol,
Texture,
TextureAnimation,
TextureAnimationParams,
Vector,
Vertex,
};
@@ -77,19 +81,19 @@ public:
virtual void ParseXML(tinyxml2::XMLElement* reader);
virtual void ParseRawData();
virtual void DeclareReferences(const std::string& prefix);
virtual void ParseRawDataLate();
virtual void DeclareReferencesLate(const std::string& prefix);
virtual std::string GetBodySourceCode() const;
virtual std::string GetSourceOutputCode(const std::string& prefix);
virtual std::string GetSourceOutputHeader(const std::string& prefix);
virtual void PreGenSourceFiles();
virtual void GenerateHLIntermediette(HLFileIntermediette& hlFile);
virtual void CalcHash();
virtual void Save(const fs::path& outFolder);
// Properties
virtual bool IsExternalResource() const;
virtual bool DoesSupportArray() const; // Can this type be wrapped in an <Array> node?
virtual std::string GetSourceTypeName() const;
virtual std::string GetSourceTypeName() const = 0;
virtual ZResourceType GetResourceType() const = 0;
virtual std::string GetExternalExtension() const;
@@ -129,6 +133,14 @@ protected:
void RegisterOptionalAttribute(const std::string& attr, const std::string& defaultValue = "");
};
class ZResourceExporter
{
public:
ZResourceExporter() = default;
virtual void Save(ZResource* res, fs::path outPath, BinaryWriter* writer) = 0;
};
uint32_t Seg2Filespace(segptr_t segmentedAddress, uint32_t parentBaseAddress);
typedef ZResource*(ZResourceFactoryFunc)(ZFile* nParent);
@@ -148,3 +160,11 @@ typedef ZResource*(ZResourceFactoryFunc)(ZFile* nParent);
} \
}; \
static ZRes_##nodeName inst_ZRes_##nodeName
#define REGISTER_EXPORTER(expFunc) \
class ZResExp_##expFunc \
{ \
public: \
ZResExp_##expFunc() { expFunc(); } \
}; \
static ZResExp_##expFunc inst_ZResExp_##expFunc;
@@ -1,8 +1,8 @@
#include "SetActorCutsceneList.h"
#include "BitConverter.h"
#include "Globals.h"
#include "StringHelper.h"
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
#include "ZFile.h"
#include "ZRoom/ZRoom.h"
@@ -58,11 +58,6 @@ std::string SetActorCutsceneList::GetBodySourceCode() const
listName.c_str());
}
size_t SetActorCutsceneList::GetRawDataSize() const
{
return ZRoomCommand::GetRawDataSize() + (cutscenes.size() * 16);
}
std::string SetActorCutsceneList::GetCommandCName() const
{
return "SCmdCutsceneActorList";
@@ -26,6 +26,8 @@ public:
class SetActorCutsceneList : public ZRoomCommand
{
public:
std::vector<ActorCutsceneEntry> cutscenes;
SetActorCutsceneList(ZFile* nParent);
void ParseRawData() override;
@@ -35,8 +37,6 @@ public:
std::string GetCommandCName() const override;
RoomCommand GetRoomCommand() const override;
size_t GetRawDataSize() const override;
private:
std::vector<ActorCutsceneEntry> cutscenes;
};
+77 -46
View File
@@ -1,8 +1,8 @@
#include "SetActorList.h"
#include "BitConverter.h"
#include "Globals.h"
#include "StringHelper.h"
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
#include "ZFile.h"
#include "ZRoom/ZNames.h"
#include "ZRoom/ZRoom.h"
@@ -15,10 +15,26 @@ void SetActorList::ParseRawData()
{
ZRoomCommand::ParseRawData();
numActors = cmdArg1;
}
void SetActorList::DeclareReferences(const std::string& prefix)
{
if (numActors != 0 && cmdArg2 != 0)
{
std::string varName =
StringHelper::Sprintf("%sActorList_%06X", prefix.c_str(), segmentOffset);
parent->AddDeclarationPlaceholder(segmentOffset, varName);
}
}
void SetActorList::ParseRawDataLate()
{
ZRoomCommand::ParseRawDataLate();
size_t actorsAmount = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 0x10;
uint32_t currentPtr = segmentOffset;
for (size_t i = 0; i < numActors; i++)
for (size_t i = 0; i < actorsAmount; i++)
{
ActorSpawnEntry entry(parent->GetRawData(), currentPtr);
@@ -27,50 +43,56 @@ void SetActorList::ParseRawData()
}
}
void SetActorList::DeclareReferences(const std::string& prefix)
void SetActorList::DeclareReferencesLate(const std::string& prefix)
{
if (!actors.empty())
if (actors.empty())
return;
std::string declaration = "";
size_t largestlength = 0;
for (const auto& entry : actors)
{
std::string declaration = "";
size_t index = 0;
for (const auto& entry : actors)
{
declaration +=
StringHelper::Sprintf("\t{ %s }, // 0x%06X", entry.GetBodySourceCode().c_str(),
segmentOffset + (index * 16));
if (index < actors.size() - 1)
declaration += "\n";
index++;
}
const auto& entry = actors.front();
DeclarationPadding padding = DeclarationPadding::Pad16;
if (Globals::Instance->game == ZGame::MM_RETAIL)
padding = DeclarationPadding::None;
parent->AddDeclarationArray(
segmentOffset, DeclarationAlignment::Align4, padding,
actors.size() * entry.GetRawDataSize(), entry.GetSourceTypeName(),
StringHelper::Sprintf("%sActorList_%06X", prefix.c_str(), segmentOffset),
GetActorListArraySize(), declaration);
size_t actorNameLength = ZNames::GetActorName(entry.GetActorId()).size();
if (actorNameLength > largestlength)
largestlength = actorNameLength;
}
size_t index = 0;
for (auto& entry : actors)
{
entry.SetLargestActorName(largestlength);
declaration += StringHelper::Sprintf("\t{ %s },", entry.GetBodySourceCode().c_str());
if (index < actors.size() - 1)
declaration += "\n";
index++;
}
const auto& entry = actors.front();
DeclarationPadding padding = DeclarationPadding::Pad16;
if (Globals::Instance->game == ZGame::MM_RETAIL)
padding = DeclarationPadding::None;
std::string varName = StringHelper::Sprintf("%sActorList_%06X", prefix.c_str(), segmentOffset);
parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::Align4, padding,
actors.size() * entry.GetRawDataSize(), entry.GetSourceTypeName(),
varName, GetActorListArraySize(), declaration);
}
std::string SetActorList::GetBodySourceCode() const
{
std::string listName = parent->GetDeclarationPtrName(cmdArg2);
if (numActors != actors.size())
{
printf("%s: numActors(%i) ~ actors(%li)\n", parent->GetName().c_str(), numActors,
actors.size());
}
return StringHelper::Sprintf("SCENE_CMD_ACTOR_LIST(%i, %s)", numActors, listName.c_str());
}
size_t SetActorList::GetRawDataSize() const
{
return ZRoomCommand::GetRawDataSize() + ((int32_t)actors.size() * 16);
}
size_t SetActorList::GetActorListArraySize() const
{
size_t actorCount = 0;
@@ -110,27 +132,31 @@ ActorSpawnEntry::ActorSpawnEntry(const std::vector<uint8_t>& rawData, uint32_t r
posX = BitConverter::ToInt16BE(rawData, rawDataIndex + 2);
posY = BitConverter::ToInt16BE(rawData, rawDataIndex + 4);
posZ = BitConverter::ToInt16BE(rawData, rawDataIndex + 6);
rotX = BitConverter::ToInt16BE(rawData, rawDataIndex + 8);
rotY = BitConverter::ToInt16BE(rawData, rawDataIndex + 10);
rotZ = BitConverter::ToInt16BE(rawData, rawDataIndex + 12);
rotX = BitConverter::ToUInt16BE(rawData, rawDataIndex + 8);
rotY = BitConverter::ToUInt16BE(rawData, rawDataIndex + 10);
rotZ = BitConverter::ToUInt16BE(rawData, rawDataIndex + 12);
initVar = BitConverter::ToInt16BE(rawData, rawDataIndex + 14);
}
std::string ActorSpawnEntry::GetBodySourceCode() const
{
std::string body = "\n";
std::string body = "";
body += "\t\t" + ZNames::GetActorName(actorNum) + ",\n";
body += StringHelper::Sprintf("\t\t{ %6i, %6i, %6i },\n", posX, posY, posZ);
std::string actorNameFmt = StringHelper::Sprintf("%%-%zus ", largestActorName + 1);
body =
StringHelper::Sprintf(actorNameFmt.c_str(), (ZNames::GetActorName(actorNum) + ",").c_str());
body += StringHelper::Sprintf("{ %6i, %6i, %6i }, ", posX, posY, posZ);
if (Globals::Instance->game == ZGame::MM_RETAIL)
body += StringHelper::Sprintf("\t\t{ SPAWN_ROT_FLAGS(%i, 0x%04X), SPAWN_ROT_FLAGS(%i, "
"0x%04X), SPAWN_ROT_FLAGS(%i, 0x%04X)},\n",
body += StringHelper::Sprintf("{ SPAWN_ROT_FLAGS(%#5hX, 0x%04X)"
", SPAWN_ROT_FLAGS(%#5hX, 0x%04X)"
", SPAWN_ROT_FLAGS(%#5hX, 0x%04X) }, ",
(rotX >> 7) & 0b111111111, rotX & 0b1111111,
(rotY >> 7) & 0b111111111, rotY & 0b1111111,
(rotZ >> 7) & 0b111111111, rotZ & 0b1111111);
else
body += StringHelper::Sprintf("\t\t{ %6i, %6i, %6i },\n", rotX, rotY, rotZ);
body += StringHelper::Sprintf("\t\t0x%04X\n ", initVar);
body += StringHelper::Sprintf("{ %#6hX, %#6hX, %#6hX }, ", rotX, rotY, rotZ);
body += StringHelper::Sprintf("0x%04X", initVar);
return body;
}
@@ -149,3 +175,8 @@ uint16_t ActorSpawnEntry::GetActorId() const
{
return actorNum;
}
void ActorSpawnEntry::SetLargestActorName(size_t nameSize)
{
largestActorName = nameSize;
}
+17 -14
View File
@@ -5,6 +5,16 @@
class ActorSpawnEntry
{
public:
uint16_t actorNum;
int16_t posX;
int16_t posY;
int16_t posZ;
uint16_t rotX;
uint16_t rotY;
uint16_t rotZ;
uint16_t initVar;
size_t largestActorName = 16;
ActorSpawnEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
std::string GetBodySourceCode() const;
@@ -13,35 +23,28 @@ public:
int32_t GetRawDataSize() const;
uint16_t GetActorId() const;
protected:
uint16_t actorNum;
int16_t posX;
int16_t posY;
int16_t posZ;
int16_t rotX;
int16_t rotY;
int16_t rotZ;
uint16_t initVar;
void SetLargestActorName(size_t nameSize);
};
class SetActorList : public ZRoomCommand
{
public:
uint8_t numActors;
std::vector<ActorSpawnEntry> actors;
SetActorList(ZFile* nParent);
void ParseRawData() override;
void DeclareReferences(const std::string& prefix) override;
void ParseRawDataLate() override;
void DeclareReferencesLate(const std::string& prefix) override;
std::string GetBodySourceCode() const override;
RoomCommand GetRoomCommand() const override;
size_t GetRawDataSize() const override;
std::string GetCommandCName() const override;
protected:
size_t GetActorListArraySize() const;
uint8_t numActors;
std::vector<ActorSpawnEntry> actors;
};
@@ -1,14 +1,14 @@
#include "SetAlternateHeaders.h"
#include "BitConverter.h"
#include "StringHelper.h"
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
#include "ZFile.h"
SetAlternateHeaders::SetAlternateHeaders(ZFile* nParent) : ZRoomCommand(nParent)
{
}
void SetAlternateHeaders::DeclareReferences(const std::string& prefix)
void SetAlternateHeaders::DeclareReferences([[maybe_unused]] const std::string& prefix)
{
if (segmentOffset != 0)
parent->AddDeclarationPlaceholder(segmentOffset);
@@ -23,8 +23,14 @@ void SetAlternateHeaders::ParseRawDataLate()
int32_t address = BitConverter::ToInt32BE(parent->GetRawData(), segmentOffset + (i * 4));
headers.push_back(address);
if (address != 0)
zRoom->commandSets.push_back(CommandSet(address));
if (address != 0 && parent->GetDeclaration(GETSEGOFFSET(address)) == nullptr)
{
ZRoom* altheader = new ZRoom(parent);
altheader->ExtractFromBinary(GETSEGOFFSET(address), zRoom->GetResourceType());
altheader->DeclareReferences(parent->GetName());
parent->resources.push_back(altheader);
}
}
}
@@ -36,19 +42,16 @@ void SetAlternateHeaders::DeclareReferencesLate(const std::string& prefix)
for (size_t i = 0; i < headers.size(); i++)
{
if (headers.at(i) == 0)
declaration += StringHelper::Sprintf("\tNULL,");
else
declaration +=
StringHelper::Sprintf("\t%sSet%04X,", prefix.c_str(), GETSEGOFFSET(headers[i]));
declaration += StringHelper::Sprintf(
"\t%s,", parent->GetDeclarationPtrName(headers.at(i)).c_str());
if (i + 1 < headers.size())
declaration += "\n";
}
parent->AddDeclarationArray(
segmentOffset, DeclarationAlignment::None, headers.size() * 4, "SCmdBase*",
StringHelper::Sprintf("%sAlternateHeaders0x%06X", prefix.c_str(), segmentOffset), 0,
segmentOffset, DeclarationAlignment::Align4, headers.size() * 4, "SceneCmd*",
StringHelper::Sprintf("%sAltHeader_%06X", prefix.c_str(), segmentOffset), 0,
declaration);
}
}
@@ -6,6 +6,8 @@
class SetAlternateHeaders : public ZRoomCommand
{
public:
std::vector<uint32_t> headers;
SetAlternateHeaders(ZFile* nParent);
void DeclareReferences(const std::string& prefix) override;
@@ -18,5 +20,4 @@ public:
std::string GetCommandCName() const override;
private:
std::vector<uint32_t> headers;
};
@@ -1,115 +1,34 @@
/**
* File: SetAnimatedMaterialList.cpp
* Description: Defines a class SetAnimatedMaterialList to enable ZRoom to declare
* ZTextureAnimations, using that ZResource to do the work.
*/
#include "SetAnimatedMaterialList.h"
#include "BitConverter.h"
#include "Globals.h"
#include "StringHelper.h"
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
#include "ZFile.h"
#include "ZRoom/ZRoom.h"
#include "ZTextureAnimation.h"
SetAnimatedMaterialList::SetAnimatedMaterialList(ZFile* nParent) : ZRoomCommand(nParent)
SetAnimatedMaterialList::SetAnimatedMaterialList(ZFile* nParent)
: ZRoomCommand(nParent), textureAnimation(nParent)
{
}
void SetAnimatedMaterialList::ParseRawData()
{
ZRoomCommand::ParseRawData();
int32_t currentPtr = segmentOffset;
bool keepGoing = true;
do
{
AnimatedMaterial lastTexture(parent->GetRawData(), currentPtr);
keepGoing = (lastTexture.segment != 0) && (lastTexture.segment > -1);
currentPtr += 8;
textures.push_back(lastTexture);
} while (keepGoing);
textureAnimation.SetRawDataIndex(segmentOffset);
textureAnimation.ParseRawData();
}
void SetAnimatedMaterialList::DeclareReferences(const std::string& prefix)
{
std::string nameStr =
StringHelper::Sprintf("%sAnimatedMaterialList0x%06X", prefix.c_str(), segmentOffset);
for (auto& texture : textures)
{
size_t declSize = 0;
std::string declTypeName = "";
std::string declName = StringHelper::Sprintf("%sAnimatedMaterialParams0x%06X",
prefix.c_str(), texture.segmentOffset);
std::string declaration = "";
size_t index = 0;
switch (texture.type)
{
case 0:
case 1:
for (const auto& param : texture.params)
{
declaration += param->GenerateSourceCode(zRoom, texture.segmentOffset);
if (index < texture.params.size() - 1)
declaration += "\n";
index++;
}
declSize = texture.params.size() * 4;
declTypeName = "AnimatedMatTexScrollParams";
parent->AddDeclarationArray(texture.segmentOffset, DeclarationAlignment::Align4,
declSize, declTypeName, declName, texture.params.size(),
declaration);
break;
case 2:
case 3:
case 4:
declSize = texture.params.at(0)->GetParamsSize();
declTypeName = "AnimatedMatColorParams";
declaration = texture.params.at(0)->GenerateSourceCode(zRoom, texture.segmentOffset);
parent->AddDeclaration(texture.segmentOffset, DeclarationAlignment::Align4, declSize,
declTypeName, declName,
StringHelper::Sprintf("\n\t%s\n", declaration.c_str()));
break;
case 5:
declSize = texture.params.at(0)->GetParamsSize();
declTypeName = "AnimatedMatTexCycleParams";
declaration = texture.params.at(0)->GenerateSourceCode(zRoom, texture.segmentOffset);
parent->AddDeclaration(texture.segmentOffset, DeclarationAlignment::Align4, declSize,
declTypeName, declName,
StringHelper::Sprintf("\n\t%s\n", declaration.c_str()));
break;
case 6:
continue;
default:
throw std::runtime_error(
StringHelper::Sprintf("Error in SetAnimatedMaterialList::DeclareReferences (%s)\n"
"\t Unknown texture.type: %i\n",
nameStr.c_str(), texture.type));
}
}
if (!textures.empty())
{
std::string declaration = "";
for (size_t i = 0; i < textures.size(); i++)
{
std::string textureName = parent->GetDeclarationPtrName(textures.at(i).segmentAddress);
declaration += StringHelper::Sprintf("\t{ %2i, %2i, %s },", textures.at(i).segment,
textures.at(i).type, textureName.c_str());
if (i + 1 < textures.size())
declaration += "\n";
}
parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::Align4,
DeclarationPadding::Pad16, textures.size() * 8,
"AnimatedMaterial", nameStr, textures.size(), declaration);
}
textureAnimation.SetName(textureAnimation.GetDefaultName(prefix.c_str()));
textureAnimation.DeclareReferences(prefix);
textureAnimation.GetSourceOutputCode(prefix);
}
std::string SetAnimatedMaterialList::GetBodySourceCode() const
@@ -118,20 +37,6 @@ std::string SetAnimatedMaterialList::GetBodySourceCode() const
return StringHelper::Sprintf("SCENE_CMD_ANIMATED_MATERIAL_LIST(%s)", listName.c_str());
}
size_t SetAnimatedMaterialList::GetRawDataSize() const
{
size_t paramsSize = 0;
for (const auto& texture : textures)
{
for (const auto& param : texture.params)
{
paramsSize += param->GetParamsSize();
}
}
return ZRoomCommand::GetRawDataSize() + paramsSize;
}
std::string SetAnimatedMaterialList::GetCommandCName() const
{
return "SCmdTextureAnimations";
@@ -141,273 +46,3 @@ RoomCommand SetAnimatedMaterialList::GetRoomCommand() const
{
return RoomCommand::SetAnimatedMaterialList;
}
AnimatedMaterial::AnimatedMaterial(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex)
: segment(rawData.at(rawDataIndex)), type(BitConverter::ToInt16BE(rawData, rawDataIndex + 2))
{
segmentAddress = BitConverter::ToInt32BE(rawData, rawDataIndex + 4);
segmentOffset = GETSEGOFFSET(segmentAddress);
switch (type)
{
case 0:
params.push_back(std::make_shared<ScrollingTexture>(rawData, segmentOffset));
break;
case 1:
params.push_back(std::make_shared<ScrollingTexture>(rawData, segmentOffset));
params.push_back(std::make_shared<ScrollingTexture>(rawData, segmentOffset + 4));
break;
case 2:
case 3:
case 4:
params.push_back(std::make_shared<FlashingTexture>(rawData, segmentOffset, type));
break;
case 5:
params.push_back(std::make_shared<AnimatedMatTexCycleParams>(rawData, segmentOffset));
break;
case 6: // Some terminator when there are no animated textures?
break;
}
}
ScrollingTexture::ScrollingTexture(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex)
: xStep(rawData.at(rawDataIndex + 0)), yStep(rawData.at(rawDataIndex + 1)),
width(rawData.at(rawDataIndex + 2)), height(rawData.at(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;
}
F3DPrimColor::F3DPrimColor(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex)
: r(rawData.at(rawDataIndex + 0)), g(rawData.at(rawDataIndex + 1)),
b(rawData.at(rawDataIndex + 2)), a(rawData.at(rawDataIndex + 3)),
lodFrac(rawData.at(rawDataIndex + 4))
{
}
FlashingTextureEnvColor::FlashingTextureEnvColor(const std::vector<uint8_t>& rawData,
uint32_t rawDataIndex)
: r(rawData.at(rawDataIndex + 0)), g(rawData.at(rawDataIndex + 1)),
b(rawData.at(rawDataIndex + 2)), a(rawData.at(rawDataIndex + 3))
{
}
FlashingTexture::FlashingTexture(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex,
int32_t type)
: cycleLength(BitConverter::ToUInt16BE(rawData, rawDataIndex + 0)),
numKeyFrames(BitConverter::ToUInt16BE(rawData, rawDataIndex + 2))
{
uint16_t length = (type == 2) ? cycleLength : numKeyFrames;
primColorSegmentAddr = BitConverter::ToInt32BE(rawData, rawDataIndex + 4);
envColorSegmentAddr = BitConverter::ToInt32BE(rawData, rawDataIndex + 8);
keyFrameSegmentAddr = BitConverter::ToInt32BE(rawData, rawDataIndex + 12);
primColorSegmentOffset = GETSEGOFFSET(primColorSegmentAddr);
envColorSegmentOffset = GETSEGOFFSET(envColorSegmentAddr);
keyFrameSegmentOffset = GETSEGOFFSET(keyFrameSegmentAddr);
int32_t currentPtr = primColorSegmentOffset;
for (uint16_t i = 0; i < length; i++)
{
primColors.push_back(F3DPrimColor(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)
{
std::string declaration = "";
size_t index = 0;
for (F3DPrimColor& 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,
primColors.size() * 5, "F3DPrimColor",
StringHelper::Sprintf("%sAnimatedMaterialPrimColor_%06X",
zRoom->GetName().c_str(),
primColorSegmentOffset),
primColors.size(), declaration);
}
if (envColorSegmentOffset != 0)
{
std::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, envColors.size() * 4,
"F3DEnvColor",
StringHelper::Sprintf("%sAnimatedMaterialEnvColors0x%06X", zRoom->GetName().c_str(),
envColorSegmentOffset),
envColors.size(), declaration);
}
if (keyFrameSegmentOffset != 0)
{
std::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, keyFrames.size() * 2, "u16",
StringHelper::Sprintf("%sAnimatedMaterialKeyFrames0x%06X", zRoom->GetName().c_str(),
keyFrameSegmentOffset),
keyFrames.size(), declaration);
}
std::string primName = zRoom->parent->GetDeclarationPtrName(primColorSegmentAddr);
std::string envName = zRoom->parent->GetDeclarationPtrName(envColorSegmentAddr);
std::string keyName = zRoom->parent->GetDeclarationPtrName(keyFrameSegmentAddr);
return StringHelper::Sprintf("%i, %i, %s, %s, %s", cycleLength, numKeyFrames, primName.c_str(),
envName.c_str(), keyName.c_str());
}
size_t FlashingTexture::GetParamsSize()
{
return 16;
}
AnimatedMatTexCycleParams::AnimatedMatTexCycleParams(const std::vector<uint8_t>& rawData,
uint32_t rawDataIndex)
: cycleLength(BitConverter::ToUInt16BE(rawData, rawDataIndex + 0))
{
textureSegmentOffsetsSegmentAddress = BitConverter::ToInt32BE(rawData, rawDataIndex + 4);
textureIndicesSegmentAddress = BitConverter::ToInt32BE(rawData, rawDataIndex + 8);
textureSegmentOffsetsSegmentOffset = GETSEGOFFSET(textureSegmentOffsetsSegmentAddress);
textureIndicesSegmentOffset = GETSEGOFFSET(textureIndicesSegmentAddress);
int32_t currentPtr = textureIndicesSegmentOffset;
int32_t maxIndex = 0;
for (uint16_t i = 0; i < cycleLength; i++)
{
uint8_t newIndex = rawData.at(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 AnimatedMatTexCycleParams::GenerateSourceCode(ZRoom* zRoom, uint32_t baseAddress)
{
if (textureSegmentOffsetsSegmentOffset != 0)
{
std::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,
textureSegmentOffsets.size() * 4, "u64*",
StringHelper::Sprintf("%sAnimatedMaterialTexSegOffsets0x%06X", zRoom->GetName().c_str(),
textureSegmentOffsetsSegmentOffset),
textureSegmentOffsets.size(), declaration);
}
if (textureIndicesSegmentOffset != 0)
{
std::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, textureIndices.size(), "u8",
StringHelper::Sprintf("%sAnimatedMaterialTexIndices0x%06X", zRoom->GetName().c_str(),
textureIndicesSegmentOffset),
textureIndices.size(), declaration);
}
std::string segmName =
zRoom->parent->GetDeclarationPtrName(textureSegmentOffsetsSegmentAddress);
std::string indexesName = zRoom->parent->GetDeclarationPtrName(textureIndicesSegmentAddress);
return StringHelper::Sprintf("%i, %s, %s", cycleLength, segmName.c_str(), indexesName.c_str());
}
size_t AnimatedMatTexCycleParams::GetParamsSize()
{
return 12;
}
@@ -2,103 +2,7 @@
#include <memory>
#include "ZRoom/ZRoomCommand.h"
// TODO move into header and add all types
class AnitmatedTextureParams
{
public:
virtual std::string GenerateSourceCode(ZRoom* zRoom, uint32_t baseAddress) = 0;
virtual size_t GetParamsSize() = 0;
};
class ScrollingTexture : public AnitmatedTextureParams
{
public:
ScrollingTexture(const 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 F3DPrimColor
{
public:
F3DPrimColor(const 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(const 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(const 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;
segptr_t primColorSegmentAddr;
segptr_t envColorSegmentAddr;
segptr_t keyFrameSegmentAddr;
uint32_t primColorSegmentOffset;
uint32_t envColorSegmentOffset;
uint32_t keyFrameSegmentOffset;
std::vector<F3DPrimColor> primColors;
std::vector<FlashingTextureEnvColor> envColors;
std::vector<uint16_t> keyFrames;
};
class AnimatedMatTexCycleParams : public AnitmatedTextureParams
{
public:
AnimatedMatTexCycleParams(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
std::string GenerateSourceCode(ZRoom* zRoom, uint32_t baseAddress) override;
size_t GetParamsSize() override;
uint16_t cycleLength;
segptr_t textureSegmentOffsetsSegmentAddress;
segptr_t textureIndicesSegmentAddress;
uint32_t textureSegmentOffsetsSegmentOffset;
uint32_t textureIndicesSegmentOffset;
std::vector<uint32_t> textureSegmentOffsets;
std::vector<uint8_t> textureIndices;
};
class AnimatedMaterial
{
public:
AnimatedMaterial(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
int8_t segment;
int16_t type;
segptr_t segmentAddress;
uint32_t segmentOffset;
std::vector<std::shared_ptr<AnitmatedTextureParams>> params;
};
#include "ZTextureAnimation.h"
class SetAnimatedMaterialList : public ZRoomCommand
{
@@ -111,9 +15,8 @@ public:
std::string GetBodySourceCode() const override;
RoomCommand GetRoomCommand() const override;
size_t GetRawDataSize() const override;
std::string GetCommandCName() const override;
private:
std::vector<AnimatedMaterial> textures;
ZTextureAnimation textureAnimation;
};
@@ -1,7 +1,7 @@
#include "SetCameraSettings.h"
#include "BitConverter.h"
#include "StringHelper.h"
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
SetCameraSettings::SetCameraSettings(ZFile* nParent) : ZRoomCommand(nParent)
{
@@ -5,6 +5,9 @@
class SetCameraSettings : public ZRoomCommand
{
public:
uint8_t cameraMovement;
uint32_t mapHighlight;
SetCameraSettings(ZFile* nParent);
void ParseRawData() override;
@@ -15,6 +18,4 @@ public:
RoomCommand GetRoomCommand() const override;
private:
uint8_t cameraMovement;
uint32_t mapHighlight;
};
@@ -1,7 +1,7 @@
#include "SetCollisionHeader.h"
#include "BitConverter.h"
#include "StringHelper.h"
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
#include "ZFile.h"
#include "ZRoom/ZRoom.h"
@@ -6,6 +6,8 @@
class SetCollisionHeader : public ZRoomCommand
{
public:
ZCollisionHeader* collisionHeader;
SetCollisionHeader(ZFile* nParent);
~SetCollisionHeader();
@@ -15,7 +17,4 @@ public:
std::string GetCommandCName() const override;
RoomCommand GetRoomCommand() const override;
private:
ZCollisionHeader* collisionHeader;
};
@@ -1,7 +1,7 @@
#include "SetCsCamera.h"
#include "BitConverter.h"
#include "StringHelper.h"
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
#include "ZFile.h"
#include "ZRoom/ZRoom.h"
@@ -112,11 +112,6 @@ std::string SetCsCamera::GetBodySourceCode() const
listName.c_str());
}
size_t SetCsCamera::GetRawDataSize() const
{
return ZRoomCommand::GetRawDataSize() + (cameras.size() * 8) + (points.size() * 6);
}
std::string SetCsCamera::GetCommandCName() const
{
return "SCmdCsCameraList";
+3 -5
View File
@@ -25,6 +25,9 @@ public:
class SetCsCamera : public ZRoomCommand
{
public:
std::vector<CsCameraEntry> cameras;
std::vector<ZVector> points;
SetCsCamera(ZFile* nParent);
void ParseRawData() override;
@@ -33,10 +36,5 @@ public:
std::string GetBodySourceCode() const override;
RoomCommand GetRoomCommand() const override;
size_t GetRawDataSize() const override;
std::string GetCommandCName() const override;
private:
std::vector<CsCameraEntry> cameras;
std::vector<ZVector> points;
};
@@ -1,8 +1,8 @@
#include "SetCutscenes.h"
#include "BitConverter.h"
#include "Globals.h"
#include "StringHelper.h"
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
#include "ZFile.h"
#include "ZRoom/ZRoom.h"
@@ -10,6 +10,12 @@ SetCutscenes::SetCutscenes(ZFile* nParent) : ZRoomCommand(nParent)
{
}
SetCutscenes::~SetCutscenes()
{
for (ZCutsceneBase* cutscene : cutscenes)
delete cutscene;
}
void SetCutscenes::ParseRawData()
{
ZRoomCommand::ParseRawData();
@@ -76,12 +82,6 @@ void SetCutscenes::ParseRawData()
}
}
SetCutscenes::~SetCutscenes()
{
for (ZCutsceneBase* cutscene : cutscenes)
delete cutscene;
}
std::string SetCutscenes::GetBodySourceCode() const
{
std::string listName = parent->GetDeclarationPtrName(cmdArg2);
@@ -92,11 +92,6 @@ std::string SetCutscenes::GetBodySourceCode() const
return StringHelper::Sprintf("SCENE_CMD_CUTSCENE_DATA(%s)", listName.c_str());
}
size_t SetCutscenes::GetRawDataSize() const
{
return ZRoomCommand::GetRawDataSize();
}
std::string SetCutscenes::GetCommandCName() const
{
return "SCmdCutsceneData";
@@ -18,6 +18,10 @@ public:
class SetCutscenes : public ZRoomCommand
{
public:
std::vector<ZCutsceneBase*> cutscenes;
std::vector<CutsceneEntry> cutsceneEntries; // (MM Only)
uint8_t numCutscenes; // (MM Only)
SetCutscenes(ZFile* nParent);
~SetCutscenes();
@@ -26,11 +30,5 @@ public:
std::string GetBodySourceCode() const override;
RoomCommand GetRoomCommand() const override;
size_t GetRawDataSize() const override;
std::string GetCommandCName() const override;
private:
std::vector<ZCutsceneBase*> cutscenes;
std::vector<CutsceneEntry> cutsceneEntries; // (MM Only)
uint8_t numCutscenes; // (MM Only)
};
@@ -1,5 +1,5 @@
#include "SetEchoSettings.h"
#include "StringHelper.h"
#include "Utils/StringHelper.h"
SetEchoSettings::SetEchoSettings(ZFile* nParent) : ZRoomCommand(nParent)
{
@@ -5,6 +5,8 @@
class SetEchoSettings : public ZRoomCommand
{
public:
uint8_t echo;
SetEchoSettings(ZFile* nParent);
void ParseRawData() override;
@@ -13,7 +15,4 @@ public:
std::string GetCommandCName() const override;
RoomCommand GetRoomCommand() const override;
private:
uint8_t echo;
};
@@ -1,7 +1,7 @@
#include "SetEntranceList.h"
#include "BitConverter.h"
#include "SetStartPositionList.h"
#include "StringHelper.h"
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
#include "ZFile.h"
#include "ZRoom/ZRoom.h"
@@ -9,7 +9,7 @@ SetEntranceList::SetEntranceList(ZFile* nParent) : ZRoomCommand(nParent)
{
}
void SetEntranceList::DeclareReferences(const std::string& prefix)
void SetEntranceList::DeclareReferences([[maybe_unused]] const std::string& prefix)
{
if (segmentOffset != 0)
parent->AddDeclarationPlaceholder(segmentOffset);
@@ -30,7 +30,7 @@ void SetEntranceList::ParseRawDataLate()
}
}
void SetEntranceList::DeclareReferencesLate(const std::string& prefix)
void SetEntranceList::DeclareReferencesLate([[maybe_unused]] const std::string& prefix)
{
if (!entrances.empty())
{
@@ -50,7 +50,7 @@ void SetEntranceList::DeclareReferencesLate(const std::string& prefix)
parent->AddDeclarationArray(
segmentOffset, DeclarationAlignment::None, entrances.size() * 2, "EntranceEntry",
StringHelper::Sprintf("%sEntranceList0x%06X", zRoom->GetName().c_str(), segmentOffset),
StringHelper::Sprintf("%sEntranceList0x%06X", prefix.c_str(), segmentOffset),
entrances.size(), declaration);
}
}
@@ -5,18 +5,19 @@
class EntranceEntry
{
public:
uint8_t startPositionIndex;
uint8_t roomToLoad;
EntranceEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
std::string GetBodySourceCode() const;
protected:
uint8_t startPositionIndex;
uint8_t roomToLoad;
};
class SetEntranceList : public ZRoomCommand
{
public:
std::vector<EntranceEntry> entrances;
SetEntranceList(ZFile* nParent);
void DeclareReferences(const std::string& prefix) override;
@@ -27,7 +28,4 @@ public:
RoomCommand GetRoomCommand() const override;
std::string GetCommandCName() const override;
private:
std::vector<EntranceEntry> entrances;
};
@@ -1,7 +1,7 @@
#include "SetExitList.h"
#include "BitConverter.h"
#include "StringHelper.h"
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
#include "ZFile.h"
#include "ZRoom/ZRoom.h"
@@ -9,7 +9,7 @@ SetExitList::SetExitList(ZFile* nParent) : ZRoomCommand(nParent)
{
}
void SetExitList::DeclareReferences(const std::string& prefix)
void SetExitList::DeclareReferences([[maybe_unused]] const std::string& prefix)
{
if (segmentOffset != 0)
parent->AddDeclarationPlaceholder(segmentOffset);
@@ -30,7 +30,7 @@ void SetExitList::ParseRawDataLate()
}
}
void SetExitList::DeclareReferencesLate(const std::string& prefix)
void SetExitList::DeclareReferencesLate([[maybe_unused]] const std::string& prefix)
{
if (!exits.empty())
{
@@ -45,8 +45,8 @@ void SetExitList::DeclareReferencesLate(const std::string& prefix)
parent->AddDeclarationArray(
segmentOffset, DeclarationAlignment::Align4, exits.size() * 2, "u16",
StringHelper::Sprintf("%sExitList_%06X", zRoom->GetName().c_str(), segmentOffset),
exits.size(), declaration);
StringHelper::Sprintf("%sExitList_%06X", prefix.c_str(), segmentOffset), exits.size(),
declaration);
}
}
+2 -3
View File
@@ -5,6 +5,8 @@
class SetExitList : public ZRoomCommand
{
public:
std::vector<uint16_t> exits;
SetExitList(ZFile* nParent);
void DeclareReferences(const std::string& prefix) override;
@@ -15,7 +17,4 @@ public:
RoomCommand GetRoomCommand() const override;
std::string GetCommandCName() const override;
private:
std::vector<uint16_t> exits;
};
@@ -1,6 +1,6 @@
#include "SetLightList.h"
#include "BitConverter.h"
#include "StringHelper.h"
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
SetLightList::SetLightList(ZFile* nParent) : ZRoomCommand(nParent)
{
@@ -27,6 +27,9 @@ protected:
class SetLightList : public ZRoomCommand
{
public:
uint8_t numLights;
std::vector<LightInfo> lights;
SetLightList(ZFile* nParent);
void ParseRawData() override;
@@ -36,8 +39,4 @@ public:
RoomCommand GetRoomCommand() const override;
std::string GetCommandCName() const override;
private:
uint8_t numLights;
std::vector<LightInfo> lights;
};
@@ -1,6 +1,6 @@
#include "SetLightingSettings.h"
#include "BitConverter.h"
#include "StringHelper.h"
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
#include "ZFile.h"
#include "ZRoom/ZRoom.h"
@@ -5,13 +5,6 @@
class LightingSettings
{
public:
LightingSettings(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
std::string GetBodySourceCode() const;
size_t GetRawDataSize() const;
protected:
uint8_t ambientClrR, ambientClrG, ambientClrB;
uint8_t diffuseClrA_R, diffuseClrA_G, diffuseClrA_B;
uint8_t diffuseDirA_X, diffuseDirA_Y, diffuseDirA_Z;
@@ -20,11 +13,19 @@ protected:
uint8_t fogClrR, fogClrG, fogClrB;
uint16_t unk;
uint16_t drawDistance;
LightingSettings(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
std::string GetBodySourceCode() const;
size_t GetRawDataSize() const;
};
class SetLightingSettings : public ZRoomCommand
{
public:
std::vector<LightingSettings> settings;
SetLightingSettings(ZFile* nParent);
void ParseRawData() override;
@@ -34,7 +35,4 @@ public:
RoomCommand GetRoomCommand() const override;
std::string GetCommandCName() const override;
private:
std::vector<LightingSettings> settings;
};
+13 -19
View File
@@ -1,8 +1,8 @@
#include "SetMesh.h"
#include <Globals.h>
#include <Path.h>
#include "BitConverter.h"
#include "StringHelper.h"
#include <Utils/Path.h>
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
#include "ZBackground.h"
#include "ZFile.h"
#include "ZRoom/ZRoom.h"
@@ -59,7 +59,6 @@ void GenDListDeclarations(ZRoom* zRoom, ZFile* parent, ZDisplayList* dList)
StringHelper::Sprintf("%s%s", zRoom->GetName().c_str(), dList->GetName().c_str());
dList->SetName(srcVarName);
dList->scene = zRoom->scene;
std::string sourceOutput = dList->GetSourceOutputCode(zRoom->GetName());
for (ZDisplayList* otherDList : dList->otherDLists)
@@ -98,11 +97,6 @@ std::string SetMesh::GetBodySourceCode() const
return StringHelper::Sprintf("SCENE_CMD_MESH(%s)", list.c_str());
}
size_t SetMesh::GetRawDataSize() const
{
return ZRoomCommand::GetRawDataSize();
}
std::string SetMesh::GetCommandCName() const
{
return "SCmdMesh";
@@ -113,7 +107,8 @@ RoomCommand SetMesh::GetRoomCommand() const
return RoomCommand::SetMesh;
}
PolygonDlist::PolygonDlist(const std::string& prefix, const std::vector<uint8_t>& nRawData,
PolygonDlist::PolygonDlist(const std::string& prefix,
[[maybe_unused]] const std::vector<uint8_t>& nRawData,
uint32_t nRawDataIndex, ZFile* nParent, ZRoom* nRoom)
{
rawDataIndex = nRawDataIndex;
@@ -151,7 +146,7 @@ void PolygonDlist::DeclareReferences(const std::string& prefix)
xluDList = MakeDlist(xlu, prefix);
}
ZDisplayList* PolygonDlist::MakeDlist(segptr_t ptr, const std::string& prefix)
ZDisplayList* PolygonDlist::MakeDlist(segptr_t ptr, [[maybe_unused]] const std::string& prefix)
{
if (ptr == 0)
{
@@ -268,8 +263,9 @@ 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)
BgImage::BgImage(bool nIsSubStruct, const std::string& prefix,
[[maybe_unused]] const std::vector<uint8_t>& nRawData, uint32_t nRawDataIndex,
ZFile* nParent)
{
rawDataIndex = nRawDataIndex;
parent = nParent;
@@ -306,9 +302,7 @@ void BgImage::ParseRawData()
ZBackground* BgImage::MakeBackground(segptr_t ptr, const std::string& prefix)
{
if (ptr == 0)
{
return nullptr;
}
uint32_t backAddress = Seg2Filespace(ptr, parent->baseAddress);
@@ -406,7 +400,8 @@ std::string BgImage::GetName()
/* PolygonType section */
PolygonTypeBase::PolygonTypeBase(ZFile* nParent, const std::vector<uint8_t>& nRawData,
PolygonTypeBase::PolygonTypeBase(ZFile* nParent,
[[maybe_unused]] const std::vector<uint8_t>& nRawData,
uint32_t nRawDataIndex, ZRoom* nRoom)
: rawDataIndex{nRawDataIndex}, parent{nParent}, zRoom{nRoom}
{
@@ -653,9 +648,8 @@ void PolygonType2::DeclareReferences(const std::string& prefix)
polyDlistType, polyDListName, polyDLists.size(), declaration);
}
parent->AddDeclaration(GETSEGOFFSET(end), DeclarationAlignment::Align4,
DeclarationPadding::Pad16, 4, "static s32", "terminatorMaybe",
"0x01000000");
parent->AddDeclaration(GETSEGOFFSET(end), DeclarationAlignment::Align4, 4, "static s32",
"terminatorMaybe", "0x01000000");
}
std::string PolygonType2::GetBodySourceCode() const
+26 -25
View File
@@ -8,6 +8,17 @@
class PolygonDlist
{
public:
uint8_t polyType;
int16_t x, y, z; // polyType == 2
int16_t unk_06; // polyType == 2
segptr_t opa = 0; // Gfx*
segptr_t xlu = 0; // Gfx*
ZDisplayList* opaDList = nullptr; // Gfx*
ZDisplayList* xluDList = nullptr; // Gfx*
PolygonDlist() = default;
PolygonDlist(const std::string& prefix, const std::vector<uint8_t>& nRawData,
uint32_t nRawDataIndex, ZFile* nParent, ZRoom* nRoom);
@@ -28,17 +39,6 @@ public:
std::string GetName();
protected:
int16_t x, y, z; // polyType == 2
int16_t unk_06; // polyType == 2
segptr_t opa = 0; // Gfx*
segptr_t xlu = 0; // Gfx*
uint8_t polyType;
ZDisplayList* opaDList = nullptr; // Gfx*
ZDisplayList* xluDList = nullptr; // Gfx*
uint32_t rawDataIndex;
ZFile* parent;
ZRoom* zRoom;
@@ -49,7 +49,7 @@ protected:
class BgImage
{
protected:
public:
uint16_t unk_00;
uint8_t id;
segptr_t source;
@@ -69,6 +69,7 @@ protected:
std::string name;
bool isSubStruct;
protected:
void ParseRawData();
ZBackground* MakeBackground(segptr_t ptr, const std::string& prefix);
@@ -89,8 +90,12 @@ public:
class PolygonTypeBase
{
public:
uint8_t type;
std::vector<PolygonDlist> polyDLists;
PolygonTypeBase(ZFile* nParent, const std::vector<uint8_t>& nRawData, uint32_t nRawDataIndex,
ZRoom* nRoom);
virtual ~PolygonTypeBase() = default;
virtual void ParseRawData() = 0;
virtual void DeclareReferences(const std::string& prefix) = 0;
@@ -108,10 +113,6 @@ public:
std::string GetDefaultName(const std::string& prefix) const;
protected:
uint8_t type;
std::vector<PolygonDlist> polyDLists;
uint32_t rawDataIndex;
ZFile* parent;
ZRoom* zRoom;
@@ -120,7 +121,7 @@ protected:
class PolygonType1 : public PolygonTypeBase
{
protected:
public:
uint8_t format;
segptr_t dlist;
@@ -132,7 +133,6 @@ protected:
segptr_t list; // BgImage*
std::vector<BgImage> multiList;
public:
PolygonType1(ZFile* nParent, const std::vector<uint8_t>& nRawData, uint32_t nRawDataIndex,
ZRoom* nRoom);
@@ -149,6 +149,10 @@ public:
class PolygonType2 : public PolygonTypeBase
{
public:
uint8_t num;
segptr_t start;
segptr_t end;
PolygonType2(ZFile* nParent, const std::vector<uint8_t>& nRawData, uint32_t nRawDataIndex,
ZRoom* nRoom);
@@ -160,14 +164,15 @@ public:
size_t GetRawDataSize() const override;
protected:
uint8_t num;
segptr_t start;
segptr_t end;
};
class SetMesh : public ZRoomCommand
{
public:
uint8_t data;
uint8_t meshHeaderType;
std::shared_ptr<PolygonTypeBase> polyType;
SetMesh(ZFile* nParent);
void ParseRawData() override;
@@ -176,12 +181,8 @@ public:
std::string GetBodySourceCode() const override;
RoomCommand GetRoomCommand() const override;
size_t GetRawDataSize() const override;
std::string GetCommandCName() const override;
private:
uint8_t meshHeaderType;
std::shared_ptr<PolygonTypeBase> polyType;
std::string GenDListExterns(ZDisplayList* dList);
};
@@ -1,8 +1,8 @@
#include "SetMinimapChests.h"
#include "BitConverter.h"
#include "Globals.h"
#include "StringHelper.h"
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
#include "ZFile.h"
#include "ZRoom/ZRoom.h"
@@ -64,11 +64,6 @@ RoomCommand SetMinimapChests::GetRoomCommand() const
return RoomCommand::SetMinimapChests;
}
size_t SetMinimapChests::GetRawDataSize() const
{
return ZRoomCommand::GetRawDataSize() + (chests.size() * 10);
}
MinimapChest::MinimapChest(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex)
: unk0(BitConverter::ToUInt16BE(rawData, rawDataIndex + 0)),
unk2(BitConverter::ToUInt16BE(rawData, rawDataIndex + 2)),
@@ -20,6 +20,8 @@ protected:
class SetMinimapChests : public ZRoomCommand
{
public:
std::vector<MinimapChest> chests;
SetMinimapChests(ZFile* nParent);
void ParseRawData() override;
@@ -28,9 +30,5 @@ public:
std::string GetBodySourceCode() const override;
RoomCommand GetRoomCommand() const override;
size_t GetRawDataSize() const override;
std::string GetCommandCName() const override;
private:
std::vector<MinimapChest> chests;
};
@@ -1,8 +1,8 @@
#include "SetMinimapList.h"
#include "BitConverter.h"
#include "Globals.h"
#include "StringHelper.h"
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
#include "ZFile.h"
#include "ZRoom/ZRoom.h"
@@ -77,11 +77,6 @@ RoomCommand SetMinimapList::GetRoomCommand() const
return RoomCommand::SetMinimapList;
}
size_t SetMinimapList::GetRawDataSize() const
{
return ZRoomCommand::GetRawDataSize() + (minimaps.size() * 10);
}
MinimapEntry::MinimapEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex)
: unk0(BitConverter::ToUInt16BE(rawData, rawDataIndex + 0)),
unk2(BitConverter::ToUInt16BE(rawData, rawDataIndex + 2)),
@@ -20,6 +20,8 @@ protected:
class SetMinimapList : public ZRoomCommand
{
public:
std::vector<MinimapEntry> minimaps;
SetMinimapList(ZFile* nParent);
void ParseRawData() override;
@@ -28,12 +30,9 @@ public:
std::string GetBodySourceCode() const override;
RoomCommand GetRoomCommand() const override;
size_t GetRawDataSize() const override;
std::string GetCommandCName() const override;
private:
std::vector<MinimapEntry> minimaps;
segptr_t listSegmentAddr;
uint32_t listSegmentOffset;
uint32_t unk4;
@@ -1,8 +1,8 @@
#include "SetObjectList.h"
#include "BitConverter.h"
#include "Globals.h"
#include "StringHelper.h"
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
#include "ZFile.h"
#include "ZRoom/ZNames.h"
#include "ZRoom/ZRoom.h"
@@ -57,11 +57,6 @@ std::string SetObjectList::GetBodySourceCode() const
return StringHelper::Sprintf("SCENE_CMD_OBJECT_LIST(%i, %s)", objects.size(), listName.c_str());
}
size_t SetObjectList::GetRawDataSize() const
{
return ZRoomCommand::GetRawDataSize() + (objects.size() * 2);
}
std::string SetObjectList::GetCommandCName() const
{
return "SCmdObjectList";
@@ -5,17 +5,15 @@
class SetObjectList : public ZRoomCommand
{
public:
std::vector<uint16_t> objects;
SetObjectList(ZFile* nParent);
void ParseRawData() override;
void DeclareReferences(const std::string& prefix);
void DeclareReferences(const std::string& prefix) override;
std::string GetBodySourceCode() const override;
std::string GetCommandCName() const override;
RoomCommand GetRoomCommand() const override;
size_t GetRawDataSize() const override;
private:
std::vector<uint16_t> objects;
};
+3 -10
View File
@@ -1,7 +1,7 @@
#include "SetPathways.h"
#include "BitConverter.h"
#include "Globals.h"
#include "StringHelper.h"
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
#include "ZFile.h"
#include "ZRoom/ZRoom.h"
@@ -9,7 +9,7 @@ SetPathways::SetPathways(ZFile* nParent) : ZRoomCommand(nParent), pathwayList(nP
{
}
void SetPathways::DeclareReferences(const std::string& prefix)
void SetPathways::DeclareReferences([[maybe_unused]] const std::string& prefix)
{
if (segmentOffset != 0)
parent->AddDeclarationPlaceholder(segmentOffset);
@@ -40,13 +40,6 @@ std::string SetPathways::GetBodySourceCode() const
return StringHelper::Sprintf("SCENE_CMD_PATH_LIST(%s)", listName.c_str());
}
size_t SetPathways::GetRawDataSize() const
{
int32_t size = pathwayList.GetRawDataSize();
return ZRoomCommand::GetRawDataSize() + size;
}
std::string SetPathways::GetCommandCName() const
{
return "SCmdPathList";
+2 -4
View File
@@ -8,6 +8,8 @@
class SetPathways : public ZRoomCommand
{
public:
ZPath pathwayList;
SetPathways(ZFile* nParent);
void DeclareReferences(const std::string& prefix) override;
@@ -20,9 +22,5 @@ public:
std::string GetBodySourceCode() const override;
RoomCommand GetRoomCommand() const override;
size_t GetRawDataSize() const override;
std::string GetCommandCName() const override;
private:
ZPath pathwayList;
};
@@ -1,7 +1,7 @@
#include "SetRoomBehavior.h"
#include "BitConverter.h"
#include "Globals.h"
#include "StringHelper.h"
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
SetRoomBehavior::SetRoomBehavior(ZFile* nParent) : ZRoomCommand(nParent)
{
@@ -5,16 +5,6 @@
class SetRoomBehavior : public ZRoomCommand
{
public:
SetRoomBehavior(ZFile* nParent);
void ParseRawData() override;
std::string GetBodySourceCode() const override;
RoomCommand GetRoomCommand() const override;
std::string GetCommandCName() const override;
protected:
uint8_t gameplayFlags;
uint32_t gameplayFlags2;
@@ -27,4 +17,13 @@ protected:
uint8_t enablePosLights;
uint8_t kankyoContextUnkE2;
SetRoomBehavior(ZFile* nParent);
void ParseRawData() override;
std::string GetBodySourceCode() const override;
RoomCommand GetRoomCommand() const override;
std::string GetCommandCName() const override;
};

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