Untargeted Improvements
Hello everyone! New day, new devlog!
I added some new instructions!
CCF — Clear Carry Flag
SCF — Set Carry Flag
RRA — Rotate Right A
RLA — Rotate Left A
RRCA — Rotate Right Circular A
RLCA — Rotate Left Circular A
CPL — Complement Bits of A Register
Figuring out some of the bitwise logic for the rotation command, especially RLA (and because I was working in the car) was kind of difficult.
fn rra(&mut self) -> u8 {
let carry = if self.registers.f.carry { 1 } else { 0 };
let value = self.registers.a;
self.registers.f.zero = false;
self.registers.f.subtract = false;
self.registers.f.carry = value & 0x1 == 1;
self.registers.f.half_carry = false;
(value >> 1) | (carry << 7)
}
fn rla(&mut self) -> u8 {
let carry = if self.registers.f.carry { 1 } else { 0 };
let value = self.registers.a;
self.registers.f.zero = false;
self.registers.f.subtract = false;
self.registers.f.carry = (value >> 7) & 0x1 == 1;
// Originally I was doing the bit isolation before the bitshift,
// and I forgot about the bitshift initially,
// so I was just doing a bit isolation and then clippy complained b/c it would never be true.
self.registers.f.half_carry = false;
(value << 1) | carry
}
Next are BIT, RES, and SET, and then more instructions!
The image is a question I saw on Protobowl a few months back.
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.