xref: /freebsd/contrib/file/magic/Magdir/console (revision 8ddb146abcdf061be9f2c0db7e391697dafad85c)
1
2#------------------------------------------------------------------------------
3# $File: console,v 1.68 2022/05/14 20:04:43 christos Exp $
4# Console game magic
5# Toby Deshane <hac@shoelace.digivill.net>
6
7# ines: file(1) magic for Marat's iNES Nintendo Entertainment System ROM dump format
8# Updated by David Korth <gerbilsoft@gerbilsoft.com>
9# References:
10# - https://wiki.nesdev.com/w/index.php/INES
11# - https://wiki.nesdev.com/w/index.php/NES_2.0
12
13# Common header for iNES, NES 2.0, and Wii U iNES.
140	name		nes-rom-image-ines
15>7	byte&0x0C	=0x8		(NES 2.0)
16>4	byte		x		\b: %ux16k PRG
17>5	byte		x		\b, %ux8k CHR
18>6	byte&0x08	=0x8		[4-Scr]
19>6	byte&0x09	=0x0		[H-mirror]
20>6	byte&0x09	=0x1		[V-mirror]
21>6	byte&0x02	=0x2		[SRAM]
22>6	byte&0x04	=0x4		[Trainer]
23>7	byte&0x03	=0x2		[PC10]
24>7	byte&0x03	=0x1		[VS]
25>>7	byte&0x0C	=0x8
26# NES 2.0: VS PPU
27>>>13	byte&0x0F	=0x0		\b, RP2C03B
28>>>13	byte&0x0F	=0x1		\b, RP2C03G
29>>>13	byte&0x0F	=0x2		\b, RP2C04-0001
30>>>13	byte&0x0F	=0x3		\b, RP2C04-0002
31>>>13	byte&0x0F	=0x4		\b, RP2C04-0003
32>>>13	byte&0x0F	=0x5		\b, RP2C04-0004
33>>>13	byte&0x0F	=0x6		\b, RP2C03B
34>>>13	byte&0x0F	=0x7		\b, RP2C03C
35>>>13	byte&0x0F	=0x8		\b, RP2C05-01
36>>>13	byte&0x0F	=0x9		\b, RP2C05-02
37>>>13	byte&0x0F	=0xA		\b, RP2C05-03
38>>>13	byte&0x0F	=0xB		\b, RP2C05-04
39>>>13	byte&0x0F	=0xC		\b, RP2C05-05
40# TODO: VS protection hardware?
41>>7	byte		x		\b]
42# NES 2.0-specific flags.
43>7	byte&0x0C	=0x8
44>>12	byte&0x03	=0x0		[NTSC]
45>>12	byte&0x03	=0x1		[PAL]
46>>12	byte&0x02	=0x2		[NTSC+PAL]
47
48# Standard iNES ROM header.
490	string		NES\x1A		NES ROM image (iNES)
50!:mime	application/x-nes-rom
51>0	use		nes-rom-image-ines
52
53# Wii U Virtual Console iNES ROM header.
540	belong		0x4E455300	NES ROM image (Wii U Virtual Console)
55!:mime	application/x-nes-rom
56>0	use		nes-rom-image-ines
57
58#------------------------------------------------------------------------------
59# unif: file(1) magic for UNIF-format Nintendo Entertainment System ROM images
60# Reference: https://wiki.nesdev.com/w/index.php/UNIF
61# From: David Korth <gerbilsoft@gerbilsoft.com>
62#
63# NOTE: The UNIF format uses chunks instead of a fixed header,
64# so most of the data isn't easily parseable.
65#
660	string	UNIF
67>4	lelong	<16	NES ROM image (UNIF v%d format)
68!:mime	application/x-nes-rom
69
70#------------------------------------------------------------------------------
71# fds: file(1) magic for Famciom Disk System disk images
72# Reference: https://wiki.nesdev.com/w/index.php/Family_Computer_Disk_System#.FDS_format
73# From: David Korth <gerbilsoft@gerbilsoft.com>
74# TODO: Check "Disk info block" and get info from that in addition to the optional header.
75
76# Disk info block. (block 1)
770	name	nintendo-fds-disk-info-block
78>23	byte	!1		FMC-
79>23	byte	1		FSC-
80>16	string	x		\b%.3s
81>15	ubyte	x		\b, mfr %02X
82>20	ubyte	x		(Rev.%02u)
83
84# Headered version.
850	string	FDS\x1A
86>0x11	string	*NINTENDO-HVC*	Famicom Disk System disk image:
87!:mime	application/x-fds-disk
88>>0x10	use	nintendo-fds-disk-info-block
89>4	byte	1	(%u side)
90>4	byte	!1	(%u sides)
91
92# Unheadered version.
931	string	*NINTENDO-HVC*	Famicom Disk System disk image:
94!:mime	application/x-fds-disk
95>0	use	nintendo-fds-disk-info-block
96
97#------------------------------------------------------------------------------
98# tnes: file(1) magic for TNES-format Nintendo Entertainment System ROM images
99# Used by Nintendo 3DS NES Virtual Console games.
100# From: David Korth <gerbilsoft@gerbilsoft.com>
101#
1020		string	TNES	NES ROM image (Nintendo 3DS Virtual Console)
103!:mime		application/x-nes-rom
104>4		byte	100	\b: FDS,
105>>0x2010	use	nintendo-fds-disk-info-block
106>4		byte	!100	\b: TNES mapper %u
107>>5	byte		x		\b, %ux8k PRG
108>>6	byte		x		\b, %ux8k CHR
109>>7	byte&0x08	=1		[WRAM]
110>>8	byte&0x09	=1		[H-mirror]
111>>8	byte&0x09	=2		[V-mirror]
112>>8	byte&0x02	=3		[VRAM]
113
114#------------------------------------------------------------------------------
115# gameboy: file(1) magic for the Nintendo (Color) Gameboy raw ROM format
116# Reference: http://gbdev.gg8.se/wiki/articles/The_Cartridge_Header
117#
1180x104		bequad		0xCEED6666CC0D000B	Game Boy ROM image
119# TODO: application/x-gameboy-color-rom for GBC.
120!:mime		application/x-gameboy-rom
121>0x143		byte&0x80	0x80
122>>0x134		string		>\0			\b: "%.15s"
123>0x143		byte&0x80	!0x80
124>>0x134		string		>\0			\b: "%.16s"
125>0x14c		byte		x			(Rev.%02u)
126
127# Machine type. (SGB, CGB, SGB+CGB)
128# Old licensee code 0x33 is required for SGB, but not CGB.
129>0x14b		byte		0x33
130>>0x146		byte		0x03
131>>>0x143	byte&0x80	0x80	[SGB+CGB]
132>>>0x143	byte&0x80	!0x80	[SGB]
133>>0x146		byte		!0x03
134>>>0x143	byte&0xC0	0x80	[CGB]
135>>>0x143	byte&0xC0	0xC0	[CGB ONLY]
136>0x14b		byte		!0x33
137>>0x143		byte&0xC0	0x80	[CGB]
138>>0x143		byte&0xC0	0xC0	[CGB ONLY]
139
140# Mapper.
141>0x147 byte 0x00  [ROM ONLY]
142>0x147 byte 0x01  [MBC1]
143>0x147 byte 0x02  [MBC1+RAM]
144>0x147 byte 0x03  [MBC1+RAM+BATT]
145>0x147 byte 0x05  [MBC2]
146>0x147 byte 0x06  [MBC2+BATTERY]
147>0x147 byte 0x08  [ROM+RAM]
148>0x147 byte 0x09  [ROM+RAM+BATTERY]
149>0x147 byte 0x0B  [MMM01]
150>0x147 byte 0x0C  [MMM01+SRAM]
151>0x147 byte 0x0D  [MMM01+SRAM+BATT]
152>0x147 byte 0x0F  [MBC3+TIMER+BATT]
153>0x147 byte 0x10  [MBC3+TIMER+RAM+BATT]
154>0x147 byte 0x11  [MBC3]
155>0x147 byte 0x12  [MBC3+RAM]
156>0x147 byte 0x13  [MBC3+RAM+BATT]
157>0x147 byte 0x19  [MBC5]
158>0x147 byte 0x1A  [MBC5+RAM]
159>0x147 byte 0x1B  [MBC5+RAM+BATT]
160>0x147 byte 0x1C  [MBC5+RUMBLE]
161>0x147 byte 0x1D  [MBC5+RUMBLE+SRAM]
162>0x147 byte 0x1E  [MBC5+RUMBLE+SRAM+BATT]
163>0x147 byte 0xFC  [Pocket Camera]
164>0x147 byte 0xFD  [Bandai TAMA5]
165>0x147 byte 0xFE  [Hudson HuC-3]
166>0x147 byte 0xFF  [Hudson HuC-1]
167
168# ROM size.
169>0x148 byte 0     \b, ROM: 256Kbit
170>0x148 byte 1     \b, ROM: 512Kbit
171>0x148 byte 2     \b, ROM: 1Mbit
172>0x148 byte 3     \b, ROM: 2Mbit
173>0x148 byte 4     \b, ROM: 4Mbit
174>0x148 byte 5     \b, ROM: 8Mbit
175>0x148 byte 6     \b, ROM: 16Mbit
176>0x148 byte 7     \b, ROM: 32Mbit
177>0x148 byte 0x52  \b, ROM: 9Mbit
178>0x148 byte 0x53  \b, ROM: 10Mbit
179>0x148 byte 0x54  \b, ROM: 12Mbit
180
181# RAM size.
182>0x149 byte 1     \b, RAM: 16Kbit
183>0x149 byte 2     \b, RAM: 64Kbit
184>0x149 byte 3     \b, RAM: 256Kbit
185>0x149 byte 4     \b, RAM: 1Mbit
186>0x149 byte 5     \b, RAM: 512Kbit
187
188#------------------------------------------------------------------------------
189# genesis: file(1) magic for various Sega Mega Drive / Genesis ROM image and disc formats
190# Updated by David Korth <gerbilsoft@gerbilsoft.com>
191# References:
192# - https://www.retrodev.com/segacd.html
193# - http://devster.monkeeh.com/sega/32xguide1.txt
194#
195
196# Common Sega Mega Drive header format.
197# FIXME: Name fields are 48 bytes, but have spaces for padding instead of 00s.
1980		name	sega-mega-drive-header
199# ROM title. (Use domestic if present; if not, use international.)
200>0x120		byte	>0x20
201>>0x120		string	>\0	\b: "%.16s"
202>0x120		byte	<0x21
203>>0x150		string	>\0	\b: "%.16s"
204# Other information.
205>0x180		string	>\0	(%.14s
206>>0x110		string  >\0	\b, %.16s
207>0x180		byte	0
208>>0x110		string  >\0	(%.16s
209>0		byte	x	\b)
210
211# TODO: Check for 32X CD?
212# Sega Mega CD disc images: 2048-byte sectors.
2130	string	SEGADISCSYSTEM\ \ 	Sega Mega CD disc image
214!:mime	application/x-sega-cd-rom
215>0	use	sega-mega-drive-header
216>0	byte	x			\b, 2048-byte sectors
2170	string	SEGABOOTDISC\ \ \ \ 	Sega Mega CD disc image
218!:mime	application/x-sega-cd-rom
219>0	use	sega-mega-drive-header
220>0	byte	x			\b, 2048-byte sectors
221# Sega Mega CD disc images: 2352-byte sectors.
2220x10	string	SEGADISCSYSTEM\ \ 	Sega Mega CD disc image
223!:mime	application/x-sega-cd-rom
224>0x10	use	sega-mega-drive-header
225>0	byte	x			\b, 2352-byte sectors
2260x10	string	SEGABOOTDISC\ \ \ \ 	Sega Mega CD disc image
227!:mime	application/x-sega-cd-rom
228>0x10	use	sega-mega-drive-header
229>0	byte	x			\b, 2352-byte sectors
230
231# Sega Mega Drive: Identify the system ID.
2320x100		string	SEGA
233>0x3C0		string	MARS\ CHECK\ MODE	Sega 32X ROM image
234!:mime		application/x-genesis-32x-rom
235>>0		use	sega-mega-drive-header
236>0x104		string	\ PICO			Sega Pico ROM image
237!:mime		application/x-sega-pico-rom
238>>0		use	sega-mega-drive-header
239>0x104		string	TOYS\ PICO		Sega Pico ROM image
240!:mime		application/x-sega-pico-rom
241>>0		use	sega-mega-drive-header
242>0x104		string	\ TOYS\ PICO		Sega Pico ROM image
243!:mime		application/x-sega-pico-rom
244>>0		use	sega-mega-drive-header
245>0x104		string	\ IAC			Sega Pico ROM image
246!:mime		application/x-sega-pico-rom
247>>0		use	sega-mega-drive-header
248>0x104		string	\ TERA68K		Sega Teradrive (68K) ROM image
249!:mime		application/x-sega-teradrive-rom
250>>0		use	sega-mega-drive-header
251>0x104		string	\ TERA286		Sega Teradrive (286) ROM image
252!:mime		application/x-sega-teradrive-rom
253>>0		use	sega-mega-drive-header
254>0x180		string	BR			Sega Mega CD Boot ROM image
255!:mime		application/x-genesis-rom
256>>0		use	sega-mega-drive-header
257>0x104		default	x			Sega Mega Drive / Genesis ROM image
258!:mime		application/x-genesis-rom
259>>0		use	sega-mega-drive-header
260
261# Sega Mega Drive: Some ROMs have "SEGA" at 0x101, not 0x100.
2620x100		string	\ SEGA			Sega Mega Drive / Genesis ROM image
263>0		use	sega-mega-drive-header
264
265# Sega Pico ROMs that don't start with "SEGA".
2660x100		string	SAMSUNG\ PICO		Samsung Pico ROM image
267!:mime		application/x-sega-pico-rom
268>0		use	sega-mega-drive-header
2690x100		string	IMA\ IKUNOUJYUKU	Samsung Pico ROM image
270!:mime		application/x-sega-pico-rom
271>0		use	sega-mega-drive-header
2720x100		string	IMA IKUNOJYUKU		Samsung Pico ROM image
273!:mime		application/x-sega-pico-rom
274>0		use	sega-mega-drive-header
275
276# Sega Picture Magic (modified 32X)
2770x100		string	Picture\ Magic
278>0x3C0		string	PICTURE MAGIC-01	Sega 32X ROM image
279!:mime		application/x-genesis-32x-rom
280>>0		use	sega-mega-drive-header
281
282#------------------------------------------------------------------------------
283# genesis: file(1) magic for the Super MegaDrive ROM dump format
284#
285
286# NOTE: Due to interleaving, we can't display anything
287# other than the copier header information.
2880      name    sega-genesis-smd-header
289>0     byte    x       %dx16k blocks
290>2     byte    0       \b, last in series or standalone
291>2     byte    >0      \b, split ROM
292
293# "Sega Genesis" header.
2940x280	string EAGN
295>8	beshort	0xAABB	Sega Mega Drive / Genesis ROM image (SMD format):
296!:mime	application/x-genesis-rom
297>>0	use     sega-genesis-smd-header
298
299# "Sega Mega Drive" header.
3000x280	string EAMG
301>8	beshort	0xAABB	Sega Mega Drive / Genesis ROM image (SMD format):
302!:mime	application/x-genesis-rom
303>>0	use     sega-genesis-smd-header
304
305#------------------------------------------------------------------------------
306# smsgg:  file(1) magic for Sega Master System and Game Gear ROM images
307# Detects all Game Gear and export Sega Master System ROM images,
308# and some Japanese Sega Master System ROM images.
309# From: David Korth <gerbilsoft@gerbilsoft.com>
310# Reference: https://www.smspower.org/Development/ROMHeader
311#
312
313# General SMS header rule.
314# The SMS boot ROM checks the header at three locations.
3150	name	sega-master-system-rom-header
316# Machine type.
317>0x0F	byte&0xF0	0x30	Sega Master System
318!:mime	application/x-sms-rom
319>0x0F	byte&0xF0	0x40	Sega Master System
320!:mime	application/x-sms-rom
321>0x0F	byte&0xF0	0x50	Sega Game Gear
322!:mime	application/x-gamegear-rom
323>0x0F	byte&0xF0	0x60	Sega Game Gear
324!:mime	application/x-gamegear-rom
325>0x0F	byte&0xF0	0x70	Sega Game Gear
326!:mime	application/x-gamegear-rom
327>0x0F	default		x	Sega Master System / Game Gear
328!:mime	application/x-sms-rom
329>0	byte		x	ROM image:
330# Product code.
331>0x0E	byte&0xF0	0x10	1
332>0x0E	byte&0xF0	0x20	2
333>0x0E	byte&0xF0	0x30	3
334>0x0E	byte&0xF0	0x40	4
335>0x0E	byte&0xF0	0x50	5
336>0x0E	byte&0xF0	0x60	6
337>0x0E	byte&0xF0	0x70	7
338>0x0E	byte&0xF0	0x80	8
339>0x0E	byte&0xF0	0x90	9
340>0x0E	byte&0xF0	0xA0	10
341>0x0E	byte&0xF0	0xB0	11
342>0x0E	byte&0xF0	0xC0	12
343>0x0E	byte&0xF0	0xD0	13
344>0x0E	byte&0xF0	0xE0	14
345>0x0E	byte&0xF0	0xF0	15
346# If the product code is 5 digits, we'll need to backspace here.
347>0x0E	byte&0xF0	!0
348>>0x0C	leshort		x	\b%04x
349>0x0E	byte&0xF0	0
350>>0x0C	leshort		x	%04x
351# Revision.
352>0x0E	byte&0x0F	x	(Rev.%02d)
353# ROM size. (Used for the boot ROM checksum routine.)
354>0x0F	byte&0x0F	0x0A	(8 KB)
355>0x0F	byte&0x0F	0x0B	(16 KB)
356>0x0F	byte&0x0F	0x0C	(32 KB)
357>0x0F	byte&0x0F	0x0D	(48 KB)
358>0x0F	byte&0x0F	0x0E	(64 KB)
359>0x0F	byte&0x0F	0x0F	(128 KB)
360>0x0F	byte&0x0F	0x00	(256 KB)
361>0x0F	byte&0x0F	0x01	(512 KB)
362>0x0F	byte&0x0F	0x02	(1 MB)
363
364# SMS/GG header locations.
3650x7FF0	string	TMR\ SEGA
366>0x7FF0	use	sega-master-system-rom-header
3670x3FF0	string	TMR\ SEGA
368>0x3FF0	use	sega-master-system-rom-header
3690x1FF0	string	TMR\ SEGA
370>0x1FF0	use	sega-master-system-rom-header
371
372#------------------------------------------------------------------------------
373# saturn: file(1) magic for the Sega Saturn disc image format.
374# From: David Korth <gerbilsoft@gerbilsoft.com>
375#
376
377# Common Sega Saturn disc header format.
378# NOTE: Title is 112 bytes, but we're only showing 32 due to space padding.
379# TODO: Release date, device information, region code, others?
3800	name	sega-saturn-disc-header
381>0x60	string	>\0	\b: "%.32s"
382>0x20	string	>\0	(%.10s
383>>0x2A	string	>\0	\b, %.6s)
384>>0x2A	byte	0	\b)
385
386# 2048-byte sector version.
3870	string	SEGA\ SEGASATURN\ 	Sega Saturn disc image
388!:mime	application/x-saturn-rom
389>0	use	sega-saturn-disc-header
390>0	byte	x			(2048-byte sectors)
391# 2352-byte sector version.
3920x10	string	SEGA\ SEGASATURN\ 	Sega Saturn disc image
393!:mime	application/x-saturn-rom
394>0x10	use	sega-saturn-disc-header
395>0	byte	x			(2352-byte sectors)
396
397#------------------------------------------------------------------------------
398# dreamcast: file(1) magic for the Sega Dreamcast disc image format.
399# From: David Korth <gerbilsoft@gerbilsoft.com>
400# Reference: https://mc.pp.se/dc/ip0000.bin.html
401#
402
403# Common Sega Dreamcast disc header format.
404# NOTE: Title is 128 bytes, but we're only showing 32 due to space padding.
405# TODO: Release date, device information, region code, others?
4060	name	sega-dreamcast-disc-header
407>0x80	string	>\0	\b: "%.32s"
408>0x40	string	>\0	(%.10s
409>>0x4A	string	>\0	\b, %.6s)
410>>0x4A	byte	0	\b)
411
412# 2048-byte sector version.
4130	string	SEGA\ SEGAKATANA\ 	Sega Dreamcast disc image
414!:mime	application/x-dc-rom
415>0	use	sega-dreamcast-disc-header
416>0	byte	x			(2048-byte sectors)
417# 2352-byte sector version.
4180x10	string	SEGA\ SEGAKATANA\ 	Sega Dreamcast disc image
419!:mime	application/x-dc-rom
420>0x10	use	sega-dreamcast-disc-header
421>0	byte	x			(2352-byte sectors)
422
423#------------------------------------------------------------------------------
424# dreamcast:  file(1) uncertain magic for the Sega Dreamcast VMU image format
425#
4260 belong 0x21068028   Sega Dreamcast VMU game image
4270 string LCDi         Dream Animator file
428
429#------------------------------------------------------------------------------
430# z64: file(1) magic for the Z64 format N64 ROM dumps
431# Reference: http://forum.pj64-emu.com/showthread.php?t=2239
432# From: David Korth <gerbilsoft@gerbilsoft.com>
433#
4340	bequad	0x803712400000000F	Nintendo 64 ROM image
435!:mime	application/x-n64-rom
436>0x20	string	>\0	\b: "%.20s"
437>0x3B	string	x	(%.4s
438>0x3F	byte	x	\b, Rev.%02u)
439
440#------------------------------------------------------------------------------
441# v64: file(1) magic for the V64 format N64 ROM dumps
442# Same as z64 format, but with 16-bit byteswapping.
443#
4440	bequad	0x3780401200000F00	Nintendo 64 ROM image (V64)
445!:mime	application/x-n64-rom
446
447#------------------------------------------------------------------------------
448# n64-swap2: file(1) magic for the swap2 format N64 ROM dumps
449# Same as z64 format, but with swapped 16-bit words.
450#
4510	bequad	0x12408037000F0000	Nintendo 64 ROM image (wordswapped)
452!:mime	application/x-n64-rom
453
454#------------------------------------------------------------------------------
455# n64-le32: file(1) magic for the 32-bit byteswapped format N64 ROM dumps
456# Same as z64 format, but with 32-bit byteswapping.
457#
4580	bequad	0x401237800F000000	Nintendo 64 ROM image (32-bit byteswapped)
459!:mime	application/x-n64-rom
460
461#------------------------------------------------------------------------------
462# gba: file(1) magic for the Nintendo Game Boy Advance raw ROM format
463# Reference: https://problemkaputt.de/gbatek.htm#gbacartridgeheader
464#
465# Original version from: "Nelson A. de Oliveira" <naoliv@gmail.com>
466# Updated version from: David Korth <gerbilsoft@gerbilsoft.com>
467#
4684	bequad	0x24FFAE51699AA221	Game Boy Advance ROM image
469!:mime	application/x-gba-rom
470>0xA0	string	>\0	\b: "%.12s"
471>0xAC	string	x	(%.6s
472>0xBC	byte	x	\b, Rev.%02u)
473
474#------------------------------------------------------------------------------
475# nds: file(1) magic for the Nintendo DS(i) raw ROM format
476# Reference: https://problemkaputt.de/gbatek.htm#dscartridgeheader
477#
478# Original version from: "Nelson A. de Oliveira" <naoliv@gmail.com>
479# Updated version from: David Korth <gerbilsoft@gerbilsoft.com>
480#
4810xC0	bequad	0x24FFAE51699AA221	Nintendo DS ROM image
482!:mime	application/x-nintendo-ds-rom
483>0x00	string	>\0		\b: "%.12s"
484>0x0C	string	x		(%.6s
485>0x1E	byte	x		\b, Rev.%02u)
486>0x12	byte	2		(DSi enhanced)
487>0x12	byte	3		(DSi only)
488# Secure Area check.
489>0x20		lelong	<0x4000		(homebrew)
490>0x20		lelong	>0x3FFF
491>>0x4000	lequad	0x0000000000000000	(multiboot)
492>>0x4000	lequad	!0x0000000000000000
493>>>0x4000	lequad	0xE7FFDEFFE7FFDEFF	(decrypted)
494>>>0x4000	lequad	!0xE7FFDEFFE7FFDEFF
495>>>>0x1000	lequad	0x0000000000000000	(encrypted)
496>>>>0x1000	lequad	!0x0000000000000000	(mask ROM)
497
498#------------------------------------------------------------------------------
499# nds_passme: file(1) magic for Nintendo DS ROM images for GBA cartridge boot.
500# This is also used for loading .nds files using the MSET exploit on 3DS.
501# Reference: https://github.com/devkitPro/ndstool/blob/master/source/ndscreate.cpp
5020xC0	bequad	0xC8604FE201708FE2	Nintendo DS Slot-2 ROM image (PassMe)
503!:mime	application/x-nintendo-ds-rom
504
505#------------------------------------------------------------------------------
506# ngp: file(1) magic for the Neo Geo Pocket (Color) raw ROM format.
507# From: David Korth <gerbilsoft@gerbilsoft.com>
508# References:
509# - https://neogpc.googlecode.com/svn-history/r10/trunk/src/core/neogpc.cpp
510# - https://www.devrs.com/ngp/files/ngpctech.txt
511#
5120x0A	string		BY\ SNK\ CORPORATION	Neo Geo Pocket
513!:mime	application/x-neo-geo-pocket-rom
514>0x23	byte		0x10			Color
515>0	byte		x			ROM image
516>0x24	string		>\0			\b: "%.12s"
517>0x21	uleshort	x			\b, NEOP%04X
518>0x1F	ubyte		0xFF			(debug mode enabled)
519
520#------------------------------------------------------------------------------
521# msx: file(1) magic for MSX game cartridge dumps
522# Too simple - MPi
523#0 beshort 0x4142 MSX game cartridge dump
524
525#------------------------------------------------------------------------------
526# Sony Playstation executables (Adam Sjoegren <asjo@diku.dk>) :
5270	string	PS-X\ EXE	Sony Playstation executable
528>16	lelong	x		PC=%#08x,
529>20	lelong	!0		GP=%#08x,
530>24	lelong	!0		.text=[%#08x,
531>>28	lelong	x		\b%#x],
532>32	lelong	!0		.data=[%#08x,
533>>36	lelong	x		\b%#x],
534>40	lelong	!0		.bss=[%#08x,
535>>44	lelong	x		\b%#x],
536>48	lelong	!0		Stack=%#08x,
537>48	lelong	=0		No Stack!,
538>52	lelong	!0		StackSize=%#x,
539#>76	string	>\0		(%s)
540#  Area:
541>113	string	x		(%s)
542
543# CPE executables
5440	string	CPE		CPE executable
545>3	byte	x		(version %d)
546
547#------------------------------------------------------------------------------
548# Microsoft Xbox executables .xbe (Esa Hyytia <ehyytia@cc.hut.fi>)
5490	string	XBEH	Microsoft Xbox executable
550!:mime	audio/x-xbox-executable
551!:ext	xbe
552# expect base address of 0x10000
553>0x0104                 ulelong =0x10000
554>>(0x0118.l-0x0FFF4)    lestring16 x       \b: "%.40s"
555>>(0x0118.l-0x0FFF5)    byte     x         (%c
556>>(0x0118.l-0x0FFF6)    byte     x         \b%c-
557>>(0x0118.l-0x0FFF8)    uleshort x         \b%03u)
558>>(0x0118.l-0x0FF60)    ulelong&0x80000007  0x80000007 \b, all regions
559>>(0x0118.l-0x0FF60)    ulelong&0x80000007  !0x80000007
560>>>(0x0118.l-0x0FF60)   ulelong >0           (regions:
561>>>>(0x0118.l-0x0FF60)  ulelong &0x00000001  NA
562>>>>(0x0118.l-0x0FF60)  ulelong &0x00000002  Japan
563>>>>(0x0118.l-0x0FF60)  ulelong &0x00000004  Rest_of_World
564>>>>(0x0118.l-0x0FF60)  ulelong &0x80000000  Manufacturer
565>>>(0x0118.l-0x0FF60)   ulelong >0           \b)
566# probabilistic checks whether signed or not
567>0x0004 ulelong =0x0
568>>&2    ulelong =0x0
569>>>&2   ulelong =0x0  \b, not signed
570>0x0004 ulelong >0
571>>&2    ulelong >0
572>>>&2   ulelong >0    \b, signed
573
574# --------------------------------
575# Microsoft Xbox data file formats
5760       string          XIP0            XIP, Microsoft Xbox data
5770       string          XTF0            XTF, Microsoft Xbox data
578
579#------------------------------------------------------------------------------
580# Microsoft Xbox 360 executables (.xex)
581# From: David Korth <gerbilsoft@gerbilsoft.com>
582# References:
583# - https://free60project.github.io/wiki/XEX.html
584# - https://github.com/xenia-project/xenia/blob/HEAD/src/xenia/kernel/util/xex2_info.h
585
586# Title ID (part of Execution ID section)
5870		name	xbox-360-xex-execution-id
588>(0.L+0xC)	byte	x	(%c
589>(0.L+0xD)	byte	x	\b%c
590>(0.L+0xE)	beshort	x	\b-%04u, media ID:
591>(0.L)		belong	x	%08X)
592
593# Region code (part of Security Info)
5940	name	xbox-360-xex-region-code
595>0	ubelong	0xFFFFFFFF	\b, all regions
596>0	ubelong	!0xFFFFFFFF
597>>0	ubelong	>0		(regions:
598>>0	ubelong&0x000000FF	0x000000FF	USA
599>>0	ubelong&0x00000100	0x00000100	Japan
600>>0	ubelong&0x00000200	0x00000200	China
601>>0	ubelong&0x0000FC00	0x0000FC00	Asia
602>>0	ubelong&0x00FF0000	0x00FF0000	PAL
603>>0	ubelong&0x00FF0000	0x00FE0000	PAL [except AU/NZ]
604>>0	ubelong&0x00FF0000	0x00010000	AU/NZ
605>>0	ubelong&0xFF000000	0xFF000000	Other
606>>0	ubelong	>0		\b)
607
6080	string	XEX2	Microsoft Xbox 360 executable
609!:mime	audio/x-xbox360-executable
610!:ext	xex
611>0x18	search/0x100	\x00\x04\x00\x06
612>>&0	use	xbox-360-xex-execution-id
613>(0x010.L+0x178)	use	xbox-360-xex-region-code
614
6150	string	XEX1	Microsoft Xbox 360 executable (XEX1)
616!:mime	audio/x-xbox360-executable
617!:ext	xex
618>0x18	search/0x100	\x00\x04\x00\x06
619>>&0	use	xbox-360-xex-execution-id
620>(0x010.L+0x154)	use	xbox-360-xex-region-code
621
622#------------------------------------------------------------------------------
623# Microsoft Xbox 360 packages
624# From: David Korth <gerbilsoft@gerbilsoft.com>
625# References:
626# - https://free60project.github.io/wiki/STFS.html
627# - https://github.com/xenia-project/xenia/blob/HEAD/src/xenia/kernel/util/xex2_info.h
628
629# TODO: More information for console-signed packages.
630
6310	name	xbox-360-package
632>0x360	byte	x	(%c
633>0x361	byte	x	\b%c
634>0x362	beshort	x	\b-%04u, media ID:
635>0x354	belong	x	%08X)
636>0x344	belong	x	\b, content type:
637>>0x344	belong	0x1		Saved Game
638>>0x344	belong	0x2		Marketplace Content
639>>0x344	belong	0x3		Publisher
640>>0x344	belong	0x1000		Xbox 360 Title
641>>0x344	belong	0x2000		IPTV Pause Buffer
642>>0x344	belong	0x4000		Installed Game
643>>0x344	belong	0x5000		Original Xbox Game
644>>0x344	belong	0x9000		Avatar Item
645>>0x344	belong	0x10000		Profile
646>>0x344	belong	0x20000		Gamer Picture
647>>0x344	belong	0x30000		Theme
648>>0x344	belong	0x40000		Cache File
649>>0x344	belong	0x50000		Storage Download
650>>0x344	belong	0x60000		Xbox Saved Game
651>>0x344	belong	0x70000		Xbox Download
652>>0x344	belong	0x80000		Game Demo
653>>0x344	belong	0x90000		Video
654>>0x344	belong	0xA0000		Game
655>>0x344	belong	0xB0000		Installer
656>>0x344	belong	0xC0000		Game Trailer
657>>0x344	belong	0xD0000		Arcade Title
658>>0x344	belong	0xE0000		XNA
659>>0x344	belong	0xF0000		License Store
660>>0x344	belong	0x100000	Movie
661>>0x344	belong	0x200000	TV
662>>0x344	belong	0x300000	Music Video
663>>0x344	belong	0x400000	Game Video
664>>0x344	belong	0x500000	Podcast Video
665>>0x344	belong	0x600000	Viral Video
666>>0x344	belong	0x2000000	Community Game
667
6680	string	CON\x20	Microsoft Xbox 360 package (console-signed)
669>0	use	xbox-360-package
6700	string	PIRS
671>0	belong	0	Microsoft Xbox 360 package (non-Xbox Live)
672>>0	use	xbox-360-package
6730	string	LIVE
674>0x104	belong	0	Microsoft Xbox 360 package (Xbox Live)
675>>0	use	xbox-360-package
676
677# Atari Lynx cartridge dump (EXE/BLL header)
678# From: "Stefan A. Haubenthal" <polluks@sdf.lonestar.org>
679# Reference:
680# https://raw.githubusercontent.com/cc65/cc65/master/libsrc/lynx/exehdr.s
681# Double-check that the image type matches too, 0x8008 conflicts with
682# 8 character OMF-86 object file headers.
6830	beshort		0x8008
684>6	string		BS93		Lynx homebrew cartridge
685!:mime	application/x-atari-lynx-rom
686>>2	beshort		x		\b, RAM start $%04x
6870	string		LYNX		Lynx cartridge
688!:mime	application/x-atari-lynx-rom
689>4	leshort/4	>0		\b, bank 0 %dk
690>6	leshort/4	>0		\b, bank 1 %dk
691>10	string		>\0		\b, "%.32s"
692>42	string		>\0		\b, "%.16s"
693
694# Opera file system that is used on the 3DO console
695# From: Serge van den Boom <svdb@stack.nl>
6960	string		\x01ZZZZZ\x01	3DO "Opera" file system
697
698# From: Alex Myczko <alex@aiei.ch>
699# From: David Pflug <david@pflug.email>
700# is the offset 12 or the offset 16 correct?
701# GBS (Game Boy Sound) magic
702# ftp://ftp.modland.com/pub/documents/format_documentation/\
703# Gameboy%20Sound%20System%20(.gbs).txt
7040	string		GBS		Nintendo Gameboy Music/Audio Data
705#12	string		GameBoy\ Music\ Module	Nintendo Gameboy Music Module
706>16	string		>\0	("%.32s" by
707>48	string		>\0	%.32s, copyright
708>80	string		>\0	%.32s),
709>3	byte		x	version %u,
710>4	byte		x	%u tracks
711
712# IPS Patch Files from: From: Thomas Klausner <tk@giga.or.at>
713# see https://zerosoft.zophar.net/ips.php
7140	string	PATCH			IPS patch file
715!:ext	ips
716
717# BPS Patch Files - from: David Korth <gerbilsoft@gerbilsoft.com>
718# Reference: https://www.romhacking.net/documents/746/
7190	string	BPS1			BPS patch file
720!:ext	bps
721
722# APS Patch Files - from: David Korth <gerbilsoft@gerbilsoft.com>
723# Reference: https://github.com/btimofeev/UniPatcher/wiki/APS-(N64)
7240	string	APS10			APS patch file
725!:ext	aps
726>5	byte	0			\b, simple patch
727>5	byte	1			\b, N64-specific patch for
728>>58	byte	x			N%c
729>>59	byte	x			\b%c
730>>60	byte	x			\b%c
731>7	byte	!0x20
732# FIXME: /T specifier isn't working with a fixed-length string.
733>>7	string	x			\b: "%.50s"
734
735# UPS Patch Files - from: David Korth <gerbilsoft@gerbilsoft.com>
736# Reference: http://fileformats.archiveteam.org/wiki/UPS_(binary_patch_format)
7370	string	UPS1			UPS patch file
738!:ext	ups
739
740# Playstations Patch Files from: From: Thomas Klausner <tk@giga.or.at>
7410	string	PPF30			Playstation Patch File version 3.0
742>5	byte	0			\b, PPF 1.0 patch
743>5	byte	1			\b, PPF 2.0 patch
744>5	byte	2			\b, PPF 3.0 patch
745>>56	byte	0			\b, Imagetype BIN (any)
746>>56	byte	1			\b, Imagetype GI (PrimoDVD)
747>>57	byte	0			\b, Blockcheck disabled
748>>57	byte	1			\b, Blockcheck enabled
749>>58	byte	0			\b, Undo data not available
750>>58	byte	1			\b, Undo data available
751>6	string	x			\b, description: %s
752
7530	string	PPF20			Playstation Patch File version 2.0
754>5	byte	0			\b, PPF 1.0 patch
755>5	byte	1			\b, PPF 2.0 patch
756>>56	lelong	>0			\b, size of file to patch %d
757>6	string	x			\b, description: %s
758
7590	string	PPF10			Playstation Patch File version 1.0
760>5	byte	0			\b, Simple Encoding
761>6	string	x			\b, description: %s
762
763# From: Daniel Dawson <ddawson@icehouse.net>
764# SNES9x .smv "movie" file format.
7650		string		SMV\x1A	SNES9x input recording
766>0x4		lelong		x	\b, version %d
767# version 4 is latest so far
768>0x4		lelong		<5
769>>0x8		ledate		x	\b, recorded at %s
770>>0xc		lelong		>0	\b, rerecorded %d times
771>>0x10		lelong		x	\b, %d frames long
772>>0x14		byte		>0	\b, data for controller(s):
773>>>0x14		byte		&0x1	#1
774>>>0x14		byte		&0x2	#2
775>>>0x14		byte		&0x4	#3
776>>>0x14		byte		&0x8	#4
777>>>0x14		byte		&0x10	#5
778>>0x15		byte		^0x1	\b, begins from snapshot
779>>0x15		byte		&0x1	\b, begins from reset
780>>0x15		byte		^0x2	\b, NTSC standard
781>>0x15		byte		&0x2	\b, PAL standard
782>>0x17		byte		&0x1    \b, settings:
783# WIP1Timing not used as of version 4
784>>>0x4		lelong		<4
785>>>>0x17	byte		&0x2	WIP1Timing
786>>>0x17		byte		&0x4	Left+Right
787>>>0x17		byte		&0x8	VolumeEnvX
788>>>0x17		byte		&0x10	FakeMute
789>>>0x17		byte		&0x20	SyncSound
790# New flag as of version 4
791>>>0x4		lelong		>3
792>>>>0x17	byte		&0x80	NoCPUShutdown
793>>0x4		lelong		<4
794>>>0x18		lelong		>0x23
795>>>>0x20	leshort		!0
796>>>>>0x20	lestring16	x	\b, metadata: "%s"
797>>0x4		lelong		>3
798>>>0x24		byte		>0	\b, port 1:
799>>>>0x24	byte		1	joypad
800>>>>0x24	byte		2	mouse
801>>>>0x24	byte		3	SuperScope
802>>>>0x24	byte		4	Justifier
803>>>>0x24	byte		5	multitap
804>>>0x24		byte		>0	\b, port 2:
805>>>>0x25	byte		1	joypad
806>>>>0x25	byte		2	mouse
807>>>>0x25	byte		3	SuperScope
808>>>>0x25	byte		4	Justifier
809>>>>0x25	byte		5	multitap
810>>>0x18		lelong		>0x43
811>>>>0x40	leshort		!0
812>>>>>0x40	lestring16	x	\b, metadata: "%s"
813>>0x17		byte		&0x40   \b, ROM:
814>>>(0x18.l-26)	lelong		x	CRC32 %#08x
815>>>(0x18.l-23)	string		x	"%s"
816
817# Type: scummVM savegame files
818# From: Sven Hartge <debian@ds9.argh.org>
8190	string	SCVM	ScummVM savegame
820>12	string	>\0	"%s"
821
822#------------------------------------------------------------------------------
823# Nintendo GameCube / Wii file formats.
824#
825
826# Type: Nintendo GameCube/Wii common disc header data.
827# From: David Korth <gerbilsoft@gerbilsoft.com>
828# Reference: https://wiibrew.org/wiki/Wii_Disc
8290	name	nintendo-gcn-disc-common
830>0x20	string	x	"%.64s"
831>0x00	string	x	(%.6s
832>0x06	byte	>0
833>>0x06	byte	1	\b, Disc 2
834>>0x06	byte	2	\b, Disc 3
835>>0x06	byte	3	\b, Disc 4
836>0x07	byte	x	\b, Rev.%02u)
837>0x18	belong	0x5D1C9EA3
838>>0x60	beshort	0x0101	\b (Unencrypted)
839>0x200	string	NKIT	\b (NKit compressed)
840
841
842# Type: Nintendo GameCube disc image
843# From: David Korth <gerbilsoft@gerbilsoft.com>
844# Reference: https://wiibrew.org/wiki/Wii_Disc
8450x1C	belong	0xC2339F3D	Nintendo GameCube disc image:
846!:mime	application/x-gamecube-rom
847>0	use	nintendo-gcn-disc-common
848
849# Type: Nintendo GameCube embedded disc image
850# Commonly found on demo discs.
851# From: David Korth <gerbilsoft@gerbilsoft.com>
852# Reference: http://hitmen.c02.at/files/yagcd/yagcd/index.html#idx14.8
8530		belong	0xAE0F38A2
854>0x0C		belong	0x00100000
855>>(8.L+0x1C)	belong	0xC2339F3D	Nintendo GameCube embedded disc image:
856!:mime	application/x-gamecube-rom
857>>>(8.L)	use	nintendo-gcn-disc-common
858
859# Type: Nintendo Wii disc image
860# From: David Korth <gerbilsoft@gerbilsoft.com>
861# Reference: https://wiibrew.org/wiki/Wii_Disc
8620x18	belong	0x5D1C9EA3	Nintendo Wii disc image:
863>0	use	nintendo-gcn-disc-common
864
865# Type: Nintendo Wii disc image (WBFS format)
866# From: David Korth <gerbilsoft@gerbilsoft.com>
867# Reference: https://wiibrew.org/wiki/Wii_Disc
8680	string	WBFS
869>0x218	belong	0x5D1C9EA3	Nintendo Wii disc image (WBFS format):
870!:mime	application/x-wii-rom
871>>0x200	use	nintendo-gcn-disc-common
872
873# Type: Nintendo GameCube/Wii disc image (CISO format)
874# NOTE: This is NOT the same as Compact ISO or PSP CISO,
875# though it has the same magic number.
8760		string	CISO
877# Other fields are used to determine what type of CISO this is:
878# - 0x04 == 0x00200000: GameCube/Wii CISO (block_size)
879# - 0x10 == 0x00000800: PSP CISO (ISO-9660 sector size)
880# - None of the above: Compact ISO.
881>4		lelong	0x200000
882>>8		byte	1
883>>>0x801C	belong	0xC2339F3D	Nintendo GameCube disc image (CISO format):
884!:mime	application/x-wii-rom
885>>>>0x8000	use	nintendo-gcn-disc-common
886>>>0x8018	belong	0x5D1C9EA3	Nintendo Wii disc image (CISO format):
887!:mime	application/x-wii-rom
888>>>>0x8000	use	nintendo-gcn-disc-common
889
890# Type: Nintendo GameCube/Wii disc image (GCZ format)
891# Due to zlib compression, we can't get the actual disc information.
8920	lelong	0xB10BC001
893>4	lelong	0		Nintendo GameCube disc image (GCZ format)
894!:mime	application/x-gamecube-rom
895>4	lelong	1		Nintendo Wii disc image (GCZ format)
896!:mime	application/x-wii-rom
897>4	default	x		Nintendo GameCube/Wii disc image (GCZ format)
898
899# Type: Nintendo GameCube/Wii disc image (WDF format)
9000		string	WII\001DISC
901>8		belong	1
902# WDFv1
903>>0x54		belong	0xC2339F3D	Nintendo GameCube disc image (WDFv1 format):
904!:mime	application/x-gamecube-rom
905>>>0x38		use	nintendo-gcn-disc-common
906>>0x58		belong	0x5D1C9EA3	Nintendo Wii disc image (WDFv1 format):
907!:mime	application/x-wii-rom
908>>>0x38		use	nintendo-gcn-disc-common
909>8		belong	2
910# WDFv2
911>>(12.L+0x1C)	belong	0xC2339F3D	Nintendo GameCube disc image (WDFv2 format):
912!:mime	application/x-gamecube-rom
913>>>(12.L)	use	nintendo-gcn-disc-common
914>>(12.L+0x18)	belong	0x5D1C9EA3	Nintendo Wii disc image (WDFv2 format):
915!:mime	application/x-wii-rom
916>>>(12.L)	use	nintendo-gcn-disc-common
917
918# Type: Nintendo GameCube/Wii disc image (WIA format)
9190	string	WIA\001	Nintendo
920>0x48	belong	1	GameCube
921!:mime	application/x-gamecube-rom
922>0x48	belong	2	Wii
923!:mime	application/x-wii-rom
924>0x48	default	x	GameCube/Wii
925>0x48	belong	x	disc image (WIA format):
926>>0x58	use	nintendo-gcn-disc-common
927
928# Type: Nintendo GameCube/Wii disc image (with SDK header)
929# From: David Korth <gerbilsoft@gerbilsoft.com>
930# Reference: https://wiibrew.org/wiki/Wii_Disc
9310		belong	0xFFFF0000
932>0x18		belong	0x00000000
933>>0x1C		belong	0x00000000
934>>>0x8018	belong	0x5D1C9EA3	Nintendo Wii SDK disc image:
935!:mime	application/x-wii-rom
936>>>>0x8000	use	nintendo-gcn-disc-common
937>>>0x801C	belong	0xC2339F3D	Nintendo GameCube SDK disc image:
938!:mime	application/x-gamecube-rom
939>>>>0x8000	use	nintendo-gcn-disc-common
940
941# Type: Nintendo GameCube/Wii disc image (RVZ format)
9420	string		RVZ\001	Nintendo
943>0x48	belong		1	GameCube
944!:mime	application/x-gamecube-rom
945>0x48	belong		2	Wii
946!:mime	application/x-wii-rom
947>0x48	default		x	GameCube/Wii
948>0x48	belong		x	disc image (RVZ format):
949>>0x58	use		nintendo-gcn-disc-common
950
951#------------------------------------------------------------------------------
952# Nintendo 3DS file formats.
953#
954
955# Type: Nintendo 3DS "NCSD" image. (game cards and eMMC)
956# From: David Korth <gerbilsoft@gerbilsoft.com>
957# Reference: https://www.3dbrew.org/wiki/NCSD
9580x100		string		NCSD
959>0x118		lequad		0		Nintendo 3DS Game Card image
960# NCCH header for partition 0. (game data)
961>>0x1150	string		>\0	\b: "%.16s"
962>>0x312		byte		x	(Rev.%02u)
963>>0x118C	byte		2	(New3DS only)
964>>0x18D		byte		0		(inner device)
965>>0x18D		byte		1		(Card1)
966>>0x18D		byte		2		(Card2)
967>>0x18D		byte		3		(extended device)
968>0x118		bequad		0x0102020202000000	Nintendo 3DS eMMC dump (Old3DS)
969>0x118		bequad		0x0102020203000000	Nintendo 3DS eMMC dump (New3DS)
970
971# Nintendo 3DS version code.
972# Reference: https://www.3dbrew.org/wiki/Titles
973# Format: leshort containing three fields:
974# - 6-bit: Major
975# - 6-bit: Minor
976# - 4-bit: Revision
977# NOTE: Only supporting major/minor versions from 0-15 right now.
978# NOTE: Should be prefixed with "v".
9790	name	nintendo-3ds-version-code
980# Raw version.
981>0	leshort	x	\b%u,
982# Major version.
983>0	leshort&0xFC00	0x0000	0
984>0	leshort&0xFC00	0x0400	1
985>0	leshort&0xFC00	0x0800	2
986>0	leshort&0xFC00	0x0C00	3
987>0	leshort&0xFC00	0x1000	4
988>0	leshort&0xFC00	0x1400	5
989>0	leshort&0xFC00	0x1800	6
990>0	leshort&0xFC00	0x1C00	7
991>0	leshort&0xFC00	0x2000	8
992>0	leshort&0xFC00	0x2400	9
993>0	leshort&0xFC00	0x2800	10
994>0	leshort&0xFC00	0x2C00	11
995>0	leshort&0xFC00	0x3000	12
996>0	leshort&0xFC00	0x3400	13
997>0	leshort&0xFC00	0x3800	14
998>0	leshort&0xFC00	0x3C00	15
999# Minor version.
1000>0	leshort&0x03F0	0x0000	\b.0
1001>0	leshort&0x03F0	0x0010	\b.1
1002>0	leshort&0x03F0	0x0020	\b.2
1003>0	leshort&0x03F0	0x0030	\b.3
1004>0	leshort&0x03F0	0x0040	\b.4
1005>0	leshort&0x03F0	0x0050	\b.5
1006>0	leshort&0x03F0	0x0060	\b.6
1007>0	leshort&0x03F0	0x0070	\b.7
1008>0	leshort&0x03F0	0x0080	\b.8
1009>0	leshort&0x03F0	0x0090	\b.9
1010>0	leshort&0x03F0	0x00A0	\b.10
1011>0	leshort&0x03F0	0x00B0	\b.11
1012>0	leshort&0x03F0	0x00C0	\b.12
1013>0	leshort&0x03F0	0x00D0	\b.13
1014>0	leshort&0x03F0	0x00E0	\b.14
1015>0	leshort&0x03F0	0x00F0	\b.15
1016# Revision.
1017>0	leshort&0x000F	x	\b.%u
1018
1019# Type: Nintendo 3DS "NCCH" container.
1020# https://www.3dbrew.org/wiki/NCCH
10210x100		string	NCCH	Nintendo 3DS
1022>0x18D		byte&2	0	File Archive (CFA)
1023>0x18D		byte&2	2	Executable Image (CXI)
1024>0x150		string	>\0	\b: "%.16s"
1025>0x18D		byte	0x05
1026>>0x10E		leshort	x	(Old3DS System Update v
1027>>0x10E		use	nintendo-3ds-version-code
1028>>0x10E		leshort	x	\b)
1029>0x18D		byte	0x15
1030>>0x10E		leshort	x	(New3DS System Update v
1031>>0x10E		use	nintendo-3ds-version-code
1032>>0x10E		leshort	x	\b)
1033>0x18D		byte	!0x05
1034>>0x18D		byte	!0x15
1035>>>0x112	byte	x	(v
1036>>>0x112	use	nintendo-3ds-version-code
1037>>>0x112	byte	x	\b)
1038>0x18C		byte	2	(New3DS only)
1039
1040# Type: Nintendo 3DS "SMDH" file. (application description)
1041# From: David Korth <gerbilsoft@gerbilsoft.com>
1042# Reference: https://3dbrew.org/wiki/SMDH
10430		string		SMDH		Nintendo 3DS SMDH file
1044>0x208		leshort		!0
1045>>0x208		lestring16	x		\b: "%.128s"
1046>>0x388		leshort		!0
1047>>>0x388	lestring16	x		by %.128s
1048>0x208		leshort		0
1049>>0x008		leshort		!0
1050>>>0x008	lestring16	x		\b: "%.128s"
1051>>>0x188	leshort		!0
1052>>>>0x188	lestring16	x		by %.128s
1053
1054# Type: Nintendo 3DS Homebrew Application.
1055# From: David Korth <gerbilsoft@gerbilsoft.com>
1056# Reference: https://3dbrew.org/wiki/3DSX_Format
10570	string	3DSX	Nintendo 3DS Homebrew Application (3DSX)
1058
1059# Type: Nintendo 3DS Banner Model Data.
1060# From: David Korth <gerbilsoft@gerbilsoft.com>
1061# Reference: https://3dbrew.org/wiki/CBMD
10620	string	CBMD\0\0\0\0	Nintendo 3DS Banner Model Data
1063
1064#------------------------------------------------------------------------------
1065# a7800: file(1) magic for the Atari 7800 raw ROM format.
1066# From: David Korth <gerbilsoft@gerbilsoft.com>
1067# Reference: https://sites.google.com/site/atari7800wiki/a78-header
1068
10690	byte	>0
1070>0	byte	<3
1071>>1	string	ATARI7800	Atari 7800 ROM image
1072!:mime	application/x-atari-7800-rom
1073>>>0x11	string	>\0	\b: "%.32s"
1074# Display type.
1075>>>0x39	byte	0	(NTSC)
1076>>>0x39	byte	1	(PAL)
1077>>>0x36	byte&1	1	(POKEY)
1078
1079#------------------------------------------------------------------------------
1080# vectrex: file(1) magic for the GCE Vectrex raw ROM format.
1081# From: David Korth <gerbilsoft@gerbilsoft.com>
1082# Reference: http://www.playvectrex.com/designit/chrissalo/hello1.htm
1083#
1084# NOTE: Title is terminated with 0x80, not 0.
1085# The header is terminated with a 0, so that will
1086# terminate the title as well.
1087#
10880	string	g\ GCE	Vectrex ROM image
1089>0x11	string	>\0	\b: "%.16s"
1090
1091#------------------------------------------------------------------------------
1092# amiibo: file(1) magic for Nintendo amiibo NFC dumps.
1093# From: David Korth <gerbilsoft@gerbilsoft.com>
1094# Reference: https://www.3dbrew.org/wiki/Amiibo
10950x00		byte	0x04
1096>0x0A		beshort	0x0FE0
1097>>0x0C		belong	0xF110FFEE
1098>>>0x208	beshort	0x0100
1099>>>>0x020A	byte	0x0F
1100>>>>>0x020C	bequad	0x000000045F000000
1101>>>>>>0x5B	byte	0x02
1102>>>>>>>0x54	belong	x	Nintendo amiibo NFC dump - amiibo ID: %08X-
1103>>>>>>>0x58	belong	x	\b%08X
1104
1105#------------------------------------------------------------------------------
1106# Type: Nintendo Switch XCI (Game Cartridge Image)
1107# From: Benjamin Lowry <ben@ben.gmbh>
1108# Reference: https://switchbrew.org/wiki/Gamecard_Format
11090x100		string	HEAD
1110>0x10D		byte	0xFA	Nintendo Switch cartridge image (XCI), 1GB
1111>0x10D		byte	0xF8	Nintendo Switch cartridge image (XCI), 2GB
1112>0x10D		byte	0xF0	Nintendo Switch cartridge image (XCI), 4GB
1113>0x10D		byte	0xE0	Nintendo Switch cartridge image (XCI), 8GB
1114>0x10D		byte	0xE1	Nintendo Switch cartridge image (XCI), 16GB
1115>0x10D		byte	0xE2	Nintendo Switch cartridge image (XCI), 32GB
1116
1117#------------------------------------------------------------------------------
1118# Type: Nintendo Switch Executable
1119# From: Benjamin Lowry <ben@ben.gmbh>
1120# Reference: https://switchbrew.org/wiki/NSO
11210x00		string	NSO0	Nintendo Switch executable (NSO)
1122
1123#------------------------------------------------------------------------------
1124# Type: Nintendo Switch PFS0
1125# From: Benjamin Lowry <ben@ben.gmbh>
1126# Reference: https://switchbrew.org/wiki/NCA_Format#PFS0
11270x00		string	PFS0	Nintendo Switch partition filesystem (PFS0)
1128>0x04		ulelong	x	\b, %d files
1129
1130#------------------------------------------------------------------------------
1131# amiibo: file(1) magic for Nintendo Badge Arcade files.
1132# From: David Korth <gerbilsoft@gerbilsoft.com>
1133# References:
1134# - https://github.com/GerbilSoft/rom-properties/issues/92
1135# - https://github.com/CaitSith2/BadgeArcadeTool
1136# - https://github.com/TheMachinumps/Advanced-badge-editor
1137
1138# PRBS: Individual badge and/or mega badge.
11390		string	PRBS
1140>0x44		byte	>0x20	Nintendo Badge Arcade
1141>>0xB8		ulelong	<2
1142>>>0xBC		ulelong	<2	badge:
1143>>>0xBC		ulelong	>1	Mega Badge
1144>>>>0xB8	ulelong	x	(%ux
1145>>>>0xBC	ulelong	x	\b%u):
1146>>0xB8		ulelong	>1	Mega Badge
1147>>>0xB8		ulelong	x	(%ux
1148>>>0xBC		ulelong	x	\b%u):
1149>0x44		string	x	"%s"
1150>0x3C		ulelong	x	\b, badge ID: %u
1151>0x74		byte	>0x20
1152>>0x74		string	x	\b, set: "%s"
1153>0xA8		ulelong	!0xFFFFFFFF
1154>>0xA8		ulelong	x	\b, launch title ID: %08X
1155>>0xA4		ulelong	x	\b-%08X
1156
1157# CABS: Badge set.
11580	string	CABS
1159>0x2C	byte	>0x20	Nintendo Badge Arcade badge set:
1160>>0x2C	string	x	"%.48s"
1161>>0x24	ulelong	x	\b, set ID: %u
1162
1163#------------------------------------------------------------------------------
1164# sufami: file(1) magic for Sufami Turbo ROM images.
1165# From: David Korth <gerbilsoft@gerbilsoft.com>
1166# References:
1167# - https://problemkaputt.de/fullsnes.htm#snescartsufamiturbominicartridgeadaptor
11680	string		BANDAI\ SFC-ADX
1169>0x10	string		!SFC-ADX\ BACKUP	Sufami Turbo ROM image:
1170>>0x10	string/T	x	"%.14s"
1171>>0x30	byte		x	\b, ID %02X
1172>>0x31	byte		x	\b%02X
1173>>0x32	byte		x	\b%02X
1174>>0x33	ubyte		>0	\b, series index %u
1175>>0x34	ubyte		0	[SlowROM]
1176>>0x34	ubyte		1	[FastROM]
1177>>0x35	ubyte		1	[SRAM]
1178>>0x35	ubyte		3	[Special]
1179