Builds clean.

This commit is contained in:
Themaister 2012-04-07 12:17:40 +02:00
parent 5d51942f69
commit e012e290ae
14 changed files with 145 additions and 230 deletions

View File

@ -136,9 +136,9 @@ endif
endif endif
ifeq ($(HAVE_XML), 1) ifeq ($(HAVE_XML), 1)
OBJ += gfx/snes_state.o gfx/image.o OBJ += gfx/state_tracker.o gfx/image.o
else ifeq ($(HAVE_CG), 1) else ifeq ($(HAVE_CG), 1)
OBJ += gfx/snes_state.o gfx/image.o OBJ += gfx/state_tracker.o gfx/image.o
endif endif
ifeq ($(HAVE_DYLIB), 1) ifeq ($(HAVE_DYLIB), 1)

View File

@ -84,7 +84,7 @@ ifeq ($(HAVE_RSOUND), 1)
endif endif
ifeq ($(HAVE_XML), 1) ifeq ($(HAVE_XML), 1)
OBJ += gfx/shader_glsl.o gfx/image.o gfx/snes_state.o cheats.o OBJ += gfx/shader_glsl.o gfx/image.o gfx/state_tracker.o cheats.o
DEFINES += -Ilibxml2 -DHAVE_XML DEFINES += -Ilibxml2 -DHAVE_XML
LIBS += -lxml2 -liconv LIBS += -lxml2 -liconv
endif endif

View File

@ -142,11 +142,11 @@ static bool xml_grab_cheats(cheat_manager_t *handle, xmlNodePtr ptr)
static void cheat_manager_apply_cheats(cheat_manager_t *handle) static void cheat_manager_apply_cheats(cheat_manager_t *handle)
{ {
unsigned index = 0; unsigned index = 0;
psnes_cheat_reset(); pretro_cheat_reset();
for (unsigned i = 0; i < handle->size; i++) for (unsigned i = 0; i < handle->size; i++)
{ {
if (handle->cheats[i].state) if (handle->cheats[i].state)
psnes_cheat_set(index++, true, handle->cheats[i].code); pretro_cheat_set(index++, true, handle->cheats[i].code);
} }
} }
@ -238,7 +238,7 @@ cheat_manager_t* cheat_manager_new(const char *path)
{ {
LIBXML_TEST_VERSION; LIBXML_TEST_VERSION;
psnes_cheat_reset(); pretro_cheat_reset();
xmlParserCtxtPtr ctx = NULL; xmlParserCtxtPtr ctx = NULL;
xmlDocPtr doc = NULL; xmlDocPtr doc = NULL;

View File

@ -43,7 +43,7 @@
#define SYM(x) do { \ #define SYM(x) do { \
function_t func = dylib_proc(lib_handle, #x); \ function_t func = dylib_proc(lib_handle, #x); \
memcpy(&p##x, &func, sizeof(func)); \ memcpy(&p##x, &func, sizeof(func)); \
if (p##x == NULL) { SSNES_ERR("Failed to load symbol: \"%s\"\n", #x); ssnes_fail(1, "init_libsnes_sym()"); } \ if (p##x == NULL) { SSNES_ERR("Failed to load symbol: \"%s\"\n", #x); ssnes_fail(1, "init_libretro_sym()"); } \
} while (0) } while (0)
static dylib_t lib_handle = NULL; static dylib_t lib_handle = NULL;
@ -94,11 +94,11 @@ static void set_environment_defaults(void);
static void load_symbols(void) static void load_symbols(void)
{ {
#ifdef HAVE_DYNAMIC #ifdef HAVE_DYNAMIC
SSNES_LOG("Loading dynamic libsnes from: \"%s\"\n", g_settings.libsnes); SSNES_LOG("Loading dynamic libsnes from: \"%s\"\n", g_settings.libretro);
lib_handle = dylib_load(g_settings.libsnes); lib_handle = dylib_load(g_settings.libretro);
if (!lib_handle) if (!lib_handle)
{ {
SSNES_ERR("Failed to open dynamic library: \"%s\"\n", g_settings.libsnes); SSNES_ERR("Failed to open dynamic library: \"%s\"\n", g_settings.libretro);
ssnes_fail(1, "load_dynamic()"); ssnes_fail(1, "load_dynamic()");
} }
#endif #endif
@ -138,7 +138,7 @@ static void load_symbols(void)
SYM(retro_get_memory_size); SYM(retro_get_memory_size);
} }
void init_libsnes_sym(void) void init_libretro_sym(void)
{ {
// Guarantee that we can do "dirty" casting. // Guarantee that we can do "dirty" casting.
// Every OS that this program supports should pass this ... // Every OS that this program supports should pass this ...
@ -153,18 +153,19 @@ void init_libsnes_sym(void)
SSNES_ERR("Serious problem. SSNES wants to load libsnes dyamically, but it is already linked.\n"); SSNES_ERR("Serious problem. SSNES wants to load libsnes dyamically, but it is already linked.\n");
SSNES_ERR("This could happen if other modules SSNES depends on link against libsnes directly.\n"); SSNES_ERR("This could happen if other modules SSNES depends on link against libsnes directly.\n");
SSNES_ERR("Proceeding could cause a crash. Aborting ...\n"); SSNES_ERR("Proceeding could cause a crash. Aborting ...\n");
ssnes_fail(1, "init_libsnes_sym()"); ssnes_fail(1, "init_libretro_sym()");
} }
if (!*g_settings.libsnes) if (!*g_settings.libretro)
{ {
#if defined(_WIN32) #if defined(_WIN32)
strlcpy(g_settings.libsnes, "retro.dll", sizeof(g_settings.libsnes)); const char *libretro_path = "retro.dll";
#elif defined(__APPLE__) #elif defined(__APPLE__)
strlcpy(g_settings.libsnes, "libretro.dylib", sizeof(g_settings.libsnes)); const char *libretro_path = "libretro.dylib";
#else #else
strlcpy(g_settings.libsnes, "libretro.so", sizeof(g_settings.libsnes)); const char *libretro_path = "libretro.so";
#endif #endif
strlcpy(g_settings.libretro, libretro_path, sizeof(g_settings.libretro));
} }
#endif #endif
@ -174,7 +175,7 @@ void init_libsnes_sym(void)
set_environment(); set_environment();
} }
void uninit_libsnes_sym(void) void uninit_libretro_sym(void)
{ {
#ifdef HAVE_DYNAMIC #ifdef HAVE_DYNAMIC
if (lib_handle) if (lib_handle)

4
file.c
View File

@ -604,9 +604,9 @@ static bool load_roms(unsigned rom_type, const char **rom_paths, size_t roms)
} }
if (rom_type == 0) if (rom_type == 0)
ret = retro_load_game(&info[0]); ret = pretro_load_game(&info[0]);
else else
ret = retro_load_game_special(rom_type, info, roms); ret = pretro_load_game_special(rom_type, info, roms);
if (!ret) if (!ret)
SSNES_ERR("Failed to load game.\n"); SSNES_ERR("Failed to load game.\n");

View File

@ -160,7 +160,7 @@ struct settings
bool netplay_client_swap_input; bool netplay_client_swap_input;
} input; } input;
char libsnes[PATH_MAX]; char libretro[PATH_MAX];
char cheat_database[PATH_MAX]; char cheat_database[PATH_MAX];
char cheat_settings_path[PATH_MAX]; char cheat_settings_path[PATH_MAX];

