Implemented audio Dump To File

Fixed MFOCRF, MTOCRF, MTCRF
Minor fixes
This commit is contained in:
DH 2014-02-22 14:06:23 +02:00
parent 7c6c20ef18
commit 81b19057bb
10 changed files with 68 additions and 34 deletions

View file

@ -115,10 +115,11 @@ void thread::start(std::function<void()> 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(...)

View file

@ -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)));
}
}
}

View file

@ -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);

View file

@ -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;

View file

@ -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++)
{

View file

@ -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<float> 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();

View file

@ -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))

View file

@ -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());

View file

@ -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());

View file

@ -105,6 +105,7 @@ public:
IniEntry<u8> KeyboardHandlerMode;
IniEntry<u8> MouseHandlerMode;
IniEntry<u8> AudioOutMode;
IniEntry<bool> AudioDumpToFile;
IniEntry<bool> HLELogging;
IniEntry<int> 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<int>('A'));
@ -222,6 +225,7 @@ public:
KeyboardHandlerMode.Save();
MouseHandlerMode.Save();
AudioOutMode.Save();
AudioDumpToFile.Save();
HLELogging.Save();
PadHandlerLeft.Save();