add game genie support, FDS BIOS and game genie ROM are set to load from fceugx/disksys.rom and fceugx/gg.rom

This commit is contained in:
dborth 2009-07-29 06:33:17 +00:00
parent 906517a7c0
commit 0a40d9f9c6
9 changed files with 71 additions and 7 deletions

View File

@ -293,7 +293,7 @@ void setchr8r(int r, unsigned int V)
if(CHRram[r])
PPUCHRRAM|=(255);
else
PPUCHRRAM=0;
PPUCHRRAM=0;
}
void setchr1(unsigned int A, unsigned int V)
@ -429,11 +429,15 @@ void SetupCartMirroring(int m, int hard, uint8 *extra)
mirrorhard=hard;
}
#ifdef GEKKO
uint8 *GENIEROM=0;
#else
static uint8 *GENIEROM=0;
#endif
void FixGenieMap(void);
// Called when a game(file) is opened successfully.
// Called when a game(file) is opened successfully.
void OpenGenie(void)
{
FILE *fp;

View File

@ -110,7 +110,11 @@ static void CloseGame(void)
if(GameInfo->type!=GIT_NSF)
{
#ifdef GEKKO
FCEU_FlushGameCheats(0,1); // don't save cheats
#else
FCEU_FlushGameCheats(0,0);
#endif
}
GameInterface(GI_CLOSE);

View File

@ -9,6 +9,8 @@
* Cheat handling
***************************************************************************/
#include <malloc.h>
#include "fceugx.h"
#include "fceusupport.h"
#include "fileop.h"
@ -143,3 +145,50 @@ SetupCheats()
FreeSaveBuffer ();
}
void OpenGameGenie()
{
if (GENIEROM) // already loaded
{
geniestage=1;
return;
}
int romSize = 0;
char * tmpbuffer = (char *) memalign(32, 512 * 1024);
if(!tmpbuffer)
return;
char filepath[1024];
if (MakeFilePath(filepath, FILE_GGROM, GCSettings.LoadMethod))
{
romSize = LoadFile(tmpbuffer, filepath, 0, GCSettings.LoadMethod, SILENT);
}
if (romSize > 0)
{
GENIEROM=(uint8 *)malloc(4096+1024);
if(tmpbuffer[0]==0x4E) /* iNES ROM image */
{
memcpy(GENIEROM,tmpbuffer+16,4096);
memcpy(GENIEROM+4096,tmpbuffer+16400,256);
}
else
{
memcpy(GENIEROM,tmpbuffer,4352);
}
/* Workaround for the FCE Ultra CHR page size only being 1KB */
for(int x=0; x<4; x++)
memcpy(GENIEROM+4096+(x<<8),GENIEROM+4096,256);
geniestage=1;
}
else
{
free(GENIEROM);
GENIEROM=0;
}
free(tmpbuffer);
}

View File

@ -10,5 +10,6 @@
***************************************************************************/
void SetupCheats();
void OpenGameGenie();
extern int numcheats;

View File

@ -274,7 +274,7 @@ int main(int argc, char *argv[])
if (!FCEUI_Initialize())
ExitApp();
FCEUI_SetGameGenie(0); // 0 - OFF, 1 - ON
FCEUI_SetGameGenie(1); // 0 - OFF, 1 - ON
memset(FDSBIOS, 0, sizeof(FDSBIOS)); // clear FDS BIOS memory

View File

@ -40,6 +40,7 @@ enum {
FILE_STATE,
FILE_ROM,
FILE_FDSBIOS,
FILE_GGROM,
FILE_CHEAT,
FILE_PREF
};

View File

@ -129,9 +129,9 @@ int GCMemROM(int method, int size)
{
FCEU_ResetVidSys();
//if(GameInfo->type!=GIT_NSF)
// if(FSettings.GameGenie)
// OpenGenie();
if(GameInfo->type!=GIT_NSF)
if(FSettings.GameGenie)
OpenGameGenie();
PowerNES();
//if(GameInfo->type!=GIT_NSF)

View File

@ -42,6 +42,7 @@ extern int iNESLoad(const char *name, FCEUFILE *fp, int o);
extern int UNIFLoad(const char *name, FCEUFILE *fp);
extern int NSFLoad(FCEUFILE *fp);
extern uint8 FDSBIOS[8192];
extern uint8 *GENIEROM;
extern FCEUGI *GameInfo;
extern int CloseGame();

View File

@ -269,9 +269,13 @@ bool MakeFilePath(char filepath[], int type, int method, char * filename, int fi
break;
case FILE_FDSBIOS:
sprintf(folder, GCSettings.LoadFolder);
sprintf(folder, "fceugx");
sprintf(file, "disksys.rom");
break;
case FILE_GGROM:
sprintf(folder, "fceugx");
sprintf(file, "gg.rom");
break;
case FILE_CHEAT:
sprintf(folder, GCSettings.CheatFolder);
sprintf(file, "%s.cht", romFilename);