View difference between Paste ID: S0fmWuSu and Sg4HX2vd
SHOW: | | - or go back to the newest paste.
1
My sfrom Header Format Conclusions - DarkAkuma
2
3
After trial-n-error, and a bit of research from https://www.3dbrew.org/ 3DS and WiiU wiki's, the format of the SNES Classic has been determined to be the following. It's not EXACTLY the same, but often similar enough.
4
5
Header 1:
6
7
Addr:   Size:	Description:
8
0x00 	0x04 	Always 0x00000100
9
0x04 	0x04 	File size (Including ROM, Headers, PCM audio samples index, and SDD-1 graphics data if present)
10
0x08 	0x04 	Always 0x00000030
11
0x0C 	0x04 	End of the ROM region (not the file)
12
0x10 	0x04 	Start of the footer region (presumably an index for the PCM audio samples). Matches end of file/file size if PCM data is missing
13
0x14 	0x04 	Points to the second header (starts with 3C)
14
0x18 	0x04 	Assumed start of decompressed SDD-1 graphics data. Matches end of file/file size if no SDD-1 not a SDD-1 game.
15
0x1C 	0x04 	Always 0x00000000
16
0x20 	0x04 	End of second header? Usually a 0x00000001.
17
0x24 	0x08 	SNES Classic, 3DS/Wii U Virtual Console Game ID (WUP-J**X, X — title region (E for EUR)?)
18
0x2C 	0x04 	Always 0x00000000
19
20
Header 2:
21
22
Addr:   Size:	Description:
23
0x00 	0x01 	Emulation speed in FPS (always 0x3C in official VC)
24
0x01 	0x02 	Always 0x00. Might be part of the following ROM size.
25
0x03 	0x01 	ROM size (In Mbits? I'm not great with Mbit. Rounding up seems to work fine.)
26
0x04 	0x01 	Always 0x00
27
0x05 	0x03 	Size of the converted PCM audio samples region (starting after ROM). 0x000000 if PCM data is missing
28
0x08 	0x01 	Always 0x00
29
0x09 	0x02 	PCM footer region size. 0x0000 if PCM data is missing
30
0x0B 	0x02 	Always 0x0000
31
0x0D 	0x02 	Game preset ID? (varies for each game). 0x10XX = Early VC releases, 0x11XX range = Capcom games, 0x12XX range = Super FX games.
32
0x0F 	0x01 	Almost always 0x02. Seems to control the amount of controllers to read input from. (Though setting it to 0x00 still lets 1 player work.)
33
0x10 	0x01 	Sound volume
34
0x11 	0x01 	ROM type (0x14 = LoROM / 0x15 = HiROM)
35
0x12 	0x01 	Super FX flag (0xC0 = Super FX game. 0x00 = Anything else)
36
0x1B	0x04    Always 0x00000001 (End of second header? Referred to by Header1:0x20)
37
0x1F	0x04    Always 0x00000001 (???)
38
0x23+	0xXX	Null padding to round to the next 16 bytes.
39
40
Notes:
41
42
At this time SDD-1 data doesn't work, but I just assume it's use if it did.
43
44
The major difference is spotted in the second header. The sfrom in the SNESClassic are all 35 bytes (0x23) with 0x00's padding out to the next 16 bytes. It's minor, but it is a difference.
45
46
My belief is that the Game Preset ID value is used for a switch/table type look up. Probably with some fall through, but some cases calling game specific routines. Here's a mock up to illustrate it.
47
48
// Mockup function.
49
void SomeFunction()
50
{
51
	ushort value = GetValueAt0D(); // In big endian order. 
52
	
53
	switch	(value)
54
	{
55
		// Game developers add their unique game/region id to the end of the appropriate section.
56
		
57
		// 0x1000-0x10FF is for most games.
58
		case (0x1000):
59
		case (0x1001):
60
		case (0x1002):
61
		{
62
			// Do something.
63
		}
64
		case (0x1003):
65
		case (0x1004):
66
		{
67
			// Do something different.
68
		}
69
		// etc...
70
		case (0x10FE):
71
		case (0x10FF):
72
		{
73
			// Do something even more different.
74
		}
75
		// 0x1100-0x11FF = Reserved for Capcom?
76
		case (0x1100)
77
		case (0x1101)
78
		case (0x1102)
79
		// etc...
80
		case (0x11FF)
81
		{
82
			// Do something unique to Capcom game code.
83
		}
84
		// 0x1200-0x12FF = Reserved for Super FX?
85
		case (0x1200)
86
		case (0x1201)
87
		case (0x1202)
88
		// etc...
89
		case (0x12FF)
90
		{
91
			// Do something necessary for Super FX games.
92
		}
93
	}
94
	
95
	// Continue on with something else...
96
}