Some cleanup 2

This commit is contained in:
Nekotekina 2014-07-10 04:13:04 +04:00
parent b5f376f834
commit 22b9afdb60
5 changed files with 262 additions and 82 deletions

View file

@ -5,8 +5,7 @@
#include "RSXThread.h"
#include "Emu/SysCalls/lv2/sys_time.h"
//#define ARGS(x) (x >= count ? OutOfArgsCount(x, cmd, count) : Memory.Read32(Memory.RSXIOMem.GetStartAddr() + m_ctrl->get + (4*(x+1))))
#define ARGS(x) (x >= count ? OutOfArgsCount(x, cmd, count) : Memory.Read32(Memory.RSXIOMem.RealAddr(Memory.RSXIOMem.GetStartAddr() + m_ctrl->get + (4*(x+1)))))
#define ARGS(x) (x >= count ? OutOfArgsCount(x, cmd, count, args) : args[x])
u32 methodRegisters[0xffff];
@ -46,10 +45,7 @@ u32 GetAddress(u32 offset, u8 location)
switch(location)
{
case CELL_GCM_LOCATION_LOCAL: return Memory.RSXFBMem.GetStartAddr() + offset;
case CELL_GCM_LOCATION_MAIN:
u64 realAddr;
Memory.RSXIOMem.getRealAddr(Memory.RSXIOMem.GetStartAddr() + offset, realAddr); // TODO: Error Check?
return realAddr;
case CELL_GCM_LOCATION_MAIN: return Memory.RSXIOMem.RealAddr(Memory.RSXIOMem.GetStartAddr() + offset); // TODO: Error Check?
}
LOG_ERROR(RSX, "GetAddress(offset=0x%x, location=0x%x)", location);
@ -141,7 +137,7 @@ u32 RSXVertexData::GetTypeSize()
#define CMD_LOG(...)
#endif
u32 RSXThread::OutOfArgsCount(const uint x, const u32 cmd, const u32 count)
u32 RSXThread::OutOfArgsCount(const uint x, const u32 cmd, const u32 count, mem32_ptr_t args)
{
std::string debug = GetMethodName(cmd);
debug += "(";
@ -207,7 +203,7 @@ u32 RSXThread::OutOfArgsCount(const uint x, const u32 cmd, const u32 count)
index = (cmd - a) / m; \
case a \
void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t& args, const u32 count)
void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t args, const u32 count)
{
#if CMD_DEBUG
std::string debug = GetMethodName(cmd);
@ -2454,9 +2450,7 @@ void RSXThread::Task()
}
//ConLog.Write("addr = 0x%x", m_ioAddress + get);
u64 realAddr;
Memory.RSXIOMem.getRealAddr(Memory.RSXIOMem.GetStartAddr() + get, realAddr);
const u32 cmd = Memory.Read32(realAddr);
const u32 cmd = ReadIO32(get);
const u32 count = (cmd >> 18) & 0x7ff;
//if(cmd == 0) continue;
@ -2471,7 +2465,7 @@ void RSXThread::Task()
{
m_call_stack.push(get + 4);
u32 offs = cmd & ~CELL_GCM_METHOD_FLAG_CALL;
u32 addr = Memory.RSXIOMem.GetStartAddr() + offs;
//u32 addr = Memory.RSXIOMem.GetStartAddr() + offs;
//LOG_WARNING(RSX, "rsx call(0x%x) #0x%x - 0x%x - 0x%x", offs, addr, cmd, get);
m_ctrl->get = offs;
continue;
@ -2500,13 +2494,13 @@ void RSXThread::Task()
continue;
}
mem32_ptr_t args((u32)Memory.RSXIOMem.RealAddr(Memory.RSXIOMem.GetStartAddr() + get + 4));
for(u32 i=0; i<count; i++)
{
methodRegisters[(cmd & 0xffff) + (i*4*inc)] = ARGS(i);
}
Memory.RSXIOMem.getRealAddr(Memory.RSXIOMem.GetStartAddr() + get + 4, realAddr);
mem32_ptr_t args((u32)realAddr);
DoCmd(cmd, cmd & 0x3ffff, args, count);
m_ctrl->get = get + (count + 1) * 4;