NesContainers
Public Types | Public Member Functions | Static Public Member Functions | Properties
com.clusterrr.Famicom.Containers.NesFile Class Reference

iNES / NES 2.0 file container for NES/Famicom games More...

Public Types

enum class  iNesVersion { iNES = 1 , NES20 = 2 }
 Version of iNES format More...
 
enum class  ConsoleType { Normal = 0 , VsSystem = 1 , Playchoice10 = 2 , Extended = 3 }
 Console type More...
 
enum class  VsPpuType {
  RP2C03B = 0x00 , RP2C03G = 0x01 , RP2C04_0001 = 0x02 , RP2C04_0002 = 0x03 ,
  RP2C04_0003 = 0x04 , RP2C04_0004 = 0x05 , RC2C03B = 0x06 , RC2C03C = 0x07 ,
  RC2C05_01 = 0x08 , RC2C05_02 = 0x09 , RC2C05_03 = 0x0A , RC2C05_04 = 0x0B ,
  RC2C05_05 = 0x0C
}
 Vs. System PPU type More...
 
enum class  VsHardwareType {
  VsUnisystemNormal = 0x00 , VsUnisystemRBIBaseballProtection = 0x01 , VsUnisystemTKOBoxingProtection = 0x02 , VsUnisystemSuperXeviousProtection = 0x03 ,
  VsUnisystemVsIceClimberJapanProtection = 0x04 , VsDualSystemNormal = 0x05 , VsDualSystemRaidOnBungelingBayProtection = 0x06
}
 Vs. System hardware type More...
 
enum class  ExtendedConsoleType {
  RegularNES = 0x00 , NintendoVsSystem = 0x01 , Playchoice10 = 0x02 , FamicloneWithDecimalMode = 0x03 ,
  VRTechnologyVT01Monochrome = 0x04 , VRTechnologyVT01WithRedCyanSTNPalette = 0x05 , VRTechnologyVT02 = 0x06 , VRTechnologyVT03 = 0x07 ,
  VRTechnologyVT09 = 0x08 , VRTechnologyVT32 = 0x09 , VRTechnologyVT369 = 0x0A , UMC_UM6578 = 0x0B
}
 Extended console type More...
 
enum class  ExpansionDevice {
  Unspecified = 0x00 , Standard = 0x01 , NesFourScore = 0x02 , FamicomFourPlayersAdapter = 0x03 ,
  VsSystem = 0x04 , VsSystemWithReversedInputs = 0x05 , VsPinball = 0x06 , VsZapper = 0x07 ,
  Zapper = 0x08 , TwoZappers = 0x09 , BandaiHyperShotLightgun = 0x0A , PowerPadSideA = 0x0B ,
  PowerPadSideB = 0x0C , FamilyTrainerSideA = 0x0D , FamilyTrainerSideB = 0x0E , ArkanoidVausControllerNES = 0x0F ,
  ArkanoidVausControllerFamicom = 0x10 , TwoVausControllersPlusFamicomDataRecorder = 0x11 , KonamiHyperShotController = 0x12 , CoconutsPachinkoController = 0x13 ,
  ExcitingBoxingPunchingBag = 0x14 , JissenMahjongController = 0x15 , PartyTap = 0x16 , OekaKidsTablet = 0x17 ,
  SunsoftBarcodeBattler = 0x18 , MiraclePianoKeyboard = 0x19 , PokkunMoguraa = 0x1A , TopRider = 0x1B ,
  DoubleFisted = 0x1C , Famicom3DSystem = 0x1D , DoremikkoKeyboard = 0x1E , RobGyroSet = 0x1F ,
  FamicomDataRecorder = 0x20 , ASCIITurboFile = 0x21 , IGSStorageBattleBox = 0x22 , FamilyBasicKeyboardPlusFamicomDataRecorder = 0x23 ,
  DongdaPEC586Keyboard = 0x24 , BitCorpBit79Keyboard = 0x25 , SuborKeyboard = 0x26 , SuborKeyboardPlusMouse3x8 = 0x27 ,
  SuborKeyboardPlusMouse24 = 0x28 , SnesMouse4017 = 0x29 , Multicart = 0x2A , TwoSnesControllers = 0x2B ,
  RacerMateBicycle = 0x2C , UForce = 0x2D , RobStackUp = 0x2E , CityPatrolmanLightgun = 0x2F ,
  SharpC1CassetteInterface = 0x30 , StandardControllerWithSwapped = 0x31 , ExcaliborSudokuPad = 0x32 , AblPinball = 0x33 ,
  GoldenNuggetCasinoExtraButtons = 0x34
}
 Type of expansion device connected to console, source: https://www.nesdev.org/wiki/NES_2.0#Default_Expansion_Device More...
 

