This commit is contained in:
Nekotekina 2014-08-19 12:32:00 +04:00
commit 4446aa5d17
33 changed files with 1263 additions and 437 deletions

View File

@ -16,7 +16,7 @@ before_install:
- echo "yes" | sudo apt-add-repository 'deb http://repos.codelite.org/wx3.0/ubuntu/ precise universe' - echo "yes" | sudo apt-add-repository 'deb http://repos.codelite.org/wx3.0/ubuntu/ precise universe'
- sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
- sudo apt-get update - sudo apt-get update
- sudo apt-get install libwxgtk3.0-dev libopenal-dev freeglut3-dev libglew-dev - sudo apt-get install libwxgtk3.0-dev libopenal-dev freeglut3-dev libglew-dev libc6-dev
- sudo apt-get install aria2 -qq - sudo apt-get install aria2 -qq
- download_extract() { aria2c -x 16 $1 -o $2 && tar -xf $2; } - download_extract() { aria2c -x 16 $1 -o $2 && tar -xf $2; }
- if [ "$CXX" = "g++" ]; then sudo apt-get install -qq g++-4.8; export CXX="g++-4.8" CC="gcc-4.8"; else sudo apt-get install libstdc++-4.8-dev; fi - if [ "$CXX" = "g++" ]; then sudo apt-get install -qq g++-4.8; export CXX="g++-4.8" CC="gcc-4.8"; else sudo apt-get install libstdc++-4.8-dev; fi

View File

@ -16,7 +16,7 @@ AutoPause& AutoPause::getInstance(void)
return *gAutoPause; return *gAutoPause;
} }
//Still use binary format. Default Setting should be "disable all auto-pause". //Still use binary format. Default Setting should be "disable all auto pause".
AutoPause::AutoPause(void) AutoPause::AutoPause(void)
{ {
m_pause_function.reserve(16); m_pause_function.reserve(16);
@ -36,7 +36,7 @@ AutoPause::~AutoPause(void)
m_pause_syscall_enable = false; m_pause_syscall_enable = false;
} }
//Load Auto-Pause Configuration from file "pause.bin" //Load Auto Pause Configuration from file "pause.bin"
//This would be able to create in a GUI window. //This would be able to create in a GUI window.
void AutoPause::Reload(void) void AutoPause::Reload(void)
{ {
@ -65,19 +65,19 @@ void AutoPause::Reload(void)
//Less than 1024 - be regarded as a system call. //Less than 1024 - be regarded as a system call.
//emplace_back may not cause reductant move/copy operation. //emplace_back may not cause reductant move/copy operation.
m_pause_syscall.emplace_back(num); m_pause_syscall.emplace_back(num);
LOG_WARNING(HLE, "Auto-Pause: Find System Call ID %x", num); LOG_WARNING(HLE, "Auto Pause: Find System Call ID %x", num);
} }
else else
{ {
m_pause_function.emplace_back(num); m_pause_function.emplace_back(num);
LOG_WARNING(HLE, "Auto-Pause: Find Function Call ID %x", num); LOG_WARNING(HLE, "Auto Pause: Find Function Call ID %x", num);
} }
} }
list.Close(); list.Close();
} }
else else
{ {
LOG_WARNING(HLE, "No Pause ID specified in pause.bin, Auto-Pause would not act."); LOG_WARNING(HLE, "No pause.bin found, Auto Pause will not work.");
} }
m_pause_syscall_enable = Ini.DBGAutoPauseSystemCall.GetValue(); m_pause_syscall_enable = Ini.DBGAutoPauseSystemCall.GetValue();
m_pause_function_enable = Ini.DBGAutoPauseFunctionCall.GetValue(); m_pause_function_enable = Ini.DBGAutoPauseFunctionCall.GetValue();
@ -99,7 +99,7 @@ void AutoPause::TryPause(u32 code) {
if (code == m_pause_syscall[i]) if (code == m_pause_syscall[i])
{ {
Emu.Pause(); Emu.Pause();
LOG_ERROR(HLE, "Auto-Pause Triggered: System call %x", code); //Used Error LOG_ERROR(HLE, "Auto Pause Triggered: System call %x", code); //Used Error
} }
} }
} }
@ -117,7 +117,7 @@ void AutoPause::TryPause(u32 code) {
if (code == m_pause_function[i]) if (code == m_pause_function[i])
{ {
Emu.Pause(); Emu.Pause();
LOG_ERROR(HLE, "Auto-Pause Triggered: Function call %x", code); //Used Error LOG_ERROR(HLE, "Auto Pause Triggered: Function call %x", code); //Used Error
} }
} }
} }

View File

