(svn r3596) -Codechange: [OSX] changed to use Apple's macros instead of OTTD macros for endian conversion
authorbjarni
Sun, 12 Feb 2006 14:31:33 +0000
changeset 3016 c63fb93fa1a0
parent 3015 76371a33e6c4
child 3017 915fae59d5e0
(svn r3596) -Codechange: [OSX] changed to use Apple's macros instead of OTTD macros for endian conversion
This increases the execution speed a lot since GCC can't detect the OTTD macro as an endian conversion
while Apple's code uses the instruction to convert endian instead of a series of instructions to produce the same result

Since we don't have that many endian conversions in the game, overall performance should not increase noteworthy
music/qtmidi.c
os/macosx/osx_stdafx.h
stdafx.h
video/cocoa_v.m
--- a/music/qtmidi.c	Sun Feb 12 10:44:52 2006 +0000
+++ b/music/qtmidi.c	Sun Feb 12 14:31:33 2006 +0000
@@ -24,6 +24,10 @@
 /*
  * OpenTTD includes.
  */
+#define  WindowClass OSX_WindowClass
+#include <QuickTime/QuickTime.h>
+#undef   WindowClass
+
 #include "../stdafx.h"
 #include "../openttd.h"
 #include "qtmidi.h"
@@ -32,19 +36,10 @@
  * System includes. We need to workaround with some defines because there's
  * stuff already defined in QuickTime headers.
  */
-#define  bool        OSX_bool
-#define  Rect        OSX_Rect
-#define  Point       OSX_Point
-#define  SL_ERROR    OSX_SL_ERROR
-#define  WindowClass OSX_WindowClass
 #define  OTTD_Random OSX_OTTD_Random
-#include <CoreServices/CoreServices.h>
-#include <QuickTime/QuickTime.h>
 #undef   OTTD_Random
 #undef   WindowClass
 #undef   SL_ERROR
-#undef   Point
-#undef   Rect
 #undef   bool
 
 #include <assert.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/os/macosx/osx_stdafx.h	Sun Feb 12 14:31:33 2006 +0000
@@ -0,0 +1,19 @@
+/* $Id$ */
+
+#ifndef MACOS_STDAFX_H
+#define MACOS_STDAFX_H
+
+#include <CoreServices/CoreServices.h>
+// remove the variables that CoreServices defines, but we define ourselves too
+#undef bool
+#undef false
+#undef true
+
+/* Name conflict */
+#define Rect		OTTDRect
+#define Point		OTTDPoint
+#define GetTime		OTTDGetTime
+
+#define SL_ERROR OSX_SL_ERROR
+
+#endif /* MACOS_STDAFX_H */
--- a/stdafx.h	Sun Feb 12 10:44:52 2006 +0000
+++ b/stdafx.h	Sun Feb 12 14:31:33 2006 +0000
@@ -52,8 +52,15 @@
 # endif
 #endif /* __MORPHOS__ */
 
+#ifdef __APPLE__
+#include "os/macosx/osx_stdafx.h"
+// make endian swapping use Apple's macros to increase speed
+#define BSWAP32(x) Endian32_Swap(x)
+#define BSWAP16(x) Endian16_Swap(x)
+#else
 #define BSWAP32(x) ((((x) >> 24) & 0xFF) | (((x) >> 8) & 0xFF00) | (((x) << 8) & 0xFF0000) | (((x) << 24) & 0xFF000000))
 #define BSWAP16(x) ((x) >> 8 | (x) << 8)
+#endif
 
 // by default we use [] var arrays
 #define VARARRAY_SIZE
--- a/video/cocoa_v.m	Sun Feb 12 10:44:52 2006 +0000
+++ b/video/cocoa_v.m	Sun Feb 12 14:31:33 2006 +0000
@@ -36,9 +36,6 @@
 #endif
 
 
-/* Name conflict */
-#define Rect		OTTDRect
-#define Point		OTTDPoint
 /* Defined in ppc/param.h or i386/param.h included from sys/param.h */
 #undef ALIGN
 /* Defined in stdbool.h */