xref: /freebsd/contrib/file/magic/Magdir/console (revision 6be3386466ab79a84b48429ae66244f21526d3df)
1
2#------------------------------------------------------------------------------
3# $File: console,v 1.55 2020/04/19 17:30:55 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	byte	x		\b, mfr %02X
82>20	byte	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>0x14b		byte		0x33
129>>0x146		byte		0x03
130>>>0x143	byte&0x80	0x80	[SGB+CGB]
131>>>0x143	byte&0x80	!0x80	[SGB]
132>>0x146		byte		!0x03
133>>>0x143	byte&0xC0	0x80	[CGB]
134>>>0x143	byte&0xC0	0xC0	[CGB ONLY]
135>0x14b		byte		!0x33
136
137# Mapper.
138>0x147 byte 0x00  [ROM ONLY]
139>0x147 byte 0x01  [MBC1]
140>0x147 byte 0x02  [MBC1+RAM]
141>0x147 byte 0x03  [MBC1+RAM+BATT]
142>0x147 byte 0x05  [MBC2]
143>0x147 byte 0x06  [MBC2+BATTERY]
144>0x147 byte 0x08  [ROM+RAM]
145>0x147 byte 0x09  [ROM+RAM+BATTERY]
146>0x147 byte 0x0B  [MMM01]
147>0x147 byte 0x0C  [MMM01+SRAM]
148>0x147 byte 0x0D  [MMM01+SRAM+BATT]
149>0x147 byte 0x0F  [MBC3+TIMER+BATT]
150>0x147 byte 0x10  [MBC3+TIMER+RAM+BATT]
151>0x147 byte 0x11  [MBC3]
152>0x147 byte 0x12  [MBC3+RAM]
153>0x147 byte 0x13  [MBC3+RAM+BATT]
154>0x147 byte 0x19  [MBC5]
155>0x147 byte 0x1A  [MBC5+RAM]
156>0x147 byte 0x1B  [MBC5+RAM+BATT]
157>0x147 byte 0x1C  [MBC5+RUMBLE]
158>0x147 byte 0x1D  [MBC5+RUMBLE+SRAM]
159>0x147 byte 0x1E  [MBC5+RUMBLE+SRAM+BATT]
160>0x147 byte 0xFC  [Pocket Camera]
161>0x147 byte 0xFD  [Bandai TAMA5]
162>0x147 byte 0xFE  [Hudson HuC-3]
163>0x147 byte 0xFF  [Hudson HuC-1]
164
165# ROM size.
166>0x148 byte 0     \b, ROM: 256Kbit
167>0x148 byte 1     \b, ROM: 512Kbit
168>0x148 byte 2     \b, ROM: 1Mbit
169>0x148 byte 3     \b, ROM: 2Mbit
170>0x148 byte 4     \b, ROM: 4Mbit
171>0x148 byte 5     \b, ROM: 8Mbit
172>0x148 byte 6     \b, ROM: 16Mbit
173>0x148 byte 7     \b, ROM: 32Mbit
174>0x148 byte 0x52  \b, ROM: 9Mbit
175>0x148 byte 0x53  \b, ROM: 10Mbit
176>0x148 byte 0x54  \b, ROM: 12Mbit
177
178# RAM size.
179>0x149 byte 1     \b, RAM: 16Kbit
180>0x149 byte 2     \b, RAM: 64Kbit
181>0x149 byte 3     \b, RAM: 128Kbit
182>0x149 byte 4     \b, RAM: 1Mbit
183>0x149 byte 5     \b, RAM: 512Kbit
184
185#------------------------------------------------------------------------------
186# genesis: file(1) magic for various Sega Mega Drive / Genesis ROM image and disc formats
187# Updated by David Korth <gerbilsoft@gerbilsoft.com>
188# References:
189# - https://www.retrodev.com/segacd.html
190# - http://devster.monkeeh.com/sega/32xguide1.txt
191#
192
193# Common Sega Mega Drive header format.
194# FIXME: Name fields are 48 bytes, but have spaces for padding instead of 00s.
1950		name	sega-mega-drive-header
196# ROM title. (Use domestic if present; if not, use international.)
197>0x120		byte	>0x20
198>>0x120		string	>\0	\b: "%.16s"
199>0x120		byte	<0x21
200>>0x150		string	>\0	\b: "%.16s"
201# Other information.
202>0x180		string	>\0	(%.14s
203>>0x110		string  >\0	\b, %.16s
204>0x180		byte	0
205>>0x110		string  >\0	(%.16s
206>0		byte	x	\b)
207
208# TODO: Check for 32X CD?
209# Sega Mega CD disc images: 2048-byte sectors.
2100	string	SEGADISCSYSTEM\ \ 	Sega Mega CD disc image
211!:mime	application/x-sega-cd-rom
212>0	use	sega-mega-drive-header
213>0	byte	x			\b, 2048-byte sectors
2140	string	SEGABOOTDISC\ \ \ \ 	Sega Mega CD disc image
215!:mime	application/x-sega-cd-rom
216>0	use	sega-mega-drive-header
217>0	byte	x			\b, 2048-byte sectors
218# Sega Mega CD disc images: 2352-byte sectors.
2190x10	string	SEGADISCSYSTEM\ \ 	Sega Mega CD disc image
220!:mime	application/x-sega-cd-rom
221>0x10	use	sega-mega-drive-header
222>0	byte	x			\b, 2352-byte sectors
2230x10	string	SEGABOOTDISC\ \ \ \ 	Sega Mega CD disc image
224!:mime	application/x-sega-cd-rom
225>0x10	use	sega-mega-drive-header
226>0	byte	x			\b, 2352-byte sectors
227
228# Sega Mega Drive, 32X, Pico, and Mega CD Boot ROM images.
2290x100		string	SEGA
230>0x3C0		bequad	0x4D41525320434845	Sega 32X ROM image
231!:mime		application/x-genesis-32x-rom
232>>0		use	sega-mega-drive-header
233>0x3C0		bequad	!0x4D41525320434845
234>>0x105		belong	0x5049434F	Sega Pico ROM image
235!:mime		application/x-sega-pico-rom
236>>>0		use	sega-mega-drive-header
237>>0x105		belong	!0x5049434F
238>>>0x180	beshort	0x4252		Sega Mega CD Boot ROM image
239!:mime		application/x-genesis-rom
240>>>0x180	beshort	!0x4252		Sega Mega Drive / Genesis ROM image
241!:mime		application/x-genesis-rom
242>>>0		use	sega-mega-drive-header
243
244#------------------------------------------------------------------------------
245# genesis: file(1) magic for the Super MegaDrive ROM dump format
246#
247
248# NOTE: Due to interleaving, we can't display anything
249# other than the copier header information.
2500      name    sega-genesis-smd-header
251>0     byte    x       %dx16k blocks
252>2     byte    0       \b, last in series or standalone
253>2     byte    >0      \b, split ROM
254
255# "Sega Genesis" header.
2560x280	string EAGN
257>8	beshort	0xAABB	Sega Mega Drive / Genesis ROM image (SMD format):
258!:mime	application/x-genesis-rom
259>>0	use     sega-genesis-smd-header
260
261# "Sega Mega Drive" header.
2620x280	string EAMG
263>8	beshort	0xAABB	Sega Mega Drive / Genesis ROM image (SMD format):
264!:mime	application/x-genesis-rom
265>>0	use     sega-genesis-smd-header
266
267#------------------------------------------------------------------------------
268# smsgg:  file(1) magic for Sega Master System and Game Gear ROM images
269# Detects all Game Gear and export Sega Master System ROM images,
270# and some Japanese Sega Master System ROM images.
271# From: David Korth <gerbilsoft@gerbilsoft.com>
272# Reference: https://www.smspower.org/Development/ROMHeader
273#
274
275# General SMS header rule.
276# The SMS boot ROM checks the header at three locations.
2770	name	sega-master-system-rom-header
278# Machine type.
279>0x0F	byte&0xF0	0x30	Sega Master System
280!:mime	application/x-sms-rom
281>0x0F	byte&0xF0	0x40	Sega Master System
282!:mime	application/x-sms-rom
283>0x0F	byte&0xF0	0x50	Sega Game Gear
284!:mime	application/x-gamegear-rom
285>0x0F	byte&0xF0	0x60	Sega Game Gear
286!:mime	application/x-gamegear-rom
287>0x0F	byte&0xF0	0x70	Sega Game Gear
288!:mime	application/x-gamegear-rom
289>0x0F	default		x	Sega Master System / Game Gear
290!:mime	application/x-sms-rom
291>0	byte		x	ROM image:
292# Product code.
293>0x0E	byte&0xF0	0x10	1
294>0x0E	byte&0xF0	0x20	2
295>0x0E	byte&0xF0	0x30	3
296>0x0E	byte&0xF0	0x40	4
297>0x0E	byte&0xF0	0x50	5
298>0x0E	byte&0xF0	0x60	6
299>0x0E	byte&0xF0	0x70	7
300>0x0E	byte&0xF0	0x80	8
301>0x0E	byte&0xF0	0x90	9
302>0x0E	byte&0xF0	0xA0	10
303>0x0E	byte&0xF0	0xB0	11
304>0x0E	byte&0xF0	0xC0	12
305>0x0E	byte&0xF0	0xD0	13
306>0x0E	byte&0xF0	0xE0	14
307>0x0E	byte&0xF0	0xF0	15
308# If the product code is 5 digits, we'll need to backspace here.
309>0x0E	byte&0xF0	!0
310>>0x0C	leshort		x	\b%04x
311>0x0E	byte&0xF0	0
312>>0x0C	leshort		x	%04x
313# Revision.
314>0x0E	byte&0x0F	x	(Rev.%02d)
315# ROM size. (Used for the boot ROM checksum routine.)
316>0x0F	byte&0x0F	0x0A	(8 KB)
317>0x0F	byte&0x0F	0x0B	(16 KB)
318>0x0F	byte&0x0F	0x0C	(32 KB)
319>0x0F	byte&0x0F	0x0D	(48 KB)
320>0x0F	byte&0x0F	0x0E	(64 KB)
321>0x0F	byte&0x0F	0x0F	(128 KB)
322>0x0F	byte&0x0F	0x00	(256 KB)
323>0x0F	byte&0x0F	0x01	(512 KB)
324>0x0F	byte&0x0F	0x02	(1 MB)
325
326# SMS/GG header locations.
3270x7FF0	string	TMR\ SEGA
328>0x7FF0	use	sega-master-system-rom-header
3290x3FF0	string	TMR\ SEGA
330>0x3FF0	use	sega-master-system-rom-header
3310x1FF0	string	TMR\ SEGA
332>0x1FF0	use	sega-master-system-rom-header
333
334#------------------------------------------------------------------------------
335# saturn: file(1) magic for the Sega Saturn disc image format.
336# From: David Korth <gerbilsoft@gerbilsoft.com>
337#
338
339# Common Sega Saturn disc header format.
340# NOTE: Title is 112 bytes, but we're only showing 32 due to space padding.
341# TODO: Release date, device information, region code, others?
3420	name	sega-saturn-disc-header
343>0x60	string	>\0	\b: "%.32s"
344>0x20	string	>\0	(%.10s
345>>0x2A	string	>\0	\b, %.6s)
346>>0x2A	byte	0	\b)
347
348# 2048-byte sector version.
3490	string	SEGA\ SEGASATURN\ 	Sega Saturn disc image
350!:mime	application/x-saturn-rom
351>0	use	sega-saturn-disc-header
352>0	byte	x			(2048-byte sectors)
353# 2352-byte sector version.
3540x10	string	SEGA\ SEGASATURN\ 	Sega Saturn disc image
355!:mime	application/x-saturn-rom
356>0x10	use	sega-saturn-disc-header
357>0	byte	x			(2352-byte sectors)
358
359#------------------------------------------------------------------------------
360# dreamcast: file(1) magic for the Sega Dreamcast disc image format.
361# From: David Korth <gerbilsoft@gerbilsoft.com>
362# Reference: https://mc.pp.se/dc/ip0000.bin.html
363#
364
365# Common Sega Dreamcast disc header format.
366# NOTE: Title is 128 bytes, but we're only showing 32 due to space padding.
367# TODO: Release date, device information, region code, others?
3680	name	sega-dreamcast-disc-header
369>0x80	string	>\0	\b: "%.32s"
370>0x40	string	>\0	(%.10s
371>>0x4A	string	>\0	\b, %.6s)
372>>0x4A	byte	0	\b)
373
374# 2048-byte sector version.
3750	string	SEGA\ SEGAKATANA\ 	Sega Dreamcast disc image
376!:mime	application/x-dc-rom
377>0	use	sega-dreamcast-disc-header
378>0	byte	x			(2048-byte sectors)
379# 2352-byte sector version.
3800x10	string	SEGA\ SEGAKATANA\ 	Sega Dreamcast disc image
381!:mime	application/x-dc-rom
382>0x10	use	sega-dreamcast-disc-header
383>0	byte	x			(2352-byte sectors)
384
385#------------------------------------------------------------------------------
386# dreamcast:  file(1) uncertain magic for the Sega Dreamcast VMU image format
387#
3880 belong 0x21068028   Sega Dreamcast VMU game image
3890 string LCDi         Dream Animator file
390
391#------------------------------------------------------------------------------
392# z64: file(1) magic for the Z64 format N64 ROM dumps
393# Reference: http://forum.pj64-emu.com/showthread.php?t=2239
394# From: David Korth <gerbilsoft@gerbilsoft.com>
395#
3960	bequad	0x803712400000000F	Nintendo 64 ROM image
397!:mime	application/x-n64-rom
398>0x20	string	>\0	\b: "%.20s"
399>0x3B	string	x	(%.4s
400>0x3F	byte	x	\b, Rev.%02u)
401
402#------------------------------------------------------------------------------
403# v64: file(1) magic for the V64 format N64 ROM dumps
404# Same as z64 format, but with 16-bit byteswapping.
405#
4060	bequad	0x3780401200000F00	Nintendo 64 ROM image (V64)
407!:mime	application/x-n64-rom
408
409#------------------------------------------------------------------------------
410# n64-swap2: file(1) magic for the swap2 format N64 ROM dumps
411# Same as z64 format, but with swapped 16-bit words.
412#
4130	bequad	0x12408037000F0000	Nintendo 64 ROM image (wordswapped)
414!:mime	application/x-n64-rom
415
416#------------------------------------------------------------------------------
417# n64-le32: file(1) magic for the 32-bit byteswapped format N64 ROM dumps
418# Same as z64 format, but with 32-bit byteswapping.
419#
4200	bequad	0x401237800F000000	Nintendo 64 ROM image (32-bit byteswapped)
421!:mime	application/x-n64-rom
422
423#------------------------------------------------------------------------------
424# gba: file(1) magic for the Nintendo Game Boy Advance raw ROM format
425# Reference: https://problemkaputt.de/gbatek.htm#gbacartridgeheader
426#
427# Original version from: "Nelson A. de Oliveira" <naoliv@gmail.com>
428# Updated version from: David Korth <gerbilsoft@gerbilsoft.com>
429#
4304	bequad	0x24FFAE51699AA221	Game Boy Advance ROM image
431!:mime	application/x-gba-rom
432>0xA0	string	>\0	\b: "%.12s"
433>0xAC	string	x	(%.6s
434>0xBC	byte	x	\b, Rev.%02u)
435
436#------------------------------------------------------------------------------
437# nds: file(1) magic for the Nintendo DS(i) raw ROM format
438# Reference: https://problemkaputt.de/gbatek.htm#dscartridgeheader
439#
440# Original version from: "Nelson A. de Oliveira" <naoliv@gmail.com>
441# Updated version from: David Korth <gerbilsoft@gerbilsoft.com>
442#
4430xC0	bequad	0x24FFAE51699AA221	Nintendo DS ROM image
444!:mime	application/x-nintendo-ds-rom
445>0x00	string	>\0		\b: "%.12s"
446>0x0C	string	x		(%.6s
447>0x1E	byte	x		\b, Rev.%02u)
448>0x12	byte	2		(DSi enhanced)
449>0x12	byte	3		(DSi only)
450# Secure Area check.
451>0x20		lelong	<0x4000		(homebrew)
452>0x20		lelong	>0x3FFF
453>>0x4000	lequad	0x0000000000000000	(multiboot)
454>>0x4000	lequad	!0x0000000000000000
455>>>0x4000	lequad	0xE7FFDEFFE7FFDEFF	(decrypted)
456>>>0x4000	lequad	!0xE7FFDEFFE7FFDEFF
457>>>>0x1000	lequad	0x0000000000000000	(encrypted)
458>>>>0x1000	lequad	!0x0000000000000000	(mask ROM)
459
460#------------------------------------------------------------------------------
461# nds_passme: file(1) magic for Nintendo DS ROM images for GBA cartridge boot.
462# This is also used for loading .nds files using the MSET exploit on 3DS.
463# Reference: https://github.com/devkitPro/ndstool/blob/master/source/ndscreate.cpp
4640xC0	bequad	0xC8604FE201708FE2	Nintendo DS Slot-2 ROM image (PassMe)
465!:mime	application/x-nintendo-ds-rom
466
467#------------------------------------------------------------------------------
468# ngp: file(1) magic for the Neo Geo Pocket (Color) raw ROM format.
469# From: David Korth <gerbilsoft@gerbilsoft.com>
470# References:
471# - https://neogpc.googlecode.com/svn-history/r10/trunk/src/core/neogpc.cpp
472# - https://www.devrs.com/ngp/files/ngpctech.txt
473#
4740x0A	string	BY\ SNK\ CORPORATION	Neo Geo Pocket
475!:mime	application/x-neo-geo-pocket-rom
476>0x23	byte	0x10			Color
477>0	byte	x			ROM image
478>0x24	string	>\0			\b: "%.12s"
479>0x1F	byte	0xFF			(debug mode enabled)
480
481#------------------------------------------------------------------------------
482# msx: file(1) magic for MSX game cartridge dumps
483# Too simple - MPi
484#0 beshort 0x4142 MSX game cartridge dump
485
486#------------------------------------------------------------------------------
487# Sony Playstation executables (Adam Sjoegren <asjo@diku.dk>) :
4880	string	PS-X\ EXE	Sony Playstation executable
489>16	lelong	x		PC=0x%08x,
490>20	lelong	!0		GP=0x%08x,
491>24	lelong	!0		.text=[0x%08x,
492>>28	lelong	x		\b0x%x],
493>32	lelong	!0		.data=[0x%08x,
494>>36	lelong	x		\b0x%x],
495>40	lelong	!0		.bss=[0x%08x,
496>>44	lelong	x		\b0x%x],
497>48	lelong	!0		Stack=0x%08x,
498>48	lelong	=0		No Stack!,
499>52	lelong	!0		StackSize=0x%x,
500#>76	string	>\0		(%s)
501#  Area:
502>113	string	x		(%s)
503
504# CPE executables
5050	string	CPE		CPE executable
506>3	byte	x		(version %d)
507
508#------------------------------------------------------------------------------
509# Microsoft Xbox executables .xbe (Esa Hyytia <ehyytia@cc.hut.fi>)
5100	string	XBEH	Microsoft Xbox executable
511!:mime	audio/x-xbox-executable
512!:ext	xbe
513# expect base address of 0x10000
514>0x0104                 ulelong =0x10000
515>>(0x0118.l-0x0FFF4)    lestring16 x       \b: "%.40s"
516>>(0x0118.l-0x0FFF5)    byte     x         (%c
517>>(0x0118.l-0x0FFF6)    byte     x         \b%c-
518>>(0x0118.l-0x0FFF8)    uleshort x         \b%03u)
519>>(0x0118.l-0x0FF60)    ulelong&0x80000007  0x80000007 \b, all regions
520>>(0x0118.l-0x0FF60)    ulelong&0x80000007  !0x80000007
521>>>(0x0118.l-0x0FF60)   ulelong >0           (regions:
522>>>>(0x0118.l-0x0FF60)  ulelong &0x00000001  NA
523>>>>(0x0118.l-0x0FF60)  ulelong &0x00000002  Japan
524>>>>(0x0118.l-0x0FF60)  ulelong &0x00000004  Rest_of_World
525>>>>(0x0118.l-0x0FF60)  ulelong &0x80000000  Manufacturer
526>>>(0x0118.l-0x0FF60)   ulelong >0           \b)
527# probabilistic checks whether signed or not
528>0x0004 ulelong =0x0
529>>&2    ulelong =0x0
530>>>&2   ulelong =0x0  \b, not signed
531>0x0004 ulelong >0
532>>&2    ulelong >0
533>>>&2   ulelong >0    \b, signed
534
535# --------------------------------
536# Microsoft Xbox data file formats
5370       string          XIP0            XIP, Microsoft Xbox data
5380       string          XTF0            XTF, Microsoft Xbox data
539
540#------------------------------------------------------------------------------
541# Microsoft Xbox 360 executables (.xex)
542# From: David Korth <gerbilsoft@gerbilsoft.com>
543# References:
544# - https://free60project.github.io/wiki/XEX.html
545# - https://github.com/xenia-project/xenia/blob/HEAD/src/xenia/kernel/util/xex2_info.h
546
547# Title ID (part of Execution ID section)
5480		name	xbox-360-xex-execution-id
549>(0.L+0xC)	byte	x	(%c
550>(0.L+0xD)	byte	x	\b%c
551>(0.L+0xE)	beshort	x	\b-%04u, media ID:
552>(0.L)		belong	x	%08X)
553
554# Region code (part of Security Info)
5550	name	xbox-360-xex-region-code
556>0	ubelong	0xFFFFFFFF	\b, all regions
557>0	ubelong	!0xFFFFFFFF
558>>0	ubelong	>0		(regions:
559>>0	ubelong&0x000000FF	0x000000FF	USA
560>>0	ubelong&0x00000100	0x00000100	Japan
561>>0	ubelong&0x00000200	0x00000200	China
562>>0	ubelong&0x0000FC00	0x0000FC00	Asia
563>>0	ubelong&0x00FF0000	0x00FF0000	PAL
564>>0	ubelong&0x00FF0000	0x00FE0000	PAL [except AU/NZ]
565>>0	ubelong&0x00FF0000	0x00010000	AU/NZ
566>>0	ubelong&0xFF000000	0xFF000000	Other
567>>0	ubelong	>0		\b)
568
5690	string	XEX2	Microsoft Xbox 360 executable
570!:mime	audio/x-xbox360-executable
571!:ext	xex
572>0x18	search/0x100	\x00\x04\x00\x06
573>>&0	use	xbox-360-xex-execution-id
574>(0x010.L+0x178)	use	xbox-360-xex-region-code
575
5760	string	XEX1	Microsoft Xbox 360 executable (XEX1)
577!:mime	audio/x-xbox360-executable
578!:ext	xex
579>0x18	search/0x100	\x00\x04\x00\x06
580>>&0	use	xbox-360-xex-execution-id
581>(0x010.L+0x154)	use	xbox-360-xex-region-code
582
583#------------------------------------------------------------------------------
584# Microsoft Xbox 360 packages
585# From: David Korth <gerbilsoft@gerbilsoft.com>
586# References:
587# - https://free60project.github.io/wiki/STFS.html
588# - https://github.com/xenia-project/xenia/blob/HEAD/src/xenia/kernel/util/xex2_info.h
589
590# TODO: More information for console-signed packages.
591
5920	name	xbox-360-package
593>0x360	byte	x	(%c
594>0x361	byte	x	\b%c
595>0x362	beshort	x	\b-%04u, media ID:
596>0x354	belong	x	%08X)
597>0x344	belong	x	\b, content type:
598>>0x344	belong	0x1		Saved Game
599>>0x344	belong	0x2		Marketplace Content
600>>0x344	belong	0x3		Publisher
601>>0x344	belong	0x1000		Xbox 360 Title
602>>0x344	belong	0x2000		IPTV Pause Buffer
603>>0x344	belong	0x4000		Installed Game
604>>0x344	belong	0x5000		Original Xbox Game
605>>0x344	belong	0x9000		Avatar Item
606>>0x344	belong	0x10000		Profile
607>>0x344	belong	0x20000		Gamer Picture
608>>0x344	belong	0x30000		Theme
609>>0x344	belong	0x40000		Cache File
610>>0x344	belong	0x50000		Storage Download
611>>0x344	belong	0x60000		Xbox Saved Game
612>>0x344	belong	0x70000		Xbox Download
613>>0x344	belong	0x80000		Game Demo
614>>0x344	belong	0x90000		Video
615>>0x344	belong	0xA0000		Game
616>>0x344	belong	0xB0000		Installer
617>>0x344	belong	0xC0000		Game Trailer
618>>0x344	belong	0xD0000		Arcade Title
619>>0x344	belong	0xE0000		XNA
620>>0x344	belong	0xF0000		License Store
621>>0x344	belong	0x100000	Movie
622>>0x344	belong	0x200000	TV
623>>0x344	belong	0x300000	Music Video
624>>0x344	belong	0x400000	Game Video
625>>0x344	belong	0x500000	Podcast Video
626>>0x344	belong	0x600000	Viral Video
627>>0x344	belong	0x2000000	Community Game
628
6290	string	CON\x20	Microsoft Xbox 360 package (console-signed)
630>0	use	xbox-360-package
6310	string	PIRS
632>0	belong	0	Microsoft Xbox 360 package (non-Xbox Live)
633>>0	use	xbox-360-package
6340	string	LIVE
635>0x104	belong	0	Microsoft Xbox 360 package (Xbox Live)
636>>0	use	xbox-360-package
637
638# Atari Lynx cartridge dump (EXE/BLL header)
639# From: "Stefan A. Haubenthal" <polluks@web.de>
640
641# Double-check that the image type matches too, 0x8008 conflicts with
642# 8 character OMF-86 object file headers.
6430	beshort		0x8008
644>6	string		BS93		Lynx homebrew cartridge
645!:mime	application/x-atari-lynx-rom
646>>2	beshort		x		\b, RAM start $%04x
647>6	string		LYNX		Lynx cartridge
648!:mime	application/x-atari-lynx-rom
649>>2	beshort		x		\b, RAM start $%04x
650
651# Opera file system that is used on the 3DO console
652# From: Serge van den Boom <svdb@stack.nl>
6530	string		\x01ZZZZZ\x01	3DO "Opera" file system
654
655# From: Alex Myczko <alex@aiei.ch>
656# From: David Pflug <david@pflug.email>
657# is the offset 12 or the offset 16 correct?
658# GBS (Game Boy Sound) magic
659# ftp://ftp.modland.com/pub/documents/format_documentation/\
660# Gameboy%20Sound%20System%20(.gbs).txt
6610	string		GBS		Nintendo Gameboy Music/Audio Data
662#12	string		GameBoy\ Music\ Module	Nintendo Gameboy Music Module
663>16	string		>\0	("%.32s" by
664>48	string		>\0	%.32s, copyright
665>80	string		>\0	%.32s),
666>3	byte		x	version %u,
667>4	byte		x	%u tracks
668
669# IPS Patch Files from: From: Thomas Klausner <tk@giga.or.at>
670# see https://zerosoft.zophar.net/ips.php
6710	string	PATCH			IPS patch file
672!:ext	ips
673
674# BPS Patch Files - from: David Korth <gerbilsoft@gerbilsoft.com>
675# Reference: https://www.romhacking.net/documents/746/
6760	string	BPS1			BPS patch file
677!:ext	bps
678
679# APS Patch Files - from: David Korth <gerbilsoft@gerbilsoft.com>
680# Reference: https://github.com/btimofeev/UniPatcher/wiki/APS-(N64)
6810	string	APS10			APS patch file
682!:ext	aps
683>5	byte	0			\b, simple patch
684>5	byte	1			\b, N64-specific patch for
685>>58	byte	x			N%c
686>>59	byte	x			\b%c
687>>60	byte	x			\b%c
688>7	byte	!0x20
689# FIXME: /T specifier isn't working with a fixed-length string.
690>>7	string	x			\b: "%.50s"
691
692# UPS Patch Files - from: David Korth <gerbilsoft@gerbilsoft.com>
693# Reference: http://fileformats.archiveteam.org/wiki/UPS_(binary_patch_format)
6940	string	UPS1			UPS patch file
695!:ext	ups
696
697# Playstations Patch Files from: From: Thomas Klausner <tk@giga.or.at>
6980	string	PPF30			Playstation Patch File version 3.0
699>5	byte	0			\b, PPF 1.0 patch
700>5	byte	1			\b, PPF 2.0 patch
701>5	byte	2			\b, PPF 3.0 patch
702>>56	byte	0			\b, Imagetype BIN (any)
703>>56	byte	1			\b, Imagetype GI (PrimoDVD)
704>>57	byte	0			\b, Blockcheck disabled
705>>57	byte	1			\b, Blockcheck enabled
706>>58	byte	0			\b, Undo data not available
707>>58	byte	1			\b, Undo data available
708>6	string	x			\b, description: %s
709
7100	string	PPF20			Playstation Patch File version 2.0
711>5	byte	0			\b, PPF 1.0 patch
712>5	byte	1			\b, PPF 2.0 patch
713>>56	lelong	>0			\b, size of file to patch %d
714>6	string	x			\b, description: %s
715
7160	string	PPF10			Playstation Patch File version 1.0
717>5	byte	0			\b, Simple Encoding
718>6	string	x			\b, description: %s
719
720# From: Daniel Dawson <ddawson@icehouse.net>
721# SNES9x .smv "movie" file format.
7220		string		SMV\x1A	SNES9x input recording
723>0x4		lelong		x	\b, version %d
724# version 4 is latest so far
725>0x4		lelong		<5
726>>0x8		ledate		x	\b, recorded at %s
727>>0xc		lelong		>0	\b, rerecorded %d times
728>>0x10		lelong		x	\b, %d frames long
729>>0x14		byte		>0	\b, data for controller(s):
730>>>0x14		byte		&0x1	#1
731>>>0x14		byte		&0x2	#2
732>>>0x14		byte		&0x4	#3
733>>>0x14		byte		&0x8	#4
734>>>0x14		byte		&0x10	#5
735>>0x15		byte		^0x1	\b, begins from snapshot
736>>0x15		byte		&0x1	\b, begins from reset
737>>0x15		byte		^0x2	\b, NTSC standard
738>>0x15		byte		&0x2	\b, PAL standard
739>>0x17		byte		&0x1    \b, settings:
740# WIP1Timing not used as of version 4
741>>>0x4		lelong		<4
742>>>>0x17	byte		&0x2	WIP1Timing
743>>>0x17		byte		&0x4	Left+Right
744>>>0x17		byte		&0x8	VolumeEnvX
745>>>0x17		byte		&0x10	FakeMute
746>>>0x17		byte		&0x20	SyncSound
747# New flag as of version 4
748>>>0x4		lelong		>3
749>>>>0x17	byte		&0x80	NoCPUShutdown
750>>0x4		lelong		<4
751>>>0x18		lelong		>0x23
752>>>>0x20	leshort		!0
753>>>>>0x20	lestring16	x	\b, metadata: "%s"
754>>0x4		lelong		>3
755>>>0x24		byte		>0	\b, port 1:
756>>>>0x24	byte		1	joypad
757>>>>0x24	byte		2	mouse
758>>>>0x24	byte		3	SuperScope
759>>>>0x24	byte		4	Justifier
760>>>>0x24	byte		5	multitap
761>>>0x24		byte		>0	\b, port 2:
762>>>>0x25	byte		1	joypad
763>>>>0x25	byte		2	mouse
764>>>>0x25	byte		3	SuperScope
765>>>>0x25	byte		4	Justifier
766>>>>0x25	byte		5	multitap
767>>>0x18		lelong		>0x43
768>>>>0x40	leshort		!0
769>>>>>0x40	lestring16	x	\b, metadata: "%s"
770>>0x17		byte		&0x40   \b, ROM:
771>>>(0x18.l-26)	lelong		x	CRC32 0x%08x
772>>>(0x18.l-23)	string		x	"%s"
773
774# Type: scummVM savegame files
775# From: Sven Hartge <debian@ds9.argh.org>
7760	string	SCVM	ScummVM savegame
777>12	string	>\0	"%s"
778
779#------------------------------------------------------------------------------
780# Nintendo GameCube / Wii file formats.
781#
782
783# Type: Nintendo GameCube/Wii common disc header data.
784# From: David Korth <gerbilsoft@gerbilsoft.com>
785# Reference: https://wiibrew.org/wiki/Wii_Disc
7860	name	nintendo-gcn-disc-common
787>0x20	string	x	"%.64s"
788>0x00	string	x	(%.6s
789>0x06	byte	>0
790>>0x06	byte	1	\b, Disc 2
791>>0x06	byte	2	\b, Disc 3
792>>0x06	byte	3	\b, Disc 4
793>0x07	byte	x	\b, Rev.%02u)
794>0x18	belong	0x5D1C9EA3
795>>0x60	beshort	0x0101	\b (Unencrypted)
796>0x200	string	NKIT	\b (NKit compressed)
797
798
799# Type: Nintendo GameCube disc image
800# From: David Korth <gerbilsoft@gerbilsoft.com>
801# Reference: https://wiibrew.org/wiki/Wii_Disc
8020x1C	belong	0xC2339F3D	Nintendo GameCube disc image:
803!:mime	application/x-gamecube-rom
804>0	use	nintendo-gcn-disc-common
805
806# Type: Nintendo GameCube embedded disc image
807# Commonly found on demo discs.
808# From: David Korth <gerbilsoft@gerbilsoft.com>
809# Reference: http://hitmen.c02.at/files/yagcd/yagcd/index.html#idx14.8
8100		belong	0xAE0F38A2
811>0x0C		belong	0x00100000
812>>(8.L+0x1C)	belong	0xC2339F3D	Nintendo GameCube embedded disc image:
813!:mime	application/x-gamecube-rom
814>>>(8.L)	use	nintendo-gcn-disc-common
815
816# Type: Nintendo Wii disc image
817# From: David Korth <gerbilsoft@gerbilsoft.com>
818# Reference: https://wiibrew.org/wiki/Wii_Disc
8190x18	belong	0x5D1C9EA3	Nintendo Wii disc image:
820>0	use	nintendo-gcn-disc-common
821
822# Type: Nintendo Wii disc image (WBFS format)
823# From: David Korth <gerbilsoft@gerbilsoft.com>
824# Reference: https://wiibrew.org/wiki/Wii_Disc
8250	string	WBFS
826>0x218	belong	0x5D1C9EA3	Nintendo Wii disc image (WBFS format):
827!:mime	application/x-wii-rom
828>>0x200	use	nintendo-gcn-disc-common
829
830# Type: Nintendo GameCube/Wii disc image (CISO format)
831# NOTE: This is NOT the same as Compact ISO or PSP CISO,
832# though it has the same magic number.
8330		string	CISO
834# Other fields are used to determine what type of CISO this is:
835# - 0x04 == 0x00200000: GameCube/Wii CISO (block_size)
836# - 0x10 == 0x00000800: PSP CISO (ISO-9660 sector size)
837# - None of the above: Compact ISO.
838>4		lelong	0x200000
839>>8		byte	1
840>>>0x801C	belong	0xC2339F3D	Nintendo GameCube disc image (CISO format):
841!:mime	application/x-wii-rom
842>>>>0x8000	use	nintendo-gcn-disc-common
843>>>0x8018	belong	0x5D1C9EA3	Nintendo Wii disc image (CISO format):
844!:mime	application/x-wii-rom
845>>>>0x8000	use	nintendo-gcn-disc-common
846
847# Type: Nintendo GameCube/Wii disc image (GCZ format)
848# Due to zlib compression, we can't get the actual disc information.
8490	lelong	0xB10BC001
850>4	lelong	0		Nintendo GameCube disc image (GCZ format)
851!:mime	application/x-gamecube-rom
852>4	lelong	1		Nintendo Wii disc image (GCZ format)
853!:mime	application/x-wii-rom
854>4	default	x		Nintendo GameCube/Wii disc image (GCZ format)
855
856# Type: Nintendo GameCube/Wii disc image (WDF format)
8570		string	WII\001DISC
858>8		belong	1
859# WDFv1
860>>0x54		belong	0xC2339F3D	Nintendo GameCube disc image (WDFv1 format):
861!:mime	application/x-gamecube-rom
862>>>0x38		use	nintendo-gcn-disc-common
863>>0x58		belong	0x5D1C9EA3	Nintendo Wii disc image (WDFv1 format):
864!:mime	application/x-wii-rom
865>>>0x38		use	nintendo-gcn-disc-common
866>8		belong	2
867# WDFv2
868>>(12.L+0x1C)	belong	0xC2339F3D	Nintendo GameCube disc image (WDFv2 format):
869!:mime	application/x-gamecube-rom
870>>>(12.L)	use	nintendo-gcn-disc-common
871>>(12.L+0x18)	belong	0x5D1C9EA3	Nintendo Wii disc image (WDFv2 format):
872!:mime	application/x-wii-rom
873>>>(12.L)	use	nintendo-gcn-disc-common
874
875# Type: Nintendo GameCube/Wii disc image (WIA format)
8760	string	WIA\001	Nintendo
877>0x48	belong	1	GameCube
878!:mime	application/x-gamecube-rom
879>0x48	belong	2	Wii
880!:mime	application/x-wii-rom
881>0x48	default	x	GameCube/Wii
882>0x48	belong	x	disc image (WIA format):
883>>0x58	use	nintendo-gcn-disc-common
884
885# Type: Nintendo GameCube/Wii disc image (with SDK header)
886# From: David Korth <gerbilsoft@gerbilsoft.com>
887# Reference: https://wiibrew.org/wiki/Wii_Disc
8880		belong	0xFFFF0000
889>0x18		belong	0x00000000
890>>0x1C		belong	0x00000000
891>>>0x8018	belong	0x5D1C9EA3	Nintendo Wii SDK disc image:
892!:mime	application/x-wii-rom
893>>>>0x8000	use	nintendo-gcn-disc-common
894>>>0x801C	belong	0xC2339F3D	Nintendo GameCube SDK disc image:
895!:mime	application/x-gamecube-rom
896>>>>0x8000	use	nintendo-gcn-disc-common
897
898#------------------------------------------------------------------------------
899# Nintendo 3DS file formats.
900#
901
902# Type: Nintendo 3DS "NCSD" image. (game cards and eMMC)
903# From: David Korth <gerbilsoft@gerbilsoft.com>
904# Reference: https://www.3dbrew.org/wiki/NCSD
9050x100		string		NCSD
906>0x118		lequad		0		Nintendo 3DS Game Card image
907# NCCH header for partition 0. (game data)
908>>0x1150	string		>\0	\b: "%.16s"
909>>0x312		byte		x	(Rev.%02u)
910>>0x118C	byte		2	(New3DS only)
911>>0x18D		byte		0		(inner device)
912>>0x18D		byte		1		(Card1)
913>>0x18D		byte		2		(Card2)
914>>0x18D		byte		3		(extended device)
915>0x118		bequad		0x0102020202000000	Nintendo 3DS eMMC dump (Old3DS)
916>0x118		bequad		0x0102020203000000	Nintendo 3DS eMMC dump (New3DS)
917
918# Nintendo 3DS version code.
919# Reference: https://www.3dbrew.org/wiki/Titles
920# Format: leshort containing three fields:
921# - 6-bit: Major
922# - 6-bit: Minor
923# - 4-bit: Revision
924# NOTE: Only supporting major/minor versions from 0-15 right now.
925# NOTE: Should be prefixed with "v".
9260	name	nintendo-3ds-version-code
927# Raw version.
928>0	leshort	x	\b%u,
929# Major version.
930>0	leshort&0xFC00	0x0000	0
931>0	leshort&0xFC00	0x0400	1
932>0	leshort&0xFC00	0x0800	2
933>0	leshort&0xFC00	0x0C00	3
934>0	leshort&0xFC00	0x1000	4
935>0	leshort&0xFC00	0x1400	5
936>0	leshort&0xFC00	0x1800	6
937>0	leshort&0xFC00	0x1C00	7
938>0	leshort&0xFC00	0x2000	8
939>0	leshort&0xFC00	0x2400	9
940>0	leshort&0xFC00	0x2800	10
941>0	leshort&0xFC00	0x2C00	11
942>0	leshort&0xFC00	0x3000	12
943>0	leshort&0xFC00	0x3400	13
944>0	leshort&0xFC00	0x3800	14
945>0	leshort&0xFC00	0x3C00	15
946# Minor version.
947>0	leshort&0x03F0	0x0000	\b.0
948>0	leshort&0x03F0	0x0010	\b.1
949>0	leshort&0x03F0	0x0020	\b.2
950>0	leshort&0x03F0	0x0030	\b.3
951>0	leshort&0x03F0	0x0040	\b.4
952>0	leshort&0x03F0	0x0050	\b.5
953>0	leshort&0x03F0	0x0060	\b.6
954>0	leshort&0x03F0	0x0070	\b.7
955>0	leshort&0x03F0	0x0080	\b.8
956>0	leshort&0x03F0	0x0090	\b.9
957>0	leshort&0x03F0	0x00A0	\b.10
958>0	leshort&0x03F0	0x00B0	\b.11
959>0	leshort&0x03F0	0x00C0	\b.12
960>0	leshort&0x03F0	0x00D0	\b.13
961>0	leshort&0x03F0	0x00E0	\b.14
962>0	leshort&0x03F0	0x00F0	\b.15
963# Revision.
964>0	leshort&0x000F	x	\b.%u
965
966# Type: Nintendo 3DS "NCCH" container.
967# https://www.3dbrew.org/wiki/NCCH
9680x100		string	NCCH	Nintendo 3DS
969>0x18D		byte&2	0	File Archive (CFA)
970>0x18D		byte&2	2	Executable Image (CXI)
971>0x150		string	>\0	\b: "%.16s"
972>0x18D		byte	0x05
973>>0x10E		leshort	x	(Old3DS System Update v
974>>0x10E		use	nintendo-3ds-version-code
975>>0x10E		leshort	x	\b)
976>0x18D		byte	0x15
977>>0x10E		leshort	x	(New3DS System Update v
978>>0x10E		use	nintendo-3ds-version-code
979>>0x10E		leshort	x	\b)
980>0x18D		byte	!0x05
981>>0x18D		byte	!0x15
982>>>0x112	byte	x	(v
983>>>0x112	use	nintendo-3ds-version-code
984>>>0x112	byte	x	\b)
985>0x18C		byte	2	(New3DS only)
986
987# Type: Nintendo 3DS "SMDH" file. (application description)
988# From: David Korth <gerbilsoft@gerbilsoft.com>
989# Reference: https://3dbrew.org/wiki/SMDH
9900		string		SMDH		Nintendo 3DS SMDH file
991>0x208		leshort		!0
992>>0x208		lestring16	x		\b: "%.128s"
993>>0x388		leshort		!0
994>>>0x388	lestring16	x		by %.128s
995>0x208		leshort		0
996>>0x008		leshort		!0
997>>>0x008	lestring16	x		\b: "%.128s"
998>>>0x188	leshort		!0
999>>>>0x188	lestring16	x		by %.128s
1000
1001# Type: Nintendo 3DS Homebrew Application.
1002# From: David Korth <gerbilsoft@gerbilsoft.com>
1003# Reference: https://3dbrew.org/wiki/3DSX_Format
10040	string	3DSX	Nintendo 3DS Homebrew Application (3DSX)
1005
1006#------------------------------------------------------------------------------
1007# a7800: file(1) magic for the Atari 7800 raw ROM format.
1008# From: David Korth <gerbilsoft@gerbilsoft.com>
1009# Reference: https://sites.google.com/site/atari7800wiki/a78-header
1010
10110	byte	>0
1012>0	byte	<3
1013>>1	string	ATARI7800	Atari 7800 ROM image
1014!:mime	application/x-atari-7800-rom
1015>>>0x11	string	>\0	\b: "%.32s"
1016# Display type.
1017>>>0x39	byte	0	(NTSC)
1018>>>0x39	byte	1	(PAL)
1019>>>0x36	byte&1	1	(POKEY)
1020
1021#------------------------------------------------------------------------------
1022# vectrex: file(1) magic for the GCE Vectrex raw ROM format.
1023# From: David Korth <gerbilsoft@gerbilsoft.com>
1024# Reference: http://www.playvectrex.com/designit/chrissalo/hello1.htm
1025#
1026# NOTE: Title is terminated with 0x80, not 0.
1027# The header is terminated with a 0, so that will
1028# terminate the title as well.
1029#
10300	string	g\ GCE	Vectrex ROM image
1031>0x11	string	>\0	\b: "%.16s"
1032
1033#------------------------------------------------------------------------------
1034# amiibo: file(1) magic for Nintendo amiibo NFC dumps.
1035# From: David Korth <gerbilsoft@gerbilsoft.com>
1036# Reference: https://www.3dbrew.org/wiki/Amiibo
10370x00		byte	0x04
1038>0x0A		beshort	0x0FE0
1039>>0x0C		belong	0xF110FFEE
1040>>>0x208	beshort	0x0100
1041>>>>0x020A	byte	0x0F
1042>>>>>0x020C	bequad	0x000000045F000000
1043>>>>>>0x5B	byte	0x02
1044>>>>>>>0x54	belong	x	Nintendo amiibo NFC dump - amiibo ID: %08X-
1045>>>>>>>0x58	belong	x	\b%08X
1046
1047#------------------------------------------------------------------------------
1048# Type: Nintendo Switch XCI (Game Cartridge Image)
1049# From: Benjamin Lowry <ben@ben.gmbh>
1050# Reference: https://switchbrew.org/wiki/Gamecard_Format
10510x100		string	HEAD
1052>0x10D		byte	0xFA	Nintendo Switch cartridge image (XCI), 1GB
1053>0x10D		byte	0xF8	Nintendo Switch cartridge image (XCI), 2GB
1054>0x10D		byte	0xF0	Nintendo Switch cartridge image (XCI), 4GB
1055>0x10D		byte	0xE0	Nintendo Switch cartridge image (XCI), 8GB
1056>0x10D		byte	0xE1	Nintendo Switch cartridge image (XCI), 16GB
1057>0x10D		byte	0xE2	Nintendo Switch cartridge image (XCI), 32GB
1058
1059#------------------------------------------------------------------------------
1060# Type: Nintendo Switch Executable
1061# From: Benjamin Lowry <ben@ben.gmbh>
1062# Reference: https://switchbrew.org/wiki/NSO
10630x00		string	NSO0	Nintendo Switch executable (NSO)
1064
1065#------------------------------------------------------------------------------
1066# Type: Nintendo Switch PFS0
1067# From: Benjamin Lowry <ben@ben.gmbh>
1068# Reference: https://switchbrew.org/wiki/NCA_Format#PFS0
10690x00		string	PFS0	Nintendo Switch partition filesystem (PFS0)
1070>0x04		ulelong	x	\b, %d files
1071
1072#------------------------------------------------------------------------------
1073# amiibo: file(1) magic for Nintendo Badge Arcade files.
1074# From: David Korth <gerbilsoft@gerbilsoft.com>
1075# References:
1076# - https://github.com/GerbilSoft/rom-properties/issues/92
1077# - https://github.com/CaitSith2/BadgeArcadeTool
1078# - https://github.com/TheMachinumps/Advanced-badge-editor
1079
1080# PRBS: Individual badge and/or mega badge.
10810		string	PRBS
1082>0x44		byte	>0x20	Nintendo Badge Arcade
1083>>0xB8		ulelong	<2
1084>>>0xBC		ulelong	<2	badge:
1085>>>0xBC		ulelong	>1	Mega Badge
1086>>>>0xB8	ulelong	x	(%ux
1087>>>>0xBC	ulelong	x	\b%u):
1088>>0xB8		ulelong	>1	Mega Badge
1089>>>0xB8		ulelong	x	(%ux
1090>>>0xBC		ulelong	x	\b%u):
1091>0x44		string	x	"%s"
1092>0x3C		ulelong	x	\b, badge ID: %u
1093>0x74		byte	>0x20
1094>>0x74		string	x	\b, set: "%s"
1095>0xA8		ulelong	!0xFFFFFFFF
1096>>0xA8		ulelong	x	\b, launch title ID: %08X
1097>>0xA4		ulelong	x	\b-%08X
1098
1099# CABS: Badge set.
11000	string	CABS
1101>0x2C	byte	>0x20	Nintendo Badge Arcade badge set:
1102>>0x2C	string	x	"%.48s"
1103>>0x24	ulelong	x	\b, set ID: %u
1104