Allow deduplicating background tiles

This commit is contained in:
Gwilym Inzani 2023-08-29 13:16:57 +01:00
parent dd119604d8
commit 8158bc1ff3
2 changed files with 23 additions and 4 deletions

View file

@ -36,6 +36,7 @@ struct BackgroundGfxOption {
module_name: String, module_name: String,
file_name: String, file_name: String,
colours: Colours, colours: Colours,
deduplicate: bool,
} }
impl config::Image for BackgroundGfxOption { impl config::Image for BackgroundGfxOption {
@ -72,12 +73,30 @@ impl Parse for BackgroundGfxOption {
Colours::Colours16 Colours::Colours16
}; };
let lookahead = input.lookahead1();
let deduplicate = if lookahead.peek(syn::Ident) {
let deduplicate: syn::Ident = input.parse()?;
if deduplicate == "deduplicate" {
true
} else {
return Err(syn::Error::new_spanned(
deduplicate,
"Must either be the literal deduplicate or missing",
));
}
} else {
false
};
let file_name: syn::LitStr = input.parse()?; let file_name: syn::LitStr = input.parse()?;
Ok(Self { Ok(Self {
module_name: module_name.to_string(), module_name: module_name.to_string(),
file_name: file_name.value(), file_name: file_name.value(),
colours, colours,
deduplicate,
}) })
} }
} }

View file

@ -47,10 +47,10 @@ impl Game {
include_background_gfx!( include_background_gfx!(
games, "121105", games, "121105",
hat => "gfx/hat.png", hat => deduplicate "gfx/hat.png",
purple => "gfx/purple.png", purple => deduplicate "gfx/purple.png",
hyperspace => "gfx/hyperspace.png", hyperspace => deduplicate "gfx/hyperspace.png",
amplitude => "gfx/amplitude.png" amplitude => deduplicate "gfx/amplitude.png"
); );
fn get_game(gba: &mut agb::Gba) -> Game { fn get_game(gba: &mut agb::Gba) -> Game {