NES 2.0 Additions Proposal

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

lidnariq
Site Admin
Posts: 11593
Joined: Sun Apr 13, 2008 11:12 am

Re: NES 2.0 Additions Proposal

Post by lidnariq »

NewRisingSun wrote:I would still like to solicit more input on how to deal with ROMs with more than 64 MiB of PRG-ROM.
My suggestion:

1- Anything released that doesn't provide true random access to ROM is out of scope for stuffing into .nes (e.g. bare NAND flash, CompactFlash, SD card)

2- 256 MiB NOR FLASH is already really expensive ($18/@1600). Market forces give every reason to believe no larger NOR FLASH will be ever sold.

3- I like rainwarrior's floating-point-ish option.
yielding a much more streamlined implementation.
To my disappointment, I feel like mapper 185 already case cast a vote in favor of making the emulator's code base a mess in preference to baking in padding.
The trimming would also be kind of awkward for Vs. Mahjong because one of the 16 KiB banks would contain PRG data from both units.
But the 16 KiB banks are an artifact anyway, given the number of games that do 8 KiB banking. Is it really all that different to quantize things to 8 KiB vs 32 KiB?
Last edited by lidnariq on Wed Jul 04, 2018 2:31 pm, edited 1 time in total.
NewRisingSun
Posts: 1530
Joined: Thu May 19, 2005 11:30 am

Re: NES 2.0 Additions Proposal

Post by NewRisingSun »

Ok, then trimmed Vs. Mahjong and Bungeling Bay it is. I hope to post the updated proposals this weekend.
NewRisingSun
Posts: 1530
Joined: Thu May 19, 2005 11:30 am

Re: NES 2.0 Additions Proposal

Post by NewRisingSun »

Here is the updated proposal, as promised.

Byte 7: Flags 7

Code: Select all

       7654 3210
       ---------
       NNNN SSTT
       |||| ||++- Console type (see below)
       |||| ++--- NES 2.0 identificator (binary 10)
       ++++------ Upper four bits of mapper number
       
       Console types:
       $00      Regular NES/Famicom/Dendy home console, byte 13 unused
       $01      Vs. System, byte 13's two nibbles indicating palette and protection/type
       $02      Playchoice 10, byte 13 unused, three Misc. ROMs specified in byte 14 (8 KiB INST, 16 bytes PROM Data, 16 bytes PROM CounterOut).
       $03      Extended, byte 13 further describing the console
Byte 9: Upper bits of ROM size

Code: Select all

        7       0
        ---------
        CCCC PPPP

        C: 4 more CHR ROM size bits
        P: 4 more PRG ROM size bits

        If P/C has the value $F, header bytes $4/$5 changes meaning from number of 16 KiB/8 KiB PRG/CHR banks to the following floating-point-like format:

        7       0
        ---------
        EEEE EEMM
        |||| ||++- Multiplier, actual value is MM*2+1 (1,3,5,7)
        ++++ ++--- Exponent (2^E), 0-63

        The actual PRG- or CHR-ROM size therefore becomes 2^E * (MM*2+1). This allows for ROM sizes larger than the current maximum of 64 MiB without too much padding.
Byte 12: TV System

