From ad1c540d6ed1b2888bb780ae6bd14941af13e648 Mon Sep 17 00:00:00 2001 From: Dario Date: Sun, 21 Jul 2024 17:18:35 -0300 Subject: [PATCH] Add unaligned load support for vertex PD, fix edge case in sync requirement detection. --- src/gbi/rt64_gbi.cpp | 7 +++++-- src/hle/rt64_rsp.cpp | 12 ++++++++---- src/hle/rt64_rsp.h | 3 ++- src/hle/rt64_state.cpp | 1 - 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/gbi/rt64_gbi.cpp b/src/gbi/rt64_gbi.cpp index fd6e175..b263a4b 100644 --- a/src/gbi/rt64_gbi.cpp +++ b/src/gbi/rt64_gbi.cpp @@ -44,6 +44,7 @@ namespace RT64 { // Constant Identifier UCode LowP NoN ReJ MVP Point // const GBIInstance F3D_SM64 = { "SW Version: 2.0D, 04-01-96 (SM64)", GBIUCode::F3D, { false, false, false, false, false } }; + const GBIInstance F3D_PD = { "SW Version: Unknown (PD)", GBIUCode::F3DPD, { false, false, false, false, false } }; const GBIInstance F3DEX_1_21 = { "F3DEX 1.21", GBIUCode::F3DEX, { false, false, false, false, false } }; const GBIInstance F3DLX_1_21_REJ = { "F3DLX 1.21.Rej", GBIUCode::F3DEX, { true, false, true, false, false } }; const GBIInstance F3DEX_1_23 = { "F3DEX 1.23", GBIUCode::F3DEX, { false, false, false, false, false } }; @@ -71,8 +72,9 @@ namespace RT64 { // // Length Hash Known instances // - static std::array textSegments = { + static std::array textSegments = { GBISegment{ 0x1408, 0xF50165C013FCB8A2ULL, { &F3D_SM64 } }, + GBISegment{ 0x1418, 0xAEBF9966DD0486DDULL, { &F3D_PD } }, GBISegment{ 0x1430, 0x9A7772037D709388ULL, { &F3DEX_1_21 } }, GBISegment{ 0x13D0, 0x1BEA638E869B0195ULL, { &F3DLX_1_21_REJ } }, // Needs confirmation. GBISegment{ 0x1430, 0xAC03DE5B7B1E710FULL, { &F3DEX_1_23 } }, @@ -95,8 +97,9 @@ namespace RT64 { GBISegment{ 0x18C0, 0x9300F34F3B438634ULL, { &S2DEX2_FIFO_2_08 } }, }; - static std::array dataSegments = { + static std::array dataSegments = { GBISegment{ 0x800, 0x276AC049785A7E70ULL, { &F3D_SM64 } }, + GBISegment{ 0x800, 0x72AD2373CEC74AA7ULL, { &F3D_PD } }, GBISegment{ 0x800, 0x4B5FDED20C137EC1ULL, { &F3DEX_1_21 } }, GBISegment{ 0x800, 0x3828B4F75B0A0E6AULL, { &F3DEX_1_23 } }, GBISegment{ 0x800, 0x484C6940F5072C39ULL, { &F3DLX_1_21_REJ } }, // Needs confirmation. diff --git a/src/hle/rt64_rsp.cpp b/src/hle/rt64_rsp.cpp index 871e1c1..15eb4e8 100644 --- a/src/hle/rt64_rsp.cpp +++ b/src/hle/rt64_rsp.cpp @@ -91,11 +91,11 @@ namespace RT64 { } // Masks addresses as the RSP DMA hardware would. - uint32_t RSP::maskPhysicalAddress(uint32_t address) { + template uint32_t RSP::maskPhysicalAddress(uint32_t address) { if (state->extended.extendRDRAM && ((address & 0xF0000000) == 0x80000000)) { return address - 0x80000000; } - return address & 0x00FFFFF8; + return address & mask; } // Performs a lookup in the segment table to convert the given address. @@ -109,7 +109,11 @@ namespace RT64 { // Converts the given segmented address and then applies the RSP DMA physical address mask. // Used in cases where the RSP performs a DMA with a segmented address as the input. uint32_t RSP::fromSegmentedMasked(uint32_t segAddress) { - return maskPhysicalAddress(fromSegmented(segAddress)); + return maskPhysicalAddress<0x00FFFFF8>(fromSegmented(segAddress)); + } + + uint32_t RSP::fromSegmentedMaskedPD(uint32_t segAddress) { + return maskPhysicalAddress<0x00FFFFFC>(fromSegmented(segAddress)); } void RSP::setSegment(uint32_t seg, uint32_t address) { @@ -324,7 +328,7 @@ namespace RT64 { return; } - const uint32_t rdramAddress = fromSegmentedMasked(address); + const uint32_t rdramAddress = fromSegmentedMaskedPD(address); const VertexPD *dlVerts = reinterpret_cast(state->fromRDRAM(rdramAddress)); for (uint32_t i = 0; i < vtxCount; i++) { Vertex &dst = vertices[dstIndex + i]; diff --git a/src/hle/rt64_rsp.h b/src/hle/rt64_rsp.h index f6563ab..ba8f7d8 100644 --- a/src/hle/rt64_rsp.h +++ b/src/hle/rt64_rsp.h @@ -221,9 +221,10 @@ namespace RT64 { void reset(); Projection::Type getCurrentProjectionType() const; void addCurrentProjection(Projection::Type type); - uint32_t maskPhysicalAddress(uint32_t address); + template uint32_t maskPhysicalAddress(uint32_t address); uint32_t fromSegmented(uint32_t segAddress); uint32_t fromSegmentedMasked(uint32_t segAddress); + uint32_t fromSegmentedMaskedPD(uint32_t segAddress); void setSegment(uint32_t seg, uint32_t address); void matrix(uint32_t address, uint8_t params); void popMatrix(uint32_t count); diff --git a/src/hle/rt64_state.cpp b/src/hle/rt64_state.cpp index 2b15096..5d8d3cc 100644 --- a/src/hle/rt64_state.cpp +++ b/src/hle/rt64_state.cpp @@ -975,7 +975,6 @@ namespace RT64 { const DrawCallTile &callTile = callTiles[callDesc.tileIndex + t]; if (callTile.rawTMEM) { flags.canDecodeTMEM = true; - break; } if (callTile.syncRequired && !callTile.tileCopyUsed) {