deal with some more annoying warnings
[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
3cf51e08 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
ef79bbde
P
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>
ef79bbde
P
52
53// Define types
54typedef int8_t s8;
55typedef int16_t s16;
56typedef int32_t s32;
57typedef int64_t s64;
58typedef intptr_t sptr;
59
60typedef uint8_t u8;
61typedef uint16_t u16;
62typedef uint32_t u32;
63typedef uint64_t u64;
64typedef uintptr_t uptr;
65
66typedef 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"
ef79bbde 78
89f33b73 79#ifndef _WIN32
ef79bbde
P
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
104extern FILE *emuLog;
105extern int Log;
106
107void __Log(char *fmt, ...);
108
109typedef 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 u8 Cpu; // CPU_DYNAREC or CPU_INTERPRETER
136 u8 PsxType; // PSX_TYPE_NTSC or PSX_TYPE_PAL
137#ifdef _WIN32
138 char Lang[256];
139#endif
140} PcsxConfig;
141
142extern PcsxConfig Config;
143extern boolean NetOpened;
144
496d88d4 145struct PcsxSaveFuncs {
146 void *(*open)(const char *name, const char *mode);
147 int (*read)(void *file, void *buf, u32 len);
148 int (*write)(void *file, const void *buf, u32 len);
149 long (*seek)(void *file, long offs, int whence);
150 void (*close)(void *file);
151};
152extern struct PcsxSaveFuncs SaveFuncs;
153
ef79bbde 154#define gzfreeze(ptr, size) { \
496d88d4 155 if (Mode == 1) SaveFuncs.write(f, ptr, size); \
156 if (Mode == 0) SaveFuncs.read(f, ptr, size); \
ef79bbde
P
157}
158
159// Make the timing events trigger faster as we are currently assuming everything
160// takes one cycle, which is not the case on real hardware.
161// FIXME: Count the proper cycle and get rid of this
162#define BIAS 2
163#define PSXCLK 33868800 /* 33.8688 MHz */
164
165enum {
166 PSX_TYPE_NTSC = 0,
167 PSX_TYPE_PAL
168}; // PSX Types
169
170enum {
171 CPU_DYNAREC = 0,
172 CPU_INTERPRETER
173}; // CPU Types
174
175int EmuInit();
176void EmuReset();
177void EmuShutdown();
178void EmuUpdate();
179
180#ifdef __cplusplus
181}
182#endif
183#endif