This commit is contained in:
twinaphex 2020-10-05 23:30:44 +02:00
parent 98d3f33481
commit 5d97808f18
26 changed files with 129 additions and 135 deletions

View File

@ -17,14 +17,12 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mednafen.h"
#include "Stream.h"
#include "FileStream.h"
#include <stdarg.h>
#include <string.h>
#include "Stream.h"
#include "FileStream.h"
FileStream::FileStream(const char *path, const int mode)
{
fp = filestream_open(path, (mode == MODE_WRITE) ? RETRO_VFS_FILE_ACCESS_WRITE : RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE);

View File

@ -7,6 +7,24 @@
#endif
#endif
// Source: http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
// Rounds up to the nearest power of 2.
static INLINE uint32 round_up_pow2(uint32 v)
{
v--;
v |= v >> 1;
v |= v >> 2;
v |= v >> 4;
v |= v >> 8;
v |= v >> 16;
v++;
v += (v == 0);
return(v);
}
/*
TODO:
Write and Seek expansion that fail should not corrupt the state.

View File

@ -17,7 +17,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mednafen.h"
#include "Stream.h"
Stream::Stream()

View File

@ -5,12 +5,13 @@
// TODO?: BufferedStream, no virtual functions, yes inline functions, constructor takes a Stream* argument.
#include "mednafen.h"
#include <errno.h>
#include <stdio.h> // For SEEK_* defines, which we will use in Stream out of FORCE OF HABIT.
#include <string>
#include "mednafen-types.h"
#define MODE_READ 0
#define MODE_WRITE 1
#define MODE_WRITE_SAFE 2

View File

@ -25,7 +25,6 @@
// Don't allow exceptions to propagate into the vorbis/musepack/etc. libraries, as it could easily leave the state of the library's decoder "object" in an
// inconsistent state, which would cause all sorts of unfun when we try to destroy it while handling the exception farther up.
#include <mednafen/mednafen.h>
#include "CDAFReader.h"
#include "CDAFReader_Vorbis.h"
#ifdef HAVE_MPC

View File

@ -22,7 +22,7 @@
#ifndef __MDFN_CDAFREADER_H
#define __MDFN_CDAFREADER_H
#include <mednafen/Stream.h>
#include "../Stream.h"
class CDAFReader
{

View File

@ -19,11 +19,10 @@
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <mednafen/mednafen.h>
#include "CDAFReader.h"
#include "CDAFReader_MPC.h"
#include <mednafen/mpcdec/mpcdec.h>
#include "../mpcdec/mpcdec.h"
class CDAFReader_MPC : public CDAFReader
{

View File

@ -18,12 +18,12 @@
** along with this program; if not, write to the Free Software Foundation, Inc.,
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <string.h>
#include <mednafen/mednafen.h>
#include "CDAFReader.h"
#include "CDAFReader_Vorbis.h"
#include <mednafen/tremor/ivorbisfile.h>
#include "../tremor/ivorbisfile.h"
class CDAFReader_Vorbis : public CDAFReader
{

View File

@ -15,7 +15,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "../mednafen.h"
#include "CDAccess.h"
#include "CDAccess_Image.h"
#include "CDAccess_CCD.h"

View File

@ -19,8 +19,9 @@
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <mednafen/mednafen.h>
#include <mednafen/general.h>
#include "../mednafen-types.h"
#include "../git.h"
#include "../general.h"
#include "CDAccess_CCD.h"

View File

@ -19,8 +19,8 @@
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <mednafen/FileStream.h>
#include <mednafen/MemoryStream.h>
#include "../FileStream.h"
#include "../MemoryStream.h"
#include "CDAccess.h"

View File

@ -19,8 +19,9 @@
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "../mednafen.h"
#include "../mednafen-types.h"
#include "../mednafen-endian.h"
#include "../git.h"
#include "../general.h"
#include "CDAccess_CHD.h"

View File

@ -19,8 +19,8 @@
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <mednafen/FileStream.h>
#include <mednafen/MemoryStream.h>
#include "../FileStream.h"
#include "../MemoryStream.h"
#include "CDAccess.h"
#include "chd.h"

View File

@ -28,8 +28,6 @@
it will be added onto the implicit default 00:02:00 of pregap.
*/
#include "../mednafen.h"
#include <stdint.h>
#include <string.h>
@ -37,7 +35,9 @@
#include <time.h>
#include <memory>
#include "../mednafen-types.h"
#include "../general.h"
#include "../git.h"
#include "../mednafen-endian.h"
#include "../FileStream.h"
#include "../MemoryStream.h"

View File

@ -17,7 +17,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "../mednafen.h"
#include "CDUtility.h"
#include "dvdisaster.h"
#include "lec.h"

View File

@ -1,6 +1,9 @@
#ifndef __MDFN_CDROM_CDUTILITY_H
#define __MDFN_CDROM_CDUTILITY_H
#include <stdint.h>
#include <string.h>
// Call once at app startup before creating any threads that could potentially cause re-entrancy to these functions.
// It will also be called automatically if needed for the first time a function in this namespace that requires
// the initialization function to be called is called, for potential

View File

@ -15,15 +15,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "../mednafen.h"
#include <stdint.h>
#include <string.h>
#include <sys/types.h>
#include "cdromif.h"
#include "CDAccess.h"
#include <boolean.h>
#include <retro_miscellaneous.h>
#include "cdromif.h"
#include "CDAccess.h"
#include "../mednafen.h"
typedef struct
{
bool valid;

View File

@ -18,11 +18,11 @@
#ifndef __MDFN_CDROM_CDROMIF_H
#define __MDFN_CDROM_CDROMIF_H
#include "CDUtility.h"
#include <mednafen/Stream.h>
#include <queue>
#include "CDUtility.h"
#include "../Stream.h"
class CDIF
{
public:

View File

@ -15,7 +15,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <mednafen/mednafen.h>
#include <math.h>
#include <algorithm>
#include "scsicd.h"

View File

@ -15,8 +15,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mednafen.h"
#include <string.h>
#include <stdarg.h>
@ -35,54 +33,50 @@ void MDFN_GetFilePathComponents(const std::string &file_path,
std::string *dir_path_out, std::string *file_base_out,
std::string *file_ext_out)
{
size_t final_ds; // in file_path
string file_name;
size_t fn_final_dot; // in local var file_name
string dir_path, file_base, file_ext; // Temporary output
string file_name;
size_t fn_final_dot; // in local var file_name
string dir_path, file_base, file_ext; // Temporary output
#ifdef _WIN32
final_ds = file_path.find_last_of('\\');
size_t alt_final_ds = file_path.find_last_of('/');
if(final_ds == string::npos || (alt_final_ds != string::npos && alt_final_ds > final_ds))
final_ds = alt_final_ds;
size_t final_ds = file_path.find_last_of('\\');
size_t alt_final_ds = file_path.find_last_of('/');
if(final_ds == string::npos || (alt_final_ds != string::npos && alt_final_ds > final_ds))
final_ds = alt_final_ds;
#else
final_ds = file_path.find_last_of('/');
size_t final_ds = file_path.find_last_of('/');
#endif
if(final_ds == string::npos)
{
dir_path = string(".");
file_name = file_path;
}
else
{
dir_path = file_path.substr(0, final_ds);
file_name = file_path.substr(final_ds + 1);
}
if(final_ds == string::npos)
{
dir_path = string(".");
file_name = file_path;
}
else
{
dir_path = file_path.substr(0, final_ds);
file_name = file_path.substr(final_ds + 1);
}
fn_final_dot = file_name.find_last_of('.');
fn_final_dot = file_name.find_last_of('.');
if(fn_final_dot != string::npos)
{
file_base = file_name.substr(0, fn_final_dot);
file_ext = file_name.substr(fn_final_dot);
}
else
{
file_base = file_name;
file_ext = string("");
}
if(fn_final_dot != string::npos)
{
file_base = file_name.substr(0, fn_final_dot);
file_ext = file_name.substr(fn_final_dot);
}
else
{
file_base = file_name;
file_ext = string("");
}
if(dir_path_out)
*dir_path_out = dir_path;
if(dir_path_out)
*dir_path_out = dir_path;
if(file_base_out)
*file_base_out = file_base;
if(file_base_out)
*file_base_out = file_base;
if(file_ext_out)
*file_ext_out = file_ext;
if(file_ext_out)
*file_ext_out = file_ext;
}
std::string MDFN_EvalFIP(const std::string &dir_path, const std::string &rel_path, bool skip_safety_check)
@ -101,58 +95,53 @@ std::string MDFN_EvalFIP(const std::string &dir_path, const std::string &rel_pat
// Remove whitespace from beginning of string
void MDFN_ltrim(std::string &string)
{
size_t len = string.length();
size_t di, si;
bool InWhitespace = TRUE;
size_t len = string.length();
size_t si;
bool InWhitespace = true;
size_t di = si = 0;
di = si = 0;
while(si < len)
{
if(InWhitespace && (string[si] == ' ' || string[si] == '\r' || string[si] == '\n' || string[si] == '\t' || string[si] == 0x0b)) { }
else
{
InWhitespace = false;
string[di] = string[si];
di++;
}
si++;
}
while(si < len)
{
if(InWhitespace && (string[si] == ' ' || string[si] == '\r' || string[si] == '\n' || string[si] == '\t' || string[si] == 0x0b))
{
}
else
{
InWhitespace = FALSE;
string[di] = string[si];
di++;
}
si++;
}
string.resize(di);
string.resize(di);
}
// Remove whitespace from end of string
void MDFN_rtrim(std::string &string)
{
size_t len = string.length();
size_t len = string.length();
if(len)
{
size_t x = len;
size_t new_len = len;
if(len)
{
size_t x = len;
size_t new_len = len;
do
{
x--;
do
{
x--;
if(!(string[x] == ' ' || string[x] == '\r' || string[x] == '\n' || string[x] == '\t' || string[x] == 0x0b))
break;
new_len--;
} while(x);
if(!(string[x] == ' ' || string[x] == '\r' || string[x] == '\n' || string[x] == '\t' || string[x] == 0x0b))
break;
string.resize(new_len);
}
new_len--;
} while(x);
string.resize(new_len);
}
}
void MDFN_trim(std::string &string)
{
MDFN_rtrim(string);
MDFN_ltrim(string);
MDFN_rtrim(string);
MDFN_ltrim(string);
}

View File

@ -324,23 +324,6 @@ typedef struct
double mouse_sensitivity;
} MDFNGI;
// Source: http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
// Rounds up to the nearest power of 2.
static INLINE uint32 round_up_pow2(uint32 v)
{
v--;
v |= v >> 1;
v |= v >> 2;
v |= v >> 4;
v |= v >> 8;
v |= v >> 16;
v++;
v += (v == 0);
return(v);
}
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -21,7 +21,8 @@
#include <errno.h>
#include <string.h>
#include "../../mednafen.h"
#include "../../mednafen-types.h"
#include "../../state.h"
#include "../../state_helpers.h"
#include "arcade_card.h"

View File

@ -15,13 +15,12 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mednafen.h"
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <vector>
#include "mednafen.h"
#include "general.h"
#include "mempatcher.h"

View File

@ -14,11 +14,11 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mednafen.h"
#include "okiadpcm.h"
#include <math.h>
#include "mednafen-types.h"
#include "okiadpcm.h"
const int OKIADPCM_StepSizes[49] =
{
// These can also be generated like:

View File

@ -23,7 +23,10 @@
PCE_FAST(less accurate, faster, etc.) fork from PCE module "pcecd.cpp".
*/
#include "../mednafen.h"
#include <string.h>
#include "../mednafen-types.h"
#include "../state.h"
#include "../okiadpcm.h"
#include "../cdrom/SimpleFIFO.h"
#include "../state_helpers.h"

View File

@ -18,7 +18,8 @@
#include <string.h>
#include <math.h>
#include "../mednafen.h"
#include "../mednafen-types.h"
#include "../state.h"
#include "../state_helpers.h"
#include "psg.h"