forked from p1pkin/demul
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Demul.c
80 lines (65 loc) · 1.48 KB
/
Demul.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
* Demul
* Copyright (C) 2006 Demul Team
*
* Demul is not free software: you can't redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Demul isn't distributed in the hope that it will be useful,
* and WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
*/
#include "demul.h"
#include "interpreter.h"
#include "dynarec.h"
#include "arm.h"
#include "gpu.h"
#include "plugins.h"
#include "configure.h"
#include "debug.h"
bool EmuRunning = false;
static bool EmuOpened = false;
int OpenEmu() {
if (EmuOpened) return 1;
if (!LoadConfig())
return false;
while (!loadPlugins()) {
if (!SetConfig())
return false;
}
while (memOpen() == 0) {
if (!SetConfig())
return false;
}
if (intpOpen() == 0) return 0;
if (armOpen() == 0) return 0;
if (recOpen() == 0) return 0;
EmuOpened = true;
return 1;
}
void RunEmu(void *p) {
EmuRunning = true;
if (!openPlugins())
return;
for (;; ) {
if (cfg.sh4mode == MODE_INTERPRETER) intpExecute();
else recExecute();
}
}
void CloseEmu() {
if (EmuRunning)
closePlugins();
unloadPlugins();
#ifdef DEMUL_DEBUG
closeDebug();
#endif
memClose();
armClose();
intpClose();
recClose();
EmuRunning = false;
EmuOpened = false;
}