[BS-X] Save Memory Pack option (Windows)

This commit is contained in:
luigiblood 2016-11-23 23:38:21 +01:00
parent 17fa454a1e
commit 50228801f1
6 changed files with 43 additions and 1 deletions

View File

@ -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)

View File

@ -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 *);

View File

@ -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

View File

@ -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

View File

@ -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.)"

View File

@ -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)