diff --git a/Source/Common/Trace.cpp b/Source/Common/Trace.cpp index 314b53dc7..d0eb4d238 100644 --- a/Source/Common/Trace.cpp +++ b/Source/Common/Trace.cpp @@ -111,6 +111,7 @@ void CTraceLog::WriteTrace ( TraceType Type, LPCTSTR Message) else if ((Type & TraceRSP )!= 0) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("RSP : ")); } else if ((Type & TraceTLB )!= 0) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("TLB : ")); } else if ((Type & TraceValidate )!= 0) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("Valid : ")); } + else if ((Type & TraceAudio )!= 0) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("Audio : ")); } else { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("Unknown: ")); } for (int i = 0; i < (int)m_Modules.size(); i++ ) diff --git a/Source/Common/TraceDefs.h b/Source/Common/TraceDefs.h index 427bc9555..622fd126a 100644 --- a/Source/Common/TraceDefs.h +++ b/Source/Common/TraceDefs.h @@ -12,6 +12,7 @@ enum TraceType TraceRSP = 0x00000040, TraceTLB = 0x00000080, TraceValidate = 0x00000100, + TraceAudio = 0x00000200, TraceNoHeader = 0x80000000, }; diff --git a/Source/Project64/N64 System/Mips/Audio.cpp b/Source/Project64/N64 System/Mips/Audio.cpp index 05c2f7cd5..a5a1b614c 100644 --- a/Source/Project64/N64 System/Mips/Audio.cpp +++ b/Source/Project64/N64 System/Mips/Audio.cpp @@ -11,7 +11,6 @@ CAudio::~CAudio (void) void CAudio::Reset ( void ) { - m_CurrentLength = 0; m_SecondBuff = 0; m_Status = 0; m_BytesPerSecond = 0; @@ -36,18 +35,20 @@ DWORD CAudio::GetStatus ( void ) void CAudio::LenChanged ( void ) { + WriteTraceF(TraceAudio,__FUNCTION__ ": _Reg->AI_LEN_REG = %d",_Reg->AI_LEN_REG); if (_Reg->AI_LEN_REG != 0) { - if (m_CurrentLength == 0) { + DWORD NewLength = GetLength() + _Reg->AI_LEN_REG; + _SystemTimer->SetTimer(CSystemTimer::AiTimer,NewLength * m_CountsPerByte,false); + WriteTraceF(TraceAudio,__FUNCTION__ ": NewLength = %d",NewLength); + /*if (m_CurrentLength == 0) { m_CurrentLength = _Reg->AI_LEN_REG; - _SystemTimer->SetTimer(CSystemTimer::AiTimer,m_CurrentLength * m_CountsPerByte,false); } else { m_SecondBuff = _Reg->AI_LEN_REG; - m_Status |= 0x80000000; - } + //m_Status |= 0x80000000; + }*/ } else { _SystemTimer->StopTimer(CSystemTimer::AiTimer); - m_CurrentLength = 0; m_SecondBuff = 0; m_Status = 0; } @@ -60,7 +61,7 @@ void CAudio::LenChanged ( void ) void CAudio::TimerDone ( void ) { - _Reg->MI_INTR_REG |= MI_INTR_AI; + /*_Reg->MI_INTR_REG |= MI_INTR_AI; _Reg->CheckInterrupts(); if (m_SecondBuff != 0) { @@ -69,6 +70,8 @@ void CAudio::TimerDone ( void ) m_CurrentLength = m_SecondBuff; m_SecondBuff = 0; m_Status &= 0x7FFFFFFF; +*/ + m_SecondBuff = 0; } void CAudio::SetViIntr ( DWORD VI_INTR_TIME ) @@ -83,6 +86,7 @@ void CAudio::SetViIntr ( DWORD VI_INTR_TIME ) void CAudio::SetFrequency (DWORD Dacrate, DWORD System) { + WriteTraceF(TraceAudio,__FUNCTION__ "(Dacrate: %X System: %d): AI_BITRATE_REG = %X",Dacrate,System,_Reg->AI_BITRATE_REG); DWORD Frequency; switch (System) { @@ -93,6 +97,8 @@ void CAudio::SetFrequency (DWORD Dacrate, DWORD System) //nBlockAlign = 16 / 8 * 2; m_BytesPerSecond = Frequency * 4; + m_BytesPerSecond = 194532; + m_BytesPerSecond = 128024; if (System == SYSTEM_PAL) { m_FramesPerSecond = 50; diff --git a/Source/Project64/N64 System/Mips/Audio.h b/Source/Project64/N64 System/Mips/Audio.h index dca317c5c..2125d4014 100644 --- a/Source/Project64/N64 System/Mips/Audio.h +++ b/Source/Project64/N64 System/Mips/Audio.h @@ -12,20 +12,10 @@ public: void SetViIntr ( DWORD VI_INTR_TIME ); void SetFrequency ( DWORD Dacrate, DWORD System ); -/* void AiCallBack ( void ); - void UpdateAudioTimer ( DWORD CountsPerFrame ); -*/ private: - DWORD m_CurrentLength; DWORD m_SecondBuff; DWORD m_Status; DWORD m_BytesPerSecond; int m_CountsPerByte; int m_FramesPerSecond; - -/* float m_VSyncTiming; - double m_FramesPerSecond; - DWORD m_Length; - DWORD m_CurrentCount; - DWORD m_IntScheduled;*/ }; diff --git a/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp b/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp index 2a7cd3edb..10c9df931 100644 --- a/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp +++ b/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp @@ -875,7 +875,7 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) { case 0x0450000C: /* Clear Interrupt */; AndConstToVariable(~MI_INTR_AI,&_Reg->MI_INTR_REG,"MI_INTR_REG"); - if (bFixedAudio()) + if (!bFixedAudio()) { AndConstToVariable(~MI_INTR_AI,&_Reg->m_AudioIntrReg,"m_AudioIntrReg"); } @@ -1141,7 +1141,10 @@ void CMipsMemoryVM::Compile_SW_Register (x86Reg Reg, DWORD VAddr ) case 0x0450000C: /* Clear Interrupt */; AndConstToVariable(~MI_INTR_AI,&_Reg->MI_INTR_REG,"MI_INTR_REG"); - AndConstToVariable(~MI_INTR_AI,&_Reg->m_AudioIntrReg,"m_AudioIntrReg"); + if (!bFixedAudio()) + { + AndConstToVariable(~MI_INTR_AI,&_Reg->m_AudioIntrReg,"m_AudioIntrReg"); + } BeforeCallDirect(m_RegWorkingSet); MoveConstToX86reg((DWORD)_Reg,x86_ECX); Call_Direct(AddressOf(&CRegisters::CheckInterrupts),"CRegisters::CheckInterrupts"); diff --git a/Source/Project64/N64 System/N64 Class.cpp b/Source/Project64/N64 System/N64 Class.cpp index b01b7ae8c..684e0c1ef 100644 --- a/Source/Project64/N64 System/N64 Class.cpp +++ b/Source/Project64/N64 System/N64 Class.cpp @@ -449,6 +449,10 @@ void CN64System::DisplayRomInfo ( WND_HANDLE hParent ) { void CN64System::Pause(void) { + if (m_EndEmulation) + { + return; + } ResetEvent(m_hPauseEvent); _Settings->SaveBool(GameRunning_CPU_Paused,true); _Notify->RefreshMenu(); diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp b/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp index 69f597dcb..db61c2697 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp +++ b/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp @@ -816,7 +816,7 @@ CCompiledFunc * CRecompiler::CompilerCode ( void ) void CRecompiler::ClearRecompCode_Phys(DWORD Address, int length, REMOVE_REASON Reason ) { - WriteTraceF(TraceError,"CRecompiler::ClearRecompCode_Phys Not Implemented (Address: %X, Length: %d Reason: %d)",Address,length,Reason); + //WriteTraceF(TraceError,"CRecompiler::ClearRecompCode_Phys Not Implemented (Address: %X, Length: %d Reason: %d)",Address,length,Reason); if (LookUpMode() == FuncFind_VirtualLookup) { diff --git a/Source/Project64/Plugins/Audio Plugin.cpp b/Source/Project64/Plugins/Audio Plugin.cpp index 643a7a5ad..3f97c0dbe 100644 --- a/Source/Project64/Plugins/Audio Plugin.cpp +++ b/Source/Project64/Plugins/Audio Plugin.cpp @@ -242,7 +242,9 @@ bool CAudioPlugin::ValidPluginVersion(PLUGIN_INFO * PluginInfo) { void CAudioPlugin::UnloadPlugin(void) { - if (m_hAudioThread) { + if (m_hAudioThread) + { + WriteTraceF(TraceAudio,__FUNCTION__ ": Terminate Audio Thread"); TerminateThread(m_hAudioThread,0); m_hAudioThread = NULL; } @@ -264,6 +266,8 @@ void CAudioPlugin::UnloadPlugin(void) { void CAudioPlugin::DacrateChanged (SystemType Type) { if (!Initilized()) { return; } + WriteTraceF(TraceAudio,__FUNCTION__ ": SystemType: %s", Type == SYSTEM_NTSC ? "SYSTEM_NTSC" : "SYSTEM_PAL"); + DWORD Frequency = _Reg->AI_DACRATE_REG * 30; DWORD CountsPerSecond = (_Reg->VI_V_SYNC_REG != 0 ? (_Reg->VI_V_SYNC_REG + 1) * _Settings->LoadDword(Game_ViRefreshRate) : 500000) * 60; m_DacrateChanged(Type); @@ -271,7 +275,8 @@ void CAudioPlugin::DacrateChanged (SystemType Type) void CAudioPlugin::AudioThread (CAudioPlugin * _this) { SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL ); - for (;;) { + for (;;) + { _this->Update(true); } } diff --git a/Source/Project64/User Interface/Main Menu Class.cpp b/Source/Project64/User Interface/Main Menu Class.cpp index 7c78a8b81..55e135f1e 100644 --- a/Source/Project64/User Interface/Main Menu Class.cpp +++ b/Source/Project64/User Interface/Main Menu Class.cpp @@ -430,6 +430,19 @@ bool CMainMenu::ProcessMessage(WND_HANDLE hWnd, DWORD FromAccelerator, DWORD Men _Settings->SaveDword(Debugger_AppLogLevel, LogLevel ); } break; + case ID_DEBUGGER_APPLOG_AUDIO_EMU: + { + DWORD LogLevel = _Settings->LoadDword(Debugger_AppLogLevel); + if ((LogLevel & TraceAudio) != 0) + { + LogLevel &= ~TraceAudio; + } else { + + LogLevel |= TraceAudio; + } + _Settings->SaveDword(Debugger_AppLogLevel, LogLevel ); + } + break; case ID_DEBUGGER_APPLOG_FLUSH: _Settings->SaveBool(Debugger_AppLogFlush,!_Settings->LoadBool(Debugger_AppLogFlush)); break; @@ -1004,6 +1017,10 @@ void CMainMenu::FillOutMenu ( MENU_HANDLE hMenu ) { if ((LogLevel & TraceGfxPlugin) != 0) { Item.ItemTicked = true; } DebugAppLoggingMenu.push_back(Item); + Item.Reset(ID_DEBUGGER_APPLOG_AUDIO_EMU,EMPTY_STRING,EMPTY_STDSTR,NULL,"Audio Emulation" ); + if ((LogLevel & TraceAudio) != 0) { Item.ItemTicked = true; } + DebugAppLoggingMenu.push_back(Item); + Item.Reset(ID_DEBUGGER_APPLOG_DEBUG,EMPTY_STRING,EMPTY_STDSTR,NULL,"Debug Messages" ); if ((LogLevel & TraceDebug) != 0) { Item.ItemTicked = true; } DebugAppLoggingMenu.push_back(Item); diff --git a/Source/Project64/User Interface/Main Menu Class.h b/Source/Project64/User Interface/Main Menu Class.h index 12da278ef..9f14478b2 100644 --- a/Source/Project64/User Interface/Main Menu Class.h +++ b/Source/Project64/User Interface/Main Menu Class.h @@ -40,7 +40,7 @@ enum MainMenuID { // App logging ID_DEBUGGER_APPLOG_ERRORS, ID_DEBUGGER_APPLOG_SETTINGS, ID_DEBUGGER_APPLOG_GFX_PLUGIN, ID_DEBUGGER_APPLOG_DEBUG, ID_DEBUGGER_APPLOG_FLUSH, ID_DEBUGGER_APPLOG_RECOMPILER, - ID_DEBUGGER_APPLOG_RSP, ID_DEBUGGER_APPLOG_TLB, + ID_DEBUGGER_APPLOG_RSP, ID_DEBUGGER_APPLOG_TLB, ID_DEBUGGER_APPLOG_AUDIO_EMU, //Profile Menu ID_PROFILE_PROFILE, ID_PROFILE_RESETCOUNTER, ID_PROFILE_GENERATELOG, diff --git a/Source/Project64/User Interface/UI Resources.aps b/Source/Project64/User Interface/UI Resources.aps index d3faf10e2..1c9f1f2e4 100644 Binary files a/Source/Project64/User Interface/UI Resources.aps and b/Source/Project64/User Interface/UI Resources.aps differ diff --git a/Source/Project64/User Interface/UI Resources.rc b/Source/Project64/User Interface/UI Resources.rc index 88d552385..0aea8c0b8 100644 --- a/Source/Project64/User Interface/UI Resources.rc +++ b/Source/Project64/User Interface/UI Resources.rc @@ -925,8 +925,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,7,51,50 - PRODUCTVERSION 1,7,51,50 + FILEVERSION 1,7,51,51 + PRODUCTVERSION 1,7,51,51 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -943,12 +943,12 @@ BEGIN BEGIN VALUE "CompanyName", " " VALUE "FileDescription", "Project64" - VALUE "FileVersion", "1, 7, 51, 50" + VALUE "FileVersion", "1, 7, 51, 51" VALUE "InternalName", "Project64" VALUE "LegalCopyright", "Copyright © 2010" VALUE "OriginalFilename", "Project64.exe" VALUE "ProductName", " Project64" - VALUE "ProductVersion", "1, 7, 51, 50" + VALUE "ProductVersion", "1, 7, 51, 51" END END BLOCK "VarFileInfo"