Skip to content

Commit d724425

Browse files
committed
nes: Remove unused arguments.
snes: add cgram.
1 parent 4211806 commit d724425

File tree

5 files changed

+20
-34
lines changed

5 files changed

+20
-34
lines changed

nes/rust/src/controller.rs

+2-13
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,6 @@ pub trait NesControllerTrait {
400400
fn read_data(
401401
&mut self,
402402
screen: &common_emulator::video::RgbImage,
403-
ppux: u16,
404-
ppuy: u16,
405403
x: u16,
406404
y: u16,
407405
) -> u8;
@@ -579,14 +577,12 @@ impl NesControllerTrait for FourScore {
579577
fn read_data(
580578
&mut self,
581579
screen: &common_emulator::video::RgbImage,
582-
ppux: u16,
583-
ppuy: u16,
584580
x: u16,
585581
y: u16,
586582
) -> u8 {
587583
match self.clock_counter {
588-
0..=7 => self.controllers[0].read_data(screen, ppux, ppuy, x, y),
589-
8..=15 => self.controllers[1].read_data(screen, ppux, ppuy, x, y),
584+
0..=7 => self.controllers[0].read_data(screen, x, y),
585+
8..=15 => self.controllers[1].read_data(screen, x, y),
590586
16..=17 => 0,
591587
18 => 0xFF,
592588
19..=23 => 0,
@@ -638,8 +634,6 @@ impl NesControllerTrait for DummyController {
638634
fn read_data(
639635
&mut self,
640636
screen: &common_emulator::video::RgbImage,
641-
ppux: u16,
642-
ppuy: u16,
643637
x: u16,
644638
y: u16,
645639
) -> u8 {
@@ -705,8 +699,6 @@ impl NesControllerTrait for Zapper {
705699
fn read_data(
706700
&mut self,
707701
screen: &common_emulator::video::RgbImage,
708-
ppux: u16,
709-
ppuy: u16,
710702
x: u16,
711703
y: u16,
712704
) -> u8 {
@@ -717,7 +709,6 @@ impl NesControllerTrait for Zapper {
717709
y: y as f32,
718710
});
719711
if color[0] > 200 && color[1] > 200 && color[2] > 200 {
720-
println!("Detect color at {},{} {},{}", ppux, ppuy, x, y);
721712
d |= 1 << 3;
722713
}
723714
}
@@ -896,8 +887,6 @@ impl NesControllerTrait for StandardController {
896887
fn read_data(
897888
&mut self,
898889
screen: &common_emulator::video::RgbImage,
899-
ppux: u16,
900-
ppuy: u16,
901890
x: u16,
902891
y: u16,
903892
) -> u8 {

nes/rust/src/motherboard.rs

-4
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,6 @@ impl NesMotherboard {
377377
0x4016 => {
378378
let d = self.controllers[0].read_data(
379379
per.ppu.get_frame(),
380-
per.ppu.column(),
381-
per.ppu.row(),
382380
self.x,
383381
self.y,
384382
) & 0x1f;
@@ -388,8 +386,6 @@ impl NesMotherboard {
388386
0x4017 => {
389387
let d = self.controllers[1].read_data(
390388
per.ppu.get_frame(),
391-
per.ppu.column(),
392-
per.ppu.row(),
393389
self.x,
394390
self.y,
395391
) & 0x1f;

nes/rust/src/windows/main.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -955,17 +955,17 @@ impl TrackedWindow for MainNesWindow {
955955
})
956956
.sense(egui::Sense::click_and_drag()),
957957
);
958-
if (r.clicked() || r.dragged()) && !self.mouse {
959-
self.mouse = true;
960-
self.mouse_miss = false;
961-
self.mouse_delay = 15;
962-
} else if (r.clicked_by(egui::PointerButton::Secondary)
958+
if (r.clicked_by(egui::PointerButton::Secondary)
963959
|| r.dragged_by(egui::PointerButton::Secondary))
964960
&& !self.mouse
965961
{
966962
self.mouse = true;
967963
self.mouse_miss = true;
968964
self.mouse_delay = 15;
965+
} else if (r.clicked() || r.dragged()) && !self.mouse {
966+
self.mouse = true;
967+
self.mouse_miss = false;
968+
self.mouse_delay = 15;
969969
}
970970
if r.hovered() {
971971
if let Some(pos) = r.hover_pos() {
@@ -992,11 +992,7 @@ impl TrackedWindow for MainNesWindow {
992992
&& pixel.b() > 100;
993993

994994
//println!("Hover at {:?}", pos - r.rect.left_top());
995-
} else {
996-
self.mouse_vision = false;
997995
}
998-
} else {
999-
self.mouse_vision = false;
1000996
}
1001997
}
1002998
});

snes/rust/src/ppu.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,16 @@ impl SnesPpu {
105105
#[non_exhaustive]
106106
#[serde_with::serde_as]
107107
#[derive(serde::Serialize, serde::Deserialize)]
108-
pub struct SnesPpu2 {}
108+
pub struct SnesPpu2 {
109+
/// Where palette data is stored
110+
#[serde_as(as = "Bytes")]
111+
cgram: [u8; 512],
112+
}
109113

110114
impl SnesPpu2 {
111115
/// Construct the struct
112116
pub fn new() -> Self {
113-
Self {}
117+
Self { cgram: [0; 512] }
114118
}
115119

116120
/// Read a register on the ppu

snes/rust/src/windows/main.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -887,12 +887,13 @@ impl TrackedWindow for MainSnesWindow {
887887
})
888888
.sense(egui::Sense::click_and_drag()),
889889
);
890-
if r.clicked() || r.dragged() {
890+
if (r.clicked() || r.dragged()) && !self.mouse {
891891
self.mouse = true;
892892
self.mouse_miss = false;
893893
self.mouse_delay = 10;
894-
} else if r.clicked_by(egui::PointerButton::Secondary)
895-
|| r.dragged_by(egui::PointerButton::Secondary)
894+
} else if (r.clicked_by(egui::PointerButton::Secondary)
895+
|| r.dragged_by(egui::PointerButton::Secondary))
896+
&& !self.mouse
896897
{
897898
self.mouse = true;
898899
self.mouse_miss = true;
@@ -906,9 +907,9 @@ impl TrackedWindow for MainSnesWindow {
906907

907908
let pixel = c.local.image.get_pixel(coord / zoom);
908909
self.mouse_vision = !self.mouse_miss
909-
&& pixel.r() > 10
910-
&& pixel.g() > 10
911-
&& pixel.b() > 10;
910+
&& pixel.r() > 100
911+
&& pixel.g() > 100
912+
&& pixel.b() > 100;
912913

913914
//println!("Hover at {:?}", pos - r.rect.left_top());
914915
} else {

0 commit comments

Comments
 (0)