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