summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--uisimulator/common/io.c31
-rw-r--r--uisimulator/sdl/uisdl.c48
2 files changed, 57 insertions, 22 deletions
diff --git a/uisimulator/common/io.c b/uisimulator/common/io.c
index 1e0c25bad1..fff12a0832 100644
--- a/uisimulator/common/io.c
+++ b/uisimulator/common/io.c
@@ -139,7 +139,9 @@ void dircache_remove(const char *name);
139void dircache_rename(const char *oldpath, const char *newpath); 139void dircache_rename(const char *oldpath, const char *newpath);
140#endif 140#endif
141 141
142#define SIMULATOR_ARCHOS_ROOT "archos" 142
143#define SIMULATOR_DEFAULT_ROOT "archos"
144extern const char *sim_root_dir;
143 145
144static int num_openfiles = 0; 146static int num_openfiles = 0;
145 147
@@ -317,6 +319,13 @@ static void io_trigger_and_wait(int cmd)
317 yield(); 319 yield();
318} 320}
319 321
322static const char *get_sim_rootdir()
323{
324 if (sim_root_dir != NULL)
325 return sim_root_dir;
326 return SIMULATOR_DEFAULT_ROOT;
327}
328
320MYDIR *sim_opendir(const char *name) 329MYDIR *sim_opendir(const char *name)
321{ 330{
322 char buffer[MAX_PATH]; /* sufficiently big */ 331 char buffer[MAX_PATH]; /* sufficiently big */
@@ -325,7 +334,7 @@ MYDIR *sim_opendir(const char *name)
325#ifndef __PCTOOL__ 334#ifndef __PCTOOL__
326 if(name[0] == '/') 335 if(name[0] == '/')
327 { 336 {
328 snprintf(buffer, sizeof(buffer), "%s%s", SIMULATOR_ARCHOS_ROOT, name); 337 snprintf(buffer, sizeof(buffer), "%s%s", get_sim_rootdir(), name);
329 dir=(DIR_T *)OPENDIR(buffer); 338 dir=(DIR_T *)OPENDIR(buffer);
330 } 339 }
331 else 340 else
@@ -360,8 +369,8 @@ struct sim_dirent *sim_readdir(MYDIR *dir)
360#ifdef __PCTOOL__ 369#ifdef __PCTOOL__
361 snprintf(buffer, sizeof(buffer), "%s/%s", dir->name, secret.d_name); 370 snprintf(buffer, sizeof(buffer), "%s/%s", dir->name, secret.d_name);
362#else 371#else
363 snprintf(buffer, sizeof(buffer), SIMULATOR_ARCHOS_ROOT "%s/%s", 372 snprintf(buffer, sizeof(buffer), "%s/%s/%s",
364 dir->name, secret.d_name); 373 get_sim_rootdir(), dir->name, secret.d_name);
365#endif 374#endif
366 STAT(buffer, &s); /* get info */ 375 STAT(buffer, &s); /* get info */
367 376
@@ -400,7 +409,7 @@ int sim_open(const char *name, int o)
400#ifndef __PCTOOL__ 409#ifndef __PCTOOL__
401 if(name[0] == '/') 410 if(name[0] == '/')
402 { 411 {
403 snprintf(buffer, sizeof(buffer), "%s%s", SIMULATOR_ARCHOS_ROOT, name); 412 snprintf(buffer, sizeof(buffer), "%s%s", get_sim_rootdir(), name);
404 413
405 debugf("We open the real file '%s'\n", buffer); 414 debugf("We open the real file '%s'\n", buffer);
406 if (num_openfiles < MAX_OPEN_FILES) 415 if (num_openfiles < MAX_OPEN_FILES)
@@ -438,7 +447,7 @@ int sim_creat(const char *name)
438 char buffer[MAX_PATH]; /* sufficiently big */ 447 char buffer[MAX_PATH]; /* sufficiently big */
439 if(name[0] == '/') 448 if(name[0] == '/')
440 { 449 {
441 snprintf(buffer, sizeof(buffer), "%s%s", SIMULATOR_ARCHOS_ROOT, name); 450 snprintf(buffer, sizeof(buffer), "%s%s", get_sim_rootdir(), name);
442 451
443 debugf("We create the real file '%s'\n", buffer); 452 debugf("We create the real file '%s'\n", buffer);
444 return OPEN(buffer, O_BINARY | O_WRONLY | O_CREAT | O_TRUNC, 0666); 453 return OPEN(buffer, O_BINARY | O_WRONLY | O_CREAT | O_TRUNC, 0666);
@@ -496,7 +505,7 @@ int sim_mkdir(const char *name)
496#else 505#else
497 char buffer[MAX_PATH]; /* sufficiently big */ 506 char buffer[MAX_PATH]; /* sufficiently big */
498 507
499 snprintf(buffer, sizeof(buffer), "%s%s", SIMULATOR_ARCHOS_ROOT, name); 508 snprintf(buffer, sizeof(buffer), "%s%s", get_sim_rootdir(), name);
500 509
501 debugf("We create the real directory '%s'\n", buffer); 510 debugf("We create the real directory '%s'\n", buffer);
502 return MKDIR(buffer, 0777); 511 return MKDIR(buffer, 0777);
@@ -511,7 +520,7 @@ int sim_rmdir(const char *name)
511 char buffer[MAX_PATH]; /* sufficiently big */ 520 char buffer[MAX_PATH]; /* sufficiently big */
512 if(name[0] == '/') 521 if(name[0] == '/')
513 { 522 {
514 snprintf(buffer, sizeof(buffer), "%s%s", SIMULATOR_ARCHOS_ROOT, name); 523 snprintf(buffer, sizeof(buffer), "%s%s", get_sim_rootdir(), name);
515 524
516 debugf("We remove the real directory '%s'\n", buffer); 525 debugf("We remove the real directory '%s'\n", buffer);
517 return RMDIR(buffer); 526 return RMDIR(buffer);
@@ -532,7 +541,7 @@ int sim_remove(const char *name)
532#endif 541#endif
533 542
534 if(name[0] == '/') { 543 if(name[0] == '/') {
535 snprintf(buffer, sizeof(buffer), "%s%s", SIMULATOR_ARCHOS_ROOT, name); 544 snprintf(buffer, sizeof(buffer), "%s%s", get_sim_rootdir(), name);
536 545
537 debugf("We remove the real file '%s'\n", buffer); 546 debugf("We remove the real file '%s'\n", buffer);
538 return REMOVE(buffer); 547 return REMOVE(buffer);
@@ -554,9 +563,9 @@ int sim_rename(const char *oldpath, const char* newpath)
554#endif 563#endif
555 564
556 if(oldpath[0] == '/') { 565 if(oldpath[0] == '/') {
557 snprintf(buffer1, sizeof(buffer1), "%s%s", SIMULATOR_ARCHOS_ROOT, 566 snprintf(buffer1, sizeof(buffer1), "%s%s", get_sim_rootdir(),
558 oldpath); 567 oldpath);
559 snprintf(buffer2, sizeof(buffer2), "%s%s", SIMULATOR_ARCHOS_ROOT, 568 snprintf(buffer2, sizeof(buffer2), "%s%s", get_sim_rootdir(),
560 newpath); 569 newpath);
561 570
562 debugf("We rename the real file '%s' to '%s'\n", buffer1, buffer2); 571 debugf("We rename the real file '%s' to '%s'\n", buffer1, buffer2);
diff --git a/uisimulator/sdl/uisdl.c b/uisimulator/sdl/uisdl.c
index d9c64abce2..15fc1333cb 100644
--- a/uisimulator/sdl/uisdl.c
+++ b/uisimulator/sdl/uisdl.c
@@ -56,6 +56,7 @@ SDL_TimerID tick_timer_id;
56bool lcd_display_redraw = true; /* Used for player simulator */ 56bool lcd_display_redraw = true; /* Used for player simulator */
57char having_new_lcd = true; /* Used for player simulator */ 57char having_new_lcd = true; /* Used for player simulator */
58bool sim_alarm_wakeup = false; 58bool sim_alarm_wakeup = false;
59const char *sim_root_dir = NULL;
59 60
60bool debug_audio = false; 61bool debug_audio = false;
61 62
@@ -195,40 +196,65 @@ bool gui_shutdown(void)
195 196
196int main(int argc, char *argv[]) 197int main(int argc, char *argv[])
197{ 198{
198 if (argc >= 1) { 199 if (argc >= 1)
200 {
199 int x; 201 int x;
200 for (x = 1; x < argc; x++) { 202 for (x = 1; x < argc; x++)
201 if (!strcmp("--debugaudio", argv[x])) { 203 {
204 if (!strcmp("--debugaudio", argv[x]))
205 {
202 debug_audio = true; 206 debug_audio = true;
203 printf("Writing debug audio file.\n"); 207 printf("Writing debug audio file.\n");
204 } else if (!strcmp("--debugwps", argv[x])) { 208 }
209 else if (!strcmp("--debugwps", argv[x]))
210 {
205 debug_wps = true; 211 debug_wps = true;
206 printf("WPS debug mode enabled.\n"); 212 printf("WPS debug mode enabled.\n");
207 } else if (!strcmp("--background", argv[x])) { 213 }
214 else if (!strcmp("--background", argv[x]))
215 {
208 background = true; 216 background = true;
209 printf("Using background image.\n"); 217 printf("Using background image.\n");
210 } else if (!strcmp("--old_lcd", argv[x])) { 218 }
219 else if (!strcmp("--old_lcd", argv[x]))
220 {
211 having_new_lcd = false; 221 having_new_lcd = false;
212 printf("Using old LCD layout.\n"); 222 printf("Using old LCD layout.\n");
213 } else if (!strcmp("--zoom", argv[x])) { 223 }
224 else if (!strcmp("--zoom", argv[x]))
225 {
214 x++; 226 x++;
215 if(x < argc) 227 if(x < argc)
216 display_zoom=atoi(argv[x]); 228 display_zoom=atoi(argv[x]);
217 else 229 else
218 display_zoom = 2; 230 display_zoom = 2;
219 printf("Window zoom is %d\n", display_zoom); 231 printf("Window zoom is %d\n", display_zoom);
220 } else if (!strcmp("--alarm", argv[x])) { 232 }
233 else if (!strcmp("--alarm", argv[x]))
234 {
221 sim_alarm_wakeup = true; 235 sim_alarm_wakeup = true;
222 printf("Simulating alarm wakeup.\n"); 236 printf("Simulating alarm wakeup.\n");
223 } else { 237 }
238 else if (!strcmp("--root", argv[x]))
239 {
240 x++;
241 if (x < argc)
242 {
243 sim_root_dir = argv[x];
244 printf("Root directory: %s\n", sim_root_dir);
245 }
246 }
247 else
248 {
224 printf("rockboxui\n"); 249 printf("rockboxui\n");
225 printf("Arguments:\n"); 250 printf("Arguments:\n");
226 printf(" --debugaudio \t Write raw PCM data to audiodebug.raw\n"); 251 printf(" --debugaudio \t Write raw PCM data to audiodebug.raw\n");
227 printf(" --debugwps \t Print advanced WPS debug info\n"); 252 printf(" --debugwps \t Print advanced WPS debug info\n");
228 printf(" --background \t Use background image of hardware\n"); 253 printf(" --background \t Use background image of hardware\n");
229 printf(" --old_lcd \t [Player] simulate old playermodel (ROM version<4.51)\n"); 254 printf(" --old_lcd \t [Player] simulate old playermodel (ROM version<4.51)\n");
230 printf(" --zoom [VAL]\t window zoom (will disable backgrounds)\n"); 255 printf(" --zoom [VAL]\t Window zoom (will disable backgrounds)\n");
231 printf(" --alarm \t Simulate a wakup-up on Alarm\n"); 256 printf(" --alarm \t Simulate a wake-up on alarm\n");
257 printf(" --root [DIR]\t Set root directory\n");
232 exit(0); 258 exit(0);
233 } 259 }
234 } 260 }