@ -238,17 +238,17 @@ struct CellGcmSurface
u8 colorFormat; u8 colorFormat;
u8 colorTarget; u8 colorTarget;
u8 colorLocation[4]; u8 colorLocation[4];
u32 colorOffset[4]; be_t<u32> colorOffset[4];
u32 colorPitch[4]; be_t<u32> colorPitch[4];
u8 depthFormat; u8 depthFormat;
u8 depthLocation; u8 depthLocation;
u8 _padding[2]; u8 _padding[2];
u32 depthOffset; be_t<u32> depthOffset;
u32 depthPitch; be_t<u32> depthPitch;
u16 width; be_t<u16> width;
u16 height; be_t<u16> height;
u16 x; be_t<u16> x;
u16 y; be_t<u16> y;
}; };
struct CellGcmReportData struct CellGcmReportData
@ -268,6 +268,14 @@ struct CellGcmZcullInfo
u32 status1; u32 status1;
}; };
struct CellGcmDisplayInfo
{
be_t<u32> offset;
be_t<u32> pitch;
be_t<u32> width;
be_t<u32> height;
};
struct CellGcmTileInfo struct CellGcmTileInfo
{ {
be_t<u32> tile; be_t<u32> tile;

View File

@ -267,9 +267,8 @@ std::string GLFragmentDecompilerThread::BuildCode()
std::string p; std::string p;
for (u32 i = 0; i<m_parr.params.size(); ++i) for (auto& param : m_parr.params) {
{ p += param.Format();
p += m_parr.params[i].Format();
} }
return std::string("#version 330\n" return std::string("#version 330\n"
@ -321,115 +320,114 @@ void GLFragmentDecompilerThread::Task()
switch(opcode) switch(opcode)
{ {
case 0x00: break; //NOP case RSX_FP_OPCODE_NOP: break;
case 0x01: SetDst("$0"); break; //MOV case RSX_FP_OPCODE_MOV: SetDst("$0"); break;
case 0x02: SetDst("($0 * $1)"); break; //MUL case RSX_FP_OPCODE_MUL: SetDst("($0 * $1)"); break;
case 0x03: SetDst("($0 + $1)"); break; //ADD case RSX_FP_OPCODE_ADD: SetDst("($0 + $1)"); break;
case 0x04: SetDst("($0 * $1 + $2)"); break; //MAD case RSX_FP_OPCODE_MAD: SetDst("($0 * $1 + $2)"); break;
case 0x05: SetDst("vec4(dot($0.xyz, $1.xyz))"); break; // DP3 case RSX_FP_OPCODE_DP3: SetDst("vec4(dot($0.xyz, $1.xyz))"); break;
case 0x06: SetDst("vec4(dot($0, $1))"); break; // DP4 case RSX_FP_OPCODE_DP4: SetDst("vec4(dot($0, $1))"); break;
case 0x07: SetDst("vec4(distance($0, $1))"); break; // DST case RSX_FP_OPCODE_DST: SetDst("vec4(distance($0, $1))"); break;
case 0x08: SetDst("min($0, $1)"); break; // MIN case RSX_FP_OPCODE_MIN: SetDst("min($0, $1)"); break;
case 0x09: SetDst("max($0, $1)"); break; // MAX case RSX_FP_OPCODE_MAX: SetDst("max($0, $1)"); break;
case 0x0a: SetDst("vec4(lessThan($0, $1))"); break; // SLT case RSX_FP_OPCODE_SLT: SetDst("vec4(lessThan($0, $1))"); break;
case 0x0b: SetDst("vec4(greaterThanEqual($0, $1))"); break; // SGE case RSX_FP_OPCODE_SGE: SetDst("vec4(greaterThanEqual($0, $1))"); break;
case 0x0c: SetDst("vec4(lessThanEqual($0, $1))"); break; // SLE case RSX_FP_OPCODE_SLE: SetDst("vec4(lessThanEqual($0, $1))"); break;
case 0x0d: SetDst("vec4(greaterThan($0, $1))"); break; // SGT case RSX_FP_OPCODE_SGT: SetDst("vec4(greaterThan($0, $1))"); break;
case 0x0e: SetDst("vec4(notEqual($0, $1))"); break; // SNE case RSX_FP_OPCODE_SNE: SetDst("vec4(notEqual($0, $1))"); break;
case 0x0f: SetDst("vec4(equal($0, $1))"); break; // SEQ case RSX_FP_OPCODE_SEQ: SetDst("vec4(equal($0, $1))"); break;
case 0x10: SetDst("fract($0)"); break; // FRC case RSX_FP_OPCODE_FRC: SetDst("fract($0)"); break;
case 0x11: SetDst("floor($0)"); break; // FLR case RSX_FP_OPCODE_FLR: SetDst("floor($0)"); break;
case 0x12: SetDst("discard", false); break; // KIL (kill fragment) case RSX_FP_OPCODE_KIL: SetDst("discard", false); break;
//case 0x13: break; // PK4 (pack four signed 8-bit values) //case RSX_FP_OPCODE_PK4: break;
//case 0x14: break; // UP4 (unpack four signed 8-bit values) //case RSX_FP_OPCODE_UP4: break;
case 0x15: SetDst("dFdx($0)"); break; // DDX case RSX_FP_OPCODE_DDX: SetDst("dFdx($0)"); break;
case 0x16: SetDst("dFdy($0)"); break; // DDY case RSX_FP_OPCODE_DDY: SetDst("dFdy($0)"); break;
case 0x17: SetDst("texture($t, $0.xy)"); break; // TEX (texture lookup) case RSX_FP_OPCODE_TEX: SetDst("texture($t, $0.xy)"); break;
//case 0x18: break; // TXP (projective texture lookup) //case RSX_FP_OPCODE_TXP: break;
//case 0x19: break; // TXD (texture lookup with derivatives) //case RSX_FP_OPCODE_TXD: break;
case 0x1a: SetDst("(1 / $0)"); break; // RCP case RSX_FP_OPCODE_RCP: SetDst("(1 / $0)"); break;
case 0x1b: SetDst("inversesqrt(abs($0))"); break; // RSQ case RSX_FP_OPCODE_RSQ: SetDst("inversesqrt(abs($0))"); break;
case 0x1c: SetDst("exp2($0)"); break; // EX2 case RSX_FP_OPCODE_EX2: SetDst("exp2($0)"); break;
case 0x1d: SetDst("log2($0)"); break; // LG2 case RSX_FP_OPCODE_LG2: SetDst("log2($0)"); break;
case 0x1e: SetDst("vec4(1.0, $0.x, ($0.x > 0 ? exp2($0.w * log2($0.y)) : 0.0), 1.0)"); break; // LIT (compute light coefficients) case RSX_FP_OPCODE_LIT: SetDst("vec4(1.0, $0.x, ($0.x > 0 ? exp2($0.w * log2($0.y)) : 0.0), 1.0)"); break;
case 0x1f: SetDst("($0 * ($1 - $2) + $2)"); break; // LRP (linear interpolation) case RSX_FP_OPCODE_LRP: SetDst("($0 * ($1 - $2) + $2)"); break;
case 0x20: SetDst("vec4(equal($0, vec4(1.0)))"); break; // STR (set on true) case RSX_FP_OPCODE_STR: SetDst("vec4(equal($0, vec4(1.0)))"); break;
case 0x21: SetDst("vec4(equal($0, vec4(0.0)))"); break; // SFL (set on false) case RSX_FP_OPCODE_SFL: SetDst("vec4(equal($0, vec4(0.0)))"); break;
case 0x22: SetDst("cos($0)"); break; // COS case RSX_FP_OPCODE_COS: SetDst("cos($0)"); break;
case 0x23: SetDst("sin($0)"); break; // SIN case RSX_FP_OPCODE_SIN: SetDst("sin($0)"); break;
//case 0x24: break; // PK2 (pack two 16-bit floats) //case RSX_FP_OPCODE_PK2: break;
//case 0x25: break; // UP2 (unpack two 16-bit floats) //case RSX_FP_OPCODE_UP2: break;
case 0x26: SetDst("pow($0, $1)"); break; // POW case RSX_FP_OPCODE_POW: SetDst("pow($0, $1)"); break;
//case 0x27: break; // PKB //case RSX_FP_OPCODE_PKB: break;
//case 0x28: break; // UPB //case RSX_FP_OPCODE_UPB: break;
//case 0x29: break; // PK16 //case RSX_FP_OPCODE_PK16: break;
//case 0x2a: break; // UP16 //case RSX_FP_OPCODE_UP16: break;
//case 0x2b: break; // BEM //case RSX_FP_OPCODE_BEM: break;
//case 0x2c: break; // PKG //case RSX_FP_OPCODE_PKG: break;
//case 0x2d: break; // UPG //case RSX_FP_OPCODE_UPG: break;
case 0x2e: SetDst("($0.x * $1.x + $0.y * $1.y + $2.x)"); break; // DP2A (2-component dot product and add) case RSX_FP_OPCODE_DP2A: SetDst("($0.x * $1.x + $0.y * $1.y + $2.x)"); break;
//case 0x2f: break; // TXL (texture lookup with LOD) //case RSX_FP_OPCODE_TXL: break;
//case 0x30: break; //case RSX_FP_OPCODE_TXB: break;
//case 0x31: break; // TXB (texture lookup with bias) //case RSX_FP_OPCODE_TEXBEM: break;
//case 0x33: break; // TEXBEM //case RSX_FP_OPCODE_TXPBEM: break;
//case 0x34: break; // TXPBEM //case RSX_FP_OPCODE_BEMLUM: break;
//case 0x35: break; // BEMLUM case RSX_FP_OPCODE_REFL: SetDst("($0 - 2.0 * $1 * dot($0, $1))"); break;
case 0x36: SetDst("($0 - 2.0 * $1 * dot($0, $1))"); break; // RFL (reflection vector) //case RSX_FP_OPCODE_TIMESWTEX: break;
//case 0x37: break; // TIMESWTEX case RSX_FP_OPCODE_DP2: SetDst("vec4(dot($0.xy, $1.xy))"); break;
case 0x38: SetDst("vec4(dot($0.xy, $1.xy))"); break; // DP2 case RSX_FP_OPCODE_NRM: SetDst("normalize($0.xyz)"); break;
case 0x39: SetDst("normalize($0.xyz)"); break; // NRM case RSX_FP_OPCODE_DIV: SetDst("($0 / $1)"); break;
case 0x3a: SetDst("($0 / $1)"); break; // DIV case RSX_FP_OPCODE_DIVSQ: SetDst("($0 / sqrt($1))"); break;
case 0x3b: SetDst("($0 / sqrt($1))"); break; // DIVSQ case RSX_FP_OPCODE_LIF: SetDst("vec4(1.0, $0.y, ($0.y > 0 ? pow(2.0, $0.w) : 0.0), 1.0)"); break;
case 0x3c: SetDst("vec4(1.0, $0.y, ($0.y > 0 ? pow(2.0, $0.w) : 0.0), 1.0)"); break; // LIF case RSX_FP_OPCODE_FENCT: break;
case 0x3d: break; // FENCT case RSX_FP_OPCODE_FENCB: break;
case 0x3e: break; // FENCB
case 0x40: SetDst("break"); break; //BRK case RSX_FP_OPCODE_BRK: SetDst("break"); break;
//case 0x41: break; //CAL //case RSX_FP_OPCODE_CAL: break;
case 0x42: case RSX_FP_OPCODE_IFE:
AddCode("if($cond)"); //IF AddCode("if($cond)");
m_else_offsets.push_back(src1.else_offset << 2); m_else_offsets.push_back(src1.else_offset << 2);
m_end_offsets.push_back(src2.end_offset << 2); m_end_offsets.push_back(src2.end_offset << 2);
AddCode("{"); AddCode("{");
m_code_level++; m_code_level++;
break; break;
case 0x43: //LOOP case RSX_FP_OPCODE_LOOP:
if(!src0.exec_if_eq && !src0.exec_if_gr && !src0.exec_if_lt) if(!src0.exec_if_eq && !src0.exec_if_gr && !src0.exec_if_lt)
{ {
AddCode(fmt::Format("$ifcond for(int i%u = %u; i%u < %u; i%u += %u) {} //-> %u //LOOP", AddCode(fmt::Format("$ifcond for(int i%u = %u; i%u < %u; i%u += %u) {} //-> %u //LOOP",
m_loop_count, src1.rep2, m_loop_count, src1.rep1, m_loop_count, src1.rep3, src2.end_offset)); m_loop_count, src1.init_counter, m_loop_count, src1.end_counter, m_loop_count, src1.increment, src2.end_offset));
} }
else else
{ {
AddCode(fmt::Format("$ifcond for(int i%u = %u; i%u < %u; i%u += %u) //LOOP", AddCode(fmt::Format("$ifcond for(int i%u = %u; i%u < %u; i%u += %u) //LOOP",
m_loop_count, src1.rep2, m_loop_count, src1.rep1, m_loop_count, src1.rep3)); m_loop_count, src1.init_counter, m_loop_count, src1.end_counter, m_loop_count, src1.increment));
m_loop_count++; m_loop_count++;
m_end_offsets.push_back(src2.end_offset << 2); m_end_offsets.push_back(src2.end_offset << 2);
AddCode("{"); AddCode("{");
m_code_level++; m_code_level++;
} }
break; break;
case 0x44: //REP case RSX_FP_OPCODE_REP:
if(!src0.exec_if_eq && !src0.exec_if_gr && !src0.exec_if_lt) if(!src0.exec_if_eq && !src0.exec_if_gr && !src0.exec_if_lt)
{ {
AddCode(fmt::Format("$ifcond for(int i%u = %u; i%u < %u; i%u += %u) {} //-> %u //REP", AddCode(fmt::Format("$ifcond for(int i%u = %u; i%u < %u; i%u += %u) {} //-> %u //REP",
m_loop_count, src1.rep2, m_loop_count, src1.rep1, m_loop_count, src1.rep3, src2.end_offset)); m_loop_count, src1.init_counter, m_loop_count, src1.end_counter, m_loop_count, src1.increment, src2.end_offset));
} }
else else
{ {
AddCode(fmt::Format("if($cond) for(int i%u = %u; i%u < %u; i%u += %u) //REP", AddCode(fmt::Format("if($cond) for(int i%u = %u; i%u < %u; i%u += %u) //REP",
m_loop_count, src1.rep2, m_loop_count, src1.rep1, m_loop_count, src1.rep3)); m_loop_count, src1.init_counter, m_loop_count, src1.end_counter, m_loop_count, src1.increment));
m_loop_count++; m_loop_count++;
m_end_offsets.push_back(src2.end_offset << 2); m_end_offsets.push_back(src2.end_offset << 2);
AddCode("{"); AddCode("{");
m_code_level++; m_code_level++;
} }
break; break;
//case 0x45: SetDst("return"); break; //RET //case RSX_FP_OPCODE_RET: SetDst("return"); break;
default: default:
LOG_ERROR(RSX, "Unknown fp opcode 0x%x (inst %d)", opcode, m_size / (4 * 4)); LOG_ERROR(RSX, "Unknown fp opcode 0x%x (inst %d)", opcode, m_size / (4 * 4));
@ -543,10 +541,9 @@ void GLShaderProgram::Compile()
void GLShaderProgram::Delete() void GLShaderProgram::Delete()
{ {
for (u32 i = 0; i<m_parr.params.size(); ++i) for (auto& param : m_parr.params) {
{ param.items.clear();
m_parr.params[i].items.clear(); param.type.clear();
m_parr.params[i].type.clear();
} }
m_parr.params.clear(); m_parr.params.clear();

View File

@ -10,21 +10,21 @@ struct GLFragmentDecompilerThread : public ThreadBase
struct struct
{ {
u32 end : 1; u32 end : 1; // Set to 1 if this is the last instruction
u32 dest_reg : 6; u32 dest_reg : 6; // Destination register index
u32 fp16 : 1; u32 fp16 : 1; // Destination is a half register (H0 to H47)
u32 set_cond : 1; u32 set_cond : 1; // Condition Code Registers (CC0 and CC1) are updated
u32 mask_x : 1; u32 mask_x : 1;
u32 mask_y : 1; u32 mask_y : 1;
u32 mask_z : 1; u32 mask_z : 1;
u32 mask_w : 1; u32 mask_w : 1;
u32 src_attr_reg_num : 4; u32 src_attr_reg_num : 4;
u32 tex_num : 4; u32 tex_num : 4;
u32 exp_tex : 1; u32 exp_tex : 1; // _bx2
u32 prec : 2; u32 prec : 2;
u32 opcode : 6; u32 opcode : 6;
u32 no_dest : 1; u32 no_dest : 1;
u32 saturate : 1; u32 saturate : 1; // _sat
}; };
} dst; } dst;
@ -82,13 +82,14 @@ struct GLFragmentDecompilerThread : public ThreadBase
u32 : 1; u32 : 1;
}; };
// LOOP, REP
struct struct
{ {
u32 : 2; u32 : 2;
u32 rep1 : 8; u32 end_counter : 8; // End counter value for LOOP or rep count for REP
u32 rep2 : 8; u32 init_counter : 8; // Initial counter value for LOOP
u32 : 1; u32 : 1;
u32 rep3 : 8; u32 increment : 8; // Increment value for LOOP
}; };
} src1; } src1;

View File

@ -14,7 +14,6 @@
#define CMD_LOG(...) #define CMD_LOG(...)
#endif #endif
gcmBuffer gcmBuffers[8];
GLuint g_flip_tex, g_depth_tex, g_pbo[6]; GLuint g_flip_tex, g_depth_tex, g_pbo[6];
int last_width = 0, last_height = 0, last_depth_format = 0; int last_width = 0, last_height = 0, last_depth_format = 0;
@ -189,64 +188,67 @@ void GLGSRender::EnableVertexData(bool indexed_draw)
GL_HALF_FLOAT, GL_HALF_FLOAT,
GL_UNSIGNED_BYTE, GL_UNSIGNED_BYTE,
GL_SHORT, GL_SHORT,
GL_FLOAT, // Needs conversion
GL_UNSIGNED_BYTE, GL_UNSIGNED_BYTE,
}; };
static const bool gl_normalized[] = static const bool gl_normalized[] =
{ {
true, GL_TRUE,
false, GL_FALSE,
false, GL_FALSE,
true, GL_TRUE,
false, GL_FALSE,
false, GL_TRUE,
GL_FALSE,
}; };
if(m_vertex_data[i].type >= 1 && m_vertex_data[i].type <= 7) if (m_vertex_data[i].type < 1 && m_vertex_data[i].type > 7) {
LOG_ERROR(RSX, "GLGSRender::EnableVertexData: Bad vertex data type (%d)!", m_vertex_data[i].type);
}
if(!m_vertex_data[i].addr)
{ {
if(!m_vertex_data[i].addr) switch(m_vertex_data[i].type)
{ {
switch(m_vertex_data[i].type) case CELL_GCM_VERTEX_S32K:
case CELL_GCM_VERTEX_S1:
switch(m_vertex_data[i].size)
{ {
case CELL_GCM_VERTEX_S32K: case 1: glVertexAttrib1s(i, (GLshort&)m_vertex_data[i].data[0]); break;
case CELL_GCM_VERTEX_S1: case 2: glVertexAttrib2sv(i, (GLshort*)&m_vertex_data[i].data[0]); break;
switch(m_vertex_data[i].size) case 3: glVertexAttrib3sv(i, (GLshort*)&m_vertex_data[i].data[0]); break;
{ case 4: glVertexAttrib4sv(i, (GLshort*)&m_vertex_data[i].data[0]); break;
case 1: glVertexAttrib1s(i, (GLshort&)m_vertex_data[i].data[0]); break;
case 2: glVertexAttrib2sv(i, (GLshort*)&m_vertex_data[i].data[0]); break;
case 3: glVertexAttrib3sv(i, (GLshort*)&m_vertex_data[i].data[0]); break;
case 4: glVertexAttrib4sv(i, (GLshort*)&m_vertex_data[i].data[0]); break;
}
break;
case CELL_GCM_VERTEX_F:
switch(m_vertex_data[i].size)
{
case 1: glVertexAttrib1f(i, (GLfloat&)m_vertex_data[i].data[0]); break;
case 2: glVertexAttrib2fv(i, (GLfloat*)&m_vertex_data[i].data[0]); break;
case 3: glVertexAttrib3fv(i, (GLfloat*)&m_vertex_data[i].data[0]); break;
case 4: glVertexAttrib4fv(i, (GLfloat*)&m_vertex_data[i].data[0]); break;
}
break;
case CELL_GCM_VERTEX_CMP:
case CELL_GCM_VERTEX_UB:
glVertexAttrib4ubv(i, (GLubyte*)&m_vertex_data[i].data[0]);
break;
} }
break;
checkForGlError("glVertexAttrib"); case CELL_GCM_VERTEX_F:
} switch(m_vertex_data[i].size)
else {
{ case 1: glVertexAttrib1f(i, (GLfloat&)m_vertex_data[i].data[0]); break;
u32 gltype = gl_types[m_vertex_data[i].type - 1]; case 2: glVertexAttrib2fv(i, (GLfloat*)&m_vertex_data[i].data[0]); break;
bool normalized = gl_normalized[m_vertex_data[i].type - 1]; case 3: glVertexAttrib3fv(i, (GLfloat*)&m_vertex_data[i].data[0]); break;
case 4: glVertexAttrib4fv(i, (GLfloat*)&m_vertex_data[i].data[0]); break;
}
break;
glEnableVertexAttribArray(i); case CELL_GCM_VERTEX_CMP:
checkForGlError("glEnableVertexAttribArray"); case CELL_GCM_VERTEX_UB:
glVertexAttribPointer(i, m_vertex_data[i].size, gltype, normalized, 0, reinterpret_cast<void*>(offset_list[i])); glVertexAttrib4ubv(i, (GLubyte*)&m_vertex_data[i].data[0]);
checkForGlError("glVertexAttribPointer"); break;
} }
checkForGlError("glVertexAttrib");
}
else
{
u32 gltype = gl_types[m_vertex_data[i].type - 1];
bool normalized = gl_normalized[m_vertex_data[i].type - 1];
glEnableVertexAttribArray(i);
checkForGlError("glEnableVertexAttribArray");
glVertexAttribPointer(i, m_vertex_data[i].size, gltype, normalized, 0, reinterpret_cast<void*>(offset_list[i]));
checkForGlError("glVertexAttribPointer");
} }
} }
} }
@ -265,15 +267,15 @@ void GLGSRender::DisableVertexData()
void GLGSRender::InitVertexData() void GLGSRender::InitVertexData()
{ {
GLfloat scaleOffsetMat[16] = {1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f};
int l; int l;
GLfloat scaleOffsetMat[16] = {
1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
};
for(u32 i=0; i<m_transform_constants.size(); ++i) for (const RSXTransformConstant& c : m_transform_constants) {
{
const RSXTransformConstant& c = m_transform_constants[i];
const std::string name = fmt::Format("vc[%u]", c.id); const std::string name = fmt::Format("vc[%u]", c.id);
l = m_program.GetLocation(name); l = m_program.GetLocation(name);
checkForGlError("glGetUniformLocation " + name); checkForGlError("glGetUniformLocation " + name);
@ -284,13 +286,13 @@ void GLGSRender::InitVertexData()
} }
// Scale // Scale
scaleOffsetMat[0] = (GLfloat&)methodRegisters[NV4097_SET_VIEWPORT_SCALE + (0x4 * 0)] / (RSXThread::m_width / RSXThread::m_width_scale); scaleOffsetMat[0] = (GLfloat&)methodRegisters[NV4097_SET_VIEWPORT_SCALE + (0x4 * 0)] / (RSXThread::m_width / RSXThread::m_width_scale);
scaleOffsetMat[5] = (GLfloat&)methodRegisters[NV4097_SET_VIEWPORT_SCALE + (0x4 * 1)] / (RSXThread::m_height / RSXThread::m_height_scale); scaleOffsetMat[5] = (GLfloat&)methodRegisters[NV4097_SET_VIEWPORT_SCALE + (0x4 * 1)] / (RSXThread::m_height / RSXThread::m_height_scale);
scaleOffsetMat[10] = (GLfloat&)methodRegisters[NV4097_SET_VIEWPORT_SCALE + (0x4 * 2)]; scaleOffsetMat[10] = (GLfloat&)methodRegisters[NV4097_SET_VIEWPORT_SCALE + (0x4 * 2)];
// Offset // Offset
scaleOffsetMat[3] = (GLfloat&)methodRegisters[NV4097_SET_VIEWPORT_OFFSET + (0x4 * 0)] - (RSXThread::m_width / RSXThread::m_width_scale); scaleOffsetMat[3] = (GLfloat&)methodRegisters[NV4097_SET_VIEWPORT_OFFSET + (0x4 * 0)] - (RSXThread::m_width / RSXThread::m_width_scale);
scaleOffsetMat[7] = (GLfloat&)methodRegisters[NV4097_SET_VIEWPORT_OFFSET + (0x4 * 1)] - (RSXThread::m_height / RSXThread::m_height_scale); scaleOffsetMat[7] = (GLfloat&)methodRegisters[NV4097_SET_VIEWPORT_OFFSET + (0x4 * 1)] - (RSXThread::m_height / RSXThread::m_height_scale);
scaleOffsetMat[11] = (GLfloat&)methodRegisters[NV4097_SET_VIEWPORT_OFFSET + (0x4 * 2)] - 1 / 2.0f; scaleOffsetMat[11] = (GLfloat&)methodRegisters[NV4097_SET_VIEWPORT_OFFSET + (0x4 * 2)] - 1 / 2.0f;
scaleOffsetMat[3] /= RSXThread::m_width / RSXThread::m_width_scale; scaleOffsetMat[3] /= RSXThread::m_width / RSXThread::m_width_scale;
@ -309,10 +311,7 @@ void GLGSRender::InitFragmentData()
return; return;
} }
for(u32 i=0; i<m_fragment_constants.size(); ++i) for(const RSXTransformConstant& c : m_fragment_constants) {
{
const RSXTransformConstant& c = m_fragment_constants[i];
u32 id = c.id - m_cur_shader_prog->offset; u32 id = c.id - m_cur_shader_prog->offset;
//LOG_WARNING(RSX,"fc%u[0x%x - 0x%x] = (%f, %f, %f, %f)", id, c.id, m_cur_shader_prog->offset, c.x, c.y, c.z, c.w); //LOG_WARNING(RSX,"fc%u[0x%x - 0x%x] = (%f, %f, %f, %f)", id, c.id, m_cur_shader_prog->offset, c.x, c.y, c.z, c.w);
@ -1272,13 +1271,13 @@ void GLGSRender::Flip()
if (m_read_buffer) if (m_read_buffer)
{ {
format = GL_BGRA; format = GL_BGRA;
gcmBuffer* buffers = (gcmBuffer*)Memory.GetMemFromAddr(m_gcm_buffers_addr); CellGcmDisplayInfo* buffers = (CellGcmDisplayInfo*)Memory.GetMemFromAddr(m_gcm_buffers_addr);
u32 addr = GetAddress(re(buffers[m_gcm_current_buffer].offset), CELL_GCM_LOCATION_LOCAL); u32 addr = GetAddress(buffers[m_gcm_current_buffer].offset, CELL_GCM_LOCATION_LOCAL);
if (Memory.IsGoodAddr(addr)) if (Memory.IsGoodAddr(addr))
{ {
width = re(buffers[m_gcm_current_buffer].width); width = buffers[m_gcm_current_buffer].width;
height = re(buffers[m_gcm_current_buffer].height); height = buffers[m_gcm_current_buffer].height;
src_buffer = (u8*)Memory.VirtualToRealAddr(addr); src_buffer = (u8*)Memory.VirtualToRealAddr(addr);
} }
else else

View File

@ -175,10 +175,10 @@ std::string GLVertexDecompilerThread::GetFunc()
{ {
std::string name = "func$a"; std::string name = "func$a";
for(uint i=0; i<m_funcs.size(); ++i) for (const auto& func : m_funcs) {
{ if (func.name.compare(name) == 0) {
if(m_funcs[i].name.compare(name) == 0)
return name + "()"; return name + "()";
}
} }
m_funcs.emplace_back(); m_funcs.emplace_back();
@ -380,9 +380,8 @@ std::string GLVertexDecompilerThread::BuildCode()
std::string p; std::string p;
for (u32 i = 0; i<m_parr.params.size(); ++i) for (auto& param : m_parr.params) {
{ p += param.Format();
p += m_parr.params[i].Format();
} }
std::string fp; std::string fp;

View File

@ -33,14 +33,6 @@ struct GSInfo
} }
}; };
struct gcmBuffer
{
u32 offset;
u32 pitch;
u32 width;
u32 height;
};
class GSManager class GSManager
{ {
GSInfo m_info; GSInfo m_info;

View File

@ -1,5 +1,76 @@
#pragma once #pragma once
enum
{
RSX_FP_OPCODE_NOP = 0x00, // No-Operation
RSX_FP_OPCODE_MOV = 0x01, // Move
RSX_FP_OPCODE_MUL = 0x02, // Multiply
RSX_FP_OPCODE_ADD = 0x03, // Add
RSX_FP_OPCODE_MAD = 0x04, // Multiply-Add
RSX_FP_OPCODE_DP3 = 0x05, // 3-component Dot Product
RSX_FP_OPCODE_DP4 = 0x06, // 4-component Dot Product
RSX_FP_OPCODE_DST = 0x07, // Distance
RSX_FP_OPCODE_MIN = 0x08, // Minimum
RSX_FP_OPCODE_MAX = 0x09, // Maximum
RSX_FP_OPCODE_SLT = 0x0A, // Set-If-LessThan
RSX_FP_OPCODE_SGE = 0x0B, // Set-If-GreaterEqual
RSX_FP_OPCODE_SLE = 0x0C, // Set-If-LessEqual
RSX_FP_OPCODE_SGT = 0x0D, // Set-If-GreaterThan
RSX_FP_OPCODE_SNE = 0x0E, // Set-If-NotEqual
RSX_FP_OPCODE_SEQ = 0x0F, // Set-If-Equal
RSX_FP_OPCODE_FRC = 0x10, // Fraction (fract)
RSX_FP_OPCODE_FLR = 0x11, // Floor
RSX_FP_OPCODE_KIL = 0x12, // Kill fragment
RSX_FP_OPCODE_PK4 = 0x13, // Pack four signed 8-bit values
RSX_FP_OPCODE_UP4 = 0x14, // Unpack four signed 8-bit values
RSX_FP_OPCODE_DDX = 0x15, // Partial-derivative in x (Screen space derivative w.r.t. x)
RSX_FP_OPCODE_DDY = 0x16, // Partial-derivative in y (Screen space derivative w.r.t. y)
RSX_FP_OPCODE_TEX = 0x17, // Texture lookup
RSX_FP_OPCODE_TXP = 0x18, // Texture sample with projection (Projective texture lookup)
RSX_FP_OPCODE_TXD = 0x19, // Texture sample with partial differentiation (Texture lookup with derivatives)
RSX_FP_OPCODE_RCP = 0x1A, // Reciprocal
RSX_FP_OPCODE_RSQ = 0x1B, // Reciprocal Square Root
RSX_FP_OPCODE_EX2 = 0x1C, // Exponentiation base 2
RSX_FP_OPCODE_LG2 = 0x1D, // Log base 2
RSX_FP_OPCODE_LIT = 0x1E, // Lighting coefficients
RSX_FP_OPCODE_LRP = 0x1F, // Linear Interpolation
RSX_FP_OPCODE_STR = 0x20, // Set-If-True
RSX_FP_OPCODE_SFL = 0x21, // Set-If-False
RSX_FP_OPCODE_COS = 0x22, // Cosine
RSX_FP_OPCODE_SIN = 0x23, // Sine
RSX_FP_OPCODE_PK2 = 0x24, // Pack two 16-bit floats
RSX_FP_OPCODE_UP2 = 0x25, // Unpack two 16-bit floats
RSX_FP_OPCODE_POW = 0x26, // Power
RSX_FP_OPCODE_PKB = 0x27, // Pack bytes
RSX_FP_OPCODE_UPB = 0x28, // Unpack bytes
RSX_FP_OPCODE_PK16 = 0x29, // Pack 16 bits
RSX_FP_OPCODE_UP16 = 0x2A, // Unpack 16
RSX_FP_OPCODE_BEM = 0x2B, // Bump-environment map (a.k.a. 2D coordinate transform)
RSX_FP_OPCODE_PKG = 0x2C, // Pack with sRGB transformation
RSX_FP_OPCODE_UPG = 0x2D, // Unpack gamma
RSX_FP_OPCODE_DP2A = 0x2E, // 2-component dot product with scalar addition
RSX_FP_OPCODE_TXL = 0x2F, // Texture sample with LOD
RSX_FP_OPCODE_TXB = 0x31, // Texture sample with bias
RSX_FP_OPCODE_TEXBEM = 0x33,
RSX_FP_OPCODE_TXPBEM = 0x34,
RSX_FP_OPCODE_BEMLUM = 0x35,
RSX_FP_OPCODE_REFL = 0x36, // Reflection vector
RSX_FP_OPCODE_TIMESWTEX = 0x37,
RSX_FP_OPCODE_DP2 = 0x38, // 2-component dot product
RSX_FP_OPCODE_NRM = 0x39, // Normalize
RSX_FP_OPCODE_DIV = 0x3A, // Division
RSX_FP_OPCODE_DIVSQ = 0x3B, // Divide by Square Root
RSX_FP_OPCODE_LIF = 0x3C, // Final part of LIT
RSX_FP_OPCODE_FENCT = 0x3D, // Fence T?
RSX_FP_OPCODE_FENCB = 0x3E, // Fence B?
RSX_FP_OPCODE_BRK = 0x40, // Break
RSX_FP_OPCODE_CAL = 0x41, // Subroutine call
RSX_FP_OPCODE_IFE = 0x42, // If
RSX_FP_OPCODE_LOOP = 0x43, // Loop
RSX_FP_OPCODE_REP = 0x44, // Repeat
RSX_FP_OPCODE_RET = 0x45, // Return
};
struct RSXShaderProgram struct RSXShaderProgram
{ {
u32 size; u32 size;
@ -14,4 +85,4 @@ struct RSXShaderProgram
, ctrl(0) , ctrl(0)
{ {
} }
}; };

View File

@ -26,7 +26,7 @@ void RSXTexture::Init()
// Address // Address
methodRegisters[NV4097_SET_TEXTURE_ADDRESS + (m_index*32)] = methodRegisters[NV4097_SET_TEXTURE_ADDRESS + (m_index*32)] =
((/*wraps*/1) | ((/*anisoBias*/0) << 4) | ((/*wrapt*/1) << 8) | ((/*unsignedRemap*/0) << 12) | ((/*wraps*/1) | ((/*anisoBias*/0) << 4) | ((/*wrapt*/1) << 8) | ((/*unsignedRemap*/0) << 12) |
((/*wrapr*/2) << 16) | ((/*gamma*/0) << 20) |((/*signedRemap*/0) << 24) | ((/*zfunc*/0) << 28)); ((/*wrapr*/3) << 16) | ((/*gamma*/0) << 20) |((/*signedRemap*/0) << 24) | ((/*zfunc*/0) << 28));
// Control0 // Control0
methodRegisters[NV4097_SET_TEXTURE_CONTROL0 + (m_index*32)] = methodRegisters[NV4097_SET_TEXTURE_CONTROL0 + (m_index*32)] =

View File

@ -73,7 +73,7 @@ void RSXVertexData::Reset()
data.clear(); data.clear();
} }
void RSXVertexData::Load(u32 start, u32 count) void RSXVertexData::Load(u32 start, u32 count, u32 baseOffset, u32 baseIndex=0)
{ {
if(!addr) return; if(!addr) return;
@ -83,7 +83,7 @@ void RSXVertexData::Load(u32 start, u32 count)
for(u32 i=start; i<start + count; ++i) for(u32 i=start; i<start + count; ++i)
{ {
const u8* src = Memory.GetMemFromAddr(addr) + stride * i; const u8* src = Memory.GetMemFromAddr(addr) + baseOffset + stride * (i+baseIndex);
u8* dst = &data[i * tsize * size]; u8* dst = &data[i * tsize * size];
switch(tsize) switch(tsize)
@ -117,16 +117,18 @@ u32 RSXVertexData::GetTypeSize()
{ {
switch (type) switch (type)
{ {
case 1: return 2; case CELL_GCM_VERTEX_S1: return 2;
case 2: return 4; case CELL_GCM_VERTEX_F: return 4;
case 3: return 2; case CELL_GCM_VERTEX_SF: return 2;
case 4: return 1; case CELL_GCM_VERTEX_UB: return 1;
case 5: return 2; case CELL_GCM_VERTEX_S32K: return 2;
case 7: return 1; case CELL_GCM_VERTEX_CMP: return 4;
} case CELL_GCM_VERTEX_UB256: return 1;
LOG_ERROR(RSX, "Bad vertex data type! %d", type); default:
return 1; LOG_ERROR(RSX, "RSXVertexData::GetTypeSize: Bad vertex data type (%d)!", type);
return 1;
}
} }
#define CMD_DEBUG 0 #define CMD_DEBUG 0
@ -903,6 +905,21 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t args, const u32
} }
break; break;
case NV4097_SET_VERTEX_DATA_BASE_OFFSET:
{
m_vertex_data_base_offset = ARGS(0);
if (count >= 2) {
m_vertex_data_base_index = ARGS(1);
}
}
break;
case NV4097_SET_VERTEX_DATA_BASE_INDEX:
{
m_vertex_data_base_index = ARGS(0);
}
break;
case NV4097_SET_BEGIN_END: case NV4097_SET_BEGIN_END:
{ {
const u32 a0 = ARGS(0); const u32 a0 = ARGS(0);
@ -1320,9 +1337,9 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t args, const u32
case 2: m_surface_pitch_a = ARGS(1); case 2: m_surface_pitch_a = ARGS(1);
} }
gcmBuffer* buffers = (gcmBuffer*)Memory.GetMemFromAddr(m_gcm_buffers_addr); CellGcmDisplayInfo* buffers = (CellGcmDisplayInfo*)Memory.GetMemFromAddr(m_gcm_buffers_addr);
m_width = re(buffers[m_gcm_current_buffer].width); m_width = buffers[m_gcm_current_buffer].width;
m_height = re(buffers[m_gcm_current_buffer].height); m_height = buffers[m_gcm_current_buffer].height;
// Rescale native resolution to fit 1080p/720p/480p/576p window size // Rescale native resolution to fit 1080p/720p/480p/576p window size
nativeRescale((float)m_width, (float)m_height); nativeRescale((float)m_width, (float)m_height);

View File

@ -36,7 +36,7 @@ struct RSXVertexData
void Reset(); void Reset();
bool IsEnabled() const { return size > 0; } bool IsEnabled() const { return size > 0; }
void Load(u32 start, u32 count); void Load(u32 start, u32 count, u32 baseOffset, u32 baseIndex);
u32 GetTypeSize(); u32 GetTypeSize();
}; };
@ -412,6 +412,10 @@ public:
u8 m_shader_window_origin; u8 m_shader_window_origin;
u16 m_shader_window_pixel_centers; u16 m_shader_window_pixel_centers;
// Vertex Data
u32 m_vertex_data_base_offset;
u32 m_vertex_data_base_index;
// Front face // Front face
bool m_set_front_face; bool m_set_front_face;
u32 m_front_face; u32 m_front_face;
@ -505,8 +509,9 @@ protected:
m_line_width = 1.0; m_line_width = 1.0;
m_line_stipple_pattern = 0xffff; m_line_stipple_pattern = 0xffff;
m_line_stipple_factor = 1; m_line_stipple_factor = 1;
for (size_t i = 0; i < 32; i++) m_vertex_data_base_offset = 0;
{ m_vertex_data_base_index = 0;
for (size_t i = 0; i < 32; i++) {
m_polygon_stipple_pattern[i] = 0xFFFFFFFF; m_polygon_stipple_pattern[i] = 0xFFFFFFFF;
} }
@ -624,7 +629,7 @@ protected:
{ {
if(!m_vertex_data[i].IsEnabled()) continue; if(!m_vertex_data[i].IsEnabled()) continue;
m_vertex_data[i].Load(first, count); m_vertex_data[i].Load(first, count, m_vertex_data_base_offset, m_vertex_data_base_index);
} }
} }

