mirror of https://github.com/snes9xgit/snes9x.git
Fix libretro compilation.
This commit is contained in:
parent
f4f7f03be3
commit
18b5a09a16
32
cheats2.cpp
32
cheats2.cpp
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
#include "bml.h"
|
#include "bml.h"
|
||||||
#include "cheats.h"
|
#include "cheats.h"
|
||||||
#include "fmt/format.h"
|
|
||||||
#include "snes9x.h"
|
#include "snes9x.h"
|
||||||
#include "memmap.h"
|
#include "memmap.h"
|
||||||
|
|
||||||
|
@ -522,10 +521,14 @@ int S9xModifyCheatGroup(uint32 num, const std::string &name, const std::string &
|
||||||
|
|
||||||
std::string S9xCheatToText(const SCheat &c)
|
std::string S9xCheatToText(const SCheat &c)
|
||||||
{
|
{
|
||||||
if (c.conditional)
|
char output[256]{};
|
||||||
return fmt::format("{:06x}={:02x}?{:02x}", c.address, c.cond_byte, c.byte);
|
|
||||||
|
|
||||||
return fmt::format("{:06x}={:02x}", c.address, c.byte);
|
if (c.conditional)
|
||||||
|
sprintf(output, "%06x=%02x?%02x", c.address, c.cond_byte, c.byte);
|
||||||
|
else
|
||||||
|
sprintf(output, "%06x=%02x", c.address, c.byte);
|
||||||
|
|
||||||
|
return std::string(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string S9xCheatGroupToText(SCheatGroup &g)
|
std::string S9xCheatGroupToText(SCheatGroup &g)
|
||||||
|
@ -638,8 +641,9 @@ static bool8 S9xLoadCheatFileClassic(const std::string &filename)
|
||||||
c.address = data[2] | (data[3] << 8) | (data[4] << 16);
|
c.address = data[2] | (data[3] << 8) | (data[4] << 16);
|
||||||
|
|
||||||
std::string name((const char *)&data[8], 20);
|
std::string name((const char *)&data[8], 20);
|
||||||
auto cheat = fmt::format("{:x}={:x}", c.address, c.byte);
|
char code[32]{};
|
||||||
|
sprintf(code, "%x=%x", c.address, c.byte);
|
||||||
|
std::string cheat(code);
|
||||||
S9xAddCheatGroup(name, cheat);
|
S9xAddCheatGroup(name, cheat);
|
||||||
|
|
||||||
if (c.enabled)
|
if (c.enabled)
|
||||||
|
@ -691,14 +695,14 @@ bool8 S9xSaveCheatFile(const std::string &filename)
|
||||||
|
|
||||||
for (i = 0; i < Cheat.group.size(); i++)
|
for (i = 0; i < Cheat.group.size(); i++)
|
||||||
{
|
{
|
||||||
fmt::print(file,
|
fprintf(file,
|
||||||
"cheat\n"
|
"cheat\n"
|
||||||
" name: {}\n"
|
" name: %s\n"
|
||||||
" code: {}\n"
|
" code: %s\n"
|
||||||
"{}\n",
|
"%s\n",
|
||||||
Cheat.group[i].name,
|
Cheat.group[i].name.c_str(),
|
||||||
S9xCheatGroupToText(i),
|
S9xCheatGroupToText(i).c_str(),
|
||||||
Cheat.group[i].enabled ? " enable\n" : "");
|
Cheat.group[i].enabled ? " enable\n" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
|
@ -60,5 +60,5 @@ SOURCES_CXX := $(CORE_DIR)/apu/apu.cpp \
|
||||||
$(CORE_DIR)/sha256.cpp \
|
$(CORE_DIR)/sha256.cpp \
|
||||||
$(CORE_DIR)/bml.cpp \
|
$(CORE_DIR)/bml.cpp \
|
||||||
$(CORE_DIR)/movie.cpp \
|
$(CORE_DIR)/movie.cpp \
|
||||||
$(CORE_DIR)/compat.cpp \
|
$(CORE_DIR)/fscompat.cpp \
|
||||||
$(CORE_DIR)/libretro/libretro.cpp
|
$(CORE_DIR)/libretro/libretro.cpp
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "crosshairs.h"
|
#include "crosshairs.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
|
@ -936,10 +937,10 @@ void retro_cheat_set(unsigned index, bool enabled, const char *codeline)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Goldfinger was broken and nobody noticed. Removed */
|
/* Goldfinger was broken and nobody noticed. Removed */
|
||||||
if (S9xAddCheatGroup ("retro", code) >= 0)
|
if (S9xAddCheatGroup (std::string("retro"), std::string(code)) >= 0)
|
||||||
{
|
{
|
||||||
if (enabled)
|
if (enabled)
|
||||||
S9xEnableCheatGroup (Cheat.g.size () - 1);
|
S9xEnableCheatGroup (Cheat.group.size () - 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1059,14 +1060,14 @@ static bool8 LoadBIOS(uint8 *biosrom, const char *biosname, int biossize)
|
||||||
char name[PATH_MAX + 1];
|
char name[PATH_MAX + 1];
|
||||||
bool8 r = FALSE;
|
bool8 r = FALSE;
|
||||||
|
|
||||||
strcpy(name, S9xGetDirectory(ROMFILENAME_DIR));
|
strcpy(name, S9xGetDirectory(ROMFILENAME_DIR).c_str());
|
||||||
strcat(name, SLASH_STR);
|
strcat(name, SLASH_STR);
|
||||||
strcat(name, biosname);
|
strcat(name, biosname);
|
||||||
|
|
||||||
fp = fopen(name, "rb");
|
fp = fopen(name, "rb");
|
||||||
if (!fp)
|
if (!fp)
|
||||||
{
|
{
|
||||||
strcpy(name, S9xGetDirectory(BIOS_DIR));
|
strcpy(name, S9xGetDirectory(BIOS_DIR).c_str());
|
||||||
strcat(name, SLASH_STR);
|
strcat(name, SLASH_STR);
|
||||||
strcat(name, biosname);
|
strcat(name, biosname);
|
||||||
|
|
||||||
|
@ -2108,23 +2109,23 @@ const char* S9xGetFilename(const char* in, s9x_getdirtype type)
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* S9xGetDirectory(s9x_getdirtype type)
|
std::string S9xGetDirectory(s9x_getdirtype type)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case BIOS_DIR:
|
case BIOS_DIR:
|
||||||
return retro_system_directory;
|
return std::string(retro_system_directory);
|
||||||
default:
|
default:
|
||||||
return g_rom_dir;
|
return std::string(g_rom_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return std::string("");
|
||||||
}
|
}
|
||||||
void S9xInitInputDevices() {}
|
void S9xInitInputDevices() {}
|
||||||
void S9xHandlePortCommand(s9xcommand_t, short, short) {}
|
void S9xHandlePortCommand(s9xcommand_t, short, short) {}
|
||||||
bool S9xPollButton(unsigned int, bool*) { return false; }
|
bool S9xPollButton(unsigned int, bool*) { return false; }
|
||||||
void S9xToggleSoundChannel(int) {}
|
void S9xToggleSoundChannel(int) {}
|
||||||
const char* S9xGetFilenameInc(const char* in, s9x_getdirtype) { return ""; }
|
std::string S9xGetFilenameInc(std::string in, s9x_getdirtype) { return ""; }
|
||||||
const char* S9xBasename(const char* in) { return in; }
|
const char* S9xBasename(const char* in) { return in; }
|
||||||
bool8 S9xInitUpdate() { return TRUE; }
|
bool8 S9xInitUpdate() { return TRUE; }
|
||||||
void S9xExtraUsage() {}
|
void S9xExtraUsage() {}
|
||||||
|
|
Loading…
Reference in New Issue