Skip to content

KavinTheG/NES

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

99 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NES

This is my implementation of an NES emulator written in C.

TODO

  • Rendering
    • 8x8 sprite rendering
    • 8x16 sprite rendering
    • Horizontal sprite flipping
    • Vertical sprite flipping
    • Background rendering
    • Sprite-background priority handling
    • Sprite overflow / sprite zero hit detection
  • Audio support
    • Pulse Channels
    • Triange Channel
    • Noise Channel
    • DMC
  • Mapper support
    • NROM / mapper 0

Project Structure

classDiagram-v2
direction LR

class Cpu6502 {
  +ppu : PPU*
  +apu_mmio : APU_MMIO*
  +PC : uint16_t
  +A, X, Y : uint8_t
}

class PPU {
  +v, t : uint16_t
  +frame_buffer : [240][256]
}

class APU_MMIO {
  +apu : APU*
  +registers : uint8_t[0x18]
}

class APU {
  +pulse1 : Pulse*
  +pulse2 : Pulse*
  +triangle : Triangle*
  +noise : Noise*
  +frame_counter : FrameCounter*
}

Cpu6502 --> PPU
Cpu6502 --> APU_MMIO
APU_MMIO --> APU
Loading
classDiagram-v2
direction TB

class APU {
  +pulse1 : Pulse
  +pulse2 : Pulse
  +triangle : Triangle
  +noise : Noise
  +frame_counter : FrameCounter
}

class Pulse {
  +envelope : Envelope
  +sweep : Sweep
  +duty : uint8_t
  +timer : uint16_t
  +counter : uint16_t
  +length_counter : uint8_t
}

class Triangle {
  +linear_counter : Divider
  +timer : uint16_t
  +counter : uint16_t
  +length_counter : uint8_t
}

class Noise {
  +envelope : Envelope
  +timer : uint16_t
  +counter : uint16_t
  +lfsr : uint16_t
  +length_counter : uint8_t
}

class FrameCounter {
  +divider : Divider
  +mode : uint8_t
  +step : uint8_t
}

APU --> Pulse : pulse1/pulse2
APU --> Triangle
APU --> Noise
APU --> FrameCounter


Loading
classDiagram-v2
direction TB

class Envelope {
  +divider : Divider
  +decay_level : uint8_t
  +volume : uint8_t
  +loop : bool
}

class Sweep {
  +divider : Divider
  +shift : uint8_t
  +negate : bool
  +enabled : bool
}

class Divider {
  +P : uint8_t
  +counter : uint8_t
}

Envelope --> Divider
Sweep --> Divider

Loading

Usage

Requirements

The following items are required for this program to function:

  • gcc/clang
  • SDL2

Building

Git clone the repository with the following command:

git clone https://github.com/KavinTheG/chip8.git

Change directory to the NES project directory

cd NES

Enter the following command to build the project. Ensure a build directory exists.

make

This will create a binary file located in the bin/ folder. Currently, I am only testing on the nes-test.nes rom and donkey kong rom. Run the command below to execute.

./bin/emulator game-title.nes

Progress

Able to run Donkey Kong. image

image image

References

About

NES Emulator written in C

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published