small refactor for readability
This commit is contained in:
@@ -9,11 +9,14 @@
|
||||
namespace chocochip8 {
|
||||
|
||||
class Interpreter {
|
||||
private:
|
||||
using reg_t = uint8_t;
|
||||
using sreg_t = unsigned;
|
||||
|
||||
public:
|
||||
constexpr static uint16_t scResetVector = 0x0200;
|
||||
constexpr static sreg_t scResetVector = 0x0200;
|
||||
constexpr static size_t scMemorySize = 4096;
|
||||
|
||||
private:
|
||||
enum {
|
||||
R_V0, R_V1, R_V2, R_V3, R_V4, R_V5, R_V6, R_V7,
|
||||
R_V8, R_V9, R_VA, R_VB, R_VC, R_VD, R_VE, R_VF,
|
||||
@@ -32,20 +35,20 @@ private:
|
||||
public:
|
||||
Interpreter(unsigned ticksPerSecond, Display &display, Buzzer &buzzer, Keypad &keypad);
|
||||
void tick();
|
||||
void loadProgram(uint16_t where, char const* data, size_t count);
|
||||
void loadProgram(size_t where, char const* data, size_t count);
|
||||
|
||||
private:
|
||||
void executeArithmetic(Opcode opcode, int iReg, uint8_t operand);
|
||||
void executeArithmetic(Opcode opcode, int iReg, reg_t operand);
|
||||
|
||||
private:
|
||||
std::vector<uint8_t> mvMemory;
|
||||
std::stack<uint16_t> mCallStack;
|
||||
std::stack<sreg_t> mCallStack;
|
||||
Display &mrDisplay;
|
||||
Buzzer &mrBuzzer;
|
||||
Keypad &mrKeypad;
|
||||
const unsigned mcTicksPerSecond;
|
||||
unsigned mvSpecialReg[SR_COUNT];
|
||||
uint8_t mvReg[R_COUNT];
|
||||
sreg_t mvSpecialReg[SR_COUNT];
|
||||
reg_t mvReg[R_COUNT];
|
||||
}; // class Interpreter
|
||||
|
||||
}; // namespace chocohip8
|
||||
|
||||
Reference in New Issue
Block a user