mirror of
https://github.com/TheBozos/DC_Recomp.git
synced 2026-12-01 07:38:29 -10:00
BozoEngine saves the runtime; DC's "dc" section (runtime/dc_state.cpp) adds what that does not hold: the compiled sound modules' IOP host, the MDT copies (the only model left once the game reuses a static piece's MDT memory) and their bindings, pinned and patched pictures, GS place ownership, water objects, frame identities, the haze seeds, the fishing strip and the native Options pages. Images are written once in a table. On load the caches of the old guest memory are dropped (decoded textures, render places, CLUT overrides, shadow queues, the partial frame) and so are the cheats' mirrors and queued edits. Unsaveable mid debug-font composition. --save-state FILE --save-state-at N, --load-state FILE [--load-state-at N], --dump-ram FILE; F5 / F7 / F6 slots and F2's Save states tab in the window. Engine pinned to c853ec0 (BozoEngine #101) until the save-state commit is on master. Checked: headless Matataki (saved 6500) and dungeon (5000) states loaded in a new process and mid-run give EE RAM identical to the uninterrupted runs; windowed save + load gives identical captures at seven frames and identical RAM. 135/135 suites, CI build 66/66, seven routes unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
46 lines
2.1 KiB
C++
46 lines
2.1 KiB
C++
// Dark Cloud's sound-library selection. Engine services and translation are game independent.
|
|
#include "dc_audio_modules.h"
|
|
#include "bozo/state.h"
|
|
#include <algorithm>
|
|
#include <cctype>
|
|
#include <memory>
|
|
#include <stdexcept>
|
|
namespace dc
|
|
{
|
|
namespace
|
|
{
|
|
std::unique_ptr<bozo::native::irx::CompiledLibraries> sound;
|
|
}
|
|
void installAudio(bozo::libs::Libraries &libraries)
|
|
{
|
|
sound = std::make_unique<bozo::native::irx::CompiledLibraries>(libraries, 0x80000);
|
|
addDcAudioImages(*sound);
|
|
libraries.mc.slotMask = 3; // DC uses slot 1 for the physical port card.
|
|
libraries.audioProvider = [](uint64_t cycle) { return sound->advanceTo(cycle); };
|
|
libraries.sif.transfer = [](uint32_t address, const uint8_t *bytes, uint32_t count)
|
|
{ sound->writeBuffer(address, bytes, count); };
|
|
libraries.sif.allocateBuffer = [](uint32_t bytes) { return sound->allocateBuffer(bytes); };
|
|
libraries.sif.freeBuffer = [](uint32_t address) { return sound->freeBuffer(address); };
|
|
libraries.sif.resetProvider = [] { sound->reset(); };
|
|
libraries.sif.moduleLoader = [](const std::string &path)
|
|
{
|
|
auto name = path.substr(path.find_last_of("/\\") + 1);
|
|
if (const auto version = name.find(';'); version != std::string::npos)
|
|
name.resize(version);
|
|
for (char &c : name)
|
|
c = static_cast<char>(std::toupper(static_cast<unsigned char>(c)));
|
|
// These services are answered directly at their EE APIs by Bozo's native pad and memory-card libraries.
|
|
if (name == "SIO2MAN.IRX" || name == "PADMAN.IRX" || name == "MCMAN.IRX" || name == "MCSERV.IRX")
|
|
return 1;
|
|
return sound->startImage(name + ";1");
|
|
};
|
|
}
|
|
// Save states: the compiled sound modules' IOP host, and why it cannot be saved right now (empty: it can).
|
|
void audioState(bozo::state::Archive &a)
|
|
{
|
|
if (sound)
|
|
sound->serialize(a);
|
|
}
|
|
std::string audioUnsaveable() { return sound ? sound->unsaveable() : std::string(); }
|
|
} // namespace dc
|