-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcpu.hpp
More file actions
31 lines (26 loc) · 977 Bytes
/
Copy pathcpu.hpp
File metadata and controls
31 lines (26 loc) · 977 Bytes
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
#ifndef CPU_HPP
#define CPU_HPP
#include <array>
#include <cstdint>
template<size_t STACK,
size_t MEMORY,
size_t REGISTER,
size_t KEYS,
size_t WIDTH,
size_t HEIGHT>
struct CPU
{
std::array<uint32_t, WIDTH * HEIGHT> display { 0 };
std::array<uint16_t, STACK> stack { 0 };
std::array<uint8_t, MEMORY> memory { 0 };
std::array<uint8_t, REGISTER> registers { 0 };
std::array<uint8_t, KEYS> keypads { 0 };
uint16_t pc; // used to store the currently executing address
uint16_t I; // this register is generally used to store memory addresses
uint16_t opcode; // the current operation code
uint8_t sp; // used to point to the topmost level of the stack
// these are automatically decremented at a rate of 60Hz.
uint8_t dt; // delay of the program
uint8_t st; // delay of the sounds
};
#endif // CPU_HPP