-
Notifications
You must be signed in to change notification settings - Fork 0
/
SoftRes.cpp
55 lines (47 loc) · 1.15 KB
/
SoftRes.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
//
// SoftRes.cpp
// MIPS_Emulator
//
// Created by Matt on 7/10/16.
// Copyright © 2016 Matt. All rights reserved.
//
#include "SoftRes.h"
SoftRes::SoftRes() {
addresses.push_back(SOFTRES_BASE);
addresses.push_back(SOFTRES_BASE+11);
addresses.push_back(SOFTRES_PHYBASE);
addresses.push_back(SOFTRES_PHYBASE+11);
}
SoftRes::~SoftRes() {
}
void SoftRes::initDevice() {
registers[0] = 0x0;
registers[1] = 0x0;
registers[2] = 0x0;
registers[3] = 0x0;
registers[8] = 0x0A;
}
std::vector<uint32_t> SoftRes::getAddresses() {
return this->addresses;
}
uint8_t SoftRes::readByte(uint32_t address) {
address &= 0xFF;
if (address > 11) {
throw std::runtime_error("Memory tried to read from invalid SoftRes address");
}
else {
return registers[address];
}
}
void SoftRes::storeByte(uint32_t address, uint8_t value) {
address &= 0xFF;
if (address > 11) {
throw std::runtime_error("Memory tried to read from invalid SoftRes address");
}
else {
registers[address] = value;
if (registers[3] == GORESET) {
throw SoftResetException();
}
}
}