1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 10:42:36 +01:00
This commit is contained in:
Nekotekina 2014-01-02 18:56:53 +04:00
commit 64b18b4dc2
3 changed files with 499 additions and 100 deletions

View File

@ -3,6 +3,8 @@
#include "Emu/SysCalls/SC_FUNC.h"
#include "cellFont.h"
//#include "stblib/stb_truetype.h"
void cellFont_init();
void cellFont_unload();
Module cellFont(0x0019, cellFont_init, nullptr, cellFont_unload);
@ -99,6 +101,7 @@ struct CellFont
be_t<float> scale_y;
be_t<float> slant;
be_t<u32> renderer_addr;
//stbtt_fontinfo stbfont;
};
struct CellFontType
@ -261,9 +264,44 @@ s32 cellFontSetFontsetOpenMode(u32 openMode)
return CELL_FONT_OK;
}
int cellFontOpenFontMemory(mem_ptr_t<CellFontLibrary> library, u32 fontAddr, u32 fontSize, u32 subNum, u32 uniqueId, mem_ptr_t<CellFont> font)
{
cellFont.Warning("cellFontOpenFontMemory(library_addr=0x%x, fontAddr=0x%x, fontSize=%d, subNum=%d, uniqueId=%d, font_addr=0x%x)",
library.GetAddr(), fontAddr, fontSize, subNum, uniqueId, font.GetAddr());
if (!s_fontInternalInstance->m_bInitialized)
return CELL_FONT_ERROR_UNINITIALIZED;
if (!library.IsGood() || !font.IsGood())
return CELL_FONT_ERROR_INVALID_PARAMETER;
if (!Memory.IsGoodAddr(fontAddr))
return CELL_FONT_ERROR_FONT_OPEN_FAILED;
//stbtt_InitFont(&(font->stbfont), (unsigned char*)Memory.VirtualToRealAddr(fontAddr), 0);
font->renderer_addr = NULL;
//TODO: Write data in font
return CELL_FONT_OK;
}
int cellFontOpenFontFile(mem_ptr_t<CellFontLibrary> library, mem8_ptr_t fontPath, u32 subNum, s32 uniqueId, mem_ptr_t<CellFont> font)
{
cellFont.Warning("cellFontOpenFontFile(library_addr=0x%x, fontPath=\"%s\", subNum=%d, uniqueId=%d, font_addr=0x%x)",
library.GetAddr(), fontPath.GetString(), subNum, uniqueId, font.GetAddr());
vfsFile f(fontPath.GetString());
if (!f.IsOpened())
return CELL_FONT_ERROR_FONT_OPEN_FAILED;
u32 fileSize = f.GetSize();
MemoryAllocator<u8> buffer(fileSize);
f.Read(Memory.VirtualToRealAddr(buffer.GetAddr()), fileSize);
cellFontOpenFontMemory(library.GetAddr(), buffer.GetAddr(), fileSize, subNum, uniqueId, font.GetAddr());
return CELL_FONT_OK;
}
int cellFontOpenFontset(mem_ptr_t<CellFontLibrary> library, mem_ptr_t<CellFontType> fontType, mem_ptr_t<CellFont> font)
{
cellFont.Warning("cellFontOpenFontset(library_addr=0x%x, fontType_addr=0x%x, font_addr=0x%x)",
cellFont.Log("cellFontOpenFontset(library_addr=0x%x, fontType_addr=0x%x, font_addr=0x%x)",
library.GetAddr(), fontType.GetAddr(), font.GetAddr());
if (!library.IsGood() || !fontType.IsGood() || !font.IsGood())
@ -273,10 +311,77 @@ int cellFontOpenFontset(mem_ptr_t<CellFontLibrary> library, mem_ptr_t<CellFontTy
if (fontType->map != CELL_FONT_MAP_UNICODE)
cellFont.Warning("cellFontOpenFontset: Only Unicode is supported");
font->renderer_addr = NULL;
//TODO: Write data in font
std::string file;
switch(fontType->type)
{
case CELL_FONT_TYPE_RODIN_SANS_SERIF_LATIN: file = "/dev_flash/data/font/SCE-PS3-RD-R-LATIN.TTF"; break;
case CELL_FONT_TYPE_RODIN_SANS_SERIF_LIGHT_LATIN: file = "/dev_flash/data/font/SCE-PS3-RD-L-LATIN.TTF"; break;
case CELL_FONT_TYPE_RODIN_SANS_SERIF_BOLD_LATIN: file = "/dev_flash/data/font/SCE-PS3-RD-B-LATIN.TTF"; break;
case CELL_FONT_TYPE_RODIN_SANS_SERIF_LATIN2: file = "/dev_flash/data/font/SCE-PS3-RD-R-LATIN2.TTF"; break;
case CELL_FONT_TYPE_RODIN_SANS_SERIF_LIGHT_LATIN2: file = "/dev_flash/data/font/SCE-PS3-RD-L-LATIN2.TTF"; break;
case CELL_FONT_TYPE_RODIN_SANS_SERIF_BOLD_LATIN2: file = "/dev_flash/data/font/SCE-PS3-RD-B-LATIN2.TTF"; break;
case CELL_FONT_TYPE_MATISSE_SERIF_LATIN: file = "/dev_flash/data/font/SCE-PS3-MT-R-LATIN.TTF"; break;
case CELL_FONT_TYPE_NEWRODIN_GOTHIC_JAPANESE: file = "/dev_flash/data/font/SCE-PS3-NR-R-JPN.TTF"; break;
case CELL_FONT_TYPE_NEWRODIN_GOTHIC_LIGHT_JAPANESE: file = "/dev_flash/data/font/SCE-PS3-NR-L-JPN.TTF"; break;
case CELL_FONT_TYPE_NEWRODIN_GOTHIC_BOLD_JAPANESE: file = "/dev_flash/data/font/SCE-PS3-NR-B-JPN.TTF"; break;
case CELL_FONT_TYPE_YD_GOTHIC_KOREAN: file = "/dev_flash/data/font/SCE-PS3-YG-R-KOR.TTF"; break;
case CELL_FONT_TYPE_SEURAT_MARU_GOTHIC_LATIN: file = "/dev_flash/data/font/SCE-PS3-SR-R-LATIN.TTF"; break;
case CELL_FONT_TYPE_SEURAT_MARU_GOTHIC_LATIN2: file = "/dev_flash/data/font/SCE-PS3-SR-R-LATIN2.TTF"; break;
case CELL_FONT_TYPE_VAGR_SANS_SERIF_ROUND: file = "/dev_flash/data/font/SCE-PS3-VR-R-LATIN.TTF"; break;
case CELL_FONT_TYPE_VAGR_SANS_SERIF_ROUND_LATIN2: file = "/dev_flash/data/font/SCE-PS3-VR-R-LATIN2.TTF"; break;
case CELL_FONT_TYPE_SEURAT_MARU_GOTHIC_JAPANESE: file = "/dev_flash/data/font/SCE-PS3-SR-R-JPN.TTF"; break;
return CELL_FONT_OK;
case CELL_FONT_TYPE_NEWRODIN_GOTHIC_JP_SET:
case CELL_FONT_TYPE_NEWRODIN_GOTHIC_LATIN_SET:
case CELL_FONT_TYPE_NEWRODIN_GOTHIC_RODIN_SET:
case CELL_FONT_TYPE_NEWRODIN_GOTHIC_RODIN2_SET:
case CELL_FONT_TYPE_NEWRODIN_GOTHIC_YG_RODIN2_SET:
case CELL_FONT_TYPE_NEWRODIN_GOTHIC_YG_DFHEI5_SET:
case CELL_FONT_TYPE_NEWRODIN_GOTHIC_YG_DFHEI5_RODIN_SET:
case CELL_FONT_TYPE_NEWRODIN_GOTHIC_YG_DFHEI5_RODIN2_SET:
case CELL_FONT_TYPE_DFHEI5_GOTHIC_YG_NEWRODIN_TCH_SET:
case CELL_FONT_TYPE_DFHEI5_GOTHIC_YG_NEWRODIN_RODIN_TCH_SET:
case CELL_FONT_TYPE_DFHEI5_GOTHIC_YG_NEWRODIN_RODIN2_TCH_SET:
case CELL_FONT_TYPE_DFHEI5_GOTHIC_YG_NEWRODIN_SCH_SET:
case CELL_FONT_TYPE_DFHEI5_GOTHIC_YG_NEWRODIN_RODIN_SCH_SET:
case CELL_FONT_TYPE_DFHEI5_GOTHIC_YG_NEWRODIN_RODIN2_SCH_SET:
case CELL_FONT_TYPE_SEURAT_MARU_GOTHIC_RSANS_SET:
case CELL_FONT_TYPE_SEURAT_CAPIE_MARU_GOTHIC_RSANS_SET:
case CELL_FONT_TYPE_SEURAT_CAPIE_MARU_GOTHIC_JP_SET:
case CELL_FONT_TYPE_SEURAT_MARU_GOTHIC_YG_DFHEI5_RSANS_SET:
case CELL_FONT_TYPE_SEURAT_CAPIE_MARU_GOTHIC_YG_DFHEI5_RSANS_SET:
case CELL_FONT_TYPE_VAGR_SEURAT_CAPIE_MARU_GOTHIC_RSANS_SET:
case CELL_FONT_TYPE_VAGR_SEURAT_CAPIE_MARU_GOTHIC_YG_DFHEI5_RSANS_SET:
case CELL_FONT_TYPE_NEWRODIN_GOTHIC_YG_LIGHT_SET:
case CELL_FONT_TYPE_NEWRODIN_GOTHIC_YG_RODIN_LIGHT_SET:
case CELL_FONT_TYPE_NEWRODIN_GOTHIC_YG_RODIN2_LIGHT_SET:
case CELL_FONT_TYPE_NEWRODIN_GOTHIC_RODIN_LIGHT_SET:
case CELL_FONT_TYPE_NEWRODIN_GOTHIC_RODIN2_LIGHT_SET:
case CELL_FONT_TYPE_NEWRODIN_GOTHIC_YG_BOLD_SET:
case CELL_FONT_TYPE_NEWRODIN_GOTHIC_YG_RODIN_BOLD_SET:
case CELL_FONT_TYPE_NEWRODIN_GOTHIC_YG_RODIN2_BOLD_SET:
case CELL_FONT_TYPE_NEWRODIN_GOTHIC_RODIN_BOLD_SET:
case CELL_FONT_TYPE_NEWRODIN_GOTHIC_RODIN2_BOLD_SET:
case CELL_FONT_TYPE_SEURAT_MARU_GOTHIC_RSANS2_SET:
case CELL_FONT_TYPE_SEURAT_CAPIE_MARU_GOTHIC_RSANS2_SET:
case CELL_FONT_TYPE_SEURAT_MARU_GOTHIC_YG_DFHEI5_RSANS2_SET:
case CELL_FONT_TYPE_SEURAT_CAPIE_MARU_GOTHIC_YG_DFHEI5_RSANS2_SET:
case CELL_FONT_TYPE_SEURAT_CAPIE_MARU_GOTHIC_YG_DFHEI5_VAGR2_SET:
case CELL_FONT_TYPE_SEURAT_CAPIE_MARU_GOTHIC_VAGR2_SET:
cellFont.Warning("cellFontOpenFontset: fontType->type = %d not supported yet. RD-R-LATIN.TTF will be used instead.", fontType->type);
file = "/dev_flash/data/font/SCE-PS3-RD-R-LATIN.TTF";
break;
default:
cellFont.Warning("cellFontOpenFontset: fontType->type = %d not supported.", fontType->type);
return CELL_FONT_ERROR_NO_SUPPORT_FONTSET;
}
u32 file_addr = Memory.Alloc(file.length()+1, 1);
Memory.WriteString(file_addr, file);
int ret = cellFontOpenFontFile(library.GetAddr(), file_addr, 0, 0, font.GetAddr()); //TODO: The values of subNum, uniqueId may be incorrect
Memory.Free(file_addr);
return ret;
}
int cellFontOpenFontInstance(mem_ptr_t<CellFont> openedFont, mem_ptr_t<CellFont> font)
@ -486,12 +591,6 @@ int cellFontOpenFontsetOnMemory()
return CELL_FONT_OK;
}
int cellFontOpenFontFile()
{
UNIMPLEMENTED_FUNC(cellFont);
return CELL_FONT_OK;
}
int cellFontGraphicsSetScalePixel()
{
UNIMPLEMENTED_FUNC(cellFont);
@ -564,12 +663,6 @@ int cellFontGraphicsSetupDrawContext()
return CELL_FONT_OK;
}
int cellFontOpenFontMemory()
{
UNIMPLEMENTED_FUNC(cellFont);
return CELL_FONT_OK;
}
int cellFontSetupRenderEffectWeight()
{
UNIMPLEMENTED_FUNC(cellFont);

View File

@ -2,45 +2,36 @@
#include "RSXDebugger.h"
#include "Emu/Memory/Memory.h"
#include "Emu/GS/sysutil_video.h"
#include "Emu/GS/GCM.h"
const char* s_rsx_flags [] = {
"Alpha test",
"Blend",
"Cull face",
"Depth bounds test",
"Depth test",
"Dither",
"Line smooth",
"Logic op",
"Poly smooth",
"Poly offset fill",
"Poly offset line",
"Poly offset point",
"Stencil test",
enum GCMEnumTypes
{
CELL_GCM,
CELL_GCM_PRIMITIVE,
};
RSXDebugger::RSXDebugger(wxWindow* parent)
: wxFrame(parent, wxID_ANY, "RSX Debugger", wxDefaultPosition, wxSize(700, 450))
, m_item_count(23)
, m_addr(0x0)
, exit(false)
{
exit = false;
m_addr = 0x0;
m_colcount = 16;
this->SetBackgroundColour(wxColour(240,240,240)); //This fix the ugly background color under Windows
wxBoxSizer& s_panel = *new wxBoxSizer(wxHORIZONTAL);
//Tools
wxBoxSizer& s_tools = *new wxBoxSizer(wxVERTICAL);
//Controls: Memory Viewer Options
// Controls
wxStaticBoxSizer& s_controls = *new wxStaticBoxSizer(wxHORIZONTAL, this, "Memory Viewer Options");
// Controls: Address
wxStaticBoxSizer& s_controls_addr = *new wxStaticBoxSizer(wxHORIZONTAL, this, "Address:");
t_addr = new wxTextCtrl(this, wxID_ANY, "00000000", wxDefaultPosition, wxSize(60,-1));
t_addr->SetMaxLength(8);
s_controls_addr.Add(t_addr);
// Controls: Go to
wxStaticBoxSizer& s_controls_goto = *new wxStaticBoxSizer(wxHORIZONTAL, this, "Go to:");
wxButton* b_goto_get = new wxButton(this, wxID_ANY, "Get", wxDefaultPosition, wxSize(40,-1));
wxButton* b_goto_put = new wxButton(this, wxID_ANY, "Put", wxDefaultPosition, wxSize(40,-1));
@ -100,29 +91,26 @@ RSXDebugger::RSXDebugger(wxWindow* parent)
m_list_settings ->SetFont(wxFont(8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
//Tabs: List Columns
m_list_commands->InsertColumn(0, "Address", 0, 100);
m_list_commands->InsertColumn(1, "Value", 0, 100);
m_list_commands->InsertColumn(0, "Address", 0, 80);
m_list_commands->InsertColumn(1, "Value", 0, 80);
m_list_commands->InsertColumn(2, "Command", 0, 250);
m_list_commands->InsertColumn(3, "Count", 0, 40);
m_list_flags->InsertColumn(0, "Name", 0, 150);
m_list_flags->InsertColumn(1, "Value", 0, 300);
m_list_lightning->InsertColumn(0, "Name");
m_list_lightning->InsertColumn(1, "Value");
m_list_texture->InsertColumn(0, "Name");
m_list_texture->InsertColumn(1, "Value");
m_list_settings->InsertColumn(0, "Name");
m_list_settings->InsertColumn(1, "Value");
m_list_lightning->InsertColumn(0, "Name", 0, 150);
m_list_lightning->InsertColumn(1, "Value", 0, 300);
m_list_texture->InsertColumn(0, "Name", 0, 150);
m_list_texture->InsertColumn(1, "Value", 0, 300);
m_list_settings->InsertColumn(0, "Name", 0, 150);
m_list_settings->InsertColumn(1, "Value", 0, 300);
// Fill list
for(u32 i=0; i<m_item_count; i++)
{
m_list_commands->InsertItem(m_list_commands->GetItemCount(), wxEmptyString);
}
for(u32 i=0; i < sizeof(s_rsx_flags)/sizeof(s_rsx_flags[0]); i++)
{
m_list_flags->InsertItem(m_list_flags->GetItemCount(), s_rsx_flags[i]);
}
//Tools: Tools = Memory Viewer Options + Raw Image Preview Options + Buttons
//Tools: Tools = Controls + Notebook Tabs
s_tools.AddSpacer(10);
s_tools.Add(&s_controls);
s_tools.AddSpacer(10);
@ -142,9 +130,7 @@ RSXDebugger::RSXDebugger(wxWindow* parent)
//Buffers and textures
CellVideoOutResolution res = ResolutionTable[ResolutionIdToNum(Ini.GSResolution.GetValue())];
m_buffers_width = res.width;
m_buffers_height = res.height;
m_panel_width = (m_buffers_width*108)/m_buffers_height;
m_panel_width = (res.width*108)/res.height;
m_panel_height = 108;
m_text_width = 108;
m_text_height = 108;
@ -156,14 +142,14 @@ RSXDebugger::RSXDebugger(wxWindow* parent)
p_buffer_colorD = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(m_panel_width, m_panel_height));
p_buffer_depth = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(m_panel_width, m_panel_height));
p_buffer_stencil = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(m_panel_width, m_panel_height));
p_buffer_text = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(m_text_width, m_text_height));
p_buffer_tex = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(m_text_width, m_text_height));
s_buffers_colorA.Add(p_buffer_colorA);
s_buffers_colorB.Add(p_buffer_colorB);
s_buffers_colorC.Add(p_buffer_colorC);
s_buffers_colorD.Add(p_buffer_colorD);
s_buffers_depth.Add(p_buffer_depth);
s_buffers_stencil.Add(p_buffer_stencil);
s_buffers_text.Add(p_buffer_text);
s_buffers_text.Add(p_buffer_tex);
//Merge and display everything
s_buffers1.AddSpacer(10);
@ -201,7 +187,7 @@ RSXDebugger::RSXDebugger(wxWindow* parent)
Connect(b_goto_put->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(RSXDebugger::GoToPut));
m_list_commands->Connect(wxEVT_MOUSEWHEEL, wxMouseEventHandler(RSXDebugger::OnScrollMemory), NULL, this);
m_list_flags->Connect(wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler(RSXDebugger::ModifyFlags), NULL, this);
m_list_flags->Connect(wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler(RSXDebugger::SetFlags), NULL, this);
//Fill the frame
UpdateInformation();
@ -253,14 +239,21 @@ void RSXDebugger::GoToPut(wxCommandEvent& event)
void RSXDebugger::UpdateInformation()
{
ShowMemory();
ShowBuffers();
ShowFlags();
this->SetFocus();
GetMemory();
GetBuffers();
GetFlags();
GetLightning();
GetTexture();
GetSettings();
}
void RSXDebugger::ShowMemory()
void RSXDebugger::GetMemory()
{
// Clean commands column
for(u32 i=0; i<m_item_count; i++)
m_list_commands->SetItem(i, 2, wxEmptyString);
// Write information
for(u32 i=0; i<m_item_count; i++)
{
u32 addr = m_addr + 4*i;
@ -269,7 +262,18 @@ void RSXDebugger::ShowMemory()
if (Memory.IsGoodAddr(addr))
{
u32 cmd = Memory.Read32(addr);
u32 count = (cmd >> 18) & 0x7ff;
u32 ioAddr = Emu.GetGSManager().GetRender().m_ioAddress;
m_list_commands->SetItem(i, 1, wxString::Format("%08x", cmd));
m_list_commands->SetItem(i, 3, wxString::Format("%d", count));
if (count > 0)
{
wxString disasm = DisAsmCommand(cmd, count, addr, ioAddr);
for (u32 j=0; j<count && i+j<m_item_count; j++)
{
m_list_commands->SetItem(i+j, 2, disasm);
}
}
}
else
{
@ -278,13 +282,12 @@ void RSXDebugger::ShowMemory()
}
}
void RSXDebugger::ShowBuffers()
void RSXDebugger::GetBuffers()
{
// TODO: This is a *very* ugly way of checking if m_render was initialized. It throws an error while debugging with VS
if (!RSXReady()) return;
const GSRender& render = Emu.GetGSManager().GetRender();
if (!&render)
return;
// Draw Buffers
// TODO: Currently it only supports color buffers
for (u32 bufferId=0; bufferId < render.m_gcm_buffers_count; bufferId++)
{
@ -316,40 +319,148 @@ void RSXDebugger::ShowBuffers()
default: pnl = p_buffer_colorD; break;
}
wxImage img(m_buffers_width, m_buffers_height, buffer);
wxImage img(width, height, buffer);
wxClientDC dc_canvas(pnl);
dc_canvas.DrawBitmap(img.Scale(m_panel_width, m_panel_height), 0, 0, false);
}
// Draw Texture
u32 TexBuffer_addr = render.m_textures[0].m_offset;
unsigned char* TexBuffer = (unsigned char*)Memory.VirtualToRealAddr(TexBuffer_addr);
u32 width = render.m_textures[0].m_width;
u32 height = render.m_textures[0].m_height;
unsigned char* buffer = (unsigned char*)malloc(width * height * 3);
memcpy(buffer, TexBuffer, width * height * 3);
wxImage img(width, height, buffer);
wxClientDC dc_canvas(p_buffer_tex);
dc_canvas.DrawBitmap(img.Scale(m_text_width, m_text_height), 0, 0, false);
}
void RSXDebugger::ShowFlags()
void RSXDebugger::GetFlags()
{
if (!RSXReady())
{
for (u32 i=0; i<m_list_flags->GetItemCount(); i++)
{
m_list_flags->SetItem(i, 1, "N/A");
}
return;
}
if (!RSXReady()) return;
const GSRender& render = Emu.GetGSManager().GetRender();
m_list_flags->DeleteAllItems();
int i=0;
m_list_flags->SetItem(i++, 1, render.m_set_alpha_test ? "Enabled" : "Disabled");
m_list_flags->SetItem(i++, 1, render.m_set_blend ? "Enabled" : "Disabled");
m_list_flags->SetItem(i++, 1, render.m_set_cull_face_enable ? "Enabled" : "Disabled");
m_list_flags->SetItem(i++, 1, render.m_set_depth_bounds_test ? "Enabled" : "Disabled");
m_list_flags->SetItem(i++, 1, render.m_depth_test_enable ? "Enabled" : "Disabled");
m_list_flags->SetItem(i++, 1, render.m_set_dither ? "Enabled" : "Disabled");
m_list_flags->SetItem(i++, 1, render.m_set_line_smooth ? "Enabled" : "Disabled");
m_list_flags->SetItem(i++, 1, render.m_set_logic_op ? "Enabled" : "Disabled");
m_list_flags->SetItem(i++, 1, render.m_set_poly_smooth ? "Enabled" : "Disabled");
m_list_flags->SetItem(i++, 1, render.m_set_poly_offset_fill ? "Enabled" : "Disabled");
m_list_flags->SetItem(i++, 1, render.m_set_poly_offset_line ? "Enabled" : "Disabled");
m_list_flags->SetItem(i++, 1, render.m_set_poly_offset_point ? "Enabled" : "Disabled");
m_list_flags->SetItem(i++, 1, render.m_set_stencil_test ? "Enabled" : "Disabled");
#define LIST_FLAGS_ADD(name, value) \
m_list_flags->InsertItem(i, name); m_list_flags->SetItem(i, 1, value ? "Enabled" : "Disabled"); i++;
LIST_FLAGS_ADD("Alpha test", render.m_set_alpha_test);
LIST_FLAGS_ADD("Blend", render.m_set_blend);
LIST_FLAGS_ADD("Cull face", render.m_set_cull_face_enable);
LIST_FLAGS_ADD("Depth bounds test", render.m_set_depth_bounds_test);
LIST_FLAGS_ADD("Depth test", render.m_depth_test_enable);
LIST_FLAGS_ADD("Dither", render.m_set_dither);
LIST_FLAGS_ADD("Line smooth", render.m_set_line_smooth);
LIST_FLAGS_ADD("Logic op", render.m_set_logic_op);
LIST_FLAGS_ADD("Poly smooth", render.m_set_poly_smooth);
LIST_FLAGS_ADD("Poly offset fill", render.m_set_poly_offset_fill);
LIST_FLAGS_ADD("Poly offset line", render.m_set_poly_offset_line);
LIST_FLAGS_ADD("Poly offset point", render.m_set_poly_offset_point);
LIST_FLAGS_ADD("Stencil test", render.m_set_stencil_test);
#undef LIST_FLAGS_ADD
}
void RSXDebugger::ModifyFlags(wxListEvent& event)
void RSXDebugger::GetLightning()
{
if (!RSXReady()) return;
const GSRender& render = Emu.GetGSManager().GetRender();
m_list_lightning->DeleteAllItems();
int i=0;
#define LIST_LIGHTNING_ADD(name, value) \
m_list_lightning->InsertItem(i, name); m_list_lightning->SetItem(i, 1, value); i++;
LIST_LIGHTNING_ADD("Shade model", (render.m_shade_mode == 0x1D00) ? "Flat" : "Smooth");
#undef LIST_LIGHTNING_ADD
}
void RSXDebugger::GetTexture()
{
if (!RSXReady()) return;
const GSRender& render = Emu.GetGSManager().GetRender();
m_list_texture->DeleteAllItems();
int i=0;
#define LIST_TEXTURE_ADD(name, value) \
m_list_texture->InsertItem(i, name); m_list_texture->SetItem(i, 1, value); i++;
LIST_TEXTURE_ADD("Texture #0 Address:", wxString::Format("0x%x", render.m_textures[0].m_offset));
LIST_TEXTURE_ADD("Texture #0 Size:", wxString::Format("%d x %d",
render.m_textures[0].m_width,
render.m_textures[0].m_height));
#undef LIST_TEXTURE_ADD
}
void RSXDebugger::GetSettings()
{
if (!RSXReady()) return;
const GSRender& render = Emu.GetGSManager().GetRender();
m_list_settings->DeleteAllItems();
int i=0;
#define LIST_SETTINGS_ADD(name, value) \
m_list_settings->InsertItem(i, name); m_list_settings->SetItem(i, 1, value); i++;
LIST_SETTINGS_ADD("Alpha func", !(render.m_set_alpha_func) ? "(none)" : wxString::Format("0x%x (%s)",
render.m_alpha_func,
ParseGCMEnum(render.m_alpha_func, CELL_GCM)));
LIST_SETTINGS_ADD("Blend color", !(render.m_set_blend_color) ? "(none)" : wxString::Format("R:%d, G:%d, B:%d, A:%d",
render.m_blend_color_r,
render.m_blend_color_g,
render.m_blend_color_b,
render.m_blend_color_a));
LIST_SETTINGS_ADD("Clipping", wxString::Format("Min:%f, Max:%f", render.m_clip_min, render.m_clip_max));
LIST_SETTINGS_ADD("Color mask", !(render.m_set_color_mask) ? "(none)" : wxString::Format("R:%d, G:%d, B:%d, A:%d",
render.m_color_mask_r,
render.m_color_mask_g,
render.m_color_mask_b,
render.m_color_mask_a));
LIST_SETTINGS_ADD("Context DMA Color A", wxString::Format("0x%x", render.m_context_dma_color_a));
LIST_SETTINGS_ADD("Context DMA Color B", wxString::Format("0x%x", render.m_context_dma_color_b));
LIST_SETTINGS_ADD("Context DMA Color C", wxString::Format("0x%x", render.m_context_dma_color_c));
LIST_SETTINGS_ADD("Context DMA Color D", wxString::Format("0x%x", render.m_context_dma_color_d));
LIST_SETTINGS_ADD("Context DMA Zeta", wxString::Format("0x%x", render.m_context_dma_z));
LIST_SETTINGS_ADD("Depth func", !(render.m_set_depth_func) ? "(none)" : wxString::Format("0x%x (%s)",
render.m_depth_func,
ParseGCMEnum(render.m_depth_func, CELL_GCM)));
LIST_SETTINGS_ADD("Draw mode", wxString::Format("%d (%s)",
render.m_draw_mode,
ParseGCMEnum(render.m_draw_mode, CELL_GCM_PRIMITIVE)));
LIST_SETTINGS_ADD("Scissor", wxString::Format("X:%d, Y:%d, W:%d, H:%d",
render.m_scissor_x,
render.m_scissor_y,
render.m_scissor_w,
render.m_scissor_h));
LIST_SETTINGS_ADD("Stencil func", !(render.m_set_stencil_func) ? "(none)" : wxString::Format("0x%x (%s)",
render.m_stencil_func,
ParseGCMEnum(render.m_stencil_func, CELL_GCM)));
LIST_SETTINGS_ADD("Surface Pitch A", wxString::Format("0x%x", render.m_surface_pitch_a));
LIST_SETTINGS_ADD("Surface Pitch B", wxString::Format("0x%x", render.m_surface_pitch_b));
LIST_SETTINGS_ADD("Surface Pitch C", wxString::Format("0x%x", render.m_surface_pitch_c));
LIST_SETTINGS_ADD("Surface Pitch D", wxString::Format("0x%x", render.m_surface_pitch_d));
LIST_SETTINGS_ADD("Surface Pitch Z", wxString::Format("0x%x", render.m_surface_pitch_z));
LIST_SETTINGS_ADD("Surface Offset A", wxString::Format("0x%x", render.m_surface_offset_a));
LIST_SETTINGS_ADD("Surface Offset B", wxString::Format("0x%x", render.m_surface_offset_b));
LIST_SETTINGS_ADD("Surface Offset C", wxString::Format("0x%x", render.m_surface_offset_c));
LIST_SETTINGS_ADD("Surface Offset D", wxString::Format("0x%x", render.m_surface_offset_d));
LIST_SETTINGS_ADD("Surface Offset Z", wxString::Format("0x%x", render.m_surface_offset_z));
LIST_SETTINGS_ADD("Viewport", wxString::Format("X:%d, Y:%d, W:%d, H:%d",
render.m_viewport_x,
render.m_viewport_y,
render.m_viewport_w,
render.m_viewport_h));
#undef LIST_SETTINGS_ADD
}
void RSXDebugger::SetFlags(wxListEvent& event)
{
if (!RSXReady()) return;
GSRender& render = Emu.GetGSManager().GetRender();
@ -372,6 +483,199 @@ void RSXDebugger::ModifyFlags(wxListEvent& event)
UpdateInformation();
}
wxString RSXDebugger::ParseGCMEnum(u32 value, u32 type)
{
switch(type)
{
case CELL_GCM:
{
switch(value)
{
case 0x0200: return "Never";
case 0x0201: return "Less";
case 0x0202: return "Equal";
case 0x0203: return "Less or Equal";
case 0x0204: return "Greater";
case 0x0205: return "Not Equal";
case 0x0206: return "Greater or Equal";
case 0x0207: return "Always";
case 0x0: return "Zero";
case 0x1: return "One";
case 0x0300: return "SRC_COLOR";
case 0x0301: return "1 - SRC_COLOR";
case 0x0302: return "SRC_ALPHA";
case 0x0303: return "1 - SRC_ALPHA";
case 0x0304: return "DST_ALPHA";
case 0x0305: return "1 - DST_ALPHA";
case 0x0306: return "DST_COLOR";
case 0x0307: return "1 - DST_COLOR";
case 0x0308: return "SRC_ALPHA_SATURATE";
case 0x8001: return "CONSTANT_COLOR";
case 0x8002: return "1 - CONSTANT_COLOR";
case 0x8003: return "CONSTANT_ALPHA";
case 0x8004: return "1 - CONSTANT_ALPHA";
case 0x8006: return "Add";
case 0x8007: return "Min";
case 0x8008: return "Max";
case 0x800A: return "Substract";
case 0x800B: return "Reverse Substract";
case 0xF005: return "Reverse Substract Signed";
case 0xF006: return "Add Signed";
case 0xF007: return "Reverse Add Signed";
default: return "Wrong Value!";
}
}
case CELL_GCM_PRIMITIVE:
{
switch(value)
{
case 1: return "POINTS";
case 2: return "LINES";
case 3: return "LINE_LOOP";
case 4: return "LINE_STRIP";
case 5: return "TRIANGLES";
case 6: return "TRIANGLE_STRIP";
case 7: return "TRIANGLE_FAN";
case 8: return "QUADS";
case 9: return "QUAD_STRIP";
case 10: return "POLYGON";
default: return "Wrong Value!";
}
}
default: return "Unknown!";
}
}
#define case_16(a, m) \
case a + m: \
case a + m * 2: \
case a + m * 3: \
case a + m * 4: \
case a + m * 5: \
case a + m * 6: \
case a + m * 7: \
case a + m * 8: \
case a + m * 9: \
case a + m * 10: \
case a + m * 11: \
case a + m * 12: \
case a + m * 13: \
case a + m * 14: \
case a + m * 15: \
index = (cmd - a) / m; \
case a \
wxString RSXDebugger::DisAsmCommand(u32 cmd, u32 count, u32 currentAddr, u32 ioAddr)
{
wxString disasm = wxEmptyString;
if(cmd & CELL_GCM_METHOD_FLAG_JUMP)
{
u32 jumpAddr = cmd & ~(CELL_GCM_METHOD_FLAG_JUMP | CELL_GCM_METHOD_FLAG_NON_INCREMENT);
disasm = wxString::Format("JUMP: %08x -> %08x", currentAddr, ioAddr+jumpAddr);
}
if(cmd & CELL_GCM_METHOD_FLAG_CALL)
{
u32 callAddr = cmd & ~CELL_GCM_METHOD_FLAG_CALL;
disasm = wxString::Format("CALL: %08x -> %08x", currentAddr, ioAddr+callAddr);
}
if(cmd == CELL_GCM_METHOD_FLAG_RETURN)
{
disasm = "RETURN";
}
if(cmd & CELL_GCM_METHOD_FLAG_NON_INCREMENT)
{
disasm = "Non Increment cmd";
}
if(cmd == 0)
{
disasm = "Null cmd";
}
u32 index = 0;
mem32_ptr_t args(currentAddr + 4);
switch(cmd & 0x3ffff)
{
case 0x3fead:
disasm = "???"; break;
case NV4097_NO_OPERATION:
disasm = "NOP"; break;
case NV406E_SET_REFERENCE:
disasm = "???"; break;
case_16(NV4097_SET_TEXTURE_OFFSET, 0x20):
disasm = wxString::Format(" Texture Offset: %08x", args[0]);
switch ((args[1] & 0x3) - 1)
{
case CELL_GCM_LOCATION_LOCAL: disasm += " (Local memory);"; break;
case CELL_GCM_LOCATION_MAIN: disasm += " (Main memory);"; break;
default: disasm += " (Bad location!);"; break;
}
disasm += wxString::Format(" Cubemap:%s; Dimension:0x%x; Format:0x%x; Mipmap:0x%x",
((args[1] >> 2) & 0x1) ? "True" : "False",
((args[1] >> 4) & 0xf),
((args[1] >> 8) & 0xff),
((args[1] >> 16) & 0xffff));
break;
case NV4097_SET_COLOR_MASK:
disasm = wxString::Format(" Color mask: True (A:%d, R:%d, G:%d, B:%d)",
args[0] & 0x1000000 ? "1" : "0",
args[0] & 0x0010000 ? "1" : "0",
args[0] & 0x0000100 ? "1" : "0",
args[0] & 0x0000001 ? "1" : "0");
break;
case NV4097_SET_ALPHA_TEST_ENABLE:
disasm = args[0] ? "Alpha test: Enable" : "Alpha test: Disable";
break;
case NV4097_SET_BLEND_ENABLE:
disasm = args[0] ? "Blend: Enable" : "Blend: Disable";
break;
case NV4097_SET_DEPTH_BOUNDS_TEST_ENABLE:
disasm = args[0] ? "Depth bounds test: Enable" : "Depth bounds test: Disable";
break;
case NV4097_SET_CONTEXT_DMA_COLOR_A:
disasm = wxString::Format("Context DMA Color A: 0x%x", args[0]);
break;
case NV4097_SET_CONTEXT_DMA_COLOR_B:
disasm = wxString::Format("Context DMA Color B: 0x%x", args[0]);
break;
case NV4097_SET_CONTEXT_DMA_COLOR_C:
disasm = wxString::Format("Context DMA Color C: 0x%x", args[0]);
if(count > 1)
disasm = wxString::Format("Context DMA Color C: 0x%x", args[1]);
break;
case NV4097_SET_CONTEXT_DMA_ZETA:
disasm = wxString::Format("Context DMA Zeta: 0x%x", args[0]);
break;
case NV4097_SET_SURFACE_PITCH_C:
disasm = wxString::Format("Surface Pitch C: 0x%x; ", args[0]);
disasm += wxString::Format("Surface Pitch D: 0x%x; ", args[1]);
disasm += wxString::Format("Surface Offset C: 0x%x; ", args[2]);
disasm += wxString::Format("Surface Offset D: 0x%x", args[3]);
break;
case NV4097_SET_SURFACE_PITCH_Z:
disasm = wxString::Format("Surface Pitch Z: 0x%x; ", args[0]);
break;
default:
break;
}
return disasm;
}
bool RSXDebugger::RSXReady()
{
// TODO: This is a *very* ugly way of checking if m_render was initialized. It throws an error while debugging in VS
@ -382,4 +686,3 @@ bool RSXDebugger::RSXReady()
}
return true;
}