Public Member Functions

 NesFile ()
 Constructor to create empty NesFile object More...
 
 NesFile (byte[] data)
 Create NesFile object from raw .nes file contents More...
 
 NesFile (string fileName)
 Create NesFile object from the specified .nes file More...
 
byte[] ToBytes ()
 Returns .nes file contents (header + PRG + CHR) More...
 
void Save (string filename)
 Save as .nes file More...
 
byte[] CalculateMD5 ()
 Calculate MD5 checksum of ROM (CHR+PRG without header) More...
 
uint CalculateCRC32 ()
 Calculate CRC32 checksum of ROM (CHR+PRG without header) More...
 

Static Public Member Functions

static NesFile FromBytes (byte[] data)
 Create NesFile object from raw .nes file contents More...
 
static NesFile FromFile (string filename)
 Create NesFile object from the specified .nes file More...
 

Properties

byte[]?? PRG [get, set]
 PRG data More...
 
byte[]?? CHR [get, set]
 CHR data More...
 
byte[]?? Trainer [get, set]
 Trainer More...
 
byte[]?? MiscellaneousROM [get, set]
 Miscellaneous ROM (NES 2.0 only) More...
 
ushort Mapper = 0 [get, set]
 Mapper number More...
 
byte Submapper = 0 [get, set]
 Submapper number (NES 2.0 only) More...
 
bool Battery = false [get, set]
 Battery-backed (or other non-volatile memory) memory is present More...
 
iNesVersion Version [get, set]
 Version of .nes file format: iNES or NES 2.0 More...
 
uint??? PrgRamSize [get, set]
 PRG RAM Size (NES 2.0 only) More...
 
uint??? PrgNvRamSize [get, set]
 PRG NVRAM Size (NES 2.0 only) More...
 
uint??? ChrRamSize [get, set]
 CHR RAM Size (NES 2.0 only) More...
 
uint??? ChrNvRamSize [get, set]
 CHR NVRAM Size (NES 2.0 only) More...
 
MirroringType Mirroring = MirroringType.Horizontal [get, set]
 Mirroring type More...
 
Timing Region = Timing.Ntsc [get, set]
 For non-homebrew NES/Famicom games, this field's value is always a function of the region in which a game was released (NES 2.0 only) More...
 
ConsoleType Console = ConsoleType.Normal [get, set]
 Console type (NES 2.0 only) More...
 
VsPpuType VsPpu = VsPpuType.RP2C03B [get, set]
 Vs. System PPU type (used when Console is ConsoleType.VsSystem) More...
 
VsHardwareType VsHardware = VsHardwareType.VsUnisystemNormal [get, set]
 Vs. System hardware type (used when Console is ConsoleType.VsSystem) More...
 
ExtendedConsoleType ExtendedConsole = ExtendedConsoleType.RegularNES [get, set]
 Extended console type (used when Console is ConsoleType.Extended) More...
 
ExpansionDevice DefaultExpansionDevice = ExpansionDevice.Unspecified [get, set]
 Default expansion device (NES 2.0 only) More...
 
byte MiscellaneousROMsCount = 0 [get, set]
 Miscellaneous ROMs сount (NES 2.0 only) More...
 

Detailed Description

iNES / NES 2.0 file container for NES/Famicom games

Member Enumeration Documentation

◆ iNesVersion

