head	1.1;
branch	1.1.1;
access;
symbols
	netbsd-11-0-RC4:1.1.1.14
	netbsd-11-0-RC3:1.1.1.14
	netbsd-11-0-RC2:1.1.1.14
	netbsd-11-0-RC1:1.1.1.14
	perseant-exfatfs-base-20250801:1.1.1.14
	netbsd-11:1.1.1.14.0.4
	netbsd-11-base:1.1.1.14
	netbsd-10-1-RELEASE:1.1.1.13
	perseant-exfatfs-base-20240630:1.1.1.14
	perseant-exfatfs:1.1.1.14.0.2
	perseant-exfatfs-base:1.1.1.14
	netbsd-8-3-RELEASE:1.1.1.5
	netbsd-9-4-RELEASE:1.1.1.9
	netbsd-10-0-RELEASE:1.1.1.13
	netbsd-10-0-RC6:1.1.1.13
	netbsd-10-0-RC5:1.1.1.13
	netbsd-10-0-RC4:1.1.1.13
	netbsd-10-0-RC3:1.1.1.13
	netbsd-10-0-RC2:1.1.1.13
	netbsd-10-0-RC1:1.1.1.13
	FILE5_45:1.1.1.14
	netbsd-10:1.1.1.13.0.2
	netbsd-10-base:1.1.1.13
	FILE5_43:1.1.1.13
	netbsd-9-3-RELEASE:1.1.1.9
	cjep_sun2x-base1:1.1.1.12
	cjep_sun2x:1.1.1.12.0.4
	cjep_sun2x-base:1.1.1.12
	cjep_staticlib_x-base1:1.1.1.12
	netbsd-9-2-RELEASE:1.1.1.9
	cjep_staticlib_x:1.1.1.12.0.2
	cjep_staticlib_x-base:1.1.1.12
	FILE5_40:1.1.1.12
	netbsd-9-1-RELEASE:1.1.1.9
	FILE5_39:1.1.1.11
	phil-wifi-20200421:1.1.1.10
	phil-wifi-20200411:1.1.1.10
	is-mlppp:1.1.1.10.0.2
	is-mlppp-base:1.1.1.10
	phil-wifi-20200406:1.1.1.10
	netbsd-8-2-RELEASE:1.1.1.5
	netbsd-9-0-RELEASE:1.1.1.9
	netbsd-9-0-RC2:1.1.1.9
	FILE5_38:1.1.1.10
	netbsd-9-0-RC1:1.1.1.9
	phil-wifi-20191119:1.1.1.9
	netbsd-9:1.1.1.9.0.2
	netbsd-9-base:1.1.1.9
	phil-wifi-20190609:1.1.1.9
	netbsd-8-1-RELEASE:1.1.1.5
	FILE5_37:1.1.1.9
	netbsd-8-1-RC1:1.1.1.5
	pgoyette-compat-merge-20190127:1.1.1.6.2.2
	pgoyette-compat-20190127:1.1.1.8
	pgoyette-compat-20190118:1.1.1.8
	pgoyette-compat-1226:1.1.1.8
	pgoyette-compat-1126:1.1.1.8
	pgoyette-compat-1020:1.1.1.8
	FILE5_35:1.1.1.8
	pgoyette-compat-0930:1.1.1.7
	pgoyette-compat-0906:1.1.1.7
	netbsd-7-2-RELEASE:1.1.1.3
	pgoyette-compat-0728:1.1.1.7
	netbsd-8-0-RELEASE:1.1.1.5
	phil-wifi:1.1.1.7.0.2
	phil-wifi-base:1.1.1.7
	pgoyette-compat-0625:1.1.1.7
	netbsd-8-0-RC2:1.1.1.5
	pgoyette-compat-0521:1.1.1.7
	pgoyette-compat-0502:1.1.1.7
	pgoyette-compat-0422:1.1.1.7
	netbsd-8-0-RC1:1.1.1.5
	FILE5_33:1.1.1.7
	pgoyette-compat-0415:1.1.1.6
	pgoyette-compat-0407:1.1.1.6
	pgoyette-compat-0330:1.1.1.6
	pgoyette-compat-0322:1.1.1.6
	pgoyette-compat-0315:1.1.1.6
	netbsd-7-1-2-RELEASE:1.1.1.3
	pgoyette-compat:1.1.1.6.0.2
	pgoyette-compat-base:1.1.1.6
	netbsd-7-1-1-RELEASE:1.1.1.3
	matt-nb8-mediatek:1.1.1.5.0.6
	matt-nb8-mediatek-base:1.1.1.5
	FILE5_32:1.1.1.6
	perseant-stdc-iso10646:1.1.1.5.0.4
	perseant-stdc-iso10646-base:1.1.1.5
	netbsd-8:1.1.1.5.0.2
	netbsd-8-base:1.1.1.5
	FILE5_31:1.1.1.5
	prg-localcount2-base3:1.1.1.4
	prg-localcount2-base2:1.1.1.4
	prg-localcount2-base1:1.1.1.4
	prg-localcount2:1.1.1.4.0.2
	prg-localcount2-base:1.1.1.4
	pgoyette-localcount-20170426:1.1.1.4
	bouyer-socketcan-base1:1.1.1.4
	pgoyette-localcount-20170320:1.1.1.4
	netbsd-7-1:1.1.1.3.0.20
	netbsd-7-1-RELEASE:1.1.1.3
	netbsd-7-1-RC2:1.1.1.3
	FILE5_30:1.1.1.4
	netbsd-7-nhusb-base-20170116:1.1.1.3
	bouyer-socketcan:1.1.1.3.0.18
	bouyer-socketcan-base:1.1.1.3
	pgoyette-localcount-20170107:1.1.1.3
	netbsd-7-1-RC1:1.1.1.3
	pgoyette-localcount-20161104:1.1.1.3
	netbsd-7-0-2-RELEASE:1.1.1.3
	localcount-20160914:1.1.1.3
	netbsd-7-nhusb:1.1.1.3.0.16
	netbsd-7-nhusb-base:1.1.1.3
	pgoyette-localcount-20160806:1.1.1.3
	pgoyette-localcount-20160726:1.1.1.3
	pgoyette-localcount:1.1.1.3.0.14
	pgoyette-localcount-base:1.1.1.3
	netbsd-7-0-1-RELEASE:1.1.1.3
	netbsd-7-0:1.1.1.3.0.12
	netbsd-7-0-RELEASE:1.1.1.3
	netbsd-7-0-RC3:1.1.1.3
	netbsd-7-0-RC2:1.1.1.3
	netbsd-7-0-RC1:1.1.1.3
	FILE5_22:1.1.1.3
	FILE5_20:1.1.1.3
	netbsd-6-0-6-RELEASE:1.1.1.2
	netbsd-6-1-5-RELEASE:1.1.1.2
	netbsd-7:1.1.1.3.0.10
	netbsd-7-base:1.1.1.3
	FILE5_19:1.1.1.3
	yamt-pagecache-base9:1.1.1.3
	yamt-pagecache-tag8:1.1.1.2
	netbsd-6-1-4-RELEASE:1.1.1.2
	netbsd-6-0-5-RELEASE:1.1.1.2
	tls-earlyentropy:1.1.1.3.0.8
	tls-earlyentropy-base:1.1.1.3
	riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.1.1.3
	riastradh-drm2-base3:1.1.1.3
	netbsd-6-1-3-RELEASE:1.1.1.2
	netbsd-6-0-4-RELEASE:1.1.1.2
	FILE5_16:1.1.1.3
	netbsd-6-1-2-RELEASE:1.1.1.2
	netbsd-6-0-3-RELEASE:1.1.1.2
	netbsd-6-1-1-RELEASE:1.1.1.2
	riastradh-drm2-base2:1.1.1.3
	riastradh-drm2-base1:1.1.1.3
	riastradh-drm2:1.1.1.3.0.6
	riastradh-drm2-base:1.1.1.3
	netbsd-6-1:1.1.1.2.0.16
	netbsd-6-0-2-RELEASE:1.1.1.2
	netbsd-6-1-RELEASE:1.1.1.2
	khorben-n900:1.1.1.3.0.4
	netbsd-6-1-RC4:1.1.1.2
	netbsd-6-1-RC3:1.1.1.2
	agc-symver:1.1.1.3.0.2
	agc-symver-base:1.1.1.3
	FILE5_14:1.1.1.3
	netbsd-6-1-RC2:1.1.1.2
	netbsd-6-1-RC1:1.1.1.2
	yamt-pagecache-base8:1.1.1.2
	FILE_5_12:1.1.1.2
	netbsd-6-0-1-RELEASE:1.1.1.2
	yamt-pagecache-base7:1.1.1.2
	matt-nb6-plus-nbase:1.1.1.2
	yamt-pagecache-base6:1.1.1.2
	netbsd-6-0:1.1.1.2.0.12
	netbsd-6-0-RELEASE:1.1.1.2
	netbsd-6-0-RC2:1.1.1.2
	tls-maxphys:1.1.1.2.0.10
	tls-maxphys-base:1.1.1.3
	matt-nb6-plus:1.1.1.2.0.8
	matt-nb6-plus-base:1.1.1.2
	netbsd-6-0-RC1:1.1.1.2
	yamt-pagecache-base5:1.1.1.2
	yamt-pagecache-base4:1.1.1.2
	FILE5_11:1.1.1.2
	netbsd-6:1.1.1.2.0.6
	netbsd-6-base:1.1.1.2
	yamt-pagecache-base3:1.1.1.2
	yamt-pagecache-base2:1.1.1.2
	yamt-pagecache:1.1.1.2.0.4
	yamt-pagecache-base:1.1.1.2
	FILE5_09:1.1.1.2
	cherry-xenmp:1.1.1.2.0.2
	cherry-xenmp-base:1.1.1.2
	FILE5_07:1.1.1.2
	bouyer-quota2-nbase:1.1.1.1
	bouyer-quota2:1.1.1.1.0.4
	bouyer-quota2-base:1.1.1.1
	matt-mips64-premerge-20101231:1.1.1.1
	matt-premerge-20091211:1.1.1.1
	jym-xensuspend-base:1.1.1.1
	jym-xensuspend:1.1.1.1.0.2
	jym-xensuspend-nbase:1.1.1.1
	FILE5_03:1.1.1.1
	CHRISTOS:1.1.1;
locks; strict;
comment	@# @;


1.1
date	2009.05.08.16.35.08;	author christos;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2009.05.08.16.35.08;	author christos;	state Exp;
branches
	1.1.1.1.2.1;
next	1.1.1.2;

1.1.1.2
date	2011.05.12.20.46.58;	author christos;	state Exp;
branches
	1.1.1.2.4.1
	1.1.1.2.10.1;
next	1.1.1.3;

1.1.1.3
date	2013.03.23.15.49.17;	author christos;	state Exp;
branches
	1.1.1.3.14.1
	1.1.1.3.18.1;
next	1.1.1.4;

1.1.1.4
date	2017.02.10.17.42.57;	author christos;	state Exp;
branches;
next	1.1.1.5;
commitid	HAP3kn9Hn6ovMqFz;

1.1.1.5
date	2017.05.24.23.59.57;	author christos;	state Exp;
branches;
next	1.1.1.6;
commitid	WbyOU2LBE5qOyHSz;

1.1.1.6
date	2017.09.08.13.22.43;	author christos;	state Exp;
branches
	1.1.1.6.2.1;
next	1.1.1.7;
commitid	Hp7DmePhD4aVAo6A;

1.1.1.7
date	2018.04.15.19.32.48;	author christos;	state Exp;
branches
	1.1.1.7.2.1;
next	1.1.1.8;
commitid	unKSwpX2g9VqBzyA;

1.1.1.8
date	2018.10.18.23.54.09;	author christos;	state Exp;
branches;
next	1.1.1.9;
commitid	e8WctwerBeEm4vWA;

1.1.1.9
date	2019.05.22.17.19.57;	author christos;	state Exp;
branches;
next	1.1.1.10;
commitid	VXeNRYYruN1MWdoB;

1.1.1.10
date	2019.12.17.02.23.53;	author christos;	state Exp;
branches;
next	1.1.1.11;
commitid	vqYTz60fS9PNg0PB;

1.1.1.11
date	2020.06.15.00.18.48;	author christos;	state Exp;
branches;
next	1.1.1.12;
commitid	HMbuXSjPojU5LfcC;

1.1.1.12
date	2021.04.09.18.58.01;	author christos;	state Exp;
branches;
next	1.1.1.13;
commitid	W9ddLLbSkHHinEOC;

1.1.1.13
date	2022.09.24.20.07.54;	author christos;	state Exp;
branches;
next	1.1.1.14;
commitid	Nf6F9kcpc0EPC9VD;

1.1.1.14
date	2023.08.18.18.36.50;	author christos;	state Exp;
branches;
next	;
commitid	IX26ghc1E2S0AiBE;

1.1.1.1.2.1
date	2009.05.08.16.35.08;	author jym;	state dead;
branches;
next	1.1.1.1.2.2;

1.1.1.1.2.2
date	2009.05.13.18.51.55;	author jym;	state Exp;
branches;
next	;

1.1.1.2.4.1
date	2014.05.22.15.44.59;	author yamt;	state Exp;
branches;
next	;
commitid	tYJXbWAuFvTh7yBx;

1.1.1.2.10.1
date	2013.06.23.06.26.32;	author tls;	state Exp;
branches;
next	;
commitid	OnlO1cBgtQRcIHUw;

1.1.1.3.14.1
date	2017.03.20.06.52.19;	author pgoyette;	state Exp;
branches;
next	;
commitid	jjw7cAwgyKq7RfKz;

1.1.1.3.18.1
date	2017.04.21.16.51.24;	author bouyer;	state Exp;
branches;
next	;
commitid	dUG7nkTKALCadqOz;

1.1.1.6.2.1
date	2018.04.22.07.20.08;	author pgoyette;	state Exp;
branches;
next	1.1.1.6.2.2;
commitid	W6xykws0Zbl4kpzA;

1.1.1.6.2.2
date	2018.10.20.06.58.20;	author pgoyette;	state Exp;
branches;
next	;
commitid	mTSoqZEZ4arHnFWA;

1.1.1.7.2.1
date	2019.06.10.21.44.46;	author christos;	state Exp;
branches;
next	1.1.1.7.2.2;
commitid	jtc8rnCzWiEEHGqB;

1.1.1.7.2.2
date	2020.04.08.14.04.04;	author martin;	state Exp;
branches;
next	;
commitid	Qli2aW9E74UFuA3C;


desc
@@


1.1
log
@Initial revision
@
text
@#------------------------------------------------------------------------------
# Console game magic
# Toby Deshane <hac@@shoelace.digivill.net>
#    ines:  file(1) magic for Marat's iNES Nintendo Entertainment System
#           ROM dump format

0 string NES\032 iNES ROM dump,
>4 byte  x     %dx16k PRG
>5 byte  x     \b, %dx8k CHR
>6 byte&0x01  =0x1  \b, [Vert.]
>6 byte&0x01  =0x0  \b, [Horiz.]
>6 byte&0x02  =0x2  \b, [SRAM]
>6 byte&0x04  =0x4  \b, [Trainer]
>6 byte&0x04  =0x8  \b, [4-Scr]

#------------------------------------------------------------------------------
# gameboy:  file(1) magic for the Nintendo (Color) Gameboy raw ROM format
#
0x104 belong 0xCEED6666 Gameboy ROM:
>0x134 string >\0 "%.16s"
>0x146 byte 0x03  \b,[SGB]
>0x147 byte 0x00  \b, [ROM ONLY]
>0x147 byte 0x01  \b, [ROM+MBC1]
>0x147 byte 0x02  \b, [ROM+MBC1+RAM]
>0x147 byte 0x03  \b, [ROM+MBC1+RAM+BATT]
>0x147 byte 0x05  \b, [ROM+MBC2]
>0x147 byte 0x06  \b, [ROM+MBC2+BATTERY]
>0x147 byte 0x08  \b, [ROM+RAM]
>0x147 byte 0x09  \b, [ROM+RAM+BATTERY]
>0x147 byte 0x0B  \b, [ROM+MMM01]
>0x147 byte 0x0C  \b, [ROM+MMM01+SRAM]
>0x147 byte 0x0D  \b, [ROM+MMM01+SRAM+BATT]
>0x147 byte 0x0F  \b, [ROM+MBC3+TIMER+BATT]
>0x147 byte 0x10  \b, [ROM+MBC3+TIMER+RAM+BATT]
>0x147 byte 0x11  \b, [ROM+MBC3]
>0x147 byte 0x12  \b, [ROM+MBC3+RAM]
>0x147 byte 0x13  \b, [ROM+MBC3+RAM+BATT]
>0x147 byte 0x19  \b, [ROM+MBC5]
>0x147 byte 0x1A  \b, [ROM+MBC5+RAM]
>0x147 byte 0x1B  \b, [ROM+MBC5+RAM+BATT]
>0x147 byte 0x1C  \b, [ROM+MBC5+RUMBLE]
>0x147 byte 0x1D  \b, [ROM+MBC5+RUMBLE+SRAM]
>0x147 byte 0x1E  \b, [ROM+MBC5+RUMBLE+SRAM+BATT]
>0x147 byte 0x1F  \b, [Pocket Camera]
>0x147 byte 0xFD  \b, [Bandai TAMA5]
>0x147 byte 0xFE  \b, [Hudson HuC-3]
>0x147 byte 0xFF  \b, [Hudson HuC-1]

>0x148 byte 0     \b, ROM: 256Kbit
>0x148 byte 1     \b, ROM: 512Kbit
>0x148 byte 2     \b, ROM: 1Mbit
>0x148 byte 3     \b, ROM: 2Mbit
>0x148 byte 4     \b, ROM: 4Mbit
>0x148 byte 5     \b, ROM: 8Mbit
>0x148 byte 6     \b, ROM: 16Mbit
>0x148 byte 0x52  \b, ROM: 9Mbit
>0x148 byte 0x53  \b, ROM: 10Mbit
>0x148 byte 0x54  \b, ROM: 12Mbit

>0x149 byte 1     \b, RAM: 16Kbit
>0x149 byte 2     \b, RAM: 64Kbit
>0x149 byte 3     \b, RAM: 128Kbit
>0x149 byte 4     \b, RAM: 1Mbit

#>0x14e long  x     \b, CRC: %x

#------------------------------------------------------------------------------
# genesis:  file(1) magic for the Sega MegaDrive/Genesis raw ROM format
#
0x100 string SEGA  Sega MegaDrive/Genesis raw ROM dump
>0x120 string >\0 Name: "%.16s"
>0x110 string >\0 %.16s
>0x1B0 string RA with SRAM

#------------------------------------------------------------------------------
# genesis:  file(1) magic for the Super MegaDrive ROM dump format
#
0x280 string EAGN  Super MagicDrive ROM dump
>0 byte x %dx16k blocks
>2 byte 0 \b, last in series or standalone
>2 byte >0 \b, split ROM
>8 byte 0xAA
>9 byte 0xBB

#------------------------------------------------------------------------------
# genesis:  file(1) alternate magic for the Super MegaDrive ROM dump format
#
0x280 string EAMG  Super MagicDrive ROM dump
>0 byte x %dx16k blocks
>2 byte x \b, last in series or standalone
>8 byte 0xAA
>9 byte 0xBB

#------------------------------------------------------------------------------
# smsgg:  file(1) magic for Sega Master System and Game Gear ROM dumps
#
# Does not detect all images.  Very preliminary guesswork.  Need more data
# on format.
#
# FIXME: need a little more info...;P
#
#0 byte 0xF3
#>1 byte 0xED  Sega Master System/Game Gear ROM dump
#>1 byte 0x31  Sega Master System/Game Gear ROM dump
#>1 byte 0xDB  Sega Master System/Game Gear ROM dump
#>1 byte 0xAF  Sega Master System/Game Gear ROM dump
#>1 byte 0xC3  Sega Master System/Game Gear ROM dump

#------------------------------------------------------------------------------
# dreamcast:  file(1) uncertain magic for the Sega Dreamcast VMU image format
#
0 belong 0x21068028   Sega Dreamcast VMU game image
0 string LCDi         Dream Animator file

#------------------------------------------------------------------------------
# v64: file(1) uncertain magic for the V64 format N64 ROM dumps
#
0 belong 0x37804012    V64 Nintendo 64 ROM dump

# From: "Nelson A. de Oliveira" <naoliv@@gmail.com>
# Nintendo .nds
192	string	\044\377\256Qi\232	Nintendo DS Game ROM Image
# Nintendo .gba
0	string	\056\000\000\352$\377\256Qi	Nintendo Game Boy Advance ROM Image

#------------------------------------------------------------------------------
# msx: file(1) magic for MSX game cartridge dumps
# Too simple - MPi
#0 beshort 0x4142 MSX game cartridge dump 

#------------------------------------------------------------------------------
# Sony Playstation executables (Adam Sjoegren <asjo@@diku.dk>) :
0	string	PS-X\ EXE	Sony Playstation executable
#  Area:
>113	string	x		(%s)

#------------------------------------------------------------------------------
# Microsoft Xbox executables .xbe (Esa Hyytiä <ehyytia@@cc.hut.fi>)
0       string          XBEH            XBE, Microsoft Xbox executable
# probabilistic checks whether signed or not
>0x0004 ulelong =0x0
>>&2    ulelong =0x0
>>>&2   ulelong =0x0  \b, not signed
>0x0004 ulelong >0
>>&2    ulelong >0
>>>&2   ulelong >0    \b, signed
# expect base address of 0x10000
>0x0104               ulelong =0x10000
>>(0x0118-0x0FF60)    ulelong&0x80000007  0x80000007 \b, all regions
>>(0x0118-0x0FF60)    ulelong&0x80000007  !0x80000007
>>>(0x0118-0x0FF60)   ulelong >0           (regions:
>>>>(0x0118-0x0FF60)  ulelong &0x00000001  NA
>>>>(0x0118-0x0FF60)  ulelong &0x00000002  Japan
>>>>(0x0118-0x0FF60)  ulelong &0x00000004  Rest_of_World
>>>>(0x0118-0x0FF60)  ulelong &0x80000000  Manufacturer
>>>(0x0118-0x0FF60)   ulelong >0           \b)

# --------------------------------
# Microsoft Xbox data file formats
0       string          XIP0            XIP, Microsoft Xbox data
0       string          XTF0            XTF, Microsoft Xbox data

# Atari Lynx cartridge dump (EXE/BLL header)
# From: "Stefan A. Haubenthal" <polluks@@web.de>

0	beshort		0x8008		Lynx cartridge,
>2	beshort		x		RAM start $%04x
>6	string		BS93

# Opera file system that is used on the 3DO console
# From: Serge van den Boom <svdb@@stack.nl>
0	string		\x01ZZZZZ\x01	3DO "Opera" file system

# From Gürkan Sengün <gurkan@@linuks.mine.nu>, www.linuks.mine.nu
0	string		GBS		Nintendo Gameboy Music/Audio Data
12	string		GameBoy\ Music\ Module	Nintendo Gameboy Music Module

# Playstations Patch Files from: From: Thomas Klausner <tk@@giga.or.at>
0	string	PPF30			Playstation Patch File version 3.0
>5	byte	0			\b, PPF 1.0 patch
>5	byte	1			\b, PPF 2.0 patch
>5	byte	2			\b, PPF 3.0 patch
>>56	byte	0			\b, Imagetype BIN (any)
>>56	byte	1			\b, Imagetype GI (PrimoDVD)
>>57	byte	0			\b, Blockcheck disabled
>>57	byte	1			\b, Blockcheck enabled
>>58	byte	0			\b, Undo data not available
>>58	byte	1			\b, Undo data available
>6	string	x			\b, description: %s

0	string	PPF20			Playstation Patch File version 2.0
>5	byte	0			\b, PPF 1.0 patch
>5	byte	1			\b, PPF 2.0 patch
>>56	lelong	>0			\b, size of file to patch %d
>6	string	x			\b, description: %s

0	string	PPF10			Playstation Patch File version 1.0
>5	byte	0			\b, Simple Encoding
>6	string	x			\b, description: %s

