Commit | Line | Data |
---|---|---|
ef79bbde P |
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 | ||
3cf51e08 | 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 | ||
ef79bbde P |
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> | |
ef79bbde P |
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" | |
ef79bbde | 78 | |
89f33b73 | 79 | #ifndef _WIN32 |
ef79bbde P |
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; | |
943a507a | 135 | boolean icache_emulation; |
32631e6a | 136 | boolean DisableStalls; |
ef79bbde P |
137 | u8 Cpu; // CPU_DYNAREC or CPU_INTERPRETER |
138 | u8 PsxType; // PSX_TYPE_NTSC or PSX_TYPE_PAL | |
139 | #ifdef _WIN32 | |
140 | char Lang[256]; | |
141 | #endif | |
142 | } PcsxConfig; | |
143 | ||
144 | extern PcsxConfig Config; | |
145 | extern boolean NetOpened; | |
146 | ||
496d88d4 | 147 | struct PcsxSaveFuncs { |
148 | void *(*open)(const char *name, const char *mode); | |
149 | int (*read)(void *file, void *buf, u32 len); | |
150 | int (*write)(void *file, const void *buf, u32 len); | |
151 | long (*seek)(void *file, long offs, int whence); | |
152 | void (*close)(void *file); | |
153 | }; | |
154 | extern struct PcsxSaveFuncs SaveFuncs; | |
155 | ||
ef79bbde | 156 | #define gzfreeze(ptr, size) { \ |
496d88d4 | 157 | if (Mode == 1) SaveFuncs.write(f, ptr, size); \ |
158 | if (Mode == 0) SaveFuncs.read(f, ptr, size); \ | |
ef79bbde P |
159 | } |
160 | ||
161 | // Make the timing events trigger faster as we are currently assuming everything | |
162 | // takes one cycle, which is not the case on real hardware. | |
163 | // FIXME: Count the proper cycle and get rid of this | |
164 | #define BIAS 2 | |
165 | #define PSXCLK 33868800 /* 33.8688 MHz */ | |
166 | ||
167 | enum { | |
168 | PSX_TYPE_NTSC = 0, | |
169 | PSX_TYPE_PAL | |
170 | }; // PSX Types | |
171 | ||
172 | enum { | |
173 | CPU_DYNAREC = 0, | |
174 | CPU_INTERPRETER | |
175 | }; // CPU Types | |
176 | ||
177 | int EmuInit(); | |
178 | void EmuReset(); | |
179 | void EmuShutdown(); | |
180 | void EmuUpdate(); | |
181 | ||
182 | #ifdef __cplusplus | |
183 | } | |
184 | #endif | |
185 | #endif |