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 02110-1301 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 // It is safe if these overflow
34 u32 rewind_counter=0;
35 u8 vblank_count_hideafter=0;
36
EmuInit()37 int EmuInit() {
38 return psxInit();
39 }
40
EmuReset()41 void EmuReset() {
42 FreeCheatSearchResults();
43 FreeCheatSearchMem();
44
45 psxReset();
46 }
47
EmuShutdown()48 void EmuShutdown() {
49 ClearAllCheats();
50 FreeCheatSearchResults();
51 FreeCheatSearchMem();
52
53 FreePPFCache();
54
55 psxShutdown();
56
57 CleanupMemSaveStates();
58 }
59
EmuUpdate()60 void EmuUpdate() {
61 // Do not allow hotkeys inside a softcall from HLE BIOS
62 if (!Config.HLE || !hleSoftCall)
63 SysUpdate();
64
65 ApplyCheats();
66
67 if (vblank_count_hideafter) {
68 if (!(--vblank_count_hideafter)) {
69 GPU_showScreenPic(NULL);
70 }
71 }
72
73 if (Config.RewindInterval > 0 && !(++rewind_counter%Config.RewindInterval)) {
74 CreateRewindState();
75 }
76 }
77
__Log(char * fmt,...)78 void __Log(char *fmt, ...) {
79 va_list list;
80 #ifdef LOG_STDOUT
81 char tmp[1024];
82 #endif
83
84 va_start(list, fmt);
85 #ifndef LOG_STDOUT
86 vfprintf(emuLog, fmt, list);
87 #else
88 vsprintf(tmp, fmt, list);
89 SysPrintf(tmp);
90 #endif
91 va_end(list);
92 }
93