all repos — mgba @ b4fa4fe77e23ed774e749608144fc0d1330b941c

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 GBATimer {
22	uint16_t reload;
23	uint16_t oldReload;
24	uint32_t lastEvent;
25	struct mTimingEvent event;
26	int32_t overflowInterval;
27	GBATimerFlags flags;
28};
29
30struct ARMCore;
31struct GBA;
32void GBATimerInit(struct GBA* gba);
33void GBATimerWriteTMCNT_LO(struct GBATimer* timer, uint16_t reload);
34void GBATimerWriteTMCNT_HI(struct GBATimer* timer, struct mTiming* timing, struct ARMCore* cpu, uint16_t* io, uint16_t control);
35
36void GBATimerUpdateRegister(struct GBA* gba, int timer);
37void GBATimerUpdateRegisterInternal(struct GBATimer* timer, struct mTiming* timing, struct ARMCore* cpu, uint16_t* io, int32_t skew);
38void GBATimerUpdateCountUp(struct mTiming* timing, struct GBATimer* nextTimer, uint16_t* io, uint32_t cyclesLate);
39void GBATimerUpdate(struct mTiming* timing, struct GBATimer* timer, uint16_t* io, uint32_t cyclesLate);
40
41CXX_GUARD_END
42
43#endif