summary refs log tree commit diff
path: root/src/memory.rs
blob: 3f1aadf4b09d5cf8f68a964dcdc7b90d17d49316 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// SPDX-License-Identifier: AGPL-3.0-or-later

//! 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];
	}
}