mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-07 22:55:40 +12:00
Use CPU for counting ticks instead of scheduler
This commit is contained in:
parent
7343497f36
commit
97f97dc6e2
3 changed files with 36 additions and 36 deletions
|
@ -11,14 +11,16 @@
|
||||||
#include "memory.hpp"
|
#include "memory.hpp"
|
||||||
#include "scheduler.hpp"
|
#include "scheduler.hpp"
|
||||||
|
|
||||||
|
class Emulator;
|
||||||
class CPU;
|
class CPU;
|
||||||
|
|
||||||
class MyEnvironment final : public Dynarmic::A32::UserCallbacks {
|
class MyEnvironment final : public Dynarmic::A32::UserCallbacks {
|
||||||
public:
|
public:
|
||||||
u64 ticksLeft = 0;
|
u64 ticksLeft = 0;
|
||||||
u64 totalTicks = 0;
|
u64 totalTicks = 0;
|
||||||
Memory& mem;
|
Memory& mem;
|
||||||
Kernel& kernel;
|
Kernel& kernel;
|
||||||
|
Scheduler& scheduler;
|
||||||
|
|
||||||
u64 getCyclesForInstruction(bool isThumb, u32 instruction);
|
u64 getCyclesForInstruction(bool isThumb, u32 instruction);
|
||||||
|
|
||||||
|
@ -109,7 +111,7 @@ public:
|
||||||
return getCyclesForInstruction(isThumb, instruction);
|
return getCyclesForInstruction(isThumb, instruction);
|
||||||
}
|
}
|
||||||
|
|
||||||
MyEnvironment(Memory& mem, Kernel& kernel) : mem(mem), kernel(kernel) {}
|
MyEnvironment(Memory& mem, Kernel& kernel, Scheduler& scheduler) : mem(mem), kernel(kernel), scheduler(scheduler) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class CPU {
|
class CPU {
|
||||||
|
|
|
@ -18,12 +18,10 @@ struct Scheduler {
|
||||||
using EventMap = boost::container::flat_multimap<Key, Val, std::less<Key>, boost::container::static_vector<std::pair<Key, Val>, size>>;
|
using EventMap = boost::container::flat_multimap<Key, Val, std::less<Key>, boost::container::static_vector<std::pair<Key, Val>, size>>;
|
||||||
|
|
||||||
EventMap<u64, EventType, totalNumberOfEvents> events;
|
EventMap<u64, EventType, totalNumberOfEvents> events;
|
||||||
u64 currentTimestamp = 0;
|
|
||||||
u64 nextTimestamp = 0;
|
u64 nextTimestamp = 0;
|
||||||
|
|
||||||
// Set nextTimestamp to the timestamp of the next event
|
// Set nextTimestamp to the timestamp of the next event
|
||||||
void updateNextTimestamp() { nextTimestamp = events.cbegin()->first; }
|
void updateNextTimestamp() { nextTimestamp = events.cbegin()->first; }
|
||||||
void addCycles(u64 cycles) { currentTimestamp += cycles; }
|
|
||||||
|
|
||||||
void addEvent(EventType type, u64 timestamp) {
|
void addEvent(EventType type, u64 timestamp) {
|
||||||
events.emplace(timestamp, type);
|
events.emplace(timestamp, type);
|
||||||
|
@ -40,8 +38,6 @@ struct Scheduler {
|
||||||
};
|
};
|
||||||
|
|
||||||
void reset() {
|
void reset() {
|
||||||
currentTimestamp = 0;
|
|
||||||
|
|
||||||
// Clear any pending events
|
// Clear any pending events
|
||||||
events.clear();
|
events.clear();
|
||||||
// Add a dummy event to always keep the scheduler non-empty
|
// Add a dummy event to always keep the scheduler non-empty
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "arm_defs.hpp"
|
#include "arm_defs.hpp"
|
||||||
|
|
||||||
CPU::CPU(Memory& mem, Kernel& kernel) : mem(mem), env(mem, kernel) {
|
CPU::CPU(Memory& mem, Kernel& kernel) : mem(mem), env(mem, kernel, scheduler) {
|
||||||
cp15 = std::make_shared<CP15>();
|
cp15 = std::make_shared<CP15>();
|
||||||
|
|
||||||
Dynarmic::A32::UserConfig config;
|
Dynarmic::A32::UserConfig config;
|
||||||
|
@ -32,6 +32,8 @@ void CPU::reset() {
|
||||||
// Reset scheduler and add a VBlank event
|
// Reset scheduler and add a VBlank event
|
||||||
scheduler.reset();
|
scheduler.reset();
|
||||||
scheduler.addEvent(Scheduler::EventType::VBlank, ticksPerSec / 60);
|
scheduler.addEvent(Scheduler::EventType::VBlank, ticksPerSec / 60);
|
||||||
|
|
||||||
|
printf("%lld\n", scheduler.nextTimestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // CPU_DYNARMIC
|
#endif // CPU_DYNARMIC
|
Loading…
Add table
Reference in a new issue