frontend: generic: preliminary SDL support
[pcsx_rearmed.git] / libpcsxcore / psxcommon.h
CommitLineData
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
29extern "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
48typedef int8_t s8;
49typedef int16_t s16;
50typedef int32_t s32;
51typedef int64_t s64;
52typedef intptr_t sptr;
53
54typedef uint8_t u8;
55typedef uint16_t u16;
56typedef uint32_t u32;
57typedef uint64_t u64;
58typedef uintptr_t uptr;
59
60typedef 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"
ef79bbde
P
72
73#if defined (__LINUX__) || defined (__MACOSX__)
74#define strnicmp strncasecmp
75#endif
76#define __inline inline
77
78// Enables NLS/internationalization if active
79#ifdef ENABLE_NLS
80
81#include <libintl.h>
82
83#undef _
84#define _(String) gettext(String)
85#ifdef gettext_noop
86# define N_(String) gettext_noop (String)
87#else
88# define N_(String) (String)
89#endif
90
91#else
92
93#define _(msgid) msgid
94#define N_(msgid) msgid
95
96#endif
97
98extern FILE *emuLog;
99extern int Log;
100
101void __Log(char *fmt, ...);
102
103typedef struct {
104 char Gpu[MAXPATHLEN];
105 char Spu[MAXPATHLEN];
106 char Cdr[MAXPATHLEN];
107 char Pad1[MAXPATHLEN];
108 char Pad2[MAXPATHLEN];
109 char Net[MAXPATHLEN];
110 char Sio1[MAXPATHLEN];
111 char Mcd1[MAXPATHLEN];
112 char Mcd2[MAXPATHLEN];
113 char Bios[MAXPATHLEN];
114 char BiosDir[MAXPATHLEN];
115 char PluginsDir[MAXPATHLEN];
116 char PatchesDir[MAXPATHLEN];
117 boolean Xa;
118 boolean Sio;
119 boolean Mdec;
120 boolean PsxAuto;
121 boolean Cdda;
122 boolean HLE;
123 boolean Debug;
124 boolean PsxOut;
125 boolean SpuIrq;
126 boolean RCntFix;
127 boolean UseNet;
128 boolean VSyncWA;
4feed8d3 129 boolean CdrReschedule;
ef79bbde
P
130 u8 Cpu; // CPU_DYNAREC or CPU_INTERPRETER
131 u8 PsxType; // PSX_TYPE_NTSC or PSX_TYPE_PAL
132#ifdef _WIN32
133 char Lang[256];
134#endif
135} PcsxConfig;
136
137extern PcsxConfig Config;
138extern boolean NetOpened;
139
140#define gzfreeze(ptr, size) { \
141 if (Mode == 1) gzwrite(f, ptr, size); \
142 if (Mode == 0) gzread(f, ptr, size); \
143}
144
145// Make the timing events trigger faster as we are currently assuming everything
146// takes one cycle, which is not the case on real hardware.
147// FIXME: Count the proper cycle and get rid of this
148#define BIAS 2
149#define PSXCLK 33868800 /* 33.8688 MHz */
150
151enum {
152 PSX_TYPE_NTSC = 0,
153 PSX_TYPE_PAL
154}; // PSX Types
155
156enum {
157 CPU_DYNAREC = 0,
158 CPU_INTERPRETER
159}; // CPU Types
160
161int EmuInit();
162void EmuReset();
163void EmuShutdown();
164void EmuUpdate();
165
166#ifdef __cplusplus
167}
168#endif
169#endif