6502 CPU Emulator
Here is a 6502 CPU emulator I wrote for the P2.
The demo program runs (and pass) the 6502 functional test from https://github.com/Klaus2m5/6502_65C02_functional_tests which tests all instructions, address modes, math operations, etc.
Here is the debug output:
In this stage I focused mainly on accurate emulation, that's why the code is as it is now. The cycle count should be very accurate, including the cross-page additional cycles, this should allow to add delay timings compatible with the original chip.
In the current state, without much optimizations and with some (maybe not needed) safe checks, it runs at about 22.659 P2 clocks per 6502 clock on average, if math serves me right, it means that a P2 at 160 MHz can run the emulation at about 7MHz. With some minimal optimizations, a bare 20MHz P2 should run at C64 speed without problems.