View File

@ -13,52 +13,50 @@ extern void cellFont_init();
extern void cellFont_load(); extern void cellFont_load();
extern void cellFont_unload(); extern void cellFont_unload();
extern Module *cellFont; extern Module *cellFont;
extern void sys_net_init();
extern Module *sys_net;
extern void cellUserInfo_init();
extern Module *cellUserInfo;
extern void cellSysutil_init();
extern Module *cellSysutil;
extern void cellSysutilAp_init();
extern Module *cellSysutilAp;
extern void cellPngDec_init();
extern Module *cellPngDec;
extern void cellNetCtl_init();
extern Module *cellNetCtl;
extern void cellJpgDec_init();
extern Module *cellJpgDec;
extern void cellFontFT_init(); extern void cellFontFT_init();
extern void cellFontFT_load(); extern void cellFontFT_load();
extern void cellFontFT_unload(); extern void cellFontFT_unload();
extern Module *cellFontFT; extern Module *cellFontFT;
extern void cellGifDec_init(); extern void cellGame_init();
extern Module *cellGifDec; extern Module *cellGame;
extern void cellGcmSys_init(); extern void cellGcmSys_init();
extern void cellGcmSys_load(); extern void cellGcmSys_load();
extern void cellGcmSys_unload(); extern void cellGcmSys_unload();
extern Module *cellGcmSys; extern Module *cellGcmSys;
extern void cellGame_init(); extern void cellGem_init();
extern Module *cellGame; extern Module *cellGem;
extern void sys_io_init(); extern void cellGifDec_init();
extern Module *sys_io; extern Module *cellGifDec;
extern void cellJpgDec_init();
extern Module *cellJpgDec;
extern void cellL10n_init(); extern void cellL10n_init();
extern Module *cellL10n; extern Module *cellL10n;
extern void cellNetCtl_init();
extern Module *cellNetCtl;
extern void cellPamf_init(); extern void cellPamf_init();
extern Module *cellPamf; extern Module *cellPamf;
extern void cellPngDec_init();
extern Module *cellPngDec;
extern void cellResc_init(); extern void cellResc_init();
extern void cellResc_load(); extern void cellResc_load();
extern void cellResc_unload(); extern void cellResc_unload();
extern Module *cellResc; extern Module *cellResc;
extern void cellSail_init();
extern Module *cellSail;
extern void cellRtc_init(); extern void cellRtc_init();
extern Module *cellRtc; extern Module *cellRtc;
extern void cellSail_init();
extern Module *cellSail;
extern void cellSpurs_init(); extern void cellSpurs_init();
extern Module *cellSpurs; extern Module *cellSpurs;
extern void cellSync_init(); extern void cellSync_init();
extern Module *cellSync; extern Module *cellSync;
extern void cellSysmodule_init(); extern void cellSysmodule_init();
extern Module *cellSysmodule; extern Module *cellSysmodule;
extern void cellSysutil_init();
extern Module *cellSysutil;
extern void cellSysutilAp_init();
extern Module *cellSysutilAp;
extern void cellUserInfo_init();
extern Module *cellUserInfo;
extern void cellVdec_init(); extern void cellVdec_init();
extern Module *cellVdec; extern Module *cellVdec;
extern void cellVpost_init(); extern void cellVpost_init();
@ -86,6 +84,10 @@ extern void sysPrxForUser_init();
extern Module *sysPrxForUser; extern Module *sysPrxForUser;
extern void sys_fs_init(); extern void sys_fs_init();
extern Module *sys_fs; extern Module *sys_fs;
extern void sys_io_init();
extern Module *sys_io;
extern void sys_net_init();
extern Module *sys_net;
struct ModuleInfo struct ModuleInfo
{ {
@ -219,60 +221,70 @@ void ModuleManager::init()
m_mod_init.emplace_back(0x0007, cellDmux_init); m_mod_init.emplace_back(0x0007, cellDmux_init);
cellFont = static_cast <Module*>(&(m_mod_init.back())) + 1; cellFont = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0019, cellFont_init, cellFont_load, cellFont_unload); m_mod_init.emplace_back(0x0019, cellFont_init, cellFont_load, cellFont_unload);
sys_net = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back((u16)0x0000, sys_net_init);
sceNpTrophy = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0xf035, sceNpTrophy_init, nullptr, sceNpTrophy_unload);
sceNp = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0016, sceNp_init);
cellUserInfo = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0032, cellUserInfo_init);
cellSysutil = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0015, cellSysutil_init);
cellSysutilAp = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0039, cellSysutilAp_init);
cellPngDec = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0018, cellPngDec_init);
cellNetCtl = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0014, cellNetCtl_init);
cellJpgDec = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x000f, cellJpgDec_init);
cellFontFT = static_cast <Module*>(&(m_mod_init.back())) + 1; cellFontFT = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x001a, cellFontFT_init, cellFontFT_load, cellFontFT_unload); m_mod_init.emplace_back(0x001a, cellFontFT_init, cellFontFT_load, cellFontFT_unload);
cellGifDec = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0xf010, cellGifDec_init);
cellGcmSys = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0010, cellGcmSys_init, cellGcmSys_load, cellGcmSys_unload);
cellGame = static_cast <Module*>(&(m_mod_init.back())) + 1; cellGame = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x003e, cellGame_init); m_mod_init.emplace_back(0x003e, cellGame_init);
sys_io = static_cast <Module*>(&(m_mod_init.back())) + 1; cellGcmSys = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0017, sys_io_init); m_mod_init.emplace_back(0x0010, cellGcmSys_init, cellGcmSys_load, cellGcmSys_unload);
cellGem = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x005a, cellGem_init);
cellJpgDec = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x000f, cellJpgDec_init);
cellGifDec = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0xf010, cellGifDec_init);
cellL10n = static_cast <Module*>(&(m_mod_init.back())) + 1; cellL10n = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x001e, cellL10n_init); m_mod_init.emplace_back(0x001e, cellL10n_init);
cellNetCtl = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0014, cellNetCtl_init);
cellPamf = static_cast <Module*>(&(m_mod_init.back())) + 1; cellPamf = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0012, cellPamf_init); m_mod_init.emplace_back(0x0012, cellPamf_init);
cellSail = static_cast <Module*>(&(m_mod_init.back())) + 1; cellPngDec = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back("cellSail", cellSail_init); m_mod_init.emplace_back(0x0018, cellPngDec_init);
cellResc = static_cast <Module*>(&(m_mod_init.back())) + 1; cellResc = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x001f, cellResc_init, cellResc_load, cellResc_unload); m_mod_init.emplace_back(0x001f, cellResc_init, cellResc_load, cellResc_unload);
cellRtc = static_cast <Module*>(&(m_mod_init.back())) + 1; cellRtc = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0009, cellRtc_init); m_mod_init.emplace_back(0x0009, cellRtc_init);
cellSail = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back("cellSail", cellSail_init);
cellSpurs = static_cast <Module*>(&(m_mod_init.back())) + 1; cellSpurs = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x000a, cellSpurs_init); m_mod_init.emplace_back(0x000a, cellSpurs_init);
cellSync = static_cast <Module*>(&(m_mod_init.back())) + 1; cellSync = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back("cellSync", cellSync_init); m_mod_init.emplace_back("cellSync", cellSync_init);
cellSysutil = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0015, cellSysutil_init);
cellSysutilAp = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0039, cellSysutilAp_init);
cellSysmodule = static_cast <Module*>(&(m_mod_init.back())) + 1; cellSysmodule = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back("cellSysmodule", cellSysmodule_init); m_mod_init.emplace_back("cellSysmodule", cellSysmodule_init);
cellUserInfo = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0032, cellUserInfo_init);
cellVdec = static_cast <Module*>(&(m_mod_init.back())) + 1; cellVdec = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0005, cellVdec_init); m_mod_init.emplace_back(0x0005, cellVdec_init);
cellVpost = static_cast <Module*>(&(m_mod_init.back())) + 1; cellVpost = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0008, cellVpost_init); m_mod_init.emplace_back(0x0008, cellVpost_init);
libmixer = static_cast <Module*>(&(m_mod_init.back())) + 1; libmixer = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back("libmixer", libmixer_init); m_mod_init.emplace_back("libmixer", libmixer_init);
sceNp = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0016, sceNp_init);
sceNpClans = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x003a, sceNpClans_init, nullptr, sceNpClans_unload);
sceNpCommerce2 = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0044, sceNpCommerce2_init, nullptr, sceNpCommerce2_unload);
sceNpSns = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0059, sceNpSns_init, nullptr, sceNpSns_unload);
sceNpTrophy = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0xf035, sceNpTrophy_init, nullptr, sceNpTrophy_unload);
sceNpTus = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0045, sceNpTus_init, nullptr, sceNpTus_unload);
sysPrxForUser = static_cast <Module*>(&(m_mod_init.back())) + 1; sysPrxForUser = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back("sysPrxForUser", sysPrxForUser_init); m_mod_init.emplace_back("sysPrxForUser", sysPrxForUser_init);
sys_fs = static_cast <Module*>(&(m_mod_init.back())) + 1; sys_fs = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x000e, sys_fs_init); m_mod_init.emplace_back(0x000e, sys_fs_init);
sys_io = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0017, sys_io_init);
sys_net = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back((u16)0x0000, sys_net_init);
initialized = true; initialized = true;
} }
} }

