-
Notifications
You must be signed in to change notification settings - Fork 0
/
lucid.cc
101 lines (90 loc) · 2.42 KB
/
lucid.cc
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include <memory/memory.hh>
#include <cpu/sh4_cpu.hh>
#include <cpu/sh4_decode.hh>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
int main(int argc, char **argv)
{
const std::string bios_arg = "-bios", flash_arg = "-flash", binary_arg = "-bin";
std::string bios_file, flash_file, binary_file;
bool load_bios = false, load_flash = false, load_binary = false;
if (argc < 2)
{
std::cerr << "Usage: " << argv[0] << " <bios_file>\n";
return 1;
}
else
{
for (int i = 1; i < argc; i++)
{
if (bios_arg.compare(argv[i]) == 0)
{
if (argv[i + 1] != NULL)
{
bios_file = argv[i + 1];
i++;
load_bios = true;
}
else
{
std::cerr << "No bios file provided\n";
return 1;
}
}
else if (flash_arg.compare(argv[i]) == 0)
{
if (argv[i + 1] != NULL)
{
flash_file = argv[i + 1];
i++;
load_flash = true;
}
else
{
std::cerr << "No flash file provided\n";
return 1;
}
}
else if (binary_arg.compare(argv[i]) == 0)
{
if (argv[i + 1] != NULL)
{
binary_file = argv[i + 1];
i++;
load_binary = true;
}
else
{
std::cerr << "No binary file provided\n";
return 1;
}
}
}
}
// Initialize CPU
Sh4_Cpu cpu;
std::cout << "CPU Initialized" << std::endl;
Memory memory;
if (load_bios)
{
memory.load_bios(bios_file);
}
else
{
std::cout << "In order for Lucid to work we need a BIOS file...!" << std::endl;
return 1;
}
if (load_flash) memory.load_flash(flash_file);
if (load_binary)
{
memory.load_binary(binary_file);
cpu.set_pc(0x00200000);
cpu.set_delay_pc(0x00200000 + 2);
}
std::cout << "Memory Map Initialized" << std::endl;
Sh4_Decode decoder(&cpu, &memory);
decoder.run();
return 0;
}