-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finish mbc3 rtc saving implementation
- Loading branch information
Showing
5 changed files
with
110 additions
and
50 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,4 @@ serde-big-array = "0.5.1" | |
ciborium = "0.2.1" | ||
nom = "7.1.3" | ||
cookie-factory = "0.3.2" | ||
thiserror = "1.0.44" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,17 @@ | ||
use std::{error::Error as StdError, fmt::Display}; | ||
|
||
#[derive(Debug)] | ||
#[derive(Debug, thiserror::Error)] | ||
pub enum Error { | ||
#[error("bootrom is enabled but no bootrom was provided")] | ||
MissingBootrom, | ||
#[error("bootrom size isn't 0x100 bytes")] | ||
InvalidBootRom, | ||
#[error("save size does not match the size expected by the loaded rom")] | ||
InvalidSave, | ||
#[error("failed to parse saved rtc data")] | ||
InvalidRtcData, | ||
#[error("the current rom does not support save data")] | ||
SaveNotSupported, | ||
#[error("rom header cannot be parsed ({0})")] | ||
InvalidRomHeader(&'static str), | ||
#[error("unsupported rom mapper id {0}")] | ||
UnsupportedMapper(u8), | ||
} | ||
|
||
impl Display for Error { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
match self { | ||
Self::MissingBootrom => write!(f, "bootrom is enabled but no bootrom was provided"), | ||
Self::InvalidBootRom => write!(f, "bootrom size isn't 0x100 bytes"), | ||
Self::InvalidSave => write!( | ||
f, | ||
"save size does not match the size expected by the loaded rom" | ||
), | ||
Self::SaveNotSupported => write!(f, "the current rom does not support save data"), | ||
Self::InvalidRomHeader(reason) => { | ||
write!(f, "rom header cannot be parsed ({reason})") | ||
} | ||
Self::UnsupportedMapper(id) => write!(f, "unsupported rom mapper id {id}"), | ||
} | ||
} | ||
} | ||
|
||
impl StdError for Error {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters