From 53567cbc8d71f57e812ddbf555e73fac4ca249e8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 3 Oct 2020 12:45:05 +0200 Subject: [PATCH] Cleanups --- mednafen/mednafen-endian.c | 44 -------------------------------------- mednafen/mednafen-endian.h | 5 ----- mednafen/mednafen.h | 1 - mednafen/mempatcher.h | 2 -- mednafen/state.c | 24 +++++++++++++++++++++ 5 files changed, 24 insertions(+), 52 deletions(-) diff --git a/mednafen/mednafen-endian.c b/mednafen/mednafen-endian.c index d8108a7..08fdc00 100644 --- a/mednafen/mednafen-endian.c +++ b/mednafen/mednafen-endian.c @@ -200,47 +200,3 @@ void Endian_V_NE_to_LE(void *src, uint32_t bytesize) FlipByteOrder((uint8_t *)src, bytesize); #endif } - -int write16le(uint16_t b, FILE *fp) -{ - uint8_t s[2]; - s[0]=b; - s[1]=b>>8; - return((fwrite(s,1,2,fp)<2)?0:2); -} - -int write32le(uint32_t b, FILE *fp) -{ - uint8_t s[4]; - s[0]=b; - s[1]=b>>8; - s[2]=b>>16; - s[3]=b>>24; - return((fwrite(s,1,4,fp)<4)?0:4); -} - -int read32le(uint32_t *Bufo, FILE *fp) -{ - uint32_t buf; - if(fread(&buf,1,4,fp)<4) - return 0; -#ifdef MSB_FIRST - *(uint32_t*)Bufo=((buf&0xFF)<<24)|((buf&0xFF00)<<8)|((buf&0xFF0000)>>8)|((buf&0xFF000000)>>24); -#else - *(uint32_t*)Bufo=buf; -#endif - return 1; -} - -int read16le(char *d, FILE *fp) -{ -#ifdef MSB_FIRST - int ret; - ret=fread(d+1,1,1,fp); - ret+=fread(d,1,1,fp); - return ret<2?0:2; -#else - return((fread(d,1,2,fp)<2)?0:2); -#endif -} - diff --git a/mednafen/mednafen-endian.h b/mednafen/mednafen-endian.h index 96a8539..c68b832 100644 --- a/mednafen/mednafen-endian.h +++ b/mednafen/mednafen-endian.h @@ -1,17 +1,12 @@ #ifndef __MDFN_ENDIAN_H #define __MDFN_ENDIAN_H -#include #include #ifdef __cplusplus extern "C" { #endif -int write16le(uint16_t b, FILE *fp); -int write32le(uint32_t b, FILE *fp); -int read32le(uint32_t *Bufo, FILE *fp); - void Endian_A16_Swap(void *src, uint32_t nelements); void Endian_A32_Swap(void *src, uint32_t nelements); void Endian_A64_Swap(void *src, uint32_t nelements); diff --git a/mednafen/mednafen.h b/mednafen/mednafen.h index 6436318..1a381dd 100644 --- a/mednafen/mednafen.h +++ b/mednafen/mednafen.h @@ -2,7 +2,6 @@ #define _MEDNAFEN_H #include "mednafen-types.h" -#include #include #include diff --git a/mednafen/mempatcher.h b/mednafen/mempatcher.h index 7f877ea..ddcaf0c 100644 --- a/mednafen/mempatcher.h +++ b/mednafen/mempatcher.h @@ -2,7 +2,6 @@ #define __MDFN_MEMPATCHER_H #include "mempatcher-driver.h" -#include typedef struct __SUBCHEAT { @@ -11,7 +10,6 @@ typedef struct __SUBCHEAT int compare; // < 0 on no compare } SUBCHEAT; -extern std::vector SubCheats[8]; extern bool SubCheatsOn; bool MDFNMP_Init(uint32 ps, uint32 numpages); diff --git a/mednafen/state.c b/mednafen/state.c index 5ee004f..61bbd2f 100644 --- a/mednafen/state.c +++ b/mednafen/state.c @@ -32,6 +32,30 @@ /* Forward declaration */ int StateAction(StateMem *sm, int load, int data_only); +static int write32le(uint32_t b, FILE *fp) +{ + uint8_t s[4]; + s[0]=b; + s[1]=b>>8; + s[2]=b>>16; + s[3]=b>>24; + return((fwrite(s,1,4,fp)<4)?0:4); +} + +static int read32le(uint32_t *Bufo, FILE *fp) +{ + uint32_t buf; + if(fread(&buf,1,4,fp)<4) + return 0; +#ifdef MSB_FIRST + *(uint32_t*)Bufo=((buf&0xFF)<<24)|((buf&0xFF00)<<8)|((buf&0xFF0000)>>8)|((buf&0xFF000000)>>24); +#else + *(uint32_t*)Bufo=buf; +#endif + return 1; +} + + int32_t smem_read(StateMem *st, void *buffer, uint32_t len) { if ((len + st->loc) > st->len)