Accept patch in FS#9637 by Keith Perri, fixing a crash when loading a cfg which speci...
[kugel-rb.git] / apps / plugins / doom / rockmacros.h
blob6e09e6e80686721dafbf9feb66f6e887f99580e3
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2005 Michiel van der Kolk, Jens Arnold
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
21 #ifndef __ROCKMACROS_H__
22 #define __ROCKMACROS_H__
24 #include "plugin.h"
25 #include "ctype.h"
26 #include "autoconf.h"
27 #include "z_zone.h"
29 extern const struct plugin_api* rb;
30 extern bool noprintf;
31 extern bool doomexit;
33 /* libc functions */
34 int printf(const char *fmt, ...);
35 int fileexists(const char * fname);
36 int my_open(const char *file, int flags);
37 int my_close(int id);
38 char *my_strtok( char * s, const char * delim );
39 #define alloca __builtin_alloca
40 #define fdprintf(...) rb->fdprintf(__VA_ARGS__)
41 #define vsnprintf(...) rb->vsnprintf(__VA_ARGS__)
42 #define read_line(a,b,c) rb->read_line((a),(b),(c))
44 #ifdef SIMULATOR
45 #undef open
46 #undef close
47 #undef lseek
48 #undef filesize
49 #undef read
50 #undef write
51 #define open(a,b) rb->sim_open((a),(b))
52 #define close(a) rb->sim_close((a))
53 #define lseek(a,b,c) rb->sim_lseek((a),(b),(c))
54 #define filesize(a) rb->sim_filesize((a))
55 #define read(a,b,c) rb->sim_read((a),(b),(c))
56 #define write(a,b,c) rb->sim_write((a),(b),(c))
57 #else /* !SIMULATOR */
58 #define open(a,b) my_open((a),(b))
59 #define close(a) my_close((a))
60 #define lseek(a,b,c) rb->lseek((a),(b),(c))
61 #define filesize(a) rb->filesize((a))
62 #define read(a,b,c) rb->read((a),(b),(c))
63 #define write(a,b,c) rb->write((a),(b),(c))
64 #endif /* !SIMULATOR */
66 #define strtok(a,b) my_strtok((a),(b))
67 #define strcat(a,b) rb->strcat((a),(b))
68 #define memset(a,b,c) rb->memset((a),(b),(c))
69 #define memmove(a,b,c) rb->memmove((a),(b),(c))
70 #define memcmp(a,b,c) rb->memcmp((a),(b),(c))
71 #define memchr(a,b,c) rb->memchr((a),(b),(c))
72 #define strcpy(a,b) rb->strcpy((a),(b))
73 #define strncpy(a,b,c) rb->strncpy((a),(b),(c))
74 #define strlen(a) rb->strlen((a))
75 #define strcmp(a,b) rb->strcmp((a),(b))
76 #define strncmp(a,b,c) rb->strncmp((a),(b),(c))
77 #define strchr(a,b) rb->strchr((a),(b))
78 #define strrchr(a,b) rb->strrchr((a),(b))
79 #define strcasecmp(a,b) rb->strcasecmp((a),(b))
80 #define strncasecmp(a,b,c) rb->strncasecmp((a),(b),(c))
81 #define srand(a) rb->srand((a))
82 #define rand() rb->rand()
83 #define atoi(a) rb->atoi((a))
84 #define strcat(a,b) rb->strcat((a),(b))
85 #define snprintf rb->snprintf
87 /* Using #define isn't enough with GCC 4.0.1 */
88 inline void* memcpy(void* dst, const void* src, size_t size);
90 #define PACKEDATTR __attribute__((packed)) // Needed for a few things
91 #define GAMEBASE ROCKBOX_DIR "/doom/"
92 //#define SIMPLECHECKS
93 #define NO_PREDEFINED_LUMPS
94 #define TABLES_AS_LUMPS // This frees up alot of space in the plugin buffer
96 #define MAKE_FOURCC(a,b,c,d) (uint32_t)((((a)<<24)|((b)<<16)|((c)<<8)|(d)))
98 /* Config file magic - increment the version number whenever the settings
99 structure changes.
101 #define DOOM_CONFIG_MAGIC MAKE_FOURCC('D','O','O','M')
102 #define DOOM_CONFIG_VERSION 3
104 #endif