This repository has been archived by the owner on Jul 2, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathcommon.h
236 lines (188 loc) · 5.32 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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
//
// Copyright (c) 2009, Wei Mingzhi <[email protected]>.
// All rights reserved.
//
// This file is part of SDLPAL.
//
// SDLPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#ifndef _COMMON_H
#define _COMMON_H
//#define PAL_WIN95 1 // not valid for now
//#define PAL_CLASSIC 1
#ifdef __cplusplus
extern "C"
{
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <limits.h>
#include <stdarg.h>
#include <assert.h>
#include "SDL.h"
#include "SDL_endian.h"
#ifdef _SDL_stdinc_h
#define malloc SDL_malloc
#define calloc SDL_calloc
#define free SDL_free
#define realloc SDL_realloc
#endif
#if SDL_VERSION_ATLEAST(2,0,0)
#define SDLK_KP1 SDLK_KP_1
#define SDLK_KP2 SDLK_KP_2
#define SDLK_KP3 SDLK_KP_3
#define SDLK_KP4 SDLK_KP_4
#define SDLK_KP5 SDLK_KP_5
#define SDLK_KP6 SDLK_KP_6
#define SDLK_KP7 SDLK_KP_7
#define SDLK_KP8 SDLK_KP_8
#define SDLK_KP9 SDLK_KP_9
#define SDLK_KP0 SDLK_KP_0
#define SDL_HWSURFACE 0
#endif
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
#define SWAP16(X) (X)
#define SWAP32(X) (X)
#else
#define SWAP16(X) SDL_Swap16(X)
#define SWAP32(X) SDL_Swap32(X)
#endif
//gcc6 fix
#ifndef cxmax
#define cxmax(a, b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef cxmin
#define cxmin(a, b) (((a) < (b)) ? (a) : (b))
#endif
#if defined (__SYMBIAN32__)
#undef _WIN32
#undef SDL_INIT_JOYSTICK
#define SDL_INIT_JOYSTICK 0
#define PAL_HAS_MOUSE 1
#define PAL_PREFIX "e:/data/pal/"
#define PAL_SAVE_PREFIX "e:/data/pal/"
#elif defined (GEKKO)
#define PAL_HAS_JOYSTICKS 1
#define PAL_HAS_MOUSE 0
#define PAL_PREFIX "SD:/apps/sdlpal/"
#define PAL_SAVE_PREFIX "SD:/apps/sdlpal/"
#elif defined (PSP)
#define PAL_HAS_JOYSTICKS 0
#define PAL_PREFIX "ms0:/"
#define PAL_SAVE_PREFIX "ms0:/PSP/SAVEDATA/SDLPAL/"
#elif defined (__N3DS__)
#define PAL_PREFIX "sdmc:/3ds/sdlpal/"
#define PAL_SAVE_PREFIX "sdmc:/3ds/sdlpal/"
#elif defined (__IOS__)
#define PAL_PREFIX UTIL_IOS_BasePath()
#define PAL_SAVE_PREFIX UTIL_IOS_SavePath()
#define PAL_HAS_TOUCH 1
#elif defined (__ANDROID__)
#define PAL_PREFIX "/mnt/sdcard/sdlpal/"
#define PAL_SAVE_PREFIX "/mnt/sdcard/sdlpal/"
#define PAL_HAS_TOUCH 1
#elif defined (__WINPHONE__)
#define PAL_PREFIX "Assets\\Data\\"
#define PAL_SAVE_PREFIX "" // ???
#define PAL_HAS_TOUCH 1
#include <stdio.h>
#ifdef __cplusplus
#include <cstdio>
#endif
FILE *MY_fopen(const char *path, const char *mode);
#define fopen MY_fopen
#else
#define PAL_HAS_JOYSTICKS 1
#ifndef _WIN32_WCE
#if SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION <= 2
#define PAL_ALLOW_KEYREPEAT 1
#define PAL_HAS_CD 1
#endif
#if !defined (CYGWIN) && !defined (DINGOO) && !defined (GPH) && !defined (GEKKO) && !defined (__WINPHONE__)
#define PAL_HAS_MP3 1
#endif
#endif
#ifndef PAL_PREFIX
#define PAL_PREFIX "./"
#endif
#ifndef PAL_SAVE_PREFIX
#define PAL_SAVE_PREFIX "./"
#endif
#endif
#ifndef SDL_INIT_CDROM
#define SDL_INIT_CDROM 0
#endif
#ifdef _WIN32
#include <windows.h>
#if !defined(__BORLANDC__) && !defined(_WIN32_WCE)
#include <io.h>
#endif
#define vsnprintf _vsnprintf
#ifdef _MSC_VER
#pragma warning (disable:4018)
#pragma warning (disable:4028)
#pragma warning (disable:4244)
#pragma warning (disable:4305)
#pragma warning (disable:4761)
#pragma warning (disable:4996)
#endif
#ifndef _LPCBYTE_DEFINED
#define _LPCBYTE_DEFINED
typedef const BYTE *LPCBYTE;
#endif
#ifndef __WINPHONE__
#define PAL_HAS_NATIVEMIDI 1
#endif
#else
#include <unistd.h>
#define CONST const
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
#define VOID void
typedef char CHAR;
typedef short SHORT;
typedef long LONG;
typedef unsigned long ULONG, *PULONG;
typedef unsigned short USHORT, *PUSHORT;
typedef unsigned char UCHAR, *PUCHAR;
typedef unsigned short WORD, *LPWORD;
typedef unsigned int DWORD, *LPDWORD;
typedef int INT, *LPINT;
#ifndef __OBJC__
typedef int BOOL, *LPBOOL;
#endif
typedef unsigned int UINT, *PUINT, UINT32, *PUINT32;
typedef unsigned char BYTE, *LPBYTE;
typedef CONST BYTE *LPCBYTE;
typedef float FLOAT, *LPFLOAT;
typedef void *LPVOID;
typedef const void *LPCVOID;
typedef CHAR *LPSTR;
typedef const CHAR *LPCSTR;
#endif
#if defined (__SYMBIAN32__) || defined (__N3DS__)
#define PAL_LARGE static
#else
#define PAL_LARGE /* */
#endif
#ifdef __cplusplus
}
#endif
#endif