Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PS2 usability fixes #15861

Merged
merged 1 commit into from
Nov 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 54 additions & 3 deletions frontend/drivers/platform_ps2.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,46 @@ enum frontend_architecture frontend_ps2_get_arch(void)
return FRONTEND_ARCH_MIPS;
}

static uint64_t frontend_ps2_get_total_mem(void) { return 32*1024*1024; }

/* Crude try-and-fail approach, in lack of a better solution. */
static uint64_t frontend_ps2_get_free_mem(void)
{
uint64_t free_mem;
size_t s0 = 32*1024*1024;
void* p1;
void* p2;
void* p3;

while (s0 && (p1 = malloc(s0)) == NULL)
s0 >>= 1;

free_mem = s0;

s0 = 32*1024*1024;

while (s0 && (p2 = malloc(s0)) == NULL)
s0 >>= 1;

free_mem += s0;

s0 = 32*1024*1024;

while (s0 && (p3 = malloc(s0)) == NULL)
s0 >>= 1;

free_mem += s0;

if (p1)
free(p1);
if (p2)
free(p2);
if (p3)
free(p3);

return free_mem;
}

static int frontend_ps2_parse_drive_list(void *data, bool load_content)
{
#ifndef IS_SALAMANDER
Expand Down Expand Up @@ -474,12 +514,23 @@ static int frontend_ps2_parse_drive_list(void *data, bool load_content)
return 0;
}

static void frontend_ps2_process_args(int *argc, char *argv[])
{
#ifndef IS_SALAMANDER
/* Make sure active core path is set here. */
char path[PATH_MAX_LENGTH] = {0};
strlcpy(path, argv[0], sizeof(path));
if (path_is_valid(path))
path_set(RARCH_PATH_CORE, path);
#endif
}

frontend_ctx_driver_t frontend_ctx_ps2 = {
frontend_ps2_get_env, /* get_env */
frontend_ps2_init, /* init */
frontend_ps2_deinit, /* deinit */
frontend_ps2_exitspawn, /* exitspawn */
NULL, /* process_args */
frontend_ps2_process_args, /* process_args */
frontend_ps2_exec, /* exec */
#ifdef IS_SALAMANDER
NULL, /* set_fork */
Expand All @@ -494,8 +545,8 @@ frontend_ctx_driver_t frontend_ctx_ps2 = {
frontend_ps2_get_arch, /* get_architecture */
NULL, /* get_powerstate */
frontend_ps2_parse_drive_list,/* parse_drive_list */
NULL, /* get_total_mem */
NULL, /* get_free_mem */
frontend_ps2_get_total_mem, /* get_total_mem */
frontend_ps2_get_free_mem, /* get_free_mem */
NULL, /* install_signal_handler */
NULL, /* get_sighandler_state */
NULL, /* set_sighandler_state */
Expand Down
4 changes: 4 additions & 0 deletions libretro-common/rthreads/rthreads.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@
#include <sys/time.h>
#endif

#if defined(PS2)
#include <ps2sdkapi.h>
#endif

#ifdef __MACH__
#include <mach/clock.h>
#include <mach/mach.h>
Expand Down
6 changes: 5 additions & 1 deletion retroarch.c
Original file line number Diff line number Diff line change
Expand Up @@ -4803,7 +4803,11 @@ void main_exit(void *args)
#if defined(HAVE_LOGGER) && !defined(ANDROID)
logger_shutdown();
#endif

#ifdef PS2
/* PS2 frontend driver deinit also detaches filesystem,
* so make sure logs are written in advance. */
retro_main_log_file_deinit();
#endif
frontend_driver_deinit(args);
frontend_driver_exitspawn(
path_get_ptr(RARCH_PATH_CORE),
Expand Down
Loading