Skip to content

PeakRacing/nes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

333 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

English | 中文

nes simulator

Pull Requests Welcomefirst-timers-only Friendly

github licenseLatest ReleaseWindowsLinuxMacos

github: PeakRacing/nes: A NES emulator in C (github.com) (recommend)

gitee: nes: c语言实现的nes模拟器 (gitee.com) (updates may not be timely due to synchronization issues)

Introduction

​ The nes simulator implemented in C , requires C11 or above

attention:This repository is only for the nes simulator and does not provide the game !!!

Platform support:

  • Windows

  • Linux

  • MacOS

Simulator support:

  • CPU (All instructions)

  • PPU (Simulating at pixel-level precision)

  • APU (Fixed-point calculation)

mapper support:

​ 0, 1, 2, 3, 4, 7, 94, 177, 180

Software Architecture

​ The example is based on SDL for image and sound output, without special dependencies, and you can port to any hardware by yourself

Compile Tutorial

​ clone repository,install xmake,execute xmake directly to compile

Compile Preparation

Windows:

​ install MSVC(Visual Studio)

​ install xmake

Linux(Ubuntu):

sudo add-apt-repository ppa:xmake-io/xmake -y
sudo apt-get update -y
sudo apt-get install -y git make gcc p7zip-full libsdl2-dev xmake

Macox:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update
brew install make gcc sdl2 xmake

Compilation Method

​ clone repository,execute xmake directly to compile

Note: This project supports both SDL2 and SDL3, use SDL2 to execute 'xmake' under SDL/SDL2

Download link

github: https://github.com/PeakRacing/nes/releases

gitee: https://gitee.com/PeakRacing/nes/releases

Instructions

​ on linux or macos enter ./nes xxx.nes load the game to run

​ on windows enter .\nes.exe xxx.nes load the game to run

Key mapping

joystick up down left right select start A B
P1 W S A D V B J K
P2 1 2 5 6

Note: P2 uses numberic keypad

Transplant instructions

​ The source code in the incand src directories does not need to be modified, only the three files in the port directory nes_conf.h nes_port.c nes_port.h

  • nes_conf.h is a configuration file, configure according to your needs, such as printing extra definitions, the implementation of nes_log_printf
  • nes_port.c is the main porting file, which needs to be ported according to the needs

Note: If the target platform for migration has weak performance and small space, some macro configurations are specially reserved:

  • NES_ENABLE_SOUND can be set to 0 to turn off the APU to increase the running speed
  • NES_RAM_LACK can be set to 1, using a half-screen refresh to reduce RAM consumption (running at a slower speed)
  • You can configure NES_FRAME_SKIP to skip frames
  • NES_ROM_STREAM can be set to 1 to dynamically switch banks from a file. This mode only requires a 40KB active bank buffer (PRG 32KB, CHR 8KB). The file handle remains open, but the bank switching speed will decrease. It is designed for low memory.
  • If SPI 8-byte transmission is used for embedded platforms, the color anomaly configuration NES_COLOR_SWAP can be used to switch the large and small ends

Showcase

mapper 0:

Super Mario Bros F1_race Star Luster (J) Ikki (J)
Circus Charlie

mapper 2:

Contra1 Castlevania Journey Lifeporce
mega_man Athena (J)

mapper 3:

contra Donkey_kong

mapper 94:

Senjou no Ookami

mapper 180:

Crazy Climber

Discussion group

Non-technical support, only for the purpose of interest exchange.

Communication

Literature reference

https://www.nesdev.org/

About

A NES emulator in C

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages