From be0de1ee26612a901b9159d9b936dd20b8f8aa44 Mon Sep 17 00:00:00 2001 From: jpd002 Date: Fri, 14 Nov 2008 17:10:21 +0000 Subject: [PATCH] PsfPlayer v0.16 git-svn-id: http://svn.purei.org/purei/trunk@416 b36208d7-6611-0410-8bec-b1987f11c4a2 --- Source/iop/IopBios.cpp | 15 +++++++---- Source/iop/IopBios.h | 2 +- Source/iop/Iop_SifMan.cpp | 46 ++++++++++++++++++++++++++++++++ Source/iop/Iop_Sifman.h | 18 +++++++++---- Source/iop/Iop_SpuBase.cpp | 11 ++++++++ Source/iop/Iop_SpuBase.h | 1 + Source/iop/Iop_Thbase.cpp | 9 ++++++- tools/PsfPlayer2/Source/AppDef.h | 4 +-- tools/PsfPlayer2/Tester.vcproj | 6 ++++- tools/PsfPlayer2/Todolist.txt | 4 +-- 10 files changed, 98 insertions(+), 18 deletions(-) create mode 100644 Source/iop/Iop_SifMan.cpp diff --git a/Source/iop/IopBios.cpp b/Source/iop/IopBios.cpp index 3fc5f73d1..da20c5dda 100644 --- a/Source/iop/IopBios.cpp +++ b/Source/iop/IopBios.cpp @@ -65,7 +65,6 @@ CIopBios::~CIopBios() SaveAllModulesTags(m_cpu.m_Functions, "functions"); #endif DeleteModules(); - delete m_sifMan; } void CIopBios::Reset() @@ -122,6 +121,9 @@ void CIopBios::Reset() { RegisterModule(new Iop::CIntrman(*this, m_ram)); } + { + RegisterModule(m_sifMan); + } #ifdef _IOP_EMULATE_MODULES { RegisterModule(new Iop::CFileIo(*m_sifMan, *m_ioman)); @@ -403,7 +405,7 @@ uint32 CIopBios::WakeupThread(uint32 threadId, bool inInterrupt) return thread.wakeupCount; } -uint32 CIopBios::GetThreadId() +uint32 CIopBios::GetCurrentThreadId() { return m_currentThreadId; } @@ -477,6 +479,12 @@ void CIopBios::Reschedule() { LoadThreadContext(nextThreadId); } +#ifdef _DEBUG + if(nextThreadId != m_currentThreadId) + { + CLog::GetInstance().Print(LOGNAME, "Switched over to thread %i.\r\n", nextThreadId); + } +#endif m_currentThreadId = nextThreadId; m_cpu.m_nQuota = 1; } @@ -733,9 +741,6 @@ void CIopBios::HandleException() } else { - //Hack for FFX PSF --------------------- - //m_cpu.m_State.nGPR[CMIPS::V0].nD0 = 1; - //Hack for FFX PSF --------------------- #ifdef _DEBUG CLog::GetInstance().Print(LOGNAME, "%0.8X: Trying to call a function from non-existing module (%s, %d).\r\n", m_cpu.m_State.nPC, moduleName.c_str(), functionId); diff --git a/Source/iop/IopBios.h b/Source/iop/IopBios.h index a1d8dc3a5..f566f14f2 100644 --- a/Source/iop/IopBios.h +++ b/Source/iop/IopBios.h @@ -43,7 +43,7 @@ public: uint32 CreateThread(uint32, uint32); void StartThread(uint32, uint32* = NULL); void DelayThread(uint32); - uint32 GetThreadId(); + uint32 GetCurrentThreadId(); void SleepThread(); uint32 WakeupThread(uint32, bool); diff --git a/Source/iop/Iop_SifMan.cpp b/Source/iop/Iop_SifMan.cpp new file mode 100644 index 000000000..4be3b4531 --- /dev/null +++ b/Source/iop/Iop_SifMan.cpp @@ -0,0 +1,46 @@ +#include "Iop_SifMan.h" +#include "../Log.h" + +#define LOG_NAME ("iop_sifman") + +using namespace Iop; +using namespace std; + +CSifMan::CSifMan() +{ + +} + +CSifMan::~CSifMan() +{ + +} + +string CSifMan::GetId() const +{ + return "sifman"; +} + +void CSifMan::Invoke(CMIPS& context, unsigned int functionId) +{ + switch(functionId) + { + case 7: + context.m_State.nGPR[CMIPS::V0].nD0 = static_cast(SifSetDma( + context.m_State.nGPR[CMIPS::A0].nV0, + context.m_State.nGPR[CMIPS::A1].nV0 + )); + break; + default: + CLog::GetInstance().Print(LOG_NAME, "%0.8X: Unknown function (%d) called.", context.m_State.nPC, functionId); + break; + } +} + +uint32 CSifMan::SifSetDma(uint32 structAddr, uint32 length) +{ + CLog::GetInstance().Print(LOG_NAME, "SifSetDma(structAddr = 0x%0.8X, length = %X);\r\n", + structAddr, length); + return 1; +} + diff --git a/Source/iop/Iop_Sifman.h b/Source/iop/Iop_Sifman.h index 5e070917c..777b03068 100644 --- a/Source/iop/Iop_Sifman.h +++ b/Source/iop/Iop_Sifman.h @@ -2,17 +2,25 @@ #define _IOP_SIFMAN_H_ #include "../SifModule.h" +#include "Iop_Module.h" namespace Iop { - class CSifMan + class CSifMan : public CModule { public: - virtual ~CSifMan() {} + CSifMan(); + virtual ~CSifMan(); - virtual void RegisterModule(uint32, CSifModule*) = 0; - virtual void SendPacket(void*, uint32) = 0; - virtual void SetDmaBuffer(uint8*, uint32) = 0; + virtual std::string GetId() const; + virtual void Invoke(CMIPS&, unsigned int); + + virtual void RegisterModule(uint32, CSifModule*) = 0; + virtual void SendPacket(void*, uint32) = 0; + virtual void SetDmaBuffer(uint8*, uint32) = 0; + + private: + uint32 SifSetDma(uint32, uint32); }; } diff --git a/Source/iop/Iop_SpuBase.cpp b/Source/iop/Iop_SpuBase.cpp index 3bf8996ed..c25419505 100644 --- a/Source/iop/Iop_SpuBase.cpp +++ b/Source/iop/Iop_SpuBase.cpp @@ -256,6 +256,12 @@ void CSpuBase::Render(int16* samples, unsigned int sampleCount, unsigned int sam } else { + if(reader.IsDone()) + { + channel.status = STOPPED; + channel.adsrVolume = 0; + continue; + } uint8* repeat = reader.GetRepeat(); channel.repeat = repeat - m_ram; } @@ -726,6 +732,11 @@ uint8* CSpuBase::CSampleReader::GetCurrent() const return m_nextSample; } +bool CSpuBase::CSampleReader::IsDone() const +{ + return m_done; +} + double CSpuBase::CSampleReader::GetSamplingRate() const { return m_sourceSamplingRate; diff --git a/Source/iop/Iop_SpuBase.h b/Source/iop/Iop_SpuBase.h index 36e2815b7..10af80015 100644 --- a/Source/iop/Iop_SpuBase.h +++ b/Source/iop/Iop_SpuBase.h @@ -192,6 +192,7 @@ namespace Iop void GetSamples(int16*, unsigned int, unsigned int); uint8* GetRepeat() const; uint8* GetCurrent() const; + bool IsDone() const; private: enum diff --git a/Source/iop/Iop_Thbase.cpp b/Source/iop/Iop_Thbase.cpp index cabcfdeb6..c05358e1b 100644 --- a/Source/iop/Iop_Thbase.cpp +++ b/Source/iop/Iop_Thbase.cpp @@ -1,9 +1,12 @@ #include "Iop_Thbase.h" #include "IopBios.h" +#include "../Log.h" using namespace Iop; using namespace std; +#define LOG_NAME ("iop_thbase") + CThbase::CThbase(CIopBios& bios, uint8* ram) : m_ram(ram), m_bios(bios) @@ -87,7 +90,7 @@ uint32 CThbase::DelayThread(uint32 delay) uint32 CThbase::GetThreadId() { - return m_bios.GetThreadId(); + return m_bios.GetCurrentThreadId(); } uint32 CThbase::SleepThread() @@ -108,6 +111,10 @@ uint32 CThbase::iWakeupThread(uint32 threadId) uint32 CThbase::GetSystemTime(uint32 resultAddr) { +#ifdef _DEBUG + CLog::GetInstance().Print(LOG_NAME, "%d : GetSystemTime(result);\r\n", + m_bios.GetCurrentThreadId()); +#endif uint64* result = NULL; if(resultAddr != 0) { diff --git a/tools/PsfPlayer2/Source/AppDef.h b/tools/PsfPlayer2/Source/AppDef.h index f427bab2c..6d7eaccc7 100644 --- a/tools/PsfPlayer2/Source/AppDef.h +++ b/tools/PsfPlayer2/Source/AppDef.h @@ -2,7 +2,7 @@ #define _APPDEF_H_ #define APP_NAME _T("PsfPlayer") -#define APP_VERSION (16) -#define APP_VERSIONSTR _T("0.16") +#define APP_VERSION (17) +#define APP_VERSIONSTR _T("0.17") #endif diff --git a/tools/PsfPlayer2/Tester.vcproj b/tools/PsfPlayer2/Tester.vcproj index c2d28c7d7..2da636465 100644 --- a/tools/PsfPlayer2/Tester.vcproj +++ b/tools/PsfPlayer2/Tester.vcproj @@ -41,7 +41,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories=""C:\Program Files\OpenAL 1.1 SDK\include";C:\Projects\Rawr\Source;C:\Projects\zlib;C:\Components\boost_1_35_0\boost\tr1\tr1;C:\Components\boost_1_35_0;C:\Projects\Framework\include;C:\Projects\Rawr\tools\PsfPlayer2\Source" - PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_MSVC;_PSX;_NULL_SIFMAN;DEBUGGER_INCLUDED" + PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_MSVC;_PSX;_NULL_SIFMAN" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="3" @@ -700,6 +700,10 @@ RelativePath="..\..\Source\iop\Iop_RootCounters.h" > + + diff --git a/tools/PsfPlayer2/Todolist.txt b/tools/PsfPlayer2/Todolist.txt index 022cbfec4..17fcbfa46 100644 --- a/tools/PsfPlayer2/Todolist.txt +++ b/tools/PsfPlayer2/Todolist.txt @@ -1,11 +1,9 @@ TODO: +- Final Fantasy 7 - Still More Fighting - Cymbals sound not fading? - Reverb for SPU2 - Reverb enable option -- Support for both SPU cores. - Fix nasty bug with PSX sound files and home computer. -- Atelier Iris - Final Fantasy X -- Seperate Ioman and Fileio modules. - Exception for invalid PSFs - 32-bits MA_MIPSIV support