Skip to content

Commit

Permalink
Builds clean.
Browse files Browse the repository at this point in the history
  • Loading branch information
Themaister committed Apr 9, 2012
1 parent 5d51942 commit e012e29
Show file tree
Hide file tree
Showing 14 changed files with 145 additions and 230 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ endif
endif

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)
OBJ += gfx/snes_state.o gfx/image.o
OBJ += gfx/state_tracker.o gfx/image.o
endif

ifeq ($(HAVE_DYLIB), 1)
Expand Down
2 changes: 1 addition & 1 deletion Makefile.win
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ ifeq ($(HAVE_RSOUND), 1)
endif

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
LIBS += -lxml2 -liconv
endif
Expand Down
6 changes: 3 additions & 3 deletions cheats.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
unsigned index = 0;
psnes_cheat_reset();
pretro_cheat_reset();
for (unsigned i = 0; i < handle->size; i++)
{
if (handle->cheats[i].state)
psnes_cheat_set(index++, true, handle->cheats[i].code);
pretro_cheat_set(index++, true, handle->cheats[i].code);
}
}

Expand Down Expand Up @@ -238,7 +238,7 @@ cheat_manager_t* cheat_manager_new(const char *path)
{
LIBXML_TEST_VERSION;

psnes_cheat_reset();
pretro_cheat_reset();

xmlParserCtxtPtr ctx = NULL;
xmlDocPtr doc = NULL;
Expand Down
23 changes: 12 additions & 11 deletions dynamic.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#define SYM(x) do { \
function_t func = dylib_proc(lib_handle, #x); \
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)

static dylib_t lib_handle = NULL;
Expand Down Expand Up @@ -94,11 +94,11 @@ static void set_environment_defaults(void);
static void load_symbols(void)
{
#ifdef HAVE_DYNAMIC
SSNES_LOG("Loading dynamic libsnes from: \"%s\"\n", g_settings.libsnes);
lib_handle = dylib_load(g_settings.libsnes);
SSNES_LOG("Loading dynamic libsnes from: \"%s\"\n", g_settings.libretro);
lib_handle = dylib_load(g_settings.libretro);
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()");
}
#endif
Expand Down Expand Up @@ -138,7 +138,7 @@ static void load_symbols(void)
SYM(retro_get_memory_size);
}

void init_libsnes_sym(void)
void init_libretro_sym(void)
{
// Guarantee that we can do "dirty" casting.
// Every OS that this program supports should pass this ...
Expand All @@ -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("This could happen if other modules SSNES depends on link against libsnes directly.\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)
strlcpy(g_settings.libsnes, "retro.dll", sizeof(g_settings.libsnes));
const char *libretro_path = "retro.dll";
#elif defined(__APPLE__)
strlcpy(g_settings.libsnes, "libretro.dylib", sizeof(g_settings.libsnes));
const char *libretro_path = "libretro.dylib";
#else
strlcpy(g_settings.libsnes, "libretro.so", sizeof(g_settings.libsnes));
const char *libretro_path = "libretro.so";
#endif
strlcpy(g_settings.libretro, libretro_path, sizeof(g_settings.libretro));
}
#endif

Expand All @@ -174,7 +175,7 @@ void init_libsnes_sym(void)
set_environment();
}

void uninit_libsnes_sym(void)
void uninit_libretro_sym(void)
{
#ifdef HAVE_DYNAMIC
if (lib_handle)
Expand Down
4 changes: 2 additions & 2 deletions file.c
Original file line number Diff line number Diff line change
Expand Up @@ -604,9 +604,9 @@ static bool load_roms(unsigned rom_type, const char **rom_paths, size_t roms)
}

if (rom_type == 0)
ret = retro_load_game(&info[0]);
ret = pretro_load_game(&info[0]);
else
ret = retro_load_game_special(rom_type, info, roms);
ret = pretro_load_game_special(rom_type, info, roms);

if (!ret)
SSNES_ERR("Failed to load game.\n");
Expand Down
2 changes: 1 addition & 1 deletion general.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ struct settings
bool netplay_client_swap_input;
} input;

char libsnes[PATH_MAX];
char libretro[PATH_MAX];
char cheat_database[PATH_MAX];
char cheat_settings_path[PATH_MAX];

Expand Down
6 changes: 3 additions & 3 deletions gfx/ext_gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

unsigned player = 0;
if (device == SNES_DEVICE_MULTITAP)
player = (port == SNES_PORT_1) ? 1 : index + 2;
if (device == RETRO_DEVICE_JOYPAD_MULTITAP)
player = (port == 1) ? 1 : index + 2;
else
player = (port == SNES_PORT_1) ? 1 : 2;
player = port + 1;

if (id < SSNES_BIND_LIST_END)
{
Expand Down
67 changes: 28 additions & 39 deletions gfx/py_state/py_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,45 +22,38 @@
#include <string.h>

#include "../../dynamic.h"
#include "../../libsnes.hpp"
#include "../../libretro.h"
#include "py_state.h"
#include "../../general.h"
#include "../../compat/strl.h"
#include "../../compat/posix_string.h"
#include "../../file.h"

#define PY_READ_FUNC_DECL(RAMTYPE) py_read_##RAMTYPE
#define PY_READ_FUNC(RAMTYPE) \
static PyObject* PY_READ_FUNC_DECL(RAMTYPE) (PyObject *self, PyObject *args) \
{ \
(void)self; \
\
const uint8_t *data = psnes_get_memory_data(SNES_MEMORY_##RAMTYPE); \
if (!data) \
{ \
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]); \
static PyObject* py_read_wram(PyObject *self, PyObject *args)
{
(void)self;

const uint8_t *data = (const uint8_t*)pretro_get_memory_data(RETRO_MEMORY_SYSTEM_RAM);
if (!data)
{
Py_INCREF(Py_None);
return Py_None;
}

PY_READ_FUNC(WRAM)
PY_READ_FUNC(VRAM)
PY_READ_FUNC(APURAM)
PY_READ_FUNC(CGRAM)
PY_READ_FUNC(OAM)
size_t max = pretro_get_memory_size(RETRO_MEMORY_SYSTEM_RAM);

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(data[addr]);
}

static PyObject *py_read_input(PyObject *self, PyObject *args)
{
Expand All @@ -86,7 +79,7 @@ static PyObject *py_read_input(PyObject *self, PyObject *args)
};

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,
key);

Expand All @@ -112,17 +105,13 @@ static PyObject *py_read_input_meta(PyObject *self, PyObject *args)
}

static PyMethodDef SNESMethods[] = {
{ "read_wram", PY_READ_FUNC_DECL(WRAM), METH_VARARGS, "Read WRAM from SNES." },
{ "read_vram", PY_READ_FUNC_DECL(VRAM), METH_VARARGS, "Read VRAM from SNES." },
{ "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." },
{ "read_wram", py_read_wram, METH_VARARGS, "Read WRAM from system." },
{ "input", py_read_input, METH_VARARGS, "Read input state from system." },
{ "input_meta", py_read_input_meta, METH_VARARGS, "Read SSNES specific input." },
{ 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))
static void py_set_attrs(PyObject *mod)
{
Expand Down
Loading

0 comments on commit e012e29

Please sign in to comment.