From ce5bbf077db3f58165842b8f2a58938a7dab1ff0 Mon Sep 17 00:00:00 2001 From: John Peterson Date: Tue, 6 Jan 2009 01:52:16 +0000 Subject: [PATCH] MusicMod: Attached it to Wii games git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1802 8ced0084-cf51-0410-be5f-012b33b47a6e --- Branches/MusicMod/Main/Src/Main.cpp | 157 ++++++++++-------- Branches/MusicMod/Main/Src/Main.h | 4 +- .../Src/IPC_HLE/WII_IPC_HLE_Device_DI.cpp | 24 +++ Source/Core/DiscIO/Src/VolumeGC.cpp | 6 +- 4 files changed, 113 insertions(+), 78 deletions(-) diff --git a/Branches/MusicMod/Main/Src/Main.cpp b/Branches/MusicMod/Main/Src/Main.cpp index ed24b55dfe..c55fca0401 100644 --- a/Branches/MusicMod/Main/Src/Main.cpp +++ b/Branches/MusicMod/Main/Src/Main.cpp @@ -71,8 +71,9 @@ extern int GlobalVolume; -// --------------------------------------------------------------------------------------- +// ======================================================================================= // A function to sort the filelist table after offset +// ------------------------ void StructSort (std::vector &MyFiles) { MyFilesStructure temp; @@ -100,6 +101,8 @@ void StructSort (std::vector &MyFiles) //wprintf("StructSort > Done\n"); } +// ============================ + // ======================================================================================= /* Run these things once */ @@ -149,8 +152,7 @@ void Init() // ======================================================================================= -/* This will load Plainamp.dll. It's the original Plainamp.exe with removed GUI and some small - modifications. */ +/* This will read the GC file system. */ // ------------------------ void Main(std::string FileName) { @@ -205,8 +207,81 @@ bool CheckFileEnding(std::string FileName) // ======================================================================================= -// -void CheckFile(u64 offset, u64 size) +// Check if we should play this file +// --------------------------------------------------------------------------------------- +void CheckFile(std::string File, int FileNumber) +{ + // Do nothing if we found the same file again + if (currentfile == File) return; + + //wprintf(">>>> (%i)Current read %s <%u = %ux%i> \n", i, CurrentFiles[i].path.c_str(), offset, CurrentFiles[i].offset, size); + + if (CheckFileEnding(File.c_str())) + { + wprintf("\n >>> (%i/%i) Match %s\n\n", FileNumber, + MyFiles.size(), File.c_str()); + + currentfile = File; // save the found file + + // --------------------------------------------------------------------------------------- + // We will now save the file to the PC hard drive + // --------------------------------------------------------------------------------------- + // Get the filename + std::size_t pointer = File.find_last_of("\\"); + std::string fragment = File.substr (0, (pointer-0)); + int compare = File.length() - fragment.length(); // Get the length of the filename + fragment = File.substr ((pointer+1), compare); // Now we have the filename + + // --------------------------------------------------------------------------------------- + // Create the file path + std::string FilePath = (MusicPath + fragment); + // --------------------------------------------------------------------------------------- + WritingFile = true; // Avoid detecting the file we are writing + wprintf("Writing <%s> to <%s>\n", File.c_str(), FilePath.c_str()); + my_pFileSystem->ExportFile(File.c_str(), FilePath.c_str()); + WritingFile = false; + + // --------------------------------------------------------------------------------------- + // Play the file we found + if(dllloaded) + { + Player_Play((char*)FilePath.c_str()); // retype it from const char* to char* + } else { + wprintf("Warning > Music DLL is not loaded"); + } + + // --------------------------------------------------------------------------------------- + // Remove the last file, if any + if(CurrentPlayFile.length() > 0) + { + if(!remove(CurrentPlayFile.c_str())) + { + wprintf("The program failed to remove <%s>\n", CurrentPlayFile.c_str()); + } else { + wprintf("The program removed <%s>\n", CurrentPlayFile.c_str()); + } + } + + // --------------------------------------------------------------------------------------- + // Save the current playing file + CurrentPlayFile = FilePath; // Save the filename so we can remove it later + return; + // --------------------- + + } + + // Tell about the files we ignored + wprintf("(%i/%i) Ignored %s\n", FileNumber, MyFiles.size(), File.c_str()); + + // Update the current file + currentfile = File; +} + + +////////////////////////////////////////////////////////////////////////////////////////// +// Find the current filename for a certain offset on the GC fileystem +// ŻŻŻŻŻŻŻŻŻŻŻŻŻ +void FindFilename(u64 offset, u64 size) { // ======================================================================================= /* Only do this test: @@ -217,7 +292,6 @@ void CheckFile(u64 offset, u64 size) if(PowerPC::state == PowerPC::CPUState::CPU_RUNNING && offset != 0 && !WritingFile) { - ////////////////////////////////////////////////////////////////////////////////////////// /* Get the filename. Here we go through all files until we come to the file that has the matching offset. Before MyFiles has data this loop will go nowhere. We have to @@ -244,79 +318,16 @@ void CheckFile(u64 offset, u64 size) if (MyFiles[i + 1].offset >= offset || offset > MyFiles[MyFiles.size() - 1].offset) { // Now we know that the game is reading from MyFiles[i].path + CheckFile(MyFiles[i].path, i); - // Break if we found the same file again - if (currentfile == MyFiles[i].path) break; - - //wprintf(">>>> (%i)Current read %s <%u = %ux%i> \n", i, CurrentFiles[i].path.c_str(), offset, CurrentFiles[i].offset, size); - - if (CheckFileEnding(MyFiles[i].path.c_str())) - { - //u64 myoffset2 = (u32)offset; - wprintf("\n >>> (%i/%i) Match %s <%u = %ux%i> \n\n", i, - MyFiles.size(), MyFiles[i].path.c_str(), offset, MyFiles[i].offset, size); - //wprintf(">>>> [i + 1].offset %i", MyFiles[i + 1].offset); - currentfile = MyFiles[i].path; // save the found file - - // --------------------------------------------------------------------------------------- - // We will now save the file to the PC hard drive - // --------------------------------------------------------------------------------------- - // Get the filename - std::size_t pointer = MyFiles[i].path.find_last_of("\\"); - std::string fragment = MyFiles[i].path.substr (0, (pointer-0)); - int compare = MyFiles[i].path.length() - fragment.length(); // get the length of the filename - fragment = MyFiles[i].path.substr ((pointer+1), compare); // now we have the filename - - // --------------------------------------------------------------------------------------- - // Create the file path - std::string FilePath = (MusicPath + fragment); - // --------------------------------------------------------------------------------------- - WritingFile = true; // Avoid detecting the file we are writing - wprintf("Writing <%s> to <%s>\n", MyFiles[i].path.c_str(), FilePath.c_str()); - my_pFileSystem->ExportFile(MyFiles[i].path.c_str(), FilePath.c_str()); - WritingFile = false; - - // --------------------------------------------------------------------------------------- - // Play the file we found - if(dllloaded) - { - Player_Play((char*)FilePath.c_str()); // retype it from const char* to char* - } else { - wprintf("Warning > Music DLL is not loaded"); - } - - // --------------------------------------------------------------------------------------- - // Remove the last file, if any - if(CurrentPlayFile.length() > 0) - { - if(!remove(CurrentPlayFile.c_str())) - { - wprintf("The program failed to remove <%s>\n", CurrentPlayFile.c_str()); - } else { - wprintf("The program removed <%s>\n", CurrentPlayFile.c_str()); - } - } - - // --------------------------------------------------------------------------------------- - // Save the current playing file - CurrentPlayFile = FilePath; // Save the filename so we can remove it later - break; - // --------------------------------------------------------------------------------------- - - } - - // --------------------------------------------------------------------------------------- - // Tell about the files we ignored - wprintf("(%i/%i) Ignored %s <%u = %ux%i> \n", i, MyFiles.size(), MyFiles[i].path.c_str(), offset, MyFiles[i].offset, size); - currentfile = MyFiles[i].path; + // Stop checking break; - // --------------------------------------------------------------------------------------- } } } // This ends the entire filescan // ======================================================================================= - - } +///////////////////////////////// + } // end of namespace \ No newline at end of file diff --git a/Branches/MusicMod/Main/Src/Main.h b/Branches/MusicMod/Main/Src/Main.h index 69a9040834..92ea473507 100644 --- a/Branches/MusicMod/Main/Src/Main.h +++ b/Branches/MusicMod/Main/Src/Main.h @@ -25,7 +25,7 @@ namespace MusicMod { void Main(std::string FileName); -void CheckFile(u64 offset, u64 size); - +void FindFilename(u64 offset, u64 size); +void CheckFile(std::string File, int FileNumber = 0); } \ No newline at end of file diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_DI.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_DI.cpp index c3a8c6a508..e7491db8cf 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_DI.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_DI.cpp @@ -15,6 +15,10 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ + +////////////////////////////////////////////////////////////////////////////////////////// +// Include +// ŻŻŻŻŻŻŻŻŻŻ #include "Common.h" #include "WII_IPC_HLE_Device_DI.h" @@ -27,6 +31,17 @@ #include "VolumeCreator.h" #include "Filesystem.h" +/////////////////////////////////// + + +////////////////////////////////////////////////// +// Music mod +// ŻŻŻŻŻŻŻŻŻŻ +#include "../../../../Branches/MusicMod/Main/Src/Setup.h" // Define MUSICMOD here +#ifdef MUSICMOD +#include "../../../../Branches/MusicMod/Main/Src/Main.h" +#endif +/////////////////////// CWII_IPC_HLE_Device_di::CWII_IPC_HLE_Device_di(u32 _DeviceID, const std::string& _rDeviceName ) @@ -176,6 +191,15 @@ u32 CWII_IPC_HLE_Device_di::ExecuteCommand(u32 _BufferIn, u32 _BufferInSize, u32 PanicAlert("Cant read from DVD_Plugin - DVD-Interface: Fatal Error"); } + ////////////////////////////////////////////////// + // Music mod + // ŻŻŻŻŻŻŻŻŻŻ + #ifdef MUSICMOD + std::string Tmp = pFilename; + MusicMod::CheckFile(Tmp); + #endif + /////////////////////// + return 0x1; } break; diff --git a/Source/Core/DiscIO/Src/VolumeGC.cpp b/Source/Core/DiscIO/Src/VolumeGC.cpp index 03799fe809..1caf3ff4d6 100644 --- a/Source/Core/DiscIO/Src/VolumeGC.cpp +++ b/Source/Core/DiscIO/Src/VolumeGC.cpp @@ -48,9 +48,9 @@ bool CVolumeGC::Read(u64 _Offset, u64 _Length, u8* _pBuffer) const ////////////////////////////////////////////////// // Music mod // ŻŻŻŻŻŻŻŻŻŻ -#ifdef MUSICMOD - MusicMod::CheckFile(_Offset, _Length); -#endif + #ifdef MUSICMOD + MusicMod::FindFilename(_Offset, _Length); + #endif /////////////////////// return m_pReader->Read(_Offset, _Length, _pBuffer); }