예제 #1
0
void applyArguments(const struct mArguments* args, struct mSubParser* subparser, struct mCoreConfig* config) {
	if (args->frameskip >= 0) {
		mCoreConfigSetOverrideIntValue(config, "frameskip", args->frameskip);
	}
	if (args->logLevel > INT_MIN) {
		mCoreConfigSetOverrideIntValue(config, "logLevel", args->logLevel);
	}
	if (args->bios) {
		mCoreConfigSetOverrideValue(config, "bios", args->bios);
	}
	if (subparser) {
		subparser->apply(subparser, config);
	}
}
예제 #2
0
파일: perf-main.c 프로젝트: leiradel/mgba
bool _mPerfRunCore(const char* fname, const struct mArguments* args, const struct PerfOpts* perfOpts) {
	struct mCore* core = mCoreFind(fname);
	if (!core) {
		return false;
	}

	// TODO: Put back debugger
	char gameCode[9] = { 0 };

	core->init(core);
	if (!perfOpts->noVideo) {
		core->setVideoBuffer(core, _outputBuffer, 256);
	}
	mCoreLoadFile(core, fname);
	mCoreConfigInit(&core->config, "perf");
	mCoreConfigLoad(&core->config);

	if (perfOpts->threadedVideo) {
		mCoreConfigSetOverrideIntValue(&core->config, "threadedVideo", 1);
	} else {
		mCoreConfigSetOverrideIntValue(&core->config, "threadedVideo", 0);
	}

	struct mCoreOptions opts = {};
	mCoreConfigMap(&core->config, &opts);
	opts.audioSync = false;
	opts.videoSync = false;
	applyArguments(args, NULL, &core->config);
	mCoreConfigLoadDefaults(&core->config, &opts);
	mCoreConfigSetDefaultValue(&core->config, "idleOptimization", "detect");
	mCoreLoadConfig(core);

	core->reset(core);
	if (_savestate) {
		mCoreLoadStateNamed(core, _savestate, 0);
	}

	core->getGameCode(core, gameCode);

	int frames = perfOpts->frames;
	if (!frames) {
		frames = perfOpts->duration * 60;
	}
	struct timeval tv;
	gettimeofday(&tv, 0);
	uint64_t start = 1000000LL * tv.tv_sec + tv.tv_usec;
	_mPerfRunloop(core, &frames, perfOpts->csv);
	gettimeofday(&tv, 0);
	uint64_t end = 1000000LL * tv.tv_sec + tv.tv_usec;
	uint64_t duration = end - start;

	mCoreConfigFreeOpts(&opts);
	mCoreConfigDeinit(&core->config);
	core->deinit(core);

	float scaledFrames = frames * 1000000.f;
	if (perfOpts->csv) {
		char buffer[256];
		const char* rendererName;
		if (perfOpts->noVideo) {
			rendererName = "none";
		} else if (perfOpts->threadedVideo) {
			rendererName = "threaded-software";
		} else {
			rendererName = "software";
		}
		snprintf(buffer, sizeof(buffer), "%s,%i,%" PRIu64 ",%s\n", gameCode, frames, duration, rendererName);
		printf("%s", buffer);
		if (_socket != INVALID_SOCKET) {
			SocketSend(_socket, buffer, strlen(buffer));
		}
	} else {
		printf("%u frames in %" PRIu64 " microseconds: %g fps (%gx)\n", frames, duration, scaledFrames / duration, scaledFrames / (duration * 60.f));
	}

	return true;
}
예제 #3
0
void _applyGraphicsArgs(struct mSubParser* parser, struct mCoreConfig* config) {
	struct mGraphicsOpts* graphicsOpts = parser->opts;
	mCoreConfigSetOverrideIntValue(config, "fullscreen", graphicsOpts->fullscreen);
}