Partial cleanup of sprintf usage in favor of snprintf. This is to resolve deprecation warnings on Mac OSX

This commit is contained in:
harry 2024-02-23 20:53:01 -05:00
parent 80f17c664b
commit 7b79d9db4c
13 changed files with 146 additions and 117 deletions

View File

@ -286,7 +286,7 @@ char *Disassemble(int addr, uint8 *opcode) {
#ifdef BRK_3BYTE_HACK #ifdef BRK_3BYTE_HACK
case 0x00: case 0x00:
sprintf(str,"BRK %02X %02X", opcode[1], opcode[2]); snprintf(str, sizeof(str), "BRK %02X %02X", opcode[1], opcode[2]);
break; break;
#else #else
case 0x00: strcpy(str,"BRK"); break; case 0x00: strcpy(str,"BRK"); break;
@ -333,7 +333,7 @@ char *Disassemble(int addr, uint8 *opcode) {
case 0xE1: strcpy(chr,"SBC"); goto _indirectx; case 0xE1: strcpy(chr,"SBC"); goto _indirectx;
_indirectx: _indirectx:
indirectX(tmp); indirectX(tmp);
sprintf(str,"%s ($%02X,X) @ $%04X = #$%02X", chr,opcode[1],tmp,GetMem(tmp)); snprintf(str, sizeof(str), "%s ($%02X,X) @ $%04X = #$%02X", chr,opcode[1],tmp,GetMem(tmp));
break; break;
//Zero Page //Zero Page
@ -361,7 +361,7 @@ char *Disassemble(int addr, uint8 *opcode) {
_zeropage: _zeropage:
// ################################## Start of SP CODE ########################### // ################################## Start of SP CODE ###########################
// Change width to %04X // don't! // Change width to %04X // don't!
sprintf(str,"%s $%02X = #$%02X", chr,opcode[1],GetMem(opcode[1])); snprintf(str, sizeof(str), "%s $%02X = #$%02X", chr,opcode[1],GetMem(opcode[1]));
// ################################## End of SP CODE ########################### // ################################## End of SP CODE ###########################
break; break;
@ -379,7 +379,7 @@ char *Disassemble(int addr, uint8 *opcode) {
case 0xE0: strcpy(chr,"CPX"); goto _immediate; case 0xE0: strcpy(chr,"CPX"); goto _immediate;
case 0xE9: strcpy(chr,"SBC"); goto _immediate; case 0xE9: strcpy(chr,"SBC"); goto _immediate;
_immediate: _immediate:
sprintf(str,"%s #$%02X", chr,opcode[1]); snprintf(str, sizeof(str), "%s #$%02X", chr,opcode[1]);
break; break;
//Absolute //Absolute
@ -406,7 +406,7 @@ char *Disassemble(int addr, uint8 *opcode) {
case 0xEE: strcpy(chr,"INC"); goto _absolute; case 0xEE: strcpy(chr,"INC"); goto _absolute;
_absolute: _absolute:
absolute(tmp); absolute(tmp);
sprintf(str,"%s $%04X = #$%02X", chr,tmp,GetMem(tmp)); snprintf(str, sizeof(str), "%s $%04X = #$%02X", chr,tmp,GetMem(tmp));
break; break;
//branches //branches
@ -420,7 +420,7 @@ char *Disassemble(int addr, uint8 *opcode) {
case 0xF0: strcpy(chr,"BEQ"); goto _branch; case 0xF0: strcpy(chr,"BEQ"); goto _branch;
_branch: _branch:
relative(tmp); relative(tmp);
sprintf(str,"%s $%04X", chr,tmp); snprintf(str, sizeof(str), "%s $%04X", chr,tmp);
break; break;
//(Indirect),Y //(Indirect),Y
@ -434,7 +434,7 @@ char *Disassemble(int addr, uint8 *opcode) {
case 0xF1: strcpy(chr,"SBC"); goto _indirecty; case 0xF1: strcpy(chr,"SBC"); goto _indirecty;
_indirecty: _indirecty:
indirectY(tmp); indirectY(tmp);
sprintf(str,"%s ($%02X),Y @ $%04X = #$%02X", chr,opcode[1],tmp,GetMem(tmp)); snprintf(str, sizeof(str), "%s ($%02X),Y @ $%04X = #$%02X", chr,opcode[1],tmp,GetMem(tmp));
break; break;
//Zero Page,X //Zero Page,X
@ -458,7 +458,7 @@ char *Disassemble(int addr, uint8 *opcode) {
zpIndex(tmp,RX); zpIndex(tmp,RX);
// ################################## Start of SP CODE ########################### // ################################## Start of SP CODE ###########################
// Change width to %04X // don't! // Change width to %04X // don't!
sprintf(str,"%s $%02X,X @ $%04X = #$%02X", chr,opcode[1],tmp,GetMem(tmp)); snprintf(str, sizeof(str), "%s $%02X,X @ $%04X = #$%02X", chr,opcode[1],tmp,GetMem(tmp));
// ################################## End of SP CODE ########################### // ################################## End of SP CODE ###########################
break; break;
@ -475,7 +475,7 @@ char *Disassemble(int addr, uint8 *opcode) {
_absolutey: _absolutey:
absolute(tmp); absolute(tmp);
tmp2=(tmp+RY); tmp2=(tmp+RY);
sprintf(str,"%s $%04X,Y @ $%04X = #$%02X", chr,tmp,tmp2,GetMem(tmp2)); snprintf(str, sizeof(str), "%s $%04X,Y @ $%04X = #$%02X", chr,tmp,tmp2,GetMem(tmp2));
break; break;
//Absolute,X //Absolute,X
@ -497,16 +497,16 @@ char *Disassemble(int addr, uint8 *opcode) {
_absolutex: _absolutex:
absolute(tmp); absolute(tmp);
tmp2=(tmp+RX); tmp2=(tmp+RX);
sprintf(str,"%s $%04X,X @ $%04X = #$%02X", chr,tmp,tmp2,GetMem(tmp2)); snprintf(str, sizeof(str), "%s $%04X,X @ $%04X = #$%02X", chr,tmp,tmp2,GetMem(tmp2));
break; break;
//jumps //jumps
case 0x20: strcpy(chr,"JSR"); goto _jump; case 0x20: strcpy(chr,"JSR"); goto _jump;
case 0x4C: strcpy(chr,"JMP"); goto _jump; case 0x4C: strcpy(chr,"JMP"); goto _jump;
case 0x6C: absolute(tmp); sprintf(str,"JMP ($%04X) = $%04X", tmp,GetMem(tmp)|GetMem(tmp+1)<<8); break; case 0x6C: absolute(tmp); snprintf(str, sizeof(str), "JMP ($%04X) = $%04X", tmp,GetMem(tmp)|GetMem(tmp+1)<<8); break;
_jump: _jump:
absolute(tmp); absolute(tmp);
sprintf(str,"%s $%04X", chr,tmp); snprintf(str, sizeof(str), "%s $%04X", chr,tmp);
break; break;
//Zero Page,Y //Zero Page,Y
@ -516,7 +516,7 @@ char *Disassemble(int addr, uint8 *opcode) {
zpIndex(tmp,RY); zpIndex(tmp,RY);
// ################################## Start of SP CODE ########################### // ################################## Start of SP CODE ###########################
// Change width to %04X // don't! // Change width to %04X // don't!
sprintf(str,"%s $%02X,Y @ $%04X = #$%02X", chr,opcode[1],tmp,GetMem(tmp)); snprintf(str, sizeof(str), "%s $%02X,Y @ $%04X = #$%02X", chr,opcode[1],tmp,GetMem(tmp));
// ################################## End of SP CODE ########################### // ################################## End of SP CODE ###########################
break; break;

View File

@ -130,7 +130,7 @@ AboutWindow::AboutWindow(QWidget *parent)
mainLayout->addLayout( hbox1 ); mainLayout->addLayout( hbox1 );
sprintf( stmp, "git URL: %s", fceu_get_git_url() ); snprintf( stmp, sizeof(stmp), "git URL: %s", fceu_get_git_url() );
hbox1 = new QHBoxLayout(); hbox1 = new QHBoxLayout();
lbl = new QLabel( tr(stmp) ); lbl = new QLabel( tr(stmp) );
@ -140,7 +140,7 @@ AboutWindow::AboutWindow(QWidget *parent)
mainLayout->addLayout( hbox1 ); mainLayout->addLayout( hbox1 );
sprintf( stmp, "git Revision: %s", fceu_get_git_rev() ); snprintf( stmp, sizeof(stmp), "git Revision: %s", fceu_get_git_rev() );
hbox1 = new QHBoxLayout(); hbox1 = new QHBoxLayout();
lbl = new QLabel( tr(stmp) ); lbl = new QLabel( tr(stmp) );
@ -191,23 +191,23 @@ AboutWindow::AboutWindow(QWidget *parent)
credits->insertPlainText( "\nOpen Source Dependencies:\n" ); credits->insertPlainText( "\nOpen Source Dependencies:\n" );
sprintf( stmp, " Compiled with Qt version %d.%d.%d\n", QT_VERSION_MAJOR, QT_VERSION_MINOR, QT_VERSION_PATCH ); snprintf( stmp, sizeof(stmp), " Compiled with Qt version %d.%d.%d\n", QT_VERSION_MAJOR, QT_VERSION_MINOR, QT_VERSION_PATCH );
credits->insertPlainText( stmp ); credits->insertPlainText( stmp );
sprintf( stmp, " Compiled with SDL version %d.%d.%d\n", SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL ); snprintf( stmp, sizeof(stmp), " Compiled with SDL version %d.%d.%d\n", SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL );
credits->insertPlainText( stmp ); credits->insertPlainText( stmp );
SDL_version v; SDL_version v;
SDL_GetVersion(&v); SDL_GetVersion(&v);
sprintf( stmp, " Linked with SDL version %d.%d.%d\n", v.major, v.minor, v.patch); snprintf( stmp, sizeof(stmp), " Linked with SDL version %d.%d.%d\n", v.major, v.minor, v.patch);
credits->insertPlainText( stmp ); credits->insertPlainText( stmp );
#ifdef ZLIB_VERSION #ifdef ZLIB_VERSION
sprintf( stmp, " Compiled with zlib %s\n", ZLIB_VERSION ); snprintf( stmp, sizeof(stmp), " Compiled with zlib %s\n", ZLIB_VERSION );
credits->insertPlainText( stmp ); credits->insertPlainText( stmp );
#endif #endif
#ifdef _USE_LIBARCHIVE #ifdef _USE_LIBARCHIVE
sprintf( stmp, " Compiled with libarchive %s\n", ARCHIVE_VERSION_ONLY_STRING ); snprintf( stmp, sizeof(stmp), " Compiled with libarchive %s\n", ARCHIVE_VERSION_ONLY_STRING );
credits->insertPlainText( stmp ); credits->insertPlainText( stmp );
const char *libArcName[] = { "zlib", "liblzma", "bzlib", "liblz4", "libzstd", nullptr }; const char *libArcName[] = { "zlib", "liblzma", "bzlib", "liblz4", "libzstd", nullptr };
const char *libArcVersion[] = { archive_zlib_version(), archive_liblzma_version(), const char *libArcVersion[] = { archive_zlib_version(), archive_liblzma_version(),
@ -217,7 +217,7 @@ AboutWindow::AboutWindow(QWidget *parent)
{ {
if (libArcVersion[i]) if (libArcVersion[i])
{ {
sprintf( stmp, " %s %s\n", libArcName[i], libArcVersion[i]); snprintf( stmp, sizeof(stmp), " %s %s\n", libArcName[i], libArcVersion[i]);
credits->insertPlainText( stmp ); credits->insertPlainText( stmp );
} }
i++; i++;
@ -225,27 +225,27 @@ AboutWindow::AboutWindow(QWidget *parent)
#endif #endif
#ifdef _S9XLUA_H #ifdef _S9XLUA_H
sprintf( stmp, " Compiled with %s\n", LUA_RELEASE ); snprintf( stmp, sizeof(stmp), " Compiled with %s\n", LUA_RELEASE );
credits->insertPlainText( stmp ); credits->insertPlainText( stmp );
#endif #endif
#ifdef _USE_LIBAV #ifdef _USE_LIBAV
sprintf( stmp, " Compiled with ffmpeg libraries:\n"); snprintf( stmp, sizeof(stmp), " Compiled with ffmpeg libraries:\n");
credits->insertPlainText( stmp ); credits->insertPlainText( stmp );
sprintf( stmp, " libavutil %i.%i.%i\n", LIBAVUTIL_VERSION_MAJOR, LIBAVUTIL_VERSION_MINOR, LIBAVUTIL_VERSION_MICRO); snprintf( stmp, sizeof(stmp), " libavutil %i.%i.%i\n", LIBAVUTIL_VERSION_MAJOR, LIBAVUTIL_VERSION_MINOR, LIBAVUTIL_VERSION_MICRO);
credits->insertPlainText( stmp ); credits->insertPlainText( stmp );
sprintf( stmp, " libavformat %i.%i.%i\n", LIBAVFORMAT_VERSION_MAJOR, LIBAVFORMAT_VERSION_MINOR, LIBAVFORMAT_VERSION_MICRO); snprintf( stmp, sizeof(stmp), " libavformat %i.%i.%i\n", LIBAVFORMAT_VERSION_MAJOR, LIBAVFORMAT_VERSION_MINOR, LIBAVFORMAT_VERSION_MICRO);
credits->insertPlainText( stmp ); credits->insertPlainText( stmp );
sprintf( stmp, " libavcodec %i.%i.%i\n", LIBAVCODEC_VERSION_MAJOR, LIBAVCODEC_VERSION_MINOR, LIBAVCODEC_VERSION_MICRO); snprintf( stmp, sizeof(stmp), " libavcodec %i.%i.%i\n", LIBAVCODEC_VERSION_MAJOR, LIBAVCODEC_VERSION_MINOR, LIBAVCODEC_VERSION_MICRO);
credits->insertPlainText( stmp ); credits->insertPlainText( stmp );
sprintf( stmp, " libswscale %i.%i.%i\n", LIBSWSCALE_VERSION_MAJOR, LIBSWSCALE_VERSION_MINOR, LIBSWSCALE_VERSION_MICRO); snprintf( stmp, sizeof(stmp), " libswscale %i.%i.%i\n", LIBSWSCALE_VERSION_MAJOR, LIBSWSCALE_VERSION_MINOR, LIBSWSCALE_VERSION_MICRO);
credits->insertPlainText( stmp ); credits->insertPlainText( stmp );
sprintf( stmp, " libswresample %i.%i.%i\n", LIBSWRESAMPLE_VERSION_MAJOR, LIBSWRESAMPLE_VERSION_MINOR, LIBSWRESAMPLE_VERSION_MICRO); snprintf( stmp, sizeof(stmp), " libswresample %i.%i.%i\n", LIBSWRESAMPLE_VERSION_MAJOR, LIBSWRESAMPLE_VERSION_MINOR, LIBSWRESAMPLE_VERSION_MICRO);
credits->insertPlainText( stmp ); credits->insertPlainText( stmp );
#endif #endif
#ifdef _USE_X264 #ifdef _USE_X264
sprintf( stmp, " Compiled with x264 version %s\n", X264_POINTVER ); snprintf( stmp, sizeof(stmp), " Compiled with x264 version %s\n", X264_POINTVER );
credits->insertPlainText( stmp ); credits->insertPlainText( stmp );
#endif #endif

View File

@ -946,7 +946,7 @@ int GamePad_t::saveCurrentMapToFile(const char *name)
output.append(name); output.append(name);
output.append(","); output.append(",");
output.append("config:"); output.append("config:");
sprintf( stmp, "%i,", c ); snprintf( stmp, sizeof(stmp), "%i,", c );
output.append(stmp); output.append(stmp);
for (i = 0; i < GAMEPAD_NUM_BUTTONS; i++) for (i = 0; i < GAMEPAD_NUM_BUTTONS; i++)
@ -970,26 +970,26 @@ int GamePad_t::saveCurrentMapToFile(const char *name)
} }
stmp[k] = 0; stmp[k] = 0;
//sprintf(stmp, "k%s", SDL_GetKeyName(bmap[c][i].ButtonNum)); //snprintf(stmp, sizeof(stmp), "k%s", SDL_GetKeyName(bmap[c][i].ButtonNum));
} }
else else
{ {
if (bmap[c][i].ButtonNum & 0x2000) if (bmap[c][i].ButtonNum & 0x2000)
{ {
/* Hat "button" */ /* Hat "button" */
sprintf(stmp, "h%i.%i", snprintf(stmp, sizeof(stmp), "h%i.%i",
(bmap[c][i].ButtonNum >> 8) & 0x1F, bmap[c][i].ButtonNum & 0xFF); (bmap[c][i].ButtonNum >> 8) & 0x1F, bmap[c][i].ButtonNum & 0xFF);
} }
else if (bmap[c][i].ButtonNum & 0x8000) else if (bmap[c][i].ButtonNum & 0x8000)
{ {
/* Axis "button" */ /* Axis "button" */
sprintf(stmp, "%ca%i", snprintf(stmp, sizeof(stmp), "%ca%i",
(bmap[c][i].ButtonNum & 0x4000) ? '-' : '+', bmap[c][i].ButtonNum & 0x3FFF); (bmap[c][i].ButtonNum & 0x4000) ? '-' : '+', bmap[c][i].ButtonNum & 0x3FFF);
} }
else else
{ {
/* Button */ /* Button */
sprintf(stmp, "b%i", bmap[c][i].ButtonNum); snprintf(stmp, sizeof(stmp), "b%i", bmap[c][i].ButtonNum);
} }
} }
output.append(buttonNames[i]); output.append(buttonNames[i]);
@ -1034,26 +1034,26 @@ int GamePad_t::saveCurrentMapToFile(const char *name)
stmp[k] = keyName[j]; k++; j++; stmp[k] = keyName[j]; k++; j++;
} }
stmp[k] = 0; stmp[k] = 0;
//sprintf(stmp, "k%s", SDL_GetKeyName(fk->bmap[i].ButtonNum)); //snprintf(stmp, sizeof(stmp), "k%s", SDL_GetKeyName(fk->bmap[i].ButtonNum));
} }
else else
{ {
if (fk->bmap[i].ButtonNum & 0x2000) if (fk->bmap[i].ButtonNum & 0x2000)
{ {
/* Hat "button" */ /* Hat "button" */
sprintf(stmp, "h%i.%i", snprintf(stmp, sizeof(stmp), "h%i.%i",
(fk->bmap[i].ButtonNum >> 8) & 0x1F, fk->bmap[i].ButtonNum & 0xFF); (fk->bmap[i].ButtonNum >> 8) & 0x1F, fk->bmap[i].ButtonNum & 0xFF);
} }
else if (fk->bmap[i].ButtonNum & 0x8000) else if (fk->bmap[i].ButtonNum & 0x8000)
{ {
/* Axis "button" */ /* Axis "button" */
sprintf(stmp, "%ca%i", snprintf(stmp, sizeof(stmp), "%ca%i",
(fk->bmap[i].ButtonNum & 0x4000) ? '-' : '+', fk->bmap[i].ButtonNum & 0x3FFF); (fk->bmap[i].ButtonNum & 0x4000) ? '-' : '+', fk->bmap[i].ButtonNum & 0x3FFF);
} }
else else
{ {
/* Button */ /* Button */
sprintf(stmp, "b%i", fk->bmap[i].ButtonNum); snprintf(stmp, sizeof(stmp), "b%i", fk->bmap[i].ButtonNum);
} }
} }
if ( i == 0 ) if ( i == 0 )

View File

@ -866,8 +866,8 @@ int FDSLoad(const char *name, FCEUFILE *fp) {
FDSSoundStateAdd(); FDSSoundStateAdd();
for (x = 0; x < TotalSides; x++) { for (x = 0; x < TotalSides; x++) {
char temp[5]; char temp[8];
sprintf(temp, "DDT%d", x); snprintf(temp, sizeof(temp), "DDT%d", x);
AddExState(diskdata[x], 65500, 0, temp); AddExState(diskdata[x], 65500, 0, temp);
} }

View File

@ -148,7 +148,7 @@ end:
std::string FCEU_MakeIpsFilename(FileBaseInfo fbi) { std::string FCEU_MakeIpsFilename(FileBaseInfo fbi) {
char ret[FILENAME_MAX] = ""; char ret[FILENAME_MAX] = "";
sprintf(ret,"%s" PSS "%s%s.ips",fbi.filebasedirectory.c_str(),fbi.filebase.c_str(),fbi.ext.c_str()); snprintf(ret, sizeof(ret), "%s" PSS "%s%s.ips",fbi.filebasedirectory.c_str(),fbi.filebase.c_str(),fbi.ext.c_str());
return ret; return ret;
} }
@ -618,9 +618,9 @@ std::string FCEU_MakeFName(int type, int id1, const char *cd1)
struct stat fileInfo; struct stat fileInfo;
do { do {
if(odirs[FCEUIOD_MOVIES]) if(odirs[FCEUIOD_MOVIES])
sprintf(ret,"%s" PSS "%s-%d.fm2",odirs[FCEUIOD_MOVIES],FileBase, id1); snprintf(ret, sizeof(ret), "%s" PSS "%s-%d.fm2",odirs[FCEUIOD_MOVIES],FileBase, id1);
else else
sprintf(ret,"%s" PSS "movies" PSS "%s-%d.fm2",BaseDirectory.c_str(),FileBase, id1); snprintf(ret, sizeof(ret), "%s" PSS "movies" PSS "%s-%d.fm2",BaseDirectory.c_str(),FileBase, id1);
id1++; id1++;
} while (stat(ret, &fileInfo) == 0); } while (stat(ret, &fileInfo) == 0);
break; break;
@ -644,19 +644,19 @@ std::string FCEU_MakeFName(int type, int id1, const char *cd1)
if(odirs[FCEUIOD_STATES]) if(odirs[FCEUIOD_STATES])
{ {
sprintf(ret,"%s" PSS "%s%s.fc%d",odirs[FCEUIOD_STATES],FileBase,mfn,id1); snprintf(ret, sizeof(ret), "%s" PSS "%s%s.fc%d",odirs[FCEUIOD_STATES],FileBase,mfn,id1);
} else } else
{ {
sprintf(ret,"%s" PSS "fcs" PSS "%s%s.fc%d",BaseDirectory.c_str(),FileBase,mfn,id1); snprintf(ret, sizeof(ret), "%s" PSS "fcs" PSS "%s%s.fc%d",BaseDirectory.c_str(),FileBase,mfn,id1);
} }
if(stat(ret,&tmpstat)==-1) if(stat(ret,&tmpstat)==-1)
{ {
if(odirs[FCEUIOD_STATES]) if(odirs[FCEUIOD_STATES])
{ {
sprintf(ret,"%s" PSS "%s%s.fc%d",odirs[FCEUIOD_STATES],FileBase,mfn,id1); snprintf(ret, sizeof(ret), "%s" PSS "%s%s.fc%d",odirs[FCEUIOD_STATES],FileBase,mfn,id1);
} else } else
{ {
sprintf(ret,"%s" PSS "fcs" PSS "%s%s.fc%d",BaseDirectory.c_str(),FileBase,mfn,id1); snprintf(ret, sizeof(ret), "%s" PSS "fcs" PSS "%s%s.fc%d",BaseDirectory.c_str(),FileBase,mfn,id1);
} }
} }
} }
@ -665,46 +665,46 @@ std::string FCEU_MakeFName(int type, int id1, const char *cd1)
{ {
if(odirs[FCEUIOD_STATES]) if(odirs[FCEUIOD_STATES])
{ {
sprintf(ret,"%s" PSS "%s-resume.fcs",odirs[FCEUIOD_STATES],FileBase); snprintf(ret, sizeof(ret), "%s" PSS "%s-resume.fcs",odirs[FCEUIOD_STATES],FileBase);
} else } else
{ {
sprintf(ret,"%s" PSS "fcs" PSS "%s-resume.fcs",BaseDirectory.c_str(),FileBase); snprintf(ret, sizeof(ret), "%s" PSS "fcs" PSS "%s-resume.fcs",BaseDirectory.c_str(),FileBase);
} }
if(stat(ret,&tmpstat)==-1) if(stat(ret,&tmpstat)==-1)
{ {
if(odirs[FCEUIOD_STATES]) if(odirs[FCEUIOD_STATES])
{ {
sprintf(ret,"%s" PSS "%s-resume.fcs",odirs[FCEUIOD_STATES],FileBase); snprintf(ret, sizeof(ret), "%s" PSS "%s-resume.fcs",odirs[FCEUIOD_STATES],FileBase);
} else } else
{ {
sprintf(ret,"%s" PSS "fcs" PSS "%s-resume.fcs",BaseDirectory.c_str(),FileBase); snprintf(ret, sizeof(ret), "%s" PSS "fcs" PSS "%s-resume.fcs",BaseDirectory.c_str(),FileBase);
} }
} }
} }
break; break;
case FCEUMKF_SNAP: case FCEUMKF_SNAP:
if(odirs[FCEUIOD_SNAPS]) if(odirs[FCEUIOD_SNAPS])
sprintf(ret,"%s" PSS "%s-%d.%s",odirs[FCEUIOD_SNAPS],FileBase,id1,cd1); snprintf(ret, sizeof(ret), "%s" PSS "%s-%d.%s",odirs[FCEUIOD_SNAPS],FileBase,id1,cd1);
else else
sprintf(ret,"%s" PSS "snaps" PSS "%s-%d.%s",BaseDirectory.c_str(),FileBase,id1,cd1); snprintf(ret, sizeof(ret), "%s" PSS "snaps" PSS "%s-%d.%s",BaseDirectory.c_str(),FileBase,id1,cd1);
break; break;
case FCEUMKF_FDS: case FCEUMKF_FDS:
if(odirs[FCEUIOD_NV]) if(odirs[FCEUIOD_NV])
sprintf(ret,"%s" PSS "%s.fds",odirs[FCEUIOD_NV],FileBase); snprintf(ret, sizeof(ret), "%s" PSS "%s.fds",odirs[FCEUIOD_NV],FileBase);
else else
sprintf(ret,"%s" PSS "sav" PSS "%s.fds",BaseDirectory.c_str(),FileBase); snprintf(ret, sizeof(ret), "%s" PSS "sav" PSS "%s.fds",BaseDirectory.c_str(),FileBase);
break; break;
case FCEUMKF_SAV: case FCEUMKF_SAV:
if(odirs[FCEUIOD_NV]) if(odirs[FCEUIOD_NV])
sprintf(ret,"%s" PSS "%s.%s",odirs[FCEUIOD_NV],FileBase,cd1); snprintf(ret, sizeof(ret), "%s" PSS "%s.%s",odirs[FCEUIOD_NV],FileBase,cd1);
else else
sprintf(ret,"%s" PSS "sav" PSS "%s.%s",BaseDirectory.c_str(),FileBase,cd1); snprintf(ret, sizeof(ret), "%s" PSS "sav" PSS "%s.%s",BaseDirectory.c_str(),FileBase,cd1);
if(stat(ret,&tmpstat)==-1) if(stat(ret,&tmpstat)==-1)
{ {
if(odirs[FCEUIOD_NV]) if(odirs[FCEUIOD_NV])
sprintf(ret,"%s" PSS "%s.%s",odirs[FCEUIOD_NV],FileBase,cd1); snprintf(ret, sizeof(ret), "%s" PSS "%s.%s",odirs[FCEUIOD_NV],FileBase,cd1);
else else
sprintf(ret,"%s" PSS "sav" PSS "%s.%s",BaseDirectory.c_str(),FileBase,cd1); snprintf(ret, sizeof(ret), "%s" PSS "sav" PSS "%s.%s",BaseDirectory.c_str(),FileBase,cd1);
} }
break; break;
case FCEUMKF_AUTOSTATE: case FCEUMKF_AUTOSTATE:
@ -722,52 +722,52 @@ std::string FCEU_MakeFName(int type, int id1, const char *cd1)
if(odirs[FCEUIOD_STATES]) if(odirs[FCEUIOD_STATES])
{ {
sprintf(ret,"%s" PSS "%s%s-autosave%d.fcs",odirs[FCEUIOD_STATES],FileBase,mfn,id1); snprintf(ret, sizeof(ret), "%s" PSS "%s%s-autosave%d.fcs",odirs[FCEUIOD_STATES],FileBase,mfn,id1);
} else } else
{ {
sprintf(ret,"%s" PSS "fcs" PSS "%s%s-autosave%d.fcs",BaseDirectory.c_str(),FileBase,mfn,id1); snprintf(ret, sizeof(ret), "%s" PSS "fcs" PSS "%s%s-autosave%d.fcs",BaseDirectory.c_str(),FileBase,mfn,id1);
} }
if(stat(ret,&tmpstat)==-1) if(stat(ret,&tmpstat)==-1)
{ {
if(odirs[FCEUIOD_STATES]) if(odirs[FCEUIOD_STATES])
{ {
sprintf(ret,"%s" PSS "%s%s-autosave%d.fcs",odirs[FCEUIOD_STATES],FileBase,mfn,id1); snprintf(ret, sizeof(ret), "%s" PSS "%s%s-autosave%d.fcs",odirs[FCEUIOD_STATES],FileBase,mfn,id1);
} else } else
{ {
sprintf(ret,"%s" PSS "fcs" PSS "%s%s-autosave%d.fcs",BaseDirectory.c_str(),FileBase,mfn,id1); snprintf(ret, sizeof(ret), "%s" PSS "fcs" PSS "%s%s-autosave%d.fcs",BaseDirectory.c_str(),FileBase,mfn,id1);
} }
} }
break; break;
case FCEUMKF_CHEAT: case FCEUMKF_CHEAT:
if(odirs[FCEUIOD_CHEATS]) if(odirs[FCEUIOD_CHEATS])
sprintf(ret,"%s" PSS "%s.cht",odirs[FCEUIOD_CHEATS],FileBase); snprintf(ret, sizeof(ret), "%s" PSS "%s.cht",odirs[FCEUIOD_CHEATS],FileBase);
else else
sprintf(ret,"%s" PSS "cheats" PSS "%s.cht",BaseDirectory.c_str(),FileBase); snprintf(ret, sizeof(ret), "%s" PSS "cheats" PSS "%s.cht",BaseDirectory.c_str(),FileBase);
break; break;
case FCEUMKF_IPS: case FCEUMKF_IPS:
strcpy(ret,FCEU_MakeIpsFilename(CurrentFileBase()).c_str()); strcpy(ret,FCEU_MakeIpsFilename(CurrentFileBase()).c_str());
break; break;
case FCEUMKF_GGROM:sprintf(ret,"%s" PSS "gg.rom",BaseDirectory.c_str());break; case FCEUMKF_GGROM:snprintf(ret, sizeof(ret), "%s" PSS "gg.rom",BaseDirectory.c_str());break;
case FCEUMKF_FDSROM: case FCEUMKF_FDSROM:
if(odirs[FCEUIOD_FDSROM]) if(odirs[FCEUIOD_FDSROM])
sprintf(ret,"%s" PSS "disksys.rom",odirs[FCEUIOD_FDSROM]); snprintf(ret, sizeof(ret), "%s" PSS "disksys.rom",odirs[FCEUIOD_FDSROM]);
else else
sprintf(ret,"%s" PSS "disksys.rom",BaseDirectory.c_str()); snprintf(ret, sizeof(ret), "%s" PSS "disksys.rom",BaseDirectory.c_str());
break; break;
case FCEUMKF_PALETTE:sprintf(ret,"%s" PSS "%s.pal",BaseDirectory.c_str(),FileBase);break; case FCEUMKF_PALETTE:snprintf(ret, sizeof(ret), "%s" PSS "%s.pal",BaseDirectory.c_str(),FileBase);break;
case FCEUMKF_MOVIEGLOB: case FCEUMKF_MOVIEGLOB:
//these globs use ??? because we can load multiple formats //these globs use ??? because we can load multiple formats
if(odirs[FCEUIOD_MOVIES]) if(odirs[FCEUIOD_MOVIES])
sprintf(ret,"%s" PSS "*.???",odirs[FCEUIOD_MOVIES]); snprintf(ret, sizeof(ret), "%s" PSS "*.???",odirs[FCEUIOD_MOVIES]);
else else
sprintf(ret,"%s" PSS "movies" PSS "*.???",BaseDirectory.c_str()); snprintf(ret, sizeof(ret), "%s" PSS "movies" PSS "*.???",BaseDirectory.c_str());
break; break;
case FCEUMKF_MOVIEGLOB2:sprintf(ret,"%s" PSS "*.???",BaseDirectory.c_str());break; case FCEUMKF_MOVIEGLOB2:snprintf(ret, sizeof(ret), "%s" PSS "*.???",BaseDirectory.c_str());break;
case FCEUMKF_STATEGLOB: case FCEUMKF_STATEGLOB:
if(odirs[FCEUIOD_STATES]) if(odirs[FCEUIOD_STATES])
sprintf(ret,"%s" PSS "%s*.fc?",odirs[FCEUIOD_STATES],FileBase); snprintf(ret, sizeof(ret), "%s" PSS "%s*.fc?",odirs[FCEUIOD_STATES],FileBase);
else else
sprintf(ret,"%s" PSS "fcs" PSS "%s*.fc?",BaseDirectory.c_str(),FileBase); snprintf(ret, sizeof(ret), "%s" PSS "fcs" PSS "%s*.fc?",BaseDirectory.c_str(),FileBase);
break; break;
} }

View File

@ -475,21 +475,33 @@ static void CheckHInfo(uint64 partialmd5) {
if (MapperNo == 99) if (MapperNo == 99)
Mirroring = 2; Mirroring = 2;
if (tofix) { if (tofix)
char gigastr[768]; {
strcpy(gigastr, "The iNES header contains incorrect information. For now, the information will be corrected in RAM. "); char tmpStr[128];
std::string gigastr;
gigastr.reserve(768);
gigastr.assign("The iNES header contains incorrect information. For now, the information will be corrected in RAM. ");
if (tofix & 1) if (tofix & 1)
sprintf(gigastr + strlen(gigastr), "The mapper number should be set to %d. ", MapperNo); {
if (tofix & 2) { snprintf(tmpStr, sizeof(tmpStr), "The mapper number should be set to %d. ", MapperNo);
gigastr.append(tmpStr);
}
if (tofix & 2)
{
const char *mstr[3] = { "Horizontal", "Vertical", "Four-screen" }; const char *mstr[3] = { "Horizontal", "Vertical", "Four-screen" };
sprintf(gigastr + strlen(gigastr), "Mirroring should be set to \"%s\". ", mstr[Mirroring & 3]); snprintf(tmpStr, sizeof(tmpStr), "Mirroring should be set to \"%s\". ", mstr[Mirroring & 3]);
gigastr.append(tmpStr);
} }
if (tofix & 4) if (tofix & 4)
strcat(gigastr, "The battery-backed bit should be set. "); {
gigastr.append("The battery-backed bit should be set. ");
}
if (tofix & 8) if (tofix & 8)
strcat(gigastr, "This game should not have any CHR ROM. "); {
strcat(gigastr, "\n"); gigastr.append("This game should not have any CHR ROM. ");
FCEU_printf("%s", gigastr); }
gigastr.append("\n");
FCEU_printf("%s", gigastr.c_str());
} }
} }

View File

@ -906,7 +906,7 @@ static void LuaStackToBinaryConverter(lua_State* L, int i, std::vector<unsigned
default: default:
{ {
char errmsg [1024]; char errmsg [1024];
sprintf(errmsg, "values of type \"%s\" are not allowed to be returned from registered save functions.\r\n", luaL_typename(L,i)); snprintf(errmsg, sizeof(errmsg), "values of type \"%s\" are not allowed to be returned from registered save functions.\r\n", luaL_typename(L,i));
if(info_print) if(info_print)
info_print(info_uid, errmsg); info_print(info_uid, errmsg);
else else
@ -1070,9 +1070,9 @@ void BinaryToLuaStackConverter(lua_State* L, const unsigned char*& data, unsigne
{ {
char errmsg [1024]; char errmsg [1024];
if(type <= 10 && type != LUA_TTABLE) if(type <= 10 && type != LUA_TTABLE)
sprintf(errmsg, "values of type \"%s\" are not allowed to be loaded into registered load functions. The save state's Lua save data file might be corrupted.\r\n", lua_typename(L,type)); snprintf(errmsg, sizeof(errmsg), "values of type \"%s\" are not allowed to be loaded into registered load functions. The save state's Lua save data file might be corrupted.\r\n", lua_typename(L,type));
else else
sprintf(errmsg, "The save state's Lua save data file seems to be corrupted.\r\n"); snprintf(errmsg, sizeof(errmsg), "The save state's Lua save data file seems to be corrupted.\r\n");
if(info_print) if(info_print)
info_print(info_uid, errmsg); info_print(info_uid, errmsg);
else else
@ -2113,7 +2113,7 @@ void HandleCallbackError(lua_State* L, bool stop, int msgDepth = -1)
lua_setfield(L, LUA_REGISTRYINDEX, guiCallbackTable); lua_setfield(L, LUA_REGISTRYINDEX, guiCallbackTable);
char errmsg [2048]; char errmsg [2048];
sprintf(errmsg, "%s\n%s", lua_tostring(L,-1), trace); snprintf(errmsg, sizeof(errmsg), "%s\n%s", lua_tostring(L,-1), trace);
// Error? // Error?
#ifdef __WIN_DRIVER__ #ifdef __WIN_DRIVER__
@ -6375,7 +6375,7 @@ void FCEU_LuaFrameBoundary()
lua_setfield(L, LUA_REGISTRYINDEX, guiCallbackTable); lua_setfield(L, LUA_REGISTRYINDEX, guiCallbackTable);
char errmsg [1024]; char errmsg [1024];
sprintf(errmsg, "%s\n%s", lua_tostring(thread,-1), trace); snprintf(errmsg, sizeof(errmsg), "%s\n%s", lua_tostring(thread,-1), trace);
// Error? // Error?
#ifdef __WIN_DRIVER__ #ifdef __WIN_DRIVER__

View File

@ -1358,22 +1358,22 @@ void FCEU_DrawMovies(uint8 *XBuf)
if (movieMode == MOVIEMODE_PLAY) if (movieMode == MOVIEMODE_PLAY)
{ {
sprintf(counterbuf, "%d/%d%s%s", currFrameCounter, (int)currMovieData.records.size(), GetMovieRecordModeStr(), GetMovieReadOnlyStr()); snprintf(counterbuf, sizeof(counterbuf), "%d/%d%s%s", currFrameCounter, (int)currMovieData.records.size(), GetMovieRecordModeStr(), GetMovieReadOnlyStr());
} else if (movieMode == MOVIEMODE_RECORD) } else if (movieMode == MOVIEMODE_RECORD)
{ {
if (movieRecordMode == MOVIE_RECORD_MODE_TRUNCATE) if (movieRecordMode == MOVIE_RECORD_MODE_TRUNCATE)
sprintf(counterbuf, "%d%s%s (record)", currFrameCounter, GetMovieRecordModeStr(), GetMovieReadOnlyStr()); // nearly classic snprintf(counterbuf, sizeof(counterbuf), "%d%s%s (record)", currFrameCounter, GetMovieRecordModeStr(), GetMovieReadOnlyStr()); // nearly classic
else else
sprintf(counterbuf, "%d/%d%s%s (record)", currFrameCounter, (int)currMovieData.records.size(), GetMovieRecordModeStr(), GetMovieReadOnlyStr()); snprintf(counterbuf, sizeof(counterbuf), "%d/%d%s%s (record)", currFrameCounter, (int)currMovieData.records.size(), GetMovieRecordModeStr(), GetMovieReadOnlyStr());
} else if (movieMode == MOVIEMODE_FINISHED) } else if (movieMode == MOVIEMODE_FINISHED)
{ {
sprintf(counterbuf,"%d/%d%s%s (finished)",currFrameCounter,(int)currMovieData.records.size(), GetMovieRecordModeStr(), GetMovieReadOnlyStr()); snprintf(counterbuf, sizeof(counterbuf), "%d/%d%s%s (finished)",currFrameCounter,(int)currMovieData.records.size(), GetMovieRecordModeStr(), GetMovieReadOnlyStr());
color = 0x17; //Show red to get attention color = 0x17; //Show red to get attention
} else if (movieMode == MOVIEMODE_TASEDITOR) } else if (movieMode == MOVIEMODE_TASEDITOR)
{ {
sprintf(counterbuf,"%d",currFrameCounter); snprintf(counterbuf, sizeof(counterbuf),"%d",currFrameCounter);
} else } else
sprintf(counterbuf,"%d (no movie)",currFrameCounter); snprintf(counterbuf, sizeof(counterbuf),"%d (no movie)",currFrameCounter);
if (counterbuf[0]) if (counterbuf[0])
DrawTextTrans(ClipSidesOffset+XBuf+FCEU_TextScanlineOffsetFromBottom(30)+1, 256, (uint8*)counterbuf, color+0x80); DrawTextTrans(ClipSidesOffset+XBuf+FCEU_TextScanlineOffsetFromBottom(30)+1, 256, (uint8*)counterbuf, color+0x80);
@ -1381,7 +1381,7 @@ void FCEU_DrawMovies(uint8 *XBuf)
if (rerecord_display && movieMode != MOVIEMODE_INACTIVE) if (rerecord_display && movieMode != MOVIEMODE_INACTIVE)
{ {
char counterbuf[32] = {0}; char counterbuf[32] = {0};
sprintf(counterbuf, "%d", currMovieData.rerecordCount); snprintf(counterbuf, sizeof(counterbuf), "%d", currMovieData.rerecordCount);
if (counterbuf[0]) if (counterbuf[0])
DrawTextTrans(ClipSidesOffset+XBuf+FCEU_TextScanlineOffsetFromBottom(50)+1, 256, (uint8*)counterbuf, 0x28+0x80); DrawTextTrans(ClipSidesOffset+XBuf+FCEU_TextScanlineOffsetFromBottom(50)+1, 256, (uint8*)counterbuf, 0x28+0x80);
@ -1394,7 +1394,7 @@ void FCEU_DrawLagCounter(uint8 *XBuf)
{ {
// If currently lagging - display red, else display green // If currently lagging - display red, else display green
uint8 color = (lagFlag) ? (0x16+0x80) : (0x2A+0x80); uint8 color = (lagFlag) ? (0x16+0x80) : (0x2A+0x80);
sprintf(lagcounterbuf, "%d", lagCounter); snprintf(lagcounterbuf, sizeof(lagcounterbuf), "%d", lagCounter);
if(lagcounterbuf[0]) if(lagcounterbuf[0])
DrawTextTrans(ClipSidesOffset + XBuf + FCEU_TextScanlineOffsetFromBottom(40) + 1, 256, (uint8*)lagcounterbuf, color); DrawTextTrans(ClipSidesOffset + XBuf + FCEU_TextScanlineOffsetFromBottom(40) + 1, 256, (uint8*)lagcounterbuf, color);
} }

View File

@ -581,7 +581,7 @@ void DrawNSF(uint8 *XBuf)
DrawTextTrans(ClipSidesOffset+XBuf+42*256+4+(((31-strlen((char*)NSFHeader.Copyright))<<2)), 256,NSFHeader.Copyright, kFgColor); DrawTextTrans(ClipSidesOffset+XBuf+42*256+4+(((31-strlen((char*)NSFHeader.Copyright))<<2)), 256,NSFHeader.Copyright, kFgColor);
DrawTextTrans(ClipSidesOffset+XBuf+70*256+4+(((31-strlen("Song:"))<<2)), 256, (uint8*)"Song:", kFgColor); DrawTextTrans(ClipSidesOffset+XBuf+70*256+4+(((31-strlen("Song:"))<<2)), 256, (uint8*)"Song:", kFgColor);
sprintf(snbuf,"<%d/%d>",CurrentSong,NSFHeader.TotalSongs); snprintf(snbuf, sizeof(snbuf), "<%d/%d>",CurrentSong,NSFHeader.TotalSongs);
DrawTextTrans(XBuf+82*256+4+(((31-strlen(snbuf))<<2)), 256, (uint8*)snbuf, kFgColor); DrawTextTrans(XBuf+82*256+4+(((31-strlen(snbuf))<<2)), 256, (uint8*)snbuf, kFgColor);
{ {

View File

@ -136,7 +136,7 @@ profileExecVector::profileExecVector(void)
strcpy( threadName, thread->objectName().toStdString().c_str()); strcpy( threadName, thread->objectName().toStdString().c_str());
} }
#endif #endif
sprintf( fileName, "fceux-profile-%s.log", threadName); snprintf( fileName, sizeof(fileName), "fceux-profile-%s.log", threadName);
logFp = ::fopen(fileName, "w"); logFp = ::fopen(fileName, "w");
@ -212,7 +212,7 @@ int profilerFuncMap::addRecord(const char *fileNameStringLiteral,
autoScopedLock aLock(_mapMtx); autoScopedLock aLock(_mapMtx);
char lineString[64]; char lineString[64];
sprintf( lineString, ":%i", fileLineNumber); snprintf( lineString, sizeof(lineString), ":%i", fileLineNumber);
std::string fname(fileNameStringLiteral); std::string fname(fileNameStringLiteral);
@ -233,7 +233,7 @@ funcProfileRecord *profilerFuncMap::findRecord(const char *fileNameStringLiteral
char lineString[64]; char lineString[64];
funcProfileRecord *rec = nullptr; funcProfileRecord *rec = nullptr;
sprintf( lineString, ":%i", fileLineNumber); snprintf( lineString, sizeof(lineString), ":%i", fileLineNumber);
std::string fname(fileNameStringLiteral); std::string fname(fileNameStringLiteral);

View File

@ -345,7 +345,7 @@ static bool ReadStateChunks(EMUFILE* is, int32 totalsize)
if(!warned) if(!warned)
{ {
char str [256]; char str [256];
sprintf(str, "Warning: Found unknown save chunk of type %d.\nThis could indicate the save state is corrupted\nor made with a different (incompatible) emulator version.", t); snprintf(str, sizeof(str), "Warning: Found unknown save chunk of type %d.\nThis could indicate the save state is corrupted\nor made with a different (incompatible) emulator version.", t);
FCEUD_PrintError(str); FCEUD_PrintError(str);
warned=true; warned=true;
} }

View File

@ -765,7 +765,7 @@ void ShowFPS(void)
if ( da > FCEUD_GetTimeFreq() ) if ( da > FCEUD_GetTimeFreq() )
{ {
sprintf(fpsmsg, "%.1f", (double)boopcount / ((double)da / FCEUD_GetTimeFreq())); snprintf(fpsmsg, sizeof(fpsmsg), "%.1f", (double)boopcount / ((double)da / FCEUD_GetTimeFreq()));
boopcount = 0; boopcount = 0;
boop_ts = ts; boop_ts = ts;
@ -797,7 +797,7 @@ static void FCEU_DrawPauseCountDown(uint8 *XBuf)
framesPerSec = 60; framesPerSec = 60;
} }
sprintf(text, "Unpausing in %d...", (pauseFramesLeft / framesPerSec) + 1); snprintf(text, sizeof(text), "Unpausing in %d...", (pauseFramesLeft / framesPerSec) + 1);
if (text[0]) if (text[0])
{ {

View File

@ -354,33 +354,50 @@ void FCEU_VSUniCheck(uint64 md5partial, int *MapperNo, uint8 *Mirroring) {
GameInfo->vs_cswitch = 1; GameInfo->vs_cswitch = 1;
} }
if (tofix) { if (tofix)
char gigastr[768]; {
strcpy(gigastr, "The iNES header contains incorrect information. For now, the information will be corrected in RAM. "); char tmpStr[128];
std::string gigastr;
gigastr.reserve(768);
gigastr.assign("The iNES header contains incorrect information. For now, the information will be corrected in RAM. ");
if (tofix & 4) { if (tofix & 4) {
sprintf(gigastr + strlen(gigastr), "Game type should be set to Vs. System. "); snprintf(tmpStr, sizeof(tmpStr), "Game type should be set to Vs. System. ");
gigastr.append(tmpStr);
} }
if (tofix & 1) if (tofix & 1)
sprintf(gigastr + strlen(gigastr), "The mapper number should be set to %d. ", *MapperNo); {
if (tofix & 2) { snprintf(tmpStr, sizeof(tmpStr), "The mapper number should be set to %d. ", *MapperNo);
gigastr.append(tmpStr);
}
if (tofix & 2)
{
const char* mstr[3] = { "Horizontal", "Vertical", "Four-screen" }; const char* mstr[3] = { "Horizontal", "Vertical", "Four-screen" };
sprintf(gigastr + strlen(gigastr), "Mirroring should be set to \"%s\". ", mstr[vs->mirroring & 3]); snprintf(tmpStr, sizeof(tmpStr), "Mirroring should be set to \"%s\". ", mstr[vs->mirroring & 3]);
gigastr.append(tmpStr);
} }
if (tofix & 8) { if (tofix & 8) {
const char* mstr[4] = { "Normal", "RBI Baseball protection", "TKO Boxing protection", "Super Xevious protection"}; const char* mstr[4] = { "Normal", "RBI Baseball protection", "TKO Boxing protection", "Super Xevious protection"};
sprintf(gigastr + strlen(gigastr), "Vs. System type should be set to \"%s\". ", mstr[vs->type]); snprintf(tmpStr, sizeof(tmpStr), "Vs. System type should be set to \"%s\". ", mstr[vs->type]);
gigastr.append(tmpStr);
} }
if (tofix & 16) if (tofix & 16)
{ {
const char* mstr[10] = { "Default", "RP2C04-0001", "RP2C04-0002", "RP2C04-0003", "RP2C04-0004", "RC2C03B", "RC2C05-01", "RC2C05-02" , "RC2C05-03" , "RC2C05-04" }; const char* mstr[10] = { "Default", "RP2C04-0001", "RP2C04-0002", "RP2C04-0003", "RP2C04-0004", "RC2C03B", "RC2C05-01", "RC2C05-02" , "RC2C05-03" , "RC2C05-04" };
sprintf(gigastr + strlen(gigastr), "Vs. System PPU should be set to \"%s\". ", mstr[vs->ppu]); snprintf(tmpStr, sizeof(tmpStr), "Vs. System PPU should be set to \"%s\". ", mstr[vs->ppu]);
gigastr.append(tmpStr);
} }
if (tofix & 32) if (tofix & 32)
sprintf(gigastr + strlen(gigastr), "The controller type should be set to zapper. "); {
snprintf(tmpStr, sizeof(tmpStr), "The controller type should be set to zapper. ");
gigastr.append(tmpStr);
}
if (tofix & 64) if (tofix & 64)
sprintf(gigastr + strlen(gigastr), "The controllers should be swapped. "); {
strcat(gigastr, "\n"); snprintf(tmpStr, sizeof(tmpStr), "The controllers should be swapped. ");
FCEU_printf("%s", gigastr); gigastr.append(tmpStr);
}
gigastr.append("\n");
FCEU_printf("%s", gigastr.c_str());
} }
return; return;