bsnes/nall/intrinsics.hpp
Tim Allen ae5d380d06 Update to v098r11 release.
byuu says:

Changelog:
- fixed nall/path.hpp compilation issue
- fixed ruby/audio/xaudio header declaration compilation issue (again)
- cleaned up xaudio2.hpp file to match my coding syntax (12.5% of the
  file was whitespace overkill)
- added null terminator entry to nall/windows/utf8.hpp argc[] array
- nall/windows/guid.hpp uses the Windows API for generating the GUID
  - this should stop all the bug reports where two nall users were
    generating GUIDs at the exact same second
- fixed hiro/cocoa compilation issue with uint# types
- fixed major higan/sfc Super Game Boy audio latency issue
- fixed higan/sfc CPU core bug with pei, [dp], [dp]+y instructions
- major cleanups to higan/processor/r65816 core
  - merged emulation/native-mode opcodes
  - use camel-case naming on memory.hpp functions
  - simplify address masking code for memory.hpp functions
  - simplify a few opcodes themselves (avoid redundant copies, etc)
  - rename regs.* to r.* to match modern convention of other CPU cores
- removed device.order<> concept from Emulator::Interface
  - cores will now do the translation to make the job of the UI easier
- fixed plurality naming of arrays in Emulator::Interface
  - example: emulator.ports[p].devices[d].inputs[i]
  - example: vector<Medium> media
- probably more surprises

Major show-stoppers to the next official release:
- we need to work on GB core improvements: LY=153/0 case, multiple STAT
  IRQs case, GBC audio output regs, etc.
- we need to re-add software cursors for light guns (Super Scope,
  Justifier)
- after the above, we need to fix the turbo button for the Super Scope

I really have no idea how I want to implement the light guns. Ideally,
we'd want it in higan/video, so we can support the NES Zapper with the
same code. But this isn't going to be easy, because only the SNES knows
when its output is interlaced, and its resolutions can vary as
{256,512}x{224,240,448,480} which requires pixel doubling that was
hard-coded to the SNES-specific behavior, but isn't appropriate to be
exposed in higan/video.
2016-05-25 21:13:02 +10:00

159 lines
5.4 KiB
C++

