All Projects → AndreaOrru → Laines

AndreaOrru / Laines

Licence: bsd-2-clause
Cycle-accurate NES emulator in ~1000 lines of code

Projects that are alternatives of or similar to Laines

Nes
A Javascript NES Emulator
Stars: ✭ 168 (-87.69%)
Mutual labels:  nintendo, nes, emulator
Provenance
iOS & tvOS multi-emulator frontend, supporting various Atari, Bandai, NEC, Nintendo, Sega, SNK and Sony console systems… Get Started: https://wiki.provenance-emu.com |
Stars: ✭ 4,732 (+246.67%)
Mutual labels:  nintendo, nes, emulator
Retrograde Android
Play retro video games on your Android TV!
Stars: ✭ 114 (-91.65%)
Mutual labels:  nintendo, nes, emulator
Lemuroid
All in 1 emulator on Android!
Stars: ✭ 194 (-85.79%)
Mutual labels:  nintendo, nes, emulator
awesome-emu-resources
A curated list of emulator development resources
Stars: ✭ 26 (-98.1%)
Mutual labels:  emulator, nintendo, nes
Retro Go
Retro emulation for the ODROID-GO
Stars: ✭ 73 (-94.65%)
Mutual labels:  nintendo, nes, emulator
first nes
Create your own games for the Nintendo Entertainment System! This "starter" game is easily extensible for your own projects. Includes references.
Stars: ✭ 94 (-93.11%)
Mutual labels:  emulator, nintendo, nes
NostalgiaLite
Three game emulators: FC(Nes), GG, GBC for Android
Stars: ✭ 85 (-93.77%)
Mutual labels:  emulator, nintendo, nes
Rustynes
👾 An NES emulator by Rust and WebAssembly
Stars: ✭ 399 (-70.77%)
Mutual labels:  nes, emulator
Coreboy
A GameBoy Emulator, in C#
Stars: ✭ 397 (-70.92%)
Mutual labels:  nintendo, emulator
Nestopia
Cross-platform Nestopia emulator core with a GUI
Stars: ✭ 405 (-70.33%)
Mutual labels:  nintendo, emulator
Hnes
🎮 NES Emulator written in Haskell
Stars: ✭ 340 (-75.09%)
Mutual labels:  nes, emulator
Anese
Another NES Emulator - written for fun & learning - first implementation of wideNES
Stars: ✭ 323 (-76.34%)
Mutual labels:  nes, emulator
Jsnes Web
A browser UI for JSNES, a JavaScript NES emulator
Stars: ✭ 398 (-70.84%)
Mutual labels:  nes, emulator
Inds
Revival of the Nintendo DS emulator for iOS
Stars: ✭ 293 (-78.53%)
Mutual labels:  nintendo, emulator
Road To Yuzu Without Switch
This Repo explains how to install the Yuzu Switch Emulator without a Switch
Stars: ✭ 267 (-80.44%)
Mutual labels:  nintendo, emulator
Nestur
The NES (emulator) you left outside in the rain but let dry and still kind of works
Stars: ✭ 505 (-63%)
Mutual labels:  nes, emulator
Jsnes
A JavaScript NES emulator.
Stars: ✭ 5,354 (+292.23%)
Mutual labels:  nes, emulator
Skyline
Run Nintendo Switch homebrew & games on your Android device!
Stars: ✭ 670 (-50.92%)
Mutual labels:  nintendo, emulator
Vba M Nx
WIP full featured port of VBA-M for Nintendo Switch
Stars: ✭ 11 (-99.19%)
Mutual labels:  nintendo, emulator

LaiNES

Compact, cycle-accurate NES emulator in ~1000 lines of C++ (well, originally).

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++11 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
./laines

Usage

The emulator comes bundled with a simple GUI to navigate the filesystem and set preferences. Use arrow keys and Enter to operate it. ESC toggles between emulation and menu.

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)

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 are implemented in just 219 and 283 lines of code respectively. 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 - Mapper 002 & 003, configuration.
  • PudgeMa - Scrollable menu and bug fixes.
  • tyfkda - Show error message instead of segfault for unsupported mappers.

References and credits

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].