Version of iNES format

Enumerator
iNES 

Classic iNES format

NES20 

NES 2.0 format

◆ ConsoleType

Console type

Enumerator
Normal 

Nintendo Entertainment System/Family Computer

VsSystem 

Nintendo Vs. System

Playchoice10 

Nintendo Playchoice 10

Extended 

Extended Console Type

◆ VsPpuType

Vs. System PPU type

Enumerator
RP2C03B 

RP2C03B

RP2C03G 

RP2C03G

RP2C04_0001 

RP2C04-0001

RP2C04_0002 

RP2C04-0002


RP2C04_0003 

RP2C04-0003

RP2C04_0004 

RP2C04-0004

RC2C03B 

RC2C03B

RC2C03C 

RC2C03C

RC2C05_01 

RC2C05-01 ($2002 AND $?? =$1B)

RC2C05_02 

RC2C05-02 ($2002 AND $3F =$3D)

RC2C05_03 

RC2C05-03 ($2002 AND $1F =$1C)

RC2C05_04 

RC2C05-04 ($2002 AND $1F =$1B)

RC2C05_05 

RC2C05-05 ($2002 AND $1F =unknown)

◆ VsHardwareType

Vs. System hardware type

Enumerator
VsUnisystemNormal 

Vs. Unisystem (normal)

VsUnisystemRBIBaseballProtection 

Vs. Unisystem (RBI Baseball protection)

VsUnisystemTKOBoxingProtection 

Vs. Unisystem (TKO Boxing protection)

VsUnisystemSuperXeviousProtection 

Vs. Unisystem (Super Xevious protection)

VsUnisystemVsIceClimberJapanProtection 

Vs. Unisystem (Vs. Ice Climber Japan protection)

VsDualSystemNormal 

Vs. Dual System (normal)

VsDualSystemRaidOnBungelingBayProtection 

Vs. Dual System (Raid on Bungeling Bay protection)

◆ ExtendedConsoleType

Extended console type

Enumerator
RegularNES 

Regular NES/Famicom/Dendy

NintendoVsSystem 

Nintendo Vs. System

Playchoice10 

Playchoice 10

FamicloneWithDecimalMode 

Regular Famiclone, but with CPU that supports Decimal Mode (e.g. Bit Corporation Creator)

VRTechnologyVT01Monochrome 

V.R. Technology VT01 with monochrome palette

VRTechnologyVT01WithRedCyanSTNPalette 

V.R. Technology VT01 with red/cyan STN palette

VRTechnologyVT02 

V.R. Technology VT02

VRTechnologyVT03 

V.R. Technology VT03

VRTechnologyVT09 

V.R. Technology VT09

VRTechnologyVT32 

V.R. Technology VT32

VRTechnologyVT369 

V.R. Technology VT369

UMC_UM6578 

UMC UM6578

◆ ExpansionDevice

Type of expansion device connected to console, source: https://www.nesdev.org/wiki/NES_2.0#Default_Expansion_Device

Enumerator
Unspecified 

Expansion device is not specified

Standard 

Standard NES/Famicom controllers

NesFourScore 

NES Four Score/Satellite with two additional standard controllers

FamicomFourPlayersAdapter 

Famicom Four Players Adapter with two additional standard controllers

VsSystem 

Vs. System

VsSystemWithReversedInputs 

Vs. System with reversed inputs

VsPinball 

Vs. Pinball (Japan)

VsZapper 

Vs. Zapper

Zapper 

Zapper ($4017)

TwoZappers 

Two Zappers

BandaiHyperShotLightgun 

Bandai Hyper Shot Lightgun

PowerPadSideA 

Power Pad Side A

PowerPadSideB 

Power Pad Side B

FamilyTrainerSideA 

Family Trainer Side A

FamilyTrainerSideB 

Family Trainer Side B

ArkanoidVausControllerNES 

Arkanoid Vaus Controller (NES)

ArkanoidVausControllerFamicom 

Arkanoid Vaus Controller (Famicom)

TwoVausControllersPlusFamicomDataRecorder 

