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 02110-1301 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> 45 #include <zlib.h> 46 47 // Define types 48 typedef int8_t s8; 49 typedef int16_t s16; 50 typedef int32_t s32; 51 typedef int64_t s64; 52 typedef intptr_t sptr; 53 54 typedef uint8_t u8; 55 typedef uint16_t u16; 56 typedef uint32_t u32; 57 typedef uint64_t u64; 58 typedef uintptr_t uptr; 59 60 typedef uint8_t boolean; 61 62 #ifndef TRUE 63 #define TRUE 1 64 #endif 65 66 #ifndef FALSE 67 #define FALSE 0 68 #endif 69 70 // Local includes 71 #include "system.h" 72 #include "debug.h" 73 74 #if defined (__linux__) || defined (__MACOSX__) || defined (__FreeBSD__) 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 //If running under Mac OS X, use the Localizable.strings file instead. 93 #elif defined(_MACOSX) 94 #ifdef PCSXRCORE 95 __private_extern char* Pcsxr_locale_text(char* toloc); 96 #define _(String) Pcsxr_locale_text(String) 97 #define N_(String) String 98 #else 99 #ifndef PCSXRPLUG 100 #warning please define the plug being built to use Mac OS X localization! 101 #define _(msgid) msgid 102 #define N_(msgid) msgid 103 #else 104 //Kludge to get the preprocessor to accept PCSXRPLUG as a variable. 105 #define PLUGLOC_x(x,y) x ## y 106 #define PLUGLOC_y(x,y) PLUGLOC_x(x,y) 107 #define PLUGLOC PLUGLOC_y(PCSXRPLUG,_locale_text) 108 __private_extern char* PLUGLOC(char* toloc); 109 #define _(String) PLUGLOC(String) 110 #define N_(String) String 111 #endif 112 #endif 113 #else 114 115 #define _(msgid) msgid 116 #define N_(msgid) msgid 117 118 #endif 119 120 extern FILE *emuLog; 121 extern int Log; 122 123 void __Log(char *fmt, ...); 124 125 typedef struct { 126 char Gpu[MAXPATHLEN]; 127 char Spu[MAXPATHLEN]; 128 char Cdr[MAXPATHLEN]; 129 char Pad1[MAXPATHLEN]; 130 char Pad2[MAXPATHLEN]; 131 char Net[MAXPATHLEN]; 132 char Sio1[MAXPATHLEN]; 133 char Mcd1[MAXPATHLEN]; 134 char Mcd2[MAXPATHLEN]; 135 char Bios[MAXPATHLEN]; 136 char BiosDir[MAXPATHLEN]; 137 char PluginsDir[MAXPATHLEN]; 138 char PatchesDir[MAXPATHLEN]; 139 char IsoImgDir[MAXPATHLEN]; 140 boolean Xa; 141 boolean SioIrq; 142 boolean Mdec; 143 boolean PsxAuto; 144 u8 Cdda; 145 boolean HLE; 146 boolean SlowBoot; 147 boolean Debug; 148 boolean PsxOut; 149 boolean SpuIrq; 150 boolean RCntFix; 151 boolean UseNet; 152 boolean VSyncWA; 153 boolean NoMemcard; 154 boolean Widescreen; 155 boolean HideCursor; 156 boolean SaveWindowPos; 157 s32 WindowPos[2]; 158 u8 Cpu; // CPU_DYNAREC or CPU_INTERPRETER 159 u8 PsxType; // PSX_TYPE_NTSC or PSX_TYPE_PAL 160 u32 RewindCount; 161 u32 RewindInterval; 162 u32 AltSpeed1; // Percent relative to natural speed. 163 u32 AltSpeed2; 164 u8 HackFix; 165 #ifdef _WIN32 166 char Lang[256]; 167 #endif 168 } PcsxConfig; 169 170 extern PcsxConfig Config; 171 extern boolean NetOpened; 172 173 // It is safe if these overflow 174 extern u32 rewind_counter; 175 extern u8 vblank_count_hideafter; 176 177 #define gzfreeze(ptr, size) { \ 178 if (Mode == 1) gzwrite(f, ptr, size); \ 179 if (Mode == 0) gzread(f, ptr, size); \ 180 } 181 182 // Make the timing events trigger faster as we are currently assuming everything 183 // takes one cycle, which is not the case on real hardware. 184 // FIXME: Count the proper cycle and get rid of this 185 #define BIAS 2 186 #define PSXCLK 33868800 /* 33.8688 MHz */ 187 188 enum { 189 PSX_TYPE_NTSC = 0, 190 PSX_TYPE_PAL 191 }; // PSX Types 192 193 enum { 194 CPU_DYNAREC = 0, 195 CPU_INTERPRETER 196 }; // CPU Types 197 198 enum { 199 CDDA_ENABLED_LE = 0, 200 CDDA_DISABLED, 201 CDDA_ENABLED_BE 202 }; // CDDA Types 203 204 int EmuInit(); 205 void EmuReset(); 206 void EmuShutdown(); 207 void EmuUpdate(); 208 209 #ifdef __cplusplus 210 } 211 #endif 212 #endif 213