all repos — mgba @ fa884d071ecaa3e05ff20b45a67bf9500dd3d6b6

mGBA Game Boy Advance Emulator

include/mgba/core/timing.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 M_CORE_TIMING
 7#define M_CORE_TIMING
 8
 9#include <mgba-util/common.h>
10
11CXX_GUARD_START
12
13struct mTiming;
14struct mTimingEvent {
15	void* context;
16	void (*callback)(struct mTiming*, void* context, uint32_t);
17	const char* name;
18	uint32_t when;
19	unsigned priority;
20
21	struct mTimingEvent* next;
22};
23
24struct mTiming {
25	struct mTimingEvent* root;
26
27	uint32_t masterCycles;
28	int32_t* relativeCycles;
29	int32_t* nextEvent;
30};
31
32void mTimingInit(struct mTiming* timing, int32_t* relativeCycles, int32_t* nextEvent);
33void mTimingDeinit(struct mTiming* timing);
34void mTimingClear(struct mTiming* timing);
35void mTimingSchedule(struct mTiming* timing, struct mTimingEvent*, int32_t when);
36void mTimingDeschedule(struct mTiming* timing, struct mTimingEvent*);
37bool mTimingIsScheduled(const struct mTiming* timing, const struct mTimingEvent*);
38int32_t mTimingTick(struct mTiming* timing, int32_t cycles);
39int32_t mTimingCurrentTime(const struct mTiming* timing);
40int32_t mTimingNextEvent(struct mTiming* timing);
41
42CXX_GUARD_END
43
44#endif