all repos — mgba @ 9aa6d8fe3c299c0e6690b61439dff6c235df8846

mGBA Game Boy Advance Emulator

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