View File

@ -5,6 +5,7 @@
#include "Emu/SysCalls/Modules.h" #include "Emu/SysCalls/Modules.h"
#include "Emu/SysCalls/SysCalls.h" #include "Emu/SysCalls/SysCalls.h"
#include "Emu/RSX/GCM.h" #include "Emu/RSX/GCM.h"
#include "Emu/SysCalls/lv2/sys_process.h"
#include "sysPrxForUser.h" #include "sysPrxForUser.h"
#include "cellGcmSys.h" #include "cellGcmSys.h"
@ -37,6 +38,29 @@ gcmInfo gcm_info;
u32 map_offset_addr = 0; u32 map_offset_addr = 0;
u32 map_offset_pos = 0; u32 map_offset_pos = 0;
// Auxiliary functions
/*
* Get usable local memory size for a specific game SDK version
* Example: For 0x00446000 (FW 4.46) we get a localSize of 0x0F900000 (249MB)
*/
u32 gcmGetLocalMemorySize(u32 sdk_version)
{
if (sdk_version >= 0x00220000) {
return 0x0F900000; // 249MB
}
if (sdk_version >= 0x00200000) {
return 0x0F200000; // 242MB
}
if (sdk_version >= 0x00190000) {
return 0x0EA00000; // 234MB
}
if (sdk_version >= 0x00180000) {
return 0x0E800000; // 232MB
}
return 0x0E000000; // 224MB
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Data Retrieval // Data Retrieval
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -267,16 +291,29 @@ u32 cellGcmGetTiledPitchSize(u32 size)
return 0; return 0;
} }
int cellGcmInit(u32 context_addr, u32 cmdSize, u32 ioSize, u32 ioAddress) void _cellGcmFunc1()
{ {
cellGcmSys->Warning("cellGcmInit(context_addr=0x%x,cmdSize=0x%x,ioSize=0x%x,ioAddress=0x%x)", context_addr, cmdSize, ioSize, ioAddress); cellGcmSys->Todo("_cellGcmFunc1()");
return;
}
void _cellGcmFunc15(mem_ptr_t<CellGcmContextData> context)
{
cellGcmSys->Todo("_cellGcmFunc15(context_addr=0x%x)", context.GetAddr());
return;
}
// Called by cellGcmInit
s32 _cellGcmInitBody(mem_ptr_t<CellGcmContextData> context, u32 cmdSize, u32 ioSize, u32 ioAddress)
{
cellGcmSys->Warning("_cellGcmInitBody(context_addr=0x%x, cmdSize=0x%x, ioSize=0x%x, ioAddress=0x%x)", context.GetAddr(), cmdSize, ioSize, ioAddress);
if(!cellGcmSys->IsLoaded()) if(!cellGcmSys->IsLoaded())
cellGcmSys->Load(); cellGcmSys->Load();
if(!local_size && !local_addr) if(!local_size && !local_addr)
{ {
local_size = 0xf900000; //TODO local_size = 0xf900000; // TODO: Get sdk_version in _cellGcmFunc15 and pass it to gcmGetLocalMemorySize
local_addr = Memory.RSXFBMem.GetStartAddr(); local_addr = Memory.RSXFBMem.GetStartAddr();
Memory.RSXFBMem.AllocAlign(local_size); Memory.RSXFBMem.AllocAlign(local_size);
} }
@ -323,7 +360,7 @@ int cellGcmInit(u32 context_addr, u32 cmdSize, u32 ioSize, u32 ioAddress)
gcm_info.control_addr = gcm_info.context_addr + 0x40; gcm_info.control_addr = gcm_info.context_addr + 0x40;
Memory.WriteData(gcm_info.context_addr, current_context); Memory.WriteData(gcm_info.context_addr, current_context);
Memory.Write32(context_addr, gcm_info.context_addr); Memory.Write32(context.GetAddr(), gcm_info.context_addr);
CellGcmControl& ctrl = (CellGcmControl&)Memory[gcm_info.control_addr]; CellGcmControl& ctrl = (CellGcmControl&)Memory[gcm_info.control_addr];
ctrl.put = 0; ctrl.put = 0;
@ -331,8 +368,8 @@ int cellGcmInit(u32 context_addr, u32 cmdSize, u32 ioSize, u32 ioAddress)
ctrl.ref = -1; ctrl.ref = -1;
auto& render = Emu.GetGSManager().GetRender(); auto& render = Emu.GetGSManager().GetRender();
render.m_ctxt_addr = context_addr; render.m_ctxt_addr = context.GetAddr();
render.m_gcm_buffers_addr = Memory.Alloc(sizeof(gcmBuffer) * 8, sizeof(gcmBuffer)); render.m_gcm_buffers_addr = Memory.Alloc(sizeof(CellGcmDisplayInfo) * 8, sizeof(CellGcmDisplayInfo));
render.m_zculls_addr = Memory.Alloc(sizeof(CellGcmZcullInfo) * 8, sizeof(CellGcmZcullInfo)); render.m_zculls_addr = Memory.Alloc(sizeof(CellGcmZcullInfo) * 8, sizeof(CellGcmZcullInfo));
render.m_tiles_addr = Memory.Alloc(sizeof(CellGcmTileInfo) * 15, sizeof(CellGcmTileInfo)); render.m_tiles_addr = Memory.Alloc(sizeof(CellGcmTileInfo) * 15, sizeof(CellGcmTileInfo));
render.m_gcm_buffers_count = 0; render.m_gcm_buffers_count = 0;
@ -374,21 +411,19 @@ int cellGcmSetDisplayBuffer(u32 id, u32 offset, u32 pitch, u32 width, u32 height
{ {
cellGcmSys->Log("cellGcmSetDisplayBuffer(id=0x%x,offset=0x%x,pitch=%d,width=%d,height=%d)", id, offset, width ? pitch / width : pitch, width, height); cellGcmSys->Log("cellGcmSetDisplayBuffer(id=0x%x,offset=0x%x,pitch=%d,width=%d,height=%d)", id, offset, width ? pitch / width : pitch, width, height);
if (id > 7) if (id > 7) {
{
cellGcmSys->Error("cellGcmSetDisplayBuffer : CELL_EINVAL"); cellGcmSys->Error("cellGcmSetDisplayBuffer : CELL_EINVAL");
return CELL_EINVAL; return CELL_EINVAL;
} }
gcmBuffer* buffers = (gcmBuffer*)Memory.GetMemFromAddr(Emu.GetGSManager().GetRender().m_gcm_buffers_addr); CellGcmDisplayInfo* buffers = (CellGcmDisplayInfo*)Memory.GetMemFromAddr(Emu.GetGSManager().GetRender().m_gcm_buffers_addr);
buffers[id].offset = re(offset); buffers[id].offset = offset;
buffers[id].pitch = re(pitch); buffers[id].pitch = pitch;
buffers[id].width = re(width); buffers[id].width = width;
buffers[id].height = re(height); buffers[id].height = height;
if(id + 1 > Emu.GetGSManager().GetRender().m_gcm_buffers_count) if (id + 1 > Emu.GetGSManager().GetRender().m_gcm_buffers_count) {
{
Emu.GetGSManager().GetRender().m_gcm_buffers_count = id + 1; Emu.GetGSManager().GetRender().m_gcm_buffers_count = id + 1;
} }
@ -1066,18 +1101,6 @@ int cellGcmSetFlipCommand(u32 ctx, u32 id)
return cellGcmSetPrepareFlip(ctx, id); return cellGcmSetPrepareFlip(ctx, id);
} }
s64 cellGcmFunc15(u32 unk_addr)
{
cellGcmSys->Todo("cellGcmFunc15(unk_addr=0x%x)", unk_addr);
if (0/*TODO: If what?*/) {
_sys_memset(unk_addr, 0, 0x84);
}
// TODO
return 0;
}
int cellGcmSetFlipCommandWithWaitLabel(u32 ctx, u32 id, u32 label_index, u32 label_value) int cellGcmSetFlipCommandWithWaitLabel(u32 ctx, u32 id, u32 label_index, u32 label_value)
{ {
cellGcmSys->Log("cellGcmSetFlipCommandWithWaitLabel(ctx=0x%x, id=0x%x, label_index=0x%x, label_value=0x%x)", cellGcmSys->Log("cellGcmSetFlipCommandWithWaitLabel(ctx=0x%x, id=0x%x, label_index=0x%x, label_value=0x%x)",
@ -1196,7 +1219,9 @@ void cellGcmSys_init()
cellGcmSys->AddFunc(0x23ae55a3, cellGcmGetLastSecondVTime); cellGcmSys->AddFunc(0x23ae55a3, cellGcmGetLastSecondVTime);
cellGcmSys->AddFunc(0x055bd74d, cellGcmGetTiledPitchSize); cellGcmSys->AddFunc(0x055bd74d, cellGcmGetTiledPitchSize);
cellGcmSys->AddFunc(0x723bbc7e, cellGcmGetVBlankCount); cellGcmSys->AddFunc(0x723bbc7e, cellGcmGetVBlankCount);
cellGcmSys->AddFunc(0x15bae46b, cellGcmInit); cellGcmSys->AddFunc(0x5f909b17, _cellGcmFunc1);
cellGcmSys->AddFunc(0x3a33c1fd, _cellGcmFunc15);
cellGcmSys->AddFunc(0x15bae46b, _cellGcmInitBody);
cellGcmSys->AddFunc(0xfce9e764, cellGcmInitSystemMode); cellGcmSys->AddFunc(0xfce9e764, cellGcmInitSystemMode);
cellGcmSys->AddFunc(0xb2e761d4, cellGcmResetFlipStatus); cellGcmSys->AddFunc(0xb2e761d4, cellGcmResetFlipStatus);
cellGcmSys->AddFunc(0x51c9d62b, cellGcmSetDebugOutputLevel); cellGcmSys->AddFunc(0x51c9d62b, cellGcmSetDebugOutputLevel);
@ -1258,7 +1283,6 @@ void cellGcmSys_init()
// Other // Other
cellGcmSys->AddFunc(0x21397818, cellGcmSetFlipCommand); cellGcmSys->AddFunc(0x21397818, cellGcmSetFlipCommand);
cellGcmSys->AddFunc(0x3a33c1fd, cellGcmFunc15);
cellGcmSys->AddFunc(0xd8f88e1a, cellGcmSetFlipCommandWithWaitLabel); cellGcmSys->AddFunc(0xd8f88e1a, cellGcmSetFlipCommandWithWaitLabel);
cellGcmSys->AddFunc(0xd0b1d189, cellGcmSetTile); cellGcmSys->AddFunc(0xd0b1d189, cellGcmSetTile);
} }

View File

@ -7,7 +7,7 @@ enum
CELL_GCM_ERROR_INVALID_ENUM = 0x80210002, CELL_GCM_ERROR_INVALID_ENUM = 0x80210002,
CELL_GCM_ERROR_INVALID_VALUE = 0x80210003, CELL_GCM_ERROR_INVALID_VALUE = 0x80210003,
CELL_GCM_ERROR_INVALID_ALIGNMENT = 0x80210004, CELL_GCM_ERROR_INVALID_ALIGNMENT = 0x80210004,
CELL_GCM_ERROR_ADDRESS_OVERWRAP = 0x80210005 CELL_GCM_ERROR_ADDRESS_OVERWRAP = 0x80210005,
}; };
struct gcm_offset struct gcm_offset
@ -18,6 +18,8 @@ struct gcm_offset
// Auxiliary functions // Auxiliary functions
void InitOffsetTable(); void InitOffsetTable();
u32 gcmGetLocalMemorySize();
// SysCalls // SysCalls
s32 cellGcmSetPrepareFlip(mem_ptr_t<CellGcmContextData> ctxt, u32 id); s32 cellGcmSetPrepareFlip(mem_ptr_t<CellGcmContextData> ctxt, u32 id);

View File

@ -1,26 +1,11 @@
#include "stdafx.h" #include "stdafx.h"
#if 0 #include "Emu/SysCalls/Modules.h"
#include "Emu/SysCalls/SysCalls.h" #include "Emu/SysCalls/SysCalls.h"
#include "Emu/SysCalls/SC_FUNC.h" #include "cellGem.h"
void cellGem_init(); void cellGem_init();
Module cellGem(0x005a, cellGem_init); //Module cellGem(0x005a, cellGem_init);
Module *cellGem = nullptr;
// Error Codes
enum
{
CELL_GEM_ERROR_RESOURCE_ALLOCATION_FAILED = 0x80121801,
CELL_GEM_ERROR_ALREADY_INITIALIZED = 0x80121802,
CELL_GEM_ERROR_UNINITIALIZED = 0x80121803,
CELL_GEM_ERROR_INVALID_PARAMETER = 0x80121804,
CELL_GEM_ERROR_INVALID_ALIGNMENT = 0x80121805,
CELL_GEM_ERROR_UPDATE_NOT_FINISHED = 0x80121806,
CELL_GEM_ERROR_UPDATE_NOT_STARTED = 0x80121807,
CELL_GEM_ERROR_CONVERT_NOT_FINISHED = 0x80121808,
CELL_GEM_ERROR_CONVERT_NOT_STARTED = 0x80121809,
CELL_GEM_ERROR_WRITE_NOT_FINISHED = 0x8012180A,
CELL_GEM_ERROR_NOT_A_HUE = 0x8012180B,
};
int cellGemCalibrate() int cellGemCalibrate()
{ {
@ -124,10 +109,16 @@ int cellGemGetInfo()
return CELL_OK; return CELL_OK;
} }
int cellGemGetMemorySize() // Should int be used, even when type is int_32t (s32)?
s32 cellGemGetMemorySize(be_t<s32> max_connect)
{ {
UNIMPLEMENTED_FUNC(cellGem); cellGem->Warning("cellGemGetMemorySize(max_connect=%i)", max_connect);
return CELL_OK;
if (max_connect > CELL_GEM_MAX_NUM)
return CELL_GEM_ERROR_INVALID_PARAMETER;
// Return in kilobytes, megabytes or something else? (currently kilobytes)
return max_connect * 4000;
} }
int cellGemGetRGB() int cellGemGetRGB()
@ -240,47 +231,46 @@ int cellGemWriteExternalPort()
void cellGem_init() void cellGem_init()
{ {
//cellGem.AddFunc(, cellGemAttributeInit); //cellGem->AddFunc(, cellGemAttributeInit);
cellGem.AddFunc(0xafa99ead, cellGemCalibrate); cellGem->AddFunc(0xafa99ead, cellGemCalibrate);
cellGem.AddFunc(0x9b9714a4, cellGemClearStatusFlags); cellGem->AddFunc(0x9b9714a4, cellGemClearStatusFlags);
cellGem.AddFunc(0x1a13d010, cellGemConvertVideoFinish); cellGem->AddFunc(0x1a13d010, cellGemConvertVideoFinish);
cellGem.AddFunc(0x6dce048c, cellGemConvertVideoStart); cellGem->AddFunc(0x6dce048c, cellGemConvertVideoStart);
cellGem.AddFunc(0x4219de31, cellGemEnableCameraPitchAngleCorrection); cellGem->AddFunc(0x4219de31, cellGemEnableCameraPitchAngleCorrection);
cellGem.AddFunc(0x1a2518a2, cellGemEnableMagnetometer); cellGem->AddFunc(0x1a2518a2, cellGemEnableMagnetometer);
cellGem.AddFunc(0xe1f85a80, cellGemEnd); cellGem->AddFunc(0xe1f85a80, cellGemEnd);
cellGem.AddFunc(0x6fc4c791, cellGemFilterState); cellGem->AddFunc(0x6fc4c791, cellGemFilterState);
cellGem.AddFunc(0xce6d7791, cellGemForceRGB); cellGem->AddFunc(0xce6d7791, cellGemForceRGB);
cellGem.AddFunc(0x6a5b7048, cellGemGetAccelerometerPositionInDevice); cellGem->AddFunc(0x6a5b7048, cellGemGetAccelerometerPositionInDevice);
cellGem.AddFunc(0x2d2c2764, cellGemGetAllTrackableHues); cellGem->AddFunc(0x2d2c2764, cellGemGetAllTrackableHues);
cellGem.AddFunc(0x8befac67, cellGemGetCameraState); cellGem->AddFunc(0x8befac67, cellGemGetCameraState);
cellGem.AddFunc(0x02eb41bb, cellGemGetEnvironmentLightingColor); cellGem->AddFunc(0x02eb41bb, cellGemGetEnvironmentLightingColor);
cellGem.AddFunc(0xb8ef56a6, cellGemGetHuePixels); cellGem->AddFunc(0xb8ef56a6, cellGemGetHuePixels);
cellGem.AddFunc(0x92cc4b34, cellGemGetImageState); cellGem->AddFunc(0x92cc4b34, cellGemGetImageState);
cellGem.AddFunc(0xd37b127a, cellGemGetInertialState); cellGem->AddFunc(0xd37b127a, cellGemGetInertialState);
cellGem.AddFunc(0x9e1dff96, cellGemGetInfo); cellGem->AddFunc(0x9e1dff96, cellGemGetInfo);
cellGem.AddFunc(0x2e0a170d, cellGemGetMemorySize); cellGem->AddFunc(0x2e0a170d, cellGemGetMemorySize);
cellGem.AddFunc(0x1b30cc22, cellGemGetRGB); cellGem->AddFunc(0x1b30cc22, cellGemGetRGB);
cellGem.AddFunc(0x6db6b007, cellGemGetRumble); cellGem->AddFunc(0x6db6b007, cellGemGetRumble);
cellGem.AddFunc(0x6441d38d, cellGemGetState); cellGem->AddFunc(0x6441d38d, cellGemGetState);
cellGem.AddFunc(0xfee33481, cellGemGetStatusFlags); cellGem->AddFunc(0xfee33481, cellGemGetStatusFlags);
cellGem.AddFunc(0x18ea899a, cellGemGetTrackerHue); cellGem->AddFunc(0x18ea899a, cellGemGetTrackerHue);
//cellGem.AddFunc(, cellGemGetVideoConvertSize); //cellGem->AddFunc(, cellGemGetVideoConvertSize);
cellGem.AddFunc(0xc7622586, cellGemHSVtoRGB); cellGem->AddFunc(0xc7622586, cellGemHSVtoRGB);
cellGem.AddFunc(0x13ea7c64, cellGemInit); cellGem->AddFunc(0x13ea7c64, cellGemInit);
cellGem.AddFunc(0xe3e4f0d6, cellGemInvalidateCalibration); cellGem->AddFunc(0xe3e4f0d6, cellGemInvalidateCalibration);
cellGem.AddFunc(0xfb5887f9, cellGemIsTrackableHue); cellGem->AddFunc(0xfb5887f9, cellGemIsTrackableHue);
cellGem.AddFunc(0xa03ef587, cellGemPrepareCamera); cellGem->AddFunc(0xa03ef587, cellGemPrepareCamera);
cellGem.AddFunc(0xc07896f9, cellGemPrepareVideoConvert); cellGem->AddFunc(0xc07896f9, cellGemPrepareVideoConvert);
//cellGem.AddFunc(, cellGemReadExternalPortDeviceInfo); //cellGem->AddFunc(, cellGemReadExternalPortDeviceInfo);
cellGem.AddFunc(0xde54e2fc, cellGemReset); cellGem->AddFunc(0xde54e2fc, cellGemReset);
cellGem.AddFunc(0x49609306, cellGemSetRumble); cellGem->AddFunc(0x49609306, cellGemSetRumble);
cellGem.AddFunc(0x77e08704, cellGemSetYaw); cellGem->AddFunc(0x77e08704, cellGemSetYaw);
cellGem.AddFunc(0x928ac5f8, cellGemTrackHues); cellGem->AddFunc(0x928ac5f8, cellGemTrackHues);
cellGem.AddFunc(0x41ae9c31, cellGemUpdateFinish); cellGem->AddFunc(0x41ae9c31, cellGemUpdateFinish);
cellGem.AddFunc(0x0ecd2261, cellGemUpdateStart); cellGem->AddFunc(0x0ecd2261, cellGemUpdateStart);
//cellGem.AddFunc(, cellGemVideoConvertAttributeInit); //cellGem->AddFunc(, cellGemVideoConvertAttributeInit);
//cellGem.AddFunc(, cellGemVideoConvertAttributeInitRgba); //cellGem->AddFunc(, cellGemVideoConvertAttributeInitRgba);
cellGem.AddFunc(0x1f6328d8, cellGemWriteExternalPort); cellGem->AddFunc(0x1f6328d8, cellGemWriteExternalPort);
} }
#endif

View File

@ -0,0 +1,190 @@
#pragma once
#include "cellSpurs.h"
// Had to use define, since enum doesn't allow floats
#define CELL_GEM_SPHERE_RADIUS_MM = 22.5f;
// Error Codes
enum
{
CELL_GEM_ERROR_RESOURCE_ALLOCATION_FAILED = 0x80121801,
CELL_GEM_ERROR_ALREADY_INITIALIZED = 0x80121802,
CELL_GEM_ERROR_UNINITIALIZED = 0x80121803,
CELL_GEM_ERROR_INVALID_PARAMETER = 0x80121804,
CELL_GEM_ERROR_INVALID_ALIGNMENT = 0x80121805,
CELL_GEM_ERROR_UPDATE_NOT_FINISHED = 0x80121806,
CELL_GEM_ERROR_UPDATE_NOT_STARTED = 0x80121807,
CELL_GEM_ERROR_CONVERT_NOT_FINISHED = 0x80121808,
CELL_GEM_ERROR_CONVERT_NOT_STARTED = 0x80121809,
CELL_GEM_ERROR_WRITE_NOT_FINISHED = 0x8012180A,
CELL_GEM_ERROR_NOT_A_HUE = 0x8012180B,
};
// Runtime statuses
enum
{
CELL_GEM_NOT_CONNECTED = 1,
CELL_GEM_SPHERE_NOT_CALIBRATED = 2,
CELL_GEM_SPHERE_CALIBRATING = 3,
CELL_GEM_COMPUTING_AVAILABLE_COLORS = 4,
CELL_GEM_HUE_NOT_SET = 5,
CELL_GEM_NO_VIDEO = 6,
CELL_GEM_TIME_OUT_OF_RANGE = 7,
CELL_GEM_NOT_CALIBRATED = 8,
CELL_GEM_NO_EXTERNAL_PORT_DEVICE = 9,
};
// General constents
enum
{
CELL_GEM_CTRL_CIRCLE = 1 << 5,
CELL_GEM_CTRL_CROSS = 1 << 6,
CELL_GEM_CTRL_MOVE = 1 << 2,
CELL_GEM_CTRL_SELECT = 1 << 0,
CELL_GEM_CTRL_SQUARE = 1 << 7,
CELL_GEM_CTRL_START = 1 << 3,
CELL_GEM_CTRL_T = 1 << 1,
CELL_GEM_CTRL_TRIANGLE = 1 << 4,
CELL_GEM_DONT_CARE_HUE = 4 << 24,
CELL_GEM_DONT_CHANGE_HUE = 8 << 24,
CELL_GEM_DONT_TRACK_HUE = 2 << 24,
CELL_GEM_EXT_CONNECTED = 1 << 0,
CELL_GEM_EXT_EXT0 = 1 << 1,
CELL_GEM_EXT_EXT1 = 1 << 2,
CELL_GEM_EXTERNAL_PORT_DEVICE_INFO_SIZE = 38,
CELL_GEM_EXTERNAL_PORT_OUTPUT_SIZE = 40,
CELL_GEM_FLAG_CALIBRATION_FAILED_BRIGHT_LIGHTING = 1 << 4,
CELL_GEM_FLAG_CALIBRATION_FAILED_CANT_FIND_SPHERE = 1 << 2,
CELL_GEM_FLAG_CALIBRATION_FAILED_MOTION_DETECTED = 1 << 3,
CELL_GEM_FLAG_CALIBRATION_OCCURRED = 1 << 0,
CELL_GEM_FLAG_CALIBRATION_SUCCEEDED = 1 << 1,
CELL_GEM_FLAG_CALIBRATION_WARNING_BRIGHT_LIGHTING = 1 << 6,
ELL_GEM_FLAG_CALIBRATION_WARNING_MOTION_DETECTED = 1 << 5,
CELL_GEM_FLAG_CAMERA_PITCH_ANGLE_CHANGED = 1 << 9,
CELL_GEM_FLAG_CURRENT_HUE_CONFLICTS_WITH_ENVIRONMENT = 1 << 13,
CELL_GEM_FLAG_LIGHTING_CHANGED = 1 << 7,
CELL_GEM_FLAG_VARIABLE_MAGNETIC_FIELD = 1 << 10,
CELL_GEM_FLAG_VERY_COLORFUL_ENVIRONMENT = 1 << 12,
CELL_GEM_FLAG_WEAK_MAGNETIC_FIELD = 1 << 11,
CELL_GEM_FLAG_WRONG_FIELD_OF_VIEW_SETTING = 1 << 8,
CELL_GEM_INERTIAL_STATE_FLAG_LATEST = 0,
CELL_GEM_INERTIAL_STATE_FLAG_NEXT = 2,
CELL_GEM_INERTIAL_STATE_FLAG_PREVIOUS = 1,
CELL_GEM_LATENCY_OFFSET = -22000,
CELL_GEM_MAX_CAMERA_EXPOSURE = 511,
CELL_GEM_MAX_NUM = 4,
CELL_GEM_MIN_CAMERA_EXPOSURE = 40,
CELL_GEM_STATE_FLAG_CURRENT_TIME = 0,
CELL_GEM_STATE_FLAG_LATEST_IMAGE_TIME = 1,
CELL_GEM_STATE_FLAG_TIMESTAMP = 2,
CELL_GEM_STATUS_DISCONNECTED = 0,
CELL_GEM_STATUS_READY = 1,
CELL_GEM_TRACKING_FLAG_POSITION_TRACKED = 1 << 0,
CELL_GEM_TRACKING_FLAG_VISIBLE = 1 << 1,
CELL_GEM_VERSION = 2,
};
struct CellGemAttribute
{
be_t<u32> version;
be_t<u32> max_connect;
be_t<u32> memory_ptr;
CellSpurs spurs;
u8 spu_priorities[8];
};
struct CellGemCameraState
{
be_t<s32> exposure;
float exposure_time;
float gain;
float pitch_angle;
float pitch_angle_estimate;
};
struct CellGemExtPortData
{
be_t<u16> status;
be_t<u16> digital1;
be_t<u16> digital2;
be_t<u16> analog_right_x;
be_t<u16> analog_right_y;
be_t<u16> analog_left_x;
be_t<u16> analog_left_y;
u8 custom[5];
};
struct CellGemImageState
{
//system_time_t frame_timestamp; // TODO: Figure what to use for them
//system_time_t timestamp;
float u;
float v;
float r;
float projectionx;
float projectiony;
float distance;
u8 visible;
u8 r_valid;
};
struct CellGemPadData
{
be_t<u16> digitalbuttons;
be_t<u16> analog_T;
};
struct CellGemInertialState
{
//vec_float4 accelerometer; // TODO: Figure what to use as replacement for vec_float4
//vec_float4 gyro;
//vec_float4 accelerometer_bias;
//vec_float4 gyro_bias;
CellGemPadData pad;
CellGemExtPortData ext;
//system_time_t timestamp;
be_t<s32> counter;
float temperature;
};
struct CellGemInfo
{
be_t<u32> max_connect;
be_t<u32> now_connect;
be_t<u32> status[CELL_GEM_MAX_NUM];
be_t<u32> port[CELL_GEM_MAX_NUM];
};
struct CellGemState
{
//vec_float4 pos;
//vec_float4 vel;
//vec_float4 accel;
//vec_float4 quat;
//vec_float4 angvel;
//vec_float4 angaccel;
//vec_float4 handle_pos;
//vec_float4 handle_vel;
//vec_float4 handle_accel;
CellGemPadData pad;
CellGemExtPortData ext;
//system_time_t timestamp;
float temperature;
float camera_pitch_angle;
be_t<u32> tracking_flags;
};
struct CellGemVideoConvertAttribute
{
be_t<s32> version;
be_t<s32> output_format;
be_t<s32> conversion_flags;
float gain;
float red_gain;
float green_gain;
float blue_gain;
be_t<u32> buffer_memory;
be_t<u32> video_data_out;
u8 alpha;
};

View File

@ -3,39 +3,22 @@
#include "Emu/Memory/Memory.h" #include "Emu/Memory/Memory.h"
#include "Emu/System.h" #include "Emu/System.h"
#include "Emu/SysCalls/Modules.h" #include "Emu/SysCalls/Modules.h"
#include "cellL10n.h"
#include <stdio.h>
#include <stdlib.h>
// Requires GCC 4.10 apparently..
#ifdef _MSC_VER #ifdef _MSC_VER
#include <windows.h>
#include <wchar.h>
#include <codecvt> #include <codecvt>
#else
#include <iconv.h>
#endif #endif
//void cellL10n_init(); //void cellL10n_init();
//Module cellL10n(0x001e, cellL10n_init); //Module cellL10n(0x001e, cellL10n_init);
Module *cellL10n = nullptr; Module *cellL10n = nullptr;
// L10nResult
enum
{
ConversionOK,
SRCIllegal,
DSTExhausted,
ConverterUnknown,
};
// detection result
enum
{
L10N_STR_UNKNOWN = (1 << 0),
L10N_STR_ASCII = (1 << 1),
L10N_STR_JIS = (1 << 2),
L10N_STR_EUCJP = (1 << 3),
L10N_STR_SJIS = (1 << 4),
L10N_STR_UTF8 = (1 << 5),
L10N_STR_ILLEGAL = (1 << 16),
L10N_STR_ERROR = (1 << 17),
};
int UTF16stoUTF8s(mem16_ptr_t utf16, mem64_t utf16_len, mem8_ptr_t utf8, mem64_t utf8_len) int UTF16stoUTF8s(mem16_ptr_t utf16, mem64_t utf16_len, mem8_ptr_t utf8, mem64_t utf8_len)
{ {
cellL10n->Warning("UTF16stoUTF8s(utf16_addr=0x%x, utf16_len_addr=0x%x, utf8_addr=0x%x, utf8_len_addr=0x%x)", cellL10n->Warning("UTF16stoUTF8s(utf16_addr=0x%x, utf16_len_addr=0x%x, utf8_addr=0x%x, utf8_len_addr=0x%x)",
@ -66,6 +49,289 @@ int jstrchk(mem8_ptr_t jstr)
return L10N_STR_UTF8; return L10N_STR_UTF8;
} }
//translate code id to code name. some codepage may has another name.
//If this makes your compilation fail, try replace the string code with one in "iconv -l"
bool _L10nCodeParse(int code, std::string& retCode)
{
if ((code >= _L10N_CODE_) || (code < 0)) return false;
switch (code)
{
//I don't know these Unicode Variants is LB or BE.
case L10N_UTF8: retCode = "UTF-8"; return true;
case L10N_UTF16: retCode = "UTF-16"; return true;
case L10N_UTF32: retCode = "UTF-32"; return true;
case L10N_UCS2: retCode = "UCS-2"; return true;
case L10N_UCS4: retCode = "UCS-4"; return true;
case L10N_ISO_8859_1: retCode = "ISO-8859-1"; return true;
case L10N_ISO_8859_2: retCode = "ISO-8859-2"; return true;
case L10N_ISO_8859_3: retCode = "ISO-8859-3"; return true;
case L10N_ISO_8859_4: retCode = "ISO-8859-4"; return true;
case L10N_ISO_8859_5: retCode = "ISO-8859-5"; return true;
case L10N_ISO_8859_6: retCode = "ISO-8859-6"; return true;
case L10N_ISO_8859_7: retCode = "ISO-8859-7"; return true;
case L10N_ISO_8859_8: retCode = "ISO-8859-8"; return true;
case L10N_ISO_8859_9: retCode = "ISO-8859-9"; return true;
case L10N_ISO_8859_10: retCode = "ISO-8859-10"; return true;
case L10N_ISO_8859_11: retCode = "ISO-8859-11"; return true;
case L10N_ISO_8859_13: retCode = "ISO-8859-13"; return true; //No ISO-8859-12 ha ha.
case L10N_ISO_8859_14: retCode = "ISO-8859-14"; return true;
case L10N_ISO_8859_15: retCode = "ISO-8859-15"; return true;
case L10N_ISO_8859_16: retCode = "ISO-8859-16"; return true;
case L10N_CODEPAGE_437: retCode = "CP437"; return true;
case L10N_CODEPAGE_850: retCode = "CP850"; return true;
case L10N_CODEPAGE_863: retCode = "CP863"; return true;
case L10N_CODEPAGE_866: retCode = "CP866"; return true;
case L10N_CODEPAGE_932: retCode = "CP932"; return true;
case L10N_CODEPAGE_936: retCode = "CP936"; return true;
case L10N_CODEPAGE_949: retCode = "CP949"; return true;
case L10N_CODEPAGE_950: retCode = "CP950"; return true;
case L10N_CODEPAGE_1251:retCode = "CP1251"; return true; //CYRL
case L10N_CODEPAGE_1252:retCode = "CP1252"; return true; //ANSI
case L10N_EUC_CN: retCode = "EUC-CN"; return true; //GB2312
case L10N_EUC_JP: retCode = "EUC-JP"; return true;
case L10N_EUC_KR: retCode = "EUC-KR"; return true;
case L10N_ISO_2022_JP: retCode = "ISO-2022-JP"; return true;
case L10N_ARIB: retCode = "ARABIC"; return true; //TODO: think that should be ARABIC.
case L10N_HZ: retCode = "HZ"; return true;
case L10N_GB18030: retCode = "GB18030"; return true;
case L10N_RIS_506: retCode = "SHIFT-JIS"; return true; //MusicShiftJIS, MS_KANJI
//These are only supported with FW 3.10 and above
case L10N_CODEPAGE_852: retCode = "CP852"; return true;
case L10N_CODEPAGE_1250:retCode = "CP1250"; return true; //EE
case L10N_CODEPAGE_737: retCode = "CP737"; return true;
case L10N_CODEPAGE_1253:retCode = "CP1253"; return true; //Greek
case L10N_CODEPAGE_857: retCode = "CP857"; return true;
case L10N_CODEPAGE_1254:retCode = "CP1254"; return true; //Turk
case L10N_CODEPAGE_775: retCode = "CP775"; return true;
case L10N_CODEPAGE_1257:retCode = "CP1257"; return true; //WINBALTRIM
case L10N_CODEPAGE_855: retCode = "CP855"; return true;
case L10N_CODEPAGE_858: retCode = "CP858"; return true;
case L10N_CODEPAGE_860: retCode = "CP860"; return true;
case L10N_CODEPAGE_861: retCode = "CP861"; return true;
case L10N_CODEPAGE_865: retCode = "CP865"; return true;
case L10N_CODEPAGE_869: retCode = "CP869"; return true;
default: return false;
}
}
//translate code id to code name.
//If this makes your compilation fail, try replace the string code with one in "iconv -l"
bool _L10nCodeParse(int code, unsigned int & retCode)
{
retCode = 0;
if ((code >= _L10N_CODE_) || (code < 0)) return false;
switch (code)
{
case L10N_UTF8: retCode = 65001; return false;
case L10N_UTF16: retCode = 1200; return false; //1200=LE,1201=BE
case L10N_UTF32: retCode = 12000; return false; //12000=LE,12001=BE
case L10N_UCS2: retCode = 1200; return false; //Not in OEM, but just the same as UTF16
case L10N_UCS4: retCode = 12000; return false; //Not in OEM, but just the same as UTF32
//All OEM Code Pages are Multi-Byte, not wchar_t,u16,u32.
case L10N_ISO_8859_1: retCode = 28591; return true;
case L10N_ISO_8859_2: retCode = 28592; return true;
case L10N_ISO_8859_3: retCode = 28593; return true;
case L10N_ISO_8859_4: retCode = 28594; return true;
case L10N_ISO_8859_5: retCode = 28595; return true;
case L10N_ISO_8859_6: retCode = 28596; return true;
case L10N_ISO_8859_7: retCode = 28597; return true;
case L10N_ISO_8859_8: retCode = 28598; return true;
case L10N_ISO_8859_9: retCode = 28599; return true;
case L10N_ISO_8859_10: retCode = 28600; return true;
case L10N_ISO_8859_11: retCode = 28601; return true;
case L10N_ISO_8859_13: retCode = 28603; return true; //No ISO-8859-12 ha ha.
case L10N_ISO_8859_14: retCode = 28604; return true;
case L10N_ISO_8859_15: retCode = 28605; return true;
case L10N_ISO_8859_16: retCode = 28606; return true;
case L10N_CODEPAGE_437: retCode = 437; return true;
case L10N_CODEPAGE_850: retCode = 850; return true;
case L10N_CODEPAGE_863: retCode = 863; return true;
case L10N_CODEPAGE_866: retCode = 866; return true;
case L10N_CODEPAGE_932: retCode = 932; return true;
case L10N_CODEPAGE_936: retCode = 936; return true;
case L10N_CODEPAGE_949: retCode = 949; return true;
case L10N_CODEPAGE_950: retCode = 950; return true;
case L10N_CODEPAGE_1251:retCode = 1251; return true; //CYRL
case L10N_CODEPAGE_1252:retCode = 1252; return true; //ANSI
case L10N_EUC_CN: retCode = 51936; return true; //GB2312
case L10N_EUC_JP: retCode = 51932; return true;
case L10N_EUC_KR: retCode = 51949; return true;
case L10N_ISO_2022_JP: retCode = 50222; return true;
//Maybe 708/720/864/1256/10004/20420/28596/
case L10N_ARIB: retCode = 20420; return true; //TODO: think that should be ARABIC.
case L10N_HZ: retCode = 52936; return true;
case L10N_GB18030: retCode = 54936; return true;
case L10N_RIS_506: retCode = 932; return true; //MusicShiftJIS, MS_KANJI, TODO: Code page
//These are only supported with FW 3.10 and above
case L10N_CODEPAGE_852: retCode = 852; return true;
case L10N_CODEPAGE_1250:retCode = 1250; return true; //EE
case L10N_CODEPAGE_737: retCode = 737; return true;
case L10N_CODEPAGE_1253:retCode = 1253; return true; //Greek
case L10N_CODEPAGE_857: retCode = 857; return true;
case L10N_CODEPAGE_1254:retCode = 1254; return true; //Turk
case L10N_CODEPAGE_775: retCode = 775; return true;
case L10N_CODEPAGE_1257:retCode = 1257; return true; //WINBALTRIM
case L10N_CODEPAGE_855: retCode = 855; return true;
case L10N_CODEPAGE_858: retCode = 858; return true;
case L10N_CODEPAGE_860: retCode = 860; return true;
case L10N_CODEPAGE_861: retCode = 861; return true;
case L10N_CODEPAGE_865: retCode = 865; return true;
case L10N_CODEPAGE_869: retCode = 869; return true;
default: return false;
}
}
//TODO: check and complete transforms. note: unicode to/from other Unicode Formats is needed.
#ifdef _MSC_VER
//Use code page to transform std::string to std::wstring.
int _OEM2Wide(unsigned int oem_code, const std::string src, std::wstring& dst)
{
//Such length returned should include the '\0' character.
int length = MultiByteToWideChar(oem_code, 0, src.c_str(), -1, NULL, 0);
wchar_t *store = new wchar_t[length];
memset(store, 0, (length)*sizeof(wchar_t));
MultiByteToWideChar(oem_code, 0, src.c_str(), -1, (LPWSTR)store, length);
std::wstring result(store);
dst = result;
delete store; store = NULL;
return length - 1;
}
//Use Code page to transform std::wstring to std::string.
int _Wide2OEM(unsigned int oem_code, const std::wstring src, std::string& dst)
{
//Such length returned should include the '\0' character.
int length = WideCharToMultiByte(oem_code, 0, src.c_str(), -1, NULL, 0, NULL, NULL);
char *store = new char[length];
memset(store, 0, (length)*sizeof(char));
WideCharToMultiByte(oem_code, 0, src.c_str(), -1, store, length, NULL, NULL);
std::string result(store);
dst = result;
delete store; store = NULL;
return length - 1;
}
//Convert Codepage to Codepage (all char*)
std::string _OemToOem(unsigned int src_code, unsigned int dst_code, const std::string str)
{
std::wstring wide; std::string result;
_OEM2Wide(src_code, str, wide);
_Wide2OEM(dst_code, wide, result);
return result;
}
/*
//Original piece of code. and this is for windows using with _OEM2Wide,_Wide2OEM,_OemToOem.
//The Char -> Char Execution of this function has already been tested using VS and CJK text with encoding.
int _L10nConvertStr(int src_code, const void *src, size_t * src_len, int dst_code, void *dst, size_t * dst_len)
{
unsigned int srcCode = 0, dstCode = 0; //OEM code pages
bool src_page_converted = _L10nCodeParse(src_code, srcCode); //Check if code is in list.
bool dst_page_converted = _L10nCodeParse(dst_code, dstCode);
if (((!src_page_converted) && (srcCode == 0))
|| ((!dst_page_converted) && (dstCode == 0)))
return ConverterUnknown;
if (strnlen_s((char*)src, *src_len) != *src_len) return SRCIllegal;
//std::string wrapped_source = (char*)Memory.VirtualToRealAddr(src.GetAddr());
std::string wrapped_source((char*)src);
//if (wrapped_source.length != src_len.GetValue()) return SRCIllegal;
std::string target = _OemToOem(srcCode, dstCode, wrapped_source);
if (target.length() > *dst_len) return DSTExhausted;
Memory.WriteString(dst, target.c_str());
return ConversionOK;
}
//This is the one used with iconv library for linux/mac. Also char->char.
//I've tested the code with console apps using codeblocks.
int _L10nConvertStr(int src_code, const void* src, size_t * src_len, int dst_code, void * dst, size_t * dst_len)
{
std::string srcCode, dstCode;
int retValue = ConversionOK;
if ((_L10nCodeParse(src_code, srcCode)) && (_L10nCodeParse(dst_code, dstCode)))
{
iconv_t ict = iconv_open(srcCode.c_str(), dstCode.c_str());
//char *srcBuf = (char*)Memory.VirtualToRealAddr(src.GetAddr());
//char *dstBuf = (char*)Memory.VirtualToRealAddr(dst.GetAddr());
char *srcBuf = (char*)src, *dstBuf = (char*)dst;
size_t srcLen = *src_len, dstLen = *dst_len;
size_t ictd = iconv(ict, &srcBuf, &srcLen, &dstBuf, &dstLen);
if (ictd != *src_len)
{
if (errno == EILSEQ)
retValue = SRCIllegal; //Invalid multi-byte sequence
else if (errno == E2BIG)
retValue = DSTExhausted;//Not enough space
else if (errno == EINVAL)
retValue = SRCIllegal;
}
iconv_close(ict);
//retValue = ConversionOK;
}
else retValue = ConverterUnknown;
return retValue;
}*/
#endif
//TODO: Check the code in emulation. If support for UTF8/UTF16/UTF32/UCS2/UCS4 should use wider chars.. awful.
int L10nConvertStr(int src_code, mem8_ptr_t src, mem64_t src_len, int dst_code, mem8_ptr_t dst, mem64_t dst_len)
{
LOG_ERROR(HLE, "L10nConvertStr(src_code=%d,src=0x%x,src_len=%ld,dst_code=%d,dst=0x%x,dst_len=%ld)",
src_code, src.GetAddr(), src_len.GetValue(), dst_code, dst.GetAddr(), dst_len.GetValue());
LOG_ERROR(HLE, "L10nConvertStr: 1st char at dst: %x(Hex)", *((char*)Memory.VirtualToRealAddr(src.GetAddr())));
#ifdef _MSC_VER
unsigned int srcCode = 0, dstCode = 0; //OEM code pages
bool src_page_converted = _L10nCodeParse(src_code, srcCode); //Check if code is in list.
bool dst_page_converted = _L10nCodeParse(dst_code, dstCode);
if (((!src_page_converted) && (srcCode == 0))
|| ((!dst_page_converted) && (dstCode == 0)))
return ConverterUnknown;
//if (strnlen_s((char*)src, *src_len) != *src_len) return SRCIllegal;
std::string wrapped_source = (char*)Memory.VirtualToRealAddr(src.GetAddr());
//std::string wrapped_source((char*)src);
if (wrapped_source.length() != src_len.GetValue()) return SRCIllegal;
std::string target = _OemToOem(srcCode, dstCode, wrapped_source);
if (target.length() > dst_len.GetValue()) return DSTExhausted;
Memory.WriteString(dst, target.c_str());
return ConversionOK;
#else
std::string srcCode, dstCode;
int retValue = ConversionOK;
if ((_L10nCodeParse(src_code, srcCode)) && (_L10nCodeParse(dst_code, dstCode)))
{
iconv_t ict = iconv_open(srcCode.c_str(), dstCode.c_str());
char *srcBuf = (char*)Memory.VirtualToRealAddr(src.GetAddr());
char *dstBuf = (char*)Memory.VirtualToRealAddr(dst.GetAddr());
//char *srcBuf = (char*)src, *dstBuf = (char*)dst;
//size_t srcLen = *src_len, dstLen = *dst_len;
size_t srcLen = src_len.GetValue(), dstLen = dst_len.GetValue();
size_t ictd = iconv(ict, &srcBuf, &srcLen, &dstBuf, &dstLen);
if (ictd != src_len.GetValue())//if (ictd != *src_len)
{
if (errno == EILSEQ)
retValue = SRCIllegal; //Invalid multi-byte sequence
else if (errno == E2BIG)
retValue = DSTExhausted;//Not enough space
else if (errno == EINVAL)
retValue = SRCIllegal;
}
iconv_close(ict);
//retValue = ConversionOK;
}
else retValue = ConverterUnknown;
return retValue;
#endif
}
void cellL10n_init() void cellL10n_init()
{ {
// NOTE: I think this module should be LLE'd instead of implementing all its functions // NOTE: I think this module should be LLE'd instead of implementing all its functions
@ -171,7 +437,7 @@ void cellL10n_init()
// cellL10n->AddFunc(0x8f472054, UTF8stoEUCCNs); // cellL10n->AddFunc(0x8f472054, UTF8stoEUCCNs);
// cellL10n->AddFunc(0x90e9b5d2, EUCJPstoUCS2s); // cellL10n->AddFunc(0x90e9b5d2, EUCJPstoUCS2s);
// cellL10n->AddFunc(0x91a99765, UHCtoUCS2); // cellL10n->AddFunc(0x91a99765, UHCtoUCS2);
// cellL10n->AddFunc(0x931ff25a, L10nConvertStr); cellL10n->AddFunc(0x931ff25a, L10nConvertStr);
// cellL10n->AddFunc(0x949bb14c, GBKstoUTF8s); // cellL10n->AddFunc(0x949bb14c, GBKstoUTF8s);
// cellL10n->AddFunc(0x9557ac9b, UTF8toUHC); // cellL10n->AddFunc(0x9557ac9b, UTF8toUHC);
// cellL10n->AddFunc(0x9768b6d3, UTF32toUTF8); // cellL10n->AddFunc(0x9768b6d3, UTF32toUTF8);
@ -221,7 +487,7 @@ void cellL10n_init()
// cellL10n->AddFunc(0xdefa1c17, UTF8stoHZs); // cellL10n->AddFunc(0xdefa1c17, UTF8stoHZs);
// cellL10n->AddFunc(0xe2eabb32, eucjp2kuten); // cellL10n->AddFunc(0xe2eabb32, eucjp2kuten);
// cellL10n->AddFunc(0xe6d9e234, UTF8toBIG5); // cellL10n->AddFunc(0xe6d9e234, UTF8toBIG5);
cellL10n->AddFunc(0xe6f5711b, UTF16stoUTF8s); // cellL10n->AddFunc(0xe6f5711b, UTF16stoUTF8s);
// cellL10n->AddFunc(0xe956dc64, JISstoUCS2s); // cellL10n->AddFunc(0xe956dc64, JISstoUCS2s);
// cellL10n->AddFunc(0xeabc3d00, GB18030toUTF8); // cellL10n->AddFunc(0xeabc3d00, GB18030toUTF8);
// cellL10n->AddFunc(0xeb3dc670, UTF8toSJIS); // cellL10n->AddFunc(0xeb3dc670, UTF8toSJIS);

View File

@ -0,0 +1,86 @@
#include "stdafx.h"
// Requires GCC 4.10 apparently..
#ifdef _MSC_VER
#include <codecvt>
#endif
// L10nResult
enum
{
ConversionOK,
SRCIllegal,
DSTExhausted,
ConverterUnknown,
};
// detection result
enum
{
L10N_STR_UNKNOWN = (1 << 0),
L10N_STR_ASCII = (1 << 1),
L10N_STR_JIS = (1 << 2),
L10N_STR_EUCJP = (1 << 3),
L10N_STR_SJIS = (1 << 4),
L10N_STR_UTF8 = (1 << 5),
L10N_STR_ILLEGAL = (1 << 16),
L10N_STR_ERROR = (1 << 17),
};
//CodePages
enum {
L10N_UTF8 = 0,
L10N_UTF16,
L10N_UTF32,
L10N_UCS2,
L10N_UCS4,
L10N_ISO_8859_1,
L10N_ISO_8859_2,
L10N_ISO_8859_3,
L10N_ISO_8859_4,
L10N_ISO_8859_5,
L10N_ISO_8859_6,
L10N_ISO_8859_7,
L10N_ISO_8859_8,
L10N_ISO_8859_9,
L10N_ISO_8859_10,
L10N_ISO_8859_11,
L10N_ISO_8859_13,
L10N_ISO_8859_14,
L10N_ISO_8859_15,
L10N_ISO_8859_16,
L10N_CODEPAGE_437,
L10N_CODEPAGE_850,
L10N_CODEPAGE_863,
L10N_CODEPAGE_866,
L10N_CODEPAGE_932,
L10N_CODEPAGE_936,
L10N_CODEPAGE_949,
L10N_CODEPAGE_950,
L10N_CODEPAGE_1251,
L10N_CODEPAGE_1252,
L10N_EUC_CN,
L10N_EUC_JP,
L10N_EUC_KR,
L10N_ISO_2022_JP,
L10N_ARIB,
L10N_HZ,
L10N_GB18030,
L10N_RIS_506,
//FW 3.10 and above
L10N_CODEPAGE_852,
L10N_CODEPAGE_1250,
L10N_CODEPAGE_737,
L10N_CODEPAGE_1253,
L10N_CODEPAGE_857,
L10N_CODEPAGE_1254,
L10N_CODEPAGE_775,
L10N_CODEPAGE_1257,
L10N_CODEPAGE_855,
L10N_CODEPAGE_858,
L10N_CODEPAGE_860,
L10N_CODEPAGE_861,
L10N_CODEPAGE_865,
L10N_CODEPAGE_869,
_L10N_CODE_
};

View File

@ -904,10 +904,10 @@ int cellRescGcmSurface2RescSrc(mem_ptr_t<CellGcmSurface> gcmSurface, mem_ptr_t<C
} }
rescSrc->format = textureFormat; rescSrc->format = textureFormat;
rescSrc->pitch = re(gcmSurface->colorPitch[0]); rescSrc->pitch = gcmSurface->colorPitch[0];
rescSrc->width = re(gcmSurface->width) * xW; rescSrc->width = gcmSurface->width * xW;
rescSrc->height = re(gcmSurface->height) * xH; rescSrc->height = gcmSurface->height * xH;
rescSrc->offset = re(gcmSurface->colorOffset[0]); rescSrc->offset = gcmSurface->colorOffset[0];
return CELL_OK; return CELL_OK;
} }

View File

@ -33,8 +33,8 @@ struct sceNpTrophyInternalContext
std::unique_ptr<TROPUSRLoader> tropusr; std::unique_ptr<TROPUSRLoader> tropusr;
//TODO: remove the following code when Visual C++ no longer generates // TODO: remove the following code when Visual C++ no longer generates
//compiler errors for it. All of this should be auto-generated // compiler errors for it. All of this should be auto-generated
#if defined(_MSC_VER) && _MSC_VER <= 1800 #if defined(_MSC_VER) && _MSC_VER <= 1800
sceNpTrophyInternalContext() sceNpTrophyInternalContext()
: trp_stream(), : trp_stream(),

View File

@ -920,7 +920,7 @@ void default_syscall()
void SysCalls::DoSyscall(u32 code) void SysCalls::DoSyscall(u32 code)
{ {
//Auto-Pause using simple singleton. //Auto Pause using simple singleton.
Debug::AutoPause::getInstance().TryPause(code); Debug::AutoPause::getInstance().TryPause(code);
if(code < 1024) if(code < 1024)

View File

@ -19,27 +19,57 @@ s32 sys_rsx_device_close()
return CELL_OK; return CELL_OK;
} }
s32 sys_rsx_memory_allocate() /*
* lv2 SysCall 668 (0x29C): sys_rsx_memory_allocate
* @param mem_handle (OUT): Context / ID, which is used by sys_rsx_memory_free to free allocated memory.
* @param mem_addr (OUT): Returns the local memory base address, usually 0xC0000000.
* @param size (IN): Local memory size. E.g. 0x0F900000 (249 MB).
* @param flags (IN): E.g. Immediate value passed in cellGcmSys is 8.
* @param a5 (IN): E.g. Immediate value passed in cellGcmSys is 0x00300000 (3 MB?).
* @param a6 (IN): E.g. Immediate value passed in cellGcmSys is 16.
* @param a7 (IN): E.g. Immediate value passed in cellGcmSys is 8.
*/
s32 sys_rsx_memory_allocate(mem32_t mem_handle, mem32_t mem_addr, u32 size, u64 flags, u64 a5, u64 a6, u64 a7)
{ {
sys_rsx.Todo("sys_rsx_memory_allocate()"); sys_rsx.Todo("sys_rsx_memory_allocate(mem_handle_addr=0x%x, local_mem_addr=0x%x, size=0x%x, flags=0x%x, a5=%d, a6=%d, a7=%d)",
mem_handle.GetAddr(), mem_addr.GetAddr(), size, flags, a5, a6, a7);
return CELL_OK; return CELL_OK;
} }
s32 sys_rsx_memory_free() /*
* lv2 SysCall 669 (0x29D): sys_rsx_memory_free
* @param mem_handle (OUT): Context / ID, for allocated local memory generated by sys_rsx_memory_allocate
*/
s32 sys_rsx_memory_free(u32 mem_handle)
{ {
sys_rsx.Todo("sys_rsx_memory_free()"); sys_rsx.Todo("sys_rsx_memory_free(mem_handle=%d)", mem_handle);
return CELL_OK; return CELL_OK;
} }
s32 sys_rsx_context_allocate() /*
* lv2 SysCall 670 (0x29E): sys_rsx_context_allocate
* @param context_id (OUT): RSX_context, E.g. 0x55555555 (in vsh.self)
* @param lpar_dma_control (OUT): Control register area. E.g. 0x60100000 (in vsh.self)
* @param lpar_driver_info (OUT): RSX data like frequencies, sizes, version... E.g. 0x60200000 (in vsh.self)
* @param lpar_reports (OUT): Report data area. E.g. 0x60300000 (in vsh.self)
* @param mem_ctx (IN): mem_ctx given by sys_rsx_memory_allocate
* @param system_mode (IN):
*/
s32 sys_rsx_context_allocate(mem32_t context_id, mem32_t lpar_dma_control, mem32_t lpar_driver_info, mem32_t lpar_reports, u64 mem_ctx, u64 system_mode)
{ {
sys_rsx.Todo("sys_rsx_context_allocate()"); sys_rsx.Todo("sys_rsx_context_allocate(context_id_addr=0x%x, lpar_dma_control_addr=0x%x, lpar_driver_info_addr=0x%x, lpar_reports_addr=0x%x, mem_ctx=0x%x, system_mode=0x%x)",
context_id.GetAddr(), lpar_dma_control.GetAddr(), lpar_driver_info.GetAddr(), lpar_reports.GetAddr(), mem_ctx, system_mode);
return CELL_OK; return CELL_OK;
} }
s32 sys_rsx_context_free() /*
* lv2 SysCall 671 (0x29F): sys_rsx_context_free
* @param a1 (IN): RSX_context generated by sys_rsx_context_allocate to free the context.
*/
s32 sys_rsx_context_free(u32 context_id)
{ {
sys_rsx.Todo("sys_rsx_context_free()"); sys_rsx.Todo("sys_rsx_context_free(context_id=%d)", context_id);
return CELL_OK; return CELL_OK;
} }
@ -55,21 +85,98 @@ s32 sys_rsx_context_iounmap()
return CELL_OK; return CELL_OK;
} }
s32 sys_rsx_context_attribute(s32 context_id, u64 a2, u64 a3, u64 a4, u64 a5, u64 a6) /*
* lv2 SysCall 674 (0x2A2): sys_rsx_context_attribute
* @param context_id (IN): RSX context, e.g. 0x55555555
* @param package_id (IN):
* @param a3 (IN):
* @param a4 (IN):
* @param a5 (IN):
* @param a6 (IN):
*/
s32 sys_rsx_context_attribute(s32 context_id, u32 package_id, u64 a3, u64 a4, u64 a5, u64 a6)
{ {
sys_rsx.Todo("sys_rsx_context_attribute(context_id=%d, a2=%llu, a3=%llu, a4=%llu, a5=%llu, a6=%llu)", context_id, a2, a3, a4, a5, a6); sys_rsx.Todo("sys_rsx_context_attribute(context_id=0x%x, package_id=0x%x, a3=%llu, a4=%llu, a5=%llu, a6=%llu)",
context_id, package_id, a3, a4, a5, a6);
switch(package_id)
{
case 0x001: // FIFO
break;
case 0x100: // Display mode set
break;
case 0x101: // Display sync
break;
case 0x102: // Display flip
break;
case 0x103: // ?
break;
case 0x104: // Display buffer
break;
case 0x106: // ? (Used by cellGcmInitPerfMon)
break;
case 0x10a: // ?
break;
case 0x300: // Tiles
break;
case 0x301: // Depth-buffer (Z-cull)
break;
case 0x600: // Framebuffer setup
break;
case 0x601: // Framebuffer blit
break;
case 0x602: // Framebuffer blit sync
break;
default:
return CELL_EINVAL;
}
return CELL_OK; return CELL_OK;
} }
s32 sys_rsx_device_map(mem32_t a1, mem32_t a2, u32 a3) /*
* lv2 SysCall 675 (0x2A3): sys_rsx_device_map
* @param a1 (OUT): For example: In vsh.self it is 0x60000000, global semaphore. For a game it is 0x40000000.
* @param a2 (OUT): Unused?
* @param dev_id (IN): An immediate value and always 8. (cellGcmInitPerfMon uses 11, 10, 9, 7, 12 successively).
*/
s32 sys_rsx_device_map(mem32_t a1, mem32_t a2, u32 dev_id)
{ {
sys_rsx.Todo("sys_rsx_device_map(a1_addr=0x%x, a2_addr=0x%x, a3=%d)", a1.GetAddr(), a2.GetAddr(), a3); sys_rsx.Todo("sys_rsx_device_map(a1_addr=0x%x, a2_addr=0x%x, a3=%d)", a1.GetAddr(), a2.GetAddr(), dev_id);
if (dev_id > 15) {
// TODO: Throw RSX error
return CELL_EINVAL;
}
if (dev_id == 0 || dev_id > 8) {
// TODO: lv1 related so we may ignore it.
// if (something) { return CELL_EPERM; }
}
return CELL_OK; return CELL_OK;
} }
s32 sys_rsx_device_unmap() /*
* lv2 SysCall 676 (0x2A4): sys_rsx_device_unmap
* @param dev_id (IN): An immediate value and always 8.
*/
s32 sys_rsx_device_unmap(u32 dev_id)
{ {
sys_rsx.Todo("sys_rsx_device_unmap()"); sys_rsx.Todo("sys_rsx_device_unmap(a1=%d)", dev_id);
return CELL_OK; return CELL_OK;
} }

View File

@ -3,13 +3,13 @@
// SysCalls // SysCalls
s32 sys_rsx_device_open(); s32 sys_rsx_device_open();
s32 sys_rsx_device_close(); s32 sys_rsx_device_close();
s32 sys_rsx_memory_allocate(); s32 sys_rsx_memory_allocate(mem32_t mem_handle, mem32_t mem_addr, u32 size, u64 flags, u64 a5, u64 a6, u64 a7);
s32 sys_rsx_memory_free(); s32 sys_rsx_memory_free(u32 mem_handle);
s32 sys_rsx_context_allocate(); s32 sys_rsx_context_allocate(mem32_t context_id, mem32_t lpar_dma_control, mem32_t lpar_driver_info, mem32_t lpar_reports, u64 mem_ctx, u64 system_mode);
s32 sys_rsx_context_free(); s32 sys_rsx_context_free(u32 context_id);
s32 sys_rsx_context_iomap(); s32 sys_rsx_context_iomap();
s32 sys_rsx_context_iounmap(); s32 sys_rsx_context_iounmap();
s32 sys_rsx_context_attribute(s32 context_id, u64 a2, u64 a3, u64 a4, u64 a5, u64 a6); s32 sys_rsx_context_attribute(s32 context_id, u32 package_id, u64 a3, u64 a4, u64 a5, u64 a6);
s32 sys_rsx_device_map(mem32_t a1, mem32_t a2, u32 a3); s32 sys_rsx_device_map(mem32_t a1, mem32_t a2, u32 dev_id);
s32 sys_rsx_device_unmap(); s32 sys_rsx_device_unmap(u32 dev_id);
s32 sys_rsx_attribute(); s32 sys_rsx_attribute();

View File

@ -11,7 +11,7 @@ enum
//TODO::Get the enable configuration from ini. //TODO::Get the enable configuration from ini.
AutoPauseManagerDialog::AutoPauseManagerDialog(wxWindow* parent) AutoPauseManagerDialog::AutoPauseManagerDialog(wxWindow* parent)
: wxDialog(parent, wxID_ANY, "Auto-Pause Manager") : wxDialog(parent, wxID_ANY, "Auto Pause Manager")
{ {
SetMinSize(wxSize(400, 360)); SetMinSize(wxSize(400, 360));
@ -19,8 +19,7 @@ AutoPauseManagerDialog::AutoPauseManagerDialog(wxWindow* parent)
m_entry_convert.clear(); m_entry_convert.clear();
m_entry_convert.str(""); m_entry_convert.str("");
m_entry_convert << "To use Auto-Pause: need the IDs of Function call or System call. Need Restart game." m_entry_convert << "To use auto pause: enter the ID(s) of a function or a system call. Restart of the game is required to apply. You can enable/disable this in the settings.";
<< " Disable/enable using setting Misc.";
wxStaticText* s_description = new wxStaticText(this, wxID_ANY, m_entry_convert.str(),wxDefaultPosition, wxDefaultSize, 0); wxStaticText* s_description = new wxStaticText(this, wxID_ANY, m_entry_convert.str(),wxDefaultPosition, wxDefaultSize, 0);
s_description->Wrap(400); s_description->Wrap(400);
@ -197,7 +196,7 @@ void AutoPauseManagerDialog::OnRemove(wxCommandEvent& event)
void AutoPauseManagerDialog::OnSave(wxCommandEvent& event) void AutoPauseManagerDialog::OnSave(wxCommandEvent& event)
{ {
SaveEntries(); SaveEntries();
LOG_SUCCESS(HLE,"Auto-Pause: File pause.bin was updated."); LOG_SUCCESS(HLE,"Auto Pause: File pause.bin was updated.");
//event.Skip(); //event.Skip();
} }
@ -214,7 +213,7 @@ void AutoPauseManagerDialog::OnReload(wxCommandEvent& event)
} }
AutoPauseSettingsDialog::AutoPauseSettingsDialog(wxWindow* parent, u32 *entry) AutoPauseSettingsDialog::AutoPauseSettingsDialog(wxWindow* parent, u32 *entry)
: wxDialog(parent, wxID_ANY, "Auto-Pause Setting") : wxDialog(parent, wxID_ANY, "Auto Pause Setting")
, m_presult(entry) , m_presult(entry)
{ {
m_entry = *m_presult; m_entry = *m_presult;
@ -225,8 +224,7 @@ AutoPauseSettingsDialog::AutoPauseSettingsDialog(wxWindow* parent, u32 *entry)
m_entry_convert.clear(); m_entry_convert.clear();
m_entry_convert.str(""); m_entry_convert.str("");
m_entry_convert << "Specify ID of System Call or Function Call below." m_entry_convert << "Specify ID of System Call or Function Call below. You need to use a Hexadecimal ID.";
<< " Please remember give the Hexidemical id.";
wxStaticText* s_description = new wxStaticText(this, wxID_ANY, m_entry_convert.str(), wxDefaultPosition, wxDefaultSize, 0); wxStaticText* s_description = new wxStaticText(this, wxID_ANY, m_entry_convert.str(), wxDefaultPosition, wxDefaultSize, 0);
s_description->Wrap(400); s_description->Wrap(400);
@ -249,7 +247,7 @@ AutoPauseSettingsDialog::AutoPauseSettingsDialog(wxWindow* parent, u32 *entry)
m_entry_convert << std::hex << std::setw(8) << std::setfill('0') << m_entry; m_entry_convert << std::hex << std::setw(8) << std::setfill('0') << m_entry;
m_id->SetValue(m_entry_convert.str()); m_id->SetValue(m_entry_convert.str());
SetTitle("Auto-Pause Setting: "+m_entry_convert.str()); SetTitle("Auto Pause Setting: "+m_entry_convert.str());
Bind(wxEVT_BUTTON, &AutoPauseSettingsDialog::OnOk, this, wxID_OK); Bind(wxEVT_BUTTON, &AutoPauseSettingsDialog::OnOk, this, wxID_OK);
Bind(wxEVT_TEXT, &AutoPauseSettingsDialog::OnUpdateValue, this, wxID_STATIC); Bind(wxEVT_TEXT, &AutoPauseSettingsDialog::OnUpdateValue, this, wxID_STATIC);

View File

@ -1,6 +1,7 @@
#include "stdafx.h" #include "stdafx.h"
#include <wx/listctrl.h> #include <wx/listctrl.h>
#include <wx/clipbrd.h>
#include <fstream> #include <fstream>
#include <vector> #include <vector>
#include <mutex> #include <mutex>
@ -24,6 +25,12 @@ const int BUFFER_MAX_SIZE = 1024 * 1024;
//amount of characters in the TextCtrl text-buffer for the emulation log //amount of characters in the TextCtrl text-buffer for the emulation log
const int GUI_BUFFER_MAX_SIZE = 1024 * 1024; const int GUI_BUFFER_MAX_SIZE = 1024 * 1024;
enum
{
id_log_copy, //Copy log to ClipBoard
id_log_clear //Clear log
};
struct wxWriter : Log::LogListener struct wxWriter : Log::LogListener
{ {
wxTextCtrl *m_log; wxTextCtrl *m_log;
@ -146,6 +153,10 @@ LogFrame::LogFrame(wxWindow* parent)
SetSizer(s_main); SetSizer(s_main);
Layout(); Layout();
m_log->Bind(wxEVT_RIGHT_DOWN, &LogFrame::OnRightClick, this);
Bind(wxEVT_MENU, &LogFrame::OnContextMenu, this, id_log_clear);
Bind(wxEVT_MENU, &LogFrame::OnContextMenu, this, id_log_copy);
Show(); Show();
} }
@ -162,4 +173,40 @@ bool LogFrame::Close(bool force)
void LogFrame::OnQuit(wxCloseEvent& event) void LogFrame::OnQuit(wxCloseEvent& event)
{ {
event.Skip(); event.Skip();
}
//Deals with the RightClick on Log Console, shows up the Context Menu.
void LogFrame::OnRightClick(wxMouseEvent& event)
{
wxMenu* menu = new wxMenu();
menu->Append(id_log_copy, "&Copy");
menu->AppendSeparator();
menu->Append(id_log_clear, "C&lear");
PopupMenu(menu);
}
//Well you can bind more than one control to a single handler.
void LogFrame::OnContextMenu(wxCommandEvent& event)
{
int id = event.GetId();
switch (id)
{
case id_log_clear:
m_log->Clear();
break;
case id_log_copy:
if (wxTheClipboard->Open())
{
m_tdo = new wxTextDataObject(m_log->GetStringSelection());
if (m_tdo->GetTextLength() > 0)
{
wxTheClipboard->SetData(new wxTextDataObject(m_log->GetStringSelection()));
}
wxTheClipboard->Close();
}
break;
default:
event.Skip();
}
} }

View File

@ -1,4 +1,5 @@
#pragma once #pragma once
#include <wx/dataobj.h>
#include "Utilities/Log.h" #include "Utilities/Log.h"
@ -9,6 +10,8 @@ class LogFrame
wxAuiNotebook m_tabs; wxAuiNotebook m_tabs;
wxTextCtrl *m_log; wxTextCtrl *m_log;
wxTextCtrl *m_tty; wxTextCtrl *m_tty;
//Copy Action in Context Menu
wxTextDataObject* m_tdo;
public: public:
LogFrame(wxWindow* parent); LogFrame(wxWindow* parent);
@ -21,6 +24,8 @@ private:
virtual void Task(){}; virtual void Task(){};
void OnQuit(wxCloseEvent& event); void OnQuit(wxCloseEvent& event);
void OnRightClick(wxMouseEvent& event); //Show context menu
void OnContextMenu(wxCommandEvent& event); //After select
DECLARE_EVENT_TABLE(); DECLARE_EVENT_TABLE();
}; };

View File

@ -89,7 +89,7 @@ MainFrame::MainFrame()
menu_conf->Append(id_config_emu, "Settings"); menu_conf->Append(id_config_emu, "Settings");
menu_conf->Append(id_config_pad, "PAD Settings"); menu_conf->Append(id_config_pad, "PAD Settings");
menu_conf->AppendSeparator(); menu_conf->AppendSeparator();
menu_conf->Append(id_config_autopause_manager, "Auto-Pause Settings"); menu_conf->Append(id_config_autopause_manager, "Auto Pause Settings");
menu_conf->AppendSeparator(); menu_conf->AppendSeparator();
menu_conf->Append(id_config_vfs_manager, "Virtual File System Manager"); menu_conf->Append(id_config_vfs_manager, "Virtual File System Manager");
menu_conf->Append(id_config_vhdd_manager, "Virtual HDD Manager"); menu_conf->Append(id_config_vhdd_manager, "Virtual HDD Manager");
@ -398,9 +398,10 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event))
wxCheckBox* chbox_hle_savetty = new wxCheckBox(p_hle, wxID_ANY, "Save TTY output to file"); wxCheckBox* chbox_hle_savetty = new wxCheckBox(p_hle, wxID_ANY, "Save TTY output to file");
wxCheckBox* chbox_hle_exitonstop = new wxCheckBox(p_hle, wxID_ANY, "Exit RPCS3 when process finishes"); wxCheckBox* chbox_hle_exitonstop = new wxCheckBox(p_hle, wxID_ANY, "Exit RPCS3 when process finishes");
wxCheckBox* chbox_hle_always_start = new wxCheckBox(p_hle, wxID_ANY, "Always start after boot"); wxCheckBox* chbox_hle_always_start = new wxCheckBox(p_hle, wxID_ANY, "Always start after boot");
//Auto-Pause related
wxCheckBox* chbox_dbg_ap_systemcall = new wxCheckBox(p_hle, wxID_ANY, "Auto-Pause at System Call"); //Auto Pause
wxCheckBox* chbox_dbg_ap_functioncall = new wxCheckBox(p_hle, wxID_ANY, "Auto-Pause at Function Call"); wxCheckBox* chbox_dbg_ap_systemcall = new wxCheckBox(p_hle, wxID_ANY, "Auto Pause at System Call");
wxCheckBox* chbox_dbg_ap_functioncall = new wxCheckBox(p_hle, wxID_ANY, "Auto Pause at Function Call");
cbox_cpu_decoder->Append("PPU Interpreter & DisAsm"); cbox_cpu_decoder->Append("PPU Interpreter & DisAsm");
cbox_cpu_decoder->Append("PPU Interpreter"); cbox_cpu_decoder->Append("PPU Interpreter");
@ -463,7 +464,6 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event))
cbox_sys_lang->Append("Polish"); cbox_sys_lang->Append("Polish");
cbox_sys_lang->Append("English (UK)"); cbox_sys_lang->Append("English (UK)");
// Get values from .ini // Get values from .ini
chbox_gs_log_prog ->SetValue(Ini.GSLogPrograms.GetValue()); chbox_gs_log_prog ->SetValue(Ini.GSLogPrograms.GetValue());
chbox_gs_dump_depth ->SetValue(Ini.GSDumpDepthBuffer.GetValue()); chbox_gs_dump_depth ->SetValue(Ini.GSDumpDepthBuffer.GetValue());
@ -476,7 +476,8 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event))
chbox_hle_savetty ->SetValue(Ini.HLESaveTTY.GetValue()); chbox_hle_savetty ->SetValue(Ini.HLESaveTTY.GetValue());
chbox_hle_exitonstop ->SetValue(Ini.HLEExitOnStop.GetValue()); chbox_hle_exitonstop ->SetValue(Ini.HLEExitOnStop.GetValue());
chbox_hle_always_start ->SetValue(Ini.HLEAlwaysStart.GetValue()); chbox_hle_always_start ->SetValue(Ini.HLEAlwaysStart.GetValue());
//Auto-Pause related
//Auto Pause related
chbox_dbg_ap_systemcall ->SetValue(Ini.DBGAutoPauseSystemCall.GetValue()); chbox_dbg_ap_systemcall ->SetValue(Ini.DBGAutoPauseSystemCall.GetValue());
chbox_dbg_ap_functioncall->SetValue(Ini.DBGAutoPauseFunctionCall.GetValue()); chbox_dbg_ap_functioncall->SetValue(Ini.DBGAutoPauseFunctionCall.GetValue());
@ -492,14 +493,12 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event))
cbox_hle_loglvl ->SetSelection(Ini.HLELogLvl.GetValue()); cbox_hle_loglvl ->SetSelection(Ini.HLELogLvl.GetValue());
cbox_sys_lang ->SetSelection(Ini.SysLanguage.GetValue()); cbox_sys_lang ->SetSelection(Ini.SysLanguage.GetValue());
// Enable/Disable parameters
// Enable / Disable parameters
chbox_audio_dump->Enable(Emu.IsStopped()); chbox_audio_dump->Enable(Emu.IsStopped());
chbox_audio_conv->Enable(Emu.IsStopped()); chbox_audio_conv->Enable(Emu.IsStopped());
chbox_hle_logging->Enable(Emu.IsStopped()); chbox_hle_logging->Enable(Emu.IsStopped());
chbox_hle_hook_stfunc->Enable(Emu.IsStopped()); chbox_hle_hook_stfunc->Enable(Emu.IsStopped());
s_round_cpu_decoder->Add(cbox_cpu_decoder, wxSizerFlags().Border(wxALL, 5).Expand()); s_round_cpu_decoder->Add(cbox_cpu_decoder, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_spu_decoder->Add(cbox_spu_decoder, wxSizerFlags().Border(wxALL, 5).Expand()); s_round_spu_decoder->Add(cbox_spu_decoder, wxSizerFlags().Border(wxALL, 5).Expand());
@ -547,7 +546,8 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event))
s_subpanel_hle->Add(chbox_hle_savetty, wxSizerFlags().Border(wxALL, 5).Expand()); s_subpanel_hle->Add(chbox_hle_savetty, wxSizerFlags().Border(wxALL, 5).Expand());
s_subpanel_hle->Add(chbox_hle_exitonstop, wxSizerFlags().Border(wxALL, 5).Expand()); s_subpanel_hle->Add(chbox_hle_exitonstop, wxSizerFlags().Border(wxALL, 5).Expand());
s_subpanel_hle->Add(chbox_hle_always_start, wxSizerFlags().Border(wxALL, 5).Expand()); s_subpanel_hle->Add(chbox_hle_always_start, wxSizerFlags().Border(wxALL, 5).Expand());
//Auto-Pause
//Auto Pause
s_subpanel_hle->Add(chbox_dbg_ap_systemcall, wxSizerFlags().Border(wxALL, 5).Expand()); s_subpanel_hle->Add(chbox_dbg_ap_systemcall, wxSizerFlags().Border(wxALL, 5).Expand());
s_subpanel_hle->Add(chbox_dbg_ap_functioncall, wxSizerFlags().Border(wxALL, 5).Expand()); s_subpanel_hle->Add(chbox_dbg_ap_functioncall, wxSizerFlags().Border(wxALL, 5).Expand());
@ -594,7 +594,8 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event))
Ini.HLELogLvl.SetValue(cbox_hle_loglvl->GetSelection()); Ini.HLELogLvl.SetValue(cbox_hle_loglvl->GetSelection());
Ini.SysLanguage.SetValue(cbox_sys_lang->GetSelection()); Ini.SysLanguage.SetValue(cbox_sys_lang->GetSelection());
Ini.HLEAlwaysStart.SetValue(chbox_hle_always_start->GetValue()); Ini.HLEAlwaysStart.SetValue(chbox_hle_always_start->GetValue());
//Auto-Pause
//Auto Pause
Ini.DBGAutoPauseFunctionCall.SetValue(chbox_dbg_ap_functioncall->GetValue()); Ini.DBGAutoPauseFunctionCall.SetValue(chbox_dbg_ap_functioncall->GetValue());
Ini.DBGAutoPauseSystemCall.SetValue(chbox_dbg_ap_systemcall->GetValue()); Ini.DBGAutoPauseSystemCall.SetValue(chbox_dbg_ap_systemcall->GetValue());