View File

@ -5,11 +5,7 @@
class RSXDebugger : public wxFrame
{
u32 m_addr;
u32 m_colcount;
u32 m_rowcount;
u32 m_buffers_width;
u32 m_buffers_height;
u32 m_panel_width;
u32 m_panel_height;
u32 m_text_width;
@ -30,7 +26,7 @@ class RSXDebugger : public wxFrame
wxPanel* p_buffer_colorD;
wxPanel* p_buffer_depth;
wxPanel* p_buffer_stencil;
wxPanel* p_buffer_text;
wxPanel* p_buffer_tex;
public:
bool exit;
@ -48,11 +44,18 @@ public:
virtual void GoToPut(wxCommandEvent& event);
virtual void UpdateInformation();
virtual void ShowMemory();
virtual void ShowBuffers();
virtual void ShowFlags();
virtual void GetMemory();
virtual void GetBuffers();
virtual void GetFlags();
virtual void GetLightning();
virtual void GetTexture();
virtual void GetSettings();
virtual void SetFlags(wxListEvent& event);
wxString ParseGCMEnum(u32 value, u32 type);
wxString DisAsmCommand(u32 cmd, u32 count, u32 currentAddr, u32 ioAddr);
virtual void ModifyFlags(wxListEvent& event);
bool RSXReady();
void SetPC(const uint pc) { m_addr = pc; }