mirror of
https://github.com/libretro/RetroArch
synced 2025-04-16 08:43:10 +00:00
(RARCH_CONSOLE) Split up main_wrap code into its own file
This commit is contained in:
parent
739fd99a21
commit
c77b49b19a
@ -25,6 +25,10 @@ CONSOLE EXTENSIONS
|
|||||||
|
|
||||||
#include "../rarch_console_video.c"
|
#include "../rarch_console_video.c"
|
||||||
|
|
||||||
|
#ifdef HAVE_RARCH_MAIN_WRAP
|
||||||
|
#include "../rarch_console_main_wrap.c"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "../rarch_console.c"
|
#include "../rarch_console.c"
|
||||||
|
|
||||||
#ifdef HAVE_CONFIGFILE
|
#ifdef HAVE_CONFIGFILE
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stddef.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "../boolean.h"
|
#include "../boolean.h"
|
||||||
#include "../compat/strl.h"
|
#include "../compat/strl.h"
|
||||||
@ -27,107 +26,8 @@
|
|||||||
|
|
||||||
#include "rarch_console.h"
|
#include "rarch_console.h"
|
||||||
|
|
||||||
#define MAX_ARGS 32
|
|
||||||
|
|
||||||
default_paths_t default_paths;
|
default_paths_t default_paths;
|
||||||
|
|
||||||
/*============================================================
|
|
||||||
RetroArch MAIN WRAP
|
|
||||||
============================================================ */
|
|
||||||
|
|
||||||
#ifdef HAVE_RARCH_MAIN_WRAP
|
|
||||||
|
|
||||||
static int rarch_main_init_wrap(const struct rarch_main_wrap *args)
|
|
||||||
{
|
|
||||||
int argc = 0;
|
|
||||||
char *argv[MAX_ARGS] = {NULL};
|
|
||||||
|
|
||||||
argv[argc++] = strdup("retroarch");
|
|
||||||
|
|
||||||
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");
|
|
||||||
|
|
||||||
#ifdef HAVE_FILE_LOGGER
|
|
||||||
RARCH_LOG("foo\n");
|
|
||||||
for(int i = 0; i < argc; i++)
|
|
||||||
RARCH_LOG("arg #%d: %s\n", i, argv[i]);
|
|
||||||
RARCH_LOG("bar\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int ret = rarch_main_init(argc, argv);
|
|
||||||
|
|
||||||
char **tmp = argv;
|
|
||||||
while (*tmp)
|
|
||||||
{
|
|
||||||
free(*tmp);
|
|
||||||
tmp++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool rarch_startup (const char * config_path)
|
|
||||||
{
|
|
||||||
bool retval = false;
|
|
||||||
|
|
||||||
if(g_console.initialize_rarch_enable)
|
|
||||||
{
|
|
||||||
if(g_console.emulator_initialized)
|
|
||||||
rarch_main_deinit();
|
|
||||||
|
|
||||||
struct rarch_main_wrap args = {0};
|
|
||||||
|
|
||||||
args.verbose = g_extern.verbose;
|
|
||||||
args.config_path = config_path;
|
|
||||||
args.sram_path = g_console.default_sram_dir_enable ? g_console.default_sram_dir : NULL,
|
|
||||||
args.state_path = g_console.default_savestate_dir_enable ? g_console.default_savestate_dir : NULL,
|
|
||||||
args.rom_path = g_console.rom_path;
|
|
||||||
|
|
||||||
int init_ret = rarch_main_init_wrap(&args);
|
|
||||||
(void)init_ret;
|
|
||||||
|
|
||||||
if(init_ret == 0)
|
|
||||||
{
|
|
||||||
g_console.emulator_initialized = 1;
|
|
||||||
g_console.initialize_rarch_enable = 0;
|
|
||||||
retval = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//failed to load the ROM for whatever reason
|
|
||||||
g_console.emulator_initialized = 0;
|
|
||||||
g_console.mode_switch = MODE_MENU;
|
|
||||||
rarch_settings_msg(S_MSG_ROM_LOADING_ERROR, S_DELAY_180);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_RARCH_EXEC
|
#ifdef HAVE_RARCH_EXEC
|
||||||
|
|
||||||
#ifdef __CELLOS_LV2__
|
#ifdef __CELLOS_LV2__
|
||||||
|
@ -92,20 +92,6 @@ enum {
|
|||||||
|
|
||||||
#define MENU_ITEM_LAST MENU_ITEM_RETURN_TO_DASHBOARD+1
|
#define MENU_ITEM_LAST MENU_ITEM_RETURN_TO_DASHBOARD+1
|
||||||
|
|
||||||
#ifdef HAVE_RARCH_MAIN_WRAP
|
|
||||||
|
|
||||||
struct rarch_main_wrap
|
|
||||||
{
|
|
||||||
const char *rom_path;
|
|
||||||
const char *sram_path;
|
|
||||||
const char *state_path;
|
|
||||||
const char *config_path;
|
|
||||||
bool verbose;
|
|
||||||
};
|
|
||||||
|
|
||||||
bool rarch_startup (const char * config_path);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_RARCH_EXEC
|
#ifdef HAVE_RARCH_EXEC
|
||||||
void rarch_exec (void);
|
void rarch_exec (void);
|
||||||
#endif
|
#endif
|
||||||
|
110
console/rarch_console_main_wrap.c
Normal file
110
console/rarch_console_main_wrap.c
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
/* RetroArch - A frontend for libretro.
|
||||||
|
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||||
|
* Copyright (C) 2011-2012 - Daniel De Matteis
|
||||||
|
*
|
||||||
|
* RetroArch 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.
|
||||||
|
*
|
||||||
|
* RetroArch 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 RetroArch.
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#include "rarch_console_main_wrap.h"
|
||||||
|
|
||||||
|
#define MAX_ARGS 32
|
||||||
|
|
||||||
|
static int rarch_main_init_wrap(const struct rarch_main_wrap *args)
|
||||||
|
{
|
||||||
|
int argc = 0;
|
||||||
|
char *argv[MAX_ARGS] = {NULL};
|
||||||
|
|
||||||
|
argv[argc++] = strdup("retroarch");
|
||||||
|
|
||||||
|
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");
|
||||||
|
|
||||||
|
#ifdef HAVE_FILE_LOGGER
|
||||||
|
RARCH_LOG("foo\n");
|
||||||
|
for(int i = 0; i < argc; i++)
|
||||||
|
RARCH_LOG("arg #%d: %s\n", i, argv[i]);
|
||||||
|
RARCH_LOG("bar\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int ret = rarch_main_init(argc, argv);
|
||||||
|
|
||||||
|
char **tmp = argv;
|
||||||
|
while (*tmp)
|
||||||
|
{
|
||||||
|
free(*tmp);
|
||||||
|
tmp++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool rarch_startup (const char * config_path)
|
||||||
|
{
|
||||||
|
bool retval = false;
|
||||||
|
|
||||||
|
if(g_console.initialize_rarch_enable)
|
||||||
|
{
|
||||||
|
if(g_console.emulator_initialized)
|
||||||
|
rarch_main_deinit();
|
||||||
|
|
||||||
|
struct rarch_main_wrap args = {0};
|
||||||
|
|
||||||
|
args.verbose = g_extern.verbose;
|
||||||
|
args.config_path = config_path;
|
||||||
|
args.sram_path = g_console.default_sram_dir_enable ? g_console.default_sram_dir : NULL,
|
||||||
|
args.state_path = g_console.default_savestate_dir_enable ? g_console.default_savestate_dir : NULL,
|
||||||
|
args.rom_path = g_console.rom_path;
|
||||||
|
|
||||||
|
int init_ret = rarch_main_init_wrap(&args);
|
||||||
|
(void)init_ret;
|
||||||
|
|
||||||
|
if(init_ret == 0)
|
||||||
|
{
|
||||||
|
g_console.emulator_initialized = 1;
|
||||||
|
g_console.initialize_rarch_enable = 0;
|
||||||
|
retval = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//failed to load the ROM for whatever reason
|
||||||
|
g_console.emulator_initialized = 0;
|
||||||
|
g_console.mode_switch = MODE_MENU;
|
||||||
|
rarch_settings_msg(S_MSG_ROM_LOADING_ERROR, S_DELAY_180);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
31
console/rarch_console_main_wrap.h
Normal file
31
console/rarch_console_main_wrap.h
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/* RetroArch - A frontend for libretro.
|
||||||
|
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||||
|
* Copyright (C) 2011-2012 - Daniel De Matteis
|
||||||
|
*
|
||||||
|
* RetroArch 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.
|
||||||
|
*
|
||||||
|
* RetroArch 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 RetroArch.
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef RARCH_CONSOLE_MAIN_WRAP_H__
|
||||||
|
#define RARCH_CONSOLE_MAIN_WRAP_H__
|
||||||
|
|
||||||
|
struct rarch_main_wrap
|
||||||
|
{
|
||||||
|
const char *rom_path;
|
||||||
|
const char *sram_path;
|
||||||
|
const char *state_path;
|
||||||
|
const char *config_path;
|
||||||
|
bool verbose;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool rarch_startup (const char * config_path);
|
||||||
|
|
||||||
|
#endif
|
@ -49,6 +49,7 @@
|
|||||||
#include "../../console/rarch_console_input.h"
|
#include "../../console/rarch_console_input.h"
|
||||||
#include "../../console/rarch_console_config.h"
|
#include "../../console/rarch_console_config.h"
|
||||||
#include "../../console/rarch_console_settings.h"
|
#include "../../console/rarch_console_settings.h"
|
||||||
|
#include "../../console/rarch_console_main_wrap.h"
|
||||||
#include "../../console/rarch_console_video.h"
|
#include "../../console/rarch_console_video.h"
|
||||||
#include "../../conf/config_file.h"
|
#include "../../conf/config_file.h"
|
||||||
#include "../../conf/config_file_macros.h"
|
#include "../../conf/config_file_macros.h"
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "../../libretro.h"
|
#include "../../libretro.h"
|
||||||
|
|
||||||
#include "../../console/rarch_console_input.h"
|
#include "../../console/rarch_console_input.h"
|
||||||
|
#include "../../console/rarch_console_main_wrap.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
|
|
||||||
#include "../../console/rarch_console.h"
|
#include "../../console/rarch_console.h"
|
||||||
#include "../../console/rarch_console_config.h"
|
#include "../../console/rarch_console_config.h"
|
||||||
|
#include "../../console/rarch_console_main_wrap.h"
|
||||||
#include "../../conf/config_file.h"
|
#include "../../conf/config_file.h"
|
||||||
#include "../../conf/config_file_macros.h"
|
#include "../../conf/config_file_macros.h"
|
||||||
#include "../../file.h"
|
#include "../../file.h"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user