From d9d292fd1c72f83b15bb834b24be5857e836d315 Mon Sep 17 00:00:00 2001 From: Rachel Bryk Date: Sun, 6 Apr 2014 09:28:44 -0400 Subject: [PATCH] Add dsp rom hashes to movie header. Also fix a random typo. --- Source/Core/Core/DSP/DSPCore.cpp | 2 +- Source/Core/Core/Movie.cpp | 41 ++++++++++++++++++++++++++++++++ Source/Core/Core/Movie.h | 4 +++- 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/DSP/DSPCore.cpp b/Source/Core/Core/DSP/DSPCore.cpp index 520db9ac49..a8932e4101 100644 --- a/Source/Core/Core/DSP/DSPCore.cpp +++ b/Source/Core/Core/DSP/DSPCore.cpp @@ -74,7 +74,7 @@ static bool LoadRom(const std::string& fname, int size_in_words, u16 *rom) return false; } -// Returns false iff the hash fails and the user hits "Yes" +// Returns false if the hash fails and the user hits "Yes" static bool VerifyRoms(const std::string& irom_filename, const std::string& coef_filename) { struct DspRomHashes diff --git a/Source/Core/Core/Movie.cpp b/Source/Core/Core/Movie.cpp index bc13a76be6..a08d2c7a2a 100644 --- a/Source/Core/Core/Movie.cpp +++ b/Source/Core/Core/Movie.cpp @@ -4,7 +4,9 @@ #include +#include "Common/CommonPaths.h" #include "Common/FileUtil.h" +#include "Common/Hash.h" #include "Common/NandPaths.h" #include "Common/Thread.h" #include "Common/Timer.h" @@ -14,6 +16,7 @@ #include "Core/Movie.h" #include "Core/NetPlayProto.h" #include "Core/State.h" +#include "Core/DSP/DSPCore.h" #include "Core/HW/DVDInterface.h" #include "Core/HW/EXI.h" #include "Core/HW/EXI_Channel.h" @@ -63,6 +66,8 @@ u64 g_titleID = 0; unsigned char MD5[16]; u8 bongos; u8 revision[20]; +u32 DSPiromHash = 0; +u32 DSPcoefHash = 0; bool g_bRecordingFromSaveState = false; bool g_bPolled = false; @@ -709,6 +714,8 @@ void ReadHeader() g_discChange = (char*) tmpHeader.discChange; author = (char*) tmpHeader.author; memcpy(MD5, tmpHeader.md5, 16); + DSPiromHash = tmpHeader.DSPiromHash; + DSPcoefHash = tmpHeader.DSPcoefHash; } bool PlayInput(const std::string& filename) @@ -1134,6 +1141,8 @@ void SaveRecording(const std::string& filename) memcpy(header.md5,MD5,16); header.bongos = bongos; memcpy(header.revision, revision, ArraySize(header.revision)); + header.DSPiromHash = DSPiromHash; + header.DSPcoefHash = DSPcoefHash; // TODO header.uniqueID = 0; @@ -1198,6 +1207,38 @@ void GetSettings() sscanf(&scm_rev_git_str[2 * i], "%02hhx", &tmp[i]); revision[i] = tmp[i]; } + if (!bDSPHLE) + { + std::string irom_file = File::GetUserPath(D_GCUSER_IDX) + DSP_IROM; + std::string coef_file = File::GetUserPath(D_GCUSER_IDX) + DSP_COEF; + + if (!File::Exists(irom_file)) + irom_file = File::GetSysDirectory() + GC_SYS_DIR DIR_SEP DSP_IROM; + if (!File::Exists(coef_file)) + coef_file = File::GetSysDirectory() + GC_SYS_DIR DIR_SEP DSP_COEF; + std::vector irom(DSP_IROM_SIZE); + File::IOFile file_irom(irom_file, "rb"); + + file_irom.ReadArray(irom.data(), DSP_IROM_SIZE); + file_irom.Close(); + for (int i = 0; i < DSP_IROM_SIZE; i++) + irom[i] = Common::swap16(irom[i]); + + std::vector coef(DSP_COEF_SIZE); + File::IOFile file_coef(coef_file, "rb"); + + file_coef.ReadArray(coef.data(), DSP_COEF_SIZE); + file_coef.Close(); + for (int i = 0; i < DSP_COEF_SIZE; i++) + coef[i] = Common::swap16(coef[i]); + DSPiromHash = HashAdler32((u8*)irom.data(), DSP_IROM_BYTE_SIZE); + DSPcoefHash = HashAdler32((u8*)coef.data(), DSP_COEF_BYTE_SIZE); + } + else + { + DSPiromHash = 0; + DSPcoefHash = 0; + } } void CheckMD5() diff --git a/Source/Core/Core/Movie.h b/Source/Core/Core/Movie.h index a317b0b01b..91830a8143 100644 --- a/Source/Core/Core/Movie.h +++ b/Source/Core/Core/Movie.h @@ -114,7 +114,9 @@ struct DTMHeader u8 reserved[13]; // Padding for any new config options u8 discChange[40]; // Name of iso file to switch to, for two disc games. u8 revision[20]; // Git hash - u8 reserved2[27]; // Make heading 256 bytes, just because we can + u32 DSPiromHash; + u32 DSPcoefHash; + u8 reserved2[19]; // Make heading 256 bytes, just because we can }; static_assert(sizeof(DTMHeader) == 256, "DTMHeader should be 256 bytes");