cdrom: 75/150 sectors per second speed

This commit is contained in:
Jakub Czekański 2021-01-31 01:19:52 +01:00
parent 4ef44fb086
commit e33cbf5aef
2 changed files with 5 additions and 8 deletions

View file

@ -12,8 +12,6 @@
namespace device {
namespace cdrom {
const int CPU_FREQ = 38'868'800;
CDROM::CDROM(System* sys) : sys(sys) {
verbose = config.debug.log.cdrom;
disc = std::make_unique<disc::Empty>();
@ -151,9 +149,8 @@ void CDROM::step(int cycles) {
}
}
const int CD_SECTOR_SIZE = 2048;
const int sectorsPerSecond = (44100 * 2 * 2) / CD_SECTOR_SIZE;
const int cyclesPerSector = (CPU_FREQ / sectorsPerSecond) / (mode.speed ? 2 : 1); // not perfect division
const int sectorsPerSecond = mode.speed ? 150 : 75;
const int cyclesPerSector = timing::CPU_CLOCK / sectorsPerSecond;
for (int i = 0; i < readcnt / cyclesPerSector; i++) {
handleSector();
}

View file

@ -13,14 +13,14 @@ const float CYCLES_PER_LINE_PAL = 3406.1f;
const int LINES_TOTAL_NTSC = 263;
const int LINES_TOTAL_PAL = 314;
#else
const float CYCLES_PER_LINE_NTSC = 3372;
const float CYCLES_PER_LINE_NTSC = 3372.7f;
const float CYCLES_PER_LINE_PAL = 3389;
const int LINES_TOTAL_NTSC = 263;
const int LINES_TOTAL_PAL = 314;
#endif
const float NTSC_FRAMERATE = (float)GPU_CLOCK / (CYCLES_PER_LINE_NTSC * LINES_TOTAL_NTSC);
const float PAL_FRAMERATE = (float)GPU_CLOCK / (CYCLES_PER_LINE_PAL * LINES_TOTAL_PAL);
const double NTSC_FRAMERATE = (double)GPU_CLOCK / (CYCLES_PER_LINE_NTSC * LINES_TOTAL_NTSC);
const double PAL_FRAMERATE = (double)GPU_CLOCK / (CYCLES_PER_LINE_PAL * LINES_TOTAL_PAL);
constexpr uint64_t usToCpuCycles(uint64_t us) { return us * CPU_CLOCK / US_IN_SECOND; }
} // namespace timing