Implemented 0x6XKK
parent
e08895d35d
commit
80053eeda7
|
@ -87,5 +87,13 @@ public:
|
|||
* @return
|
||||
*/
|
||||
unsigned short getRegister(unsigned char i);
|
||||
|
||||
/**
|
||||
* Sets a value in the register (V)
|
||||
*
|
||||
* @param i The index of the register to set
|
||||
* @param value The value to be set
|
||||
*/
|
||||
void setRegister(unsigned char i, unsigned short value);
|
||||
};
|
||||
#endif //CHIP8_CHIP8_H
|
||||
|
|
|
@ -49,6 +49,11 @@ private:
|
|||
* Handles Chip8 instruction 0x5000
|
||||
*/
|
||||
static void handle5000(Chip8&, Instruction);
|
||||
|
||||
/**
|
||||
* Handles Chip8 instruction 0x6000
|
||||
*/
|
||||
static void handle6000(Chip8&, Instruction);
|
||||
public:
|
||||
InstructionHandler();
|
||||
|
||||
|
|
|
@ -69,3 +69,7 @@ unsigned short Chip8::getProgramCounter() const {
|
|||
unsigned short Chip8::getRegister(unsigned char reg) {
|
||||
return this->v[reg];
|
||||
}
|
||||
|
||||
void Chip8::setRegister(unsigned char reg, unsigned short value) {
|
||||
this->v[reg] = value;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@ InstructionHandler::InstructionHandler() {
|
|||
this->handlers[0x2000] = handle2000;
|
||||
this->handlers[0x3000] = handle3000;
|
||||
this->handlers[0x4000] = handle4000;
|
||||
this->handlers[0x5000] = handle5000;
|
||||
this->handlers[0x6000] = handle6000;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -108,4 +110,14 @@ void InstructionHandler::handle5000(Chip8& chip8, Instruction instruction) {
|
|||
if (chip8.getRegister(instruction.x()) == chip8.getRegister(instruction.y())) {
|
||||
chip8.setProgramCounter(chip8.getProgramCounter() + 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the 0x6XKK Chip8 instruction which is used to put value KK in register V[x].
|
||||
*
|
||||
* @param chip8 The Chip8 instance
|
||||
* @param instruction The Instruction instance
|
||||
*/
|
||||
void InstructionHandler::handle6000(Chip8& chip8, Instruction instruction) {
|
||||
chip8.setRegister(instruction.x(), instruction.kk());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue