#include "stdafx.h" #include "Emu/Cell/PPUThread.h" #include "Emu/Cell/PPUDecoder.h" #include "Emu/Cell/PPUInterpreter.h" #include "Emu/Cell/PPUDisAsm.h" #include extern gcmInfo gcm_info; PPUThread& GetCurrentPPUThread() { PPCThread* thread = GetCurrentPPCThread(); if(!thread || thread->GetType() != PPC_THREAD_PPU) throw wxString("GetCurrentPPUThread: bad thread"); return *(PPUThread*)thread; } PPUThread::PPUThread() : PPCThread(PPC_THREAD_PPU) , SysCalls(*this) { Reset(); } PPUThread::~PPUThread() { //~PPCThread(); } void PPUThread::DoReset() { //reset regs memset(VPR, 0, sizeof(VPR)); memset(FPR, 0, sizeof(FPR)); memset(GPR, 0, sizeof(GPR)); memset(SPRG, 0, sizeof(SPRG)); CR.CR = 0; LR = 0; CTR = 0; USPRG0 = 0; TB = 0; XER.XER = 0; FPSCR.FPSCR = 0; VSCR.VSCR = 0; cycle = 0; reserve = false; reserve_addr = 0; } void PPUThread::AddArgv(const wxString& arg) { stack_point -= arg.Len() + 1; stack_point = Memory.AlignAddr(stack_point, 0x10) - 0x10; argv_addr.AddCpy(stack_point); Memory.WriteString(stack_point, arg); } void PPUThread::InitRegs() { const u32 pc = Memory.Read32(entry); const u32 rtoc = Memory.Read32(entry + 4); //ConLog.Write("entry = 0x%x", entry); //ConLog.Write("rtoc = 0x%x", rtoc); SetPc(pc); const s32 thread_num = Emu.GetCPU().GetThreadNumById(GetType(), GetId()); if(thread_num < 0) { ConLog.Error("GetThreadNumById failed."); Emu.Pause(); return; } /* const s32 tls_size = Emu.GetTLSFilesz() * thread_num; if(tls_size >= Emu.GetTLSMemsz()) { ConLog.Error("Out of TLS memory."); Emu.Pause(); return; } */ stack_point = Memory.AlignAddr(stack_point, 0x200) - 0x200; GPR[1] = stack_point; GPR[2] = rtoc; for(int i=4; i<32; ++i) { if(i != 6) GPR[i] = (i+1) * 0x10000; } if(argv_addr.GetCount()) { u64 argc = argv_addr.GetCount(); stack_point -= 0xc + 4 * argc; u64 argv = stack_point; mem64_t argv_list(argv); for(int i=0; i 220) { cycle = 0; TB++; } m_dec->Decode(code); } bool FPRdouble::IsINF(PPCdouble d) { return ((u64&)d & 0x7FFFFFFFFFFFFFFFULL) == 0x7FF0000000000000ULL; } bool FPRdouble::IsNaN(PPCdouble d) { return wxIsNaN(d) ? 1 : 0; } bool FPRdouble::IsQNaN(PPCdouble d) { return ((u64&)d & 0x7FF0000000000000ULL) == 0x7FF0000000000000ULL && ((u64&)d & 0x0007FFFFFFFFFFFULL) == 0ULL && ((u64&)d & 0x000800000000000ULL) != 0ULL; } bool FPRdouble::IsSNaN(PPCdouble d) { return ((u64&)d & 0x7FF0000000000000ULL) == 0x7FF0000000000000ULL && ((u64&)d & 0x000FFFFFFFFFFFFFULL) != 0ULL && ((u64&)d & 0x0008000000000000ULL) == 0ULL; } int FPRdouble::Cmp(PPCdouble a, PPCdouble b) { if(a < b) return CR_LT; if(a > b) return CR_GT; if(a == b) return CR_EQ; return CR_SO; }