From: notaz Date: Thu, 23 Aug 2007 13:24:11 +0000 (+0000) Subject: ROM load progress bar X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b9f8cb3d6d8d0b5965fab83a27fc356a56442ddb;p=libpicofe.git ROM load progress bar git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@224 be3aeb3a-fb24-0410-a615-afba39da0efa --- diff --git a/gp2x/Makefile b/gp2x/Makefile index d9c40bb..489d62f 100644 --- a/gp2x/Makefile +++ b/gp2x/Makefile @@ -210,7 +210,7 @@ $(error need VER) endif endif -rel: PicoDrive.gpe code940/code940.bin ../readme.txt config.txt PicoDrive.man.txt PicoDrive.png +rel: PicoDrive.gpe code940/pico940.bin ../readme.txt config.txt PicoDrive.man.txt PicoDrive.png zip -9 -j ../../PicoDrive_$(VER).zip $^ mmuhack.o code940/code940.bin: diff --git a/gp2x/emu.c b/gp2x/emu.c index cb924c3..bfbc0c1 100644 --- a/gp2x/emu.c +++ b/gp2x/emu.c @@ -287,6 +287,8 @@ int emu_ReloadRom(void) return 0; } + menu_romload_prepare(used_rom_name); + if(rom_data) { free(rom_data); rom_data = 0; @@ -297,9 +299,11 @@ int emu_ReloadRom(void) sprintf(menuErrorMsg, "PicoCartLoad() failed."); printf("%s\n", menuErrorMsg); pm_close(rom); + menu_romload_end(); return 0; } pm_close(rom); + menu_romload_end(); // detect wrong files (Pico crashes on very small files), also see if ROM EP is good if(rom_size <= 0x200 || strncmp((char *)rom_data, "Pico", 4) == 0 || diff --git a/gp2x/gp2x.c b/gp2x/gp2x.c index d6a701c..c0396d9 100644 --- a/gp2x/gp2x.c +++ b/gp2x/gp2x.c @@ -159,10 +159,11 @@ void gp2x_video_wait_vsync(void) void gp2x_memcpy_buffers(int buffers, void *data, int offset, int len) { - if (buffers & (1<<0)) memcpy((char *)gp2x_screens[0] + offset, data, len); - if (buffers & (1<<1)) memcpy((char *)gp2x_screens[1] + offset, data, len); - if (buffers & (1<<2)) memcpy((char *)gp2x_screens[2] + offset, data, len); - if (buffers & (1<<3)) memcpy((char *)gp2x_screens[3] + offset, data, len); + char *dst; + if (buffers & (1<<0)) { dst = (char *)gp2x_screens[0] + offset; if (dst != data) memcpy(dst, data, len); } + if (buffers & (1<<1)) { dst = (char *)gp2x_screens[1] + offset; if (dst != data) memcpy(dst, data, len); } + if (buffers & (1<<2)) { dst = (char *)gp2x_screens[2] + offset; if (dst != data) memcpy(dst, data, len); } + if (buffers & (1<<3)) { dst = (char *)gp2x_screens[3] + offset; if (dst != data) memcpy(dst, data, len); } } diff --git a/gp2x/menu.c b/gp2x/menu.c index 9b51d7c..06a3e3d 100644 --- a/gp2x/menu.c +++ b/gp2x/menu.c @@ -420,6 +420,39 @@ static unsigned long wait_for_input_usbjoy(unsigned long interesting, int *joy) +// --------- loading ROM screen ---------- + +static void load_progress_cb(int percent) +{ + int ln, len = percent * 320 / 100; + unsigned char *dst = (unsigned char *)gp2x_screen + 320*20; + + if (len > 320) len = 320; + for (ln = 10; ln > 0; ln--, dst += 320) + memset(dst, 0xf0, len); + gp2x_video_flip2(); +} + +void menu_romload_prepare(const char *rom_name) +{ + const char *p = rom_name + strlen(rom_name); + while (p > rom_name && *p != '/') p--; + + gp2x_pd_clone_buffer2(); + gp2x_smalltext8(1, 1, "Loading"); + gp2x_smalltext8_lim(1, 10, p, 53); + gp2x_memcpy_buffers(3, gp2x_screen, 0, 320*240); + gp2x_video_flip2(); + PicoCartLoadProgressCB = load_progress_cb; +} + +void menu_romload_end(void) +{ + PicoCartLoadProgressCB = NULL; + gp2x_smalltext8(1, 30, "Starting emulation..."); + gp2x_video_flip2(); +} + // -------------- ROM selector -------------- static void draw_dirlist(char *curdir, struct dirent **namelist, int n, int sel) @@ -429,7 +462,6 @@ static void draw_dirlist(char *curdir, struct dirent **namelist, int n, int sel) start = 12 - sel; n--; // exclude current dir (".") - //memset(gp2x_screen, 0, 320*240); gp2x_pd_clone_buffer2(); if(start - 2 >= 0) diff --git a/gp2x/menu.h b/gp2x/menu.h index 87c51b5..8c9e29b 100644 --- a/gp2x/menu.h +++ b/gp2x/menu.h @@ -10,6 +10,8 @@ void gp2x_text_out15 (int x, int y, const char *text); void gp2x_text_out8_2(int x, int y, const char *texto, int color); void menu_loop(void); int menu_loop_tray(void); +void menu_romload_prepare(const char *rom_name); +void menu_romload_end(void); #define CONFIGURABLE_KEYS \ (GP2X_UP|GP2X_DOWN|GP2X_LEFT|GP2X_RIGHT|GP2X_A|GP2X_B|GP2X_X|GP2X_Y| \