* Fixed iNesSave and iNesSaveAs (#579)

* Moved "Config->Game Genie" to "Config->Enable->Game Genie ROM"
This commit is contained in:
ansstuff 2013-02-11 12:03:37 +00:00
parent b7584d0da2
commit 3d9095fc29
4 changed files with 741 additions and 727 deletions

View File

@ -1158,7 +1158,8 @@ BOOL CALLBACK PatcherCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam
UpdatePatcher(hwndDlg);
break;
case IDC_ROMPATCHER_BTN_SAVE:
if(!iNesSave())MessageBox(NULL,"Error Saving","Error",MB_OK);
if (!iNesSave())
MessageBox(NULL, "Error Saving", "Error", MB_OK);
break;
}
break;

View File

@ -120,6 +120,7 @@ BEGIN
MENUITEM "&Frame Adv. - Skip Lag", MENU_DISPLAY_FA_LAGSKIP
MENUITEM "Backup Savestates", ID_ENABLE_BACKUPSAVESTATES
MENUITEM "Compress Savestates", ID_ENABLE_COMPRESSSAVESTATES
MENUITEM "&Game Genie ROM", MENU_GAME_GENIE
MENUITEM "Auto-resume old play session", ID_ENABLE_AUTORESUME
END
POPUP "&Display"
@ -143,14 +144,13 @@ BEGIN
MENUITEM "Graphics: &OBJ", MENU_DISPLAY_OBJ
END
MENUITEM SEPARATOR
MENUITEM "&Game Genie", MENU_GAME_GENIE
MENUITEM "&PAL Emulation", MENU_PAL
MENUITEM SEPARATOR
POPUP "PPU"
BEGIN
MENUITEM "Old PPU", ID_OLDPPU
MENUITEM "New PPU (slow!)", ID_NEWPPU
END
MENUITEM SEPARATOR
MENUITEM "&Directories...", MENU_DIRECTORIES
MENUITEM "&GUI...", MENU_GUI_OPTIONS
MENUITEM "&Input...", MENU_INPUT

View File

@ -890,25 +890,32 @@ int iNesSave() {
}
fp = fopen(name, "wb");
if (!fp)
return 0;
if (fwrite(&head, 1, 16, fp) != 16) {
if (fwrite(&head, 1, 16, fp) != 16)
{
fclose(fp);
return 0;
}
if (head.ROM_type & 4) { /* Trainer */
if (head.ROM_type & 4)
{
/* Trainer */
fwrite(trainerpoo, 512, 1, fp);
}
fwrite(ROM, 0x4000, ROM_size, fp);
if (head.VROM_size) fwrite(VROM, 0x2000, head.VROM_size, fp);
fclose(fp);
if (head.VROM_size)
fwrite(VROM, 0x2000, head.VROM_size, fp);
fclose(fp);
return 1;
}
int iNesSaveAs(char* name) {
int iNesSaveAs(char* name)
{
//adelikat: TODO: iNesSave() and this have pretty much the same code, outsource the common code to a single function
FILE *fp;
@ -916,21 +923,27 @@ int iNesSaveAs(char* name) {
if (GameInterface != iNESGI) return 0;
fp = fopen(name, "wb");
if (!fp)
return 0;
if (fwrite(&head, 1, 16, fp) != 16) {
if (fwrite(&head, 1, 16, fp) != 16)
{
fclose(fp);
return 0;
}
if (head.ROM_type & 4) { /* Trainer */
if (head.ROM_type & 4)
{
/* Trainer */
fwrite(trainerpoo, 512, 1, fp);
}
fwrite(ROM, 0x4000, ROM_size, fp);
if (head.VROM_size) fwrite(VROM, 0x2000, head.VROM_size, fp);
fclose(fp);
if (head.VROM_size)
fwrite(VROM, 0x2000, head.VROM_size, fp);
fclose(fp);
return 1;
}

Binary file not shown.