f118c2dbb813d4668b9b838e4fa43ec91376c35c
[pcsx_rearmed.git] / libpcsxcore / psxcommon.c
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 #include "psxcommon.h"
21 #include "r3000a.h"
22 #include "psxbios.h"
23
24 #include "cheat.h"
25 #include "ppf.h"
26
27 PcsxConfig Config;
28 boolean NetOpened = FALSE;
29
30 int Log = 0;
31 FILE *emuLog = NULL;
32
33 int EmuInit() {
34         return psxInit();
35 }
36
37 void EmuReset() {
38         FreeCheatSearchResults();
39         FreeCheatSearchMem();
40
41         psxReset();
42 }
43
44 void EmuShutdown() {
45         ClearAllCheats();
46         FreeCheatSearchResults();
47         FreeCheatSearchMem();
48
49         FreePPFCache();
50
51         psxShutdown();
52 }
53
54 void EmuUpdate() {
55         // Do not allow hotkeys inside a softcall from HLE BIOS
56         if (!Config.HLE || !hleSoftCall)
57                 SysUpdate();
58
59         ApplyCheats();
60 }
61
62 void __Log(char *fmt, ...) {
63         va_list list;
64 #ifdef LOG_STDOUT
65         char tmp[1024];
66 #endif
67
68         va_start(list, fmt);
69 #ifndef LOG_STDOUT
70         vfprintf(emuLog, fmt, list);
71 #else
72         vsprintf(tmp, fmt, list);
73         SysPrintf(tmp);
74 #endif
75         va_end(list);
76 }