Bus: Fix sideloading EXEs without initial SP value

This commit is contained in:
Stenzek 2024-08-11 21:58:21 +10:00
parent 62eb557832
commit 00a58eb4e5
No known key found for this signature in database

View file

@ -981,9 +981,14 @@ bool Bus::InjectExecutable(std::span<const u8> buffer, bool set_pc, Error* error
if (set_pc) if (set_pc)
{ {
const u32 r_pc = header.initial_pc; const u32 r_pc = header.initial_pc;
CPU::g_state.regs.gp = header.initial_gp; const u32 r_gp = header.initial_gp;
CPU::g_state.regs.sp = header.initial_sp_base + header.initial_sp_offset; const u32 r_sp = header.initial_sp_base + header.initial_sp_offset;
CPU::g_state.regs.fp = header.initial_sp_base + header.initial_sp_offset; CPU::g_state.regs.gp = r_gp;
if (r_sp != 0)
{
CPU::g_state.regs.sp = r_sp;
CPU::g_state.regs.fp = r_sp;
}
CPU::SetPC(r_pc); CPU::SetPC(r_pc);
} }