notaz.gp2x.de
/
ginge.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
wiz blitters, fb restore, tweaks
[ginge.git]
/
prep
/
main.c
diff --git
a/prep/main.c
b/prep/main.c
index
7cc4337
..
a03bc38
100644
(file)
--- a/
prep/main.c
+++ b/
prep/main.c
@@
-16,11
+16,18
@@
#define LOADER_DYNAMIC "ginge_dyn.sh"
#define LAUNCHER "gp2xmenu"
#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;
#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)
{
static char *sskip(char *p)
{
@@
-36,6
+43,16
@@
static char *cskip(char *p)
return 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;
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;
char *p, *pe;
int l;
+ if (!init_done)
+ fb_text_init();
+
if (fb_mem == NULL)
return;
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;
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;
FILE *fin, *fout;
int ret;
- fb_text_init();
-
if (argc < 2) {
err("usage: %s <script|program> [args]\n", argv[0]);
return 1;
}
if (argc < 2) {
err("usage: %s <script|program> [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;
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:
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:
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;
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);
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);
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:
break;
default:
@@
-405,6
+421,10
@@
pass:
fclose(fin);
no_in_script:
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);
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);
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);
system("echo ---; cat /tmp/ginge_conv.sh; echo ---");
chmod(out_script, S_IRWXU|S_IRWXG|S_IRWXO);
chdir(cwd);