Skip to content

Commit

Permalink
Fix rtc save loading
Browse files Browse the repository at this point in the history
  • Loading branch information
Kanabenki committed Aug 14, 2023
1 parent 48beb8a commit f24145f
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/gameboy/cartridge/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,12 @@ impl Cartridge {
return Err(Error::SaveNotSupported);
}
if let Mapper::Mbc3(mapper) = &mut mapper {
if save.len() == ram_size + 48
&& mapper.has_rtc()
&& mapper.set_rtc_data(&save[ram_size..]).is_ok()
{
save.truncate(ram_size);
} else {
return Err(Error::InvalidRtcData);
if save.len() == ram_size + 48 && mapper.has_rtc() {
if mapper.set_rtc_data(&save[ram_size..]).is_ok() {
save.truncate(ram_size);
} else {
return Err(Error::InvalidRtcData);
}
}
}
if save.len() != ram_size {
Expand Down

0 comments on commit f24145f

Please sign in to comment.