diff --git a/Breaknes/BreaksCore/AbstractBoard.cpp b/Breaknes/BreaksCore/AbstractBoard.cpp index 0f70e517..b66c74c5 100644 --- a/Breaknes/BreaksCore/AbstractBoard.cpp +++ b/Breaknes/BreaksCore/AbstractBoard.cpp @@ -105,7 +105,6 @@ namespace Breaknes } ppu_regdump = new RegDumper("PPU", GetPHICounter(), filename); prev_phi_counter_for_ppuregdump = GetPHICounter(); - phi_flush_counter_ppuregdump = 0; printf("PPU regdump enabled to file: %s\n", filename); } @@ -132,7 +131,6 @@ namespace Breaknes } apu_regdump = new RegDumper("APU", GetPHICounter(), filename); prev_phi_counter_for_apuregdump = GetPHICounter(); - phi_flush_counter_apuregdump = 0; printf("APU regdump enabled to file: %s\n", filename); } @@ -151,47 +149,36 @@ namespace Breaknes /// void Board::TreatCoreForRegdump(uint16_t addr_bus, uint8_t data_bus, BaseLogic::TriState m2, BaseLogic::TriState rnw) { - // The reason for checking for delta = 1 is that the first trigger is received during PHI1 of the core when it sets the register address; - // And since the PHI counter is posedge, we need to catch its next change (the next PHI2 after the address is set) - + // APU Regdump if (apu_regdump && (addr_bus & ~MappedAPUMask) == MappedAPUBase) { uint64_t phi_now = GetPHICounter(); uint64_t delta = phi_now - prev_phi_counter_for_apuregdump; - if (prev_phi_counter_for_apuregdump != phi_now && delta == 1) { + if (prev_phi_counter_for_apuregdump != phi_now) { if (rnw == BaseLogic::TriState::One) apu_regdump->LogRegRead(phi_now, addr_bus & MappedAPUMask); else if (rnw == BaseLogic::TriState::Zero) apu_regdump->LogRegWrite(phi_now, addr_bus & MappedAPUMask, data_bus); - - phi_flush_counter_apuregdump += delta; - if (phi_flush_counter_apuregdump >= JustAboutOneSecond) { - phi_flush_counter_apuregdump = 0; - apu_regdump->Flush(); - } + + prev_phi_counter_for_apuregdump = phi_now; } - prev_phi_counter_for_apuregdump = phi_now; } + // PPU Regump (isomorphic) if (ppu_regdump && (addr_bus & ~MappedPPUMask) == MappedPPUBase) { uint64_t phi_now = GetPHICounter(); uint64_t delta = phi_now - prev_phi_counter_for_ppuregdump; - if (prev_phi_counter_for_ppuregdump != phi_now && delta == 1) { + if (prev_phi_counter_for_ppuregdump != phi_now) { if (rnw == BaseLogic::TriState::One) ppu_regdump->LogRegRead(phi_now, addr_bus & MappedPPUMask); else if (rnw == BaseLogic::TriState::Zero) ppu_regdump->LogRegWrite(phi_now, addr_bus & MappedPPUMask, data_bus); - phi_flush_counter_ppuregdump += delta; - if (phi_flush_counter_ppuregdump >= JustAboutOneSecond) { - phi_flush_counter_ppuregdump = 0; - ppu_regdump->Flush(); - } + prev_phi_counter_for_ppuregdump = phi_now; } - prev_phi_counter_for_ppuregdump = phi_now; - } +} } void Board::GetApuSignalFeatures(APUSim::AudioSignalFeatures* features) diff --git a/Breaknes/BreaksCore/AbstractBoard.h b/Breaknes/BreaksCore/AbstractBoard.h index de5fa501..d8d2603a 100644 --- a/Breaknes/BreaksCore/AbstractBoard.h +++ b/Breaknes/BreaksCore/AbstractBoard.h @@ -54,8 +54,6 @@ namespace Breaknes RegDumper* apu_regdump = nullptr; size_t prev_phi_counter_for_ppuregdump = 0; size_t prev_phi_counter_for_apuregdump = 0; - size_t phi_flush_counter_ppuregdump = 0; - size_t phi_flush_counter_apuregdump = 0; void TreatCoreForRegdump(uint16_t addr_bus, uint8_t data_bus, BaseLogic::TriState m2, BaseLogic::TriState rnw); diff --git a/BreaksAPU/APUSim/core.cpp b/BreaksAPU/APUSim/core.cpp index 0853fac7..d5baee4a 100644 --- a/BreaksAPU/APUSim/core.cpp +++ b/BreaksAPU/APUSim/core.cpp @@ -73,10 +73,11 @@ namespace APUSim // TBD: Other APU revisions - // The software PHI counter is triggered by the raising edge. + // The software PHI counter is triggered by the falling edge. // This is purely a software design for convenience, and has nothing to do with APU hardware circuitry. + // CPU cycles count by falling edge means that it is a counter of FULL cycles (i.e. PHI1+PHI2 of the processor are executed) - if (IsPosedge(prev_phi, new_phi)) + if (IsNegedge(prev_phi, new_phi)) { apu->phi_counter++; } diff --git a/Common/BaseBoardLib/RegDumpProcessor.cpp b/Common/BaseBoardLib/RegDumpProcessor.cpp index 226a615e..42c4abc9 100644 --- a/Common/BaseBoardLib/RegDumpProcessor.cpp +++ b/Common/BaseBoardLib/RegDumpProcessor.cpp @@ -23,7 +23,7 @@ namespace BaseBoard { // Increase the cycle counter - if (IsPosedge(PrevCLK, CLK)) + if (IsNegedge(PrevCLK, CLK)) { clk_counter++; hold = false;