xref: /freebsd/contrib/file/magic/Magdir/console (revision a4d6d3b8910f3805eebcd8703e11e066aad2e2a1)
1b6cee71dSXin LI
2b6cee71dSXin LI#------------------------------------------------------------------------------
3*a4d6d3b8SXin LI# $File: console,v 1.68 2022/05/14 20:04:43 christos Exp $
4b6cee71dSXin LI# Console game magic
5b6cee71dSXin LI# Toby Deshane <hac@shoelace.digivill.net>
6b6cee71dSXin LI
73e41d09dSXin LI# ines: file(1) magic for Marat's iNES Nintendo Entertainment System ROM dump format
83e41d09dSXin LI# Updated by David Korth <gerbilsoft@gerbilsoft.com>
93e41d09dSXin LI# References:
1048c779cdSXin LI# - https://wiki.nesdev.com/w/index.php/INES
1148c779cdSXin LI# - https://wiki.nesdev.com/w/index.php/NES_2.0
1240427ccaSGordon Tetlow
1340427ccaSGordon Tetlow# Common header for iNES, NES 2.0, and Wii U iNES.
1440427ccaSGordon Tetlow0	name		nes-rom-image-ines
153e41d09dSXin LI>7	byte&0x0C	=0x8		(NES 2.0)
163e41d09dSXin LI>4	byte		x		\b: %ux16k PRG
1740427ccaSGordon Tetlow>5	byte		x		\b, %ux8k CHR
183e41d09dSXin LI>6	byte&0x08	=0x8		[4-Scr]
193e41d09dSXin LI>6	byte&0x09	=0x0		[H-mirror]
203e41d09dSXin LI>6	byte&0x09	=0x1		[V-mirror]
213e41d09dSXin LI>6	byte&0x02	=0x2		[SRAM]
223e41d09dSXin LI>6	byte&0x04	=0x4		[Trainer]
233e41d09dSXin LI>7	byte&0x03	=0x2		[PC10]
2440427ccaSGordon Tetlow>7	byte&0x03	=0x1		[VS]
253e41d09dSXin LI>>7	byte&0x0C	=0x8
263e41d09dSXin LI# NES 2.0: VS PPU
273e41d09dSXin LI>>>13	byte&0x0F	=0x0		\b, RP2C03B
283e41d09dSXin LI>>>13	byte&0x0F	=0x1		\b, RP2C03G
293e41d09dSXin LI>>>13	byte&0x0F	=0x2		\b, RP2C04-0001
303e41d09dSXin LI>>>13	byte&0x0F	=0x3		\b, RP2C04-0002
313e41d09dSXin LI>>>13	byte&0x0F	=0x4		\b, RP2C04-0003
323e41d09dSXin LI>>>13	byte&0x0F	=0x5		\b, RP2C04-0004
333e41d09dSXin LI>>>13	byte&0x0F	=0x6		\b, RP2C03B
343e41d09dSXin LI>>>13	byte&0x0F	=0x7		\b, RP2C03C
353e41d09dSXin LI>>>13	byte&0x0F	=0x8		\b, RP2C05-01
363e41d09dSXin LI>>>13	byte&0x0F	=0x9		\b, RP2C05-02
373e41d09dSXin LI>>>13	byte&0x0F	=0xA		\b, RP2C05-03
383e41d09dSXin LI>>>13	byte&0x0F	=0xB		\b, RP2C05-04
393e41d09dSXin LI>>>13	byte&0x0F	=0xC		\b, RP2C05-05
403e41d09dSXin LI# TODO: VS protection hardware?
413e41d09dSXin LI>>7	byte		x		\b]
423e41d09dSXin LI# NES 2.0-specific flags.
433e41d09dSXin LI>7	byte&0x0C	=0x8
443e41d09dSXin LI>>12	byte&0x03	=0x0		[NTSC]
453e41d09dSXin LI>>12	byte&0x03	=0x1		[PAL]
463e41d09dSXin LI>>12	byte&0x02	=0x2		[NTSC+PAL]
473e41d09dSXin LI
4840427ccaSGordon Tetlow# Standard iNES ROM header.
4940427ccaSGordon Tetlow0	string		NES\x1A		NES ROM image (iNES)
502dc4dbb9SEitan Adler!:mime	application/x-nes-rom
5140427ccaSGordon Tetlow>0	use		nes-rom-image-ines
5240427ccaSGordon Tetlow
5340427ccaSGordon Tetlow# Wii U Virtual Console iNES ROM header.
5440427ccaSGordon Tetlow0	belong		0x4E455300	NES ROM image (Wii U Virtual Console)
552dc4dbb9SEitan Adler!:mime	application/x-nes-rom
5640427ccaSGordon Tetlow>0	use		nes-rom-image-ines
5740427ccaSGordon Tetlow
583e41d09dSXin LI#------------------------------------------------------------------------------
593e41d09dSXin LI# unif: file(1) magic for UNIF-format Nintendo Entertainment System ROM images
6048c779cdSXin LI# Reference: https://wiki.nesdev.com/w/index.php/UNIF
613e41d09dSXin LI# From: David Korth <gerbilsoft@gerbilsoft.com>
623e41d09dSXin LI#
633e41d09dSXin LI# NOTE: The UNIF format uses chunks instead of a fixed header,
643e41d09dSXin LI# so most of the data isn't easily parseable.
653e41d09dSXin LI#
663e41d09dSXin LI0	string	UNIF
6740427ccaSGordon Tetlow>4	lelong	<16	NES ROM image (UNIF v%d format)
682dc4dbb9SEitan Adler!:mime	application/x-nes-rom
69b6cee71dSXin LI
70b6cee71dSXin LI#------------------------------------------------------------------------------
71282e23f0SXin LI# fds: file(1) magic for Famciom Disk System disk images
7248c779cdSXin LI# Reference: https://wiki.nesdev.com/w/index.php/Family_Computer_Disk_System#.FDS_format
73282e23f0SXin LI# From: David Korth <gerbilsoft@gerbilsoft.com>
74282e23f0SXin LI# TODO: Check "Disk info block" and get info from that in addition to the optional header.
75282e23f0SXin LI
76282e23f0SXin LI# Disk info block. (block 1)
77282e23f0SXin LI0	name	nintendo-fds-disk-info-block
78282e23f0SXin LI>23	byte	!1		FMC-
79282e23f0SXin LI>23	byte	1		FSC-
80282e23f0SXin LI>16	string	x		\b%.3s
81*a4d6d3b8SXin LI>15	ubyte	x		\b, mfr %02X
82*a4d6d3b8SXin LI>20	ubyte	x		(Rev.%02u)
83282e23f0SXin LI
84282e23f0SXin LI# Headered version.
85282e23f0SXin LI0	string	FDS\x1A
8640427ccaSGordon Tetlow>0x11	string	*NINTENDO-HVC*	Famicom Disk System disk image:
872dc4dbb9SEitan Adler!:mime	application/x-fds-disk
88282e23f0SXin LI>>0x10	use	nintendo-fds-disk-info-block
89282e23f0SXin LI>4	byte	1	(%u side)
90282e23f0SXin LI>4	byte	!1	(%u sides)
91282e23f0SXin LI
92282e23f0SXin LI# Unheadered version.
9340427ccaSGordon Tetlow1	string	*NINTENDO-HVC*	Famicom Disk System disk image:
942dc4dbb9SEitan Adler!:mime	application/x-fds-disk
95282e23f0SXin LI>0	use	nintendo-fds-disk-info-block
96282e23f0SXin LI
97282e23f0SXin LI#------------------------------------------------------------------------------
9840427ccaSGordon Tetlow# tnes: file(1) magic for TNES-format Nintendo Entertainment System ROM images
9940427ccaSGordon Tetlow# Used by Nintendo 3DS NES Virtual Console games.
10040427ccaSGordon Tetlow# From: David Korth <gerbilsoft@gerbilsoft.com>
10140427ccaSGordon Tetlow#
10240427ccaSGordon Tetlow0		string	TNES	NES ROM image (Nintendo 3DS Virtual Console)
1032dc4dbb9SEitan Adler!:mime		application/x-nes-rom
10440427ccaSGordon Tetlow>4		byte	100	\b: FDS,
10540427ccaSGordon Tetlow>>0x2010	use	nintendo-fds-disk-info-block
10640427ccaSGordon Tetlow>4		byte	!100	\b: TNES mapper %u
10740427ccaSGordon Tetlow>>5	byte		x		\b, %ux8k PRG
10840427ccaSGordon Tetlow>>6	byte		x		\b, %ux8k CHR
10940427ccaSGordon Tetlow>>7	byte&0x08	=1		[WRAM]
11040427ccaSGordon Tetlow>>8	byte&0x09	=1		[H-mirror]
11140427ccaSGordon Tetlow>>8	byte&0x09	=2		[V-mirror]
11240427ccaSGordon Tetlow>>8	byte&0x02	=3		[VRAM]
11340427ccaSGordon Tetlow
11440427ccaSGordon Tetlow#------------------------------------------------------------------------------
115b6cee71dSXin LI# gameboy: file(1) magic for the Nintendo (Color) Gameboy raw ROM format
1163e41d09dSXin LI# Reference: http://gbdev.gg8.se/wiki/articles/The_Cartridge_Header
117b6cee71dSXin LI#
1183e41d09dSXin LI0x104		bequad		0xCEED6666CC0D000B	Game Boy ROM image
1192dc4dbb9SEitan Adler# TODO: application/x-gameboy-color-rom for GBC.
1202dc4dbb9SEitan Adler!:mime		application/x-gameboy-rom
1213e41d09dSXin LI>0x143		byte&0x80	0x80
1223e41d09dSXin LI>>0x134		string		>\0			\b: "%.15s"
1233e41d09dSXin LI>0x143		byte&0x80	!0x80
1243e41d09dSXin LI>>0x134		string		>\0			\b: "%.16s"
1253e41d09dSXin LI>0x14c		byte		x			(Rev.%02u)
126b6cee71dSXin LI
1273e41d09dSXin LI# Machine type. (SGB, CGB, SGB+CGB)
12843a5ec4eSXin LI# Old licensee code 0x33 is required for SGB, but not CGB.
1293e41d09dSXin LI>0x14b		byte		0x33
1303e41d09dSXin LI>>0x146		byte		0x03
1313e41d09dSXin LI>>>0x143	byte&0x80	0x80	[SGB+CGB]
1323e41d09dSXin LI>>>0x143	byte&0x80	!0x80	[SGB]
1333e41d09dSXin LI>>0x146		byte		!0x03
1343e41d09dSXin LI>>>0x143	byte&0xC0	0x80	[CGB]
1353e41d09dSXin LI>>>0x143	byte&0xC0	0xC0	[CGB ONLY]
1362dc4dbb9SEitan Adler>0x14b		byte		!0x33
13743a5ec4eSXin LI>>0x143		byte&0xC0	0x80	[CGB]
13843a5ec4eSXin LI>>0x143		byte&0xC0	0xC0	[CGB ONLY]
1393e41d09dSXin LI
1403e41d09dSXin LI# Mapper.
1413e41d09dSXin LI>0x147 byte 0x00  [ROM ONLY]
1423e41d09dSXin LI>0x147 byte 0x01  [MBC1]
1433e41d09dSXin LI>0x147 byte 0x02  [MBC1+RAM]
1443e41d09dSXin LI>0x147 byte 0x03  [MBC1+RAM+BATT]
1453e41d09dSXin LI>0x147 byte 0x05  [MBC2]
1463e41d09dSXin LI>0x147 byte 0x06  [MBC2+BATTERY]
1473e41d09dSXin LI>0x147 byte 0x08  [ROM+RAM]
1483e41d09dSXin LI>0x147 byte 0x09  [ROM+RAM+BATTERY]
1493e41d09dSXin LI>0x147 byte 0x0B  [MMM01]
1503e41d09dSXin LI>0x147 byte 0x0C  [MMM01+SRAM]
1513e41d09dSXin LI>0x147 byte 0x0D  [MMM01+SRAM+BATT]
1523e41d09dSXin LI>0x147 byte 0x0F  [MBC3+TIMER+BATT]
1533e41d09dSXin LI>0x147 byte 0x10  [MBC3+TIMER+RAM+BATT]
1543e41d09dSXin LI>0x147 byte 0x11  [MBC3]
1553e41d09dSXin LI>0x147 byte 0x12  [MBC3+RAM]
1563e41d09dSXin LI>0x147 byte 0x13  [MBC3+RAM+BATT]
1573e41d09dSXin LI>0x147 byte 0x19  [MBC5]
1583e41d09dSXin LI>0x147 byte 0x1A  [MBC5+RAM]
1593e41d09dSXin LI>0x147 byte 0x1B  [MBC5+RAM+BATT]
1603e41d09dSXin LI>0x147 byte 0x1C  [MBC5+RUMBLE]
1613e41d09dSXin LI>0x147 byte 0x1D  [MBC5+RUMBLE+SRAM]
1623e41d09dSXin LI>0x147 byte 0x1E  [MBC5+RUMBLE+SRAM+BATT]
1633e41d09dSXin LI>0x147 byte 0xFC  [Pocket Camera]
1643e41d09dSXin LI>0x147 byte 0xFD  [Bandai TAMA5]
1653e41d09dSXin LI>0x147 byte 0xFE  [Hudson HuC-3]
1663e41d09dSXin LI>0x147 byte 0xFF  [Hudson HuC-1]
1673e41d09dSXin LI
1683e41d09dSXin LI# ROM size.
169b6cee71dSXin LI>0x148 byte 0     \b, ROM: 256Kbit
170b6cee71dSXin LI>0x148 byte 1     \b, ROM: 512Kbit
171b6cee71dSXin LI>0x148 byte 2     \b, ROM: 1Mbit
172b6cee71dSXin LI>0x148 byte 3     \b, ROM: 2Mbit
173b6cee71dSXin LI>0x148 byte 4     \b, ROM: 4Mbit
174b6cee71dSXin LI>0x148 byte 5     \b, ROM: 8Mbit
175b6cee71dSXin LI>0x148 byte 6     \b, ROM: 16Mbit
1763e41d09dSXin LI>0x148 byte 7     \b, ROM: 32Mbit
177b6cee71dSXin LI>0x148 byte 0x52  \b, ROM: 9Mbit
178b6cee71dSXin LI>0x148 byte 0x53  \b, ROM: 10Mbit
179b6cee71dSXin LI>0x148 byte 0x54  \b, ROM: 12Mbit
180b6cee71dSXin LI
1813e41d09dSXin LI# RAM size.
182b6cee71dSXin LI>0x149 byte 1     \b, RAM: 16Kbit
183b6cee71dSXin LI>0x149 byte 2     \b, RAM: 64Kbit
18443a5ec4eSXin LI>0x149 byte 3     \b, RAM: 256Kbit
185b6cee71dSXin LI>0x149 byte 4     \b, RAM: 1Mbit
1863e41d09dSXin LI>0x149 byte 5     \b, RAM: 512Kbit
187b6cee71dSXin LI
188b6cee71dSXin LI#------------------------------------------------------------------------------
1893e41d09dSXin LI# genesis: file(1) magic for various Sega Mega Drive / Genesis ROM image and disc formats
1903e41d09dSXin LI# Updated by David Korth <gerbilsoft@gerbilsoft.com>
1913e41d09dSXin LI# References:
19248c779cdSXin LI# - https://www.retrodev.com/segacd.html
1933e41d09dSXin LI# - http://devster.monkeeh.com/sega/32xguide1.txt
194b6cee71dSXin LI#
1953e41d09dSXin LI
1963e41d09dSXin LI# Common Sega Mega Drive header format.
1973e41d09dSXin LI# FIXME: Name fields are 48 bytes, but have spaces for padding instead of 00s.
1983e41d09dSXin LI0		name	sega-mega-drive-header
1993e41d09dSXin LI# ROM title. (Use domestic if present; if not, use international.)
2003e41d09dSXin LI>0x120		byte	>0x20
2013e41d09dSXin LI>>0x120		string	>\0	\b: "%.16s"
2023e41d09dSXin LI>0x120		byte	<0x21
2033e41d09dSXin LI>>0x150		string	>\0	\b: "%.16s"
2043e41d09dSXin LI# Other information.
2053e41d09dSXin LI>0x180		string	>\0	(%.14s
2063e41d09dSXin LI>>0x110		string  >\0	\b, %.16s
2073e41d09dSXin LI>0x180		byte	0
2083e41d09dSXin LI>>0x110		string  >\0	(%.16s
2093e41d09dSXin LI>0		byte	x	\b)
2103e41d09dSXin LI
2113e41d09dSXin LI# TODO: Check for 32X CD?
2123e41d09dSXin LI# Sega Mega CD disc images: 2048-byte sectors.
2133e41d09dSXin LI0	string	SEGADISCSYSTEM\ \ 	Sega Mega CD disc image
2142dc4dbb9SEitan Adler!:mime	application/x-sega-cd-rom
2153e41d09dSXin LI>0	use	sega-mega-drive-header
2163e41d09dSXin LI>0	byte	x			\b, 2048-byte sectors
2173e41d09dSXin LI0	string	SEGABOOTDISC\ \ \ \ 	Sega Mega CD disc image
2182dc4dbb9SEitan Adler!:mime	application/x-sega-cd-rom
2193e41d09dSXin LI>0	use	sega-mega-drive-header
2203e41d09dSXin LI>0	byte	x			\b, 2048-byte sectors
2213e41d09dSXin LI# Sega Mega CD disc images: 2352-byte sectors.
2223e41d09dSXin LI0x10	string	SEGADISCSYSTEM\ \ 	Sega Mega CD disc image
2232dc4dbb9SEitan Adler!:mime	application/x-sega-cd-rom
2243e41d09dSXin LI>0x10	use	sega-mega-drive-header
2253e41d09dSXin LI>0	byte	x			\b, 2352-byte sectors
2263e41d09dSXin LI0x10	string	SEGABOOTDISC\ \ \ \ 	Sega Mega CD disc image
2272dc4dbb9SEitan Adler!:mime	application/x-sega-cd-rom
2283e41d09dSXin LI>0x10	use	sega-mega-drive-header
2293e41d09dSXin LI>0	byte	x			\b, 2352-byte sectors
2303e41d09dSXin LI
231*a4d6d3b8SXin LI# Sega Mega Drive: Identify the system ID.
2323e41d09dSXin LI0x100		string	SEGA
233*a4d6d3b8SXin LI>0x3C0		string	MARS\ CHECK\ MODE	Sega 32X ROM image
2342dc4dbb9SEitan Adler!:mime		application/x-genesis-32x-rom
2353e41d09dSXin LI>>0		use	sega-mega-drive-header
236*a4d6d3b8SXin LI>0x104		string	\ PICO			Sega Pico ROM image
2372dc4dbb9SEitan Adler!:mime		application/x-sega-pico-rom
238*a4d6d3b8SXin LI>>0		use	sega-mega-drive-header
239*a4d6d3b8SXin LI>0x104		string	TOYS\ PICO		Sega Pico ROM image
240*a4d6d3b8SXin LI!:mime		application/x-sega-pico-rom
241*a4d6d3b8SXin LI>>0		use	sega-mega-drive-header
242*a4d6d3b8SXin LI>0x104		string	\ TOYS\ PICO		Sega Pico ROM image
243*a4d6d3b8SXin LI!:mime		application/x-sega-pico-rom
244*a4d6d3b8SXin LI>>0		use	sega-mega-drive-header
245*a4d6d3b8SXin LI>0x104		string	\ IAC			Sega Pico ROM image
246*a4d6d3b8SXin LI!:mime		application/x-sega-pico-rom
247*a4d6d3b8SXin LI>>0		use	sega-mega-drive-header
248*a4d6d3b8SXin LI>0x104		string	\ TERA68K		Sega Teradrive (68K) ROM image
249*a4d6d3b8SXin LI!:mime		application/x-sega-teradrive-rom
250*a4d6d3b8SXin LI>>0		use	sega-mega-drive-header
251*a4d6d3b8SXin LI>0x104		string	\ TERA286		Sega Teradrive (286) ROM image
252*a4d6d3b8SXin LI!:mime		application/x-sega-teradrive-rom
253*a4d6d3b8SXin LI>>0		use	sega-mega-drive-header
254*a4d6d3b8SXin LI>0x180		string	BR			Sega Mega CD Boot ROM image
2552dc4dbb9SEitan Adler!:mime		application/x-genesis-rom
256*a4d6d3b8SXin LI>>0		use	sega-mega-drive-header
257*a4d6d3b8SXin LI>0x104		default	x			Sega Mega Drive / Genesis ROM image
2582dc4dbb9SEitan Adler!:mime		application/x-genesis-rom
259*a4d6d3b8SXin LI>>0		use	sega-mega-drive-header
260*a4d6d3b8SXin LI
261*a4d6d3b8SXin LI# Sega Mega Drive: Some ROMs have "SEGA" at 0x101, not 0x100.
262*a4d6d3b8SXin LI0x100		string	\ SEGA			Sega Mega Drive / Genesis ROM image
263*a4d6d3b8SXin LI>0		use	sega-mega-drive-header
264*a4d6d3b8SXin LI
265*a4d6d3b8SXin LI# Sega Pico ROMs that don't start with "SEGA".
266*a4d6d3b8SXin LI0x100		string	SAMSUNG\ PICO		Samsung Pico ROM image
267*a4d6d3b8SXin LI!:mime		application/x-sega-pico-rom
268*a4d6d3b8SXin LI>0		use	sega-mega-drive-header
269*a4d6d3b8SXin LI0x100		string	IMA\ IKUNOUJYUKU	Samsung Pico ROM image
270*a4d6d3b8SXin LI!:mime		application/x-sega-pico-rom
271*a4d6d3b8SXin LI>0		use	sega-mega-drive-header
272*a4d6d3b8SXin LI0x100		string	IMA IKUNOJYUKU		Samsung Pico ROM image
273*a4d6d3b8SXin LI!:mime		application/x-sega-pico-rom
274*a4d6d3b8SXin LI>0		use	sega-mega-drive-header
275*a4d6d3b8SXin LI
276*a4d6d3b8SXin LI# Sega Picture Magic (modified 32X)
277*a4d6d3b8SXin LI0x100		string	Picture\ Magic
278*a4d6d3b8SXin LI>0x3C0		string	PICTURE MAGIC-01	Sega 32X ROM image
279*a4d6d3b8SXin LI!:mime		application/x-genesis-32x-rom
280*a4d6d3b8SXin LI>>0		use	sega-mega-drive-header
281b6cee71dSXin LI
282b6cee71dSXin LI#------------------------------------------------------------------------------
283b6cee71dSXin LI# genesis: file(1) magic for the Super MegaDrive ROM dump format
284b6cee71dSXin LI#
2853e41d09dSXin LI
2863e41d09dSXin LI# NOTE: Due to interleaving, we can't display anything
2873e41d09dSXin LI# other than the copier header information.
2883e41d09dSXin LI0      name    sega-genesis-smd-header
289b6cee71dSXin LI>0     byte    x       %dx16k blocks
290b6cee71dSXin LI>2     byte    0       \b, last in series or standalone
291b6cee71dSXin LI>2     byte    >0      \b, split ROM
2923e41d09dSXin LI
2933e41d09dSXin LI# "Sega Genesis" header.
2943e41d09dSXin LI0x280	string EAGN
2953e41d09dSXin LI>8	beshort	0xAABB	Sega Mega Drive / Genesis ROM image (SMD format):
2962dc4dbb9SEitan Adler!:mime	application/x-genesis-rom
2973e41d09dSXin LI>>0	use     sega-genesis-smd-header
2983e41d09dSXin LI
2993e41d09dSXin LI# "Sega Mega Drive" header.
3003e41d09dSXin LI0x280	string EAMG
3013e41d09dSXin LI>8	beshort	0xAABB	Sega Mega Drive / Genesis ROM image (SMD format):
3022dc4dbb9SEitan Adler!:mime	application/x-genesis-rom
3033e41d09dSXin LI>>0	use     sega-genesis-smd-header
304b6cee71dSXin LI
305b6cee71dSXin LI#------------------------------------------------------------------------------
3063e41d09dSXin LI# smsgg:  file(1) magic for Sega Master System and Game Gear ROM images
3073e41d09dSXin LI# Detects all Game Gear and export Sega Master System ROM images,
3083e41d09dSXin LI# and some Japanese Sega Master System ROM images.
3093e41d09dSXin LI# From: David Korth <gerbilsoft@gerbilsoft.com>
31048c779cdSXin LI# Reference: https://www.smspower.org/Development/ROMHeader
311b6cee71dSXin LI#
3123e41d09dSXin LI
3133e41d09dSXin LI# General SMS header rule.
3143e41d09dSXin LI# The SMS boot ROM checks the header at three locations.
3153e41d09dSXin LI0	name	sega-master-system-rom-header
3163e41d09dSXin LI# Machine type.
3173e41d09dSXin LI>0x0F	byte&0xF0	0x30	Sega Master System
3182dc4dbb9SEitan Adler!:mime	application/x-sms-rom
3193e41d09dSXin LI>0x0F	byte&0xF0	0x40	Sega Master System
3202dc4dbb9SEitan Adler!:mime	application/x-sms-rom
3213e41d09dSXin LI>0x0F	byte&0xF0	0x50	Sega Game Gear
3222dc4dbb9SEitan Adler!:mime	application/x-gamegear-rom
3233e41d09dSXin LI>0x0F	byte&0xF0	0x60	Sega Game Gear
3242dc4dbb9SEitan Adler!:mime	application/x-gamegear-rom
3253e41d09dSXin LI>0x0F	byte&0xF0	0x70	Sega Game Gear
3262dc4dbb9SEitan Adler!:mime	application/x-gamegear-rom
3272dc4dbb9SEitan Adler>0x0F	default		x	Sega Master System / Game Gear
3282dc4dbb9SEitan Adler!:mime	application/x-sms-rom
3293e41d09dSXin LI>0	byte		x	ROM image:
3303e41d09dSXin LI# Product code.
3313e41d09dSXin LI>0x0E	byte&0xF0	0x10	1
3323e41d09dSXin LI>0x0E	byte&0xF0	0x20	2
3333e41d09dSXin LI>0x0E	byte&0xF0	0x30	3
3343e41d09dSXin LI>0x0E	byte&0xF0	0x40	4
3353e41d09dSXin LI>0x0E	byte&0xF0	0x50	5
3363e41d09dSXin LI>0x0E	byte&0xF0	0x60	6
3373e41d09dSXin LI>0x0E	byte&0xF0	0x70	7
3383e41d09dSXin LI>0x0E	byte&0xF0	0x80	8
3393e41d09dSXin LI>0x0E	byte&0xF0	0x90	9
3403e41d09dSXin LI>0x0E	byte&0xF0	0xA0	10
3413e41d09dSXin LI>0x0E	byte&0xF0	0xB0	11
3423e41d09dSXin LI>0x0E	byte&0xF0	0xC0	12
3433e41d09dSXin LI>0x0E	byte&0xF0	0xD0	13
3443e41d09dSXin LI>0x0E	byte&0xF0	0xE0	14
3453e41d09dSXin LI>0x0E	byte&0xF0	0xF0	15
3463e41d09dSXin LI# If the product code is 5 digits, we'll need to backspace here.
3473e41d09dSXin LI>0x0E	byte&0xF0	!0
3483e41d09dSXin LI>>0x0C	leshort		x	\b%04x
3493e41d09dSXin LI>0x0E	byte&0xF0	0
3503e41d09dSXin LI>>0x0C	leshort		x	%04x
3513e41d09dSXin LI# Revision.
3523e41d09dSXin LI>0x0E	byte&0x0F	x	(Rev.%02d)
3533e41d09dSXin LI# ROM size. (Used for the boot ROM checksum routine.)
3543e41d09dSXin LI>0x0F	byte&0x0F	0x0A	(8 KB)
3553e41d09dSXin LI>0x0F	byte&0x0F	0x0B	(16 KB)
3563e41d09dSXin LI>0x0F	byte&0x0F	0x0C	(32 KB)
3573e41d09dSXin LI>0x0F	byte&0x0F	0x0D	(48 KB)
3583e41d09dSXin LI>0x0F	byte&0x0F	0x0E	(64 KB)
3593e41d09dSXin LI>0x0F	byte&0x0F	0x0F	(128 KB)
3603e41d09dSXin LI>0x0F	byte&0x0F	0x00	(256 KB)
3613e41d09dSXin LI>0x0F	byte&0x0F	0x01	(512 KB)
3623e41d09dSXin LI>0x0F	byte&0x0F	0x02	(1 MB)
3633e41d09dSXin LI
3643e41d09dSXin LI# SMS/GG header locations.
3653e41d09dSXin LI0x7FF0	string	TMR\ SEGA
3663e41d09dSXin LI>0x7FF0	use	sega-master-system-rom-header
3673e41d09dSXin LI0x3FF0	string	TMR\ SEGA
3683e41d09dSXin LI>0x3FF0	use	sega-master-system-rom-header
3693e41d09dSXin LI0x1FF0	string	TMR\ SEGA
3703e41d09dSXin LI>0x1FF0	use	sega-master-system-rom-header
371b6cee71dSXin LI
372b6cee71dSXin LI#------------------------------------------------------------------------------
3733e41d09dSXin LI# saturn: file(1) magic for the Sega Saturn disc image format.
3743e41d09dSXin LI# From: David Korth <gerbilsoft@gerbilsoft.com>
375b6cee71dSXin LI#
3763e41d09dSXin LI
3773e41d09dSXin LI# Common Sega Saturn disc header format.
3783e41d09dSXin LI# NOTE: Title is 112 bytes, but we're only showing 32 due to space padding.
3793e41d09dSXin LI# TODO: Release date, device information, region code, others?
3803e41d09dSXin LI0	name	sega-saturn-disc-header
3813e41d09dSXin LI>0x60	string	>\0	\b: "%.32s"
3823e41d09dSXin LI>0x20	string	>\0	(%.10s
3833e41d09dSXin LI>>0x2A	string	>\0	\b, %.6s)
3843e41d09dSXin LI>>0x2A	byte	0	\b)
3853e41d09dSXin LI
3863e41d09dSXin LI# 2048-byte sector version.
3873e41d09dSXin LI0	string	SEGA\ SEGASATURN\ 	Sega Saturn disc image
3882dc4dbb9SEitan Adler!:mime	application/x-saturn-rom
3893e41d09dSXin LI>0	use	sega-saturn-disc-header
3903e41d09dSXin LI>0	byte	x			(2048-byte sectors)
3913e41d09dSXin LI# 2352-byte sector version.
3923e41d09dSXin LI0x10	string	SEGA\ SEGASATURN\ 	Sega Saturn disc image
3932dc4dbb9SEitan Adler!:mime	application/x-saturn-rom
3943e41d09dSXin LI>0x10	use	sega-saturn-disc-header
3953e41d09dSXin LI>0	byte	x			(2352-byte sectors)
3963e41d09dSXin LI
3973e41d09dSXin LI#------------------------------------------------------------------------------
3983e41d09dSXin LI# dreamcast: file(1) magic for the Sega Dreamcast disc image format.
3993e41d09dSXin LI# From: David Korth <gerbilsoft@gerbilsoft.com>
40048c779cdSXin LI# Reference: https://mc.pp.se/dc/ip0000.bin.html
401b6cee71dSXin LI#
4023e41d09dSXin LI
4033e41d09dSXin LI# Common Sega Dreamcast disc header format.
4043e41d09dSXin LI# NOTE: Title is 128 bytes, but we're only showing 32 due to space padding.
4053e41d09dSXin LI# TODO: Release date, device information, region code, others?
4063e41d09dSXin LI0	name	sega-dreamcast-disc-header
4073e41d09dSXin LI>0x80	string	>\0	\b: "%.32s"
4083e41d09dSXin LI>0x40	string	>\0	(%.10s
4093e41d09dSXin LI>>0x4A	string	>\0	\b, %.6s)
4103e41d09dSXin LI>>0x4A	byte	0	\b)
4113e41d09dSXin LI
4123e41d09dSXin LI# 2048-byte sector version.
4133e41d09dSXin LI0	string	SEGA\ SEGAKATANA\ 	Sega Dreamcast disc image
4142dc4dbb9SEitan Adler!:mime	application/x-dc-rom
4153e41d09dSXin LI>0	use	sega-dreamcast-disc-header
4163e41d09dSXin LI>0	byte	x			(2048-byte sectors)
4173e41d09dSXin LI# 2352-byte sector version.
4183e41d09dSXin LI0x10	string	SEGA\ SEGAKATANA\ 	Sega Dreamcast disc image
4192dc4dbb9SEitan Adler!:mime	application/x-dc-rom
4203e41d09dSXin LI>0x10	use	sega-dreamcast-disc-header
4213e41d09dSXin LI>0	byte	x			(2352-byte sectors)
422b6cee71dSXin LI
423b6cee71dSXin LI#------------------------------------------------------------------------------
424b6cee71dSXin LI# dreamcast:  file(1) uncertain magic for the Sega Dreamcast VMU image format
425b6cee71dSXin LI#
426b6cee71dSXin LI0 belong 0x21068028   Sega Dreamcast VMU game image
427b6cee71dSXin LI0 string LCDi         Dream Animator file
428b6cee71dSXin LI
429b6cee71dSXin LI#------------------------------------------------------------------------------
4303e41d09dSXin LI# z64: file(1) magic for the Z64 format N64 ROM dumps
4313e41d09dSXin LI# Reference: http://forum.pj64-emu.com/showthread.php?t=2239
4323e41d09dSXin LI# From: David Korth <gerbilsoft@gerbilsoft.com>
433b6cee71dSXin LI#
4343e41d09dSXin LI0	bequad	0x803712400000000F	Nintendo 64 ROM image
4352dc4dbb9SEitan Adler!:mime	application/x-n64-rom
4363e41d09dSXin LI>0x20	string	>\0	\b: "%.20s"
4373e41d09dSXin LI>0x3B	string	x	(%.4s
4383e41d09dSXin LI>0x3F	byte	x	\b, Rev.%02u)
439b6cee71dSXin LI
4403e41d09dSXin LI#------------------------------------------------------------------------------
4413e41d09dSXin LI# v64: file(1) magic for the V64 format N64 ROM dumps
4423e41d09dSXin LI# Same as z64 format, but with 16-bit byteswapping.
4433e41d09dSXin LI#
4443e41d09dSXin LI0	bequad	0x3780401200000F00	Nintendo 64 ROM image (V64)
4452dc4dbb9SEitan Adler!:mime	application/x-n64-rom
4463e41d09dSXin LI
4473e41d09dSXin LI#------------------------------------------------------------------------------
4483e41d09dSXin LI# n64-swap2: file(1) magic for the swap2 format N64 ROM dumps
4493e41d09dSXin LI# Same as z64 format, but with swapped 16-bit words.
4503e41d09dSXin LI#
4513e41d09dSXin LI0	bequad	0x12408037000F0000	Nintendo 64 ROM image (wordswapped)
4522dc4dbb9SEitan Adler!:mime	application/x-n64-rom
4533e41d09dSXin LI
4543e41d09dSXin LI#------------------------------------------------------------------------------
4553e41d09dSXin LI# n64-le32: file(1) magic for the 32-bit byteswapped format N64 ROM dumps
4563e41d09dSXin LI# Same as z64 format, but with 32-bit byteswapping.
4573e41d09dSXin LI#
4583e41d09dSXin LI0	bequad	0x401237800F000000	Nintendo 64 ROM image (32-bit byteswapped)
4592dc4dbb9SEitan Adler!:mime	application/x-n64-rom
4603e41d09dSXin LI
4613e41d09dSXin LI#------------------------------------------------------------------------------
4623e41d09dSXin LI# gba: file(1) magic for the Nintendo Game Boy Advance raw ROM format
46348c779cdSXin LI# Reference: https://problemkaputt.de/gbatek.htm#gbacartridgeheader
4643e41d09dSXin LI#
4653e41d09dSXin LI# Original version from: "Nelson A. de Oliveira" <naoliv@gmail.com>
4663e41d09dSXin LI# Updated version from: David Korth <gerbilsoft@gerbilsoft.com>
4673e41d09dSXin LI#
4683e41d09dSXin LI4	bequad	0x24FFAE51699AA221	Game Boy Advance ROM image
4692dc4dbb9SEitan Adler!:mime	application/x-gba-rom
4703e41d09dSXin LI>0xA0	string	>\0	\b: "%.12s"
4713e41d09dSXin LI>0xAC	string	x	(%.6s
4723e41d09dSXin LI>0xBC	byte	x	\b, Rev.%02u)
4733e41d09dSXin LI
4743e41d09dSXin LI#------------------------------------------------------------------------------
4753e41d09dSXin LI# nds: file(1) magic for the Nintendo DS(i) raw ROM format
47648c779cdSXin LI# Reference: https://problemkaputt.de/gbatek.htm#dscartridgeheader
4773e41d09dSXin LI#
4783e41d09dSXin LI# Original version from: "Nelson A. de Oliveira" <naoliv@gmail.com>
4793e41d09dSXin LI# Updated version from: David Korth <gerbilsoft@gerbilsoft.com>
4803e41d09dSXin LI#
4813e41d09dSXin LI0xC0	bequad	0x24FFAE51699AA221	Nintendo DS ROM image
4822dc4dbb9SEitan Adler!:mime	application/x-nintendo-ds-rom
4833e41d09dSXin LI>0x00	string	>\0		\b: "%.12s"
4843e41d09dSXin LI>0x0C	string	x		(%.6s
4853e41d09dSXin LI>0x1E	byte	x		\b, Rev.%02u)
4863e41d09dSXin LI>0x12	byte	2		(DSi enhanced)
4873e41d09dSXin LI>0x12	byte	3		(DSi only)
48840427ccaSGordon Tetlow# Secure Area check.
48940427ccaSGordon Tetlow>0x20		lelong	<0x4000		(homebrew)
49040427ccaSGordon Tetlow>0x20		lelong	>0x3FFF
49140427ccaSGordon Tetlow>>0x4000	lequad	0x0000000000000000	(multiboot)
49240427ccaSGordon Tetlow>>0x4000	lequad	!0x0000000000000000
49340427ccaSGordon Tetlow>>>0x4000	lequad	0xE7FFDEFFE7FFDEFF	(decrypted)
49440427ccaSGordon Tetlow>>>0x4000	lequad	!0xE7FFDEFFE7FFDEFF
49540427ccaSGordon Tetlow>>>>0x1000	lequad	0x0000000000000000	(encrypted)
49640427ccaSGordon Tetlow>>>>0x1000	lequad	!0x0000000000000000	(mask ROM)
4973e41d09dSXin LI
4983e41d09dSXin LI#------------------------------------------------------------------------------
4993e41d09dSXin LI# nds_passme: file(1) magic for Nintendo DS ROM images for GBA cartridge boot.
5003e41d09dSXin LI# This is also used for loading .nds files using the MSET exploit on 3DS.
5013e41d09dSXin LI# Reference: https://github.com/devkitPro/ndstool/blob/master/source/ndscreate.cpp
5023e41d09dSXin LI0xC0	bequad	0xC8604FE201708FE2	Nintendo DS Slot-2 ROM image (PassMe)
5032dc4dbb9SEitan Adler!:mime	application/x-nintendo-ds-rom
5043e41d09dSXin LI
5053e41d09dSXin LI#------------------------------------------------------------------------------
5063e41d09dSXin LI# ngp: file(1) magic for the Neo Geo Pocket (Color) raw ROM format.
5073e41d09dSXin LI# From: David Korth <gerbilsoft@gerbilsoft.com>
5083e41d09dSXin LI# References:
5093e41d09dSXin LI# - https://neogpc.googlecode.com/svn-history/r10/trunk/src/core/neogpc.cpp
51048c779cdSXin LI# - https://www.devrs.com/ngp/files/ngpctech.txt
5113e41d09dSXin LI#
5123e41d09dSXin LI0x0A	string		BY\ SNK\ CORPORATION	Neo Geo Pocket
5132dc4dbb9SEitan Adler!:mime	application/x-neo-geo-pocket-rom
5143e41d09dSXin LI>0x23	byte		0x10			Color
5153e41d09dSXin LI>0	byte		x			ROM image
5163e41d09dSXin LI>0x24	string		>\0			\b: "%.12s"
517*a4d6d3b8SXin LI>0x21	uleshort	x			\b, NEOP%04X
518*a4d6d3b8SXin LI>0x1F	ubyte		0xFF			(debug mode enabled)
519b6cee71dSXin LI
520b6cee71dSXin LI#------------------------------------------------------------------------------
521b6cee71dSXin LI# msx: file(1) magic for MSX game cartridge dumps
522b6cee71dSXin LI# Too simple - MPi
523b6cee71dSXin LI#0 beshort 0x4142 MSX game cartridge dump
524b6cee71dSXin LI
525b6cee71dSXin LI#------------------------------------------------------------------------------
526b6cee71dSXin LI# Sony Playstation executables (Adam Sjoegren <asjo@diku.dk>) :
527b6cee71dSXin LI0	string	PS-X\ EXE	Sony Playstation executable
52843a5ec4eSXin LI>16	lelong	x		PC=%#08x,
52943a5ec4eSXin LI>20	lelong	!0		GP=%#08x,
53043a5ec4eSXin LI>24	lelong	!0		.text=[%#08x,
53143a5ec4eSXin LI>>28	lelong	x		\b%#x],
53243a5ec4eSXin LI>32	lelong	!0		.data=[%#08x,
53343a5ec4eSXin LI>>36	lelong	x		\b%#x],
53443a5ec4eSXin LI>40	lelong	!0		.bss=[%#08x,
53543a5ec4eSXin LI>>44	lelong	x		\b%#x],
53643a5ec4eSXin LI>48	lelong	!0		Stack=%#08x,
5373e41d09dSXin LI>48	lelong	=0		No Stack!,
53843a5ec4eSXin LI>52	lelong	!0		StackSize=%#x,
5393e41d09dSXin LI#>76	string	>\0		(%s)
540b6cee71dSXin LI#  Area:
541b6cee71dSXin LI>113	string	x		(%s)
542b6cee71dSXin LI
5433e41d09dSXin LI# CPE executables
5443e41d09dSXin LI0	string	CPE		CPE executable
5453e41d09dSXin LI>3	byte	x		(version %d)
5463e41d09dSXin LI
547b6cee71dSXin LI#------------------------------------------------------------------------------
548b6cee71dSXin LI# Microsoft Xbox executables .xbe (Esa Hyytia <ehyytia@cc.hut.fi>)
54948c779cdSXin LI0	string	XBEH	Microsoft Xbox executable
550d38c30c0SXin LI!:mime	audio/x-xbox-executable
551d38c30c0SXin LI!:ext	xbe
55248c779cdSXin LI# expect base address of 0x10000
55348c779cdSXin LI>0x0104                 ulelong =0x10000
55448c779cdSXin LI>>(0x0118.l-0x0FFF4)    lestring16 x       \b: "%.40s"
55548c779cdSXin LI>>(0x0118.l-0x0FFF5)    byte     x         (%c
55648c779cdSXin LI>>(0x0118.l-0x0FFF6)    byte     x         \b%c-
55748c779cdSXin LI>>(0x0118.l-0x0FFF8)    uleshort x         \b%03u)
55848c779cdSXin LI>>(0x0118.l-0x0FF60)    ulelong&0x80000007  0x80000007 \b, all regions
55948c779cdSXin LI>>(0x0118.l-0x0FF60)    ulelong&0x80000007  !0x80000007
56048c779cdSXin LI>>>(0x0118.l-0x0FF60)   ulelong >0           (regions:
56148c779cdSXin LI>>>>(0x0118.l-0x0FF60)  ulelong &0x00000001  NA
56248c779cdSXin LI>>>>(0x0118.l-0x0FF60)  ulelong &0x00000002  Japan
56348c779cdSXin LI>>>>(0x0118.l-0x0FF60)  ulelong &0x00000004  Rest_of_World
56448c779cdSXin LI>>>>(0x0118.l-0x0FF60)  ulelong &0x80000000  Manufacturer
56548c779cdSXin LI>>>(0x0118.l-0x0FF60)   ulelong >0           \b)
566b6cee71dSXin LI# probabilistic checks whether signed or not
567b6cee71dSXin LI>0x0004 ulelong =0x0
568b6cee71dSXin LI>>&2    ulelong =0x0
569b6cee71dSXin LI>>>&2   ulelong =0x0  \b, not signed
570b6cee71dSXin LI>0x0004 ulelong >0
571b6cee71dSXin LI>>&2    ulelong >0
572b6cee71dSXin LI>>>&2   ulelong >0    \b, signed
573b6cee71dSXin LI
574b6cee71dSXin LI# --------------------------------
575b6cee71dSXin LI# Microsoft Xbox data file formats
576b6cee71dSXin LI0       string          XIP0            XIP, Microsoft Xbox data
577b6cee71dSXin LI0       string          XTF0            XTF, Microsoft Xbox data
578b6cee71dSXin LI
57948c779cdSXin LI#------------------------------------------------------------------------------
58048c779cdSXin LI# Microsoft Xbox 360 executables (.xex)
58148c779cdSXin LI# From: David Korth <gerbilsoft@gerbilsoft.com>
58248c779cdSXin LI# References:
58348c779cdSXin LI# - https://free60project.github.io/wiki/XEX.html
58448c779cdSXin LI# - https://github.com/xenia-project/xenia/blob/HEAD/src/xenia/kernel/util/xex2_info.h
58548c779cdSXin LI
58648c779cdSXin LI# Title ID (part of Execution ID section)
58748c779cdSXin LI0		name	xbox-360-xex-execution-id
58848c779cdSXin LI>(0.L+0xC)	byte	x	(%c
58948c779cdSXin LI>(0.L+0xD)	byte	x	\b%c
590d38c30c0SXin LI>(0.L+0xE)	beshort	x	\b-%04u, media ID:
591d38c30c0SXin LI>(0.L)		belong	x	%08X)
592d38c30c0SXin LI
593d38c30c0SXin LI# Region code (part of Security Info)
594d38c30c0SXin LI0	name	xbox-360-xex-region-code
595d38c30c0SXin LI>0	ubelong	0xFFFFFFFF	\b, all regions
596d38c30c0SXin LI>0	ubelong	!0xFFFFFFFF
597d38c30c0SXin LI>>0	ubelong	>0		(regions:
598d38c30c0SXin LI>>0	ubelong&0x000000FF	0x000000FF	USA
599d38c30c0SXin LI>>0	ubelong&0x00000100	0x00000100	Japan
600d38c30c0SXin LI>>0	ubelong&0x00000200	0x00000200	China
601d38c30c0SXin LI>>0	ubelong&0x0000FC00	0x0000FC00	Asia
602d38c30c0SXin LI>>0	ubelong&0x00FF0000	0x00FF0000	PAL
603d38c30c0SXin LI>>0	ubelong&0x00FF0000	0x00FE0000	PAL [except AU/NZ]
604d38c30c0SXin LI>>0	ubelong&0x00FF0000	0x00010000	AU/NZ
605d38c30c0SXin LI>>0	ubelong&0xFF000000	0xFF000000	Other
606d38c30c0SXin LI>>0	ubelong	>0		\b)
60748c779cdSXin LI
60848c779cdSXin LI0	string	XEX2	Microsoft Xbox 360 executable
609d38c30c0SXin LI!:mime	audio/x-xbox360-executable
610d38c30c0SXin LI!:ext	xex
61148c779cdSXin LI>0x18	search/0x100	\x00\x04\x00\x06
61248c779cdSXin LI>>&0	use	xbox-360-xex-execution-id
613d38c30c0SXin LI>(0x010.L+0x178)	use	xbox-360-xex-region-code
61448c779cdSXin LI
615d38c30c0SXin LI0	string	XEX1	Microsoft Xbox 360 executable (XEX1)
616d38c30c0SXin LI!:mime	audio/x-xbox360-executable
617d38c30c0SXin LI!:ext	xex
618d38c30c0SXin LI>0x18	search/0x100	\x00\x04\x00\x06
619d38c30c0SXin LI>>&0	use	xbox-360-xex-execution-id
620d38c30c0SXin LI>(0x010.L+0x154)	use	xbox-360-xex-region-code
62148c779cdSXin LI
622d38c30c0SXin LI#------------------------------------------------------------------------------
623d38c30c0SXin LI# Microsoft Xbox 360 packages
624d38c30c0SXin LI# From: David Korth <gerbilsoft@gerbilsoft.com>
625d38c30c0SXin LI# References:
626d38c30c0SXin LI# - https://free60project.github.io/wiki/STFS.html
627d38c30c0SXin LI# - https://github.com/xenia-project/xenia/blob/HEAD/src/xenia/kernel/util/xex2_info.h
628d38c30c0SXin LI
629d38c30c0SXin LI# TODO: More information for console-signed packages.
630d38c30c0SXin LI
631d38c30c0SXin LI0	name	xbox-360-package
632d38c30c0SXin LI>0x360	byte	x	(%c
633d38c30c0SXin LI>0x361	byte	x	\b%c
634d38c30c0SXin LI>0x362	beshort	x	\b-%04u, media ID:
635d38c30c0SXin LI>0x354	belong	x	%08X)
636d38c30c0SXin LI>0x344	belong	x	\b, content type:
637d38c30c0SXin LI>>0x344	belong	0x1		Saved Game
638d38c30c0SXin LI>>0x344	belong	0x2		Marketplace Content
639d38c30c0SXin LI>>0x344	belong	0x3		Publisher
640d38c30c0SXin LI>>0x344	belong	0x1000		Xbox 360 Title
641d38c30c0SXin LI>>0x344	belong	0x2000		IPTV Pause Buffer
642d38c30c0SXin LI>>0x344	belong	0x4000		Installed Game
643d38c30c0SXin LI>>0x344	belong	0x5000		Original Xbox Game
644d38c30c0SXin LI>>0x344	belong	0x9000		Avatar Item
645d38c30c0SXin LI>>0x344	belong	0x10000		Profile
646d38c30c0SXin LI>>0x344	belong	0x20000		Gamer Picture
647d38c30c0SXin LI>>0x344	belong	0x30000		Theme
648d38c30c0SXin LI>>0x344	belong	0x40000		Cache File
649d38c30c0SXin LI>>0x344	belong	0x50000		Storage Download
650d38c30c0SXin LI>>0x344	belong	0x60000		Xbox Saved Game
651d38c30c0SXin LI>>0x344	belong	0x70000		Xbox Download
652d38c30c0SXin LI>>0x344	belong	0x80000		Game Demo
653d38c30c0SXin LI>>0x344	belong	0x90000		Video
654d38c30c0SXin LI>>0x344	belong	0xA0000		Game
655d38c30c0SXin LI>>0x344	belong	0xB0000		Installer
656d38c30c0SXin LI>>0x344	belong	0xC0000		Game Trailer
657d38c30c0SXin LI>>0x344	belong	0xD0000		Arcade Title
658d38c30c0SXin LI>>0x344	belong	0xE0000		XNA
659d38c30c0SXin LI>>0x344	belong	0xF0000		License Store
660d38c30c0SXin LI>>0x344	belong	0x100000	Movie
661d38c30c0SXin LI>>0x344	belong	0x200000	TV
662d38c30c0SXin LI>>0x344	belong	0x300000	Music Video
663d38c30c0SXin LI>>0x344	belong	0x400000	Game Video
664d38c30c0SXin LI>>0x344	belong	0x500000	Podcast Video
665d38c30c0SXin LI>>0x344	belong	0x600000	Viral Video
666d38c30c0SXin LI>>0x344	belong	0x2000000	Community Game
667d38c30c0SXin LI
668d38c30c0SXin LI0	string	CON\x20	Microsoft Xbox 360 package (console-signed)
669d38c30c0SXin LI>0	use	xbox-360-package
6702726a701SXin LI0	string	PIRS
6712726a701SXin LI>0	belong	0	Microsoft Xbox 360 package (non-Xbox Live)
6722726a701SXin LI>>0	use	xbox-360-package
6732726a701SXin LI0	string	LIVE
6742726a701SXin LI>0x104	belong	0	Microsoft Xbox 360 package (Xbox Live)
6752726a701SXin LI>>0	use	xbox-360-package
67648c779cdSXin LI
677b6cee71dSXin LI# Atari Lynx cartridge dump (EXE/BLL header)
678*a4d6d3b8SXin LI# From: "Stefan A. Haubenthal" <polluks@sdf.lonestar.org>
679*a4d6d3b8SXin LI# Reference:
680*a4d6d3b8SXin LI# https://raw.githubusercontent.com/cc65/cc65/master/libsrc/lynx/exehdr.s
681b6cee71dSXin LI# Double-check that the image type matches too, 0x8008 conflicts with
682b6cee71dSXin LI# 8 character OMF-86 object file headers.
683b6cee71dSXin LI0	beshort		0x8008
684b6cee71dSXin LI>6	string		BS93		Lynx homebrew cartridge
6852dc4dbb9SEitan Adler!:mime	application/x-atari-lynx-rom
686b6cee71dSXin LI>>2	beshort		x		\b, RAM start $%04x
687*a4d6d3b8SXin LI0	string		LYNX		Lynx cartridge
6882dc4dbb9SEitan Adler!:mime	application/x-atari-lynx-rom
689*a4d6d3b8SXin LI>4	leshort/4	>0		\b, bank 0 %dk
690*a4d6d3b8SXin LI>6	leshort/4	>0		\b, bank 1 %dk
691*a4d6d3b8SXin LI>10	string		>\0		\b, "%.32s"
692*a4d6d3b8SXin LI>42	string		>\0		\b, "%.16s"
693b6cee71dSXin LI
694b6cee71dSXin LI# Opera file system that is used on the 3DO console
695b6cee71dSXin LI# From: Serge van den Boom <svdb@stack.nl>
696b6cee71dSXin LI0	string		\x01ZZZZZ\x01	3DO "Opera" file system
697b6cee71dSXin LI
69858a0f0d0SEitan Adler# From: Alex Myczko <alex@aiei.ch>
6995f0216bdSXin LI# From: David Pflug <david@pflug.email>
7005f0216bdSXin LI# is the offset 12 or the offset 16 correct?
7015f0216bdSXin LI# GBS (Game Boy Sound) magic
7025f0216bdSXin LI# ftp://ftp.modland.com/pub/documents/format_documentation/\
7035f0216bdSXin LI# Gameboy%20Sound%20System%20(.gbs).txt
704b6cee71dSXin LI0	string		GBS		Nintendo Gameboy Music/Audio Data
7055f0216bdSXin LI#12	string		GameBoy\ Music\ Module	Nintendo Gameboy Music Module
7062dc4dbb9SEitan Adler>16	string		>\0	("%.32s" by
7072dc4dbb9SEitan Adler>48	string		>\0	%.32s, copyright
7082dc4dbb9SEitan Adler>80	string		>\0	%.32s),
7092dc4dbb9SEitan Adler>3	byte		x	version %u,
7102dc4dbb9SEitan Adler>4	byte		x	%u tracks
711b6cee71dSXin LI
71240427ccaSGordon Tetlow# IPS Patch Files from: From: Thomas Klausner <tk@giga.or.at>
71348c779cdSXin LI# see https://zerosoft.zophar.net/ips.php
71440427ccaSGordon Tetlow0	string	PATCH			IPS patch file
7152726a701SXin LI!:ext	ips
7162726a701SXin LI
7172726a701SXin LI# BPS Patch Files - from: David Korth <gerbilsoft@gerbilsoft.com>
7182726a701SXin LI# Reference: https://www.romhacking.net/documents/746/
7192726a701SXin LI0	string	BPS1			BPS patch file
7202726a701SXin LI!:ext	bps
7212726a701SXin LI
7222726a701SXin LI# APS Patch Files - from: David Korth <gerbilsoft@gerbilsoft.com>
7232726a701SXin LI# Reference: https://github.com/btimofeev/UniPatcher/wiki/APS-(N64)
7242726a701SXin LI0	string	APS10			APS patch file
7252726a701SXin LI!:ext	aps
7262726a701SXin LI>5	byte	0			\b, simple patch
7272726a701SXin LI>5	byte	1			\b, N64-specific patch for
7282726a701SXin LI>>58	byte	x			N%c
7292726a701SXin LI>>59	byte	x			\b%c
7302726a701SXin LI>>60	byte	x			\b%c
7312726a701SXin LI>7	byte	!0x20
7322726a701SXin LI# FIXME: /T specifier isn't working with a fixed-length string.
7332726a701SXin LI>>7	string	x			\b: "%.50s"
7342726a701SXin LI
7352726a701SXin LI# UPS Patch Files - from: David Korth <gerbilsoft@gerbilsoft.com>
7362726a701SXin LI# Reference: http://fileformats.archiveteam.org/wiki/UPS_(binary_patch_format)
7372726a701SXin LI0	string	UPS1			UPS patch file
7382726a701SXin LI!:ext	ups
73940427ccaSGordon Tetlow
740b6cee71dSXin LI# Playstations Patch Files from: From: Thomas Klausner <tk@giga.or.at>
741b6cee71dSXin LI0	string	PPF30			Playstation Patch File version 3.0
742b6cee71dSXin LI>5	byte	0			\b, PPF 1.0 patch
743b6cee71dSXin LI>5	byte	1			\b, PPF 2.0 patch
744b6cee71dSXin LI>5	byte	2			\b, PPF 3.0 patch
745b6cee71dSXin LI>>56	byte	0			\b, Imagetype BIN (any)
746b6cee71dSXin LI>>56	byte	1			\b, Imagetype GI (PrimoDVD)
747b6cee71dSXin LI>>57	byte	0			\b, Blockcheck disabled
748b6cee71dSXin LI>>57	byte	1			\b, Blockcheck enabled
749b6cee71dSXin LI>>58	byte	0			\b, Undo data not available
750b6cee71dSXin LI>>58	byte	1			\b, Undo data available
751b6cee71dSXin LI>6	string	x			\b, description: %s
752b6cee71dSXin LI
753b6cee71dSXin LI0	string	PPF20			Playstation Patch File version 2.0
754b6cee71dSXin LI>5	byte	0			\b, PPF 1.0 patch
755b6cee71dSXin LI>5	byte	1			\b, PPF 2.0 patch
756b6cee71dSXin LI>>56	lelong	>0			\b, size of file to patch %d
757b6cee71dSXin LI>6	string	x			\b, description: %s
758b6cee71dSXin LI
759b6cee71dSXin LI0	string	PPF10			Playstation Patch File version 1.0
760b6cee71dSXin LI>5	byte	0			\b, Simple Encoding
761b6cee71dSXin LI>6	string	x			\b, description: %s
762b6cee71dSXin LI
763b6cee71dSXin LI# From: Daniel Dawson <ddawson@icehouse.net>
764b6cee71dSXin LI# SNES9x .smv "movie" file format.
765b6cee71dSXin LI0		string		SMV\x1A	SNES9x input recording
766b6cee71dSXin LI>0x4		lelong		x	\b, version %d
767b6cee71dSXin LI# version 4 is latest so far
768b6cee71dSXin LI>0x4		lelong		<5
769b6cee71dSXin LI>>0x8		ledate		x	\b, recorded at %s
770b6cee71dSXin LI>>0xc		lelong		>0	\b, rerecorded %d times
771b6cee71dSXin LI>>0x10		lelong		x	\b, %d frames long
772b6cee71dSXin LI>>0x14		byte		>0	\b, data for controller(s):
773b6cee71dSXin LI>>>0x14		byte		&0x1	#1
774b6cee71dSXin LI>>>0x14		byte		&0x2	#2
775b6cee71dSXin LI>>>0x14		byte		&0x4	#3
776b6cee71dSXin LI>>>0x14		byte		&0x8	#4
777b6cee71dSXin LI>>>0x14		byte		&0x10	#5
778b6cee71dSXin LI>>0x15		byte		^0x1	\b, begins from snapshot
779b6cee71dSXin LI>>0x15		byte		&0x1	\b, begins from reset
780b6cee71dSXin LI>>0x15		byte		^0x2	\b, NTSC standard
781b6cee71dSXin LI>>0x15		byte		&0x2	\b, PAL standard
782b6cee71dSXin LI>>0x17		byte		&0x1    \b, settings:
783b6cee71dSXin LI# WIP1Timing not used as of version 4
784b6cee71dSXin LI>>>0x4		lelong		<4
785b6cee71dSXin LI>>>>0x17	byte		&0x2	WIP1Timing
786b6cee71dSXin LI>>>0x17		byte		&0x4	Left+Right
787b6cee71dSXin LI>>>0x17		byte		&0x8	VolumeEnvX
788b6cee71dSXin LI>>>0x17		byte		&0x10	FakeMute
789b6cee71dSXin LI>>>0x17		byte		&0x20	SyncSound
790b6cee71dSXin LI# New flag as of version 4
791b6cee71dSXin LI>>>0x4		lelong		>3
792b6cee71dSXin LI>>>>0x17	byte		&0x80	NoCPUShutdown
793b6cee71dSXin LI>>0x4		lelong		<4
794b6cee71dSXin LI>>>0x18		lelong		>0x23
795b6cee71dSXin LI>>>>0x20	leshort		!0
796b6cee71dSXin LI>>>>>0x20	lestring16	x	\b, metadata: "%s"
797b6cee71dSXin LI>>0x4		lelong		>3
798b6cee71dSXin LI>>>0x24		byte		>0	\b, port 1:
799b6cee71dSXin LI>>>>0x24	byte		1	joypad
800b6cee71dSXin LI>>>>0x24	byte		2	mouse
801b6cee71dSXin LI>>>>0x24	byte		3	SuperScope
802b6cee71dSXin LI>>>>0x24	byte		4	Justifier
803b6cee71dSXin LI>>>>0x24	byte		5	multitap
804b6cee71dSXin LI>>>0x24		byte		>0	\b, port 2:
805b6cee71dSXin LI>>>>0x25	byte		1	joypad
806b6cee71dSXin LI>>>>0x25	byte		2	mouse
807b6cee71dSXin LI>>>>0x25	byte		3	SuperScope
808b6cee71dSXin LI>>>>0x25	byte		4	Justifier
809b6cee71dSXin LI>>>>0x25	byte		5	multitap
810b6cee71dSXin LI>>>0x18		lelong		>0x43
811b6cee71dSXin LI>>>>0x40	leshort		!0
812b6cee71dSXin LI>>>>>0x40	lestring16	x	\b, metadata: "%s"
813b6cee71dSXin LI>>0x17		byte		&0x40   \b, ROM:
81443a5ec4eSXin LI>>>(0x18.l-26)	lelong		x	CRC32 %#08x
815b6cee71dSXin LI>>>(0x18.l-23)	string		x	"%s"
816b6cee71dSXin LI
817b6cee71dSXin LI# Type: scummVM savegame files
818b6cee71dSXin LI# From: Sven Hartge <debian@ds9.argh.org>
819b6cee71dSXin LI0	string	SCVM	ScummVM savegame
820b6cee71dSXin LI>12	string	>\0	"%s"
8213e41d09dSXin LI
8223e41d09dSXin LI#------------------------------------------------------------------------------
8233e41d09dSXin LI# Nintendo GameCube / Wii file formats.
8243e41d09dSXin LI#
8253e41d09dSXin LI
8263e41d09dSXin LI# Type: Nintendo GameCube/Wii common disc header data.
8273e41d09dSXin LI# From: David Korth <gerbilsoft@gerbilsoft.com>
82848c779cdSXin LI# Reference: https://wiibrew.org/wiki/Wii_Disc
8293e41d09dSXin LI0	name	nintendo-gcn-disc-common
8303e41d09dSXin LI>0x20	string	x	"%.64s"
8313e41d09dSXin LI>0x00	string	x	(%.6s
8323e41d09dSXin LI>0x06	byte	>0
8333e41d09dSXin LI>>0x06	byte	1	\b, Disc 2
8343e41d09dSXin LI>>0x06	byte	2	\b, Disc 3
8353e41d09dSXin LI>>0x06	byte	3	\b, Disc 4
8363e41d09dSXin LI>0x07	byte	x	\b, Rev.%02u)
8372dc4dbb9SEitan Adler>0x18	belong	0x5D1C9EA3
8382dc4dbb9SEitan Adler>>0x60	beshort	0x0101	\b (Unencrypted)
8392726a701SXin LI>0x200	string	NKIT	\b (NKit compressed)
8402726a701SXin LI
8413e41d09dSXin LI
8423e41d09dSXin LI# Type: Nintendo GameCube disc image
8433e41d09dSXin LI# From: David Korth <gerbilsoft@gerbilsoft.com>
84448c779cdSXin LI# Reference: https://wiibrew.org/wiki/Wii_Disc
8453e41d09dSXin LI0x1C	belong	0xC2339F3D	Nintendo GameCube disc image:
8462dc4dbb9SEitan Adler!:mime	application/x-gamecube-rom
8473e41d09dSXin LI>0	use	nintendo-gcn-disc-common
8483e41d09dSXin LI
849282e23f0SXin LI# Type: Nintendo GameCube embedded disc image
850282e23f0SXin LI# Commonly found on demo discs.
851282e23f0SXin LI# From: David Korth <gerbilsoft@gerbilsoft.com>
852282e23f0SXin LI# Reference: http://hitmen.c02.at/files/yagcd/yagcd/index.html#idx14.8
853282e23f0SXin LI0		belong	0xAE0F38A2
854282e23f0SXin LI>0x0C		belong	0x00100000
855282e23f0SXin LI>>(8.L+0x1C)	belong	0xC2339F3D	Nintendo GameCube embedded disc image:
8562dc4dbb9SEitan Adler!:mime	application/x-gamecube-rom
857282e23f0SXin LI>>>(8.L)	use	nintendo-gcn-disc-common
858282e23f0SXin LI
8593e41d09dSXin LI# Type: Nintendo Wii disc image
8603e41d09dSXin LI# From: David Korth <gerbilsoft@gerbilsoft.com>
86148c779cdSXin LI# Reference: https://wiibrew.org/wiki/Wii_Disc
8623e41d09dSXin LI0x18	belong	0x5D1C9EA3	Nintendo Wii disc image:
8633e41d09dSXin LI>0	use	nintendo-gcn-disc-common
8643e41d09dSXin LI
8653e41d09dSXin LI# Type: Nintendo Wii disc image (WBFS format)
8663e41d09dSXin LI# From: David Korth <gerbilsoft@gerbilsoft.com>
86748c779cdSXin LI# Reference: https://wiibrew.org/wiki/Wii_Disc
8683e41d09dSXin LI0	string	WBFS
8693e41d09dSXin LI>0x218	belong	0x5D1C9EA3	Nintendo Wii disc image (WBFS format):
8702dc4dbb9SEitan Adler!:mime	application/x-wii-rom
8713e41d09dSXin LI>>0x200	use	nintendo-gcn-disc-common
8723e41d09dSXin LI
87340427ccaSGordon Tetlow# Type: Nintendo GameCube/Wii disc image (CISO format)
87440427ccaSGordon Tetlow# NOTE: This is NOT the same as Compact ISO or PSP CISO,
87540427ccaSGordon Tetlow# though it has the same magic number.
87640427ccaSGordon Tetlow0		string	CISO
87740427ccaSGordon Tetlow# Other fields are used to determine what type of CISO this is:
87840427ccaSGordon Tetlow# - 0x04 == 0x00200000: GameCube/Wii CISO (block_size)
87940427ccaSGordon Tetlow# - 0x10 == 0x00000800: PSP CISO (ISO-9660 sector size)
88040427ccaSGordon Tetlow# - None of the above: Compact ISO.
88140427ccaSGordon Tetlow>4		lelong	0x200000
88240427ccaSGordon Tetlow>>8		byte	1
88340427ccaSGordon Tetlow>>>0x801C	belong	0xC2339F3D	Nintendo GameCube disc image (CISO format):
8842dc4dbb9SEitan Adler!:mime	application/x-wii-rom
88540427ccaSGordon Tetlow>>>>0x8000	use	nintendo-gcn-disc-common
88640427ccaSGordon Tetlow>>>0x8018	belong	0x5D1C9EA3	Nintendo Wii disc image (CISO format):
8872dc4dbb9SEitan Adler!:mime	application/x-wii-rom
88840427ccaSGordon Tetlow>>>>0x8000	use	nintendo-gcn-disc-common
88940427ccaSGordon Tetlow
89040427ccaSGordon Tetlow# Type: Nintendo GameCube/Wii disc image (GCZ format)
89140427ccaSGordon Tetlow# Due to zlib compression, we can't get the actual disc information.
89240427ccaSGordon Tetlow0	lelong	0xB10BC001
89340427ccaSGordon Tetlow>4	lelong	0		Nintendo GameCube disc image (GCZ format)
8942dc4dbb9SEitan Adler!:mime	application/x-gamecube-rom
89540427ccaSGordon Tetlow>4	lelong	1		Nintendo Wii disc image (GCZ format)
8962dc4dbb9SEitan Adler!:mime	application/x-wii-rom
8972dc4dbb9SEitan Adler>4	default	x		Nintendo GameCube/Wii disc image (GCZ format)
89840427ccaSGordon Tetlow
89940427ccaSGordon Tetlow# Type: Nintendo GameCube/Wii disc image (WDF format)
90040427ccaSGordon Tetlow0		string	WII\001DISC
90140427ccaSGordon Tetlow>8		belong	1
90240427ccaSGordon Tetlow# WDFv1
90340427ccaSGordon Tetlow>>0x54		belong	0xC2339F3D	Nintendo GameCube disc image (WDFv1 format):
9042dc4dbb9SEitan Adler!:mime	application/x-gamecube-rom
90540427ccaSGordon Tetlow>>>0x38		use	nintendo-gcn-disc-common
90640427ccaSGordon Tetlow>>0x58		belong	0x5D1C9EA3	Nintendo Wii disc image (WDFv1 format):
9072dc4dbb9SEitan Adler!:mime	application/x-wii-rom
90840427ccaSGordon Tetlow>>>0x38		use	nintendo-gcn-disc-common
90940427ccaSGordon Tetlow>8		belong	2
91040427ccaSGordon Tetlow# WDFv2
91140427ccaSGordon Tetlow>>(12.L+0x1C)	belong	0xC2339F3D	Nintendo GameCube disc image (WDFv2 format):
9122dc4dbb9SEitan Adler!:mime	application/x-gamecube-rom
91340427ccaSGordon Tetlow>>>(12.L)	use	nintendo-gcn-disc-common
91440427ccaSGordon Tetlow>>(12.L+0x18)	belong	0x5D1C9EA3	Nintendo Wii disc image (WDFv2 format):
9152dc4dbb9SEitan Adler!:mime	application/x-wii-rom
91640427ccaSGordon Tetlow>>>(12.L)	use	nintendo-gcn-disc-common
91740427ccaSGordon Tetlow
91840427ccaSGordon Tetlow# Type: Nintendo GameCube/Wii disc image (WIA format)
91940427ccaSGordon Tetlow0	string	WIA\001	Nintendo
92040427ccaSGordon Tetlow>0x48	belong	1	GameCube
9212dc4dbb9SEitan Adler!:mime	application/x-gamecube-rom
92240427ccaSGordon Tetlow>0x48	belong	2	Wii
9232dc4dbb9SEitan Adler!:mime	application/x-wii-rom
9242dc4dbb9SEitan Adler>0x48	default	x	GameCube/Wii
92540427ccaSGordon Tetlow>0x48	belong	x	disc image (WIA format):
92640427ccaSGordon Tetlow>>0x58	use	nintendo-gcn-disc-common
92740427ccaSGordon Tetlow
9282dc4dbb9SEitan Adler# Type: Nintendo GameCube/Wii disc image (with SDK header)
9292dc4dbb9SEitan Adler# From: David Korth <gerbilsoft@gerbilsoft.com>
93048c779cdSXin LI# Reference: https://wiibrew.org/wiki/Wii_Disc
9312dc4dbb9SEitan Adler0		belong	0xFFFF0000
9322dc4dbb9SEitan Adler>0x18		belong	0x00000000
9332dc4dbb9SEitan Adler>>0x1C		belong	0x00000000
9342dc4dbb9SEitan Adler>>>0x8018	belong	0x5D1C9EA3	Nintendo Wii SDK disc image:
93548c779cdSXin LI!:mime	application/x-wii-rom
9362dc4dbb9SEitan Adler>>>>0x8000	use	nintendo-gcn-disc-common
9372dc4dbb9SEitan Adler>>>0x801C	belong	0xC2339F3D	Nintendo GameCube SDK disc image:
93848c779cdSXin LI!:mime	application/x-gamecube-rom
9392dc4dbb9SEitan Adler>>>>0x8000	use	nintendo-gcn-disc-common
9402dc4dbb9SEitan Adler
941*a4d6d3b8SXin LI# Type: Nintendo GameCube/Wii disc image (RVZ format)
942*a4d6d3b8SXin LI0	string		RVZ\001	Nintendo
943*a4d6d3b8SXin LI>0x48	belong		1	GameCube
944*a4d6d3b8SXin LI!:mime	application/x-gamecube-rom
945*a4d6d3b8SXin LI>0x48	belong		2	Wii
946*a4d6d3b8SXin LI!:mime	application/x-wii-rom
947*a4d6d3b8SXin LI>0x48	default		x	GameCube/Wii
948*a4d6d3b8SXin LI>0x48	belong		x	disc image (RVZ format):
949*a4d6d3b8SXin LI>>0x58	use		nintendo-gcn-disc-common
950*a4d6d3b8SXin LI
9513e41d09dSXin LI#------------------------------------------------------------------------------
9523e41d09dSXin LI# Nintendo 3DS file formats.
9533e41d09dSXin LI#
9543e41d09dSXin LI
9553e41d09dSXin LI# Type: Nintendo 3DS "NCSD" image. (game cards and eMMC)
9563e41d09dSXin LI# From: David Korth <gerbilsoft@gerbilsoft.com>
9573e41d09dSXin LI# Reference: https://www.3dbrew.org/wiki/NCSD
9583e41d09dSXin LI0x100		string		NCSD
9593e41d09dSXin LI>0x118		lequad		0		Nintendo 3DS Game Card image
960282e23f0SXin LI# NCCH header for partition 0. (game data)
961282e23f0SXin LI>>0x1150	string		>\0	\b: "%.16s"
962282e23f0SXin LI>>0x312		byte		x	(Rev.%02u)
963282e23f0SXin LI>>0x118C	byte		2	(New3DS only)
9643e41d09dSXin LI>>0x18D		byte		0		(inner device)
9653e41d09dSXin LI>>0x18D		byte		1		(Card1)
9663e41d09dSXin LI>>0x18D		byte		2		(Card2)
9673e41d09dSXin LI>>0x18D		byte		3		(extended device)
9683e41d09dSXin LI>0x118		bequad		0x0102020202000000	Nintendo 3DS eMMC dump (Old3DS)
9693e41d09dSXin LI>0x118		bequad		0x0102020203000000	Nintendo 3DS eMMC dump (New3DS)
9703e41d09dSXin LI
971282e23f0SXin LI# Nintendo 3DS version code.
972282e23f0SXin LI# Reference: https://www.3dbrew.org/wiki/Titles
973282e23f0SXin LI# Format: leshort containing three fields:
974282e23f0SXin LI# - 6-bit: Major
975282e23f0SXin LI# - 6-bit: Minor
976282e23f0SXin LI# - 4-bit: Revision
977282e23f0SXin LI# NOTE: Only supporting major/minor versions from 0-15 right now.
978282e23f0SXin LI# NOTE: Should be prefixed with "v".
979282e23f0SXin LI0	name	nintendo-3ds-version-code
980282e23f0SXin LI# Raw version.
981282e23f0SXin LI>0	leshort	x	\b%u,
982282e23f0SXin LI# Major version.
983282e23f0SXin LI>0	leshort&0xFC00	0x0000	0
984282e23f0SXin LI>0	leshort&0xFC00	0x0400	1
985282e23f0SXin LI>0	leshort&0xFC00	0x0800	2
986282e23f0SXin LI>0	leshort&0xFC00	0x0C00	3
987282e23f0SXin LI>0	leshort&0xFC00	0x1000	4
988282e23f0SXin LI>0	leshort&0xFC00	0x1400	5
989282e23f0SXin LI>0	leshort&0xFC00	0x1800	6
990282e23f0SXin LI>0	leshort&0xFC00	0x1C00	7
991282e23f0SXin LI>0	leshort&0xFC00	0x2000	8
992282e23f0SXin LI>0	leshort&0xFC00	0x2400	9
993282e23f0SXin LI>0	leshort&0xFC00	0x2800	10
994282e23f0SXin LI>0	leshort&0xFC00	0x2C00	11
995282e23f0SXin LI>0	leshort&0xFC00	0x3000	12
996282e23f0SXin LI>0	leshort&0xFC00	0x3400	13
997282e23f0SXin LI>0	leshort&0xFC00	0x3800	14
998282e23f0SXin LI>0	leshort&0xFC00	0x3C00	15
999282e23f0SXin LI# Minor version.
1000282e23f0SXin LI>0	leshort&0x03F0	0x0000	\b.0
1001282e23f0SXin LI>0	leshort&0x03F0	0x0010	\b.1
1002282e23f0SXin LI>0	leshort&0x03F0	0x0020	\b.2
1003282e23f0SXin LI>0	leshort&0x03F0	0x0030	\b.3
1004282e23f0SXin LI>0	leshort&0x03F0	0x0040	\b.4
1005282e23f0SXin LI>0	leshort&0x03F0	0x0050	\b.5
1006282e23f0SXin LI>0	leshort&0x03F0	0x0060	\b.6
1007282e23f0SXin LI>0	leshort&0x03F0	0x0070	\b.7
1008282e23f0SXin LI>0	leshort&0x03F0	0x0080	\b.8
1009282e23f0SXin LI>0	leshort&0x03F0	0x0090	\b.9
1010282e23f0SXin LI>0	leshort&0x03F0	0x00A0	\b.10
1011282e23f0SXin LI>0	leshort&0x03F0	0x00B0	\b.11
1012282e23f0SXin LI>0	leshort&0x03F0	0x00C0	\b.12
1013282e23f0SXin LI>0	leshort&0x03F0	0x00D0	\b.13
1014282e23f0SXin LI>0	leshort&0x03F0	0x00E0	\b.14
1015282e23f0SXin LI>0	leshort&0x03F0	0x00F0	\b.15
1016282e23f0SXin LI# Revision.
1017282e23f0SXin LI>0	leshort&0x000F	x	\b.%u
1018282e23f0SXin LI
10193e41d09dSXin LI# Type: Nintendo 3DS "NCCH" container.
10203e41d09dSXin LI# https://www.3dbrew.org/wiki/NCCH
10213e41d09dSXin LI0x100		string	NCCH	Nintendo 3DS
10223e41d09dSXin LI>0x18D		byte&2	0	File Archive (CFA)
10233e41d09dSXin LI>0x18D		byte&2	2	Executable Image (CXI)
1024282e23f0SXin LI>0x150		string	>\0	\b: "%.16s"
1025282e23f0SXin LI>0x18D		byte	0x05
1026282e23f0SXin LI>>0x10E		leshort	x	(Old3DS System Update v
1027282e23f0SXin LI>>0x10E		use	nintendo-3ds-version-code
1028282e23f0SXin LI>>0x10E		leshort	x	\b)
1029282e23f0SXin LI>0x18D		byte	0x15
1030282e23f0SXin LI>>0x10E		leshort	x	(New3DS System Update v
1031282e23f0SXin LI>>0x10E		use	nintendo-3ds-version-code
1032282e23f0SXin LI>>0x10E		leshort	x	\b)
1033282e23f0SXin LI>0x18D		byte	!0x05
1034282e23f0SXin LI>>0x18D		byte	!0x15
1035282e23f0SXin LI>>>0x112	byte	x	(v
1036282e23f0SXin LI>>>0x112	use	nintendo-3ds-version-code
1037282e23f0SXin LI>>>0x112	byte	x	\b)
1038282e23f0SXin LI>0x18C		byte	2	(New3DS only)
10393e41d09dSXin LI
10403e41d09dSXin LI# Type: Nintendo 3DS "SMDH" file. (application description)
10413e41d09dSXin LI# From: David Korth <gerbilsoft@gerbilsoft.com>
10423e41d09dSXin LI# Reference: https://3dbrew.org/wiki/SMDH
10433e41d09dSXin LI0		string		SMDH		Nintendo 3DS SMDH file
10443e41d09dSXin LI>0x208		leshort		!0
10453e41d09dSXin LI>>0x208		lestring16	x		\b: "%.128s"
10463e41d09dSXin LI>>0x388		leshort		!0
10473e41d09dSXin LI>>>0x388	lestring16	x		by %.128s
10483e41d09dSXin LI>0x208		leshort		0
10493e41d09dSXin LI>>0x008		leshort		!0
10503e41d09dSXin LI>>>0x008	lestring16	x		\b: "%.128s"
10513e41d09dSXin LI>>>0x188	leshort		!0
10523e41d09dSXin LI>>>>0x188	lestring16	x		by %.128s
10533e41d09dSXin LI
10543e41d09dSXin LI# Type: Nintendo 3DS Homebrew Application.
10553e41d09dSXin LI# From: David Korth <gerbilsoft@gerbilsoft.com>
105640427ccaSGordon Tetlow# Reference: https://3dbrew.org/wiki/3DSX_Format
10573e41d09dSXin LI0	string	3DSX	Nintendo 3DS Homebrew Application (3DSX)
10583e41d09dSXin LI
105943a5ec4eSXin LI# Type: Nintendo 3DS Banner Model Data.
106043a5ec4eSXin LI# From: David Korth <gerbilsoft@gerbilsoft.com>
106143a5ec4eSXin LI# Reference: https://3dbrew.org/wiki/CBMD
106243a5ec4eSXin LI0	string	CBMD\0\0\0\0	Nintendo 3DS Banner Model Data
106343a5ec4eSXin LI
10643e41d09dSXin LI#------------------------------------------------------------------------------
10653e41d09dSXin LI# a7800: file(1) magic for the Atari 7800 raw ROM format.
10663e41d09dSXin LI# From: David Korth <gerbilsoft@gerbilsoft.com>
10673e41d09dSXin LI# Reference: https://sites.google.com/site/atari7800wiki/a78-header
10683e41d09dSXin LI
10693e41d09dSXin LI0	byte	>0
10703e41d09dSXin LI>0	byte	<3
10713e41d09dSXin LI>>1	string	ATARI7800	Atari 7800 ROM image
10722dc4dbb9SEitan Adler!:mime	application/x-atari-7800-rom
10733e41d09dSXin LI>>>0x11	string	>\0	\b: "%.32s"
10743e41d09dSXin LI# Display type.
10753e41d09dSXin LI>>>0x39	byte	0	(NTSC)
10763e41d09dSXin LI>>>0x39	byte	1	(PAL)
10773e41d09dSXin LI>>>0x36	byte&1	1	(POKEY)
10783e41d09dSXin LI
10793e41d09dSXin LI#------------------------------------------------------------------------------
10803e41d09dSXin LI# vectrex: file(1) magic for the GCE Vectrex raw ROM format.
10813e41d09dSXin LI# From: David Korth <gerbilsoft@gerbilsoft.com>
10823e41d09dSXin LI# Reference: http://www.playvectrex.com/designit/chrissalo/hello1.htm
10833e41d09dSXin LI#
10843e41d09dSXin LI# NOTE: Title is terminated with 0x80, not 0.
10853e41d09dSXin LI# The header is terminated with a 0, so that will
10863e41d09dSXin LI# terminate the title as well.
10873e41d09dSXin LI#
10883e41d09dSXin LI0	string	g\ GCE	Vectrex ROM image
10893e41d09dSXin LI>0x11	string	>\0	\b: "%.16s"
109040427ccaSGordon Tetlow
109140427ccaSGordon Tetlow#------------------------------------------------------------------------------
109240427ccaSGordon Tetlow# amiibo: file(1) magic for Nintendo amiibo NFC dumps.
109340427ccaSGordon Tetlow# From: David Korth <gerbilsoft@gerbilsoft.com>
109440427ccaSGordon Tetlow# Reference: https://www.3dbrew.org/wiki/Amiibo
109540427ccaSGordon Tetlow0x00		byte	0x04
109640427ccaSGordon Tetlow>0x0A		beshort	0x0FE0
109740427ccaSGordon Tetlow>>0x0C		belong	0xF110FFEE
109840427ccaSGordon Tetlow>>>0x208	beshort	0x0100
109940427ccaSGordon Tetlow>>>>0x020A	byte	0x0F
110040427ccaSGordon Tetlow>>>>>0x020C	bequad	0x000000045F000000
110140427ccaSGordon Tetlow>>>>>>0x5B	byte	0x02
110240427ccaSGordon Tetlow>>>>>>>0x54	belong	x	Nintendo amiibo NFC dump - amiibo ID: %08X-
110340427ccaSGordon Tetlow>>>>>>>0x58	belong	x	\b%08X
11042726a701SXin LI
11052726a701SXin LI#------------------------------------------------------------------------------
11062726a701SXin LI# Type: Nintendo Switch XCI (Game Cartridge Image)
11072726a701SXin LI# From: Benjamin Lowry <ben@ben.gmbh>
11082726a701SXin LI# Reference: https://switchbrew.org/wiki/Gamecard_Format
11092726a701SXin LI0x100		string	HEAD
11102726a701SXin LI>0x10D		byte	0xFA	Nintendo Switch cartridge image (XCI), 1GB
11112726a701SXin LI>0x10D		byte	0xF8	Nintendo Switch cartridge image (XCI), 2GB
11122726a701SXin LI>0x10D		byte	0xF0	Nintendo Switch cartridge image (XCI), 4GB
11132726a701SXin LI>0x10D		byte	0xE0	Nintendo Switch cartridge image (XCI), 8GB
11142726a701SXin LI>0x10D		byte	0xE1	Nintendo Switch cartridge image (XCI), 16GB
11152726a701SXin LI>0x10D		byte	0xE2	Nintendo Switch cartridge image (XCI), 32GB
11162726a701SXin LI
11172726a701SXin LI#------------------------------------------------------------------------------
11182726a701SXin LI# Type: Nintendo Switch Executable
11192726a701SXin LI# From: Benjamin Lowry <ben@ben.gmbh>
11202726a701SXin LI# Reference: https://switchbrew.org/wiki/NSO
11212726a701SXin LI0x00		string	NSO0	Nintendo Switch executable (NSO)
11222726a701SXin LI
11232726a701SXin LI#------------------------------------------------------------------------------
11242726a701SXin LI# Type: Nintendo Switch PFS0
11252726a701SXin LI# From: Benjamin Lowry <ben@ben.gmbh>
11262726a701SXin LI# Reference: https://switchbrew.org/wiki/NCA_Format#PFS0
11272726a701SXin LI0x00		string	PFS0	Nintendo Switch partition filesystem (PFS0)
11282726a701SXin LI>0x04		ulelong	x	\b, %d files
11292726a701SXin LI
11302726a701SXin LI#------------------------------------------------------------------------------
11312726a701SXin LI# amiibo: file(1) magic for Nintendo Badge Arcade files.
11322726a701SXin LI# From: David Korth <gerbilsoft@gerbilsoft.com>
11332726a701SXin LI# References:
11342726a701SXin LI# - https://github.com/GerbilSoft/rom-properties/issues/92
11352726a701SXin LI# - https://github.com/CaitSith2/BadgeArcadeTool
11362726a701SXin LI# - https://github.com/TheMachinumps/Advanced-badge-editor
11372726a701SXin LI
11382726a701SXin LI# PRBS: Individual badge and/or mega badge.
11392726a701SXin LI0		string	PRBS
11402726a701SXin LI>0x44		byte	>0x20	Nintendo Badge Arcade
11412726a701SXin LI>>0xB8		ulelong	<2
11422726a701SXin LI>>>0xBC		ulelong	<2	badge:
11432726a701SXin LI>>>0xBC		ulelong	>1	Mega Badge
11442726a701SXin LI>>>>0xB8	ulelong	x	(%ux
11452726a701SXin LI>>>>0xBC	ulelong	x	\b%u):
11462726a701SXin LI>>0xB8		ulelong	>1	Mega Badge
11472726a701SXin LI>>>0xB8		ulelong	x	(%ux
11482726a701SXin LI>>>0xBC		ulelong	x	\b%u):
11492726a701SXin LI>0x44		string	x	"%s"
11502726a701SXin LI>0x3C		ulelong	x	\b, badge ID: %u
11512726a701SXin LI>0x74		byte	>0x20
11522726a701SXin LI>>0x74		string	x	\b, set: "%s"
11532726a701SXin LI>0xA8		ulelong	!0xFFFFFFFF
11542726a701SXin LI>>0xA8		ulelong	x	\b, launch title ID: %08X
11552726a701SXin LI>>0xA4		ulelong	x	\b-%08X
11562726a701SXin LI
11572726a701SXin LI# CABS: Badge set.
11582726a701SXin LI0	string	CABS
11592726a701SXin LI>0x2C	byte	>0x20	Nintendo Badge Arcade badge set:
11602726a701SXin LI>>0x2C	string	x	"%.48s"
11612726a701SXin LI>>0x24	ulelong	x	\b, set ID: %u
116243a5ec4eSXin LI
116343a5ec4eSXin LI#------------------------------------------------------------------------------
116443a5ec4eSXin LI# sufami: file(1) magic for Sufami Turbo ROM images.
116543a5ec4eSXin LI# From: David Korth <gerbilsoft@gerbilsoft.com>
116643a5ec4eSXin LI# References:
116743a5ec4eSXin LI# - https://problemkaputt.de/fullsnes.htm#snescartsufamiturbominicartridgeadaptor
116843a5ec4eSXin LI0	string		BANDAI\ SFC-ADX
116943a5ec4eSXin LI>0x10	string		!SFC-ADX\ BACKUP	Sufami Turbo ROM image:
117043a5ec4eSXin LI>>0x10	string/T	x	"%.14s"
117143a5ec4eSXin LI>>0x30	byte		x	\b, ID %02X
117243a5ec4eSXin LI>>0x31	byte		x	\b%02X
117343a5ec4eSXin LI>>0x32	byte		x	\b%02X
117443a5ec4eSXin LI>>0x33	ubyte		>0	\b, series index %u
117543a5ec4eSXin LI>>0x34	ubyte		0	[SlowROM]
117643a5ec4eSXin LI>>0x34	ubyte		1	[FastROM]
117743a5ec4eSXin LI>>0x35	ubyte		1	[SRAM]
117843a5ec4eSXin LI>>0x35	ubyte		3	[Special]
1179