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 | ||
34 | // System includes | |
35 | #include <stdio.h> | |
36 | #include <string.h> | |
37 | #include <stdarg.h> | |
38 | #include <stdint.h> | |
39 | #include <stdlib.h> | |
40 | #include <math.h> | |
41 | #include <time.h> | |
42 | #include <ctype.h> | |
12367ad0 | 43 | #ifndef __SWITCH__ |
ef79bbde | 44 | #include <sys/types.h> |
12367ad0 | 45 | #endif |
ef79bbde | 46 | #include <assert.h> |
ef79bbde P |
47 | |
48 | // Define types | |
49 | typedef int8_t s8; | |
50 | typedef int16_t s16; | |
51 | typedef int32_t s32; | |
52 | typedef int64_t s64; | |
53 | typedef intptr_t sptr; | |
54 | ||
55 | typedef uint8_t u8; | |
56 | typedef uint16_t u16; | |
57 | typedef uint32_t u32; | |
58 | typedef uint64_t u64; | |
59 | typedef uintptr_t uptr; | |
60 | ||
61 | typedef uint8_t boolean; | |
62 | ||
63 | #ifndef TRUE | |
64 | #define TRUE 1 | |
65 | #endif | |
66 | ||
67 | #ifndef FALSE | |
68 | #define FALSE 0 | |
69 | #endif | |
70 | ||
71 | // Local includes | |
72 | #include "system.h" | |
ef79bbde | 73 | |
89f33b73 | 74 | #ifndef _WIN32 |
ef79bbde P |
75 | #define strnicmp strncasecmp |
76 | #endif | |
77 | #define __inline inline | |
78 | ||
79 | // Enables NLS/internationalization if active | |
80 | #ifdef ENABLE_NLS | |
81 | ||
82 | #include <libintl.h> | |
83 | ||
84 | #undef _ | |
85 | #define _(String) gettext(String) | |
86 | #ifdef gettext_noop | |
87 | # define N_(String) gettext_noop (String) | |
88 | #else | |
89 | # define N_(String) (String) | |
90 | #endif | |
91 | ||
92 | #else | |
93 | ||
94 | #define _(msgid) msgid | |
95 | #define N_(msgid) msgid | |
96 | ||
97 | #endif | |
98 | ||
99 | extern FILE *emuLog; | |
100 | extern int Log; | |
101 | ||
102 | void __Log(char *fmt, ...); | |
103 | ||
104 | typedef struct { | |
105 | char Gpu[MAXPATHLEN]; | |
106 | char Spu[MAXPATHLEN]; | |
107 | char Cdr[MAXPATHLEN]; | |
108 | char Pad1[MAXPATHLEN]; | |
109 | char Pad2[MAXPATHLEN]; | |
110 | char Net[MAXPATHLEN]; | |
111 | char Sio1[MAXPATHLEN]; | |
112 | char Mcd1[MAXPATHLEN]; | |
113 | char Mcd2[MAXPATHLEN]; | |
114 | char Bios[MAXPATHLEN]; | |
115 | char BiosDir[MAXPATHLEN]; | |
116 | char PluginsDir[MAXPATHLEN]; | |
117 | char PatchesDir[MAXPATHLEN]; | |
118 | boolean Xa; | |
119 | boolean Sio; | |
120 | boolean Mdec; | |
121 | boolean PsxAuto; | |
122 | boolean Cdda; | |
679b71e2 | 123 | boolean AsyncCD; |
1d2757f4 | 124 | boolean CHD_Precache; /* loads disk image into memory, works with CHD only. */ |
ef79bbde | 125 | boolean HLE; |
f422f444 | 126 | boolean SlowBoot; |
ef79bbde P |
127 | boolean Debug; |
128 | boolean PsxOut; | |
129 | boolean SpuIrq; | |
130 | boolean RCntFix; | |
131 | boolean UseNet; | |
132 | boolean VSyncWA; | |
133 | u8 Cpu; // CPU_DYNAREC or CPU_INTERPRETER | |
134 | u8 PsxType; // PSX_TYPE_NTSC or PSX_TYPE_PAL | |
135 | #ifdef _WIN32 | |
136 | char Lang[256]; | |
137 | #endif | |
138 | } PcsxConfig; | |
139 | ||
140 | extern PcsxConfig Config; | |
141 | extern boolean NetOpened; | |
142 | ||
496d88d4 | 143 | struct PcsxSaveFuncs { |
144 | void *(*open)(const char *name, const char *mode); | |
145 | int (*read)(void *file, void *buf, u32 len); | |
146 | int (*write)(void *file, const void *buf, u32 len); | |
147 | long (*seek)(void *file, long offs, int whence); | |
148 | void (*close)(void *file); | |
149 | }; | |
150 | extern struct PcsxSaveFuncs SaveFuncs; | |
151 | ||
ef79bbde | 152 | #define gzfreeze(ptr, size) { \ |
496d88d4 | 153 | if (Mode == 1) SaveFuncs.write(f, ptr, size); \ |
154 | if (Mode == 0) SaveFuncs.read(f, ptr, size); \ | |
ef79bbde P |
155 | } |
156 | ||
157 | // Make the timing events trigger faster as we are currently assuming everything | |
158 | // takes one cycle, which is not the case on real hardware. | |
159 | // FIXME: Count the proper cycle and get rid of this | |
160 | #define BIAS 2 | |
161 | #define PSXCLK 33868800 /* 33.8688 MHz */ | |
162 | ||
163 | enum { | |
164 | PSX_TYPE_NTSC = 0, | |
165 | PSX_TYPE_PAL | |
166 | }; // PSX Types | |
167 | ||
168 | enum { | |
169 | CPU_DYNAREC = 0, | |
170 | CPU_INTERPRETER | |
171 | }; // CPU Types | |
172 | ||
173 | int EmuInit(); | |
174 | void EmuReset(); | |
175 | void EmuShutdown(); | |
176 | void EmuUpdate(); | |
177 | ||
178 | #ifdef __cplusplus | |
179 | } | |
180 | #endif | |
181 | #endif |