25 lines
417 B
C++
25 lines
417 B
C++
|
#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;
|
||
|
}
|
||
|
}
|