Code: Select all

       7654 3210
       ---------
       .... ..TT
              ++- Frame timing
                  0: RP2C02 (NTSC)
                  1: RP2C07 (PAL licensed)
                  2: RP2C02 and RP2C07 (game self-adjusting or doesn't matter)
                  3: UMC 6527P (PAL with NTSC-like timing, also known as "Dendy" or "Micro Genius" mode)
Byte 13 if Byte 7 AND $03 == $01: Vs. Hardware

Code: Select all

        Bits 0-3: Palette (unchanged from current spec)
        Bits 4-7: Vs. Mode
                $0      Normal- no special mode(s)
                $1      RBI Baseball  (protection hardware at port 5E0xh)
                $2      TKO Boxing    (protection hardware at port 5E0xh, different from 1)
                $3      Super Xevious (protection hardware at port 5xxxh)
                $4      Vs. Ice Climber Japanese (protection: controller bit $08s always 1)
                $5      Vs. Dual System
                $6      Vs. Raid on Bungeling Bay (dual CPU, protection: controller bit $08s always 1)
Byte 13 if Byte 7 AND $03 == $03: Extended console type

Code: Select all

        $00     NES/Famicom
        $01     Vs. System
        $02     Playchoice 10
        $03     Bit Corporation Creator (normal Famiclone but with decimal-mode-supporting CPU)
        $04     VT01 Monochrome
        $05     VT01 Red/Cyan
        $06     VT02
        $07     VT03
        $08     VT09
        $09     VT3x
        $0A     VT36x
        $0B-$FF Reserved for future expansion
Byte 15: Input/expansion port device

Code: Select all

        $00     Unspecified, use NES standard controllers
        $01     Famicom controllers with Microphone
        $02     NES Four Score/Satellite with two additional standard controllers
        $03     Famicom Four Players Adapter with two additional standard controllers
        $04     Vs. System
        $05     Vs. System with reversed inputs
        $06     Vs. Pinball (Japan)
        $07     Vs. Zapper
        $08     Zapper
        $09     Two Zappers
        $0A     Bandai Hyper Shot
        $0B     Power Pad Side A
        $0C     Power Pad Side B
        $0D     Family Trainer Side A
        $0E     Family Trainer Side B
        $0F     Arkanoid Paddle (NES)
        $10     Arkanoid Paddle (Famicom)
        $11     Two Vaus Controllers plus Famicom Data Recorder
        $12     Konami Hyper Shot
        $13     Coconuts Pachinko Controller
        $14     Exciting Boxing Punching Bag
        $15     Jissen Mahjong Controller
        $16     Party Tap
        $17     Oeka Kids Tablet
        $18     Sunsoft Barcode Battler
        $19     Miracle Piano Keyboard
        $1A     Pokkun Moguraa
        $1B     Top Rider
        $1C     Double-Fisted
        $1D     Famicom 3D System
        $1E     Doremikko Keyboard
        $1F     R.O.B. Gyro Set
        $20     Famicom Data Recorder (don't emulate keyboard)
        $21     ASCII Turbo File
        $22     IGS Storage Battle Box
        $23     Family BASIC Keyboard plus Famicom Data Recorder
        $24     Dongda PEC-586 Keyboard
        $25     Bit Corp. Bit-79 Keyboard
        $26     Subor Keyboard
        $27     Subor Keyboard plus mouse (3x8-bit protocol)
        $28     Subor Keyboard plus mouse (24-bit protocol)
        $29     SNES Mouse
        $2A     Generic multicart
        $2B     Two SNES controllers replacing the two standard NES controllers
Input Device Notes:
  • Does not include input devices that attach to cartridge hardware.
  • Most games only support one input device, making this value entirely unambiguous for them. For the few (mostly homebrew) games that allow selecting devices, this becomes a "default" input --- pick one, or don't and leave it at $00, letting the user decide in any case.
Device-specific notes:
  • "Famicom controllers with Microphone": Use only if the microphone is actually used.
  • "Vs. System": Used for both Unisystem and Dual.
  • "Famicom Four Players Adapter": Use only if the games use the 3P and 4P controllers for independent input, not if they're just doubling 1P and 2P input.
  • "Two Zappers": Becomes just "Zapper" if the user has only one mouse and does not use netplay. Even when emulating two Zappers, keep emulating 1P controller (the $4016 bits do not overlap, after all) so that player may choose to use it as well.
  • "Two Vaus Controllers plus Famicom Data Recorder": For Arkanoid II.
  • "Double-Fisted": Used for Crazy Climber and Smash TV. Implies NES Four Score for Smash TV's two-player double-fisted mode, which does not bother Crazy Climber.
  • "R.O.B. Gyro Set": See what Nestopia does there.
  • "Subor Keyboard": Implies Tape Recorder.
  • "Generic multicart": Emulate this as "Zapper in Famicom Expansion port", keeping 1P and 2P controllers attached. This value exists to signal to emulators so-inclined to detect the handful of common expansion-device-using multicart games, for example by comparing ROM strings involving controller read code, and auto-select the device for the selected game.
ROM layout for Vs. Dual games:
  • Most Vs. Dual games have unique 32 KiB PRG-ROM for each unit. Include both sequentially for 64 KiB of PRG-ROM.
  • If both units have the same CHR-ROM data, include it only once.
  • Vs. Mahjong has 24 KiB of PRG-ROM for each unit. Include both sequentially for 48 KiB of PRG-ROM, mapping each 24 KiB to each CPU's $A000-$FFFF, keeping CPU $8000-$9FFF as open bus.
  • Vs. Raid on Bungeling Bay has 32 KiB of PRG-ROM for the first unit, and 8 KiB of PRG-ROM for the second unit. Include the first 32 KiB, then the second unit's 8 KiB without padding to form 40 KiB of PRG-ROM, denoted by setting byte 9's LSB to $F and byte 4 to $36. Map the first unit's 32 KiB to CPU $8000-$FFFF, the second unit's 8 KiB to CPU $E000-$FFFF, and keep the second unit's CPU $8000-$DFFF as open bus.
---
Obiter dictum: Note what I wrote about Playchoice 10 and Misc ROMs. The Extended Console Type now has values 0-2 identical to what Byte 7 bits 0-1 already specified for congruity. I did not include a proposal for >64 MiB ROM sizes: the only such ROM known to me is the Coolgirl homebrew multicart, which has 66.5 MiB and would be nasty to pad to a power of two, so I am still undecided on what to do with that. Here is my current Nintendulator-NRS build, which includes an updated Header Editor incorporating all aspects of this proposal including the new byte 9. (It does not actually emulate all those expansion devices, yet.)

Edit: I have incorporated Rainwarrior's floating-point-ish proposal and modified the ROM layout description for Vs. Raid on Bungeling Bay to make use of it. This could also be used to contain Galaxian's 8 KiB of PRG-ROM without padding. Doing so would however break compatibility with existing emulators that would otherwise run the game, one of NES 2.0's stated goals. It's less of an issue for Vs. Raid on Bungeling Bay because no previous emulator runs the game from an iNES-format image anyway.
Last edited by NewRisingSun on Sun Jul 08, 2018 10:29 pm, edited 14 times in total.
lidnariq
Site Admin
Posts: 11593
Joined: Sun Apr 13, 2008 11:12 am

Re: NES 2.0 Additions Proposal

Post by lidnariq »

NewRisingSun wrote:the only such ROM known to me is the Coolgirl homebrew multicart, which has 66.5 MiB
?
I see a S29GL512 64 MiB flash, two RAMs (K6F2008 and U?62256), four voltage translation ICs (two 74ALVC16245s and two TI parts), and an Altera MAX 2. Does the MAX 2's fusemap somehow encode 2.5MiB of ROM?
NewRisingSun
Posts: 1530
Joined: Thu May 19, 2005 11:30 am

Re: NES 2.0 Additions Proposal

Post by NewRisingSun »

The actual size of the UNIF PRG0 chunk is 0x4280000 bytes. Make of that what you will.
lidnariq
Site Admin
Posts: 11593
Joined: Sun Apr 13, 2008 11:12 am

Re: NES 2.0 Additions Proposal

Post by lidnariq »

That's ... weird.
One, the battery is clearly made to be replaced, and I don't see any significant bulk capacitance to retain the contents of the RAMs when it's missing, and two, in the pictures of the PCB I'm pretty certain I only see the backed-up power line getting to the 32KiB RAM, not the 256KiB SRAM.

(Thirdly, 288KiB ≠ 2.5MiB anyway)

edit: Ninja'd by an edit.

I found ClusterM's build tool to generate a custom coolgirl multicart. It appears to just generate a flat 256 MiB UNIF PRG0...
NewRisingSun
Posts: 1530
Joined: Thu May 19, 2005 11:30 am

Re: NES 2.0 Additions Proposal

Post by NewRisingSun »

My UNIF ROM image came from a "Non-GoodNES" pack. I suppose somebody just trimmed it, or it came from an earlier version of the build tool.

I have updated the proposal with Rainwarrior's ROM size proposal, which I like very much (it took me a while to understand it).
lidnariq
Site Admin
Posts: 11593
Joined: Sun Apr 13, 2008 11:12 am

Re: NES 2.0 Additions Proposal

Post by lidnariq »

ClusterR's web site also seems to allow (in javascript) the generation of images to flash onto a coolgirl flashcart. It's conceivable that it doesn't add any padding, or trims the padding.
Sour
Posts: 903
Joined: Sun Feb 07, 2016 6:16 pm

Re: NES 2.0 Additions Proposal

Post by Sour »

NewRisingSun wrote:"Vs. System": Used for both Unisystem and Dual. Differs from standard controllers in that "start button 1/2/3/4" are "1P Select/1P Start/2P Select/2P Start".
This bit seems to contradict the wiki which says that 1 & 3 are for player 1, and 2 & 4 are for player 2.

The only examples of arcades that I found in pictures were:
A) The DualSystem red tent - 1/2/3/4 are all together on the right side and don't really look like they are associated with either P1 or P2
B) A number of unisystem arcade cabinets which kind of look like "1" is P1's button, and "2" is P2 (which matches the wiki). But these have no 3/4 buttons, and really 1/2 just look like they are meant to be used as 1/2 player mode selection at the start and nothing else.

