LaiNES

AndreaOrruBSD-2-Clause长期未更新

用 C++ 写的极简 NES 模拟器,逐周期精确还原红白机硬件行为,适合研究模拟器原理或跑经典游戏。

Compact cycle-accurate NES emulator

暂无版本1,518star113fork同步于 2026-11-07 07:34 UTC

怎么上手

由 README 提炼,执行前请确认
sudo apt-get install clang scons libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev
git clone --recursive https://github.com/AndreaOrru/LaiNES && cd LaiNES && scons -j4 && ./laines
硬件要求按 README 说明

README 未说明具体硬件要求,仅要求兼容 SCons、C++14 编译器与 SDL2 的 Unix 系统

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

紧凑的周期精确 NES 模拟器,用 C++ 实现,适合想读源码学模拟器原理的工程师

用 C++ 写的极简 NES 模拟器,逐周期精确还原红白机硬件行为,适合研究模拟器原理或跑经典游戏。

核心能力

  • 周期精确模拟 6502 CPU 与 PPU,支持全部非官方操作码
  • 支持 NROM、MMC1/3/5、VRC6 等 13 种常见 mapper
  • 内置文件浏览器 GUI,ESC 在游戏与菜单间切换
  • 支持存档与读档,保留 CPU、PPU、APU 与 mapper 状态
  • 按住 Tab 可 8 倍速快进,支持多手柄与自定义按键

容易踩的坑

必须加 --recursive 克隆子模块,否则编译会失败;Linux 音频异常时需先 export SDL_AUDIODRIVER=ALSA;ROM 需自备,且仅支持 README 列出的 mapper,其余会报错

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

0 个版本

暂无 release 数据(可能没有发版,或尚未同步)。

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    LaiNES

    Compact, cycle-accurate NES emulator.

    File Browser Super Mario Bros. 3 Kirby's Adventure

    Star Wars Super Mario Bros. The Legend of Zelda

    Requirements

    LaiNES should run on any Unix system that is compatible with the following tools.

    • SCons
    • C++14 compatible compiler (e.g. clang++)
    • SDL2 (including sdl2-ttf and sdl2-image)

    Building and running

    Install the dependencies:

    # Arch Linux:
    sudo pacman -S clang scons sdl2 sdl2_image sdl2_ttf
    
    # Debian-based systems:
    sudo apt-get install clang scons libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev
    
    # Mac OS X:
    brew install scons sdl2 sdl2_image sdl2_ttf
    

    Compile and run:

    git clone --recursive https://github.com/AndreaOrru/LaiNES && cd LaiNES
    scons -j4
    ./laines
    

    Usage

    The emulator comes bundled with a simple GUI to navigate the filesystem and set preferences. ESC toggles between emulation and menu.

    Menu Navigation

    • Arrow Keys: Navigate up/down through menu items
    • Enter: Select menu item
    • Page Up/Down: Navigate one page at a time
    • Letter Keys (File Browser): Jump to entries starting with that letter

    The main menu includes a Reset option to reload and restart the current ROM (only enabled when a ROM is loaded).

    Gameplay Controls

    • ESC: Toggle between gameplay and menu
    • Tab (hold): Fast forward mode (8x speed, indicated by ">>" in top-right corner)

    Savestate Support

    LaiNES includes savestate functionality accessible through the main menu (Save State and Load State options). Savestates preserve the complete emulator state including CPU, PPU, APU, mapper state, and expansion audio. Savestates are automatically stored per-ROM and can be loaded at any time.

    The size of the window and the controls are customizable. LaiNES supports multiple controllers and should work with joysticks as well. The default controls for the first player are as follows:

    Controller Settings

    Compatibility

    LaiNES implements the most common mappers, which should be enough for a good percentage of the games:

    • NROM (Mapper 000)
    • MMC1 / SxROM (Mapper 001)
    • UxROM (Mapper 002)
    • CNROM (Mapper 003)
    • MMC3, MMC6 / TxROM (Mapper 004)
    • MMC5 / ExROM (Mapper 005)
    • AxROM (Mapper 007)
    • MMC2 / PxROM (Mapper 009)
    • MMC4 / FxROM (Mapper 010)
    • Color Dreams (Mapper 011)
    • VRC6 (Mapper 024) - with expansion audio support
    • BNROM / NINA-001 (Mapper 034)
    • GxROM (Mapper 066)

    You can check the compatibility for each ROM in the following list: http://tuxnes.sourceforge.net/nesmapper.txt

    Technical notes

    The 6502 CPU and the PPU were originally implemented in just 219 and 283 lines of code respectively, though they have since grown to include full unofficial opcode support and enhanced accuracy. Meta-programming is used extensively to keep the codebase compact. Here is a good example of how that is achieved:

    /* Cycle emulation.
     *     For each CPU cycle, we call the PPU thrice, because it runs at 3 times the frequency. */
    #define T   tick()
    inline void tick() { PPU::step(); PPU::step(); PPU::step(); ... }
    ...
    
    /* Addressing modes.
     *     These are all the possible ways instructions can access memory. */
    typedef u16 (*Mode)(void);
    inline u16 imm() { return PC++; }
    ...
    inline u16 zpx() { T; return (zp() + X) % 0x100; }
    ...
    
    /* Fetch parameter.
     *     Get the address of the opcode parameter in a, and the value in p. */
    #define G  u16 a = m(); u8 p = rd(a)
    ...
    
    /* Instruction emulation (LDx where x is in registers {A, X, Y}).
     *     upd_nz, not shown, just updates the CPU flags register. */
    template<u8& r, Mode m> void ld() { G; upd_nz(r = p); }
    ...
    
    /* Execute a CPU instruction.
     *     Opcodes are instantiated with the right template parameters
     *     (i.e. register and/or addressing mode).*/
    void exec()
    {
        switch (rd(PC++))  // Fetch the opcode.
        {
            // Select the right function to emulate the instruction:
             ...
             case 0xA0: return ld<Y,imm>();  case 0xA1: return ld<A,izx>();
             ...
        }
    }
    

    Known issues

    • If you're experiencing audio issues on Linux, try typing export SDL_AUDIODRIVER=ALSA before running the emulator.

    Contributors

    • Jeff Katz - Major enhancements including:
      • Additional mapper support: MMC5 (005), VRC6 (024), MMC2/MMC4 (009/010), and mappers 002, 003, 007, 011, 034, 066
      • VRC6 expansion audio support
      • Savestate system with full mapper/audio state preservation
      • Comprehensive accuracy improvements: CPU timing, PPU sprite overflow, APU IRQ, DMA timing, NMI timing
      • Complete unofficial 6502 opcode support
      • Fast forward mode and enhanced menu navigation
      • Configuration saving system
    • PudgeMa - Scrollable menu and bug fixes.
    • tyfkda - Show error message instead of segfault for unsupported mappers.

    References and credits