Skip to content
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
5 changes: 4 additions & 1 deletion Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ SOURCES_C := \
ifeq ($(STATIC_LINKING),1)
else
SOURCES_C += $(LIBRETRO_COMM_DIR)/file/file_path.c \
$(LIBRETRO_COMM_DIR)/file/file_path_io.c \
$(LIBRETRO_COMM_DIR)/compat/compat_posix_string.c \
$(LIBRETRO_COMM_DIR)/compat/compat_snprintf.c \
$(LIBRETRO_COMM_DIR)/compat/compat_strl.c \
$(LIBRETRO_COMM_DIR)/compat/compat_strcasestr.c \
$(LIBRETRO_COMM_DIR)/compat/fopen_utf8.c \
$(LIBRETRO_COMM_DIR)/encodings/encoding_utf.c \
$(LIBRETRO_COMM_DIR)/string/stdstring.c \
$(LIBRETRO_COMM_DIR)/time/rtime.c
$(LIBRETRO_COMM_DIR)/streams/file_stream.c \
$(LIBRETRO_COMM_DIR)/time/rtime.c \
$(LIBRETRO_COMM_DIR)/vfs/vfs_implementation.c

endif

Expand Down
21 changes: 19 additions & 2 deletions src/cart.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
#include "cart.h"
#include "osd.h"

#ifdef __LIBRETRO__
#include <streams/file_stream.h>
#endif

int isIntellicart(void);
int loadIntellicart(void);
int isROM(void);
Expand All @@ -46,12 +50,24 @@ int pos = 0; // current position in data
int LoadCart(const char *path)
{
unsigned char word[1];
FILE *fp;

printf("[INFO] [FREEINTV] Attempting to load cartridge ROM from: %s\n", path);

size = 0;

#ifdef __LIBRETRO__
RFILE *fp;
if((fp = filestream_open(path, RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE)) != NULL)
{
while(filestream_read(fp, word, sizeof(word)) == sizeof(word) && size<0x20000)
{
data[size] = word[0];
size++;
}
filestream_close(fp);
printf("[INFO] [FREEINTV] Cartridge load complete: %d bytes read\n", size);
#else
FILE *fp;
if((fp = fopen(path,"rb"))!=NULL)
{
while(fread(word,sizeof(word),1,fp) && size<0x20000)
Expand All @@ -68,7 +84,8 @@ int LoadCart(const char *path)
{
printf("[ERROR] [FREEINTV] Cartridge load error indicator set\n");
}

#endif

OSD_drawText(8, 7, "SIZE:");
OSD_drawInt(14, 7, size, 10);

Expand Down
2 changes: 1 addition & 1 deletion src/deps/libretro-common/compat/compat_fnmatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include <compat/fnmatch.h>

/* Implemnentation of fnmatch(3) so it can be
/* Implementation of fnmatch(3) so it can be
* distributed to non *nix platforms.
*
* No flags are implemented ATM.
Expand Down
84 changes: 44 additions & 40 deletions src/deps/libretro-common/compat/compat_getopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
#include <compat/strcasestr.h>
#include <compat/posix_string.h>

#include <retro_assert.h>

char *optarg;
int optind, opterr, optopt;

Expand Down Expand Up @@ -110,63 +108,73 @@ static int parse_short(const char *optstring, char * const *argv)
return optarg ? opt[0] : '?';
}

/* If we see additional characters,
* and they don't take arguments, this
* means we have multiple flags in one. */
if (embedded_arg)
{
/* If we see additional characters,
* and they don't take arguments, this
* means we have multiple flags in one. */
memmove(&argv[0][1], &argv[0][2], strlen(&argv[0][2]) + 1);
return opt[0];
}
else
optind++;

optind++;
return opt[0];
}

static int parse_long(const struct option *longopts, char * const *argv)
{
size_t indice;
const struct option *opt = NULL;
for (indice = 0; longopts[indice].name; indice++)
const char *arg = &argv[0][2];
const char *eq = strchr(arg, '=');
size_t len = eq ? (size_t)(eq - arg) : strlen(arg);

for (; longopts->name; longopts++)
{
if (!strcmp(longopts[indice].name, &argv[0][2]))
const char *n = longopts->name;
const char *a = arg;
size_t rem = len;

while (rem && *n == *a)
{
opt = &longopts[indice];
break;
n++;
a++;
rem--;
}
}

if (!opt)
return '?';
if (rem || *n)
continue;

/* getopt_long has an "optional" arg, but we don't bother with that. */
if (opt->has_arg && !argv[1])
return '?';

if (opt->has_arg)
{
optarg = argv[1];
optind += 2;
}
else
optind++;
if (longopts->has_arg)
{
if (eq)
{
optarg = (char *)(eq + 1);
optind++;
}
else if (argv[1])
{
optarg = argv[1];
optind += 2;
}
else
return '?';
}
else
optind++;

if (opt->flag)
{
*opt->flag = opt->val;
return 0;
if (longopts->flag)
{
*longopts->flag = longopts->val;
return 0;
}
return longopts->val;
}

return opt->val;
return '?';
}

static void shuffle_block(char **begin, char **last, char **end)
{
ptrdiff_t len = last - begin;
const char **tmp = (const char**)calloc(len, sizeof(const char*));

retro_assert(tmp);

memcpy((void*)tmp, begin, len * sizeof(const char*));
memmove(begin, last, (end - last) * sizeof(const char*));
memcpy(end - len, tmp, len * sizeof(const char*));
Expand All @@ -179,8 +187,6 @@ int getopt_long(int argc, char *argv[],
{
int short_index, long_index;

(void)longindex;

if (optind == 0)
optind = 1;

Expand Down Expand Up @@ -208,8 +214,6 @@ int getopt_long(int argc, char *argv[],
long_index = 0;
}

retro_assert(short_index == 0 || long_index == 0);

if (short_index == 0)
return parse_short(optstring, &argv[optind]);
if (long_index == 0)
Expand Down
Loading
Loading