Emulation wise, it's "easier" to map the buttons to what the wiki says at the moment (1/3 = P1, 2/4 = P2), since that maps directly to the standard NES controllers.

For the record, Nestopia uses these mappings:
1 = P1 Start, 3 = P1 Select (e.g same as wiki, but switches the select/start bits)
2 = P2 Start, 4 = P2 Select

I don't really think there's a "perfect" way to map these, but I was about to commit my current changes/fixes w/ P1 as 1 & 3 and P2 as 2 & 4, which doesn't match the proposal, so I figured I should bring it up.
lidnariq
Site Admin
Posts: 11593
Joined: Sun Apr 13, 2008 11:12 am

Re: NES 2.0 Additions Proposal

Post by lidnariq »

Sour wrote:This bit seems to contradict the wiki which says that 1 & 3 are for player 1, and 2 & 4 are for player 2.
The two different official schematics—one of the mainboard, and one of the wiring harness—disagree as to what bit comes in where.

The wiring harness specification ("VS_Wiring.pdf") says that pins 8/9/10/11 are S SELECT 1/2/3/4 in order... but also that there is no button associated with S SELECT 3/4.
The MDS mainboard schematic ("VSSCHEM.pdf") says that pins 8/9/10/11 are S SELECT 1/3/2/4 in that order.

