Take out most of the __LIBRETRO__ hacks in mainline codebase

This commit is contained in:
twinaphex
2014-04-18 19:22:25 +02:00
parent 216a88eda3
commit da7ac270f8
8 changed files with 0 additions and 78 deletions

View File

@@ -21,10 +21,6 @@
/* Contains file I/O functions that write/read data */
/* LSB first. */
#ifdef __LIBRETRO__
#define ENDIAN_LIBRETRO
#endif
#include <stdio.h>
#include "fceu-memory.h"
#include "fceu-types.h"

View File

@@ -460,11 +460,9 @@ void FCEU_printf(char *format, ...) {
vsprintf(temp, format, ap);
FCEUD_Message(temp);
#ifndef __LIBRETRO__
ofile = fopen("stdout.txt", "ab");
fwrite(temp, 1, strlen(temp), ofile);
fclose(ofile);
#endif
va_end(ap);
}

View File

@@ -37,10 +37,6 @@
#include "driver.h"
#include "general.h"
#ifndef __LIBRETRO__
#define SUPPORTS_UNZIP_AND_GZIP
#endif
typedef struct {
uint8 *data;
uint32 size;
@@ -142,7 +138,6 @@ static MEMWRAP *MakeMemWrap(void *tz, int type) {
}
fread(tmp->data, 1, tmp->size, (FILE*)tz);
}
#ifdef SUPPORTS_UNZIP_AND_GZIP
else if (type == 1) {
/* Bleck. The gzip file format has the size of the uncompressed data,
but I can't get to the info with the zlib interface(?). */
@@ -166,20 +161,17 @@ static MEMWRAP *MakeMemWrap(void *tz, int type) {
}
unzReadCurrentFile(tz, tmp->data, ufo.uncompressed_size);
}
#endif
doret:
if (type == 0) {
fclose((FILE*)tz);
}
#ifdef SUPPORTS_UNZIP_AND_GZIP
else if (type == 1) {
gzclose(tz);
} else if (type == 2) {
unzCloseCurrentFile(tz);
unzClose(tz);
}
#endif
return tmp;
}
@@ -199,7 +191,6 @@ FCEUFILE * FCEU_fopen(const char *path, const char *ipsfn, char *mode, char *ext
fceufp = (FCEUFILE*)malloc(sizeof(FCEUFILE));
{
#ifdef SUPPORTS_UNZIP_AND_GZIP
unzFile tz;
if ((tz = unzOpen(path))) { // If it's not a zip file, use regular file handlers.
// Assuming file type by extension usually works,
@@ -286,7 +277,6 @@ FCEUFILE * FCEU_fopen(const char *path, const char *ipsfn, char *mode, char *ext
}
close(fd);
}
#endif
}
if ((t = FCEUD_UTF8fopen(path, mode))) {
@@ -309,7 +299,6 @@ FCEUFILE * FCEU_fopen(const char *path, const char *ipsfn, char *mode, char *ext
}
int FCEU_fclose(FCEUFILE *fp) {
#ifdef SUPPORTS_UNZIP_AND_GZIP
if (fp->type == 1) {
gzclose(fp->fp);
} else if (fp->type >= 2) {
@@ -318,7 +307,6 @@ int FCEU_fclose(FCEUFILE *fp) {
free(fp->fp);
fp->fp = 0;
} else
#endif
{
fclose((FILE*)fp->fp);
}
@@ -328,7 +316,6 @@ int FCEU_fclose(FCEUFILE *fp) {
}
uint64 FCEU_fread(void *ptr, size_t size, size_t nmemb, FCEUFILE *fp) {
#ifdef SUPPORTS_UNZIP_AND_GZIP
if (fp->type == 1) {
return gzread(fp->fp, ptr, size * nmemb);
} else if (fp->type >= 2) {
@@ -349,25 +336,21 @@ uint64 FCEU_fread(void *ptr, size_t size, size_t nmemb, FCEUFILE *fp) {
return nmemb;
}
} else
#endif
{
return fread(ptr, size, nmemb, (FILE*)fp->fp);
}
}
uint64 FCEU_fwrite(void *ptr, size_t size, size_t nmemb, FCEUFILE *fp) {
#ifdef SUPPORTS_UNZIP_AND_GZIP
if (fp->type == 1) {
return gzwrite(fp->fp, ptr, size * nmemb);
} else if (fp->type >= 2) {
return 0;
} else
#endif
return fwrite(ptr, size, nmemb, (FILE*)fp->fp);
}
int FCEU_fseek(FCEUFILE *fp, long offset, int whence) {
#ifdef SUPPORTS_UNZIP_AND_GZIP
if (fp->type == 1) {
return((gzseek(fp->fp, offset, whence) > 0) ? 0 : -1);
} else if (fp->type >= 2) {
@@ -385,29 +368,24 @@ int FCEU_fseek(FCEUFILE *fp, long offset, int whence) {
}
return 0;
} else
#endif
return fseek((FILE*)fp->fp, offset, whence);
}
uint64 FCEU_ftell(FCEUFILE *fp) {
#ifdef SUPPORTS_UNZIP_AND_GZIP
if (fp->type == 1) {
return gztell(fp->fp);
} else if (fp->type >= 2) {
return(((MEMWRAP*)(fp->fp))->location);
} else
#endif
return ftell((FILE*)fp->fp);
}
void FCEU_rewind(FCEUFILE *fp) {
#ifdef SUPPORTS_UNZIP_AND_GZIP
if (fp->type == 1) {
gzrewind(fp->fp);
} else if (fp->type >= 2) {
((MEMWRAP*)(fp->fp))->location = 0;
} else
#endif
/* Rewind */
fseek(fp->fp, 0, SEEK_SET);
}
@@ -415,7 +393,6 @@ void FCEU_rewind(FCEUFILE *fp) {
int FCEU_read16le(uint16 *val, FCEUFILE *fp) {
uint8 t[2];
#ifdef SUPPORTS_UNZIP_AND_GZIP
if (fp->type >= 1) {
if (fp->type >= 2) {
MEMWRAP *wz;
@@ -429,7 +406,6 @@ int FCEU_read16le(uint16 *val, FCEUFILE *fp) {
if (gzread(fp->fp, &t, 2) != 2) return(0);
return(1);
} else
#endif
{
if (fread(t, 1, 2, (FILE*)fp->fp) != 2) return(0);
}
@@ -438,7 +414,6 @@ int FCEU_read16le(uint16 *val, FCEUFILE *fp) {
}
int FCEU_read32le(uint32 *Bufo, FCEUFILE *fp) {
#ifdef SUPPORTS_UNZIP_AND_GZIP
if (fp->type >= 1) {
uint8 t[4];
#ifndef LSB_FIRST
@@ -465,14 +440,12 @@ int FCEU_read32le(uint32 *Bufo, FCEUFILE *fp) {
#endif
return 1;
} else
#endif
{
return read32le(Bufo, (FILE*)fp->fp);
}
}
int FCEU_fgetc(FCEUFILE *fp) {
#ifdef SUPPORTS_UNZIP_AND_GZIP
if (fp->type == 1)
return gzgetc(fp->fp);
else if (fp->type >= 2) {
@@ -482,12 +455,10 @@ int FCEU_fgetc(FCEUFILE *fp) {
return wz->data[wz->location++];
return EOF;
} else
#endif
return fgetc((FILE*)fp->fp);
}
uint64 FCEU_fgetsize(FCEUFILE *fp) {
#ifdef SUPPORTS_UNZIP_AND_GZIP
if (fp->type == 1) {
int x, t;
t = gztell(fp->fp);
@@ -498,7 +469,6 @@ uint64 FCEU_fgetsize(FCEUFILE *fp) {
} else if (fp->type >= 2)
return ((MEMWRAP*)(fp->fp))->size;
else
#endif
{
long t, r;
t = ftell((FILE*)fp->fp);
@@ -510,9 +480,7 @@ uint64 FCEU_fgetsize(FCEUFILE *fp) {
}
int FCEU_fisarchive(FCEUFILE *fp) {
#ifdef SUPPORTS_UNZIP_AND_GZIP
if (fp->type == 2)
return 1;
#endif
return 0;
}

View File

@@ -85,7 +85,6 @@ char *FCEU_MakeFName(int type, int id1, char *cd1) {
struct stat tmpstat;
switch (type) {
#ifndef __LIBRETRO__
case FCEUMKF_NPTEMP: asprintf(&ret, "%s"PSS "m590plqd94fo.tmp", BaseDirectory); break;
case FCEUMKF_MOVIE:
if (odirs[FCEUIOD_STATE])
@@ -154,7 +153,6 @@ char *FCEU_MakeFName(int type, int id1, char *cd1) {
break;
case FCEUMKF_IPS: asprintf(&ret, "%s"PSS "%s%s.ips", FileBaseDirectory, FileBase, FileExt);
break;
#endif
case FCEUMKF_GGROM: asprintf(&ret, "%s"PSS "gg.rom", BaseDirectory); break;
case FCEUMKF_FDSROM: asprintf(&ret, "%s"PSS "disksys.rom", BaseDirectory); break;
case FCEUMKF_PALETTE:

View File

@@ -40,10 +40,6 @@
#include "input.h"
#include "fceu-endian.h"
#ifndef __LIBRETRO__
#define NETPLAY_ENABLED
#endif
int FCEUnetplay = 0;
static uint8 netjoy[4]; /* Controller cache. */
@@ -80,9 +76,6 @@ int FCEUI_NetplayStart(int nlocal, int divisor) {
}
int FCEUNET_SendCommand(uint8 cmd, uint32 len) {
#ifdef __LIBRETRO__
return 0;
#else
uint8 buf[numlocal + 1 + 4];
buf[0] = 0xFF;
@@ -95,7 +88,6 @@ int FCEUNET_SendCommand(uint8 cmd, uint32 len) {
}
#endif
return(1);
#endif
}
void FCEUI_NetplayText(uint8 *text) {
@@ -110,7 +102,6 @@ void FCEUI_NetplayText(uint8 *text) {
}
int FCEUNET_SendFile(uint8 cmd, char *fn) {
#ifdef NETPLAY_ENABLED
uint32 len;
uLongf clen;
char *buf, *cbuf;
@@ -146,12 +137,10 @@ int FCEUNET_SendFile(uint8 cmd, char *fn) {
}
#endif
free(cbuf);
#endif
return(1);
}
static FILE *FetchFile(uint32 remlen) {
#ifdef NETPLAY_ENABLED
uint32 clen = remlen;
char *cbuf;
uLongf len;
@@ -197,7 +186,6 @@ static FILE *FetchFile(uint32 remlen) {
return(fp);
}
free(fn);
#endif
return(0);
}

View File

@@ -21,10 +21,6 @@
/* TODO: Add (better) file io error checking */
/* TODO: Change save state file format. */
#ifdef __LIBRETRO__
#define STATE_LIBRETRO
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -260,9 +256,6 @@ void FCEUSS_Save(char *fname) {
return;
}
#ifdef HAVE_MEMSTREAM
st = memstream_open(1);
#else
if (fname)
st = FCEUD_UTF8fopen(fname, "wb");
else {
@@ -274,15 +267,12 @@ void FCEUSS_Save(char *fname) {
FCEU_DispMessage("State %d save error.", CurrentState);
return;
}
#endif
FCEUSS_SaveFP(st);
SaveStateStatus[CurrentState] = 1;
fclose(st);
#ifndef HAVE_MEMSTREAM
FCEU_DispMessage("State %d saved.", CurrentState);
#endif
}
int FCEUSS_LoadFP(MEM_TYPE *st) {
@@ -314,9 +304,6 @@ int FCEUSS_Load(char *fname) {
MEM_TYPE *st;
char *fn;
#ifdef HAVE_MEMSTREAM
st = memstream_open(0);
#else
if (geniestage == 1) {
FCEU_DispMessage("Cannot load FCS in GG screen.");
return(0);
@@ -334,21 +321,16 @@ int FCEUSS_Load(char *fname) {
SaveStateStatus[CurrentState] = 0;
return(0);
}
#endif
if (FCEUSS_LoadFP(st)) {
#ifndef HAVE_MEMSTREAM
SaveStateStatus[CurrentState] = 1;
FCEU_DispMessage("State %d loaded.", CurrentState);
#endif
SaveStateStatus[CurrentState] = 1;
fclose(st);
return(1);
} else {
SaveStateStatus[CurrentState] = 1;
#ifndef HAVE_MEMSTREAM
FCEU_DispMessage("Error(s) reading state %d!", CurrentState);
#endif
fclose(st);
return(0);
}

View File

@@ -40,10 +40,6 @@
uint8 *XBuf = NULL;
static uint8 *xbsave = NULL;
#ifndef __LIBRETRO__
#define SNAPSHOTS_ENABLED
#endif
void FCEU_KillVirtualVideo(void) {
if (xbsave) {
free(xbsave);
@@ -179,7 +175,6 @@ static int WritePNGChunk(FILE *fp, uint32 size, char *type, uint8 *data) {
}
int SaveSnapshot(void) {
#ifdef SNAPSHOTS_ENABLED
static uint32 lastu = 0;
char *fn = 0;
@@ -274,7 +269,6 @@ int SaveSnapshot(void) {
free(compmem);
if (pp)
fclose(pp);
#endif
return(0);
}

View File

@@ -15,7 +15,6 @@ static long wsize;
// so).
void FCEU_WriteWaveData(int32 *Buffer, int Count) {
#ifndef __LIBRETRO__
int16 temp[Count]; /* Yay. Is this the first use of this "feature" of C in FCE Ultra? */
int16 *dest;
int x;
@@ -34,7 +33,6 @@ void FCEU_WriteWaveData(int32 *Buffer, int Count) {
Buffer++;
}
wsize += fwrite(temp, 1, Count * sizeof(int16), soundlog);
#endif
}
int FCEUI_EndWaveRecord(void) {