{"id":13419776,"url":"https://github.com/AndreaOrru/LaiNES","last_synced_at":"2025-03-15T05:33:05.512Z","repository":{"id":11718930,"uuid":"14239434","full_name":"AndreaOrru/LaiNES","owner":"AndreaOrru","description":"Cycle-accurate NES emulator in ~1000 lines of code","archived":false,"fork":false,"pushed_at":"2022-02-02T11:58:30.000Z","size":877,"stargazers_count":1502,"open_issues_count":19,"forks_count":114,"subscribers_count":43,"default_branch":"master","last_synced_at":"2025-03-14T19:14:00.686Z","etag":null,"topics":["emulator","emulators","minimal","nes","nintendo","nintendo-nes"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AndreaOrru.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-11-08T17:20:27.000Z","updated_at":"2025-02-16T16:56:13.000Z","dependencies_parsed_at":"2022-08-09T15:30:40.547Z","dependency_job_id":null,"html_url":"https://github.com/AndreaOrru/LaiNES","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndreaOrru%2FLaiNES","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndreaOrru%2FLaiNES/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndreaOrru%2FLaiNES/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndreaOrru%2FLaiNES/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AndreaOrru","download_url":"https://codeload.github.com/AndreaOrru/LaiNES/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243690112,"owners_count":20331726,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["emulator","emulators","minimal","nes","nintendo","nintendo-nes"],"created_at":"2024-07-30T22:01:20.684Z","updated_at":"2025-03-15T05:33:05.168Z","avatar_url":"https://github.com/AndreaOrru.png","language":"C++","funding_links":[],"categories":["TODO scan for Android support in followings","C++"],"sub_categories":[],"readme":"LaiNES\n======\n\nCompact, cycle-accurate NES emulator in ~1000 lines of C++ (well, originally).\n\n![File Browser](http://i.imgur.com/2tuDlCw.png)\n![Super Mario Bros. 3](http://i.imgur.com/Gm4QWsE.png)\n![Kirby's Adventure](http://i.imgur.com/xA2vwim.png)\n\n![Star Wars](http://i.imgur.com/j3MmRba.png)\n![Super Mario Bros.](http://i.imgur.com/yal0ps1.png)\n![The Legend of Zelda](http://i.imgur.com/OLO02ij.png)\n\n## Requirements\nLaiNES should run on any Unix system that is compatible with the following tools.\n- SCons\n- C++11 compatible compiler (e.g. clang++)\n- SDL2 (including sdl2-ttf and sdl2-image)\n\n## Building and running\nInstall the dependencies:\n```sh\n# Arch Linux:\nsudo pacman -S clang scons sdl2 sdl2_image sdl2_ttf\n\n# Debian-based systems:\nsudo apt-get install clang scons libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev\n\n# Mac OS X:\nbrew install scons sdl2 sdl2_image sdl2_ttf\n```\n\nCompile and run:\n```sh\ngit clone --recursive https://github.com/AndreaOrru/LaiNES \u0026\u0026 cd LaiNES\nscons\n./laines\n```\n\n## Usage\nThe 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.\n\nThe 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:\n\n![Controller Settings](http://i.imgur.com/ERQ2nmJ.png)\n\n## Compatibility\nLaiNES implements the most common mappers, which should be enough for a good percentage of the games:\n- NROM (Mapper 000)\n- MMC1 / SxROM (Mapper 001)\n- UxROM (Mapper 002)\n- CNROM (Mapper 003)\n- MMC3, MMC6 / TxROM (Mapper 004)\n\nYou can check the compatibility for each ROM in the following list:\nhttp://tuxnes.sourceforge.net/nesmapper.txt\n\n## Technical notes\nThe 6502 CPU and the PPU are implemented in just 219 and 283 lines of code respectively.\nMeta-programming is used extensively to keep the codebase compact.\nHere is a good example of how that is achieved:\n```c++\n/* Cycle emulation.\n *     For each CPU cycle, we call the PPU thrice, because it runs at 3 times the frequency. */\n#define T   tick()\ninline void tick() { PPU::step(); PPU::step(); PPU::step(); ... }\n...\n\n/* Addressing modes.\n *     These are all the possible ways instructions can access memory. */\ntypedef u16 (*Mode)(void);\ninline u16 imm() { return PC++; }\n...\ninline u16 zpx() { T; return (zp() + X) % 0x100; }\n...\n\n/* Fetch parameter.\n *     Get the address of the opcode parameter in a, and the value in p. */\n#define G  u16 a = m(); u8 p = rd(a)\n...\n\n/* Instruction emulation (LDx where x is in registers {A, X, Y}).\n *     upd_nz, not shown, just updates the CPU flags register. */\ntemplate\u003cu8\u0026 r, Mode m\u003e void ld() { G; upd_nz(r = p); }\n...\n\n/* Execute a CPU instruction.\n *     Opcodes are instantiated with the right template parameters\n *     (i.e. register and/or addressing mode).*/\nvoid exec()\n{\n    switch (rd(PC++))  // Fetch the opcode.\n    {\n        // Select the right function to emulate the instruction:\n         ...\n         case 0xA0: return ld\u003cY,imm\u003e();  case 0xA1: return ld\u003cA,izx\u003e();\n         ...\n    }\n}\n```\n\n## Known issues\n* If you're experiencing audio issues on Linux, try typing `export SDL_AUDIODRIVER=ALSA` before running the emulator.\n\n## Contributors\n* [Jeff Katz](https://github.com/kraln) - Mapper 002 \u0026 003, configuration.\n* [PudgeMa](https://github.com/PudgeMa) - Scrollable menu and bug fixes.\n* [tyfkda](https://github.com/tyfkda) - Show error message instead of segfault for unsupported mappers.\n\n## References and credits\n- Special thanks to [Ulf Magnusson](https://github.com/ulfalizer) for the invaluable [PPU diagram](http://wiki.nesdev.com/w/images/d/d1/Ntsc_timing.png) and for his [excellent implementation](https://github.com/ulfalizer/nesalizer) which was a big source of inspiration.\n- blargg's APU sound chip emulator: http://blargg.8bitalley.com/libs/audio.html#Nes_Snd_Emu\n- Complete hardware reference: http://problemkaputt.de/everynes.htm\n- Tick-by-tick breakdown of 6502 instructions: http://nesdev.com/6502_cpu.txt\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAndreaOrru%2FLaiNES","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAndreaOrru%2FLaiNES","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAndreaOrru%2FLaiNES/lists"}