Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libsnes/bsnes/nall/moduloarray.hpp
2 views
1
#ifndef NALL_MODULO_HPP
2
#define NALL_MODULO_HPP
3
4
#include <nall/serializer.hpp>
5
6
namespace nall {
7
template<typename T, int size> class modulo_array {
8
public:
9
inline T operator[](int index) const {
10
return buffer[size + index];
11
}
12
13
inline T read(int index) const {
14
return buffer[size + index];
15
}
16
17
inline void write(unsigned index, const T value) {
18
buffer[index] =
19
buffer[index + size] =
20
buffer[index + size + size] = value;
21
}
22
23
void serialize(serializer &s) {
24
s.array(buffer, size * 3);
25
}
26
27
modulo_array() {
28
buffer = new T[size * 3]();
29
}
30
31
~modulo_array() {
32
delete[] buffer;
33
}
34
35
private:
36
T *buffer;
37
};
38
}
39
40
#endif
41
42