Refactor Snes class and enhance Apu functionality

- Updated Snes constructor to initialize CPU callbacks directly, improving readability and maintainability.
- Removed unnecessary CpuCallbacks parameter from Cpu constructor, streamlining the class design.
- Added new methods in Apu for retrieving cycles, status, control, and handling DMA transfers, enhancing audio processing capabilities.
- Introduced unit tests for Apu to validate initialization, sample generation, and handshake timing, ensuring robust audio functionality.
This commit is contained in:
scawful
2025-09-24 12:51:29 -04:00
parent f1b1c91986
commit 3734884ba3
7 changed files with 289 additions and 18 deletions

View File

@@ -31,10 +31,12 @@ class InstructionEntry {
class Cpu {
public:
explicit Cpu(Memory& mem, CpuCallbacks& callbacks)
: memory(mem), callbacks_(callbacks) {}
explicit Cpu(Memory& mem) : memory(mem) {}
void Reset(bool hard = false);
auto& callbacks() { return callbacks_; }
const auto& callbacks() const { return callbacks_; }
void RunOpcode();
void ExecuteInstruction(uint8_t opcode);
@@ -781,8 +783,8 @@ class Cpu {
bool int_wanted_ = false;
bool int_delay_ = false;
CpuCallbacks callbacks_;
Memory& memory;
CpuCallbacks callbacks_;
};
} // namespace emu