Support Vtx Overlaps

This commit is contained in:
inspectredc
2025-07-04 17:41:27 -06:00
committed by Lywx
parent 5e334dc8c7
commit 59773d06d9
4 changed files with 20 additions and 11 deletions
+12 -6
View File
@@ -1405,12 +1405,7 @@ std::optional<std::uint32_t> Companion::GetFileOffsetFromSegmentedAddr(const uin
return std::nullopt;
}
std::optional<std::tuple<std::string, YAML::Node>> Companion::GetNodeByAddr(uint32_t addr){
if(!this->gAddrMap.contains(this->gCurrentFile)){
return std::nullopt;
}
// HACK: Adjust address to rom address if virtual address
uint32_t Companion::PatchVirtualAddr(uint32_t addr) {
if (addr & 0x80000000) {
if (gVirtualAddrMap.contains(gCurrentFile)) {
addr -= std::get<0>(gVirtualAddrMap[gCurrentFile]);
@@ -1418,6 +1413,17 @@ std::optional<std::tuple<std::string, YAML::Node>> Companion::GetNodeByAddr(uint
}
}
return addr;
}
std::optional<std::tuple<std::string, YAML::Node>> Companion::GetNodeByAddr(uint32_t addr){
if(!this->gAddrMap.contains(this->gCurrentFile)){
return std::nullopt;
}
// HACK: Adjust address to rom address if virtual address
addr = PatchVirtualAddr(addr);
if(!this->gAddrMap[this->gCurrentFile].contains(addr)){
for (auto &file : this->gCurrentExternalFiles) {
if (!this->gAddrMap.contains(file)) {
+1
View File
@@ -153,6 +153,7 @@ public:
std::optional<std::uint32_t> GetFileOffsetFromSegmentedAddr(uint8_t segment) const;
std::optional<std::shared_ptr<BaseFactory>> GetFactory(const std::string& type);
uint32_t PatchVirtualAddr(uint32_t addr);
std::optional<std::tuple<std::string, YAML::Node>> GetNodeByAddr(uint32_t addr);
std::optional<std::tuple<std::string, YAML::Node>> GetSafeNodeByAddr(const uint32_t addr, std::string type);
std::optional<std::vector<std::tuple<std::string, YAML::Node>>> GetNodesByType(const std::string& type);
+6 -5
View File
@@ -606,7 +606,8 @@ std::optional<std::shared_ptr<IParsedData>> DListFactory::parse(std::vector<uint
const auto decl = Companion::Instance->GetNodeByAddr(w1);
if(!decl.has_value()){
auto search = SearchVtx(w1);
auto adjPtr = Companion::Instance->PatchVirtualAddr(w1);
auto search = SearchVtx(adjPtr);
if(search.has_value()){
auto [path, vtx] = search.value();
@@ -617,14 +618,14 @@ std::optional<std::shared_ptr<IParsedData>> DListFactory::parse(std::vector<uint
auto lCount = GetSafeNode<uint32_t>(vtx, "count");
auto lSize = ALIGN16(lCount * sizeof(N64Vtx_t));
if(w1 > lOffset && w1 <= lOffset + lSize){
SPDLOG_INFO("Found vtx at 0x{:X} matching last vtx at 0x{:X}", w1, lOffset);
GFXDOverride::RegisterVTXOverlap(w1, search.value());
if(adjPtr > lOffset && adjPtr <= lOffset + lSize){
SPDLOG_INFO("Found vtx at 0x{:X} matching last vtx at 0x{:X}", adjPtr, lOffset);
GFXDOverride::RegisterVTXOverlap(adjPtr, search.value());
}
} else {
YAML::Node vtx;
vtx["type"] = "VTX";
vtx["offset"] = w1;
vtx["offset"] = adjPtr;
vtx["count"] = nvtx;
Companion::Instance->AddAsset(vtx);
}
+1
View File
@@ -52,6 +52,7 @@ void Quadrangle(const N64Gfx* gfx) {
}
int Vtx(uint32_t ptr, int32_t num) {
ptr = Companion::Instance->PatchVirtualAddr(ptr);
auto vtx = GetVtxOverlap(ptr);
if(vtx.has_value()){