# From: Daniel Dawson <ddawson@@icehouse.net>
# SNES9x .smv "movie" file format.
0		string		SMV\x1A	SNES9x input recording
>0x4		lelong		x	\b, version %d
# version 4 is latest so far 
>0x4		lelong		<5
>>0x8		ledate		x	\b, recorded at %s
>>0xc		lelong		>0	\b, rerecorded %d times
>>0x10		lelong		x	\b, %d frames long
>>0x14		byte		>0	\b, data for controller(s):
>>>0x14		byte		&0x1	#1
>>>0x14		byte		&0x2	#2
>>>0x14		byte		&0x4	#3
>>>0x14		byte		&0x8	#4
>>>0x14		byte		&0x10	#5
>>0x15		byte		^0x1	\b, begins from snapshot
>>0x15		byte		&0x1	\b, begins from reset
>>0x15		byte		^0x2	\b, NTSC standard
>>0x15		byte		&0x2	\b, PAL standard
>>0x17		byte		&0x1    \b, settings:
# WIP1Timing not used as of version 4
>>>0x4		lelong		<4
>>>>0x17	byte		&0x2	WIP1Timing
>>>0x17		byte		&0x4	Left+Right
>>>0x17		byte		&0x8	VolumeEnvX
>>>0x17		byte		&0x10	FakeMute
>>>0x17		byte		&0x20	SyncSound
# New flag as of version 4
>>>0x4		lelong		>3
>>>>0x17	byte		&0x80	NoCPUShutdown
>>0x4		lelong		<4
>>>0x18		lelong		>0x23
>>>>0x20	leshort		!0
>>>>>0x20	lestring16	x	\b, metadata: "%s"
>>0x4		lelong		>3
>>>0x24		byte		>0	\b, port 1:
>>>>0x24	byte		1	joypad
>>>>0x24	byte		2	mouse
>>>>0x24	byte		3	SuperScope
>>>>0x24	byte		4	Justifier
>>>>0x24	byte		5	multitap
>>>0x24		byte		>0	\b, port 2:
>>>>0x25	byte		1	joypad
>>>>0x25	byte		2	mouse
>>>>0x25	byte		3	SuperScope
>>>>0x25	byte		4	Justifier
>>>>0x25	byte		5	multitap
>>>0x18		lelong		>0x43
>>>>0x40	leshort		!0
>>>>>0x40	lestring16	x	\b, metadata: "%s"
>>0x17		byte		&0x40   \b, ROM:
>>>(0x18.l-26)	lelong		x	CRC32 0x%08x
>>>(0x18.l-23)	string		x	"%s"

@


1.1.1.1
log
@from ftp.astron.com
@
text
@@


1.1.1.2
log
@from ftp.astron.com.
- many security related fixes
- no MAXPATHLEN limits
- fixed missing text specification on ascii magic
- new ``pascal'' style string formats
- whitespace comparison fix
- more magic
@
text
@a0 1

a1 1
# $File: console,v 1.18 2010/09/20 19:19:17 rrt Exp $
d166 3
a168 7
# Double-check that the image type matches too, 0x8008 conflicts with
# 8 character OMF-86 object file headers.
0	beshort		0x8008		
>6	string		BS93		Lynx homebrew cartridge
>>2	beshort		x		\b, RAM start $%04x
>6	string		LYNX		Lynx cartridge
>>2	beshort		x		\b, RAM start $%04x
a254 4
# Type: scummVM savegame files
# From: Sven Hartge <debian@@ds9.argh.org>
0	string	SCVM	ScummVM savegame
>12	string	>\0	"%s"
@


1.1.1.2.4.1
log
@sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs.  ("Protocol error: too many arguments")
@
text
@d3 1
a3 1
# $File: console,v 1.19 2013/02/06 14:18:52 christos Exp $
d140 1
a140 1
# Microsoft Xbox executables .xbe (Esa Hyytia <ehyytia@@cc.hut.fi>)
d180 1
a180 1
# From Gurkan Sengun <gurkan@@linuks.mine.nu>, www.linuks.mine.nu
@


1.1.1.2.10.1
log
@resync from head
@
text
@d3 1
a3 1
# $File: console,v 1.19 2013/02/06 14:18:52 christos Exp $
d140 1
a140 1
# Microsoft Xbox executables .xbe (Esa Hyytia <ehyytia@@cc.hut.fi>)
d180 1
a180 1
# From Gurkan Sengun <gurkan@@linuks.mine.nu>, www.linuks.mine.nu
@


1.1.1.3
log
@import file-5.14
changes are "name" + "use" keyword features, bug fixes
@
text
@d3 1
a3 1
# $File: console,v 1.19 2013/02/06 14:18:52 christos Exp $
d140 1
a140 1
# Microsoft Xbox executables .xbe (Esa Hyytia <ehyytia@@cc.hut.fi>)
d180 1
a180 1
# From Gurkan Sengun <gurkan@@linuks.mine.nu>, www.linuks.mine.nu
@


1.1.1.3.18.1
log
@Sync with HEAD
@
text
@d3 1
a3 1
# $File: console,v 1.29 2017/02/08 21:53:06 christos Exp $
d6 2
d9 41
a49 48
# ines: file(1) magic for Marat's iNES Nintendo Entertainment System ROM dump format
# Updated by David Korth <gerbilsoft@@gerbilsoft.com>
# References:
# - http://wiki.nesdev.com/w/index.php/INES
# - http://wiki.nesdev.com/w/index.php/NES_2.0

# Common header for iNES, NES 2.0, and Wii U iNES.
0	name		nes-rom-image-ines
>7	byte&0x0C	=0x8		(NES 2.0)
>4	byte		x		\b: %ux16k PRG
>5	byte		x		\b, %ux8k CHR
>6	byte&0x08	=0x8		[4-Scr]
>6	byte&0x09	=0x0		[H-mirror]
>6	byte&0x09	=0x1		[V-mirror]
>6	byte&0x02	=0x2		[SRAM]
>6	byte&0x04	=0x4		[Trainer]
>7	byte&0x03	=0x2		[PC10]
>7	byte&0x03	=0x1		[VS]
>>7	byte&0x0C	=0x8
# NES 2.0: VS PPU
>>>13	byte&0x0F	=0x0		\b, RP2C03B
>>>13	byte&0x0F	=0x1		\b, RP2C03G
>>>13	byte&0x0F	=0x2		\b, RP2C04-0001
>>>13	byte&0x0F	=0x3		\b, RP2C04-0002
>>>13	byte&0x0F	=0x4		\b, RP2C04-0003
>>>13	byte&0x0F	=0x5		\b, RP2C04-0004
>>>13	byte&0x0F	=0x6		\b, RP2C03B
>>>13	byte&0x0F	=0x7		\b, RP2C03C
>>>13	byte&0x0F	=0x8		\b, RP2C05-01
>>>13	byte&0x0F	=0x9		\b, RP2C05-02
>>>13	byte&0x0F	=0xA		\b, RP2C05-03
>>>13	byte&0x0F	=0xB		\b, RP2C05-04
>>>13	byte&0x0F	=0xC		\b, RP2C05-05
# TODO: VS protection hardware?
>>7	byte		x		\b]
# NES 2.0-specific flags.
>7	byte&0x0C	=0x8
>>12	byte&0x03	=0x0		[NTSC]
>>12	byte&0x03	=0x1		[PAL]
>>12	byte&0x02	=0x2		[NTSC+PAL]

# Standard iNES ROM header.
0	string		NES\x1A		NES ROM image (iNES)
>0	use		nes-rom-image-ines

# Wii U Virtual Console iNES ROM header.
0	belong		0x4E455300	NES ROM image (Wii U Virtual Console)
>0	use		nes-rom-image-ines
a50 101
#------------------------------------------------------------------------------
# unif: file(1) magic for UNIF-format Nintendo Entertainment System ROM images
# Reference: http://wiki.nesdev.com/w/index.php/UNIF
# From: David Korth <gerbilsoft@@gerbilsoft.com>
#
# NOTE: The UNIF format uses chunks instead of a fixed header,
# so most of the data isn't easily parseable.
#
0	string	UNIF
>4	lelong	<16	NES ROM image (UNIF v%d format)

#------------------------------------------------------------------------------
# fds: file(1) magic for Famciom Disk System disk images
# Reference: http://wiki.nesdev.com/w/index.php/Family_Computer_Disk_System#.FDS_format
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# TODO: Check "Disk info block" and get info from that in addition to the optional header.

# Disk info block. (block 1)
0	name	nintendo-fds-disk-info-block
>23	byte	!1		FMC-
>23	byte	1		FSC-
>16	string	x		\b%.3s
>15	byte	x		\b, mfr %02X
>20	byte	x		(Rev.%02u)

# Headered version.
0	string	FDS\x1A
>0x11	string	*NINTENDO-HVC*	Famicom Disk System disk image:
>>0x10	use	nintendo-fds-disk-info-block
>4	byte	1	(%u side)
>4	byte	!1	(%u sides)

# Unheadered version.
1	string	*NINTENDO-HVC*	Famicom Disk System disk image:
>0	use	nintendo-fds-disk-info-block

#------------------------------------------------------------------------------
# tnes: file(1) magic for TNES-format Nintendo Entertainment System ROM images
# Used by Nintendo 3DS NES Virtual Console games.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
#
0		string	TNES	NES ROM image (Nintendo 3DS Virtual Console)
>4		byte	100	\b: FDS,
>>0x2010	use	nintendo-fds-disk-info-block
>4		byte	!100	\b: TNES mapper %u
>>5	byte		x		\b, %ux8k PRG
>>6	byte		x		\b, %ux8k CHR
>>7	byte&0x08	=1		[WRAM]
>>8	byte&0x09	=1		[H-mirror]
>>8	byte&0x09	=2		[V-mirror]
>>8	byte&0x02	=3		[VRAM]

#------------------------------------------------------------------------------
# gameboy: file(1) magic for the Nintendo (Color) Gameboy raw ROM format
# Reference: http://gbdev.gg8.se/wiki/articles/The_Cartridge_Header
#
0x104		bequad		0xCEED6666CC0D000B	Game Boy ROM image
>0x143		byte&0x80	0x80
>>0x134		string		>\0			\b: "%.15s"
>0x143		byte&0x80	!0x80
>>0x134		string		>\0			\b: "%.16s"
>0x14c		byte		x			(Rev.%02u)

# Machine type. (SGB, CGB, SGB+CGB)
>0x14b		byte		0x33
>>0x146		byte		0x03
>>>0x143	byte&0x80	0x80	[SGB+CGB]
>>>0x143	byte&0x80	!0x80	[SGB]
>>0x146		byte		!0x03
>>>0x143	byte&0xC0	0x80	[CGB]
>>>0x143	byte&0xC0	0xC0	[CGB ONLY]

# Mapper.
>0x147 byte 0x00  [ROM ONLY]
>0x147 byte 0x01  [MBC1]
>0x147 byte 0x02  [MBC1+RAM]
>0x147 byte 0x03  [MBC1+RAM+BATT]
>0x147 byte 0x05  [MBC2]
>0x147 byte 0x06  [MBC2+BATTERY]
>0x147 byte 0x08  [ROM+RAM]
>0x147 byte 0x09  [ROM+RAM+BATTERY]
>0x147 byte 0x0B  [MMM01]
>0x147 byte 0x0C  [MMM01+SRAM]
>0x147 byte 0x0D  [MMM01+SRAM+BATT]
>0x147 byte 0x0F  [MBC3+TIMER+BATT]
>0x147 byte 0x10  [MBC3+TIMER+RAM+BATT]
>0x147 byte 0x11  [MBC3]
>0x147 byte 0x12  [MBC3+RAM]
>0x147 byte 0x13  [MBC3+RAM+BATT]
>0x147 byte 0x19  [MBC5]
>0x147 byte 0x1A  [MBC5+RAM]
>0x147 byte 0x1B  [MBC5+RAM+BATT]
>0x147 byte 0x1C  [MBC5+RUMBLE]
>0x147 byte 0x1D  [MBC5+RUMBLE+SRAM]
>0x147 byte 0x1E  [MBC5+RUMBLE+SRAM+BATT]
>0x147 byte 0xFC  [Pocket Camera]
>0x147 byte 0xFD  [Bandai TAMA5]
>0x147 byte 0xFE  [Hudson HuC-3]
>0x147 byte 0xFF  [Hudson HuC-1]

# ROM size.
a57 1
>0x148 byte 7     \b, ROM: 32Mbit
a61 1
# RAM size.
d66 2
a67 1
>0x149 byte 5     \b, RAM: 512Kbit
d70 1
a70 5
# genesis: file(1) magic for various Sega Mega Drive / Genesis ROM image and disc formats
# Updated by David Korth <gerbilsoft@@gerbilsoft.com>
# References:
# - http://www.retrodev.com/segacd.html
# - http://devster.monkeeh.com/sega/32xguide1.txt
d72 4
a75 43

# Common Sega Mega Drive header format.
# FIXME: Name fields are 48 bytes, but have spaces for padding instead of 00s.
0		name	sega-mega-drive-header
# ROM title. (Use domestic if present; if not, use international.)
>0x120		byte	>0x20
>>0x120		string	>\0	\b: "%.16s"
>0x120		byte	<0x21
>>0x150		string	>\0	\b: "%.16s"
# Other information.
>0x180		string	>\0	(%.14s
>>0x110		string  >\0	\b, %.16s
>0x180		byte	0
>>0x110		string  >\0	(%.16s
>0		byte	x	\b)

# TODO: Check for 32X CD?
# Sega Mega CD disc images: 2048-byte sectors.
0	string	SEGADISCSYSTEM\ \ 	Sega Mega CD disc image
>0	use	sega-mega-drive-header
>0	byte	x			\b, 2048-byte sectors
0	string	SEGABOOTDISC\ \ \ \ 	Sega Mega CD disc image
>0	use	sega-mega-drive-header
>0	byte	x			\b, 2048-byte sectors
# Sega Mega CD disc images: 2352-byte sectors.
0x10	string	SEGADISCSYSTEM\ \ 	Sega Mega CD disc image
>0x10	use	sega-mega-drive-header
>0	byte	x			\b, 2352-byte sectors
0x10	string	SEGABOOTDISC\ \ \ \ 	Sega Mega CD disc image
>0x10	use	sega-mega-drive-header
>0	byte	x			\b, 2352-byte sectors

# Sega Mega Drive, 32X, Pico, and Mega CD Boot ROM images.
0x100		string	SEGA
>0x3C0		bequad	0x4D41525320434845	Sega 32X ROM image
>>0		use	sega-mega-drive-header
>0x3C0		bequad	!0x4D41525320434845
>>0x105		belong	0x5049434F	Sega Pico ROM image
>>>0		use	sega-mega-drive-header
>>0x105		belong	!0x5049434F
>>>0x180	beshort	0x4252		Sega Mega CD Boot ROM image
>>>0x180	beshort	!0x4252		Sega Mega Drive / Genesis ROM image
>>>0		use	sega-mega-drive-header
d78 1
a78 1
# genesis: file(1) magic for the Super MegaDrive ROM dump format
d80 6
a85 17

# NOTE: Due to interleaving, we can't display anything
# other than the copier header information.
0      name    sega-genesis-smd-header
>0     byte    x       %dx16k blocks
>2     byte    0       \b, last in series or standalone
>2     byte    >0      \b, split ROM

# "Sega Genesis" header.
0x280	string EAGN
>8	beshort	0xAABB	Sega Mega Drive / Genesis ROM image (SMD format):
>>0	use     sega-genesis-smd-header

# "Sega Mega Drive" header.
0x280	string EAMG
>8	beshort	0xAABB	Sega Mega Drive / Genesis ROM image (SMD format):
>>0	use     sega-genesis-smd-header
d88 1
a88 5
# smsgg:  file(1) magic for Sega Master System and Game Gear ROM images
# Detects all Game Gear and export Sega Master System ROM images,
# and some Japanese Sega Master System ROM images.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: http://www.smspower.org/Development/ROMHeader
d90 5
a94 54

# General SMS header rule.
# The SMS boot ROM checks the header at three locations.
0	name	sega-master-system-rom-header
# Machine type.
>0x0F	byte&0xF0	0x30	Sega Master System
>0x0F	byte&0xF0	0x40	Sega Master System
>0x0F	byte&0xF0	0x50	Sega Game Gear
>0x0F	byte&0xF0	0x60	Sega Game Gear
>0x0F	byte&0xF0	0x70	Sega Game Gear
>0x0F	byte&0xF0	<0x30	Sega Master System / Game Gear
>0x0F	byte&0xF0	>0x70	Sega Master System / Game Gear
>0	byte		x	ROM image:
# Product code.
>0x0E	byte&0xF0	0x10	1
>0x0E	byte&0xF0	0x20	2
>0x0E	byte&0xF0	0x30	3
>0x0E	byte&0xF0	0x40	4
>0x0E	byte&0xF0	0x50	5
>0x0E	byte&0xF0	0x60	6
>0x0E	byte&0xF0	0x70	7
>0x0E	byte&0xF0	0x80	8
>0x0E	byte&0xF0	0x90	9
>0x0E	byte&0xF0	0xA0	10
>0x0E	byte&0xF0	0xB0	11
>0x0E	byte&0xF0	0xC0	12
>0x0E	byte&0xF0	0xD0	13
>0x0E	byte&0xF0	0xE0	14
>0x0E	byte&0xF0	0xF0	15
# If the product code is 5 digits, we'll need to backspace here.
>0x0E	byte&0xF0	!0
>>0x0C	leshort		x	\b%04x
>0x0E	byte&0xF0	0
>>0x0C	leshort		x	%04x
# Revision.
>0x0E	byte&0x0F	x	(Rev.%02d)
# ROM size. (Used for the boot ROM checksum routine.)
>0x0F	byte&0x0F	0x0A	(8 KB)
>0x0F	byte&0x0F	0x0B	(16 KB)
>0x0F	byte&0x0F	0x0C	(32 KB)
>0x0F	byte&0x0F	0x0D	(48 KB)
>0x0F	byte&0x0F	0x0E	(64 KB)
>0x0F	byte&0x0F	0x0F	(128 KB)
>0x0F	byte&0x0F	0x00	(256 KB)
>0x0F	byte&0x0F	0x01	(512 KB)
>0x0F	byte&0x0F	0x02	(1 MB)

# SMS/GG header locations.
0x7FF0	string	TMR\ SEGA
>0x7FF0	use	sega-master-system-rom-header
0x3FF0	string	TMR\ SEGA
>0x3FF0	use	sega-master-system-rom-header
0x1FF0	string	TMR\ SEGA
>0x1FF0	use	sega-master-system-rom-header
d97 4
a100 2
# saturn: file(1) magic for the Sega Saturn disc image format.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
d102 1
a102 23

# Common Sega Saturn disc header format.
# NOTE: Title is 112 bytes, but we're only showing 32 due to space padding.
# TODO: Release date, device information, region code, others?
0	name	sega-saturn-disc-header
>0x60	string	>\0	\b: "%.32s"
>0x20	string	>\0	(%.10s
>>0x2A	string	>\0	\b, %.6s)
>>0x2A	byte	0	\b)

# 2048-byte sector version.
0	string	SEGA\ SEGASATURN\ 	Sega Saturn disc image
>0	use	sega-saturn-disc-header
>0	byte	x			(2048-byte sectors)
# 2352-byte sector version.
0x10	string	SEGA\ SEGASATURN\ 	Sega Saturn disc image
>0x10	use	sega-saturn-disc-header
>0	byte	x			(2352-byte sectors)

#------------------------------------------------------------------------------
# dreamcast: file(1) magic for the Sega Dreamcast disc image format.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: http://mc.pp.se/dc/ip0000.bin.html
d104 6
a109 18

# Common Sega Dreamcast disc header format.
# NOTE: Title is 128 bytes, but we're only showing 32 due to space padding.
# TODO: Release date, device information, region code, others?
0	name	sega-dreamcast-disc-header
>0x80	string	>\0	\b: "%.32s"
>0x40	string	>\0	(%.10s
>>0x4A	string	>\0	\b, %.6s)
>>0x4A	byte	0	\b)

# 2048-byte sector version.
0	string	SEGA\ SEGAKATANA\ 	Sega Dreamcast disc image
>0	use	sega-dreamcast-disc-header
>0	byte	x			(2048-byte sectors)
# 2352-byte sector version.
0x10	string	SEGA\ SEGAKATANA\ 	Sega Dreamcast disc image
>0x10	use	sega-dreamcast-disc-header
>0	byte	x			(2352-byte sectors)
d118 1
a118 3
# z64: file(1) magic for the Z64 format N64 ROM dumps
# Reference: http://forum.pj64-emu.com/showthread.php?t=2239
# From: David Korth <gerbilsoft@@gerbilsoft.com>
d120 1
a120 4
0	bequad	0x803712400000000F	Nintendo 64 ROM image
>0x20	string	>\0	\b: "%.20s"
>0x3B	string	x	(%.4s
>0x3F	byte	x	\b, Rev.%02u)
d122 5
a126 62
#------------------------------------------------------------------------------
# v64: file(1) magic for the V64 format N64 ROM dumps
# Same as z64 format, but with 16-bit byteswapping.
#
0	bequad	0x3780401200000F00	Nintendo 64 ROM image (V64)

#------------------------------------------------------------------------------
# n64-swap2: file(1) magic for the swap2 format N64 ROM dumps
# Same as z64 format, but with swapped 16-bit words.
#
0	bequad	0x12408037000F0000	Nintendo 64 ROM image (wordswapped)

#------------------------------------------------------------------------------
# n64-le32: file(1) magic for the 32-bit byteswapped format N64 ROM dumps
# Same as z64 format, but with 32-bit byteswapping.
#
0	bequad	0x401237800F000000	Nintendo 64 ROM image (32-bit byteswapped)

#------------------------------------------------------------------------------
# gba: file(1) magic for the Nintendo Game Boy Advance raw ROM format
# Reference: http://problemkaputt.de/gbatek.htm#gbacartridgeheader
#
# Original version from: "Nelson A. de Oliveira" <naoliv@@gmail.com>
# Updated version from: David Korth <gerbilsoft@@gerbilsoft.com>
#
4	bequad	0x24FFAE51699AA221	Game Boy Advance ROM image
>0xA0	string	>\0	\b: "%.12s"
>0xAC	string	x	(%.6s
>0xBC	byte	x	\b, Rev.%02u)

#------------------------------------------------------------------------------
# nds: file(1) magic for the Nintendo DS(i) raw ROM format
# Reference: http://problemkaputt.de/gbatek.htm#dscartridgeheader
#
# Original version from: "Nelson A. de Oliveira" <naoliv@@gmail.com>
# Updated version from: David Korth <gerbilsoft@@gerbilsoft.com>
#
0xC0	bequad	0x24FFAE51699AA221	Nintendo DS ROM image
>0x00	string	>\0		\b: "%.12s"
>0x0C	string	x		(%.6s
>0x1E	byte	x		\b, Rev.%02u)
>0x12	byte	2		(DSi enhanced)
>0x12	byte	3		(DSi only)

#------------------------------------------------------------------------------
# nds_passme: file(1) magic for Nintendo DS ROM images for GBA cartridge boot.
# This is also used for loading .nds files using the MSET exploit on 3DS.
# Reference: https://github.com/devkitPro/ndstool/blob/master/source/ndscreate.cpp
0xC0	bequad	0xC8604FE201708FE2	Nintendo DS Slot-2 ROM image (PassMe)

#------------------------------------------------------------------------------
# ngp: file(1) magic for the Neo Geo Pocket (Color) raw ROM format.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# References:
# - https://neogpc.googlecode.com/svn-history/r10/trunk/src/core/neogpc.cpp
# - http://www.devrs.com/ngp/files/ngpctech.txt
#
0x0A	string	BY\ SNK\ CORPORATION	Neo Geo Pocket
>0x23	byte	0x10			Color
>0	byte	x			ROM image
>0x24	string	>\0			\b: "%.12s"
>0x1F	byte	0xFF			(debug mode enabled)
a135 12
>16	lelong	x		PC=0x%08x,
>20	lelong	!0		GP=0x%08x,
>24	lelong	!0		.text=[0x%08x,
>>28	lelong	x		\b0x%x],
>32	lelong	!0		.data=[0x%08x,
>>36	lelong	x		\b0x%x],
>40	lelong	!0		.bss=[0x%08x,
>>44	lelong	x		\b0x%x],
>48	lelong	!0		Stack=0x%08x,
>48	lelong	=0		No Stack!,
>52	lelong	!0		StackSize=0x%x,
#>76	string	>\0		(%s)
a138 4
# CPE executables
0	string	CPE		CPE executable
>3	byte	x		(version %d)

d180 1
a180 6
# From: Gurkan Sengun <gurkan@@linuks.mine.nu>, www.linuks.mine.nu
# From: David Pflug <david@@pflug.email>
# is the offset 12 or the offset 16 correct?
# GBS (Game Boy Sound) magic
# ftp://ftp.modland.com/pub/documents/format_documentation/\
# Gameboy%20Sound%20System%20(.gbs).txt 
d182 1
a182 10
#12	string		GameBoy\ Music\ Module	Nintendo Gameboy Music Module
>16	string		>\0	("%s" by
>48	string		>\0	%s, copyright
>80	string		>\0	%s),
>3	byte		x	version %d,
>4	byte		x	%d tracks

# IPS Patch Files from: From: Thomas Klausner <tk@@giga.or.at>
# see http://zerosoft.zophar.net/ips.php
0	string	PATCH			IPS patch file
a264 238

