# HG changeset patch # User Matti Hamalainen # Date 1375728813 -10800 # Node ID 1db62040204eb70000ee6d8c1aaa82ce18654d0e # Parent bef14a3387a1921ea31c55efd908329427c41352 Combine some headers to single mplatform.h diff -r bef14a3387a1 -r 1db62040204e src/main.c --- a/src/main.c Mon Aug 05 20:53:49 2013 +0300 +++ b/src/main.c Mon Aug 05 21:53:33 2013 +0300 @@ -9,26 +9,30 @@ #include #include +#include "bass.h" +#include "mplatform.h" + #include "freetype-gl.h" #include "vertex-buffer.h" #include "markup.h" #include "shader.h" #include "mat4.h" -#if defined(_WIN32) || defined(_WIN64) -# define wcpncpy wcsncpy -# define wcpcpy wcscpy -#endif - -#ifndef __APPLE__ -#include -#endif - -#define XXX 1 -#include "bass.h" #include "midifile.h" #include "midiutil.h" +#ifdef __APPLE__ + #include "glew.h" + #include + #include + #include "freeglut.h" +#else + #include + #include + #include +#endif + + int quitflag = 0; // GLUT window handle (1 for windowed display, 0 for fullscreen gamemode) @@ -73,24 +77,13 @@ float vhsbeat = 0.0; float vhsbeat_start = 0; -#ifdef __APPLE__ - #include "glew.h" - #include - #include - #include "freeglut.h" -#else - #include - #include - #include -#endif - #include -//#include #include #include #include #include + #include "stb_image.c" diff -r bef14a3387a1 -r 1db62040204e src/mendian.h --- a/src/mendian.h Mon Aug 05 20:53:49 2013 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -#ifndef MENDIAN_H -#define MENDIAN_H 1 - -#include "mtypes.h" - -/* Endianess swapping macros - */ -#define DM_SWAP_16_LE_BE(value) ((Uint16) ( \ - (Uint16) ((Uint16) (value) >> 8) | \ - (Uint16) ((Uint16) (value) << 8)) ) - - -#define DM_SWAP_32_LE_BE(value) ((Uint32) ( \ - (((Uint32) (value) & (Uint32) 0x000000ffU) << 24) | \ - (((Uint32) (value) & (Uint32) 0x0000ff00U) << 8) | \ - (((Uint32) (value) & (Uint32) 0x00ff0000U) >> 8) | \ - (((Uint32) (value) & (Uint32) 0xff000000U) >> 24))) - - -/* Macros that swap only when needed ... - */ -#if (BYTEORDER == BIG_ENDIAN) -# define DM_LE16_TO_NATIVE(value) DM_SWAP_16_LE_BE(value) -# define DM_LE32_TO_NATIVE(value) DM_SWAP_32_LE_BE(value) -# define DM_NATIVE_TO_LE16(value) DM_SWAP_16_LE_BE(value) -# define DM_NATIVE_TO_LE32(value) DM_SWAP_32_LE_BE(value) - -# define DM_BE16_TO_NATIVE(value) ((Uint16) (value)) -# define DM_BE32_TO_NATIVE(value) ((Uint32) (value)) -# define DM_NATIVE_TO_BE16(value) ((Uint16) (value)) -# define DM_NATIVE_TO_BE32(value) ((Uint32) (value)) - -#elif (BYTEORDER == LIL_ENDIAN) - -# define DM_LE16_TO_NATIVE(value) ((Uint16) (value)) -# define DM_LE32_TO_NATIVE(value) ((Uint32) (value)) -# define DM_NATIVE_TO_LE16(value) ((Uint16) (value)) -# define DM_NATIVE_TO_LE32(value) ((Uint32) (value)) - -# define DM_BE16_TO_NATIVE(value) DM_SWAP_16_LE_BE(value) -# define DM_BE32_TO_NATIVE(value) DM_SWAP_32_LE_BE(value) -# define DM_NATIVE_TO_BE16(value) DM_SWAP_16_LE_BE(value) -# define DM_NATIVE_TO_BE32(value) DM_SWAP_32_LE_BE(value) - -#endif - - -#endif diff -r bef14a3387a1 -r 1db62040204e src/midifile.c --- a/src/midifile.c Mon Aug 05 20:53:49 2013 +0300 +++ b/src/midifile.c Mon Aug 05 21:53:33 2013 +0300 @@ -21,15 +21,12 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "mplatform.h" #include #include #include #include -#ifndef __APPLE__ -#include -#endif #include "midifile.h" -#include "mendian.h" /* diff -r bef14a3387a1 -r 1db62040204e src/midifile.h --- a/src/midifile.h Mon Aug 05 20:53:49 2013 +0300 +++ b/src/midifile.h Mon Aug 05 21:53:33 2013 +0300 @@ -2,7 +2,7 @@ #define _MIDIFILE_H #include "midiinfo.h" /* enumerations and constants for GM */ -#include "mtypes.h" +#include "mplatform.h" /* diff -r bef14a3387a1 -r 1db62040204e src/mplatform.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/mplatform.h Mon Aug 05 21:53:33 2013 +0300 @@ -0,0 +1,91 @@ +#ifndef MPLATFORM_H +#define MPLATFORM_H 1 + + +/* Some platform specifics + */ +#if defined(_WIN32) || defined(_WIN64) +# define wcpncpy wcsncpy +# define wcpcpy wcscpy +#endif + +#ifndef __APPLE__ +#include +#endif + + +/* Sized integer types + */ +#ifdef _WIN32 +#include +typedef unsigned __int8 Uint8; +typedef unsigned __int16 Uint16; +typedef unsigned __int32 Uint32; +typedef unsigned __int64 Uint64; +#else +#include +typedef uint8_t Uint8; +typedef uint16_t Uint16; +typedef uint32_t Uint32; +typedef uint64_t Uint64; +#endif + + +/* Define a boolean type + */ +#if !defined(FALSE) && !defined(TRUE) && !defined(BOOL) +typedef enum { FALSE = 0, TRUE = 1 } BOOL; +#endif + +#ifndef BOOL +# ifdef bool +# define BOOL bool +# else +# define BOOL int +# endif +#endif + + +/* Endianess swapping macros + */ +#define DM_SWAP_16_LE_BE(value) ((Uint16) ( \ + (Uint16) ((Uint16) (value) >> 8) | \ + (Uint16) ((Uint16) (value) << 8)) ) + + +#define DM_SWAP_32_LE_BE(value) ((Uint32) ( \ + (((Uint32) (value) & (Uint32) 0x000000ffU) << 24) | \ + (((Uint32) (value) & (Uint32) 0x0000ff00U) << 8) | \ + (((Uint32) (value) & (Uint32) 0x00ff0000U) >> 8) | \ + (((Uint32) (value) & (Uint32) 0xff000000U) >> 24))) + + +/* Macros that swap only when needed ... + */ +#if (BYTEORDER == BIG_ENDIAN) +# define DM_LE16_TO_NATIVE(value) DM_SWAP_16_LE_BE(value) +# define DM_LE32_TO_NATIVE(value) DM_SWAP_32_LE_BE(value) +# define DM_NATIVE_TO_LE16(value) DM_SWAP_16_LE_BE(value) +# define DM_NATIVE_TO_LE32(value) DM_SWAP_32_LE_BE(value) + +# define DM_BE16_TO_NATIVE(value) ((Uint16) (value)) +# define DM_BE32_TO_NATIVE(value) ((Uint32) (value)) +# define DM_NATIVE_TO_BE16(value) ((Uint16) (value)) +# define DM_NATIVE_TO_BE32(value) ((Uint32) (value)) + +#elif (BYTEORDER == LIL_ENDIAN) + +# define DM_LE16_TO_NATIVE(value) ((Uint16) (value)) +# define DM_LE32_TO_NATIVE(value) ((Uint32) (value)) +# define DM_NATIVE_TO_LE16(value) ((Uint16) (value)) +# define DM_NATIVE_TO_LE32(value) ((Uint32) (value)) + +# define DM_BE16_TO_NATIVE(value) DM_SWAP_16_LE_BE(value) +# define DM_BE32_TO_NATIVE(value) DM_SWAP_32_LE_BE(value) +# define DM_NATIVE_TO_BE16(value) DM_SWAP_16_LE_BE(value) +# define DM_NATIVE_TO_BE32(value) DM_SWAP_32_LE_BE(value) + +#endif + + +#endif // MPLATFORM_H diff -r bef14a3387a1 -r 1db62040204e src/mtypes.h --- a/src/mtypes.h Mon Aug 05 20:53:49 2013 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -#ifndef MTYPES_H -#define MTYPES_H 1 - - -typedef unsigned char Uint8; -typedef unsigned short Uint16; -typedef unsigned int Uint32; - - -/* Define a boolean type - */ -#if !defined(FALSE) && !defined(TRUE) && !defined(BOOL) -typedef enum { FALSE = 0, TRUE = 1 } BOOL; -#endif - -#ifndef BOOL -# ifdef bool -# define BOOL bool -# else -# define BOOL int -# endif -#endif - - -#endif