- - The CPU is emulated for every clock tick. Instead of emulating instructions instantly and sleeping on clock timings, I've mimicked the real hardware and emulated every instruction cycle. So, memory reads and writes fall exactly on the clock they're supposed to. I was expecting this to be slow and not cache-friendly, but on my system, it eats just as much CPU time as any other emulators.
- The PPU also runs for every clock tick. No batch-running only when state changes. The PPU alternates execution with the CPU at precise clock timings. Again, this kind of emulation eats just as much CPU time as any other, on my system.
- Also, mappers are also isolated with hook functions, and they mimic real cartridges' pinout. There's the CIRAM Enable and Mirror pins, and they may also receive CPU/PPU reads and writes.
Has there been any other emulator projects using precise instruction/PPU timing like this?
Here's a Windows build.
It will immediately open a file prompt to select a ROM. Press the Letter O key to select another ROM. Controls are Arrow keys = D-Pad, Space = A Button, X = B Button, Enter = Start Button, Ctrl = Select Button. Only working mappers are 0x0 and 0x2 (NROM and UxROM). Some games still freeze for unknown reasons.
Also, here's a peek at the CPU source file. You can see a big switch block taking the instruction cycle as parameter (line 186). Then, for every case, there's another switch taking the instruction addressing mode as parameter (e.g., line 213). When it is the final cycle for an instruction, it branches to yet another switch which handles specific opcode behavior (e.g., line 490 and beyond).