#------------------------------------------------------------------------------
# Nintendo GameCube / Wii file formats.
#

# Type: Nintendo GameCube/Wii common disc header data.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: http://wiibrew.org/wiki/Wii_Disc
0	name	nintendo-gcn-disc-common
>0x20	string	x	"%.64s"
>0x00	string	x	(%.6s
>0x06	byte	>0
>>0x06	byte	1	\b, Disc 2
>>0x06	byte	2	\b, Disc 3
>>0x06	byte	3	\b, Disc 4
>0x07	byte	x	\b, Rev.%02u)

# Type: Nintendo GameCube disc image
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: http://wiibrew.org/wiki/Wii_Disc
0x1C	belong	0xC2339F3D	Nintendo GameCube disc image:
>0	use	nintendo-gcn-disc-common

# Type: Nintendo GameCube embedded disc image
# Commonly found on demo discs.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: http://hitmen.c02.at/files/yagcd/yagcd/index.html#idx14.8
0		belong	0xAE0F38A2
>0x0C		belong	0x00100000
>>(8.L+0x1C)	belong	0xC2339F3D	Nintendo GameCube embedded disc image:
>>>(8.L)	use	nintendo-gcn-disc-common

# Type: Nintendo Wii disc image
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: http://wiibrew.org/wiki/Wii_Disc
0x18	belong	0x5D1C9EA3	Nintendo Wii disc image:
>0	use	nintendo-gcn-disc-common

# Type: Nintendo Wii disc image (WBFS format)
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: http://wiibrew.org/wiki/Wii_Disc
0	string	WBFS
>0x218	belong	0x5D1C9EA3	Nintendo Wii disc image (WBFS format):
>>0x200	use	nintendo-gcn-disc-common

# Type: Nintendo GameCube/Wii disc image (CISO format)
# NOTE: This is NOT the same as Compact ISO or PSP CISO,
# though it has the same magic number.
0		string	CISO
# Other fields are used to determine what type of CISO this is:
# - 0x04 == 0x00200000: GameCube/Wii CISO (block_size)
# - 0x10 == 0x00000800: PSP CISO (ISO-9660 sector size)
# - None of the above: Compact ISO.
>4		lelong	0x200000
>>8		byte	1
>>>0x801C	belong	0xC2339F3D	Nintendo GameCube disc image (CISO format):
>>>>0x8000	use	nintendo-gcn-disc-common
>>>0x8018	belong	0x5D1C9EA3	Nintendo Wii disc image (CISO format):
>>>>0x8000	use	nintendo-gcn-disc-common

# Type: Nintendo GameCube/Wii disc image (GCZ format)
# Due to zlib compression, we can't get the actual disc information.
0	lelong	0xB10BC001
>4	lelong	0		Nintendo GameCube disc image (GCZ format)
>4	lelong	1		Nintendo Wii disc image (GCZ format)
>4	lelong	>1		Nintendo GameCube/Wii disc image (GCZ format)

# Type: Nintendo GameCube/Wii disc image (WDF format)
0		string	WII\001DISC
>8		belong	1
# WDFv1
>>0x54		belong	0xC2339F3D	Nintendo GameCube disc image (WDFv1 format):
>>>0x38		use	nintendo-gcn-disc-common
>>0x58		belong	0x5D1C9EA3	Nintendo Wii disc image (WDFv1 format):
>>>0x38		use	nintendo-gcn-disc-common
>8		belong	2
# WDFv2
>>(12.L+0x1C)	belong	0xC2339F3D	Nintendo GameCube disc image (WDFv2 format):
>>>(12.L)	use	nintendo-gcn-disc-common
>>(12.L+0x18)	belong	0x5D1C9EA3	Nintendo Wii disc image (WDFv2 format):
>>>(12.L)	use	nintendo-gcn-disc-common

# Type: Nintendo GameCube/Wii disc image (WIA format)
0	string	WIA\001	Nintendo
>0x48	belong	0	GameCube/Wii
>0x48	belong	1	GameCube
>0x48	belong	2	Wii
>0x48	belong	>2	GameCube/Wii
>0x48	belong	x	disc image (WIA format):
>>0x58	use	nintendo-gcn-disc-common

#------------------------------------------------------------------------------
# Nintendo 3DS file formats.
#

# Type: Nintendo 3DS "NCSD" image. (game cards and eMMC)
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: https://www.3dbrew.org/wiki/NCSD
0x100		string		NCSD
>0x118		lequad		0		Nintendo 3DS Game Card image
# NCCH header for partition 0. (game data)
>>0x1150	string		>\0	\b: "%.16s"
>>0x312		byte		x	(Rev.%02u)
>>0x118C	byte		2	(New3DS only)
>>0x18D		byte		0		(inner device)
>>0x18D		byte		1		(Card1)
>>0x18D		byte		2		(Card2)
>>0x18D		byte		3		(extended device)
>0x118		bequad		0x0102020202000000	Nintendo 3DS eMMC dump (Old3DS)
>0x118		bequad		0x0102020203000000	Nintendo 3DS eMMC dump (New3DS)

# Nintendo 3DS version code.
# Reference: https://www.3dbrew.org/wiki/Titles
# Format: leshort containing three fields:
# - 6-bit: Major
# - 6-bit: Minor
# - 4-bit: Revision
# NOTE: Only supporting major/minor versions from 0-15 right now.
# NOTE: Should be prefixed with "v".
0	name	nintendo-3ds-version-code
# Raw version.
>0	leshort	x	\b%u,
# Major version.
>0	leshort&0xFC00	0x0000	0
>0	leshort&0xFC00	0x0400	1
>0	leshort&0xFC00	0x0800	2
>0	leshort&0xFC00	0x0C00	3
>0	leshort&0xFC00	0x1000	4
>0	leshort&0xFC00	0x1400	5
>0	leshort&0xFC00	0x1800	6
>0	leshort&0xFC00	0x1C00	7
>0	leshort&0xFC00	0x2000	8
>0	leshort&0xFC00	0x2400	9
>0	leshort&0xFC00	0x2800	10
>0	leshort&0xFC00	0x2C00	11
>0	leshort&0xFC00	0x3000	12
>0	leshort&0xFC00	0x3400	13
>0	leshort&0xFC00	0x3800	14
>0	leshort&0xFC00	0x3C00	15
# Minor version.
>0	leshort&0x03F0	0x0000	\b.0
>0	leshort&0x03F0	0x0010	\b.1
>0	leshort&0x03F0	0x0020	\b.2
>0	leshort&0x03F0	0x0030	\b.3
>0	leshort&0x03F0	0x0040	\b.4
>0	leshort&0x03F0	0x0050	\b.5
>0	leshort&0x03F0	0x0060	\b.6
>0	leshort&0x03F0	0x0070	\b.7
>0	leshort&0x03F0	0x0080	\b.8
>0	leshort&0x03F0	0x0090	\b.9
>0	leshort&0x03F0	0x00A0	\b.10
>0	leshort&0x03F0	0x00B0	\b.11
>0	leshort&0x03F0	0x00C0	\b.12
>0	leshort&0x03F0	0x00D0	\b.13
>0	leshort&0x03F0	0x00E0	\b.14
>0	leshort&0x03F0	0x00F0	\b.15
# Revision.
>0	leshort&0x000F	x	\b.%u

# Type: Nintendo 3DS "NCCH" container.
# https://www.3dbrew.org/wiki/NCCH
0x100		string	NCCH	Nintendo 3DS
>0x18D		byte&2	0	File Archive (CFA)
>0x18D		byte&2	2	Executable Image (CXI)
>0x150		string	>\0	\b: "%.16s"
>0x18D		byte	0x05
>>0x10E		leshort	x	(Old3DS System Update v
>>0x10E		use	nintendo-3ds-version-code
>>0x10E		leshort	x	\b)
>0x18D		byte	0x15
>>0x10E		leshort	x	(New3DS System Update v
>>0x10E		use	nintendo-3ds-version-code
>>0x10E		leshort	x	\b)
>0x18D		byte	!0x05
>>0x18D		byte	!0x15
>>>0x112	byte	x	(v
>>>0x112	use	nintendo-3ds-version-code
>>>0x112	byte	x	\b)
>0x18C		byte	2	(New3DS only)

# Type: Nintendo 3DS "SMDH" file. (application description)
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: https://3dbrew.org/wiki/SMDH
0		string		SMDH		Nintendo 3DS SMDH file
>0x208		leshort		!0
>>0x208		lestring16	x		\b: "%.128s"
>>0x388		leshort		!0
>>>0x388	lestring16	x		by %.128s
>0x208		leshort		0
>>0x008		leshort		!0
>>>0x008	lestring16	x		\b: "%.128s"
>>>0x188	leshort		!0
>>>>0x188	lestring16	x		by %.128s

# Type: Nintendo 3DS Homebrew Application.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Refernece: https://3dbrew.org/wiki/3DSX_Format
0	string	3DSX	Nintendo 3DS Homebrew Application (3DSX)

#------------------------------------------------------------------------------
# a7800: file(1) magic for the Atari 7800 raw ROM format.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: https://sites.google.com/site/atari7800wiki/a78-header

0	byte	>0
>0	byte	<3
>>1	string	ATARI7800	Atari 7800 ROM image
>>>0x11	string	>\0	\b: "%.32s"
# Display type.
>>>0x39	byte	0	(NTSC)
>>>0x39	byte	1	(PAL)
>>>0x36	byte&1	1	(POKEY)

#------------------------------------------------------------------------------
# vectrex: file(1) magic for the GCE Vectrex raw ROM format.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: http://www.playvectrex.com/designit/chrissalo/hello1.htm
#
# NOTE: Title is terminated with 0x80, not 0.
# The header is terminated with a 0, so that will
# terminate the title as well.
#
0	string	g\ GCE	Vectrex ROM image
>0x11	string	>\0	\b: "%.16s"

#------------------------------------------------------------------------------
# amiibo: file(1) magic for Nintendo amiibo NFC dumps.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: https://www.3dbrew.org/wiki/Amiibo
0x00		byte	0x04
>0x0A		beshort	0x0FE0
>>0x0C		belong	0xF110FFEE
>>>0x208	beshort	0x0100
>>>>0x020A	byte	0x0F
>>>>>0x020C	bequad	0x000000045F000000
>>>>>>0x5B	byte	0x02
>>>>>>>0x54	belong	x	Nintendo amiibo NFC dump - amiibo ID: %08X-
>>>>>>>0x58	belong	x	\b%08X
@


1.1.1.3.14.1
log
@Sync with HEAD
@
text
@d3 1
a3 1
# $File: console,v 1.29 2017/02/08 21:53:06 christos Exp $
d6 2
d9 41
a49 48
# ines: file(1) magic for Marat's iNES Nintendo Entertainment System ROM dump format
# Updated by David Korth <gerbilsoft@@gerbilsoft.com>
# References:
# - http://wiki.nesdev.com/w/index.php/INES
# - http://wiki.nesdev.com/w/index.php/NES_2.0

# Common header for iNES, NES 2.0, and Wii U iNES.
0	name		nes-rom-image-ines
>7	byte&0x0C	=0x8		(NES 2.0)
>4	byte		x		\b: %ux16k PRG
>5	byte		x		\b, %ux8k CHR
>6	byte&0x08	=0x8		[4-Scr]
>6	byte&0x09	=0x0		[H-mirror]
>6	byte&0x09	=0x1		[V-mirror]
>6	byte&0x02	=0x2		[SRAM]
>6	byte&0x04	=0x4		[Trainer]
>7	byte&0x03	=0x2		[PC10]
>7	byte&0x03	=0x1		[VS]
>>7	byte&0x0C	=0x8
# NES 2.0: VS PPU
>>>13	byte&0x0F	=0x0		\b, RP2C03B
>>>13	byte&0x0F	=0x1		\b, RP2C03G
>>>13	byte&0x0F	=0x2		\b, RP2C04-0001
>>>13	byte&0x0F	=0x3		\b, RP2C04-0002
>>>13	byte&0x0F	=0x4		\b, RP2C04-0003
>>>13	byte&0x0F	=0x5		\b, RP2C04-0004
>>>13	byte&0x0F	=0x6		\b, RP2C03B
>>>13	byte&0x0F	=0x7		\b, RP2C03C
>>>13	byte&0x0F	=0x8		\b, RP2C05-01
>>>13	byte&0x0F	=0x9		\b, RP2C05-02
>>>13	byte&0x0F	=0xA		\b, RP2C05-03
>>>13	byte&0x0F	=0xB		\b, RP2C05-04
>>>13	byte&0x0F	=0xC		\b, RP2C05-05
# TODO: VS protection hardware?
>>7	byte		x		\b]
# NES 2.0-specific flags.
>7	byte&0x0C	=0x8
>>12	byte&0x03	=0x0		[NTSC]
>>12	byte&0x03	=0x1		[PAL]
>>12	byte&0x02	=0x2		[NTSC+PAL]

# Standard iNES ROM header.
0	string		NES\x1A		NES ROM image (iNES)
>0	use		nes-rom-image-ines

# Wii U Virtual Console iNES ROM header.
0	belong		0x4E455300	NES ROM image (Wii U Virtual Console)
>0	use		nes-rom-image-ines
a50 101
#------------------------------------------------------------------------------
# unif: file(1) magic for UNIF-format Nintendo Entertainment System ROM images
# Reference: http://wiki.nesdev.com/w/index.php/UNIF
# From: David Korth <gerbilsoft@@gerbilsoft.com>
#
# NOTE: The UNIF format uses chunks instead of a fixed header,
# so most of the data isn't easily parseable.
#
0	string	UNIF
>4	lelong	<16	NES ROM image (UNIF v%d format)

#------------------------------------------------------------------------------
# fds: file(1) magic for Famciom Disk System disk images
# Reference: http://wiki.nesdev.com/w/index.php/Family_Computer_Disk_System#.FDS_format
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# TODO: Check "Disk info block" and get info from that in addition to the optional header.

# Disk info block. (block 1)
0	name	nintendo-fds-disk-info-block
>23	byte	!1		FMC-
>23	byte	1		FSC-
>16	string	x		\b%.3s
>15	byte	x		\b, mfr %02X
>20	byte	x		(Rev.%02u)

# Headered version.
0	string	FDS\x1A
>0x11	string	*NINTENDO-HVC*	Famicom Disk System disk image:
>>0x10	use	nintendo-fds-disk-info-block
>4	byte	1	(%u side)
>4	byte	!1	(%u sides)

# Unheadered version.
1	string	*NINTENDO-HVC*	Famicom Disk System disk image:
>0	use	nintendo-fds-disk-info-block

#------------------------------------------------------------------------------
# tnes: file(1) magic for TNES-format Nintendo Entertainment System ROM images
# Used by Nintendo 3DS NES Virtual Console games.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
#
0		string	TNES	NES ROM image (Nintendo 3DS Virtual Console)
>4		byte	100	\b: FDS,
>>0x2010	use	nintendo-fds-disk-info-block
>4		byte	!100	\b: TNES mapper %u
>>5	byte		x		\b, %ux8k PRG
>>6	byte		x		\b, %ux8k CHR
>>7	byte&0x08	=1		[WRAM]
>>8	byte&0x09	=1		[H-mirror]
>>8	byte&0x09	=2		[V-mirror]
>>8	byte&0x02	=3		[VRAM]

#------------------------------------------------------------------------------
# gameboy: file(1) magic for the Nintendo (Color) Gameboy raw ROM format
# Reference: http://gbdev.gg8.se/wiki/articles/The_Cartridge_Header
#
0x104		bequad		0xCEED6666CC0D000B	Game Boy ROM image
>0x143		byte&0x80	0x80
>>0x134		string		>\0			\b: "%.15s"
>0x143		byte&0x80	!0x80
>>0x134		string		>\0			\b: "%.16s"
>0x14c		byte		x			(Rev.%02u)

# Machine type. (SGB, CGB, SGB+CGB)
>0x14b		byte		0x33
>>0x146		byte		0x03
>>>0x143	byte&0x80	0x80	[SGB+CGB]
>>>0x143	byte&0x80	!0x80	[SGB]
>>0x146		byte		!0x03
>>>0x143	byte&0xC0	0x80	[CGB]
>>>0x143	byte&0xC0	0xC0	[CGB ONLY]

# Mapper.
>0x147 byte 0x00  [ROM ONLY]
>0x147 byte 0x01  [MBC1]
>0x147 byte 0x02  [MBC1+RAM]
>0x147 byte 0x03  [MBC1+RAM+BATT]
>0x147 byte 0x05  [MBC2]
>0x147 byte 0x06  [MBC2+BATTERY]
>0x147 byte 0x08  [ROM+RAM]
>0x147 byte 0x09  [ROM+RAM+BATTERY]
>0x147 byte 0x0B  [MMM01]
>0x147 byte 0x0C  [MMM01+SRAM]
>0x147 byte 0x0D  [MMM01+SRAM+BATT]
>0x147 byte 0x0F  [MBC3+TIMER+BATT]
>0x147 byte 0x10  [MBC3+TIMER+RAM+BATT]
>0x147 byte 0x11  [MBC3]
>0x147 byte 0x12  [MBC3+RAM]
>0x147 byte 0x13  [MBC3+RAM+BATT]
>0x147 byte 0x19  [MBC5]
>0x147 byte 0x1A  [MBC5+RAM]
>0x147 byte 0x1B  [MBC5+RAM+BATT]
>0x147 byte 0x1C  [MBC5+RUMBLE]
>0x147 byte 0x1D  [MBC5+RUMBLE+SRAM]
>0x147 byte 0x1E  [MBC5+RUMBLE+SRAM+BATT]
>0x147 byte 0xFC  [Pocket Camera]
>0x147 byte 0xFD  [Bandai TAMA5]
>0x147 byte 0xFE  [Hudson HuC-3]
>0x147 byte 0xFF  [Hudson HuC-1]

# ROM size.
a57 1
>0x148 byte 7     \b, ROM: 32Mbit
a61 1
# RAM size.
d66 2
a67 1
>0x149 byte 5     \b, RAM: 512Kbit
d70 1
a70 5
# genesis: file(1) magic for various Sega Mega Drive / Genesis ROM image and disc formats
# Updated by David Korth <gerbilsoft@@gerbilsoft.com>
# References:
# - http://www.retrodev.com/segacd.html
# - http://devster.monkeeh.com/sega/32xguide1.txt
d72 4
a75 43

# Common Sega Mega Drive header format.
# FIXME: Name fields are 48 bytes, but have spaces for padding instead of 00s.
0		name	sega-mega-drive-header
# ROM title. (Use domestic if present; if not, use international.)
>0x120		byte	>0x20
>>0x120		string	>\0	\b: "%.16s"
>0x120		byte	<0x21
>>0x150		string	>\0	\b: "%.16s"
# Other information.
>0x180		string	>\0	(%.14s
>>0x110		string  >\0	\b, %.16s
>0x180		byte	0
>>0x110		string  >\0	(%.16s
>0		byte	x	\b)

# TODO: Check for 32X CD?
# Sega Mega CD disc images: 2048-byte sectors.
0	string	SEGADISCSYSTEM\ \ 	Sega Mega CD disc image
>0	use	sega-mega-drive-header
>0	byte	x			\b, 2048-byte sectors
0	string	SEGABOOTDISC\ \ \ \ 	Sega Mega CD disc image
>0	use	sega-mega-drive-header
>0	byte	x			\b, 2048-byte sectors
# Sega Mega CD disc images: 2352-byte sectors.
0x10	string	SEGADISCSYSTEM\ \ 	Sega Mega CD disc image
>0x10	use	sega-mega-drive-header
>0	byte	x			\b, 2352-byte sectors
0x10	string	SEGABOOTDISC\ \ \ \ 	Sega Mega CD disc image
>0x10	use	sega-mega-drive-header
>0	byte	x			\b, 2352-byte sectors

# Sega Mega Drive, 32X, Pico, and Mega CD Boot ROM images.
0x100		string	SEGA
>0x3C0		bequad	0x4D41525320434845	Sega 32X ROM image
>>0		use	sega-mega-drive-header
>0x3C0		bequad	!0x4D41525320434845
>>0x105		belong	0x5049434F	Sega Pico ROM image
>>>0		use	sega-mega-drive-header
>>0x105		belong	!0x5049434F
>>>0x180	beshort	0x4252		Sega Mega CD Boot ROM image
>>>0x180	beshort	!0x4252		Sega Mega Drive / Genesis ROM image
>>>0		use	sega-mega-drive-header
d78 1
a78 1
# genesis: file(1) magic for the Super MegaDrive ROM dump format
d80 6
a85 17

# NOTE: Due to interleaving, we can't display anything
# other than the copier header information.
0      name    sega-genesis-smd-header
>0     byte    x       %dx16k blocks
>2     byte    0       \b, last in series or standalone
>2     byte    >0      \b, split ROM

# "Sega Genesis" header.
0x280	string EAGN
>8	beshort	0xAABB	Sega Mega Drive / Genesis ROM image (SMD format):
>>0	use     sega-genesis-smd-header

# "Sega Mega Drive" header.
0x280	string EAMG
>8	beshort	0xAABB	Sega Mega Drive / Genesis ROM image (SMD format):
>>0	use     sega-genesis-smd-header
d88 1
a88 5
# smsgg:  file(1) magic for Sega Master System and Game Gear ROM images
# Detects all Game Gear and export Sega Master System ROM images,
# and some Japanese Sega Master System ROM images.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: http://www.smspower.org/Development/ROMHeader
d90 5
a94 54

# General SMS header rule.
# The SMS boot ROM checks the header at three locations.
0	name	sega-master-system-rom-header
# Machine type.
>0x0F	byte&0xF0	0x30	Sega Master System
>0x0F	byte&0xF0	0x40	Sega Master System
>0x0F	byte&0xF0	0x50	Sega Game Gear
>0x0F	byte&0xF0	0x60	Sega Game Gear
>0x0F	byte&0xF0	0x70	Sega Game Gear
>0x0F	byte&0xF0	<0x30	Sega Master System / Game Gear
>0x0F	byte&0xF0	>0x70	Sega Master System / Game Gear
>0	byte		x	ROM image:
# Product code.
>0x0E	byte&0xF0	0x10	1
>0x0E	byte&0xF0	0x20	2
>0x0E	byte&0xF0	0x30	3
>0x0E	byte&0xF0	0x40	4
>0x0E	byte&0xF0	0x50	5
>0x0E	byte&0xF0	0x60	6
>0x0E	byte&0xF0	0x70	7
>0x0E	byte&0xF0	0x80	8
>0x0E	byte&0xF0	0x90	9
>0x0E	byte&0xF0	0xA0	10
>0x0E	byte&0xF0	0xB0	11
>0x0E	byte&0xF0	0xC0	12
>0x0E	byte&0xF0	0xD0	13
>0x0E	byte&0xF0	0xE0	14
>0x0E	byte&0xF0	0xF0	15
# If the product code is 5 digits, we'll need to backspace here.
>0x0E	byte&0xF0	!0
>>0x0C	leshort		x	\b%04x
>0x0E	byte&0xF0	0
>>0x0C	leshort		x	%04x
# Revision.
>0x0E	byte&0x0F	x	(Rev.%02d)
# ROM size. (Used for the boot ROM checksum routine.)
>0x0F	byte&0x0F	0x0A	(8 KB)
>0x0F	byte&0x0F	0x0B	(16 KB)
>0x0F	byte&0x0F	0x0C	(32 KB)
>0x0F	byte&0x0F	0x0D	(48 KB)
>0x0F	byte&0x0F	0x0E	(64 KB)
>0x0F	byte&0x0F	0x0F	(128 KB)
>0x0F	byte&0x0F	0x00	(256 KB)
>0x0F	byte&0x0F	0x01	(512 KB)
>0x0F	byte&0x0F	0x02	(1 MB)

# SMS/GG header locations.
0x7FF0	string	TMR\ SEGA
>0x7FF0	use	sega-master-system-rom-header
0x3FF0	string	TMR\ SEGA
>0x3FF0	use	sega-master-system-rom-header
0x1FF0	string	TMR\ SEGA
>0x1FF0	use	sega-master-system-rom-header
d97 4
a100 2
# saturn: file(1) magic for the Sega Saturn disc image format.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
d102 1
a102 23

# Common Sega Saturn disc header format.
# NOTE: Title is 112 bytes, but we're only showing 32 due to space padding.
# TODO: Release date, device information, region code, others?
0	name	sega-saturn-disc-header
>0x60	string	>\0	\b: "%.32s"
>0x20	string	>\0	(%.10s
>>0x2A	string	>\0	\b, %.6s)
>>0x2A	byte	0	\b)

# 2048-byte sector version.
0	string	SEGA\ SEGASATURN\ 	Sega Saturn disc image
>0	use	sega-saturn-disc-header
>0	byte	x			(2048-byte sectors)
# 2352-byte sector version.
0x10	string	SEGA\ SEGASATURN\ 	Sega Saturn disc image
>0x10	use	sega-saturn-disc-header
>0	byte	x			(2352-byte sectors)

