all repos — mgba @ e649be94f5399a7c29d023fbdb0b336834fc9860

mGBA Game Boy Advance Emulator

src/ds/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 DS_TIMER_H
 7#define DS_TIMER_H
 8
 9#include "util/common.h"
10
11DECL_BITFIELD(DSTimerFlags, uint32_t);
12DECL_BITS(DSTimerFlags, PrescaleBits, 0, 4);
13DECL_BIT(DSTimerFlags, CountUp, 4);
14DECL_BIT(DSTimerFlags, DoIrq, 5);
15DECL_BIT(DSTimerFlags, Enable, 6);
16
17struct DSTimer {
18	uint16_t reload;
19	uint16_t oldReload;
20	int32_t lastEvent;
21	int32_t nextEvent;
22	int32_t overflowInterval;
23	DSTimerFlags flags;
24};
25
26// TODO: Merge back into GBATimer
27struct ARMCore;
28void DSTimerUpdateRegister(struct DSTimer* timer, struct ARMCore* cpu, uint16_t* io);
29void DSTimerWriteTMCNT_LO(struct DSTimer* timer, uint16_t reload);
30void DSTimerWriteTMCNT_HI(struct DSTimer* timer, struct ARMCore* cpu, uint16_t* io, uint16_t control);
31
32struct DS;
33int32_t DSTimersProcessEvents(struct DS* ds, int32_t cycles);
34#endif