6502Emu

This is a personal project where I am creating a from-scratch emulator for a 6502-based computer. This could, if expanded upon, create an NES, Atari, or Commodore 64 emulator. So far this project is only being created by me in C++, and I am using no external libraries (at the moment). I hope to keep this as strictly from-scratch work, but in the future, I might use the Win32 API or other APIs to help with creating a GUI or optimized debugger.

Right now, the application includes basic 6502 instructions that can be read in through a binary ROM file (Which can be created through my .txt to .bin file converter) that includes the opcodes for the instructions. Later, my plan is to have an assembler that would take in a .asm file and convert into opcodes for quick assembly development. The emulator currently runs with a debugger that monitors memory locations, flags, etc. This project can cross-compile with Linux and Windows, which I show in these screenshots.

Screenshot-1.png
Screenshot (86)-1.png
TerminalRecording.gif

In the recording above, the program is loaded with a ROM file that holds the program instructions for a counting program. This program counts up the two first bytes in the system’s ram using 6502 CPU instructions that were preassembled. This demonstrates the functionality of fundamental 6502 commands, like loading, storing, adding, incrementing, and branching. The top left of the console window, labeled “Memory Viewer”, shows a table of the first segment of the system’s ram (as well as some key registers and flags on the top) so that a programmer can see what is going on within the program, as there is no “screen” or other form of output in the computer yet. The right side of the console window has an output that can be written to (from the emulator code, not the assembly code). 

One of the most challenging aspects of this project was the code structure. This program spans multiple projects that are compiled separately, and I heavily relied on abstraction and polymorphism as well in order to organize the code and make it as easy to work in as possible. Each component was created with the intent to interface with them in a logical way to ensure that everything was decoupled and scalable. This made it possible to add cross-compilation and compatibility with Linux, because the proprietary system calls were properly abstracted. It also will allow me to add a GUI, a graphics library, or other APIs in the future.