From b0e8755afc915589a7c2f58c43538a522fe278fc Mon Sep 17 00:00:00 2001 From: Bart Trzynadlowski Date: Wed, 6 Jul 2011 05:07:04 +0000 Subject: [PATCH] Added Spikeout protection data. Added code to detect and abort erroneous 0-length texture transfers (was causing Spikeout to hang the emulator). --- Src/Model3/Model3.cpp | 26 ++++++++++++++++++++++---- Src/Model3/Real3D.cpp | 8 ++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/Src/Model3/Model3.cpp b/Src/Model3/Model3.cpp index 472bb53..dfb8d4a 100644 --- a/Src/Model3/Model3.cpp +++ b/Src/Model3/Model3.cpp @@ -504,6 +504,17 @@ void CModel3::WriteInputs(unsigned reg, UINT8 data) data from it. ******************************************************************************/ +static const UINT16 spikeoutSecurity[] = +{ + 0x0000, + 0x4f4d, 0x4544, 0x2d4c, 0x2033, 0x7953, 0x7473, 0x6d65, 0x5020, + 0x6f72, 0x7267, 0x6d61, 0x4320, 0x706f, 0x7279, 0x6769, 0x7468, + 0x2820, 0x2943, 0x3120, 0x3939, 0x2035, 0x4553, 0x4147, 0x4520, + 0x746e, 0x7265, 0x7270, 0x7369, 0x7365, 0x4c2c, 0x4454, 0x202e, + 0x6c41, 0x206c, 0x6972, 0x6867, 0x2074, 0x6572, 0x6573, 0x7672, + 0x6465, 0x202e, 0x2020, 0x0020 +}; + static const UINT16 vs298Security[] = { 0x0000, // dummy read @@ -578,7 +589,12 @@ UINT32 CModel3::ReadSecurity(unsigned reg) return 0; case 0x1C: // Data - if (!strcmp(Game->id, "vs298")) + if (!strcmp(Game->id, "spikeout")) + { + data = (spikeoutSecurity[securityPtr++] << 16); + securityPtr %= (sizeof(spikeoutSecurity)/sizeof(UINT16)); + } + else if (!strcmp(Game->id, "vs298")) { data = (vs298Security[securityPtr++] << 16); securityPtr %= (sizeof(vs298Security)/sizeof(UINT16)); @@ -1859,9 +1875,7 @@ void CModel3::ClearNVRAM(void) } void CModel3::RunFrame(void) -{ - printf("cmdbuf=%08X %08X %08X %08X %08X %08X %08X %08X\n", Read32(0x100180), Read32(0x100184), Read32(0x100188), Read32(0x10018C), Read32(0x100190), Read32(0x100194), Read32(0x100198), Read32(0x10019C)); - +{ // Run the PowerPC for a frame ppc_execute(ppcFrequency/60-10000); @@ -1888,6 +1902,10 @@ void CModel3::RunFrame(void) } SoundBoard.RunFrame(); IRQ.Deassert(0x40); + + + // Print out sound command buffer in Scud Race RAM + printf("cmdbuf=%08X %08X %08X %08X %08X %08X %08X %08X\n", Read32(0x100180), Read32(0x100184), Read32(0x100188), Read32(0x10018C), Read32(0x100190), Read32(0x100194), Read32(0x100198), Read32(0x10019C)); #endif // End frame diff --git a/Src/Model3/Real3D.cpp b/Src/Model3/Real3D.cpp index 6c7478d..ce380cf 100644 --- a/Src/Model3/Real3D.cpp +++ b/Src/Model3/Real3D.cpp @@ -674,6 +674,14 @@ void CReal3D::Flush(void) size = 2+textureFIFO[i+0]/2; size /= 4; header = textureFIFO[i+1]; // texture information header + + // Spikeout seems to be uploading 0 length textures + if (0 == size) + { + DebugLog("Real3D: 0-length texture upload @ PC=%08X (%08X %08X %08X)\n", ppc_get_pc(), textureFIFO[i+0], textureFIFO[i+1], textureFIFO[i+2]); + break; + } + UploadTexture(header,(UINT16 *)&textureFIFO[i+2]); DebugLog("Real3D: Texture upload completed: %X bytes (%X)\n", size*4, textureFIFO[i+0]); i += size;