Commit | Line | Data |
---|---|---|
b7b2fb41 B |
1 | /* |
2 | * (C) notaz, 2010-2011 | |
3 | * | |
4 | * This work is licensed under the terms of the GNU GPLv2 or later. | |
5 | * See the COPYING file in the top-level directory. | |
6 | */ | |
7 | ||
8 | #include <stdio.h> | |
9 | #include <string.h> | |
10 | #include <stdarg.h> | |
11 | #include <dlfcn.h> | |
12 | #include <sys/stat.h> | |
13 | #include <sys/types.h> | |
14 | #include <unistd.h> | |
15 | #include <signal.h> | |
16 | ||
17 | #include "main.h" | |
18 | #include "plugin.h" | |
b7b2fb41 B |
19 | #include "../libpcsxcore/misc.h" |
20 | #include "../plugins/cdrcimg/cdrcimg.h" | |
b7b2fb41 B |
21 | |
22 | // from softgpu plugin | |
23 | extern int iUseDither; | |
24 | extern int UseFrameSkip; | |
25 | extern int UseFrameLimit; | |
26 | extern uint32_t dwActFixes; | |
27 | extern float fFrameRateHz; | |
28 | extern int dwFrameRateTicks; | |
29 | ||
30 | // sound plugin | |
31 | extern int iUseReverb; | |
32 | extern int iUseInterpolation; | |
33 | extern int iXAPitch; | |
34 | extern int iSPUIRQWait; | |
35 | extern int iUseTimer; | |
36 | ||
37 | static void ChangeWorkingDirectory(char *exe) | |
38 | { | |
e0c692d9 | 39 | s8 exepath[1024]; |
40 | s8* s; | |
41 | sprintf(exepath, "%s", exe); | |
b7b2fb41 B |
42 | s = strrchr(exepath, '/'); |
43 | if (s != NULL) { | |
44 | *s = '\0'; | |
45 | chdir(exepath); | |
46 | } | |
47 | } | |
48 | ||
e0c692d9 | 49 | int maemo_main(int argc, char **argv) |
b7b2fb41 B |
50 | { |
51 | ChangeWorkingDirectory("c"); | |
52 | char file[MAXPATHLEN] = ""; | |
53 | char path[MAXPATHLEN]; | |
54 | const char *cdfile = NULL; | |
55 | int loadst = 0; | |
56 | void *tmp; | |
57 | int i; | |
58 | ||
b7b2fb41 | 59 | strcpy(Config.BiosDir, "/home/user/MyDocs"); |
b7b2fb41 | 60 | strcpy(Config.PluginsDir, "/opt/maemo/usr/games/plugins"); |
e0c692d9 | 61 | snprintf(Config.PatchesDir, sizeof(Config.PatchesDir), "/opt/maemo/usr/games" PATCHES_DIR); |
62 | Config.PsxAuto = 1; | |
b7b2fb41 B |
63 | |
64 | // read command line options | |
65 | for (i = 1; i < argc; i++) { | |
66 | if (!strcmp(argv[i], "-psxout")) Config.PsxOut = 1; | |
67 | else if (!strcmp(argv[i], "-load")) loadst = atol(argv[++i]); | |
68 | else if (!strcmp(argv[i], "-cdfile")) { | |
69 | char isofilename[MAXPATHLEN]; | |
70 | ||
71 | if (i+1 >= argc) break; | |
72 | strncpy(isofilename, argv[++i], MAXPATHLEN); | |
73 | if (isofilename[0] != '/') { | |
74 | getcwd(path, MAXPATHLEN); | |
75 | if (strlen(path) + strlen(isofilename) + 1 < MAXPATHLEN) { | |
76 | strcat(path, "/"); | |
77 | strcat(path, isofilename); | |
78 | strcpy(isofilename, path); | |
79 | } else | |
80 | isofilename[0] = 0; | |
81 | } | |
82 | ||
83 | cdfile = isofilename; | |
84 | } | |
85 | else if (!strcmp(argv[i],"-frameskip")){ | |
86 | ||
87 | int tv_reg=atol(argv[++i]); | |
88 | if (tv_reg>0){ | |
89 | UseFrameSkip=1; | |
90 | fFrameRateHz = (tv_reg==1)?50.0f: 59.94f; | |
91 | dwFrameRateTicks = (100000*100 / (unsigned long)(fFrameRateHz*100)); | |
92 | } | |
93 | } | |
94 | else if (!strcmp(argv[i],"-sputhreaded")){ | |
95 | iUseTimer=1; | |
96 | } | |
97 | else if (!strcmp(argv[i],"-nosound")){ | |
98 | strcpy(Config.Spu, "spunull.so"); | |
99 | } | |
100 | else if(!strcmp(argv[i], "-bdir")) sprintf(Config.BiosDir, "%s", argv[++i]); | |
101 | else if(!strcmp(argv[i], "-bios")) sprintf(Config.Bios, "%s", argv[++i]); | |
102 | else if (!strcmp(argv[i],"-gles")){ | |
103 | strcpy(Config.Gpu, "gpuGLES.so"); | |
104 | } | |
105 | else if (!strcmp(argv[i], "-cdda")) Config.Cdda = 1; | |
106 | else if (!strcmp(argv[i], "-xa")) Config.Xa = 1; | |
107 | else if (!strcmp(argv[i], "-rcnt")) Config.RCntFix = 1 ; | |
108 | else if (!strcmp(argv[i], "-sio")) Config.Sio = 1; | |
109 | else if (!strcmp(argv[i], "-spuirq")) Config.SpuIrq = 1; | |
110 | else if (!strcmp(argv[i], "-vsync")) Config.VSyncWA = 1; | |
111 | else if (!strcmp(argv[i], "-h") || | |
112 | !strcmp(argv[i], "-help") || | |
113 | !strcmp(argv[i], "--help")) { | |
114 | printf(PACKAGE_NAME " " PACKAGE_VERSION "\n"); | |
115 | printf("%s\n", _( | |
116 | " pcsx [options] [file]\n" | |
117 | "\toptions:\n" | |
118 | "\t-cdfile FILE\tRuns a CD image file\n" | |
119 | "\t-psxout\t\tEnable PSX output\n" | |
120 | "\t-nosound\t\tDisable sound using spunull plugin\n" | |
121 | "\t-sputhreaded\t\tMove sound to separate thread\n" | |
122 | "\t-frameskip\t\tEnable frameskip\n" | |
123 | "\t-load STATENUM\tLoads savestate STATENUM (1-5)\n" | |
124 | "\t-h -help\tDisplay this message\n" | |
125 | "\tfile\t\tLoads file\n")); | |
126 | return 0; | |
127 | } else { | |
128 | strncpy(file, argv[i], MAXPATHLEN); | |
129 | if (file[0] != '/') { | |
130 | getcwd(path, MAXPATHLEN); | |
131 | if (strlen(path) + strlen(file) + 1 < MAXPATHLEN) { | |
132 | strcat(path, "/"); | |
133 | strcat(path, file); | |
134 | strcpy(file, path); | |
135 | } else | |
136 | file[0] = 0; | |
137 | } | |
138 | } | |
139 | } | |
140 | ||
b7b2fb41 B |
141 | hildon_init(&argc, &argv); |
142 | ||
143 | if (cdfile) | |
144 | set_cd_image(cdfile); | |
145 | ||
146 | if (SysInit() == -1) | |
147 | return 1; | |
148 | ||
b7b2fb41 B |
149 | if (LoadPlugins() == -1) { |
150 | SysMessage("Failed loading plugins!"); | |
151 | return 1; | |
152 | } | |
b7b2fb41 B |
153 | |
154 | if (OpenPlugins() == -1) { | |
155 | return 1; | |
156 | } | |
157 | plugin_call_rearmed_cbs(); | |
158 | ||
159 | CheckCdrom(); | |
160 | SysReset(); | |
161 | ||
162 | if (file[0] != '\0') { | |
163 | if (Load(file) != -1) | |
164 | ready_to_go = 1; | |
165 | } else { | |
166 | if (cdfile) { | |
167 | if (LoadCdrom() == -1) { | |
168 | ClosePlugins(); | |
169 | printf(_("Could not load CD-ROM!\n")); | |
170 | return -1; | |
171 | } | |
172 | ready_to_go = 1; | |
173 | } | |
174 | } | |
175 | ||
176 | // If a state has been specified, then load that | |
177 | if (loadst) { | |
178 | char state_filename[MAXPATHLEN]; | |
179 | int ret = get_state_filename(state_filename, sizeof(state_filename), loadst - 1); | |
180 | if (ret == 0) | |
181 | ret = LoadState(state_filename); | |
182 | printf("%s state %s\n", ret ? "failed to load" : "loaded", state_filename); | |
183 | } | |
184 | ||
b7b2fb41 B |
185 | if (ready_to_go) |
186 | maemo_init(); | |
187 | else | |
188 | { | |
e0c692d9 | 189 | printf ("somethings goes wrong, maybe you forgot -cdfile ? \n"); |
190 | return 0; | |
b7b2fb41 B |
191 | } |
192 | ||
e0c692d9 | 193 | psxCpu->Execute(); |
b7b2fb41 B |
194 | |
195 | return 0; | |
196 | } | |
197 |