diff options
| author | Sophie Forrest <57433227+sophieforrest@users.noreply.github.com> | 2024-01-13 19:17:57 +1300 |
|---|---|---|
| committer | Sophie Forrest <57433227+sophieforrest@users.noreply.github.com> | 2024-01-13 19:17:57 +1300 |
| commit | 13becb31e8b669dd6254c68b3aae110e7711d9db (patch) | |
| tree | f4320bc6c0e86064291ac29f4dfaddb8fbb3f376 /src/memory.rs | |
chore: init project
Diffstat (limited to 'src/memory.rs')
| -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]; + } +} |