changeset 37:1db62040204e

Combine some headers to single mplatform.h
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 05 Aug 2013 21:53:33 +0300
parents bef14a3387a1
children 217cd6863772
files src/main.c src/mendian.h src/midifile.c src/midifile.h src/mplatform.h src/mtypes.h
diffstat 6 files changed, 109 insertions(+), 101 deletions(-) [+]
line wrap: on
line diff
--- 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 <wchar.h>
 #include <time.h>
 
+#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 <malloc.h>
-#endif
-
-#define XXX 1
-#include "bass.h"
 #include "midifile.h"
 #include "midiutil.h"
 
+#ifdef __APPLE__
+    #include "glew.h"
+    #include <OpenGL/OpenGL.h>
+    #include <OpenGL/glu.h>
+    #include "freeglut.h"
+#else
+    #include <GL/glew.h>
+    #include <GL/glu.h>
+    #include <GL/freeglut.h>
+#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 <OpenGL/OpenGL.h>
-    #include <OpenGL/glu.h>
-    #include "freeglut.h"
-#else
-    #include <GL/glew.h>
-    #include <GL/glu.h>
-    #include <GL/freeglut.h>
-#endif
-
 #include <assimp/Importer.hpp>
-//#include <assimp/PostProcess.h>
 #include <assimp/postprocess.h>
 #include <assimp/scene.h>
 #include <assimp/DefaultLogger.hpp>
 #include <assimp/LogStream.hpp>
 
+
 #include "stb_image.c"
 
 
--- 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
--- 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 <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdarg.h>
-#ifndef  __APPLE__
-#include <malloc.h>
-#endif
 #include "midifile.h"
-#include "mendian.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"
 
 
 /*
--- /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 <malloc.h>
+#endif
+
+
+/* Sized integer types
+ */
+#ifdef _WIN32
+#include <wtypes.h>
+typedef unsigned __int8 Uint8;
+typedef unsigned __int16 Uint16;
+typedef unsigned __int32 Uint32;
+typedef unsigned __int64 Uint64;
+#else
+#include <stdint.h>
+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
--- 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