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