![6502 emulator c 6502 emulator c](https://miro.medium.com/max/1400/1*FeNjHAjDRrgLw9w5PJ0GgQ.gif)
- #6502 EMULATOR C GENERATOR#
- #6502 EMULATOR C MANUAL#
- #6502 EMULATOR C PORTABLE#
- #6502 EMULATOR C CODE#
- #6502 EMULATOR C WINDOWS#
Hey guys, I've been working on my first emulator for the past couple of weeks:
![6502 emulator c 6502 emulator c](https://pbs.twimg.com/media/Dm6D8qcXoAAk2GT.jpg)
#6502 EMULATOR C CODE#
#6502 EMULATOR C PORTABLE#
#6502 EMULATOR C MANUAL#
#6502 EMULATOR C WINDOWS#
The initial run of emu6502 was done in a Windows console window, which is not so nice to look at and I thought about porting this to an actual console with a screen and buttons. The advantage of going for an existing ‘platform’ is that I had plenty of available projects ready as people developed some cool things against 6502asm, so I would not have to develop my own games on top of the emulator. No sound, sprites or other console niceties. Memory locations $200 to $5FF map to the screen pixels.
#6502 EMULATOR C GENERATOR#
The specification of the fantasy console is quite simple - 32x32 pixels of 16 colors each, input handled by sending ASCII code to address $FF and random generator output at $FE. I looked around for similar projects and found 6502asm, self-titled “World’s first fantasy console!”. Simple hardware usually has memory-mapped I/O, so the controller buttons could appear at some memory location, and when one writes to another memory location, the video chip would pick this up and display it. The CPU on its own isn’t that useful, as we need some way to handle input and output. There is an instruction decoder implemented as a giant switch statement and implementation of each instruction handler. The emulator itself is simple - it operates over a state structure with the values of CPU registers, memory and flags. Emu6502 is written in C, has a hand-written test-suite in 6502 machine code, was developed mostly in Visual Studio 2019, but compiles with gcc and emscripten as well. I eventually ended up with a working 6502 emulator, hosted here on Github as emu6502. The first 256 bytes of the memory are special, it’s called the ‘zero-page’ and can be accessed faster than the rest. The MOS 6502 is interesting to program from the 2019 viewpoint, as it has only 3 registers and 64 KB of memory divided into pages. One would typically program this in the 6502 assembly, for more information check out the wonderful Easy6502 interactive ebook by Nick Morgan, it includes an emulator as well. I read about the MOS 6502 microprocessor and it looked promising as it was used in famous products such as Apple II, Commodore 64, BBC Micro, Tamagotchi and others. Back in April 2019 I decided to get into emulation and thought about writing a simple one.