Should fix Wii boot.dol regression - apparently some problem

with retro_file ?
This commit is contained in:
twinaphex 2015-11-15 03:13:34 +01:00
parent 5c6840323b
commit e4ba9efae1
1 changed files with 27 additions and 9 deletions

View File

@ -27,7 +27,6 @@
#include <sdcard/wiisd_io.h> #include <sdcard/wiisd_io.h>
#include <retro_log.h> #include <retro_log.h>
#include <retro_file.h>
#include <file/file_path.h> #include <file/file_path.h>
#include <retro_miscellaneous.h> #include <retro_miscellaneous.h>
@ -49,9 +48,10 @@ char gx_rom_path[PATH_MAX_LENGTH];
static void dol_copy_argv_path(const char *dolpath, const char *argpath) static void dol_copy_argv_path(const char *dolpath, const char *argpath)
{ {
char tmp[PATH_MAX_LENGTH]; char tmp[PATH_MAX_LENGTH];
size_t t_len, len = 0; size_t t_len;
struct __argv *argv = (struct __argv *)ARGS_ADDR; struct __argv *argv = (struct __argv *)ARGS_ADDR;
char *cmdline = NULL; char *cmdline = NULL;
size_t len = 0;
memset(ARGS_ADDR, 0, sizeof(struct __argv)); memset(ARGS_ADDR, 0, sizeof(struct __argv));
@ -115,13 +115,13 @@ static void dol_copy_argv_path(const char *dolpath, const char *argpath)
* heap memory and are restricted to the stack only. */ * heap memory and are restricted to the stack only. */
void system_exec_wii(const char *_path, bool should_load_game) void system_exec_wii(const char *_path, bool should_load_game)
{ {
size_t booter_size; FILE *fp;
ssize_t length; size_t size, booter_size;
void *dol;
char path[PATH_MAX_LENGTH]; char path[PATH_MAX_LENGTH];
char game_path[PATH_MAX_LENGTH]; char game_path[PATH_MAX_LENGTH];
void *dol = NULL;
#ifndef IS_SALAMANDER #ifndef IS_SALAMANDER
global_t *global = global_get_ptr(); global_t *global = global_get_ptr();
bool original_verbose = global->verbosity; bool original_verbose = global->verbosity;
global->verbosity = true; global->verbosity = true;
#endif #endif
@ -139,12 +139,30 @@ void system_exec_wii(const char *_path, bool should_load_game)
} }
RARCH_LOG("Attempt to load executable: [%s]\n", path); RARCH_LOG("Attempt to load executable: [%s]\n", path);
if (retro_read_file(path, dol, &length) != 1)
fp = fopen(path, "rb");
if (fp == NULL)
{ {
RARCH_ERR("Could not open DOL file %s.\n", path); RARCH_ERR("Could not open DOL file %s.\n", path);
goto exit; goto exit;
} }
fseek(fp, 0, SEEK_END);
size = ftell(fp);
fseek(fp, 0, SEEK_SET);
/* try to allocate a buffer for it. if we can't, fail. */
dol = malloc(size);
if (!dol)
{
RARCH_ERR("Could not execute DOL file %s.\n", path);
fclose(fp);
goto exit;
}
fread(dol, 1, size, fp);
fclose(fp);
fatUnmount("carda:"); fatUnmount("carda:");
fatUnmount("cardb:"); fatUnmount("cardb:");
fatUnmount("sd:"); fatUnmount("sd:");
@ -153,8 +171,8 @@ void system_exec_wii(const char *_path, bool should_load_game)
__io_usbstorage.shutdown(); __io_usbstorage.shutdown();
/* don't use memcpy, there might be an overlap. */ /* don't use memcpy, there might be an overlap. */
memmove(EXECUTE_ADDR, dol, length); memmove(EXECUTE_ADDR, dol, size);
DCFlushRange(EXECUTE_ADDR, length); DCFlushRange(EXECUTE_ADDR, size);
dol_copy_argv_path(path, should_load_game ? game_path : NULL); dol_copy_argv_path(path, should_load_game ? game_path : NULL);