From 3658e710d2e4de6c323b5b74dbac21925875e8f3 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Tue, 6 Jan 2015 00:13:27 -0800 Subject: [PATCH] Tweaks; timebase supports TBU. --- src/alloy/frontend/ppc/ppc_emit_control.cc | 17 +++++++++++++++-- src/xenia/kernel/apps/xmp_app.cc | 2 +- src/xenia/kernel/xboxkrnl_modules.cc | 1 + 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/alloy/frontend/ppc/ppc_emit_control.cc b/src/alloy/frontend/ppc/ppc_emit_control.cc index 7de4a02a4..49f1a62ff 100644 --- a/src/alloy/frontend/ppc/ppc_emit_control.cc +++ b/src/alloy/frontend/ppc/ppc_emit_control.cc @@ -555,7 +555,14 @@ XEEMITTER(mfspr, 0x7C0002A6, XFX)(PPCHIRBuilder& f, InstrData& i) { // CTR v = f.LoadCTR(); break; - // 268 + 269 = TB + TBU + case 268: + // TB + v = f.LoadClock(); + break; + case 269: + // TBU + v = f.Shr(f.LoadClock(), 32); + break; default: XEINSTRNOTIMPLEMENTED(); return 1; @@ -566,8 +573,14 @@ XEEMITTER(mfspr, 0x7C0002A6, XFX)(PPCHIRBuilder& f, InstrData& i) { XEEMITTER(mftb, 0x7C0002E6, XFX)(PPCHIRBuilder& f, InstrData& i) { Value* time = f.LoadClock(); + const uint32_t n = ((i.XFX.spr & 0x1F) << 5) | ((i.XFX.spr >> 5) & 0x1F); + if (n == 268) { + // TB - full bits. + } else { + // TBU - upper bits only. + time = f.Shr(time, 32); + } f.StoreGPR(i.XFX.RT, time); - return 0; } diff --git a/src/xenia/kernel/apps/xmp_app.cc b/src/xenia/kernel/apps/xmp_app.cc index 423a64506..e3ce93c27 100644 --- a/src/xenia/kernel/apps/xmp_app.cc +++ b/src/xenia/kernel/apps/xmp_app.cc @@ -30,7 +30,7 @@ X_RESULT XXMPApp::XMPGetStatusEx(uint32_t unk, uint32_t unk_ptr, uint32_t disabled_ptr) { // Some stupid games will hammer this on a thread - induce a delay // here to keep from starving real threads. - Sleep(1); + Sleep(10); XELOGD("XMPGetStatusEx(%.8X, %.8X, %.8X)", unk, unk_ptr, disabled_ptr); diff --git a/src/xenia/kernel/xboxkrnl_modules.cc b/src/xenia/kernel/xboxkrnl_modules.cc index 33f66aa26..1a57e4cdd 100644 --- a/src/xenia/kernel/xboxkrnl_modules.cc +++ b/src/xenia/kernel/xboxkrnl_modules.cc @@ -246,6 +246,7 @@ SHIM_CALL XexGetProcedureAddress_shim(PPCContext* ppc_state, out_function_ptr); X_STATUS result = X_STATUS_INVALID_HANDLE; + SHIM_SET_MEM_32(out_function_ptr, 0xDEADF00D); XModule* module = NULL;