[Gamecube/Wii] added configurable BIOS & Lock-on ROM support

This commit is contained in:
EkeEke 2014-08-25 00:30:18 +02:00
parent 6052d29a24
commit 620f372cb2
20 changed files with 654 additions and 238 deletions

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 MiB

After

Width:  |  Height:  |  Size: 3.7 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 MiB

After

Width:  |  Height:  |  Size: 3.8 MiB

View File

@ -2,7 +2,7 @@
* Genesis Plus * Genesis Plus
* Action Replay / Pro Action Replay emulation * Action Replay / Pro Action Replay emulation
* *
* Copyright (C) 2009-2011 Eke-Eke (Genesis Plus GX) * Copyright (C) 2009-2014 Eke-Eke (Genesis Plus GX)
* *
* Redistribution and use of this code or any derivative works are permitted * Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met: * provided that the following conditions are met:
@ -60,7 +60,6 @@ static void ar_write_ram_8(uint32 address, uint32 data);
void areplay_init(void) void areplay_init(void)
{ {
int size; int size;
FILE *f;
memset(&action_replay,0,sizeof(action_replay)); memset(&action_replay,0,sizeof(action_replay));
@ -69,19 +68,15 @@ void areplay_init(void)
action_replay.rom = cart.rom + 0x810000; action_replay.rom = cart.rom + 0x810000;
action_replay.ram = cart.rom + 0x830000; action_replay.ram = cart.rom + 0x830000;
/* Open Action Replay ROM */ /* try to load Action Replay ROM file */
f = fopen(AR_ROM,"rb"); size = load_archive(AR_ROM, action_replay.rom, 0x20000, NULL);
if (f == NULL) return;
/* ROM size */
fseek(f, 0, SEEK_END);
size = ftell(f);
fseek(f, 0, SEEK_SET);
/* detect Action Replay board type */ /* detect Action Replay board type */
switch (size) switch (size)
{ {
case 0x8000: case 0x8000:
{
if (!memcmp(action_replay.rom + 0x120, "ACTION REPLAY ", 16))
{ {
/* normal Action Replay (32K) */ /* normal Action Replay (32K) */
action_replay.enabled = TYPE_AR; action_replay.enabled = TYPE_AR;
@ -90,17 +85,16 @@ void areplay_init(void)
m68k.memory_map[0x01].write16 = ar_write_regs; m68k.memory_map[0x01].write16 = ar_write_regs;
break; break;
} }
}
case 0x10000: case 0x10000:
case 0x20000: case 0x20000:
{ {
/* read Stack Pointer */ /* Read stack pointer MSB */
uint8 sp[4]; uint8 sp = READ_BYTE(action_replay.rom, 0x01);
fread(&sp, 4, 1, f);
fseek(f, 0, SEEK_SET);
/* Detect board version */ /* Detect board version */
if (sp[1] == 0x42) if ((sp == 0x42) && !memcmp(action_replay.rom + 0x120, "ACTION REPLAY 2 ", 16))
{ {
/* PRO Action Replay 1 (64/128K) */ /* PRO Action Replay 1 (64/128K) */
action_replay.enabled = TYPE_PRO1; action_replay.enabled = TYPE_PRO1;
@ -108,7 +102,7 @@ void areplay_init(void)
/* internal registers mapped at $010000-$01ffff */ /* internal registers mapped at $010000-$01ffff */
m68k.memory_map[0x01].write16 = ar_write_regs; m68k.memory_map[0x01].write16 = ar_write_regs;
} }
else if (sp[1] == 0x60) else if ((sp == 0x60) && !memcmp(action_replay.rom + 0x3c6, "ACTION REPLAY II", 16))
{ {
/* PRO Action Replay 2 (64K) */ /* PRO Action Replay 2 (64K) */
action_replay.enabled = TYPE_PRO2; action_replay.enabled = TYPE_PRO2;
@ -120,11 +114,11 @@ void areplay_init(void)
/* internal RAM (64k), mapped at $420000-$42ffff or $600000-$60ffff */ /* internal RAM (64k), mapped at $420000-$42ffff or $600000-$60ffff */
if (action_replay.enabled) if (action_replay.enabled)
{ {
m68k.memory_map[sp[1]].base = action_replay.ram; m68k.memory_map[sp].base = action_replay.ram;
m68k.memory_map[sp[1]].read8 = NULL; m68k.memory_map[sp].read8 = NULL;
m68k.memory_map[sp[1]].read16 = NULL; m68k.memory_map[sp].read16 = NULL;
m68k.memory_map[sp[1]].write8 = ar_write_ram_8; m68k.memory_map[sp].write8 = ar_write_ram_8;
m68k.memory_map[sp[1]].write16 = NULL; m68k.memory_map[sp].write16 = NULL;
} }
break; break;
} }
@ -135,16 +129,10 @@ void areplay_init(void)
} }
} }
#ifdef LSB_FIRST
if (action_replay.enabled) if (action_replay.enabled)
{ {
/* Load ROM */ int i;
int i = 0;
for (i=0; i<size; i+=0x1000)
{
fread(action_replay.rom + i, 0x1000, 1, f);
}
#ifdef LSB_FIRST
for (i= 0; i<size; i+=2) for (i= 0; i<size; i+=2)
{ {
/* Byteswap ROM */ /* Byteswap ROM */
@ -152,11 +140,8 @@ void areplay_init(void)
action_replay.rom[i] = action_replay.rom[i+1]; action_replay.rom[i] = action_replay.rom[i+1];
action_replay.rom[i+1] = temp; action_replay.rom[i+1] = temp;
} }
#endif
} }
#endif
/* Close ROM file */
fclose(f);
} }
void areplay_shutdown(void) void areplay_shutdown(void)

View File

@ -2,7 +2,7 @@
* Genesis Plus * Genesis Plus
* DATEL Action Replay / Pro Action Replay emulation * DATEL Action Replay / Pro Action Replay emulation
* *
* Copyright (C) 2009-2011 Eke-Eke (Genesis Plus GX) * Copyright (C) 2009-2014 Eke-Eke (Genesis Plus GX)
* *
* Redistribution and use of this code or any derivative works are permitted * Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met: * provided that the following conditions are met:

View File

