MemoryBase::operator[] replaced

This commit is contained in:
Nekotekina 2014-09-06 02:12:10 +04:00
parent db9cbe6cdd
commit 12becc6120
19 changed files with 74 additions and 87 deletions

View file

@ -2366,7 +2366,7 @@ private:
void LWARX(u32 rd, u32 ra, u32 rb) void LWARX(u32 rd, u32 ra, u32 rb)
{ {
CPU.R_ADDR = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]; CPU.R_ADDR = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
CPU.R_VALUE = (u32&)Memory[CPU.R_ADDR]; CPU.R_VALUE = vm::get_ref<u32>(CPU.R_ADDR);
CPU.GPR[rd] = re32((u32)CPU.R_VALUE); CPU.GPR[rd] = re32((u32)CPU.R_VALUE);
} }
void LDX(u32 rd, u32 ra, u32 rb) void LDX(u32 rd, u32 ra, u32 rb)
@ -2517,7 +2517,7 @@ private:
void LDARX(u32 rd, u32 ra, u32 rb) void LDARX(u32 rd, u32 ra, u32 rb)
{ {
CPU.R_ADDR = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]; CPU.R_ADDR = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
CPU.R_VALUE = (u64&)Memory[CPU.R_ADDR]; CPU.R_VALUE = vm::get_ref<u64>(CPU.R_ADDR);
CPU.GPR[rd] = re64(CPU.R_VALUE); CPU.GPR[rd] = re64(CPU.R_VALUE);
} }
void DCBF(u32 ra, u32 rb) void DCBF(u32 ra, u32 rb)
@ -2952,7 +2952,7 @@ private:
} }
void LDBRX(u32 rd, u32 ra, u32 rb) void LDBRX(u32 rd, u32 ra, u32 rb)
{ {
CPU.GPR[rd] = (u64&)Memory[ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]]; CPU.GPR[rd] = vm::get_ref<u64>(ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]);
} }
void LSWX(u32 rd, u32 ra, u32 rb) void LSWX(u32 rd, u32 ra, u32 rb)
{ {
@ -2960,7 +2960,7 @@ private:
} }
void LWBRX(u32 rd, u32 ra, u32 rb) void LWBRX(u32 rd, u32 ra, u32 rb)
{ {
CPU.GPR[rd] = (u32&)Memory[ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]]; CPU.GPR[rd] = vm::get_ref<u32>(ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]);
} }
void LFSX(u32 frd, u32 ra, u32 rb) void LFSX(u32 frd, u32 ra, u32 rb)
{ {
@ -3055,7 +3055,7 @@ private:
} }
void STWBRX(u32 rs, u32 ra, u32 rb) void STWBRX(u32 rs, u32 ra, u32 rb)
{ {
(u32&)Memory[ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]] = (u32)CPU.GPR[rs]; vm::get_ref<u32>(ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]) = (u32)CPU.GPR[rs];
} }
void STFSX(u32 frs, u32 ra, u32 rb) void STFSX(u32 frs, u32 ra, u32 rb)
{ {
@ -3122,7 +3122,7 @@ private:
} }
void LHBRX(u32 rd, u32 ra, u32 rb) void LHBRX(u32 rd, u32 ra, u32 rb)
{ {
CPU.GPR[rd] = (u16&)Memory[ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]]; CPU.GPR[rd] = vm::get_ref<u16>(ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]);
} }
void SRAW(u32 ra, u32 rs, u32 rb, bool rc) void SRAW(u32 ra, u32 rs, u32 rb, bool rc)
{ {
@ -3203,7 +3203,7 @@ private:
} }
void STHBRX(u32 rs, u32 ra, u32 rb) void STHBRX(u32 rs, u32 ra, u32 rb)
{ {
(u16&)Memory[ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]] = (u16)CPU.GPR[rs]; vm::get_ref<u16>(ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]) = (u16)CPU.GPR[rs];
} }
void EXTSH(u32 ra, u32 rs, bool rc) void EXTSH(u32 ra, u32 rs, bool rc)
{ {

View file

@ -3,7 +3,7 @@
#define UNIMPLEMENTED() UNK(__FUNCTION__) #define UNIMPLEMENTED() UNK(__FUNCTION__)
#define MEM_AND_REG_HASH() \ #define MEM_AND_REG_HASH() \
unsigned char mem_h[20]; sha1(&Memory[CPU.dmac.ls_offset], 256*1024, mem_h); \ unsigned char mem_h[20]; sha1(vm::get_ptr<u8>(CPU.dmac.ls_offset), 256*1024, mem_h); \
unsigned char reg_h[20]; sha1((const unsigned char*)CPU.GPR, sizeof(CPU.GPR), reg_h); \ unsigned char reg_h[20]; sha1((const unsigned char*)CPU.GPR, sizeof(CPU.GPR), reg_h); \
LOG_NOTICE(Log::SPU, "Mem hash: 0x%llx, reg hash: 0x%llx", *(u64*)mem_h, *(u64*)reg_h); LOG_NOTICE(Log::SPU, "Mem hash: 0x%llx, reg hash: 0x%llx", *(u64*)mem_h, *(u64*)reg_h);

View file

@ -186,7 +186,7 @@ u8 SPURecompilerCore::DecodeMemory(const u64 address)
const u16 pos = (u16)(CPU.PC >> 2); const u16 pos = (u16)(CPU.PC >> 2);
//ConLog.Write("DecodeMemory: pos=%d", pos); //ConLog.Write("DecodeMemory: pos=%d", pos);
u32* ls = (u32*)&Memory[m_offset]; u32* ls = vm::get_ptr<u32>(m_offset);
if (entry[pos].pointer) if (entry[pos].pointer)
{ {
@ -252,7 +252,7 @@ u8 SPURecompilerCore::DecodeMemory(const u64 address)
} }
u32 res = pos; u32 res = pos;
res = func(cpu, &Memory[m_offset], imm_table.data(), &g_imm_table); res = func(cpu, vm::get_ptr<void>(m_offset), imm_table.data(), &g_imm_table);
if (res > 0xffff) if (res > 0xffff)
{ {

View file

@ -389,8 +389,8 @@ void SPUThread::EnqMfcCmd(MFCReg& MFCArgs)
R_ADDR = ea; R_ADDR = ea;
for (u32 i = 0; i < 16; i++) for (u32 i = 0; i < 16; i++)
{ {
R_DATA[i] = *(u64*)&Memory[R_ADDR + i * 8]; R_DATA[i] = vm::get_ptr<u64>(R_ADDR)[i];
*(u64*)&Memory[dmac.ls_offset + lsa + i * 8] = R_DATA[i]; vm::get_ptr<u64>(dmac.ls_offset + lsa)[i] = R_DATA[i];
} }
MFCArgs.AtomicStat.PushUncond(MFC_GETLLAR_SUCCESS); MFCArgs.AtomicStat.PushUncond(MFC_GETLLAR_SUCCESS);
} }
@ -404,12 +404,12 @@ void SPUThread::EnqMfcCmd(MFCReg& MFCArgs)
u64 buf[16]; u64 buf[16];
for (u32 i = 0; i < 16; i++) for (u32 i = 0; i < 16; i++)
{ {
buf[i] = *(u64*)&Memory[dmac.ls_offset + lsa + i * 8]; buf[i] = vm::get_ptr<u64>(dmac.ls_offset + lsa)[i];
if (buf[i] != R_DATA[i]) if (buf[i] != R_DATA[i])
{ {
changed++; changed++;
mask |= (0x3 << (i * 2)); mask |= (0x3 << (i * 2));
if (*(u64*)&Memory[R_ADDR + i * 8] != R_DATA[i]) if (vm::get_ptr<u64>(R_ADDR)[i] != R_DATA[i])
{ {
m_events |= SPU_EVENT_LR; m_events |= SPU_EVENT_LR;
MFCArgs.AtomicStat.PushUncond(MFC_PUTLLC_FAILURE); MFCArgs.AtomicStat.PushUncond(MFC_PUTLLC_FAILURE);
@ -497,7 +497,7 @@ bool SPUThread::CheckEvents()
{ {
for (u32 i = 0; i < 16; i++) for (u32 i = 0; i < 16; i++)
{ {
if (*(u64*)&Memory[R_ADDR + i * 8] != R_DATA[i]) if (vm::get_ptr<u64>(R_ADDR)[i] != R_DATA[i])
{ {
m_events |= SPU_EVENT_LR; m_events |= SPU_EVENT_LR;
R_ADDR = 0; R_ADDR = 0;

View file

@ -318,19 +318,6 @@ public:
bool Map(const u64 addr, const u32 size); bool Map(const u64 addr, const u32 size);
bool Unmap(const u64 addr); bool Unmap(const u64 addr);
template<typename T> u8& operator[] (const T addr)
{
if ((u32)addr == addr)
{
return *((u8*)GetBaseAddr() + addr);
}
else
{
InvalidAddress(__FUNCTION__, addr);
return *(u8*)GetBaseAddr();
}
}
}; };
extern MemoryBase Memory; extern MemoryBase Memory;

View file

@ -1201,6 +1201,8 @@ void GLGSRender::WriteDepthBuffer()
LOG_WARNING(RSX, "Bad depth buffer address: address=0x%x, offset=0x%x, dma=0x%x", address, m_surface_offset_z, m_context_dma_z); LOG_WARNING(RSX, "Bad depth buffer address: address=0x%x, offset=0x%x, dma=0x%x", address, m_surface_offset_z, m_context_dma_z);
return; return;
} }
auto ptr = vm::get_ptr<void>(address);
glBindBuffer(GL_PIXEL_PACK_BUFFER, g_pbo[4]); glBindBuffer(GL_PIXEL_PACK_BUFFER, g_pbo[4]);
checkForGlError("WriteDepthBuffer(): glBindBuffer"); checkForGlError("WriteDepthBuffer(): glBindBuffer");
glReadPixels(0, 0, RSXThread::m_width, RSXThread::m_height, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, 0); glReadPixels(0, 0, RSXThread::m_width, RSXThread::m_height, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, 0);
@ -1208,7 +1210,7 @@ void GLGSRender::WriteDepthBuffer()
GLubyte *packed = (GLubyte *)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY); GLubyte *packed = (GLubyte *)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY);
if (packed) if (packed)
{ {
memcpy(&Memory[address], packed, RSXThread::m_width * RSXThread::m_height * 4); memcpy(ptr, packed, RSXThread::m_width * RSXThread::m_height * 4);
glUnmapBuffer(GL_PIXEL_PACK_BUFFER); glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
checkForGlError("WriteDepthBuffer(): glUnmapBuffer"); checkForGlError("WriteDepthBuffer(): glUnmapBuffer");
} }
@ -1217,9 +1219,9 @@ void GLGSRender::WriteDepthBuffer()
checkForGlError("WriteDepthBuffer(): glReadPixels"); checkForGlError("WriteDepthBuffer(): glReadPixels");
glBindTexture(GL_TEXTURE_2D, g_depth_tex); glBindTexture(GL_TEXTURE_2D, g_depth_tex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, RSXThread::m_width, RSXThread::m_height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, &Memory[address]); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, RSXThread::m_width, RSXThread::m_height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, ptr);
checkForGlError("WriteDepthBuffer(): glTexImage2D"); checkForGlError("WriteDepthBuffer(): glTexImage2D");
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, &Memory[address]); glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, ptr);
checkForGlError("WriteDepthBuffer(): glGetTexImage"); checkForGlError("WriteDepthBuffer(): glGetTexImage");
} }
@ -1246,7 +1248,7 @@ void GLGSRender::WriteColorBufferA()
GLubyte *packed = (GLubyte *)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY); GLubyte *packed = (GLubyte *)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY);
if (packed) if (packed)
{ {
memcpy(&Memory[address], packed, RSXThread::m_width * RSXThread::m_height * 4); memcpy(vm::get_ptr<void>(address), packed, RSXThread::m_width * RSXThread::m_height * 4);
glUnmapBuffer(GL_PIXEL_PACK_BUFFER); glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
checkForGlError("WriteColorBufferA(): glUnmapBuffer"); checkForGlError("WriteColorBufferA(): glUnmapBuffer");
} }
@ -1277,7 +1279,7 @@ void GLGSRender::WriteColorBufferB()
GLubyte *packed = (GLubyte *)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY); GLubyte *packed = (GLubyte *)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY);
if (packed) if (packed)
{ {
memcpy(&Memory[address], packed, RSXThread::m_width * RSXThread::m_height * 4); memcpy(vm::get_ptr<void>(address), packed, RSXThread::m_width * RSXThread::m_height * 4);
glUnmapBuffer(GL_PIXEL_PACK_BUFFER); glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
checkForGlError("WriteColorBufferB(): glUnmapBuffer"); checkForGlError("WriteColorBufferB(): glUnmapBuffer");
} }
@ -1308,7 +1310,7 @@ void GLGSRender::WriteColorBufferC()
GLubyte *packed = (GLubyte *)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY); GLubyte *packed = (GLubyte *)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY);
if (packed) if (packed)
{ {
memcpy(&Memory[address], packed, RSXThread::m_width * RSXThread::m_height * 4); memcpy(vm::get_ptr<void>(address), packed, RSXThread::m_width * RSXThread::m_height * 4);
glUnmapBuffer(GL_PIXEL_PACK_BUFFER); glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
checkForGlError("WriteColorBufferC(): glUnmapBuffer"); checkForGlError("WriteColorBufferC(): glUnmapBuffer");
} }
@ -1339,7 +1341,7 @@ void GLGSRender::WriteColorBufferD()
GLubyte *packed = (GLubyte *)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY); GLubyte *packed = (GLubyte *)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY);
if (packed) if (packed)
{ {
memcpy(&Memory[address], packed, RSXThread::m_width * RSXThread::m_height * 4); memcpy(vm::get_ptr<void>(address), packed, RSXThread::m_width * RSXThread::m_height * 4);
glUnmapBuffer(GL_PIXEL_PACK_BUFFER); glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
checkForGlError("WriteColorBufferD(): glUnmapBuffer"); checkForGlError("WriteColorBufferD(): glUnmapBuffer");
} }

