diff options
Diffstat (limited to '')
| -rw-r--r-- | src/memory.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/memory.rs b/src/memory.rs new file mode 100644 index 0000000..d251231 --- /dev/null +++ b/src/memory.rs @@ -0,0 +1,26 @@ +//! Implementation of memory for the MOS 6502. + +/// Maximum amount of memory that exists within the emulator. +pub const MAXIMUM_MEMORY: usize = 1024 * 64; + +/// Implementation of memory for the 6502. +pub struct Memory { + /// Data for the memory. + pub data: [u8; MAXIMUM_MEMORY], +} + +impl Memory { + /// Creates a new instance of the memory. Returns blank memory with all + /// zeroes. + pub const fn new() -> Self { + Self { + data: [0; MAXIMUM_MEMORY], + } + } + + /// Resets all data in the memory to zero. This simply allocates a new array + /// and sets the memory to the new, zeroed array. + pub fn reset(&mut self) { + self.data = [0; MAXIMUM_MEMORY]; + } +} |