Implemented 0x7XKK

main
Tiger 2023-09-15 21:28:07 +02:00
parent 80053eeda7
commit 84a3f0bda5
2 changed files with 16 additions and 0 deletions

View File

@ -54,6 +54,11 @@ private:
* Handles Chip8 instruction 0x6000 * Handles Chip8 instruction 0x6000
*/ */
static void handle6000(Chip8&, Instruction); static void handle6000(Chip8&, Instruction);
/**
* Handles Chip8 instruction 0x7000
*/
static void handle7000(Chip8&, Instruction);
public: public:
InstructionHandler(); InstructionHandler();

View File

@ -9,6 +9,7 @@ InstructionHandler::InstructionHandler() {
this->handlers[0x4000] = handle4000; this->handlers[0x4000] = handle4000;
this->handlers[0x5000] = handle5000; this->handlers[0x5000] = handle5000;
this->handlers[0x6000] = handle6000; this->handlers[0x6000] = handle6000;
this->handlers[0x7000] = handle7000;
} }
/** /**
@ -121,3 +122,13 @@ void InstructionHandler::handle5000(Chip8& chip8, Instruction instruction) {
void InstructionHandler::handle6000(Chip8& chip8, Instruction instruction) { void InstructionHandler::handle6000(Chip8& chip8, Instruction instruction) {
chip8.setRegister(instruction.x(), instruction.kk()); chip8.setRegister(instruction.x(), instruction.kk());
} }
/**
* Handles the 0x7XKK Chip8 instruction which is used to add the value KK to register V[x] and set the result in register V[x].
*
* @param chip8 The Chip8 instance
* @param instruction The Instruction instance
*/
void InstructionHandler::handle7000(Chip8& chip8, Instruction instruction) {
chip8.setRegister(instruction.x(), chip8.getRegister(instruction.x()) + instruction.kk());
}