View file

@ -8,7 +8,7 @@ int GLProgramBuffer::SearchFp(const RSXShaderProgram& rsx_fp, GLShaderProgram& g
{ {
for(u32 i=0; i<m_buf.size(); ++i) for(u32 i=0; i<m_buf.size(); ++i)
{ {
if(memcmp(&m_buf[i].fp_data[0], &Memory[rsx_fp.addr], m_buf[i].fp_data.size()) != 0) continue; if(memcmp(&m_buf[i].fp_data[0], vm::get_ptr<void>(rsx_fp.addr), m_buf[i].fp_data.size()) != 0) continue;
gl_fp.SetId(m_buf[i].fp_id); gl_fp.SetId(m_buf[i].fp_id);
gl_fp.SetShaderText(m_buf[i].fp_shader); gl_fp.SetShaderText(m_buf[i].fp_shader);
@ -104,7 +104,7 @@ void GLProgramBuffer::Add(GLProgram& prog, GLShaderProgram& gl_fp, RSXShaderProg
new_buf.vp_id = gl_vp.id; new_buf.vp_id = gl_vp.id;
new_buf.fp_id = gl_fp.GetId(); new_buf.fp_id = gl_fp.GetId();
new_buf.fp_data.insert(new_buf.fp_data.end(),&Memory[rsx_fp.addr], &Memory[rsx_fp.addr] + rsx_fp.size); new_buf.fp_data.insert(new_buf.fp_data.end(), vm::get_ptr<u8>(rsx_fp.addr), vm::get_ptr<u8>(rsx_fp.addr + rsx_fp.size));
new_buf.vp_data = rsx_vp.data; new_buf.vp_data = rsx_vp.data;
new_buf.vp_shader = gl_vp.shader; new_buf.vp_shader = gl_vp.shader;

View file

@ -41,7 +41,7 @@ void RSXThread::nativeRescale(float width, float height)
} }
} }
u32 GetAddress(u32 offset, u8 location) u32 GetAddress(u32 offset, u32 location)
{ {
switch(location) switch(location)
{ {
@ -1774,11 +1774,11 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const
if (lineCount == 1 && !inPitch && !outPitch && !notify) if (lineCount == 1 && !inPitch && !outPitch && !notify)
{ {
memcpy(&Memory[GetAddress(outOffset, 0)], &Memory[GetAddress(inOffset, 0)], lineLength); memcpy(vm::get_ptr<void>(GetAddress(outOffset, 0)), vm::get_ptr<void>(GetAddress(inOffset, 0)), lineLength);
} }
else else
{ {
LOG_WARNING(RSX, "NV0039_OFFSET_IN: TODO: offset(in=0x%x, out=0x%x), pitch(in=0x%x, out=0x%x), line(len=0x%x, cnt=0x%x), fmt(in=0x%x, out=0x%x), notify=0x%x", LOG_ERROR(RSX, "NV0039_OFFSET_IN: TODO: offset(in=0x%x, out=0x%x), pitch(in=0x%x, out=0x%x), line(len=0x%x, cnt=0x%x), fmt(in=0x%x, out=0x%x), notify=0x%x",
inOffset, outOffset, inPitch, outPitch, lineLength, lineCount, inFormat, outFormat, notify); inOffset, outOffset, inPitch, outPitch, lineLength, lineCount, inFormat, outFormat, notify);
} }
} }
@ -1793,7 +1793,7 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const
} }
else else
{ {
LOG_WARNING(RSX, "NV0039_OFFSET_OUT: TODO: offset=0x%x", offset); LOG_ERROR(RSX, "NV0039_OFFSET_OUT: TODO: offset=0x%x", offset);
} }
} }
break; break;
@ -1933,8 +1933,8 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const
u16 u = ARGS(3); u16 u = ARGS(3);
u16 v = ARGS(3) >> 16; u16 v = ARGS(3) >> 16;
u8* pixels_src = &Memory[GetAddress(offset, m_context_dma_img_src - 0xfeed0000)]; u8* pixels_src = vm::get_ptr<u8>(GetAddress(offset, m_context_dma_img_src - 0xfeed0000));
u8* pixels_dst = &Memory[GetAddress(m_dst_offset, m_context_dma_img_dst - 0xfeed0000)]; u8* pixels_dst = vm::get_ptr<u8>(GetAddress(m_dst_offset, m_context_dma_img_dst - 0xfeed0000));
for(u16 y=0; y<m_color_conv_in_h; ++y) for(u16 y=0; y<m_color_conv_in_h; ++y)
{ {
@ -2269,7 +2269,7 @@ void RSXThread::Task()
void RSXThread::Init(const u32 ioAddress, const u32 ioSize, const u32 ctrlAddress, const u32 localAddress) void RSXThread::Init(const u32 ioAddress, const u32 ioSize, const u32 ctrlAddress, const u32 localAddress)
{ {
m_ctrl = (CellGcmControl*)&Memory[ctrlAddress]; m_ctrl = vm::get_ptr<CellGcmControl>(ctrlAddress);
m_ioAddress = ioAddress; m_ioAddress = ioAddress;
m_ioSize = ioSize; m_ioSize = ioSize;
m_ctrlAddress = ctrlAddress; m_ctrlAddress = ctrlAddress;

View file

@ -18,7 +18,7 @@ enum Method
}; };
extern u32 methodRegisters[0xffff]; extern u32 methodRegisters[0xffff];
u32 GetAddress(u32 offset, u8 location); u32 GetAddress(u32 offset, u32 location);
struct RSXVertexData struct RSXVertexData
{ {

View file

@ -175,7 +175,7 @@ int cellAudioInit()
const u32 position = port.tag % port.block; // old value const u32 position = port.tag % port.block; // old value
const u32 buf_addr = m_config.m_buffer + (i * 128 * 1024) + (position * block_size * sizeof(float)); const u32 buf_addr = m_config.m_buffer + (i * 128 * 1024) + (position * block_size * sizeof(float));
auto buf = (be_t<float>*)&Memory[buf_addr]; auto buf = vm::get_ptr<be_t<float>>(buf_addr);
static const float k = 1.0f; // may be 1.0f static const float k = 1.0f; // may be 1.0f
const float m = port.level; const float m = port.level;

View file

@ -380,7 +380,7 @@ s32 _cellGcmInitBody(vm::ptr<CellGcmContextData> context, u32 cmdSize, u32 ioSiz
vm::get_ref<CellGcmContextData>(gcm_info.context_addr) = current_context; vm::get_ref<CellGcmContextData>(gcm_info.context_addr) = current_context;
Memory.Write32(context.addr(), gcm_info.context_addr); Memory.Write32(context.addr(), gcm_info.context_addr);
CellGcmControl& ctrl = (CellGcmControl&)Memory[gcm_info.control_addr]; auto& ctrl = vm::get_ref<CellGcmControl>(gcm_info.control_addr);
ctrl.put = 0; ctrl.put = 0;
ctrl.get = 0; ctrl.get = 0;
ctrl.ref = -1; ctrl.ref = -1;
@ -510,7 +510,7 @@ s32 cellGcmSetPrepareFlip(vm::ptr<CellGcmContextData> ctxt, u32 id)
//cellGcmCallback(ctxt.addr(), current + 8 - end); //cellGcmCallback(ctxt.addr(), current + 8 - end);
//copied: //copied:
CellGcmControl& ctrl = (CellGcmControl&)Memory[gcm_info.control_addr]; auto& ctrl = vm::get_ref<CellGcmControl>(gcm_info.control_addr);
const s32 res = ctxt->current - ctxt->begin - ctrl.put; const s32 res = ctxt->current - ctxt->begin - ctrl.put;
@ -530,7 +530,7 @@ s32 cellGcmSetPrepareFlip(vm::ptr<CellGcmContextData> ctxt, u32 id)
if(ctxt.addr() == gcm_info.context_addr) if(ctxt.addr() == gcm_info.context_addr)
{ {
CellGcmControl& ctrl = (CellGcmControl&)Memory[gcm_info.control_addr]; auto& ctrl = vm::get_ref<CellGcmControl>(gcm_info.control_addr);
ctrl.put += 8; ctrl.put += 8;
} }
@ -1164,8 +1164,8 @@ int cellGcmCallback(u32 context_addr, u32 count)
GSLockCurrent gslock(GS_LOCK_WAIT_FLUSH); GSLockCurrent gslock(GS_LOCK_WAIT_FLUSH);
CellGcmContextData& ctx = (CellGcmContextData&)Memory[context_addr]; auto& ctx = vm::get_ref<CellGcmContextData>(context_addr);
CellGcmControl& ctrl = (CellGcmControl&)Memory[gcm_info.control_addr]; auto& ctrl = vm::get_ref<CellGcmControl>(gcm_info.control_addr);
const s32 res = ctx.current - ctx.begin - ctrl.put; const s32 res = ctx.current - ctx.begin - ctrl.put;

View file

@ -10,6 +10,8 @@
Module *cellResc = nullptr; Module *cellResc = nullptr;
extern s32 cellVideoOutConfigure(u32 videoOut, vm::ptr<CellVideoOutConfiguration> config, vm::ptr<CellVideoOutOption> option, u32 waitForEvent);
static const float static const float
PICTURE_SIZE = (1.0f), PICTURE_SIZE = (1.0f),
UV_DELTA_PS = (1.f / 8.f), UV_DELTA_PS = (1.f / 8.f),
@ -732,7 +734,7 @@ int cellRescSetDisplayMode(u32 displayMode)
videocfg->aspect = CELL_VIDEO_OUT_ASPECT_AUTO; videocfg->aspect = CELL_VIDEO_OUT_ASPECT_AUTO;
videocfg->pitch = s_rescInternalInstance->m_dstPitch; videocfg->pitch = s_rescInternalInstance->m_dstPitch;
cellVideoOutConfigure(CELL_VIDEO_OUT_PRIMARY, videocfg.addr(), 0, 0); cellVideoOutConfigure(CELL_VIDEO_OUT_PRIMARY, videocfg, vm::ptr<CellVideoOutOption>::make(0), 0);
if (IsPalInterpolate()) if (IsPalInterpolate())
{ {

View file

@ -1139,9 +1139,10 @@ s32 syncLFQueueInitialize(vm::ptr<CellSyncLFQueue> queue, vm::ptr<u8> buffer, u3
{ {
if (sdk_ver > 0x17ffff) if (sdk_ver > 0x17ffff)
{ {
auto data = vm::get_ptr<u64>(queue.addr());
for (u32 i = 0; i < sizeof(CellSyncLFQueue) / sizeof(u64); i++) for (u32 i = 0; i < sizeof(CellSyncLFQueue) / sizeof(u64); i++)
{ {
if ((u64&)Memory[queue.addr() + i * sizeof(u64)]) if (data[i])
{ {
return CELL_SYNC_ERROR_STAT; return CELL_SYNC_ERROR_STAT;
} }

View file

@ -178,31 +178,29 @@ int cellVideoOutGetResolution(u32 resolutionId, vm::ptr<CellVideoOutResolution>
return CELL_VIDEO_OUT_SUCCEEDED; return CELL_VIDEO_OUT_SUCCEEDED;
} }
s32 cellVideoOutConfigure(u32 videoOut, u32 config_addr, u32 option_addr, u32 waitForEvent) s32 cellVideoOutConfigure(u32 videoOut, vm::ptr<CellVideoOutConfiguration> config, vm::ptr<CellVideoOutOption> option, u32 waitForEvent)
{ {
cellSysutil->Warning("cellVideoOutConfigure(videoOut=%d, config_addr=0x%x, option_addr=0x%x, waitForEvent=0x%x)", cellSysutil->Warning("cellVideoOutConfigure(videoOut=%d, config_addr=0x%x, option_addr=0x%x, waitForEvent=0x%x)",
videoOut, config_addr, option_addr, waitForEvent); videoOut, config.addr(), option.addr(), waitForEvent);
CellVideoOutConfiguration& config = (CellVideoOutConfiguration&)Memory[config_addr];
switch(videoOut) switch(videoOut)
{ {
case CELL_VIDEO_OUT_PRIMARY: case CELL_VIDEO_OUT_PRIMARY:
if(config.resolutionId) if(config->resolutionId)
{ {
Emu.GetGSManager().GetInfo().mode.resolutionId = config.resolutionId; Emu.GetGSManager().GetInfo().mode.resolutionId = config->resolutionId;
} }
Emu.GetGSManager().GetInfo().mode.format = config.format; Emu.GetGSManager().GetInfo().mode.format = config->format;
if(config.aspect) if(config->aspect)
{ {
Emu.GetGSManager().GetInfo().mode.aspect = config.aspect; Emu.GetGSManager().GetInfo().mode.aspect = config->aspect;
} }
if(config.pitch) if(config->pitch)
{ {
Emu.GetGSManager().GetInfo().mode.pitch = config.pitch; Emu.GetGSManager().GetInfo().mode.pitch = config->pitch;
} }
return CELL_VIDEO_OUT_SUCCEEDED; return CELL_VIDEO_OUT_SUCCEEDED;

View file

@ -214,9 +214,6 @@ struct CellHddGameCBResult
be_t<u32> reserved_addr; // void* be_t<u32> reserved_addr; // void*
}; };
// SysCalls
s32 cellVideoOutConfigure(u32 videoOut, u32 config_addr, u32 option_addr, u32 waitForEvent);
typedef s32 CellWebBrowserId; typedef s32 CellWebBrowserId;
typedef void* CellWebBrowserClientSession; typedef void* CellWebBrowserClientSession;
typedef void(*CellWebBrowserCallback)(s32 cb_type, vm::ptr<CellWebBrowserClientSession>, vm::ptr<void> usrdata); typedef void(*CellWebBrowserCallback)(s32 cb_type, vm::ptr<CellWebBrowserClientSession>, vm::ptr<void> usrdata);

View file

@ -22,10 +22,10 @@ u64 mixcount;
std::vector<SSPlayer> ssp; std::vector<SSPlayer> ssp;
int cellAANAddData(u32 aan_handle, u32 aan_port, u32 offset, u32 addr, u32 samples) int cellAANAddData(u32 aan_handle, u32 aan_port, u32 offset, vm::ptr<float> addr, u32 samples)
{ {
libmixer->Log("cellAANAddData(handle=%d, port=%d, offset=0x%x, addr=0x%x, samples=%d)", libmixer->Log("cellAANAddData(handle=%d, port=%d, offset=0x%x, addr=0x%x, samples=%d)",
aan_handle, aan_port, offset, addr, samples); aan_handle, aan_port, offset, addr.addr(), samples);
u32 type = aan_port >> 16; u32 type = aan_port >> 16;
u32 port = aan_port & 0xffff; u32 port = aan_port & 0xffff;
@ -58,7 +58,7 @@ int cellAANAddData(u32 aan_handle, u32 aan_port, u32 offset, u32 addr, u32 sampl
// mono upmixing // mono upmixing
for (u32 i = 0; i < samples; i++) for (u32 i = 0; i < samples; i++)
{ {
const float center = *(be_t<float>*)&Memory[addr + i * sizeof(float)]; const float center = addr[i];
mixdata[i * 8 + 0] += center; mixdata[i * 8 + 0] += center;
mixdata[i * 8 + 1] += center; mixdata[i * 8 + 1] += center;
} }
@ -68,8 +68,8 @@ int cellAANAddData(u32 aan_handle, u32 aan_port, u32 offset, u32 addr, u32 sampl
// stereo upmixing // stereo upmixing
for (u32 i = 0; i < samples; i++) for (u32 i = 0; i < samples; i++)
{ {
const float left = *(be_t<float>*)&Memory[addr + i * 2 * sizeof(float)]; const float left = addr[i * 2 + 0];
const float right = *(be_t<float>*)&Memory[addr + (i * 2 + 1) * sizeof(float)]; const float right = addr[i * 2 + 1];
mixdata[i * 8 + 0] += left; mixdata[i * 8 + 0] += left;
mixdata[i * 8 + 1] += right; mixdata[i * 8 + 1] += right;
} }
@ -79,12 +79,12 @@ int cellAANAddData(u32 aan_handle, u32 aan_port, u32 offset, u32 addr, u32 sampl
// 5.1 upmixing // 5.1 upmixing
for (u32 i = 0; i < samples; i++) for (u32 i = 0; i < samples; i++)
{ {
const float left = *(be_t<float>*)&Memory[addr + i * 6 * sizeof(float)]; const float left = addr[i * 6 + 0];
const float right = *(be_t<float>*)&Memory[addr + (i * 6 + 1) * sizeof(float)]; const float right = addr[i * 6 + 1];
const float center = *(be_t<float>*)&Memory[addr + (i * 6 + 2) * sizeof(float)]; const float center = addr[i * 6 + 2];
const float low_freq = *(be_t<float>*)&Memory[addr + (i * 6 + 3) * sizeof(float)]; const float low_freq = addr[i * 6 + 3];
const float rear_left = *(be_t<float>*)&Memory[addr + (i * 6 + 4) * sizeof(float)]; const float rear_left = addr[i * 6 + 4];
const float rear_right = *(be_t<float>*)&Memory[addr + (i * 6 + 5) * sizeof(float)]; const float rear_right = addr[i * 6 + 5];
mixdata[i * 8 + 0] += left; mixdata[i * 8 + 0] += left;
mixdata[i * 8 + 1] += right; mixdata[i * 8 + 1] += right;
mixdata[i * 8 + 2] += center; mixdata[i * 8 + 2] += center;
@ -98,7 +98,7 @@ int cellAANAddData(u32 aan_handle, u32 aan_port, u32 offset, u32 addr, u32 sampl
// 7.1 // 7.1
for (u32 i = 0; i < samples * 8; i++) for (u32 i = 0; i < samples * 8; i++)
{ {
mixdata[i] += *(be_t<float>*)&Memory[addr + i * sizeof(float)]; mixdata[i] += addr[i];
} }
} }
@ -435,7 +435,7 @@ int cellSurMixerCreate(vm::ptr<const CellSurMixerConfig> config)
//u64 stamp2 = get_system_time(); //u64 stamp2 = get_system_time();
auto buf = (be_t<float>*)&Memory[m_config.m_buffer + (128 * 1024 * SUR_PORT) + (mixcount % port.block) * port.channel * 256 * sizeof(float)]; auto buf = vm::get_ptr<be_t<float>>(m_config.m_buffer + (128 * 1024 * SUR_PORT) + (mixcount % port.block) * port.channel * 256 * sizeof(float));
for (u32 i = 0; i < (sizeof(mixdata) / sizeof(float)); i++) for (u32 i = 0; i < (sizeof(mixdata) / sizeof(float)); i++)
{ {

View file

@ -330,7 +330,7 @@ void RSXDebugger::OnClickBuffer(wxMouseEvent& event)
void RSXDebugger::GoToGet(wxCommandEvent& event) void RSXDebugger::GoToGet(wxCommandEvent& event)
{ {
if (!RSXReady()) return; if (!RSXReady()) return;
CellGcmControl* ctrl = (CellGcmControl*)&Memory[Emu.GetGSManager().GetRender().m_ctrlAddress]; auto ctrl = vm::get_ptr<CellGcmControl>(Emu.GetGSManager().GetRender().m_ctrlAddress);
u64 realAddr; u64 realAddr;
if (Memory.RSXIOMem.getRealAddr(Memory.RSXIOMem.GetStartAddr() + ctrl->get, realAddr)) { if (Memory.RSXIOMem.getRealAddr(Memory.RSXIOMem.GetStartAddr() + ctrl->get, realAddr)) {
m_addr = realAddr; // WARNING: Potential Truncation? Cast from u64 to u32 m_addr = realAddr; // WARNING: Potential Truncation? Cast from u64 to u32
@ -344,7 +344,7 @@ void RSXDebugger::GoToGet(wxCommandEvent& event)
void RSXDebugger::GoToPut(wxCommandEvent& event) void RSXDebugger::GoToPut(wxCommandEvent& event)
{ {
if (!RSXReady()) return; if (!RSXReady()) return;
CellGcmControl* ctrl = (CellGcmControl*)&Memory[Emu.GetGSManager().GetRender().m_ctrlAddress]; auto ctrl = vm::get_ptr<CellGcmControl>(Emu.GetGSManager().GetRender().m_ctrlAddress);
u64 realAddr; u64 realAddr;
if (Memory.RSXIOMem.getRealAddr(Memory.RSXIOMem.GetStartAddr() + ctrl->put, realAddr)) { if (Memory.RSXIOMem.getRealAddr(Memory.RSXIOMem.GetStartAddr() + ctrl->put, realAddr)) {
m_addr = realAddr; // WARNING: Potential Truncation? Cast from u64 to u32 m_addr = realAddr; // WARNING: Potential Truncation? Cast from u64 to u32

View file

@ -448,7 +448,7 @@ bool ELF32Loader::LoadPhdrData(u64 _offset)
} }
elf32_f.Seek(phdr_arr[i].p_offset); elf32_f.Seek(phdr_arr[i].p_offset);
elf32_f.Read(&Memory[phdr_arr[i].p_vaddr + offset], phdr_arr[i].p_filesz); elf32_f.Read(vm::get_ptr<void>(phdr_arr[i].p_vaddr + offset), phdr_arr[i].p_filesz);
} }
else if(phdr_arr[i].p_type == 0x00000004) else if(phdr_arr[i].p_type == 0x00000004)
{ {

View file

@ -355,8 +355,8 @@ bool ELF64Loader::LoadPhdrData(u64 offset)
else if (phdr.p_filesz) else if (phdr.p_filesz)
{ {
elf64_f.Seek(phdr.p_offset); elf64_f.Seek(phdr.p_offset);
elf64_f.Read(&Memory[offset + phdr.p_vaddr], phdr.p_filesz); elf64_f.Read(vm::get_ptr<void>(offset + phdr.p_vaddr), phdr.p_filesz);
Emu.GetSFuncManager().StaticAnalyse(&Memory[offset + phdr.p_vaddr], (u32)phdr.p_filesz, (u32)phdr.p_vaddr); Emu.GetSFuncManager().StaticAnalyse(vm::get_ptr<void>(offset + phdr.p_vaddr), (u32)phdr.p_filesz, (u32)phdr.p_vaddr);
} }
} }
break; break;
@ -370,7 +370,7 @@ bool ELF64Loader::LoadPhdrData(u64 offset)
if(!phdr.p_filesz) if(!phdr.p_filesz)
break; break;
const sys_process_param& proc_param = *(sys_process_param*)&Memory[offset + phdr.p_vaddr]; auto& proc_param = vm::get_ref<sys_process_param>(offset + phdr.p_vaddr);
if (proc_param.size < sizeof(sys_process_param)) { if (proc_param.size < sizeof(sys_process_param)) {
LOG_WARNING(LOADER, "Bad proc param size! [0x%x : 0x%x]", proc_param.size, sizeof(sys_process_param)); LOG_WARNING(LOADER, "Bad proc param size! [0x%x : 0x%x]", proc_param.size, sizeof(sys_process_param));
@ -397,7 +397,7 @@ bool ELF64Loader::LoadPhdrData(u64 offset)
if(!phdr.p_filesz) if(!phdr.p_filesz)
break; break;
sys_proc_prx_param proc_prx_param = *(sys_proc_prx_param*)&Memory[offset + phdr.p_vaddr]; sys_proc_prx_param proc_prx_param = vm::get_ref<sys_proc_prx_param>(offset + phdr.p_vaddr);
#ifdef LOADER_DEBUG #ifdef LOADER_DEBUG