forked from AZO234/NP2kai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.h
executable file
·205 lines (174 loc) · 5.49 KB
/
common.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
#ifndef NP2_COMMON_H
#define NP2_COMMON_H
enum {
SUCCESS = 0,
FAILURE = 1
};
#ifndef BRESULT
#define BRESULT UINT
#endif
#ifndef INTPTR
#define INTPTR intptr_t
#endif
#ifndef UINTPTR
#define UINTPTR uintptr_t
#endif
#ifndef LOADINTELDWORD
#define LOADINTELDWORD(a) (((UINT32)(((UINT8*)(a))[0])) | \
((UINT32)(((UINT8*)(a))[1]) << 8) | \
((UINT32)(((UINT8*)(a))[2]) << 16) | \
((UINT32)(((UINT8*)(a))[3]) << 24))
#endif
#ifndef LOADINTELWORD
#define LOADINTELWORD(a) (((UINT16)((UINT8*)(a))[0]) | ((UINT16)(((UINT8*)(a))[1]) << 8))
#endif
#ifndef STOREINTELDWORD
#define STOREINTELDWORD(a, b) *(((UINT8*)(a))+0) = (UINT8)((b)); \
*(((UINT8*)(a))+1) = (UINT8)((b)>>8); \
*(((UINT8*)(a))+2) = (UINT8)((b)>>16); \
*(((UINT8*)(a))+3) = (UINT8)((b)>>24)
#endif
#ifndef STOREINTELWORD
#define STOREINTELWORD(a, b) *(((UINT8*)(a))+0) = (UINT8)((b)); \
*(((UINT8*)(a))+1) = (UINT8)((b)>>8)
#endif
/* Big Ending */
#ifndef LOADMOTOROLAQWORD
#define LOADMOTOROLAQWORD(a) (((UINT64)((UINT8*)(a))[7]) | \
((UINT64)(((UINT8*)(a))[6]) << 8) | \
((UINT64)(((UINT8*)(a))[5]) << 16) | \
((UINT64)(((UINT8*)(a))[4]) << 24) | \
((UINT64)(((UINT8*)(a))[3]) << 32) | \
((UINT64)(((UINT8*)(a))[2]) << 40) | \
((UINT64)(((UINT8*)(a))[1]) << 48) | \
((UINT64)(((UINT8*)(a))[0]) << 56))
#endif
#ifndef LOADMOTOROLADWORD
#define LOADMOTOROLADWORD(a) (((UINT32)((UINT8*)(a))[3]) | \
((UINT32)(((UINT8*)(a))[2]) << 8) | \
((UINT32)(((UINT8*)(a))[1]) << 16) | \
((UINT32)(((UINT8*)(a))[0]) << 24))
#endif
#ifndef LOADMOTOROLAWORD
#define LOADMOTOROLAWORD(a) (((UINT16)((UINT8*)(a))[1]) | ((UINT16)(((UINT8*)(a))[0]) << 8))
#endif
#ifndef STOREMOTOROLAQWORD
#define STOREMOTOROLAQWORD(a, b) *(((UINT8*)(a))+7) = (UINT8)((b)); \
*(((UINT8*)(a))+6) = (UINT8)((b)>>8); \
*(((UINT8*)(a))+5) = (UINT8)((b)>>16); \
*(((UINT8*)(a))+4) = (UINT8)((b)>>24); \
*(((UINT8*)(a))+3) = (UINT8)((b)>>32); \
*(((UINT8*)(a))+2) = (UINT8)((b)>>40); \
*(((UINT8*)(a))+1) = (UINT8)((b)>>48); \
*(((UINT8*)(a))+0) = (UINT8)((b)>>56)
#endif
#ifndef STOREMOTOROLADWORD
#define STOREMOTOROLADWORD(a, b) *(((UINT8*)(a))+3) = (UINT8)((b)); \
*(((UINT8*)(a))+2) = (UINT8)((b)>>8); \
*(((UINT8*)(a))+1) = (UINT8)((b)>>16); \
*(((UINT8*)(a))+0) = (UINT8)((b)>>24)
#endif
#ifndef STOREMOTOROLAWORD
#define STOREMOTOROLAWORD(a, b) *(((UINT8*)(a))+1) = (UINT8)((b)); \
*(((UINT8*)(a))+0) = (UINT8)((b)>>8)
#endif
/* *** */
#ifndef NELEMENTS
#define NELEMENTS(a) ((int)(sizeof(a) / sizeof(a[0])))
#endif
// ---- Optimize Macros
#ifndef REG8
#define REG8 UINT8
#endif
#ifndef REG16
#define REG16 UINT16
#endif
#ifndef LOW8
#define LOW8(a) ((UINT8)(a))
#endif
#ifndef LOW10
#define LOW10(a) ((a) & 0x03ff)
#endif
#ifndef LOW11
#define LOW11(a) ((a) & 0x07ff)
#endif
#ifndef LOW12
#define LOW12(a) ((a) & 0x0fff)
#endif
#ifndef LOW14
#define LOW14(a) ((a) & 0x3fff)
#endif
#ifndef LOW15
#define LOW15(a) ((a) & 0x7fff)
#endif
#ifndef LOW16
#define LOW16(a) ((UINT16)(a))
#endif
#ifndef HIGH16
#define HIGH16(a) (((UINT32)(a)) >> 16)
#endif
#ifndef OEMCHAR
#define OEMCHAR char
#endif
#ifndef OEMTEXT
#define OEMTEXT(string) string
#endif
#if !defined(RGB16)
#define RGB16 UINT16
#endif
#if !defined(RGB32)
#if defined(BYTESEX_LITTLE)
typedef union {
UINT32 d;
struct {
UINT8 b;
UINT8 g;
UINT8 r;
UINT8 e;
} p;
} RGB32;
#define RGB32D(r, g, b) (((r) << 16) + ((g) << 8) + ((b) << 0))
#elif defined(BYTESEX_BIG)
typedef union {
UINT32 d;
struct {
UINT8 e;
UINT8 r;
UINT8 g;
UINT8 b;
} p;
} RGB32;
#define RGB32D(r, g, b) (((r) << 16) + ((g) << 8) + ((b) << 0))
#endif
#endif
#define FTYPEID(a, b, c, d) (((a) << 24) + ((b) << 16) + ((c) << 8) + (d))
enum {
FTYPE_NONE = 0,
FTYPE_SMIL = FTYPEID('S','M','I','L'),
FTYPE_TEXT = FTYPEID('T','E','X','T'),
FTYPE_BMP = FTYPEID('B','M','P',' '),
FTYPE_GIF = FTYPEID('G','I','F',' '),
FTYPE_WAVE = FTYPEID('W','A','V','E'),
FTYPE_OGG = FTYPEID('O','G','G',' '),
FTYPE_MP3 = FTYPEID('M','P','3',' '),
FTYPE_D88 = FTYPEID('.','D','8','8'),
FTYPE_FDI = FTYPEID('.','F','D','I'),
FTYPE_BETA = FTYPEID('B','E','T','A'),
FTYPE_THD = FTYPEID('.','T','H','D'),
FTYPE_NHD = FTYPEID('.','N','H','D'),
FTYPE_HDI = FTYPEID('.','H','D','I'),
FTYPE_HDD = FTYPEID('.','H','D','D'),
FTYPE_S98 = FTYPEID('.','S','9','8'),
FTYPE_MIMPI = FTYPEID('M','I','M','P')
};
#if !defined(INLINE)
#if defined(DEBUG)
#define INLINE
#else
#define INLINE inline
#endif
#endif
#if !defined(FASTCALL)
#define FASTCALL
#endif
#endif /* NP2_COMMON_H */