2961
|
1 /* Copyright (C) 2005 Guillaume Duhamel
|
|
2
|
|
3 This file is part of DeSmuME
|
|
4
|
|
5 DeSmuME is free software; you can redistribute it and/or modify
|
|
6 it under the terms of the GNU General Public License as published by
|
|
7 the Free Software Foundation; either version 2 of the License, or
|
|
8 (at your option) any later version.
|
|
9
|
|
10 DeSmuME is distributed in the hope that it will be useful,
|
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 GNU General Public License for more details.
|
|
14
|
|
15 You should have received a copy of the GNU General Public License
|
|
16 along with DeSmuME; if not, write to the Free Software
|
|
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
18 */
|
|
19
|
|
20 #ifndef TYPES_HPP
|
|
21 #define TYPES_HPP
|
|
22
|
|
23 #ifndef FASTCALL
|
|
24 #ifdef __MINGW32__
|
|
25 #define FASTCALL __attribute__((fastcall))
|
|
26 #elif defined (__i386__)
|
|
27 #define FASTCALL __attribute__((regparm(3)))
|
|
28 #else
|
|
29 #define FASTCALL
|
|
30 #endif
|
|
31 #endif
|
|
32
|
|
33 #ifndef INLINE
|
|
34 #ifdef _MSC_VER
|
|
35 #define INLINE _inline
|
|
36 #else
|
|
37 #define INLINE inline
|
|
38 #endif
|
|
39 #endif
|
|
40
|
|
41 #ifdef DESMUME_COCOA
|
|
42 #ifdef __BIG_ENDIAN__
|
|
43 #define WORDS_BIGENDIAN
|
|
44 #endif
|
|
45 #endif
|
|
46
|
|
47 #if defined(__LP64__)
|
|
48 typedef unsigned char u8;
|
|
49 typedef unsigned short u16;
|
|
50 typedef unsigned int u32;
|
|
51 typedef unsigned long u64;
|
|
52 typedef unsigned long pointer;
|
|
53
|
|
54 typedef signed char s8;
|
|
55 typedef signed short s16;
|
|
56 typedef signed int s32;
|
|
57 typedef signed long s64;
|
|
58 #else
|
|
59 typedef unsigned char u8;
|
|
60 typedef unsigned short u16;
|
|
61 typedef unsigned long u32;
|
|
62 #ifdef _MSC_VER
|
|
63 typedef unsigned __int64 u64;
|
|
64 #else
|
|
65 typedef unsigned long long u64;
|
|
66 #endif
|
|
67 typedef unsigned long pointer;
|
|
68
|
|
69 typedef signed char s8;
|
|
70 typedef signed short s16;
|
|
71 typedef signed long s32;
|
|
72 #ifdef _MSC_VER
|
|
73 typedef __int64 s64;
|
|
74 #else
|
|
75 typedef signed long long s64;
|
|
76 #endif
|
|
77 #endif
|
|
78
|
|
79 typedef u8 uint8;
|
|
80 typedef u16 uint16;
|
|
81
|
|
82 #ifndef OBJ_C
|
|
83 typedef u32 uint32;
|
|
84 #else
|
|
85 #define uint32 u32 //uint32 is defined in Leopard somewhere, avoid conflicts
|
|
86 #endif
|
|
87
|
|
88 /*---------- GPU3D fixed-points types -----------*/
|
|
89
|
|
90 typedef s32 f32;
|
|
91 #define inttof32(n) ((n) << 12)
|
|
92 #define f32toint(n) ((n) >> 12)
|
|
93 #define floattof32(n) ((int32)((n) * (1 << 12)))
|
|
94 #define f32tofloat(n) (((float)(n)) / (float)(1<<12))
|
|
95
|
|
96 typedef s16 t16;
|
|
97 #define f32tot16(n) ((t16)(n >> 8))
|
|
98 #define inttot16(n) ((n) << 4)
|
|
99 #define t16toint(n) ((n) >> 4)
|
|
100 #define floattot16(n) ((t16)((n) * (1 << 4)))
|
|
101 #define t16ofloat(n) (((float)(n)) / (float)(1<<4))
|
|
102
|
|
103 typedef s16 v16;
|
|
104 #define inttov16(n) ((n) << 12)
|
|
105 #define f32tov16(n) (n)
|
|
106 #define floattov16(n) ((v16)((n) * (1 << 12)))
|
|
107 #define v16toint(n) ((n) >> 12)
|
|
108 #define v16tofloat(n) (((float)(n)) / (float)(1<<12))
|
|
109
|
|
110 typedef s16 v10;
|
|
111 #define inttov10(n) ((n) << 9)
|
|
112 #define f32tov10(n) ((v10)(n >> 3))
|
|
113 #define v10toint(n) ((n) >> 9)
|
|
114 #define floattov10(n) ((v10)((n) * (1 << 9)))
|
|
115 #define v10tofloat(n) (((float)(n)) / (float)(1<<9))
|
|
116
|
|
117 /*----------------------*/
|
|
118
|
|
119 #ifndef OBJ_C
|
|
120 typedef int BOOL;
|
|
121 #else
|
|
122 //apple also defines BOOL
|
|
123 typedef int desmume_BOOL;
|
|
124 #define BOOL desmume_BOOL
|
|
125 #endif
|
|
126
|
|
127 #ifndef TRUE
|
|
128 #define TRUE 1
|
|
129 #endif
|
|
130
|
|
131 #ifndef FALSE
|
|
132 #define FALSE 0
|
|
133 #endif
|
|
134
|
|
135 #ifdef __GNUC__
|
|
136 #define PACKED __attribute__((packed))
|
|
137 #endif
|
|
138
|
|
139 #ifdef WORDS_BIGENDIAN
|
|
140 # define LOCAL_BE
|
|
141 #else
|
|
142 # define LOCAL_LE
|
|
143 #endif
|
|
144
|
|
145 /* little endian (ds' endianess) to local endianess convert macros */
|
|
146 #ifdef LOCAL_BE /* local arch is big endian */
|
|
147 # define LE_TO_LOCAL_16(x) ((((x)&0xff)<<8)|(((x)>>8)&0xff))
|
|
148 # define LE_TO_LOCAL_32(x) ((((x)&0xff)<<24)|(((x)&0xff00)<<8)|(((x)>>8)&0xff00)|(((x)>>24)&0xff))
|
|
149 # define LOCAL_TO_LE_16(x) ((((x)&0xff)<<8)|(((x)>>8)&0xff))
|
|
150 # define LOCAL_TO_LE_32(x) ((((x)&0xff)<<24)|(((x)&0xff00)<<8)|(((x)>>8)&0xff00)|(((x)>>24)&0xff))
|
|
151 #else /* local arch is little endian */
|
|
152 # define LE_TO_LOCAL_16(x) (x)
|
|
153 # define LE_TO_LOCAL_32(x) (x)
|
|
154 # define LOCAL_TO_LE_16(x) (x)
|
|
155 # define LOCAL_TO_LE_32(x) (x)
|
|
156 #endif
|
|
157
|
|
158 /* kilobytes and megabytes macro */
|
|
159 #define MB(x) ((x)*1024*1024)
|
|
160 #define KB(x) ((x)*1024)
|
|
161
|
|
162 #define CPU_STR(c) ((c==ARM9)?"ARM9":"ARM7")
|
|
163 typedef enum
|
|
164 {
|
|
165 ARM9 = 0,
|
|
166 ARM7 = 1
|
|
167 } cpu_id_t;
|
|
168
|
|
169 #define __PACKED __attribute__((__packed__))
|
|
170
|
|
171 #endif
|