diff --git a/sw/deployer/src/main.rs b/sw/deployer/src/main.rs index 01b61a8..9c190c8 100644 --- a/sw/deployer/src/main.rs +++ b/sw/deployer/src/main.rs @@ -180,6 +180,7 @@ impl From for SaveType { n64::SaveType::Sram => Self::Sram, n64::SaveType::SramBanked => Self::SramBanked, n64::SaveType::Flashram => Self::Flashram, + n64::SaveType::Sram128kB => Self::Sram, } } } @@ -263,9 +264,9 @@ fn handle_upload_command(sn: Option, args: &UploadArgs) -> Result<(), sc let save: SaveType = if let Some(save_type) = args.save_type.clone() { save_type } else { - let (save_type, name) = n64::guess_save_type(&mut rom_file)?; - if let Some(name) = name { - println!("Detected ROM name: {name}"); + let (save_type, title) = n64::guess_save_type(&mut rom_file)?; + if let Some(title) = title { + println!("ROM title: {title}"); }; save_type.into() }; diff --git a/sw/deployer/src/n64.rs b/sw/deployer/src/n64.rs index 37dfca8..7c6d460 100644 --- a/sw/deployer/src/n64.rs +++ b/sw/deployer/src/n64.rs @@ -7,6 +7,7 @@ pub enum SaveType { Sram, SramBanked, Flashram, + Sram128kB, } const HASH_CHUNK_LENGTH: usize = 256 * 1024; @@ -27,7 +28,7 @@ pub fn guess_save_type( 3 => SaveType::Sram, 4 => SaveType::SramBanked, 5 => SaveType::Flashram, - 6 => SaveType::Sram, + 6 => SaveType::Sram128kB, _ => SaveType::None, }, None, @@ -70,18 +71,15 @@ pub fn guess_save_type( let database = ini::Ini::load_from_str(database_ini) .expect("Error during mupen64plus.ini parse operation"); if let Some(section) = database.section(Some(hash)) { - if let Some(save_type) = section.get("SaveType") { - return Ok(( - match save_type { - "Eeprom 4KB" => SaveType::Eeprom4k, - "Eeprom 16KB" => SaveType::Eeprom16k, - "SRAM" => SaveType::Sram, - "Flash RAM" => SaveType::Flashram, - _ => SaveType::None, - }, - section.get("GoodName").map(|s| s.to_string()), - )); - } + let save_type = section.get("SaveType").map_or(SaveType::None, |t| match t { + "Eeprom 4KB" => SaveType::Eeprom4k, + "Eeprom 16KB" => SaveType::Eeprom16k, + "SRAM" => SaveType::Sram, + "Flash RAM" => SaveType::Flashram, + _ => SaveType::None, + }); + let title = section.get("GoodName").map(|s| s.to_string()); + return Ok((save_type, title)); } Ok((SaveType::None, None)) diff --git a/sw/deployer/src/sc64/mod.rs b/sw/deployer/src/sc64/mod.rs index fe43eb3..3ef25db 100644 --- a/sw/deployer/src/sc64/mod.rs +++ b/sw/deployer/src/sc64/mod.rs @@ -327,8 +327,9 @@ impl SC64 { } let mut pi_config = vec![0u8; 4]; - reader.read(&mut pi_config)?; + reader.rewind()?; + reader.read(&mut pi_config)?; let endian_swapper = match &pi_config[0..4] { [0x37, 0x80, 0x40, 0x12] => { @@ -352,6 +353,8 @@ impl SC64 { min(length, SDRAM_LENGTH) }; + reader.rewind()?; + self.memory_write_chunked(reader, SDRAM_ADDRESS, sdram_length, Some(endian_swapper))?; self.command_config_set(Config::RomShadowEnable(rom_shadow_enabled.into()))?;