RSX Debugger, Mem. Viewer and module improvements

* Small cleanup in cellJpgDec and cellPngDec.
* cellPamf added to the project and a few test lines added to
cellPamfGetHeaderSize(2).
* Improved speed of the Raw Image Preview on the the Memory Viewer.
* Now you can click on the shown buffers / textures in the RSX Debugger
in order to see them in full size. More settings added to the tabs.
* Fixed cellFsStat in order to fix the crash aused by opening
directiories. The solution is really *really* ugly. Once vfsDir is
ready, I will replace it with something better.
This commit is contained in:
Alexandro Sánchez Bach 2014-01-05 00:45:44 +01:00
parent 1a43fe5ceb
commit aa9b0d0a31
10 changed files with 173 additions and 105 deletions

View file

@ -61,6 +61,7 @@ MemoryViewerPanel::MemoryViewerPanel(wxWindow* parent)
cbox_img_mode->Append("RGB");
cbox_img_mode->Append("ARGB");
cbox_img_mode->Append("RGBA");
cbox_img_mode->Append("ABGR");
cbox_img_mode->Select(1); //ARGB
s_tools_img_mode.Add(cbox_img_mode);
@ -119,7 +120,6 @@ MemoryViewerPanel::MemoryViewerPanel(wxWindow* parent)
SetSizerAndFit(&s_panel);
//Events
//Connect( wxEVT_SIZE, wxSizeEventHandler(MemoryViewerPanel::OnResize) );
Connect(t_addr->GetId(), wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(MemoryViewerPanel::OnChangeToolsAddr) );
Connect(sc_bytes->GetId(), wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(MemoryViewerPanel::OnChangeToolsBytes) );
Connect(sc_bytes->GetId(), wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler(MemoryViewerPanel::OnChangeToolsBytes) );
@ -128,7 +128,7 @@ MemoryViewerPanel::MemoryViewerPanel(wxWindow* parent)
Connect(b_next->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(MemoryViewerPanel::Next));
Connect(b_fprev->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(MemoryViewerPanel::fPrev));
Connect(b_fnext->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(MemoryViewerPanel::fNext));
Connect(b_img->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(MemoryViewerPanel::ShowImage));
Connect(b_img->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(MemoryViewerPanel::OnShowImage));
t_mem_addr ->Connect(wxEVT_MOUSEWHEEL, wxMouseEventHandler(MemoryViewerPanel::OnScrollMemory), NULL, this);
t_mem_hex ->Connect(wxEVT_MOUSEWHEEL, wxMouseEventHandler(MemoryViewerPanel::OnScrollMemory), NULL, this);
@ -138,15 +138,6 @@ MemoryViewerPanel::MemoryViewerPanel(wxWindow* parent)
ShowMemory();
};
/*void MemoryViewerPanel::OnResize(wxSizeEvent& event)
{
const wxSize size(GetClientSize());
hex_wind->SetSize( size.GetWidth(), size.GetHeight() - 25);
hex_wind->SetColumnWidth(COL_COUNT, size.GetWidth() - m_colcount - 4);
event.Skip();
}*/
void MemoryViewerPanel::OnChangeToolsAddr(wxCommandEvent& event)
{
t_addr->GetValue().ToULong((unsigned long *)&m_addr, 16);
@ -179,6 +170,15 @@ void MemoryViewerPanel::OnScrollMemory(wxMouseEvent& event)
event.Skip();
}
void MemoryViewerPanel::OnShowImage(wxCommandEvent& WXUNUSED(event))
{
u32 addr = m_addr;
int mode = cbox_img_mode->GetSelection();
int sizex = sc_img_size_x->GetValue();
int sizey = sc_img_size_y->GetValue();
ShowImage(this, m_addr, mode, sizex, sizey, false);
}
void MemoryViewerPanel::ShowMemory()
{
wxString t_mem_addr_str;
@ -211,58 +211,70 @@ void MemoryViewerPanel::ShowMemory()
t_mem_ascii->SetValue(t_mem_ascii_str);
}
void MemoryViewerPanel::ShowImage(wxCommandEvent& WXUNUSED(event))
void MemoryViewerPanel::ShowImage(wxWindow* parent, u32 addr, int mode, int width, int height, bool flipv)
{
wxString title = wxString::Format("Raw Image @ 0x%x", m_addr);
int mode = cbox_img_mode->GetSelection();
int sizex = sc_img_size_x->GetValue();
int sizey = sc_img_size_y->GetValue();
wxFrame* f_image_viewer = new wxFrame(this, wxID_ANY, title, wxDefaultPosition, wxDefaultSize,
wxString title = wxString::Format("Raw Image @ 0x%x", addr);
wxFrame* f_image_viewer = new wxFrame(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize,
wxSYSTEM_MENU | wxMINIMIZE_BOX | wxCLOSE_BOX | wxCAPTION | wxCLIP_CHILDREN);
f_image_viewer->SetBackgroundColour(wxColour(240,240,240)); //This fix the ugly background color under Windows
f_image_viewer->SetAutoLayout(true);
f_image_viewer->SetClientSize(wxSize(sizex,sizey));
f_image_viewer->SetClientSize(wxSize(width, height));
f_image_viewer->Show();
wxClientDC dc_canvas(f_image_viewer);
u32 addr = m_addr;
for(int y = 0; y < sizex; y++)
unsigned char* originalBuffer = (unsigned char*)Memory.VirtualToRealAddr(addr);
unsigned char* convertedBuffer = (unsigned char*)malloc(width * height * 3);
switch(mode)
{
for(int x = 0; x < sizey; x++)
{
char R,G,B;
switch(mode)
{
case(0): //RGB
R = Memory.IsGoodAddr(addr+0) ? Memory.Read8(addr+0) : 0;
G = Memory.IsGoodAddr(addr+1) ? Memory.Read8(addr+1) : 0;
B = Memory.IsGoodAddr(addr+2) ? Memory.Read8(addr+2) : 0;
dc_canvas.SetPen(wxPen(wxColour(R,G,B), 3));
dc_canvas.DrawPoint(x,y);
addr += 3;
break;
case(1): //ARGB
//A = Memory.IsGoodAddr(addr+0) ? Memory.Read8(addr+0) : 0;
R = Memory.IsGoodAddr(addr+1) ? Memory.Read8(addr+1) : 0;
G = Memory.IsGoodAddr(addr+2) ? Memory.Read8(addr+2) : 0;
B = Memory.IsGoodAddr(addr+3) ? Memory.Read8(addr+3) : 0;
dc_canvas.SetPen(wxPen(wxColour(R,G,B), 3));
dc_canvas.DrawPoint(x,y);
addr += 4;
break;
case(2): //RGBA
R = Memory.IsGoodAddr(addr+0) ? Memory.Read8(addr+0) : 0;
G = Memory.IsGoodAddr(addr+1) ? Memory.Read8(addr+1) : 0;
B = Memory.IsGoodAddr(addr+2) ? Memory.Read8(addr+2) : 0;
//A = Memory.IsGoodAddr(addr+3) ? Memory.Read8(addr+3) : 0;
dc_canvas.SetPen(wxPen(wxColour(R,G,B), 3));
dc_canvas.DrawPoint(x,y);
addr += 4;
break;
case(0): // RGB
memcpy(convertedBuffer, originalBuffer, width * height * 3);
break;
case(1): // ARGB
for (u32 y=0; y<height; y++){
for (u32 i=0, j=0; j<width*4; i+=3, j+=4){
convertedBuffer[i+0 + y*width*3] = originalBuffer[j+1 + y*width*4];
convertedBuffer[i+1 + y*width*3] = originalBuffer[j+2 + y*width*4];
convertedBuffer[i+2 + y*width*3] = originalBuffer[j+3 + y*width*4];
}
}
break;
case(2): // RGBA
for (u32 y=0; y<height; y++){
for (u32 i=0, j=0; j<width*4; i+=3, j+=4){
convertedBuffer[i+0 + y*width*3] = originalBuffer[j+0 + y*width*4];
convertedBuffer[i+1 + y*width*3] = originalBuffer[j+1 + y*width*4];
convertedBuffer[i+2 + y*width*3] = originalBuffer[j+2 + y*width*4];
}
}
break;
case(3): // ABGR
for (u32 y=0; y<height; y++){
for (u32 i=0, j=0; j<width*4; i+=3, j+=4){
convertedBuffer[i+0 + y*width*3] = originalBuffer[j+3 + y*width*4];
convertedBuffer[i+1 + y*width*3] = originalBuffer[j+2 + y*width*4];
convertedBuffer[i+2 + y*width*3] = originalBuffer[j+1 + y*width*4];
}
}
break;
}
// Flip vertically
if (flipv){
for (u32 y=0; y<height/2; y++){
for (u32 x=0; x<width*3; x++){
const u8 t = convertedBuffer[x + y*width*3];
convertedBuffer[x + y*width*3] = convertedBuffer[x + (height-y-1)*width*3];
convertedBuffer[x + (height-y-1)*width*3] = t;
}
}
}
wxImage img(width, height, convertedBuffer);
dc_canvas.DrawBitmap(img, 0, 0, false);
}
void MemoryViewerPanel::Next (wxCommandEvent& WXUNUSED(event)) { m_addr += m_colcount; ShowMemory(); }