From d72442577faab1bb1fe261cf58af2a9cc54b1c20 Mon Sep 17 00:00:00 2001 From: Thomas Epperson Date: Thu, 8 Feb 2024 09:10:16 -0600 Subject: [PATCH] nes: Remove unused arguments. snes: add cgram. --- nes/rust/src/controller.rs | 15 ++------------- nes/rust/src/motherboard.rs | 4 ---- nes/rust/src/windows/main.rs | 14 +++++--------- snes/rust/src/ppu.rs | 8 ++++++-- snes/rust/src/windows/main.rs | 13 +++++++------ 5 files changed, 20 insertions(+), 34 deletions(-) diff --git a/nes/rust/src/controller.rs b/nes/rust/src/controller.rs index 8b582bb..e77a6fe 100644 --- a/nes/rust/src/controller.rs +++ b/nes/rust/src/controller.rs @@ -400,8 +400,6 @@ pub trait NesControllerTrait { fn read_data( &mut self, screen: &common_emulator::video::RgbImage, - ppux: u16, - ppuy: u16, x: u16, y: u16, ) -> u8; @@ -579,14 +577,12 @@ impl NesControllerTrait for FourScore { fn read_data( &mut self, screen: &common_emulator::video::RgbImage, - ppux: u16, - ppuy: u16, x: u16, y: u16, ) -> u8 { match self.clock_counter { - 0..=7 => self.controllers[0].read_data(screen, ppux, ppuy, x, y), - 8..=15 => self.controllers[1].read_data(screen, ppux, ppuy, x, y), + 0..=7 => self.controllers[0].read_data(screen, x, y), + 8..=15 => self.controllers[1].read_data(screen, x, y), 16..=17 => 0, 18 => 0xFF, 19..=23 => 0, @@ -638,8 +634,6 @@ impl NesControllerTrait for DummyController { fn read_data( &mut self, screen: &common_emulator::video::RgbImage, - ppux: u16, - ppuy: u16, x: u16, y: u16, ) -> u8 { @@ -705,8 +699,6 @@ impl NesControllerTrait for Zapper { fn read_data( &mut self, screen: &common_emulator::video::RgbImage, - ppux: u16, - ppuy: u16, x: u16, y: u16, ) -> u8 { @@ -717,7 +709,6 @@ impl NesControllerTrait for Zapper { y: y as f32, }); if color[0] > 200 && color[1] > 200 && color[2] > 200 { - println!("Detect color at {},{} {},{}", ppux, ppuy, x, y); d |= 1 << 3; } } @@ -896,8 +887,6 @@ impl NesControllerTrait for StandardController { fn read_data( &mut self, screen: &common_emulator::video::RgbImage, - ppux: u16, - ppuy: u16, x: u16, y: u16, ) -> u8 { diff --git a/nes/rust/src/motherboard.rs b/nes/rust/src/motherboard.rs index 32c8c49..63b492d 100644 --- a/nes/rust/src/motherboard.rs +++ b/nes/rust/src/motherboard.rs @@ -377,8 +377,6 @@ impl NesMotherboard { 0x4016 => { let d = self.controllers[0].read_data( per.ppu.get_frame(), - per.ppu.column(), - per.ppu.row(), self.x, self.y, ) & 0x1f; @@ -388,8 +386,6 @@ impl NesMotherboard { 0x4017 => { let d = self.controllers[1].read_data( per.ppu.get_frame(), - per.ppu.column(), - per.ppu.row(), self.x, self.y, ) & 0x1f; diff --git a/nes/rust/src/windows/main.rs b/nes/rust/src/windows/main.rs index 21bdea3..617758d 100644 --- a/nes/rust/src/windows/main.rs +++ b/nes/rust/src/windows/main.rs @@ -955,17 +955,17 @@ impl TrackedWindow for MainNesWindow { }) .sense(egui::Sense::click_and_drag()), ); - if (r.clicked() || r.dragged()) && !self.mouse { - self.mouse = true; - self.mouse_miss = false; - self.mouse_delay = 15; - } else if (r.clicked_by(egui::PointerButton::Secondary) + if (r.clicked_by(egui::PointerButton::Secondary) || r.dragged_by(egui::PointerButton::Secondary)) && !self.mouse { self.mouse = true; self.mouse_miss = true; self.mouse_delay = 15; + } else if (r.clicked() || r.dragged()) && !self.mouse { + self.mouse = true; + self.mouse_miss = false; + self.mouse_delay = 15; } if r.hovered() { if let Some(pos) = r.hover_pos() { @@ -992,11 +992,7 @@ impl TrackedWindow for MainNesWindow { && pixel.b() > 100; //println!("Hover at {:?}", pos - r.rect.left_top()); - } else { - self.mouse_vision = false; } - } else { - self.mouse_vision = false; } } }); diff --git a/snes/rust/src/ppu.rs b/snes/rust/src/ppu.rs index 0861d5f..1b1768e 100644 --- a/snes/rust/src/ppu.rs +++ b/snes/rust/src/ppu.rs @@ -105,12 +105,16 @@ impl SnesPpu { #[non_exhaustive] #[serde_with::serde_as] #[derive(serde::Serialize, serde::Deserialize)] -pub struct SnesPpu2 {} +pub struct SnesPpu2 { + /// Where palette data is stored + #[serde_as(as = "Bytes")] + cgram: [u8; 512], +} impl SnesPpu2 { /// Construct the struct pub fn new() -> Self { - Self {} + Self { cgram: [0; 512] } } /// Read a register on the ppu diff --git a/snes/rust/src/windows/main.rs b/snes/rust/src/windows/main.rs index b389961..62603fc 100644 --- a/snes/rust/src/windows/main.rs +++ b/snes/rust/src/windows/main.rs @@ -887,12 +887,13 @@ impl TrackedWindow for MainSnesWindow { }) .sense(egui::Sense::click_and_drag()), ); - if r.clicked() || r.dragged() { + if (r.clicked() || r.dragged()) && !self.mouse { self.mouse = true; self.mouse_miss = false; self.mouse_delay = 10; - } else if r.clicked_by(egui::PointerButton::Secondary) - || r.dragged_by(egui::PointerButton::Secondary) + } else if (r.clicked_by(egui::PointerButton::Secondary) + || r.dragged_by(egui::PointerButton::Secondary)) + && !self.mouse { self.mouse = true; self.mouse_miss = true; @@ -906,9 +907,9 @@ impl TrackedWindow for MainSnesWindow { let pixel = c.local.image.get_pixel(coord / zoom); self.mouse_vision = !self.mouse_miss - && pixel.r() > 10 - && pixel.g() > 10 - && pixel.b() > 10; + && pixel.r() > 100 + && pixel.g() > 100 + && pixel.b() > 100; //println!("Hover at {:?}", pos - r.rect.left_top()); } else {