mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
ROM load progress bar
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@224 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
6d7acf9eff
commit
a9b3ffd3cc
7 changed files with 73 additions and 8 deletions
29
Pico/Cart.c
29
Pico/Cart.c
|
@ -15,6 +15,8 @@
|
||||||
|
|
||||||
static char *rom_exts[] = { "bin", "gen", "smd", "iso" };
|
static char *rom_exts[] = { "bin", "gen", "smd", "iso" };
|
||||||
|
|
||||||
|
void (*PicoCartLoadProgressCB)(int percent) = NULL;
|
||||||
|
|
||||||
|
|
||||||
pm_file *pm_open(const char *path)
|
pm_file *pm_open(const char *path)
|
||||||
{
|
{
|
||||||
|
@ -244,7 +246,7 @@ static unsigned char *PicoCartAlloc(int filesize)
|
||||||
|
|
||||||
int PicoCartLoad(pm_file *f,unsigned char **prom,unsigned int *psize)
|
int PicoCartLoad(pm_file *f,unsigned char **prom,unsigned int *psize)
|
||||||
{
|
{
|
||||||
unsigned char *rom=NULL; int size;
|
unsigned char *rom=NULL; int size, bytes_read;
|
||||||
if (f==NULL) return 1;
|
if (f==NULL) return 1;
|
||||||
|
|
||||||
size=f->size;
|
size=f->size;
|
||||||
|
@ -258,7 +260,30 @@ int PicoCartLoad(pm_file *f,unsigned char **prom,unsigned int *psize)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pm_read(rom,size,f); // Load up the rom
|
if (PicoCartLoadProgressCB != NULL)
|
||||||
|
{
|
||||||
|
// read ROM in blocks, just for fun
|
||||||
|
int ret;
|
||||||
|
unsigned char *p = rom;
|
||||||
|
bytes_read=0;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
int todo = size - bytes_read;
|
||||||
|
if (todo > 256*1024) todo = 256*1024;
|
||||||
|
ret = pm_read(p,todo,f);
|
||||||
|
bytes_read += ret;
|
||||||
|
p += ret;
|
||||||
|
PicoCartLoadProgressCB(bytes_read * 100 / size);
|
||||||
|
}
|
||||||
|
while (ret > 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
bytes_read = pm_read(rom,size,f); // Load up the rom
|
||||||
|
if (bytes_read <= 0) {
|
||||||
|
printf("read failed\n");
|
||||||
|
free(rom);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// maybe we are loading MegaCD BIOS?
|
// maybe we are loading MegaCD BIOS?
|
||||||
if (!(PicoMCD&1) && size == 0x20000 && (!strncmp((char *)rom+0x124, "BOOT", 4) || !strncmp((char *)rom+0x128, "BOOT", 4))) {
|
if (!(PicoMCD&1) && size == 0x20000 && (!strncmp((char *)rom+0x124, "BOOT", 4) || !strncmp((char *)rom+0x128, "BOOT", 4))) {
|
||||||
|
|
|
@ -92,6 +92,7 @@ int PicoCartInsert(unsigned char *rom,unsigned int romsize);
|
||||||
void Byteswap(unsigned char *data,int len);
|
void Byteswap(unsigned char *data,int len);
|
||||||
// anotherguest
|
// anotherguest
|
||||||
int PicoUnloadCart(unsigned char* romdata);
|
int PicoUnloadCart(unsigned char* romdata);
|
||||||
|
extern void (*PicoCartLoadProgressCB)(int percent);
|
||||||
|
|
||||||
// Draw.c
|
// Draw.c
|
||||||
void PicoDrawSetColorFormat(int which); // 0=BGR444, 1=RGB555, 2=8bit(HighPal pal)
|
void PicoDrawSetColorFormat(int which); // 0=BGR444, 1=RGB555, 2=8bit(HighPal pal)
|
||||||
|
|
|
@ -210,7 +210,7 @@ $(error need VER)
|
||||||
endif
|
endif
|
||||||
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
|
zip -9 -j ../../PicoDrive_$(VER).zip $^ mmuhack.o
|
||||||
|
|
||||||
code940/code940.bin:
|
code940/code940.bin:
|
||||||
|
|
|
@ -287,6 +287,8 @@ int emu_ReloadRom(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
menu_romload_prepare(used_rom_name);
|
||||||
|
|
||||||
if(rom_data) {
|
if(rom_data) {
|
||||||
free(rom_data);
|
free(rom_data);
|
||||||
rom_data = 0;
|
rom_data = 0;
|
||||||
|
@ -297,9 +299,11 @@ int emu_ReloadRom(void)
|
||||||
sprintf(menuErrorMsg, "PicoCartLoad() failed.");
|
sprintf(menuErrorMsg, "PicoCartLoad() failed.");
|
||||||
printf("%s\n", menuErrorMsg);
|
printf("%s\n", menuErrorMsg);
|
||||||
pm_close(rom);
|
pm_close(rom);
|
||||||
|
menu_romload_end();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
pm_close(rom);
|
pm_close(rom);
|
||||||
|
menu_romload_end();
|
||||||
|
|
||||||
// detect wrong files (Pico crashes on very small files), also see if ROM EP is good
|
// 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 ||
|
if(rom_size <= 0x200 || strncmp((char *)rom_data, "Pico", 4) == 0 ||
|
||||||
|
|
|
@ -159,10 +159,11 @@ void gp2x_video_wait_vsync(void)
|
||||||
|
|
||||||
void gp2x_memcpy_buffers(int buffers, void *data, int offset, int len)
|
void gp2x_memcpy_buffers(int buffers, void *data, int offset, int len)
|
||||||
{
|
{
|
||||||
if (buffers & (1<<0)) memcpy((char *)gp2x_screens[0] + offset, data, len);
|
char *dst;
|
||||||
if (buffers & (1<<1)) memcpy((char *)gp2x_screens[1] + offset, data, len);
|
if (buffers & (1<<0)) { dst = (char *)gp2x_screens[0] + offset; if (dst != data) memcpy(dst, data, len); }
|
||||||
if (buffers & (1<<2)) memcpy((char *)gp2x_screens[2] + offset, data, len);
|
if (buffers & (1<<1)) { dst = (char *)gp2x_screens[1] + offset; if (dst != data) memcpy(dst, data, len); }
|
||||||
if (buffers & (1<<3)) memcpy((char *)gp2x_screens[3] + offset, 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); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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 --------------
|
// -------------- ROM selector --------------
|
||||||
|
|
||||||
static void draw_dirlist(char *curdir, struct dirent **namelist, int n, int sel)
|
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;
|
start = 12 - sel;
|
||||||
n--; // exclude current dir (".")
|
n--; // exclude current dir (".")
|
||||||
|
|
||||||
//memset(gp2x_screen, 0, 320*240);
|
|
||||||
gp2x_pd_clone_buffer2();
|
gp2x_pd_clone_buffer2();
|
||||||
|
|
||||||
if(start - 2 >= 0)
|
if(start - 2 >= 0)
|
||||||
|
|
|
@ -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 gp2x_text_out8_2(int x, int y, const char *texto, int color);
|
||||||
void menu_loop(void);
|
void menu_loop(void);
|
||||||
int menu_loop_tray(void);
|
int menu_loop_tray(void);
|
||||||
|
void menu_romload_prepare(const char *rom_name);
|
||||||
|
void menu_romload_end(void);
|
||||||
|
|
||||||
#define CONFIGURABLE_KEYS \
|
#define CONFIGURABLE_KEYS \
|
||||||
(GP2X_UP|GP2X_DOWN|GP2X_LEFT|GP2X_RIGHT|GP2X_A|GP2X_B|GP2X_X|GP2X_Y| \
|
(GP2X_UP|GP2X_DOWN|GP2X_LEFT|GP2X_RIGHT|GP2X_A|GP2X_B|GP2X_X|GP2X_Y| \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue