summaryrefslogtreecommitdiff
path: root/apps/plugins/sdl/include/SDL_config_rockbox.h
blob: 2b7f9a679343c81f570323a380d5d1e8b8d5e32c (plain)
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
/*
    SDL - Simple DirectMedia Layer
    Copyright (C) 1997-2012 Sam Lantinga

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library 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
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

    Sam Lantinga
    slouken@libsdl.org
*/

#ifndef _SDL_config_rockbox_h
#define _SDL_config_rockbox_h

#include "SDL_platform.h"

/* Rockbox SDL config header */

#include "plugin.h"
#include "lib/pluginlib_exit.h"

#include <setjmp.h>
#include <stdarg.h>
#include <stdint.h>
#include <stddef.h>
#include <tlsf.h>

//#define COMBINED_SDL

/* "recommended" sample rate for Rockbox. Games should use this by
 * default unless necessary to do otherwise. */
#ifdef SIMULATOR
#define RB_SAMPR SAMPR_44
#else
#define RB_SAMPR SAMPR_22
#endif

/* Enable the stub cdrom driver (src/cdrom/dummy/\*.c) */
#define SDL_CDROM_DISABLED      1

/* Enable the stub joystick driver (src/joystick/dummy/\*.c) */
#define SDL_JOYSTICK_DISABLED   1

/* Enable the stub shared object loader (src/loadso/dummy/\*.c) */
#define SDL_LOADSO_DISABLED     1

/* woot */
#define SDL_AUDIO_DRIVER_ROCKBOX 1
#define SDL_THREAD_ROCKBOX       1
#undef  SDL_THREAD_PTHREAD
#define SDL_TIMER_ROCKBOX        1
#define SDL_VIDEO_DRIVER_ROCKBOX 1

#ifndef ROCKBOX_BIG_ENDIAN
#define SDL_BYTEORDER SDL_LIL_ENDIAN
#else
#define SDL_BYTEORDER SDL_BIG_ENDIAN
#endif

#define SDL_HAS_64BIT_TYPE 1
#define LACKS_UNISTD_H    1
#define LACKS_STDLIB_H    1
#define LACKS_MMAN_H      1
#define LACKS_SYS_PARAM_H 1
#define LACKS_SYS_MMAN_H  1

#define HAVE_STDIO_H      1
#define HAVE_MALLOC       1
#define HAVE_FREE         1
#define HAVE_REALLOC      1
#define HAVE_QSORT        1
#define HAVE_STRLEN       1
#define HAVE_STRLCPY      1
#define HAVE_STRCMP       1
#define HAVE_STRNCMP      1

#undef strdup

/* clock() wraps current_tick */
#define CLOCKS_PER_SEC HZ

/*
  copied from firmware/assert.h
*/

#undef assert

#ifdef NDEBUG           /* required by ANSI standard */
#define assert(p)       ((void)0)
#else

#define assert(e)       ((e) ? (void)0 : fatal("assertion failed %s:%d", __FILE__, __LINE__))

#endif /* NDEBUG */

#define SDL_calloc calloc
#define atan atan_wrapper
#define atan2 atan2_wrapper
#define atexit rb_atexit
#define atof atof_wrapper
#define atoi rb->atoi
#define atol atoi
#define calloc tlsf_calloc
#define ceil ceil_wrapper
#define clock() (*rb->current_tick)
#define closedir rb->closedir
#define cos cos_wrapper
#define exit rb_exit
#define exp(x) pow(2.71828182845, (x)) /* HACK */
#define fabs fabs_wrapper
#define floor floor_wrapper
#define fmod fmod_wrapper
#define free tlsf_free
#define fscanf fscanf_wrapper
#define getchar() rb->sleep(2*HZ)
#define getenv SDL_getenv
#define log rb_log
#define lseek rb->lseek
#define malloc tlsf_malloc
#define mkdir rb->mkdir
#define opendir rb->opendir
#define pow pow_wrapper
#define printf printf_wrapper
#define putenv(x) /* nothing */
#define puts printf
#define qsort rb->qsort
#define rand rb->rand
#define rb_atexit rbsdl_atexit
#define readdir rb->readdir
#define realloc tlsf_realloc
#define remove rb->remove
#define sin sin_wrapper
#define snprintf rb->snprintf
#define sprintf sprintf_wrapper
#define sqrt sqrt_wrapper
#define srand rb->srand
#define sscanf SDL_sscanf
#define strcasecmp rb->strcasecmp
#define strcat strcat_wrapper
#define strchr rb->strchr
#define strcmp rb->strcmp
#define strcpy strcpy_wrapper
#define strdup strdup_wrapper
#define strerror(x) "error"
#define strlcpy rb->strlcpy
#define strlen rb->strlen
#define strncasecmp rb->strncasecmp
#define strncat rb->strlcat /* hack */
#define strncmp rb->strncmp
#define strpbrk strpbrk_wrapper
#define strrchr rb->strrchr
#define strstr SDL_strstr
#define strtok strtok_wrapper
#define strtok_r rb->strtok_r
#define strtol SDL_strtol
#define tan tan_wrapper
#define time(x) (*rb->current_tick/HZ)
#define unlink remove
#define vprintf vprintf_wrapper
#define vsnprintf rb->vsnprintf
#define vsprintf vsprintf_wrapper

// use Rockbox's string routines
#define SDL_memcpy memcpy
#define SDL_memcmp memcmp

#define M_PI 3.14159265358979323846
#define EOF (-1)

#define LOAD_XPM
#define MID_MUSIC
#define USE_TIMIDITY_MIDI

#define FILENAME_MAX MAX_PATH

char *strcat_wrapper(char *dest, const char *src);
char *strcpy_wrapper(char *dest, const char *src);
char *strtok_wrapper(char *str, const char *delim);
double ceil_wrapper(double x);
double cos_wrapper(double);
double floor_wrapper(double n);
double sin_wrapper(double);
float atan2_wrapper(float, float);
float atan_wrapper(float x);
float fabs_wrapper(float);
float fmod(float x, float y);
float pow_wrapper(float x, float y);
float rb_log(float x);
float sqrt_wrapper(float);
float tan_wrapper(float);
int mkdir_wrapepr(const char *path);
int printf_wrapper(const char*, ...);
int sprintf_wrapper(char*, const char*, ...);
int vprintf(const char *fmt, va_list ap);
void fatal(char *fmt, ...);
void rb_exit(int rc);
void rbsdl_atexit(void (*)(void));
float atof_wrapper (char *str);

/* speed */
static inline uint16_t readLE16(void *addr)
{
    uint8_t *ptr = addr;
    return (*(ptr+1) << 8) | *ptr;
}

static inline uint32_t readLE32(void *addr)
{
    uint8_t *ptr = addr;
    return (*(ptr+3) << 24) |(*(ptr+2) << 16) | (*(ptr+1) << 8) | *ptr;
}

#endif /* _SDL_config_rockbox_h */