Skip to content

Commit

Permalink
fix clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
corwinkuiper committed Jan 3, 2025
1 parent edb539d commit b964fa4
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 20 deletions.
2 changes: 1 addition & 1 deletion agb/examples/dma_effect_circular_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fn main(mut gba: agb::Gba) -> ! {

let x_pos = pos.x.floor().max(0) as u16;
let y_pos = pos.y.floor().max(0);
let x_adjustment = x_pos << 8 | x_pos;
let x_adjustment = (x_pos << 8) | x_pos;
for (i, value) in circle_poses.iter_mut().enumerate() {
let i = i as i32;
if i <= y_pos || i >= y_pos + 64 {
Expand Down
2 changes: 1 addition & 1 deletion agb/examples/dynamic_tiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn main(mut gba: agb::Gba) -> ! {
let mut value = 0;

for j in 0..4 {
value |= (value << 8) | ((x + i) % 8) | ((y + j) % 8) << 4;
value |= (value << 8) | ((x + i) % 8) | (((y + j) % 8) << 4);
}

*bit = value;
Expand Down
2 changes: 1 addition & 1 deletion agb/src/bitarray.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ impl<const N: usize> Bitarray<N> {

pub fn get(&self, index: usize) -> Option<bool> {
if index < N * 32 {
Some((self.a[index / 32] >> (index % 32) & 1) != 0)
Some(((self.a[index / 32] >> (index % 32)) & 1) != 0)
} else {
None
}
Expand Down
10 changes: 7 additions & 3 deletions agb/src/display/bitmap4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ impl Bitmap4<'_> {

let c = addr.get(x_in_screen, y_in_screen);
if x & 0b1 != 0 {
addr.set(x_in_screen, y_in_screen, c & 0xff | u16::from(colour) << 8);
addr.set(
x_in_screen,
y_in_screen,
c & 0xff | (u16::from(colour) << 8),
);
} else {
addr.set(x_in_screen, y_in_screen, c & 0xff00 | u16::from(colour));
}
Expand Down Expand Up @@ -117,7 +121,7 @@ impl Bitmap4<'_> {
let x_in_screen = (x / 2) as usize;
let y_in_screen = y as usize;
let c = u16::from(colour);
addr.set(x_in_screen, y_in_screen, c << 8 | c);
addr.set(x_in_screen, y_in_screen, (c << 8) | c);
}

/// Fills specified page with color.
Expand All @@ -131,7 +135,7 @@ impl Bitmap4<'_> {

for x in 0..(WIDTH / 2) as usize {
for y in 0..(HEIGHT as usize) {
addr.set(x, y, c << 8 | c);
addr.set(x, y, (c << 8) | c);
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions agb/src/display/object/sprites/sprite_allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,10 @@ impl DynamicSprite {
/// Wipes the sprite
pub fn clear(&mut self, paletted_pixel: usize) {
assert!(paletted_pixel < 0x10);
let reset =
(paletted_pixel | paletted_pixel << 4 | paletted_pixel << 8 | paletted_pixel << 12)
as u16;
let reset = (paletted_pixel
| (paletted_pixel << 4)
| (paletted_pixel << 8)
| (paletted_pixel << 12)) as u16;
self.data.fill(reset);
}

Expand Down
4 changes: 2 additions & 2 deletions agb/src/display/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,10 @@ impl MovableWindow {
self.inner.commit(self.id);

let left_right =
(self.rect.position.x as u16) << 8 | (self.rect.position.x + self.rect.size.x) as u16;
((self.rect.position.x as u16) << 8) | (self.rect.position.x + self.rect.size.x) as u16;

let top_bottom =
(self.rect.position.y as u16) << 8 | (self.rect.position.y + self.rect.size.y) as u16;
((self.rect.position.y as u16) << 8) | (self.rect.position.y + self.rect.size.y) as u16;
unsafe {
REG_HORIZONTAL_BASE.add(self.id).write_volatile(left_right);
REG_VERTICAL_BASE.add(self.id).write_volatile(top_bottom);
Expand Down
6 changes: 3 additions & 3 deletions agb/src/dma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ impl Dma {
self.ctrl_addr.set(
(0b10 << 0x15) | // keep destination address fixed
// (0b00 << 0x17) | // increment the source address each time
1 << 0x19 | // repeat the copy each hblank
(1 << 0x19) | // repeat the copy each hblank
// 0 << 0x1a | // copy in half words (see n_transfers above)
0b10 << 0x1c | // copy each hblank
1 << 0x1f | // enable the dma
(0b10 << 0x1c) | // copy each hblank
(1 << 0x1f) | // enable the dma
n_transfers, // the number of halfwords to copy
);

Expand Down
2 changes: 1 addition & 1 deletion agb/src/save/flash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pub fn detect_chip_id() -> Result<u16, Error> {
issue_flash_command(CMD_READ_CHIP_ID);
let high = unsafe { read_raw_byte(0x0E000001) };
let low = unsafe { read_raw_byte(0x0E000000) };
let id = (high as u16) << 8 | low as u16;
let id = ((high as u16) << 8) | low as u16;
issue_flash_command(CMD_READ_CONTENTS);
Ok(id)
}
Expand Down
6 changes: 3 additions & 3 deletions agb/src/sound/dmg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ impl SweepSettings {

fn as_bits(&self) -> u16 {
(u16::from(self.number_of_sweep_shifts) & 0b111)
| ((1 - self.sound_direction.as_bits()) << 3) // sweep works backwards
| (u16::from(self.sweep_time) & 0b111) << 4
| ((1 - self.sound_direction.as_bits()) << 3) // sweep works backwards
| ((u16::from(self.sweep_time) & 0b111) << 4)
}
}

Expand Down Expand Up @@ -210,7 +210,7 @@ impl EnvelopeSettings {
}

fn as_bits(&self) -> u16 {
u16::from(self.step_time) << 8
(u16::from(self.step_time) << 8)
| (self.direction.as_bits() << 11)
| (u16::from(self.initial_volume) << 12)
}
Expand Down
2 changes: 1 addition & 1 deletion agb/src/sound/mixer/hw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub(super) fn set_sound_control_register_for_mixer() {
SOUND_CONTROL_X.set(1 << 7);

// Set the sound bias PWM resampling rate to 8bit at 65536Hz (default for most games)
SOUND_BIAS.set(SOUND_BIAS.get() | 1 << 14);
SOUND_BIAS.set(SOUND_BIAS.get() | (1 << 14));
}

pub(super) fn set_timer_counter_for_frequency_and_enable(timer: &mut Timer, frequency: i32) {
Expand Down
2 changes: 1 addition & 1 deletion tracker/agb-midi-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub fn parse_midi(midi_info: &MidiInfo) -> Track {

for (i, preset) in sf2.get_presets().iter().enumerate() {
preset_lookup.insert(
preset.get_bank_number() << 16 | preset.get_patch_number(),
(preset.get_bank_number() << 16) | preset.get_patch_number(),
i,
);
}
Expand Down

0 comments on commit b964fa4

Please sign in to comment.