Skip to content

Commit

Permalink
CPU: Handle mirrors of BIOS syscalls
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Nov 11, 2024
1 parent 3f41dcc commit 6ffa5bf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/core/cpu_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2422,9 +2422,11 @@ template<PGXPMode pgxp_mode, bool debug>
if (s_trace_to_log)
LogInstruction(g_state.current_instruction.bits, g_state.current_instruction_pc, true);

if (g_state.current_instruction_pc == 0xA0) [[unlikely]]
// handle all mirrors of the syscall trampoline
const u32 masked_pc = (g_state.current_instruction_pc & PHYSICAL_MEMORY_ADDRESS_MASK);
if (masked_pc == 0xA0) [[unlikely]]
HandleA0Syscall();
else if (g_state.current_instruction_pc == 0xB0) [[unlikely]]
else if (masked_pc == 0xB0) [[unlikely]]
HandleB0Syscall();
}

Expand Down
5 changes: 3 additions & 2 deletions src/core/cpu_newrec_compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@ void CPU::NewRec::Compiler::BeginBlock()

if (g_settings.bios_tty_logging)
{
if (m_block->pc == 0xa0)
const u32 masked_pc = (m_block->pc & PHYSICAL_MEMORY_ADDRESS_MASK);
if (masked_pc == 0xa0)
GenerateCall(reinterpret_cast<const void*>(&CPU::HandleA0Syscall));
else if (m_block->pc == 0xb0)
else if (masked_pc == 0xb0)
GenerateCall(reinterpret_cast<const void*>(&CPU::HandleB0Syscall));
}

Expand Down
5 changes: 3 additions & 2 deletions src/core/cpu_recompiler_code_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1000,9 +1000,10 @@ void CodeGenerator::BlockPrologue()

if (g_settings.bios_tty_logging)
{
if (m_pc == 0xa0)
const u32 masked_pc = (m_pc & PHYSICAL_MEMORY_ADDRESS_MASK);
if (masked_pc == 0xa0)
EmitFunctionCall(nullptr, &CPU::HandleA0Syscall);
else if (m_pc == 0xb0)
else if (masked_pc == 0xb0)
EmitFunctionCall(nullptr, &CPU::HandleB0Syscall);
}

Expand Down

0 comments on commit 6ffa5bf

Please sign in to comment.