Skip to content

Commit

Permalink
Fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
João Freitas authored and joajfreitas committed Oct 28, 2023
1 parent bc298ca commit 3302c7f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 23 deletions.
1 change: 1 addition & 0 deletions src/bitwise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub fn test_bit16<const INDEX: u8>(word: u16) -> bool {
word & mask == mask
}

#[allow(unused)]
pub fn get_bit8<const INDEX: u8>(word: u8) -> u8 {
(word >> INDEX) & 0x1
}
Expand Down
9 changes: 3 additions & 6 deletions src/debugger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,10 @@ impl Debugger {
let mut gameboy = Gameboy::new();
gameboy.set_debug(true);

let mut debugger = Debugger {
Debugger {
gameboy,
breakpoints: Vec::new(),
};



debugger
}
}

fn check(&self) -> bool {
Expand Down Expand Up @@ -127,6 +123,7 @@ pub struct DebuggerTextInterface<'a> {
}

impl DebuggerTextInterface<'_> {
#[allow(clippy::new_without_default)]
pub fn new() -> Self {
let debugger = Debugger::new();
let mut lua = Lua::new();
Expand Down
9 changes: 3 additions & 6 deletions src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl Memory {
}

pub fn slice(&self, range: MemoryRange) -> &[u8] {
&self.mem[(range.start as usize)..(range.end as usize)]
&self.mem[range.start..range.end]
}
}

Expand Down Expand Up @@ -132,7 +132,7 @@ impl Bus {
}

pub fn clone_from_slice(&mut self, range: MemoryRange, slice: &[u8]) {
self.memory().mem[(range.start as usize)..(range.end as usize)].clone_from_slice(slice);
self.memory().mem[range.start..range.end].clone_from_slice(slice);
}

//pub fn slice(&self, range: MemoryRange) -> &[u8] {
Expand Down Expand Up @@ -197,9 +197,6 @@ impl Bus {
}

pub fn vram(&self) -> Vec<u8> {
self.memory().mem[map::VRAM]
.into_iter()
.map(|x| *x)
.collect()
self.memory().mem[map::VRAM].to_vec()
}
}
8 changes: 0 additions & 8 deletions src/ppu.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::bitwise;
use crate::memory::Bus;
use tile::TileMap;

Expand Down Expand Up @@ -52,7 +51,6 @@ impl Ppu {
self.tilemap = TileMap::load(&self.bus.vram());
self.mode = dbg!(Mode::PixelTransfer);
dbg!(self.dots_this_frame);
return;
}
}

Expand All @@ -67,7 +65,6 @@ impl Ppu {
let address = WIDTH * self.bus.ly() as usize + current_pixel;
if address >= WIDTH * HEIGHT {
self.bus.ly();
self.dots_this_frame;
}

let column = address % WIDTH;
Expand All @@ -80,8 +77,6 @@ impl Ppu {
let tile_x = column % 8;
let tile_y = line % 8;

let tile_pixel_address = 8 * tile_y + tile_x;

let tile = self.tilemap.tiles[tile_data_address as usize];
println!("{:#02X?}", tile.pixels);

Expand All @@ -98,19 +93,16 @@ impl Ppu {
if self.bus.ly() >= HEIGHT as u8 {
self.mode = dbg!(Mode::VBlank);
dbg!(self.dots_this_frame);
return;
} else if self.dots_this_frame % 456 == 0 {
self.mode = dbg!(Mode::OamScan);
dbg!(self.dots_this_frame);
return;
}
}

fn v_blank(&mut self) {
if self.dots_this_frame == 0 {
self.mode = dbg!(Mode::OamScan);
dbg!(self.dots_this_frame);
return;
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/ppu/tile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ pub struct Tile {

impl Tile {

#[allow(unused)]
pub fn load(data: &[u8; 16]) -> Tile {
Tile {
pixels: data.clone(),
pixels: *data,
}
}
pub fn get_pixel(&self, y: usize, x: usize) -> u8{
Expand All @@ -27,7 +28,7 @@ impl fmt::Debug for Tile {
for j in 0..8 {
write!(f, "{}", self.get_pixel(i, j))?;
}
write!(f, "\n")?;
writeln!(f)?;

}
write!(f, "")
Expand All @@ -49,7 +50,7 @@ impl TileMap {
}
}

pub fn load(vram: &Vec<u8>) -> TileMap {
pub fn load(vram: &[u8]) -> TileMap {
let mut tilemap = TileMap::default();

for i in 0..384 {
Expand Down

0 comments on commit 3302c7f

Please sign in to comment.