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 | |
33788798 | 40 | // devkitpro has uint32_t as long, unfortunately |
41 | #ifdef _3DS | |
42 | #pragma GCC diagnostic ignored "-Wformat" | |
43 | #endif | |
3cf51e08 | 44 | |
ef79bbde P |
45 | // System includes |
46 | #include <stdio.h> | |
47 | #include <string.h> | |
48 | #include <stdarg.h> | |
49 | #include <stdint.h> | |
50 | #include <stdlib.h> | |
51 | #include <math.h> | |
52 | #include <time.h> | |
53 | #include <ctype.h> | |
7a8d521f | 54 | #ifndef __SWITCH__ |
ef79bbde | 55 | #include <sys/types.h> |
7a8d521f | 56 | #endif |
ef79bbde | 57 | #include <assert.h> |
ef79bbde P |
58 | |
59 | // Define types | |
60 | typedef int8_t s8; | |
61 | typedef int16_t s16; | |
62 | typedef int32_t s32; | |
63 | typedef int64_t s64; | |
64 | typedef intptr_t sptr; | |
65 | ||
66 | typedef uint8_t u8; | |
67 | typedef uint16_t u16; | |
68 | typedef uint32_t u32; | |
69 | typedef uint64_t u64; | |
70 | typedef uintptr_t uptr; | |
71 | ||
72 | typedef uint8_t boolean; | |
73 | ||
74 | #ifndef TRUE | |
75 | #define TRUE 1 | |
76 | #endif | |
77 | ||
78 | #ifndef FALSE | |
79 | #define FALSE 0 | |
80 | #endif | |
81 | ||
82 | // Local includes | |
83 | #include "system.h" | |
ef79bbde | 84 | |
89f33b73 | 85 | #ifndef _WIN32 |
ef79bbde P |
86 | #define strnicmp strncasecmp |
87 | #endif | |
88 | #define __inline inline | |
89 | ||
90 | // Enables NLS/internationalization if active | |
91 | #ifdef ENABLE_NLS | |
92 | ||
93 | #include <libintl.h> | |
94 | ||
95 | #undef _ | |
96 | #define _(String) gettext(String) | |
97 | #ifdef gettext_noop | |
98 | # define N_(String) gettext_noop (String) | |
99 | #else | |
100 | # define N_(String) (String) | |
101 | #endif | |
102 | ||
103 | #else | |
104 | ||
105 | #define _(msgid) msgid | |
106 | #define N_(msgid) msgid | |
107 | ||
108 | #endif | |
109 | ||
110 | extern FILE *emuLog; | |
111 | extern int Log; | |
112 | ||
113 | void __Log(char *fmt, ...); | |
114 | ||
d5aeda23 | 115 | #define CYCLE_MULT_DEFAULT 175 |
116 | ||
ef79bbde P |
117 | typedef struct { |
118 | char Gpu[MAXPATHLEN]; | |
119 | char Spu[MAXPATHLEN]; | |
120 | char Cdr[MAXPATHLEN]; | |
121 | char Pad1[MAXPATHLEN]; | |
122 | char Pad2[MAXPATHLEN]; | |
123 | char Net[MAXPATHLEN]; | |
d5aeda23 | 124 | char Sio1[MAXPATHLEN]; |
ef79bbde P |
125 | char Mcd1[MAXPATHLEN]; |
126 | char Mcd2[MAXPATHLEN]; | |
127 | char Bios[MAXPATHLEN]; | |
128 | char BiosDir[MAXPATHLEN]; | |
129 | char PluginsDir[MAXPATHLEN]; | |
130 | char PatchesDir[MAXPATHLEN]; | |
131 | boolean Xa; | |
ef79bbde P |
132 | boolean Mdec; |
133 | boolean PsxAuto; | |
134 | boolean Cdda; | |
7a8d521f | 135 | boolean AsyncCD; |
0e178648 | 136 | boolean CHD_Precache; /* loads disk image into memory, works with CHD only. */ |
ef79bbde | 137 | boolean HLE; |
7a8d521f | 138 | boolean SlowBoot; |
ef79bbde P |
139 | boolean Debug; |
140 | boolean PsxOut; | |
ef79bbde | 141 | boolean UseNet; |
943a507a | 142 | boolean icache_emulation; |
32631e6a | 143 | boolean DisableStalls; |
bc7c5acb | 144 | boolean PreciseExceptions; |
8c84ba5f | 145 | int GpuListWalking; |
d5aeda23 | 146 | int cycle_multiplier; // 100 for 1.0 |
147 | int cycle_multiplier_override; | |
ef79bbde P |
148 | u8 Cpu; // CPU_DYNAREC or CPU_INTERPRETER |
149 | u8 PsxType; // PSX_TYPE_NTSC or PSX_TYPE_PAL | |
688bdb95 | 150 | struct { |
151 | boolean cdr_read_timing; | |
8c84ba5f | 152 | boolean gpu_slow_list_walking; |
9ed80467 | 153 | boolean gpu_centering; |
e5241564 | 154 | boolean dualshock_init_analog; |
26665bc5 | 155 | boolean gpu_timing1024; |
688bdb95 | 156 | } hacks; |
ef79bbde P |
157 | } PcsxConfig; |
158 | ||
159 | extern PcsxConfig Config; | |
160 | extern boolean NetOpened; | |
161 | ||
496d88d4 | 162 | struct PcsxSaveFuncs { |
163 | void *(*open)(const char *name, const char *mode); | |
164 | int (*read)(void *file, void *buf, u32 len); | |
165 | int (*write)(void *file, const void *buf, u32 len); | |
166 | long (*seek)(void *file, long offs, int whence); | |
167 | void (*close)(void *file); | |
168 | }; | |
169 | extern struct PcsxSaveFuncs SaveFuncs; | |
170 | ||
ef79bbde | 171 | #define gzfreeze(ptr, size) { \ |
496d88d4 | 172 | if (Mode == 1) SaveFuncs.write(f, ptr, size); \ |
173 | if (Mode == 0) SaveFuncs.read(f, ptr, size); \ | |
ef79bbde P |
174 | } |
175 | ||
ef79bbde P |
176 | #define PSXCLK 33868800 /* 33.8688 MHz */ |
177 | ||
178 | enum { | |
179 | PSX_TYPE_NTSC = 0, | |
180 | PSX_TYPE_PAL | |
181 | }; // PSX Types | |
182 | ||
183 | enum { | |
184 | CPU_DYNAREC = 0, | |
185 | CPU_INTERPRETER | |
186 | }; // CPU Types | |
187 | ||
188 | int EmuInit(); | |
189 | void EmuReset(); | |
190 | void EmuShutdown(); | |
191 | void EmuUpdate(); | |
192 | ||
193 | #ifdef __cplusplus | |
194 | } | |
195 | #endif | |
196 | #endif |