@ -2,7 +2,7 @@
* Genesis Plus * Genesis Plus
* Game Genie Hardware emulation * Game Genie Hardware emulation
* *
* Copyright (C) 2009-2011 Eke-Eke (Genesis Plus GX) * Copyright (C) 2009-2014 Eke-Eke (Genesis Plus GX)
* *
* Based on documentation from Charles McDonald * Based on documentation from Charles McDonald
* (http://cgfm2.emuviews.com/txt/genie.txt) * (http://cgfm2.emuviews.com/txt/genie.txt)
@ -59,29 +59,17 @@ static void ggenie_write_regs(unsigned int offset, unsigned int data);
void ggenie_init(void) void ggenie_init(void)
{ {
int i;
FILE *f;
memset(&ggenie,0,sizeof(ggenie)); memset(&ggenie,0,sizeof(ggenie));
/* Store Game Genie ROM (32k) above cartridge ROM + SRAM area */ /* Store Game Genie ROM (32k) above cartridge ROM + SRAM area */
if (cart.romsize > 0x810000) return; if (cart.romsize > 0x810000) return;
ggenie.rom = cart.rom + 0x810000; ggenie.rom = cart.rom + 0x810000;
/* Open Game Genie ROM file */ /* Try to load Game Genie ROM file */
f = fopen(GG_ROM,"rb"); if (load_archive(GG_ROM, ggenie.rom, 0x8000, NULL) > 0)
if (f == NULL) return;
/* Load ROM */
for (i=0; i<0x8000; i+=0x1000)
{ {
fread(ggenie.rom + i, 0x1000, 1, f);
}
/* Close ROM file */
fclose(f);
#ifdef LSB_FIRST #ifdef LSB_FIRST
int i;
for (i=0; i<0x8000; i+=2) for (i=0; i<0x8000; i+=2)
{ {
/* Byteswap ROM */ /* Byteswap ROM */
@ -94,8 +82,9 @@ void ggenie_init(void)
/* $0000-$7fff mirrored into $8000-$ffff */ /* $0000-$7fff mirrored into $8000-$ffff */
memcpy(ggenie.rom + 0x8000, ggenie.rom, 0x8000); memcpy(ggenie.rom + 0x8000, ggenie.rom, 0x8000);
/* set flag */ /* Game Genie hardware is enabled */
ggenie.enabled = 1; ggenie.enabled = 1;
}
} }
void ggenie_shutdown(void) void ggenie_shutdown(void)

View File

@ -2,7 +2,7 @@
* Genesis Plus * Genesis Plus
* Game Genie Hardware emulation * Game Genie Hardware emulation
* *
* Copyright (C) 2009-2011 Eke-Eke (Genesis Plus GX) * Copyright (C) 2009-2014 Eke-Eke (Genesis Plus GX)
* *
* Based on documentation from Charles McDonald * Based on documentation from Charles McDonald
* (http://cgfm2.emuviews.com/txt/genie.txt) * (http://cgfm2.emuviews.com/txt/genie.txt)

View File

@ -463,28 +463,23 @@ void md_cart_init(void)
case TYPE_SK: case TYPE_SK:
{ {
FILE *f;
/* store S&K ROM above cartridge ROM (and before backup memory) */ /* store S&K ROM above cartridge ROM (and before backup memory) */
if (cart.romsize > 0x600000) break; if (cart.romsize > 0x600000) break;
/* load Sonic & Knuckles ROM (2 MB) */ /* try to load Sonic & Knuckles ROM file (2 MB) */
f = fopen(SK_ROM,"rb"); if (load_archive(SK_ROM, cart.rom + 0x600000, 0x200000, NULL) == 0x200000)
if (!f) break;
for (i=0; i<0x200000; i+=0x1000)
{ {
fread(cart.rom + 0x600000 + i, 0x1000, 1, f); /* check ROM header */
} if (!memcmp(cart.rom + 0x600000 + 0x120, "SONIC & KNUCKLES",16))
fclose(f);
/* load Sonic 2 UPMEM ROM (256 KB) */
f = fopen(SK_UPMEM,"rb");
if (!f) break;
for (i=0; i<0x40000; i+=0x1000)
{ {
fread(cart.rom + 0x900000 + i, 0x1000, 1, f); /* try to load Sonic 2 & Knuckles UPMEM ROM (256 KB) */
if (load_archive(SK_UPMEM, cart.rom + 0x900000, 0x40000, NULL) == 0x40000)
{
/* $000000-$1FFFFF is mapped to S&K ROM */
for (i=0x00; i<0x20; i++)
{
m68k.memory_map[i].base = cart.rom + 0x600000 + (i << 16);
} }
fclose(f);
#ifdef LSB_FIRST #ifdef LSB_FIRST
for (i=0; i<0x200000; i+=2) for (i=0; i<0x200000; i+=2)
@ -503,14 +498,10 @@ void md_cart_init(void)
cart.rom[i + 0x900000 + 1] = temp; cart.rom[i + 0x900000 + 1] = temp;
} }
#endif #endif
/* $000000-$1FFFFF is mapped to S&K ROM */
for (i=0x00; i<0x20; i++)
{
m68k.memory_map[i].base = cart.rom + 0x600000 + (i << 16);
}
cart.special |= HW_LOCK_ON; cart.special |= HW_LOCK_ON;
}
}
}
break; break;
} }

View File

@ -453,7 +453,7 @@ int load_bios(void)
if (cart.romsize <= 0x400000) if (cart.romsize <= 0x400000)
{ {
/* load Game Gear BOOTROM file */ /* load Game Gear BOOTROM file */
size = load_archive(GG_BIOS, cart.rom + 0x400000, 0x100000, 0); size = load_archive(GG_BIOS, cart.rom + 0x400000, 0x400000, 0);
if (size > 0) if (size > 0)
{ {

View File

@ -41,6 +41,8 @@
#include "gui.h" #include "gui.h"
#include "file_load.h" #include "file_load.h"
t_config config;
static int config_load(void) static int config_load(void)
{ {
/* open configuration file */ /* open configuration file */
@ -239,6 +241,20 @@ void config_default(void)
sprintf (config.lastdir[4][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[4][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH);
#endif #endif
/* system ROM paths */
sprintf (config.sys_rom[0], "%s/bios/bios_CD_U.bin", DEFAULT_PATH);
sprintf (config.sys_rom[1], "%s/bios/bios_CD_E.bin", DEFAULT_PATH);
sprintf (config.sys_rom[2], "%s/bios/bios_CD_J.bin", DEFAULT_PATH);
sprintf (config.sys_rom[3], "%s/bios/bios_MD.bin", DEFAULT_PATH);
sprintf (config.sys_rom[4], "%s/bios/bios_U.sms", DEFAULT_PATH);
sprintf (config.sys_rom[5], "%s/bios/bios_E.sms", DEFAULT_PATH);
sprintf (config.sys_rom[6], "%s/bios/bios_J.sms", DEFAULT_PATH);
sprintf (config.sys_rom[7], "%s/bios/bios.gg", DEFAULT_PATH);
sprintf (config.sys_rom[8], "%s/lock-on/ggenie.bin", DEFAULT_PATH);
sprintf (config.sys_rom[9], "%s/lock-on/areplay.bin", DEFAULT_PATH);
sprintf (config.sys_rom[10], "%s/lock-on/sk.bin", DEFAULT_PATH);
sprintf (config.sys_rom[11], "%s/lock-on/sk2chip.bin", DEFAULT_PATH);
/* try to restore user config */ /* try to restore user config */
int loaded = config_load(); int loaded = config_load();

View File

@ -119,11 +119,10 @@ typedef struct
float ntsc_artifacts; float ntsc_artifacts;
float ntsc_fringing; float ntsc_fringing;
float ntsc_bleed; float ntsc_bleed;
char sys_rom[12][256];
} t_config; } t_config;
/* Global data */ extern t_config config;
t_config config;
extern void config_save(void); extern void config_save(void);
extern void config_default(void); extern void config_default(void);

View File

@ -1,7 +1,7 @@
/* /*
* file_load.c * file_load.c
* *
* ROM File loading support * File loading support
* *
* Copyright Eke-Eke (2008-2014) * Copyright Eke-Eke (2008-2014)
* *
@ -238,12 +238,6 @@ int UpdateDirectory(bool go_up, char *dirname)
/* go up to parent directory */ /* go up to parent directory */
if (go_up) if (go_up)
{ {
/* special case */
if (deviceType == TYPE_RECENT) return 0;
/* check if we already are at root directory */
if (!strcmp(rootdir[deviceType], (const char *)fileDir)) return 0;
int size=0; int size=0;
char temp[MAXPATHLEN]; char temp[MAXPATHLEN];
@ -253,14 +247,20 @@ int UpdateDirectory(bool go_up, char *dirname)
while (test != NULL) while (test != NULL)
{ {
size = strlen(test); size = strlen(test);
if (dirname)
{
strncpy(dirname,test,size); strncpy(dirname,test,size);
dirname[size] = 0; dirname[size] = 0;
}
test = strtok(NULL,"/"); test = strtok(NULL,"/");
} }
/* check if we already are at root directory */
size = strlen(fileDir) - size - 1;
if (!size) return 0;
/* remove last folder from path */ /* remove last folder from path */
size = strlen(fileDir) - size; fileDir[size] = 0;
fileDir[size - 1] = 0;
} }
else else
{ {
@ -501,8 +501,30 @@ int OpenDirectory(int device, int type)
} }
} }
/* parse last directory */ /* System ROM selection */
if (type >= FILETYPE_MAX)
{
/* allocate temporary directory */
fileDir = malloc(MAXPATHLEN);
if (!fileDir)
{
GUI_WaitPrompt("Error","Unable to allocate memory !");
return 0;
}
/* extract System ROM directory */
strcpy(fileDir, config.sys_rom[type-FILETYPE_MAX]);
int i = strlen(fileDir) - 1;
while (fileDir[i] != '/')
i--;
fileDir[i+1] = 0;
}
else
{
/* parse last ROM type directory on selected device */
fileDir = config.lastdir[type][device]; fileDir = config.lastdir[type][device];
}
max = ParseDirectory(); max = ParseDirectory();
if (max <= 0) if (max <= 0)
{ {
@ -527,13 +549,24 @@ int OpenDirectory(int device, int type)
/* check if device or file type has changed */ /* check if device or file type has changed */
if ((device != deviceType) || (type != fileType)) if ((device != deviceType) || (type != fileType))
{ {
/* reset current types */ /* reset device type */
deviceType = device; deviceType = device;
/* make sure we are not selecting System ROM file */
if (type < FILETYPE_MAX)
{
/* reset file type */
fileType = type; fileType = type;
/* reset File selector */ /* reset File selector */
ClearSelector(max); ClearSelector(max);
} }
}
return 1; return max;
}
char *GetCurrentDirectory(void)
{
return fileDir;
} }

View File

@ -1,7 +1,7 @@
/* /*
* file_load.c * file_load.c
* *
* ROM File loading support * File loading support
* *
* Copyright Eke-Eke (2008-2014) * Copyright Eke-Eke (2008-2014)
* *
@ -62,6 +62,8 @@ typedef enum
FILETYPE_MAX FILETYPE_MAX
}FILETYPES; }FILETYPES;
extern char *GetCurrentDirectory(void);
extern int OpenDirectory(int device, int type); extern int OpenDirectory(int device, int type);
extern int UpdateDirectory(bool go_up, char *filename); extern int UpdateDirectory(bool go_up, char *filename);
extern int ParseDirectory(void); extern int ParseDirectory(void);

View File

@ -4,7 +4,7 @@
* Load a normal file, or ZIP/GZ archive into ROM buffer. * Load a normal file, or ZIP/GZ archive into ROM buffer.
* Returns loaded ROM size (zero if an error occured). * Returns loaded ROM size (zero if an error occured).
* *
* Copyright Eke-Eke (2007-2013), based on original work from Softdev (2006) * Copyright Eke-Eke (2007-2014), based on original work from Softdev (2006)
* *
* Redistribution and use of this code or any derivative works are permitted * Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met: * provided that the following conditions are met:
@ -87,26 +87,54 @@ int load_archive(char *filename, unsigned char *buffer, int maxsize, char *exten
{ {
int size = 0; int size = 0;
char in[CHUNKSIZE]; char in[CHUNKSIZE];
char msg[64] = "Unable to open file"; char msg[64];
char type[16];
/* Open file */ /* Open file */
FILE *fd = fopen(filename, "rb"); FILE *fd = fopen(filename, "rb");
/* Master System & Game Gear BIOS are optional files */ /* Autodetect needed System ROM files */
if (!strcmp(filename,MS_BIOS_US) || !strcmp(filename,MS_BIOS_EU) || !strcmp(filename,MS_BIOS_JP) || !strcmp(filename,GG_BIOS)) if (filename == CD_BIOS_US)
{ {
/* disable all messages */ sprintf(type,"CD BIOS (USA)");
}
else if (filename == CD_BIOS_EU)
{
sprintf(type,"CD BIOS (PAL)");
}
else if (filename == CD_BIOS_JP)
{
sprintf(type,"CD BIOS (JAP)");
}
else if (filename == AR_ROM)
{
sprintf(type,"Action Replay");
}
else if (filename == GG_ROM)
{
sprintf(type,"Game Genie");
}
else if (filename == SK_ROM)
{
sprintf(type,"S&K (2MB ROM)");
}
else if (filename == SK_UPMEM)
{
sprintf(type,"S2&K (256K ROM)");
}
else if ((filename == MS_BIOS_US) || (filename == MS_BIOS_EU) || (filename == MS_BIOS_JP) || (filename == GG_BIOS) || (filename == MD_BIOS))
{
/* Mega Drive / Genesis, Master System & Game Gear BIOS are optional so we disable error messages */
SILENT = 1; SILENT = 1;
} }
else
/* Mega CD BIOS are required files */
if (!strcmp(filename,CD_BIOS_US) || !strcmp(filename,CD_BIOS_EU) || !strcmp(filename,CD_BIOS_JP))
{ {
sprintf(msg,"Unable to open %s", filename + 14); sprintf(type,"file");
} }
if (!fd) if (!fd)
{ {
sprintf(msg,"Unable to open %s", type);
GUI_WaitPrompt("Error", msg); GUI_WaitPrompt("Error", msg);
SILENT = 0; SILENT = 0;
return 0; return 0;
@ -128,13 +156,17 @@ int load_archive(char *filename, unsigned char *buffer, int maxsize, char *exten
size = FLIP32(pkzip->uncompressedSize); size = FLIP32(pkzip->uncompressedSize);
/* Check ROM size */ /* Check ROM size */
if (size > maxsize) if (size > MAXROMSIZE)
{ {
fclose(fd); fclose(fd);
GUI_WaitPrompt("Error","File is too large"); GUI_WaitPrompt("Error","File is too large");
SILENT = 0; SILENT = 0;
return 0; return 0;
} }
else if (size > maxsize)
{
size = maxsize;
}
sprintf (msg, "Unzipping %d bytes ...", size); sprintf (msg, "Unzipping %d bytes ...", size);
GUI_MsgBoxUpdate("Information",msg); GUI_MsgBoxUpdate("Information",msg);
@ -148,25 +180,23 @@ int load_archive(char *filename, unsigned char *buffer, int maxsize, char *exten
zs.avail_in = 0; zs.avail_in = 0;
zs.next_in = Z_NULL; zs.next_in = Z_NULL;
int res = inflateInit2(&zs, -MAX_WBITS); int res = inflateInit2(&zs, -MAX_WBITS);
if (res != Z_OK) if (res != Z_OK)
{ {
fclose(fd); fclose(fd);
GUI_WaitPrompt("Error","Unable to unzip file"); sprintf(msg,"Unable to unzip %s", type);
GUI_WaitPrompt("Error",msg);
SILENT = 0; SILENT = 0;
return 0; return 0;
} }
/* Compressed filename offset */ /* Compressed filename offset */
int offset = sizeof (PKZIPHEADER) + FLIP16(pkzip->filenameLength); int offset = sizeof (PKZIPHEADER) + FLIP16(pkzip->filenameLength);
if (extension) if (extension)
{ {
memcpy(extension, &in[offset - 3], 3); memcpy(extension, &in[offset - 3], 3);
extension[3] = 0; extension[3] = 0;
} }
/* Initial Zip buffer offset */ /* Initial Zip buffer offset */
offset += FLIP16(pkzip->extraDataLength); offset += FLIP16(pkzip->extraDataLength);
zs.next_in = (Bytef *)&in[offset]; zs.next_in = (Bytef *)&in[offset];
@ -174,6 +204,9 @@ int load_archive(char *filename, unsigned char *buffer, int maxsize, char *exten
/* Initial Zip remaining chunk size */ /* Initial Zip remaining chunk size */
zs.avail_in = CHUNKSIZE - offset; zs.avail_in = CHUNKSIZE - offset;
/* Initialize output size */
size = 0;
/* Start unzipping file */ /* Start unzipping file */
do do
{ {
@ -188,26 +221,34 @@ int load_archive(char *filename, unsigned char *buffer, int maxsize, char *exten
{ {
inflateEnd(&zs); inflateEnd(&zs);
fclose(fd); fclose(fd);
GUI_WaitPrompt("Error","Unable to unzip file"); sprintf(msg,"Unable to unzip %s", type);
GUI_WaitPrompt("Error",msg);
SILENT = 0; SILENT = 0;
return 0; return 0;
} }
offset = CHUNKSIZE - zs.avail_out; offset = CHUNKSIZE - zs.avail_out;
if ((size + offset) > maxsize)
{
offset = maxsize - size;
}
if (offset) if (offset)
{ {
memcpy(buffer, out, offset); memcpy(buffer, out, offset);
buffer += offset; buffer += offset;
size += offset;
} }
} }
while (zs.avail_out == 0); while ((zs.avail_out == 0) && (size < maxsize));
/* Read next chunk of zipped data */ /* Read next chunk of zipped data */
fread(in, CHUNKSIZE, 1, fd); fread(in, CHUNKSIZE, 1, fd);
zs.next_in = (Bytef *)&in[0]; zs.next_in = (Bytef *)&in[0];
zs.avail_in = CHUNKSIZE; zs.avail_in = CHUNKSIZE;
} }
while (res != Z_STREAM_END); while ((res != Z_STREAM_END) && (size < maxsize));
inflateEnd (&zs); inflateEnd (&zs);
} }
else else
@ -217,14 +258,18 @@ int load_archive(char *filename, unsigned char *buffer, int maxsize, char *exten
size = ftell(fd); size = ftell(fd);
fseek(fd, 0, SEEK_SET); fseek(fd, 0, SEEK_SET);
/* size limit */ /* Check ROM size */
if(size > maxsize) if (size > MAXROMSIZE)
{ {
fclose(fd); fclose(fd);
GUI_WaitPrompt("Error","File is too large"); GUI_WaitPrompt("Error","File is too large");
SILENT = 0; SILENT = 0;
return 0; return 0;
} }
else if (size > maxsize)
{
size = maxsize;
}
sprintf((char *)msg,"Loading %d bytes ...", size); sprintf((char *)msg,"Loading %d bytes ...", size);
GUI_MsgBoxUpdate("Information", (char *)msg); GUI_MsgBoxUpdate("Information", (char *)msg);

View File

@ -4,7 +4,7 @@
* Load a normal file, or ZIP/GZ archive into ROM buffer. * Load a normal file, or ZIP/GZ archive into ROM buffer.
* Returns loaded ROM size (zero if an error occured). * Returns loaded ROM size (zero if an error occured).
* *
* Copyright Eke-Eke (2007-2013), based on original work from Softdev (2006) * Copyright Eke-Eke (2007-2014), based on original work from Softdev (2006)
* *
* Redistribution and use of this code or any derivative works are permitted * Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met: * provided that the following conditions are met:

View File

@ -1,7 +1,7 @@
/* /*
* filesel.c * filesel.c
* *
* ROM File Browser * File Browser
* *
* Copyright Eke-Eke (2009-2014) * Copyright Eke-Eke (2009-2014)
* *
@ -97,7 +97,7 @@ static gui_item action_cancel =
static gui_item action_select = static gui_item action_select =
{ {
NULL,Key_A_png,"","Load ROM file",602,422,28,28 NULL,Key_A_png,"","Load file",602,422,28,28
}; };
/*****************************************************************************/ /*****************************************************************************/
@ -139,6 +139,9 @@ static const char *Cart_dir[FILETYPE_MAX] =
"sg" "sg"
}; };
static gui_image dir_icon;
static gui_image bar_over;
/*****************************************************************************/ /*****************************************************************************/
/* GUI Descriptor */ /* GUI Descriptor */
/*****************************************************************************/ /*****************************************************************************/
@ -162,22 +165,6 @@ static void selector_cb(void)
char text[MAXPATHLEN]; char text[MAXPATHLEN];
int yoffset = 108; int yoffset = 108;
/* Initialize directory icon */
gui_image dir_icon;
dir_icon.texture = gxTextureOpenPNG(Browser_dir_png,0);
dir_icon.w = dir_icon.texture->width;
dir_icon.h = dir_icon.texture->height;
dir_icon.x = 26;
dir_icon.y = (26 - dir_icon.h)/2;
/* Initialize selection bar */
gui_image bar_over;
bar_over.texture = gxTextureOpenPNG(Overlay_bar_png,0);
bar_over.w = bar_over.texture->width;
bar_over.h = bar_over.texture->height;
bar_over.x = 16;
bar_over.y = (26 - bar_over.h)/2;
/* Draw browser array */ /* Draw browser array */
gxDrawRectangle(15, 108, 358, 26, 127, (GXColor)BG_COLOR_1); gxDrawRectangle(15, 108, 358, 26, 127, (GXColor)BG_COLOR_1);
gxDrawRectangle(15, 134, 358, 26, 127, (GXColor)BG_COLOR_2); gxDrawRectangle(15, 134, 358, 26, 127, (GXColor)BG_COLOR_2);
@ -250,9 +237,6 @@ static void selector_cb(void)
yoffset += 26; yoffset += 26;
} }
gxTextureClose(&bar_over.texture);
gxTextureClose(&dir_icon.texture);
} }
@ -272,6 +256,10 @@ int FileSelector(int type)
FILE *snap; FILE *snap;
gui_menu *m = &menu_selector; gui_menu *m = &menu_selector;
int offset_ = -1;
int selection_ = -1;
int maxfiles_ = -1;
#ifdef HW_RVL #ifdef HW_RVL
int x,y; int x,y;
gui_butn *button; gui_butn *button;
@ -294,14 +282,171 @@ int FileSelector(int type)
bg_filesel[9+i].state &= ~IMAGE_VISIBLE; bg_filesel[9+i].state &= ~IMAGE_VISIBLE;
} }
/* Select cartridge type */ /* System ROM selection */
if (type >= FILETYPE_MAX)
{
/* Save current ROM browser */
offset_ = offset;
maxfiles_ = maxfiles;
selection_ = selection;
/* Initialize ROM browser */
maxfiles = ParseDirectory();
selection = offset = 0;
while (selection < maxfiles)
{
if (strstr(config.sys_rom[type-FILETYPE_MAX], filelist[selection].filename))
{
offset = selection;
while ((offset > (maxfiles - 10)) && (offset > 0))
{
offset--;
}
break;
}
selection++;
}
/* By default, select first file in directory if ROM is not found */
if (selection >= maxfiles)
{
selection = 0;
}
/* Set menu title and cartridge label type */
switch (type - FILETYPE_MAX)
{
case 0:
{
strcpy(m->title,"Sega CD (USA) BIOS Selection");
type = FILETYPE_MD;
break;
}
case 1:
{
strcpy(m->title,"Mega CD (PAL) BIOS Selection");
type = FILETYPE_MD;
break;
}
case 2:
{
strcpy(m->title,"Mega CD (JAP) BIOS Selection");
type = FILETYPE_MD;
break;
}
case 3:
{
strcpy(m->title,"Mega Drive/Genesis BootROM Selection");
type = FILETYPE_MD;
break;
}
case 4:
{
strcpy(m->title,"Master System (USA) BootROM Selection");
type = FILETYPE_MS;
break;
}
case 5:
{
strcpy(m->title,"Master System (PAL) BootROM Selection");
type = FILETYPE_MS;
break;
}
case 6:
{
strcpy(m->title,"Master System (JAP) BootROM Selection");
type = FILETYPE_MS;
break;
}
case 7:
{
strcpy(m->title,"Game Gear BootROM Selection");
type = FILETYPE_GG;
break;
}
case 8:
{
strcpy(m->title,"Game Genie ROM Selection");
type = FILETYPE_MD;
break;
}
case 9:
{
strcpy(m->title,"Action Replay (Pro) ROM Selection");
type = FILETYPE_MD;
break;
}
case 10:
{
strcpy(m->title,"Sonic & Knuckles ROM Selection");
type = FILETYPE_MD;
break;
}
case 11:
{
strcpy(m->title,"Sonic 2 & Knuckles ROM Selection");
type = FILETYPE_MD;
break;
}
}
}
else
{
/* reset menu title */
strcpy(m->title, "Game Selection");
}
/* Set default helper for Back button */
strcpy(m->helpers[0]->comment, "Exit");
/* Check if we are not browsing recent file list */
if (type >= 0) if (type >= 0)
{ {
/* Select cartridge type */ /* Select cartridge type */
bg_filesel[9 + type].data = Cart_png[type]; bg_filesel[9 + type].data = Cart_png[type];
bg_filesel[9 + type].state |= IMAGE_VISIBLE; bg_filesel[9 + type].state |= IMAGE_VISIBLE;
/* Get current directory */
char *dir = GetCurrentDirectory();
/* Get current directory name length */
int size = strlen(dir);
/* Check if we are not in Root directory */
if (size > 1)
{
if (dir[size - 2] != ':')
{
/* Update helper for Back button */
strcpy(m->helpers[0]->comment, "Previous Directory");
} }
}
/* Initialize directory icon */
dir_icon.texture = gxTextureOpenPNG(Browser_dir_png,0);
dir_icon.w = dir_icon.texture->width;
dir_icon.h = dir_icon.texture->height;
dir_icon.x = 26;
dir_icon.y = (26 - dir_icon.h)/2;
}
/* Initialize selection bar */
bar_over.texture = gxTextureOpenPNG(Overlay_bar_png,0);
bar_over.w = bar_over.texture->width;
bar_over.h = bar_over.texture->height;
bar_over.x = 16;
bar_over.y = (26 - bar_over.h)/2;
/* Initialize Menu */ /* Initialize Menu */
GUI_InitMenu(m); GUI_InitMenu(m);
@ -340,10 +485,10 @@ int FileSelector(int type)
/* show selected cartridge label */ /* show selected cartridge label */
bg_filesel[9 + type].state |= IMAGE_VISIBLE; bg_filesel[9 + type].state |= IMAGE_VISIBLE;
}
/* default screenshot file path */ /* default screenshot file path */
sprintf(fname,"%s/snaps/%s/%s", DEFAULT_PATH, Cart_dir[type], filelist[selection].filename); sprintf(fname,"%s/snaps/%s/%s", DEFAULT_PATH, Cart_dir[type], filelist[selection].filename);
}
/* restore recent type flag */ /* restore recent type flag */
type = -1; type = -1;
@ -376,7 +521,7 @@ int FileSelector(int type)
} }
} }
/* update helper */ /* update Action button helper */
if (m->selected != -1) if (m->selected != -1)
{ {
/* out of focus */ /* out of focus */
@ -390,8 +535,17 @@ int FileSelector(int type)
else else
{ {
/* this is a ROM file */ /* this is a ROM file */
if (offset_ != -1)
{
/* System ROM browser */
strcpy(action_select.comment,"Select File");
}
else
{
/* Normal ROM browser */
strcpy(action_select.comment,"Load File"); strcpy(action_select.comment,"Load File");
} }
}
/* Draw menu*/ /* Draw menu*/
GUI_DrawMenu(m); GUI_DrawMenu(m);
@ -399,6 +553,8 @@ int FileSelector(int type)
#ifdef HW_RVL #ifdef HW_RVL
if (Shutdown) if (Shutdown)
{ {
gxTextureClose(&bar_over.texture);
gxTextureClose(&dir_icon.texture);
gxTextureClose(&w_pointer); gxTextureClose(&w_pointer);
GUI_DeleteMenu(m); GUI_DeleteMenu(m);
GUI_FadeOut(); GUI_FadeOut();
@ -465,10 +621,10 @@ int FileSelector(int type)
if (p & PAD_BUTTON_DOWN) if (p & PAD_BUTTON_DOWN)
{ {
selection++; selection++;
if (selection == maxfiles) if (selection >= maxfiles)
selection = offset = 0; selection = offset = 0;
if ((selection - offset) >= 10) else if (selection >= (offset + 10))
offset += 10; offset++;
} }
/* highlight previous item */ /* highlight previous item */
@ -479,11 +635,10 @@ int FileSelector(int type)
{ {
selection = maxfiles - 1; selection = maxfiles - 1;
offset = maxfiles - 10; offset = maxfiles - 10;
if (offset < 0) offset = 0;
} }
if (selection < offset) else if (selection < offset)
offset -= 10; offset --;
if (offset < 0)
offset = 0;
} }
/* go back one page */ /* go back one page */
@ -494,10 +649,12 @@ int FileSelector(int type)
selection -= 10; selection -= 10;
if (selection < 0) if (selection < 0)
{ {
/* first page */
selection = offset = 0; selection = offset = 0;
} }
else if (selection < offset) else if (selection < offset)
{ {
/* previous page */
offset -= 10; offset -= 10;
if (offset < 0) offset = 0; if (offset < 0) offset = 0;
} }
@ -528,8 +685,19 @@ int FileSelector(int type)
/* quit */ /* quit */
else if (p & PAD_TRIGGER_Z) else if (p & PAD_TRIGGER_Z)
{ {
/* System ROM selection */
if (offset_ != -1)
{
/* restore current ROM browser */
offset = offset_;
maxfiles = maxfiles_;
selection = selection_;
}
gxTextureClose(&bar_over.texture);
gxTextureClose(&dir_icon.texture);
GUI_DeleteMenu(m); GUI_DeleteMenu(m);
return 0; return -1;
} }
/* previous directory */ /* previous directory */
@ -537,12 +705,40 @@ int FileSelector(int type)
{ {
string_offset = 0; string_offset = 0;
/* recent ROM list */
if (type < 0)
{
/* exit */
gxTextureClose(&bar_over.texture);
gxTextureClose(&dir_icon.texture);
GUI_DeleteMenu(m);
return -1;
}
/* update browser directory (and get current folder)*/ /* update browser directory (and get current folder)*/
if (UpdateDirectory(1, prev_folder)) if (UpdateDirectory(1, prev_folder))
{ {
/* get directory entries */ /* get directory entries */
maxfiles = ParseDirectory(); maxfiles = ParseDirectory();
/* Get current directory */
char *dir = GetCurrentDirectory();
/* current directory name length */
int size = strlen(dir);
/* Adjust helper for back button */
if ((size > 1) && (dir[size - 2] != ':'))
{
/* Back button goes up one directory */
strcpy(m->helpers[0]->comment, "Previous Directory");
}
else
{
/* Back button exits from root directory */
strcpy(m->helpers[0]->comment, "Exit");
}
/* clear selection by default */ /* clear selection by default */
selection = offset = 0; selection = offset = 0;
old = -1; old = -1;
@ -564,9 +760,20 @@ int FileSelector(int type)
} }
else else
{ {
/* exit */ /* System ROM selection */
if (offset_ != -1)
{
/* restore current ROM browser */
offset = offset_;
maxfiles = maxfiles_;
selection = selection_;
}
/* Exit */
gxTextureClose(&bar_over.texture);
gxTextureClose(&dir_icon.texture);
GUI_DeleteMenu(m); GUI_DeleteMenu(m);
return 0; return -1;
} }
} }
@ -592,13 +799,29 @@ int FileSelector(int type)
} }
else else
{ {
/* load ROM file from device */ int ret;
int ret = LoadFile(selection);
/* System ROM selection */
if (offset_ != -1)
{
/* return ROM file index */
ret = selection;
/* restore current ROM browser */
offset = offset_;
maxfiles = maxfiles_;
selection = selection_;
}
else
{
/* load ROM file from device then return ROM size (zero if an error occured) */
ret = LoadFile(selection);
}
/* exit menu */ /* exit menu */
gxTextureClose(&bar_over.texture);
gxTextureClose(&dir_icon.texture);
GUI_DeleteMenu(m); GUI_DeleteMenu(m);
/* return ROM size (or zero if an error occured) */
return ret; return ret;
} }
} }

