mirror of https://github.com/snes9xgit/snes9x.git
More cleaning.
This commit is contained in:
parent
596e84af2a
commit
c69552ccff
20
display.h
20
display.h
|
@ -9,24 +9,6 @@
|
||||||
|
|
||||||
#include "snes9x.h"
|
#include "snes9x.h"
|
||||||
|
|
||||||
enum s9x_getdirtype
|
|
||||||
{
|
|
||||||
DEFAULT_DIR = 0,
|
|
||||||
HOME_DIR,
|
|
||||||
ROMFILENAME_DIR,
|
|
||||||
ROM_DIR,
|
|
||||||
SRAM_DIR,
|
|
||||||
SNAPSHOT_DIR,
|
|
||||||
SCREENSHOT_DIR,
|
|
||||||
SPC_DIR,
|
|
||||||
CHEAT_DIR,
|
|
||||||
PATCH_DIR,
|
|
||||||
BIOS_DIR,
|
|
||||||
LOG_DIR,
|
|
||||||
SAT_DIR,
|
|
||||||
LAST_DIR
|
|
||||||
};
|
|
||||||
|
|
||||||
void S9xUsage (void);
|
void S9xUsage (void);
|
||||||
char * S9xParseArgs (char **, int);
|
char * S9xParseArgs (char **, int);
|
||||||
void S9xParseArgsForCheats (char **, int);
|
void S9xParseArgsForCheats (char **, int);
|
||||||
|
@ -45,9 +27,9 @@ bool8 S9xOpenSnapshotFile (const char *, bool8, STREAM *);
|
||||||
void S9xCloseSnapshotFile (STREAM);
|
void S9xCloseSnapshotFile (STREAM);
|
||||||
const char * S9xStringInput (const char *);
|
const char * S9xStringInput (const char *);
|
||||||
std::string S9xGetDirectory (enum s9x_getdirtype);
|
std::string S9xGetDirectory (enum s9x_getdirtype);
|
||||||
std::string S9xGetFilename (std::string, enum s9x_getdirtype);
|
|
||||||
std::string S9xGetFilenameInc (std::string, enum s9x_getdirtype);
|
std::string S9xGetFilenameInc (std::string, enum s9x_getdirtype);
|
||||||
std::string S9xBasename (std::string);
|
std::string S9xBasename (std::string);
|
||||||
|
std::string S9xBasenameNoExt (std::string);
|
||||||
|
|
||||||
// Routines the port has to implement if it uses command-line
|
// Routines the port has to implement if it uses command-line
|
||||||
|
|
||||||
|
|
30
fscompat.cpp
30
fscompat.cpp
|
@ -1,7 +1,10 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include "port.h"
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string.h>
|
|
||||||
|
#include "display.h"
|
||||||
|
#include "fscompat.h"
|
||||||
|
#include "port.h"
|
||||||
|
#include "memmap.h"
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
|
@ -19,6 +22,29 @@ std::string makepath(const SplitPath &path)
|
||||||
return makepath(path.drive, path.dir, path.stem, path.ext);
|
return makepath(path.drive, path.dir, path.stem, path.ext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string S9xGetFilename(string filename, string ext, enum s9x_getdirtype dirtype)
|
||||||
|
{
|
||||||
|
auto path = splitpath(filename);
|
||||||
|
auto dir = S9xGetDirectory(dirtype);
|
||||||
|
return makepath(path.drive, dir, path.stem, ext);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string S9xGetFilename(string ext, enum s9x_getdirtype dirtype)
|
||||||
|
{
|
||||||
|
return S9xGetFilename(Memory.ROMFilename, ext, dirtype);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string S9xBasename(std::string filename)
|
||||||
|
{
|
||||||
|
auto path = splitpath(filename);
|
||||||
|
return path.stem + path.ext;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string S9xBasenameNoExt(std::string filename)
|
||||||
|
{
|
||||||
|
return splitpath(filename).stem;
|
||||||
|
}
|
||||||
|
|
||||||
#if __cplusplus >= 201703L
|
#if __cplusplus >= 201703L
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
|
@ -113,24 +113,6 @@ std::string S9xGetDirectory(enum s9x_getdirtype dirtype)
|
||||||
return dirname;
|
return dirname;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string S9xGetFilename(std::string ex, enum s9x_getdirtype dirtype)
|
|
||||||
{
|
|
||||||
fs::path path(S9xGetDirectory(dirtype));
|
|
||||||
path /= fs::path(Memory.ROMFilename).filename();
|
|
||||||
path.replace_extension(ex);
|
|
||||||
return path.string();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string S9xBasename(std::string filename)
|
|
||||||
{
|
|
||||||
return fs::path(filename).filename().string();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string S9xBasenameNoExt(std::string f)
|
|
||||||
{
|
|
||||||
return fs::path(f).stem();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool8 S9xOpenSnapshotFile(const char *filename, bool8 read_only, STREAM *file)
|
bool8 S9xOpenSnapshotFile(const char *filename, bool8 read_only, STREAM *file)
|
||||||
{
|
{
|
||||||
if (read_only)
|
if (read_only)
|
||||||
|
|
|
@ -903,7 +903,7 @@ const char *markup = _(R"(<b>Information for %s</b>
|
||||||
char output[2048];
|
char output[2048];
|
||||||
|
|
||||||
snprintf(output, 2048, markup,
|
snprintf(output, 2048, markup,
|
||||||
Memory.ROMFilename,
|
Memory.ROMFilename.c_str(),
|
||||||
Memory.ROMName,
|
Memory.ROMName,
|
||||||
Memory.ROMSpeed,
|
Memory.ROMSpeed,
|
||||||
((Memory.ROMSpeed & 0x10) != 0) ? "FastROM" : "SlowROM",
|
((Memory.ROMSpeed & 0x10) != 0) ? "FastROM" : "SlowROM",
|
||||||
|
@ -1020,12 +1020,6 @@ void Snes9xWindow::reset_screensaver()
|
||||||
XResetScreenSaver(GDK_DISPLAY_XDISPLAY(gdk_display));
|
XResetScreenSaver(GDK_DISPLAY_XDISPLAY(gdk_display));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef GDK_WINDOWING_WAYLAND
|
|
||||||
if (GDK_IS_WAYLAND_WINDOW(gdk_window))
|
|
||||||
{
|
|
||||||
// TODO screensaver for wayland
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
config->screensaver_needs_reset = false;
|
config->screensaver_needs_reset = false;
|
||||||
}
|
}
|
||||||
|
|
150
memmap.cpp
150
memmap.cpp
|
@ -49,7 +49,6 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static bool8 stopMovie = TRUE;
|
static bool8 stopMovie = TRUE;
|
||||||
static char LastRomFilename[PATH_MAX + 1] = "";
|
|
||||||
|
|
||||||
// from NSRT
|
// from NSRT
|
||||||
static const char *nintendo_licensees[] =
|
static const char *nintendo_licensees[] =
|
||||||
|
@ -1025,9 +1024,6 @@ void CMemory::Deinit (void)
|
||||||
IPPU.TileCached[t] = NULL;
|
IPPU.TileCached[t] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Safe(NULL);
|
|
||||||
SafeANK(NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// file management and ROM detection
|
// file management and ROM detection
|
||||||
|
@ -1273,7 +1269,7 @@ uint32 CMemory::FileLoader (uint8 *buffer, const char *filename, uint32 maxsize)
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(ROMFilename, filename);
|
ROMFilename = filename;
|
||||||
#else
|
#else
|
||||||
S9xMessage(S9X_ERROR, S9X_ROM_INFO, "This binary was not created with Zip support.");
|
S9xMessage(S9X_ERROR, S9X_ROM_INFO, "This binary was not created with Zip support.");
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -1293,7 +1289,7 @@ uint32 CMemory::FileLoader (uint8 *buffer, const char *filename, uint32 maxsize)
|
||||||
|
|
||||||
totalSize = HeaderRemove(size, buffer);
|
totalSize = HeaderRemove(size, buffer);
|
||||||
|
|
||||||
strcpy(ROMFilename, filename);
|
ROMFilename = filename;
|
||||||
#else
|
#else
|
||||||
S9xMessage(S9X_ERROR, S9X_ROM_INFO, "This binary was not created with JMA support.");
|
S9xMessage(S9X_ERROR, S9X_ROM_INFO, "This binary was not created with JMA support.");
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -1308,7 +1304,7 @@ uint32 CMemory::FileLoader (uint8 *buffer, const char *filename, uint32 maxsize)
|
||||||
if (!fp)
|
if (!fp)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
strcpy(ROMFilename, filename);
|
ROMFilename = filename;
|
||||||
|
|
||||||
uint32 size = 0;
|
uint32 size = 0;
|
||||||
|
|
||||||
|
@ -1336,7 +1332,7 @@ bool8 CMemory::LoadROMMem (const uint8 *source, uint32 sourceSize)
|
||||||
if(!source || sourceSize > MAX_ROM_SIZE)
|
if(!source || sourceSize > MAX_ROM_SIZE)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
strcpy(ROMFilename,"MemoryROM");
|
ROMFilename = "MemoryROM";
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -1573,12 +1569,6 @@ bool8 CMemory::LoadROMInt (int32 ROMfillSize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strncmp(LastRomFilename, ROMFilename, PATH_MAX + 1))
|
|
||||||
{
|
|
||||||
strncpy(LastRomFilename, ROMFilename, PATH_MAX + 1);
|
|
||||||
LastRomFilename[PATH_MAX] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(&SNESGameFixes, 0, sizeof(SNESGameFixes));
|
memset(&SNESGameFixes, 0, sizeof(SNESGameFixes));
|
||||||
SNESGameFixes.SRAMInitialValue = 0x60;
|
SNESGameFixes.SRAMInitialValue = 0x60;
|
||||||
|
|
||||||
|
@ -1711,7 +1701,7 @@ bool8 CMemory::LoadMultiCartInt ()
|
||||||
else
|
else
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
|
|
||||||
strcpy(ROMFilename, path.c_str());
|
ROMFilename = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (Multi.cartType)
|
switch (Multi.cartType)
|
||||||
|
@ -1736,9 +1726,9 @@ bool8 CMemory::LoadMultiCartInt ()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Multi.cartSizeA)
|
if (Multi.cartSizeA)
|
||||||
strcpy(ROMFilename, Multi.fileNameA);
|
ROMFilename = Multi.fileNameA;
|
||||||
else if (Multi.cartSizeB)
|
else if (Multi.cartSizeB)
|
||||||
strcpy(ROMFilename, Multi.fileNameB);
|
ROMFilename = Multi.fileNameB;
|
||||||
|
|
||||||
memset(&SNESGameFixes, 0, sizeof(SNESGameFixes));
|
memset(&SNESGameFixes, 0, sizeof(SNESGameFixes));
|
||||||
SNESGameFixes.SRAMInitialValue = 0x60;
|
SNESGameFixes.SRAMInitialValue = 0x60;
|
||||||
|
@ -1879,22 +1869,14 @@ bool8 CMemory::LoadSRAM (const char *filename)
|
||||||
{
|
{
|
||||||
FILE *file;
|
FILE *file;
|
||||||
int size, len;
|
int size, len;
|
||||||
char sramName[PATH_MAX + 1];
|
|
||||||
|
|
||||||
strcpy(sramName, filename);
|
|
||||||
|
|
||||||
ClearSRAM();
|
ClearSRAM();
|
||||||
|
|
||||||
if (Multi.cartType && Multi.sramSizeB)
|
if (Multi.cartType && Multi.sramSizeB)
|
||||||
{
|
{
|
||||||
char temp[PATH_MAX + 1];
|
|
||||||
|
|
||||||
strcpy(temp, ROMFilename);
|
|
||||||
strcpy(ROMFilename, Multi.fileNameB);
|
|
||||||
|
|
||||||
size = (1 << (Multi.sramSizeB + 3)) * 128;
|
size = (1 << (Multi.sramSizeB + 3)) * 128;
|
||||||
|
|
||||||
file = fopen(S9xGetFilename(".srm", SRAM_DIR).c_str(), "rb");
|
file = fopen(S9xGetFilename(Multi.fileNameB, ".srm", SRAM_DIR).c_str(), "rb");
|
||||||
if (file)
|
if (file)
|
||||||
{
|
{
|
||||||
len = fread((char *) Multi.sramB, 1, 0x10000, file);
|
len = fread((char *) Multi.sramB, 1, 0x10000, file);
|
||||||
|
@ -1902,8 +1884,6 @@ bool8 CMemory::LoadSRAM (const char *filename)
|
||||||
if (len - size == 512)
|
if (len - size == 512)
|
||||||
memmove(Multi.sramB, Multi.sramB + 512, size);
|
memmove(Multi.sramB, Multi.sramB + 512, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(ROMFilename, temp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size = SRAMSize ? (1 << (SRAMSize + 3)) * 128 : 0;
|
size = SRAMSize ? (1 << (SRAMSize + 3)) * 128 : 0;
|
||||||
|
@ -1914,7 +1894,7 @@ bool8 CMemory::LoadSRAM (const char *filename)
|
||||||
|
|
||||||
if (size)
|
if (size)
|
||||||
{
|
{
|
||||||
file = fopen(sramName, "rb");
|
file = fopen(filename, "rb");
|
||||||
if (file)
|
if (file)
|
||||||
{
|
{
|
||||||
len = fread((char *) SRAM, 1, size, file);
|
len = fread((char *) SRAM, 1, size, file);
|
||||||
|
@ -1967,29 +1947,19 @@ bool8 CMemory::SaveSRAM (const char *filename)
|
||||||
|
|
||||||
FILE *file;
|
FILE *file;
|
||||||
int size;
|
int size;
|
||||||
char sramName[PATH_MAX + 1];
|
|
||||||
|
|
||||||
strcpy(sramName, filename);
|
|
||||||
|
|
||||||
if (Multi.cartType && Multi.sramSizeB)
|
if (Multi.cartType && Multi.sramSizeB)
|
||||||
{
|
{
|
||||||
char name[PATH_MAX + 1], temp[PATH_MAX + 1];
|
std::string name = S9xGetFilename(Multi.fileNameB, ".srm", SRAM_DIR);
|
||||||
|
|
||||||
strcpy(temp, ROMFilename);
|
|
||||||
strcpy(ROMFilename, Multi.fileNameB);
|
|
||||||
strcpy(name, S9xGetFilename(".srm", SRAM_DIR).c_str());
|
|
||||||
|
|
||||||
size = (1 << (Multi.sramSizeB + 3)) * 128;
|
size = (1 << (Multi.sramSizeB + 3)) * 128;
|
||||||
|
|
||||||
file = fopen(name, "wb");
|
file = fopen(name.c_str(), "wb");
|
||||||
if (file)
|
if (file)
|
||||||
{
|
{
|
||||||
if (!fwrite((char *) Multi.sramB, size, 1, file))
|
if (!fwrite((char *) Multi.sramB, size, 1, file))
|
||||||
printf ("Couldn't write to subcart SRAM file.\n");
|
printf ("Couldn't write to subcart SRAM file.\n");
|
||||||
fclose(file);
|
fclose(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(ROMFilename, temp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size = SRAMSize ? (1 << (SRAMSize + 3)) * 128 : 0;
|
size = SRAMSize ? (1 << (SRAMSize + 3)) * 128 : 0;
|
||||||
|
@ -2000,7 +1970,7 @@ bool8 CMemory::SaveSRAM (const char *filename)
|
||||||
|
|
||||||
if (size)
|
if (size)
|
||||||
{
|
{
|
||||||
file = fopen(sramName, "wb");
|
file = fopen(filename, "wb");
|
||||||
if (file)
|
if (file)
|
||||||
{
|
{
|
||||||
if (!fwrite((char *) SRAM, size, 1, file))
|
if (!fwrite((char *) SRAM, size, 1, file))
|
||||||
|
@ -2023,13 +1993,11 @@ bool8 CMemory::SaveMPAK (const char *filename)
|
||||||
{
|
{
|
||||||
FILE *file;
|
FILE *file;
|
||||||
int size;
|
int size;
|
||||||
char mempakName[PATH_MAX + 1];
|
|
||||||
|
|
||||||
strcpy(mempakName, filename);
|
|
||||||
size = 0x100000;
|
size = 0x100000;
|
||||||
if (size)
|
if (size)
|
||||||
{
|
{
|
||||||
file = fopen(mempakName, "wb");
|
file = fopen(filename, "wb");
|
||||||
if (file)
|
if (file)
|
||||||
{
|
{
|
||||||
size_t written;
|
size_t written;
|
||||||
|
@ -2053,87 +2021,6 @@ static uint32 caCRC32 (uint8 *array, uint32 size, uint32 crc32)
|
||||||
return (~crc32);
|
return (~crc32);
|
||||||
}
|
}
|
||||||
|
|
||||||
char * CMemory::Safe (const char *s)
|
|
||||||
{
|
|
||||||
static char *safe = NULL;
|
|
||||||
static int safe_len = 0;
|
|
||||||
|
|
||||||
if (s == NULL)
|
|
||||||
{
|
|
||||||
if (safe)
|
|
||||||
{
|
|
||||||
free(safe);
|
|
||||||
safe = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
int len = strlen(s);
|
|
||||||
if (!safe || len + 1 > safe_len)
|
|
||||||
{
|
|
||||||
if (safe)
|
|
||||||
free(safe);
|
|
||||||
|
|
||||||
safe_len = len + 1;
|
|
||||||
safe = (char *) malloc(safe_len);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < len; i++)
|
|
||||||
{
|
|
||||||
if (s[i] >= 32 && s[i] < 127)
|
|
||||||
safe[i] = s[i];
|
|
||||||
else
|
|
||||||
safe[i] = '_';
|
|
||||||
}
|
|
||||||
|
|
||||||
safe[len] = 0;
|
|
||||||
|
|
||||||
return (safe);
|
|
||||||
}
|
|
||||||
|
|
||||||
char * CMemory::SafeANK (const char *s)
|
|
||||||
{
|
|
||||||
static char *safe = NULL;
|
|
||||||
static int safe_len = 0;
|
|
||||||
|
|
||||||
if (s == NULL)
|
|
||||||
{
|
|
||||||
if (safe)
|
|
||||||
{
|
|
||||||
free(safe);
|
|
||||||
safe = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
int len = strlen(s);
|
|
||||||
if (!safe || len + 1 > safe_len)
|
|
||||||
{
|
|
||||||
if (safe)
|
|
||||||
free(safe);
|
|
||||||
|
|
||||||
safe_len = len + 1;
|
|
||||||
safe = (char *) malloc(safe_len);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < len; i++)
|
|
||||||
{
|
|
||||||
if (s[i] >= 32 && s[i] < 127) // ASCII
|
|
||||||
safe [i] = s[i];
|
|
||||||
else
|
|
||||||
if (ROMRegion == 0 && ((uint8) s[i] >= 0xa0 && (uint8) s[i] < 0xe0)) // JIS X 201 - Katakana
|
|
||||||
safe [i] = s[i];
|
|
||||||
else
|
|
||||||
safe [i] = '_';
|
|
||||||
}
|
|
||||||
|
|
||||||
safe [len] = 0;
|
|
||||||
|
|
||||||
return (safe);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMemory::ParseSNESHeader (uint8 *RomHeader)
|
void CMemory::ParseSNESHeader (uint8 *RomHeader)
|
||||||
{
|
{
|
||||||
bool8 bs = Settings.BS & !Settings.BSXItself;
|
bool8 bs = Settings.BS & !Settings.BSXItself;
|
||||||
|
@ -2563,15 +2450,10 @@ void CMemory::InitROM (void)
|
||||||
ApplyROMFixes();
|
ApplyROMFixes();
|
||||||
|
|
||||||
//// Show ROM information
|
//// Show ROM information
|
||||||
char displayName[ROM_NAME_LEN];
|
ROMId[4] = 0;
|
||||||
|
|
||||||
strcpy(RawROMName, ROMName);
|
|
||||||
sprintf(displayName, "%s", SafeANK(ROMName));
|
|
||||||
sprintf(ROMName, "%s", Safe(ROMName));
|
|
||||||
sprintf(ROMId, "%s", Safe(ROMId));
|
|
||||||
|
|
||||||
sprintf(String, "\"%s\" [%s] %s, %s, %s, %s, SRAM:%s, ID:%s, CRC32:%08X",
|
sprintf(String, "\"%s\" [%s] %s, %s, %s, %s, SRAM:%s, ID:%s, CRC32:%08X",
|
||||||
displayName, isChecksumOK ? "checksum ok" : ((Multi.cartType == 4) ? "no checksum" : "bad checksum"),
|
ROMName, isChecksumOK ? "checksum ok" : ((Multi.cartType == 4) ? "no checksum" : "bad checksum"),
|
||||||
MapType(), Size(), KartContents(), Settings.PAL ? "PAL" : "NTSC", StaticRAMSize(), ROMId, ROMCRC32);
|
MapType(), Size(), KartContents(), Settings.PAL ? "PAL" : "NTSC", StaticRAMSize(), ROMId, ROMCRC32);
|
||||||
S9xMessage(S9X_INFO, S9X_ROM_INFO, String);
|
S9xMessage(S9X_INFO, S9X_ROM_INFO, String);
|
||||||
|
|
||||||
|
@ -4058,8 +3940,6 @@ void CMemory::CheckForAnyPatch (const char *rom_filename, bool8 header, int32 &r
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
snprintf(ips, 8, "ips%d", i);
|
snprintf(ips, 8, "ips%d", i);
|
||||||
if (strlen(ips) > _MAX_EXT)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (unzFindExtension(file, ips) != UNZ_OK)
|
if (unzFindExtension(file, ips) != UNZ_OK)
|
||||||
break;
|
break;
|
||||||
|
|
7
memmap.h
7
memmap.h
|
@ -12,6 +12,8 @@
|
||||||
#define MEMMAP_SHIFT (12)
|
#define MEMMAP_SHIFT (12)
|
||||||
#define MEMMAP_MASK (MEMMAP_BLOCK_SIZE - 1)
|
#define MEMMAP_MASK (MEMMAP_BLOCK_SIZE - 1)
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
struct CMemory
|
struct CMemory
|
||||||
{
|
{
|
||||||
enum
|
enum
|
||||||
|
@ -70,9 +72,8 @@ struct CMemory
|
||||||
uint8 BlockIsROM[MEMMAP_NUM_BLOCKS];
|
uint8 BlockIsROM[MEMMAP_NUM_BLOCKS];
|
||||||
uint8 ExtendedFormat;
|
uint8 ExtendedFormat;
|
||||||
|
|
||||||
char ROMFilename[PATH_MAX + 1];
|
std::string ROMFilename;
|
||||||
char ROMName[ROM_NAME_LEN];
|
char ROMName[ROM_NAME_LEN];
|
||||||
char RawROMName[ROM_NAME_LEN];
|
|
||||||
char ROMId[5];
|
char ROMId[5];
|
||||||
int32 CompanyId;
|
int32 CompanyId;
|
||||||
uint8 ROMRegion;
|
uint8 ROMRegion;
|
||||||
|
@ -120,8 +121,6 @@ struct CMemory
|
||||||
bool8 SaveSRTC (void);
|
bool8 SaveSRTC (void);
|
||||||
bool8 SaveMPAK (const char *);
|
bool8 SaveMPAK (const char *);
|
||||||
|
|
||||||
char * Safe (const char *);
|
|
||||||
char * SafeANK (const char *);
|
|
||||||
void ParseSNESHeader (uint8 *);
|
void ParseSNESHeader (uint8 *);
|
||||||
void InitROM (void);
|
void InitROM (void);
|
||||||
|
|
||||||
|
|
|
@ -740,7 +740,6 @@ int S9xMovieCreate (const char *filename, uint8 controllers_mask, uint8 opts, co
|
||||||
}
|
}
|
||||||
|
|
||||||
Movie.ROMCRC32 = Memory.ROMCRC32;
|
Movie.ROMCRC32 = Memory.ROMCRC32;
|
||||||
strncpy(Movie.ROMName, Memory.RawROMName, 23);
|
|
||||||
|
|
||||||
write_movie_extrarominfo(fd, &Movie);
|
write_movie_extrarominfo(fd, &Movie);
|
||||||
|
|
||||||
|
|
5
msu1.cpp
5
msu1.cpp
|
@ -112,10 +112,9 @@ static bool AudioOpen()
|
||||||
|
|
||||||
AudioClose();
|
AudioClose();
|
||||||
|
|
||||||
char ext[_MAX_EXT];
|
std::string extension = "-" + std::to_string(MSU1.MSU1_CURRENT_TRACK) + ".pcm";
|
||||||
snprintf(ext, _MAX_EXT, "-%d.pcm", MSU1.MSU1_CURRENT_TRACK);
|
|
||||||
|
|
||||||
audioStream = S9xMSU1OpenFile(ext);
|
audioStream = S9xMSU1OpenFile(extension.c_str());
|
||||||
if (audioStream)
|
if (audioStream)
|
||||||
{
|
{
|
||||||
if (GETC_STREAM(audioStream) != 'M')
|
if (GETC_STREAM(audioStream) != 'M')
|
||||||
|
|
|
@ -647,7 +647,7 @@ bool8 S9xNPGetROMImage (uint32 len)
|
||||||
S9xNPSetAction ("Receiving ROM filename...");
|
S9xNPSetAction ("Receiving ROM filename...");
|
||||||
uint32 filename_len = len - Memory.CalculatedSize - 5;
|
uint32 filename_len = len - Memory.CalculatedSize - 5;
|
||||||
if (filename_len > PATH_MAX ||
|
if (filename_len > PATH_MAX ||
|
||||||
!S9xNPGetData (NetPlay.Socket, (uint8 *) Memory.ROMFilename, filename_len))
|
!S9xNPGetData (NetPlay.Socket, (uint8 *) Memory.ROMFilename.c_str(), filename_len))
|
||||||
{
|
{
|
||||||
S9xNPSetError ("Error while receiving ROM filename from server.");
|
S9xNPSetError ("Error while receiving ROM filename from server.");
|
||||||
S9xNPDisconnect ();
|
S9xNPDisconnect ();
|
||||||
|
|
|
@ -960,7 +960,7 @@ bool8 S9xNPSendROMImageToClient (int c)
|
||||||
uint8 header [7 + 1 + 4];
|
uint8 header [7 + 1 + 4];
|
||||||
uint8 *ptr = header;
|
uint8 *ptr = header;
|
||||||
int len = sizeof (header) + Memory.CalculatedSize +
|
int len = sizeof (header) + Memory.CalculatedSize +
|
||||||
strlen (Memory.ROMFilename) + 1;
|
Memory.ROMFilename.length() + 1;
|
||||||
*ptr++ = NP_SERV_MAGIC;
|
*ptr++ = NP_SERV_MAGIC;
|
||||||
*ptr++ = NPServer.Clients [c].SendSequenceNum++;
|
*ptr++ = NPServer.Clients [c].SendSequenceNum++;
|
||||||
*ptr++ = NP_SERV_ROM_IMAGE;
|
*ptr++ = NP_SERV_ROM_IMAGE;
|
||||||
|
@ -972,8 +972,8 @@ bool8 S9xNPSendROMImageToClient (int c)
|
||||||
if (!S9xNPSSendData (NPServer.Clients [c].Socket, header, sizeof (header)) ||
|
if (!S9xNPSSendData (NPServer.Clients [c].Socket, header, sizeof (header)) ||
|
||||||
!S9xNPSSendData (NPServer.Clients [c].Socket, Memory.ROM,
|
!S9xNPSSendData (NPServer.Clients [c].Socket, Memory.ROM,
|
||||||
Memory.CalculatedSize) ||
|
Memory.CalculatedSize) ||
|
||||||
!S9xNPSSendData (NPServer.Clients [c].Socket, (uint8 *) Memory.ROMFilename,
|
!S9xNPSSendData (NPServer.Clients [c].Socket, (uint8 *) Memory.ROMFilename.c_str(),
|
||||||
strlen (Memory.ROMFilename) + 1))
|
Memory.ROMFilename.length() + 1))
|
||||||
{
|
{
|
||||||
S9xNPShutdownClient (c, TRUE);
|
S9xNPShutdownClient (c, TRUE);
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
|
|
|
@ -1175,7 +1175,7 @@ void S9xFreezeToStream (STREAM stream)
|
||||||
sprintf(buffer, "%s:%04d\n", SNAPSHOT_MAGIC, SNAPSHOT_VERSION);
|
sprintf(buffer, "%s:%04d\n", SNAPSHOT_MAGIC, SNAPSHOT_VERSION);
|
||||||
WRITE_STREAM(buffer, strlen(buffer), stream);
|
WRITE_STREAM(buffer, strlen(buffer), stream);
|
||||||
|
|
||||||
sprintf(buffer, "NAM:%06d:%s%c", (int) strlen(Memory.ROMFilename) + 1, Memory.ROMFilename, 0);
|
sprintf(buffer, "NAM:%06d:%s%c", (int) Memory.ROMFilename.length() + 1, Memory.ROMFilename.c_str(), 0);
|
||||||
WRITE_STREAM(buffer, strlen(buffer) + 1, stream);
|
WRITE_STREAM(buffer, strlen(buffer) + 1, stream);
|
||||||
|
|
||||||
FreezeStruct(stream, "CPU", &CPU, SnapCPU, COUNT(SnapCPU));
|
FreezeStruct(stream, "CPU", &CPU, SnapCPU, COUNT(SnapCPU));
|
||||||
|
|
Loading…
Reference in New Issue