Master the fundamental concepts of emulation through this focused micro-challenge.
The Nintendo Entertainment System runs a Ricoh 2A03, a 6502 derivative at 1.79 MHz (NTSC). Emulating it means accurate fetch-decode-execute, memory maps, and cycle counting for the PPU and APU.
6502 features:
Memory map slices:
For example, opcode \`0xA9\` (LDA immediate) loads the next byte into A and sets Z/N flags.
Cycle accuracy matters: many PPU tricks depend on the CPU running a known number of cycles per instruction.
Read the memory map through a bus function so mapper chips can redirect PRG-ROM windows later. Hard-coding `0x8000` reads works for NROM only; MMC1 and UxROM need bank switching hooks.
This exercise asks you to implement a 6502 CPU core with correct addressing modes for a starter opcode set. You will fetch from the NES memory map and update flags the way test ROMs expect.
You will use the same mental model here when reading production interpreter source later in the track. Sketch one concrete input on paper, predict the outcome, then confirm with code. That discipline catches logic errors early and makes debugging far faster when you extend the implementation in follow-on tasks.
Implement the NES 6502 CPU core in C.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github