The Semi Abstract State Machine is an emulator written strictly for educational purposes. I've written it as part of a project I've been tinkering with for some time. Home built CPUs. My project book is full of design specs and schematics. However the scale I had envisioned has kept me from actually building anything. To that end I elected to start off with a software project ease in to this project.
This is where the SASM project comes in. I decided I might want to try a simulation of my deign prior to wasting time and money following a bad idea. I'm not a programmer. If you are a programmer and you look at my code I'll apologize in advance. I subscribe to the "Learn by doing" method. To that end I chose not to look at any emulators source code and plot my own course.
Not know what I was doing I elected to start with an existing and well used (lots of software already written) CPU. So the SASM project began with the goal of writing a CPU core and its surrounding hardware from scratch. The 6502 is perfect for this as it has a very simple instruction set, and there are multiple basic interpreters already written for this processor. The Project was written in C# as It seems to be fairly straight forward and has managed code to protect me from the operating system.
Within about a week I had the basics in place, It contains about %90 of the canonical features of the 6502 as decimal mode is almost never used this was enough to start the debugging. This took substantially longer.
The first target I set was to run the Commodore 64 kernel at least enough to see the Boot screen. This was accomplished with a simple Windows Forms Program that monitor the memory addresses were the screen text was stored and stepping though the kernel's boot code until things went wrong. Unfortunately the Commodores boot routine takes somewhere between 1 and 3 million clock cycles to complete. This was slow and painful, process. The bugs mostly were incorrectly setting status flags after operations.
Once a boot screen was present a few buttons were added to the form to inject keys strokes into the commodores key buffer. Once again this was slow going. Some basic commands were working and others were not. But ultimately about 3 weeks into the project it was up and running.
I'm currently in the process of writing software to simulate the various hardware using. Keyboard and display were first, then audio.
In the second month working on this I converted from Window Forms to XNA to add graphics and sound support.
The project is now starting its third month, and has been an absolute blast. So I attempting to get everything documented, and clean up the source code.