home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 February / chip_20022115.iso / amiga / chipgame / scummvm_aga.lha / ScummVM_AGA / src / scummsys.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-01-05  |  6.0 KB  |  263 lines

  1. /* ScummVM - Scumm Interpreter
  2.  * Copyright (C) 2001  Ludvig Strigeus
  3.  *
  4.  * This program is free software; you can redistribute it and/or
  5.  * modify it under the terms of the GNU General Public License
  6.  * as published by the Free Software Foundation; either version 2
  7.  * of the License, or (at your option) any later version.
  8.  
  9.  * This program is distributed in the hope that it will be useful,
  10.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.  * GNU General Public License for more details.
  13.  
  14.  * You should have received a copy of the GNU General Public License
  15.  * along with this program; if not, write to the Free Software
  16.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  17.  *
  18.  * $Header: /cvsroot/scummvm/scummvm/scummsys.h,v 1.15 2001/11/15 14:50:46 cmatsuoka Exp $
  19.  *
  20.  */
  21.  
  22. #if defined(_MSC_VER)
  23.  
  24. #pragma warning (disable: 4244)
  25. #pragma warning (disable: 4101)
  26.  
  27. #define scumm_stricmp stricmp
  28.  
  29. #if defined(CHECK_HEAP)
  30. #undef CHECK_HEAP
  31. #define CHECK_HEAP checkHeap();
  32. #else
  33. #define CHECK_HEAP
  34. #endif
  35.  
  36. #define SCUMM_LITTLE_ENDIAN
  37.  
  38. #define FORCEINLINE __forceinline
  39. #define NORETURN _declspec(noreturn)
  40.  
  41. typedef unsigned char byte;
  42. typedef unsigned char uint8;
  43. typedef unsigned short uint16;
  44. typedef unsigned long uint32;
  45. typedef unsigned int uint;
  46. typedef signed char int8;
  47. typedef signed short int16;
  48. typedef signed long int32;
  49.  
  50. #define START_PACK_STRUCTS pack (push,1)
  51. #define END_PACK_STRUCTS   pack(pop)
  52. #define GCC_PACK
  53.  
  54. #elif defined(__CYGWIN__)
  55.  
  56. #define scumm_stricmp stricmp
  57. #define CHECK_HEAP
  58. #define SCUMM_LITTLE_ENDIAN
  59.  
  60. #define FORCEINLINE inline
  61. #define NORETURN __attribute__((__noreturn__))
  62. #define GCC_PACK __attribute__((packed))
  63. #define CDECL
  64.  
  65. typedef unsigned char byte;
  66. typedef unsigned char uint8;
  67. typedef unsigned short uint16;
  68. typedef unsigned long uint32;
  69. typedef unsigned int uint;
  70. typedef signed char int8;
  71. typedef signed short int16;
  72. typedef signed long int32;
  73.  
  74. #define START_PACK_STRUCTS pack (push,1)
  75. #define END_PACK_STRUCTS   pack(pop)
  76.  
  77. #elif (defined(UNIX) || defined(__APPLE__))
  78.  
  79. #define scumm_stricmp strcasecmp
  80.  
  81. #define CHECK_HEAP
  82.  
  83. /* need this for the SDL_BYTEORDER define */
  84. #include <SDL_byteorder.h>
  85.  
  86. #if SDL_BYTEORDER == SDL_LIL_ENDIAN
  87. #define SCUMM_LITTLE_ENDIAN
  88. #elif SDL_BYTEORDER == SDL_BIG_ENDIAN
  89. #define SCUMM_BIG_ENDIAN
  90. #define SCUMM_NEED_ALIGNMENT
  91. #else
  92. #error Neither SDL_BIG_ENDIAN nor SDL_LITTLE_ENDIAN is set.
  93. #endif
  94.  
  95. #define FORCEINLINE inline
  96. #define CDECL 
  97.  
  98. typedef unsigned char byte;
  99. typedef unsigned char uint8;
  100. typedef unsigned short uint16;
  101. typedef unsigned long uint32;
  102. typedef unsigned int uint;
  103. typedef signed char int8;
  104. typedef signed short int16;
  105. typedef signed long int32;
  106.  
  107. #if defined(__GNUC__)
  108. #define START_PACK_STRUCTS
  109. #define END_PACK_STRUCTS
  110. #define GCC_PACK __attribute__((packed))
  111. #define NORETURN __attribute__((__noreturn__)) 
  112. #else
  113. #define START_PACK_STRUCTS pack (1)
  114. #define END_PACK_STRUCTS   pack ()
  115. #define GCC_PACK
  116. #define NORETURN
  117. #endif
  118.  
  119. #elif (defined(__MORPHOS__) || defined( AMIGA ))
  120.  
  121. #define scumm_stricmp stricmp
  122.  
  123. #define CHECK_HEAP
  124.  
  125. #define SCUMM_BIG_ENDIAN
  126.  
  127. #ifdef __MORPHOS__
  128. #define SCUMM_NEED_ALIGNMENT
  129. #endif
  130.  
  131. #define FORCEINLINE inline
  132. #define CDECL
  133.  
  134. typedef unsigned char byte;
  135. typedef unsigned char uint8;
  136. typedef unsigned short uint16;
  137. typedef unsigned long uint32;
  138. typedef unsigned int uint;
  139. typedef signed char int8;
  140. typedef signed short int16;
  141. typedef signed long int32;
  142.  
  143. #if defined(__GNUC__)
  144. #define START_PACK_STRUCTS
  145. #define END_PACK_STRUCTS
  146. #define GCC_PACK __attribute__((packed))
  147. #define NORETURN __attribute__((__noreturn__))
  148. #else
  149. #define START_PACK_STRUCTS pack (1)
  150. #define END_PACK_STRUCTS   pack ()
  151. #define GCC_PACK
  152. #define NORETURN
  153. #endif
  154.  
  155. #else
  156. #error No system type defined
  157. #endif
  158.  
  159.  
  160. #if defined(SCUMM_LITTLE_ENDIAN)
  161.  
  162. //#if defined(SCUMM_NEED_ALIGNMENT)
  163. //#error Little endian processors that need alignment is not implemented
  164. //#endif
  165.  
  166. #define MKID(a) ((((a)>>24)&0xFF) | (((a)>>8)&0xFF00) | (((a)<<8)&0xFF0000) | (((a)<<24)&0xFF000000))
  167.  
  168. #if defined(SCUMM_NEED_ALIGNMENT)
  169.     uint FORCEINLINE READ_LE_UINT16(void *ptr) {
  170.         return (((byte*)ptr)[1]<<8)|((byte*)ptr)[0];
  171.     }
  172. #else
  173.     uint FORCEINLINE READ_LE_UINT16(void *ptr) {
  174.         return *(uint16*)(ptr);
  175.     }
  176. #endif
  177.  
  178. uint FORCEINLINE READ_BE_UINT16(void *ptr) {
  179.     return (((byte*)ptr)[0]<<8)|((byte*)ptr)[1];
  180. }
  181.  
  182. #if defined(SCUMM_NEED_ALIGNMENT)
  183.     uint32 FORCEINLINE READ_LE_UINT32(void *ptr) {
  184.         byte *b = (byte*)ptr;
  185.         return (b[3]<<24)+(b[2]<<16)+(b[1]<<8)+(b[0]);
  186.     }
  187. #else
  188.     uint32 FORCEINLINE READ_LE_UINT32(void *ptr) {
  189.         return *(uint32*)(ptr);
  190.     }
  191. #endif
  192.  
  193. uint32 FORCEINLINE READ_BE_UINT32(void *ptr) {
  194.     byte *b = (byte*)ptr;
  195.     return (b[0]<<24)+(b[1]<<16)+(b[2]<<8)+(b[3]);
  196. }
  197.  
  198. #define READ_BE_UINT32_UNALIGNED READ_BE_UINT32
  199. #define READ_BE_UINT16_UNALIGNED READ_BE_UINT16
  200.  
  201. #define READ_UINT32_UNALIGNED(a) READ_LE_UINT32(a)
  202.  
  203. #define FROM_LE_32(__a__) __a__
  204. #define FROM_LE_16(__a__) __a__
  205.  
  206. #define TO_LE_32(__a__) __a__
  207. #define TO_LE_16(__a__) __a__
  208.  
  209. #define TO_BE_32(a) ((((a)>>24)&0xFF) | (((a)>>8)&0xFF00) | (((a)<<8)&0xFF0000) | (((a)<<24)&0xFF000000))
  210.  
  211. #elif defined(SCUMM_BIG_ENDIAN)
  212.  
  213. #define MKID(a) (a)
  214.  
  215. uint32 FORCEINLINE FROM_LE_32(uint32 a) {
  216.     return ((a>>24)&0xFF) + ((a>>8)&0xFF00) + ((a<<8)&0xFF0000) + ((a<<24)&0xFF000000);
  217. }
  218.  
  219. uint16 FORCEINLINE FROM_LE_16(uint16 a) {
  220.     return ((a>>8)&0xFF) + ((a<<8)&0xFF00);
  221. }
  222.  
  223. #define TO_LE_32 FROM_LE_32
  224. #define TO_LE_16 FROM_LE_16
  225.  
  226. uint32 FORCEINLINE READ_LE_UINT32(void *ptr) {
  227.     byte *b = (byte*)ptr;
  228.     return (b[3]<<24)+(b[2]<<16)+(b[1]<<8)+(b[0]);
  229. }
  230.  
  231. uint32 FORCEINLINE READ_BE_UINT32(void *ptr) {
  232.     return *(uint32*)(ptr);
  233. }
  234.  
  235. uint FORCEINLINE READ_LE_UINT16(void *ptr) {
  236.     byte *b = (byte*)ptr;
  237.     return (b[1]<<8) + b[0];
  238. }
  239.  
  240. uint FORCEINLINE READ_BE_UINT16(void *ptr) {
  241.     return *(uint16*)(ptr);
  242. }
  243.  
  244. uint FORCEINLINE READ_BE_UINT16_UNALIGNED(void *ptr) {
  245.     return (((byte*)ptr)[0]<<8)|((byte*)ptr)[1];
  246. }
  247.  
  248. uint32 FORCEINLINE READ_BE_UINT32_UNALIGNED(void *ptr) {
  249.     byte *b = (byte*)ptr;
  250.     return (b[0]<<24)+(b[1]<<16)+(b[2]<<8)+(b[3]);
  251. }
  252.  
  253. #define READ_UINT32_UNALIGNED READ_BE_UINT32_UNALIGNED
  254.  
  255. #define TO_BE_32(a) (a)
  256.  
  257. #else
  258.  
  259. #error No endianness defined
  260.  
  261. #endif
  262.  
  263.