#------------------------------------------------------------------------------
# dreamcast: file(1) magic for the Sega Dreamcast disc image format.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: http://mc.pp.se/dc/ip0000.bin.html
d104 6
a109 18

# Common Sega Dreamcast disc header format.
# NOTE: Title is 128 bytes, but we're only showing 32 due to space padding.
# TODO: Release date, device information, region code, others?
0	name	sega-dreamcast-disc-header
>0x80	string	>\0	\b: "%.32s"
>0x40	string	>\0	(%.10s
>>0x4A	string	>\0	\b, %.6s)
>>0x4A	byte	0	\b)

# 2048-byte sector version.
0	string	SEGA\ SEGAKATANA\ 	Sega Dreamcast disc image
>0	use	sega-dreamcast-disc-header
>0	byte	x			(2048-byte sectors)
# 2352-byte sector version.
0x10	string	SEGA\ SEGAKATANA\ 	Sega Dreamcast disc image
>0x10	use	sega-dreamcast-disc-header
>0	byte	x			(2352-byte sectors)
d118 1
a118 3
# z64: file(1) magic for the Z64 format N64 ROM dumps
# Reference: http://forum.pj64-emu.com/showthread.php?t=2239
# From: David Korth <gerbilsoft@@gerbilsoft.com>
d120 1
a120 4
0	bequad	0x803712400000000F	Nintendo 64 ROM image
>0x20	string	>\0	\b: "%.20s"
>0x3B	string	x	(%.4s
>0x3F	byte	x	\b, Rev.%02u)
d122 5
a126 62
#------------------------------------------------------------------------------
# v64: file(1) magic for the V64 format N64 ROM dumps
# Same as z64 format, but with 16-bit byteswapping.
#
0	bequad	0x3780401200000F00	Nintendo 64 ROM image (V64)

#------------------------------------------------------------------------------
# n64-swap2: file(1) magic for the swap2 format N64 ROM dumps
# Same as z64 format, but with swapped 16-bit words.
#
0	bequad	0x12408037000F0000	Nintendo 64 ROM image (wordswapped)

#------------------------------------------------------------------------------
# n64-le32: file(1) magic for the 32-bit byteswapped format N64 ROM dumps
# Same as z64 format, but with 32-bit byteswapping.
#
0	bequad	0x401237800F000000	Nintendo 64 ROM image (32-bit byteswapped)

#------------------------------------------------------------------------------
# gba: file(1) magic for the Nintendo Game Boy Advance raw ROM format
# Reference: http://problemkaputt.de/gbatek.htm#gbacartridgeheader
#
# Original version from: "Nelson A. de Oliveira" <naoliv@@gmail.com>
# Updated version from: David Korth <gerbilsoft@@gerbilsoft.com>
#
4	bequad	0x24FFAE51699AA221	Game Boy Advance ROM image
>0xA0	string	>\0	\b: "%.12s"
>0xAC	string	x	(%.6s
>0xBC	byte	x	\b, Rev.%02u)

#------------------------------------------------------------------------------
# nds: file(1) magic for the Nintendo DS(i) raw ROM format
# Reference: http://problemkaputt.de/gbatek.htm#dscartridgeheader
#
# Original version from: "Nelson A. de Oliveira" <naoliv@@gmail.com>
# Updated version from: David Korth <gerbilsoft@@gerbilsoft.com>
#
0xC0	bequad	0x24FFAE51699AA221	Nintendo DS ROM image
>0x00	string	>\0		\b: "%.12s"
>0x0C	string	x		(%.6s
>0x1E	byte	x		\b, Rev.%02u)
>0x12	byte	2		(DSi enhanced)
>0x12	byte	3		(DSi only)

#------------------------------------------------------------------------------
# nds_passme: file(1) magic for Nintendo DS ROM images for GBA cartridge boot.
# This is also used for loading .nds files using the MSET exploit on 3DS.
# Reference: https://github.com/devkitPro/ndstool/blob/master/source/ndscreate.cpp
0xC0	bequad	0xC8604FE201708FE2	Nintendo DS Slot-2 ROM image (PassMe)

#------------------------------------------------------------------------------
# ngp: file(1) magic for the Neo Geo Pocket (Color) raw ROM format.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# References:
# - https://neogpc.googlecode.com/svn-history/r10/trunk/src/core/neogpc.cpp
# - http://www.devrs.com/ngp/files/ngpctech.txt
#
0x0A	string	BY\ SNK\ CORPORATION	Neo Geo Pocket
>0x23	byte	0x10			Color
>0	byte	x			ROM image
>0x24	string	>\0			\b: "%.12s"
>0x1F	byte	0xFF			(debug mode enabled)
a135 12
>16	lelong	x		PC=0x%08x,
>20	lelong	!0		GP=0x%08x,
>24	lelong	!0		.text=[0x%08x,
>>28	lelong	x		\b0x%x],
>32	lelong	!0		.data=[0x%08x,
>>36	lelong	x		\b0x%x],
>40	lelong	!0		.bss=[0x%08x,
>>44	lelong	x		\b0x%x],
>48	lelong	!0		Stack=0x%08x,
>48	lelong	=0		No Stack!,
>52	lelong	!0		StackSize=0x%x,
#>76	string	>\0		(%s)
a138 4
# CPE executables
0	string	CPE		CPE executable
>3	byte	x		(version %d)

d180 1
a180 6
# From: Gurkan Sengun <gurkan@@linuks.mine.nu>, www.linuks.mine.nu
# From: David Pflug <david@@pflug.email>
# is the offset 12 or the offset 16 correct?
# GBS (Game Boy Sound) magic
# ftp://ftp.modland.com/pub/documents/format_documentation/\
# Gameboy%20Sound%20System%20(.gbs).txt 
d182 1
a182 10
#12	string		GameBoy\ Music\ Module	Nintendo Gameboy Music Module
>16	string		>\0	("%s" by
>48	string		>\0	%s, copyright
>80	string		>\0	%s),
>3	byte		x	version %d,
>4	byte		x	%d tracks

# IPS Patch Files from: From: Thomas Klausner <tk@@giga.or.at>
# see http://zerosoft.zophar.net/ips.php
0	string	PATCH			IPS patch file
a264 238

#------------------------------------------------------------------------------
# Nintendo GameCube / Wii file formats.
#

# Type: Nintendo GameCube/Wii common disc header data.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: http://wiibrew.org/wiki/Wii_Disc
0	name	nintendo-gcn-disc-common
>0x20	string	x	"%.64s"
>0x00	string	x	(%.6s
>0x06	byte	>0
>>0x06	byte	1	\b, Disc 2
>>0x06	byte	2	\b, Disc 3
>>0x06	byte	3	\b, Disc 4
>0x07	byte	x	\b, Rev.%02u)

# Type: Nintendo GameCube disc image
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: http://wiibrew.org/wiki/Wii_Disc
0x1C	belong	0xC2339F3D	Nintendo GameCube disc image:
>0	use	nintendo-gcn-disc-common

# Type: Nintendo GameCube embedded disc image
# Commonly found on demo discs.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: http://hitmen.c02.at/files/yagcd/yagcd/index.html#idx14.8
0		belong	0xAE0F38A2
>0x0C		belong	0x00100000
>>(8.L+0x1C)	belong	0xC2339F3D	Nintendo GameCube embedded disc image:
>>>(8.L)	use	nintendo-gcn-disc-common

# Type: Nintendo Wii disc image
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: http://wiibrew.org/wiki/Wii_Disc
0x18	belong	0x5D1C9EA3	Nintendo Wii disc image:
>0	use	nintendo-gcn-disc-common

# Type: Nintendo Wii disc image (WBFS format)
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: http://wiibrew.org/wiki/Wii_Disc
0	string	WBFS
>0x218	belong	0x5D1C9EA3	Nintendo Wii disc image (WBFS format):
>>0x200	use	nintendo-gcn-disc-common

# Type: Nintendo GameCube/Wii disc image (CISO format)
# NOTE: This is NOT the same as Compact ISO or PSP CISO,
# though it has the same magic number.
0		string	CISO
# Other fields are used to determine what type of CISO this is:
# - 0x04 == 0x00200000: GameCube/Wii CISO (block_size)
# - 0x10 == 0x00000800: PSP CISO (ISO-9660 sector size)
# - None of the above: Compact ISO.
>4		lelong	0x200000
>>8		byte	1
>>>0x801C	belong	0xC2339F3D	Nintendo GameCube disc image (CISO format):
>>>>0x8000	use	nintendo-gcn-disc-common
>>>0x8018	belong	0x5D1C9EA3	Nintendo Wii disc image (CISO format):
>>>>0x8000	use	nintendo-gcn-disc-common

# Type: Nintendo GameCube/Wii disc image (GCZ format)
# Due to zlib compression, we can't get the actual disc information.
0	lelong	0xB10BC001
>4	lelong	0		Nintendo GameCube disc image (GCZ format)
>4	lelong	1		Nintendo Wii disc image (GCZ format)
>4	lelong	>1		Nintendo GameCube/Wii disc image (GCZ format)

# Type: Nintendo GameCube/Wii disc image (WDF format)
0		string	WII\001DISC
>8		belong	1
# WDFv1
>>0x54		belong	0xC2339F3D	Nintendo GameCube disc image (WDFv1 format):
>>>0x38		use	nintendo-gcn-disc-common
>>0x58		belong	0x5D1C9EA3	Nintendo Wii disc image (WDFv1 format):
>>>0x38		use	nintendo-gcn-disc-common
>8		belong	2
# WDFv2
>>(12.L+0x1C)	belong	0xC2339F3D	Nintendo GameCube disc image (WDFv2 format):
>>>(12.L)	use	nintendo-gcn-disc-common
>>(12.L+0x18)	belong	0x5D1C9EA3	Nintendo Wii disc image (WDFv2 format):
>>>(12.L)	use	nintendo-gcn-disc-common

# Type: Nintendo GameCube/Wii disc image (WIA format)
0	string	WIA\001	Nintendo
>0x48	belong	0	GameCube/Wii
>0x48	belong	1	GameCube
>0x48	belong	2	Wii
>0x48	belong	>2	GameCube/Wii
>0x48	belong	x	disc image (WIA format):
>>0x58	use	nintendo-gcn-disc-common

#------------------------------------------------------------------------------
# Nintendo 3DS file formats.
#

# Type: Nintendo 3DS "NCSD" image. (game cards and eMMC)
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: https://www.3dbrew.org/wiki/NCSD
0x100		string		NCSD
>0x118		lequad		0		Nintendo 3DS Game Card image
# NCCH header for partition 0. (game data)
>>0x1150	string		>\0	\b: "%.16s"
>>0x312		byte		x	(Rev.%02u)
>>0x118C	byte		2	(New3DS only)
>>0x18D		byte		0		(inner device)
>>0x18D		byte		1		(Card1)
>>0x18D		byte		2		(Card2)
>>0x18D		byte		3		(extended device)
>0x118		bequad		0x0102020202000000	Nintendo 3DS eMMC dump (Old3DS)
>0x118		bequad		0x0102020203000000	Nintendo 3DS eMMC dump (New3DS)

# Nintendo 3DS version code.
# Reference: https://www.3dbrew.org/wiki/Titles
# Format: leshort containing three fields:
# - 6-bit: Major
# - 6-bit: Minor
# - 4-bit: Revision
# NOTE: Only supporting major/minor versions from 0-15 right now.
# NOTE: Should be prefixed with "v".
0	name	nintendo-3ds-version-code
# Raw version.
>0	leshort	x	\b%u,
# Major version.
>0	leshort&0xFC00	0x0000	0
>0	leshort&0xFC00	0x0400	1
>0	leshort&0xFC00	0x0800	2
>0	leshort&0xFC00	0x0C00	3
>0	leshort&0xFC00	0x1000	4
>0	leshort&0xFC00	0x1400	5
>0	leshort&0xFC00	0x1800	6
>0	leshort&0xFC00	0x1C00	7
>0	leshort&0xFC00	0x2000	8
>0	leshort&0xFC00	0x2400	9
>0	leshort&0xFC00	0x2800	10
>0	leshort&0xFC00	0x2C00	11
>0	leshort&0xFC00	0x3000	12
>0	leshort&0xFC00	0x3400	13
>0	leshort&0xFC00	0x3800	14
>0	leshort&0xFC00	0x3C00	15
# Minor version.
>0	leshort&0x03F0	0x0000	\b.0
>0	leshort&0x03F0	0x0010	\b.1
>0	leshort&0x03F0	0x0020	\b.2
>0	leshort&0x03F0	0x0030	\b.3
>0	leshort&0x03F0	0x0040	\b.4
>0	leshort&0x03F0	0x0050	\b.5
>0	leshort&0x03F0	0x0060	\b.6
>0	leshort&0x03F0	0x0070	\b.7
>0	leshort&0x03F0	0x0080	\b.8
>0	leshort&0x03F0	0x0090	\b.9
>0	leshort&0x03F0	0x00A0	\b.10
>0	leshort&0x03F0	0x00B0	\b.11
>0	leshort&0x03F0	0x00C0	\b.12
>0	leshort&0x03F0	0x00D0	\b.13
>0	leshort&0x03F0	0x00E0	\b.14
>0	leshort&0x03F0	0x00F0	\b.15
# Revision.
>0	leshort&0x000F	x	\b.%u

# Type: Nintendo 3DS "NCCH" container.
# https://www.3dbrew.org/wiki/NCCH
0x100		string	NCCH	Nintendo 3DS
>0x18D		byte&2	0	File Archive (CFA)
>0x18D		byte&2	2	Executable Image (CXI)
>0x150		string	>\0	\b: "%.16s"
>0x18D		byte	0x05
>>0x10E		leshort	x	(Old3DS System Update v
>>0x10E		use	nintendo-3ds-version-code
>>0x10E		leshort	x	\b)
>0x18D		byte	0x15
>>0x10E		leshort	x	(New3DS System Update v
>>0x10E		use	nintendo-3ds-version-code
>>0x10E		leshort	x	\b)
>0x18D		byte	!0x05
>>0x18D		byte	!0x15
>>>0x112	byte	x	(v
>>>0x112	use	nintendo-3ds-version-code
>>>0x112	byte	x	\b)
>0x18C		byte	2	(New3DS only)

# Type: Nintendo 3DS "SMDH" file. (application description)
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: https://3dbrew.org/wiki/SMDH
0		string		SMDH		Nintendo 3DS SMDH file
>0x208		leshort		!0
>>0x208		lestring16	x		\b: "%.128s"
>>0x388		leshort		!0
>>>0x388	lestring16	x		by %.128s
>0x208		leshort		0
>>0x008		leshort		!0
>>>0x008	lestring16	x		\b: "%.128s"
>>>0x188	leshort		!0
>>>>0x188	lestring16	x		by %.128s

# Type: Nintendo 3DS Homebrew Application.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Refernece: https://3dbrew.org/wiki/3DSX_Format
0	string	3DSX	Nintendo 3DS Homebrew Application (3DSX)

#------------------------------------------------------------------------------
# a7800: file(1) magic for the Atari 7800 raw ROM format.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: https://sites.google.com/site/atari7800wiki/a78-header

0	byte	>0
>0	byte	<3
>>1	string	ATARI7800	Atari 7800 ROM image
>>>0x11	string	>\0	\b: "%.32s"
# Display type.
>>>0x39	byte	0	(NTSC)
>>>0x39	byte	1	(PAL)
>>>0x36	byte&1	1	(POKEY)

#------------------------------------------------------------------------------
# vectrex: file(1) magic for the GCE Vectrex raw ROM format.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: http://www.playvectrex.com/designit/chrissalo/hello1.htm
#
# NOTE: Title is terminated with 0x80, not 0.
# The header is terminated with a 0, so that will
# terminate the title as well.
#
0	string	g\ GCE	Vectrex ROM image
>0x11	string	>\0	\b: "%.16s"

#------------------------------------------------------------------------------
# amiibo: file(1) magic for Nintendo amiibo NFC dumps.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: https://www.3dbrew.org/wiki/Amiibo
0x00		byte	0x04
>0x0A		beshort	0x0FE0
>>0x0C		belong	0xF110FFEE
>>>0x208	beshort	0x0100
>>>>0x020A	byte	0x0F
>>>>>0x020C	bequad	0x000000045F000000
>>>>>>0x5B	byte	0x02
>>>>>>>0x54	belong	x	Nintendo amiibo NFC dump - amiibo ID: %08X-
>>>>>>>0x58	belong	x	\b%08X
@


1.1.1.4
log
@2017-02-10  12:24  Christos Zoulas <christos@@zoulas.com>

	* release 5.30

2017-02-07  23:27  Christos Zoulas <christos@@zoulas.com>

	* If we exceeded the offset in a search return no match
	  (Christoph Biedl)
	* Be more lenient on corrupt CDF files (Christoph Biedl)

2017-02-04  16:46  Christos Zoulas <christos@@zoulas.com>

	* pacify ubsan sign extension (oss-fuzz/524)

2017-02-01  12:42  Christos Zoulas <christos@@zoulas.com>

	* off by one in cdf parsing (PR/593)
	* report debugging sections in elf (PR/591)

2016-11-06  10:52  Christos Zoulas <christos@@zoulas.com>

	* Allow @@@@@@ in extensions
	* Add missing overflow check in der magic (Jonas Wagner)

2016-10-25  10:40  Christos Zoulas <christos@@zoulas.com>

	* release 5.29

2016-10-24  11:20  Christos Zoulas <christos@@zoulas.com>

	* der getlength overflow (Jonas Wagner)
	* multiple magic file load failure (Christoph Biedl)

2016-10-17  11:26  Christos Zoulas <christos@@zoulas.com>

	* CDF parsing improvements (Guy Helmer)

2016-07-20   7:26  Christos Zoulas <christos@@zoulas.com>

	* Add support for signed indirect offsets

2016-07-18   7:41  Christos Zoulas <christos@@zoulas.com>

	* cat /dev/null | file - should print empty (Christoph Biedl)

2016-07-05  15:20  Christos Zoulas <christos@@zoulas.com>

	* Bump string size from 64 to 96.

2016-06-13  20:20  Christos Zoulas <christos@@zoulas.com>

	* PR/556: Fix separators on annotations.

2016-06-13  19:40  Christos Zoulas <christos@@zoulas.com>

	* release 5.28
	* fix leak on allocation failure

2016-06-01   1:20  Christos Zoulas <christos@@zoulas.com>

	* PR/555: Avoid overflow for offset > nbytes
	* PR/550: Segv on DER parsing:
	    - use the correct variable for length
	    - set offset to 0 on failure.

2016-05-13  12:00  Christos Zoulas <christos@@zoulas.com>

	* release 5.27

2016-04-18   9:35  Christos Zoulas <christos@@zoulas.com>

	* Errors comparing DER entries or computing offsets
	  are just indications of malformed non-DER files.
	  Don't print them.
	* Offset comparison was off-by-one.
	* Fix compression code (Werner Fink)
	* Put new bytes constant in the right file (not the generated one)

2016-04-16  18:34  Christos Zoulas <christos@@zoulas.com>

	* release 5.26

2016-03-31  13:50  Christos Zoulas <christos@@zoulas.com>

	* make the number of bytes read from files configurable.

2016-03-21  13:40  Christos Zoulas <christos@@zoulas.com>

	* Add bounds checks for DER code (discovered by Thomas Jarosch)
	* Change indirect recursion limit to indirect use count and
	  bump from 15 to 50 to prevent abuse.

2016-03-13  20:39  Christos Zoulas <christos@@zoulas.com>

	* Add -00 which prints filename\0description\0

2016-03-01  13:28  Christos Zoulas <christos@@zoulas.com>

	* Fix ID3 indirect parsing

2016-01-19  10:18  Christos Zoulas <christos@@zoulas.com>

	* add DER parsing capability

2015-11-13  10:35  Christos Zoulas <christos@@zoulas.com>

	* provide dprintf(3) for the OS's that don't have it.

2015-11-11  16:25  Christos Zoulas <christos@@zoulas.com>

	* redo the compression code report decompression errors

2015-11-10  23:25  Christos Zoulas <christos@@zoulas.com>

	* REG_STARTEND code is not working as expected, delete it.

2015-11-09  16:05  Christos Zoulas <christos@@zoulas.com>

	* Add zlib support if we have it.

2015-11-05  11:22  Christos Zoulas <christos@@zoulas.com>

	* PR/492: compression forking was broken with magic_buffer.

2015-09-16   9:50  Christos Zoulas <christos@@zoulas.com>

	* release 5.25

2015-09-11  13:25  Christos Zoulas <christos@@zoulas.com>

	* add a limit to the length of regex searches

2015-09-08   9:50  Christos Zoulas <christos@@zoulas.com>

	* fix problems with --parameter (Christoph Biedl)

2015-07-11  10:35  Christos Zoulas <christos@@zoulas.com>

	* Windows fixes PR/466 (Jason Hood)

2015-07-09  10:35  Christos Zoulas <christos@@zoulas.com>

	* release 5.24

2015-06-11   8:52  Christos Zoulas <christos@@zoulas.com>

	* redo long option encoding to fix off-by-one in 5.23

2015-06-10  13:50  Christos Zoulas <christos@@zoulas.com>

	* release 5.23

2015-06-09  16:10  Christos Zoulas <christos@@zoulas.com>

	* Fix issue with regex range for magic with offset
	* Always return true from mget with USE (success to mget not match
	  indication). Fixes mime evaluation after USE magic
	* PR/459: Don't insert magic entries to the list if there are parsing
	  errors for them.

2015-06-03  16:00  Christos Zoulas <christos@@zoulas.com>

	* PR/455: Add utf-7 encoding

2015-06-03  14:30  Christos Zoulas <christos@@zoulas.com>

	* PR/455: Implement -Z, look inside, but don't report on compression
	* PR/454: Fix allocation error on bad magic.

2015-05-29  10:30  Christos Zoulas <christos@@zoulas.com>

	* handle MAGIC_CONTINUE everywhere, not just in softmagic

2015-05-21  14:30  Christos Zoulas <christos@@zoulas.com>

	* don't print descriptions for NAME types when mime.

2015-04-09  15:59  Christos Zoulas <christos@@zoulas.com>

	* Add --extension to list the known extensions for this file type
	  Idea by Andrew J Roazen

2015-02-14  12:23  Christos Zoulas <christos@@zoulas.com>

	* Bump file search buffer size to 1M.

2015-01-09  14:35  Christos Zoulas <christos@@zoulas.com>

	* Fix multiple issues with date formats reported by Christoph Biedl:
		- T_LOCAL meaning was reversed
		- Arithmetic did not work
	  Also stop adjusting daylight savings for gmt printing.

2015-01-05  13:00  Christos Zoulas <christos@@zoulas.com>

	* PR/411: Fix memory corruption from corrupt cdf file.
@
text
@d3 1
a3 1
# $File: console,v 1.29 2017/02/08 21:53:06 christos Exp $
d6 2
d9 41
a49 48
# ines: file(1) magic for Marat's iNES Nintendo Entertainment System ROM dump format
# Updated by David Korth <gerbilsoft@@gerbilsoft.com>
# References:
# - http://wiki.nesdev.com/w/index.php/INES
# - http://wiki.nesdev.com/w/index.php/NES_2.0

# Common header for iNES, NES 2.0, and Wii U iNES.
0	name		nes-rom-image-ines
>7	byte&0x0C	=0x8		(NES 2.0)
>4	byte		x		\b: %ux16k PRG
>5	byte		x		\b, %ux8k CHR
>6	byte&0x08	=0x8		[4-Scr]
>6	byte&0x09	=0x0		[H-mirror]
>6	byte&0x09	=0x1		[V-mirror]
>6	byte&0x02	=0x2		[SRAM]
>6	byte&0x04	=0x4		[Trainer]
>7	byte&0x03	=0x2		[PC10]
>7	byte&0x03	=0x1		[VS]
>>7	byte&0x0C	=0x8
# NES 2.0: VS PPU
>>>13	byte&0x0F	=0x0		\b, RP2C03B
>>>13	byte&0x0F	=0x1		\b, RP2C03G
>>>13	byte&0x0F	=0x2		\b, RP2C04-0001
>>>13	byte&0x0F	=0x3		\b, RP2C04-0002
>>>13	byte&0x0F	=0x4		\b, RP2C04-0003
>>>13	byte&0x0F	=0x5		\b, RP2C04-0004
>>>13	byte&0x0F	=0x6		\b, RP2C03B
>>>13	byte&0x0F	=0x7		\b, RP2C03C
>>>13	byte&0x0F	=0x8		\b, RP2C05-01
>>>13	byte&0x0F	=0x9		\b, RP2C05-02
>>>13	byte&0x0F	=0xA		\b, RP2C05-03
>>>13	byte&0x0F	=0xB		\b, RP2C05-04
>>>13	byte&0x0F	=0xC		\b, RP2C05-05
# TODO: VS protection hardware?
>>7	byte		x		\b]
# NES 2.0-specific flags.
>7	byte&0x0C	=0x8
>>12	byte&0x03	=0x0		[NTSC]
>>12	byte&0x03	=0x1		[PAL]
>>12	byte&0x02	=0x2		[NTSC+PAL]

