Sketch Timer and implement Interrupt support
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
28
src/Library/src/Timer/timer.cpp
Normal file
28
src/Library/src/Timer/timer.cpp
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user