cpu.rs: Actually derive (De)Serialize if feature=serde

This commit is contained in:
John 2023-04-23 12:16:31 -05:00
parent 5b5c5b41ab
commit 16a5e6a2a4
2 changed files with 4 additions and 0 deletions

View File

@ -37,6 +37,7 @@ type Nib = u8;
/// Represents the internal state of the CPU interpreter /// Represents the internal state of the CPU interpreter
#[derive(Clone, PartialEq)] #[derive(Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct CPU { pub struct CPU {
/// Flags that control how the CPU behaves, but which aren't inherent to the /// Flags that control how the CPU behaves, but which aren't inherent to the
/// chip-8. Includes [Quirks], target IPF, etc. /// chip-8. Includes [Quirks], target IPF, etc.
@ -57,6 +58,7 @@ pub struct CPU {
// Execution data // Execution data
cycle: usize, cycle: usize,
breakpoints: Vec<Adr>, breakpoints: Vec<Adr>,
#[cfg_attr(feature = "serde", serde(skip))]
disassembler: Dis, disassembler: Dis,
} }

View File

@ -81,6 +81,7 @@ impl Get<u8> for Bus {
/// Represents a named region in memory /// Represents a named region in memory
#[non_exhaustive] #[non_exhaustive]
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum Region { pub enum Region {
/// Character ROM (but writable!) /// Character ROM (but writable!)
Charset, Charset,
@ -110,6 +111,7 @@ impl Display for Region {
/// Stores memory in a series of named regions with ranges /// Stores memory in a series of named regions with ranges
#[derive(Clone, Debug, Default, PartialEq)] #[derive(Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Bus { pub struct Bus {
memory: Vec<u8>, memory: Vec<u8>,
region: [Option<Range<usize>>; Region::Count as usize], region: [Option<Range<usize>>; Region::Count as usize],