English | 中文
github: Dozingfiretruck/nes: A NES emulator in C (github.com) (recommend)
gitee: nes: c语言实现的nes模拟器 (gitee.com) (updates may not be timely due to synchronization issues)
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
-
PPU
-
APU
mapper support:
0, 2, 3, 7, 94, 117, 180
The example is based on SDL2 for image and sound output, without special dependencies, and you can port to any hardware by yourself
clone repository,install xmake,execute xmake
directly to compile
install MSVC(Visual Studio 2022)
install xmake
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
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update
brew install make gcc sdl2 xmake
clone repository,execute xmake
directly to compile
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
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
The source code in the inc
and 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 the configuration file, which can be configured according to your needsnes_port.h
is the migrating header file, which usually only needs to be migrated nes_printf- `nes_port.c is the main migration file, and all functions need to be migrated
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 speedNES_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 - 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
In addition, the APU synthesis uses single floating-point calculations, and the code can optimize the single-floating-point calculation acceleration or not use single-floating-point calculations to speed up the operation in nes_apu.c
mapper 0:
mapper 2:
mapper 3:
mapper 94:
mapper 180: