Merge remote-tracking branch 'upstream/master' into feature/savestates-2

This commit is contained in:
Hamish Milne
2020-03-28 12:46:24 +00:00
17 changed files with 224 additions and 93 deletions

View File

@ -22,14 +22,21 @@ bool Timing::Event::operator<(const Timing::Event& right) const {
return std::tie(time, fifo_order) < std::tie(right.time, right.fifo_order);
}
Timing::Timing(std::size_t num_cores) {
Timing::Timing(std::size_t num_cores, u32 cpu_clock_percentage) {
timers.resize(num_cores);
for (std::size_t i = 0; i < num_cores; ++i) {
timers[i] = std::make_shared<Timer>();
}
UpdateClockSpeed(cpu_clock_percentage);
current_timer = timers[0];
}
void Timing::UpdateClockSpeed(u32 cpu_clock_percentage) {
for (auto& timer : timers) {
timer->cpu_clock_scale = 100.0 / cpu_clock_percentage;
}
}
TimingEventType* Timing::RegisterEvent(const std::string& name, TimedCallback callback) {
// check for existing type with same name.
// we want event type names to remain unique so that we can use them for serialization.
@ -117,6 +124,8 @@ std::shared_ptr<Timing::Timer> Timing::GetTimer(std::size_t cpu_id) {
return timers[cpu_id];
}
Timing::Timer::Timer() = default;
Timing::Timer::~Timer() {
MoveEvents();
}
@ -130,7 +139,7 @@ u64 Timing::Timer::GetTicks() const {
}
void Timing::Timer::AddTicks(u64 ticks) {
downcount -= ticks;
downcount -= static_cast<u64>(ticks * cpu_clock_scale);
}
u64 Timing::Timer::GetIdleTicks() const {