update apu ram management
This commit is contained in:
@@ -31,12 +31,26 @@ static const uint8_t bootRom[0x40] = {
|
|||||||
void Apu::Init() {
|
void Apu::Init() {
|
||||||
// Set the clock frequency
|
// Set the clock frequency
|
||||||
clock_.SetFrequency(kApuClockSpeed);
|
clock_.SetFrequency(kApuClockSpeed);
|
||||||
|
ram.resize(0x10000);
|
||||||
|
for (int i = 0; i < 0x10000; i++) {
|
||||||
|
ram[i] = 0;
|
||||||
|
}
|
||||||
|
// Copy the boot rom into the ram at ffc0
|
||||||
|
for (int i = 0; i < 0x40; i++) {
|
||||||
|
ram[0xffc0 + i] = bootRom[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Apu::Reset() {
|
void Apu::Reset() {
|
||||||
spc700_.Reset(true);
|
spc700_.Reset(true);
|
||||||
dsp_.Reset();
|
dsp_.Reset();
|
||||||
ram.clear();
|
for (int i = 0; i < 0x10000; i++) {
|
||||||
|
ram[i] = 0;
|
||||||
|
}
|
||||||
|
// Copy the boot rom into the ram at ffc0
|
||||||
|
for (int i = 0; i < 0x40; i++) {
|
||||||
|
ram[0xffc0 + i] = bootRom[i];
|
||||||
|
}
|
||||||
rom_readable_ = true;
|
rom_readable_ = true;
|
||||||
dsp_adr_ = 0;
|
dsp_adr_ = 0;
|
||||||
cycles_ = 0;
|
cycles_ = 0;
|
||||||
@@ -51,17 +65,6 @@ void Apu::Reset() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Apu::Update() {
|
|
||||||
auto cycles_to_run = clock_.GetCycleCount();
|
|
||||||
|
|
||||||
for (auto i = 0; i < cycles_to_run; ++i) {
|
|
||||||
// Update the SPC700
|
|
||||||
uint8_t opcode = spc700_.read(spc700_.PC);
|
|
||||||
spc700_.ExecuteInstructions(opcode);
|
|
||||||
spc700_.PC++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Apu::RunCycles(uint64_t cycles) {
|
void Apu::RunCycles(uint64_t cycles) {
|
||||||
uint64_t sync_to =
|
uint64_t sync_to =
|
||||||
(uint64_t)cycles *
|
(uint64_t)cycles *
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ class Apu {
|
|||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
void Reset();
|
void Reset();
|
||||||
void Update();
|
|
||||||
|
|
||||||
void RunCycles(uint64_t cycles);
|
void RunCycles(uint64_t cycles);
|
||||||
uint8_t SpcRead(uint16_t address);
|
uint8_t SpcRead(uint16_t address);
|
||||||
@@ -80,13 +79,13 @@ class Apu {
|
|||||||
// Port buffers (equivalent to $2140 to $2143 for the main CPU)
|
// Port buffers (equivalent to $2140 to $2143 for the main CPU)
|
||||||
uint8_t in_ports_[6]; // includes 2 bytes of ram
|
uint8_t in_ports_[6]; // includes 2 bytes of ram
|
||||||
uint8_t out_ports_[4];
|
uint8_t out_ports_[4];
|
||||||
|
std::vector<uint8_t> ram = std::vector<uint8_t>(0x10000, 0);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Timer timer_[3];
|
Timer timer_[3];
|
||||||
uint32_t cycles_;
|
uint32_t cycles_;
|
||||||
uint8_t dsp_adr_;
|
uint8_t dsp_adr_;
|
||||||
bool rom_readable_ = false;
|
bool rom_readable_ = false;
|
||||||
std::vector<uint8_t> ram = std::vector<uint8_t>(0x10000, 0);
|
|
||||||
|
|
||||||
// Member variables to store internal APU state and resources
|
// Member variables to store internal APU state and resources
|
||||||
Clock &clock_;
|
Clock &clock_;
|
||||||
|
|||||||
Reference in New Issue
Block a user