// This is part of Pico Library\r
\r
// (c) Copyright 2004 Dave, All rights reserved.\r
-// (c) Copyright 2006 notaz, All rights reserved.\r
+// (c) Copyright 2006-2007, Grazvydas "notaz" Ignotas\r
// Free for non-commercial use.\r
\r
// For commercial use, separate licencing terms must be obtained.\r
\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