diff --git a/Makefile.ps3 b/Makefile.ps3 index c3d7161e6d..157633edfb 100644 --- a/Makefile.ps3 +++ b/Makefile.ps3 @@ -40,7 +40,6 @@ PPU_SRCS = fifo_buffer.c \ ps3/cellframework2/fileio/file_browser.c \ ps3/ps3_audio.c \ ps3/menu.c \ - console/main_wrap.c \ console/console_ext.c \ console/librsound/librsound.c \ console/szlib/szlib.c \ diff --git a/console/console_ext.c b/console/console_ext.c index a58d387b0c..4db5566909 100644 --- a/console/console_ext.c +++ b/console/console_ext.c @@ -1,5 +1,6 @@ /* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes. * Copyright (C) 2010-2012 - Hans-Kristian Arntzen + * Copyright (C) 2011-2012 - Daniel De Matteis * * Some code herein may be based on code found in BSNES. * @@ -16,13 +17,16 @@ */ #include +#include +#include #include +#include #include "../boolean.h" #include "../compat/strl.h" #include "../libsnes.hpp" #include "../general.h" -#include -#include +#include "../compat/strl.h" +#include "main_wrap.h" #ifdef HAVE_ZLIB #include "szlib/zlib.h" @@ -33,6 +37,8 @@ #include "../compat/posix_string.h" #endif +#define MAX_ARGS 32 + static char g_rom_ext[1024]; void ssnes_console_set_rom_ext(const char *ext) @@ -191,3 +197,46 @@ int ssnes_extract_zipfile(const char *zip_path) } #endif + +int ssnes_main_init_wrap(const struct ssnes_main_wrap *args) +{ + int argc = 0; + char *argv[MAX_ARGS] = {NULL}; + + argv[argc++] = strdup("ssnes"); + + if (args->rom_path) + argv[argc++] = strdup(args->rom_path); + + if (args->sram_path) + { + argv[argc++] = strdup("-s"); + argv[argc++] = strdup(args->sram_path); + } + + if (args->state_path) + { + argv[argc++] = strdup("-S"); + argv[argc++] = strdup(args->state_path); + } + + if (args->config_path) + { + argv[argc++] = strdup("-c"); + argv[argc++] = strdup(args->config_path); + } + + if (args->verbose) + argv[argc++] = strdup("-v"); + + int ret = ssnes_main_init(argc, argv); + + char **tmp = argv; + while (*tmp) + { + free(*tmp); + tmp++; + } + + return ret; +} diff --git a/console/console_ext.h b/console/console_ext.h index a9fcedb1d4..9f7006b604 100644 --- a/console/console_ext.h +++ b/console/console_ext.h @@ -1,5 +1,6 @@ /* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes. * Copyright (C) 2010-2012 - Hans-Kristian Arntzen + * Copyright (C) 2011-2012 - Daniel De Matteis * * Some code herein may be based on code found in BSNES. * @@ -18,8 +19,6 @@ #ifndef ROM_EXT_H__ #define ROM_EXT_H__ -#include - void ssnes_console_set_rom_ext(const char *ext); // Get rom extensions for current library. diff --git a/console/main_wrap.c b/console/main_wrap.c deleted file mode 100644 index cc1dba09dc..0000000000 --- a/console/main_wrap.c +++ /dev/null @@ -1,69 +0,0 @@ -/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes. - * Copyright (C) 2010-2012 - Hans-Kristian Arntzen - * - * Some code herein may be based on code found in BSNES. - * - * SSNES is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * SSNES is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with SSNES. - * If not, see . - */ - -#include "main_wrap.h" -#include "../general.h" -#include "../compat/strl.h" -#include -#include -#include - -#define MAX_ARGS 32 - -int ssnes_main_init_wrap(const struct ssnes_main_wrap *args) -{ - int argc = 0; - char *argv[MAX_ARGS] = {NULL}; - - argv[argc++] = strdup("ssnes"); - - if (args->rom_path) - argv[argc++] = strdup(args->rom_path); - - if (args->sram_path) - { - argv[argc++] = strdup("-s"); - argv[argc++] = strdup(args->sram_path); - } - - if (args->state_path) - { - argv[argc++] = strdup("-S"); - argv[argc++] = strdup(args->state_path); - } - - if (args->config_path) - { - argv[argc++] = strdup("-c"); - argv[argc++] = strdup(args->config_path); - } - - if (args->verbose) - argv[argc++] = strdup("-v"); - - int ret = ssnes_main_init(argc, argv); - - char **tmp = argv; - while (*tmp) - { - free(*tmp); - tmp++; - } - - return ret; -} - diff --git a/console/main_wrap.h b/console/main_wrap.h index eb411fa119..b13ee209b1 100644 --- a/console/main_wrap.h +++ b/console/main_wrap.h @@ -1,5 +1,6 @@ /* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes. * Copyright (C) 2010-2012 - Hans-Kristian Arntzen + * Copyright (C) 2011-2012 - Daniel De Matteis * * Some code herein may be based on code found in BSNES. * @@ -15,13 +16,6 @@ * If not, see . */ -#ifndef MAIN_WRAP_H__ -#define MAIN_WRAP_H__ - -#ifndef __cplusplus -#include -#endif - // Builds argc/argv and calls ssnes_main_init(). struct ssnes_main_wrap @@ -34,6 +28,3 @@ struct ssnes_main_wrap }; int ssnes_main_init_wrap(const struct ssnes_main_wrap *args); - -#endif - diff --git a/file.c b/file.c index bc687df2d9..095748a766 100644 --- a/file.c +++ b/file.c @@ -143,6 +143,7 @@ static void patch_rom(uint8_t **buf, ssize_t *size) const char *patch_desc = NULL; const char *patch_path = NULL; + patch_error_t err = PATCH_UNKNOWN; patch_func_t func = NULL; ssize_t patch_size = 0; @@ -183,7 +184,7 @@ static void patch_rom(uint8_t **buf, ssize_t *size) goto error; } - patch_error_t err = func((const uint8_t*)patch_data, patch_size, ret_buf, ret_size, patched_rom, &target_size); + err = func((const uint8_t*)patch_data, patch_size, ret_buf, ret_size, patched_rom, &target_size); if (err == PATCH_SUCCESS) { SSNES_LOG("ROM patched successfully (%s).\n", patch_desc);