Merge pull request #10625 from phcoder/dosalam

Support for dos salamander
This commit is contained in:
Autechre 2020-05-13 09:29:37 +02:00 committed by GitHub
commit 1545285953
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 98 additions and 9 deletions

View File

@ -129,6 +129,7 @@ elif [ $PLATFORM = "dos" ]; then
platform=dos
MAKEFILE_GRIFFIN=yes
EXT=a
SALAMANDER=yes
fi
# Cleanup Salamander core if it exists
@ -153,6 +154,10 @@ if [ $SALAMANDER = "yes" ]; then
if [ $PLATFORM = "psp1" ] ; then
mv -f ../EBOOT.PBP ../pkg/${platform}/EBOOT.PBP
fi
if [ $platform = "dos" ] ; then
mkdir -p ../pkg/${platform}
mv -f ../retrodos_salamander.exe ../pkg/${platform}/RETRODOS.EXE
fi
if [ $PLATFORM = "vita" ] ; then
mkdir -p ../pkg/${platform}/retroarch.vpk/vpk/sce_sys/livearea/contents
vita-make-fself -c -s ../retroarchvita_salamander.velf ../pkg/${platform}/retroarch.vpk/vpk/eboot.bin
@ -307,8 +312,8 @@ for f in `ls -v *_${platform}.${EXT}`; do
elif [ $PLATFORM = "wii" ] ; then
mv -f ../retroarch_${platform}.dol ../pkg/${platform}/${name}_libretro_${platform}.dol
elif [ $PLATFORM = "dos" ] ; then
mkdir -p ../pkg/${platform}
mv -f ../retrodos.exe ../pkg/${platform}/${name}_libretro_${platform}.exe
mkdir -p ../pkg/${platform}/cores
mv -f ../retrodos.exe ../pkg/${platform}/cores/${name}.exe
elif [ $PLATFORM = "emscripten" ] ; then
mkdir -p ../pkg/emscripten/
mv -f ../${name}_libretro.js ../pkg/emscripten/${name}_libretro.js

View File

@ -16,8 +16,14 @@
#include <stdint.h>
#include <stdio.h>
#include <process.h>
#include <string/stdstring.h>
#include <file/file_path.h>
#include "../frontend_driver.h"
#include "../../defaults.h"
static enum frontend_fork dos_fork_mode = FRONTEND_FORK_NONE;
static void frontend_dos_init(void *data)
{
@ -47,12 +53,18 @@ static void frontend_dos_get_env_settings(int *argc, char *argv[],
retro_main_log_file_init("retrodos.txt", false);
strlcpy(base_path, "retrodos", sizeof(base_path));
strlcpy(base_path, argv[0], sizeof(base_path));
char *slash = strrchr(base_path, '/');
if (slash)
*slash = '\0';
slash = strrchr(base_path, '/');
if (slash && strcasecmp(slash, "/cores"))
*slash = '\0';
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], base_path,
"cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE]));
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], base_path,
"cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO]));
"coreinfo", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO]));
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG], base_path,
"autoconf", sizeof(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG]));
@ -101,14 +113,80 @@ static void frontend_dos_get_env_settings(int *argc, char *argv[],
}
}
static void frontend_dos_exec(const char *path, bool should_load_game)
{
printf("Loading %s, %d\n", path, should_load_game);
char *newargv[] = { NULL, NULL };
size_t len = strlen(path);
newargv[0] = (char*)malloc(len);
strlcpy(newargv[0], path, len);
execv(path, newargv);
}
static void frontend_dos_exitspawn(char *s, size_t len, char *args)
{
bool should_load_content = false;
if (dos_fork_mode == FRONTEND_FORK_NONE)
return;
switch (dos_fork_mode)
{
case FRONTEND_FORK_CORE_WITH_ARGS:
should_load_content = true;
break;
case FRONTEND_FORK_NONE:
default:
break;
}
frontend_dos_exec(s, should_load_content);
}
static bool frontend_unix_set_fork(enum frontend_fork fork_mode)
{
switch (fork_mode)
{
case FRONTEND_FORK_CORE:
RARCH_LOG("FRONTEND_FORK_CORE\n");
unix_fork_mode = fork_mode;
break;
case FRONTEND_FORK_CORE_WITH_ARGS:
RARCH_LOG("FRONTEND_FORK_CORE_WITH_ARGS\n");
unix_fork_mode = fork_mode;
break;
case FRONTEND_FORK_RESTART:
RARCH_LOG("FRONTEND_FORK_RESTART\n");
unix_fork_mode = FRONTEND_FORK_CORE;
{
char executable_path[PATH_MAX_LENGTH] = {0};
fill_pathname_application_path(executable_path,
sizeof(executable_path));
path_set(RARCH_PATH_CORE, executable_path);
}
command_event(CMD_EVENT_QUIT, NULL);
break;
case FRONTEND_FORK_NONE:
default:
return false;
}
return true;
}
frontend_ctx_driver_t frontend_ctx_dos = {
frontend_dos_get_env_settings,/* environment_get */
frontend_dos_init, /* init */
NULL, /* deinit */
NULL, /* exitspawn */
frontend_dos_exitspawn, /* exitspawn */
NULL, /* process_args */
NULL, /* exec */
NULL, /* set_fork */
frontend_dos_exec, /* exec */
frontend_dos_set_fork, /* set_fork */
frontend_dos_shutdown, /* shutdown */
NULL, /* get_name */
NULL, /* get_os */

View File

@ -218,6 +218,9 @@ bool frontend_driver_get_core_extension(char *s, size_t len)
#elif defined(HAVE_LIBNX)
strlcpy(s, "nro", len);
return true;
#elif defined(DJGPP)
strlcpy(s, "exe", len);
return true;
#elif defined(_3DS)
if (envIsHomebrew())
strlcpy(s, "3dsx", len);
@ -264,6 +267,9 @@ bool frontend_driver_get_salamander_basename(char *s, size_t len)
#elif defined(_3DS)
strlcpy(s, "retroarch.core", len);
return true;
#elif defined(DJGPP)
strlcpy(s, "retrodos.exe", len);
return true;
#elif defined(SWITCH)
strlcpy(s, "retroarch_switch.nro", len);
return true;

View File

@ -240,14 +240,14 @@ retro_time_t cpu_features_get_time_usec(void)
return ticks_to_us(OSGetSystemTime());
#elif defined(SWITCH) || defined(HAVE_LIBNX)
return (svcGetSystemTick() * 10) / 192;
#elif defined(_POSIX_MONOTONIC_CLOCK) || defined(__QNX__) || defined(ANDROID) || defined(__MACH__)
#elif defined(_POSIX_MONOTONIC_CLOCK) || defined(__QNX__) || defined(ANDROID) || defined(__MACH__) || defined(DJGPP)
struct timespec tv = {0};
if (ra_clock_gettime(CLOCK_MONOTONIC, &tv) < 0)
return 0;
return tv.tv_sec * INT64_C(1000000) + (tv.tv_nsec + 500) / 1000;
#elif defined(EMSCRIPTEN)
return emscripten_get_now() * 1000;
#elif defined(PS2) || defined(DJGPP)
#elif defined(PS2)
return clock()*(1000000LL/CLOCKS_PER_SEC);
#elif defined(__mips__)
struct timeval tv;