GameBoy Emulator 1
Game Boy emulator core and tooling
Loading...
Searching...
No Matches
timer.hpp
1#pragma once
2
3#include "common.hpp"
4
6
7class Timer {
8public:
9 explicit Timer(InterruptController& ic);
10 ~Timer() = default;
11
12 void step(int cycles);
13 u8 read(u16 address) const;
14 void write(u16 address, u8 value);
15 void reset();
16
17 // Serialization support
18 u16 get_div_counter() const { return div_counter; }
19 u8 get_tima() const { return tima; }
20 u8 get_tma() const { return tma; }
21 u8 get_tac() const { return tac; }
22 int get_tima_counter() const { return tima_counter; }
23
24 void set_div_counter(u16 value) { div_counter = value; }
25 void set_tima(u8 value) { tima = value; }
26 void set_tma(u8 value) { tma = value; }
27 void set_tac(u8 value) { tac = value; }
28 void set_tima_counter(int value) { tima_counter = value; }
29
30private:
32 u16 div_counter = 0;
33 u8 tima = 0;
34 u8 tma = 0;
35 u8 tac = 0;
36 int tima_counter = 0;
37};