Regardless, the MDS mainboard schematic says that pins 8/9 are read by S 2A03 via $4016, and pins 10/11 are read by S 2A03 via $4017... and that $4017 is player 2 and $4016 is player 1, unlike everything I've heard before?
NewRisingSun
Posts: 1530
Joined: Thu May 19, 2005 11:30 am

Re: NES 2.0 Additions Proposal

Post by NewRisingSun »

I made a list of how the various games use the $4016 and $4017 serial bits, and what they call them:

Code: Select all

Game                    $4016 $04               $4016 $08               $4017 $04               $4017 $08
Normal NES              1P Select               1P Start                2P Select               2P Start

Input type: "$04 Vs. System":
Vs. Balloon Fight       1P Start ("blue/1")     -                       2P Start ("green/2")    -
Vs. Baseball            1P Start ("blue/1")     -                       2P Start ("green/2")    -
Vs. Mahjong             1P Start ("blue/1")     -                       2P Start ("green/2")    -
Vs. Pinball             1P Start ("blue/1")     -                       2P Start ("green/2")    -
Vs. Slalom              1P Start ("blue/1")     -                       2P Start ("green/2")    -
Vs. Super Mario Bros.   1P Start ("blue")       -                       2P Start ("green")      -
Vs. Wrecking Crew       1P Start ("blue/1")     -                       2P Start ("green/2")    -
Vs. Tennis              1P vs. Comp ("blue/1")  2P vs. Comp("pink/3")   1P vs. 2P ("green/2")   2P vs. 2P ("yellow/4")

