summary refs log tree commit diff
path: root/src/main.rs
diff options
context:
space:
mode:
authorSophie Forrest <57433227+sophieforrest@users.noreply.github.com>2024-01-13 19:17:57 +1300
committerSophie Forrest <57433227+sophieforrest@users.noreply.github.com>2024-01-13 19:17:57 +1300
commit13becb31e8b669dd6254c68b3aae110e7711d9db (patch)
treef4320bc6c0e86064291ac29f4dfaddb8fbb3f376 /src/main.rs
chore: init project
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 0000000..003d198
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,33 @@
+//! 6502 Emulator written in Rust. Based off of information from Dave's playlist
+//! <https://www.youtube.com/playlist?list=PLLwK93hM93Z13TRzPx9JqTIn33feefl37> using the now defunct
+//! obelisk 6502 documentation.
+//!
+//! Many comments are sourced from the Obelisk 6502 documentation <https://web.archive.org/web/20210501031403/http://www.obelisk.me.uk/index.html>
+
+mod cpu;
+mod instruction;
+mod memory;
+
+use cpu::Cpu;
+use memory::Memory;
+
+fn main() {
+	let mut cpu = Cpu::new();
+	let mut memory = Memory::new();
+
+	cpu.reset(&mut memory);
+
+	// little program
+	if let Some(opcode) = memory.data.get_mut(0xFFFC) {
+		*opcode = 0xA5;
+	}
+	if let Some(opcode) = memory.data.get_mut(0xFFFD) {
+		*opcode = 0x42;
+	}
+	if let Some(opcode) = memory.data.get_mut(0x0042) {
+		*opcode = 0x84;
+	}
+	// end program
+
+	cpu.execute(3, &memory);
+}