-
Notifications
You must be signed in to change notification settings - Fork 0
/
boot.cpp
69 lines (69 loc) · 837 Bytes
/
boot.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
#include "cpu.cpp"
void reset()
{
gpu.reset();
mmu.reset();
cpu.reset();
}
void step(){
if (cpu.reg.pc > 0x0100)
{
mmu.b = 0;
}
uint8_t op = mmu.read8(cpu.reg.pc++);
cpu.map(op);
cpu.m_tot += cpu.m;
cpu.t_tot += cpu.t;
cpu.gpuStep();
}
void frame()
{
int nxtFrame = cpu.t_tot + 70224;
do
{
step();
} while (cpu.t_tot < nxtFrame);
}
void floop(){
int i;
cin>>i;
for(;i>0;i--)
frame();
}
int main(int argc, char *args[])
{
char ch,name[15];
reset();
cin>>name;
mmu.load(name);
do
{
cin >> ch;
if (ch == 's')
{
step();
}
else if (ch == 'c')
{
frame();
}
else if (ch == 'l')
{
floop();
}
else if (ch == 'e')
{
reset();
}
else if(ch=='r')
{
cpu.printState();
gpu.printState();
}
else if(ch=='m')
{
mmu.dump();
}
} while (ch != 'e');
return 0;
}