Skip to content
/ UNES Public

🎮 Nintendo Entertainment System emulator written in C# and run in Unity

License

Notifications You must be signed in to change notification settings

ls9512/UNES

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UNES

UNES is an emulator plug-in that runs Nintendo Entertainment System Nintendo FC Game *.nes files in the Unity environment. The project is based on Emulator.NES to achieve cross-platform through Unity.

license Release Version topLanguage size last 996.icu

[中文文档]

1. Start

    1. Create a new or select a GameObject in the scene and add the UNESBehaviour component.
    1. Create a new RenderTexture to render the game screen.
    1. Use any way you want to display the RenderTexture file in the game.
    1. Use the default input method or realize custom input on demand.
    1. Implement the loading of *.nes files on demand to obtain byte[] format data.
    1. Call the UNESBehaviour.Boot(byte[] romData) interface to start the game.

2. Load

2.1. Resources loading

If you need to use the Resources.Load() interface to load the ROM file, you need to pay attention to changing the .nes extension to .bytes, and then use the following method to load:

var bytes = Resources.Load<TextAsset>(romPath).bytes;
UNES.BootRom(bytes);

2.2. FileStream loading

If you use the method of loading the original file byte stream, you can directly call the UNESBehaviour.Boot(byte[] romData) interface.

3. Configuration

3.1. Filter Mode

Filter mode of game screen rendering:

Mode Description
Point Texture pixels become blocky at close range.
Bilinear Bilinear bilinear filtering-averages the texture samples.
Trilinear Trilinear Trilinear filtering-averages texture samples and blends between mipmap levels.

For detailed explanation, please refer to FilterMode

3.2. Logic Thread

If the Logic Thread option is turned on, the simulation calculations of the CPU and PPU parts will be executed by other thread, and the Unity main thread is only responsible for reading the status data to refresh the game screen, which can significantly increase the number of frames.

3.3. Input Config

Customize the physical keyboard keys corresponding to the native keys.

4. input

Default configuration control method:

Native buttons Operation buttons
Start Num1
Select Num2
Up Up Arrow
Down Down Arrow
Left Left Arrow
Right Right Arrow
A A
B S

5. API

5.1. Boot

Obtain the byte array format of the original ROM file in any way for the emulator to start:

public void Boot(byte[] romData);

5.2. Save

The simulator itself only provides the data of the current running state, and does not provide the persistence implementation of the data file. Need to realize the preservation of archived data by oneself.

public byte[] GetSaveData();

5.3. Load

Obtain archive file data in any way for the emulator to restore game progress:

public void LoadSaveData(byte[] saveData);

6. Mapper

There are many Mapper extension formats in NES, and the implemented part of the project implementation can theoretically support most common games.

0 NROM
1 MMC1
2 UxROM
3 CNROM
4 MMC3
7 AxROM
9 MMC2 (Mike Tyson's Punch-Out!!)
10 MMC4
11 Color Dreams
66 GxROM
71 Camerica
79 NINA-003-006
94 Senjou no Ookami
140 Jaleco
155 MMC1A
180 Crazy Climber
206 DxROM

7. Problem

  • Audio APU simulation is not implemented.
  • Only realize Unity basic input system and pure keyboard operation mode.
  • Not all Mappers are implemented.
  • The performance of the PPU simulation part is low, and the frame number is unstable on the low-end mobile devices.

About

🎮 Nintendo Entertainment System emulator written in C# and run in Unity

Topics

Resources

License

Stars

Watchers

Forks

Languages