#pragma once
namespace nall {
using uint = unsigned;
struct Intrinsics {
enum class Compiler : uint { Clang, GCC, VisualCPP, Unknown };
enum class Platform : uint { Windows, MacOSX, Linux, BSD, Unknown };
enum class API : uint { Windows, Posix, Unknown };
enum class Display : uint { Windows, Quartz, Xorg, Unknown };
enum class Processor : uint { x86, amd64, ARM, PPC32, PPC64, Unknown };
enum class Endian : uint { LSB, MSB, Unknown };
static inline auto compiler() -> Compiler;
static inline auto platform() -> Platform;
static inline auto api() -> API;
static inline auto display() -> Display;
static inline auto processor() -> Processor;
static inline auto endian() -> Endian;
};
}
/* Compiler detection */
namespace nall {
#if defined(__clang__)
#define COMPILER_CLANG
auto Intrinsics::compiler() -> Compiler { return Compiler::Clang; }
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma clang diagnostic ignored "-Wempty-body"
#pragma clang diagnostic ignored "-Wparentheses"
#pragma clang diagnostic ignored "-Wreturn-type"
#pragma clang diagnostic ignored "-Wswitch"
#pragma clang diagnostic ignored "-Wswitch-bool"
#pragma clang diagnostic ignored "-Wtautological-compare"
#pragma clang diagnostic ignored "-Wabsolute-value"
//temporary
#pragma clang diagnostic ignored "-Winconsistent-missing-override"
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#elif defined(__GNUC__)
#define COMPILER_GCC
auto Intrinsics::compiler() -> Compiler { return Compiler::GCC; }
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
#pragma GCC diagnostic ignored "-Wpragmas"
#pragma GCC diagnostic ignored "-Wswitch-bool"
#elif defined(_MSC_VER)
#define COMPILER_VISUALCPP
auto Intrinsics::compiler() -> Compiler { return Compiler::VisualCPP; }
#pragma warning(disable:4996) //libc "deprecation" warnings
#else
#warning "unable to detect compiler"
#define COMPILER_UNKNOWN
auto Intrinsics::compiler() -> Compiler { return Compiler::Unknown; }
#endif
}
/* Platform detection */
namespace nall {
#if defined(_WIN32)
#define PLATFORM_WINDOWS
#define API_WINDOWS
#define DISPLAY_WINDOWS
auto Intrinsics::platform() -> Platform { return Platform::Windows; }
auto Intrinsics::api() -> API { return API::Windows; }
auto Intrinsics::display() -> Display { return Display::Windows; }
#elif defined(__APPLE__)
#define PLATFORM_MACOSX
#define API_POSIX
#define DISPLAY_QUARTZ
auto Intrinsics::platform() -> Platform { return Platform::MacOSX; }
auto Intrinsics::api() -> API { return API::Posix; }
auto Intrinsics::display() -> Display { return Display::Quartz; }
#elif defined(linux) || defined(__linux__)
#define PLATFORM_LINUX
#define API_POSIX
#define DISPLAY_XORG
auto Intrinsics::platform() -> Platform { return Platform::Linux; }
auto Intrinsics::api() -> API { return API::Posix; }
auto Intrinsics::display() -> Display { return Display::Xorg; }
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__)
#define PLATFORM_BSD
#define API_POSIX
#define DISPLAY_XORG
auto Intrinsics::platform() -> Platform { return Platform::BSD; }
auto Intrinsics::api() -> API { return API::Posix; }
auto Intrinsics::display() -> Display { return Display::Xorg; }
#else
#warning "unable to detect platform"
#define PLATFORM_UNKNOWN
#define API_UNKNOWN
#define DISPLAY_UNKNOWN
auto Intrinsics::platform() -> Platform { return Platform::Unknown; }
auto Intrinsics::api() -> API { return API::Unknown; }
auto Intrinsics::display() -> Display { return Display::Unknown; }
#endif
}
#if defined(PLATFORM_MACOSX)
#include <machine/endian.h>
#elif defined(PLATFORM_LINUX)
#include <endian.h>
#elif defined(PLATFORM_BSD)
#include <sys/endian.h>
#endif
/* Processor Detection */
namespace nall {
#if defined(__i386__) || defined(_M_IX86)
#define PROCESSOR_X86
auto Intrinsics::processor() -> Processor { return Processor::x86; }
#elif defined(__amd64__) || defined(_M_AMD64)
#define PROCESSOR_AMD64
auto Intrinsics::processor() -> Processor { return Processor::amd64; }
#elif defined(__arm__)
#define PROCESSOR_ARM
auto Intrinsics::processor() -> Processor { return Processor::ARM; }
#elif defined(__ppc64__) || defined(_ARCH_PPC64)
#define PROCESSOR_PPC64
auto Intrinsics::processor() -> Processor { return Processor::PPC64; }
#elif defined(__ppc__) || defined(_ARCH_PPC) || defined(_M_PPC)
#define PROCESSOR_PPC32
auto Intrinsics::processor() -> Processor { return Processor::PPC32; }
#else
#warning "unable to detect processor"
#define PROCESSOR_UNKNOWN
auto Intrinsics::processor() -> Processor { return Processor::Unknown; }
#endif
}
/* Endian detection */
namespace nall {
#if (defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && __BYTE_ORDER == __LITTLE_ENDIAN) || defined(__LITTLE_ENDIAN__) || defined(__i386__) || defined(__amd64__) || defined(_M_IX86) || defined(_M_AMD64)
#define ENDIAN_LSB
auto Intrinsics::endian() -> Endian { return Endian::LSB; }
#elif (defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && __BYTE_ORDER == __BIG_ENDIAN) || defined(__BIG_ENDIAN__) || defined(__powerpc__) || defined(_M_PPC)
#define ENDIAN_MSB
auto Intrinsics::endian() -> Endian { return Endian::MSB; }
#else
#warning "unable to detect endian"
#define ENDIAN_UNKNOWN
auto Intrinsics::endian() -> Endian { return Endian::Unknown; }
#endif
}