deal with some more annoying warnings
[pcsx_rearmed.git] / libpcsxcore / psxcommon.h
1 /***************************************************************************
2  *   Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team              *
3  *                                                                         *
4  *   This program is free software; you can redistribute it and/or modify  *
5  *   it under the terms of the GNU General Public License as published by  *
6  *   the Free Software Foundation; either version 2 of the License, or     *
7  *   (at your option) any later version.                                   *
8  *                                                                         *
9  *   This program is distributed in the hope that it will be useful,       *
10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12  *   GNU General Public License for more details.                          *
13  *                                                                         *
14  *   You should have received a copy of the GNU General Public License     *
15  *   along with this program; if not, write to the                         *
16  *   Free Software Foundation, Inc.,                                       *
17  *   51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA.           *
18  ***************************************************************************/
19
20 /* 
21 * This file contains common definitions and includes for all parts of the 
22 * emulator core.
23 */
24
25 #ifndef __PSXCOMMON_H__
26 #define __PSXCOMMON_H__
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 #include "config.h"
33
34 // XXX: don't care but maybe fix it someday
35 #if defined(__GNUC__) && __GNUC__ >= 8
36 #pragma GCC diagnostic ignored "-Wformat-truncation"
37 #pragma GCC diagnostic ignored "-Wformat-overflow"
38 #pragma GCC diagnostic ignored "-Wstringop-truncation"
39 #endif
40
41 // System includes
42 #include <stdio.h>
43 #include <string.h>
44 #include <stdarg.h>
45 #include <stdint.h>
46 #include <stdlib.h>
47 #include <math.h>
48 #include <time.h>
49 #include <ctype.h>
50 #include <sys/types.h>
51 #include <assert.h>
52
53 // Define types
54 typedef int8_t s8;
55 typedef int16_t s16;
56 typedef int32_t s32;
57 typedef int64_t s64;
58 typedef intptr_t sptr;
59
60 typedef uint8_t u8;
61 typedef uint16_t u16;
62 typedef uint32_t u32;
63 typedef uint64_t u64;
64 typedef uintptr_t uptr;
65
66 typedef uint8_t boolean;
67
68 #ifndef TRUE
69 #define TRUE 1
70 #endif
71
72 #ifndef FALSE
73 #define FALSE 0
74 #endif
75
76 // Local includes
77 #include "system.h"
78
79 #ifndef _WIN32
80 #define strnicmp strncasecmp
81 #endif
82 #define __inline inline
83
84 // Enables NLS/internationalization if active
85 #ifdef ENABLE_NLS
86
87 #include <libintl.h>
88
89 #undef _
90 #define _(String) gettext(String)
91 #ifdef gettext_noop
92 #  define N_(String) gettext_noop (String)
93 #else
94 #  define N_(String) (String)
95 #endif
96
97 #else
98
99 #define _(msgid) msgid
100 #define N_(msgid) msgid
101
102 #endif
103
104 extern FILE *emuLog;
105 extern int Log;
106
107 void __Log(char *fmt, ...);
108
109 typedef struct {
110         char Gpu[MAXPATHLEN];
111         char Spu[MAXPATHLEN];
112         char Cdr[MAXPATHLEN];
113         char Pad1[MAXPATHLEN];
114         char Pad2[MAXPATHLEN];
115         char Net[MAXPATHLEN];
116     char Sio1[MAXPATHLEN];
117         char Mcd1[MAXPATHLEN];
118         char Mcd2[MAXPATHLEN];
119         char Bios[MAXPATHLEN];
120         char BiosDir[MAXPATHLEN];
121         char PluginsDir[MAXPATHLEN];
122         char PatchesDir[MAXPATHLEN];
123         boolean Xa;
124         boolean Sio;
125         boolean Mdec;
126         boolean PsxAuto;
127         boolean Cdda;
128         boolean HLE;
129         boolean Debug;
130         boolean PsxOut;
131         boolean SpuIrq;
132         boolean RCntFix;
133         boolean UseNet;
134         boolean VSyncWA;
135         u8 Cpu; // CPU_DYNAREC or CPU_INTERPRETER
136         u8 PsxType; // PSX_TYPE_NTSC or PSX_TYPE_PAL
137 #ifdef _WIN32
138         char Lang[256];
139 #endif
140 } PcsxConfig;
141
142 extern PcsxConfig Config;
143 extern boolean NetOpened;
144
145 struct PcsxSaveFuncs {
146         void *(*open)(const char *name, const char *mode);
147         int   (*read)(void *file, void *buf, u32 len);
148         int   (*write)(void *file, const void *buf, u32 len);
149         long  (*seek)(void *file, long offs, int whence);
150         void  (*close)(void *file);
151 };
152 extern struct PcsxSaveFuncs SaveFuncs;
153
154 #define gzfreeze(ptr, size) { \
155         if (Mode == 1) SaveFuncs.write(f, ptr, size); \
156         if (Mode == 0) SaveFuncs.read(f, ptr, size); \
157 }
158
159 // Make the timing events trigger faster as we are currently assuming everything
160 // takes one cycle, which is not the case on real hardware.
161 // FIXME: Count the proper cycle and get rid of this
162 #define BIAS    2
163 #define PSXCLK  33868800        /* 33.8688 MHz */
164
165 enum {
166         PSX_TYPE_NTSC = 0,
167         PSX_TYPE_PAL
168 }; // PSX Types
169
170 enum {
171         CPU_DYNAREC = 0,
172         CPU_INTERPRETER
173 }; // CPU Types
174
175 int EmuInit();
176 void EmuReset();
177 void EmuShutdown();
178 void EmuUpdate();
179
180 #ifdef __cplusplus
181 }
182 #endif
183 #endif