From b2fee4242cd061a55e8f3bb2f6dfafbf9f87403f Mon Sep 17 00:00:00 2001 From: gm-matthew <108370479+gm-matthew@users.noreply.github.com> Date: Sat, 19 Aug 2023 23:47:00 +0100 Subject: [PATCH] DMA device register always returns Step 1.x PCI ID Step 2.x games by AM3 request PCI ID this way and expect to see 0x16c311db --- Src/Model3/Model3.cpp | 7 +------ Src/Model3/Real3D.cpp | 15 ++++++++------- Src/Model3/Real3D.h | 18 +++++++----------- 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/Src/Model3/Model3.cpp b/Src/Model3/Model3.cpp index 7b38e55..20acae9 100644 --- a/Src/Model3/Model3.cpp +++ b/Src/Model3/Model3.cpp @@ -2949,12 +2949,7 @@ bool CModel3::LoadGame(const Game &game, const ROMSet &rom_set) // Initialize Real3D int stepping = ((game.stepping[0] - '0') << 4) | (game.stepping[2] - '0'); - uint32_t real3DPCIID = game.real3d_pci_id; - if (0 == real3DPCIID) - { - real3DPCIID = stepping >= 0x20 ? CReal3D::PCIID::Step2x : CReal3D::PCIID::Step1x; - } - GPU.SetStepping(stepping, real3DPCIID); + GPU.SetStepping(stepping); // MPEG board (if present) if (rom_set.get_rom("mpeg_program").size) diff --git a/Src/Model3/Real3D.cpp b/Src/Model3/Real3D.cpp index a15ac6b..622dcda 100644 --- a/Src/Model3/Real3D.cpp +++ b/Src/Model3/Real3D.cpp @@ -27,10 +27,10 @@ * * PCI IDs * ------- - * It appears that Step 2.0 returns a different PCI ID depending on whether - * the PCI configuration space or DMA register are accessed. For example, - * Virtual On 2 expects 0x178611DB from the PCI configuration header but - * 0x16C311DB from the DMA device. + * It appears that accessing the PCI configuration space returns the PCI ID + * of Mercury (0x16C311DB) on Step 1.x and the DMA device (0x178611DB) on + * Step 2.x, while accessing the Step 2.x DMA device register returns the + * PCI ID of Mercury. Step 2.x games by AM3 expect this behavior. * * To-Do List * ---------- @@ -628,7 +628,8 @@ void CReal3D::WriteDMARegister32(unsigned reg, uint32_t data) case 0x10: // command register if ((data&0x20000000)) // DMA ID command { - dmaData = pciID; + // Games requesting PCI ID via the DMA device expect 0x16C311DB, even on step 2.x boards + dmaData = PCIID::Step1x; DebugLog("Real3D: DMA ID command issued (ATTENTION: make sure we're returning the correct value), PC=%08X, LR=%08X\n", ppc_get_pc(), ppc_get_lr()); } else if ((data&0x80000000)) @@ -921,7 +922,7 @@ uint32_t CReal3D::GetASICIDCode(ASIC asic) const return it == m_asicID.end() ? 0 : it->second; } -void CReal3D::SetStepping(int stepping, uint32_t pciIDValue) +void CReal3D::SetStepping(int stepping) { step = stepping; if ((step!=0x10) && (step!=0x15) && (step!=0x20) && (step!=0x21)) @@ -931,7 +932,7 @@ void CReal3D::SetStepping(int stepping, uint32_t pciIDValue) } // Set PCI ID - pciID = pciIDValue; + pciID = stepping >= 0x20 ? PCIID::Step2x : PCIID::Step1x; // Pass to renderer if (Render3D != NULL) diff --git a/Src/Model3/Real3D.h b/Src/Model3/Real3D.h index 3013924..7eddb66 100644 --- a/Src/Model3/Real3D.h +++ b/Src/Model3/Real3D.h @@ -68,10 +68,11 @@ public: /* * PCI IDs * - * The CReal3D object must be configured with the desired ID. Some Step 2.x - * appear to defy this and expect the 1.x ID. The symptom of this is that - * VBL is enabled briefly then disabled. This should be investigated further. - * Perhaps a different ASIC's PCI ID is being read in these situations? + * The CReal3D object must be configured with the PCI ID of the ASIC directly + * connected to the PCI slot; 0x16c311db for Step 1.x, 0x178611db for Step + * 2.x. Requesting PCI ID via the DMA device on Step 2.x appears to return + * the PCI ID of Mercury which is the ASIC connected to the PCI slot on Step + * 1.x, hence why some Step 2.x games appear to expect the 1.x ID. * * The vendor ID code 0x11db is Sega's. */ @@ -374,7 +375,7 @@ public: uint32_t GetASICIDCode(ASIC asic) const; /* - * SetStepping(stepping, pciIDValue): + * SetStepping(stepping): * * Sets the Model 3 hardware stepping, which also determines the Real3D * functionality. The default is Step 1.0. This should be called prior to @@ -383,13 +384,8 @@ public: * Parameters: * stepping 0x10 for Step 1.0, 0x15 for Step 1.5, 0x20 for Step 2.0, or * 0x21 for Step 2.1. Anything else defaults to 1.0. - * pciIDValue The PCI ID code to return. This should be one of the PCIID - * enum values otherwise games may fail to boot. Although the - * PCI ID depends on stepping, there are a few games that - * have to be explicitly configured with an older ID code, - * which is why this parameter is exposed. */ - void SetStepping(int stepping, uint32_t pciIDValue); + void SetStepping(int stepping); /*