Files
ArzarothandClaude Opus 5.5 30d06723fb [bozo/migrate] feat(audio): the disc's sound modules compiled and hosted natively
LIBSD, SDRDRV, MODHSYN, MODMSIN, STRADPCM and the SK sound kit
(SKSOUND, SKHSYNTH, SKMSIN, SKSADPCM) go through BozoEngine's
tools/native_irx into native code, run by its compiled-library host
over native libsd: sceSdRemoteInit's bind of SDRDRV completes.
SDRDRV's callback thread binds libsdr's EE server 0x80000704; nothing
answers its calls yet, so one fails the run with its command.

BozoEngine on ffop/iop-host-imports (0505c45): the event flags,
QueryIntrContext, bzero and ReferSemaStatus these modules import.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-11 05:22:53 +01:00

56 lines
2.2 KiB
C++

#include "ffop_audio.h"
#include <algorithm>
#include <cctype>
#include <format>
#include <memory>
#include <span>
#include <stdexcept>
#include <string>
namespace ffop::audio
{
namespace
{
constexpr uint32_t kHeapStart = 0x00034000u;
constexpr uint32_t kSdrCallbackServer = 0x80000704u;
std::string moduleName(const std::string &path)
{
const size_t slash = path.find_last_of("\\/:");
std::string name = path.substr(slash == std::string::npos ? 0 : slash + 1);
std::transform(name.begin(), name.end(), name.begin(), [](unsigned char c) { return std::toupper(c); });
return name;
}
}
void attach(bozo::libs::Libraries &libraries)
{
static std::unique_ptr<bozo::native::irx::CompiledLibraries> host;
host = std::make_unique<bozo::native::irx::CompiledLibraries>(libraries, kHeapStart);
std::vector<std::string> names;
for (auto &image : images())
{
names.push_back(image.name);
host->addImage(std::move(image));
}
auto *h = host.get();
libraries.sif.moduleLoader = [h, names, others = int32_t(0)](const std::string &path) mutable
{
const std::string name = moduleName(path);
if (std::find(names.begin(), names.end(), name) != names.end())
return h->startImage(name);
return 0x1000 + ++others;
};
libraries.sif.transfer = [h](uint32_t address, const uint8_t *data, uint32_t bytes) { h->writeBuffer(address, data, bytes); };
libraries.sif.allocateBuffer = [h](uint32_t bytes) { return h->allocateBuffer(bytes); };
libraries.sif.freeBuffer = [h](uint32_t address) { return h->freeBuffer(address); };
libraries.sif.resetProvider = [h] { h->reset(); };
libraries.audioProvider = [h](uint64_t cycle) { return h->advanceTo(cycle); };
libraries.sif.eeServers[kSdrCallbackServer] = [](uint32_t command, std::span<const uint8_t>, std::span<uint8_t>) {
throw std::runtime_error(std::format("FFOP: SDRDRV called libsdr's EE callback server (command {}), "
"which has no native answer yet", command));
};
}
}