-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocation.h
75 lines (65 loc) · 1.53 KB
/
location.h
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
#pragma once
#include "header.h"
#include <vector>
#include <map>
const std::map<unsigned int, unsigned char> chrSizes {
{512, 0},
{256, 0},
{128, 1},
{64, 2},
{32, 4},
{16, 5},
{8, 6},
{4, 7},
{0, 0}
};
const std::map<unsigned int, unsigned char> prgSizes {
{512, 0},
{256, 1},
{128, 2},
{64, 3},
{32, 4},
{16, 5},
{8, 6},
{4, 7},
{0, 0}
};
const std::map<unsigned char, unsigned char> mappers {
{0, 0},
{1, 1},
{2, 6},
{3, 3},
{4, 0},
{5, 5}
};
struct Location {
Location() {}
Location(const Header& header) {
prgSize = header.prgSize;
chrSize = header.chrSize;
verticalMirror = header.verticalMirror;
mapper = header.mapper;
}
unsigned int prgStart = -1;
unsigned int chrStart = -1;
unsigned int prgSize = 0;
unsigned int chrSize = 0;
unsigned char mapper = 0;
bool verticalMirror = false;
std::vector<unsigned char> getDescriptor() const {
std::vector<unsigned char> result;
result.push_back(prgSizes.at(prgSize));
result.push_back(0);
result.push_back(chrSizes.at(chrSize));
result.push_back(0);
result.push_back(prgStart >> 2);
result.push_back(prgStart >> 10);
result.push_back(chrStart >> 2);
result.push_back(chrStart >> 10);
result.push_back(0);
result.push_back(0);
result.push_back(mappers.at(mapper));
result.push_back(!verticalMirror);
return result;
}
};