Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions runtime/host/free_host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ namespace bozo::host
if (registry)
{
vu0Programs_ = registry->vu0Programs();
vu0ByPair_.clear();
for (const BozoFunctionEntry &e : vu0Programs_)
if (e.address % 8u == 0 && e.address < kVu0TableBytes)
{
if (vu0ByPair_.empty())
vu0ByPair_.assign(kVu0TableBytes / 8u, nullptr);
if (!vu0ByPair_[e.address / 8u])
vu0ByPair_[e.address / 8u] = e.function;
}
vu0Code_ = registry->vu0CodeMemory();
transfersAlwaysDone_ = registry->transfersAreAlwaysDone();
d.setSyncVAtVblank(registry->syncVCallbackIsAtVblank());
Expand Down Expand Up @@ -272,6 +281,12 @@ namespace bozo::host
void FreeHost::vu0Microprogram(ee::Dispatcher &, R5900Context *ctx, uint32_t address)
{
++stats_.vu0Calls;
if (address % 8u == 0 && address < kVu0TableBytes && !vu0ByPair_.empty())
if (const RecompiledFunction f = vu0ByPair_[address / 8u])
{
f(d_->runtime().memory.ram(), ctx, &d_->runtime());
return;
}
if (!vu0Programs_.empty())
{
for (const BozoFunctionEntry &e : vu0Programs_)
Expand Down
4 changes: 4 additions & 0 deletions runtime/include/bozo/host/free_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ namespace bozo::host
port::InstructionHandler instructionHandler_ = nullptr;
bool transfersAlwaysDone_ = false;
std::vector<BozoFunctionEntry> vu0Programs_;
// The port's VU0 programs by pair (VCALLMS targets in the 16 KB a micro memory can hold), found without a search:
// a game can call thousands a frame.
static constexpr uint32_t kVu0TableBytes = 0x4000u;
std::vector<RecompiledFunction> vu0ByPair_;
uint8_t *vu0Code_ = nullptr; // port::Registry::vu0CodeMemory
void runOverride(R5900Context *ctx, uint32_t target, port::Function fn);
// Ends the run when no frame ended for opt_.stallFields fields (a wait that never ends), saying where.
Expand Down
Loading