* 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. *
***************************************************************************/
-#include <compat/fopen_utf8.h>
-
/*
* SIO functions.
*/
#include "sio.h"
#include <sys/stat.h>
+#ifdef USE_LIBRETRO_VFS
+#include <streams/file_stream_transforms.h>
+#endif
+
// Status Flags
#define TX_RDY 0x0001
#define RX_RDY 0x0002
char McdDisable[2];
#define SIO_INT(eCycle) { \
- if (!Config.Sio) { \
- psxRegs.interrupt |= (1 << PSXINT_SIO); \
- psxRegs.intCycle[PSXINT_SIO].cycle = eCycle; \
- psxRegs.intCycle[PSXINT_SIO].sCycle = psxRegs.cycle; \
- new_dyna_set_event(PSXINT_SIO, eCycle); \
- } \
+ psxRegs.interrupt |= (1 << PSXINT_SIO); \
+ psxRegs.intCycle[PSXINT_SIO].cycle = eCycle; \
+ psxRegs.intCycle[PSXINT_SIO].sCycle = psxRegs.cycle; \
+ new_dyna_set_event(PSXINT_SIO, eCycle); \
}
// clk cycle byte
if (*str == 0)
return;
- f = fopen_utf8(str, "rb");
+ f = fopen(str, "rb");
if (f == NULL) {
SysPrintf(_("The memory card %s doesn't exist - creating it\n"), str);
CreateMcd(str);
- f = fopen_utf8(str, "rb");
+ f = fopen(str, "rb");
if (f != NULL) {
struct stat buf;
else if(buf.st_size == MCD_SIZE + 3904)
fseek(f, 3904, SEEK_SET);
}
- fread(data, 1, MCD_SIZE, f);
+ if (fread(data, 1, MCD_SIZE, f) != MCD_SIZE) {
+#ifndef NDEBUG
+ SysPrintf(_("File IO error in <%s:%s>.\n"), __FILE__, __func__);
+#endif
+ memset(data, 0x00, MCD_SIZE);
+ }
fclose(f);
}
else
else if(buf.st_size == MCD_SIZE + 3904)
fseek(f, 3904, SEEK_SET);
}
- fread(data, 1, MCD_SIZE, f);
+ if (fread(data, 1, MCD_SIZE, f) != MCD_SIZE) {
+#ifndef NDEBUG
+ SysPrintf(_("File IO error in <%s:%s>.\n"), __FILE__, __func__);
+#endif
+ memset(data, 0x00, MCD_SIZE);
+ }
fclose(f);
}
}
if (mcd == NULL || *mcd == 0 || strcmp(mcd, "none") == 0)
return;
- f = fopen_utf8(mcd, "r+b");
+ f = fopen(mcd, "r+b");
if (f != NULL) {
struct stat buf;
int s = MCD_SIZE;
int i = 0, j;
- f = fopen_utf8(mcd, "wb");
+ f = fopen(mcd, "wb");
if (f == NULL)
return;
fclose(f);
}
f = fopen(mcd, "r+");
+ if (f == NULL) return;
s = s + 3904;
fputc('1', f); s--;
fputc('2', f); s--;
fclose(f);
}
f = fopen(mcd, "r+");
+ if (f == NULL) return;
s = s + 64;
fputc('V', f); s--;
fputc('g', f); s--;