Input type: "$05 Vs. System with reversed inputs":
Atari R.B.I. Baseball   1P Start ("blue/1")     -                       2P Start ("green/2")    -
Vs. Battle City         1P Start ("")           -                       2P Start ("")           -       
Vs. Clu Clu Land        1P Start ("blue/1")     -                       2P Start ("green/2")    -
Vs. Dr. Mario           1P Start ("blue")       -                       2P Start ("green")      -
Vs. Golf (2x Start)     1P Start ("blue/1)      -                       2P Start ("green/2")    -
Vs. Gradius             1P Start ("")           -                       2P Start ("")           -       
Vs. Ice Climber         1P Start ("blue/1")     -                       2P Start ("green/2")    -
Vs. Raid on B-Bay       1P Start ("1")          -                       2P Start ("2")          -
Vs. Soccer              1P Start ("blue/1")     -                       2P Start ("green/2")    -
Ninja Jajamaru-kun      1P Start ("1")          2P Start ("3")          -                       -                       
Super Sky Kid           1P Start ("1")          2P Start ("3")          -                       -                       
Vs. Golf (4x Start)     1P Stroke ("blue/1)     1P Match ("pink/3")     2P Stroke ("green/2")   2P Match ("yellow/4")

Super Xevious, Vs. Castlevania, Vs. Duck Hunt, Vs. ExciteBike, Vs. Goonies, Vs. Gumshoe, Vs. Hogan's Alley, Vs. Mach Rider, Vs. Star Luster, Vs. Top Gun: Single-player only.
Vs. Tetris/Vs. TKO: Game mode is selected via cursor and not decided by pressing which button.
In other words, "Vs. System with reversed inputs" reverses the D-Pad and B/A buttons but not the start/select buttons. Then everything neatly falls into place. Pretty much the only oddities are Sky Kid and Jajamaru wanting to start two-player mode with button 3, which they even call by that number, rather than with button 2. In any case, the proposal does not require implementing Vs. Controls in any particular way, only that there are two mappings, normal and reverse. It's probably best to present the user with the colors and button names that the games present, though.

Edit: I have updated the Nintendulator-NRS build to support the new byte 9 as well.
Sour
Posts: 903
Joined: Sun Feb 07, 2016 6:16 pm

Re: NES 2.0 Additions Proposal

Post by Sour »

Thanks for taking the time to make that list - saves me a lot of headache when double-checking the setup I have.
Just one tiny thing, Tetris does need swapped controllers in a sense, otherwise P1 ends up being on the right side of the screen during gameplay.
NewRisingSun
Posts: 1530
Joined: Thu May 19, 2005 11:30 am

Re: NES 2.0 Additions Proposal

Post by NewRisingSun »

Since GoodNES' Vs. ROM images are useless for Vs. Dual games and don't have NES 2.0 headers for Unisystem games, I have made the attached batch file 'n headers to convert MAME's Vs. ROM sets to the NES 2.0 format according to the proposed specification. For games with odd ROM sizes, I am producing both padded and trimmed versions, the latter making use of the floating-pointish way of specifying the ROM size.
Attachments
cnvvs.7z
(25.75 KiB) Downloaded 885 times
Sour
Posts: 903
Joined: Sun Feb 07, 2016 6:16 pm

Re: NES 2.0 Additions Proposal

Post by Sour »

As of the latest commit, Mesen supports all of the proposed changes (I think). Headers specifying hardware Mesen itself doesn't support is ignored for now. VS System support is complete (including DualSystem).

Slightly unrelated, but I've also added support for ~55 mappers in the 256+ range (thanks for making the Wiki page with the UNIF<->NES 2.0 mappings, was extremely helpful)
The actual PRG- or CHR-ROM size therefore becomes 2^E +MM*2+1.
This should be 2^E * (MM*2+1), I think?
NewRisingSun
Posts: 1530
Joined: Thu May 19, 2005 11:30 am

Re: NES 2.0 Additions Proposal

Post by NewRisingSun »

I have corrected the formula.

That's nice that somebody appreciates the wiki additions.

Edit: Added the "Two SNES Controllers" entry to the Input Device list.
Post Reply