Sketch Timer and implement Interrupt support

This commit is contained in:
Björn Gaier
2023-01-06 15:18:35 +01:00
parent 6608d92934
commit ec6b93942c
6 changed files with 102 additions and 11 deletions

View File

@@ -6,9 +6,9 @@ namespace JabyEngine {
// Just testing around
static constexpr auto wuff = CounterMode::with(CounterMode::IRQAtMax, Counter0::SyncMode::Zero_At_Hblank);
timer[0].counter_mode = wuff;
timer[0].counter_mode = wuff;
timer[0].counter_mode = wuff;
Counter[0].mode = wuff;
Counter[0].mode = wuff;
Counter[0].mode = wuff;
}
}
}

View File

@@ -0,0 +1,28 @@
#define private public
#include <PSX/System/IOPorts/interrupt_io.hpp>
#include <PSX/System/syscalls.h>
#include <PSX/Timer/timer.hpp>
#undef private
namespace JabyEngine {
size_t GlobalTime :: global_counter = 0;
namespace Timer {
uint32_t interrupt_verifier() {
const auto irq_status = Interrupt::Status.read();
if(irq_status.is_bit_set(Interrupt::Timer0)) {
return ExecuteHandler;
}
else {
return SkipHandler;
}
}
uint32_t interrupt_handler(uint32_t) {
GlobalTime::global_counter++;
return 0;
}
}
}