[Tuxnes-devel] GameGenie: Only one code is used.
Brought to you by:
tmmm
|
From: Mike M. <che...@ya...> - 2003-11-30 15:43:25
|
I'm trying to fix this, but I get hung up on how to add to a pointer when parsing a string. So if
you can get this patch to work, much thanx.
The problem I can't overcome is the call to DecodeGameGenieCode needs ggcode[gamegenie]. It's a
pointer withought a cast. Giving it a cast like (char *) dose nothing. What I need to do is add
gamegenie to the value of (char *)ggcode to get a new pointer that points into the middle, after
the last ',', of ggcode. I do this in 2 places, one is unavoidable unless you rewrite the whole
thing.
--- tuxnes-0.75/emu.c 2003-11-30 09:11:49.000000000 -0600
+++ tuxnes-gggg/emu.c 2003-11-30 09:09:48.000000000 -0600
@@ -67,9 +67,8 @@
int dolink = 0;
int MAPPERNUMBER = -1;
int SRAM_ENABLED;
-int gamegenie = 0;
-int irqflag = 0;
-int mapmirror = 0;
+unsigned int irqflag = 0;
+unsigned int mapmirror = 0;
int mapperoverride = 0;
int ignorebadinstr = 0;
int showheader = 0;
@@ -1191,7 +1190,8 @@
char *mkdircall; /* buffer for /bin/mkdir call */
char *palfile = 0; /* palette file */
- char *ggcode;
+ int gamegenie = 0;
+ char *ggcode = NULL;
int ggret, parseret;
/* for the Game Genie */
@@ -1205,8 +1205,6 @@
int romfd;
#endif
- ggcode = NULL;
-
/* set up the mapper arrays */
InitMapperSubsystem();
@@ -1269,15 +1267,6 @@
cmirror = 0;
dolink = 0;
disassemble = 0;
- gamegenie = 0;
-
- /* check for the default output device */
- if ((audiofd = open (DSP, O_CREAT | O_WRONLY | O_APPEND)) < 0)
- sound_config.audiofile = NULL;
- else {
- sound_config.audiofile = DSP;
- close(audiofd);
- }
/*
* Parse args
@@ -1373,8 +1362,9 @@
showheader = 1;
break;
case 'g':
- gamegenie = 1;
ggcode = optarg;
+ for ( gamegenie = strlen(ggcode); gamegenie <= 1; gamegenie-- )
+ if ( ggcode[gamegenie-1] == ',' ) break;
break;
case 'j':
case '1':
@@ -2126,12 +2116,15 @@
}
/* enter the Game Genie codes */
- if (gamegenie)
+ while (gamegenie)
{
- ggret = DecodeGameGenieCode (ggcode, &address, &data, &compare);
+ char * _ggcode;
+ _ggcode = ggcode + gamegenie;
+ ggret = DecodeGameGenieCode (_ggcode, &address, &data, &compare);
if (ggret == GAME_GENIE_BAD_CODE)
{
- fprintf (stderr, "invalid Game Genie code: %s\n", ggcode);
+ fprintf (stderr, "invalid Game Genie code: %s\n", _ggcode);
+ gamegenie=0;
}
else if (ggret == GAME_GENIE_8_CHAR)
{
@@ -2167,6 +2160,9 @@
fprintf (stderr, "Game Genie: value at %04X = %02X\n", address,
MAPTABLE[address >> 12][address]);
}
+ bzero( ggcode + --gamegenie, 1 + strlen(ggcode) - gamegenie);
+ for ( gamegenie = strlen(ggcode); gamegenie <= 1; gamegenie-- )
+ if ( ggcode[gamegenie-1] == ',' ) break;
}
/* Choose renderer */
__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/
|