# Standard iNES ROM header.
0	string		NES\x1A		NES ROM image (iNES)
>0	use		nes-rom-image-ines

# Wii U Virtual Console iNES ROM header.
0	belong		0x4E455300	NES ROM image (Wii U Virtual Console)
>0	use		nes-rom-image-ines
a50 101
#------------------------------------------------------------------------------
# unif: file(1) magic for UNIF-format Nintendo Entertainment System ROM images
# Reference: http://wiki.nesdev.com/w/index.php/UNIF
# From: David Korth <gerbilsoft@@gerbilsoft.com>
#
# NOTE: The UNIF format uses chunks instead of a fixed header,
# so most of the data isn't easily parseable.
#
0	string	UNIF
>4	lelong	<16	NES ROM image (UNIF v%d format)

#------------------------------------------------------------------------------
# fds: file(1) magic for Famciom Disk System disk images
# Reference: http://wiki.nesdev.com/w/index.php/Family_Computer_Disk_System#.FDS_format
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# TODO: Check "Disk info block" and get info from that in addition to the optional header.

# Disk info block. (block 1)
0	name	nintendo-fds-disk-info-block
>23	byte	!1		FMC-
>23	byte	1		FSC-
>16	string	x		\b%.3s
>15	byte	x		\b, mfr %02X
>20	byte	x		(Rev.%02u)

# Headered version.
0	string	FDS\x1A
>0x11	string	*NINTENDO-HVC*	Famicom Disk System disk image:
>>0x10	use	nintendo-fds-disk-info-block
>4	byte	1	(%u side)
>4	byte	!1	(%u sides)

# Unheadered version.
1	string	*NINTENDO-HVC*	Famicom Disk System disk image:
>0	use	nintendo-fds-disk-info-block

#------------------------------------------------------------------------------
# tnes: file(1) magic for TNES-format Nintendo Entertainment System ROM images
# Used by Nintendo 3DS NES Virtual Console games.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
#
0		string	TNES	NES ROM image (Nintendo 3DS Virtual Console)
>4		byte	100	\b: FDS,
>>0x2010	use	nintendo-fds-disk-info-block
>4		byte	!100	\b: TNES mapper %u
>>5	byte		x		\b, %ux8k PRG
>>6	byte		x		\b, %ux8k CHR
>>7	byte&0x08	=1		[WRAM]
>>8	byte&0x09	=1		[H-mirror]
>>8	byte&0x09	=2		[V-mirror]
>>8	byte&0x02	=3		[VRAM]

#------------------------------------------------------------------------------
# gameboy: file(1) magic for the Nintendo (Color) Gameboy raw ROM format
# Reference: http://gbdev.gg8.se/wiki/articles/The_Cartridge_Header
#
0x104		bequad		0xCEED6666CC0D000B	Game Boy ROM image
>0x143		byte&0x80	0x80
>>0x134		string		>\0			\b: "%.15s"
>0x143		byte&0x80	!0x80
>>0x134		string		>\0			\b: "%.16s"
>0x14c		byte		x			(Rev.%02u)

# Machine type. (SGB, CGB, SGB+CGB)
>0x14b		byte		0x33
>>0x146		byte		0x03
>>>0x143	byte&0x80	0x80	[SGB+CGB]
>>>0x143	byte&0x80	!0x80	[SGB]
>>0x146		byte		!0x03
>>>0x143	byte&0xC0	0x80	[CGB]
>>>0x143	byte&0xC0	0xC0	[CGB ONLY]

# Mapper.
>0x147 byte 0x00  [ROM ONLY]
>0x147 byte 0x01  [MBC1]
>0x147 byte 0x02  [MBC1+RAM]
>0x147 byte 0x03  [MBC1+RAM+BATT]
>0x147 byte 0x05  [MBC2]
>0x147 byte 0x06  [MBC2+BATTERY]
>0x147 byte 0x08  [ROM+RAM]
>0x147 byte 0x09  [ROM+RAM+BATTERY]
>0x147 byte 0x0B  [MMM01]
>0x147 byte 0x0C  [MMM01+SRAM]
>0x147 byte 0x0D  [MMM01+SRAM+BATT]
>0x147 byte 0x0F  [MBC3+TIMER+BATT]
>0x147 byte 0x10  [MBC3+TIMER+RAM+BATT]
>0x147 byte 0x11  [MBC3]
>0x147 byte 0x12  [MBC3+RAM]
>0x147 byte 0x13  [MBC3+RAM+BATT]
>0x147 byte 0x19  [MBC5]
>0x147 byte 0x1A  [MBC5+RAM]
>0x147 byte 0x1B  [MBC5+RAM+BATT]
>0x147 byte 0x1C  [MBC5+RUMBLE]
>0x147 byte 0x1D  [MBC5+RUMBLE+SRAM]
>0x147 byte 0x1E  [MBC5+RUMBLE+SRAM+BATT]
>0x147 byte 0xFC  [Pocket Camera]
>0x147 byte 0xFD  [Bandai TAMA5]
>0x147 byte 0xFE  [Hudson HuC-3]
>0x147 byte 0xFF  [Hudson HuC-1]

# ROM size.
a57 1
>0x148 byte 7     \b, ROM: 32Mbit
a61 1
# RAM size.
d66 2
a67 1
>0x149 byte 5     \b, RAM: 512Kbit
d70 1
a70 5
# genesis: file(1) magic for various Sega Mega Drive / Genesis ROM image and disc formats
# Updated by David Korth <gerbilsoft@@gerbilsoft.com>
# References:
# - http://www.retrodev.com/segacd.html
# - http://devster.monkeeh.com/sega/32xguide1.txt
d72 4
a75 43

# Common Sega Mega Drive header format.
# FIXME: Name fields are 48 bytes, but have spaces for padding instead of 00s.
0		name	sega-mega-drive-header
# ROM title. (Use domestic if present; if not, use international.)
>0x120		byte	>0x20
>>0x120		string	>\0	\b: "%.16s"
>0x120		byte	<0x21
>>0x150		string	>\0	\b: "%.16s"
# Other information.
>0x180		string	>\0	(%.14s
>>0x110		string  >\0	\b, %.16s
>0x180		byte	0
>>0x110		string  >\0	(%.16s
>0		byte	x	\b)

# TODO: Check for 32X CD?
# Sega Mega CD disc images: 2048-byte sectors.
0	string	SEGADISCSYSTEM\ \ 	Sega Mega CD disc image
>0	use	sega-mega-drive-header
>0	byte	x			\b, 2048-byte sectors
0	string	SEGABOOTDISC\ \ \ \ 	Sega Mega CD disc image
>0	use	sega-mega-drive-header
>0	byte	x			\b, 2048-byte sectors
# Sega Mega CD disc images: 2352-byte sectors.
0x10	string	SEGADISCSYSTEM\ \ 	Sega Mega CD disc image
>0x10	use	sega-mega-drive-header
>0	byte	x			\b, 2352-byte sectors
0x10	string	SEGABOOTDISC\ \ \ \ 	Sega Mega CD disc image
>0x10	use	sega-mega-drive-header
>0	byte	x			\b, 2352-byte sectors

# Sega Mega Drive, 32X, Pico, and Mega CD Boot ROM images.
0x100		string	SEGA
>0x3C0		bequad	0x4D41525320434845	Sega 32X ROM image
>>0		use	sega-mega-drive-header
>0x3C0		bequad	!0x4D41525320434845
>>0x105		belong	0x5049434F	Sega Pico ROM image
>>>0		use	sega-mega-drive-header
>>0x105		belong	!0x5049434F
>>>0x180	beshort	0x4252		Sega Mega CD Boot ROM image
>>>0x180	beshort	!0x4252		Sega Mega Drive / Genesis ROM image
>>>0		use	sega-mega-drive-header
d78 1
a78 1
# genesis: file(1) magic for the Super MegaDrive ROM dump format
d80 6
a85 17

# NOTE: Due to interleaving, we can't display anything
# other than the copier header information.
0      name    sega-genesis-smd-header
>0     byte    x       %dx16k blocks
>2     byte    0       \b, last in series or standalone
>2     byte    >0      \b, split ROM

# "Sega Genesis" header.
0x280	string EAGN
>8	beshort	0xAABB	Sega Mega Drive / Genesis ROM image (SMD format):
>>0	use     sega-genesis-smd-header

# "Sega Mega Drive" header.
0x280	string EAMG
>8	beshort	0xAABB	Sega Mega Drive / Genesis ROM image (SMD format):
>>0	use     sega-genesis-smd-header
d88 1
a88 5
# smsgg:  file(1) magic for Sega Master System and Game Gear ROM images
# Detects all Game Gear and export Sega Master System ROM images,
# and some Japanese Sega Master System ROM images.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: http://www.smspower.org/Development/ROMHeader
d90 5
a94 54

# General SMS header rule.
# The SMS boot ROM checks the header at three locations.
0	name	sega-master-system-rom-header
# Machine type.
>0x0F	byte&0xF0	0x30	Sega Master System
>0x0F	byte&0xF0	0x40	Sega Master System
>0x0F	byte&0xF0	0x50	Sega Game Gear
>0x0F	byte&0xF0	0x60	Sega Game Gear
>0x0F	byte&0xF0	0x70	Sega Game Gear
>0x0F	byte&0xF0	<0x30	Sega Master System / Game Gear
>0x0F	byte&0xF0	>0x70	Sega Master System / Game Gear
>0	byte		x	ROM image:
# Product code.
>0x0E	byte&0xF0	0x10	1
>0x0E	byte&0xF0	0x20	2
>0x0E	byte&0xF0	0x30	3
>0x0E	byte&0xF0	0x40	4
>0x0E	byte&0xF0	0x50	5
>0x0E	byte&0xF0	0x60	6
>0x0E	byte&0xF0	0x70	7
>0x0E	byte&0xF0	0x80	8
>0x0E	byte&0xF0	0x90	9
>0x0E	byte&0xF0	0xA0	10
>0x0E	byte&0xF0	0xB0	11
>0x0E	byte&0xF0	0xC0	12
>0x0E	byte&0xF0	0xD0	13
>0x0E	byte&0xF0	0xE0	14
>0x0E	byte&0xF0	0xF0	15
# If the product code is 5 digits, we'll need to backspace here.
>0x0E	byte&0xF0	!0
>>0x0C	leshort		x	\b%04x
>0x0E	byte&0xF0	0
>>0x0C	leshort		x	%04x
# Revision.
>0x0E	byte&0x0F	x	(Rev.%02d)
# ROM size. (Used for the boot ROM checksum routine.)
>0x0F	byte&0x0F	0x0A	(8 KB)
>0x0F	byte&0x0F	0x0B	(16 KB)
>0x0F	byte&0x0F	0x0C	(32 KB)
>0x0F	byte&0x0F	0x0D	(48 KB)
>0x0F	byte&0x0F	0x0E	(64 KB)
>0x0F	byte&0x0F	0x0F	(128 KB)
>0x0F	byte&0x0F	0x00	(256 KB)
>0x0F	byte&0x0F	0x01	(512 KB)
>0x0F	byte&0x0F	0x02	(1 MB)

# SMS/GG header locations.
0x7FF0	string	TMR\ SEGA
>0x7FF0	use	sega-master-system-rom-header
0x3FF0	string	TMR\ SEGA
>0x3FF0	use	sega-master-system-rom-header
0x1FF0	string	TMR\ SEGA
>0x1FF0	use	sega-master-system-rom-header
d97 4
a100 2
# saturn: file(1) magic for the Sega Saturn disc image format.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
d102 1
a102 23

# Common Sega Saturn disc header format.
# NOTE: Title is 112 bytes, but we're only showing 32 due to space padding.
# TODO: Release date, device information, region code, others?
0	name	sega-saturn-disc-header
>0x60	string	>\0	\b: "%.32s"
>0x20	string	>\0	(%.10s
>>0x2A	string	>\0	\b, %.6s)
>>0x2A	byte	0	\b)

# 2048-byte sector version.
0	string	SEGA\ SEGASATURN\ 	Sega Saturn disc image
>0	use	sega-saturn-disc-header
>0	byte	x			(2048-byte sectors)
# 2352-byte sector version.
0x10	string	SEGA\ SEGASATURN\ 	Sega Saturn disc image
>0x10	use	sega-saturn-disc-header
>0	byte	x			(2352-byte sectors)

#------------------------------------------------------------------------------
# dreamcast: file(1) magic for the Sega Dreamcast disc image format.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: http://mc.pp.se/dc/ip0000.bin.html
d104 6
a109 18

# Common Sega Dreamcast disc header format.
# NOTE: Title is 128 bytes, but we're only showing 32 due to space padding.
# TODO: Release date, device information, region code, others?
0	name	sega-dreamcast-disc-header
>0x80	string	>\0	\b: "%.32s"
>0x40	string	>\0	(%.10s
>>0x4A	string	>\0	\b, %.6s)
>>0x4A	byte	0	\b)

# 2048-byte sector version.
0	string	SEGA\ SEGAKATANA\ 	Sega Dreamcast disc image
>0	use	sega-dreamcast-disc-header
>0	byte	x			(2048-byte sectors)
# 2352-byte sector version.
0x10	string	SEGA\ SEGAKATANA\ 	Sega Dreamcast disc image
>0x10	use	sega-dreamcast-disc-header
>0	byte	x			(2352-byte sectors)
d118 1
a118 3
# z64: file(1) magic for the Z64 format N64 ROM dumps
# Reference: http://forum.pj64-emu.com/showthread.php?t=2239
# From: David Korth <gerbilsoft@@gerbilsoft.com>
d120 1
a120 4
0	bequad	0x803712400000000F	Nintendo 64 ROM image
>0x20	string	>\0	\b: "%.20s"
>0x3B	string	x	(%.4s
>0x3F	byte	x	\b, Rev.%02u)
d122 5
a126 62
#------------------------------------------------------------------------------
# v64: file(1) magic for the V64 format N64 ROM dumps
# Same as z64 format, but with 16-bit byteswapping.
#
0	bequad	0x3780401200000F00	Nintendo 64 ROM image (V64)

#------------------------------------------------------------------------------
# n64-swap2: file(1) magic for the swap2 format N64 ROM dumps
# Same as z64 format, but with swapped 16-bit words.
#
0	bequad	0x12408037000F0000	Nintendo 64 ROM image (wordswapped)

#------------------------------------------------------------------------------
# n64-le32: file(1) magic for the 32-bit byteswapped format N64 ROM dumps
# Same as z64 format, but with 32-bit byteswapping.
#
0	bequad	0x401237800F000000	Nintendo 64 ROM image (32-bit byteswapped)

#------------------------------------------------------------------------------
# gba: file(1) magic for the Nintendo Game Boy Advance raw ROM format
# Reference: http://problemkaputt.de/gbatek.htm#gbacartridgeheader
#
# Original version from: "Nelson A. de Oliveira" <naoliv@@gmail.com>
# Updated version from: David Korth <gerbilsoft@@gerbilsoft.com>
#
4	bequad	0x24FFAE51699AA221	Game Boy Advance ROM image
>0xA0	string	>\0	\b: "%.12s"
>0xAC	string	x	(%.6s
>0xBC	byte	x	\b, Rev.%02u)

#------------------------------------------------------------------------------
# nds: file(1) magic for the Nintendo DS(i) raw ROM format
# Reference: http://problemkaputt.de/gbatek.htm#dscartridgeheader
#
# Original version from: "Nelson A. de Oliveira" <naoliv@@gmail.com>
# Updated version from: David Korth <gerbilsoft@@gerbilsoft.com>
#
0xC0	bequad	0x24FFAE51699AA221	Nintendo DS ROM image
>0x00	string	>\0		\b: "%.12s"
>0x0C	string	x		(%.6s
>0x1E	byte	x		\b, Rev.%02u)
>0x12	byte	2		(DSi enhanced)
>0x12	byte	3		(DSi only)

#------------------------------------------------------------------------------
# nds_passme: file(1) magic for Nintendo DS ROM images for GBA cartridge boot.
# This is also used for loading .nds files using the MSET exploit on 3DS.
# Reference: https://github.com/devkitPro/ndstool/blob/master/source/ndscreate.cpp
0xC0	bequad	0xC8604FE201708FE2	Nintendo DS Slot-2 ROM image (PassMe)

#------------------------------------------------------------------------------
# ngp: file(1) magic for the Neo Geo Pocket (Color) raw ROM format.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# References:
# - https://neogpc.googlecode.com/svn-history/r10/trunk/src/core/neogpc.cpp
# - http://www.devrs.com/ngp/files/ngpctech.txt
#
0x0A	string	BY\ SNK\ CORPORATION	Neo Geo Pocket
>0x23	byte	0x10			Color
>0	byte	x			ROM image
>0x24	string	>\0			\b: "%.12s"
>0x1F	byte	0xFF			(debug mode enabled)
a135 12
>16	lelong	x		PC=0x%08x,
>20	lelong	!0		GP=0x%08x,
>24	lelong	!0		.text=[0x%08x,
>>28	lelong	x		\b0x%x],
>32	lelong	!0		.data=[0x%08x,
>>36	lelong	x		\b0x%x],
>40	lelong	!0		.bss=[0x%08x,
>>44	lelong	x		\b0x%x],
>48	lelong	!0		Stack=0x%08x,
>48	lelong	=0		No Stack!,
>52	lelong	!0		StackSize=0x%x,
#>76	string	>\0		(%s)
a138 4
# CPE executables
0	string	CPE		CPE executable
>3	byte	x		(version %d)

d180 1
a180 6
# From: Gurkan Sengun <gurkan@@linuks.mine.nu>, www.linuks.mine.nu
# From: David Pflug <david@@pflug.email>
# is the offset 12 or the offset 16 correct?
# GBS (Game Boy Sound) magic
# ftp://ftp.modland.com/pub/documents/format_documentation/\
# Gameboy%20Sound%20System%20(.gbs).txt 
d182 1
a182 10
#12	string		GameBoy\ Music\ Module	Nintendo Gameboy Music Module
>16	string		>\0	("%s" by
>48	string		>\0	%s, copyright
>80	string		>\0	%s),
>3	byte		x	version %d,
>4	byte		x	%d tracks

# IPS Patch Files from: From: Thomas Klausner <tk@@giga.or.at>
# see http://zerosoft.zophar.net/ips.php
0	string	PATCH			IPS patch file
a264 238

#------------------------------------------------------------------------------
# Nintendo GameCube / Wii file formats.
#

# Type: Nintendo GameCube/Wii common disc header data.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: http://wiibrew.org/wiki/Wii_Disc
0	name	nintendo-gcn-disc-common
>0x20	string	x	"%.64s"
>0x00	string	x	(%.6s
>0x06	byte	>0
>>0x06	byte	1	\b, Disc 2
>>0x06	byte	2	\b, Disc 3
>>0x06	byte	3	\b, Disc 4
>0x07	byte	x	\b, Rev.%02u)

# Type: Nintendo GameCube disc image
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: http://wiibrew.org/wiki/Wii_Disc
0x1C	belong	0xC2339F3D	Nintendo GameCube disc image:
>0	use	nintendo-gcn-disc-common

# Type: Nintendo GameCube embedded disc image
# Commonly found on demo discs.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: http://hitmen.c02.at/files/yagcd/yagcd/index.html#idx14.8
0		belong	0xAE0F38A2
>0x0C		belong	0x00100000
>>(8.L+0x1C)	belong	0xC2339F3D	Nintendo GameCube embedded disc image:
>>>(8.L)	use	nintendo-gcn-disc-common

# Type: Nintendo Wii disc image
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: http://wiibrew.org/wiki/Wii_Disc
0x18	belong	0x5D1C9EA3	Nintendo Wii disc image:
>0	use	nintendo-gcn-disc-common

# Type: Nintendo Wii disc image (WBFS format)
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: http://wiibrew.org/wiki/Wii_Disc
0	string	WBFS
>0x218	belong	0x5D1C9EA3	Nintendo Wii disc image (WBFS format):
>>0x200	use	nintendo-gcn-disc-common

# Type: Nintendo GameCube/Wii disc image (CISO format)
# NOTE: This is NOT the same as Compact ISO or PSP CISO,
# though it has the same magic number.
0		string	CISO
# Other fields are used to determine what type of CISO this is:
# - 0x04 == 0x00200000: GameCube/Wii CISO (block_size)
# - 0x10 == 0x00000800: PSP CISO (ISO-9660 sector size)
# - None of the above: Compact ISO.
>4		lelong	0x200000
>>8		byte	1
>>>0x801C	belong	0xC2339F3D	Nintendo GameCube disc image (CISO format):
>>>>0x8000	use	nintendo-gcn-disc-common
>>>0x8018	belong	0x5D1C9EA3	Nintendo Wii disc image (CISO format):
>>>>0x8000	use	nintendo-gcn-disc-common

# Type: Nintendo GameCube/Wii disc image (GCZ format)
# Due to zlib compression, we can't get the actual disc information.
0	lelong	0xB10BC001
>4	lelong	0		Nintendo GameCube disc image (GCZ format)
>4	lelong	1		Nintendo Wii disc image (GCZ format)
>4	lelong	>1		Nintendo GameCube/Wii disc image (GCZ format)

# Type: Nintendo GameCube/Wii disc image (WDF format)
0		string	WII\001DISC
>8		belong	1
# WDFv1
>>0x54		belong	0xC2339F3D	Nintendo GameCube disc image (WDFv1 format):
>>>0x38		use	nintendo-gcn-disc-common
>>0x58		belong	0x5D1C9EA3	Nintendo Wii disc image (WDFv1 format):
>>>0x38		use	nintendo-gcn-disc-common
>8		belong	2
# WDFv2
>>(12.L+0x1C)	belong	0xC2339F3D	Nintendo GameCube disc image (WDFv2 format):
>>>(12.L)	use	nintendo-gcn-disc-common
>>(12.L+0x18)	belong	0x5D1C9EA3	Nintendo Wii disc image (WDFv2 format):
>>>(12.L)	use	nintendo-gcn-disc-common

# Type: Nintendo GameCube/Wii disc image (WIA format)
0	string	WIA\001	Nintendo
>0x48	belong	0	GameCube/Wii
>0x48	belong	1	GameCube
>0x48	belong	2	Wii
>0x48	belong	>2	GameCube/Wii
>0x48	belong	x	disc image (WIA format):
>>0x58	use	nintendo-gcn-disc-common

#------------------------------------------------------------------------------
# Nintendo 3DS file formats.
#

# Type: Nintendo 3DS "NCSD" image. (game cards and eMMC)
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: https://www.3dbrew.org/wiki/NCSD
0x100		string		NCSD
>0x118		lequad		0		Nintendo 3DS Game Card image
# NCCH header for partition 0. (game data)
>>0x1150	string		>\0	\b: "%.16s"
>>0x312		byte		x	(Rev.%02u)
>>0x118C	byte		2	(New3DS only)
>>0x18D		byte		0		(inner device)
>>0x18D		byte		1		(Card1)
>>0x18D		byte		2		(Card2)
>>0x18D		byte		3		(extended device)
>0x118		bequad		0x0102020202000000	Nintendo 3DS eMMC dump (Old3DS)
>0x118		bequad		0x0102020203000000	Nintendo 3DS eMMC dump (New3DS)

