aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
blob: 2e9fffc77b7f83e03867adc5c98d01147cbc9dd8 (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "PHL.h"
#include "game.h"
#include <stdlib.h>
#include <time.h>
#include <sys/stat.h>

void createSaveLocations()
{	
	//Force create save data folders	
	#ifdef _3DS
		//3DS builds
		mkdir("sdmc:/3ds", 0777);
		mkdir("sdmc:/3ds/appdata", 0777);
		mkdir("sdmc:/3ds/appdata/HydraCastleLabyrinth", 0777);
		mkdir("sdmc:/3ds/appdata/HydraCastleLabyrinth/data", 0777);
		mkdir("sdmc:/3ds/appdata/HydraCastleLabyrinth/map", 0777);
	#elif defined(_SDL)
		char buff[4096];
		strcpy(buff, getenv("HOME"));
		strcat(buff, "/.hydracastlelabyrinth");
		// if exist first?
		struct stat sb;
		if(!(stat(buff, &sb)==0 && S_ISDIR(sb.st_mode)))
			mkdir(buff, 0777);

	#else
		//psp, wii
		mkdir("/data", 0777);
		mkdir("/map", 0777);
	#endif
}


int main(int argc, char **argv)
{	
	//Setup
	#ifdef _3DS
		sdmcInit();
		osSetSpeedupEnable(false);
	#endif
	#ifdef _SDL
	#ifdef PANDORA
	wantFullscreen = 1;
	#else
	wantFullscreen = 0;
	#endif
	screenScale = 2;
	// get command line arguments
	for (int i=1; i<argc; i++)
	{
		if(!strcmp(argv[i], "-f"))
			wantFullscreen = 1;
		if(!strcmp(argv[i], "--fullscreen"))
			wantFullscreen = 1;
		if(!strcmp(argv[i], "-x1"))
			screenScale = 1;
		if(!strcmp(argv[i], "-x2"))
			screenScale = 2;
		if(!strcmp(argv[i], "-x3"))
			screenScale = 3;
		if(!strcmp(argv[i], "-x4"))
			screenScale = 4;
	}
	printf("Hydra Caslte Labyrinth, %s scale=x%d\n", wantFullscreen?"Fullscreen":"Windowed", screenScale);
	#endif
	
	srand(time(NULL));
	createSaveLocations();
	
	game();

	//System specific cleanup	
	#ifdef _PSP
		sceKernelExitGame();
	#endif
	
	#ifdef _3DS
		sdmcExit();
	#endif

	return 0;
}