all repos — mgba @ f6a4a13b60ae30fa74ee33422e2d951b6c0a3348

mGBA Game Boy Advance Emulator

include/mgba/internal/gba/timer.h (view raw)

 1/* Copyright (c) 2013-2016 Jeffrey Pfau
 2 *
 3 * This Source Code Form is subject to the terms of the Mozilla Public
 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 6#ifndef GBA_TIMER_H
 7#define GBA_TIMER_H
 8
 9#include <mgba-util/common.h>
10
11CXX_GUARD_START
12
13#include <mgba/core/timing.h>
14
15DECL_BITFIELD(GBATimerFlags, uint32_t);
16DECL_BITS(GBATimerFlags, PrescaleBits, 0, 4);
17DECL_BIT(GBATimerFlags, CountUp, 4);
18DECL_BIT(GBATimerFlags, DoIrq, 5);
19DECL_BIT(GBATimerFlags, Enable, 6);
20
21struct GBA;
22struct GBATimer {
23	uint16_t reload;
24	int32_t lastEvent;
25	struct mTimingEvent event;
26	GBATimerFlags flags;
27};
28
29void GBATimerInit(struct GBA* gba);
30void GBATimerUpdateRegister(struct GBA* gba, int timer, int32_t cyclesLate);
31void GBATimerWriteTMCNT_LO(struct GBA* gba, int timer, uint16_t value);
32void GBATimerWriteTMCNT_HI(struct GBA* gba, int timer, uint16_t value);
33
34CXX_GUARD_END
35
36#endif