From 81b19057bb1a6ef752672b2eaa9df2c9a7a2d76b Mon Sep 17 00:00:00 2001 From: DH Date: Sat, 22 Feb 2014 14:06:23 +0200 Subject: [PATCH] Implemented audio Dump To File Fixed MFOCRF, MTOCRF, MTCRF Minor fixes --- Utilities/Thread.cpp | 5 ++- rpcs3/Emu/Cell/PPUInterpreter.h | 10 +++-- rpcs3/Emu/GS/GL/GLGSRender.cpp | 2 + rpcs3/Emu/GS/RSXThread.cpp | 13 ++++++- rpcs3/Emu/GS/RSXThread.h | 7 +++- rpcs3/Emu/SysCalls/Modules/cellAudio.cpp | 49 +++++++++++++----------- rpcs3/Emu/SysCalls/lv2/SC_SPU_Thread.cpp | 2 +- rpcs3/Gui/GameViewer.cpp | 2 +- rpcs3/Gui/MainFrame.cpp | 8 +++- rpcs3/Ini.h | 4 ++ 10 files changed, 68 insertions(+), 34 deletions(-) diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index 793e963be9..e3e76a6b84 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -115,10 +115,11 @@ void thread::start(std::function func) { // got a crash related with strings m_thr = std::thread([this, func]() { + NamedThreadBase info(m_name); + g_tls_this_thread = &info; + try { - NamedThreadBase info(m_name); - g_tls_this_thread = &info; func(); } catch(...) diff --git a/rpcs3/Emu/Cell/PPUInterpreter.h b/rpcs3/Emu/Cell/PPUInterpreter.h index 9521bf430d..c7d76cf523 100644 --- a/rpcs3/Emu/Cell/PPUInterpreter.h +++ b/rpcs3/Emu/Cell/PPUInterpreter.h @@ -2334,6 +2334,7 @@ private: } void MFOCRF(u32 a, u32 rd, u32 crm) { + /* if(a) { u32 n = 0, count = 0; @@ -2357,8 +2358,9 @@ private: } else { - CPU.GPR[rd] = CPU.CR.CR; - } + */ + CPU.GPR[rd] = CPU.CR.CR; + //} } void LWARX(u32 rd, u32 ra, u32 rb) { @@ -2635,7 +2637,7 @@ private: if(count == 1) { //CR[4*n : 4*n+3] = RS[32+4*n : 32+4*n+3]; - CPU.SetCR(n, (CPU.GPR[rs] >> (4*n)) & 0xf); + CPU.SetCR(7 - n, (CPU.GPR[rs] >> (4*n)) & 0xf); } else CPU.CR.CR = 0; @@ -2646,7 +2648,7 @@ private: { if(crm & (1 << i)) { - CPU.SetCR(i, CPU.GPR[rs] & (0xf << i)); + CPU.SetCR(7 - i, CPU.GPR[rs] & (0xf << (i * 4))); } } } diff --git a/rpcs3/Emu/GS/GL/GLGSRender.cpp b/rpcs3/Emu/GS/GL/GLGSRender.cpp index 4a667bfe21..744897dd9d 100644 --- a/rpcs3/Emu/GS/GL/GLGSRender.cpp +++ b/rpcs3/Emu/GS/GL/GLGSRender.cpp @@ -802,6 +802,8 @@ void GLGSRender::ExecCMD() checkForGlError("glColorMask"); } + //glFrontFace(m_front_face); + if(m_set_viewport_horizontal && m_set_viewport_vertical) { //glViewport(m_viewport_x, m_viewport_y, m_viewport_w, m_viewport_h); diff --git a/rpcs3/Emu/GS/RSXThread.cpp b/rpcs3/Emu/GS/RSXThread.cpp index b2c85a7920..7fb5238fb4 100644 --- a/rpcs3/Emu/GS/RSXThread.cpp +++ b/rpcs3/Emu/GS/RSXThread.cpp @@ -219,6 +219,10 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t& args, const u3 { } break; + + case NV4097_SET_FRONT_FACE: + m_front_face = ARGS(0); + break; case_16(NV4097_SET_VERTEX_DATA4UB_M, 4): { @@ -658,7 +662,7 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t& args, const u3 case NV4097_SET_SHADER_PROGRAM: { - m_cur_shader_prog = &m_shader_progs[m_cur_shader_prog_num++]; + m_cur_shader_prog = &m_shader_progs[/*m_cur_shader_prog_num++*/0]; u32 a0 = ARGS(0); m_cur_shader_prog->offset = a0 & ~0x3; m_cur_shader_prog->addr = GetAddress(m_cur_shader_prog->offset, (a0 & 0x3) - 1); @@ -1376,6 +1380,12 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t& args, const u3 case 0x000002f8: break; + case NV0039_SET_CONTEXT_DMA_BUFFER_IN: + case NV0039_OFFSET_IN: + case NV0039_OFFSET_OUT: + //TODO + break; + case NV4097_SET_SURFACE_COLOR_AOFFSET: m_surface_offset_a = ARGS(0); break; @@ -1450,6 +1460,7 @@ void RSXThread::End() m_fragment_constants.Clear(); m_transform_constants.Clear(); m_cur_shader_prog_num = 0; + //m_cur_shader_prog = nullptr; m_clear_surface_mask = 0; m_begin_end = 0; diff --git a/rpcs3/Emu/GS/RSXThread.h b/rpcs3/Emu/GS/RSXThread.h index 1a7a14c469..94ca22be4b 100644 --- a/rpcs3/Emu/GS/RSXThread.h +++ b/rpcs3/Emu/GS/RSXThread.h @@ -151,7 +151,7 @@ class RSXThread : public ThreadBase public: static const uint m_textures_count = 16; static const uint m_vertex_count = 32; - static const uint m_fragment_count = 16; + static const uint m_fragment_count = 32; static const uint m_tiles_count = 15; protected: @@ -179,7 +179,6 @@ public: int m_debug_level; int m_frequency_mode; - u32 m_tiles_addr; u32 m_zculls_addr; u32 m_gcm_buffers_addr; @@ -438,6 +437,8 @@ public: u32 m_surface_colour_target; + u32 m_front_face; + u8 m_begin_end; bool m_read_buffer; @@ -485,6 +486,8 @@ protected: m_point_x = 0; m_point_y = 0; + m_front_face = 0x0901; + // Construct Textures for(int i=0; i<16; i++) { diff --git a/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp b/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp index 2503d9c7fd..50290f9e97 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp @@ -301,11 +301,11 @@ int cellAudioInit() thread t("AudioThread", []() { WAVHeader header(2); // WAV file header (stereo) + + static const wxString& output_name = "audio.wav"; - wxString output_name = "audio.wav"; - - wxFile output(output_name, wxFile::write); // create output file - if (!output.IsOpened()) + wxFile output; // create output file + if (Ini.AudioDumpToFile.GetValue() && !output.Open(output_name, wxFile::write)) { ConLog.Error("Audio aborted: cannot create %s", output_name.wx_str()); return; @@ -315,10 +315,11 @@ int cellAudioInit() m_config.start_time = get_system_time(); - output.Write(&header, sizeof(header)); // write file header + if (Ini.AudioDumpToFile.GetValue()) + output.Write(&header, sizeof(header)); // write file header float buffer[2*256]; // buffer for 2 channels - float buffer2[8*256]; // buffer for 8 channels (max count) + be_t buffer2[8*256]; // buffer for 8 channels (max count) memset(&buffer, 0, sizeof(buffer)); memset(&buffer2, 0, sizeof(buffer2)); @@ -370,14 +371,12 @@ int cellAudioInit() port.tag++; // absolute index of block that will be read index = (position + 1) % port.block; // write new value - - if (first_mix) { for (u32 i = 0; i < (sizeof(buffer) / sizeof(float)); i++) { // reverse byte order (TODO: use port.m_param.level) - buffer[i] = re(buffer2[i]); + buffer[i] = buffer2[i]; } first_mix = false; } @@ -385,31 +384,37 @@ int cellAudioInit() { for (u32 i = 0; i < (sizeof(buffer) / sizeof(float)); i++) { - float value = re(buffer2[i]); - buffer[i] = (buffer[i] + value) * 0.5; // TODO: valid mixing + buffer[i] = (buffer[i] + buffer2[i]) * 0.5; // TODO: valid mixing } } - } + } // send aftermix event (normal audio event) // TODO: check event source Emu.GetEventManager().SendEvent(m_config.event_key, 0x10103000e010e07, 0, 0, 0); - if (output.Write(&buffer, sizeof(buffer)) != sizeof(buffer)) // write file data + if(Ini.AudioDumpToFile.GetValue()) { - ConLog.Error("Port aborted: cannot write %s", output_name.wx_str()); - goto abort; - } + if (output.Write(&buffer, sizeof(buffer)) != sizeof(buffer)) // write file data + { + ConLog.Error("Port aborted: cannot write %s", output_name.wx_str()); + goto abort; + } - header.Size += sizeof(buffer); // update file header - header.RIFF.Size += sizeof(buffer); + header.Size += sizeof(buffer); // update file header + header.RIFF.Size += sizeof(buffer); + } } ConLog.Write("Audio finished"); - abort: - output.Seek(0); - output.Write(&header, sizeof(header)); // write fixed file header +abort: + if(Ini.AudioDumpToFile.GetValue()) + { + output.Seek(0); + output.Write(&header, sizeof(header)); // write fixed file header + + output.Close(); + } - output.Close(); m_config.m_is_audio_finalized = true; }); t.detach(); diff --git a/rpcs3/Emu/SysCalls/lv2/SC_SPU_Thread.cpp b/rpcs3/Emu/SysCalls/lv2/SC_SPU_Thread.cpp index 1cf481be3d..4b3c858264 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_SPU_Thread.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_SPU_Thread.cpp @@ -257,7 +257,7 @@ int sys_spu_thread_group_start(u32 id) //174 int sys_spu_thread_group_suspend(u32 id) { - sc_spu.Warning("sys_spu_thread_group_suspend(id=%d)", id); + sc_spu.Log("sys_spu_thread_group_suspend(id=%d)", id); SpuGroupInfo* group_info; if(!Emu.GetIdManager().GetIDData(id, group_info)) diff --git a/rpcs3/Gui/GameViewer.cpp b/rpcs3/Gui/GameViewer.cpp index 26d876bcf6..dbcf783118 100644 --- a/rpcs3/Gui/GameViewer.cpp +++ b/rpcs3/Gui/GameViewer.cpp @@ -95,9 +95,9 @@ void GameViewer::DClick(wxListEvent& event) const wxString& path = m_path + m_game_data[i].root; + Emu.Stop(); Emu.GetVFS().Init(path); wxString local_path; - Emu.Stop(); if(Emu.GetVFS().GetDevice(path, local_path) && !Emu.BootGame(local_path.ToStdString())) { ConLog.Error("Boot error: elf not found! [%s]", path.wx_str()); diff --git a/rpcs3/Gui/MainFrame.cpp b/rpcs3/Gui/MainFrame.cpp index 16d9e2ff00..91014a702b 100644 --- a/rpcs3/Gui/MainFrame.cpp +++ b/rpcs3/Gui/MainFrame.cpp @@ -379,6 +379,7 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event)) wxCheckBox* chbox_gs_dump_depth = new wxCheckBox(&diag, wxID_ANY, "Dump Depth Buffer"); wxCheckBox* chbox_gs_dump_color = new wxCheckBox(&diag, wxID_ANY, "Dump Color Buffers"); wxCheckBox* chbox_gs_vsync = new wxCheckBox(&diag, wxID_ANY, "VSync"); + wxCheckBox* chbox_audio_dump = new wxCheckBox(&diag, wxID_ANY, "Dump to file"); wxCheckBox* chbox_hle_logging = new wxCheckBox(&diag, wxID_ANY, "Log all SysCalls"); //cbox_cpu_decoder->Append("DisAsm"); @@ -416,8 +417,12 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event)) chbox_gs_dump_depth->SetValue(Ini.GSDumpDepthBuffer.GetValue()); chbox_gs_dump_color->SetValue(Ini.GSDumpColorBuffers.GetValue()); chbox_gs_vsync->SetValue(Ini.GSVSyncEnable.GetValue()); + chbox_audio_dump->SetValue(Ini.AudioDumpToFile.GetValue()); chbox_hle_logging->SetValue(Ini.HLELogging.GetValue()); + chbox_audio_dump->Enable(Emu.IsStopped()); + chbox_hle_logging->Enable(Emu.IsStopped()); + cbox_cpu_decoder->SetSelection(Ini.CPUDecoderMode.GetValue() ? Ini.CPUDecoderMode.GetValue() - 1 : 0); cbox_gs_render->SetSelection(Ini.GSRenderMode.GetValue()); cbox_gs_resolution->SetSelection(ResolutionIdToNum(Ini.GSResolution.GetValue()) - 1); @@ -450,6 +455,7 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event)) s_round_io->Add(s_round_io_mouse_handler, wxSizerFlags().Border(wxALL, 5).Expand()); s_round_audio_out->Add(cbox_audio_out, wxSizerFlags().Border(wxALL, 5).Expand()); + s_round_audio_out->Add(chbox_audio_dump, wxSizerFlags().Border(wxALL, 5).Expand()); s_round_audio->Add(s_round_audio_out, wxSizerFlags().Border(wxALL, 5).Expand()); s_round_hle->Add(chbox_hle_logging, wxSizerFlags().Border(wxALL, 5).Expand()); @@ -488,6 +494,7 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event)) Ini.KeyboardHandlerMode.SetValue(cbox_keyboard_handler->GetSelection()); Ini.MouseHandlerMode.SetValue(cbox_mouse_handler->GetSelection()); Ini.AudioOutMode.SetValue(cbox_audio_out->GetSelection()); + Ini.AudioDumpToFile.SetValue(chbox_audio_dump->GetValue()); Ini.HLELogging.SetValue(chbox_hle_logging->GetValue()); Ini.Save(); @@ -650,7 +657,6 @@ void MainFrame::ConfigPad(wxCommandEvent& WXUNUSED(event)) s_subpanel4->Add(s_round_pad_shifts_r, wxSizerFlags().Border(wxALL, 5).Expand()); s_subpanel5->Add(s_round_pad_buttons, wxSizerFlags().Border(wxALL, 5).Expand()); - s_panel->Add(s_subpanel1, wxSizerFlags().Border(wxALL, 5).Expand()); s_panel->Add(s_subpanel2, wxSizerFlags().Border(wxALL, 5).Expand()); s_panel->Add(s_subpanel3, wxSizerFlags().Border(wxALL, 5).Expand()); diff --git a/rpcs3/Ini.h b/rpcs3/Ini.h index 4542a6a525..dcfdee1176 100644 --- a/rpcs3/Ini.h +++ b/rpcs3/Ini.h @@ -105,6 +105,7 @@ public: IniEntry KeyboardHandlerMode; IniEntry MouseHandlerMode; IniEntry AudioOutMode; + IniEntry AudioDumpToFile; IniEntry HLELogging; IniEntry PadHandlerLeft; @@ -167,6 +168,7 @@ public: path = DefPath + "\\" + "Audio"; AudioOutMode.Init("AudioOutMode", path); + AudioDumpToFile.Init("AudioDumpToFile", path); path = DefPath + "\\" + "HLE"; HLELogging.Init("HLELogging", path); @@ -187,6 +189,7 @@ public: KeyboardHandlerMode.Load(0); MouseHandlerMode.Load(0); AudioOutMode.Load(0); + AudioDumpToFile.Load(0); HLELogging.Load(false); PadHandlerLeft.Load(static_cast('A')); @@ -222,6 +225,7 @@ public: KeyboardHandlerMode.Save(); MouseHandlerMode.Save(); AudioOutMode.Save(); + AudioDumpToFile.Save(); HLELogging.Save(); PadHandlerLeft.Save();