mirror of
https://github.com/Polprzewodnikowy/SummerCart64.git
synced 2024-11-25 23:24:15 +01:00
romdb fixes
This commit is contained in:
parent
6dd64d1db1
commit
35f9ec029e
@ -180,6 +180,7 @@ impl From<n64::SaveType> for SaveType {
|
|||||||
n64::SaveType::Sram => Self::Sram,
|
n64::SaveType::Sram => Self::Sram,
|
||||||
n64::SaveType::SramBanked => Self::SramBanked,
|
n64::SaveType::SramBanked => Self::SramBanked,
|
||||||
n64::SaveType::Flashram => Self::Flashram,
|
n64::SaveType::Flashram => Self::Flashram,
|
||||||
|
n64::SaveType::Sram128kB => Self::Sram,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -263,9 +264,9 @@ fn handle_upload_command(sn: Option<String>, args: &UploadArgs) -> Result<(), sc
|
|||||||
let save: SaveType = if let Some(save_type) = args.save_type.clone() {
|
let save: SaveType = if let Some(save_type) = args.save_type.clone() {
|
||||||
save_type
|
save_type
|
||||||
} else {
|
} else {
|
||||||
let (save_type, name) = n64::guess_save_type(&mut rom_file)?;
|
let (save_type, title) = n64::guess_save_type(&mut rom_file)?;
|
||||||
if let Some(name) = name {
|
if let Some(title) = title {
|
||||||
println!("Detected ROM name: {name}");
|
println!("ROM title: {title}");
|
||||||
};
|
};
|
||||||
save_type.into()
|
save_type.into()
|
||||||
};
|
};
|
||||||
|
@ -7,6 +7,7 @@ pub enum SaveType {
|
|||||||
Sram,
|
Sram,
|
||||||
SramBanked,
|
SramBanked,
|
||||||
Flashram,
|
Flashram,
|
||||||
|
Sram128kB,
|
||||||
}
|
}
|
||||||
|
|
||||||
const HASH_CHUNK_LENGTH: usize = 256 * 1024;
|
const HASH_CHUNK_LENGTH: usize = 256 * 1024;
|
||||||
@ -27,7 +28,7 @@ pub fn guess_save_type<T: Read + Seek>(
|
|||||||
3 => SaveType::Sram,
|
3 => SaveType::Sram,
|
||||||
4 => SaveType::SramBanked,
|
4 => SaveType::SramBanked,
|
||||||
5 => SaveType::Flashram,
|
5 => SaveType::Flashram,
|
||||||
6 => SaveType::Sram,
|
6 => SaveType::Sram128kB,
|
||||||
_ => SaveType::None,
|
_ => SaveType::None,
|
||||||
},
|
},
|
||||||
None,
|
None,
|
||||||
@ -70,18 +71,15 @@ pub fn guess_save_type<T: Read + Seek>(
|
|||||||
let database = ini::Ini::load_from_str(database_ini)
|
let database = ini::Ini::load_from_str(database_ini)
|
||||||
.expect("Error during mupen64plus.ini parse operation");
|
.expect("Error during mupen64plus.ini parse operation");
|
||||||
if let Some(section) = database.section(Some(hash)) {
|
if let Some(section) = database.section(Some(hash)) {
|
||||||
if let Some(save_type) = section.get("SaveType") {
|
let save_type = section.get("SaveType").map_or(SaveType::None, |t| match t {
|
||||||
return Ok((
|
|
||||||
match save_type {
|
|
||||||
"Eeprom 4KB" => SaveType::Eeprom4k,
|
"Eeprom 4KB" => SaveType::Eeprom4k,
|
||||||
"Eeprom 16KB" => SaveType::Eeprom16k,
|
"Eeprom 16KB" => SaveType::Eeprom16k,
|
||||||
"SRAM" => SaveType::Sram,
|
"SRAM" => SaveType::Sram,
|
||||||
"Flash RAM" => SaveType::Flashram,
|
"Flash RAM" => SaveType::Flashram,
|
||||||
_ => SaveType::None,
|
_ => SaveType::None,
|
||||||
},
|
});
|
||||||
section.get("GoodName").map(|s| s.to_string()),
|
let title = section.get("GoodName").map(|s| s.to_string());
|
||||||
));
|
return Ok((save_type, title));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok((SaveType::None, None))
|
Ok((SaveType::None, None))
|
||||||
|
@ -327,8 +327,9 @@ impl SC64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut pi_config = vec![0u8; 4];
|
let mut pi_config = vec![0u8; 4];
|
||||||
reader.read(&mut pi_config)?;
|
|
||||||
reader.rewind()?;
|
reader.rewind()?;
|
||||||
|
reader.read(&mut pi_config)?;
|
||||||
|
|
||||||
let endian_swapper = match &pi_config[0..4] {
|
let endian_swapper = match &pi_config[0..4] {
|
||||||
[0x37, 0x80, 0x40, 0x12] => {
|
[0x37, 0x80, 0x40, 0x12] => {
|
||||||
@ -352,6 +353,8 @@ impl SC64 {
|
|||||||
min(length, SDRAM_LENGTH)
|
min(length, SDRAM_LENGTH)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
reader.rewind()?;
|
||||||
|
|
||||||
self.memory_write_chunked(reader, SDRAM_ADDRESS, sdram_length, Some(endian_swapper))?;
|
self.memory_write_chunked(reader, SDRAM_ADDRESS, sdram_length, Some(endian_swapper))?;
|
||||||
|
|
||||||
self.command_config_set(Config::RomShadowEnable(rom_shadow_enabled.into()))?;
|
self.command_config_set(Config::RomShadowEnable(rom_shadow_enabled.into()))?;
|
||||||
|
Loading…
Reference in New Issue
Block a user