# Nintendo 3DS version code.
# Reference: https://www.3dbrew.org/wiki/Titles
# Format: leshort containing three fields:
# - 6-bit: Major
# - 6-bit: Minor
# - 4-bit: Revision
# NOTE: Only supporting major/minor versions from 0-15 right now.
# NOTE: Should be prefixed with "v".
0	name	nintendo-3ds-version-code
# Raw version.
>0	leshort	x	\b%u,
# Major version.
>0	leshort&0xFC00	0x0000	0
>0	leshort&0xFC00	0x0400	1
>0	leshort&0xFC00	0x0800	2
>0	leshort&0xFC00	0x0C00	3
>0	leshort&0xFC00	0x1000	4
>0	leshort&0xFC00	0x1400	5
>0	leshort&0xFC00	0x1800	6
>0	leshort&0xFC00	0x1C00	7
>0	leshort&0xFC00	0x2000	8
>0	leshort&0xFC00	0x2400	9
>0	leshort&0xFC00	0x2800	10
>0	leshort&0xFC00	0x2C00	11
>0	leshort&0xFC00	0x3000	12
>0	leshort&0xFC00	0x3400	13
>0	leshort&0xFC00	0x3800	14
>0	leshort&0xFC00	0x3C00	15
# Minor version.
>0	leshort&0x03F0	0x0000	\b.0
>0	leshort&0x03F0	0x0010	\b.1
>0	leshort&0x03F0	0x0020	\b.2
>0	leshort&0x03F0	0x0030	\b.3
>0	leshort&0x03F0	0x0040	\b.4
>0	leshort&0x03F0	0x0050	\b.5
>0	leshort&0x03F0	0x0060	\b.6
>0	leshort&0x03F0	0x0070	\b.7
>0	leshort&0x03F0	0x0080	\b.8
>0	leshort&0x03F0	0x0090	\b.9
>0	leshort&0x03F0	0x00A0	\b.10
>0	leshort&0x03F0	0x00B0	\b.11
>0	leshort&0x03F0	0x00C0	\b.12
>0	leshort&0x03F0	0x00D0	\b.13
>0	leshort&0x03F0	0x00E0	\b.14
>0	leshort&0x03F0	0x00F0	\b.15
# Revision.
>0	leshort&0x000F	x	\b.%u

# Type: Nintendo 3DS "NCCH" container.
# https://www.3dbrew.org/wiki/NCCH
0x100		string	NCCH	Nintendo 3DS
>0x18D		byte&2	0	File Archive (CFA)
>0x18D		byte&2	2	Executable Image (CXI)
>0x150		string	>\0	\b: "%.16s"
>0x18D		byte	0x05
>>0x10E		leshort	x	(Old3DS System Update v
>>0x10E		use	nintendo-3ds-version-code
>>0x10E		leshort	x	\b)
>0x18D		byte	0x15
>>0x10E		leshort	x	(New3DS System Update v
>>0x10E		use	nintendo-3ds-version-code
>>0x10E		leshort	x	\b)
>0x18D		byte	!0x05
>>0x18D		byte	!0x15
>>>0x112	byte	x	(v
>>>0x112	use	nintendo-3ds-version-code
>>>0x112	byte	x	\b)
>0x18C		byte	2	(New3DS only)

# Type: Nintendo 3DS "SMDH" file. (application description)
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: https://3dbrew.org/wiki/SMDH
0		string		SMDH		Nintendo 3DS SMDH file
>0x208		leshort		!0
>>0x208		lestring16	x		\b: "%.128s"
>>0x388		leshort		!0
>>>0x388	lestring16	x		by %.128s
>0x208		leshort		0
>>0x008		leshort		!0
>>>0x008	lestring16	x		\b: "%.128s"
>>>0x188	leshort		!0
>>>>0x188	lestring16	x		by %.128s

# Type: Nintendo 3DS Homebrew Application.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Refernece: https://3dbrew.org/wiki/3DSX_Format
0	string	3DSX	Nintendo 3DS Homebrew Application (3DSX)

#------------------------------------------------------------------------------
# a7800: file(1) magic for the Atari 7800 raw ROM format.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: https://sites.google.com/site/atari7800wiki/a78-header

0	byte	>0
>0	byte	<3
>>1	string	ATARI7800	Atari 7800 ROM image
>>>0x11	string	>\0	\b: "%.32s"
# Display type.
>>>0x39	byte	0	(NTSC)
>>>0x39	byte	1	(PAL)
>>>0x36	byte&1	1	(POKEY)

#------------------------------------------------------------------------------
# vectrex: file(1) magic for the GCE Vectrex raw ROM format.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: http://www.playvectrex.com/designit/chrissalo/hello1.htm
#
# NOTE: Title is terminated with 0x80, not 0.
# The header is terminated with a 0, so that will
# terminate the title as well.
#
0	string	g\ GCE	Vectrex ROM image
>0x11	string	>\0	\b: "%.16s"

#------------------------------------------------------------------------------
# amiibo: file(1) magic for Nintendo amiibo NFC dumps.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: https://www.3dbrew.org/wiki/Amiibo
0x00		byte	0x04
>0x0A		beshort	0x0FE0
>>0x0C		belong	0xF110FFEE
>>>0x208	beshort	0x0100
>>>>0x020A	byte	0x0F
>>>>>0x020C	bequad	0x000000045F000000
>>>>>>0x5B	byte	0x02
>>>>>>>0x54	belong	x	Nintendo amiibo NFC dump - amiibo ID: %08X-
>>>>>>>0x58	belong	x	\b%08X
@


1.1.1.5
log
@Import file-5.31; mostly oss-fuzz found bugs.
@
text
@d3 1
a3 1
# $File: console,v 1.30 2017/03/17 21:35:28 christos Exp $
d439 1
a439 1
#0 beshort 0x4142 MSX game cartridge dump
d494 1
a494 1
0	beshort		0x8008
d509 1
a509 1
# Gameboy%20Sound%20System%20(.gbs).txt
d549 1
a549 1
# version 4 is latest so far
@


1.1.1.6
log
@2017-09-02  11:53  Christos Zoulas <christos@@zoulas.com>

	* release 5.32

2017-08-28  16:37  Christos Zoulas <christos@@zoulas.com>

	* Always reset state in {file,buffer}_apprentice (Krzysztof Wilczynski)

2017-08-27  03:55  Christos Zoulas <christos@@zoulas.com>

	* Fix always true condition (Thomas Jarosch)

2017-05-24  17:30  Christos Zoulas <christos@@zoulas.com>

	* pickier parsing of numeric values in magic files.

2017-05-23  17:55  Christos Zoulas <christos@@zoulas.com>

	* PR/615 add magic_getflags()

2017-05-23  13:55  Christos Zoulas <christos@@zoulas.com>

	* release 5.31

2017-03-17  20:32  Christos Zoulas <christos@@zoulas.com>

	* remove trailing spaces from magic files
	* refactor is_tar
	* better bounds checks for cdf
@
text
@d3 1
a3 1
# $File: console,v 1.32 2017/08/13 00:21:47 christos Exp $
a415 9
# Secure Area check.
>0x20		lelong	<0x4000		(homebrew)
>0x20		lelong	>0x3FFF
>>0x4000	lequad	0x0000000000000000	(multiboot)
>>0x4000	lequad	!0x0000000000000000
>>>0x4000	lequad	0xE7FFDEFFE7FFDEFF	(decrypted)
>>>0x4000	lequad	!0xE7FFDEFFE7FFDEFF
>>>>0x1000	lequad	0x0000000000000000	(encrypted)
>>>>0x1000	lequad	!0x0000000000000000	(mask ROM)
d799 1
a799 1
# Reference: https://3dbrew.org/wiki/3DSX_Format
@


1.1.1.6.2.1
log
@Sync with HEAD
@
text
@d3 1
a3 1
# $File: console,v 1.35 2017/11/14 15:48:36 christos Exp $
d513 1
a513 1
# From: Alex Myczko <alex@@aiei.ch>
@


1.1.1.6.2.2
log
@Sync with head
@
text
@d3 1
a3 1
# $File: console,v 1.40 2018/06/23 16:40:40 christos Exp $
a49 1
!:mime	application/x-nes-rom
a53 1
!:mime	application/x-nes-rom
a65 1
!:mime	application/x-nes-rom
a83 1
!:mime	application/x-fds-disk
a89 1
!:mime	application/x-fds-disk
a97 1
!:mime		application/x-nes-rom
a112 2
# TODO: application/x-gameboy-color-rom for GBC.
!:mime		application/x-gameboy-rom
a126 1
>0x14b		byte		!0x33
a201 1
!:mime	application/x-sega-cd-rom
a204 1
!:mime	application/x-sega-cd-rom
a208 1
!:mime	application/x-sega-cd-rom
a211 1
!:mime	application/x-sega-cd-rom
a217 1
!:mime		application/x-genesis-32x-rom
a220 1
!:mime		application/x-sega-pico-rom
a223 1
!:mime		application/x-genesis-rom
a224 1
!:mime		application/x-genesis-rom
a240 1
!:mime	application/x-genesis-rom
a245 1
!:mime	application/x-genesis-rom
a260 1
!:mime	application/x-sms-rom
a261 1
!:mime	application/x-sms-rom
a262 1
!:mime	application/x-gamegear-rom
a263 1
!:mime	application/x-gamegear-rom
d265 2
a266 3
!:mime	application/x-gamegear-rom
>0x0F	default		x	Sega Master System / Game Gear
!:mime	application/x-sms-rom
a325 1
!:mime	application/x-saturn-rom
a329 1
!:mime	application/x-saturn-rom
a349 1
!:mime	application/x-dc-rom
a353 1
!:mime	application/x-dc-rom
a368 1
!:mime	application/x-n64-rom
a377 1
!:mime	application/x-n64-rom
a383 1
!:mime	application/x-n64-rom
a389 1
!:mime	application/x-n64-rom
a398 1
!:mime	application/x-gba-rom
a410 1
!:mime	application/x-nintendo-ds-rom
a430 1
!:mime	application/x-nintendo-ds-rom
a439 1
!:mime	application/x-neo-geo-pocket-rom
a504 1
!:mime	application/x-atari-lynx-rom
a506 1
!:mime	application/x-atari-lynx-rom
d521 5
a525 5
>16	string		>\0	("%.32s" by
>48	string		>\0	%.32s, copyright
>80	string		>\0	%.32s),
>3	byte		x	version %u,
>4	byte		x	%u tracks
a627 2
>0x18	belong	0x5D1C9EA3
>>0x60	beshort	0x0101	\b (Unencrypted)
a632 1
!:mime	application/x-gamecube-rom
a641 1
!:mime	application/x-gamecube-rom
a654 1
!:mime	application/x-wii-rom
a667 1
!:mime	application/x-wii-rom
a669 1
!:mime	application/x-wii-rom
a675 1
!:mime	application/x-gamecube-rom
d677 1
a677 2
!:mime	application/x-wii-rom
>4	default	x		Nintendo GameCube/Wii disc image (GCZ format)
a683 1
!:mime	application/x-gamecube-rom
a685 1
!:mime	application/x-wii-rom
a689 1
!:mime	application/x-gamecube-rom
a691 1
!:mime	application/x-wii-rom
d696 1
a697 1
!:mime	application/x-gamecube-rom
d699 1
a699 2
!:mime	application/x-wii-rom
>0x48	default	x	GameCube/Wii
a702 11
# Type: Nintendo GameCube/Wii disc image (with SDK header)
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: http://wiibrew.org/wiki/Wii_Disc
0		belong	0xFFFF0000
>0x18		belong	0x00000000
>>0x1C		belong	0x00000000
>>>0x8018	belong	0x5D1C9EA3	Nintendo Wii SDK disc image:
>>>>0x8000	use	nintendo-gcn-disc-common
>>>0x801C	belong	0xC2339F3D	Nintendo GameCube SDK disc image:
>>>>0x8000	use	nintendo-gcn-disc-common

a818 1
!:mime	application/x-atari-7800-rom
@


1.1.1.7
log
@2018-04-15  14:52  Christos Zoulas <christos@@zoulas.com>

	* release 5.33

2018-02-24  14:50  Christos Zoulas <christos@@zoulas.com>

	* extend the support for ${x?:} expansions for magic descriptions

2018-02-21  16:25  Christos Zoulas <christos@@zoulas.com>

	* add support for ${x?:} in mime types to handle
	  pie binaries.

2017-11-03   9:23  Christos Zoulas <christos@@zoulas.com>

	* add support for negative offsets (offsets from the end of file)

2017-09-26   8:22  Christos Zoulas <christos@@zoulas.com>

	* close the file on error when writing magic (Steve Grubb)

2017-09-24  12:02  Christos Zoulas <christos@@zoulas.com>

	* seccomp support (Paul Moore)

2017-09-02  11:53  Christos Zoulas <christos@@zoulas.com>

	* release 5.32

2017-08-28  16:37  Christos Zoulas <christos@@zoulas.com>

	* Always reset state in {file,buffer}_apprentice (Krzysztof Wilczynski)

2017-08-27  03:55  Christos Zoulas <christos@@zoulas.com>

	* Fix always true condition (Thomas Jarosch)

2017-05-24  17:30  Christos Zoulas <christos@@zoulas.com>

	* pickier parsing of numeric values in magic files.

2017-05-23  17:55  Christos Zoulas <christos@@zoulas.com>

	* PR/615 add magic_getflags()
@
text
@d3 1
a3 1
# $File: console,v 1.35 2017/11/14 15:48:36 christos Exp $
d513 1
a513 1
# From: Alex Myczko <alex@@aiei.ch>
@


1.1.1.7.2.1
log
@Sync with HEAD
@
text
@d3 1
a3 1
# $File: console,v 1.45 2019/04/19 00:42:27 christos Exp $
d10 2
a11 2
# - https://wiki.nesdev.com/w/index.php/INES
# - https://wiki.nesdev.com/w/index.php/NES_2.0
a49 1
!:mime	application/x-nes-rom
a53 1
!:mime	application/x-nes-rom
d58 1
a58 1
# Reference: https://wiki.nesdev.com/w/index.php/UNIF
a65 1
!:mime	application/x-nes-rom
d69 1
a69 1
# Reference: https://wiki.nesdev.com/w/index.php/Family_Computer_Disk_System#.FDS_format
a83 1
!:mime	application/x-fds-disk
a89 1
!:mime	application/x-fds-disk
a97 1
!:mime		application/x-nes-rom
a112 2
# TODO: application/x-gameboy-color-rom for GBC.
!:mime		application/x-gameboy-rom
a126 1
>0x14b		byte		!0x33
d180 1
a180 1
# - https://www.retrodev.com/segacd.html
a201 1
!:mime	application/x-sega-cd-rom
a204 1
!:mime	application/x-sega-cd-rom
a208 1
!:mime	application/x-sega-cd-rom
a211 1
!:mime	application/x-sega-cd-rom
a217 1
!:mime		application/x-genesis-32x-rom
a220 1
!:mime		application/x-sega-pico-rom
a223 1
!:mime		application/x-genesis-rom
a224 1
!:mime		application/x-genesis-rom
a240 1
!:mime	application/x-genesis-rom
a245 1
!:mime	application/x-genesis-rom
d253 1
a253 1
# Reference: https://www.smspower.org/Development/ROMHeader
a260 1
!:mime	application/x-sms-rom
a261 1
!:mime	application/x-sms-rom
a262 1
!:mime	application/x-gamegear-rom
a263 1
!:mime	application/x-gamegear-rom
d265 2
a266 3
!:mime	application/x-gamegear-rom
>0x0F	default		x	Sega Master System / Game Gear
!:mime	application/x-sms-rom
a325 1
!:mime	application/x-saturn-rom
a329 1
!:mime	application/x-saturn-rom
d336 1
a336 1
# Reference: https://mc.pp.se/dc/ip0000.bin.html
a349 1
!:mime	application/x-dc-rom
a353 1
!:mime	application/x-dc-rom
a368 1
!:mime	application/x-n64-rom
a377 1
!:mime	application/x-n64-rom
a383 1
!:mime	application/x-n64-rom
a389 1
!:mime	application/x-n64-rom
d393 1
a393 1
# Reference: https://problemkaputt.de/gbatek.htm#gbacartridgeheader
a398 1
!:mime	application/x-gba-rom
d405 1
a405 1
# Reference: https://problemkaputt.de/gbatek.htm#dscartridgeheader
a410 1
!:mime	application/x-nintendo-ds-rom
a430 1
!:mime	application/x-nintendo-ds-rom
d437 1
a437 1
# - https://www.devrs.com/ngp/files/ngpctech.txt
a439 1
!:mime	application/x-neo-geo-pocket-rom
d474 1
a474 15
0	string	XBEH	Microsoft Xbox executable
# expect base address of 0x10000
>0x0104                 ulelong =0x10000
>>(0x0118.l-0x0FFF4)    lestring16 x       \b: "%.40s"
>>(0x0118.l-0x0FFF5)    byte     x         (%c
>>(0x0118.l-0x0FFF6)    byte     x         \b%c-
>>(0x0118.l-0x0FFF8)    uleshort x         \b%03u)
>>(0x0118.l-0x0FF60)    ulelong&0x80000007  0x80000007 \b, all regions
>>(0x0118.l-0x0FF60)    ulelong&0x80000007  !0x80000007
>>>(0x0118.l-0x0FF60)   ulelong >0           (regions:
>>>>(0x0118.l-0x0FF60)  ulelong &0x00000001  NA
>>>>(0x0118.l-0x0FF60)  ulelong &0x00000002  Japan
>>>>(0x0118.l-0x0FF60)  ulelong &0x00000004  Rest_of_World
>>>>(0x0118.l-0x0FF60)  ulelong &0x80000000  Manufacturer
>>>(0x0118.l-0x0FF60)   ulelong >0           \b)
d482 10
a497 31
#------------------------------------------------------------------------------
# Microsoft Xbox 360 executables (.xex)
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# References:
# - https://free60project.github.io/wiki/XEX.html
# - https://github.com/xenia-project/xenia/blob/HEAD/src/xenia/kernel/util/xex2_info.h

# Title ID (part of Execution ID section)
0		name	xbox-360-xex-execution-id
>(0.L+0xC)	byte	x	(%c
>(0.L+0xD)	byte	x	\b%c
>(0.L+0xE)	beshort	x	\b-%04u)

0	string	XEX2	Microsoft Xbox 360 executable
>0x18	search/0x100	\x00\x04\x00\x06
>>&0	use	xbox-360-xex-execution-id
>(0x010.L+0x178)	ubelong	0xFFFFFFFF	\b, all regions
>(0x010.L+0x178)	ubelong	!0xFFFFFFFF
>>(0x010.L+0x178)	ubelong	>0		(regions:
>>(0x010.L+0x178)	ubelong&0x000000FF	0x000000FF	USA
>>(0x010.L+0x178)	ubelong&0x00000100	0x00000100	Japan
>>(0x010.L+0x178)	ubelong&0x00000200	0x00000200	China
>>(0x010.L+0x178)	ubelong&0x0000FC00	0x0000FC00	Asia
>>(0x010.L+0x178)	ubelong&0x00FF0000	0x00FF0000	PAL
>>(0x010.L+0x178)	ubelong&0x00FF0000	0x00FE0000	PAL [except AU/NZ]
>>(0x010.L+0x178)	ubelong&0x00FF0000	0x00010000	AU/NZ
>>(0x010.L+0x178)	ubelong&0xFF000000	0xFF000000	Other
>>(0x010.L+0x178)	ubelong	>0		\b)



a504 1
!:mime	application/x-atari-lynx-rom
a506 1
!:mime	application/x-atari-lynx-rom
d521 5
a525 5
>16	string		>\0	("%.32s" by
>48	string		>\0	%.32s, copyright
>80	string		>\0	%.32s),
>3	byte		x	version %u,
>4	byte		x	%u tracks
d528 1
a528 1
# see https://zerosoft.zophar.net/ips.php
d619 1
a619 1
# Reference: https://wiibrew.org/wiki/Wii_Disc
a627 2
>0x18	belong	0x5D1C9EA3
>>0x60	beshort	0x0101	\b (Unencrypted)
d631 1
a631 1
# Reference: https://wiibrew.org/wiki/Wii_Disc
a632 1
!:mime	application/x-gamecube-rom
a641 1
!:mime	application/x-gamecube-rom
d646 1
a646 1
# Reference: https://wiibrew.org/wiki/Wii_Disc
d652 1
a652 1
# Reference: https://wiibrew.org/wiki/Wii_Disc
a654 1
!:mime	application/x-wii-rom
a667 1
!:mime	application/x-wii-rom
a669 1
!:mime	application/x-wii-rom
a675 1
!:mime	application/x-gamecube-rom
d677 1
a677 2
!:mime	application/x-wii-rom
>4	default	x		Nintendo GameCube/Wii disc image (GCZ format)
a683 1
!:mime	application/x-gamecube-rom
a685 1
!:mime	application/x-wii-rom
a689 1
!:mime	application/x-gamecube-rom
a691 1
!:mime	application/x-wii-rom
d696 1
a697 1
!:mime	application/x-gamecube-rom
d699 1
a699 2
!:mime	application/x-wii-rom
>0x48	default	x	GameCube/Wii
a702 13
# Type: Nintendo GameCube/Wii disc image (with SDK header)
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: https://wiibrew.org/wiki/Wii_Disc
0		belong	0xFFFF0000
>0x18		belong	0x00000000
>>0x1C		belong	0x00000000
>>>0x8018	belong	0x5D1C9EA3	Nintendo Wii SDK disc image:
!:mime	application/x-wii-rom
>>>>0x8000	use	nintendo-gcn-disc-common
>>>0x801C	belong	0xC2339F3D	Nintendo GameCube SDK disc image:
!:mime	application/x-gamecube-rom
>>>>0x8000	use	nintendo-gcn-disc-common

a818 1
!:mime	application/x-atari-7800-rom
@


1.1.1.7.2.2
log
@Merge changes from current as of 20200406
@
text
@d3 1
a3 1
# $File: console,v 1.49 2019/05/27 01:33:32 christos Exp $
a510 2
!:mime	audio/x-xbox-executable
!:ext	xbe
d549 1
a549 17
>(0.L+0xE)	beshort	x	\b-%04u, media ID:
>(0.L)		belong	x	%08X)

# Region code (part of Security Info)
0	name	xbox-360-xex-region-code
>0	ubelong	0xFFFFFFFF	\b, all regions
>0	ubelong	!0xFFFFFFFF
>>0	ubelong	>0		(regions:
>>0	ubelong&0x000000FF	0x000000FF	USA
>>0	ubelong&0x00000100	0x00000100	Japan
>>0	ubelong&0x00000200	0x00000200	China
>>0	ubelong&0x0000FC00	0x0000FC00	Asia
>>0	ubelong&0x00FF0000	0x00FF0000	PAL
>>0	ubelong&0x00FF0000	0x00FE0000	PAL [except AU/NZ]
>>0	ubelong&0x00FF0000	0x00010000	AU/NZ
>>0	ubelong&0xFF000000	0xFF000000	Other
>>0	ubelong	>0		\b)
a551 2
!:mime	audio/x-xbox360-executable
!:ext	xex
d554 12
a565 15
>(0x010.L+0x178)	use	xbox-360-xex-region-code

0	string	XEX1	Microsoft Xbox 360 executable (XEX1)
!:mime	audio/x-xbox360-executable
!:ext	xex
>0x18	search/0x100	\x00\x04\x00\x06
>>&0	use	xbox-360-xex-execution-id
>(0x010.L+0x154)	use	xbox-360-xex-region-code

#------------------------------------------------------------------------------
# Microsoft Xbox 360 packages
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# References:
# - https://free60project.github.io/wiki/STFS.html
# - https://github.com/xenia-project/xenia/blob/HEAD/src/xenia/kernel/util/xex2_info.h
a566 1
# TODO: More information for console-signed packages.
a567 43
0	name	xbox-360-package
>0x360	byte	x	(%c
>0x361	byte	x	\b%c
>0x362	beshort	x	\b-%04u, media ID:
>0x354	belong	x	%08X)
>0x344	belong	x	\b, content type:
>>0x344	belong	0x1		Saved Game
>>0x344	belong	0x2		Marketplace Content
>>0x344	belong	0x3		Publisher
>>0x344	belong	0x1000		Xbox 360 Title
>>0x344	belong	0x2000		IPTV Pause Buffer
>>0x344	belong	0x4000		Installed Game
>>0x344	belong	0x5000		Original Xbox Game
>>0x344	belong	0x9000		Avatar Item
>>0x344	belong	0x10000		Profile
>>0x344	belong	0x20000		Gamer Picture
>>0x344	belong	0x30000		Theme
>>0x344	belong	0x40000		Cache File
>>0x344	belong	0x50000		Storage Download
>>0x344	belong	0x60000		Xbox Saved Game
>>0x344	belong	0x70000		Xbox Download
>>0x344	belong	0x80000		Game Demo
>>0x344	belong	0x90000		Video
>>0x344	belong	0xA0000		Game
>>0x344	belong	0xB0000		Installer
>>0x344	belong	0xC0000		Game Trailer
>>0x344	belong	0xD0000		Arcade Title
>>0x344	belong	0xE0000		XNA
>>0x344	belong	0xF0000		License Store
>>0x344	belong	0x100000	Movie
>>0x344	belong	0x200000	TV
>>0x344	belong	0x300000	Music Video
>>0x344	belong	0x400000	Game Video
>>0x344	belong	0x500000	Podcast Video
>>0x344	belong	0x600000	Viral Video
>>0x344	belong	0x2000000	Community Game

0	string	CON\x20	Microsoft Xbox 360 package (console-signed)
>0	use	xbox-360-package
0	string	PIRS	Microsoft Xbox 360 package (non-Xbox Live)
>0	use	xbox-360-package
0	string	LIVE	Microsoft Xbox 360 package (Xbox Live)
>0	use	xbox-360-package
@


