Merged console_ext.c / main_wrap.c and got rid of warning in file.c

This commit is contained in:
Twinaphex 2012-03-17 23:05:48 +01:00
parent 8ab536a968
commit 4e3359ec19
6 changed files with 55 additions and 85 deletions

View File

@ -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 \

View File

@ -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 <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <ctype.h>
#include "../boolean.h"
#include "../compat/strl.h"
#include "../libsnes.hpp"
#include "../general.h"
#include <string.h>
#include <ctype.h>
#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;
}

View File

@ -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 <stddef.h>
void ssnes_console_set_rom_ext(const char *ext);
// Get rom extensions for current library.

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#include "main_wrap.h"
#include "../general.h"
#include "../compat/strl.h"
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#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;
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef MAIN_WRAP_H__
#define MAIN_WRAP_H__
#ifndef __cplusplus
#include <stdbool.h>
#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

3
file.c
View File

@ -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);