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