2012-03-19 11:19:53 +00:00
|
|
|
#include <gba/gba.hpp>
|
|
|
|
|
2012-04-26 10:51:13 +00:00
|
|
|
namespace GameBoyAdvance {
|
2012-03-19 11:19:53 +00:00
|
|
|
|
|
|
|
Scheduler scheduler;
|
|
|
|
|
2015-11-16 08:38:05 +00:00
|
|
|
Scheduler::Scheduler() {
|
|
|
|
sync = SynchronizeMode::None;
|
|
|
|
exit_reason = ExitReason::UnknownEvent;
|
|
|
|
host = nullptr;
|
|
|
|
active = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto Scheduler::enter() -> void {
|
2012-03-19 11:19:53 +00:00
|
|
|
host = co_active();
|
|
|
|
co_switch(active);
|
|
|
|
}
|
|
|
|
|
2015-11-16 08:38:05 +00:00
|
|
|
auto Scheduler::exit(ExitReason reason) -> void {
|
2012-03-19 11:19:53 +00:00
|
|
|
exit_reason = reason;
|
|
|
|
active = co_active();
|
|
|
|
co_switch(host);
|
|
|
|
}
|
|
|
|
|
2015-11-16 08:38:05 +00:00
|
|
|
auto Scheduler::power() -> void {
|
2012-03-19 11:19:53 +00:00
|
|
|
host = co_active();
|
|
|
|
active = cpu.thread;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|