From 49e3f89c610620c0ef72d7a358c755ebad35a12e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= <joamag@gmail.com>
Date: Wed, 6 Jul 2022 13:09:15 +0100
Subject: [PATCH] feat: new instructions

---
 src/inst.rs | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/inst.rs b/src/inst.rs
index 98a88bbb..60b2d822 100644
--- a/src/inst.rs
+++ b/src/inst.rs
@@ -412,9 +412,9 @@ pub const EXTENDED: [(fn(&mut Cpu), u8, &'static str); 256] = [
     (noimpl, 4, "! UNIMP !"),
     (noimpl, 4, "! UNIMP !"),
     (bit_7_h, 8, "BIT 7, H"),
+    (bit_7_l, 8, "BIT 7, L"),
     (noimpl, 4, "! UNIMP !"),
-    (noimpl, 4, "! UNIMP !"),
-    (noimpl, 4, "! UNIMP !"),
+    (bit_7_a, 8, "BIT 7, A"),
     // 0x8 opcodes
     (noimpl, 4, "! UNIMP !"),
     (noimpl, 4, "! UNIMP !"),
@@ -2234,6 +2234,14 @@ fn bit_7_h(cpu: &mut Cpu) {
     bit_h(cpu, 7);
 }
 
+fn bit_7_l(cpu: &mut Cpu) {
+    bit_l(cpu, 7);
+}
+
+fn bit_7_a(cpu: &mut Cpu) {
+    bit_a(cpu, 7);
+}
+
 fn res_0_a(cpu: &mut Cpu) {
     cpu.a = res(cpu.a, 0);
 }
@@ -2342,6 +2350,18 @@ fn bit_h(cpu: &mut Cpu, bit: u8) {
     cpu.set_half_carry(true);
 }
 
+fn bit_l(cpu: &mut Cpu, bit: u8) {
+    cpu.set_sub(false);
+    cpu.set_zero(bit_zero(cpu.l, bit));
+    cpu.set_half_carry(true);
+}
+
+fn bit_a(cpu: &mut Cpu, bit: u8) {
+    cpu.set_sub(false);
+    cpu.set_zero(bit_zero(cpu.a, bit));
+    cpu.set_half_carry(true);
+}
+
 fn add_set_flags(cpu: &mut Cpu, first: u8, second: u8) -> u8 {
     let first = first as u32;
     let second = second as u32;
-- 
GitLab