View File

@ -292,7 +292,7 @@ void RSXDebugger::OnClickBuffer(wxMouseEvent& event)
{ {
if (!RSXReady()) return; if (!RSXReady()) return;
const GSRender& render = Emu.GetGSManager().GetRender(); const GSRender& render = Emu.GetGSManager().GetRender();
const mem_ptr_t<gcmBuffer> buffers = render.m_gcm_buffers_addr; const mem_ptr_t<CellGcmDisplayInfo> buffers = render.m_gcm_buffers_addr;
if(!buffers.IsGood()) if(!buffers.IsGood())
return; return;
@ -300,9 +300,9 @@ void RSXDebugger::OnClickBuffer(wxMouseEvent& event)
// TODO: Is there any better way to choose the color buffers // TODO: Is there any better way to choose the color buffers
#define SHOW_BUFFER(id) \ #define SHOW_BUFFER(id) \
{ \ { \
u32 addr = render.m_local_mem_addr + re(buffers[id].offset); \ u32 addr = render.m_local_mem_addr + buffers[id].offset; \
if(Memory.IsGoodAddr(addr) && buffers[id].width && buffers[id].height) \ if (Memory.IsGoodAddr(addr) && buffers[id].width && buffers[id].height) \
MemoryViewerPanel::ShowImage(this, addr, 3, re(buffers[id].width), re(buffers[id].height), true); \ MemoryViewerPanel::ShowImage(this, addr, 3, buffers[id].width, buffers[id].height, true); \
return; \ return; \
} \ } \
@ -409,16 +409,16 @@ void RSXDebugger::GetBuffers()
if(!Memory.IsGoodAddr(render.m_gcm_buffers_addr)) if(!Memory.IsGoodAddr(render.m_gcm_buffers_addr))
continue; continue;
gcmBuffer* buffers = (gcmBuffer*)Memory.GetMemFromAddr(render.m_gcm_buffers_addr); CellGcmDisplayInfo* buffers = (CellGcmDisplayInfo*)Memory.GetMemFromAddr(render.m_gcm_buffers_addr);
u32 RSXbuffer_addr = render.m_local_mem_addr + re(buffers[bufferId].offset); u32 RSXbuffer_addr = render.m_local_mem_addr + buffers[bufferId].offset;
if(!Memory.IsGoodAddr(RSXbuffer_addr)) if(!Memory.IsGoodAddr(RSXbuffer_addr))
continue; continue;
unsigned char* RSXbuffer = (unsigned char*)Memory.VirtualToRealAddr(RSXbuffer_addr); unsigned char* RSXbuffer = (unsigned char*)Memory.VirtualToRealAddr(RSXbuffer_addr);
u32 width = re(buffers[bufferId].width); u32 width = buffers[bufferId].width;
u32 height = re(buffers[bufferId].height); u32 height = buffers[bufferId].height;
unsigned char* buffer = (unsigned char*)malloc(width * height * 3); unsigned char* buffer = (unsigned char*)malloc(width * height * 3);
// ABGR to RGB and flip vertically // ABGR to RGB and flip vertically

View File

@ -52,7 +52,7 @@ void SaveDataInfoDialog::UpdateData()
m_list->SetItem(3, 1, "Stub it first"); m_list->SetItem(3, 1, "Stub it first");
m_list->InsertItem(4, 4); m_list->InsertItem(4, 4);
m_list->SetItem(4, 0, "Copy-Able?"); m_list->SetItem(4, 0, "Copyable");
m_list->SetItem(4, 1, "1 (Not allowed)"); m_list->SetItem(4, 1, "1 (Not allowed)");
m_list->InsertItem(5, 5); m_list->InsertItem(5, 5);
@ -105,7 +105,7 @@ SaveDataManageDialog::SaveDataManageDialog(wxWindow* parent, unsigned int* sort_
m_sort_options->SetSelection(*m_sort_type); m_sort_options->SetSelection(*m_sort_type);
s_sort->Add(m_sort_options, 1, wxALL | wxEXPAND, 5); s_sort->Add(m_sort_options, 1, wxALL | wxEXPAND, 5);
wxButton* s_sort_action = new wxButton(this, wxID_ANY, wxT("&Apply!"), wxDefaultPosition, wxDefaultSize, 0); wxButton* s_sort_action = new wxButton(this, wxID_ANY, wxT("&Apply"), wxDefaultPosition, wxDefaultSize, 0);
s_sort_action->Bind(wxEVT_BUTTON, &SaveDataManageDialog::OnApplySort, this); s_sort_action->Bind(wxEVT_BUTTON, &SaveDataManageDialog::OnApplySort, this);
s_sort->Add(s_sort_action, 0, wxALL, 5); s_sort->Add(s_sort_action, 0, wxALL, 5);
@ -173,8 +173,7 @@ SaveDataListDialog::SaveDataListDialog(wxWindow* parent, bool enable_manage)
m_entry_convert.clear(); m_entry_convert.clear();
m_entry_convert.str(""); m_entry_convert.str("");
m_entry_convert << "This is only a stub now. Don't expect real effect from this." m_entry_convert << "This is only a stub for now. This doesn't work yet due to related functions not being implemented.";
<< "Cause related functions hasn't been implemented yet.";
wxStaticText* s_description = new wxStaticText(this, wxID_ANY, m_entry_convert.str(), wxDefaultPosition, wxDefaultSize, 0); wxStaticText* s_description = new wxStaticText(this, wxID_ANY, m_entry_convert.str(), wxDefaultPosition, wxDefaultSize, 0);
s_description->Wrap(400); s_description->Wrap(400);
s_main->Add(s_description, 0, wxALL, 5); s_main->Add(s_description, 0, wxALL, 5);

View File

@ -152,7 +152,7 @@ public:
IniEntry<u8> HLELogLvl; IniEntry<u8> HLELogLvl;
IniEntry<bool> HLEAlwaysStart; IniEntry<bool> HLEAlwaysStart;
//Auto-Pause //Auto Pause
IniEntry<bool> DBGAutoPauseSystemCall; IniEntry<bool> DBGAutoPauseSystemCall;
IniEntry<bool> DBGAutoPauseFunctionCall; IniEntry<bool> DBGAutoPauseFunctionCall;
@ -221,7 +221,7 @@ public:
HLELogLvl.Init("HLE_HLELogLvl", path); HLELogLvl.Init("HLE_HLELogLvl", path);
HLEAlwaysStart.Init("HLE_HLEAlwaysStart", path); HLEAlwaysStart.Init("HLE_HLEAlwaysStart", path);
// Auto-Pause // Auto Pause
DBGAutoPauseFunctionCall.Init("DBG_AutoPauseFunctionCall", path); DBGAutoPauseFunctionCall.Init("DBG_AutoPauseFunctionCall", path);
DBGAutoPauseSystemCall.Init("DBG_AutoPauseSystemCall", path); DBGAutoPauseSystemCall.Init("DBG_AutoPauseSystemCall", path);
@ -285,7 +285,8 @@ public:
HLEExitOnStop.Load(false); HLEExitOnStop.Load(false);
HLELogLvl.Load(3); HLELogLvl.Load(3);
HLEAlwaysStart.Load(true); HLEAlwaysStart.Load(true);
//Auto-Pause
//Auto Pause
DBGAutoPauseFunctionCall.Load(false); DBGAutoPauseFunctionCall.Load(false);
DBGAutoPauseSystemCall.Load(false); DBGAutoPauseSystemCall.Load(false);
@ -350,7 +351,8 @@ public:
HLEExitOnStop.Save(); HLEExitOnStop.Save();
HLELogLvl.Save(); HLELogLvl.Save();
HLEAlwaysStart.Save(); HLEAlwaysStart.Save();
//Auto-Pause
//Auto Pause
DBGAutoPauseFunctionCall.Save(); DBGAutoPauseFunctionCall.Save();
DBGAutoPauseSystemCall.Save(); DBGAutoPauseSystemCall.Save();

View File

@ -356,8 +356,10 @@
<ClInclude Include="Emu\SysCalls\Modules\cellFont.h" /> <ClInclude Include="Emu\SysCalls\Modules\cellFont.h" />
<ClInclude Include="Emu\SysCalls\Modules\cellGame.h" /> <ClInclude Include="Emu\SysCalls\Modules\cellGame.h" />
<ClInclude Include="Emu\SysCalls\Modules\cellGcmSys.h" /> <ClInclude Include="Emu\SysCalls\Modules\cellGcmSys.h" />
<ClInclude Include="Emu\SysCalls\Modules\cellGem.h" />
<ClInclude Include="Emu\SysCalls\Modules\cellGifDec.h" /> <ClInclude Include="Emu\SysCalls\Modules\cellGifDec.h" />
<ClInclude Include="Emu\SysCalls\Modules\cellJpgDec.h" /> <ClInclude Include="Emu\SysCalls\Modules\cellJpgDec.h" />
<ClInclude Include="Emu\SysCalls\Modules\cellL10n.h" />
<ClInclude Include="Emu\SysCalls\Modules\cellNetCtl.h" /> <ClInclude Include="Emu\SysCalls\Modules\cellNetCtl.h" />
<ClInclude Include="Emu\SysCalls\Modules\cellMsgDialog.h" /> <ClInclude Include="Emu\SysCalls\Modules\cellMsgDialog.h" />
<ClInclude Include="Emu\SysCalls\Modules\cellPamf.h" /> <ClInclude Include="Emu\SysCalls\Modules\cellPamf.h" />

View File

@ -390,7 +390,7 @@
<Filter>Emu\Cell\currently_unused</Filter> <Filter>Emu\Cell\currently_unused</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="Emu\SysCalls\Modules\cellGem.cpp"> <ClCompile Include="Emu\SysCalls\Modules\cellGem.cpp">
<Filter>Emu\Cell\currently_unused</Filter> <Filter>Emu\SysCalls\Modules</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="Emu\SysCalls\Modules\cellHttpUtil.cpp"> <ClCompile Include="Emu\SysCalls\Modules\cellHttpUtil.cpp">
<Filter>Emu\Cell\currently_unused</Filter> <Filter>Emu\Cell\currently_unused</Filter>
@ -664,6 +664,9 @@
<ClInclude Include="Emu\SysCalls\Modules\cellFont.h"> <ClInclude Include="Emu\SysCalls\Modules\cellFont.h">
<Filter>Emu\SysCalls\Modules</Filter> <Filter>Emu\SysCalls\Modules</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Emu\SysCalls\Modules\cellGem.h">
<Filter>Emu\SysCalls\Modules</Filter>
</ClInclude>
<ClInclude Include="Emu\SysCalls\Modules\cellGifDec.h"> <ClInclude Include="Emu\SysCalls\Modules\cellGifDec.h">
<Filter>Emu\SysCalls\Modules</Filter> <Filter>Emu\SysCalls\Modules</Filter>
</ClInclude> </ClInclude>
@ -1153,5 +1156,8 @@
<ClInclude Include="..\Utilities\AutoPause.h"> <ClInclude Include="..\Utilities\AutoPause.h">
<Filter>Utilities</Filter> <Filter>Utilities</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Emu\SysCalls\Modules\cellL10n.h">
<Filter>Emu\SysCalls\Modules</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
</Project> </Project>