From ce7e913094b54c6c0f22caff39662c2f81bc56e4 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Thu, 13 Jul 2017 04:39:52 -0700 Subject: [PATCH] Initial support for AssetNameMap --- DataSpec/AssetNameMap.cpp | 80 +++++++++++++++++++++++++++++++++++++++ DataSpec/AssetNameMap.hpp | 17 +++++++++ DataSpec/CMakeLists.txt | 18 +++++++++ DataSpec/SpecBase.cpp | 2 + 4 files changed, 117 insertions(+) create mode 100644 DataSpec/AssetNameMap.cpp create mode 100644 DataSpec/AssetNameMap.hpp diff --git a/DataSpec/AssetNameMap.cpp b/DataSpec/AssetNameMap.cpp new file mode 100644 index 000000000..f2f0dd0cd --- /dev/null +++ b/DataSpec/AssetNameMap.cpp @@ -0,0 +1,80 @@ +#include "AssetNameMap.hpp" +#include "athena/MemoryReader.hpp" + +extern "C" uint8_t ASSET_NAME_MP32[]; +extern "C" uint32_t ASSET_NAME_MP32_SZ; +extern "C" uint8_t ASSET_NAME_MP64[]; +extern "C" uint32_t ASSET_NAME_MP64_SZ; + +namespace DataSpec +{ +namespace AssetNameMap +{ +logvisor::Module Log("AssetNameMap"); + +struct SAsset +{ + std::string name; + std::string directory; + hecl::FourCC type; + SAsset() = default; + SAsset(athena::io::IStreamReader& in) + { + uint32_t nameLen = in.readUint32Big(); + name = in.readString(nameLen); + uint32_t dirLen = in.readUint32Big(); + directory = in.readString(dirLen); + type = in.readUint32Big(); + } +}; + +static std::unordered_map g_AssetNameMap; +static bool g_AssetNameMapInit = false; + +void LoadAssetMap(athena::io::MemoryReader ar) +{ + if (!ar.hasError()) + { + hecl::FourCC magic = ar.readUint32Big(); + if (magic != FOURCC('AIDM')) + Log.report(logvisor::Error, _S("Unable to load asset map; Assets will not have proper filenames for most files.")); + else + { + uint32_t assetCount = ar.readUint32Big(); + for (uint32_t i = 0 ; i +#include +#include "DNACommon/DNACommon.hpp" + +namespace DataSpec +{ +namespace AssetNameMap +{ +void InitAssetNameMap(); +const std::string* TranslateIdToName(const UniqueID32&); +const std::string* TranslateIdToName(const UniqueID64&); +} +} +#endif // _DATASPEC_ASSETNAMEMAP_HPP_ diff --git a/DataSpec/CMakeLists.txt b/DataSpec/CMakeLists.txt index eaae74553..f3bfc9128 100644 --- a/DataSpec/CMakeLists.txt +++ b/DataSpec/CMakeLists.txt @@ -41,6 +41,20 @@ include(DNAMP3/CMakeLists.txt) # Embed master shader script bintoc(RetroMasterShader.c Blender/RetroMasterShader.py RETRO_MASTER_SHADER) +if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/AssetNameMap32.bin") + message(STATUS "Downloading 32bit ID map to '${CMAKE_CURRENT_BINARY_DIR}/AssetNameMap32.bin'") + file(DOWNLOAD "https://www.dropbox.com/s/8rzkxstfap6hgi3/AssetNameMap32.dat" + ${CMAKE_CURRENT_BINARY_DIR}/AssetNameMap32.bin SHOW_PROGRESS) +endif() +bintoc(AssetNameMap32.c ${CMAKE_CURRENT_BINARY_DIR}/AssetNameMap32.bin ASSET_NAME_MP32) + +if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/AssetNameMap64.bin") + message(STATUS "Downloading 64bit ID map to '${CMAKE_CURRENT_BINARY_DIR}/DNAMP3/AssetNameMap64.bin'") + file(DOWNLOAD "https://www.dropbox.com/s/o1pp3ctu5dyhfwx/AssetNameMap64.dat" + ${CMAKE_CURRENT_BINARY_DIR}/AssetNameMap64.bin SHOW_PROGRESS) +endif() +bintoc(AssetNameMap64.c ${CMAKE_CURRENT_BINARY_DIR}/AssetNameMap64.bin ASSET_NAME_MP64) + # Each game's DataSpec implementation add_library(RetroDataSpec SpecBase.cpp @@ -55,4 +69,8 @@ add_library(RetroDataSpec Blender/BlenderSupport.hpp Blender/BlenderSupport.cpp Blender/RetroMasterShader.py + AssetNameMap.hpp + AssetNameMap.cpp + AssetNameMap32.bin AssetNameMap32.c + AssetNameMap64.bin AssetNameMap64.c RetroMasterShader.c) diff --git a/DataSpec/SpecBase.cpp b/DataSpec/SpecBase.cpp index 911e7ef0c..d3395c734 100644 --- a/DataSpec/SpecBase.cpp +++ b/DataSpec/SpecBase.cpp @@ -8,6 +8,7 @@ #include "hecl/Blender/BlenderConnection.hpp" #include "DNACommon/DNACommon.hpp" #include "DNACommon/TXTR.hpp" +#include "AssetNameMap.hpp" #include #include @@ -38,6 +39,7 @@ SpecBase::SpecBase(const hecl::Database::DataSpecEntry* specEntry, hecl::Databas : hecl::Database::IDataSpec(specEntry), m_project(project), m_pc(pc), m_masterShader(project.getProjectWorkingPath(), ".hecl/RetroMasterShader.blend") { + AssetNameMap::InitAssetNameMap(); DataSpec::UniqueIDBridge::setThreadProject(m_project); }