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" |
b7b2fb41 | 19 | |
b7b2fb41 B |
20 | // sound plugin |
21 | extern int iUseReverb; | |
22 | extern int iUseInterpolation; | |
b7b2fb41 B |
23 | extern int iSPUIRQWait; |
24 | extern int iUseTimer; | |
25 | ||
76f7048e | 26 | int g_opts = OPT_SHOWFPS; |
27 | ||
54b4a001 | 28 | enum sched_action emu_action; |
29 | void do_emu_action(void); | |
bbd471af | 30 | char* file_name; |
54b4a001 | 31 | |
b7b2fb41 B |
32 | static void ChangeWorkingDirectory(char *exe) |
33 | { | |
54b4a001 | 34 | char exepath[1024]; |
35 | char *s; | |
36 | snprintf(exepath, sizeof(exepath), "%s", exe); | |
b7b2fb41 B |
37 | s = strrchr(exepath, '/'); |
38 | if (s != NULL) { | |
39 | *s = '\0'; | |
40 | chdir(exepath); | |
41 | } | |
42 | } | |
43 | ||
e0c692d9 | 44 | int maemo_main(int argc, char **argv) |
b7b2fb41 B |
45 | { |
46 | ChangeWorkingDirectory("c"); | |
47 | char file[MAXPATHLEN] = ""; | |
48 | char path[MAXPATHLEN]; | |
49 | const char *cdfile = NULL; | |
50 | int loadst = 0; | |
b7b2fb41 B |
51 | int i; |
52 | ||
b7b2fb41 | 53 | strcpy(Config.BiosDir, "/home/user/MyDocs"); |
b7b2fb41 | 54 | strcpy(Config.PluginsDir, "/opt/maemo/usr/games/plugins"); |
e0c692d9 | 55 | snprintf(Config.PatchesDir, sizeof(Config.PatchesDir), "/opt/maemo/usr/games" PATCHES_DIR); |
56 | Config.PsxAuto = 1; | |
b7b2fb41 B |
57 | |
58 | // read command line options | |
59 | for (i = 1; i < argc; i++) { | |
60 | if (!strcmp(argv[i], "-psxout")) Config.PsxOut = 1; | |
61 | else if (!strcmp(argv[i], "-load")) loadst = atol(argv[++i]); | |
62 | else if (!strcmp(argv[i], "-cdfile")) { | |
63 | char isofilename[MAXPATHLEN]; | |
b7b2fb41 B |
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 | } | |
b7b2fb41 B |
75 | cdfile = isofilename; |
76 | } | |
76f7048e | 77 | else if (!strcmp(argv[i],"-frameskip")) { |
76f7048e | 78 | int tv_reg = atol(argv[++i]); |
79 | if (tv_reg > 0) | |
bbd471af | 80 | pl_rearmed_cbs.frameskip = -1; |
b7b2fb41 | 81 | } |
bbd471af B |
82 | else if (!strcmp(argv[i],"-fullscreen")) g_opts |= 2; |
83 | else if (!strcmp(argv[i],"-accel")) g_opts |= 4; | |
84 | else if (!strcmp(argv[i],"-sputhreaded")) iUseTimer=1; | |
85 | else if (!strcmp(argv[i],"-nosound")) strcpy(Config.Spu, "spunull.so"); | |
86 | /* unworking with r10 | |
87 | else if(!strcmp(argv[i], "-bdir")) sprintf(Config.BiosDir, "%s", argv[++i]); | |
88 | else if(!strcmp(argv[i], "-bios")) sprintf(Config.Bios, "%s", argv[++i]); | |
89 | else if (!strcmp(argv[i],"-gles")) strcpy(Config.Gpu, "gpuGLES.so"); | |
90 | */ | |
b7b2fb41 B |
91 | else if (!strcmp(argv[i], "-cdda")) Config.Cdda = 1; |
92 | else if (!strcmp(argv[i], "-xa")) Config.Xa = 1; | |
93 | else if (!strcmp(argv[i], "-rcnt")) Config.RCntFix = 1 ; | |
94 | else if (!strcmp(argv[i], "-sio")) Config.Sio = 1; | |
95 | else if (!strcmp(argv[i], "-spuirq")) Config.SpuIrq = 1; | |
96 | else if (!strcmp(argv[i], "-vsync")) Config.VSyncWA = 1; | |
b7b2fb41 B |
97 | } |
98 | ||
76f7048e | 99 | pl_rearmed_cbs.gpu_peops.dwActFixes = 1<<7; |
100 | iUseReverb = 2; | |
101 | iUseInterpolation = 1; | |
102 | iSPUIRQWait = 1; | |
103 | iUseTimer = 2; | |
104 | ||
105 | in_type1 = PSE_PAD_TYPE_STANDARD; | |
106 | in_type2 = PSE_PAD_TYPE_STANDARD; | |
107 | ||
b7b2fb41 B |
108 | hildon_init(&argc, &argv); |
109 | ||
bbd471af B |
110 | char f_name[MAXPATHLEN]; |
111 | strcpy(f_name, strrchr(cdfile,'/')); | |
112 | file_name=f_name; | |
113 | ||
b7b2fb41 B |
114 | if (cdfile) |
115 | set_cd_image(cdfile); | |
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 B |
155 | if (ready_to_go) |
156 | maemo_init(); | |
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 |