all repos — mgba @ bbb74a47a1fe69870c651c93ed31337d52243535

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);
20DECL_BIT(GBATimerFlags, IrqPending, 7);
21
22struct GBA;
23struct GBATimer {
24	uint16_t reload;
25	int32_t lastEvent;
26	struct mTimingEvent event;
27	struct mTimingEvent irq;
28	GBATimerFlags flags;
29};
30
31void GBATimerInit(struct GBA* gba);
32void GBATimerUpdateRegister(struct GBA* gba, int timer, int32_t cyclesLate);
33void GBATimerWriteTMCNT_LO(struct GBA* gba, int timer, uint16_t value);
34void GBATimerWriteTMCNT_HI(struct GBA* gba, int timer, uint16_t value);
35
36CXX_GUARD_END
37
38#endif