summaryrefslogtreecommitdiff
path: root/uuu-sdl.c
blob: b15ab75df1e3e7c188afc01bc10eaacfe6c16bf3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright 2008,2009  Segher Boessenkool  <segher@kernel.crashing.org>
// Licensed under the terms of the GNU GPL, version 2
// http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt

#include <stdio.h>
#include <string.h>
#include <time.h>

// We need to include this here, since it redefines main().
#include <SDL.h>

#include "types.h"
#include "platform.h"
#include "emu.h"
#include "dialog.h"


#ifdef __APPLE__
void CGSSetConnectionProperty(int, int, int, int);
int _CGSDefaultConnection();
int CGSCreateCString(char *);
int CGSCreateBoolean(unsigned char);
void CGSReleaseObj(int);
#endif


int main(int argc, char *argv[])
{
#ifdef __APPLE__
	if (argc == 1) {
		const char *path = dialog_rom_file();
		if (!path)
			return 0;
		open_rom(path);
	}
#else
	if (0)
		;
#endif
	else {
		if (argc != 2)
			fatal("usage: %s <rom-file>\n", argv[0]);

		open_rom(argv[1]);
	}

#ifdef __APPLE__
	// Hack to speed up display refresh
	int propertyString = CGSCreateCString("DisableDeferredUpdates");
	int cid = _CGSDefaultConnection();
	CGSSetConnectionProperty(cid, cid, propertyString, CGSCreateBoolean(1));
	CGSReleaseObj(propertyString);
#endif

	srandom(time(0));

	emu();

	return 0;
}