X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=ginge.git;a=blobdiff_plain;f=prep%2Fmain.c;h=a03bc38b066fcd39d2978f58adfc5ff6093fff46;hp=7cc4337249ddfbde04b77262b488042135ff72f4;hb=6ca083930098ee075c8f61cf2c04d616349959c3;hpb=3adc9ccb6566130bde29eeaf5c126f28c57c57d5 diff --git a/prep/main.c b/prep/main.c index 7cc4337..a03bc38 100644 --- a/prep/main.c +++ b/prep/main.c @@ -16,11 +16,18 @@ #define LOADER_DYNAMIC "ginge_dyn.sh" #define LAUNCHER "gp2xmenu" +#ifdef PND +#define WRAP_APP "op_runfbapp " +#else +#define WRAP_APP "" +#endif + #include "font.c" static void *fb_mem; static int fb_stride; static int fb_x, fb_y; +static int init_done; static char *sskip(char *p) { @@ -36,6 +43,16 @@ static char *cskip(char *p) return p; } +static void fb_text_init(void) +{ + int ret = host_video_init(&fb_stride, 1); + if (ret == 0) + fb_mem = host_video_flip(); + fb_x = 4; + fb_y = 4; + init_done = 1; +} + static void fb_syms_out(void *fbi, int x, int y, int dotsz, int stride, const char *text, int count) { int v = -1, n = 0, *p; @@ -72,6 +89,9 @@ static void fb_text_out(char *text) char *p, *pe; int l; + if (!init_done) + fb_text_init(); + if (fb_mem == NULL) return; @@ -98,15 +118,6 @@ static void fb_text_out(char *text) } } -static void fb_text_init(void) -{ - int ret = host_video_init(&fb_stride, 1); - if (ret == 0) - fb_mem = host_video_flip(); - fb_x = 4; - fb_y = 4; -} - static void fbprintf(int is_err, const char *format, ...) { va_list ap; @@ -242,13 +253,18 @@ int main(int argc, char *argv[]) FILE *fin, *fout; int ret; - fb_text_init(); - if (argc < 2) { err("usage: %s [args]\n", argv[0]); return 1; } + if (strcmp(argv[1], "--cleanup") == 0) { + // as loader may crash eny time, restore screen for them menu + host_video_init(NULL, 0); + host_video_finish(); + return 0; + } + if (getcwd(cwd, sizeof(cwd)) == NULL) { err(PFX "failed to get cwd\n"); return 1; @@ -281,13 +297,13 @@ int main(int argc, char *argv[]) break; case 1: - fprintf(fout, "op_runfbapp %s%s ", root_path, LOADER_STATIC); + fprintf(fout, WRAP_APP "%s%s ", root_path, LOADER_STATIC); dump_args(fout, argc - 1, &argv[1]); fprintf(fout, "\n"); goto no_in_script; case 2: - fprintf(fout, "op_runfbapp %s%s \"%s\" ", root_path, LOADER_DYNAMIC, root_path); + fprintf(fout, WRAP_APP "%s%s \"%s\" ", root_path, LOADER_DYNAMIC, root_path); dump_args(fout, argc - 1, &argv[1]); fprintf(fout, "\n"); goto no_in_script; @@ -385,12 +401,12 @@ int main(int argc, char *argv[]) switch (ret) { case 1: printf(PFX "prefixing as static: %s", p); - fprintf(fout, "op_runfbapp %s%s ", root_path, LOADER_STATIC); + fprintf(fout, WRAP_APP "%s%s ", root_path, LOADER_STATIC); break; case 2: printf(PFX "prefixing as dynamic: %s", p); - fprintf(fout, "op_runfbapp %s%s \"%s\" ", root_path, LOADER_DYNAMIC, root_path); + fprintf(fout, WRAP_APP "%s%s \"%s\" ", root_path, LOADER_DYNAMIC, root_path); break; default: @@ -405,6 +421,10 @@ pass: fclose(fin); no_in_script: +#ifdef WIZ + fprintf(fout, "sync\n"); + fprintf(fout, "%sginge_prep --cleanup\n", root_path); +#endif if (rerun_gp2xmenu) { fprintf(fout, "cd %s\n", root_path); fprintf(fout, "exec %s%s\n", root_path, LAUNCHER); @@ -412,10 +432,13 @@ no_in_script: fclose(fout); - msg("starting script..\n"); - if (have_cramfs) - msg("\nsome files need to be unpacked, this may tike a few minutes.\n" - "Please wait at least while SD LED is active.\n"); + //msg("starting script..\n"); + if (have_cramfs) { + msg("\nsome files need to be unpacked, this may tike a few minutes.\n"); +#ifdef PND + msg("Please wait at least while SD LED is active.\n"); +#endif + } system("echo ---; cat /tmp/ginge_conv.sh; echo ---"); chmod(out_script, S_IRWXU|S_IRWXG|S_IRWXO); chdir(cwd);