2018-11-15 23:31:39 +00:00
|
|
|
/*****************************************************************************\
|
|
|
|
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
|
|
|
|
This file is licensed under the Snes9x License.
|
|
|
|
For further information, consult the LICENSE file in the root directory.
|
|
|
|
\*****************************************************************************/
|
2010-09-25 15:46:12 +00:00
|
|
|
|
|
|
|
#ifndef _PORT_H_
|
|
|
|
#define _PORT_H_
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2018-11-18 17:33:18 +00:00
|
|
|
#include <stdarg.h>
|
2010-09-25 15:46:12 +00:00
|
|
|
#include <limits.h>
|
2012-08-27 03:55:59 +00:00
|
|
|
#ifndef __LIBRETRO__
|
2010-09-25 15:46:12 +00:00
|
|
|
#include <memory.h>
|
2012-08-27 03:55:59 +00:00
|
|
|
#endif
|
2010-09-25 15:46:12 +00:00
|
|
|
#include <time.h>
|
|
|
|
#include <string.h>
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
#include <strings.h>
|
|
|
|
#endif
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#ifdef __WIN32__
|
2018-08-16 15:59:47 +00:00
|
|
|
#define NOMINMAX 1
|
2010-09-25 15:46:12 +00:00
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __WIN32__
|
|
|
|
//#define RIGHTSHIFT_IS_SAR
|
|
|
|
#define RIGHTSHIFT_int8_IS_SAR
|
|
|
|
#define RIGHTSHIFT_int16_IS_SAR
|
|
|
|
#define RIGHTSHIFT_int32_IS_SAR
|
2018-05-25 21:56:02 +00:00
|
|
|
#ifndef __LIBRETRO__
|
|
|
|
#endif //__LIBRETRO__
|
|
|
|
#endif
|
|
|
|
|
2010-09-25 15:46:12 +00:00
|
|
|
#ifdef __MACOSX__
|
|
|
|
#define PIXEL_FORMAT RGB555
|
|
|
|
#endif
|
|
|
|
|
2018-04-22 00:17:39 +00:00
|
|
|
#ifndef PIXEL_FORMAT
|
|
|
|
#define PIXEL_FORMAT RGB565
|
|
|
|
#endif
|
|
|
|
|
2019-04-07 16:07:16 +00:00
|
|
|
#if defined(__GNUC__)
|
|
|
|
#define alwaysinline inline __attribute__((always_inline))
|
|
|
|
#elif defined(_MSC_VER)
|
|
|
|
#define alwaysinline __forceinline
|
|
|
|
#else
|
|
|
|
#define alwaysinline inline
|
|
|
|
#endif
|
|
|
|
|
2010-09-25 15:46:12 +00:00
|
|
|
#ifndef snes9x_types_defined
|
|
|
|
#define snes9x_types_defined
|
|
|
|
typedef unsigned char bool8;
|
|
|
|
#ifdef HAVE_STDINT_H
|
|
|
|
#include <stdint.h>
|
|
|
|
typedef intptr_t pint;
|
|
|
|
typedef int8_t int8;
|
|
|
|
typedef uint8_t uint8;
|
|
|
|
typedef int16_t int16;
|
|
|
|
typedef uint16_t uint16;
|
|
|
|
typedef int32_t int32;
|
|
|
|
typedef uint32_t uint32;
|
|
|
|
typedef int64_t int64;
|
|
|
|
typedef uint64_t uint64;
|
|
|
|
#else // HAVE_STDINT_H
|
2010-09-25 16:46:06 +00:00
|
|
|
#ifdef __WIN32__
|
|
|
|
typedef intptr_t pint;
|
2010-09-25 15:46:12 +00:00
|
|
|
typedef signed char int8;
|
|
|
|
typedef unsigned char uint8;
|
|
|
|
typedef signed short int16;
|
|
|
|
typedef unsigned short uint16;
|
2012-01-02 00:48:51 +00:00
|
|
|
typedef signed int int32;
|
2010-09-25 15:46:12 +00:00
|
|
|
typedef unsigned int uint32;
|
|
|
|
typedef signed __int64 int64;
|
|
|
|
typedef unsigned __int64 uint64;
|
2012-01-20 03:24:36 +00:00
|
|
|
typedef int8 int8_t;
|
|
|
|
typedef uint8 uint8_t;
|
|
|
|
typedef int16 int16_t;
|
|
|
|
typedef uint16 uint16_t;
|
|
|
|
typedef int32 int32_t;
|
|
|
|
typedef uint32 uint32_t;
|
|
|
|
typedef int64 int64_t;
|
|
|
|
typedef uint64 uint64_t;
|
2010-09-25 15:46:12 +00:00
|
|
|
typedef int socklen_t;
|
|
|
|
#else // __WIN32__
|
|
|
|
typedef signed char int8;
|
|
|
|
typedef unsigned char uint8;
|
|
|
|
typedef signed short int16;
|
|
|
|
typedef unsigned short uint16;
|
|
|
|
typedef signed int int32;
|
|
|
|
typedef unsigned int uint32;
|
|
|
|
#ifdef __GNUC__
|
|
|
|
// long long is not part of ISO C++
|
|
|
|
__extension__
|
|
|
|
#endif
|
|
|
|
typedef long long int64;
|
|
|
|
typedef unsigned long long uint64;
|
2018-05-25 21:56:02 +00:00
|
|
|
typedef size_t pint;
|
2010-09-25 15:46:12 +00:00
|
|
|
#endif // __WIN32__
|
|
|
|
#endif // HAVE_STDINT_H
|
|
|
|
#endif // snes9x_types_defined
|
|
|
|
|
|
|
|
#ifndef TRUE
|
|
|
|
#define TRUE 1
|
|
|
|
#endif
|
|
|
|
#ifndef FALSE
|
|
|
|
#define FALSE 0
|
|
|
|
#endif
|
|
|
|
|
2023-01-26 23:06:45 +00:00
|
|
|
#ifndef __WIN32__
|
|
|
|
#ifndef PATH_MAX
|
|
|
|
#define PATH_MAX 1024
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
#ifndef PATH_MAX
|
|
|
|
#define PATH_MAX _MAX_PATH
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2022-05-06 21:17:03 +00:00
|
|
|
#include "fscompat.h"
|
2010-09-25 15:46:12 +00:00
|
|
|
|
|
|
|
#define S9xDisplayString DisplayStringFromBottom
|
2023-05-04 20:55:11 +00:00
|
|
|
#ifdef __WIN32__
|
2023-08-08 21:15:49 +00:00
|
|
|
#ifndef snprintf
|
|
|
|
#define snprintf _snprintf
|
|
|
|
#endif
|
|
|
|
#ifndef strcasecmp
|
|
|
|
#define strcasecmp stricmp
|
|
|
|
#endif
|
|
|
|
#ifndef strncasecmp
|
|
|
|
#define strncasecmp strnicmp
|
|
|
|
#endif
|
2012-01-02 00:48:51 +00:00
|
|
|
#endif // __WIN32__
|
2010-09-25 15:46:12 +00:00
|
|
|
|
2016-11-07 19:28:33 +00:00
|
|
|
#if defined(__DJGPP) || defined(__WIN32__)
|
2010-09-25 15:46:12 +00:00
|
|
|
#define SLASH_STR "\\"
|
|
|
|
#define SLASH_CHAR '\\'
|
|
|
|
#else
|
|
|
|
#define SLASH_STR "/"
|
|
|
|
#define SLASH_CHAR '/'
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef TITLE
|
|
|
|
#define TITLE "Snes9x"
|
|
|
|
#endif
|
|
|
|
|
2018-09-27 21:41:04 +00:00
|
|
|
#if defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) || defined(__x86_64__) || defined(__alpha__) || defined(__MIPSEL__) || defined(_M_IX86) || defined(_M_X64) || defined(_XBOX1) || defined(__arm__) || defined(ANDROID) || defined(__aarch64__) || (defined(__BYTE_ORDER__) && __BYTE_ORDER == __ORDER_LITTLE_ENDIAN__)
|
2010-09-25 15:46:12 +00:00
|
|
|
#define LSB_FIRST
|
|
|
|
#define FAST_LSB_WORD_ACCESS
|
|
|
|
#else
|
|
|
|
#define MSB_FIRST
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef FAST_LSB_WORD_ACCESS
|
|
|
|
#define READ_WORD(s) (*(uint16 *) (s))
|
|
|
|
#define READ_3WORD(s) (*(uint32 *) (s) & 0x00ffffff)
|
|
|
|
#define READ_DWORD(s) (*(uint32 *) (s))
|
|
|
|
#define WRITE_WORD(s, d) *(uint16 *) (s) = (d)
|
|
|
|
#define WRITE_3WORD(s, d) *(uint16 *) (s) = (uint16) (d), *((uint8 *) (s) + 2) = (uint8) ((d) >> 16)
|
|
|
|
#define WRITE_DWORD(s, d) *(uint32 *) (s) = (d)
|
|
|
|
#else
|
|
|
|
#define READ_WORD(s) (*(uint8 *) (s) | (*((uint8 *) (s) + 1) << 8))
|
|
|
|
#define READ_3WORD(s) (*(uint8 *) (s) | (*((uint8 *) (s) + 1) << 8) | (*((uint8 *) (s) + 2) << 16))
|
|
|
|
#define READ_DWORD(s) (*(uint8 *) (s) | (*((uint8 *) (s) + 1) << 8) | (*((uint8 *) (s) + 2) << 16) | (*((uint8 *) (s) + 3) << 24))
|
|
|
|
#define WRITE_WORD(s, d) *(uint8 *) (s) = (uint8) (d), *((uint8 *) (s) + 1) = (uint8) ((d) >> 8)
|
|
|
|
#define WRITE_3WORD(s, d) *(uint8 *) (s) = (uint8) (d), *((uint8 *) (s) + 1) = (uint8) ((d) >> 8), *((uint8 *) (s) + 2) = (uint8) ((d) >> 16)
|
|
|
|
#define WRITE_DWORD(s, d) *(uint8 *) (s) = (uint8) (d), *((uint8 *) (s) + 1) = (uint8) ((d) >> 8), *((uint8 *) (s) + 2) = (uint8) ((d) >> 16), *((uint8 *) (s) + 3) = (uint8) ((d) >> 24)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define SWAP_WORD(s) (s) = (((s) & 0xff) << 8) | (((s) & 0xff00) >> 8)
|
|
|
|
#define SWAP_DWORD(s) (s) = (((s) & 0xff) << 24) | (((s) & 0xff00) << 8) | (((s) & 0xff0000) >> 8) | (((s) & 0xff000000) >> 24)
|
|
|
|
|
|
|
|
#include "pixform.h"
|
|
|
|
|
|
|
|
#endif
|