From c9e01018f24945433f12b97c7ba96599f7fb66dc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= <joamag@gmail.com>
Date: Mon, 22 May 2023 00:54:38 +0100
Subject: [PATCH] chore: more APU read support

---
 src/apu.rs | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/apu.rs b/src/apu.rs
index 18190557..3b2f08f8 100644
--- a/src/apu.rs
+++ b/src/apu.rs
@@ -330,6 +330,12 @@ impl Apu {
 
     pub fn read(&mut self, addr: u16) -> u8 {
         match addr {
+            // 0xFF10 — NR10: Channel 1 sweep
+            0xff10 => {
+                (self.ch1_sweep_slope & 0x07)
+                    | (if self.ch1_sweep_increase { 0x08 } else { 0x00 })
+                    | ((self.ch1_sweep_pace & 0x07) << 4)
+            }
             // 0xFF11 — NR11: Channel 1 length timer & duty cycle
             0xff11 => (self.ch1_wave_duty & 0x03) << 6,
             // 0xFF12 — NR12: Channel 1 volume & envelope
@@ -391,6 +397,9 @@ impl Apu {
                     | if self.sound_enabled { 0x80 } else { 0x00 })
             }
 
+            // 0xFF30-0xFF3F — Wave pattern RAM
+            0xff30..=0xff3f => self.wave_ram[addr as usize & 0x000f],
+
             _ => {
                 warnln!("Reading from unknown APU location 0x{:04x}", addr);
                 0xff
-- 
GitLab