Commit 165bde94 authored by Libretro-Admin's avatar Libretro-Admin
Browse files

Cleanups

parent d3f85250
Pipeline #44244 passed with stage
in 1 minute and 51 seconds
......@@ -35,29 +35,6 @@
namespace Mednafen
{
static INLINE unsigned MDFN_lzcount16_0UD(uint16 v)
{
#if defined(__GNUC__) || defined(__clang__) || defined(__ICC) || defined(__INTEL_COMPILER)
return 15 ^ 31 ^ __builtin_clz(v);
#elif defined(_MSC_VER)
unsigned long idx;
_BitScanReverse(&idx, v);
return 15 ^ idx;
#else
unsigned ret = 0;
unsigned tmp;
tmp = !(v & 0xFF00) << 3; v <<= tmp; ret += tmp;
tmp = !(v & 0xF000) << 2; v <<= tmp; ret += tmp;
tmp = !(v & 0xC000) << 1; v <<= tmp; ret += tmp;
tmp = !(v & 0x8000) << 0; ret += tmp;
return(ret);
#endif
}
static INLINE unsigned MDFN_lzcount32_0UD(uint32 v)
{
#if defined(__GNUC__) || defined(__clang__) || defined(__ICC) || defined(__INTEL_COMPILER)
......@@ -119,98 +96,9 @@ static INLINE unsigned MDFN_lzcount64_0UD(uint64 v)
#endif
}
static INLINE unsigned MDFN_tzcount16_0UD(uint16 v)
{
#if defined(__GNUC__) || defined(__clang__) || defined(__ICC) || defined(__INTEL_COMPILER)
return __builtin_ctz(v);
#elif defined(_MSC_VER)
unsigned long idx;
_BitScanForward(&idx, v);
return idx;
#else
unsigned ret = 0;
unsigned tmp;
tmp = !( (uint8)v) << 3; v >>= tmp; ret += tmp;
tmp = !(v & 0x000F) << 2; v >>= tmp; ret += tmp;
tmp = !(v & 0x0003) << 1; v >>= tmp; ret += tmp;
tmp = !(v & 0x0001) << 0; ret += tmp;
return ret;
#endif
}
static INLINE unsigned MDFN_tzcount32_0UD(uint32 v)
{
#if defined(__GNUC__) || defined(__clang__) || defined(__ICC) || defined(__INTEL_COMPILER)
return __builtin_ctz(v);
#elif defined(_MSC_VER)
unsigned long idx;
_BitScanForward(&idx, v);
return idx;
#else
unsigned ret = 0;
unsigned tmp;
tmp = !((uint16)v) << 4; v >>= tmp; ret += tmp;
tmp = !( (uint8)v) << 3; v >>= tmp; ret += tmp;
tmp = !(v & 0x000F) << 2; v >>= tmp; ret += tmp;
tmp = !(v & 0x0003) << 1; v >>= tmp; ret += tmp;
tmp = !(v & 0x0001) << 0; ret += tmp;
return ret;
#endif
}
static INLINE unsigned MDFN_tzcount64_0UD(uint64 v)
{
#if defined(__GNUC__) || defined(__clang__) || defined(__ICC) || defined(__INTEL_COMPILER)
return __builtin_ctzll(v);
#elif defined(_MSC_VER)
#if defined(_WIN64)
unsigned long idx;
_BitScanForward64(&idx, v);
return idx;
#else
unsigned long idx0, idx1;
_BitScanForward(&idx1, v >> 32);
idx1 += 32;
if(!_BitScanForward(&idx0, v))
idx0 = idx1;
return idx0;
#endif
#else
unsigned ret = 0;
unsigned tmp;
tmp = !((uint32)v) << 5; v >>= tmp; ret += tmp;
tmp = !((uint16)v) << 4; v >>= tmp; ret += tmp;
tmp = !( (uint8)v) << 3; v >>= tmp; ret += tmp;
tmp = !(v & 0x000F) << 2; v >>= tmp; ret += tmp;
tmp = !(v & 0x0003) << 1; v >>= tmp; ret += tmp;
tmp = !(v & 0x0001) << 0; ret += tmp;
return ret;
#endif
}
//
// Result is defined for all possible inputs(including 0).
//
static INLINE unsigned MDFN_lzcount16(uint16 v) { return !v ? 16 : MDFN_lzcount16_0UD(v); }
static INLINE unsigned MDFN_lzcount32(uint32 v) { return !v ? 32 : MDFN_lzcount32_0UD(v); }
static INLINE unsigned MDFN_lzcount64(uint64 v) { return !v ? 64 : MDFN_lzcount64_0UD(v); }
static INLINE unsigned MDFN_tzcount16(uint16 v) { return !v ? 16 : MDFN_tzcount16_0UD(v); }
static INLINE unsigned MDFN_tzcount32(uint32 v) { return !v ? 32 : MDFN_tzcount32_0UD(v); }
static INLINE unsigned MDFN_tzcount64(uint64 v) { return !v ? 64 : MDFN_tzcount64_0UD(v); }
static INLINE unsigned MDFN_log2(uint32 v) { return 31 ^ MDFN_lzcount32_0UD(v | 1); }
static INLINE unsigned MDFN_log2(uint64 v) { return 63 ^ MDFN_lzcount64_0UD(v | 1); }
......@@ -225,13 +113,6 @@ static INLINE uint64 round_up_pow2(uint64 v) { uint64 tmp = (uint64)1 << MDFN_lo
static INLINE uint64 round_up_pow2(int32 v) { return round_up_pow2((uint32)v); }
static INLINE uint64 round_up_pow2(int64 v) { return round_up_pow2((uint64)v); }
// Rounds to the nearest power of 2(treats input as unsigned to a degree, but be aware of integer promotion rules).
static INLINE uint64 round_nearest_pow2(uint32 v, bool round_half_up = true) { uint64 tmp = (uint64)1 << MDFN_log2(v); return tmp << (v && (((v - tmp) << 1) >= (tmp + !round_half_up))); }
static INLINE uint64 round_nearest_pow2(uint64 v, bool round_half_up = true) { uint64 tmp = (uint64)1 << MDFN_log2(v); return tmp << (v && (((v - tmp) << 1) >= (tmp + !round_half_up))); }
static INLINE uint64 round_nearest_pow2(int32 v, bool round_half_up = true) { return round_nearest_pow2((uint32)v, round_half_up); }
static INLINE uint64 round_nearest_pow2(int64 v, bool round_half_up = true) { return round_nearest_pow2((uint64)v, round_half_up); }
// Some compilers' optimizers and some platforms might fubar the generated code from these macros,
// so some tests are run in...tests.cpp
#define sign_8_to_s16(_value) ((int16)(int8)(_value))
......
......@@ -95,33 +95,7 @@ void MDFNI_CloseGame(void)
}
#ifdef WANT_APPLE2_EMU
extern MDFNGI EmulatedApple2;
#endif
#ifdef WANT_NES_NEW_EMU
extern MDFNGI EmulatedNES_New;
#endif
#ifdef WANT_SNES_FAUST_EMU
extern MDFNGI EmulatedSNES_Faust;
#endif
#ifdef WANT_PCE_EMU
extern MDFNGI EmulatedPCE;
#endif
#ifdef WANT_PCE_FAST_EMU
extern MDFNGI EmulatedPCE_Fast;
#endif
#ifdef WANT_SSFPLAY_EMU
extern MDFNGI EmulatedSSFPlay;
#endif
#ifdef WANT_VB_EMU
extern MDFNGI EmulatedVB;
#endif
namespace Mednafen
{
......@@ -237,33 +211,7 @@ static bool InitializeModules(void)
{
static MDFNGI *InternalSystems[] =
{
#ifdef WANT_APPLE2_EMU
&EmulatedApple2,
#endif
#ifdef WANT_NES_NEW_EMU
&EmulatedNES_New,
#endif
#ifdef WANT_SNES_FAUST_EMU
&EmulatedSNES_Faust,
#endif
#ifdef WANT_PCE_EMU
&EmulatedPCE,
#endif
#ifdef WANT_PCE_FAST_EMU
&EmulatedPCE_Fast,
#endif
#ifdef WANT_SSFPLAY_EMU
&EmulatedSSFPlay,
#endif
#ifdef WANT_VB_EMU
&EmulatedVB,
#endif
};
for(unsigned int i = 0; i < sizeof(InternalSystems) / sizeof(MDFNGI *); i++)
AddSystem(InternalSystems[i]);
......@@ -369,31 +317,6 @@ void MDFNI_Emulate(EmulateSpecStruct *espec)
MDFNGameInfo->Emulate(espec);
//
// Sanity checks
//
if(!espec->skip)
{
if(espec->DisplayRect.h == 0)
{
fprintf(stderr, "[BUG] espec->DisplayRect.h == 0\n");
}
}
if(!espec->MasterCycles)
{
fprintf(stderr, "[BUG] espec->MasterCycles == 0\n");
}
if(espec->MasterCycles < espec->MasterCyclesALMS)
{
fprintf(stderr, "[BUG] espec->MasterCycles < espec->MasterCyclesALMS\n");
}
//
//
//
if(espec->InterlaceOn)
{
if(!PrevInterlaced)
......
......@@ -29,7 +29,6 @@
#include "cart/sa1.h"
#include "cart/superfx.h"
#include <mednafen/general.h>
#include <mednafen/FileStream.h>
#include <mednafen/hash/sha1.h>
......
......@@ -2,12 +2,5 @@
#define __MDFN_VIDEO_H
#include "video/surface.h"
//#include "video/primitives.h"
//#include "video/text.h"
namespace Mednafen
{
//void MDFN_InitFontData(void) MDFN_COLD;
}
#endif
#include <mednafen/mednafen.h>
//#include <mednafen/video.h>
//#include <mednafen/general.h>
//#include <mednafen/driver.h>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment