Skip to content

Nintendo Entertainment System emulator written in Java that emulates real NES hardware (6502 microprocessor CPU, 2C02 PPU)

Notifications You must be signed in to change notification settings

ShlomiRex/nes-emulator-java

Repository files navigation

Java NES Emulator

This is my attempt to create basic NES emulator in Java.

My goal is to not to look at other's code, but to understand on the high-level the NES architecture and create it in Java.

Progress Screenshots

While developing the NES, not everything goes according to plan.

This section is to show the fun and weird experiences I had.


First pattern tile render (notice I already added CPU debugger (everything works except the stack, which for now is just for show):

Added pattern tables, added system palette, added run/stop buttons

Added assembly viewer, PPU registers viewer, and PPU debugger

First time working palette from RAM:

First time rendering basic background (on the right - the game itself):

First time working complete palette initialization from NESTEST, code is just waiting for input interrupts:

First time display working:

Fixed debugger nametable canvases + fixed NMI interrupt loop:

First time working controller display:

First time working NESTEST:

First time working NESTEST, fixed controller input:

First time running Donkey Kong (cool glitches):

First time working donkey kong:

Cool glitch:

Found mario face in my debugger:

Fixed color issues:

First time sprite rendering:

Weird sprite rendering glitch:

Fixed sprite rendering glitch:

Fixed palette and colors for sprites:

A lot of debugger improvements, including:

  • Palette selection: redraws the pattern tables when user selects a palette
  • Rendering nametables now works correctly, sprites are not displayed there
  • Added global controls for the debugger: Run/Stop and checkbox of maximum emulation speed

Trying to fix PPU rendering issues (left - my game, right - FCEUX emulator:

First time working render output using PPU timings, instead of directly reading the nametable, notice I still have some rendering problems (not drawing '1/2' pattern correctly):

Resources

The most used resorces:

  • Online emulator for quick testing of the CPU: here
  • Best CPU instructions summary: here
  • Addressing Modes + to make my emulator CPU/cycle accurate: here, which is from a question I posted on reddit: here

Others:

  • CPU Registers: wiki
  • R6500 Microchip datasheet: datasheet
  • Complete NES Emulator from scratch: YouTube
  • NES References guide (nesdev.org): wiki
  • yizhang82's blog: blog
  • A blog/website that is no longer maintained but useful (using Wayback machine): here
  • Another youtuber reading the architecture: YouTube
  • Blog explains 6502 addressing mode: Emulator101
  • Introduction to 6502 assembly: here
  • Basic NES program that actually works: here
  • Great CPU summary of almost everything: here
  • Started reading PPU blogs, but this one is the best: here
  • Blog explains a lot about PPU, includes asm source code that runs basic blue background: here
  • Detailed PPU timings (scanline, cycles): here

About

Nintendo Entertainment System emulator written in Java that emulates real NES hardware (6502 microprocessor CPU, 2C02 PPU)

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published