From da181345762838566749a2b5158e35390e015c9c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= <joamag@gmail.com>
Date: Sat, 10 Jun 2023 13:32:37 +0100
Subject: [PATCH] chore: removed public members of genie

---
 src/genie.rs | 16 ++++++++++++----
 src/rom.rs   |  4 ++--
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/genie.rs b/src/genie.rs
index 77f5bb6b..8a1fe39a 100644
--- a/src/genie.rs
+++ b/src/genie.rs
@@ -66,13 +66,21 @@ impl Default for GameGenie {
 
 #[derive(Clone)]
 pub struct GameGenieCode {
-    pub code: String,
-    pub addr: u16,
-    pub new_data: u8,
-    pub old_data: u8,
+    code: String,
+    addr: u16,
+    new_data: u8,
+    old_data: u8,
 }
 
 impl GameGenieCode {
+    pub fn is_valid(&self, value: u8) -> bool {
+        self.old_data == value
+    }
+
+    pub fn new_data(&self) -> u8 {
+        self.new_data
+    }
+
     pub fn short_description(&self) -> String {
         self.code.to_string()
     }
diff --git a/src/rom.rs b/src/rom.rs
index 1444c5e7..350003a9 100644
--- a/src/rom.rs
+++ b/src/rom.rs
@@ -818,9 +818,9 @@ pub static GAME_GENIE: Mbc = Mbc {
             // one that is expected by the Game Genie code, if that's the case
             // applies the patch, otherwise returns the original strategy is
             // going to be used
-            if genie_code.old_data == (rom.mbc.read_rom)(rom, addr) {
+            if genie_code.is_valid((rom.mbc.read_rom)(rom, addr)) {
                 debugln!("Applying Game Genie code: {}", game_genie_code);
-                return genie_code.new_data;
+                return genie_code.new_data();
             }
         }
         (rom.mbc.read_rom)(rom, addr)
-- 
GitLab