workaround a problem with the harmattan gcc
[drnoksnes] / port.h
1 /*
2  * Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
3  *
4  * (c) Copyright 1996 - 2001 Gary Henderson (gary.henderson@ntlworld.com) and
5  *                           Jerremy Koot (jkoot@snes9x.com)
6  *
7  * Super FX C emulator code 
8  * (c) Copyright 1997 - 1999 Ivar (ivar@snes9x.com) and
9  *                           Gary Henderson.
10  * Super FX assembler emulator code (c) Copyright 1998 zsKnight and _Demo_.
11  *
12  * DSP1 emulator code (c) Copyright 1998 Ivar, _Demo_ and Gary Henderson.
13  * C4 asm and some C emulation code (c) Copyright 2000 zsKnight and _Demo_.
14  * C4 C code (c) Copyright 2001 Gary Henderson (gary.henderson@ntlworld.com).
15  *
16  * DOS port code contains the works of other authors. See headers in
17  * individual files.
18  *
19  * Snes9x homepage: http://www.snes9x.com
20  *
21  * Permission to use, copy, modify and distribute Snes9x in both binary and
22  * source form, for non-commercial purposes, is hereby granted without fee,
23  * providing that this license information and copyright notice appear with
24  * all copies and any derived work.
25  *
26  * This software is provided 'as-is', without any express or implied
27  * warranty. In no event shall the authors be held liable for any damages
28  * arising from the use of this software.
29  *
30  * Snes9x is freeware for PERSONAL USE only. Commercial users should
31  * seek permission of the copyright holders first. Commercial use includes
32  * charging money for Snes9x or software derived from Snes9x.
33  *
34  * The copyright holders request that bug fixes and improvements to the code
35  * should be forwarded to them so everyone can benefit from the modifications
36  * in future versions.
37  *
38  * Super NES and Super Nintendo Entertainment System are trademarks of
39  * Nintendo Co., Limited and its subsidiary companies.
40  */
41 #ifndef _PORT_H_
42 #define _PORT_H_
43
44 /*
45 This port.h is really a right-of-passage for anyone trying to port the emulator 
46         to another platform.  It must have started out as a set of defines for a
47         single platform, and instead of using define blocks as new platforms were
48         added, individual coders simply added exceptions and sprinkled #ifdef and #ifndef
49         statements throughout the original list.
50
51 I can't take it anymore, it's too convoluted.  So I've commented out the entire
52         section, and preemptively rewritten the first #define segment the way god intended,
53         with a single define-block for each target platform.
54 */
55
56 //Title
57 #define TITLE "DrNokSnes"
58
59 //Required Includes
60 #include "pixform.h"
61 #include <zlib.h>
62 #include <stdint.h>
63 #include <limits.h>
64 #include <string.h>
65
66 //Types Defined
67 typedef uint8_t                 bool8;
68 typedef uint8_t                 uint8;
69 typedef uint16_t                uint16;
70 typedef uint32_t                uint32;
71 typedef int8_t                  int8;
72 typedef int16_t                 int16;
73 typedef int32_t                 int32;
74 typedef int64_t                 int64;
75
76 //Defines for Extern C
77 #ifdef __cplusplus
78 #define EXTERN_C extern "C"
79 #define START_EXTERN_C EXTERN_C {
80 #define END_EXTERN_C }
81 #else
82 #define EXTERN_C extern
83 #define START_EXTERN_C
84 #define END_EXTERN_C
85 #endif
86
87 //Path Defines
88 #define _MAX_DIR PATH_MAX
89 #define _MAX_DRIVE 1
90 #define _MAX_FNAME NAME_MAX
91 #define _MAX_EXT NAME_MAX
92 #define _MAX_PATH PATH_MAX
93
94 // Boolean constants (may already be defined)
95 #ifndef TRUE
96 #define TRUE 1
97 #endif
98 #ifndef FALSE
99 #define FALSE 0
100 #endif
101
102 // Config -> Defines
103 #if CONF_BUILD_ASM_SPC700
104 #define ASM_SPC700              1
105 #else
106 #undef ASM_SPC700
107 #endif
108
109 // Configuration defines I think I know what they're for
110 #define SUPER_FX                1
111 #define USE_SA1                 1
112 #define CPU_SHUTDOWN    1
113 //#define NETPLAY_SUPPORT       1
114 #define ZLIB                    1
115 #define UNZIP_SUPPORT   1
116 #define NO_INLINE_SET_GET 1
117
118 //Misc Items
119 #define VAR_CYCLES
120 //#define SPC700_SHUTDOWN
121 #define LSB_FIRST
122 #define PIXEL_FORMAT RGB565
123 #define CHECK_SOUND()
124 #define ZeroMemory(a,b) memset((a),0,(b))
125 #define PACKING __attribute__ ((packed))
126 #define ALIGN_BY_ONE  __attribute__ ((aligned (1), packed))
127 #define LSB_FIRST
128 #undef  FAST_LSB_WORD_ACCESS
129
130 // Language abstractions
131 #define FASTCALL
132 #define STATIC static
133 #define INLINE inline
134
135 START_EXTERN_C
136 // Path functions
137 void PathMake(char *path, const char *drive, const char *dir,
138         const char *fname, const char *ext);
139 void PathSplit(const char *path, char *drive, char *dir, char *fname, char *ext);
140 /** A simplified basename function returning a pointer inside the src string */
141 const char * PathBasename(const char * path);
142 END_EXTERN_C
143
144 // Input / output functions
145 START_EXTERN_C
146 uint32 S9xReadJoypad(int which1_0_to_4);
147 bool8 S9xReadMousePosition(int which1_0_to_1, int *x, int *y, uint32 *buttons);
148 bool8 S9xReadSuperScopePosition(int *x, int *y, uint32 *buttons);
149 END_EXTERN_C
150
151 // Stream functions, used when opening ROMs and snapshots.
152 #ifdef ZLIB
153 #include <zlib.h>
154 #define STREAM gzFile
155 #define READ_STREAM(p,l,s) gzread (s,p,l)
156 #define WRITE_STREAM(p,l,s) gzwrite (s,p,l)
157 #define GETS_STREAM(p,l,s) gzgets(s,p,l)
158 #define GETC_STREAM(s) gzgetc(s)
159 #define OPEN_STREAM(f,m) gzopen (f,m)
160 #define REOPEN_STREAM(f,m) gzdopen (f,m)
161 #define FIND_STREAM(f)  gztell(f)
162 #define REVERT_STREAM(f,o,s)  gzseek(f,o,s)
163 #define CLOSE_STREAM(s) gzclose (s)
164 #else
165 #define STREAM FILE *
166 #define READ_STREAM(p,l,s) fread (p,1,l,s)
167 #define WRITE_STREAM(p,l,s) fwrite (p,1,l,s)
168 #define GETS_STREAM(p,l,s) fgets(p,l,s)
169 #define GETC_STREAM(s) fgetc(s)
170 #define OPEN_STREAM(f,m) fopen (f,m)
171 #define REOPEN_STREAM(f,m) fdopen (f,m)
172 #define FIND_STREAM(f)  ftell(f)
173 #define REVERT_STREAM(f,o,s)     fseek(f,o,s)
174 #define CLOSE_STREAM(s) fclose (s)
175 #endif
176
177 #endif
178