2010-08-09 13:28:56 +00:00
|
|
|
#ifndef NALL_PLATFORM_HPP
|
|
|
|
#define NALL_PLATFORM_HPP
|
|
|
|
|
Update to v093r02 release.
byuu says:
Changelog:
- nall: fixed major memory leak in string class
- ruby: video shaders support #define-based settings now
- phoenix/GTK+: support > 256x256 icons for window / task bar / alt-tab
- sfc: remove random/ and config/, merge into system/
- ethos: delete higan.png (48x48), replace with higan512.png (512x512)
as new higan.png
- ethos: default gamma to 100% (no color adjustment)
- ethos: use "Video Shaders/Display Emulation/" instead of "Video
Shaders/Emulation/"
- use g++ instead of g++-4.7 (g++ -v must be >= 4.7)
- use -std=c++11 instead of -std=gnu++11
- applied a few patches from Debian upstream to make their packaging job
easier
So because colors are normalized in GLSL, I won't be able to offer video
shaders absolute color literals. We will have to perform basic color
conversion inside the core.
As such, the current plan is to create some sort of Emulator::Settings
interface. With that, I'll connect an option for color correction, which
will be on by default. For FC/SFC, that will mean gamma correction
(darker / stronger colors), and for GB/GBC/GBA, it will mean simulating
the weird brightness levels of the displays. I am undecided on whether
to use pea soup green for the GB or not. By not doing so, it'll be
easier for the display emulation shader to do it.
2013-11-09 11:45:54 +00:00
|
|
|
namespace Math {
|
|
|
|
static const long double e = 2.71828182845904523536;
|
|
|
|
static const long double Pi = 3.14159265358979323846;
|
|
|
|
}
|
|
|
|
|
2011-06-05 03:45:04 +00:00
|
|
|
#if defined(_WIN32)
|
|
|
|
//minimum version needed for _wstat64, etc
|
|
|
|
#undef __MSVCRT_VERSION__
|
|
|
|
#define __MSVCRT_VERSION__ 0x0601
|
2011-08-06 14:03:52 +00:00
|
|
|
#include <nall/windows/utf8.hpp>
|
2011-06-05 03:45:04 +00:00
|
|
|
#endif
|
|
|
|
|
2010-08-09 13:28:56 +00:00
|
|
|
//=========================
|
|
|
|
//standard platform headers
|
|
|
|
//=========================
|
|
|
|
|
|
|
|
#include <limits>
|
2013-07-29 09:42:45 +00:00
|
|
|
#include <utility>
|
2010-08-09 13:28:56 +00:00
|
|
|
|
|
|
|
#include <assert.h>
|
2013-11-28 10:29:01 +00:00
|
|
|
#include <errno.h>
|
2010-08-09 13:28:56 +00:00
|
|
|
#include <limits.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
2011-06-05 03:45:04 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
2010-08-09 13:28:56 +00:00
|
|
|
#if defined(_WIN32)
|
|
|
|
#include <io.h>
|
|
|
|
#include <direct.h>
|
|
|
|
#include <shlobj.h>
|
2011-06-05 03:45:04 +00:00
|
|
|
#include <wchar.h>
|
2010-08-09 13:28:56 +00:00
|
|
|
#undef interface
|
|
|
|
#define dllexport __declspec(dllexport)
|
|
|
|
#else
|
2014-01-28 10:04:58 +00:00
|
|
|
#include <dlfcn.h>
|
2010-08-09 13:28:56 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <pwd.h>
|
|
|
|
#define dllexport
|
|
|
|
#endif
|
|
|
|
|
Update to v093r02 release.
byuu says:
Changelog:
- nall: fixed major memory leak in string class
- ruby: video shaders support #define-based settings now
- phoenix/GTK+: support > 256x256 icons for window / task bar / alt-tab
- sfc: remove random/ and config/, merge into system/
- ethos: delete higan.png (48x48), replace with higan512.png (512x512)
as new higan.png
- ethos: default gamma to 100% (no color adjustment)
- ethos: use "Video Shaders/Display Emulation/" instead of "Video
Shaders/Emulation/"
- use g++ instead of g++-4.7 (g++ -v must be >= 4.7)
- use -std=c++11 instead of -std=gnu++11
- applied a few patches from Debian upstream to make their packaging job
easier
So because colors are normalized in GLSL, I won't be able to offer video
shaders absolute color literals. We will have to perform basic color
conversion inside the core.
As such, the current plan is to create some sort of Emulator::Settings
interface. With that, I'll connect an option for color correction, which
will be on by default. For FC/SFC, that will mean gamma correction
(darker / stronger colors), and for GB/GBC/GBA, it will mean simulating
the weird brightness levels of the displays. I am undecided on whether
to use pea soup green for the GB or not. By not doing so, it'll be
easier for the display emulation shader to do it.
2013-11-09 11:45:54 +00:00
|
|
|
//==========
|
2010-08-09 13:28:56 +00:00
|
|
|
//Visual C++
|
Update to v093r02 release.
byuu says:
Changelog:
- nall: fixed major memory leak in string class
- ruby: video shaders support #define-based settings now
- phoenix/GTK+: support > 256x256 icons for window / task bar / alt-tab
- sfc: remove random/ and config/, merge into system/
- ethos: delete higan.png (48x48), replace with higan512.png (512x512)
as new higan.png
- ethos: default gamma to 100% (no color adjustment)
- ethos: use "Video Shaders/Display Emulation/" instead of "Video
Shaders/Emulation/"
- use g++ instead of g++-4.7 (g++ -v must be >= 4.7)
- use -std=c++11 instead of -std=gnu++11
- applied a few patches from Debian upstream to make their packaging job
easier
So because colors are normalized in GLSL, I won't be able to offer video
shaders absolute color literals. We will have to perform basic color
conversion inside the core.
As such, the current plan is to create some sort of Emulator::Settings
interface. With that, I'll connect an option for color correction, which
will be on by default. For FC/SFC, that will mean gamma correction
(darker / stronger colors), and for GB/GBC/GBA, it will mean simulating
the weird brightness levels of the displays. I am undecided on whether
to use pea soup green for the GB or not. By not doing so, it'll be
easier for the display emulation shader to do it.
2013-11-09 11:45:54 +00:00
|
|
|
//==========
|
2010-08-09 13:28:56 +00:00
|
|
|
|
|
|
|
#if defined(_MSC_VER)
|
Update to v093r02 release.
byuu says:
Changelog:
- nall: fixed major memory leak in string class
- ruby: video shaders support #define-based settings now
- phoenix/GTK+: support > 256x256 icons for window / task bar / alt-tab
- sfc: remove random/ and config/, merge into system/
- ethos: delete higan.png (48x48), replace with higan512.png (512x512)
as new higan.png
- ethos: default gamma to 100% (no color adjustment)
- ethos: use "Video Shaders/Display Emulation/" instead of "Video
Shaders/Emulation/"
- use g++ instead of g++-4.7 (g++ -v must be >= 4.7)
- use -std=c++11 instead of -std=gnu++11
- applied a few patches from Debian upstream to make their packaging job
easier
So because colors are normalized in GLSL, I won't be able to offer video
shaders absolute color literals. We will have to perform basic color
conversion inside the core.
As such, the current plan is to create some sort of Emulator::Settings
interface. With that, I'll connect an option for color correction, which
will be on by default. For FC/SFC, that will mean gamma correction
(darker / stronger colors), and for GB/GBC/GBA, it will mean simulating
the weird brightness levels of the displays. I am undecided on whether
to use pea soup green for the GB or not. By not doing so, it'll be
easier for the display emulation shader to do it.
2013-11-09 11:45:54 +00:00
|
|
|
#pragma warning(disable:4996) //disable libc "deprecation" warnings
|
2013-04-09 13:31:46 +00:00
|
|
|
#define va_copy(dest, src) ((dest) = (src))
|
2010-08-09 13:28:56 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(_WIN32)
|
2013-12-21 10:45:58 +00:00
|
|
|
__declspec(dllimport) int _fileno(FILE*);
|
Update to v093r02 release.
byuu says:
Changelog:
- nall: fixed major memory leak in string class
- ruby: video shaders support #define-based settings now
- phoenix/GTK+: support > 256x256 icons for window / task bar / alt-tab
- sfc: remove random/ and config/, merge into system/
- ethos: delete higan.png (48x48), replace with higan512.png (512x512)
as new higan.png
- ethos: default gamma to 100% (no color adjustment)
- ethos: use "Video Shaders/Display Emulation/" instead of "Video
Shaders/Emulation/"
- use g++ instead of g++-4.7 (g++ -v must be >= 4.7)
- use -std=c++11 instead of -std=gnu++11
- applied a few patches from Debian upstream to make their packaging job
easier
So because colors are normalized in GLSL, I won't be able to offer video
shaders absolute color literals. We will have to perform basic color
conversion inside the core.
As such, the current plan is to create some sort of Emulator::Settings
interface. With that, I'll connect an option for color correction, which
will be on by default. For FC/SFC, that will mean gamma correction
(darker / stronger colors), and for GB/GBC/GBA, it will mean simulating
the weird brightness levels of the displays. I am undecided on whether
to use pea soup green for the GB or not. By not doing so, it'll be
easier for the display emulation shader to do it.
2013-11-09 11:45:54 +00:00
|
|
|
|
|
|
|
inline int access(const char* path, int amode) { return _waccess(nall::utf16_t(path), amode); }
|
|
|
|
inline int fileno(FILE* stream) { return _fileno(stream); }
|
|
|
|
inline char* getcwd(char* buf, size_t size) { wchar_t wpath[PATH_MAX] = L""; if(!_wgetcwd(wpath, size)) return nullptr; strcpy(buf, nall::utf8_t(wpath)); return buf; }
|
|
|
|
inline int putenv(char* string) { return _wputenv(nall::utf16_t(string)); }
|
|
|
|
inline char* realpath(const char* file_name, char* resolved_name) { wchar_t wfile_name[PATH_MAX] = L""; if(!_wfullpath(wfile_name, nall::utf16_t(file_name), PATH_MAX)) return nullptr; strcpy(resolved_name, nall::utf8_t(wfile_name)); return resolved_name; }
|
|
|
|
inline int rename(const char* oldname, const char* newname) { return _wrename(nall::utf16_t(oldname), nall::utf16_t(newname)); }
|
2012-02-29 12:59:48 +00:00
|
|
|
inline void usleep(unsigned milliseconds) { Sleep(milliseconds / 1000); }
|
2010-08-09 13:28:56 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
//================
|
|
|
|
//inline expansion
|
|
|
|
//================
|
|
|
|
|
2013-04-09 13:31:46 +00:00
|
|
|
#if defined(__clang__) || defined(__GNUC__)
|
2010-08-09 13:28:56 +00:00
|
|
|
#define noinline __attribute__((noinline))
|
|
|
|
#define alwaysinline inline __attribute__((always_inline))
|
|
|
|
#elif defined(_MSC_VER)
|
|
|
|
#define noinline __declspec(noinline)
|
|
|
|
#define alwaysinline inline __forceinline
|
|
|
|
#else
|
|
|
|
#define noinline
|
|
|
|
#define alwaysinline inline
|
|
|
|
#endif
|
|
|
|
|
2013-04-09 13:31:46 +00:00
|
|
|
//===========
|
|
|
|
//unreachable
|
|
|
|
//===========
|
|
|
|
|
|
|
|
#if defined(__clang__) || defined(__GNUC__)
|
|
|
|
#define unreachable __builtin_unreachable()
|
|
|
|
#else
|
|
|
|
#define unreachable throw
|
|
|
|
#endif
|
|
|
|
|
2010-09-22 12:51:52 +00:00
|
|
|
#endif
|