all repos — mgba @ be3e884ba51609b058b0da46c7e8bded3d2a7376

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