From 45b6f484b05e2c94e06c137ac72aaad18ee2c0de Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= <joamag@gmail.com>
Date: Fri, 8 Jul 2022 15:51:39 +0100
Subject: [PATCH] feat: initial rom implementation

---
 src/cpu.rs |  4 +++-
 src/lib.rs |  1 +
 src/rom.rs | 23 +++++++++++++++++++++++
 3 files changed, 27 insertions(+), 1 deletion(-)
 create mode 100644 src/rom.rs

diff --git a/src/cpu.rs b/src/cpu.rs
index 86f7dc97..0b717de1 100644
--- a/src/cpu.rs
+++ b/src/cpu.rs
@@ -112,7 +112,9 @@ impl Cpu {
         // @todo this is so bad, need to improve this by an order
         // of magnitude
         if self.halted {
-            if ((self.mmu.ie & 0x01 == 0x01) && self.mmu.ppu().int_vblank()) || ((self.mmu.ie & 0x04 == 0x04) && self.mmu.timer().int_tima()) {
+            if ((self.mmu.ie & 0x01 == 0x01) && self.mmu.ppu().int_vblank())
+                || ((self.mmu.ie & 0x04 == 0x04) && self.mmu.timer().int_tima())
+            {
                 self.halted = false;
             }
         }
diff --git a/src/lib.rs b/src/lib.rs
index 11af82a5..42a29836 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -5,5 +5,6 @@ pub mod inst;
 pub mod mmu;
 pub mod pad;
 pub mod ppu;
+pub mod rom;
 pub mod timer;
 pub mod util;
diff --git a/src/rom.rs b/src/rom.rs
new file mode 100644
index 00000000..8c6fbeda
--- /dev/null
+++ b/src/rom.rs
@@ -0,0 +1,23 @@
+pub struct Rom {
+    data: Vec<u8>,
+}
+
+pub enum RomType {
+    RomOnly = 0x00,
+    Mbc1 = 0x01,
+    Mbc1Ram = 0x02,
+    Mbc1RamBattery = 0x03,
+    Mbc2 = 0x05,
+    Mbc2Battery = 0x06,
+    Unknown = 0xff,
+}
+
+impl Rom {
+    pub fn title() -> &'static str {
+        "asdas"
+    }
+
+    pub fn rom_type() -> RomType {
+        RomType::RomOnly
+    }
+}
-- 
GitLab