vgbc/timer/timer.cpp

25 lines
417 B
C++
Raw Normal View History

2023-09-19 23:20:42 +02:00
#include <timer/timer.h>
void TimerDiv::write8(u16 addr, u8 data)
{
switch(addr) {
case 0x0000: // DIV
divClock.restart();
break;
}
}
u8 TimerDiv::read8(u16 addr)
{
switch(addr) {
case 0x0000: // DIV
{
sf::Time elapsed = divClock.getElapsedTime();
sf::Int64 regval = elapsed.asMicroseconds();
return (regval * 16384 / 1000000) & 0xFF;
}
default:
return 0x00;
}
}