Kinoko
A reimplementation of Mario Kart Wii's physics engine in C++
Toggle main menu visibility
Loading...
Searching...
No Matches
main.cc
1
#include "host/KReplaySystem.hh"
2
#include "host/KTestSystem.hh"
3
#include "host/Option.hh"
4
5
#include <egg/core/ExpHeap.hh>
6
7
using namespace
Kinoko;
8
9
#if defined(__arm64__) || defined(__aarch64__)
10
static
void
FlushDenormalsToZero() {
11
uint64_t fpcr;
12
asm
(
"mrs %0, fpcr"
:
"=r"
(fpcr));
13
asm
(
"msr fpcr, %0"
::
"r"
(fpcr | (1 << 24)));
14
}
15
#elif defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86)
16
#include <immintrin.h>
17
18
static
void
FlushDenormalsToZero() {
19
_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
20
}
21
#endif
22
23
static
void
*s_memorySpace =
nullptr
;
24
static
EGG::Heap
*s_rootHeap =
nullptr
;
25
26
static
void
InitMemory() {
27
s_memorySpace = malloc(MEMORY_SPACE_SIZE);
28
s_rootHeap = EGG::ExpHeap::create(s_memorySpace, MEMORY_SPACE_SIZE, DEFAULT_OPT);
29
s_rootHeap->setName(
"EGGRoot"
);
30
s_rootHeap->becomeCurrentHeap();
31
32
EGG::SceneManager::SetRootHeap(s_rootHeap);
33
}
34
35
int
main(
int
argc,
char
**argv) {
36
FlushDenormalsToZero();
37
InitMemory();
38
39
// The hashmap cannot be constexpr, as it heap-allocates
40
// Therefore, it cannot be static, as memory needs to be initialized first
41
// TODO: Allow memory initialization before any other static initializers
42
const
std::unordered_map<std::string, std::function<
KSystem
*()>> modeMap = {
43
{
"test"
, []() ->
KSystem
* {
return
KTestSystem::CreateInstance(); }},
44
{
"replay"
, []() ->
KSystem
* {
return
KReplaySystem::CreateInstance(); }},
45
};
46
47
if
(argc < 2) {
48
PANIC(
"Too few arguments!"
);
49
}
50
51
KSystem
*sys =
nullptr
;
52
53
// The first argument is the executable, so we ignore it
54
// The second argument is the mode
55
const
std::string mode = argv[1];
56
57
auto
it = modeMap.find(mode);
58
if
(it != modeMap.end()) {
59
sys = it->second();
60
}
else
{
61
PANIC(
"Invalid mode!"
);
62
}
63
64
sys->
parseOptions
(argc - 2, argv + 2);
65
sys->
init
();
66
return
sys->
run
() ? 0 : 1;
67
}
Kinoko::EGG::Heap
A high-level representation of a memory heap for managing dynamic memory allocation....
Definition
Heap.hh:24
Kinoko::KSystem
Base interface for a Kinoko system.
Definition
KSystem.hh:10
Kinoko::KSystem::init
virtual void init()=0
Initializes the system.
Kinoko::KSystem::run
virtual bool run()=0
Executes a run.
Kinoko::KSystem::parseOptions
virtual void parseOptions(int argc, char **argv)=0
Parses non-generic command line options.
host
main.cc
Made by
Malleo
. Logo by
vabold
. Website generated by
Doxygen
1.17.0