gpu_neon: partially support range regs
[pcsx_rearmed.git] / maemo / main.c
... / ...
CommitLineData
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 <stdint.h>
11#include <unistd.h>
12
13#include "main.h"
14#include "menu.h"
15#include "plugin.h"
16#include "plugin_lib.h"
17#include "../libpcsxcore/misc.h"
18#include "../libpcsxcore/new_dynarec/new_dynarec.h"
19
20// sound plugin
21extern int iUseReverb;
22extern int iUseInterpolation;
23extern int iSPUIRQWait;
24extern int iUseTimer;
25
26int g_opts = OPT_SHOWFPS;
27
28enum sched_action emu_action;
29void do_emu_action(void);
30
31static void ChangeWorkingDirectory(char *exe)
32{
33 char exepath[1024];
34 char *s;
35 snprintf(exepath, sizeof(exepath), "%s", exe);
36 s = strrchr(exepath, '/');
37 if (s != NULL) {
38 *s = '\0';
39 chdir(exepath);
40 }
41}
42
43int maemo_main(int argc, char **argv)
44{
45 ChangeWorkingDirectory("c");
46 char file[MAXPATHLEN] = "";
47 char path[MAXPATHLEN];
48 const char *cdfile = NULL;
49 int loadst = 0;
50 int i;
51
52 strcpy(Config.BiosDir, "/home/user/MyDocs");
53 strcpy(Config.PluginsDir, "/opt/maemo/usr/games/plugins");
54 snprintf(Config.PatchesDir, sizeof(Config.PatchesDir), "/opt/maemo/usr/games" PATCHES_DIR);
55 Config.PsxAuto = 1;
56
57 // read command line options
58 for (i = 1; i < argc; i++) {
59 if (!strcmp(argv[i], "-psxout")) Config.PsxOut = 1;
60 else if (!strcmp(argv[i], "-load")) loadst = atol(argv[++i]);
61 else if (!strcmp(argv[i], "-cdfile")) {
62 char isofilename[MAXPATHLEN];
63
64 if (i+1 >= argc) break;
65 strncpy(isofilename, argv[++i], MAXPATHLEN);
66 if (isofilename[0] != '/') {
67 getcwd(path, MAXPATHLEN);
68 if (strlen(path) + strlen(isofilename) + 1 < MAXPATHLEN) {
69 strcat(path, "/");
70 strcat(path, isofilename);
71 strcpy(isofilename, path);
72 } else
73 isofilename[0] = 0;
74 }
75
76 cdfile = isofilename;
77 }
78 else if (!strcmp(argv[i],"-frameskip")) {
79
80 int tv_reg = atol(argv[++i]);
81 if (tv_reg > 0)
82 pl_rearmed_cbs.frameskip = 1;
83 }
84 else if (!strcmp(argv[i],"-sputhreaded")) {
85 iUseTimer=1;
86 }
87 else if (!strcmp(argv[i],"-nosound")) {
88 strcpy(Config.Spu, "spunull.so");
89 }
90 else if(!strcmp(argv[i], "-bdir")) sprintf(Config.BiosDir, "%s", argv[++i]);
91 else if(!strcmp(argv[i], "-bios")) sprintf(Config.Bios, "%s", argv[++i]);
92 else if (!strcmp(argv[i],"-gles")){
93 strcpy(Config.Gpu, "gpuGLES.so");
94 }
95 else if (!strcmp(argv[i], "-cdda")) Config.Cdda = 1;
96 else if (!strcmp(argv[i], "-xa")) Config.Xa = 1;
97 else if (!strcmp(argv[i], "-rcnt")) Config.RCntFix = 1 ;
98 else if (!strcmp(argv[i], "-sio")) Config.Sio = 1;
99 else if (!strcmp(argv[i], "-spuirq")) Config.SpuIrq = 1;
100 else if (!strcmp(argv[i], "-vsync")) Config.VSyncWA = 1;
101 else if (!strcmp(argv[i], "-h") ||
102 !strcmp(argv[i], "-help") ||
103 !strcmp(argv[i], "--help")) {
104 printf(PACKAGE_NAME " " PACKAGE_VERSION "\n");
105 printf("%s\n", _(
106 " pcsx [options] [file]\n"
107 "\toptions:\n"
108 "\t-cdfile FILE\tRuns a CD image file\n"
109 "\t-psxout\t\tEnable PSX output\n"
110 "\t-nosound\t\tDisable sound using spunull plugin\n"
111 "\t-sputhreaded\t\tMove sound to separate thread\n"
112 "\t-frameskip\t\tEnable frameskip\n"
113 "\t-load STATENUM\tLoads savestate STATENUM (1-5)\n"
114 "\t-h -help\tDisplay this message\n"
115 "\tfile\t\tLoads file\n"));
116 return 0;
117 } else {
118 strncpy(file, argv[i], MAXPATHLEN);
119 if (file[0] != '/') {
120 getcwd(path, MAXPATHLEN);
121 if (strlen(path) + strlen(file) + 1 < MAXPATHLEN) {
122 strcat(path, "/");
123 strcat(path, file);
124 strcpy(file, path);
125 } else
126 file[0] = 0;
127 }
128 }
129 }
130
131 pl_rearmed_cbs.gpu_peops.dwActFixes = 1<<7;
132 iUseReverb = 2;
133 iUseInterpolation = 1;
134 iSPUIRQWait = 1;
135 iUseTimer = 2;
136
137 in_type1 = PSE_PAD_TYPE_STANDARD;
138 in_type2 = PSE_PAD_TYPE_STANDARD;
139
140 hildon_init(&argc, &argv);
141
142 if (cdfile)
143 set_cd_image(cdfile);
144
145 if (SysInit() == -1)
146 return 1;
147
148 pl_init();
149
150 if (LoadPlugins() == -1) {
151 SysMessage("Failed loading plugins!");
152 return 1;
153 }
154
155 if (OpenPlugins() == -1) {
156 return 1;
157 }
158 plugin_call_rearmed_cbs();
159
160 CheckCdrom();
161 SysReset();
162
163 if (file[0] != '\0') {
164 if (Load(file) != -1)
165 ready_to_go = 1;
166 } else {
167 if (cdfile) {
168 if (LoadCdrom() == -1) {
169 ClosePlugins();
170 printf(_("Could not load CD-ROM!\n"));
171 return -1;
172 }
173 ready_to_go = 1;
174 }
175 }
176
177 // If a state has been specified, then load that
178 if (loadst) {
179 int ret = emu_load_state(loadst - 1);
180 printf("%s state %d\n", ret ? "failed to load" : "loaded", loadst);
181 }
182
183 if (ready_to_go)
184 maemo_init();
185 else
186 {
187 printf ("somethings goes wrong, maybe you forgot -cdfile ? \n");
188 return 0;
189 }
190
191 pl_timing_prepare(Config.PsxType);
192
193 while (1)
194 {
195 stop = 0;
196 emu_action = SACTION_NONE;
197
198 psxCpu->Execute();
199 if (emu_action != SACTION_NONE)
200 do_emu_action();
201 }
202
203 return 0;
204}
205