From 4b897f48e04878e70409ffda6c645f13a0e4cc36 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 28 Jun 2025 18:57:29 -0400 Subject: [PATCH] Corrigiendo instrucciones segun corax+ opcode test --- src/Interpreter/Interpreter.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Interpreter/Interpreter.cpp b/src/Interpreter/Interpreter.cpp index 3ec7bc3..d5fd8a9 100644 --- a/src/Interpreter/Interpreter.cpp +++ b/src/Interpreter/Interpreter.cpp @@ -333,7 +333,8 @@ void Interpreter::ld_vx_byte(const Instruction& instruction) const void Interpreter::add_vx_byte(const Instruction& instruction) const { - this->machine_state->v[instruction.x] += instruction.kk; + auto& vx = this->machine_state->v[instruction.x]; + vx = (vx + instruction.kk) & 0xFF; } void Interpreter::ld_vx_vy(const Instruction& instruction) const @@ -362,7 +363,7 @@ void Interpreter::add_vx_vy(const Instruction& instruction) const const auto& vy = this->machine_state->v[instruction.y]; auto& vf = this->machine_state->v[0xF]; - if (vx + vy > 0xFF) + if (vx + vy > 0x100) { vf = 1; } @@ -371,7 +372,7 @@ void Interpreter::add_vx_vy(const Instruction& instruction) const vf = 0; } - vx += vy; + vx = (vx + vy) & 0xFF; } void Interpreter::sub_vx_vy(const Instruction& instruction) const @@ -380,7 +381,7 @@ void Interpreter::sub_vx_vy(const Instruction& instruction) const const auto& vy = this->machine_state->v[instruction.y]; auto& vf = this->machine_state->v[0xF]; - if (vx > vy) + if (vx >= vy) { vf = 1; } @@ -389,7 +390,7 @@ void Interpreter::sub_vx_vy(const Instruction& instruction) const vf = 0; } - vx -= vy; + vx = (vx - vy) & 0xFF; } void Interpreter::shr_vx_vy(const Instruction& instruction) const @@ -421,7 +422,7 @@ void Interpreter::subn_vx_vy(const Instruction& instruction) const const auto& vy = this->machine_state->v[instruction.y]; auto& vf = this->machine_state->v[0xF]; - if (vy > vx) + if (vy >= vx) { vf = 1; } @@ -430,7 +431,7 @@ void Interpreter::subn_vx_vy(const Instruction& instruction) const vf = 0; } - vx = vy - vx; + vx = (vy - vx) & 0xFF; } void Interpreter::shl_vx_vy(const Instruction& instruction) const @@ -453,7 +454,7 @@ void Interpreter::shl_vx_vy(const Instruction& instruction) const vf = 0; } - vx = vx << 1; + vx = vx << 1 & 0xFF; } void Interpreter::sne_vx_vy(const Instruction& instruction) const