Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[BS-X] Save Memory Pack option (Windows)
  • Loading branch information
LuigiBlood committed Nov 23, 2016
1 parent 17fa454 commit 5022880
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 1 deletion.
26 changes: 26 additions & 0 deletions memmap.cpp
Expand Up @@ -2210,6 +2210,32 @@ bool8 CMemory::SaveSRAM (const char *filename)
return (FALSE);
}

bool8 CMemory::SaveMPAK (const char *filename)
{
if (Settings.BS || (Multi.cartSizeB && (Multi.cartType == 3)))
{
FILE *file;
int size;
char mempakName[PATH_MAX + 1];

strcpy(mempakName, filename);
size = 0x100000;
if (size)
{
file = fopen(mempakName, "wb");
if (file)
{
size_t ignore;
ignore = fwrite((char *)Memory.ROM + Multi.cartOffsetB, size, 1, file);
fclose(file);

return (TRUE);
}
}
}
return (FALSE);
}

// initialization

static uint32 caCRC32 (uint8 *array, uint32 size, uint32 crc32)
Expand Down
1 change: 1 addition & 0 deletions memmap.h
Expand Up @@ -291,6 +291,7 @@ struct CMemory
void ClearSRAM (bool8 onlyNonSavedSRAM = 0);
bool8 LoadSRTC (void);
bool8 SaveSRTC (void);
bool8 SaveMPAK (const char *);

char * Safe (const char *);
char * SafeANK (const char *);
Expand Down
3 changes: 2 additions & 1 deletion win32/rsrc/resource.h
Expand Up @@ -496,13 +496,14 @@
#define ID_WINDOW_SIZE_4X 40172
#define ID_DEBUG_APU_TRACE 40173
#define ID_EMULATION_BACKGROUNDINPUT 40174
#define ID_SAVEMEMPACK 40175

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 151
#define _APS_NEXT_COMMAND_VALUE 40175
#define _APS_NEXT_COMMAND_VALUE 40176
#define _APS_NEXT_CONTROL_VALUE 3018
#define _APS_NEXT_SYMED_VALUE 101
#endif
Expand Down
1 change: 1 addition & 0 deletions win32/rsrc/snes9x.rc
Expand Up @@ -822,6 +822,7 @@ BEGIN
MENUITEM "S&ave SPC Data", ID_FILE_SAVE_SPC_DATA
MENUITEM "Save Screenshot", ID_SAVESCREENSHOT
MENUITEM "Sa&ve S-RAM Data", ID_FILE_SAVE_SRAM_DATA
MENUITEM "Save Memory Pack", ID_SAVEMEMPACK
END
MENUITEM "ROM Information...", IDM_ROM_INFO
MENUITEM SEPARATOR
Expand Down
2 changes: 2 additions & 0 deletions win32/wlanguage.h
Expand Up @@ -588,6 +588,8 @@ Nintendo is a trade mark.")

#define INFO_SAVE_SPC "Saving SPC Data."

#define MPAK_SAVE_FAILED "Failed to save Memory Pack."

#define CHEATS_INFO_ENABLED "Cheats enabled."
#define CHEATS_INFO_DISABLED "Cheats disabled."
#define CHEATS_INFO_ENABLED_NONE "Cheats enabled. (None are active.)"
Expand Down
11 changes: 11 additions & 0 deletions win32/wsnes9x.cpp
Expand Up @@ -2239,6 +2239,17 @@ LRESULT CALLBACK WinProc(
if(!success)
S9xMessage(S9X_ERROR, S9X_FREEZE_FILE_INFO, SRM_SAVE_FAILED);
} break;
case ID_SAVEMEMPACK: {
const char *filename = S9xGetFilenameInc(".bs", SRAM_DIR);
bool8 success = Memory.SaveMPAK(filename);
if (!success)
S9xMessage(S9X_ERROR, 0, MPAK_SAVE_FAILED);
else
{
sprintf(String, "Saved Memory Pack %s", filename);
S9xMessage(S9X_INFO, 0, String);
}
} break;
case ID_FILE_RESET:
#ifdef NETPLAY_SUPPORT
if (Settings.NetPlayServer)
Expand Down

0 comments on commit 5022880

Please sign in to comment.