\r
static char *rom_exts[] = { "bin", "gen", "smd", "iso" };\r
\r
+void (*PicoCartLoadProgressCB)(int percent) = NULL;\r
+\r
\r
pm_file *pm_open(const char *path)\r
{\r
\r
int PicoCartLoad(pm_file *f,unsigned char **prom,unsigned int *psize)\r
{\r
- unsigned char *rom=NULL; int size;\r
+ unsigned char *rom=NULL; int size, bytes_read;\r
if (f==NULL) return 1;\r
\r
size=f->size;\r
return 1;\r
}\r
\r
- pm_read(rom,size,f); // Load up the rom\r
+ if (PicoCartLoadProgressCB != NULL)\r
+ {\r
+ // read ROM in blocks, just for fun\r
+ int ret;\r
+ unsigned char *p = rom;\r
+ bytes_read=0;\r
+ do\r
+ {\r
+ int todo = size - bytes_read;\r
+ if (todo > 256*1024) todo = 256*1024;\r
+ ret = pm_read(p,todo,f);\r
+ bytes_read += ret;\r
+ p += ret;\r
+ PicoCartLoadProgressCB(bytes_read * 100 / size);\r
+ }\r
+ while (ret > 0);\r
+ }\r
+ else\r
+ bytes_read = pm_read(rom,size,f); // Load up the rom\r
+ if (bytes_read <= 0) {\r
+ printf("read failed\n");\r
+ free(rom);\r
+ return 1;\r
+ }\r
\r
// maybe we are loading MegaCD BIOS?\r
if (!(PicoMCD&1) && size == 0x20000 && (!strncmp((char *)rom+0x124, "BOOT", 4) || !strncmp((char *)rom+0x128, "BOOT", 4))) {\r
void Byteswap(unsigned char *data,int len);\r
// anotherguest\r
int PicoUnloadCart(unsigned char* romdata);\r
+extern void (*PicoCartLoadProgressCB)(int percent);\r
\r
// Draw.c\r
void PicoDrawSetColorFormat(int which); // 0=BGR444, 1=RGB555, 2=8bit(HighPal pal)\r
endif\r
endif\r
\r
-rel: PicoDrive.gpe code940/code940.bin ../readme.txt config.txt PicoDrive.man.txt PicoDrive.png\r
+rel: PicoDrive.gpe code940/pico940.bin ../readme.txt config.txt PicoDrive.man.txt PicoDrive.png\r
zip -9 -j ../../PicoDrive_$(VER).zip $^ mmuhack.o\r
\r
code940/code940.bin:\r
return 0;\r
}\r
\r
+ menu_romload_prepare(used_rom_name);\r
+\r
if(rom_data) {\r
free(rom_data);\r
rom_data = 0;\r
sprintf(menuErrorMsg, "PicoCartLoad() failed.");\r
printf("%s\n", menuErrorMsg);\r
pm_close(rom);\r
+ menu_romload_end();\r
return 0;\r
}\r
pm_close(rom);\r
+ menu_romload_end();\r
\r
// detect wrong files (Pico crashes on very small files), also see if ROM EP is good\r
if(rom_size <= 0x200 || strncmp((char *)rom_data, "Pico", 4) == 0 ||\r
\r
void gp2x_memcpy_buffers(int buffers, void *data, int offset, int len)\r
{\r
- if (buffers & (1<<0)) memcpy((char *)gp2x_screens[0] + offset, data, len);\r
- if (buffers & (1<<1)) memcpy((char *)gp2x_screens[1] + offset, data, len);\r
- if (buffers & (1<<2)) memcpy((char *)gp2x_screens[2] + offset, data, len);\r
- if (buffers & (1<<3)) memcpy((char *)gp2x_screens[3] + offset, data, len);\r
+ char *dst;\r
+ if (buffers & (1<<0)) { dst = (char *)gp2x_screens[0] + offset; if (dst != data) memcpy(dst, data, len); }\r
+ if (buffers & (1<<1)) { dst = (char *)gp2x_screens[1] + offset; if (dst != data) memcpy(dst, data, len); }\r
+ if (buffers & (1<<2)) { dst = (char *)gp2x_screens[2] + offset; if (dst != data) memcpy(dst, data, len); }\r
+ if (buffers & (1<<3)) { dst = (char *)gp2x_screens[3] + offset; if (dst != data) memcpy(dst, data, len); }\r
}\r
\r
\r
\r
\r
\r
+// --------- loading ROM screen ----------\r
+\r
+static void load_progress_cb(int percent)\r
+{\r
+ int ln, len = percent * 320 / 100;\r
+ unsigned char *dst = (unsigned char *)gp2x_screen + 320*20;\r
+\r
+ if (len > 320) len = 320;\r
+ for (ln = 10; ln > 0; ln--, dst += 320)\r
+ memset(dst, 0xf0, len);\r
+ gp2x_video_flip2();\r
+}\r
+\r
+void menu_romload_prepare(const char *rom_name)\r
+{\r
+ const char *p = rom_name + strlen(rom_name);\r
+ while (p > rom_name && *p != '/') p--;\r
+\r
+ gp2x_pd_clone_buffer2();\r
+ gp2x_smalltext8(1, 1, "Loading");\r
+ gp2x_smalltext8_lim(1, 10, p, 53);\r
+ gp2x_memcpy_buffers(3, gp2x_screen, 0, 320*240);\r
+ gp2x_video_flip2();\r
+ PicoCartLoadProgressCB = load_progress_cb;\r
+}\r
+\r
+void menu_romload_end(void)\r
+{\r
+ PicoCartLoadProgressCB = NULL;\r
+ gp2x_smalltext8(1, 30, "Starting emulation...");\r
+ gp2x_video_flip2();\r
+}\r
+\r
// -------------- ROM selector --------------\r
\r
static void draw_dirlist(char *curdir, struct dirent **namelist, int n, int sel)\r
start = 12 - sel;\r
n--; // exclude current dir (".")\r
\r
- //memset(gp2x_screen, 0, 320*240);\r
gp2x_pd_clone_buffer2();\r
\r
if(start - 2 >= 0)\r
void gp2x_text_out8_2(int x, int y, const char *texto, int color);\r
void menu_loop(void);\r
int menu_loop_tray(void);\r
+void menu_romload_prepare(const char *rom_name);\r
+void menu_romload_end(void);\r
\r
#define CONFIGURABLE_KEYS \\r
(GP2X_UP|GP2X_DOWN|GP2X_LEFT|GP2X_RIGHT|GP2X_A|GP2X_B|GP2X_X|GP2X_Y| \\r