update core

This commit is contained in:
Logan McNaughton committed 2021-06-09 21:05:48 -06:00
1 parent f00178ad3c
commit 99260abd9e
16 files changed
+99 -53

No files matched your search

+1 -1
View File
@@ -17575,7 +17575,7 @@ SaveType=Eeprom 4KB
[EC2BCB1B7FC7D068BE1F39E79E49A842]
GoodName=Xena Warrior Princess - The Talisman of Fate (E) [!]
CRC=0A1667C7 293346A6
CountPerOp=3
CountPerOp=4
Players=4
SaveType=None
Mempak=Yes
+3 -3
View File
@@ -382,7 +382,7 @@ static m64p_error write_configlist_file(void)
if (filepath == NULL)
return M64ERR_NO_MEMORY;
fPtr = fopen(filepath, "wb");
fPtr = osal_file_open(filepath, "wb");
if (fPtr == NULL)
{
DebugMessage(M64MSG_ERROR, "Couldn't open configuration file '%s' for writing.", filepath);
@@ -471,7 +471,7 @@ m64p_error ConfigInit(const char *ConfigDirOverride, const char *DataDirOverride
if (filepath == NULL)
return M64ERR_NO_MEMORY;
fPtr = fopen(filepath, "rb");
fPtr = osal_file_open(filepath, "rb");
if (fPtr == NULL)
{
DebugMessage(M64MSG_INFO, "Couldn't open configuration file '%s'. Using defaults.", filepath);
@@ -635,7 +635,7 @@ EXPORT m64p_error CALL ConfigExternalOpen(const char *FileName, m64p_handle *Han
struct external_config* ext_config;
long ftell_result;
size_t filelen = 0;
if (FileName == NULL || (fPtr = fopen(FileName, "rb")) == NULL)
if (FileName == NULL || (fPtr = osal_file_open(FileName, "rb")) == NULL)
{
DebugMessage(M64MSG_ERROR, "Unable to open config file '%s'.", FileName);
return M64ERR_INPUT_INVALID;
@@ -106,6 +106,7 @@ static void flashram_command(struct flashram* flashram, uint32_t command)
case 0xe1000000:
/* set silicon_id mode */
flashram->mode = FLASHRAM_MODE_READ_SILICON_ID;
flashram->status |= 0x01;
break;
case 0xf0000000:
@@ -33,7 +33,7 @@ const char procfile[] = "/proc/cpuinfo";
static unsigned char check_arm_cpu_feature(const char* feature)
{
unsigned char status = 0;
FILE *pFile = fopen(procfile, "r");
FILE *pFile = osal_file_open(procfile, "r");
if (pFile != NULL)
{
@@ -57,7 +57,7 @@ static unsigned char check_arm_cpu_feature(const char* feature)
static unsigned char get_arm_cpu_implementer(void)
{
unsigned char implementer = 0;
FILE *pFile = fopen(procfile, "r");
FILE *pFile = osal_file_open(procfile, "r");
if (pFile != NULL)
{
@@ -80,7 +80,7 @@ static unsigned char get_arm_cpu_implementer(void)
static unsigned short get_arm_cpu_part(void)
{
unsigned short part = 0;
FILE *pFile = fopen(procfile, "r");
FILE *pFile = osal_file_open(procfile, "r");
if (pFile != NULL)
{
@@ -825,7 +825,7 @@ void recomp_dbg_init(void)
cs_option(handle, CS_OPT_DETAIL, CS_OPT_ON);
#if RECOMPILER_DEBUG >= NEW_DYNAREC_ARM
FILE * pFile = fopen ("jump_table.txt","w");
FILE * pFile = osal_file_open ("jump_table.txt","w");
uintptr_t * src = (uintptr_t *)((char *)base_addr+(1<<TARGET_SIZE_2)-JUMP_TABLE_SIZE);
while((char *)src<(char *)base_addr+(1<<TARGET_SIZE_2))
@@ -908,7 +908,7 @@ extern unsigned int using_tlb;
if((disasm == 0) || (handle == 0)) return;
sprintf(filename, "0x%.8x.txt",addr);
pFile = fopen (filename,"w");
pFile = osal_file_open (filename,"w");
for(int i=0;i<slen;i++)
disassemble(i, pFile);
@@ -917,7 +917,7 @@ extern unsigned int using_tlb;
fclose(pFile);
sprintf(filename, "%s_0x%.8x.txt","debug",addr);
pFile = fopen (filename,"w");
pFile = osal_file_open (filename,"w");
for(int i=0;i<slen;i++)
debugging(i, pFile);
@@ -926,7 +926,7 @@ extern unsigned int using_tlb;
fclose(pFile);
sprintf(filename, "%s_0x%.8x.txt",ARCH_NAME,addr);
pFile = fopen (filename,"w");
pFile = osal_file_open (filename,"w");
size = (intptr_t)end - (intptr_t)beginning;
size = (size < 0) ? (-size) : size;
+3 -3
View File
@@ -524,7 +524,7 @@ void dynarec_init_block(struct r4300_core* r4300, uint32_t address)
if (!already_exist)
{
#if defined(PROFILE_R4300)
r4300->recomp.pfProfile = fopen("instructionaddrs.dat", "ab");
r4300->recomp.pfProfile = osal_file_open("instructionaddrs.dat", "ab");
long x86addr = (long) b->code;
int mipsop = -2; /* -2 == NOTCOMPILED block at beginning of x86 code */
if (fwrite(&mipsop, 1, 4, r4300->recomp.pfProfile) != 4 || // write 4-byte MIPS opcode
@@ -641,7 +641,7 @@ void dynarec_recompile_block(struct r4300_core* r4300, const uint32_t* iw, struc
init_cache(r4300, block->block + (func & 0xFFF) / 4);
#if defined(PROFILE_R4300)
r4300->recomp.pfProfile = fopen("instructionaddrs.dat", "ab");
r4300->recomp.pfProfile = osal_file_open("instructionaddrs.dat", "ab");
#endif
for (i = (func & 0xFFF) / 4, finished = 0; finished != 2; ++i)
@@ -839,7 +839,7 @@ void profile_write_end_of_code_blocks(struct r4300_core* r4300)
{
size_t i;
r4300->recomp.pfProfile = fopen("instructionaddrs.dat", "ab");
r4300->recomp.pfProfile = osal_file_open("instructionaddrs.dat", "ab");
for (i = 0; i < 0x100000; ++i) {
if (r4300->cached_interp.invalid_code[i] == 0 && r4300->cached_interp.blocks[i] != NULL && r4300->cached_interp.blocks[i]->code != NULL && r4300->cached_interp.blocks[i]->block != NULL)
+2 -1
View File
@@ -38,6 +38,7 @@
#include "device/device.h"
#include "main.h"
#include "md5.h"
#include "osal/files.h"
#include "osal/preproc.h"
#include "osd/osd.h"
#include "rom.h"
@@ -411,7 +412,7 @@ void romdatabase_open(void)
return;
/* Open romdatabase. */
if (pathname == NULL || (fPtr = fopen(pathname, "rb")) == NULL)
if (pathname == NULL || (fPtr = osal_file_open(pathname, "rb")) == NULL)
{
DebugMessage(M64MSG_ERROR, "Unable to open rom database file '%s'.", pathname);
return;
+10 -9
View File
@@ -43,6 +43,7 @@
#include "device/device.h"
#include "main/list.h"
#include "main/main.h"
#include "osal/files.h"
#include "osal/preproc.h"
#include "osd/osd.h"
#include "plugin/plugin.h"
@@ -200,7 +201,7 @@ static int savestates_load_m64p(struct device* dev, char *filepath)
SDL_LockMutex(savestates_lock);
f = gzopen(filepath, "rb");
f = osal_gzopen(filepath, "rb");
if(f==NULL)
{
main_message(M64MSG_STATUS, OSD_BOTTOM_LEFT, "Could not open state file: %s", filepath);
@@ -1338,7 +1339,7 @@ static int savestates_load_pj64_unc(struct device* dev, char *filepath)
FILE *f;
/* Open the file. */
f = fopen(filepath, "rb");
f = osal_file_open(filepath, "rb");
if (f == NULL)
{
main_message(M64MSG_STATUS, OSD_BOTTOM_LEFT, "Could not open state file: %s", filepath);
@@ -1359,7 +1360,7 @@ static int savestates_load_pj64_unc(struct device* dev, char *filepath)
static savestates_type savestates_detect_type(char *filepath)
{
unsigned char magic[4];
FILE *f = fopen(filepath, "rb");
FILE *f = osal_file_open(filepath, "rb");
if (f == NULL)
{
DebugMessage(M64MSG_STATUS, "Could not open state file %s\n", filepath);
@@ -1399,21 +1400,21 @@ int savestates_load(void)
// try M64P type first
type = savestates_type_m64p;
filepath = savestates_generate_path(type);
fPtr = fopen(filepath, "rb"); // can I open this?
fPtr = osal_file_open(filepath, "rb"); // can I open this?
if (fPtr == NULL)
{
free(filepath);
// try PJ64 zipped type second
type = savestates_type_pj64_zip;
filepath = savestates_generate_path(type);
fPtr = fopen(filepath, "rb"); // can I open this?
fPtr = osal_file_open(filepath, "rb"); // can I open this?
if (fPtr == NULL)
{
free(filepath);
// finally, try PJ64 uncompressed
type = savestates_type_pj64_unc;
filepath = savestates_generate_path(type);
fPtr = fopen(filepath, "rb"); // can I open this?
fPtr = osal_file_open(filepath, "rb"); // can I open this?
if (fPtr == NULL)
{
free(filepath);
@@ -1433,7 +1434,7 @@ int savestates_load(void)
}
filepath = savestates_generate_path(type);
if (filepath != NULL)
fPtr = fopen(filepath, "rb"); // can I open this?
fPtr = osal_file_open(filepath, "rb"); // can I open this?
if (fPtr == NULL)
{
main_message(M64MSG_STATUS, OSD_BOTTOM_LEFT, "Failed to open savestate file %s", filepath);
@@ -1477,7 +1478,7 @@ static void savestates_save_m64p_work(struct work_struct *work)
SDL_LockMutex(savestates_lock);
// Write the state to a GZIP file
f = gzopen(save->filepath, "wb");
f = osal_gzopen(save->filepath, "wb");
if (f==NULL)
{
@@ -2119,7 +2120,7 @@ static int savestates_save_pj64_unc(const struct device* dev, char *filepath)
{
FILE *f;
f = fopen(filepath, "wb");
f = osal_file_open(filepath, "wb");
if (f == NULL)
{
main_message(M64MSG_STATUS, OSD_BOTTOM_LEFT, "Could not create PJ64 state file: %s", filepath);
+2 -2
View File
@@ -97,7 +97,7 @@ static int SaveRGBBufferToFile(const char *filename, const unsigned char *buf, i
return 3;
}
// open the file to write
FILE *savefile = fopen(filename, "wb");
FILE *savefile = osal_file_open(filename, "wb");
if (savefile == NULL)
{
DebugMessage(M64MSG_ERROR, "Error opening '%s' to save screenshot.", filename);
@@ -189,7 +189,7 @@ static char *GetNextScreenshotPath(void)
for (; CurrentShotIndex < 1000; CurrentShotIndex++)
{
sprintf(NumberPtr, "%03i.png", CurrentShotIndex);
FILE *pFile = fopen(ScreenshotPath, "r");
FILE *pFile = osal_file_open(ScreenshotPath, "r");
if (pFile == NULL)
break;
fclose(pFile);
+6 -6
View File
@@ -49,7 +49,7 @@
file_status_t read_from_file(const char *filename, void *data, size_t size)
{
FILE *f = fopen(filename, "rb");
FILE *f = osal_file_open(filename, "rb");
if (f == NULL)
{
return file_open_error;
@@ -67,7 +67,7 @@ file_status_t read_from_file(const char *filename, void *data, size_t size)
file_status_t write_to_file(const char *filename, const void *data, size_t size)
{
FILE *f = fopen(filename, "wb");
FILE *f = osal_file_open(filename, "wb");
if (f == NULL)
{
return file_open_error;
@@ -90,8 +90,8 @@ file_status_t write_chunk_to_file(const char *filename, const void *data, size_t
/* first try to open with rb+ to avoid wiping existing content,
* otherwise create file */
if ((f = fopen(filename, "rb+")) == NULL) {
if ((f = fopen(filename, "wb")) == NULL) {
if ((f = osal_file_open(filename, "rb+")) == NULL) {
if ((f = osal_file_open(filename, "wb")) == NULL) {
return file_open_error;
}
}
@@ -126,7 +126,7 @@ file_status_t load_file(const char* filename, void** buffer, size_t* size)
/* open file */
ret = file_open_error;
fd = fopen(filename, "rb");
fd = osal_file_open(filename, "rb");
if (fd == NULL)
{
return file_open_error;
@@ -188,7 +188,7 @@ file_status_t get_file_size(const char* filename, size_t* size)
/* open file */
ret = file_open_error;
fd = fopen(filename, "rb");
fd = osal_file_open(filename, "rb");
if (fd == NULL)
{
return file_open_error;
+5
View File
@@ -26,6 +26,8 @@
#if !defined (OSAL_FILES_H)
#define OSAL_FILES_H
#include <zlib.h>
/* some file-related preprocessor definitions */
#if defined(WIN32) && !defined(__MINGW32__)
#include <io.h> // For _unlink()
@@ -57,5 +59,8 @@ extern const char * osal_get_user_configpath(void);
extern const char * osal_get_user_datapath(void);
extern const char * osal_get_user_cachepath(void);
extern FILE * osal_file_open (const char *filename, const char *mode);
extern gzFile osal_gzopen(const char *filename, const char *mode);
#endif /* OSAL_FILES_H */
+9
View File
@@ -223,3 +223,12 @@ const char * osal_get_user_cachepath(void)
return osal_get_user_configpath();
}
FILE * osal_file_open ( const char * filename, const char * mode )
{
return fopen (filename, mode);
}
gzFile osal_gzopen(const char *filename, const char *mode)
{
return gzopen(filename, mode);
}
+8
View File
@@ -232,4 +232,12 @@ const char * osal_get_user_cachepath(void)
return NULL;
}
FILE * osal_file_open(const char *filename, const char *mode)
{
return fopen (filename, mode);
}
gzFile osal_gzopen(const char *filename, const char *mode)
{
return gzopen(filename, mode);
}
+39 -18
View File
@@ -64,8 +64,10 @@ static int search_dir_file(char *destpath, const char *path, const char *filenam
strcat(destpath, "\\");
strcat(destpath, filename);
wchar_t w_destpath[PATH_MAX];
MultiByteToWideChar(CP_UTF8, 0, destpath, -1, w_destpath, PATH_MAX);
/* test for a valid file */
if (_stat(destpath, &fileinfo) != 0)
if (_wstat(w_destpath, &fileinfo) != 0)
return 2;
if ((fileinfo.st_mode & _S_IFREG) == 0)
return 3;
@@ -91,8 +93,10 @@ int osal_mkdirp(const char *dirpath, int mode)
if (strchr(OSAL_DIR_SEPARATORS, *lastchar) != NULL)
*lastchar = 0;
wchar_t w_mypath[PATH_MAX];
MultiByteToWideChar(CP_UTF8, 0, mypath, -1, w_mypath, PATH_MAX);
// Terminate quickly if the path already exists
if (_stat(mypath, &fileinfo) == 0 && (fileinfo.st_mode & _S_IFDIR))
if (_wstat(w_mypath, &fileinfo) == 0 && (fileinfo.st_mode & _S_IFDIR))
goto goodexit;
while ((currpath = strpbrk(currpath + 1, OSAL_DIR_SEPARATORS)) != NULL)
@@ -102,9 +106,9 @@ int osal_mkdirp(const char *dirpath, int mode)
if (currpath > mypath && currpath[-1] == ':')
continue;
*currpath = '\0';
if (_stat(mypath, &fileinfo) != 0)
if (_wstat(w_mypath, &fileinfo) != 0)
{
if (_mkdir(mypath) != 0)
if (_wmkdir(w_mypath) != 0)
goto errorexit;
}
else if (!(fileinfo.st_mode & _S_IFDIR))
@@ -115,7 +119,7 @@ int osal_mkdirp(const char *dirpath, int mode)
}
// Create full path
if (_mkdir(mypath) != 0)
if (_wmkdir(w_mypath) != 0)
goto errorexit;
goodexit:
@@ -152,7 +156,8 @@ const char * osal_get_shared_filepath(const char *filename, const char *firstsea
const char * osal_get_user_configpath(void)
{
static char chHomePath[MAX_PATH];
static wchar_t chHomePath[MAX_PATH];
static char outString[MAX_PATH];
LPITEMIDLIST pidl;
LPMALLOC pMalloc;
struct _stat fileinfo;
@@ -160,35 +165,37 @@ const char * osal_get_user_configpath(void)
// Get item ID list for the path of user's personal directory
SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidl);
// get the path in a char string
SHGetPathFromIDList(pidl, chHomePath);
SHGetPathFromIDListW(pidl, chHomePath);
// do a bunch of crap just to free some memory
SHGetMalloc(&pMalloc);
pMalloc->lpVtbl->Free(pMalloc, pidl);
pMalloc->lpVtbl->Release(pMalloc);
// tack on 'mupen64plus'
if (chHomePath[strlen(chHomePath)-1] != '\\')
strcat(chHomePath, "\\");
strcat(chHomePath, "Mupen64Plus");
if (chHomePath[wcslen(chHomePath)-1] != L'\\')
wcscat(chHomePath, L"\\");
wcscat(chHomePath, L"Mupen64Plus");
// if this directory doesn't exist, then make it
if (_stat(chHomePath, &fileinfo) == 0)
if (_wstat(chHomePath, &fileinfo) == 0)
{
strcat(chHomePath, "\\");
return chHomePath;
wcscat(chHomePath, L"\\");
WideCharToMultiByte(CP_UTF8, 0, chHomePath, -1, outString, MAX_PATH, NULL, NULL);
return outString;
}
else
{
osal_mkdirp(chHomePath, 0);
if (_stat(chHomePath, &fileinfo) == 0)
_wmkdir(chHomePath);
if (_wstat(chHomePath, &fileinfo) == 0)
{
strcat(chHomePath, "\\");
return chHomePath;
wcscat(chHomePath, L"\\");
WideCharToMultiByte(CP_UTF8, 0, chHomePath, -1, outString, MAX_PATH, NULL, NULL);
return outString;
}
}
/* otherwise we are in trouble */
DebugMessage(M64MSG_ERROR, "Failed to open configuration directory '%s'.", chHomePath);
DebugMessage(M64MSG_ERROR, "Failed to open configuration directory '%ls'.", chHomePath);
return NULL;
}
@@ -204,4 +211,18 @@ const char * osal_get_user_cachepath(void)
return osal_get_user_configpath();
}
FILE * osal_file_open ( const char * filename, const char * mode )
{
wchar_t wstr_filename[PATH_MAX];
wchar_t wstr_mode[64];
MultiByteToWideChar(CP_UTF8, 0, filename, -1, wstr_filename, PATH_MAX);
MultiByteToWideChar(CP_UTF8, 0, mode, -1, wstr_mode, 64);
return _wfopen (wstr_filename, wstr_mode);
}
gzFile osal_gzopen(const char *filename, const char *mode)
{
wchar_t wstr_filename[PATH_MAX];
MultiByteToWideChar(CP_UTF8, 0, filename, -1, wstr_filename, PATH_MAX);
return gzopen_w(wstr_filename, mode);
}
+2 -2
View File
@@ -119,7 +119,7 @@ int main(int argc, void *argv[])
/* open r4300 opcode/x86 address table generated from emulator run */
printf("Loading %s...\n", argv[1]);
pfIn = fopen(argv[1], "rb");
pfIn = osal_file_open(argv[1], "rb");
if (pfIn == NULL)
{
printf("Couldn't open input file: %s\n", argv[1]);
@@ -168,7 +168,7 @@ int main(int argc, void *argv[])
/* open the profiling sample data file */
printf("Loading %s...\n", argv[2]);
pfIn = fopen(argv[2], "rb");
pfIn = osal_file_open(argv[2], "rb");
if (pfIn == NULL)
{
printf("Couldn't open input file: %s\n", argv[2]);
+1 -1
View File
@@ -120,7 +120,7 @@ int main(int argc, char *argv[])
return 1;
}
filename = argv[1];
pfTest = fopen(filename, "rb");
pfTest = osal_file_open(filename, "rb");
if (pfTest == NULL)
{
printf("Error: cannot open savestate file '%s' for reading.\n", filename);