-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.cpp
73 lines (50 loc) · 1.55 KB
/
main.cpp
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
#include "init.h"
#include "sleeping.h"
#include "const.h"
#include <thread>
static GBA* gba;
void exception_handler() {
// keep open the screen to still be able to check the register/memory contents (unstable)
gba->CPU.Paused = true;
gba->PPU.SyncToVideo = true;
while (!gba->Shutdown) {
sleep_ms(16);
}
}
#undef BENCHMARKING
#ifdef BENCHMARKING
#include <chrono>
const size_t tests = 500000;
void benchmark() {
auto start = std::chrono::high_resolution_clock::now();
for (size_t i = 0; i < tests; i++) {
gba->CPU.Registers[i & 0xf] = gba->CPU.sbcs_cv(i, i + 1, i & 1);
}
auto elapsed = std::chrono::high_resolution_clock::now() - start;
printf("First one: %lldus\n", std::chrono::duration_cast<std::chrono::microseconds>(elapsed).count());
start = std::chrono::high_resolution_clock::now();
for (size_t i = 0; i < tests; i++) {
gba->CPU.Registers[i & 0xf] = gba->CPU.sbcs_cv_old(i, i + 1, i & 1);
}
elapsed = std::chrono::high_resolution_clock::now() - start;
printf("Second one: %lldus\n", std::chrono::duration_cast<std::chrono::microseconds>(elapsed).count());
}
#endif
#undef main
int main() {
gba = Initializer::init();
// gba->LoadBIOS(std::string("D:\\Data\\GBA\\BIOS\\bios.bin"));
// gba->LoadBIOS(std::string(BIOS_FILE));
#ifdef BENCHMARKING
benchmark();
return 0;
#endif
#ifdef DO_BREAKPOINTS
gba->CPU.Paused = false;
#endif
atexit(exception_handler);
std::thread ui_thread(ui_run);
gba->Run();
ui_thread.join();
return 0;
}