1.1.1.8
log
@2018-10-18  19:32  Christos Zoulas <christos@@zoulas.com>

	* release 5.35

2018-09-10  20:38  Christos Zoulas <christos@@zoulas.com>

	* Add FreeBSD ELF core file support (John Baldwin)

2018-08-20  18:40  Christos Zoulas <christos@@zoulas.com>

	* PR/30: Allow all parameter values to be set (don't treat 0 specially)
	* handle default annotations on the softmagic match instead at the
	  end.

2018-07-25  10:17  Christos Zoulas <christos@@zoulas.com>

	* PR/23: Recognize JSON files

2018-07-25  10:17  Christos Zoulas <christos@@zoulas.com>

	* PR/18: file --mime-encoding should not print mime-type

2018-07-25   8:50  Christos Zoulas <christos@@zoulas.com>

	* release 5.34

2018-06-22  16:38  Christos Zoulas <christos@@zoulas.com>

	* Add Quad indirect offsets

2018-05-24  14:10  Christos Zoulas <christos@@zoulas.com>

	* Enable parsing of ELF dynamic sections to handle PIE better
@
text
@d3 1
a3 1
# $File: console,v 1.40 2018/06/23 16:40:40 christos Exp $
a49 1
!:mime	application/x-nes-rom
a53 1
!:mime	application/x-nes-rom
a65 1
!:mime	application/x-nes-rom
a83 1
!:mime	application/x-fds-disk
a89 1
!:mime	application/x-fds-disk
a97 1
!:mime		application/x-nes-rom
a112 2
# TODO: application/x-gameboy-color-rom for GBC.
!:mime		application/x-gameboy-rom
a126 1
>0x14b		byte		!0x33
a201 1
!:mime	application/x-sega-cd-rom
a204 1
!:mime	application/x-sega-cd-rom
a208 1
!:mime	application/x-sega-cd-rom
a211 1
!:mime	application/x-sega-cd-rom
a217 1
!:mime		application/x-genesis-32x-rom
a220 1
!:mime		application/x-sega-pico-rom
a223 1
!:mime		application/x-genesis-rom
a224 1
!:mime		application/x-genesis-rom
a240 1
!:mime	application/x-genesis-rom
a245 1
!:mime	application/x-genesis-rom
a260 1
!:mime	application/x-sms-rom
a261 1
!:mime	application/x-sms-rom
a262 1
!:mime	application/x-gamegear-rom
a263 1
!:mime	application/x-gamegear-rom
d265 2
a266 3
!:mime	application/x-gamegear-rom
>0x0F	default		x	Sega Master System / Game Gear
!:mime	application/x-sms-rom
a325 1
!:mime	application/x-saturn-rom
a329 1
!:mime	application/x-saturn-rom
a349 1
!:mime	application/x-dc-rom
a353 1
!:mime	application/x-dc-rom
a368 1
!:mime	application/x-n64-rom
a377 1
!:mime	application/x-n64-rom
a383 1
!:mime	application/x-n64-rom
a389 1
!:mime	application/x-n64-rom
a398 1
!:mime	application/x-gba-rom
a410 1
!:mime	application/x-nintendo-ds-rom
a430 1
!:mime	application/x-nintendo-ds-rom
a439 1
!:mime	application/x-neo-geo-pocket-rom
a504 1
!:mime	application/x-atari-lynx-rom
a506 1
!:mime	application/x-atari-lynx-rom
d521 5
a525 5
>16	string		>\0	("%.32s" by
>48	string		>\0	%.32s, copyright
>80	string		>\0	%.32s),
>3	byte		x	version %u,
>4	byte		x	%u tracks
a627 2
>0x18	belong	0x5D1C9EA3
>>0x60	beshort	0x0101	\b (Unencrypted)
a632 1
!:mime	application/x-gamecube-rom
a641 1
!:mime	application/x-gamecube-rom
a654 1
!:mime	application/x-wii-rom
a667 1
!:mime	application/x-wii-rom
a669 1
!:mime	application/x-wii-rom
a675 1
!:mime	application/x-gamecube-rom
d677 1
a677 2
!:mime	application/x-wii-rom
>4	default	x		Nintendo GameCube/Wii disc image (GCZ format)
a683 1
!:mime	application/x-gamecube-rom
a685 1
!:mime	application/x-wii-rom
a689 1
!:mime	application/x-gamecube-rom
a691 1
!:mime	application/x-wii-rom
d696 1
a697 1
!:mime	application/x-gamecube-rom
d699 1
a699 2
!:mime	application/x-wii-rom
>0x48	default	x	GameCube/Wii
a702 11
# Type: Nintendo GameCube/Wii disc image (with SDK header)
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: http://wiibrew.org/wiki/Wii_Disc
0		belong	0xFFFF0000
>0x18		belong	0x00000000
>>0x1C		belong	0x00000000
>>>0x8018	belong	0x5D1C9EA3	Nintendo Wii SDK disc image:
>>>>0x8000	use	nintendo-gcn-disc-common
>>>0x801C	belong	0xC2339F3D	Nintendo GameCube SDK disc image:
>>>>0x8000	use	nintendo-gcn-disc-common

a818 1
!:mime	application/x-atari-7800-rom
@


1.1.1.9
log
@2019-05-14  22:26  Christos Zoulas <christos@@zoulas.com>

	* release 5.37

2019-05-09  22:27  Christos Zoulas <christos@@zoulas.com>

	* Make sure that continuation separators are printed
	  with -k within softmagic

2019-05-06  22:27  Christos Zoulas <christos@@zoulas.com>

	* Change SIGPIPE saving and restoring during compression to use
	  sigaction(2) instead of signal(3) and cache it. (Denys Vlasenko)
	* Cache stat(2) calls more to reduce number of calls (Denys Vlasenko)

2019-05-06  17:25  Christos Zoulas <christos@@zoulas.com>

	* PR/77: Handle --mime-type and -k correctly.

2019-05-03  15:26  Christos Zoulas <christos@@zoulas.com>

	* Switch decompression code to use vfork() because
	  tools like rpmdiff and rpmbuild call libmagic
	  with large process footprints (Denys Vlasenko)

2019-04-07  14:05  Christos Zoulas <christos@@zoulas.com>

	* PR/75: --enable-zlib, did not work.

2019-02-27  11:54  Christos Zoulas <christos@@zoulas.com>

	* Improve regex efficiency (Michael Schroeder) by:
		1. Prefixing regex searches with regular search
		   for keywords where possible
		2. Using memmem(3) where available
@
text
@d3 1
a3 1
# $File: console,v 1.45 2019/04/19 00:42:27 christos Exp $
d10 2
a11 2
# - https://wiki.nesdev.com/w/index.php/INES
# - https://wiki.nesdev.com/w/index.php/NES_2.0
d60 1
a60 1
# Reference: https://wiki.nesdev.com/w/index.php/UNIF
d72 1
a72 1
# Reference: https://wiki.nesdev.com/w/index.php/Family_Computer_Disk_System#.FDS_format
d189 1
a189 1
# - https://www.retrodev.com/segacd.html
d272 1
a272 1
# Reference: https://www.smspower.org/Development/ROMHeader
d362 1
a362 1
# Reference: https://mc.pp.se/dc/ip0000.bin.html
d425 1
a425 1
# Reference: https://problemkaputt.de/gbatek.htm#gbacartridgeheader
d438 1
a438 1
# Reference: https://problemkaputt.de/gbatek.htm#dscartridgeheader
d472 1
a472 1
# - https://www.devrs.com/ngp/files/ngpctech.txt
d510 1
a510 15
0	string	XBEH	Microsoft Xbox executable
# expect base address of 0x10000
>0x0104                 ulelong =0x10000
>>(0x0118.l-0x0FFF4)    lestring16 x       \b: "%.40s"
>>(0x0118.l-0x0FFF5)    byte     x         (%c
>>(0x0118.l-0x0FFF6)    byte     x         \b%c-
>>(0x0118.l-0x0FFF8)    uleshort x         \b%03u)
>>(0x0118.l-0x0FF60)    ulelong&0x80000007  0x80000007 \b, all regions
>>(0x0118.l-0x0FF60)    ulelong&0x80000007  !0x80000007
>>>(0x0118.l-0x0FF60)   ulelong >0           (regions:
>>>>(0x0118.l-0x0FF60)  ulelong &0x00000001  NA
>>>>(0x0118.l-0x0FF60)  ulelong &0x00000002  Japan
>>>>(0x0118.l-0x0FF60)  ulelong &0x00000004  Rest_of_World
>>>>(0x0118.l-0x0FF60)  ulelong &0x80000000  Manufacturer
>>>(0x0118.l-0x0FF60)   ulelong >0           \b)
d518 10
a533 31
#------------------------------------------------------------------------------
# Microsoft Xbox 360 executables (.xex)
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# References:
# - https://free60project.github.io/wiki/XEX.html
# - https://github.com/xenia-project/xenia/blob/HEAD/src/xenia/kernel/util/xex2_info.h

# Title ID (part of Execution ID section)
0		name	xbox-360-xex-execution-id
>(0.L+0xC)	byte	x	(%c
>(0.L+0xD)	byte	x	\b%c
>(0.L+0xE)	beshort	x	\b-%04u)

0	string	XEX2	Microsoft Xbox 360 executable
>0x18	search/0x100	\x00\x04\x00\x06
>>&0	use	xbox-360-xex-execution-id
>(0x010.L+0x178)	ubelong	0xFFFFFFFF	\b, all regions
>(0x010.L+0x178)	ubelong	!0xFFFFFFFF
>>(0x010.L+0x178)	ubelong	>0		(regions:
>>(0x010.L+0x178)	ubelong&0x000000FF	0x000000FF	USA
>>(0x010.L+0x178)	ubelong&0x00000100	0x00000100	Japan
>>(0x010.L+0x178)	ubelong&0x00000200	0x00000200	China
>>(0x010.L+0x178)	ubelong&0x0000FC00	0x0000FC00	Asia
>>(0x010.L+0x178)	ubelong&0x00FF0000	0x00FF0000	PAL
>>(0x010.L+0x178)	ubelong&0x00FF0000	0x00FE0000	PAL [except AU/NZ]
>>(0x010.L+0x178)	ubelong&0x00FF0000	0x00010000	AU/NZ
>>(0x010.L+0x178)	ubelong&0xFF000000	0xFF000000	Other
>>(0x010.L+0x178)	ubelong	>0		\b)



d566 1
a566 1
# see https://zerosoft.zophar.net/ips.php
d657 1
a657 1
# Reference: https://wiibrew.org/wiki/Wii_Disc
d671 1
a671 1
# Reference: https://wiibrew.org/wiki/Wii_Disc
d688 1
a688 1
# Reference: https://wiibrew.org/wiki/Wii_Disc
d694 1
a694 1
# Reference: https://wiibrew.org/wiki/Wii_Disc
d757 1
a757 1
# Reference: https://wiibrew.org/wiki/Wii_Disc
a761 1
!:mime	application/x-wii-rom
a763 1
!:mime	application/x-gamecube-rom
@


1.1.1.10
log
@Import 5.38:
	- Always accept -S (no sandbox) even if we don't support sandboxing
	- More syscalls elided for sandboxiing
	- For ELF dynamic means having an interpreter not just PT_DYNAMIC
	- Check for large ELF session header offset
	- When saving and restoring a locale, keep the locale name in our
	  own storage.
	- Add a flag to disable CSV file detection.
	- Don't pass NULL/0 to memset to appease sanitizers.
	- Avoid spurious prints when looks for extensions or apple strings
	  in fsmagic.
	- Add builtin decompressors for xz and and bzip.
	- Add a limit for the number of CDF elements.
	- More checks for overflow in CDF.
@
text
@d3 1
a3 1
# $File: console,v 1.49 2019/05/27 01:33:32 christos Exp $
a510 2
!:mime	audio/x-xbox-executable
!:ext	xbe
d549 1
a549 17
>(0.L+0xE)	beshort	x	\b-%04u, media ID:
>(0.L)		belong	x	%08X)

# Region code (part of Security Info)
0	name	xbox-360-xex-region-code
>0	ubelong	0xFFFFFFFF	\b, all regions
>0	ubelong	!0xFFFFFFFF
>>0	ubelong	>0		(regions:
>>0	ubelong&0x000000FF	0x000000FF	USA
>>0	ubelong&0x00000100	0x00000100	Japan
>>0	ubelong&0x00000200	0x00000200	China
>>0	ubelong&0x0000FC00	0x0000FC00	Asia
>>0	ubelong&0x00FF0000	0x00FF0000	PAL
>>0	ubelong&0x00FF0000	0x00FE0000	PAL [except AU/NZ]
>>0	ubelong&0x00FF0000	0x00010000	AU/NZ
>>0	ubelong&0xFF000000	0xFF000000	Other
>>0	ubelong	>0		\b)
a551 2
!:mime	audio/x-xbox360-executable
!:ext	xex
d554 12
a565 15
>(0x010.L+0x178)	use	xbox-360-xex-region-code

0	string	XEX1	Microsoft Xbox 360 executable (XEX1)
!:mime	audio/x-xbox360-executable
!:ext	xex
>0x18	search/0x100	\x00\x04\x00\x06
>>&0	use	xbox-360-xex-execution-id
>(0x010.L+0x154)	use	xbox-360-xex-region-code

#------------------------------------------------------------------------------
# Microsoft Xbox 360 packages
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# References:
# - https://free60project.github.io/wiki/STFS.html
# - https://github.com/xenia-project/xenia/blob/HEAD/src/xenia/kernel/util/xex2_info.h
a566 1
# TODO: More information for console-signed packages.
a567 43
0	name	xbox-360-package
>0x360	byte	x	(%c
>0x361	byte	x	\b%c
>0x362	beshort	x	\b-%04u, media ID:
>0x354	belong	x	%08X)
>0x344	belong	x	\b, content type:
>>0x344	belong	0x1		Saved Game
>>0x344	belong	0x2		Marketplace Content
>>0x344	belong	0x3		Publisher
>>0x344	belong	0x1000		Xbox 360 Title
>>0x344	belong	0x2000		IPTV Pause Buffer
>>0x344	belong	0x4000		Installed Game
>>0x344	belong	0x5000		Original Xbox Game
>>0x344	belong	0x9000		Avatar Item
>>0x344	belong	0x10000		Profile
>>0x344	belong	0x20000		Gamer Picture
>>0x344	belong	0x30000		Theme
>>0x344	belong	0x40000		Cache File
>>0x344	belong	0x50000		Storage Download
>>0x344	belong	0x60000		Xbox Saved Game
>>0x344	belong	0x70000		Xbox Download
>>0x344	belong	0x80000		Game Demo
>>0x344	belong	0x90000		Video
>>0x344	belong	0xA0000		Game
>>0x344	belong	0xB0000		Installer
>>0x344	belong	0xC0000		Game Trailer
>>0x344	belong	0xD0000		Arcade Title
>>0x344	belong	0xE0000		XNA
>>0x344	belong	0xF0000		License Store
>>0x344	belong	0x100000	Movie
>>0x344	belong	0x200000	TV
>>0x344	belong	0x300000	Music Video
>>0x344	belong	0x400000	Game Video
>>0x344	belong	0x500000	Podcast Video
>>0x344	belong	0x600000	Viral Video
>>0x344	belong	0x2000000	Community Game

0	string	CON\x20	Microsoft Xbox 360 package (console-signed)
>0	use	xbox-360-package
0	string	PIRS	Microsoft Xbox 360 package (non-Xbox Live)
>0	use	xbox-360-package
0	string	LIVE	Microsoft Xbox 360 package (Xbox Live)
>0	use	xbox-360-package
@


1.1.1.11
log
@Import 5.39:

   * Remove unused subtype_mime (Steve Grubb)
   * Remove unused check in okstat (Steve Grubb)
   * Fix mime-type in elf binaries by making sure $x is set
   * Fix indirect negative offsets broken by OFFNEGATIVE
   * Fix GUID equality check
   * PR/165: Handle empty array and strings in JSON
   * PR/162: Add --exclude-quiet
   * Fix memory leak in ascmagic (Steve Grubb)
   * Fix string comparison length with ignore whitespace
   * Fix mingwin 64 compilation
   * PR/159: whitelist getpid needed for file_pipe2file()
   * Indicate negative offsets with a flag OFFNEGATIVE
     so that -0 works.
   * Introduce "offset" magic type that can be used to
     detect the file size, and bail on short files.
   * document DER better in the magic man page.
   * fix memory leaks (SonarQube)
   * rewrite confusing loops (SonarQube)
   * fix bogus test (SonarQube)
   * pass a sized buffer to file_fmttime() (SonarQube)
   * Don't allow * in printf formats, or the code itself (Christoph Biedl)
   * Introduce a printf output size checker to avoid DoS attacks
   * Avoid memory leak on error (oss-fuzz)
   * Check length of string on DER before derefercing and add new types
   * Add missing DER string (oss-fuzz)
   * Add missing DER types, and debugging
   * PR/140: Avoid abort with hand-crafted magic file (gockelhahn)
   * PR/139:  Avoid DoS in printf with hand-crafted magic file (gockelhahn)
   * PR/138: Avoid crash with hand-crafted magic file (gockelhahn)
   * PR/136: Fix static build by adding a libmagic.pc (Fabrice Fontaine)
   * add guid support native support via the "guid" type.
@
text
@d3 1
a3 1
# $File: console,v 1.55 2020/04/19 17:30:55 christos Exp $
d631 4
a634 6
0	string	PIRS
>0	belong	0	Microsoft Xbox 360 package (non-Xbox Live)
>>0	use	xbox-360-package
0	string	LIVE
>0x104	belong	0	Microsoft Xbox 360 package (Xbox Live)
>>0	use	xbox-360-package
a669 24
!:ext	ips

# BPS Patch Files - from: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: https://www.romhacking.net/documents/746/
0	string	BPS1			BPS patch file
!:ext	bps

# APS Patch Files - from: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: https://github.com/btimofeev/UniPatcher/wiki/APS-(N64)
0	string	APS10			APS patch file
!:ext	aps
>5	byte	0			\b, simple patch
>5	byte	1			\b, N64-specific patch for
>>58	byte	x			N%c
>>59	byte	x			\b%c
>>60	byte	x			\b%c
>7	byte	!0x20
# FIXME: /T specifier isn't working with a fixed-length string.
>>7	string	x			\b: "%.50s"

# UPS Patch Files - from: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: http://fileformats.archiveteam.org/wiki/UPS_(binary_patch_format)
0	string	UPS1			UPS patch file
!:ext	ups
a769 2
>0x200	string	NKIT	\b (NKit compressed)

a1017 58

#------------------------------------------------------------------------------
# Type: Nintendo Switch XCI (Game Cartridge Image)
# From: Benjamin Lowry <ben@@ben.gmbh>
# Reference: https://switchbrew.org/wiki/Gamecard_Format
0x100		string	HEAD
>0x10D		byte	0xFA	Nintendo Switch cartridge image (XCI), 1GB
>0x10D		byte	0xF8	Nintendo Switch cartridge image (XCI), 2GB
>0x10D		byte	0xF0	Nintendo Switch cartridge image (XCI), 4GB
>0x10D		byte	0xE0	Nintendo Switch cartridge image (XCI), 8GB
>0x10D		byte	0xE1	Nintendo Switch cartridge image (XCI), 16GB
>0x10D		byte	0xE2	Nintendo Switch cartridge image (XCI), 32GB

#------------------------------------------------------------------------------
# Type: Nintendo Switch Executable
# From: Benjamin Lowry <ben@@ben.gmbh>
# Reference: https://switchbrew.org/wiki/NSO
0x00		string	NSO0	Nintendo Switch executable (NSO)

#------------------------------------------------------------------------------
# Type: Nintendo Switch PFS0
# From: Benjamin Lowry <ben@@ben.gmbh>
# Reference: https://switchbrew.org/wiki/NCA_Format#PFS0
0x00		string	PFS0	Nintendo Switch partition filesystem (PFS0)
>0x04		ulelong	x	\b, %d files

#------------------------------------------------------------------------------
# amiibo: file(1) magic for Nintendo Badge Arcade files.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# References:
# - https://github.com/GerbilSoft/rom-properties/issues/92
# - https://github.com/CaitSith2/BadgeArcadeTool
# - https://github.com/TheMachinumps/Advanced-badge-editor

# PRBS: Individual badge and/or mega badge.
0		string	PRBS
>0x44		byte	>0x20	Nintendo Badge Arcade
>>0xB8		ulelong	<2
>>>0xBC		ulelong	<2	badge:
>>>0xBC		ulelong	>1	Mega Badge
>>>>0xB8	ulelong	x	(%ux
>>>>0xBC	ulelong	x	\b%u):
>>0xB8		ulelong	>1	Mega Badge
>>>0xB8		ulelong	x	(%ux
>>>0xBC		ulelong	x	\b%u):
>0x44		string	x	"%s"
>0x3C		ulelong	x	\b, badge ID: %u
>0x74		byte	>0x20
>>0x74		string	x	\b, set: "%s"
>0xA8		ulelong	!0xFFFFFFFF
>>0xA8		ulelong	x	\b, launch title ID: %08X
>>0xA4		ulelong	x	\b-%08X

# CABS: Badge set.
0	string	CABS
>0x2C	byte	>0x20	Nintendo Badge Arcade badge set:
>>0x2C	string	x	"%.48s"
>>0x24	ulelong	x	\b, set ID: %u
@


1.1.1.12
log
@2021-03-30  20:21  Christos Zoulas <christos@@zoulas.com>

	* release 5.40

2021-02-05  16:31  Christos Zoulas <christos@@zoulas.com>

	* PR/234: Add limit to the number of bytes to scan for encoding
	* PR/230: Fix /T (trim flag) for regex

2021-02-01  12:31  Christos Zoulas <christos@@zoulas.com>
	* PR/77: Trim trailing separator.

2020-12-17  15:44  Christos Zoulas <christos@@zoulas.com>

	* PR/211: Convert system read errors from corrupt ELF
	  files into human readable error messages

2020-12-08  16:24  Christos Zoulas <christos@@zoulas.com>

	* fix multithreaded decompression file descriptor issue
	  by using close-on-exec (Denys Vlasenko)

2020-06-27  11:58  Christos Zoulas <christos@@zoulas.com>

	* Exclude surrogate pairs from utf-8 detection (Michael Liu)

2020-06-25  12:53  Christos Zoulas <christos@@zoulas.com>

	* Include # to the list of ignored format chars (Werner Fink)
@
text
@d3 1
a3 1
# $File: console,v 1.62 2021/02/05 21:51:06 christos Exp $
a127 1
# Old licensee code 0x33 is required for SGB, but not CGB.
a135 2
>>0x143		byte&0xC0	0x80	[CGB]
>>0x143		byte&0xC0	0xC0	[CGB ONLY]
d181 1
a181 1
>0x149 byte 3     \b, RAM: 256Kbit
a1005 5
# Type: Nintendo 3DS Banner Model Data.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: https://3dbrew.org/wiki/CBMD
0	string	CBMD\0\0\0\0	Nintendo 3DS Banner Model Data

a1103 28

#------------------------------------------------------------------------------
# sufami: file(1) magic for Sufami Turbo ROM images.
# From: David Korth <gerbilsoft@@gerbilsoft.com>
# References:
# - https://problemkaputt.de/fullsnes.htm#snescartsufamiturbominicartridgeadaptor
0	string		BANDAI\ SFC-ADX
>0x10	string		!SFC-ADX\ BACKUP	Sufami Turbo ROM image:
>>0x10	string/T	x	"%.14s"
>>0x30	byte		x	\b, ID %02X
>>0x31	byte		x	\b%02X
>>0x32	byte		x	\b%02X
>>0x33	ubyte		>0	\b, series index %u
>>0x34	ubyte		0	[SlowROM]
>>0x34	ubyte		1	[FastROM]
>>0x35	ubyte		1	[SRAM]
>>0x35	ubyte		3	[Special]

# Type: Nintendo GameCube/Wii disc image (RVZ format)
0	string		RVZ\001	Nintendo
>0x48	belong		1	GameCube
!:mime	application/x-gamecube-rom
>0x48	belong		2	Wii
!:mime	application/x-wii-rom
>0x48	default		x	GameCube/Wii
>0x48	belong		x	disc image (RVZ format):
>>0x58	use		nintendo-gcn-disc-common

@


1.1.1.13
log
@Import file-5.43+; last was file-5.40

2022-09-20  17:12  Christos Zoulas <christos@@zoulas.com>

	* fixed various clustefuzz issues

2022-09-19  15:54  Christos Zoulas <christos@@zoulas.com>

	* Fix error detection for decompression code (Vincent Mihalkovic)

2022-09-15  13:50  Christos Zoulas <christos@@zoulas.com>

	* Add MAGIC_NO_COMPRESS_FORK and use it to produce a more
	  meaningful error message if we are sandboxing.

