3 * Copyright (C) 2006 Exophase <exophase@gmail.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or (at your option) any later version.
10 * This program 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 GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #define ror(dest, value, shift) \
24 dest = ((value) >> shift) | ((value) << (32 - shift)) \
26 #if defined(_WIN32) || defined(_WIN32_WCE)
27 #define PATH_SEPARATOR "\\"
28 #define PATH_SEPARATOR_CHAR '\\'
30 #define PATH_SEPARATOR "/"
31 #define PATH_SEPARATOR_CHAR '/'
34 // These includes must be used before SDL is included.
40 #define _BSD_SOURCE // sync
50 #endif /* _WIN32_WCE */
57 // Huge thanks to pollux for the heads up on using native file I/O
58 // functions on PSP for vastly improved memstick performance.
60 #define file_write_mem(filename_tag, buffer, size) \
62 memcpy(write_mem_ptr, buffer, size); \
63 write_mem_ptr += size; \
66 #define file_write_mem_array(filename_tag, array) \
67 file_write_mem(filename_tag, array, sizeof(array)) \
69 #define file_write_mem_variable(filename_tag, variable) \
70 file_write_mem(filename_tag, &variable, sizeof(variable)) \
75 #include <pspkernel.h>
80 #include <pspaudiolib.h>
85 #define convert_palette(value) \
86 value = ((value & 0x7FE0) << 1) | (value & 0x1F) \
88 #define psp_file_open_read PSP_O_RDONLY
89 #define psp_file_open_write (PSP_O_CREAT | PSP_O_WRONLY | PSP_O_TRUNC)
91 #define file_open(filename_tag, filename, mode) \
92 s32 filename_tag = sceIoOpen(filename, psp_file_open_##mode, 0777) \
94 #define file_check_valid(filename_tag) \
97 #define file_close(filename_tag) \
98 sceIoClose(filename_tag) \
100 #define file_read(filename_tag, buffer, size) \
101 sceIoRead(filename_tag, buffer, size) \
103 #define file_write(filename_tag, buffer, size) \
104 sceIoWrite(filename_tag, buffer, size) \
106 #define file_seek(filename_tag, offset, type) \
107 sceIoLseek(filename_tag, offset, PSP_##type) \
109 #define file_tag_type s32
119 #define function_cc __attribute__((regparm(2)))
122 typedef unsigned char u8;
123 typedef signed char s8;
124 typedef unsigned short int u16;
125 typedef signed short int s16;
126 typedef unsigned int u32;
127 typedef signed int s32;
128 typedef unsigned long long int u64;
129 typedef signed long long int s64;
131 #define convert_palette(value) \
132 value = ((value & 0x1F) << 11) | ((value & 0x03E0) << 1) | (value >> 10) \
134 #define stdio_file_open_read "rb"
135 #define stdio_file_open_write "wb"
137 #define file_open(filename_tag, filename, mode) \
138 FILE *filename_tag = fopen(filename, stdio_file_open_##mode) \
140 #define file_check_valid(filename_tag) \
145 #define file_close(filename_tag) \
147 fclose(filename_tag); \
153 #define file_close(filename_tag) \
154 fclose(filename_tag) \
158 #define file_read(filename_tag, buffer, size) \
159 fread(buffer, 1, size, filename_tag) \
161 #define file_write(filename_tag, buffer, size) \
162 fwrite(buffer, 1, size, filename_tag) \
164 #define file_seek(filename_tag, offset, type) \
165 fseek(filename_tag, offset, type) \
167 #define file_tag_type FILE *
171 // These must be variables, not constants.
173 #define file_read_variable(filename_tag, variable) \
174 file_read(filename_tag, &variable, sizeof(variable)) \
176 #define file_write_variable(filename_tag, variable) \
177 file_write(filename_tag, &variable, sizeof(variable)) \
179 // These must be statically declared arrays (ie, global or on the stack,
180 // not dynamically allocated on the heap)
182 #define file_read_array(filename_tag, array) \
183 file_read(filename_tag, array, sizeof(array)) \
185 #define file_write_array(filename_tag, array) \
186 file_write(filename_tag, array, sizeof(array)) \
190 typedef u32 fixed16_16;
191 typedef u32 fixed8_24;
193 #define float_to_fp16_16(value) \
194 (fixed16_16)((value) * 65536.0) \
196 #define fp16_16_to_float(value) \
197 (float)((value) / 65536.0) \
199 #define u32_to_fp16_16(value) \
202 #define fp16_16_to_u32(value) \
205 #define fp16_16_fractional_part(value) \
208 #define float_to_fp8_24(value) \
209 (fixed8_24)((value) * 16777216.0) \
211 #define fp8_24_fractional_part(value) \
212 ((value) & 0xFFFFFF) \
214 #define fixed_div(numerator, denominator, bits) \
215 (((numerator * (1 << bits)) + (denominator / 2)) / denominator) \
217 #define address8(base, offset) \
218 *((u8 *)((u8 *)base + (offset))) \
220 #define address16(base, offset) \
221 *((u16 *)((u8 *)base + (offset))) \
223 #define address32(base, offset) \
224 *((u32 *)((u8 *)base + (offset))) \
244 #include "arm/warm.h"
248 #define printf pspDebugScreenPrintf
253 //#define REGISTER_USAGE_ANALYZE
258 #include "gp2x/gp2x.h"
260 #define printf(format, ...) \
261 fprintf(stderr, format, ##__VA_ARGS__) \
263 #define vprintf(format, ap) \
264 vfprintf(stderr, format, ap) \
266 // #define STDIO_DEBUG
270 #include "pandora/pnd.h"
274 #include "raspberrypi/rpi.h"