2012-11-18 19:15:59 +01:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the *
|
|
|
|
* Free Software Foundation, Inc., *
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file contains common definitions and includes for all parts of the
|
|
|
|
* emulator core.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __PSXCOMMON_H__
|
|
|
|
#define __PSXCOMMON_H__
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
// System includes
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <zlib.h>
|
|
|
|
|
|
|
|
// Define types
|
|
|
|
typedef int8_t s8;
|
|
|
|
typedef int16_t s16;
|
|
|
|
typedef int32_t s32;
|
|
|
|
typedef int64_t s64;
|
|
|
|
typedef intptr_t sptr;
|
|
|
|
|
|
|
|
typedef uint8_t u8;
|
|
|
|
typedef uint16_t u16;
|
|
|
|
typedef uint32_t u32;
|
|
|
|
typedef uint64_t u64;
|
|
|
|
typedef uintptr_t uptr;
|
|
|
|
|
|
|
|
typedef uint8_t boolean;
|
|
|
|
|
|
|
|
#ifndef TRUE
|
|
|
|
#define TRUE 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef FALSE
|
|
|
|
#define FALSE 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Local includes
|
|
|
|
#include "system.h"
|
|
|
|
#include "debug.h"
|
|
|
|
|
|
|
|
#if defined (__LINUX__) || defined (__MACOSX__)
|
|
|
|
#define strnicmp strncasecmp
|
|
|
|
#endif
|
|
|
|
#define __inline inline
|
|
|
|
|
|
|
|
// Enables NLS/internationalization if active
|
|
|
|
#ifdef ENABLE_NLS
|
|
|
|
|
|
|
|
#include <libintl.h>
|
|
|
|
|
|
|
|
#undef _
|
|
|
|
#define _(String) gettext(String)
|
|
|
|
#ifdef gettext_noop
|
|
|
|
# define N_(String) gettext_noop (String)
|
|
|
|
#else
|
|
|
|
# define N_(String) (String)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//If running under Mac OS X, use the Localizable.strings file instead.
|
|
|
|
#elif defined(_MACOSX)
|
|
|
|
#ifdef PCSXRCORE
|
2014-05-22 06:24:14 +02:00
|
|
|
__private_extern char* Pcsxr_locale_text(char* toloc);
|
2012-11-18 19:15:59 +01:00
|
|
|
#define _(String) Pcsxr_locale_text(String)
|
|
|
|
#define N_(String) String
|
|
|
|
#else
|
|
|
|
#ifndef PCSXRPLUG
|
|
|
|
#warning please define the plug being built to use Mac OS X localization!
|
|
|
|
#define _(msgid) msgid
|
|
|
|
#define N_(msgid) msgid
|
|
|
|
#else
|
|
|
|
//Kludge to get the preprocessor to accept PCSXRPLUG as a variable.
|
|
|
|
#define PLUGLOC_x(x,y) x ## y
|
|
|
|
#define PLUGLOC_y(x,y) PLUGLOC_x(x,y)
|
|
|
|
#define PLUGLOC PLUGLOC_y(PCSXRPLUG,_locale_text)
|
2014-05-22 06:24:14 +02:00
|
|
|
__private_extern char* PLUGLOC(char* toloc);
|
2012-11-18 19:15:59 +01:00
|
|
|
#define _(String) PLUGLOC(String)
|
|
|
|
#define N_(String) String
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define _(msgid) msgid
|
|
|
|
#define N_(msgid) msgid
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern FILE *emuLog;
|
|
|
|
extern int Log;
|
|
|
|
|
|
|
|
void __Log(char *fmt, ...);
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char Gpu[MAXPATHLEN];
|
|
|
|
char Spu[MAXPATHLEN];
|
|
|
|
char Cdr[MAXPATHLEN];
|
|
|
|
char Pad1[MAXPATHLEN];
|
|
|
|
char Pad2[MAXPATHLEN];
|
|
|
|
char Net[MAXPATHLEN];
|
2012-12-13 15:26:27 +01:00
|
|
|
char Sio1[MAXPATHLEN];
|
2012-11-18 19:15:59 +01:00
|
|
|
char Mcd1[MAXPATHLEN];
|
|
|
|
char Mcd2[MAXPATHLEN];
|
|
|
|
char Bios[MAXPATHLEN];
|
|
|
|
char BiosDir[MAXPATHLEN];
|
|
|
|
char PluginsDir[MAXPATHLEN];
|
|
|
|
char PatchesDir[MAXPATHLEN];
|
2012-12-13 15:26:27 +01:00
|
|
|
char IsoImgDir[MAXPATHLEN];
|
2016-04-01 01:09:36 +02:00
|
|
|
char PsxExeName[12];
|
2012-11-18 19:15:59 +01:00
|
|
|
boolean Xa;
|
2013-02-14 20:18:22 +01:00
|
|
|
boolean SioIrq;
|
2012-11-18 19:15:59 +01:00
|
|
|
boolean Mdec;
|
|
|
|
boolean PsxAuto;
|
2014-04-16 20:04:29 +02:00
|
|
|
u8 Cdda;
|
2012-11-18 19:15:59 +01:00
|
|
|
boolean HLE;
|
|
|
|
boolean SlowBoot;
|
|
|
|
boolean Debug;
|
|
|
|
boolean PsxOut;
|
|
|
|
boolean SpuIrq;
|
|
|
|
boolean RCntFix;
|
|
|
|
boolean UseNet;
|
|
|
|
boolean VSyncWA;
|
2013-11-28 12:34:19 +01:00
|
|
|
boolean NoMemcard;
|
2016-04-01 01:09:36 +02:00
|
|
|
boolean PerGameMcd;
|
2012-11-18 19:15:59 +01:00
|
|
|
boolean Widescreen;
|
2013-03-02 00:44:31 +01:00
|
|
|
boolean HideCursor;
|
2013-08-27 19:07:20 +02:00
|
|
|
boolean SaveWindowPos;
|
|
|
|
s32 WindowPos[2];
|
2012-11-18 19:15:59 +01:00
|
|
|
u8 Cpu; // CPU_DYNAREC or CPU_INTERPRETER
|
|
|
|
u8 PsxType; // PSX_TYPE_NTSC or PSX_TYPE_PAL
|
2014-01-24 14:59:46 +01:00
|
|
|
u32 RewindCount;
|
2014-02-04 11:15:07 +01:00
|
|
|
u32 RewindInterval;
|
2016-03-30 16:07:35 +02:00
|
|
|
u32 AltSpeed1; // Percent relative to natural speed.
|
|
|
|
u32 AltSpeed2;
|
2014-07-24 06:06:57 +02:00
|
|
|
u8 HackFix;
|
2016-04-01 01:09:36 +02:00
|
|
|
u8 MemHack;
|
2016-05-08 14:34:45 +02:00
|
|
|
boolean OverClock; // enable overclocking
|
|
|
|
u8 PsxClock;
|
2016-05-16 17:17:19 +02:00
|
|
|
// PGXP variables
|
|
|
|
boolean PGXP_GTE;
|
|
|
|
boolean PGXP_Cache;
|
|
|
|
boolean PGXP_Texture;
|
2012-11-18 19:15:59 +01:00
|
|
|
#ifdef _WIN32
|
|
|
|
char Lang[256];
|
|
|
|
#endif
|
|
|
|
} PcsxConfig;
|
|
|
|
|
|
|
|
extern PcsxConfig Config;
|
|
|
|
extern boolean NetOpened;
|
2014-04-17 23:26:36 +02:00
|
|
|
|
|
|
|
// It is safe if these overflow
|
|
|
|
extern u32 rewind_counter;
|
|
|
|
extern u8 vblank_count_hideafter;
|
2012-11-18 19:15:59 +01:00
|
|
|
|
|
|
|
#define gzfreeze(ptr, size) { \
|
|
|
|
if (Mode == 1) gzwrite(f, ptr, size); \
|
|
|
|
if (Mode == 0) gzread(f, ptr, size); \
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make the timing events trigger faster as we are currently assuming everything
|
|
|
|
// takes one cycle, which is not the case on real hardware.
|
|
|
|
// FIXME: Count the proper cycle and get rid of this
|
2016-05-15 10:10:10 +02:00
|
|
|
extern u32 PsxClockSpeed;
|
2012-11-18 19:15:59 +01:00
|
|
|
#define BIAS 2
|
2016-05-08 14:34:45 +02:00
|
|
|
#define PSXCLK PsxClockSpeed /* 33.8688 MHz */
|
2012-11-18 19:15:59 +01:00
|
|
|
|
|
|
|
enum {
|
|
|
|
PSX_TYPE_NTSC = 0,
|
|
|
|
PSX_TYPE_PAL
|
|
|
|
}; // PSX Types
|
|
|
|
|
|
|
|
enum {
|
|
|
|
CPU_DYNAREC = 0,
|
|
|
|
CPU_INTERPRETER
|
|
|
|
}; // CPU Types
|
|
|
|
|
2014-04-16 20:04:29 +02:00
|
|
|
enum {
|
|
|
|
CDDA_ENABLED_LE = 0,
|
|
|
|
CDDA_DISABLED,
|
|
|
|
CDDA_ENABLED_BE
|
|
|
|
}; // CDDA Types
|
|
|
|
|
2012-11-18 19:15:59 +01:00
|
|
|
int EmuInit();
|
|
|
|
void EmuReset();
|
|
|
|
void EmuShutdown();
|
|
|
|
void EmuUpdate();
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|