View File

@ -65,10 +65,10 @@ static int16_t input_ext_input_state(void *data, const struct snes_keybind **sne
input_ext_t *ext = (input_ext_t*)data; input_ext_t *ext = (input_ext_t*)data;
unsigned player = 0; unsigned player = 0;
if (device == SNES_DEVICE_MULTITAP) if (device == RETRO_DEVICE_JOYPAD_MULTITAP)
player = (port == SNES_PORT_1) ? 1 : index + 2; player = (port == 1) ? 1 : index + 2;
else else
player = (port == SNES_PORT_1) ? 1 : 2; player = port + 1;
if (id < SSNES_BIND_LIST_END) if (id < SSNES_BIND_LIST_END)
{ {

View File

@ -22,45 +22,38 @@
#include <string.h> #include <string.h>
#include "../../dynamic.h" #include "../../dynamic.h"
#include "../../libsnes.hpp" #include "../../libretro.h"
#include "py_state.h" #include "py_state.h"
#include "../../general.h" #include "../../general.h"
#include "../../compat/strl.h" #include "../../compat/strl.h"
#include "../../compat/posix_string.h" #include "../../compat/posix_string.h"
#include "../../file.h" #include "../../file.h"
#define PY_READ_FUNC_DECL(RAMTYPE) py_read_##RAMTYPE static PyObject* py_read_wram(PyObject *self, PyObject *args)
#define PY_READ_FUNC(RAMTYPE) \ {
static PyObject* PY_READ_FUNC_DECL(RAMTYPE) (PyObject *self, PyObject *args) \ (void)self;
{ \
(void)self; \ const uint8_t *data = (const uint8_t*)pretro_get_memory_data(RETRO_MEMORY_SYSTEM_RAM);
\ if (!data)
const uint8_t *data = psnes_get_memory_data(SNES_MEMORY_##RAMTYPE); \ {
if (!data) \ Py_INCREF(Py_None);
{ \ return Py_None;
Py_INCREF(Py_None); \
return Py_None; \
} \
unsigned max = psnes_get_memory_size(SNES_MEMORY_##RAMTYPE); \
\
unsigned addr; \
if (!PyArg_ParseTuple(args, "I", &addr)) \
return NULL; \
\
if (addr >= max || addr < 0) \
{ \
Py_INCREF(Py_None); \
return Py_None; \
} \
\
return PyLong_FromLong((long)data[addr]); \
} }
PY_READ_FUNC(WRAM) size_t max = pretro_get_memory_size(RETRO_MEMORY_SYSTEM_RAM);
PY_READ_FUNC(VRAM)
PY_READ_FUNC(APURAM) unsigned addr;
PY_READ_FUNC(CGRAM) if (!PyArg_ParseTuple(args, "I", &addr))
PY_READ_FUNC(OAM) return NULL;
if (addr >= max || addr < 0)
{
Py_INCREF(Py_None);
return Py_None;
}
return PyLong_FromLong(data[addr]);
}
static PyObject *py_read_input(PyObject *self, PyObject *args) static PyObject *py_read_input(PyObject *self, PyObject *args)
{ {
@ -86,7 +79,7 @@ static PyObject *py_read_input(PyObject *self, PyObject *args)
}; };
int16_t res = input_input_state_func(binds, player > 1, int16_t res = input_input_state_func(binds, player > 1,
player > 2 ? SNES_DEVICE_MULTITAP : SNES_DEVICE_JOYPAD, player > 2 ? RETRO_DEVICE_JOYPAD_MULTITAP : RETRO_DEVICE_JOYPAD,
player > 2 ? player - 2 : 0, player > 2 ? player - 2 : 0,
key); key);
@ -112,17 +105,13 @@ static PyObject *py_read_input_meta(PyObject *self, PyObject *args)
} }
static PyMethodDef SNESMethods[] = { static PyMethodDef SNESMethods[] = {
{ "read_wram", PY_READ_FUNC_DECL(WRAM), METH_VARARGS, "Read WRAM from SNES." }, { "read_wram", py_read_wram, METH_VARARGS, "Read WRAM from system." },
{ "read_vram", PY_READ_FUNC_DECL(VRAM), METH_VARARGS, "Read VRAM from SNES." }, { "input", py_read_input, METH_VARARGS, "Read input state from system." },
{ "read_apuram", PY_READ_FUNC_DECL(APURAM), METH_VARARGS, "Read APURAM from SNES." },
{ "read_cgram", PY_READ_FUNC_DECL(CGRAM), METH_VARARGS, "Read CGRAM from SNES." },
{ "read_oam", PY_READ_FUNC_DECL(OAM), METH_VARARGS, "Read OAM from SNES." },
{ "input", py_read_input, METH_VARARGS, "Read input state from SNES." },
{ "input_meta", py_read_input_meta, METH_VARARGS, "Read SSNES specific input." }, { "input_meta", py_read_input_meta, METH_VARARGS, "Read SSNES specific input." },
{ NULL, NULL, 0, NULL } { NULL, NULL, 0, NULL }
}; };
#define DECL_ATTR_SNES(attr) PyObject_SetAttrString(mod, #attr, PyLong_FromLong(SNES_DEVICE_ID_JOYPAD_##attr)) #define DECL_ATTR_SNES(attr) PyObject_SetAttrString(mod, #attr, PyLong_FromLong(RETRO_DEVICE_ID_JOYPAD_##attr))
#define DECL_ATTR_SSNES(attr) PyObject_SetAttrString(mod, #attr, PyLong_FromLong(SSNES_##attr)) #define DECL_ATTR_SSNES(attr) PyObject_SetAttrString(mod, #attr, PyLong_FromLong(SSNES_##attr))
static void py_set_attrs(PyObject *mod) static void py_set_attrs(PyObject *mod)
{ {

View File

@ -27,7 +27,7 @@
#include "../compat/posix_string.h" #include "../compat/posix_string.h"
#ifdef HAVE_CONFIGFILE #ifdef HAVE_CONFIGFILE
#include "snes_state.h" #include "state_tracker.h"
#endif #endif
//#define SSNES_CG_DEBUG //#define SSNES_CG_DEBUG
@ -141,7 +141,7 @@ static CGparameter cg_attribs[PREV_TEXTURES + 1 + SSNES_CG_MAX_SHADERS];
static unsigned cg_attrib_index; static unsigned cg_attrib_index;
#ifdef HAVE_CONFIGFILE #ifdef HAVE_CONFIGFILE
static snes_tracker_t *snes_tracker = NULL; static state_tracker_t *state_tracker = NULL;
#endif #endif
static void gl_cg_reset_attrib(void) static void gl_cg_reset_attrib(void)
@ -271,13 +271,13 @@ void gl_cg_set_params(unsigned width, unsigned height,
#ifdef HAVE_CONFIGFILE #ifdef HAVE_CONFIGFILE
// Set state parameters // Set state parameters
if (snes_tracker) if (state_tracker)
{ {
static struct snes_tracker_uniform info[MAX_VARIABLES]; static struct state_tracker_uniform info[MAX_VARIABLES];
static unsigned cnt = 0; static unsigned cnt = 0;
if (active_index == 1) if (active_index == 1)
cnt = snes_get_uniform(snes_tracker, info, MAX_VARIABLES, frame_count); cnt = state_get_uniform(state_tracker, info, MAX_VARIABLES, frame_count);
for (unsigned i = 0; i < cnt; i++) for (unsigned i = 0; i < cnt; i++)
{ {
@ -328,10 +328,10 @@ static void gl_cg_deinit_state(void)
lut_textures_num = 0; lut_textures_num = 0;
#ifdef HAVE_CONFIGFILE #ifdef HAVE_CONFIGFILE
if (snes_tracker) if (state_tracker)
{ {
snes_tracker_free(snes_tracker); state_tracker_free(state_tracker);
snes_tracker = NULL; state_tracker = NULL;
} }
#endif #endif
} }
@ -565,9 +565,9 @@ static bool load_imports(const char *dir_path, config_file_t *conf)
if (!config_get_string(conf, "imports", &imports)) if (!config_get_string(conf, "imports", &imports))
return true; return true;
struct snes_tracker_uniform_info info[MAX_VARIABLES]; struct state_tracker_uniform_info info[MAX_VARIABLES];
unsigned info_cnt = 0; unsigned info_cnt = 0;
struct snes_tracker_info tracker_info = {0}; struct state_tracker_info tracker_info = {0};
#ifdef HAVE_PYTHON #ifdef HAVE_PYTHON
char script_path[128]; char script_path[128];
@ -581,20 +581,12 @@ static bool load_imports(const char *dir_path, config_file_t *conf)
char semantic_buf[64]; char semantic_buf[64];
char wram_buf[64]; char wram_buf[64];
char input_slot_buf[64]; char input_slot_buf[64];
char apuram_buf[64];
char oam_buf[64];
char cgram_buf[64];
char vram_buf[64];
char mask_buf[64]; char mask_buf[64];
char equal_buf[64]; char equal_buf[64];
print_buf(semantic_buf, "%s_semantic", id); print_buf(semantic_buf, "%s_semantic", id);
print_buf(wram_buf, "%s_wram", id); print_buf(wram_buf, "%s_wram", id);
print_buf(input_slot_buf, "%s_input_slot", id); print_buf(input_slot_buf, "%s_input_slot", id);
print_buf(apuram_buf, "%s_apuram", id);
print_buf(oam_buf, "%s_oam", id);
print_buf(cgram_buf, "%s_cgram", id);
print_buf(vram_buf, "%s_vram", id);
print_buf(mask_buf, "%s_mask", id); print_buf(mask_buf, "%s_mask", id);
print_buf(equal_buf, "%s_equal", id); print_buf(equal_buf, "%s_equal", id);
@ -609,8 +601,8 @@ static bool load_imports(const char *dir_path, config_file_t *conf)
goto end; goto end;
} }
enum snes_tracker_type tracker_type; enum state_tracker_type tracker_type;
enum snes_ram_type ram_type = SSNES_STATE_NONE; enum state_ram_type ram_type = SSNES_STATE_NONE;
if (strcmp(semantic, "capture") == 0) if (strcmp(semantic, "capture") == 0)
tracker_type = SSNES_STATE_CAPTURE; tracker_type = SSNES_STATE_CAPTURE;
@ -659,14 +651,6 @@ static bool load_imports(const char *dir_path, config_file_t *conf)
} }
else if (config_get_hex(conf, wram_buf, &addr)) else if (config_get_hex(conf, wram_buf, &addr))
ram_type = SSNES_STATE_WRAM; ram_type = SSNES_STATE_WRAM;
else if (config_get_hex(conf, apuram_buf, &addr))
ram_type = SSNES_STATE_APURAM;
else if (config_get_hex(conf, oam_buf, &addr))
ram_type = SSNES_STATE_OAM;
else if (config_get_hex(conf, cgram_buf, &addr))
ram_type = SSNES_STATE_CGRAM;
else if (config_get_hex(conf, vram_buf, &addr))
ram_type = SSNES_STATE_VRAM;
else else
{ {
SSNES_ERR("No address assigned to semantic.\n"); SSNES_ERR("No address assigned to semantic.\n");
@ -679,26 +663,14 @@ static bool load_imports(const char *dir_path, config_file_t *conf)
switch (ram_type) switch (ram_type)
{ {
case SSNES_STATE_WRAM: case SSNES_STATE_WRAM:
memtype = SNES_MEMORY_WRAM; memtype = RETRO_MEMORY_SYSTEM_RAM;
break;
case SSNES_STATE_APURAM:
memtype = SNES_MEMORY_APURAM;
break;
case SSNES_STATE_VRAM:
memtype = SNES_MEMORY_VRAM;
break;
case SSNES_STATE_OAM:
memtype = SNES_MEMORY_OAM;
break;
case SSNES_STATE_CGRAM:
memtype = SNES_MEMORY_CGRAM;
break; break;
default: default:
memtype = -1u; memtype = -1u;
} }
if ((memtype != -1u) && (addr >= psnes_get_memory_size(memtype))) if ((memtype != -1u) && (addr >= pretro_get_memory_size(memtype)))
{ {
SSNES_ERR("Address out of bounds.\n"); SSNES_ERR("Address out of bounds.\n");
ret = false; ret = false;
@ -725,11 +697,7 @@ static bool load_imports(const char *dir_path, config_file_t *conf)
id = strtok(NULL, ";"); id = strtok(NULL, ";");
} }
tracker_info.wram = psnes_get_memory_data(SNES_MEMORY_WRAM); tracker_info.wram = pretro_get_memory_data(RETRO_MEMORY_SYSTEM_RAM);
tracker_info.vram = psnes_get_memory_data(SNES_MEMORY_VRAM);
tracker_info.cgram = psnes_get_memory_data(SNES_MEMORY_CGRAM);
tracker_info.oam = psnes_get_memory_data(SNES_MEMORY_OAM);
tracker_info.apuram = psnes_get_memory_data(SNES_MEMORY_APURAM);
tracker_info.info = info; tracker_info.info = info;
tracker_info.info_elem = info_cnt; tracker_info.info_elem = info_cnt;
@ -747,9 +715,9 @@ static bool load_imports(const char *dir_path, config_file_t *conf)
tracker_info.script_is_file = true; tracker_info.script_is_file = true;
#endif #endif
snes_tracker = snes_tracker_init(&tracker_info); state_tracker = state_tracker_init(&tracker_info);
if (!snes_tracker) if (!state_tracker)
SSNES_WARN("Failed to init SNES tracker.\n"); SSNES_WARN("Failed to init state tracker.\n");
#ifdef HAVE_PYTHON #ifdef HAVE_PYTHON
if (script) if (script)
@ -834,8 +802,10 @@ static bool load_shader_params(unsigned i, config_file_t *conf)
scale->type_y = SSNES_SCALE_INPUT; scale->type_y = SSNES_SCALE_INPUT;
scale->scale_x = 1.0; scale->scale_x = 1.0;
scale->scale_y = 1.0; scale->scale_y = 1.0;
scale->abs_x = g_extern.system.geom.base_width;
scale->abs_y = g_extern.system.geom.base_height; const struct retro_game_geometry *geom = &g_extern.system.av_info.geometry;
scale->abs_x = geom->base_width;
scale->abs_y = geom->base_height;
if (strcmp(scale_type_x, "source") == 0) if (strcmp(scale_type_x, "source") == 0)
scale->type_x = SSNES_SCALE_INPUT; scale->type_x = SSNES_SCALE_INPUT;

View File

@ -21,7 +21,7 @@
#include "shader_glsl.h" #include "shader_glsl.h"
#include "../compat/strl.h" #include "../compat/strl.h"
#include "../compat/posix_string.h" #include "../compat/posix_string.h"
#include "snes_state.h" #include "state_tracker.h"
#include "../dynamic.h" #include "../dynamic.h"
#ifdef __APPLE__ #ifdef __APPLE__
@ -120,8 +120,8 @@ static GLuint gl_teximage[MAX_TEXTURES];
static unsigned gl_teximage_cnt = 0; static unsigned gl_teximage_cnt = 0;
static char gl_teximage_uniforms[MAX_TEXTURES][64]; static char gl_teximage_uniforms[MAX_TEXTURES][64];
static snes_tracker_t *gl_snes_tracker = NULL; static state_tracker_t *gl_state_tracker = NULL;
static struct snes_tracker_uniform_info gl_tracker_info[MAX_VARIABLES]; static struct state_tracker_uniform_info gl_tracker_info[MAX_VARIABLES];
static unsigned gl_tracker_info_cnt = 0; static unsigned gl_tracker_info_cnt = 0;
static char gl_tracker_script[PATH_MAX]; static char gl_tracker_script[PATH_MAX];
static char gl_tracker_script_class[64]; static char gl_tracker_script_class[64];
@ -475,16 +475,12 @@ static bool get_import_value(xmlNodePtr ptr)
xmlChar *semantic = xmlGetProp(ptr, (const xmlChar*)"semantic"); xmlChar *semantic = xmlGetProp(ptr, (const xmlChar*)"semantic");
xmlChar *wram = xmlGetProp(ptr, (const xmlChar*)"wram"); xmlChar *wram = xmlGetProp(ptr, (const xmlChar*)"wram");
xmlChar *input = xmlGetProp(ptr, (const xmlChar*)"input_slot"); xmlChar *input = xmlGetProp(ptr, (const xmlChar*)"input_slot");
xmlChar *apuram = xmlGetProp(ptr, (const xmlChar*)"apuram");
xmlChar *vram = xmlGetProp(ptr, (const xmlChar*)"vram");
xmlChar *oam = xmlGetProp(ptr, (const xmlChar*)"oam");
xmlChar *cgram = xmlGetProp(ptr, (const xmlChar*)"cgram");
xmlChar *bitmask = xmlGetProp(ptr, (const xmlChar*)"mask"); xmlChar *bitmask = xmlGetProp(ptr, (const xmlChar*)"mask");
xmlChar *bitequal = xmlGetProp(ptr, (const xmlChar*)"equal"); xmlChar *bitequal = xmlGetProp(ptr, (const xmlChar*)"equal");
unsigned memtype; unsigned memtype;
enum snes_tracker_type tracker_type; enum state_tracker_type tracker_type;
enum snes_ram_type ram_type = SSNES_STATE_NONE; enum state_ram_type ram_type = SSNES_STATE_NONE;
uint32_t addr = 0; uint32_t addr = 0;
unsigned mask_value = 0; unsigned mask_value = 0;
unsigned mask_equal = 0; unsigned mask_equal = 0;
@ -496,7 +492,6 @@ static bool get_import_value(xmlNodePtr ptr)
goto end; goto end;
} }
if (strcmp((const char*)semantic, "capture") == 0) if (strcmp((const char*)semantic, "capture") == 0)
tracker_type = SSNES_STATE_CAPTURE; tracker_type = SSNES_STATE_CAPTURE;
else if (strcmp((const char*)semantic, "capture_previous") == 0) else if (strcmp((const char*)semantic, "capture_previous") == 0)
@ -540,11 +535,11 @@ static bool get_import_value(xmlNodePtr ptr)
goto end; goto end;
} }
} }
else if (wram) { addr = strtoul((const char*)wram, NULL, 16); ram_type = SSNES_STATE_WRAM; } else if (wram)
else if (apuram) { addr = strtoul((const char*)apuram, NULL, 16); ram_type = SSNES_STATE_APURAM; } {
else if (vram) { addr = strtoul((const char*)vram, NULL, 16); ram_type = SSNES_STATE_VRAM; } addr = strtoul((const char*)wram, NULL, 16);
else if (oam) { addr = strtoul((const char*)oam, NULL, 16); ram_type = SSNES_STATE_OAM; } ram_type = SSNES_STATE_WRAM;
else if (cgram) { addr = strtoul((const char*)cgram, NULL, 16); ram_type = SSNES_STATE_CGRAM; } }
else else
{ {
SSNES_ERR("No RAM address specificed for import value.\n"); SSNES_ERR("No RAM address specificed for import value.\n");
@ -556,26 +551,14 @@ static bool get_import_value(xmlNodePtr ptr)
switch (ram_type) switch (ram_type)
{ {
case SSNES_STATE_WRAM: case SSNES_STATE_WRAM:
memtype = SNES_MEMORY_WRAM; memtype = RETRO_MEMORY_SYSTEM_RAM;
break;
case SSNES_STATE_APURAM:
memtype = SNES_MEMORY_APURAM;
break;
case SSNES_STATE_VRAM:
memtype = SNES_MEMORY_VRAM;
break;
case SSNES_STATE_OAM:
memtype = SNES_MEMORY_OAM;
break;
case SSNES_STATE_CGRAM:
memtype = SNES_MEMORY_CGRAM;
break; break;
default: default:
memtype = -1u; memtype = -1u;
} }
if ((memtype != -1u) && (addr >= psnes_get_memory_size(memtype))) if ((memtype != -1u) && (addr >= pretro_get_memory_size(memtype)))
{ {
SSNES_ERR("Address out of bounds.\n"); SSNES_ERR("Address out of bounds.\n");
ret = false; ret = false;
@ -600,10 +583,6 @@ end:
if (semantic) xmlFree(semantic); if (semantic) xmlFree(semantic);
if (wram) xmlFree(wram); if (wram) xmlFree(wram);
if (input) xmlFree(input); if (input) xmlFree(input);
if (apuram) xmlFree(apuram);
if (vram) xmlFree(vram);
if (oam) xmlFree(oam);
if (cgram) xmlFree(cgram);
if (bitmask) xmlFree(bitmask); if (bitmask) xmlFree(bitmask);
if (bitequal) xmlFree(bitequal); if (bitequal) xmlFree(bitequal);
return ret; return ret;
@ -981,12 +960,8 @@ bool gl_glsl_init(const char *path)
if (gl_tracker_info_cnt > 0) if (gl_tracker_info_cnt > 0)
{ {
struct snes_tracker_info info = {0}; struct state_tracker_info info = {0};
info.wram = psnes_get_memory_data(SNES_MEMORY_WRAM); info.wram = pretro_get_memory_data(RETRO_MEMORY_SYSTEM_RAM);
info.vram = psnes_get_memory_data(SNES_MEMORY_VRAM);
info.cgram = psnes_get_memory_data(SNES_MEMORY_CGRAM);
info.apuram = psnes_get_memory_data(SNES_MEMORY_APURAM);
info.oam = psnes_get_memory_data(SNES_MEMORY_OAM);
info.info = gl_tracker_info; info.info = gl_tracker_info;
info.info_elem = gl_tracker_info_cnt; info.info_elem = gl_tracker_info_cnt;
@ -1002,9 +977,9 @@ bool gl_glsl_init(const char *path)
info.script_is_file = *gl_tracker_script; info.script_is_file = *gl_tracker_script;
#endif #endif
gl_snes_tracker = snes_tracker_init(&info); gl_state_tracker = state_tracker_init(&info);
if (!gl_snes_tracker) if (!gl_state_tracker)
SSNES_WARN("Failed to init SNES tracker.\n"); SSNES_WARN("Failed to init state tracker.\n");
} }
glsl_enable = true; glsl_enable = true;
@ -1057,10 +1032,10 @@ void gl_glsl_deinit(void)
xmlFree(gl_script_program); xmlFree(gl_script_program);
gl_script_program = NULL; gl_script_program = NULL;
} }
if (gl_snes_tracker) if (gl_state_tracker)
{ {
snes_tracker_free(gl_snes_tracker); state_tracker_free(gl_state_tracker);
gl_snes_tracker = NULL; gl_state_tracker = NULL;
} }
gl_glsl_reset_attrib(); gl_glsl_reset_attrib();
@ -1235,13 +1210,13 @@ void gl_glsl_set_params(unsigned width, unsigned height,
pglActiveTexture(GL_TEXTURE0); pglActiveTexture(GL_TEXTURE0);
if (gl_snes_tracker) if (gl_state_tracker)
{ {
static struct snes_tracker_uniform info[MAX_VARIABLES]; static struct state_tracker_uniform info[MAX_VARIABLES];
static unsigned cnt = 0; static unsigned cnt = 0;
if (active_index == 1) if (active_index == 1)
cnt = snes_get_uniform(gl_snes_tracker, info, MAX_VARIABLES, frame_count); cnt = state_get_uniform(gl_state_tracker, info, MAX_VARIABLES, frame_count);
for (unsigned i = 0; i < cnt; i++) for (unsigned i = 0; i < cnt; i++)
{ {

View File

@ -15,17 +15,17 @@
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "snes_state.h" #include "state_tracker.h"
#include <stdlib.h> #include <stdlib.h>
#include "../compat/strl.h" #include "../compat/strl.h"
#include "../general.h" #include "../general.h"
#include "../libsnes.hpp" #include "../libretro.h"
#ifdef HAVE_PYTHON #ifdef HAVE_PYTHON
#include "py_state/py_state.h" #include "py_state/py_state.h"
#endif #endif
struct snes_tracker_internal struct state_tracker_internal
{ {
char id[64]; char id[64];
@ -41,7 +41,7 @@ struct snes_tracker_internal
uint16_t equal; uint16_t equal;
enum snes_tracker_type type; enum state_tracker_type type;
uint32_t prev[2]; uint32_t prev[2];
int frame_count; int frame_count;
@ -50,9 +50,9 @@ struct snes_tracker_internal
int transition_count; int transition_count;
}; };
struct snes_tracker struct state_tracker
{ {
struct snes_tracker_internal *info; struct state_tracker_internal *info;
unsigned info_elem; unsigned info_elem;
uint16_t input_state[2]; uint16_t input_state[2];
@ -62,9 +62,9 @@ struct snes_tracker
#endif #endif
}; };
snes_tracker_t* snes_tracker_init(const struct snes_tracker_info *info) state_tracker_t* state_tracker_init(const struct state_tracker_info *info)
{ {
snes_tracker_t *tracker = (snes_tracker_t*)calloc(1, sizeof(*tracker)); state_tracker_t *tracker = (state_tracker_t*)calloc(1, sizeof(*tracker));
if (!tracker) if (!tracker)
return NULL; return NULL;
@ -81,7 +81,7 @@ snes_tracker_t* snes_tracker_init(const struct snes_tracker_info *info)
} }
#endif #endif
tracker->info = (struct snes_tracker_internal*)calloc(info->info_elem, sizeof(struct snes_tracker_internal)); tracker->info = (struct state_tracker_internal*)calloc(info->info_elem, sizeof(struct state_tracker_internal));
tracker->info_elem = info->info_elem; tracker->info_elem = info->info_elem;
for (unsigned i = 0; i < info->info_elem; i++) for (unsigned i = 0; i < info->info_elem; i++)
@ -105,18 +105,6 @@ snes_tracker_t* snes_tracker_init(const struct snes_tracker_info *info)
case SSNES_STATE_WRAM: case SSNES_STATE_WRAM:
tracker->info[i].ptr = info->wram ? info->wram : &empty; tracker->info[i].ptr = info->wram ? info->wram : &empty;
break; break;
case SSNES_STATE_APURAM:
tracker->info[i].ptr = info->apuram ? info->apuram : &empty;
break;
case SSNES_STATE_OAM:
tracker->info[i].ptr = info->oam ? info->oam : &empty;
break;
case SSNES_STATE_CGRAM:
tracker->info[i].ptr = info->cgram ? info->cgram : &empty;
break;
case SSNES_STATE_VRAM:
tracker->info[i].ptr = info->vram ? info->vram : &empty;
break;
case SSNES_STATE_INPUT_SLOT1: case SSNES_STATE_INPUT_SLOT1:
tracker->info[i].input_ptr = &tracker->input_state[0]; tracker->info[i].input_ptr = &tracker->input_state[0];
tracker->info[i].is_input = true; tracker->info[i].is_input = true;
@ -134,7 +122,7 @@ snes_tracker_t* snes_tracker_init(const struct snes_tracker_info *info)
return tracker; return tracker;
} }
void snes_tracker_free(snes_tracker_t *tracker) void state_tracker_free(state_tracker_t *tracker)
{ {
free(tracker->info); free(tracker->info);
#ifdef HAVE_PYTHON #ifdef HAVE_PYTHON
@ -143,7 +131,7 @@ void snes_tracker_free(snes_tracker_t *tracker)
free(tracker); free(tracker);
} }
static inline uint16_t fetch(const struct snes_tracker_internal *info) static inline uint16_t fetch(const struct state_tracker_internal *info)
{ {
uint16_t val = 0; uint16_t val = 0;
if (info->is_input) if (info->is_input)
@ -160,8 +148,8 @@ static inline uint16_t fetch(const struct snes_tracker_internal *info)
} }
static void update_element( static void update_element(
struct snes_tracker_uniform *uniform, struct state_tracker_uniform *uniform,
struct snes_tracker_internal *info, struct state_tracker_internal *info,
unsigned frame_count) unsigned frame_count)
{ {
uniform->id = info->id; uniform->id = info->id;
@ -221,24 +209,24 @@ static void update_element(
} }
// Updates 16-bit input in same format as SNES itself. // Updates 16-bit input in same format as SNES itself.
static void update_input(snes_tracker_t *tracker) static void update_input(state_tracker_t *tracker)
{ {
if (driver.input == NULL) if (driver.input == NULL)
return; return;
static const unsigned buttons[] = { static const unsigned buttons[] = {
SNES_DEVICE_ID_JOYPAD_R, RETRO_DEVICE_ID_JOYPAD_R,
SNES_DEVICE_ID_JOYPAD_L, RETRO_DEVICE_ID_JOYPAD_L,
SNES_DEVICE_ID_JOYPAD_X, RETRO_DEVICE_ID_JOYPAD_X,
SNES_DEVICE_ID_JOYPAD_A, RETRO_DEVICE_ID_JOYPAD_A,
SNES_DEVICE_ID_JOYPAD_RIGHT, RETRO_DEVICE_ID_JOYPAD_RIGHT,
SNES_DEVICE_ID_JOYPAD_LEFT, RETRO_DEVICE_ID_JOYPAD_LEFT,
SNES_DEVICE_ID_JOYPAD_DOWN, RETRO_DEVICE_ID_JOYPAD_DOWN,
SNES_DEVICE_ID_JOYPAD_UP, RETRO_DEVICE_ID_JOYPAD_UP,
SNES_DEVICE_ID_JOYPAD_START, RETRO_DEVICE_ID_JOYPAD_START,
SNES_DEVICE_ID_JOYPAD_SELECT, RETRO_DEVICE_ID_JOYPAD_SELECT,
SNES_DEVICE_ID_JOYPAD_Y, RETRO_DEVICE_ID_JOYPAD_Y,
SNES_DEVICE_ID_JOYPAD_B, RETRO_DEVICE_ID_JOYPAD_B,
}; };
// Only bind for up to two players for now. // Only bind for up to two players for now.
@ -250,15 +238,15 @@ static void update_input(snes_tracker_t *tracker)
uint16_t state[2] = {0}; uint16_t state[2] = {0};
for (unsigned i = 4; i < 16; i++) for (unsigned i = 4; i < 16; i++)
{ {
state[0] |= (input_input_state_func(binds, SNES_PORT_1, SNES_DEVICE_JOYPAD, 0, buttons[i - 4]) ? 1 : 0) << i; state[0] |= (input_input_state_func(binds, 0, RETRO_DEVICE_JOYPAD, 0, buttons[i - 4]) ? 1 : 0) << i;
state[1] |= (input_input_state_func(binds, SNES_PORT_2, SNES_DEVICE_JOYPAD, 0, buttons[i - 4]) ? 1 : 0) << i; state[1] |= (input_input_state_func(binds, 1, RETRO_DEVICE_JOYPAD, 0, buttons[i - 4]) ? 1 : 0) << i;
} }
for (unsigned i = 0; i < 2; i++) for (unsigned i = 0; i < 2; i++)
tracker->input_state[i] = state[i]; tracker->input_state[i] = state[i];
} }
unsigned snes_get_uniform(snes_tracker_t *tracker, struct snes_tracker_uniform *uniforms, unsigned elem, unsigned frame_count) unsigned state_get_uniform(state_tracker_t *tracker, struct state_tracker_uniform *uniforms, unsigned elem, unsigned frame_count)
{ {
unsigned elems = tracker->info_elem < elem ? tracker->info_elem : elem; unsigned elems = tracker->info_elem < elem ? tracker->info_elem : elem;

View File

@ -15,8 +15,8 @@
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef __SSNES_SNES_STATE_H #ifndef __SSNES_SNES_TRACKER_H
#define __SSNES_SNES_STATE_H #define __SSNES_SNES_TRACKER_H
#include <stdint.h> #include <stdint.h>
#include "../boolean.h" #include "../boolean.h"
@ -25,7 +25,7 @@
#include "config.h" #include "config.h"
#endif #endif
enum snes_tracker_type enum state_tracker_type
{ {
#ifdef HAVE_PYTHON #ifdef HAVE_PYTHON
SSNES_STATE_PYTHON, SSNES_STATE_PYTHON,
@ -37,37 +37,29 @@ enum snes_tracker_type
SSNES_STATE_TRANSITION_PREV SSNES_STATE_TRANSITION_PREV
}; };
enum snes_ram_type enum state_ram_type
{ {
SSNES_STATE_NONE, SSNES_STATE_NONE,
SSNES_STATE_WRAM, SSNES_STATE_WRAM,
SSNES_STATE_APURAM,
SSNES_STATE_OAM,
SSNES_STATE_CGRAM,
SSNES_STATE_VRAM,
SSNES_STATE_INPUT_SLOT1, SSNES_STATE_INPUT_SLOT1,
SSNES_STATE_INPUT_SLOT2 SSNES_STATE_INPUT_SLOT2
}; };
struct snes_tracker_uniform_info struct state_tracker_uniform_info
{ {
char id[64]; char id[64];
uint32_t addr; uint32_t addr;
enum snes_tracker_type type; enum state_tracker_type type;
enum snes_ram_type ram_type; enum state_ram_type ram_type;
uint16_t mask; uint16_t mask;
uint16_t equal; uint16_t equal;
}; };
struct snes_tracker_info struct state_tracker_info
{ {
const uint8_t *wram; const uint8_t *wram;
const uint8_t *vram;
const uint8_t *cgram;
const uint8_t *oam;
const uint8_t *apuram;
const struct snes_tracker_uniform_info *info; const struct state_tracker_uniform_info *info;
unsigned info_elem; unsigned info_elem;
#ifdef HAVE_PYTHON #ifdef HAVE_PYTHON
@ -77,17 +69,17 @@ struct snes_tracker_info
#endif #endif
}; };
struct snes_tracker_uniform struct state_tracker_uniform
{ {
const char *id; const char *id;
float value; float value;
}; };
typedef struct snes_tracker snes_tracker_t; typedef struct state_tracker state_tracker_t;
snes_tracker_t* snes_tracker_init(const struct snes_tracker_info *info); state_tracker_t* state_tracker_init(const struct state_tracker_info *info);
void snes_tracker_free(snes_tracker_t *tracker); void state_tracker_free(state_tracker_t *tracker);
unsigned snes_get_uniform(snes_tracker_t *tracker, struct snes_tracker_uniform *uniforms, unsigned elem, unsigned frame_count); unsigned state_get_uniform(state_tracker_t *tracker, struct state_tracker_uniform *uniforms, unsigned elem, unsigned frame_count);
#endif #endif

View File

@ -444,8 +444,8 @@ bool config_load_file(const char *path)
CONFIG_GET_STRING(audio.dsp_plugin, "audio_dsp_plugin"); CONFIG_GET_STRING(audio.dsp_plugin, "audio_dsp_plugin");
CONFIG_GET_STRING(input.driver, "input_driver"); CONFIG_GET_STRING(input.driver, "input_driver");
if (!*g_settings.libsnes) if (!*g_settings.libretro)
CONFIG_GET_STRING(libsnes, "libsnes_path"); CONFIG_GET_STRING(libretro, "libretro_path");
CONFIG_GET_STRING(screenshot_directory, "screenshot_directory"); CONFIG_GET_STRING(screenshot_directory, "screenshot_directory");
if (*g_settings.screenshot_directory && !path_is_directory(g_settings.screenshot_directory)) if (*g_settings.screenshot_directory && !path_is_directory(g_settings.screenshot_directory))

View File

@ -846,7 +846,7 @@ static void parse_input(int argc, char *argv[])
#ifdef HAVE_DYNAMIC #ifdef HAVE_DYNAMIC
case 'L': case 'L':
strlcpy(g_settings.libsnes, optarg, sizeof(g_settings.libsnes)); strlcpy(g_settings.libretro, optarg, sizeof(g_settings.libretro));
break; break;
#endif #endif
@ -2244,7 +2244,7 @@ void ssnes_main_clear_state(void)
static void init_system_info(void) static void init_system_info(void)
{ {
struct retro_system_info *info = &g_extern.system.info; struct retro_system_info *info = &g_extern.system.info;
retro_get_system_info(info); pretro_get_system_info(info);
if (!info->library_name) if (!info->library_name)
info->library_name = "Unknown"; info->library_name = "Unknown";
@ -2257,7 +2257,7 @@ static void init_system_info(void)
static void init_system_av_info(void) static void init_system_av_info(void)
{ {
retro_get_system_av_info(&g_extern.system.av_info); pretro_get_system_av_info(&g_extern.system.av_info);
} }
static void verify_api_version(void) static void verify_api_version(void)