View File

@ -1,7 +1,7 @@
/* /*
* filesel.c * filesel.c
* *
* ROM File Browser * File Browser
* *
* Copyright Eke-Eke (2009-2014) * Copyright Eke-Eke (2009-2014)
* *

View File

@ -355,8 +355,25 @@ static gui_item items_audio[13] =
{NULL,NULL,"High Freq: 20000 Hz", "Adjust EQ Highest Frequency", 56,132,276,48} {NULL,NULL,"High Freq: 20000 Hz", "Adjust EQ Highest Frequency", 56,132,276,48}
}; };
/* System ROM paths */
static gui_item items_rompaths[12] =
{
{NULL,NULL,"CD BIOS (USA): NOT FOUND", "Select Sega CD (USA) BIOS", 56,132,276,48},
{NULL,NULL,"CD BIOS (PAL): NOT FOUND", "Select Mega CD (PAL) BIOS", 56,132,276,48},
{NULL,NULL,"CD BIOS (JAP): NOT FOUND", "Select Mega CD (JAP) BIOS", 56,132,276,48},
{NULL,NULL,"MD BIOS (TMSS): NOT FOUND", "Select Mega Drive / Genesis BootROM", 56,132,276,48},
{NULL,NULL,"MS BIOS (USA): NOT FOUND", "Select Master System (USA) BootROM", 56,132,276,48},
{NULL,NULL,"MS BIOS (PAL): NOT FOUND", "Select Master System (PAL) BootROM", 56,132,276,48},
{NULL,NULL,"MS BIOS (JAP): NOT FOUND", "Select Master System (JAP) BootROM", 56,132,276,48},
{NULL,NULL,"Game Gear BIOS: NOT FOUND", "Select Game Gear BootROM", 56,132,276,48},
{NULL,NULL,"Game Genie: NOT FOUND", "Select Game Genie ROM", 56,132,276,48},
{NULL,NULL,"Action Replay: NOT FOUND", "Select Action Replay (Pro) ROM", 56,132,276,48},
{NULL,NULL,"S&K (2MB ROM): NOT FOUND", "Select Sonic & Knuckle main ROM", 56,132,276,48},
{NULL,NULL,"S2&K (256K ROM): NOT FOUND","Select Sonic 2 & Knuckle upmem ROM", 56,132,276,48},
};
/* System options */ /* System options */
static gui_item items_system[10] = static gui_item items_system[11] =
{ {
{NULL,NULL,"Console Hardware: AUTO", "Select system hardware model", 56,132,276,48}, {NULL,NULL,"Console Hardware: AUTO", "Select system hardware model", 56,132,276,48},
{NULL,NULL,"Console Region: AUTO", "Select system region", 56,132,276,48}, {NULL,NULL,"Console Region: AUTO", "Select system region", 56,132,276,48},
@ -367,6 +384,7 @@ static gui_item items_system[10] =
{NULL,NULL,"68k Address Error: ON", "Enable/disable 68k address error exceptions", 56,132,276,48}, {NULL,NULL,"68k Address Error: ON", "Enable/disable 68k address error exceptions", 56,132,276,48},
{NULL,NULL,"Lock-on: OFF", "Select Lock-On cartridge type", 56,132,276,48}, {NULL,NULL,"Lock-on: OFF", "Select Lock-On cartridge type", 56,132,276,48},
{NULL,NULL,"Cartridge Swap: OFF", "Enable/disable cartridge hot swap", 56,132,276,48}, {NULL,NULL,"Cartridge Swap: OFF", "Enable/disable cartridge hot swap", 56,132,276,48},
{NULL,NULL,"BIOS & Lock-On ROM paths","Configure BIOS & Lock-On ROM paths", 56,132,276,48},
{NULL,NULL,"SVP Cycles: 1500", "Adjust SVP chip emulation speed", 56,132,276,48} {NULL,NULL,"SVP Cycles: 1500", "Adjust SVP chip emulation speed", 56,132,276,48}
}; };
@ -378,7 +396,7 @@ static gui_item items_video[16] =
#endif #endif
{ {
{NULL,NULL,"Display: PROGRESSIVE", "Select video mode", 56,132,276,48}, {NULL,NULL,"Display: PROGRESSIVE", "Select video mode", 56,132,276,48},
{NULL,NULL,"TV mode: 50/60Hz", "Select video refresh rate", 56,132,276,48}, {NULL,NULL,"TV mode: 50/60HZ", "Select video refresh rate", 56,132,276,48},
{NULL,NULL,"VSYNC: AUTO", "Enable/disable sync with Video Hardware", 56,132,276,48}, {NULL,NULL,"VSYNC: AUTO", "Enable/disable sync with Video Hardware", 56,132,276,48},
{NULL,NULL,"GX Bilinear Filter: OFF", "Enable/disable texture hardware filtering", 56,132,276,48}, {NULL,NULL,"GX Bilinear Filter: OFF", "Enable/disable texture hardware filtering", 56,132,276,48},
{NULL,NULL,"GX Deflickering Filter: OFF","Enable/disable GX hardware filtering", 56,132,276,48}, {NULL,NULL,"GX Deflickering Filter: OFF","Enable/disable GX hardware filtering", 56,132,276,48},
@ -582,6 +600,20 @@ static gui_menu menu_options =
NULL NULL
}; };
/* System ROM Path submenu */
static gui_menu menu_rompaths =
{
"System ROM Paths",
0,0,
12,4,6,0,
items_rompaths,
buttons_list,
bg_list,
{&action_cancel, &action_select},
{&arrow_up,&arrow_down},
NULL
};
/* System Options menu */ /* System Options menu */
static gui_menu menu_system = static gui_menu menu_system =
{ {
@ -1107,6 +1139,98 @@ static void soundmenu ()
GUI_DeleteMenu(m); GUI_DeleteMenu(m);
} }
/****************************************************************************
* System ROM paths menu
*
****************************************************************************/
static void rompathmenu ()
{
FILE *f;
int i, ret;
gui_menu *m = &menu_rompaths;
gui_item *items = m->items;
for (i=0; i<12; i++)
{
f = fopen(config.sys_rom[i],"rb");
if (f)
{
strcpy(strstr(items[i].text,":") + 2, "FOUND");
fclose(f);
}
else
{
strcpy(strstr(items[i].text,":") + 2, "NOT FOUND");
}
}
GUI_InitMenu(m);
while (1)
{
ret = GUI_RunMenu(m);
switch (ret)
{
case -1:
{
GUI_DeleteMenu(m);
return;
}
default:
{
/* Initialize System ROM browser */
if (OpenDirectory(config.l_device, ret + FILETYPE_MAX))
{
/* Open System ROM browser */
GUI_DeleteMenu(m);
i = FileSelector(ret + FILETYPE_MAX);
/* Get current System ROM path */
char *dir = GetCurrentDirectory();
/* System ROM selected ? */
if (i >= 0)
{
/* full System ROM pathname */
sprintf(config.sys_rom[ret],"%s%s",dir,filelist[i].filename);
/* mark System ROM as found */
strcpy(strstr(items[ret].text,":") + 2, "FOUND");
/* Genesis BOOT ROM special case */
if (config.sys_rom[ret] == MD_BIOS)
{
/* Genesis BOOT ROM must be reloaded */
if (load_archive(MD_BIOS, boot_rom, 0x800, NULL) > 0)
{
/* check if BOOT ROM header is valid */
if (!memcmp((char *)(boot_rom + 0x120),"GENESIS OS", 10))
{
/* mark Genesis BIOS as loaded */
system_bios |= SYSTEM_MD;
}
else
{
/* mark Genesis BIOS as unloaded */
system_bios &= ~SYSTEM_MD;
}
}
}
}
free(dir);
GUI_InitMenu(m);
}
}
}
}
GUI_DeleteMenu(m);
}
/**************************************************************************** /****************************************************************************
* System Settings menu * System Settings menu
* *
@ -1149,9 +1273,9 @@ static void systemmenu ()
else if (config.region_detect == 1) else if (config.region_detect == 1)
sprintf (items[1].text, "Console Region: USA"); sprintf (items[1].text, "Console Region: USA");
else if (config.region_detect == 2) else if (config.region_detect == 2)
sprintf (items[1].text, "Console Region: EUROPE"); sprintf (items[1].text, "Console Region: PAL");
else if (config.region_detect == 3) else if (config.region_detect == 3)
sprintf (items[1].text, "Console Region: JAPAN"); sprintf (items[1].text, "Console Region: JAP");
if (config.vdp_mode == 0) if (config.vdp_mode == 0)
sprintf (items[2].text, "VDP Mode: AUTO"); sprintf (items[2].text, "VDP Mode: AUTO");
@ -1184,12 +1308,12 @@ static void systemmenu ()
if (svp) if (svp)
{ {
sprintf (items[9].text, "SVP Cycles: %d", SVP_cycles); sprintf (items[10].text, "SVP Cycles: %d", SVP_cycles);
m->max_items = 10; m->max_items = 11;
} }
else else
{ {
m->max_items = 9; m->max_items = 10;
} }
GUI_InitMenu(m); GUI_InitMenu(m);
@ -1308,9 +1432,9 @@ static void systemmenu ()
else if (config.region_detect == 1) else if (config.region_detect == 1)
sprintf (items[1].text, "Console Region: USA"); sprintf (items[1].text, "Console Region: USA");
else if (config.region_detect == 2) else if (config.region_detect == 2)
sprintf (items[1].text, "Console Region: EUR"); sprintf (items[1].text, "Console Region: PAL");
else if (config.region_detect == 3) else if (config.region_detect == 3)
sprintf (items[1].text, "Console Region: JAPAN"); sprintf (items[1].text, "Console Region: JAP");
/* force system reinitialization + region BIOS */ /* force system reinitialization + region BIOS */
reinit = 2; reinit = 2;
@ -1431,10 +1555,18 @@ static void systemmenu ()
break; break;
} }
case 9: /*** SVP cycles per line ***/ case 9: /*** System ROM paths ***/
{
GUI_DeleteMenu(m);
rompathmenu();
GUI_InitMenu(m);
break;
}
case 10: /*** SVP cycles per line ***/
{ {
GUI_OptionBox(m,0,"SVP Cycles",(void *)&SVP_cycles,1,1,1500,1); GUI_OptionBox(m,0,"SVP Cycles",(void *)&SVP_cycles,1,1,1500,1);
sprintf (items[9].text, "SVP Cycles: %d", SVP_cycles); sprintf (items[10].text, "SVP Cycles: %d", SVP_cycles);
break; break;
} }
@ -2930,11 +3062,12 @@ static void optionmenu(void)
* *
****************************************************************************/ ****************************************************************************/
static t_slot slots[5]; static t_slot slots[5];
static gx_texture *star;
static void savemenu_cb(void) static void savemenu_cb(void)
{ {
int i; int i;
char msg[16]; char msg[16];
gx_texture *star = gxTextureOpenPNG(Star_full_png,0);
if (sram.on) if (sram.on)
{ {
@ -2974,7 +3107,6 @@ static void savemenu_cb(void)
if (i == config.s_default) if (i == config.s_default)
gxDrawTexture(star,22,buttons_saves[i].y+(buttons_saves[i].h-star->height)/2,star->width,star->height,255); gxDrawTexture(star,22,buttons_saves[i].y+(buttons_saves[i].h-star->height)/2,star->width,star->height,255);
} }
gxTextureClose(&star);
} }
static int savemenu(void) static int savemenu(void)
@ -2986,6 +3118,7 @@ static int savemenu(void)
gui_menu *m = &menu_saves; gui_menu *m = &menu_saves;
FILE *snap; FILE *snap;
star = gxTextureOpenPNG(Star_full_png,0);
GUI_InitMenu(m); GUI_InitMenu(m);
GUI_DrawMenuFX(m,30,0); GUI_DrawMenuFX(m,30,0);
@ -3249,6 +3382,7 @@ static int savemenu(void)
m->bg_images[5].state |= IMAGE_SLIDE_TOP; m->bg_images[5].state |= IMAGE_SLIDE_TOP;
GUI_DrawMenuFX(m,30,1); GUI_DrawMenuFX(m,30,1);
GUI_DeleteMenu(m); GUI_DeleteMenu(m);
gxTextureClose(&star);
return ret; return ret;
} }
@ -3294,7 +3428,7 @@ static int loadgamemenu ()
if (ret) if (ret)
{ {
GUI_DeleteMenu(m); GUI_DeleteMenu(m);
if (FileSelector(filetype)) if (FileSelector(filetype) > 0)
{ {
/* directly jump to game */ /* directly jump to game */
return 1; return 1;
@ -3540,9 +3674,12 @@ static void mainmenu_cb(void)
int status = areplay_get_status(); int status = areplay_get_status();
/* Action Replay Switch current status */ /* Action Replay Switch current status */
if (status == AR_SWITCH_TRAINER) strcpy(temp,"TM"); if (status == AR_SWITCH_TRAINER)
else if (status == AR_SWITCH_ON) strcpy(temp,"ON"); strcpy(temp,"TM");
else strcpy(temp,"OFF"); else if (status == AR_SWITCH_ON)
strcpy(temp,"ON");
else
strcpy(temp,"OFF");
/* Display informations */ /* Display informations */
if (m->selected == 6) if (m->selected == 6)

View File

@ -110,16 +110,11 @@ static void init_machine(void)
/* mark all BIOS as unloaded */ /* mark all BIOS as unloaded */
system_bios = 0; system_bios = 0;
/* Genesis BOOT ROM support (2KB max) */ /* try to load Genesis BOOT ROM (2KB max) */
memset(boot_rom, 0xFF, 0x800); memset(boot_rom, 0xFF, 0x800);
FILE *fp = fopen(MD_BIOS, "rb"); if (load_archive(MD_BIOS, boot_rom, 0x800, NULL) > 0)
if (fp != NULL)
{ {
/* read BOOT ROM */ /* check if BOOT ROM header is valid */
fread(boot_rom, 1, 0x800, fp);
fclose(fp);
/* check BOOT ROM */
if (!memcmp((char *)(boot_rom + 0x120),"GENESIS OS", 10)) if (!memcmp((char *)(boot_rom + 0x120),"GENESIS OS", 10))
{ {
/* mark Genesis BIOS as loaded */ /* mark Genesis BIOS as loaded */

View File

@ -37,18 +37,19 @@
/*************************************************/ /*************************************************/
/* required by Genesis Plus GX core */ /* required by Genesis Plus GX core */
/*************************************************/ /*************************************************/
#define GG_ROM "/genplus/lock-on/ggenie.bin" #define CD_BIOS_US config.sys_rom[0]
#define AR_ROM "/genplus/lock-on/areplay.bin" #define CD_BIOS_EU config.sys_rom[1]
#define SK_ROM "/genplus/lock-on/sk.bin" #define CD_BIOS_JP config.sys_rom[2]
#define SK_UPMEM "/genplus/lock-on/sk2chip.bin" #define MD_BIOS config.sys_rom[3]
#define MS_BIOS_US "/genplus/bios/bios_U.sms" #define MS_BIOS_US config.sys_rom[4]
#define MS_BIOS_EU "/genplus/bios/bios_E.sms" #define MS_BIOS_EU config.sys_rom[5]
#define MS_BIOS_JP "/genplus/bios/bios_J.sms" #define MS_BIOS_JP config.sys_rom[6]
#define GG_BIOS "/genplus/bios/bios.gg" #define GG_BIOS config.sys_rom[7]
#define MD_BIOS "/genplus/bios/bios_MD.bin" #define GG_ROM config.sys_rom[8]
#define CD_BIOS_US "/genplus/bios/bios_CD_U.bin" #define AR_ROM config.sys_rom[9]
#define CD_BIOS_EU "/genplus/bios/bios_CD_E.bin" #define SK_ROM config.sys_rom[10]
#define CD_BIOS_JP "/genplus/bios/bios_CD_J.bin" #define SK_UPMEM config.sys_rom[11]
#define CD_BRAM_US "/genplus/saves/cd/scd_U.brm" #define CD_BRAM_US "/genplus/saves/cd/scd_U.brm"
#define CD_BRAM_EU "/genplus/saves/cd/scd_E.brm" #define CD_BRAM_EU "/genplus/saves/cd/scd_E.brm"
#define CD_BRAM_JP "/genplus/saves/cd/scd_J.brm" #define CD_BRAM_JP "/genplus/saves/cd/scd_J.brm"