From 3f7da258fc878f03ed2dc491ec69ed412f0e3c3c Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Sun, 17 May 2015 13:35:12 -0700 Subject: [PATCH] Adjusting stack padding on executes. --- src/xenia/cpu/processor.cc | 8 ++++++-- src/xenia/cpu/thread_state.cc | 4 ---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/xenia/cpu/processor.cc b/src/xenia/cpu/processor.cc index 6b9994773..04f90c497 100644 --- a/src/xenia/cpu/processor.cc +++ b/src/xenia/cpu/processor.cc @@ -331,16 +331,20 @@ bool Processor::Execute(ThreadState* thread_state, uint32_t address) { PPCContext* context = thread_state->context(); - // Setup registers. - uint64_t previous_lr = context->lr; + // Pad out stack a bit, as some games seem to overwrite the caller by about + // 16 to 32b. + context->r[1] -= 64 + 112; + // This could be set to anything to give us a unique identifier to track // re-entrancy/etc. + uint64_t previous_lr = context->lr; context->lr = 0xBEBEBEBE; // Execute the function. auto result = fn->Call(thread_state, uint32_t(context->lr)); context->lr = previous_lr; + context->r[1] += 64 + 112; return result; } diff --git a/src/xenia/cpu/thread_state.cc b/src/xenia/cpu/thread_state.cc index 442ba4205..54d795f24 100644 --- a/src/xenia/cpu/thread_state.cc +++ b/src/xenia/cpu/thread_state.cc @@ -103,10 +103,6 @@ ThreadState::ThreadState(Processor* processor, uint32_t thread_id, context_->r[1] = stack_base_; context_->r[13] = pcr_address_; - // Pad out stack a bit, as some games seem to overwrite the caller by about - // 16 to 32b. - context_->r[1] -= 64; - processor_->debugger()->OnThreadCreated(this); }