Skip to content

Instantly share code, notes, and snippets.

@romatthe
Created January 4, 2018 19:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save romatthe/d6a7a330ad1188b41fe365f489f65db7 to your computer and use it in GitHub Desktop.
Save romatthe/d6a7a330ad1188b41fe365f489f65db7 to your computer and use it in GitHub Desktop.
NES

NES Emulation

Structure

struct nes {
 Memory cpuMemory;
 Memory ppuMemory;
 Memory objectAttributeMemory;
 
 CPU cpu;
 PPU ppu;
 APU apu;
 
 Cartridge cartridge;
 
 Interrupts interrupts;
 
 MMU mmu;
 
 GUI gui;
 
 Joypad joypads[NES_NUM_JOYPADS];
};

CPU & PPU

  • CPU and PPU each have their own address space
  • Separate area for sprite attributes in memory known as "object attribute memory". CPU writes to this, PPU reads from it.

Interrupts

Many device are free to generate their own interrupts, which are then handled by the CPU (unless it is currently ignoring interrupts).

There are three general types of interrupts:

  • NMI - Non Maskable Interrupts, interrupts which the CPU cannot "mask away", it must handle them
  • IRQ - Interrupt ReQuests, interrupts which the CPU is free to ignore
  • RESET - The initial power on / reset interrupt generated when you hit the power switch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment