Small changes

This commit is contained in:
CocoSimone
2023-02-19 19:21:47 +01:00
parent bead7e55bc
commit a580b54579
3 changed files with 19 additions and 8 deletions

View File

@@ -1,6 +1,7 @@
#pragma once
#include <common.hpp>
#include <queue>
#include <array>
namespace n64 {
struct Mem;
@@ -8,11 +9,19 @@ struct Registers;
}
struct Event {
u64 time = UINT64_MAX;
u64 time = 0;
void(*handler)(n64::Mem&, n64::Registers&) = nullptr;
friend bool operator<(const Event& rhs, const Event& lhs) {
return lhs.time < rhs.time;
return rhs.time < lhs.time;
}
friend bool operator>(const Event& rhs, const Event& lhs) {
return rhs.time > lhs.time;
}
friend bool operator>=(const Event& rhs, const Event& lhs) {
return rhs.time >= lhs.time;
}
};
@@ -21,8 +30,9 @@ struct Scheduler {
void enqueueRelative(const Event&);
void enqueueAbsolute(const Event&);
void tick(u64, n64::Mem&, n64::Registers&);
std::priority_queue<Event> events;
std::priority_queue<Event, std::vector<Event>, std::greater<>> events;
u64 ticks = 0;
u8 index = 0;
};
extern Scheduler scheduler;