From 4628873cfc53d3bdc7a0834b3edbb02b0b9cf4a7 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Sun, 22 Dec 2024 22:40:11 +0100 Subject: Transform mapping configurations into toml files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will allow the creation of configuration files that can live outside of this tree, so developers can fine tune configuration files of their own without having to pick up whatever is currently available. Signed-off-by: Miquel Sabaté Solà --- crates/nasm/src/main.rs | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'crates') diff --git a/crates/nasm/src/main.rs b/crates/nasm/src/main.rs index 0c754e3..c93dda0 100644 --- a/crates/nasm/src/main.rs +++ b/crates/nasm/src/main.rs @@ -4,7 +4,7 @@ use std::fs::File; use std::io::{self, Read, Write}; use std::path::Path; use xixanta::assembler::Assembler; -use xixanta::mapping::{Mapping, EMPTY, NROM, NROM65, UXROM}; +use xixanta::mapping::get_mapping_configuration; /// Assembler for the 6502 microprocessor that targets the NES/Famicom. #[derive(ClapParser, Debug)] @@ -76,18 +76,13 @@ fn main() -> Result<()> { }; // Select the linker configuration. - let mapping: Vec = match args.config { - Some(c) => match c.to_lowercase().as_str() { - "empty" => EMPTY.to_vec(), - "nrom" => NROM.to_vec(), - "nrom65" => NROM65.to_vec(), - "uxrom" | "unrom" => UXROM.to_vec(), - _ => { - println!("Unknown linker configuration '{}'", c); - std::process::exit(1); - } - }, - None => NROM.to_vec(), + let config = args.config.unwrap_or("nrom".to_string()); + let mapping = match get_mapping_configuration(&config) { + Ok(cfg) => cfg, + Err(e) => { + eprintln!("error: {}", e); + std::process::exit(1); + } }; // And assemble. -- cgit v1.2.3