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 * 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 <stdarg.h>
#include <string.h> #include <string.h>
#include "Stream.h"
#include "FileStream.h"
FileStream::FileStream(const char *path, const int mode) 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); 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
#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: TODO:
Write and Seek expansion that fail should not corrupt the state. 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 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "mednafen.h"
#include "Stream.h" #include "Stream.h"
Stream::Stream() Stream::Stream()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,9 @@
#ifndef __MDFN_CDROM_CDUTILITY_H #ifndef __MDFN_CDROM_CDUTILITY_H
#define __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. // 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 // 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 // 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 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "../mednafen.h" #include <stdint.h>
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include "cdromif.h"
#include "CDAccess.h"
#include <boolean.h> #include <boolean.h>
#include <retro_miscellaneous.h> #include <retro_miscellaneous.h>
#include "cdromif.h"
#include "CDAccess.h"
#include "../mednafen.h"
typedef struct typedef struct
{ {
bool valid; bool valid;

View File

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

View File

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

View File

@ -15,8 +15,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "mednafen.h"
#include <string.h> #include <string.h>
#include <stdarg.h> #include <stdarg.h>
@ -35,20 +33,16 @@ void MDFN_GetFilePathComponents(const std::string &file_path,
std::string *dir_path_out, std::string *file_base_out, std::string *dir_path_out, std::string *file_base_out,
std::string *file_ext_out) std::string *file_ext_out)
{ {
size_t final_ds; // in file_path
string file_name; string file_name;
size_t fn_final_dot; // in local var file_name size_t fn_final_dot; // in local var file_name
string dir_path, file_base, file_ext; // Temporary output string dir_path, file_base, file_ext; // Temporary output
#ifdef _WIN32 #ifdef _WIN32
final_ds = file_path.find_last_of('\\'); size_t final_ds = file_path.find_last_of('\\');
size_t alt_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)) if(final_ds == string::npos || (alt_final_ds != string::npos && alt_final_ds > final_ds))
final_ds = alt_final_ds; final_ds = alt_final_ds;
#else #else
final_ds = file_path.find_last_of('/'); size_t final_ds = file_path.find_last_of('/');
#endif #endif
if(final_ds == string::npos) if(final_ds == string::npos)
@ -102,20 +96,16 @@ std::string MDFN_EvalFIP(const std::string &dir_path, const std::string &rel_pat
void MDFN_ltrim(std::string &string) void MDFN_ltrim(std::string &string)
{ {
size_t len = string.length(); size_t len = string.length();
size_t di, si; size_t si;
bool InWhitespace = TRUE; bool InWhitespace = true;
size_t di = si = 0;
di = si = 0;
while(si < len) while(si < len)
{ {
if(InWhitespace && (string[si] == ' ' || string[si] == '\r' || string[si] == '\n' || string[si] == '\t' || string[si] == 0x0b)) if(InWhitespace && (string[si] == ' ' || string[si] == '\r' || string[si] == '\n' || string[si] == '\t' || string[si] == 0x0b)) { }
{
}
else else
{ {
InWhitespace = FALSE; InWhitespace = false;
string[di] = string[si]; string[di] = string[si];
di++; di++;
} }
@ -149,7 +139,6 @@ void MDFN_rtrim(std::string &string)
} }
} }
void MDFN_trim(std::string &string) void MDFN_trim(std::string &string)
{ {
MDFN_rtrim(string); MDFN_rtrim(string);

View File

@ -324,23 +324,6 @@ typedef struct
double mouse_sensitivity; double mouse_sensitivity;
} MDFNGI; } 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 #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif

View File

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

View File

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

View File

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

View File

@ -23,7 +23,10 @@
PCE_FAST(less accurate, faster, etc.) fork from PCE module "pcecd.cpp". 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 "../okiadpcm.h"
#include "../cdrom/SimpleFIFO.h" #include "../cdrom/SimpleFIFO.h"
#include "../state_helpers.h" #include "../state_helpers.h"

View File

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