mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-22 15:16:40 +11:00
Fix clippy lint for inline format args (#358)
Also updates the rust edition to 2021 for agb since I couldn't do both - [x] Changelog updated / no changelog update needed
This commit is contained in:
commit
5a7c30428b
9 changed files with 37 additions and 61 deletions
|
@ -2,7 +2,7 @@
|
||||||
name = "agb"
|
name = "agb"
|
||||||
version = "0.12.2"
|
version = "0.12.2"
|
||||||
authors = ["Corwin Kuiper <corwin@kuiper.dev>", "Gwilym Kuiper <gw@ilym.me>"]
|
authors = ["Corwin Kuiper <corwin@kuiper.dev>", "Gwilym Kuiper <gw@ilym.me>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
description = "Library for Game Boy Advance Development"
|
description = "Library for Game Boy Advance Development"
|
||||||
license = "MPL-2.0"
|
license = "MPL-2.0"
|
||||||
repository = "https://github.com/agbrs/agb"
|
repository = "https://github.com/agbrs/agb"
|
||||||
|
|
|
@ -22,7 +22,7 @@ fn main() {
|
||||||
let mut o_files = vec![];
|
let mut o_files = vec![];
|
||||||
|
|
||||||
for &a in asm.iter() {
|
for &a in asm.iter() {
|
||||||
println!("cargo:rerun-if-changed={}", a);
|
println!("cargo:rerun-if-changed={a}");
|
||||||
let filename = path::Path::new(a);
|
let filename = path::Path::new(a);
|
||||||
let filename = filename.with_extension("o");
|
let filename = filename.with_extension("o");
|
||||||
let filename = filename
|
let filename = filename
|
||||||
|
@ -31,7 +31,7 @@ fn main() {
|
||||||
.to_str()
|
.to_str()
|
||||||
.expect("Please make it valid utf-8");
|
.expect("Please make it valid utf-8");
|
||||||
|
|
||||||
let out_file_path = format!("{}/{}", out_dir, filename);
|
let out_file_path = format!("{out_dir}/{filename}");
|
||||||
|
|
||||||
let out = std::process::Command::new("arm-none-eabi-as")
|
let out = std::process::Command::new("arm-none-eabi-as")
|
||||||
.arg("-mthumb-interwork")
|
.arg("-mthumb-interwork")
|
||||||
|
@ -40,7 +40,7 @@ fn main() {
|
||||||
.args(["-o", out_file_path.as_str()])
|
.args(["-o", out_file_path.as_str()])
|
||||||
.arg(a)
|
.arg(a)
|
||||||
.output()
|
.output()
|
||||||
.unwrap_or_else(|_| panic!("failed to compile {}", a));
|
.unwrap_or_else(|_| panic!("failed to compile {a}"));
|
||||||
|
|
||||||
assert!(
|
assert!(
|
||||||
out.status.success(),
|
out.status.success(),
|
||||||
|
@ -50,7 +50,7 @@ fn main() {
|
||||||
|
|
||||||
for warning_line in String::from_utf8_lossy(&out.stderr).split('\n') {
|
for warning_line in String::from_utf8_lossy(&out.stderr).split('\n') {
|
||||||
if !warning_line.is_empty() {
|
if !warning_line.is_empty() {
|
||||||
println!("cargo:warning={}", warning_line);
|
println!("cargo:warning={warning_line}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ fn main(mut gba: agb::Gba) -> ! {
|
||||||
let mut renderer = FONT.render_text((4u16, 0u16).into());
|
let mut renderer = FONT.render_text((4u16, 0u16).into());
|
||||||
let mut writer = renderer.writer(1, 2, &mut bg, &mut vram);
|
let mut writer = renderer.writer(1, 2, &mut bg, &mut vram);
|
||||||
|
|
||||||
writeln!(&mut writer, "Frame {}", frame).unwrap();
|
writeln!(&mut writer, "Frame {frame}").unwrap();
|
||||||
writer.commit();
|
writer.commit();
|
||||||
|
|
||||||
frame += 1;
|
frame += 1;
|
||||||
|
|
|
@ -170,8 +170,7 @@ mod test {
|
||||||
let address = &*first_box as *const _ as usize;
|
let address = &*first_box as *const _ as usize;
|
||||||
assert!(
|
assert!(
|
||||||
(EWRAM_START..EWRAM_END).contains(&address),
|
(EWRAM_START..EWRAM_END).contains(&address),
|
||||||
"ewram is located between 0x0200_0000 and 0x0204_0000, address was actually found to be {:#010X}",
|
"ewram is located between 0x0200_0000 and 0x0204_0000, address was actually found to be {address:#010X}"
|
||||||
address
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,8 +196,7 @@ mod test {
|
||||||
let address = &*x as *const _ as usize;
|
let address = &*x as *const _ as usize;
|
||||||
assert!(
|
assert!(
|
||||||
(EWRAM_START..EWRAM_END).contains(&address),
|
(EWRAM_START..EWRAM_END).contains(&address),
|
||||||
"ewram is located between 0x0200_0000 and 0x0204_0000, address was actually found to be {:#010X}",
|
"ewram is located between 0x0200_0000 and 0x0204_0000, address was actually found to be {address:#010X}"
|
||||||
address
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,8 +223,7 @@ mod test {
|
||||||
|
|
||||||
assert!(
|
assert!(
|
||||||
0x0200_0000 <= data_end,
|
0x0200_0000 <= data_end,
|
||||||
"data end should be bigger than 0x0200_0000, got {}",
|
"data end should be bigger than 0x0200_0000, got {data_end}"
|
||||||
data_end
|
|
||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
0x0204_0000 > data_end,
|
0x0204_0000 > data_end,
|
||||||
|
@ -240,8 +237,7 @@ mod test {
|
||||||
|
|
||||||
assert!(
|
assert!(
|
||||||
(0x0300_0000..0x0300_8000).contains(&data_end),
|
(0x0300_0000..0x0300_8000).contains(&data_end),
|
||||||
"iwram data end should be in iwram, instead was {}",
|
"iwram data end should be in iwram, instead was {data_end}"
|
||||||
data_end
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,8 +248,7 @@ mod test {
|
||||||
let addr = p as usize;
|
let addr = p as usize;
|
||||||
assert!(
|
assert!(
|
||||||
(0x0300_0000..0x0300_8000).contains(&addr),
|
(0x0300_0000..0x0300_8000).contains(&addr),
|
||||||
"address of allocation should be within iwram, instead at {:?}",
|
"address of allocation should be within iwram, instead at {p:?}"
|
||||||
p
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -313,7 +313,7 @@ pub mod test_runner {
|
||||||
if let Some(mut mgba) = mgba::Mgba::new() {
|
if let Some(mut mgba) = mgba::Mgba::new() {
|
||||||
mgba.print(format_args!("[failed]"), mgba::DebugLevel::Error)
|
mgba.print(format_args!("[failed]"), mgba::DebugLevel::Error)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
mgba.print(format_args!("Error: {}", info), mgba::DebugLevel::Fatal)
|
mgba.print(format_args!("Error: {info}"), mgba::DebugLevel::Fatal)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,10 +370,7 @@ pub mod test_runner {
|
||||||
display::busy_wait_for_vblank();
|
display::busy_wait_for_vblank();
|
||||||
display::busy_wait_for_vblank();
|
display::busy_wait_for_vblank();
|
||||||
let mut mgba = crate::mgba::Mgba::new().unwrap();
|
let mut mgba = crate::mgba::Mgba::new().unwrap();
|
||||||
mgba.print(
|
mgba.print(format_args!("image:{image}"), crate::mgba::DebugLevel::Info)
|
||||||
format_args!("image:{}", image),
|
|
||||||
crate::mgba::DebugLevel::Info,
|
|
||||||
)
|
|
||||||
.unwrap();
|
.unwrap();
|
||||||
display::busy_wait_for_vblank();
|
display::busy_wait_for_vblank();
|
||||||
}
|
}
|
||||||
|
@ -422,8 +419,7 @@ mod test {
|
||||||
let address = ewram_ptr as usize;
|
let address = ewram_ptr as usize;
|
||||||
assert!(
|
assert!(
|
||||||
(0x0200_0000..0x0204_0000).contains(&address),
|
(0x0200_0000..0x0204_0000).contains(&address),
|
||||||
"ewram is located between 0x0200_0000 and 0x0204_0000, address was actually found to be {:#010X}",
|
"ewram is located between 0x0200_0000 and 0x0204_0000, address was actually found to be {address:#010X}",
|
||||||
address
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -437,8 +433,7 @@ mod test {
|
||||||
let address = iwram_ptr as usize;
|
let address = iwram_ptr as usize;
|
||||||
assert!(
|
assert!(
|
||||||
(0x0300_0000..0x0300_8000).contains(&address),
|
(0x0300_0000..0x0300_8000).contains(&address),
|
||||||
"iwram is located between 0x0300_0000 and 0x0300_8000, but was actually found to be at {:#010X}",
|
"iwram is located between 0x0300_0000 and 0x0300_8000, but was actually found to be at {address:#010X}"
|
||||||
address
|
|
||||||
);
|
);
|
||||||
let c = iwram_ptr.read_volatile();
|
let c = iwram_ptr.read_volatile();
|
||||||
assert_eq!(c, 9, "expected content to be 9");
|
assert_eq!(c, 9, "expected content to be 9");
|
||||||
|
@ -456,9 +451,7 @@ mod test {
|
||||||
let address = iwram_ptr as usize;
|
let address = iwram_ptr as usize;
|
||||||
assert!(
|
assert!(
|
||||||
(0x0200_0000..0x0204_0000).contains(&address),
|
(0x0200_0000..0x0204_0000).contains(&address),
|
||||||
"implicit data storage is expected to be in ewram, which is between 0x0300_0000 and 0x0300_8000, but was actually found to be at {:#010X}",
|
"implicit data storage is expected to be in ewram, which is between 0x0300_0000 and 0x0300_8000, but was actually found to be at {address:#010X}" );
|
||||||
address
|
|
||||||
);
|
|
||||||
let c = iwram_ptr.read_volatile();
|
let c = iwram_ptr.read_volatile();
|
||||||
assert_eq!(c, 9, "expected content to be 9");
|
assert_eq!(c, 9, "expected content to be 9");
|
||||||
iwram_ptr.write_volatile(u32::MAX);
|
iwram_ptr.write_volatile(u32::MAX);
|
||||||
|
|
|
@ -51,7 +51,7 @@ impl Mgba {
|
||||||
output: core::fmt::Arguments,
|
output: core::fmt::Arguments,
|
||||||
level: DebugLevel,
|
level: DebugLevel,
|
||||||
) -> Result<(), core::fmt::Error> {
|
) -> Result<(), core::fmt::Error> {
|
||||||
write!(self, "{}", output)?;
|
write!(self, "{output}")?;
|
||||||
self.set_level(level);
|
self.set_level(level);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,9 +78,7 @@ mod test {
|
||||||
for (i, &value) in values.iter().enumerate() {
|
for (i, &value) in values.iter().enumerate() {
|
||||||
assert!(
|
assert!(
|
||||||
value >= 500 / 10 / 3,
|
value >= 500 / 10 / 3,
|
||||||
"{} came up less than expected {}",
|
"{i} came up less than expected {value}"
|
||||||
i,
|
|
||||||
value
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,9 +94,7 @@ mod test {
|
||||||
for (i, &value) in values.iter().enumerate() {
|
for (i, &value) in values.iter().enumerate() {
|
||||||
assert!(
|
assert!(
|
||||||
value >= 500 / 10 / 3,
|
value >= 500 / 10 / 3,
|
||||||
"{} came up less than expected {}",
|
"{i} came up less than expected {value}"
|
||||||
i,
|
|
||||||
value
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,13 +24,13 @@ mod tiled_export {
|
||||||
|
|
||||||
pub fn export_tilemap(out_dir: &str) -> std::io::Result<()> {
|
pub fn export_tilemap(out_dir: &str) -> std::io::Result<()> {
|
||||||
let filename = "map/tilemap.json";
|
let filename = "map/tilemap.json";
|
||||||
println!("cargo:rerun-if-changed={}", filename);
|
println!("cargo:rerun-if-changed={filename}");
|
||||||
let file = File::open(filename)?;
|
let file = File::open(filename)?;
|
||||||
let reader = BufReader::new(file);
|
let reader = BufReader::new(file);
|
||||||
|
|
||||||
let tilemap: TiledTilemap = serde_json::from_reader(reader)?;
|
let tilemap: TiledTilemap = serde_json::from_reader(reader)?;
|
||||||
|
|
||||||
let output_file = File::create(format!("{}/tilemap.rs", out_dir))?;
|
let output_file = File::create(format!("{out_dir}/tilemap.rs"))?;
|
||||||
let mut writer = BufWriter::new(output_file);
|
let mut writer = BufWriter::new(output_file);
|
||||||
|
|
||||||
let tile_data: HashMap<_, _> = tilemap
|
let tile_data: HashMap<_, _> = tilemap
|
||||||
|
@ -57,31 +57,26 @@ mod tiled_export {
|
||||||
|
|
||||||
writeln!(
|
writeln!(
|
||||||
&mut writer,
|
&mut writer,
|
||||||
"pub const COLLISION_TILE: i32 = {};",
|
"pub const COLLISION_TILE: i32 = {COLLISION_TILE};",
|
||||||
COLLISION_TILE
|
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
writeln!(&mut writer, "pub const KILL_TILE: i32 = {};", KILL_TILE)?;
|
writeln!(&mut writer, "pub const KILL_TILE: i32 = {KILL_TILE};")?;
|
||||||
writeln!(&mut writer, "pub const WIN_TILE: i32 = {};", WIN_TILE)?;
|
writeln!(&mut writer, "pub const WIN_TILE: i32 = {WIN_TILE};")?;
|
||||||
|
|
||||||
writeln!(
|
writeln!(&mut writer, "pub const TILE_DATA: &[u32] = &[{tile_info}];")?;
|
||||||
&mut writer,
|
|
||||||
"pub const TILE_DATA: &[u32] = &[{}];",
|
|
||||||
tile_info
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn export_level(out_dir: &str, level_file: &str) -> std::io::Result<()> {
|
pub fn export_level(out_dir: &str, level_file: &str) -> std::io::Result<()> {
|
||||||
let filename = format!("map/{}", level_file);
|
let filename = format!("map/{level_file}");
|
||||||
println!("cargo:rerun-if-changed={}", filename);
|
println!("cargo:rerun-if-changed={filename}");
|
||||||
let file = File::open(filename)?;
|
let file = File::open(filename)?;
|
||||||
let reader = BufReader::new(file);
|
let reader = BufReader::new(file);
|
||||||
|
|
||||||
let level: TiledLevel = serde_json::from_reader(reader)?;
|
let level: TiledLevel = serde_json::from_reader(reader)?;
|
||||||
|
|
||||||
let output_file = File::create(format!("{}/{}.rs", out_dir, level_file))?;
|
let output_file = File::create(format!("{out_dir}/{level_file}.rs"))?;
|
||||||
let mut writer = BufWriter::new(output_file);
|
let mut writer = BufWriter::new(output_file);
|
||||||
|
|
||||||
let layer_1 = level.layers[0]
|
let layer_1 = level.layers[0]
|
||||||
|
@ -103,8 +98,8 @@ mod tiled_export {
|
||||||
|
|
||||||
writeln!(&mut writer, "const WIDTH: u32 = {};", level.width)?;
|
writeln!(&mut writer, "const WIDTH: u32 = {};", level.width)?;
|
||||||
writeln!(&mut writer, "const HEIGHT: u32 = {};", level.height)?;
|
writeln!(&mut writer, "const HEIGHT: u32 = {};", level.height)?;
|
||||||
writeln!(&mut writer, "const TILEMAP: &[u16] = &[{}];", layer_1)?;
|
writeln!(&mut writer, "const TILEMAP: &[u16] = &[{layer_1}];")?;
|
||||||
writeln!(&mut writer, "const BACKGROUND: &[u16] = &[{}];", layer_2)?;
|
writeln!(&mut writer, "const BACKGROUND: &[u16] = &[{layer_2}];")?;
|
||||||
|
|
||||||
let objects = level.layers[2]
|
let objects = level.layers[2]
|
||||||
.objects
|
.objects
|
||||||
|
@ -147,18 +142,15 @@ mod tiled_export {
|
||||||
|
|
||||||
writeln!(
|
writeln!(
|
||||||
&mut writer,
|
&mut writer,
|
||||||
"const SNAILS: &[(i32, i32)] = &[{}];",
|
"const SNAILS: &[(i32, i32)] = &[{snails_str}];",
|
||||||
snails_str
|
|
||||||
)?;
|
)?;
|
||||||
writeln!(
|
writeln!(
|
||||||
&mut writer,
|
&mut writer,
|
||||||
"const SLIMES: &[(i32, i32)] = &[{}];",
|
"const SLIMES: &[(i32, i32)] = &[{slimes_str}];",
|
||||||
slimes_str
|
|
||||||
)?;
|
)?;
|
||||||
writeln!(
|
writeln!(
|
||||||
&mut writer,
|
&mut writer,
|
||||||
"const ENEMY_STOPS: &[(i32, i32)] = &[{}];",
|
"const ENEMY_STOPS: &[(i32, i32)] = &[{enemy_stop_str}];",
|
||||||
enemy_stop_str
|
|
||||||
)?;
|
)?;
|
||||||
writeln!(
|
writeln!(
|
||||||
&mut writer,
|
&mut writer,
|
||||||
|
|
|
@ -10,7 +10,7 @@ fn main() {
|
||||||
let out_dir = env::var("OUT_DIR").expect("OUT_DIR environment variable must be specified");
|
let out_dir = env::var("OUT_DIR").expect("OUT_DIR environment variable must be specified");
|
||||||
|
|
||||||
let playground_filename = "map/map.tmx";
|
let playground_filename = "map/map.tmx";
|
||||||
println!("cargo:rerun-if-changed={}", playground_filename);
|
println!("cargo:rerun-if-changed={playground_filename}");
|
||||||
|
|
||||||
let map = tiled::parse_file(Path::new(playground_filename)).unwrap();
|
let map = tiled::parse_file(Path::new(playground_filename)).unwrap();
|
||||||
|
|
||||||
|
@ -60,11 +60,11 @@ fn main() {
|
||||||
pub const TILE_TYPES: &[u8] = &[#(#tile_types),*];
|
pub const TILE_TYPES: &[u8] = &[#(#tile_types),*];
|
||||||
};
|
};
|
||||||
|
|
||||||
let output_file = File::create(format!("{}/tilemap.rs", out_dir))
|
let output_file = File::create(format!("{out_dir}/tilemap.rs"))
|
||||||
.expect("failed to open tilemap.rs file for writing");
|
.expect("failed to open tilemap.rs file for writing");
|
||||||
let mut writer = BufWriter::new(output_file);
|
let mut writer = BufWriter::new(output_file);
|
||||||
|
|
||||||
write!(&mut writer, "{}", output).unwrap();
|
write!(&mut writer, "{output}").unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn extract_tiles(layer: &'_ tiled::LayerData) -> impl Iterator<Item = u16> + '_ {
|
fn extract_tiles(layer: &'_ tiled::LayerData) -> impl Iterator<Item = u16> + '_ {
|
||||||
|
|
Loading…
Add table
Reference in a new issue