2022-09-15  10:45  Christos Zoulas <christos@@zoulas.com>

	* Add built-in lzip decompression support (Michal Gorny)

2022-09-14  10:35  Christos Zoulas <christos@@zoulas.com>

	* Add built-in zstd decompression support (Martin Rodriguez Reboredo)

2022-09-13  14:55  Christos Zoulas <christos@@zoulas.com>

	* release 5.43

2022-09-10   9:17  Christos Zoulas <christos@@zoulas.com>

	* Add octal indirect magic (Michal Gorny)

2022-08-17  11:43  Christos Zoulas <christos@@zoulas.com>

	* PR/374: avoid infinite loop in non-wide code (piru)
	* PR/373: Obey MAGIC_CONTINUE with multiple magic files (vismarli)

2022-07-26  11:10  Christos Zoulas <christos@@zoulas.com>

	* Fix bug with large flist (Florian Weimer)

2022-07-07  13:21  Christos Zoulas <christos@@zoulas.com>

        * PR/364: Detect non-nul-terminated core filenames from QEMU
	  (mam-ableton)

2022-07-04  15:45  Christos Zoulas <christos@@zoulas.com>

	* PR/359: Add support for http://ndjson.org/ (darose)
	* PR/362: Fix wide printing (ro-ee)
	* PR/358: Fix width for -f - (jpalus)
	* PR/356: Fix JSON constant parsing (davewhite)

2022-06-10   9:40  Christos Zoulas <christos@@zoulas.com>

	* release 5.42

2022-05-31  14:50   Christos Zoulas <christos@@zoulas.com>

	* PR/348: add missing cases to prevent file from aborting on
	  random magic files.

2022-05-27  21:05   Christos Zoulas <christos@@zoulas.com>

	* PR/351: octalify filenames when not raw before printing.

2022-04-18  17:51   Christos Zoulas <christos@@zoulas.com>

	* fix regex cacheing bug (Dirk Mueller)
	* merge file_regcomp and file_regerror() to simplify the code
	  and reduce memory requirements for storing regexes (Dirk Mueller)

2022-03-19  12:56   Christos Zoulas <christos@@zoulas.com>

	* cache regex (Dirk Mueller)
	* detect filesystem full by flushing output (Dirk Mueller)

2021-11-19  12:36   Christos Zoulas <christos@@zoulas.com>

	* implement running decompressor programs using
	  posix_spawnp(2) instead of vfork(2)

2021-10-24  11:51   Christos Zoulas <christos@@zoulas.com>

	* Add support for msdos dates and times

2021-10-20   9:55   Christos Zoulas <christos@@zoulas.com>

	* use the system byte swapping functions if available (Werner Fink)

2021-10-18  11:57  Christos Zoulas <christos@@zoulas.com>

	* release 5.41

2021-09-23  03:51  Christos Zoulas <christos@@zoulas.com>

	* Avinash Sonawane: Fix tzname detection

2021-09-03  09:17  Christos Zoulas <christos@@zoulas.com>

	* Fix relationship tests with "search" magic, don't short circuit
	  logic

2021-07-13  01:06  Christos Zoulas <christos@@zoulas.com>

	* Fix memory leak in compile mode

2021-07-01  03:51  Christos Zoulas <christos@@zoulas.com>

	* PR/272: kiefermat: Only set returnval = 1 when we printed something
	  (in all cases print or !print). This simplifies the logic and fixes
	  the issue in the PR with -k and --mime-type there was no continuation
	  printed before the default case.

2021-06-30  13:07  Christos Zoulas <christos@@zoulas.com>

	* PR/270: Don't translate unprintable characters in %s magic formats
	  when -r
	* PR/269: Avoid undefined behavior with clang (adding offset to NULL)

2021-05-09  18:38  Christos Zoulas <christos@@zoulas.com>

	* Add a new flag (f) that requires that the match is a full word,
	   not a partial word match.
	* Add varint types (unused)

2021-04-19  17:17  Christos Zoulas <christos@@zoulas.com>

	* PR/256: mutableVoid: If the file is less than 3 bytes, use the file
	  length to determine type
	* PR/259: aleksandr.v.novichkov: mime printing through indirect magic
	  is not taken into account, use match directly so that it does.

2021-04-04  17:02  Christos Zoulas <christos@@zoulas.com>

	* count the total bytes found not the total byte positions
	  in order to determine encoding (Anatol Belski)
@
text
@d3 1
a3 1
# $File: console,v 1.68 2022/05/14 20:04:43 christos Exp $
d81 2
a82 2
>15	ubyte	x		\b, mfr %02X
>20	ubyte	x		(Rev.%02u)
d231 1
a231 1
# Sega Mega Drive: Identify the system ID.
d233 1
a233 1
>0x3C0		string	MARS\ CHECK\ MODE	Sega 32X ROM image
d236 2
a237 1
>0x104		string	\ PICO			Sega Pico ROM image
d239 3
a241 17
>>0		use	sega-mega-drive-header
>0x104		string	TOYS\ PICO		Sega Pico ROM image
!:mime		application/x-sega-pico-rom
>>0		use	sega-mega-drive-header
>0x104		string	\ TOYS\ PICO		Sega Pico ROM image
!:mime		application/x-sega-pico-rom
>>0		use	sega-mega-drive-header
>0x104		string	\ IAC			Sega Pico ROM image
!:mime		application/x-sega-pico-rom
>>0		use	sega-mega-drive-header
>0x104		string	\ TERA68K		Sega Teradrive (68K) ROM image
!:mime		application/x-sega-teradrive-rom
>>0		use	sega-mega-drive-header
>0x104		string	\ TERA286		Sega Teradrive (286) ROM image
!:mime		application/x-sega-teradrive-rom
>>0		use	sega-mega-drive-header
>0x180		string	BR			Sega Mega CD Boot ROM image
d243 1
a243 2
>>0		use	sega-mega-drive-header
>0x104		default	x			Sega Mega Drive / Genesis ROM image
d245 1
a245 22
>>0		use	sega-mega-drive-header

# Sega Mega Drive: Some ROMs have "SEGA" at 0x101, not 0x100.
0x100		string	\ SEGA			Sega Mega Drive / Genesis ROM image
>0		use	sega-mega-drive-header

# Sega Pico ROMs that don't start with "SEGA".
0x100		string	SAMSUNG\ PICO		Samsung Pico ROM image
!:mime		application/x-sega-pico-rom
>0		use	sega-mega-drive-header
0x100		string	IMA\ IKUNOUJYUKU	Samsung Pico ROM image
!:mime		application/x-sega-pico-rom
>0		use	sega-mega-drive-header
0x100		string	IMA IKUNOJYUKU		Samsung Pico ROM image
!:mime		application/x-sega-pico-rom
>0		use	sega-mega-drive-header

# Sega Picture Magic (modified 32X)
0x100		string	Picture\ Magic
>0x3C0		string	PICTURE MAGIC-01	Sega 32X ROM image
!:mime		application/x-genesis-32x-rom
>>0		use	sega-mega-drive-header
d477 1
a477 1
0x0A	string		BY\ SNK\ CORPORATION	Neo Geo Pocket
d479 4
a482 5
>0x23	byte		0x10			Color
>0	byte		x			ROM image
>0x24	string		>\0			\b: "%.12s"
>0x21	uleshort	x			\b, NEOP%04X
>0x1F	ubyte		0xFF			(debug mode enabled)
d492 9
a500 9
>16	lelong	x		PC=%#08x,
>20	lelong	!0		GP=%#08x,
>24	lelong	!0		.text=[%#08x,
>>28	lelong	x		\b%#x],
>32	lelong	!0		.data=[%#08x,
>>36	lelong	x		\b%#x],
>40	lelong	!0		.bss=[%#08x,
>>44	lelong	x		\b%#x],
>48	lelong	!0		Stack=%#08x,
d502 1
a502 1
>52	lelong	!0		StackSize=%#x,
d642 2
a643 3
# From: "Stefan A. Haubenthal" <polluks@@sdf.lonestar.org>
# Reference:
# https://raw.githubusercontent.com/cc65/cc65/master/libsrc/lynx/exehdr.s
d650 1
a650 1
0	string		LYNX		Lynx cartridge
d652 1
a652 4
>4	leshort/4	>0		\b, bank 0 %dk
>6	leshort/4	>0		\b, bank 1 %dk
>10	string		>\0		\b, "%.32s"
>42	string		>\0		\b, "%.16s"
d774 1
a774 1
>>>(0x18.l-26)	lelong		x	CRC32 %#08x
a900 10
# Type: Nintendo GameCube/Wii disc image (RVZ format)
0	string		RVZ\001	Nintendo
>0x48	belong		1	GameCube
!:mime	application/x-gamecube-rom
>0x48	belong		2	Wii
!:mime	application/x-wii-rom
>0x48	default		x	GameCube/Wii
>0x48	belong		x	disc image (RVZ format):
>>0x58	use		nintendo-gcn-disc-common

d1129 11
@


1.1.1.14
log
@Update to file-5.45 (Last was file-5.44)

2023-07-27  15:45  Christos Zoulas <christos@@zoulas.com>

	* release 5.45

2023-07-17  11:53  Christos Zoulas <christos@@zoulas.com>

	* PR/465: psrok1: Avoid muslc asctime_r crash

2023-05-21  13:05  Christos Zoulas <christos@@zoulas.com>

	* add SIMH tape format support

2023-02-09  12:50  Christos Zoulas <christos@@zoulas.com>

	* bump the max size of the elf section notes to be read to 128K
	  and make it configurable

2023-01-08   1:08  Christos Zoulas <christos@@zoulas.com>

	* PR/415: Fix decompression with program returning empty

2022-12-26   1:47  Christos Zoulas <christos@@zoulas.com>

	* PR/408: fix -p with seccomp
	* PR/412: fix MinGW compilation
@
text
@d3 1
a3 1
# $File: console,v 1.72 2023/06/16 19:24:06 christos Exp $
d71 1
a71 1
# fds: file(1) magic for Famicom Disk System disk images
a546 13
# Sony PlayStation archive (PSARC)
# From: Alexandre Iooss <erdnaxe@@crans.org>
# URL: https://www.psdevwiki.com/ps3/PlayStation_archive_(PSARC)
0	string		PSAR	Sony PlayStation Archive
!:ext	psarc
>4	ubeshort	x	\b, version %d.
>6	ubeshort	x	\b%d
>8	string		zlib	\b, zlib compression
>8	string		lzma	\b, LZMA compression
>28	ubeshort&2	0	\b, relative paths
>28	ubeshort&2	2	\b, absolute paths
>28	ubeshort&1	1	\b, ignore case

a686 3
# Update:	Joerg Jenderek
# Reference:	http://mark0.net/download/triddefs_xml.7z/defs/l/lnx.trid.xml
# Note:		called "Atari Lynx ROM" by TrID
a688 2
!:ext	lnx
# bank 0 page size like: 128 256 512
a690 1
# 32 bytes cart name like: "jconnort.lyx" "viking~1.lyx" "Eye of the Beholder" "C:\EMU\LYNX\ROMS\ULTCHESS.LYX"
a691 1
# 16 bytes manufacturer like: "Atari" "NuFX Inc." "Matthias Domin"
a692 6
# version number
#>8	leshort		!1		\b, version number %u
# rotation: 1~left Lexis (NA).lnx 2~right Centipede (Prototype).lnx
>58	ubyte		>0		\b, rotation %u
# spare
#>59	lelong		!0		\b, spare %#x
a762 22
# Compressed ISO disc image (used mostly by PSP, PS2 and MegaDrive)
# From: Alexandre Iooss <erdnaxe@@crans.org>
# URL: https://en.wikipedia.org/wiki/.CSO
# NOTE: This is NOT the same as Compact ISO or GameCube/Wii disc image,
# though it has the same magic number.
0               string                  CISO
# Match CISO version 1 with ISO-9660 sector size
>20             ubyte                   <2
>>16            ulelong                 =2048           CSO v1 disk image
!:mime  application/x-compressed-iso
!:ext   ciso/cso
>>>8            ulequad                 x               \b, original size %llu bytes
>>>16           ulelong                 x               \b, datablock size %u bytes
# Match CISO version 2
>20             ubyte                   =2
>>22            uleshort                =0
>>>4            ulelong                 =24             CSO v2 disk image
!:mime  application/x-compressed-iso
!:ext   ciso/cso
>>>>8           ulequad                 x               \b, original size %llu bytes
>>>>16          ulelong                 x               \b, datablock size %u bytes

@


1.1.1.1.2.1
log
@file console was added on branch jym-xensuspend on 2009-05-13 18:51:55 +0000
@
text
@d1 254
@


1.1.1.1.2.2
log
@Sync with HEAD.

Second commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
@
text
@a0 254
#------------------------------------------------------------------------------
# Console game magic
# Toby Deshane <hac@@shoelace.digivill.net>
#    ines:  file(1) magic for Marat's iNES Nintendo Entertainment System
#           ROM dump format

0 string NES\032 iNES ROM dump,
>4 byte  x     %dx16k PRG
>5 byte  x     \b, %dx8k CHR
>6 byte&0x01  =0x1  \b, [Vert.]
>6 byte&0x01  =0x0  \b, [Horiz.]
>6 byte&0x02  =0x2  \b, [SRAM]
>6 byte&0x04  =0x4  \b, [Trainer]
>6 byte&0x04  =0x8  \b, [4-Scr]

#------------------------------------------------------------------------------
# gameboy:  file(1) magic for the Nintendo (Color) Gameboy raw ROM format
#
0x104 belong 0xCEED6666 Gameboy ROM:
>0x134 string >\0 "%.16s"
>0x146 byte 0x03  \b,[SGB]
>0x147 byte 0x00  \b, [ROM ONLY]
>0x147 byte 0x01  \b, [ROM+MBC1]
>0x147 byte 0x02  \b, [ROM+MBC1+RAM]
>0x147 byte 0x03  \b, [ROM+MBC1+RAM+BATT]
>0x147 byte 0x05  \b, [ROM+MBC2]
>0x147 byte 0x06  \b, [ROM+MBC2+BATTERY]
>0x147 byte 0x08  \b, [ROM+RAM]
>0x147 byte 0x09  \b, [ROM+RAM+BATTERY]
>0x147 byte 0x0B  \b, [ROM+MMM01]
>0x147 byte 0x0C  \b, [ROM+MMM01+SRAM]
>0x147 byte 0x0D  \b, [ROM+MMM01+SRAM+BATT]
>0x147 byte 0x0F  \b, [ROM+MBC3+TIMER+BATT]
>0x147 byte 0x10  \b, [ROM+MBC3+TIMER+RAM+BATT]
>0x147 byte 0x11  \b, [ROM+MBC3]
>0x147 byte 0x12  \b, [ROM+MBC3+RAM]
>0x147 byte 0x13  \b, [ROM+MBC3+RAM+BATT]
>0x147 byte 0x19  \b, [ROM+MBC5]
>0x147 byte 0x1A  \b, [ROM+MBC5+RAM]
>0x147 byte 0x1B  \b, [ROM+MBC5+RAM+BATT]
>0x147 byte 0x1C  \b, [ROM+MBC5+RUMBLE]
>0x147 byte 0x1D  \b, [ROM+MBC5+RUMBLE+SRAM]
>0x147 byte 0x1E  \b, [ROM+MBC5+RUMBLE+SRAM+BATT]
>0x147 byte 0x1F  \b, [Pocket Camera]
>0x147 byte 0xFD  \b, [Bandai TAMA5]
>0x147 byte 0xFE  \b, [Hudson HuC-3]
>0x147 byte 0xFF  \b, [Hudson HuC-1]

>0x148 byte 0     \b, ROM: 256Kbit
>0x148 byte 1     \b, ROM: 512Kbit
>0x148 byte 2     \b, ROM: 1Mbit
>0x148 byte 3     \b, ROM: 2Mbit
>0x148 byte 4     \b, ROM: 4Mbit
>0x148 byte 5     \b, ROM: 8Mbit
>0x148 byte 6     \b, ROM: 16Mbit
>0x148 byte 0x52  \b, ROM: 9Mbit
>0x148 byte 0x53  \b, ROM: 10Mbit
>0x148 byte 0x54  \b, ROM: 12Mbit

>0x149 byte 1     \b, RAM: 16Kbit
>0x149 byte 2     \b, RAM: 64Kbit
>0x149 byte 3     \b, RAM: 128Kbit
>0x149 byte 4     \b, RAM: 1Mbit

#>0x14e long  x     \b, CRC: %x

#------------------------------------------------------------------------------
# genesis:  file(1) magic for the Sega MegaDrive/Genesis raw ROM format
#
0x100 string SEGA  Sega MegaDrive/Genesis raw ROM dump
>0x120 string >\0 Name: "%.16s"
>0x110 string >\0 %.16s
>0x1B0 string RA with SRAM

#------------------------------------------------------------------------------
# genesis:  file(1) magic for the Super MegaDrive ROM dump format
#
0x280 string EAGN  Super MagicDrive ROM dump
>0 byte x %dx16k blocks
>2 byte 0 \b, last in series or standalone
>2 byte >0 \b, split ROM
>8 byte 0xAA
>9 byte 0xBB

#------------------------------------------------------------------------------
# genesis:  file(1) alternate magic for the Super MegaDrive ROM dump format
#
0x280 string EAMG  Super MagicDrive ROM dump
>0 byte x %dx16k blocks
>2 byte x \b, last in series or standalone
>8 byte 0xAA
>9 byte 0xBB

#------------------------------------------------------------------------------
# smsgg:  file(1) magic for Sega Master System and Game Gear ROM dumps
#
# Does not detect all images.  Very preliminary guesswork.  Need more data
# on format.
#
# FIXME: need a little more info...;P
#
#0 byte 0xF3
#>1 byte 0xED  Sega Master System/Game Gear ROM dump
#>1 byte 0x31  Sega Master System/Game Gear ROM dump
#>1 byte 0xDB  Sega Master System/Game Gear ROM dump
#>1 byte 0xAF  Sega Master System/Game Gear ROM dump
#>1 byte 0xC3  Sega Master System/Game Gear ROM dump

#------------------------------------------------------------------------------
# dreamcast:  file(1) uncertain magic for the Sega Dreamcast VMU image format
#
0 belong 0x21068028   Sega Dreamcast VMU game image
0 string LCDi         Dream Animator file

#------------------------------------------------------------------------------
# v64: file(1) uncertain magic for the V64 format N64 ROM dumps
#
0 belong 0x37804012    V64 Nintendo 64 ROM dump

# From: "Nelson A. de Oliveira" <naoliv@@gmail.com>
# Nintendo .nds
192	string	\044\377\256Qi\232	Nintendo DS Game ROM Image
# Nintendo .gba
0	string	\056\000\000\352$\377\256Qi	Nintendo Game Boy Advance ROM Image

#------------------------------------------------------------------------------
# msx: file(1) magic for MSX game cartridge dumps
# Too simple - MPi
#0 beshort 0x4142 MSX game cartridge dump 

#------------------------------------------------------------------------------
# Sony Playstation executables (Adam Sjoegren <asjo@@diku.dk>) :
0	string	PS-X\ EXE	Sony Playstation executable
#  Area:
>113	string	x		(%s)

#------------------------------------------------------------------------------
# Microsoft Xbox executables .xbe (Esa Hyytiä <ehyytia@@cc.hut.fi>)
0       string          XBEH            XBE, Microsoft Xbox executable
# probabilistic checks whether signed or not
>0x0004 ulelong =0x0
>>&2    ulelong =0x0
>>>&2   ulelong =0x0  \b, not signed
>0x0004 ulelong >0
>>&2    ulelong >0
>>>&2   ulelong >0    \b, signed
# expect base address of 0x10000
>0x0104               ulelong =0x10000
>>(0x0118-0x0FF60)    ulelong&0x80000007  0x80000007 \b, all regions
>>(0x0118-0x0FF60)    ulelong&0x80000007  !0x80000007
>>>(0x0118-0x0FF60)   ulelong >0           (regions:
>>>>(0x0118-0x0FF60)  ulelong &0x00000001  NA
>>>>(0x0118-0x0FF60)  ulelong &0x00000002  Japan
>>>>(0x0118-0x0FF60)  ulelong &0x00000004  Rest_of_World
>>>>(0x0118-0x0FF60)  ulelong &0x80000000  Manufacturer
>>>(0x0118-0x0FF60)   ulelong >0           \b)

# --------------------------------
# Microsoft Xbox data file formats
0       string          XIP0            XIP, Microsoft Xbox data
0       string          XTF0            XTF, Microsoft Xbox data

# Atari Lynx cartridge dump (EXE/BLL header)
# From: "Stefan A. Haubenthal" <polluks@@web.de>

0	beshort		0x8008		Lynx cartridge,
>2	beshort		x		RAM start $%04x
>6	string		BS93

# Opera file system that is used on the 3DO console
# From: Serge van den Boom <svdb@@stack.nl>
0	string		\x01ZZZZZ\x01	3DO "Opera" file system

# From Gürkan Sengün <gurkan@@linuks.mine.nu>, www.linuks.mine.nu
0	string		GBS		Nintendo Gameboy Music/Audio Data
12	string		GameBoy\ Music\ Module	Nintendo Gameboy Music Module

# Playstations Patch Files from: From: Thomas Klausner <tk@@giga.or.at>
0	string	PPF30			Playstation Patch File version 3.0
>5	byte	0			\b, PPF 1.0 patch
>5	byte	1			\b, PPF 2.0 patch
>5	byte	2			\b, PPF 3.0 patch
>>56	byte	0			\b, Imagetype BIN (any)
>>56	byte	1			\b, Imagetype GI (PrimoDVD)
>>57	byte	0			\b, Blockcheck disabled
>>57	byte	1			\b, Blockcheck enabled
>>58	byte	0			\b, Undo data not available
>>58	byte	1			\b, Undo data available
>6	string	x			\b, description: %s

0	string	PPF20			Playstation Patch File version 2.0
>5	byte	0			\b, PPF 1.0 patch
>5	byte	1			\b, PPF 2.0 patch
>>56	lelong	>0			\b, size of file to patch %d
>6	string	x			\b, description: %s

0	string	PPF10			Playstation Patch File version 1.0
>5	byte	0			\b, Simple Encoding
>6	string	x			\b, description: %s

# From: Daniel Dawson <ddawson@@icehouse.net>
# SNES9x .smv "movie" file format.
0		string		SMV\x1A	SNES9x input recording
>0x4		lelong		x	\b, version %d
# version 4 is latest so far 
>0x4		lelong		<5
>>0x8		ledate		x	\b, recorded at %s
>>0xc		lelong		>0	\b, rerecorded %d times
>>0x10		lelong		x	\b, %d frames long
>>0x14		byte		>0	\b, data for controller(s):
>>>0x14		byte		&0x1	#1
>>>0x14		byte		&0x2	#2
>>>0x14		byte		&0x4	#3
>>>0x14		byte		&0x8	#4
>>>0x14		byte		&0x10	#5
>>0x15		byte		^0x1	\b, begins from snapshot
>>0x15		byte		&0x1	\b, begins from reset
>>0x15		byte		^0x2	\b, NTSC standard
>>0x15		byte		&0x2	\b, PAL standard
>>0x17		byte		&0x1    \b, settings:
# WIP1Timing not used as of version 4
>>>0x4		lelong		<4
>>>>0x17	byte		&0x2	WIP1Timing
>>>0x17		byte		&0x4	Left+Right
>>>0x17		byte		&0x8	VolumeEnvX
>>>0x17		byte		&0x10	FakeMute
>>>0x17		byte		&0x20	SyncSound
# New flag as of version 4
>>>0x4		lelong		>3
>>>>0x17	byte		&0x80	NoCPUShutdown
>>0x4		lelong		<4
>>>0x18		lelong		>0x23
>>>>0x20	leshort		!0
>>>>>0x20	lestring16	x	\b, metadata: "%s"
>>0x4		lelong		>3
>>>0x24		byte		>0	\b, port 1:
>>>>0x24	byte		1	joypad
>>>>0x24	byte		2	mouse
>>>>0x24	byte		3	SuperScope
>>>>0x24	byte		4	Justifier
>>>>0x24	byte		5	multitap
>>>0x24		byte		>0	\b, port 2:
>>>>0x25	byte		1	joypad
>>>>0x25	byte		2	mouse
>>>>0x25	byte		3	SuperScope
>>>>0x25	byte		4	Justifier
>>>>0x25	byte		5	multitap
>>>0x18		lelong		>0x43
>>>>0x40	leshort		!0
>>>>>0x40	lestring16	x	\b, metadata: "%s"
>>0x17		byte		&0x40   \b, ROM:
>>>(0x18.l-26)	lelong		x	CRC32 0x%08x
>>>(0x18.l-23)	string		x	"%s"

@