Two Vaus Controllers plus Famicom Data Recorder

KonamiHyperShotController 

Konami Hyper Shot Controller

CoconutsPachinkoController 

Coconuts Pachinko Controller

ExcitingBoxingPunchingBag 

Exciting Boxing Punching Bag (Blowup Doll)

JissenMahjongController 

Jissen Mahjong Controller

PartyTap 

Party Tap

OekaKidsTablet 

Oeka Kids Tablet

SunsoftBarcodeBattler 

Sunsoft Barcode Battler

MiraclePianoKeyboard 

Miracle Piano Keyboard

PokkunMoguraa 

Pokkun Moguraa (Whack-a-Mole Mat and Mallet)

TopRider 

Top Rider(Inflatable Bicycle)

DoubleFisted 

Double-Fisted (Requires or allows use of two controllers by one player)

Famicom3DSystem 

Famicom 3D System

DoremikkoKeyboard 

Doremikko Keyboard

RobGyroSet 

R.O.B. Gyro Set

FamicomDataRecorder 

Famicom Data Recorder (don't emulate keyboard)

ASCIITurboFile 

ASCII Turbo File

IGSStorageBattleBox 

IGS Storage Battle Box

FamilyBasicKeyboardPlusFamicomDataRecorder 

Family BASIC Keyboard plus Famicom Data Recorder

DongdaPEC586Keyboard 

Dongda PEC-586 Keyboard

BitCorpBit79Keyboard 

Bit Corp. Bit-79 Keyboard

SuborKeyboard 

Subor Keyboard

SuborKeyboardPlusMouse3x8 

Subor Keyboard plus mouse (3x8-bit protocol)

SuborKeyboardPlusMouse24 

Subor Keyboard plus mouse (24-bit protocol)

SnesMouse4017 

SNES Mouse ($4017.d0)

Multicart 

Multicart

TwoSnesControllers 

Two SNES controllers replacing the two standard NES controllers

RacerMateBicycle 

RacerMate Bicycle

UForce 

U-Force

RobStackUp 

R.O.B. Stack-Up

CityPatrolmanLightgun 

City Patrolman Lightgun

SharpC1CassetteInterface 

Sharp C1 Cassette Interface

StandardControllerWithSwapped 

Standard Controller with swapped Left-Right/Up-Down/B-A

ExcaliborSudokuPad 

Excalibor Sudoku Pad

AblPinball 

ABL Pinball

GoldenNuggetCasinoExtraButtons 

Golden Nugget Casino extra buttons

Constructor & Destructor Documentation

◆ NesFile() [1/3]

com.clusterrr.Famicom.Containers.NesFile.NesFile ( )
inline

Constructor to create empty NesFile object

◆ NesFile() [2/3]

com.clusterrr.Famicom.Containers.NesFile.NesFile ( byte[]  data)
inline

Create NesFile object from raw .nes file contents

Parameters
dataRaw .nes file data

◆ NesFile() [3/3]

com.clusterrr.Famicom.Containers.NesFile.NesFile ( string  fileName)
inline

Create NesFile object from the specified .nes file

Parameters
fileNamePath to the .nes file

Member Function Documentation

◆ FromBytes()

static NesFile com.clusterrr.Famicom.Containers.NesFile.FromBytes ( byte[]  data)
static

Create NesFile object from raw .nes file contents

Parameters
dataRaw ROM data
Returns
NesFile object

◆ FromFile()

static NesFile com.clusterrr.Famicom.Containers.NesFile.FromFile ( string  filename)
static

Create NesFile object from the specified .nes file

Parameters
filenamePath to the .nes file
Returns
NesFile object

◆ ToBytes()

byte [] com.clusterrr.Famicom.Containers.NesFile.ToBytes ( )
inline

Returns .nes file contents (header + PRG + CHR)

Returns
.nes file contents

◆ Save()

void com.clusterrr.Famicom.Containers.NesFile.Save ( string  filename)

Save as .nes file

Parameters
filenameTarget filename

◆ CalculateMD5()

byte [] com.clusterrr.Famicom.Containers.NesFile.CalculateMD5 ( )
inline

Calculate MD5 checksum of ROM (CHR+PRG without header)

Returns
MD5 checksum for all PRG and CHR data

◆ CalculateCRC32()

uint com.clusterrr.Famicom.Containers.NesFile.CalculateCRC32 ( )
inline

Calculate CRC32 checksum of ROM (CHR+PRG without header)

Returns
CRC32 checksum for all PRG and CHR data

Property Documentation

◆ PRG

byte []?? com.clusterrr.Famicom.Containers.NesFile.PRG
getset

PRG data

◆ CHR

byte []?? com.clusterrr.Famicom.Containers.NesFile.CHR
getset

CHR data

◆ Trainer

byte []?? com.clusterrr.Famicom.Containers.NesFile.Trainer
getset

Trainer

◆ MiscellaneousROM

byte []?? com.clusterrr.Famicom.Containers.NesFile.MiscellaneousROM
getset

Miscellaneous ROM (NES 2.0 only)

◆ Mapper

ushort com.clusterrr.Famicom.Containers.NesFile.Mapper = 0
getset

Mapper number

◆ Submapper

byte com.clusterrr.Famicom.Containers.NesFile.Submapper = 0
getset

Submapper number (NES 2.0 only)

◆ Battery

bool com.clusterrr.Famicom.Containers.NesFile.Battery = false
getset

Battery-backed (or other non-volatile memory) memory is present

◆ Version

iNesVersion com.clusterrr.Famicom.Containers.NesFile.Version
getset

Version of .nes file format: iNES or NES 2.0

◆ PrgRamSize

uint??? com.clusterrr.Famicom.Containers.NesFile.PrgRamSize
getset

PRG RAM Size (NES 2.0 only)

◆ PrgNvRamSize

uint??? com.clusterrr.Famicom.Containers.NesFile.PrgNvRamSize
getset

PRG NVRAM Size (NES 2.0 only)

◆ ChrRamSize

uint??? com.clusterrr.Famicom.Containers.NesFile.ChrRamSize
getset

CHR RAM Size (NES 2.0 only)

◆ ChrNvRamSize

uint??? com.clusterrr.Famicom.Containers.NesFile.ChrNvRamSize
getset

CHR NVRAM Size (NES 2.0 only)

◆ Mirroring

MirroringType com.clusterrr.Famicom.Containers.NesFile.Mirroring = MirroringType.Horizontal
getset

Mirroring type

◆ Region

Timing com.clusterrr.Famicom.Containers.NesFile.Region = Timing.Ntsc
getset

For non-homebrew NES/Famicom games, this field's value is always a function of the region in which a game was released (NES 2.0 only)


◆ Console

ConsoleType com.clusterrr.Famicom.Containers.NesFile.Console = ConsoleType.Normal
getset

Console type (NES 2.0 only)

◆ VsPpu

VsPpuType com.clusterrr.Famicom.Containers.NesFile.VsPpu = VsPpuType.RP2C03B
getset

Vs. System PPU type (used when Console is ConsoleType.VsSystem)

◆ VsHardware

VsHardwareType com.clusterrr.Famicom.Containers.NesFile.VsHardware = VsHardwareType.VsUnisystemNormal
getset

Vs. System hardware type (used when Console is ConsoleType.VsSystem)

◆ ExtendedConsole

ExtendedConsoleType com.clusterrr.Famicom.Containers.NesFile.ExtendedConsole = ExtendedConsoleType.RegularNES
getset

Extended console type (used when Console is ConsoleType.Extended)

◆ DefaultExpansionDevice

ExpansionDevice com.clusterrr.Famicom.Containers.NesFile.DefaultExpansionDevice = ExpansionDevice.Unspecified
getset

Default expansion device (NES 2.0 only)

◆ MiscellaneousROMsCount

byte com.clusterrr.Famicom.Containers.NesFile.MiscellaneousROMsCount = 0
getset

Miscellaneous ROMs сount (NES 2.0 only)