3DS Virtual Console

Revision as of 09:01, 31 January 2016 by Yellows8 (talk | contribs)

There's two types of VC titles: regular VC titles, and dedicated GBA VC titles.

Regular VC

Regular VC titles: an emulator application + VC ROM in the NCCH RomFS(among other things in the RomFS). The emulator build includes support for all supported VC platforms, not specific to just the included ROM platform.

This emulator includes GBA support, however the GBA emulation for this this is somewhat slow. This was presumably implemented before AGB_FIRM was.

Unlike Wii VC, the 3DS VC ROMs for NES use the "TNES" header.

RomFS

  • "rom:/rom/" This directory contains the ROM file(s). Filenames used under here don't matter: the filename is determined by the emulator app by doing a directory read.
  • "rom:/shaders/" This directory contains GPU shaders used by the emulator app: .shbin, .csdr, and .obj.
  • "rom:/VCM/" This directory contains graphics, audio, and text used by the emulator app.
  • "rom:/agb.bin" GBA BIOS.
  • "rom:/buildtime.txt" Emulator app build timestamp.
  • "rom:/config.ini" Emulator configuration .ini, contains sections for all supported 3DS VC platforms.
  • "rom:/<rom_name>.patch" rom_name = filename from the rom directory. This .ini contains patches for the ROM.
  • "rom:/shader.shbin" GPU shader.

Savedata

The savedata contains:

  • "rsm1.dat": Same format as the below rsm2.dat. Probably used for the "restore-point".
  • "rsm2.dat": Current emulator save-state, for storing/loading state at VC-title launch/exit.
  • "sav.dat": The actual savedata used by the emulated ROM.

Overwriting sav.dat with 0xFF-bytes doesn't have any affect on the actual emulator. Doing that with most of the rsm*.dat data doesn't crash anything.

GBA VC

GBA VC is run by AGB_FIRM. RomFS isn't used for GBA VC titles, but can be found empty within GBA VC titles. The NCCH ExeFS contains the same files as a normal application. The ExeFS:/.code contains the GBA VC ROM followed by a 0x360 byte long footer.

Footer

All values in the GBA VC footer are little-endian.

START SIZE DESCRIPTION
0x004 0x4 GBA ROM Filesize
0x008 0x4 Save type (see below)
0x020 0x1 Manufacturer info select (see below)
0x024 0x300 Unknown, three different types of this data have been observed.
0x338 0x4 GBA ROM Filesize
0x344 0x4 GBA ROM Filesize
0x350 0x4 Magic '.CAA'
0x35A 0x2 High two bytes of GBA ROM file size

Save types:

  • EEPROM (various sizes, IDs specified in footer): 0x2
  • SRAM/FRAM (128k): 0xE
  • Flash (512k): 0x9

Support for RTC and 1m-flash chips is not implemented in AGB_FIRM.

Manufacturer info: GBA games' SDK-provided save code only supports a range of manufacturers from which Nintendo was buying memory from around the time of that game's development. As such, most games don't support a generic emulated storage chip. This byte appears to select a manufacturer info set to emulate. This has been observed to be 0x90, 0xC0, and (in one EEPROM-based game), 0x80.

  • SRAM games up to and including V111 use 0xC0. Above use 0x90.
  • FRAM V103 uses 0xC0. V104+ don't exist, and lower versions also likely use 0xC0.
  • Flash V124 was observed 0x90, V131 was observed 0xC0.
  • EEPROM-based games vary wildly, since they can likely specify chip info in the 0x10-region of the footer.


NAND Savegame

AGB_FIRM saves its active save memory to NAND on exit, this is then immediately picked up by NATIVE_FIRM on reboot by checking CFG_BOOTENV. From there, this is verified and copied out to SD. The savegame format is as follows:

START SIZE DESCRIPTION
0x0 0x4 Magic ('.SAV')
0x4 0xC Always 0xFF
0x10 0x10 AES-MAC of the SHA256 hash of 0x30..0x200 + the entire save itself, keyslot 0x24, keyY from process9 .rodata
0x20 0x10 Always 0xFF
0x30 0x40 Always 0x1
0x34 0x4 Number of times saved (unused?)
0x38 0x8 AGB TitleID
0x40 0x10 SD card CID from the console the save was made on (verified on load)
0x50 0x4 Save start addr (always 0x200)
0x54 0x4 Save size
0x58 0x8 Always 0xFF (?)
0x60 0x4 See here
0x64 0x4 See here
0x68 0x198 Always 0xFF