all repos — mgba @ 903ea6bc195855b298365870d348aec3d2bdc162

mGBA Game Boy Advance Emulator

src/core/interface.c (view raw)

 1/* Copyright (c) 2013-2015 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#include <mgba/core/interface.h>
 7
 8#include <mgba/core/core.h>
 9
10DEFINE_VECTOR(mCoreCallbacksList, struct mCoreCallbacks);
11
12static time_t _rtcGenericCallback(struct mRTCSource* source) {
13	struct mRTCGenericSource* rtc = (struct mRTCGenericSource*) source;
14	switch (rtc->override) {
15	case RTC_NO_OVERRIDE:
16	default:
17		return time(0);
18	case RTC_FIXED:
19		return rtc->value;
20	case RTC_FAKE_EPOCH:
21		return rtc->value + rtc->p->frameCounter(rtc->p) * (int64_t) rtc->p->frameCycles(rtc->p) / rtc->p->frequency(rtc->p);
22	}
23}
24
25void mRTCGenericSourceInit(struct mRTCGenericSource* rtc, struct mCore* core) {
26	rtc->p = core;
27	rtc->override = RTC_NO_OVERRIDE;
28	rtc->value = 0;
29	rtc->d.sample = 0;
30	rtc->d.unixTime = _rtcGenericCallback;
31}