xref: /dragonfly/contrib/file/magic/Magdir/console (revision 9ef1e017)
1
2#------------------------------------------------------------------------------
3# $File: console,v 1.63 2021/04/26 15:56:00 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# 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, 32X, Pico, and Mega CD Boot ROM images.
2320x100		string	SEGA
233>0x3C0		bequad	0x4D41525320434845	Sega 32X ROM image
234!:mime		application/x-genesis-32x-rom
235>>0		use	sega-mega-drive-header
236>0x3C0		bequad	!0x4D41525320434845
237>>0x105		belong	0x5049434F	Sega Pico ROM image
238!:mime		application/x-sega-pico-rom
239>>>0		use	sega-mega-drive-header
240>>0x105		belong	!0x5049434F
241>>>0x180	beshort	0x4252		Sega Mega CD Boot ROM image
242!:mime		application/x-genesis-rom
243>>>0x180	beshort	!0x4252		Sega Mega Drive / Genesis ROM image
244!:mime		application/x-genesis-rom
245>>>0		use	sega-mega-drive-header
246
247#------------------------------------------------------------------------------
248# genesis: file(1) magic for the Super MegaDrive ROM dump format
249#
250
251# NOTE: Due to interleaving, we can't display anything
252# other than the copier header information.
2530      name    sega-genesis-smd-header
254>0     byte    x       %dx16k blocks
255>2     byte    0       \b, last in series or standalone
256>2     byte    >0      \b, split ROM
257
258# "Sega Genesis" header.
2590x280	string EAGN
260>8	beshort	0xAABB	Sega Mega Drive / Genesis ROM image (SMD format):
261!:mime	application/x-genesis-rom
262>>0	use     sega-genesis-smd-header
263
264# "Sega Mega Drive" header.
2650x280	string EAMG
266>8	beshort	0xAABB	Sega Mega Drive / Genesis ROM image (SMD format):
267!:mime	application/x-genesis-rom
268>>0	use     sega-genesis-smd-header
269
270#------------------------------------------------------------------------------
271# smsgg:  file(1) magic for Sega Master System and Game Gear ROM images
272# Detects all Game Gear and export Sega Master System ROM images,
273# and some Japanese Sega Master System ROM images.
274# From: David Korth <gerbilsoft@gerbilsoft.com>
275# Reference: https://www.smspower.org/Development/ROMHeader
276#
277
278# General SMS header rule.
279# The SMS boot ROM checks the header at three locations.
2800	name	sega-master-system-rom-header
281# Machine type.
282>0x0F	byte&0xF0	0x30	Sega Master System
283!:mime	application/x-sms-rom
284>0x0F	byte&0xF0	0x40	Sega Master System
285!:mime	application/x-sms-rom
286>0x0F	byte&0xF0	0x50	Sega Game Gear
287!:mime	application/x-gamegear-rom
288>0x0F	byte&0xF0	0x60	Sega Game Gear
289!:mime	application/x-gamegear-rom
290>0x0F	byte&0xF0	0x70	Sega Game Gear
291!:mime	application/x-gamegear-rom
292>0x0F	default		x	Sega Master System / Game Gear
293!:mime	application/x-sms-rom
294>0	byte		x	ROM image:
295# Product code.
296>0x0E	byte&0xF0	0x10	1
297>0x0E	byte&0xF0	0x20	2
298>0x0E	byte&0xF0	0x30	3
299>0x0E	byte&0xF0	0x40	4
300>0x0E	byte&0xF0	0x50	5
301>0x0E	byte&0xF0	0x60	6
302>0x0E	byte&0xF0	0x70	7
303>0x0E	byte&0xF0	0x80	8
304>0x0E	byte&0xF0	0x90	9
305>0x0E	byte&0xF0	0xA0	10
306>0x0E	byte&0xF0	0xB0	11
307>0x0E	byte&0xF0	0xC0	12
308>0x0E	byte&0xF0	0xD0	13
309>0x0E	byte&0xF0	0xE0	14
310>0x0E	byte&0xF0	0xF0	15
311# If the product code is 5 digits, we'll need to backspace here.
312>0x0E	byte&0xF0	!0
313>>0x0C	leshort		x	\b%04x
314>0x0E	byte&0xF0	0
315>>0x0C	leshort		x	%04x
316# Revision.
317>0x0E	byte&0x0F	x	(Rev.%02d)
318# ROM size. (Used for the boot ROM checksum routine.)
319>0x0F	byte&0x0F	0x0A	(8 KB)
320>0x0F	byte&0x0F	0x0B	(16 KB)
321>0x0F	byte&0x0F	0x0C	(32 KB)
322>0x0F	byte&0x0F	0x0D	(48 KB)
323>0x0F	byte&0x0F	0x0E	(64 KB)
324>0x0F	byte&0x0F	0x0F	(128 KB)
325>0x0F	byte&0x0F	0x00	(256 KB)
326>0x0F	byte&0x0F	0x01	(512 KB)
327>0x0F	byte&0x0F	0x02	(1 MB)
328
329# SMS/GG header locations.
3300x7FF0	string	TMR\ SEGA
331>0x7FF0	use	sega-master-system-rom-header
3320x3FF0	string	TMR\ SEGA
333>0x3FF0	use	sega-master-system-rom-header
3340x1FF0	string	TMR\ SEGA
335>0x1FF0	use	sega-master-system-rom-header
336
337#------------------------------------------------------------------------------
338# saturn: file(1) magic for the Sega Saturn disc image format.
339# From: David Korth <gerbilsoft@gerbilsoft.com>
340#
341
342# Common Sega Saturn disc header format.
343# NOTE: Title is 112 bytes, but we're only showing 32 due to space padding.
344# TODO: Release date, device information, region code, others?
3450	name	sega-saturn-disc-header
346>0x60	string	>\0	\b: "%.32s"
347>0x20	string	>\0	(%.10s
348>>0x2A	string	>\0	\b, %.6s)
349>>0x2A	byte	0	\b)
350
351# 2048-byte sector version.
3520	string	SEGA\ SEGASATURN\ 	Sega Saturn disc image
353!:mime	application/x-saturn-rom
354>0	use	sega-saturn-disc-header
355>0	byte	x			(2048-byte sectors)
356# 2352-byte sector version.
3570x10	string	SEGA\ SEGASATURN\ 	Sega Saturn disc image
358!:mime	application/x-saturn-rom
359>0x10	use	sega-saturn-disc-header
360>0	byte	x			(2352-byte sectors)
361
362#------------------------------------------------------------------------------
363# dreamcast: file(1) magic for the Sega Dreamcast disc image format.
364# From: David Korth <gerbilsoft@gerbilsoft.com>
365# Reference: https://mc.pp.se/dc/ip0000.bin.html
366#
367
368# Common Sega Dreamcast disc header format.
369# NOTE: Title is 128 bytes, but we're only showing 32 due to space padding.
370# TODO: Release date, device information, region code, others?
3710	name	sega-dreamcast-disc-header
372>0x80	string	>\0	\b: "%.32s"
373>0x40	string	>\0	(%.10s
374>>0x4A	string	>\0	\b, %.6s)
375>>0x4A	byte	0	\b)
376
377# 2048-byte sector version.
3780	string	SEGA\ SEGAKATANA\ 	Sega Dreamcast disc image
379!:mime	application/x-dc-rom
380>0	use	sega-dreamcast-disc-header
381>0	byte	x			(2048-byte sectors)
382# 2352-byte sector version.
3830x10	string	SEGA\ SEGAKATANA\ 	Sega Dreamcast disc image
384!:mime	application/x-dc-rom
385>0x10	use	sega-dreamcast-disc-header
386>0	byte	x			(2352-byte sectors)
387
388#------------------------------------------------------------------------------
389# dreamcast:  file(1) uncertain magic for the Sega Dreamcast VMU image format
390#
3910 belong 0x21068028   Sega Dreamcast VMU game image
3920 string LCDi         Dream Animator file
393
394#------------------------------------------------------------------------------
395# z64: file(1) magic for the Z64 format N64 ROM dumps
396# Reference: http://forum.pj64-emu.com/showthread.php?t=2239
397# From: David Korth <gerbilsoft@gerbilsoft.com>
398#
3990	bequad	0x803712400000000F	Nintendo 64 ROM image
400!:mime	application/x-n64-rom
401>0x20	string	>\0	\b: "%.20s"
402>0x3B	string	x	(%.4s
403>0x3F	byte	x	\b, Rev.%02u)
404
405#------------------------------------------------------------------------------
406# v64: file(1) magic for the V64 format N64 ROM dumps
407# Same as z64 format, but with 16-bit byteswapping.
408#
4090	bequad	0x3780401200000F00	Nintendo 64 ROM image (V64)
410!:mime	application/x-n64-rom
411
412#------------------------------------------------------------------------------
413# n64-swap2: file(1) magic for the swap2 format N64 ROM dumps
414# Same as z64 format, but with swapped 16-bit words.
415#
4160	bequad	0x12408037000F0000	Nintendo 64 ROM image (wordswapped)
417!:mime	application/x-n64-rom
418
419#------------------------------------------------------------------------------
420# n64-le32: file(1) magic for the 32-bit byteswapped format N64 ROM dumps
421# Same as z64 format, but with 32-bit byteswapping.
422#
4230	bequad	0x401237800F000000	Nintendo 64 ROM image (32-bit byteswapped)
424!:mime	application/x-n64-rom
425
426#------------------------------------------------------------------------------
427# gba: file(1) magic for the Nintendo Game Boy Advance raw ROM format
428# Reference: https://problemkaputt.de/gbatek.htm#gbacartridgeheader
429#
430# Original version from: "Nelson A. de Oliveira" <naoliv@gmail.com>
431# Updated version from: David Korth <gerbilsoft@gerbilsoft.com>
432#
4334	bequad	0x24FFAE51699AA221	Game Boy Advance ROM image
434!:mime	application/x-gba-rom
435>0xA0	string	>\0	\b: "%.12s"
436>0xAC	string	x	(%.6s
437>0xBC	byte	x	\b, Rev.%02u)
438
439#------------------------------------------------------------------------------
440# nds: file(1) magic for the Nintendo DS(i) raw ROM format
441# Reference: https://problemkaputt.de/gbatek.htm#dscartridgeheader
442#
443# Original version from: "Nelson A. de Oliveira" <naoliv@gmail.com>
444# Updated version from: David Korth <gerbilsoft@gerbilsoft.com>
445#
4460xC0	bequad	0x24FFAE51699AA221	Nintendo DS ROM image
447!:mime	application/x-nintendo-ds-rom
448>0x00	string	>\0		\b: "%.12s"
449>0x0C	string	x		(%.6s
450>0x1E	byte	x		\b, Rev.%02u)
451>0x12	byte	2		(DSi enhanced)
452>0x12	byte	3		(DSi only)
453# Secure Area check.
454>0x20		lelong	<0x4000		(homebrew)
455>0x20		lelong	>0x3FFF
456>>0x4000	lequad	0x0000000000000000	(multiboot)
457>>0x4000	lequad	!0x0000000000000000
458>>>0x4000	lequad	0xE7FFDEFFE7FFDEFF	(decrypted)
459>>>0x4000	lequad	!0xE7FFDEFFE7FFDEFF
460>>>>0x1000	lequad	0x0000000000000000	(encrypted)
461>>>>0x1000	lequad	!0x0000000000000000	(mask ROM)
462
463#------------------------------------------------------------------------------
464# nds_passme: file(1) magic for Nintendo DS ROM images for GBA cartridge boot.
465# This is also used for loading .nds files using the MSET exploit on 3DS.
466# Reference: https://github.com/devkitPro/ndstool/blob/master/source/ndscreate.cpp
4670xC0	bequad	0xC8604FE201708FE2	Nintendo DS Slot-2 ROM image (PassMe)
468!:mime	application/x-nintendo-ds-rom
469
470#------------------------------------------------------------------------------
471# ngp: file(1) magic for the Neo Geo Pocket (Color) raw ROM format.
472# From: David Korth <gerbilsoft@gerbilsoft.com>
473# References:
474# - https://neogpc.googlecode.com/svn-history/r10/trunk/src/core/neogpc.cpp
475# - https://www.devrs.com/ngp/files/ngpctech.txt
476#
4770x0A	string	BY\ SNK\ CORPORATION	Neo Geo Pocket
478!:mime	application/x-neo-geo-pocket-rom
479>0x23	byte	0x10			Color
480>0	byte	x			ROM image
481>0x24	string	>\0			\b: "%.12s"
482>0x1F	byte	0xFF			(debug mode enabled)
483
484#------------------------------------------------------------------------------
485# msx: file(1) magic for MSX game cartridge dumps
486# Too simple - MPi
487#0 beshort 0x4142 MSX game cartridge dump
488
489#------------------------------------------------------------------------------
490# Sony Playstation executables (Adam Sjoegren <asjo@diku.dk>) :
4910	string	PS-X\ EXE	Sony Playstation executable
492>16	lelong	x		PC=%#08x,
493>20	lelong	!0		GP=%#08x,
494>24	lelong	!0		.text=[%#08x,
495>>28	lelong	x		\b%#x],
496>32	lelong	!0		.data=[%#08x,
497>>36	lelong	x		\b%#x],
498>40	lelong	!0		.bss=[%#08x,
499>>44	lelong	x		\b%#x],
500>48	lelong	!0		Stack=%#08x,
501>48	lelong	=0		No Stack!,
502>52	lelong	!0		StackSize=%#x,
503#>76	string	>\0		(%s)
504#  Area:
505>113	string	x		(%s)
506
507# CPE executables
5080	string	CPE		CPE executable
509>3	byte	x		(version %d)
510
511#------------------------------------------------------------------------------
512# Microsoft Xbox executables .xbe (Esa Hyytia <ehyytia@cc.hut.fi>)
5130	string	XBEH	Microsoft Xbox executable
514!:mime	audio/x-xbox-executable
515!:ext	xbe
516# expect base address of 0x10000
517>0x0104                 ulelong =0x10000
518>>(0x0118.l-0x0FFF4)    lestring16 x       \b: "%.40s"
519>>(0x0118.l-0x0FFF5)    byte     x         (%c
520>>(0x0118.l-0x0FFF6)    byte     x         \b%c-
521>>(0x0118.l-0x0FFF8)    uleshort x         \b%03u)
522>>(0x0118.l-0x0FF60)    ulelong&0x80000007  0x80000007 \b, all regions
523>>(0x0118.l-0x0FF60)    ulelong&0x80000007  !0x80000007
524>>>(0x0118.l-0x0FF60)   ulelong >0           (regions:
525>>>>(0x0118.l-0x0FF60)  ulelong &0x00000001  NA
526>>>>(0x0118.l-0x0FF60)  ulelong &0x00000002  Japan
527>>>>(0x0118.l-0x0FF60)  ulelong &0x00000004  Rest_of_World
528>>>>(0x0118.l-0x0FF60)  ulelong &0x80000000  Manufacturer
529>>>(0x0118.l-0x0FF60)   ulelong >0           \b)
530# probabilistic checks whether signed or not
531>0x0004 ulelong =0x0
532>>&2    ulelong =0x0
533>>>&2   ulelong =0x0  \b, not signed
534>0x0004 ulelong >0
535>>&2    ulelong >0
536>>>&2   ulelong >0    \b, signed
537
538# --------------------------------
539# Microsoft Xbox data file formats
5400       string          XIP0            XIP, Microsoft Xbox data
5410       string          XTF0            XTF, Microsoft Xbox data
542
543#------------------------------------------------------------------------------
544# Microsoft Xbox 360 executables (.xex)
545# From: David Korth <gerbilsoft@gerbilsoft.com>
546# References:
547# - https://free60project.github.io/wiki/XEX.html
548# - https://github.com/xenia-project/xenia/blob/HEAD/src/xenia/kernel/util/xex2_info.h
549
550# Title ID (part of Execution ID section)
5510		name	xbox-360-xex-execution-id
552>(0.L+0xC)	byte	x	(%c
553>(0.L+0xD)	byte	x	\b%c
554>(0.L+0xE)	beshort	x	\b-%04u, media ID:
555>(0.L)		belong	x	%08X)
556
557# Region code (part of Security Info)
5580	name	xbox-360-xex-region-code
559>0	ubelong	0xFFFFFFFF	\b, all regions
560>0	ubelong	!0xFFFFFFFF
561>>0	ubelong	>0		(regions:
562>>0	ubelong&0x000000FF	0x000000FF	USA
563>>0	ubelong&0x00000100	0x00000100	Japan
564>>0	ubelong&0x00000200	0x00000200	China
565>>0	ubelong&0x0000FC00	0x0000FC00	Asia
566>>0	ubelong&0x00FF0000	0x00FF0000	PAL
567>>0	ubelong&0x00FF0000	0x00FE0000	PAL [except AU/NZ]
568>>0	ubelong&0x00FF0000	0x00010000	AU/NZ
569>>0	ubelong&0xFF000000	0xFF000000	Other
570>>0	ubelong	>0		\b)
571
5720	string	XEX2	Microsoft Xbox 360 executable
573!:mime	audio/x-xbox360-executable
574!:ext	xex
575>0x18	search/0x100	\x00\x04\x00\x06
576>>&0	use	xbox-360-xex-execution-id
577>(0x010.L+0x178)	use	xbox-360-xex-region-code
578
5790	string	XEX1	Microsoft Xbox 360 executable (XEX1)
580!:mime	audio/x-xbox360-executable
581!:ext	xex
582>0x18	search/0x100	\x00\x04\x00\x06
583>>&0	use	xbox-360-xex-execution-id
584>(0x010.L+0x154)	use	xbox-360-xex-region-code
585
586#------------------------------------------------------------------------------
587# Microsoft Xbox 360 packages
588# From: David Korth <gerbilsoft@gerbilsoft.com>
589# References:
590# - https://free60project.github.io/wiki/STFS.html
591# - https://github.com/xenia-project/xenia/blob/HEAD/src/xenia/kernel/util/xex2_info.h
592
593# TODO: More information for console-signed packages.
594
5950	name	xbox-360-package
596>0x360	byte	x	(%c
597>0x361	byte	x	\b%c
598>0x362	beshort	x	\b-%04u, media ID:
599>0x354	belong	x	%08X)
600>0x344	belong	x	\b, content type:
601>>0x344	belong	0x1		Saved Game
602>>0x344	belong	0x2		Marketplace Content
603>>0x344	belong	0x3		Publisher
604>>0x344	belong	0x1000		Xbox 360 Title
605>>0x344	belong	0x2000		IPTV Pause Buffer
606>>0x344	belong	0x4000		Installed Game
607>>0x344	belong	0x5000		Original Xbox Game
608>>0x344	belong	0x9000		Avatar Item
609>>0x344	belong	0x10000		Profile
610>>0x344	belong	0x20000		Gamer Picture
611>>0x344	belong	0x30000		Theme
612>>0x344	belong	0x40000		Cache File
613>>0x344	belong	0x50000		Storage Download
614>>0x344	belong	0x60000		Xbox Saved Game
615>>0x344	belong	0x70000		Xbox Download
616>>0x344	belong	0x80000		Game Demo
617>>0x344	belong	0x90000		Video
618>>0x344	belong	0xA0000		Game
619>>0x344	belong	0xB0000		Installer
620>>0x344	belong	0xC0000		Game Trailer
621>>0x344	belong	0xD0000		Arcade Title
622>>0x344	belong	0xE0000		XNA
623>>0x344	belong	0xF0000		License Store
624>>0x344	belong	0x100000	Movie
625>>0x344	belong	0x200000	TV
626>>0x344	belong	0x300000	Music Video
627>>0x344	belong	0x400000	Game Video
628>>0x344	belong	0x500000	Podcast Video
629>>0x344	belong	0x600000	Viral Video
630>>0x344	belong	0x2000000	Community Game
631
6320	string	CON\x20	Microsoft Xbox 360 package (console-signed)
633>0	use	xbox-360-package
6340	string	PIRS
635>0	belong	0	Microsoft Xbox 360 package (non-Xbox Live)
636>>0	use	xbox-360-package
6370	string	LIVE
638>0x104	belong	0	Microsoft Xbox 360 package (Xbox Live)
639>>0	use	xbox-360-package
640
641# Atari Lynx cartridge dump (EXE/BLL header)
642# From: "Stefan A. Haubenthal" <polluks@web.de>
643
644# Double-check that the image type matches too, 0x8008 conflicts with
645# 8 character OMF-86 object file headers.
6460	beshort		0x8008
647>6	string		BS93		Lynx homebrew cartridge
648!:mime	application/x-atari-lynx-rom
649>>2	beshort		x		\b, RAM start $%04x
650>6	string		LYNX		Lynx cartridge
651!:mime	application/x-atari-lynx-rom
652>>2	beshort		x		\b, RAM start $%04x
653
654# Opera file system that is used on the 3DO console
655# From: Serge van den Boom <svdb@stack.nl>
6560	string		\x01ZZZZZ\x01	3DO "Opera" file system
657
658# From: Alex Myczko <alex@aiei.ch>
659# From: David Pflug <david@pflug.email>
660# is the offset 12 or the offset 16 correct?
661# GBS (Game Boy Sound) magic
662# ftp://ftp.modland.com/pub/documents/format_documentation/\
663# Gameboy%20Sound%20System%20(.gbs).txt
6640	string		GBS		Nintendo Gameboy Music/Audio Data
665#12	string		GameBoy\ Music\ Module	Nintendo Gameboy Music Module
666>16	string		>\0	("%.32s" by
667>48	string		>\0	%.32s, copyright
668>80	string		>\0	%.32s),
669>3	byte		x	version %u,
670>4	byte		x	%u tracks
671
672# IPS Patch Files from: From: Thomas Klausner <tk@giga.or.at>
673# see https://zerosoft.zophar.net/ips.php
6740	string	PATCH			IPS patch file
675!:ext	ips
676
677# BPS Patch Files - from: David Korth <gerbilsoft@gerbilsoft.com>
678# Reference: https://www.romhacking.net/documents/746/
6790	string	BPS1			BPS patch file
680!:ext	bps
681
682# APS Patch Files - from: David Korth <gerbilsoft@gerbilsoft.com>
683# Reference: https://github.com/btimofeev/UniPatcher/wiki/APS-(N64)
6840	string	APS10			APS patch file
685!:ext	aps
686>5	byte	0			\b, simple patch
687>5	byte	1			\b, N64-specific patch for
688>>58	byte	x			N%c
689>>59	byte	x			\b%c
690>>60	byte	x			\b%c
691>7	byte	!0x20
692# FIXME: /T specifier isn't working with a fixed-length string.
693>>7	string	x			\b: "%.50s"
694
695# UPS Patch Files - from: David Korth <gerbilsoft@gerbilsoft.com>
696# Reference: http://fileformats.archiveteam.org/wiki/UPS_(binary_patch_format)
6970	string	UPS1			UPS patch file
698!:ext	ups
699
700# Playstations Patch Files from: From: Thomas Klausner <tk@giga.or.at>
7010	string	PPF30			Playstation Patch File version 3.0
702>5	byte	0			\b, PPF 1.0 patch
703>5	byte	1			\b, PPF 2.0 patch
704>5	byte	2			\b, PPF 3.0 patch
705>>56	byte	0			\b, Imagetype BIN (any)
706>>56	byte	1			\b, Imagetype GI (PrimoDVD)
707>>57	byte	0			\b, Blockcheck disabled
708>>57	byte	1			\b, Blockcheck enabled
709>>58	byte	0			\b, Undo data not available
710>>58	byte	1			\b, Undo data available
711>6	string	x			\b, description: %s
712
7130	string	PPF20			Playstation Patch File version 2.0
714>5	byte	0			\b, PPF 1.0 patch
715>5	byte	1			\b, PPF 2.0 patch
716>>56	lelong	>0			\b, size of file to patch %d
717>6	string	x			\b, description: %s
718
7190	string	PPF10			Playstation Patch File version 1.0
720>5	byte	0			\b, Simple Encoding
721>6	string	x			\b, description: %s
722
723# From: Daniel Dawson <ddawson@icehouse.net>
724# SNES9x .smv "movie" file format.
7250		string		SMV\x1A	SNES9x input recording
726>0x4		lelong		x	\b, version %d
727# version 4 is latest so far
728>0x4		lelong		<5
729>>0x8		ledate		x	\b, recorded at %s
730>>0xc		lelong		>0	\b, rerecorded %d times
731>>0x10		lelong		x	\b, %d frames long
732>>0x14		byte		>0	\b, data for controller(s):
733>>>0x14		byte		&0x1	#1
734>>>0x14		byte		&0x2	#2
735>>>0x14		byte		&0x4	#3
736>>>0x14		byte		&0x8	#4
737>>>0x14		byte		&0x10	#5
738>>0x15		byte		^0x1	\b, begins from snapshot
739>>0x15		byte		&0x1	\b, begins from reset
740>>0x15		byte		^0x2	\b, NTSC standard
741>>0x15		byte		&0x2	\b, PAL standard
742>>0x17		byte		&0x1    \b, settings:
743# WIP1Timing not used as of version 4
744>>>0x4		lelong		<4
745>>>>0x17	byte		&0x2	WIP1Timing
746>>>0x17		byte		&0x4	Left+Right
747>>>0x17		byte		&0x8	VolumeEnvX
748>>>0x17		byte		&0x10	FakeMute
749>>>0x17		byte		&0x20	SyncSound
750# New flag as of version 4
751>>>0x4		lelong		>3
752>>>>0x17	byte		&0x80	NoCPUShutdown
753>>0x4		lelong		<4
754>>>0x18		lelong		>0x23
755>>>>0x20	leshort		!0
756>>>>>0x20	lestring16	x	\b, metadata: "%s"
757>>0x4		lelong		>3
758>>>0x24		byte		>0	\b, port 1:
759>>>>0x24	byte		1	joypad
760>>>>0x24	byte		2	mouse
761>>>>0x24	byte		3	SuperScope
762>>>>0x24	byte		4	Justifier
763>>>>0x24	byte		5	multitap
764>>>0x24		byte		>0	\b, port 2:
765>>>>0x25	byte		1	joypad
766>>>>0x25	byte		2	mouse
767>>>>0x25	byte		3	SuperScope
768>>>>0x25	byte		4	Justifier
769>>>>0x25	byte		5	multitap
770>>>0x18		lelong		>0x43
771>>>>0x40	leshort		!0
772>>>>>0x40	lestring16	x	\b, metadata: "%s"
773>>0x17		byte		&0x40   \b, ROM:
774>>>(0x18.l-26)	lelong		x	CRC32 %#08x
775>>>(0x18.l-23)	string		x	"%s"
776
777# Type: scummVM savegame files
778# From: Sven Hartge <debian@ds9.argh.org>
7790	string	SCVM	ScummVM savegame
780>12	string	>\0	"%s"
781
782#------------------------------------------------------------------------------
783# Nintendo GameCube / Wii file formats.
784#
785
786# Type: Nintendo GameCube/Wii common disc header data.
787# From: David Korth <gerbilsoft@gerbilsoft.com>
788# Reference: https://wiibrew.org/wiki/Wii_Disc
7890	name	nintendo-gcn-disc-common
790>0x20	string	x	"%.64s"
791>0x00	string	x	(%.6s
792>0x06	byte	>0
793>>0x06	byte	1	\b, Disc 2
794>>0x06	byte	2	\b, Disc 3
795>>0x06	byte	3	\b, Disc 4
796>0x07	byte	x	\b, Rev.%02u)
797>0x18	belong	0x5D1C9EA3
798>>0x60	beshort	0x0101	\b (Unencrypted)
799>0x200	string	NKIT	\b (NKit compressed)
800
801
802# Type: Nintendo GameCube disc image
803# From: David Korth <gerbilsoft@gerbilsoft.com>
804# Reference: https://wiibrew.org/wiki/Wii_Disc
8050x1C	belong	0xC2339F3D	Nintendo GameCube disc image:
806!:mime	application/x-gamecube-rom
807>0	use	nintendo-gcn-disc-common
808
809# Type: Nintendo GameCube embedded disc image
810# Commonly found on demo discs.
811# From: David Korth <gerbilsoft@gerbilsoft.com>
812# Reference: http://hitmen.c02.at/files/yagcd/yagcd/index.html#idx14.8
8130		belong	0xAE0F38A2
814>0x0C		belong	0x00100000
815>>(8.L+0x1C)	belong	0xC2339F3D	Nintendo GameCube embedded disc image:
816!:mime	application/x-gamecube-rom
817>>>(8.L)	use	nintendo-gcn-disc-common
818
819# Type: Nintendo Wii disc image
820# From: David Korth <gerbilsoft@gerbilsoft.com>
821# Reference: https://wiibrew.org/wiki/Wii_Disc
8220x18	belong	0x5D1C9EA3	Nintendo Wii disc image:
823>0	use	nintendo-gcn-disc-common
824
825# Type: Nintendo Wii disc image (WBFS format)
826# From: David Korth <gerbilsoft@gerbilsoft.com>
827# Reference: https://wiibrew.org/wiki/Wii_Disc
8280	string	WBFS
829>0x218	belong	0x5D1C9EA3	Nintendo Wii disc image (WBFS format):
830!:mime	application/x-wii-rom
831>>0x200	use	nintendo-gcn-disc-common
832
833# Type: Nintendo GameCube/Wii disc image (CISO format)
834# NOTE: This is NOT the same as Compact ISO or PSP CISO,
835# though it has the same magic number.
8360		string	CISO
837# Other fields are used to determine what type of CISO this is:
838# - 0x04 == 0x00200000: GameCube/Wii CISO (block_size)
839# - 0x10 == 0x00000800: PSP CISO (ISO-9660 sector size)
840# - None of the above: Compact ISO.
841>4		lelong	0x200000
842>>8		byte	1
843>>>0x801C	belong	0xC2339F3D	Nintendo GameCube disc image (CISO format):
844!:mime	application/x-wii-rom
845>>>>0x8000	use	nintendo-gcn-disc-common
846>>>0x8018	belong	0x5D1C9EA3	Nintendo Wii disc image (CISO format):
847!:mime	application/x-wii-rom
848>>>>0x8000	use	nintendo-gcn-disc-common
849
850# Type: Nintendo GameCube/Wii disc image (GCZ format)
851# Due to zlib compression, we can't get the actual disc information.
8520	lelong	0xB10BC001
853>4	lelong	0		Nintendo GameCube disc image (GCZ format)
854!:mime	application/x-gamecube-rom
855>4	lelong	1		Nintendo Wii disc image (GCZ format)
856!:mime	application/x-wii-rom
857>4	default	x		Nintendo GameCube/Wii disc image (GCZ format)
858
859# Type: Nintendo GameCube/Wii disc image (WDF format)
8600		string	WII\001DISC
861>8		belong	1
862# WDFv1
863>>0x54		belong	0xC2339F3D	Nintendo GameCube disc image (WDFv1 format):
864!:mime	application/x-gamecube-rom
865>>>0x38		use	nintendo-gcn-disc-common
866>>0x58		belong	0x5D1C9EA3	Nintendo Wii disc image (WDFv1 format):
867!:mime	application/x-wii-rom
868>>>0x38		use	nintendo-gcn-disc-common
869>8		belong	2
870# WDFv2
871>>(12.L+0x1C)	belong	0xC2339F3D	Nintendo GameCube disc image (WDFv2 format):
872!:mime	application/x-gamecube-rom
873>>>(12.L)	use	nintendo-gcn-disc-common
874>>(12.L+0x18)	belong	0x5D1C9EA3	Nintendo Wii disc image (WDFv2 format):
875!:mime	application/x-wii-rom
876>>>(12.L)	use	nintendo-gcn-disc-common
877
878# Type: Nintendo GameCube/Wii disc image (WIA format)
8790	string	WIA\001	Nintendo
880>0x48	belong	1	GameCube
881!:mime	application/x-gamecube-rom
882>0x48	belong	2	Wii
883!:mime	application/x-wii-rom
884>0x48	default	x	GameCube/Wii
885>0x48	belong	x	disc image (WIA format):
886>>0x58	use	nintendo-gcn-disc-common
887
888# Type: Nintendo GameCube/Wii disc image (with SDK header)
889# From: David Korth <gerbilsoft@gerbilsoft.com>
890# Reference: https://wiibrew.org/wiki/Wii_Disc
8910		belong	0xFFFF0000
892>0x18		belong	0x00000000
893>>0x1C		belong	0x00000000
894>>>0x8018	belong	0x5D1C9EA3	Nintendo Wii SDK disc image:
895!:mime	application/x-wii-rom
896>>>>0x8000	use	nintendo-gcn-disc-common
897>>>0x801C	belong	0xC2339F3D	Nintendo GameCube SDK disc image:
898!:mime	application/x-gamecube-rom
899>>>>0x8000	use	nintendo-gcn-disc-common
900
901#------------------------------------------------------------------------------
902# Nintendo 3DS file formats.
903#
904
905# Type: Nintendo 3DS "NCSD" image. (game cards and eMMC)
906# From: David Korth <gerbilsoft@gerbilsoft.com>
907# Reference: https://www.3dbrew.org/wiki/NCSD
9080x100		string		NCSD
909>0x118		lequad		0		Nintendo 3DS Game Card image
910# NCCH header for partition 0. (game data)
911>>0x1150	string		>\0	\b: "%.16s"
912>>0x312		byte		x	(Rev.%02u)
913>>0x118C	byte		2	(New3DS only)
914>>0x18D		byte		0		(inner device)
915>>0x18D		byte		1		(Card1)
916>>0x18D		byte		2		(Card2)
917>>0x18D		byte		3		(extended device)
918>0x118		bequad		0x0102020202000000	Nintendo 3DS eMMC dump (Old3DS)
919>0x118		bequad		0x0102020203000000	Nintendo 3DS eMMC dump (New3DS)
920
921# Nintendo 3DS version code.
922# Reference: https://www.3dbrew.org/wiki/Titles
923# Format: leshort containing three fields:
924# - 6-bit: Major
925# - 6-bit: Minor
926# - 4-bit: Revision
927# NOTE: Only supporting major/minor versions from 0-15 right now.
928# NOTE: Should be prefixed with "v".
9290	name	nintendo-3ds-version-code
930# Raw version.
931>0	leshort	x	\b%u,
932# Major version.
933>0	leshort&0xFC00	0x0000	0
934>0	leshort&0xFC00	0x0400	1
935>0	leshort&0xFC00	0x0800	2
936>0	leshort&0xFC00	0x0C00	3
937>0	leshort&0xFC00	0x1000	4
938>0	leshort&0xFC00	0x1400	5
939>0	leshort&0xFC00	0x1800	6
940>0	leshort&0xFC00	0x1C00	7
941>0	leshort&0xFC00	0x2000	8
942>0	leshort&0xFC00	0x2400	9
943>0	leshort&0xFC00	0x2800	10
944>0	leshort&0xFC00	0x2C00	11
945>0	leshort&0xFC00	0x3000	12
946>0	leshort&0xFC00	0x3400	13
947>0	leshort&0xFC00	0x3800	14
948>0	leshort&0xFC00	0x3C00	15
949# Minor version.
950>0	leshort&0x03F0	0x0000	\b.0
951>0	leshort&0x03F0	0x0010	\b.1
952>0	leshort&0x03F0	0x0020	\b.2
953>0	leshort&0x03F0	0x0030	\b.3
954>0	leshort&0x03F0	0x0040	\b.4
955>0	leshort&0x03F0	0x0050	\b.5
956>0	leshort&0x03F0	0x0060	\b.6
957>0	leshort&0x03F0	0x0070	\b.7
958>0	leshort&0x03F0	0x0080	\b.8
959>0	leshort&0x03F0	0x0090	\b.9
960>0	leshort&0x03F0	0x00A0	\b.10
961>0	leshort&0x03F0	0x00B0	\b.11
962>0	leshort&0x03F0	0x00C0	\b.12
963>0	leshort&0x03F0	0x00D0	\b.13
964>0	leshort&0x03F0	0x00E0	\b.14
965>0	leshort&0x03F0	0x00F0	\b.15
966# Revision.
967>0	leshort&0x000F	x	\b.%u
968
969# Type: Nintendo 3DS "NCCH" container.
970# https://www.3dbrew.org/wiki/NCCH
9710x100		string	NCCH	Nintendo 3DS
972>0x18D		byte&2	0	File Archive (CFA)
973>0x18D		byte&2	2	Executable Image (CXI)
974>0x150		string	>\0	\b: "%.16s"
975>0x18D		byte	0x05
976>>0x10E		leshort	x	(Old3DS System Update v
977>>0x10E		use	nintendo-3ds-version-code
978>>0x10E		leshort	x	\b)
979>0x18D		byte	0x15
980>>0x10E		leshort	x	(New3DS System Update v
981>>0x10E		use	nintendo-3ds-version-code
982>>0x10E		leshort	x	\b)
983>0x18D		byte	!0x05
984>>0x18D		byte	!0x15
985>>>0x112	byte	x	(v
986>>>0x112	use	nintendo-3ds-version-code
987>>>0x112	byte	x	\b)
988>0x18C		byte	2	(New3DS only)
989
990# Type: Nintendo 3DS "SMDH" file. (application description)
991# From: David Korth <gerbilsoft@gerbilsoft.com>
992# Reference: https://3dbrew.org/wiki/SMDH
9930		string		SMDH		Nintendo 3DS SMDH file
994>0x208		leshort		!0
995>>0x208		lestring16	x		\b: "%.128s"
996>>0x388		leshort		!0
997>>>0x388	lestring16	x		by %.128s
998>0x208		leshort		0
999>>0x008		leshort		!0
1000>>>0x008	lestring16	x		\b: "%.128s"
1001>>>0x188	leshort		!0
1002>>>>0x188	lestring16	x		by %.128s
1003
1004# Type: Nintendo 3DS Homebrew Application.
1005# From: David Korth <gerbilsoft@gerbilsoft.com>
1006# Reference: https://3dbrew.org/wiki/3DSX_Format
10070	string	3DSX	Nintendo 3DS Homebrew Application (3DSX)
1008
1009# Type: Nintendo 3DS Banner Model Data.
1010# From: David Korth <gerbilsoft@gerbilsoft.com>
1011# Reference: https://3dbrew.org/wiki/CBMD
10120	string	CBMD\0\0\0\0	Nintendo 3DS Banner Model Data
1013
1014#------------------------------------------------------------------------------
1015# a7800: file(1) magic for the Atari 7800 raw ROM format.
1016# From: David Korth <gerbilsoft@gerbilsoft.com>
1017# Reference: https://sites.google.com/site/atari7800wiki/a78-header
1018
10190	byte	>0
1020>0	byte	<3
1021>>1	string	ATARI7800	Atari 7800 ROM image
1022!:mime	application/x-atari-7800-rom
1023>>>0x11	string	>\0	\b: "%.32s"
1024# Display type.
1025>>>0x39	byte	0	(NTSC)
1026>>>0x39	byte	1	(PAL)
1027>>>0x36	byte&1	1	(POKEY)
1028
1029#------------------------------------------------------------------------------
1030# vectrex: file(1) magic for the GCE Vectrex raw ROM format.
1031# From: David Korth <gerbilsoft@gerbilsoft.com>
1032# Reference: http://www.playvectrex.com/designit/chrissalo/hello1.htm
1033#
1034# NOTE: Title is terminated with 0x80, not 0.
1035# The header is terminated with a 0, so that will
1036# terminate the title as well.
1037#
10380	string	g\ GCE	Vectrex ROM image
1039>0x11	string	>\0	\b: "%.16s"
1040
1041#------------------------------------------------------------------------------
1042# amiibo: file(1) magic for Nintendo amiibo NFC dumps.
1043# From: David Korth <gerbilsoft@gerbilsoft.com>
1044# Reference: https://www.3dbrew.org/wiki/Amiibo
10450x00		byte	0x04
1046>0x0A		beshort	0x0FE0
1047>>0x0C		belong	0xF110FFEE
1048>>>0x208	beshort	0x0100
1049>>>>0x020A	byte	0x0F
1050>>>>>0x020C	bequad	0x000000045F000000
1051>>>>>>0x5B	byte	0x02
1052>>>>>>>0x54	belong	x	Nintendo amiibo NFC dump - amiibo ID: %08X-
1053>>>>>>>0x58	belong	x	\b%08X
1054
1055#------------------------------------------------------------------------------
1056# Type: Nintendo Switch XCI (Game Cartridge Image)
1057# From: Benjamin Lowry <ben@ben.gmbh>
1058# Reference: https://switchbrew.org/wiki/Gamecard_Format
10590x100		string	HEAD
1060>0x10D		byte	0xFA	Nintendo Switch cartridge image (XCI), 1GB
1061>0x10D		byte	0xF8	Nintendo Switch cartridge image (XCI), 2GB
1062>0x10D		byte	0xF0	Nintendo Switch cartridge image (XCI), 4GB
1063>0x10D		byte	0xE0	Nintendo Switch cartridge image (XCI), 8GB
1064>0x10D		byte	0xE1	Nintendo Switch cartridge image (XCI), 16GB
1065>0x10D		byte	0xE2	Nintendo Switch cartridge image (XCI), 32GB
1066
1067#------------------------------------------------------------------------------
1068# Type: Nintendo Switch Executable
1069# From: Benjamin Lowry <ben@ben.gmbh>
1070# Reference: https://switchbrew.org/wiki/NSO
10710x00		string	NSO0	Nintendo Switch executable (NSO)
1072
1073#------------------------------------------------------------------------------
1074# Type: Nintendo Switch PFS0
1075# From: Benjamin Lowry <ben@ben.gmbh>
1076# Reference: https://switchbrew.org/wiki/NCA_Format#PFS0
10770x00		string	PFS0	Nintendo Switch partition filesystem (PFS0)
1078>0x04		ulelong	x	\b, %d files
1079
1080#------------------------------------------------------------------------------
1081# amiibo: file(1) magic for Nintendo Badge Arcade files.
1082# From: David Korth <gerbilsoft@gerbilsoft.com>
1083# References:
1084# - https://github.com/GerbilSoft/rom-properties/issues/92
1085# - https://github.com/CaitSith2/BadgeArcadeTool
1086# - https://github.com/TheMachinumps/Advanced-badge-editor
1087
1088# PRBS: Individual badge and/or mega badge.
10890		string	PRBS
1090>0x44		byte	>0x20	Nintendo Badge Arcade
1091>>0xB8		ulelong	<2
1092>>>0xBC		ulelong	<2	badge:
1093>>>0xBC		ulelong	>1	Mega Badge
1094>>>>0xB8	ulelong	x	(%ux
1095>>>>0xBC	ulelong	x	\b%u):
1096>>0xB8		ulelong	>1	Mega Badge
1097>>>0xB8		ulelong	x	(%ux
1098>>>0xBC		ulelong	x	\b%u):
1099>0x44		string	x	"%s"
1100>0x3C		ulelong	x	\b, badge ID: %u
1101>0x74		byte	>0x20
1102>>0x74		string	x	\b, set: "%s"
1103>0xA8		ulelong	!0xFFFFFFFF
1104>>0xA8		ulelong	x	\b, launch title ID: %08X
1105>>0xA4		ulelong	x	\b-%08X
1106
1107# CABS: Badge set.
11080	string	CABS
1109>0x2C	byte	>0x20	Nintendo Badge Arcade badge set:
1110>>0x2C	string	x	"%.48s"
1111>>0x24	ulelong	x	\b, set ID: %u
1112
1113#------------------------------------------------------------------------------
1114# sufami: file(1) magic for Sufami Turbo ROM images.
1115# From: David Korth <gerbilsoft@gerbilsoft.com>
1116# References:
1117# - https://problemkaputt.de/fullsnes.htm#snescartsufamiturbominicartridgeadaptor
11180	string		BANDAI\ SFC-ADX
1119>0x10	string		!SFC-ADX\ BACKUP	Sufami Turbo ROM image:
1120>>0x10	string/T	x	"%.14s"
1121>>0x30	byte		x	\b, ID %02X
1122>>0x31	byte		x	\b%02X
1123>>0x32	byte		x	\b%02X
1124>>0x33	ubyte		>0	\b, series index %u
1125>>0x34	ubyte		0	[SlowROM]
1126>>0x34	ubyte		1	[FastROM]
1127>>0x35	ubyte		1	[SRAM]
1128>>0x35	ubyte		3	[Special]
1129
1130# Type: Nintendo GameCube/Wii disc image (RVZ format)
11310	string		RVZ\001	Nintendo
1132>0x48	belong		1	GameCube
1133!:mime	application/x-gamecube-rom
1134>0x48	belong		2	Wii
1135!:mime	application/x-wii-rom
1136>0x48	default		x	GameCube/Wii
1137>0x48	belong		x	disc image (RVZ format):
1138>>0x58	use		nintendo-gcn-disc-common
1139
1140