xref: /netbsd/external/bsd/file/dist/magic/magdir/console (revision 4c89978f)
12e1c341aSchristos
21b108b8bSchristos#------------------------------------------------------------------------------
3*4c89978fSchristos# $File: console,v 1.68 2022/05/14 20:04:43 christos Exp $
41b108b8bSchristos# Console game magic
51b108b8bSchristos# Toby Deshane <hac@shoelace.digivill.net>
61b108b8bSchristos
7b04dc002Schristos# ines: file(1) magic for Marat's iNES Nintendo Entertainment System ROM dump format
8b04dc002Schristos# Updated by David Korth <gerbilsoft@gerbilsoft.com>
9b04dc002Schristos# References:
10c3ff5af2Schristos# - https://wiki.nesdev.com/w/index.php/INES
11c3ff5af2Schristos# - https://wiki.nesdev.com/w/index.php/NES_2.0
12b04dc002Schristos
13b04dc002Schristos# Common header for iNES, NES 2.0, and Wii U iNES.
14b04dc002Schristos0	name		nes-rom-image-ines
15b04dc002Schristos>7	byte&0x0C	=0x8		(NES 2.0)
16b04dc002Schristos>4	byte		x		\b: %ux16k PRG
17b04dc002Schristos>5	byte		x		\b, %ux8k CHR
18b04dc002Schristos>6	byte&0x08	=0x8		[4-Scr]
19b04dc002Schristos>6	byte&0x09	=0x0		[H-mirror]
20b04dc002Schristos>6	byte&0x09	=0x1		[V-mirror]
21b04dc002Schristos>6	byte&0x02	=0x2		[SRAM]
22b04dc002Schristos>6	byte&0x04	=0x4		[Trainer]
23b04dc002Schristos>7	byte&0x03	=0x2		[PC10]
24b04dc002Schristos>7	byte&0x03	=0x1		[VS]
25b04dc002Schristos>>7	byte&0x0C	=0x8
26b04dc002Schristos# NES 2.0: VS PPU
27b04dc002Schristos>>>13	byte&0x0F	=0x0		\b, RP2C03B
28b04dc002Schristos>>>13	byte&0x0F	=0x1		\b, RP2C03G
29b04dc002Schristos>>>13	byte&0x0F	=0x2		\b, RP2C04-0001
30b04dc002Schristos>>>13	byte&0x0F	=0x3		\b, RP2C04-0002
31b04dc002Schristos>>>13	byte&0x0F	=0x4		\b, RP2C04-0003
32b04dc002Schristos>>>13	byte&0x0F	=0x5		\b, RP2C04-0004
33b04dc002Schristos>>>13	byte&0x0F	=0x6		\b, RP2C03B
34b04dc002Schristos>>>13	byte&0x0F	=0x7		\b, RP2C03C
35b04dc002Schristos>>>13	byte&0x0F	=0x8		\b, RP2C05-01
36b04dc002Schristos>>>13	byte&0x0F	=0x9		\b, RP2C05-02
37b04dc002Schristos>>>13	byte&0x0F	=0xA		\b, RP2C05-03
38b04dc002Schristos>>>13	byte&0x0F	=0xB		\b, RP2C05-04
39b04dc002Schristos>>>13	byte&0x0F	=0xC		\b, RP2C05-05
40b04dc002Schristos# TODO: VS protection hardware?
41b04dc002Schristos>>7	byte		x		\b]
42b04dc002Schristos# NES 2.0-specific flags.
43b04dc002Schristos>7	byte&0x0C	=0x8
44b04dc002Schristos>>12	byte&0x03	=0x0		[NTSC]
45b04dc002Schristos>>12	byte&0x03	=0x1		[PAL]
46b04dc002Schristos>>12	byte&0x02	=0x2		[NTSC+PAL]
47b04dc002Schristos
48b04dc002Schristos# Standard iNES ROM header.
49b04dc002Schristos0	string		NES\x1A		NES ROM image (iNES)
50b13ade61Schristos!:mime	application/x-nes-rom
51b04dc002Schristos>0	use		nes-rom-image-ines
52b04dc002Schristos
53b04dc002Schristos# Wii U Virtual Console iNES ROM header.
54b04dc002Schristos0	belong		0x4E455300	NES ROM image (Wii U Virtual Console)
55b13ade61Schristos!:mime	application/x-nes-rom
56b04dc002Schristos>0	use		nes-rom-image-ines
57b04dc002Schristos
58b04dc002Schristos#------------------------------------------------------------------------------
59b04dc002Schristos# unif: file(1) magic for UNIF-format Nintendo Entertainment System ROM images
60c3ff5af2Schristos# Reference: https://wiki.nesdev.com/w/index.php/UNIF
61b04dc002Schristos# From: David Korth <gerbilsoft@gerbilsoft.com>
62b04dc002Schristos#
63b04dc002Schristos# NOTE: The UNIF format uses chunks instead of a fixed header,
64b04dc002Schristos# so most of the data isn't easily parseable.
65b04dc002Schristos#
66b04dc002Schristos0	string	UNIF
67b04dc002Schristos>4	lelong	<16	NES ROM image (UNIF v%d format)
68b13ade61Schristos!:mime	application/x-nes-rom
69b04dc002Schristos
70b04dc002Schristos#------------------------------------------------------------------------------
71b04dc002Schristos# fds: file(1) magic for Famciom Disk System disk images
72c3ff5af2Schristos# Reference: https://wiki.nesdev.com/w/index.php/Family_Computer_Disk_System#.FDS_format
73b04dc002Schristos# From: David Korth <gerbilsoft@gerbilsoft.com>
74b04dc002Schristos# TODO: Check "Disk info block" and get info from that in addition to the optional header.
75b04dc002Schristos
76b04dc002Schristos# Disk info block. (block 1)
77b04dc002Schristos0	name	nintendo-fds-disk-info-block
78b04dc002Schristos>23	byte	!1		FMC-
79b04dc002Schristos>23	byte	1		FSC-
80b04dc002Schristos>16	string	x		\b%.3s
81*4c89978fSchristos>15	ubyte	x		\b, mfr %02X
82*4c89978fSchristos>20	ubyte	x		(Rev.%02u)
83b04dc002Schristos
84b04dc002Schristos# Headered version.
85b04dc002Schristos0	string	FDS\x1A
86b04dc002Schristos>0x11	string	*NINTENDO-HVC*	Famicom Disk System disk image:
87b13ade61Schristos!:mime	application/x-fds-disk
88b04dc002Schristos>>0x10	use	nintendo-fds-disk-info-block
89b04dc002Schristos>4	byte	1	(%u side)
90b04dc002Schristos>4	byte	!1	(%u sides)
91b04dc002Schristos
92b04dc002Schristos# Unheadered version.
93b04dc002Schristos1	string	*NINTENDO-HVC*	Famicom Disk System disk image:
94b13ade61Schristos!:mime	application/x-fds-disk
95b04dc002Schristos>0	use	nintendo-fds-disk-info-block
96b04dc002Schristos
97b04dc002Schristos#------------------------------------------------------------------------------
98b04dc002Schristos# tnes: file(1) magic for TNES-format Nintendo Entertainment System ROM images
99b04dc002Schristos# Used by Nintendo 3DS NES Virtual Console games.
100b04dc002Schristos# From: David Korth <gerbilsoft@gerbilsoft.com>
101b04dc002Schristos#
102b04dc002Schristos0		string	TNES	NES ROM image (Nintendo 3DS Virtual Console)
103b13ade61Schristos!:mime		application/x-nes-rom
104b04dc002Schristos>4		byte	100	\b: FDS,
105b04dc002Schristos>>0x2010	use	nintendo-fds-disk-info-block
106b04dc002Schristos>4		byte	!100	\b: TNES mapper %u
107b04dc002Schristos>>5	byte		x		\b, %ux8k PRG
108b04dc002Schristos>>6	byte		x		\b, %ux8k CHR
109b04dc002Schristos>>7	byte&0x08	=1		[WRAM]
110b04dc002Schristos>>8	byte&0x09	=1		[H-mirror]
111b04dc002Schristos>>8	byte&0x09	=2		[V-mirror]
112b04dc002Schristos>>8	byte&0x02	=3		[VRAM]
1131b108b8bSchristos
1141b108b8bSchristos#------------------------------------------------------------------------------
1151b108b8bSchristos# gameboy: file(1) magic for the Nintendo (Color) Gameboy raw ROM format
116b04dc002Schristos# Reference: http://gbdev.gg8.se/wiki/articles/The_Cartridge_Header
1171b108b8bSchristos#
118b04dc002Schristos0x104		bequad		0xCEED6666CC0D000B	Game Boy ROM image
119b13ade61Schristos# TODO: application/x-gameboy-color-rom for GBC.
120b13ade61Schristos!:mime		application/x-gameboy-rom
121b04dc002Schristos>0x143		byte&0x80	0x80
122b04dc002Schristos>>0x134		string		>\0			\b: "%.15s"
123b04dc002Schristos>0x143		byte&0x80	!0x80
124b04dc002Schristos>>0x134		string		>\0			\b: "%.16s"
125b04dc002Schristos>0x14c		byte		x			(Rev.%02u)
1261b108b8bSchristos
127b04dc002Schristos# Machine type. (SGB, CGB, SGB+CGB)
1286449c992Schristos# Old licensee code 0x33 is required for SGB, but not CGB.
129b04dc002Schristos>0x14b		byte		0x33
130b04dc002Schristos>>0x146		byte		0x03
131b04dc002Schristos>>>0x143	byte&0x80	0x80	[SGB+CGB]
132b04dc002Schristos>>>0x143	byte&0x80	!0x80	[SGB]
133b04dc002Schristos>>0x146		byte		!0x03
134b04dc002Schristos>>>0x143	byte&0xC0	0x80	[CGB]
135b04dc002Schristos>>>0x143	byte&0xC0	0xC0	[CGB ONLY]
136b13ade61Schristos>0x14b		byte		!0x33
1376449c992Schristos>>0x143		byte&0xC0	0x80	[CGB]
1386449c992Schristos>>0x143		byte&0xC0	0xC0	[CGB ONLY]
139b04dc002Schristos
140b04dc002Schristos# Mapper.
141b04dc002Schristos>0x147 byte 0x00  [ROM ONLY]
142b04dc002Schristos>0x147 byte 0x01  [MBC1]
143b04dc002Schristos>0x147 byte 0x02  [MBC1+RAM]
144b04dc002Schristos>0x147 byte 0x03  [MBC1+RAM+BATT]
145b04dc002Schristos>0x147 byte 0x05  [MBC2]
146b04dc002Schristos>0x147 byte 0x06  [MBC2+BATTERY]
147b04dc002Schristos>0x147 byte 0x08  [ROM+RAM]
148b04dc002Schristos>0x147 byte 0x09  [ROM+RAM+BATTERY]
149b04dc002Schristos>0x147 byte 0x0B  [MMM01]
150b04dc002Schristos>0x147 byte 0x0C  [MMM01+SRAM]
151b04dc002Schristos>0x147 byte 0x0D  [MMM01+SRAM+BATT]
152b04dc002Schristos>0x147 byte 0x0F  [MBC3+TIMER+BATT]
153b04dc002Schristos>0x147 byte 0x10  [MBC3+TIMER+RAM+BATT]
154b04dc002Schristos>0x147 byte 0x11  [MBC3]
155b04dc002Schristos>0x147 byte 0x12  [MBC3+RAM]
156b04dc002Schristos>0x147 byte 0x13  [MBC3+RAM+BATT]
157b04dc002Schristos>0x147 byte 0x19  [MBC5]
158b04dc002Schristos>0x147 byte 0x1A  [MBC5+RAM]
159b04dc002Schristos>0x147 byte 0x1B  [MBC5+RAM+BATT]
160b04dc002Schristos>0x147 byte 0x1C  [MBC5+RUMBLE]
161b04dc002Schristos>0x147 byte 0x1D  [MBC5+RUMBLE+SRAM]
162b04dc002Schristos>0x147 byte 0x1E  [MBC5+RUMBLE+SRAM+BATT]
163b04dc002Schristos>0x147 byte 0xFC  [Pocket Camera]
164b04dc002Schristos>0x147 byte 0xFD  [Bandai TAMA5]
165b04dc002Schristos>0x147 byte 0xFE  [Hudson HuC-3]
166b04dc002Schristos>0x147 byte 0xFF  [Hudson HuC-1]
167b04dc002Schristos
168b04dc002Schristos# ROM size.
1691b108b8bSchristos>0x148 byte 0     \b, ROM: 256Kbit
1701b108b8bSchristos>0x148 byte 1     \b, ROM: 512Kbit
1711b108b8bSchristos>0x148 byte 2     \b, ROM: 1Mbit
1721b108b8bSchristos>0x148 byte 3     \b, ROM: 2Mbit
1731b108b8bSchristos>0x148 byte 4     \b, ROM: 4Mbit
1741b108b8bSchristos>0x148 byte 5     \b, ROM: 8Mbit
1751b108b8bSchristos>0x148 byte 6     \b, ROM: 16Mbit
176b04dc002Schristos>0x148 byte 7     \b, ROM: 32Mbit
1771b108b8bSchristos>0x148 byte 0x52  \b, ROM: 9Mbit
1781b108b8bSchristos>0x148 byte 0x53  \b, ROM: 10Mbit
1791b108b8bSchristos>0x148 byte 0x54  \b, ROM: 12Mbit
1801b108b8bSchristos
181b04dc002Schristos# RAM size.
1821b108b8bSchristos>0x149 byte 1     \b, RAM: 16Kbit
1831b108b8bSchristos>0x149 byte 2     \b, RAM: 64Kbit
1846449c992Schristos>0x149 byte 3     \b, RAM: 256Kbit
1851b108b8bSchristos>0x149 byte 4     \b, RAM: 1Mbit
186b04dc002Schristos>0x149 byte 5     \b, RAM: 512Kbit
1871b108b8bSchristos
1881b108b8bSchristos#------------------------------------------------------------------------------
189b04dc002Schristos# genesis: file(1) magic for various Sega Mega Drive / Genesis ROM image and disc formats
190b04dc002Schristos# Updated by David Korth <gerbilsoft@gerbilsoft.com>
191b04dc002Schristos# References:
192c3ff5af2Schristos# - https://www.retrodev.com/segacd.html
193b04dc002Schristos# - http://devster.monkeeh.com/sega/32xguide1.txt
1941b108b8bSchristos#
195b04dc002Schristos
196b04dc002Schristos# Common Sega Mega Drive header format.
197b04dc002Schristos# FIXME: Name fields are 48 bytes, but have spaces for padding instead of 00s.
198b04dc002Schristos0		name	sega-mega-drive-header
199b04dc002Schristos# ROM title. (Use domestic if present; if not, use international.)
200b04dc002Schristos>0x120		byte	>0x20
201b04dc002Schristos>>0x120		string	>\0	\b: "%.16s"
202b04dc002Schristos>0x120		byte	<0x21
203b04dc002Schristos>>0x150		string	>\0	\b: "%.16s"
204b04dc002Schristos# Other information.
205b04dc002Schristos>0x180		string	>\0	(%.14s
206b04dc002Schristos>>0x110		string  >\0	\b, %.16s
207b04dc002Schristos>0x180		byte	0
208b04dc002Schristos>>0x110		string  >\0	(%.16s
209b04dc002Schristos>0		byte	x	\b)
210b04dc002Schristos
211b04dc002Schristos# TODO: Check for 32X CD?
212b04dc002Schristos# Sega Mega CD disc images: 2048-byte sectors.
213b04dc002Schristos0	string	SEGADISCSYSTEM\ \ 	Sega Mega CD disc image
214b13ade61Schristos!:mime	application/x-sega-cd-rom
215b04dc002Schristos>0	use	sega-mega-drive-header
216b04dc002Schristos>0	byte	x			\b, 2048-byte sectors
217b04dc002Schristos0	string	SEGABOOTDISC\ \ \ \ 	Sega Mega CD disc image
218b13ade61Schristos!:mime	application/x-sega-cd-rom
219b04dc002Schristos>0	use	sega-mega-drive-header
220b04dc002Schristos>0	byte	x			\b, 2048-byte sectors
221b04dc002Schristos# Sega Mega CD disc images: 2352-byte sectors.
222b04dc002Schristos0x10	string	SEGADISCSYSTEM\ \ 	Sega Mega CD disc image
223b13ade61Schristos!:mime	application/x-sega-cd-rom
224b04dc002Schristos>0x10	use	sega-mega-drive-header
225b04dc002Schristos>0	byte	x			\b, 2352-byte sectors
226b04dc002Schristos0x10	string	SEGABOOTDISC\ \ \ \ 	Sega Mega CD disc image
227b13ade61Schristos!:mime	application/x-sega-cd-rom
228b04dc002Schristos>0x10	use	sega-mega-drive-header
229b04dc002Schristos>0	byte	x			\b, 2352-byte sectors
230b04dc002Schristos
231*4c89978fSchristos# Sega Mega Drive: Identify the system ID.
232b04dc002Schristos0x100		string	SEGA
233*4c89978fSchristos>0x3C0		string	MARS\ CHECK\ MODE	Sega 32X ROM image
234b13ade61Schristos!:mime		application/x-genesis-32x-rom
235b04dc002Schristos>>0		use	sega-mega-drive-header
236*4c89978fSchristos>0x104		string	\ PICO			Sega Pico ROM image
237b13ade61Schristos!:mime		application/x-sega-pico-rom
238*4c89978fSchristos>>0		use	sega-mega-drive-header
239*4c89978fSchristos>0x104		string	TOYS\ PICO		Sega Pico ROM image
240*4c89978fSchristos!:mime		application/x-sega-pico-rom
241*4c89978fSchristos>>0		use	sega-mega-drive-header
242*4c89978fSchristos>0x104		string	\ TOYS\ PICO		Sega Pico ROM image
243*4c89978fSchristos!:mime		application/x-sega-pico-rom
244*4c89978fSchristos>>0		use	sega-mega-drive-header
245*4c89978fSchristos>0x104		string	\ IAC			Sega Pico ROM image
246*4c89978fSchristos!:mime		application/x-sega-pico-rom
247*4c89978fSchristos>>0		use	sega-mega-drive-header
248*4c89978fSchristos>0x104		string	\ TERA68K		Sega Teradrive (68K) ROM image
249*4c89978fSchristos!:mime		application/x-sega-teradrive-rom
250*4c89978fSchristos>>0		use	sega-mega-drive-header
251*4c89978fSchristos>0x104		string	\ TERA286		Sega Teradrive (286) ROM image
252*4c89978fSchristos!:mime		application/x-sega-teradrive-rom
253*4c89978fSchristos>>0		use	sega-mega-drive-header
254*4c89978fSchristos>0x180		string	BR			Sega Mega CD Boot ROM image
255b13ade61Schristos!:mime		application/x-genesis-rom
256*4c89978fSchristos>>0		use	sega-mega-drive-header
257*4c89978fSchristos>0x104		default	x			Sega Mega Drive / Genesis ROM image
258b13ade61Schristos!:mime		application/x-genesis-rom
259*4c89978fSchristos>>0		use	sega-mega-drive-header
260*4c89978fSchristos
261*4c89978fSchristos# Sega Mega Drive: Some ROMs have "SEGA" at 0x101, not 0x100.
262*4c89978fSchristos0x100		string	\ SEGA			Sega Mega Drive / Genesis ROM image
263*4c89978fSchristos>0		use	sega-mega-drive-header
264*4c89978fSchristos
265*4c89978fSchristos# Sega Pico ROMs that don't start with "SEGA".
266*4c89978fSchristos0x100		string	SAMSUNG\ PICO		Samsung Pico ROM image
267*4c89978fSchristos!:mime		application/x-sega-pico-rom
268*4c89978fSchristos>0		use	sega-mega-drive-header
269*4c89978fSchristos0x100		string	IMA\ IKUNOUJYUKU	Samsung Pico ROM image
270*4c89978fSchristos!:mime		application/x-sega-pico-rom
271*4c89978fSchristos>0		use	sega-mega-drive-header
272*4c89978fSchristos0x100		string	IMA IKUNOJYUKU		Samsung Pico ROM image
273*4c89978fSchristos!:mime		application/x-sega-pico-rom
274*4c89978fSchristos>0		use	sega-mega-drive-header
275*4c89978fSchristos
276*4c89978fSchristos# Sega Picture Magic (modified 32X)
277*4c89978fSchristos0x100		string	Picture\ Magic
278*4c89978fSchristos>0x3C0		string	PICTURE MAGIC-01	Sega 32X ROM image
279*4c89978fSchristos!:mime		application/x-genesis-32x-rom
280*4c89978fSchristos>>0		use	sega-mega-drive-header
2811b108b8bSchristos
2821b108b8bSchristos#------------------------------------------------------------------------------
2831b108b8bSchristos# genesis: file(1) magic for the Super MegaDrive ROM dump format
2841b108b8bSchristos#
285b04dc002Schristos
286b04dc002Schristos# NOTE: Due to interleaving, we can't display anything
287b04dc002Schristos# other than the copier header information.
288b04dc002Schristos0      name    sega-genesis-smd-header
2891b108b8bSchristos>0     byte    x       %dx16k blocks
2901b108b8bSchristos>2     byte    0       \b, last in series or standalone
2911b108b8bSchristos>2     byte    >0      \b, split ROM
292b04dc002Schristos
293b04dc002Schristos# "Sega Genesis" header.
294b04dc002Schristos0x280	string EAGN
295b04dc002Schristos>8	beshort	0xAABB	Sega Mega Drive / Genesis ROM image (SMD format):
296b13ade61Schristos!:mime	application/x-genesis-rom
297b04dc002Schristos>>0	use     sega-genesis-smd-header
298b04dc002Schristos
299b04dc002Schristos# "Sega Mega Drive" header.
300b04dc002Schristos0x280	string EAMG
301b04dc002Schristos>8	beshort	0xAABB	Sega Mega Drive / Genesis ROM image (SMD format):
302b13ade61Schristos!:mime	application/x-genesis-rom
303b04dc002Schristos>>0	use     sega-genesis-smd-header
3041b108b8bSchristos
3051b108b8bSchristos#------------------------------------------------------------------------------
306b04dc002Schristos# smsgg:  file(1) magic for Sega Master System and Game Gear ROM images
307b04dc002Schristos# Detects all Game Gear and export Sega Master System ROM images,
308b04dc002Schristos# and some Japanese Sega Master System ROM images.
309b04dc002Schristos# From: David Korth <gerbilsoft@gerbilsoft.com>
310c3ff5af2Schristos# Reference: https://www.smspower.org/Development/ROMHeader
3111b108b8bSchristos#
312b04dc002Schristos
313b04dc002Schristos# General SMS header rule.
314b04dc002Schristos# The SMS boot ROM checks the header at three locations.
315b04dc002Schristos0	name	sega-master-system-rom-header
316b04dc002Schristos# Machine type.
317b04dc002Schristos>0x0F	byte&0xF0	0x30	Sega Master System
318b13ade61Schristos!:mime	application/x-sms-rom
319b04dc002Schristos>0x0F	byte&0xF0	0x40	Sega Master System
320b13ade61Schristos!:mime	application/x-sms-rom
321b04dc002Schristos>0x0F	byte&0xF0	0x50	Sega Game Gear
322b13ade61Schristos!:mime	application/x-gamegear-rom
323b04dc002Schristos>0x0F	byte&0xF0	0x60	Sega Game Gear
324b13ade61Schristos!:mime	application/x-gamegear-rom
325b04dc002Schristos>0x0F	byte&0xF0	0x70	Sega Game Gear
326b13ade61Schristos!:mime	application/x-gamegear-rom
327b13ade61Schristos>0x0F	default		x	Sega Master System / Game Gear
328b13ade61Schristos!:mime	application/x-sms-rom
329b04dc002Schristos>0	byte		x	ROM image:
330b04dc002Schristos# Product code.
331b04dc002Schristos>0x0E	byte&0xF0	0x10	1
332b04dc002Schristos>0x0E	byte&0xF0	0x20	2
333b04dc002Schristos>0x0E	byte&0xF0	0x30	3
334b04dc002Schristos>0x0E	byte&0xF0	0x40	4
335b04dc002Schristos>0x0E	byte&0xF0	0x50	5
336b04dc002Schristos>0x0E	byte&0xF0	0x60	6
337b04dc002Schristos>0x0E	byte&0xF0	0x70	7
338b04dc002Schristos>0x0E	byte&0xF0	0x80	8
339b04dc002Schristos>0x0E	byte&0xF0	0x90	9
340b04dc002Schristos>0x0E	byte&0xF0	0xA0	10
341b04dc002Schristos>0x0E	byte&0xF0	0xB0	11
342b04dc002Schristos>0x0E	byte&0xF0	0xC0	12
343b04dc002Schristos>0x0E	byte&0xF0	0xD0	13
344b04dc002Schristos>0x0E	byte&0xF0	0xE0	14
345b04dc002Schristos>0x0E	byte&0xF0	0xF0	15
346b04dc002Schristos# If the product code is 5 digits, we'll need to backspace here.
347b04dc002Schristos>0x0E	byte&0xF0	!0
348b04dc002Schristos>>0x0C	leshort		x	\b%04x
349b04dc002Schristos>0x0E	byte&0xF0	0
350b04dc002Schristos>>0x0C	leshort		x	%04x
351b04dc002Schristos# Revision.
352b04dc002Schristos>0x0E	byte&0x0F	x	(Rev.%02d)
353b04dc002Schristos# ROM size. (Used for the boot ROM checksum routine.)
354b04dc002Schristos>0x0F	byte&0x0F	0x0A	(8 KB)
355b04dc002Schristos>0x0F	byte&0x0F	0x0B	(16 KB)
356b04dc002Schristos>0x0F	byte&0x0F	0x0C	(32 KB)
357b04dc002Schristos>0x0F	byte&0x0F	0x0D	(48 KB)
358b04dc002Schristos>0x0F	byte&0x0F	0x0E	(64 KB)
359b04dc002Schristos>0x0F	byte&0x0F	0x0F	(128 KB)
360b04dc002Schristos>0x0F	byte&0x0F	0x00	(256 KB)
361b04dc002Schristos>0x0F	byte&0x0F	0x01	(512 KB)
362b04dc002Schristos>0x0F	byte&0x0F	0x02	(1 MB)
363b04dc002Schristos
364b04dc002Schristos# SMS/GG header locations.
365b04dc002Schristos0x7FF0	string	TMR\ SEGA
366b04dc002Schristos>0x7FF0	use	sega-master-system-rom-header
367b04dc002Schristos0x3FF0	string	TMR\ SEGA
368b04dc002Schristos>0x3FF0	use	sega-master-system-rom-header
369b04dc002Schristos0x1FF0	string	TMR\ SEGA
370b04dc002Schristos>0x1FF0	use	sega-master-system-rom-header
3711b108b8bSchristos
3721b108b8bSchristos#------------------------------------------------------------------------------
373b04dc002Schristos# saturn: file(1) magic for the Sega Saturn disc image format.
374b04dc002Schristos# From: David Korth <gerbilsoft@gerbilsoft.com>
3751b108b8bSchristos#
376b04dc002Schristos
377b04dc002Schristos# Common Sega Saturn disc header format.
378b04dc002Schristos# NOTE: Title is 112 bytes, but we're only showing 32 due to space padding.
379b04dc002Schristos# TODO: Release date, device information, region code, others?
380b04dc002Schristos0	name	sega-saturn-disc-header
381b04dc002Schristos>0x60	string	>\0	\b: "%.32s"
382b04dc002Schristos>0x20	string	>\0	(%.10s
383b04dc002Schristos>>0x2A	string	>\0	\b, %.6s)
384b04dc002Schristos>>0x2A	byte	0	\b)
385b04dc002Schristos
386b04dc002Schristos# 2048-byte sector version.
387b04dc002Schristos0	string	SEGA\ SEGASATURN\ 	Sega Saturn disc image
388b13ade61Schristos!:mime	application/x-saturn-rom
389b04dc002Schristos>0	use	sega-saturn-disc-header
390b04dc002Schristos>0	byte	x			(2048-byte sectors)
391b04dc002Schristos# 2352-byte sector version.
392b04dc002Schristos0x10	string	SEGA\ SEGASATURN\ 	Sega Saturn disc image
393b13ade61Schristos!:mime	application/x-saturn-rom
394b04dc002Schristos>0x10	use	sega-saturn-disc-header
395b04dc002Schristos>0	byte	x			(2352-byte sectors)
396b04dc002Schristos
397b04dc002Schristos#------------------------------------------------------------------------------
398b04dc002Schristos# dreamcast: file(1) magic for the Sega Dreamcast disc image format.
399b04dc002Schristos# From: David Korth <gerbilsoft@gerbilsoft.com>
400c3ff5af2Schristos# Reference: https://mc.pp.se/dc/ip0000.bin.html
4011b108b8bSchristos#
402b04dc002Schristos
403b04dc002Schristos# Common Sega Dreamcast disc header format.
404b04dc002Schristos# NOTE: Title is 128 bytes, but we're only showing 32 due to space padding.
405b04dc002Schristos# TODO: Release date, device information, region code, others?
406b04dc002Schristos0	name	sega-dreamcast-disc-header
407b04dc002Schristos>0x80	string	>\0	\b: "%.32s"
408b04dc002Schristos>0x40	string	>\0	(%.10s
409b04dc002Schristos>>0x4A	string	>\0	\b, %.6s)
410b04dc002Schristos>>0x4A	byte	0	\b)
411b04dc002Schristos
412b04dc002Schristos# 2048-byte sector version.
413b04dc002Schristos0	string	SEGA\ SEGAKATANA\ 	Sega Dreamcast disc image
414b13ade61Schristos!:mime	application/x-dc-rom
415b04dc002Schristos>0	use	sega-dreamcast-disc-header
416b04dc002Schristos>0	byte	x			(2048-byte sectors)
417b04dc002Schristos# 2352-byte sector version.
418b04dc002Schristos0x10	string	SEGA\ SEGAKATANA\ 	Sega Dreamcast disc image
419b13ade61Schristos!:mime	application/x-dc-rom
420b04dc002Schristos>0x10	use	sega-dreamcast-disc-header
421b04dc002Schristos>0	byte	x			(2352-byte sectors)
4221b108b8bSchristos
4231b108b8bSchristos#------------------------------------------------------------------------------
4241b108b8bSchristos# dreamcast:  file(1) uncertain magic for the Sega Dreamcast VMU image format
4251b108b8bSchristos#
4261b108b8bSchristos0 belong 0x21068028   Sega Dreamcast VMU game image
4271b108b8bSchristos0 string LCDi         Dream Animator file
4281b108b8bSchristos
4291b108b8bSchristos#------------------------------------------------------------------------------
430b04dc002Schristos# z64: file(1) magic for the Z64 format N64 ROM dumps
431b04dc002Schristos# Reference: http://forum.pj64-emu.com/showthread.php?t=2239
432b04dc002Schristos# From: David Korth <gerbilsoft@gerbilsoft.com>
4331b108b8bSchristos#
434b04dc002Schristos0	bequad	0x803712400000000F	Nintendo 64 ROM image
435b13ade61Schristos!:mime	application/x-n64-rom
436b04dc002Schristos>0x20	string	>\0	\b: "%.20s"
437b04dc002Schristos>0x3B	string	x	(%.4s
438b04dc002Schristos>0x3F	byte	x	\b, Rev.%02u)
4391b108b8bSchristos
440b04dc002Schristos#------------------------------------------------------------------------------
441b04dc002Schristos# v64: file(1) magic for the V64 format N64 ROM dumps
442b04dc002Schristos# Same as z64 format, but with 16-bit byteswapping.
443b04dc002Schristos#
444b04dc002Schristos0	bequad	0x3780401200000F00	Nintendo 64 ROM image (V64)
445b13ade61Schristos!:mime	application/x-n64-rom
446b04dc002Schristos
447b04dc002Schristos#------------------------------------------------------------------------------
448b04dc002Schristos# n64-swap2: file(1) magic for the swap2 format N64 ROM dumps
449b04dc002Schristos# Same as z64 format, but with swapped 16-bit words.
450b04dc002Schristos#
451b04dc002Schristos0	bequad	0x12408037000F0000	Nintendo 64 ROM image (wordswapped)
452b13ade61Schristos!:mime	application/x-n64-rom
453b04dc002Schristos
454b04dc002Schristos#------------------------------------------------------------------------------
455b04dc002Schristos# n64-le32: file(1) magic for the 32-bit byteswapped format N64 ROM dumps
456b04dc002Schristos# Same as z64 format, but with 32-bit byteswapping.
457b04dc002Schristos#
458b04dc002Schristos0	bequad	0x401237800F000000	Nintendo 64 ROM image (32-bit byteswapped)
459b13ade61Schristos!:mime	application/x-n64-rom
460b04dc002Schristos
461b04dc002Schristos#------------------------------------------------------------------------------
462b04dc002Schristos# gba: file(1) magic for the Nintendo Game Boy Advance raw ROM format
463c3ff5af2Schristos# Reference: https://problemkaputt.de/gbatek.htm#gbacartridgeheader
464b04dc002Schristos#
465b04dc002Schristos# Original version from: "Nelson A. de Oliveira" <naoliv@gmail.com>
466b04dc002Schristos# Updated version from: David Korth <gerbilsoft@gerbilsoft.com>
467b04dc002Schristos#
468b04dc002Schristos4	bequad	0x24FFAE51699AA221	Game Boy Advance ROM image
469b13ade61Schristos!:mime	application/x-gba-rom
470b04dc002Schristos>0xA0	string	>\0	\b: "%.12s"
471b04dc002Schristos>0xAC	string	x	(%.6s
472b04dc002Schristos>0xBC	byte	x	\b, Rev.%02u)
473b04dc002Schristos
474b04dc002Schristos#------------------------------------------------------------------------------
475b04dc002Schristos# nds: file(1) magic for the Nintendo DS(i) raw ROM format
476c3ff5af2Schristos# Reference: https://problemkaputt.de/gbatek.htm#dscartridgeheader
477b04dc002Schristos#
478b04dc002Schristos# Original version from: "Nelson A. de Oliveira" <naoliv@gmail.com>
479b04dc002Schristos# Updated version from: David Korth <gerbilsoft@gerbilsoft.com>
480b04dc002Schristos#
481b04dc002Schristos0xC0	bequad	0x24FFAE51699AA221	Nintendo DS ROM image
482b13ade61Schristos!:mime	application/x-nintendo-ds-rom
483b04dc002Schristos>0x00	string	>\0		\b: "%.12s"
484b04dc002Schristos>0x0C	string	x		(%.6s
485b04dc002Schristos>0x1E	byte	x		\b, Rev.%02u)
486b04dc002Schristos>0x12	byte	2		(DSi enhanced)
487b04dc002Schristos>0x12	byte	3		(DSi only)
48855287a1bSchristos# Secure Area check.
48955287a1bSchristos>0x20		lelong	<0x4000		(homebrew)
49055287a1bSchristos>0x20		lelong	>0x3FFF
49155287a1bSchristos>>0x4000	lequad	0x0000000000000000	(multiboot)
49255287a1bSchristos>>0x4000	lequad	!0x0000000000000000
49355287a1bSchristos>>>0x4000	lequad	0xE7FFDEFFE7FFDEFF	(decrypted)
49455287a1bSchristos>>>0x4000	lequad	!0xE7FFDEFFE7FFDEFF
49555287a1bSchristos>>>>0x1000	lequad	0x0000000000000000	(encrypted)
49655287a1bSchristos>>>>0x1000	lequad	!0x0000000000000000	(mask ROM)
497b04dc002Schristos
498b04dc002Schristos#------------------------------------------------------------------------------
499b04dc002Schristos# nds_passme: file(1) magic for Nintendo DS ROM images for GBA cartridge boot.
500b04dc002Schristos# This is also used for loading .nds files using the MSET exploit on 3DS.
501b04dc002Schristos# Reference: https://github.com/devkitPro/ndstool/blob/master/source/ndscreate.cpp
502b04dc002Schristos0xC0	bequad	0xC8604FE201708FE2	Nintendo DS Slot-2 ROM image (PassMe)
503b13ade61Schristos!:mime	application/x-nintendo-ds-rom
504b04dc002Schristos
505b04dc002Schristos#------------------------------------------------------------------------------
506b04dc002Schristos# ngp: file(1) magic for the Neo Geo Pocket (Color) raw ROM format.
507b04dc002Schristos# From: David Korth <gerbilsoft@gerbilsoft.com>
508b04dc002Schristos# References:
509b04dc002Schristos# - https://neogpc.googlecode.com/svn-history/r10/trunk/src/core/neogpc.cpp
510c3ff5af2Schristos# - https://www.devrs.com/ngp/files/ngpctech.txt
511b04dc002Schristos#
512b04dc002Schristos0x0A	string		BY\ SNK\ CORPORATION	Neo Geo Pocket
513b13ade61Schristos!:mime	application/x-neo-geo-pocket-rom
514b04dc002Schristos>0x23	byte		0x10			Color
515b04dc002Schristos>0	byte		x			ROM image
516b04dc002Schristos>0x24	string		>\0			\b: "%.12s"
517*4c89978fSchristos>0x21	uleshort	x			\b, NEOP%04X
518*4c89978fSchristos>0x1F	ubyte		0xFF			(debug mode enabled)
5191b108b8bSchristos
5201b108b8bSchristos#------------------------------------------------------------------------------
5211b108b8bSchristos# msx: file(1) magic for MSX game cartridge dumps
5221b108b8bSchristos# Too simple - MPi
5231b108b8bSchristos#0 beshort 0x4142 MSX game cartridge dump
5241b108b8bSchristos
5251b108b8bSchristos#------------------------------------------------------------------------------
5261b108b8bSchristos# Sony Playstation executables (Adam Sjoegren <asjo@diku.dk>) :
5271b108b8bSchristos0	string	PS-X\ EXE	Sony Playstation executable
528*4c89978fSchristos>16	lelong	x		PC=%#08x,
529*4c89978fSchristos>20	lelong	!0		GP=%#08x,
530*4c89978fSchristos>24	lelong	!0		.text=[%#08x,
531*4c89978fSchristos>>28	lelong	x		\b%#x],
532*4c89978fSchristos>32	lelong	!0		.data=[%#08x,
533*4c89978fSchristos>>36	lelong	x		\b%#x],
534*4c89978fSchristos>40	lelong	!0		.bss=[%#08x,
535*4c89978fSchristos>>44	lelong	x		\b%#x],
536*4c89978fSchristos>48	lelong	!0		Stack=%#08x,
537b04dc002Schristos>48	lelong	=0		No Stack!,
538*4c89978fSchristos>52	lelong	!0		StackSize=%#x,
539b04dc002Schristos#>76	string	>\0		(%s)
5401b108b8bSchristos#  Area:
5411b108b8bSchristos>113	string	x		(%s)
5421b108b8bSchristos
543b04dc002Schristos# CPE executables
544b04dc002Schristos0	string	CPE		CPE executable
545b04dc002Schristos>3	byte	x		(version %d)
546b04dc002Schristos
5471b108b8bSchristos#------------------------------------------------------------------------------
548ce75d85eSchristos# Microsoft Xbox executables .xbe (Esa Hyytia <ehyytia@cc.hut.fi>)
549c3ff5af2Schristos0	string	XBEH	Microsoft Xbox executable
5500086c5a6Schristos!:mime	audio/x-xbox-executable
5510086c5a6Schristos!:ext	xbe
552c3ff5af2Schristos# expect base address of 0x10000
553c3ff5af2Schristos>0x0104                 ulelong =0x10000
554c3ff5af2Schristos>>(0x0118.l-0x0FFF4)    lestring16 x       \b: "%.40s"
555c3ff5af2Schristos>>(0x0118.l-0x0FFF5)    byte     x         (%c
556c3ff5af2Schristos>>(0x0118.l-0x0FFF6)    byte     x         \b%c-
557c3ff5af2Schristos>>(0x0118.l-0x0FFF8)    uleshort x         \b%03u)
558c3ff5af2Schristos>>(0x0118.l-0x0FF60)    ulelong&0x80000007  0x80000007 \b, all regions
559c3ff5af2Schristos>>(0x0118.l-0x0FF60)    ulelong&0x80000007  !0x80000007
560c3ff5af2Schristos>>>(0x0118.l-0x0FF60)   ulelong >0           (regions:
561c3ff5af2Schristos>>>>(0x0118.l-0x0FF60)  ulelong &0x00000001  NA
562c3ff5af2Schristos>>>>(0x0118.l-0x0FF60)  ulelong &0x00000002  Japan
563c3ff5af2Schristos>>>>(0x0118.l-0x0FF60)  ulelong &0x00000004  Rest_of_World
564c3ff5af2Schristos>>>>(0x0118.l-0x0FF60)  ulelong &0x80000000  Manufacturer
565c3ff5af2Schristos>>>(0x0118.l-0x0FF60)   ulelong >0           \b)
5661b108b8bSchristos# probabilistic checks whether signed or not
5671b108b8bSchristos>0x0004 ulelong =0x0
5681b108b8bSchristos>>&2    ulelong =0x0
5691b108b8bSchristos>>>&2   ulelong =0x0  \b, not signed
5701b108b8bSchristos>0x0004 ulelong >0
5711b108b8bSchristos>>&2    ulelong >0
5721b108b8bSchristos>>>&2   ulelong >0    \b, signed
5731b108b8bSchristos
5741b108b8bSchristos# --------------------------------
5751b108b8bSchristos# Microsoft Xbox data file formats
5761b108b8bSchristos0       string          XIP0            XIP, Microsoft Xbox data
5771b108b8bSchristos0       string          XTF0            XTF, Microsoft Xbox data
5781b108b8bSchristos
579c3ff5af2Schristos#------------------------------------------------------------------------------
580c3ff5af2Schristos# Microsoft Xbox 360 executables (.xex)
581c3ff5af2Schristos# From: David Korth <gerbilsoft@gerbilsoft.com>
582c3ff5af2Schristos# References:
583c3ff5af2Schristos# - https://free60project.github.io/wiki/XEX.html
584c3ff5af2Schristos# - https://github.com/xenia-project/xenia/blob/HEAD/src/xenia/kernel/util/xex2_info.h
585c3ff5af2Schristos
586c3ff5af2Schristos# Title ID (part of Execution ID section)
587c3ff5af2Schristos0		name	xbox-360-xex-execution-id
588c3ff5af2Schristos>(0.L+0xC)	byte	x	(%c
589c3ff5af2Schristos>(0.L+0xD)	byte	x	\b%c
5900086c5a6Schristos>(0.L+0xE)	beshort	x	\b-%04u, media ID:
5910086c5a6Schristos>(0.L)		belong	x	%08X)
5920086c5a6Schristos
5930086c5a6Schristos# Region code (part of Security Info)
5940086c5a6Schristos0	name	xbox-360-xex-region-code
5950086c5a6Schristos>0	ubelong	0xFFFFFFFF	\b, all regions
5960086c5a6Schristos>0	ubelong	!0xFFFFFFFF
5970086c5a6Schristos>>0	ubelong	>0		(regions:
5980086c5a6Schristos>>0	ubelong&0x000000FF	0x000000FF	USA
5990086c5a6Schristos>>0	ubelong&0x00000100	0x00000100	Japan
6000086c5a6Schristos>>0	ubelong&0x00000200	0x00000200	China
6010086c5a6Schristos>>0	ubelong&0x0000FC00	0x0000FC00	Asia
6020086c5a6Schristos>>0	ubelong&0x00FF0000	0x00FF0000	PAL
6030086c5a6Schristos>>0	ubelong&0x00FF0000	0x00FE0000	PAL [except AU/NZ]
6040086c5a6Schristos>>0	ubelong&0x00FF0000	0x00010000	AU/NZ
6050086c5a6Schristos>>0	ubelong&0xFF000000	0xFF000000	Other
6060086c5a6Schristos>>0	ubelong	>0		\b)
607c3ff5af2Schristos
608c3ff5af2Schristos0	string	XEX2	Microsoft Xbox 360 executable
6090086c5a6Schristos!:mime	audio/x-xbox360-executable
6100086c5a6Schristos!:ext	xex
611c3ff5af2Schristos>0x18	search/0x100	\x00\x04\x00\x06
612c3ff5af2Schristos>>&0	use	xbox-360-xex-execution-id
6130086c5a6Schristos>(0x010.L+0x178)	use	xbox-360-xex-region-code
614c3ff5af2Schristos
6150086c5a6Schristos0	string	XEX1	Microsoft Xbox 360 executable (XEX1)
6160086c5a6Schristos!:mime	audio/x-xbox360-executable
6170086c5a6Schristos!:ext	xex
6180086c5a6Schristos>0x18	search/0x100	\x00\x04\x00\x06
6190086c5a6Schristos>>&0	use	xbox-360-xex-execution-id
6200086c5a6Schristos>(0x010.L+0x154)	use	xbox-360-xex-region-code
621c3ff5af2Schristos
6220086c5a6Schristos#------------------------------------------------------------------------------
6230086c5a6Schristos# Microsoft Xbox 360 packages
6240086c5a6Schristos# From: David Korth <gerbilsoft@gerbilsoft.com>
6250086c5a6Schristos# References:
6260086c5a6Schristos# - https://free60project.github.io/wiki/STFS.html
6270086c5a6Schristos# - https://github.com/xenia-project/xenia/blob/HEAD/src/xenia/kernel/util/xex2_info.h
6280086c5a6Schristos
6290086c5a6Schristos# TODO: More information for console-signed packages.
6300086c5a6Schristos
6310086c5a6Schristos0	name	xbox-360-package
6320086c5a6Schristos>0x360	byte	x	(%c
6330086c5a6Schristos>0x361	byte	x	\b%c
6340086c5a6Schristos>0x362	beshort	x	\b-%04u, media ID:
6350086c5a6Schristos>0x354	belong	x	%08X)
6360086c5a6Schristos>0x344	belong	x	\b, content type:
6370086c5a6Schristos>>0x344	belong	0x1		Saved Game
6380086c5a6Schristos>>0x344	belong	0x2		Marketplace Content
6390086c5a6Schristos>>0x344	belong	0x3		Publisher
6400086c5a6Schristos>>0x344	belong	0x1000		Xbox 360 Title
6410086c5a6Schristos>>0x344	belong	0x2000		IPTV Pause Buffer
6420086c5a6Schristos>>0x344	belong	0x4000		Installed Game
6430086c5a6Schristos>>0x344	belong	0x5000		Original Xbox Game
6440086c5a6Schristos>>0x344	belong	0x9000		Avatar Item
6450086c5a6Schristos>>0x344	belong	0x10000		Profile
6460086c5a6Schristos>>0x344	belong	0x20000		Gamer Picture
6470086c5a6Schristos>>0x344	belong	0x30000		Theme
6480086c5a6Schristos>>0x344	belong	0x40000		Cache File
6490086c5a6Schristos>>0x344	belong	0x50000		Storage Download
6500086c5a6Schristos>>0x344	belong	0x60000		Xbox Saved Game
6510086c5a6Schristos>>0x344	belong	0x70000		Xbox Download
6520086c5a6Schristos>>0x344	belong	0x80000		Game Demo
6530086c5a6Schristos>>0x344	belong	0x90000		Video
6540086c5a6Schristos>>0x344	belong	0xA0000		Game
6550086c5a6Schristos>>0x344	belong	0xB0000		Installer
6560086c5a6Schristos>>0x344	belong	0xC0000		Game Trailer
6570086c5a6Schristos>>0x344	belong	0xD0000		Arcade Title
6580086c5a6Schristos>>0x344	belong	0xE0000		XNA
6590086c5a6Schristos>>0x344	belong	0xF0000		License Store
6600086c5a6Schristos>>0x344	belong	0x100000	Movie
6610086c5a6Schristos>>0x344	belong	0x200000	TV
6620086c5a6Schristos>>0x344	belong	0x300000	Music Video
6630086c5a6Schristos>>0x344	belong	0x400000	Game Video
6640086c5a6Schristos>>0x344	belong	0x500000	Podcast Video
6650086c5a6Schristos>>0x344	belong	0x600000	Viral Video
6660086c5a6Schristos>>0x344	belong	0x2000000	Community Game
6670086c5a6Schristos
6680086c5a6Schristos0	string	CON\x20	Microsoft Xbox 360 package (console-signed)
6690086c5a6Schristos>0	use	xbox-360-package
670cdf4124cSchristos0	string	PIRS
671cdf4124cSchristos>0	belong	0	Microsoft Xbox 360 package (non-Xbox Live)
672cdf4124cSchristos>>0	use	xbox-360-package
673cdf4124cSchristos0	string	LIVE
674cdf4124cSchristos>0x104	belong	0	Microsoft Xbox 360 package (Xbox Live)
675cdf4124cSchristos>>0	use	xbox-360-package
676c3ff5af2Schristos
6771b108b8bSchristos# Atari Lynx cartridge dump (EXE/BLL header)
678*4c89978fSchristos# From: "Stefan A. Haubenthal" <polluks@sdf.lonestar.org>
679*4c89978fSchristos# Reference:
680*4c89978fSchristos# https://raw.githubusercontent.com/cc65/cc65/master/libsrc/lynx/exehdr.s
6812e1c341aSchristos# Double-check that the image type matches too, 0x8008 conflicts with
6822e1c341aSchristos# 8 character OMF-86 object file headers.
6832e1c341aSchristos0	beshort		0x8008
6842e1c341aSchristos>6	string		BS93		Lynx homebrew cartridge
685b13ade61Schristos!:mime	application/x-atari-lynx-rom
6862e1c341aSchristos>>2	beshort		x		\b, RAM start $%04x
687*4c89978fSchristos0	string		LYNX		Lynx cartridge
688b13ade61Schristos!:mime	application/x-atari-lynx-rom
689*4c89978fSchristos>4	leshort/4	>0		\b, bank 0 %dk
690*4c89978fSchristos>6	leshort/4	>0		\b, bank 1 %dk
691*4c89978fSchristos>10	string		>\0		\b, "%.32s"
692*4c89978fSchristos>42	string		>\0		\b, "%.16s"
6931b108b8bSchristos
6941b108b8bSchristos# Opera file system that is used on the 3DO console
6951b108b8bSchristos# From: Serge van den Boom <svdb@stack.nl>
6961b108b8bSchristos0	string		\x01ZZZZZ\x01	3DO "Opera" file system
6971b108b8bSchristos
69899449224Schristos# From: Alex Myczko <alex@aiei.ch>
699b04dc002Schristos# From: David Pflug <david@pflug.email>
700b04dc002Schristos# is the offset 12 or the offset 16 correct?
701b04dc002Schristos# GBS (Game Boy Sound) magic
702b04dc002Schristos# ftp://ftp.modland.com/pub/documents/format_documentation/\
703b04dc002Schristos# Gameboy%20Sound%20System%20(.gbs).txt
7041b108b8bSchristos0	string		GBS		Nintendo Gameboy Music/Audio Data
705b04dc002Schristos#12	string		GameBoy\ Music\ Module	Nintendo Gameboy Music Module
706b13ade61Schristos>16	string		>\0	("%.32s" by
707b13ade61Schristos>48	string		>\0	%.32s, copyright
708b13ade61Schristos>80	string		>\0	%.32s),
709b13ade61Schristos>3	byte		x	version %u,
710b13ade61Schristos>4	byte		x	%u tracks
711b04dc002Schristos
712b04dc002Schristos# IPS Patch Files from: From: Thomas Klausner <tk@giga.or.at>
713c3ff5af2Schristos# see https://zerosoft.zophar.net/ips.php
714b04dc002Schristos0	string	PATCH			IPS patch file
715cdf4124cSchristos!:ext	ips
716cdf4124cSchristos
717cdf4124cSchristos# BPS Patch Files - from: David Korth <gerbilsoft@gerbilsoft.com>
718cdf4124cSchristos# Reference: https://www.romhacking.net/documents/746/
719cdf4124cSchristos0	string	BPS1			BPS patch file
720cdf4124cSchristos!:ext	bps
721cdf4124cSchristos
722cdf4124cSchristos# APS Patch Files - from: David Korth <gerbilsoft@gerbilsoft.com>
723cdf4124cSchristos# Reference: https://github.com/btimofeev/UniPatcher/wiki/APS-(N64)
724cdf4124cSchristos0	string	APS10			APS patch file
725cdf4124cSchristos!:ext	aps
726cdf4124cSchristos>5	byte	0			\b, simple patch
727cdf4124cSchristos>5	byte	1			\b, N64-specific patch for
728cdf4124cSchristos>>58	byte	x			N%c
729cdf4124cSchristos>>59	byte	x			\b%c
730cdf4124cSchristos>>60	byte	x			\b%c
731cdf4124cSchristos>7	byte	!0x20
732cdf4124cSchristos# FIXME: /T specifier isn't working with a fixed-length string.
733cdf4124cSchristos>>7	string	x			\b: "%.50s"
734cdf4124cSchristos
735cdf4124cSchristos# UPS Patch Files - from: David Korth <gerbilsoft@gerbilsoft.com>
736cdf4124cSchristos# Reference: http://fileformats.archiveteam.org/wiki/UPS_(binary_patch_format)
737cdf4124cSchristos0	string	UPS1			UPS patch file
738cdf4124cSchristos!:ext	ups
7391b108b8bSchristos
7401b108b8bSchristos# Playstations Patch Files from: From: Thomas Klausner <tk@giga.or.at>
7411b108b8bSchristos0	string	PPF30			Playstation Patch File version 3.0
7421b108b8bSchristos>5	byte	0			\b, PPF 1.0 patch
7431b108b8bSchristos>5	byte	1			\b, PPF 2.0 patch
7441b108b8bSchristos>5	byte	2			\b, PPF 3.0 patch
7451b108b8bSchristos>>56	byte	0			\b, Imagetype BIN (any)
7461b108b8bSchristos>>56	byte	1			\b, Imagetype GI (PrimoDVD)
7471b108b8bSchristos>>57	byte	0			\b, Blockcheck disabled
7481b108b8bSchristos>>57	byte	1			\b, Blockcheck enabled
7491b108b8bSchristos>>58	byte	0			\b, Undo data not available
7501b108b8bSchristos>>58	byte	1			\b, Undo data available
7511b108b8bSchristos>6	string	x			\b, description: %s
7521b108b8bSchristos
7531b108b8bSchristos0	string	PPF20			Playstation Patch File version 2.0
7541b108b8bSchristos>5	byte	0			\b, PPF 1.0 patch
7551b108b8bSchristos>5	byte	1			\b, PPF 2.0 patch
7561b108b8bSchristos>>56	lelong	>0			\b, size of file to patch %d
7571b108b8bSchristos>6	string	x			\b, description: %s
7581b108b8bSchristos
7591b108b8bSchristos0	string	PPF10			Playstation Patch File version 1.0
7601b108b8bSchristos>5	byte	0			\b, Simple Encoding
7611b108b8bSchristos>6	string	x			\b, description: %s
7621b108b8bSchristos
7631b108b8bSchristos# From: Daniel Dawson <ddawson@icehouse.net>
7641b108b8bSchristos# SNES9x .smv "movie" file format.
7651b108b8bSchristos0		string		SMV\x1A	SNES9x input recording
7661b108b8bSchristos>0x4		lelong		x	\b, version %d
7671b108b8bSchristos# version 4 is latest so far
7681b108b8bSchristos>0x4		lelong		<5
7691b108b8bSchristos>>0x8		ledate		x	\b, recorded at %s
7701b108b8bSchristos>>0xc		lelong		>0	\b, rerecorded %d times
7711b108b8bSchristos>>0x10		lelong		x	\b, %d frames long
7721b108b8bSchristos>>0x14		byte		>0	\b, data for controller(s):
7731b108b8bSchristos>>>0x14		byte		&0x1	#1
7741b108b8bSchristos>>>0x14		byte		&0x2	#2
7751b108b8bSchristos>>>0x14		byte		&0x4	#3
7761b108b8bSchristos>>>0x14		byte		&0x8	#4
7771b108b8bSchristos>>>0x14		byte		&0x10	#5
7781b108b8bSchristos>>0x15		byte		^0x1	\b, begins from snapshot
7791b108b8bSchristos>>0x15		byte		&0x1	\b, begins from reset
7801b108b8bSchristos>>0x15		byte		^0x2	\b, NTSC standard
7811b108b8bSchristos>>0x15		byte		&0x2	\b, PAL standard
7821b108b8bSchristos>>0x17		byte		&0x1    \b, settings:
7831b108b8bSchristos# WIP1Timing not used as of version 4
7841b108b8bSchristos>>>0x4		lelong		<4
7851b108b8bSchristos>>>>0x17	byte		&0x2	WIP1Timing
7861b108b8bSchristos>>>0x17		byte		&0x4	Left+Right
7871b108b8bSchristos>>>0x17		byte		&0x8	VolumeEnvX
7881b108b8bSchristos>>>0x17		byte		&0x10	FakeMute
7891b108b8bSchristos>>>0x17		byte		&0x20	SyncSound
7901b108b8bSchristos# New flag as of version 4
7911b108b8bSchristos>>>0x4		lelong		>3
7921b108b8bSchristos>>>>0x17	byte		&0x80	NoCPUShutdown
7931b108b8bSchristos>>0x4		lelong		<4
7941b108b8bSchristos>>>0x18		lelong		>0x23
7951b108b8bSchristos>>>>0x20	leshort		!0
7961b108b8bSchristos>>>>>0x20	lestring16	x	\b, metadata: "%s"
7971b108b8bSchristos>>0x4		lelong		>3
7981b108b8bSchristos>>>0x24		byte		>0	\b, port 1:
7991b108b8bSchristos>>>>0x24	byte		1	joypad
8001b108b8bSchristos>>>>0x24	byte		2	mouse
8011b108b8bSchristos>>>>0x24	byte		3	SuperScope
8021b108b8bSchristos>>>>0x24	byte		4	Justifier
8031b108b8bSchristos>>>>0x24	byte		5	multitap
8041b108b8bSchristos>>>0x24		byte		>0	\b, port 2:
8051b108b8bSchristos>>>>0x25	byte		1	joypad
8061b108b8bSchristos>>>>0x25	byte		2	mouse
8071b108b8bSchristos>>>>0x25	byte		3	SuperScope
8081b108b8bSchristos>>>>0x25	byte		4	Justifier
8091b108b8bSchristos>>>>0x25	byte		5	multitap
8101b108b8bSchristos>>>0x18		lelong		>0x43
8111b108b8bSchristos>>>>0x40	leshort		!0
8121b108b8bSchristos>>>>>0x40	lestring16	x	\b, metadata: "%s"
8131b108b8bSchristos>>0x17		byte		&0x40   \b, ROM:
814*4c89978fSchristos>>>(0x18.l-26)	lelong		x	CRC32 %#08x
8151b108b8bSchristos>>>(0x18.l-23)	string		x	"%s"
8161b108b8bSchristos
8172e1c341aSchristos# Type: scummVM savegame files
8182e1c341aSchristos# From: Sven Hartge <debian@ds9.argh.org>
8192e1c341aSchristos0	string	SCVM	ScummVM savegame
8202e1c341aSchristos>12	string	>\0	"%s"
821b04dc002Schristos
822b04dc002Schristos#------------------------------------------------------------------------------
823b04dc002Schristos# Nintendo GameCube / Wii file formats.
824b04dc002Schristos#
825b04dc002Schristos
826b04dc002Schristos# Type: Nintendo GameCube/Wii common disc header data.
827b04dc002Schristos# From: David Korth <gerbilsoft@gerbilsoft.com>
828c3ff5af2Schristos# Reference: https://wiibrew.org/wiki/Wii_Disc
829b04dc002Schristos0	name	nintendo-gcn-disc-common
830b04dc002Schristos>0x20	string	x	"%.64s"
831b04dc002Schristos>0x00	string	x	(%.6s
832b04dc002Schristos>0x06	byte	>0
833b04dc002Schristos>>0x06	byte	1	\b, Disc 2
834b04dc002Schristos>>0x06	byte	2	\b, Disc 3
835b04dc002Schristos>>0x06	byte	3	\b, Disc 4
836b04dc002Schristos>0x07	byte	x	\b, Rev.%02u)
837b13ade61Schristos>0x18	belong	0x5D1C9EA3
838b13ade61Schristos>>0x60	beshort	0x0101	\b (Unencrypted)
839cdf4124cSchristos>0x200	string	NKIT	\b (NKit compressed)
840cdf4124cSchristos
841b04dc002Schristos
842b04dc002Schristos# Type: Nintendo GameCube disc image
843b04dc002Schristos# From: David Korth <gerbilsoft@gerbilsoft.com>
844c3ff5af2Schristos# Reference: https://wiibrew.org/wiki/Wii_Disc
845b04dc002Schristos0x1C	belong	0xC2339F3D	Nintendo GameCube disc image:
846b13ade61Schristos!:mime	application/x-gamecube-rom
847b04dc002Schristos>0	use	nintendo-gcn-disc-common
848b04dc002Schristos
849b04dc002Schristos# Type: Nintendo GameCube embedded disc image
850b04dc002Schristos# Commonly found on demo discs.
851b04dc002Schristos# From: David Korth <gerbilsoft@gerbilsoft.com>
852b04dc002Schristos# Reference: http://hitmen.c02.at/files/yagcd/yagcd/index.html#idx14.8
853b04dc002Schristos0		belong	0xAE0F38A2
854b04dc002Schristos>0x0C		belong	0x00100000
855b04dc002Schristos>>(8.L+0x1C)	belong	0xC2339F3D	Nintendo GameCube embedded disc image:
856b13ade61Schristos!:mime	application/x-gamecube-rom
857b04dc002Schristos>>>(8.L)	use	nintendo-gcn-disc-common
858b04dc002Schristos
859b04dc002Schristos# Type: Nintendo Wii disc image
860b04dc002Schristos# From: David Korth <gerbilsoft@gerbilsoft.com>
861c3ff5af2Schristos# Reference: https://wiibrew.org/wiki/Wii_Disc
862b04dc002Schristos0x18	belong	0x5D1C9EA3	Nintendo Wii disc image:
863b04dc002Schristos>0	use	nintendo-gcn-disc-common
864b04dc002Schristos
865b04dc002Schristos# Type: Nintendo Wii disc image (WBFS format)
866b04dc002Schristos# From: David Korth <gerbilsoft@gerbilsoft.com>
867c3ff5af2Schristos# Reference: https://wiibrew.org/wiki/Wii_Disc
868b04dc002Schristos0	string	WBFS
869b04dc002Schristos>0x218	belong	0x5D1C9EA3	Nintendo Wii disc image (WBFS format):
870b13ade61Schristos!:mime	application/x-wii-rom
871b04dc002Schristos>>0x200	use	nintendo-gcn-disc-common
872b04dc002Schristos
873b04dc002Schristos# Type: Nintendo GameCube/Wii disc image (CISO format)
874b04dc002Schristos# NOTE: This is NOT the same as Compact ISO or PSP CISO,
875b04dc002Schristos# though it has the same magic number.
876b04dc002Schristos0		string	CISO
877b04dc002Schristos# Other fields are used to determine what type of CISO this is:
878b04dc002Schristos# - 0x04 == 0x00200000: GameCube/Wii CISO (block_size)
879b04dc002Schristos# - 0x10 == 0x00000800: PSP CISO (ISO-9660 sector size)
880b04dc002Schristos# - None of the above: Compact ISO.
881b04dc002Schristos>4		lelong	0x200000
882b04dc002Schristos>>8		byte	1
883b04dc002Schristos>>>0x801C	belong	0xC2339F3D	Nintendo GameCube disc image (CISO format):
884b13ade61Schristos!:mime	application/x-wii-rom
885b04dc002Schristos>>>>0x8000	use	nintendo-gcn-disc-common
886b04dc002Schristos>>>0x8018	belong	0x5D1C9EA3	Nintendo Wii disc image (CISO format):
887b13ade61Schristos!:mime	application/x-wii-rom
888b04dc002Schristos>>>>0x8000	use	nintendo-gcn-disc-common
889b04dc002Schristos
890b04dc002Schristos# Type: Nintendo GameCube/Wii disc image (GCZ format)
891b04dc002Schristos# Due to zlib compression, we can't get the actual disc information.
892b04dc002Schristos0	lelong	0xB10BC001
893b04dc002Schristos>4	lelong	0		Nintendo GameCube disc image (GCZ format)
894b13ade61Schristos!:mime	application/x-gamecube-rom
895b04dc002Schristos>4	lelong	1		Nintendo Wii disc image (GCZ format)
896b13ade61Schristos!:mime	application/x-wii-rom
897b13ade61Schristos>4	default	x		Nintendo GameCube/Wii disc image (GCZ format)
898b04dc002Schristos
899b04dc002Schristos# Type: Nintendo GameCube/Wii disc image (WDF format)
900b04dc002Schristos0		string	WII\001DISC
901b04dc002Schristos>8		belong	1
902b04dc002Schristos# WDFv1
903b04dc002Schristos>>0x54		belong	0xC2339F3D	Nintendo GameCube disc image (WDFv1 format):
904b13ade61Schristos!:mime	application/x-gamecube-rom
905b04dc002Schristos>>>0x38		use	nintendo-gcn-disc-common
906b04dc002Schristos>>0x58		belong	0x5D1C9EA3	Nintendo Wii disc image (WDFv1 format):
907b13ade61Schristos!:mime	application/x-wii-rom
908b04dc002Schristos>>>0x38		use	nintendo-gcn-disc-common
909b04dc002Schristos>8		belong	2
910b04dc002Schristos# WDFv2
911b04dc002Schristos>>(12.L+0x1C)	belong	0xC2339F3D	Nintendo GameCube disc image (WDFv2 format):
912b13ade61Schristos!:mime	application/x-gamecube-rom
913b04dc002Schristos>>>(12.L)	use	nintendo-gcn-disc-common
914b04dc002Schristos>>(12.L+0x18)	belong	0x5D1C9EA3	Nintendo Wii disc image (WDFv2 format):
915b13ade61Schristos!:mime	application/x-wii-rom
916b04dc002Schristos>>>(12.L)	use	nintendo-gcn-disc-common
917b04dc002Schristos
918b04dc002Schristos# Type: Nintendo GameCube/Wii disc image (WIA format)
919b04dc002Schristos0	string	WIA\001	Nintendo
920b04dc002Schristos>0x48	belong	1	GameCube
921b13ade61Schristos!:mime	application/x-gamecube-rom
922b04dc002Schristos>0x48	belong	2	Wii
923b13ade61Schristos!:mime	application/x-wii-rom
924b13ade61Schristos>0x48	default	x	GameCube/Wii
925b04dc002Schristos>0x48	belong	x	disc image (WIA format):
926b04dc002Schristos>>0x58	use	nintendo-gcn-disc-common
927b04dc002Schristos
928b13ade61Schristos# Type: Nintendo GameCube/Wii disc image (with SDK header)
929b13ade61Schristos# From: David Korth <gerbilsoft@gerbilsoft.com>
930c3ff5af2Schristos# Reference: https://wiibrew.org/wiki/Wii_Disc
931b13ade61Schristos0		belong	0xFFFF0000
932b13ade61Schristos>0x18		belong	0x00000000
933b13ade61Schristos>>0x1C		belong	0x00000000
934b13ade61Schristos>>>0x8018	belong	0x5D1C9EA3	Nintendo Wii SDK disc image:
935c3ff5af2Schristos!:mime	application/x-wii-rom
936b13ade61Schristos>>>>0x8000	use	nintendo-gcn-disc-common
937b13ade61Schristos>>>0x801C	belong	0xC2339F3D	Nintendo GameCube SDK disc image:
938c3ff5af2Schristos!:mime	application/x-gamecube-rom
939b13ade61Schristos>>>>0x8000	use	nintendo-gcn-disc-common
940b13ade61Schristos
941*4c89978fSchristos# Type: Nintendo GameCube/Wii disc image (RVZ format)
942*4c89978fSchristos0	string		RVZ\001	Nintendo
943*4c89978fSchristos>0x48	belong		1	GameCube
944*4c89978fSchristos!:mime	application/x-gamecube-rom
945*4c89978fSchristos>0x48	belong		2	Wii
946*4c89978fSchristos!:mime	application/x-wii-rom
947*4c89978fSchristos>0x48	default		x	GameCube/Wii
948*4c89978fSchristos>0x48	belong		x	disc image (RVZ format):
949*4c89978fSchristos>>0x58	use		nintendo-gcn-disc-common
950*4c89978fSchristos
951b04dc002Schristos#------------------------------------------------------------------------------
952b04dc002Schristos# Nintendo 3DS file formats.
953b04dc002Schristos#
954b04dc002Schristos
955b04dc002Schristos# Type: Nintendo 3DS "NCSD" image. (game cards and eMMC)
956b04dc002Schristos# From: David Korth <gerbilsoft@gerbilsoft.com>
957b04dc002Schristos# Reference: https://www.3dbrew.org/wiki/NCSD
958b04dc002Schristos0x100		string		NCSD
959b04dc002Schristos>0x118		lequad		0		Nintendo 3DS Game Card image
960b04dc002Schristos# NCCH header for partition 0. (game data)
961b04dc002Schristos>>0x1150	string		>\0	\b: "%.16s"
962b04dc002Schristos>>0x312		byte		x	(Rev.%02u)
963b04dc002Schristos>>0x118C	byte		2	(New3DS only)
964b04dc002Schristos>>0x18D		byte		0		(inner device)
965b04dc002Schristos>>0x18D		byte		1		(Card1)
966b04dc002Schristos>>0x18D		byte		2		(Card2)
967b04dc002Schristos>>0x18D		byte		3		(extended device)
968b04dc002Schristos>0x118		bequad		0x0102020202000000	Nintendo 3DS eMMC dump (Old3DS)
969b04dc002Schristos>0x118		bequad		0x0102020203000000	Nintendo 3DS eMMC dump (New3DS)
970b04dc002Schristos
971b04dc002Schristos# Nintendo 3DS version code.
972b04dc002Schristos# Reference: https://www.3dbrew.org/wiki/Titles
973b04dc002Schristos# Format: leshort containing three fields:
974b04dc002Schristos# - 6-bit: Major
975b04dc002Schristos# - 6-bit: Minor
976b04dc002Schristos# - 4-bit: Revision
977b04dc002Schristos# NOTE: Only supporting major/minor versions from 0-15 right now.
978b04dc002Schristos# NOTE: Should be prefixed with "v".
979b04dc002Schristos0	name	nintendo-3ds-version-code
980b04dc002Schristos# Raw version.
981b04dc002Schristos>0	leshort	x	\b%u,
982b04dc002Schristos# Major version.
983b04dc002Schristos>0	leshort&0xFC00	0x0000	0
984b04dc002Schristos>0	leshort&0xFC00	0x0400	1
985b04dc002Schristos>0	leshort&0xFC00	0x0800	2
986b04dc002Schristos>0	leshort&0xFC00	0x0C00	3
987b04dc002Schristos>0	leshort&0xFC00	0x1000	4
988b04dc002Schristos>0	leshort&0xFC00	0x1400	5
989b04dc002Schristos>0	leshort&0xFC00	0x1800	6
990b04dc002Schristos>0	leshort&0xFC00	0x1C00	7
991b04dc002Schristos>0	leshort&0xFC00	0x2000	8
992b04dc002Schristos>0	leshort&0xFC00	0x2400	9
993b04dc002Schristos>0	leshort&0xFC00	0x2800	10
994b04dc002Schristos>0	leshort&0xFC00	0x2C00	11
995b04dc002Schristos>0	leshort&0xFC00	0x3000	12
996b04dc002Schristos>0	leshort&0xFC00	0x3400	13
997b04dc002Schristos>0	leshort&0xFC00	0x3800	14
998b04dc002Schristos>0	leshort&0xFC00	0x3C00	15
999b04dc002Schristos# Minor version.
1000b04dc002Schristos>0	leshort&0x03F0	0x0000	\b.0
1001b04dc002Schristos>0	leshort&0x03F0	0x0010	\b.1
1002b04dc002Schristos>0	leshort&0x03F0	0x0020	\b.2
1003b04dc002Schristos>0	leshort&0x03F0	0x0030	\b.3
1004b04dc002Schristos>0	leshort&0x03F0	0x0040	\b.4
1005b04dc002Schristos>0	leshort&0x03F0	0x0050	\b.5
1006b04dc002Schristos>0	leshort&0x03F0	0x0060	\b.6
1007b04dc002Schristos>0	leshort&0x03F0	0x0070	\b.7
1008b04dc002Schristos>0	leshort&0x03F0	0x0080	\b.8
1009b04dc002Schristos>0	leshort&0x03F0	0x0090	\b.9
1010b04dc002Schristos>0	leshort&0x03F0	0x00A0	\b.10
1011b04dc002Schristos>0	leshort&0x03F0	0x00B0	\b.11
1012b04dc002Schristos>0	leshort&0x03F0	0x00C0	\b.12
1013b04dc002Schristos>0	leshort&0x03F0	0x00D0	\b.13
1014b04dc002Schristos>0	leshort&0x03F0	0x00E0	\b.14
1015b04dc002Schristos>0	leshort&0x03F0	0x00F0	\b.15
1016b04dc002Schristos# Revision.
1017b04dc002Schristos>0	leshort&0x000F	x	\b.%u
1018b04dc002Schristos
1019b04dc002Schristos# Type: Nintendo 3DS "NCCH" container.
1020b04dc002Schristos# https://www.3dbrew.org/wiki/NCCH
1021b04dc002Schristos0x100		string	NCCH	Nintendo 3DS
1022b04dc002Schristos>0x18D		byte&2	0	File Archive (CFA)
1023b04dc002Schristos>0x18D		byte&2	2	Executable Image (CXI)
1024b04dc002Schristos>0x150		string	>\0	\b: "%.16s"
1025b04dc002Schristos>0x18D		byte	0x05
1026b04dc002Schristos>>0x10E		leshort	x	(Old3DS System Update v
1027b04dc002Schristos>>0x10E		use	nintendo-3ds-version-code
1028b04dc002Schristos>>0x10E		leshort	x	\b)
1029b04dc002Schristos>0x18D		byte	0x15
1030b04dc002Schristos>>0x10E		leshort	x	(New3DS System Update v
1031b04dc002Schristos>>0x10E		use	nintendo-3ds-version-code
1032b04dc002Schristos>>0x10E		leshort	x	\b)
1033b04dc002Schristos>0x18D		byte	!0x05
1034b04dc002Schristos>>0x18D		byte	!0x15
1035b04dc002Schristos>>>0x112	byte	x	(v
1036b04dc002Schristos>>>0x112	use	nintendo-3ds-version-code
1037b04dc002Schristos>>>0x112	byte	x	\b)
1038b04dc002Schristos>0x18C		byte	2	(New3DS only)
1039b04dc002Schristos
1040b04dc002Schristos# Type: Nintendo 3DS "SMDH" file. (application description)
1041b04dc002Schristos# From: David Korth <gerbilsoft@gerbilsoft.com>
1042b04dc002Schristos# Reference: https://3dbrew.org/wiki/SMDH
1043b04dc002Schristos0		string		SMDH		Nintendo 3DS SMDH file
1044b04dc002Schristos>0x208		leshort		!0
1045b04dc002Schristos>>0x208		lestring16	x		\b: "%.128s"
1046b04dc002Schristos>>0x388		leshort		!0
1047b04dc002Schristos>>>0x388	lestring16	x		by %.128s
1048b04dc002Schristos>0x208		leshort		0
1049b04dc002Schristos>>0x008		leshort		!0
1050b04dc002Schristos>>>0x008	lestring16	x		\b: "%.128s"
1051b04dc002Schristos>>>0x188	leshort		!0
1052b04dc002Schristos>>>>0x188	lestring16	x		by %.128s
1053b04dc002Schristos
1054b04dc002Schristos# Type: Nintendo 3DS Homebrew Application.
1055b04dc002Schristos# From: David Korth <gerbilsoft@gerbilsoft.com>
105655287a1bSchristos# Reference: https://3dbrew.org/wiki/3DSX_Format
1057b04dc002Schristos0	string	3DSX	Nintendo 3DS Homebrew Application (3DSX)
1058b04dc002Schristos
10596449c992Schristos# Type: Nintendo 3DS Banner Model Data.
10606449c992Schristos# From: David Korth <gerbilsoft@gerbilsoft.com>
10616449c992Schristos# Reference: https://3dbrew.org/wiki/CBMD
10626449c992Schristos0	string	CBMD\0\0\0\0	Nintendo 3DS Banner Model Data
10636449c992Schristos
1064b04dc002Schristos#------------------------------------------------------------------------------
1065b04dc002Schristos# a7800: file(1) magic for the Atari 7800 raw ROM format.
1066b04dc002Schristos# From: David Korth <gerbilsoft@gerbilsoft.com>
1067b04dc002Schristos# Reference: https://sites.google.com/site/atari7800wiki/a78-header
1068b04dc002Schristos
1069b04dc002Schristos0	byte	>0
1070b04dc002Schristos>0	byte	<3
1071b04dc002Schristos>>1	string	ATARI7800	Atari 7800 ROM image
1072b13ade61Schristos!:mime	application/x-atari-7800-rom
1073b04dc002Schristos>>>0x11	string	>\0	\b: "%.32s"
1074b04dc002Schristos# Display type.
1075b04dc002Schristos>>>0x39	byte	0	(NTSC)
1076b04dc002Schristos>>>0x39	byte	1	(PAL)
1077b04dc002Schristos>>>0x36	byte&1	1	(POKEY)
1078b04dc002Schristos
1079b04dc002Schristos#------------------------------------------------------------------------------
1080b04dc002Schristos# vectrex: file(1) magic for the GCE Vectrex raw ROM format.
1081b04dc002Schristos# From: David Korth <gerbilsoft@gerbilsoft.com>
1082b04dc002Schristos# Reference: http://www.playvectrex.com/designit/chrissalo/hello1.htm
1083b04dc002Schristos#
1084b04dc002Schristos# NOTE: Title is terminated with 0x80, not 0.
1085b04dc002Schristos# The header is terminated with a 0, so that will
1086b04dc002Schristos# terminate the title as well.
1087b04dc002Schristos#
1088b04dc002Schristos0	string	g\ GCE	Vectrex ROM image
1089b04dc002Schristos>0x11	string	>\0	\b: "%.16s"
1090b04dc002Schristos
1091b04dc002Schristos#------------------------------------------------------------------------------
1092b04dc002Schristos# amiibo: file(1) magic for Nintendo amiibo NFC dumps.
1093b04dc002Schristos# From: David Korth <gerbilsoft@gerbilsoft.com>
1094b04dc002Schristos# Reference: https://www.3dbrew.org/wiki/Amiibo
1095b04dc002Schristos0x00		byte	0x04
1096b04dc002Schristos>0x0A		beshort	0x0FE0
1097b04dc002Schristos>>0x0C		belong	0xF110FFEE
1098b04dc002Schristos>>>0x208	beshort	0x0100
1099b04dc002Schristos>>>>0x020A	byte	0x0F
1100b04dc002Schristos>>>>>0x020C	bequad	0x000000045F000000
1101b04dc002Schristos>>>>>>0x5B	byte	0x02
1102b04dc002Schristos>>>>>>>0x54	belong	x	Nintendo amiibo NFC dump - amiibo ID: %08X-
1103b04dc002Schristos>>>>>>>0x58	belong	x	\b%08X
1104cdf4124cSchristos
1105cdf4124cSchristos#------------------------------------------------------------------------------
1106cdf4124cSchristos# Type: Nintendo Switch XCI (Game Cartridge Image)
1107cdf4124cSchristos# From: Benjamin Lowry <ben@ben.gmbh>
1108cdf4124cSchristos# Reference: https://switchbrew.org/wiki/Gamecard_Format
1109cdf4124cSchristos0x100		string	HEAD
1110cdf4124cSchristos>0x10D		byte	0xFA	Nintendo Switch cartridge image (XCI), 1GB
1111cdf4124cSchristos>0x10D		byte	0xF8	Nintendo Switch cartridge image (XCI), 2GB
1112cdf4124cSchristos>0x10D		byte	0xF0	Nintendo Switch cartridge image (XCI), 4GB
1113cdf4124cSchristos>0x10D		byte	0xE0	Nintendo Switch cartridge image (XCI), 8GB
1114cdf4124cSchristos>0x10D		byte	0xE1	Nintendo Switch cartridge image (XCI), 16GB
1115cdf4124cSchristos>0x10D		byte	0xE2	Nintendo Switch cartridge image (XCI), 32GB
1116cdf4124cSchristos
1117cdf4124cSchristos#------------------------------------------------------------------------------
1118cdf4124cSchristos# Type: Nintendo Switch Executable
1119cdf4124cSchristos# From: Benjamin Lowry <ben@ben.gmbh>
1120cdf4124cSchristos# Reference: https://switchbrew.org/wiki/NSO
1121cdf4124cSchristos0x00		string	NSO0	Nintendo Switch executable (NSO)
1122cdf4124cSchristos
1123cdf4124cSchristos#------------------------------------------------------------------------------
1124cdf4124cSchristos# Type: Nintendo Switch PFS0
1125cdf4124cSchristos# From: Benjamin Lowry <ben@ben.gmbh>
1126cdf4124cSchristos# Reference: https://switchbrew.org/wiki/NCA_Format#PFS0
1127cdf4124cSchristos0x00		string	PFS0	Nintendo Switch partition filesystem (PFS0)
1128cdf4124cSchristos>0x04		ulelong	x	\b, %d files
1129cdf4124cSchristos
1130cdf4124cSchristos#------------------------------------------------------------------------------
1131cdf4124cSchristos# amiibo: file(1) magic for Nintendo Badge Arcade files.
1132cdf4124cSchristos# From: David Korth <gerbilsoft@gerbilsoft.com>
1133cdf4124cSchristos# References:
1134cdf4124cSchristos# - https://github.com/GerbilSoft/rom-properties/issues/92
1135cdf4124cSchristos# - https://github.com/CaitSith2/BadgeArcadeTool
1136cdf4124cSchristos# - https://github.com/TheMachinumps/Advanced-badge-editor
1137cdf4124cSchristos
1138cdf4124cSchristos# PRBS: Individual badge and/or mega badge.
1139cdf4124cSchristos0		string	PRBS
1140cdf4124cSchristos>0x44		byte	>0x20	Nintendo Badge Arcade
1141cdf4124cSchristos>>0xB8		ulelong	<2
1142cdf4124cSchristos>>>0xBC		ulelong	<2	badge:
1143cdf4124cSchristos>>>0xBC		ulelong	>1	Mega Badge
1144cdf4124cSchristos>>>>0xB8	ulelong	x	(%ux
1145cdf4124cSchristos>>>>0xBC	ulelong	x	\b%u):
1146cdf4124cSchristos>>0xB8		ulelong	>1	Mega Badge
1147cdf4124cSchristos>>>0xB8		ulelong	x	(%ux
1148cdf4124cSchristos>>>0xBC		ulelong	x	\b%u):
1149cdf4124cSchristos>0x44		string	x	"%s"
1150cdf4124cSchristos>0x3C		ulelong	x	\b, badge ID: %u
1151cdf4124cSchristos>0x74		byte	>0x20
1152cdf4124cSchristos>>0x74		string	x	\b, set: "%s"
1153cdf4124cSchristos>0xA8		ulelong	!0xFFFFFFFF
1154cdf4124cSchristos>>0xA8		ulelong	x	\b, launch title ID: %08X
1155cdf4124cSchristos>>0xA4		ulelong	x	\b-%08X
1156cdf4124cSchristos
1157cdf4124cSchristos# CABS: Badge set.
1158cdf4124cSchristos0	string	CABS
1159cdf4124cSchristos>0x2C	byte	>0x20	Nintendo Badge Arcade badge set:
1160cdf4124cSchristos>>0x2C	string	x	"%.48s"
1161cdf4124cSchristos>>0x24	ulelong	x	\b, set ID: %u
11626449c992Schristos
11636449c992Schristos#------------------------------------------------------------------------------
11646449c992Schristos# sufami: file(1) magic for Sufami Turbo ROM images.
11656449c992Schristos# From: David Korth <gerbilsoft@gerbilsoft.com>
11666449c992Schristos# References:
11676449c992Schristos# - https://problemkaputt.de/fullsnes.htm#snescartsufamiturbominicartridgeadaptor
11686449c992Schristos0	string		BANDAI\ SFC-ADX
11696449c992Schristos>0x10	string		!SFC-ADX\ BACKUP	Sufami Turbo ROM image:
11706449c992Schristos>>0x10	string/T	x	"%.14s"
11716449c992Schristos>>0x30	byte		x	\b, ID %02X
11726449c992Schristos>>0x31	byte		x	\b%02X
11736449c992Schristos>>0x32	byte		x	\b%02X
11746449c992Schristos>>0x33	ubyte		>0	\b, series index %u
11756449c992Schristos>>0x34	ubyte		0	[SlowROM]
11766449c992Schristos>>0x34	ubyte		1	[FastROM]
11776449c992Schristos>>0x35	ubyte		1	[SRAM]
11786449c992Schristos>>0x35	ubyte		3	[Special]
1179