1 | /********************************************************************** <BR>
|
---|
2 | This file is part of Crack dot Com's free source code release of
|
---|
3 | Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
|
---|
4 | information about compiling & licensing issues visit this URL</a>
|
---|
5 | <PRE> If that doesn't help, contact Jonathan Clark at
|
---|
6 | golgotha_source@usa.net (Subject should have "GOLG" in it)
|
---|
7 | ***********************************************************************/
|
---|
8 |
|
---|
9 | //{{{ Interface 4 |
---|
10 | // |
---|
11 | // System dependant #defines and macros |
---|
12 | // Endianess macros |
---|
13 | // short_swap,long_swap - exchange endianess |
---|
14 | // lstl, lltl - little short to local, little long to local (swaps to x86 endianess) |
---|
15 | // |
---|
16 | |
---|
17 | #ifndef __ARCH_HPP_ |
---|
18 | #define __ARCH_HPP_ |
---|
19 | |
---|
20 | #ifdef __MAC__ |
---|
21 | #include <Types.h> |
---|
22 | #include <Files.h> |
---|
23 | #include <Errors.h> |
---|
24 | #endif |
---|
25 | |
---|
26 | |
---|
27 | // 32 bit architectures |
---|
28 | #if (__sgi || __linux || __WATCOMC__ || SUN4 || _WINDOWS || __MAC__) |
---|
29 | typedef unsigned long w32; |
---|
30 | typedef unsigned short w16; |
---|
31 | typedef unsigned char w8; |
---|
32 | typedef signed long sw32; |
---|
33 | typedef signed short sw16; |
---|
34 | typedef signed char sw8; |
---|
35 | |
---|
36 | #if (__linux || __sgi || SUN4) // gcc has long long |
---|
37 | typedef unsigned long long w64; |
---|
38 | typedef long long sw64; |
---|
39 | #elif (_WINDOWS) // visual c has __int64 |
---|
40 | typedef unsigned __int64 w64; |
---|
41 | typedef __int64 sw64; |
---|
42 | #else |
---|
43 | #error please define w64 |
---|
44 | #endif |
---|
45 | |
---|
46 | |
---|
47 | #else |
---|
48 | // 16 and 64 bit architectures are not defined yet |
---|
49 | // but can be added here as long as the compiler supports 32 bit words |
---|
50 | #error unknown architecture, please define basic types |
---|
51 | #endif |
---|
52 | |
---|
53 | |
---|
54 | #define w16_swap(x) (((((w16) (x)))<<8)|((((w16) (x)))>>8)) |
---|
55 | #define w32_swap(x) \ |
---|
56 | ((( ((w32)(x)) )>>24)|((( ((w32)(x)) )&0x00ff0000)>>8)| \ |
---|
57 | ((( ((w32)(x)) )&0x0000ff00)<<8)|(( ((w32)(x)) )<<24)) |
---|
58 | |
---|
59 | |
---|
60 | #if (__linux || __WATCOMC__ || _WINDOWS) |
---|
61 | |
---|
62 | enum { i4_bigend=0, i4_litend=1 }; |
---|
63 | |
---|
64 | #define s_to_lsb(x) (x) |
---|
65 | #define l_to_lsb(x) (x) |
---|
66 | #define s_to_msb(x) w16_swap(x) |
---|
67 | #define l_to_msb(x) w32_swap(x) |
---|
68 | |
---|
69 | #else |
---|
70 | |
---|
71 | enum { i4_bigend=1, i4_litend=0 }; |
---|
72 | |
---|
73 | #define s_to_lsb(x) w16_swap(x) |
---|
74 | #define l_to_lsb(x) w32_swap(x) |
---|
75 | #define s_to_msb(x) (x) |
---|
76 | #define l_to_msb(x) (x) |
---|
77 | |
---|
78 | #endif |
---|
79 | |
---|
80 | |
---|
81 | typedef sw16 i4_coord; // use this type for all x & y positions withing images |
---|
82 | typedef w32 i4_color; // reserved as 32bits in case we expand to 32 bit color |
---|
83 | |
---|
84 | #define i4_null 0 |
---|
85 | |
---|
86 | #ifdef _WINDOWS |
---|
87 | #define I4_FAST_CALL __fastcall |
---|
88 | #else |
---|
89 | #define I4_FAST_CALL |
---|
90 | #endif |
---|
91 | |
---|
92 | typedef w8 i4_bool; |
---|
93 | |
---|
94 | enum { i4_F=0, |
---|
95 | i4_T=1 }; |
---|
96 | |
---|
97 | |
---|
98 | // use this mainly for events, to cast to a known event type |
---|
99 | #define CAST_PTR(var_name, type, source_obj) type *var_name=(type *)(source_obj) |
---|
100 | |
---|
101 | inline void *ALIGN_FORWARD(void *addr) |
---|
102 | { |
---|
103 | return (void*)(((w32)addr+3)&~3); |
---|
104 | } |
---|
105 | |
---|
106 | inline void *ALIGN_BACKWARD(void *addr) |
---|
107 | { |
---|
108 | return (void*)(((w32)addr)&~3); |
---|
109 | } |
---|
110 | |
---|
111 | #endif |
---|