console revision 328875
1251652Sgjb 2251652Sgjb#------------------------------------------------------------------------------ 3278985Sgjb# $File: console,v 1.32 2017/08/13 00:21:47 christos Exp $ 4251652Sgjb# Console game magic 5251652Sgjb# Toby Deshane <hac@shoelace.digivill.net> 6251652Sgjb 7251652Sgjb# ines: file(1) magic for Marat's iNES Nintendo Entertainment System ROM dump format 8262761Sgjb# Updated by David Korth <gerbilsoft@gerbilsoft.com> 9262761Sgjb# References: 10262761Sgjb# - http://wiki.nesdev.com/w/index.php/INES 11251652Sgjb# - http://wiki.nesdev.com/w/index.php/NES_2.0 12251652Sgjb 13251652Sgjb# Common header for iNES, NES 2.0, and Wii U iNES. 14251652Sgjb0 name nes-rom-image-ines 15251652Sgjb>7 byte&0x0C =0x8 (NES 2.0) 16251652Sgjb>4 byte x \b: %ux16k PRG 17251652Sgjb>5 byte x \b, %ux8k CHR 18251652Sgjb>6 byte&0x08 =0x8 [4-Scr] 19251652Sgjb>6 byte&0x09 =0x0 [H-mirror] 20251652Sgjb>6 byte&0x09 =0x1 [V-mirror] 21251652Sgjb>6 byte&0x02 =0x2 [SRAM] 22251652Sgjb>6 byte&0x04 =0x4 [Trainer] 23251652Sgjb>7 byte&0x03 =0x2 [PC10] 24251652Sgjb>7 byte&0x03 =0x1 [VS] 25251652Sgjb>>7 byte&0x0C =0x8 26251652Sgjb# NES 2.0: VS PPU 27251652Sgjb>>>13 byte&0x0F =0x0 \b, RP2C03B 28251652Sgjb>>>13 byte&0x0F =0x1 \b, RP2C03G 29251652Sgjb>>>13 byte&0x0F =0x2 \b, RP2C04-0001 30251652Sgjb>>>13 byte&0x0F =0x3 \b, RP2C04-0002 31251652Sgjb>>>13 byte&0x0F =0x4 \b, RP2C04-0003 32251652Sgjb>>>13 byte&0x0F =0x5 \b, RP2C04-0004 33251652Sgjb>>>13 byte&0x0F =0x6 \b, RP2C03B 34251652Sgjb>>>13 byte&0x0F =0x7 \b, RP2C03C 35251652Sgjb>>>13 byte&0x0F =0x8 \b, RP2C05-01 36251652Sgjb>>>13 byte&0x0F =0x9 \b, RP2C05-02 37251652Sgjb>>>13 byte&0x0F =0xA \b, RP2C05-03 38251652Sgjb>>>13 byte&0x0F =0xB \b, RP2C05-04 39283161Sgjb>>>13 byte&0x0F =0xC \b, RP2C05-05 40251652Sgjb# TODO: VS protection hardware? 41283161Sgjb>>7 byte x \b] 42251652Sgjb# NES 2.0-specific flags. 43283161Sgjb>7 byte&0x0C =0x8 44283161Sgjb>>12 byte&0x03 =0x0 [NTSC] 45283161Sgjb>>12 byte&0x03 =0x1 [PAL] 46283161Sgjb>>12 byte&0x02 =0x2 [NTSC+PAL] 47262761Sgjb 48283161Sgjb# Standard iNES ROM header. 49283161Sgjb0 string NES\x1A NES ROM image (iNES) 50283161Sgjb>0 use nes-rom-image-ines 51283161Sgjb 52251652Sgjb# Wii U Virtual Console iNES ROM header. 53283161Sgjb0 belong 0x4E455300 NES ROM image (Wii U Virtual Console) 54283161Sgjb>0 use nes-rom-image-ines 55283161Sgjb 56283161Sgjb#------------------------------------------------------------------------------ 57283161Sgjb# unif: file(1) magic for UNIF-format Nintendo Entertainment System ROM images 58283161Sgjb# Reference: http://wiki.nesdev.com/w/index.php/UNIF 59283161Sgjb# From: David Korth <gerbilsoft@gerbilsoft.com> 60264106Sgjb# 61283161Sgjb# NOTE: The UNIF format uses chunks instead of a fixed header, 62283161Sgjb# so most of the data isn't easily parseable. 63283161Sgjb# 64283161Sgjb0 string UNIF 65283161Sgjb>4 lelong <16 NES ROM image (UNIF v%d format) 66283161Sgjb 67283161Sgjb#------------------------------------------------------------------------------ 68283161Sgjb# fds: file(1) magic for Famciom Disk System disk images 69252846Sgjb# Reference: http://wiki.nesdev.com/w/index.php/Family_Computer_Disk_System#.FDS_format 70283161Sgjb# From: David Korth <gerbilsoft@gerbilsoft.com> 71283161Sgjb# TODO: Check "Disk info block" and get info from that in addition to the optional header. 72283161Sgjb 73283161Sgjb# Disk info block. (block 1) 74283161Sgjb0 name nintendo-fds-disk-info-block 75283161Sgjb>23 byte !1 FMC- 76251652Sgjb>23 byte 1 FSC- 77283161Sgjb>16 string x \b%.3s 78283161Sgjb>15 byte x \b, mfr %02X 79262761Sgjb>20 byte x (Rev.%02u) 80283161Sgjb 81283161Sgjb# Headered version. 82283161Sgjb0 string FDS\x1A 83251652Sgjb>0x11 string *NINTENDO-HVC* Famicom Disk System disk image: 84283161Sgjb>>0x10 use nintendo-fds-disk-info-block 85283161Sgjb>4 byte 1 (%u side) 86283161Sgjb>4 byte !1 (%u sides) 87283161Sgjb 88283161Sgjb# Unheadered version. 89251652Sgjb1 string *NINTENDO-HVC* Famicom Disk System disk image: 90283161Sgjb>0 use nintendo-fds-disk-info-block 91283161Sgjb 92283161Sgjb#------------------------------------------------------------------------------ 93283161Sgjb# tnes: file(1) magic for TNES-format Nintendo Entertainment System ROM images 94251652Sgjb# Used by Nintendo 3DS NES Virtual Console games. 95283161Sgjb# From: David Korth <gerbilsoft@gerbilsoft.com> 96259151Sgjb# 97283161Sgjb0 string TNES NES ROM image (Nintendo 3DS Virtual Console) 98283161Sgjb>4 byte 100 \b: FDS, 99273080Sgjb>>0x2010 use nintendo-fds-disk-info-block 100283161Sgjb>4 byte !100 \b: TNES mapper %u 101283161Sgjb>>5 byte x \b, %ux8k PRG 102283161Sgjb>>6 byte x \b, %ux8k CHR 103283161Sgjb>>7 byte&0x08 =1 [WRAM] 104278985Sgjb>>8 byte&0x09 =1 [H-mirror] 105283161Sgjb>>8 byte&0x09 =2 [V-mirror] 106283161Sgjb>>8 byte&0x02 =3 [VRAM] 107283161Sgjb 108251652Sgjb#------------------------------------------------------------------------------ 109283161Sgjb# gameboy: file(1) magic for the Nintendo (Color) Gameboy raw ROM format 110283161Sgjb# Reference: http://gbdev.gg8.se/wiki/articles/The_Cartridge_Header 111283161Sgjb# 112283161Sgjb0x104 bequad 0xCEED6666CC0D000B Game Boy ROM image 113283161Sgjb>0x143 byte&0x80 0x80 114283161Sgjb>>0x134 string >\0 \b: "%.15s" 115283161Sgjb>0x143 byte&0x80 !0x80 116283161Sgjb>>0x134 string >\0 \b: "%.16s" 117283161Sgjb>0x14c byte x (Rev.%02u) 118283161Sgjb 119283161Sgjb# Machine type. (SGB, CGB, SGB+CGB) 120283161Sgjb>0x14b byte 0x33 121283161Sgjb>>0x146 byte 0x03 122283161Sgjb>>>0x143 byte&0x80 0x80 [SGB+CGB] 123283161Sgjb>>>0x143 byte&0x80 !0x80 [SGB] 124283161Sgjb>>0x146 byte !0x03 125283161Sgjb>>>0x143 byte&0xC0 0x80 [CGB] 126283161Sgjb>>>0x143 byte&0xC0 0xC0 [CGB ONLY] 127283161Sgjb 128283161Sgjb# Mapper. 129283161Sgjb>0x147 byte 0x00 [ROM ONLY] 130283161Sgjb>0x147 byte 0x01 [MBC1] 131283161Sgjb>0x147 byte 0x02 [MBC1+RAM] 132283161Sgjb>0x147 byte 0x03 [MBC1+RAM+BATT] 133283161Sgjb>0x147 byte 0x05 [MBC2] 134283161Sgjb>0x147 byte 0x06 [MBC2+BATTERY] 135283161Sgjb>0x147 byte 0x08 [ROM+RAM] 136251652Sgjb>0x147 byte 0x09 [ROM+RAM+BATTERY] 137251652Sgjb>0x147 byte 0x0B [MMM01] 138283161Sgjb>0x147 byte 0x0C [MMM01+SRAM] 139283161Sgjb>0x147 byte 0x0D [MMM01+SRAM+BATT] 140283161Sgjb>0x147 byte 0x0F [MBC3+TIMER+BATT] 141283161Sgjb>0x147 byte 0x10 [MBC3+TIMER+RAM+BATT] 142264106Sgjb>0x147 byte 0x11 [MBC3] 143283161Sgjb>0x147 byte 0x12 [MBC3+RAM] 144283161Sgjb>0x147 byte 0x13 [MBC3+RAM+BATT] 145283161Sgjb>0x147 byte 0x19 [MBC5] 146283161Sgjb>0x147 byte 0x1A [MBC5+RAM] 147283161Sgjb>0x147 byte 0x1B [MBC5+RAM+BATT] 148283161Sgjb>0x147 byte 0x1C [MBC5+RUMBLE] 149283161Sgjb>0x147 byte 0x1D [MBC5+RUMBLE+SRAM] 150283161Sgjb>0x147 byte 0x1E [MBC5+RUMBLE+SRAM+BATT] 151283161Sgjb>0x147 byte 0xFC [Pocket Camera] 152283161Sgjb>0x147 byte 0xFD [Bandai TAMA5] 153283161Sgjb>0x147 byte 0xFE [Hudson HuC-3] 154262761Sgjb>0x147 byte 0xFF [Hudson HuC-1] 155283161Sgjb 156283161Sgjb# ROM size. 157283161Sgjb>0x148 byte 0 \b, ROM: 256Kbit 158283161Sgjb>0x148 byte 1 \b, ROM: 512Kbit 159283161Sgjb>0x148 byte 2 \b, ROM: 1Mbit 160283161Sgjb>0x148 byte 3 \b, ROM: 2Mbit 161283161Sgjb>0x148 byte 4 \b, ROM: 4Mbit 162283161Sgjb>0x148 byte 5 \b, ROM: 8Mbit 163283161Sgjb>0x148 byte 6 \b, ROM: 16Mbit 164283161Sgjb>0x148 byte 7 \b, ROM: 32Mbit 165283161Sgjb>0x148 byte 0x52 \b, ROM: 9Mbit 166283161Sgjb>0x148 byte 0x53 \b, ROM: 10Mbit 167283161Sgjb>0x148 byte 0x54 \b, ROM: 12Mbit 168283161Sgjb 169283161Sgjb# RAM size. 170283161Sgjb>0x149 byte 1 \b, RAM: 16Kbit 171283161Sgjb>0x149 byte 2 \b, RAM: 64Kbit 172283161Sgjb>0x149 byte 3 \b, RAM: 128Kbit 173283161Sgjb>0x149 byte 4 \b, RAM: 1Mbit 174283161Sgjb>0x149 byte 5 \b, RAM: 512Kbit 175283161Sgjb 176283161Sgjb#------------------------------------------------------------------------------ 177283161Sgjb# genesis: file(1) magic for various Sega Mega Drive / Genesis ROM image and disc formats 178283161Sgjb# Updated by David Korth <gerbilsoft@gerbilsoft.com> 179283161Sgjb# References: 180283161Sgjb# - http://www.retrodev.com/segacd.html 181283161Sgjb# - http://devster.monkeeh.com/sega/32xguide1.txt 182283161Sgjb# 183283161Sgjb 184283161Sgjb# Common Sega Mega Drive header format. 185283161Sgjb# FIXME: Name fields are 48 bytes, but have spaces for padding instead of 00s. 186283161Sgjb0 name sega-mega-drive-header 187283161Sgjb# ROM title. (Use domestic if present; if not, use international.) 188283161Sgjb>0x120 byte >0x20 189283161Sgjb>>0x120 string >\0 \b: "%.16s" 190283161Sgjb>0x120 byte <0x21 191264106Sgjb>>0x150 string >\0 \b: "%.16s" 192264106Sgjb# Other information. 193264106Sgjb>0x180 string >\0 (%.14s 194283161Sgjb>>0x110 string >\0 \b, %.16s 195283161Sgjb>0x180 byte 0 196283161Sgjb>>0x110 string >\0 (%.16s 197283161Sgjb>0 byte x \b) 198252846Sgjb 199283161Sgjb# TODO: Check for 32X CD? 200283161Sgjb# Sega Mega CD disc images: 2048-byte sectors. 201283161Sgjb0 string SEGADISCSYSTEM\ \ Sega Mega CD disc image 202283161Sgjb>0 use sega-mega-drive-header 203283161Sgjb>0 byte x \b, 2048-byte sectors 204283161Sgjb0 string SEGABOOTDISC\ \ \ \ Sega Mega CD disc image 205283161Sgjb>0 use sega-mega-drive-header 206283161Sgjb>0 byte x \b, 2048-byte sectors 207283161Sgjb# Sega Mega CD disc images: 2352-byte sectors. 208283161Sgjb0x10 string SEGADISCSYSTEM\ \ Sega Mega CD disc image 209283161Sgjb>0x10 use sega-mega-drive-header 210283161Sgjb>0 byte x \b, 2352-byte sectors 211283161Sgjb0x10 string SEGABOOTDISC\ \ \ \ Sega Mega CD disc image 212252846Sgjb>0x10 use sega-mega-drive-header 213283161Sgjb>0 byte x \b, 2352-byte sectors 214283161Sgjb 215251652Sgjb# Sega Mega Drive, 32X, Pico, and Mega CD Boot ROM images. 216283161Sgjb0x100 string SEGA 217283161Sgjb>0x3C0 bequad 0x4D41525320434845 Sega 32X ROM image 218283161Sgjb>>0 use sega-mega-drive-header 219283161Sgjb>0x3C0 bequad !0x4D41525320434845 220251652Sgjb>>0x105 belong 0x5049434F Sega Pico ROM image 221283161Sgjb>>>0 use sega-mega-drive-header 222283161Sgjb>>0x105 belong !0x5049434F 223283161Sgjb>>>0x180 beshort 0x4252 Sega Mega CD Boot ROM image 224283161Sgjb>>>0x180 beshort !0x4252 Sega Mega Drive / Genesis ROM image 225283161Sgjb>>>0 use sega-mega-drive-header 226283161Sgjb 227283161Sgjb#------------------------------------------------------------------------------ 228283161Sgjb# genesis: file(1) magic for the Super MegaDrive ROM dump format 229283161Sgjb# 230251652Sgjb 231283161Sgjb# NOTE: Due to interleaving, we can't display anything 232283161Sgjb# other than the copier header information. 233283161Sgjb0 name sega-genesis-smd-header 234283161Sgjb>0 byte x %dx16k blocks 235283161Sgjb>2 byte 0 \b, last in series or standalone 236283161Sgjb>2 byte >0 \b, split ROM 237283161Sgjb 238283161Sgjb# "Sega Genesis" header. 239251652Sgjb0x280 string EAGN 240283161Sgjb>8 beshort 0xAABB Sega Mega Drive / Genesis ROM image (SMD format): 241283161Sgjb>>0 use sega-genesis-smd-header 242251652Sgjb 243283161Sgjb# "Sega Mega Drive" header. 244283161Sgjb0x280 string EAMG 245283161Sgjb>8 beshort 0xAABB Sega Mega Drive / Genesis ROM image (SMD format): 246283161Sgjb>>0 use sega-genesis-smd-header 247283161Sgjb 248283161Sgjb#------------------------------------------------------------------------------ 249283161Sgjb# smsgg: file(1) magic for Sega Master System and Game Gear ROM images 250283161Sgjb# Detects all Game Gear and export Sega Master System ROM images, 251283161Sgjb# and some Japanese Sega Master System ROM images. 252283161Sgjb# From: David Korth <gerbilsoft@gerbilsoft.com> 253251652Sgjb# Reference: http://www.smspower.org/Development/ROMHeader 254283161Sgjb# 255283161Sgjb 256283161Sgjb# General SMS header rule. 257283161Sgjb# The SMS boot ROM checks the header at three locations. 258283161Sgjb0 name sega-master-system-rom-header 259283161Sgjb# Machine type. 260283161Sgjb>0x0F byte&0xF0 0x30 Sega Master System 261283161Sgjb>0x0F byte&0xF0 0x40 Sega Master System 262283161Sgjb>0x0F byte&0xF0 0x50 Sega Game Gear 263283161Sgjb>0x0F byte&0xF0 0x60 Sega Game Gear 264251652Sgjb>0x0F byte&0xF0 0x70 Sega Game Gear 265283161Sgjb>0x0F byte&0xF0 <0x30 Sega Master System / Game Gear 266283161Sgjb>0x0F byte&0xF0 >0x70 Sega Master System / Game Gear 267283161Sgjb>0 byte x ROM image: 268283161Sgjb# Product code. 269283161Sgjb>0x0E byte&0xF0 0x10 1 270283161Sgjb>0x0E byte&0xF0 0x20 2 271283161Sgjb>0x0E byte&0xF0 0x30 3 272283161Sgjb>0x0E byte&0xF0 0x40 4 273283161Sgjb>0x0E byte&0xF0 0x50 5 274283161Sgjb>0x0E byte&0xF0 0x60 6 275283161Sgjb>0x0E byte&0xF0 0x70 7 276283161Sgjb>0x0E byte&0xF0 0x80 8 277283161Sgjb>0x0E byte&0xF0 0x90 9 278293859Sgjb>0x0E byte&0xF0 0xA0 10 279283161Sgjb>0x0E byte&0xF0 0xB0 11 280283161Sgjb>0x0E byte&0xF0 0xC0 12 281283161Sgjb>0x0E byte&0xF0 0xD0 13 282251652Sgjb>0x0E byte&0xF0 0xE0 14 283283161Sgjb>0x0E byte&0xF0 0xF0 15 284283161Sgjb# If the product code is 5 digits, we'll need to backspace here. 285283161Sgjb>0x0E byte&0xF0 !0 286283161Sgjb>>0x0C leshort x \b%04x 287283161Sgjb>0x0E byte&0xF0 0 288283161Sgjb>>0x0C leshort x %04x 289260071Sgjb# Revision. 290283161Sgjb>0x0E byte&0x0F x (Rev.%02d) 291283161Sgjb# ROM size. (Used for the boot ROM checksum routine.) 292283161Sgjb>0x0F byte&0x0F 0x0A (8 KB) 293283161Sgjb>0x0F byte&0x0F 0x0B (16 KB) 294283161Sgjb>0x0F byte&0x0F 0x0C (32 KB) 295283161Sgjb>0x0F byte&0x0F 0x0D (48 KB) 296283161Sgjb>0x0F byte&0x0F 0x0E (64 KB) 297283161Sgjb>0x0F byte&0x0F 0x0F (128 KB) 298283161Sgjb>0x0F byte&0x0F 0x00 (256 KB) 299283161Sgjb>0x0F byte&0x0F 0x01 (512 KB) 300283161Sgjb>0x0F byte&0x0F 0x02 (1 MB) 301283161Sgjb 302283161Sgjb# SMS/GG header locations. 303283161Sgjb0x7FF0 string TMR\ SEGA 304283161Sgjb>0x7FF0 use sega-master-system-rom-header 305264106Sgjb0x3FF0 string TMR\ SEGA 306283161Sgjb>0x3FF0 use sega-master-system-rom-header 307283161Sgjb0x1FF0 string TMR\ SEGA 308264106Sgjb>0x1FF0 use sega-master-system-rom-header 309283161Sgjb 310283161Sgjb#------------------------------------------------------------------------------ 311257776Sgjb# saturn: file(1) magic for the Sega Saturn disc image format. 312283161Sgjb# From: David Korth <gerbilsoft@gerbilsoft.com> 313283161Sgjb# 314283161Sgjb 315288435Sgjb# Common Sega Saturn disc header format. 316288435Sgjb# NOTE: Title is 112 bytes, but we're only showing 32 due to space padding. 317288435Sgjb# TODO: Release date, device information, region code, others? 318288435Sgjb0 name sega-saturn-disc-header 319288435Sgjb>0x60 string >\0 \b: "%.32s" 320288435Sgjb>0x20 string >\0 (%.10s 321288435Sgjb>>0x2A string >\0 \b, %.6s) 322288435Sgjb>>0x2A byte 0 \b) 323288435Sgjb 324288435Sgjb# 2048-byte sector version. 325288435Sgjb0 string SEGA\ SEGASATURN\ Sega Saturn disc image 326288435Sgjb>0 use sega-saturn-disc-header 327283161Sgjb>0 byte x (2048-byte sectors) 328283161Sgjb# 2352-byte sector version. 329283161Sgjb0x10 string SEGA\ SEGASATURN\ Sega Saturn disc image 330283161Sgjb>0x10 use sega-saturn-disc-header 331283161Sgjb>0 byte x (2352-byte sectors) 332283161Sgjb 333283161Sgjb#------------------------------------------------------------------------------ 334283161Sgjb# dreamcast: file(1) magic for the Sega Dreamcast disc image format. 335283161Sgjb# From: David Korth <gerbilsoft@gerbilsoft.com> 336283161Sgjb# Reference: http://mc.pp.se/dc/ip0000.bin.html 337283161Sgjb# 338283161Sgjb 339283161Sgjb# Common Sega Dreamcast disc header format. 340283161Sgjb# NOTE: Title is 128 bytes, but we're only showing 32 due to space padding. 341283161Sgjb# TODO: Release date, device information, region code, others? 342283161Sgjb0 name sega-dreamcast-disc-header 343251652Sgjb>0x80 string >\0 \b: "%.32s" 344283161Sgjb>0x40 string >\0 (%.10s 345283161Sgjb>>0x4A string >\0 \b, %.6s) 346283161Sgjb>>0x4A byte 0 \b) 347283161Sgjb 348283161Sgjb# 2048-byte sector version. 349283161Sgjb0 string SEGA\ SEGAKATANA\ Sega Dreamcast disc image 350283161Sgjb>0 use sega-dreamcast-disc-header 351283161Sgjb>0 byte x (2048-byte sectors) 352283161Sgjb# 2352-byte sector version. 353283161Sgjb0x10 string SEGA\ SEGAKATANA\ Sega Dreamcast disc image 354283161Sgjb>0x10 use sega-dreamcast-disc-header 355283161Sgjb>0 byte x (2352-byte sectors) 356283161Sgjb 357283161Sgjb#------------------------------------------------------------------------------ 358283161Sgjb# dreamcast: file(1) uncertain magic for the Sega Dreamcast VMU image format 359283161Sgjb# 360283161Sgjb0 belong 0x21068028 Sega Dreamcast VMU game image 361283161Sgjb0 string LCDi Dream Animator file 362283161Sgjb 363283161Sgjb#------------------------------------------------------------------------------ 364283161Sgjb# z64: file(1) magic for the Z64 format N64 ROM dumps 365283161Sgjb# Reference: http://forum.pj64-emu.com/showthread.php?t=2239 366289555Sgjb# From: David Korth <gerbilsoft@gerbilsoft.com> 367289555Sgjb# 368283161Sgjb0 bequad 0x803712400000000F Nintendo 64 ROM image 369283161Sgjb>0x20 string >\0 \b: "%.20s" 370252101Sgjb>0x3B string x (%.4s 371283161Sgjb>0x3F byte x \b, Rev.%02u) 372283161Sgjb 373283161Sgjb#------------------------------------------------------------------------------ 374283161Sgjb# v64: file(1) magic for the V64 format N64 ROM dumps 375283161Sgjb# Same as z64 format, but with 16-bit byteswapping. 376283161Sgjb# 377283161Sgjb0 bequad 0x3780401200000F00 Nintendo 64 ROM image (V64) 378283161Sgjb 379283161Sgjb#------------------------------------------------------------------------------ 380283161Sgjb# n64-swap2: file(1) magic for the swap2 format N64 ROM dumps 381283161Sgjb# Same as z64 format, but with swapped 16-bit words. 382283161Sgjb# 383283161Sgjb0 bequad 0x12408037000F0000 Nintendo 64 ROM image (wordswapped) 384283161Sgjb 385283161Sgjb#------------------------------------------------------------------------------ 386283161Sgjb# n64-le32: file(1) magic for the 32-bit byteswapped format N64 ROM dumps 387283161Sgjb# Same as z64 format, but with 32-bit byteswapping. 388283161Sgjb# 389283161Sgjb0 bequad 0x401237800F000000 Nintendo 64 ROM image (32-bit byteswapped) 390283161Sgjb 391283161Sgjb#------------------------------------------------------------------------------ 392283161Sgjb# gba: file(1) magic for the Nintendo Game Boy Advance raw ROM format 393283161Sgjb# Reference: http://problemkaputt.de/gbatek.htm#gbacartridgeheader 394283161Sgjb# 395283161Sgjb# Original version from: "Nelson A. de Oliveira" <naoliv@gmail.com> 396283161Sgjb# Updated version from: David Korth <gerbilsoft@gerbilsoft.com> 397283161Sgjb# 398283161Sgjb4 bequad 0x24FFAE51699AA221 Game Boy Advance ROM image 399283161Sgjb>0xA0 string >\0 \b: "%.12s" 400283161Sgjb>0xAC string x (%.6s 401283161Sgjb>0xBC byte x \b, Rev.%02u) 402283161Sgjb 403283161Sgjb#------------------------------------------------------------------------------ 404283161Sgjb# nds: file(1) magic for the Nintendo DS(i) raw ROM format 405283161Sgjb# Reference: http://problemkaputt.de/gbatek.htm#dscartridgeheader 406283161Sgjb# 407283161Sgjb# Original version from: "Nelson A. de Oliveira" <naoliv@gmail.com> 408# Updated version from: David Korth <gerbilsoft@gerbilsoft.com> 409# 4100xC0 bequad 0x24FFAE51699AA221 Nintendo DS ROM image 411>0x00 string >\0 \b: "%.12s" 412>0x0C string x (%.6s 413>0x1E byte x \b, Rev.%02u) 414>0x12 byte 2 (DSi enhanced) 415>0x12 byte 3 (DSi only) 416# Secure Area check. 417>0x20 lelong <0x4000 (homebrew) 418>0x20 lelong >0x3FFF 419>>0x4000 lequad 0x0000000000000000 (multiboot) 420>>0x4000 lequad !0x0000000000000000 421>>>0x4000 lequad 0xE7FFDEFFE7FFDEFF (decrypted) 422>>>0x4000 lequad !0xE7FFDEFFE7FFDEFF 423>>>>0x1000 lequad 0x0000000000000000 (encrypted) 424>>>>0x1000 lequad !0x0000000000000000 (mask ROM) 425 426#------------------------------------------------------------------------------ 427# nds_passme: file(1) magic for Nintendo DS ROM images for GBA cartridge boot. 428# This is also used for loading .nds files using the MSET exploit on 3DS. 429# Reference: https://github.com/devkitPro/ndstool/blob/master/source/ndscreate.cpp 4300xC0 bequad 0xC8604FE201708FE2 Nintendo DS Slot-2 ROM image (PassMe) 431 432#------------------------------------------------------------------------------ 433# ngp: file(1) magic for the Neo Geo Pocket (Color) raw ROM format. 434# From: David Korth <gerbilsoft@gerbilsoft.com> 435# References: 436# - https://neogpc.googlecode.com/svn-history/r10/trunk/src/core/neogpc.cpp 437# - http://www.devrs.com/ngp/files/ngpctech.txt 438# 4390x0A string BY\ SNK\ CORPORATION Neo Geo Pocket 440>0x23 byte 0x10 Color 441>0 byte x ROM image 442>0x24 string >\0 \b: "%.12s" 443>0x1F byte 0xFF (debug mode enabled) 444 445#------------------------------------------------------------------------------ 446# msx: file(1) magic for MSX game cartridge dumps 447# Too simple - MPi 448#0 beshort 0x4142 MSX game cartridge dump 449 450#------------------------------------------------------------------------------ 451# Sony Playstation executables (Adam Sjoegren <asjo@diku.dk>) : 4520 string PS-X\ EXE Sony Playstation executable 453>16 lelong x PC=0x%08x, 454>20 lelong !0 GP=0x%08x, 455>24 lelong !0 .text=[0x%08x, 456>>28 lelong x \b0x%x], 457>32 lelong !0 .data=[0x%08x, 458>>36 lelong x \b0x%x], 459>40 lelong !0 .bss=[0x%08x, 460>>44 lelong x \b0x%x], 461>48 lelong !0 Stack=0x%08x, 462>48 lelong =0 No Stack!, 463>52 lelong !0 StackSize=0x%x, 464#>76 string >\0 (%s) 465# Area: 466>113 string x (%s) 467 468# CPE executables 4690 string CPE CPE executable 470>3 byte x (version %d) 471 472#------------------------------------------------------------------------------ 473# Microsoft Xbox executables .xbe (Esa Hyytia <ehyytia@cc.hut.fi>) 4740 string XBEH XBE, Microsoft Xbox executable 475# probabilistic checks whether signed or not 476>0x0004 ulelong =0x0 477>>&2 ulelong =0x0 478>>>&2 ulelong =0x0 \b, not signed 479>0x0004 ulelong >0 480>>&2 ulelong >0 481>>>&2 ulelong >0 \b, signed 482# expect base address of 0x10000 483>0x0104 ulelong =0x10000 484>>(0x0118-0x0FF60) ulelong&0x80000007 0x80000007 \b, all regions 485>>(0x0118-0x0FF60) ulelong&0x80000007 !0x80000007 486>>>(0x0118-0x0FF60) ulelong >0 (regions: 487>>>>(0x0118-0x0FF60) ulelong &0x00000001 NA 488>>>>(0x0118-0x0FF60) ulelong &0x00000002 Japan 489>>>>(0x0118-0x0FF60) ulelong &0x00000004 Rest_of_World 490>>>>(0x0118-0x0FF60) ulelong &0x80000000 Manufacturer 491>>>(0x0118-0x0FF60) ulelong >0 \b) 492 493# -------------------------------- 494# Microsoft Xbox data file formats 4950 string XIP0 XIP, Microsoft Xbox data 4960 string XTF0 XTF, Microsoft Xbox data 497 498# Atari Lynx cartridge dump (EXE/BLL header) 499# From: "Stefan A. Haubenthal" <polluks@web.de> 500 501# Double-check that the image type matches too, 0x8008 conflicts with 502# 8 character OMF-86 object file headers. 5030 beshort 0x8008 504>6 string BS93 Lynx homebrew cartridge 505>>2 beshort x \b, RAM start $%04x 506>6 string LYNX Lynx cartridge 507>>2 beshort x \b, RAM start $%04x 508 509# Opera file system that is used on the 3DO console 510# From: Serge van den Boom <svdb@stack.nl> 5110 string \x01ZZZZZ\x01 3DO "Opera" file system 512 513# From: Gurkan Sengun <gurkan@linuks.mine.nu>, www.linuks.mine.nu 514# From: David Pflug <david@pflug.email> 515# is the offset 12 or the offset 16 correct? 516# GBS (Game Boy Sound) magic 517# ftp://ftp.modland.com/pub/documents/format_documentation/\ 518# Gameboy%20Sound%20System%20(.gbs).txt 5190 string GBS Nintendo Gameboy Music/Audio Data 520#12 string GameBoy\ Music\ Module Nintendo Gameboy Music Module 521>16 string >\0 ("%s" by 522>48 string >\0 %s, copyright 523>80 string >\0 %s), 524>3 byte x version %d, 525>4 byte x %d tracks 526 527# IPS Patch Files from: From: Thomas Klausner <tk@giga.or.at> 528# see http://zerosoft.zophar.net/ips.php 5290 string PATCH IPS patch file 530 531# Playstations Patch Files from: From: Thomas Klausner <tk@giga.or.at> 5320 string PPF30 Playstation Patch File version 3.0 533>5 byte 0 \b, PPF 1.0 patch 534>5 byte 1 \b, PPF 2.0 patch 535>5 byte 2 \b, PPF 3.0 patch 536>>56 byte 0 \b, Imagetype BIN (any) 537>>56 byte 1 \b, Imagetype GI (PrimoDVD) 538>>57 byte 0 \b, Blockcheck disabled 539>>57 byte 1 \b, Blockcheck enabled 540>>58 byte 0 \b, Undo data not available 541>>58 byte 1 \b, Undo data available 542>6 string x \b, description: %s 543 5440 string PPF20 Playstation Patch File version 2.0 545>5 byte 0 \b, PPF 1.0 patch 546>5 byte 1 \b, PPF 2.0 patch 547>>56 lelong >0 \b, size of file to patch %d 548>6 string x \b, description: %s 549 5500 string PPF10 Playstation Patch File version 1.0 551>5 byte 0 \b, Simple Encoding 552>6 string x \b, description: %s 553 554# From: Daniel Dawson <ddawson@icehouse.net> 555# SNES9x .smv "movie" file format. 5560 string SMV\x1A SNES9x input recording 557>0x4 lelong x \b, version %d 558# version 4 is latest so far 559>0x4 lelong <5 560>>0x8 ledate x \b, recorded at %s 561>>0xc lelong >0 \b, rerecorded %d times 562>>0x10 lelong x \b, %d frames long 563>>0x14 byte >0 \b, data for controller(s): 564>>>0x14 byte &0x1 #1 565>>>0x14 byte &0x2 #2 566>>>0x14 byte &0x4 #3 567>>>0x14 byte &0x8 #4 568>>>0x14 byte &0x10 #5 569>>0x15 byte ^0x1 \b, begins from snapshot 570>>0x15 byte &0x1 \b, begins from reset 571>>0x15 byte ^0x2 \b, NTSC standard 572>>0x15 byte &0x2 \b, PAL standard 573>>0x17 byte &0x1 \b, settings: 574# WIP1Timing not used as of version 4 575>>>0x4 lelong <4 576>>>>0x17 byte &0x2 WIP1Timing 577>>>0x17 byte &0x4 Left+Right 578>>>0x17 byte &0x8 VolumeEnvX 579>>>0x17 byte &0x10 FakeMute 580>>>0x17 byte &0x20 SyncSound 581# New flag as of version 4 582>>>0x4 lelong >3 583>>>>0x17 byte &0x80 NoCPUShutdown 584>>0x4 lelong <4 585>>>0x18 lelong >0x23 586>>>>0x20 leshort !0 587>>>>>0x20 lestring16 x \b, metadata: "%s" 588>>0x4 lelong >3 589>>>0x24 byte >0 \b, port 1: 590>>>>0x24 byte 1 joypad 591>>>>0x24 byte 2 mouse 592>>>>0x24 byte 3 SuperScope 593>>>>0x24 byte 4 Justifier 594>>>>0x24 byte 5 multitap 595>>>0x24 byte >0 \b, port 2: 596>>>>0x25 byte 1 joypad 597>>>>0x25 byte 2 mouse 598>>>>0x25 byte 3 SuperScope 599>>>>0x25 byte 4 Justifier 600>>>>0x25 byte 5 multitap 601>>>0x18 lelong >0x43 602>>>>0x40 leshort !0 603>>>>>0x40 lestring16 x \b, metadata: "%s" 604>>0x17 byte &0x40 \b, ROM: 605>>>(0x18.l-26) lelong x CRC32 0x%08x 606>>>(0x18.l-23) string x "%s" 607 608# Type: scummVM savegame files 609# From: Sven Hartge <debian@ds9.argh.org> 6100 string SCVM ScummVM savegame 611>12 string >\0 "%s" 612 613#------------------------------------------------------------------------------ 614# Nintendo GameCube / Wii file formats. 615# 616 617# Type: Nintendo GameCube/Wii common disc header data. 618# From: David Korth <gerbilsoft@gerbilsoft.com> 619# Reference: http://wiibrew.org/wiki/Wii_Disc 6200 name nintendo-gcn-disc-common 621>0x20 string x "%.64s" 622>0x00 string x (%.6s 623>0x06 byte >0 624>>0x06 byte 1 \b, Disc 2 625>>0x06 byte 2 \b, Disc 3 626>>0x06 byte 3 \b, Disc 4 627>0x07 byte x \b, Rev.%02u) 628 629# Type: Nintendo GameCube disc image 630# From: David Korth <gerbilsoft@gerbilsoft.com> 631# Reference: http://wiibrew.org/wiki/Wii_Disc 6320x1C belong 0xC2339F3D Nintendo GameCube disc image: 633>0 use nintendo-gcn-disc-common 634 635# Type: Nintendo GameCube embedded disc image 636# Commonly found on demo discs. 637# From: David Korth <gerbilsoft@gerbilsoft.com> 638# Reference: http://hitmen.c02.at/files/yagcd/yagcd/index.html#idx14.8 6390 belong 0xAE0F38A2 640>0x0C belong 0x00100000 641>>(8.L+0x1C) belong 0xC2339F3D Nintendo GameCube embedded disc image: 642>>>(8.L) use nintendo-gcn-disc-common 643 644# Type: Nintendo Wii disc image 645# From: David Korth <gerbilsoft@gerbilsoft.com> 646# Reference: http://wiibrew.org/wiki/Wii_Disc 6470x18 belong 0x5D1C9EA3 Nintendo Wii disc image: 648>0 use nintendo-gcn-disc-common 649 650# Type: Nintendo Wii disc image (WBFS format) 651# From: David Korth <gerbilsoft@gerbilsoft.com> 652# Reference: http://wiibrew.org/wiki/Wii_Disc 6530 string WBFS 654>0x218 belong 0x5D1C9EA3 Nintendo Wii disc image (WBFS format): 655>>0x200 use nintendo-gcn-disc-common 656 657# Type: Nintendo GameCube/Wii disc image (CISO format) 658# NOTE: This is NOT the same as Compact ISO or PSP CISO, 659# though it has the same magic number. 6600 string CISO 661# Other fields are used to determine what type of CISO this is: 662# - 0x04 == 0x00200000: GameCube/Wii CISO (block_size) 663# - 0x10 == 0x00000800: PSP CISO (ISO-9660 sector size) 664# - None of the above: Compact ISO. 665>4 lelong 0x200000 666>>8 byte 1 667>>>0x801C belong 0xC2339F3D Nintendo GameCube disc image (CISO format): 668>>>>0x8000 use nintendo-gcn-disc-common 669>>>0x8018 belong 0x5D1C9EA3 Nintendo Wii disc image (CISO format): 670>>>>0x8000 use nintendo-gcn-disc-common 671 672# Type: Nintendo GameCube/Wii disc image (GCZ format) 673# Due to zlib compression, we can't get the actual disc information. 6740 lelong 0xB10BC001 675>4 lelong 0 Nintendo GameCube disc image (GCZ format) 676>4 lelong 1 Nintendo Wii disc image (GCZ format) 677>4 lelong >1 Nintendo GameCube/Wii disc image (GCZ format) 678 679# Type: Nintendo GameCube/Wii disc image (WDF format) 6800 string WII\001DISC 681>8 belong 1 682# WDFv1 683>>0x54 belong 0xC2339F3D Nintendo GameCube disc image (WDFv1 format): 684>>>0x38 use nintendo-gcn-disc-common 685>>0x58 belong 0x5D1C9EA3 Nintendo Wii disc image (WDFv1 format): 686>>>0x38 use nintendo-gcn-disc-common 687>8 belong 2 688# WDFv2 689>>(12.L+0x1C) belong 0xC2339F3D Nintendo GameCube disc image (WDFv2 format): 690>>>(12.L) use nintendo-gcn-disc-common 691>>(12.L+0x18) belong 0x5D1C9EA3 Nintendo Wii disc image (WDFv2 format): 692>>>(12.L) use nintendo-gcn-disc-common 693 694# Type: Nintendo GameCube/Wii disc image (WIA format) 6950 string WIA\001 Nintendo 696>0x48 belong 0 GameCube/Wii 697>0x48 belong 1 GameCube 698>0x48 belong 2 Wii 699>0x48 belong >2 GameCube/Wii 700>0x48 belong x disc image (WIA format): 701>>0x58 use nintendo-gcn-disc-common 702 703#------------------------------------------------------------------------------ 704# Nintendo 3DS file formats. 705# 706 707# Type: Nintendo 3DS "NCSD" image. (game cards and eMMC) 708# From: David Korth <gerbilsoft@gerbilsoft.com> 709# Reference: https://www.3dbrew.org/wiki/NCSD 7100x100 string NCSD 711>0x118 lequad 0 Nintendo 3DS Game Card image 712# NCCH header for partition 0. (game data) 713>>0x1150 string >\0 \b: "%.16s" 714>>0x312 byte x (Rev.%02u) 715>>0x118C byte 2 (New3DS only) 716>>0x18D byte 0 (inner device) 717>>0x18D byte 1 (Card1) 718>>0x18D byte 2 (Card2) 719>>0x18D byte 3 (extended device) 720>0x118 bequad 0x0102020202000000 Nintendo 3DS eMMC dump (Old3DS) 721>0x118 bequad 0x0102020203000000 Nintendo 3DS eMMC dump (New3DS) 722 723# Nintendo 3DS version code. 724# Reference: https://www.3dbrew.org/wiki/Titles 725# Format: leshort containing three fields: 726# - 6-bit: Major 727# - 6-bit: Minor 728# - 4-bit: Revision 729# NOTE: Only supporting major/minor versions from 0-15 right now. 730# NOTE: Should be prefixed with "v". 7310 name nintendo-3ds-version-code 732# Raw version. 733>0 leshort x \b%u, 734# Major version. 735>0 leshort&0xFC00 0x0000 0 736>0 leshort&0xFC00 0x0400 1 737>0 leshort&0xFC00 0x0800 2 738>0 leshort&0xFC00 0x0C00 3 739>0 leshort&0xFC00 0x1000 4 740>0 leshort&0xFC00 0x1400 5 741>0 leshort&0xFC00 0x1800 6 742>0 leshort&0xFC00 0x1C00 7 743>0 leshort&0xFC00 0x2000 8 744>0 leshort&0xFC00 0x2400 9 745>0 leshort&0xFC00 0x2800 10 746>0 leshort&0xFC00 0x2C00 11 747>0 leshort&0xFC00 0x3000 12 748>0 leshort&0xFC00 0x3400 13 749>0 leshort&0xFC00 0x3800 14 750>0 leshort&0xFC00 0x3C00 15 751# Minor version. 752>0 leshort&0x03F0 0x0000 \b.0 753>0 leshort&0x03F0 0x0010 \b.1 754>0 leshort&0x03F0 0x0020 \b.2 755>0 leshort&0x03F0 0x0030 \b.3 756>0 leshort&0x03F0 0x0040 \b.4 757>0 leshort&0x03F0 0x0050 \b.5 758>0 leshort&0x03F0 0x0060 \b.6 759>0 leshort&0x03F0 0x0070 \b.7 760>0 leshort&0x03F0 0x0080 \b.8 761>0 leshort&0x03F0 0x0090 \b.9 762>0 leshort&0x03F0 0x00A0 \b.10 763>0 leshort&0x03F0 0x00B0 \b.11 764>0 leshort&0x03F0 0x00C0 \b.12 765>0 leshort&0x03F0 0x00D0 \b.13 766>0 leshort&0x03F0 0x00E0 \b.14 767>0 leshort&0x03F0 0x00F0 \b.15 768# Revision. 769>0 leshort&0x000F x \b.%u 770 771# Type: Nintendo 3DS "NCCH" container. 772# https://www.3dbrew.org/wiki/NCCH 7730x100 string NCCH Nintendo 3DS 774>0x18D byte&2 0 File Archive (CFA) 775>0x18D byte&2 2 Executable Image (CXI) 776>0x150 string >\0 \b: "%.16s" 777>0x18D byte 0x05 778>>0x10E leshort x (Old3DS System Update v 779>>0x10E use nintendo-3ds-version-code 780>>0x10E leshort x \b) 781>0x18D byte 0x15 782>>0x10E leshort x (New3DS System Update v 783>>0x10E use nintendo-3ds-version-code 784>>0x10E leshort x \b) 785>0x18D byte !0x05 786>>0x18D byte !0x15 787>>>0x112 byte x (v 788>>>0x112 use nintendo-3ds-version-code 789>>>0x112 byte x \b) 790>0x18C byte 2 (New3DS only) 791 792# Type: Nintendo 3DS "SMDH" file. (application description) 793# From: David Korth <gerbilsoft@gerbilsoft.com> 794# Reference: https://3dbrew.org/wiki/SMDH 7950 string SMDH Nintendo 3DS SMDH file 796>0x208 leshort !0 797>>0x208 lestring16 x \b: "%.128s" 798>>0x388 leshort !0 799>>>0x388 lestring16 x by %.128s 800>0x208 leshort 0 801>>0x008 leshort !0 802>>>0x008 lestring16 x \b: "%.128s" 803>>>0x188 leshort !0 804>>>>0x188 lestring16 x by %.128s 805 806# Type: Nintendo 3DS Homebrew Application. 807# From: David Korth <gerbilsoft@gerbilsoft.com> 808# Reference: https://3dbrew.org/wiki/3DSX_Format 8090 string 3DSX Nintendo 3DS Homebrew Application (3DSX) 810 811#------------------------------------------------------------------------------ 812# a7800: file(1) magic for the Atari 7800 raw ROM format. 813# From: David Korth <gerbilsoft@gerbilsoft.com> 814# Reference: https://sites.google.com/site/atari7800wiki/a78-header 815 8160 byte >0 817>0 byte <3 818>>1 string ATARI7800 Atari 7800 ROM image 819>>>0x11 string >\0 \b: "%.32s" 820# Display type. 821>>>0x39 byte 0 (NTSC) 822>>>0x39 byte 1 (PAL) 823>>>0x36 byte&1 1 (POKEY) 824 825#------------------------------------------------------------------------------ 826# vectrex: file(1) magic for the GCE Vectrex raw ROM format. 827# From: David Korth <gerbilsoft@gerbilsoft.com> 828# Reference: http://www.playvectrex.com/designit/chrissalo/hello1.htm 829# 830# NOTE: Title is terminated with 0x80, not 0. 831# The header is terminated with a 0, so that will 832# terminate the title as well. 833# 8340 string g\ GCE Vectrex ROM image 835>0x11 string >\0 \b: "%.16s" 836 837#------------------------------------------------------------------------------ 838# amiibo: file(1) magic for Nintendo amiibo NFC dumps. 839# From: David Korth <gerbilsoft@gerbilsoft.com> 840# Reference: https://www.3dbrew.org/wiki/Amiibo 8410x00 byte 0x04 842>0x0A beshort 0x0FE0 843>>0x0C belong 0xF110FFEE 844>>>0x208 beshort 0x0100 845>>>>0x020A byte 0x0F 846>>>>>0x020C bequad 0x000000045F000000 847>>>>>>0x5B byte 0x02 848>>>>>>>0x54 belong x Nintendo amiibo NFC dump - amiibo ID: %08X- 849>>>>>>>0x58 belong x \b%08X 850