-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindyemulator.cpp
78 lines (62 loc) · 2.13 KB
/
indyemulator.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
74
75
76
77
78
#include "indyemulator.h"
#include "hpc3.h"
#include "mc.h"
#include <iostream>
IndyEmulator::IndyEmulator(QObject *parent) : QObject(parent)
{
this->mb = new memory_bus();
this->p = new processor(mb);
this->mem1 = new memory(256 * 1024 * 1024, true);
mb -> register_memory(0x08000000, mem1->get_size(), mem1);
mb -> register_memory(0xffffffff88000000, mem1->get_size(), mem1); // KSEG0
mb -> register_memory(0xffffffffa8000000, mem1->get_size(), mem1); // KSEG1
mb -> register_memory(0, 512 * 1024, mem1); // needed for exception vectors
this->mem2 = new memory(256 * 1024 * 1024, true);
mb -> register_memory(0x20000000, mem2->get_size(), mem2);
this->m_prom = new rom("test.bin");
mb -> register_memory(0xffffffff1fc00000, m_prom->get_size(), m_prom);
mb -> register_memory(0xffffffff9fc00000, m_prom->get_size(), m_prom); // KSEG0
mb -> register_memory(0xffffffffbfc00000, m_prom->get_size(), m_prom); // KSEG1
this->pmc = new mc(p);
mb -> register_memory(0xffffffff1fa00000, pmc->get_size(), pmc);
mb -> register_memory(0xffffffff9fa00000, pmc->get_size(), pmc); // KSEG0
mb -> register_memory(0xffffffffbfa00000, pmc->get_size(), pmc); // KSEG1
this->hpc = new hpc3("sram.dat");
mb -> register_memory(0xffffffff1fb00000, hpc->get_size(), hpc);
mb -> register_memory(0xffffffff9fb00000, hpc->get_size(), hpc); // KSEG0
mb -> register_memory(0xffffffffbfb00000, hpc->get_size(), hpc); // KSEG1
this->isRunning = false;
}
IndyEmulator::~IndyEmulator() {
delete this->p;
delete this->mb;
delete this->pmc;
delete this->mem1;
delete this->mem2;
delete this->m_prom;
delete this->hpc;
}
void IndyEmulator::execute() {
p->reset();
while(this->isRunning) {
p->tick();
count++;
if(count % 1000000 == 0) {
emit emitPC(count);
}
}
}
void IndyEmulator::singleStep() {
p->tick();
emit emitPC(count);
count++;
}
void IndyEmulator::start() {
this->isRunning = true;
}
void IndyEmulator::stop() {
this->isRunning = false;
}
processor *IndyEmulator::getProcessor() {
return this->p;
}