2 #------------------------------------------------------------------------------
3 # $File: console,v 1.49 2019/05/27 01:33:32 christos Exp $
5 # Toby Deshane <hac@shoelace.digivill.net>
7 # ines: file(1) magic for Marat's iNES Nintendo Entertainment System ROM dump format
8 # Updated by David Korth <gerbilsoft@gerbilsoft.com>
10 # - https://wiki.nesdev.com/w/index.php/INES
11 # - https://wiki.nesdev.com/w/index.php/NES_2.0
13 # Common header for iNES, NES 2.0, and Wii U iNES.
14 0 name nes-rom-image-ines
15 >7 byte&0x0C =0x8 (NES 2.0)
16 >4 byte x \b: %ux16k PRG
17 >5 byte x \b, %ux8k CHR
18 >6 byte&0x08 =0x8 [4-Scr]
19 >6 byte&0x09 =0x0 [H-mirror]
20 >6 byte&0x09 =0x1 [V-mirror]
21 >6 byte&0x02 =0x2 [SRAM]
22 >6 byte&0x04 =0x4 [Trainer]
23 >7 byte&0x03 =0x2 [PC10]
24 >7 byte&0x03 =0x1 [VS]
27 >>>13 byte&0x0F =0x0 \b, RP2C03B
28 >>>13 byte&0x0F =0x1 \b, RP2C03G
29 >>>13 byte&0x0F =0x2 \b, RP2C04-0001
30 >>>13 byte&0x0F =0x3 \b, RP2C04-0002
31 >>>13 byte&0x0F =0x4 \b, RP2C04-0003
32 >>>13 byte&0x0F =0x5 \b, RP2C04-0004
33 >>>13 byte&0x0F =0x6 \b, RP2C03B
34 >>>13 byte&0x0F =0x7 \b, RP2C03C
35 >>>13 byte&0x0F =0x8 \b, RP2C05-01
36 >>>13 byte&0x0F =0x9 \b, RP2C05-02
37 >>>13 byte&0x0F =0xA \b, RP2C05-03
38 >>>13 byte&0x0F =0xB \b, RP2C05-04
39 >>>13 byte&0x0F =0xC \b, RP2C05-05
40 # TODO: VS protection hardware?
42 # NES 2.0-specific flags.
44 >>12 byte&0x03 =0x0 [NTSC]
45 >>12 byte&0x03 =0x1 [PAL]
46 >>12 byte&0x02 =0x2 [NTSC+PAL]
48 # Standard iNES ROM header.
49 0 string NES\x1A NES ROM image (iNES)
50 !:mime application/x-nes-rom
51 >0 use nes-rom-image-ines
53 # Wii U Virtual Console iNES ROM header.
54 0 belong 0x4E455300 NES ROM image (Wii U Virtual Console)
55 !:mime application/x-nes-rom
56 >0 use nes-rom-image-ines
58 #------------------------------------------------------------------------------
59 # unif: file(1) magic for UNIF-format Nintendo Entertainment System ROM images
60 # Reference: https://wiki.nesdev.com/w/index.php/UNIF
61 # From: David Korth <gerbilsoft@gerbilsoft.com>
63 # NOTE: The UNIF format uses chunks instead of a fixed header,
64 # so most of the data isn't easily parseable.
67 >4 lelong <16 NES ROM image (UNIF v%d format)
68 !:mime application/x-nes-rom
70 #------------------------------------------------------------------------------
71 # fds: file(1) magic for Famciom Disk System disk images
72 # Reference: https://wiki.nesdev.com/w/index.php/Family_Computer_Disk_System#.FDS_format
73 # From: David Korth <gerbilsoft@gerbilsoft.com>
74 # TODO: Check "Disk info block" and get info from that in addition to the optional header.
76 # Disk info block. (block 1)
77 0 name nintendo-fds-disk-info-block
81 >15 byte x \b, mfr %02X
86 >0x11 string *NINTENDO-HVC* Famicom Disk System disk image:
87 !:mime application/x-fds-disk
88 >>0x10 use nintendo-fds-disk-info-block
93 1 string *NINTENDO-HVC* Famicom Disk System disk image:
94 !:mime application/x-fds-disk
95 >0 use nintendo-fds-disk-info-block
97 #------------------------------------------------------------------------------
98 # tnes: file(1) magic for TNES-format Nintendo Entertainment System ROM images
99 # Used by Nintendo 3DS NES Virtual Console games.
100 # From: David Korth <gerbilsoft@gerbilsoft.com>
102 0 string TNES NES ROM image (Nintendo 3DS Virtual Console)
103 !:mime application/x-nes-rom
105 >>0x2010 use nintendo-fds-disk-info-block
106 >4 byte !100 \b: TNES mapper %u
107 >>5 byte x \b, %ux8k PRG
108 >>6 byte x \b, %ux8k CHR
109 >>7 byte&0x08 =1 [WRAM]
110 >>8 byte&0x09 =1 [H-mirror]
111 >>8 byte&0x09 =2 [V-mirror]
112 >>8 byte&0x02 =3 [VRAM]
114 #------------------------------------------------------------------------------
115 # gameboy: file(1) magic for the Nintendo (Color) Gameboy raw ROM format
116 # Reference: http://gbdev.gg8.se/wiki/articles/The_Cartridge_Header
118 0x104 bequad 0xCEED6666CC0D000B Game Boy ROM image
119 # TODO: application/x-gameboy-color-rom for GBC.
120 !:mime application/x-gameboy-rom
121 >0x143 byte&0x80 0x80
122 >>0x134 string >\0 \b: "%.15s"
123 >0x143 byte&0x80 !0x80
124 >>0x134 string >\0 \b: "%.16s"
125 >0x14c byte x (Rev.%02u)
127 # Machine type. (SGB, CGB, SGB+CGB)
130 >>>0x143 byte&0x80 0x80 [SGB+CGB]
131 >>>0x143 byte&0x80 !0x80 [SGB]
133 >>>0x143 byte&0xC0 0x80 [CGB]
134 >>>0x143 byte&0xC0 0xC0 [CGB ONLY]
138 >0x147 byte 0x00 [ROM ONLY]
139 >0x147 byte 0x01 [MBC1]
140 >0x147 byte 0x02 [MBC1+RAM]
141 >0x147 byte 0x03 [MBC1+RAM+BATT]
142 >0x147 byte 0x05 [MBC2]
143 >0x147 byte 0x06 [MBC2+BATTERY]
144 >0x147 byte 0x08 [ROM+RAM]
145 >0x147 byte 0x09 [ROM+RAM+BATTERY]
146 >0x147 byte 0x0B [MMM01]
147 >0x147 byte 0x0C [MMM01+SRAM]
148 >0x147 byte 0x0D [MMM01+SRAM+BATT]
149 >0x147 byte 0x0F [MBC3+TIMER+BATT]
150 >0x147 byte 0x10 [MBC3+TIMER+RAM+BATT]
151 >0x147 byte 0x11 [MBC3]
152 >0x147 byte 0x12 [MBC3+RAM]
153 >0x147 byte 0x13 [MBC3+RAM+BATT]
154 >0x147 byte 0x19 [MBC5]
155 >0x147 byte 0x1A [MBC5+RAM]
156 >0x147 byte 0x1B [MBC5+RAM+BATT]
157 >0x147 byte 0x1C [MBC5+RUMBLE]
158 >0x147 byte 0x1D [MBC5+RUMBLE+SRAM]
159 >0x147 byte 0x1E [MBC5+RUMBLE+SRAM+BATT]
160 >0x147 byte 0xFC [Pocket Camera]
161 >0x147 byte 0xFD [Bandai TAMA5]
162 >0x147 byte 0xFE [Hudson HuC-3]
163 >0x147 byte 0xFF [Hudson HuC-1]
166 >0x148 byte 0 \b, ROM: 256Kbit
167 >0x148 byte 1 \b, ROM: 512Kbit
168 >0x148 byte 2 \b, ROM: 1Mbit
169 >0x148 byte 3 \b, ROM: 2Mbit
170 >0x148 byte 4 \b, ROM: 4Mbit
171 >0x148 byte 5 \b, ROM: 8Mbit
172 >0x148 byte 6 \b, ROM: 16Mbit
173 >0x148 byte 7 \b, ROM: 32Mbit
174 >0x148 byte 0x52 \b, ROM: 9Mbit
175 >0x148 byte 0x53 \b, ROM: 10Mbit
176 >0x148 byte 0x54 \b, ROM: 12Mbit
179 >0x149 byte 1 \b, RAM: 16Kbit
180 >0x149 byte 2 \b, RAM: 64Kbit
181 >0x149 byte 3 \b, RAM: 128Kbit
182 >0x149 byte 4 \b, RAM: 1Mbit
183 >0x149 byte 5 \b, RAM: 512Kbit
185 #------------------------------------------------------------------------------
186 # genesis: file(1) magic for various Sega Mega Drive / Genesis ROM image and disc formats
187 # Updated by David Korth <gerbilsoft@gerbilsoft.com>
189 # - https://www.retrodev.com/segacd.html
190 # - http://devster.monkeeh.com/sega/32xguide1.txt
193 # Common Sega Mega Drive header format.
194 # FIXME: Name fields are 48 bytes, but have spaces for padding instead of 00s.
195 0 name sega-mega-drive-header
196 # ROM title. (Use domestic if present; if not, use international.)
198 >>0x120 string >\0 \b: "%.16s"
200 >>0x150 string >\0 \b: "%.16s"
202 >0x180 string >\0 (%.14s
203 >>0x110 string >\0 \b, %.16s
205 >>0x110 string >\0 (%.16s
208 # TODO: Check for 32X CD?
209 # Sega Mega CD disc images: 2048-byte sectors.
210 0 string SEGADISCSYSTEM\ \ Sega Mega CD disc image
211 !:mime application/x-sega-cd-rom
212 >0 use sega-mega-drive-header
213 >0 byte x \b, 2048-byte sectors
214 0 string SEGABOOTDISC\ \ \ \ Sega Mega CD disc image
215 !:mime application/x-sega-cd-rom
216 >0 use sega-mega-drive-header
217 >0 byte x \b, 2048-byte sectors
218 # Sega Mega CD disc images: 2352-byte sectors.
219 0x10 string SEGADISCSYSTEM\ \ Sega Mega CD disc image
220 !:mime application/x-sega-cd-rom
221 >0x10 use sega-mega-drive-header
222 >0 byte x \b, 2352-byte sectors
223 0x10 string SEGABOOTDISC\ \ \ \ Sega Mega CD disc image
224 !:mime application/x-sega-cd-rom
225 >0x10 use sega-mega-drive-header
226 >0 byte x \b, 2352-byte sectors
228 # Sega Mega Drive, 32X, Pico, and Mega CD Boot ROM images.
230 >0x3C0 bequad 0x4D41525320434845 Sega 32X ROM image
231 !:mime application/x-genesis-32x-rom
232 >>0 use sega-mega-drive-header
233 >0x3C0 bequad !0x4D41525320434845
234 >>0x105 belong 0x5049434F Sega Pico ROM image
235 !:mime application/x-sega-pico-rom
236 >>>0 use sega-mega-drive-header
237 >>0x105 belong !0x5049434F
238 >>>0x180 beshort 0x4252 Sega Mega CD Boot ROM image
239 !:mime application/x-genesis-rom
240 >>>0x180 beshort !0x4252 Sega Mega Drive / Genesis ROM image
241 !:mime application/x-genesis-rom
242 >>>0 use sega-mega-drive-header
244 #------------------------------------------------------------------------------
245 # genesis: file(1) magic for the Super MegaDrive ROM dump format
248 # NOTE: Due to interleaving, we can't display anything
249 # other than the copier header information.
250 0 name sega-genesis-smd-header
251 >0 byte x %dx16k blocks
252 >2 byte 0 \b, last in series or standalone
253 >2 byte >0 \b, split ROM
255 # "Sega Genesis" header.
257 >8 beshort 0xAABB Sega Mega Drive / Genesis ROM image (SMD format):
258 !:mime application/x-genesis-rom
259 >>0 use sega-genesis-smd-header
261 # "Sega Mega Drive" header.
263 >8 beshort 0xAABB Sega Mega Drive / Genesis ROM image (SMD format):
264 !:mime application/x-genesis-rom
265 >>0 use sega-genesis-smd-header
267 #------------------------------------------------------------------------------
268 # smsgg: file(1) magic for Sega Master System and Game Gear ROM images
269 # Detects all Game Gear and export Sega Master System ROM images,
270 # and some Japanese Sega Master System ROM images.
271 # From: David Korth <gerbilsoft@gerbilsoft.com>
272 # Reference: https://www.smspower.org/Development/ROMHeader
275 # General SMS header rule.
276 # The SMS boot ROM checks the header at three locations.
277 0 name sega-master-system-rom-header
279 >0x0F byte&0xF0 0x30 Sega Master System
280 !:mime application/x-sms-rom
281 >0x0F byte&0xF0 0x40 Sega Master System
282 !:mime application/x-sms-rom
283 >0x0F byte&0xF0 0x50 Sega Game Gear
284 !:mime application/x-gamegear-rom
285 >0x0F byte&0xF0 0x60 Sega Game Gear
286 !:mime application/x-gamegear-rom
287 >0x0F byte&0xF0 0x70 Sega Game Gear
288 !:mime application/x-gamegear-rom
289 >0x0F default x Sega Master System / Game Gear
290 !:mime application/x-sms-rom
293 >0x0E byte&0xF0 0x10 1
294 >0x0E byte&0xF0 0x20 2
295 >0x0E byte&0xF0 0x30 3
296 >0x0E byte&0xF0 0x40 4
297 >0x0E byte&0xF0 0x50 5
298 >0x0E byte&0xF0 0x60 6
299 >0x0E byte&0xF0 0x70 7
300 >0x0E byte&0xF0 0x80 8
301 >0x0E byte&0xF0 0x90 9
302 >0x0E byte&0xF0 0xA0 10
303 >0x0E byte&0xF0 0xB0 11
304 >0x0E byte&0xF0 0xC0 12
305 >0x0E byte&0xF0 0xD0 13
306 >0x0E byte&0xF0 0xE0 14
307 >0x0E byte&0xF0 0xF0 15
308 # If the product code is 5 digits, we'll need to backspace here.
310 >>0x0C leshort x \b%04x
312 >>0x0C leshort x %04x
314 >0x0E byte&0x0F x (Rev.%02d)
315 # ROM size. (Used for the boot ROM checksum routine.)
316 >0x0F byte&0x0F 0x0A (8 KB)
317 >0x0F byte&0x0F 0x0B (16 KB)
318 >0x0F byte&0x0F 0x0C (32 KB)
319 >0x0F byte&0x0F 0x0D (48 KB)
320 >0x0F byte&0x0F 0x0E (64 KB)
321 >0x0F byte&0x0F 0x0F (128 KB)
322 >0x0F byte&0x0F 0x00 (256 KB)
323 >0x0F byte&0x0F 0x01 (512 KB)
324 >0x0F byte&0x0F 0x02 (1 MB)
326 # SMS/GG header locations.
327 0x7FF0 string TMR\ SEGA
328 >0x7FF0 use sega-master-system-rom-header
329 0x3FF0 string TMR\ SEGA
330 >0x3FF0 use sega-master-system-rom-header
331 0x1FF0 string TMR\ SEGA
332 >0x1FF0 use sega-master-system-rom-header
334 #------------------------------------------------------------------------------
335 # saturn: file(1) magic for the Sega Saturn disc image format.
336 # From: David Korth <gerbilsoft@gerbilsoft.com>
339 # Common Sega Saturn disc header format.
340 # NOTE: Title is 112 bytes, but we're only showing 32 due to space padding.
341 # TODO: Release date, device information, region code, others?
342 0 name sega-saturn-disc-header
343 >0x60 string >\0 \b: "%.32s"
344 >0x20 string >\0 (%.10s
345 >>0x2A string >\0 \b, %.6s)
348 # 2048-byte sector version.
349 0 string SEGA\ SEGASATURN\ Sega Saturn disc image
350 !:mime application/x-saturn-rom
351 >0 use sega-saturn-disc-header
352 >0 byte x (2048-byte sectors)
353 # 2352-byte sector version.
354 0x10 string SEGA\ SEGASATURN\ Sega Saturn disc image
355 !:mime application/x-saturn-rom
356 >0x10 use sega-saturn-disc-header
357 >0 byte x (2352-byte sectors)
359 #------------------------------------------------------------------------------
360 # dreamcast: file(1) magic for the Sega Dreamcast disc image format.
361 # From: David Korth <gerbilsoft@gerbilsoft.com>
362 # Reference: https://mc.pp.se/dc/ip0000.bin.html
365 # Common Sega Dreamcast disc header format.
366 # NOTE: Title is 128 bytes, but we're only showing 32 due to space padding.
367 # TODO: Release date, device information, region code, others?
368 0 name sega-dreamcast-disc-header
369 >0x80 string >\0 \b: "%.32s"
370 >0x40 string >\0 (%.10s
371 >>0x4A string >\0 \b, %.6s)
374 # 2048-byte sector version.
375 0 string SEGA\ SEGAKATANA\ Sega Dreamcast disc image
376 !:mime application/x-dc-rom
377 >0 use sega-dreamcast-disc-header
378 >0 byte x (2048-byte sectors)
379 # 2352-byte sector version.
380 0x10 string SEGA\ SEGAKATANA\ Sega Dreamcast disc image
381 !:mime application/x-dc-rom
382 >0x10 use sega-dreamcast-disc-header
383 >0 byte x (2352-byte sectors)
385 #------------------------------------------------------------------------------
386 # dreamcast: file(1) uncertain magic for the Sega Dreamcast VMU image format
388 0 belong 0x21068028 Sega Dreamcast VMU game image
389 0 string LCDi Dream Animator file
391 #------------------------------------------------------------------------------
392 # z64: file(1) magic for the Z64 format N64 ROM dumps
393 # Reference: http://forum.pj64-emu.com/showthread.php?t=2239
394 # From: David Korth <gerbilsoft@gerbilsoft.com>
396 0 bequad 0x803712400000000F Nintendo 64 ROM image
397 !:mime application/x-n64-rom
398 >0x20 string >\0 \b: "%.20s"
400 >0x3F byte x \b, Rev.%02u)
402 #------------------------------------------------------------------------------
403 # v64: file(1) magic for the V64 format N64 ROM dumps
404 # Same as z64 format, but with 16-bit byteswapping.
406 0 bequad 0x3780401200000F00 Nintendo 64 ROM image (V64)
407 !:mime application/x-n64-rom
409 #------------------------------------------------------------------------------
410 # n64-swap2: file(1) magic for the swap2 format N64 ROM dumps
411 # Same as z64 format, but with swapped 16-bit words.
413 0 bequad 0x12408037000F0000 Nintendo 64 ROM image (wordswapped)
414 !:mime application/x-n64-rom
416 #------------------------------------------------------------------------------
417 # n64-le32: file(1) magic for the 32-bit byteswapped format N64 ROM dumps
418 # Same as z64 format, but with 32-bit byteswapping.
420 0 bequad 0x401237800F000000 Nintendo 64 ROM image (32-bit byteswapped)
421 !:mime application/x-n64-rom
423 #------------------------------------------------------------------------------
424 # gba: file(1) magic for the Nintendo Game Boy Advance raw ROM format
425 # Reference: https://problemkaputt.de/gbatek.htm#gbacartridgeheader
427 # Original version from: "Nelson A. de Oliveira" <naoliv@gmail.com>
428 # Updated version from: David Korth <gerbilsoft@gerbilsoft.com>
430 4 bequad 0x24FFAE51699AA221 Game Boy Advance ROM image
431 !:mime application/x-gba-rom
432 >0xA0 string >\0 \b: "%.12s"
434 >0xBC byte x \b, Rev.%02u)
436 #------------------------------------------------------------------------------
437 # nds: file(1) magic for the Nintendo DS(i) raw ROM format
438 # Reference: https://problemkaputt.de/gbatek.htm#dscartridgeheader
440 # Original version from: "Nelson A. de Oliveira" <naoliv@gmail.com>
441 # Updated version from: David Korth <gerbilsoft@gerbilsoft.com>
443 0xC0 bequad 0x24FFAE51699AA221 Nintendo DS ROM image
444 !:mime application/x-nintendo-ds-rom
445 >0x00 string >\0 \b: "%.12s"
447 >0x1E byte x \b, Rev.%02u)
448 >0x12 byte 2 (DSi enhanced)
449 >0x12 byte 3 (DSi only)
451 >0x20 lelong <0x4000 (homebrew)
453 >>0x4000 lequad 0x0000000000000000 (multiboot)
454 >>0x4000 lequad !0x0000000000000000
455 >>>0x4000 lequad 0xE7FFDEFFE7FFDEFF (decrypted)
456 >>>0x4000 lequad !0xE7FFDEFFE7FFDEFF
457 >>>>0x1000 lequad 0x0000000000000000 (encrypted)
458 >>>>0x1000 lequad !0x0000000000000000 (mask ROM)
460 #------------------------------------------------------------------------------
461 # nds_passme: file(1) magic for Nintendo DS ROM images for GBA cartridge boot.
462 # This is also used for loading .nds files using the MSET exploit on 3DS.
463 # Reference: https://github.com/devkitPro/ndstool/blob/master/source/ndscreate.cpp
464 0xC0 bequad 0xC8604FE201708FE2 Nintendo DS Slot-2 ROM image (PassMe)
465 !:mime application/x-nintendo-ds-rom
467 #------------------------------------------------------------------------------
468 # ngp: file(1) magic for the Neo Geo Pocket (Color) raw ROM format.
469 # From: David Korth <gerbilsoft@gerbilsoft.com>
471 # - https://neogpc.googlecode.com/svn-history/r10/trunk/src/core/neogpc.cpp
472 # - https://www.devrs.com/ngp/files/ngpctech.txt
474 0x0A string BY\ SNK\ CORPORATION Neo Geo Pocket
475 !:mime application/x-neo-geo-pocket-rom
476 >0x23 byte 0x10 Color
478 >0x24 string >\0 \b: "%.12s"
479 >0x1F byte 0xFF (debug mode enabled)
481 #------------------------------------------------------------------------------
482 # msx: file(1) magic for MSX game cartridge dumps
484 #0 beshort 0x4142 MSX game cartridge dump
486 #------------------------------------------------------------------------------
487 # Sony Playstation executables (Adam Sjoegren <asjo@diku.dk>) :
488 0 string PS-X\ EXE Sony Playstation executable
489 >16 lelong x PC=0x%08x,
490 >20 lelong !0 GP=0x%08x,
491 >24 lelong !0 .text=[0x%08x,
492 >>28 lelong x \b0x%x],
493 >32 lelong !0 .data=[0x%08x,
494 >>36 lelong x \b0x%x],
495 >40 lelong !0 .bss=[0x%08x,
496 >>44 lelong x \b0x%x],
497 >48 lelong !0 Stack=0x%08x,
498 >48 lelong =0 No Stack!,
499 >52 lelong !0 StackSize=0x%x,
505 0 string CPE CPE executable
506 >3 byte x (version %d)
508 #------------------------------------------------------------------------------
509 # Microsoft Xbox executables .xbe (Esa Hyytia <ehyytia@cc.hut.fi>)
510 0 string XBEH Microsoft Xbox executable
511 !:mime audio/x-xbox-executable
513 # expect base address of 0x10000
514 >0x0104 ulelong =0x10000
515 >>(0x0118.l-0x0FFF4) lestring16 x \b: "%.40s"
516 >>(0x0118.l-0x0FFF5) byte x (%c
517 >>(0x0118.l-0x0FFF6) byte x \b%c-
518 >>(0x0118.l-0x0FFF8) uleshort x \b%03u)
519 >>(0x0118.l-0x0FF60) ulelong&0x80000007 0x80000007 \b, all regions
520 >>(0x0118.l-0x0FF60) ulelong&0x80000007 !0x80000007
521 >>>(0x0118.l-0x0FF60) ulelong >0 (regions:
522 >>>>(0x0118.l-0x0FF60) ulelong &0x00000001 NA
523 >>>>(0x0118.l-0x0FF60) ulelong &0x00000002 Japan
524 >>>>(0x0118.l-0x0FF60) ulelong &0x00000004 Rest_of_World
525 >>>>(0x0118.l-0x0FF60) ulelong &0x80000000 Manufacturer
526 >>>(0x0118.l-0x0FF60) ulelong >0 \b)
527 # probabilistic checks whether signed or not
530 >>>&2 ulelong =0x0 \b, not signed
533 >>>&2 ulelong >0 \b, signed
535 # --------------------------------
536 # Microsoft Xbox data file formats
537 0 string XIP0 XIP, Microsoft Xbox data
538 0 string XTF0 XTF, Microsoft Xbox data
540 #------------------------------------------------------------------------------
541 # Microsoft Xbox 360 executables (.xex)
542 # From: David Korth <gerbilsoft@gerbilsoft.com>
544 # - https://free60project.github.io/wiki/XEX.html
545 # - https://github.com/xenia-project/xenia/blob/HEAD/src/xenia/kernel/util/xex2_info.h
547 # Title ID (part of Execution ID section)
548 0 name xbox-360-xex-execution-id
549 >(0.L+0xC) byte x (%c
550 >(0.L+0xD) byte x \b%c
551 >(0.L+0xE) beshort x \b-%04u, media ID:
552 >(0.L) belong x %08X)
554 # Region code (part of Security Info)
555 0 name xbox-360-xex-region-code
556 >0 ubelong 0xFFFFFFFF \b, all regions
557 >0 ubelong !0xFFFFFFFF
558 >>0 ubelong >0 (regions:
559 >>0 ubelong&0x000000FF 0x000000FF USA
560 >>0 ubelong&0x00000100 0x00000100 Japan
561 >>0 ubelong&0x00000200 0x00000200 China
562 >>0 ubelong&0x0000FC00 0x0000FC00 Asia
563 >>0 ubelong&0x00FF0000 0x00FF0000 PAL
564 >>0 ubelong&0x00FF0000 0x00FE0000 PAL [except AU/NZ]
565 >>0 ubelong&0x00FF0000 0x00010000 AU/NZ
566 >>0 ubelong&0xFF000000 0xFF000000 Other
569 0 string XEX2 Microsoft Xbox 360 executable
570 !:mime audio/x-xbox360-executable
572 >0x18 search/0x100 \x00\x04\x00\x06
573 >>&0 use xbox-360-xex-execution-id
574 >(0x010.L+0x178) use xbox-360-xex-region-code
576 0 string XEX1 Microsoft Xbox 360 executable (XEX1)
577 !:mime audio/x-xbox360-executable
579 >0x18 search/0x100 \x00\x04\x00\x06
580 >>&0 use xbox-360-xex-execution-id
581 >(0x010.L+0x154) use xbox-360-xex-region-code
583 #------------------------------------------------------------------------------
584 # Microsoft Xbox 360 packages
585 # From: David Korth <gerbilsoft@gerbilsoft.com>
587 # - https://free60project.github.io/wiki/STFS.html
588 # - https://github.com/xenia-project/xenia/blob/HEAD/src/xenia/kernel/util/xex2_info.h
590 # TODO: More information for console-signed packages.
592 0 name xbox-360-package
595 >0x362 beshort x \b-%04u, media ID:
596 >0x354 belong x %08X)
597 >0x344 belong x \b, content type:
598 >>0x344 belong 0x1 Saved Game
599 >>0x344 belong 0x2 Marketplace Content
600 >>0x344 belong 0x3 Publisher
601 >>0x344 belong 0x1000 Xbox 360 Title
602 >>0x344 belong 0x2000 IPTV Pause Buffer
603 >>0x344 belong 0x4000 Installed Game
604 >>0x344 belong 0x5000 Original Xbox Game
605 >>0x344 belong 0x9000 Avatar Item
606 >>0x344 belong 0x10000 Profile
607 >>0x344 belong 0x20000 Gamer Picture
608 >>0x344 belong 0x30000 Theme
609 >>0x344 belong 0x40000 Cache File
610 >>0x344 belong 0x50000 Storage Download
611 >>0x344 belong 0x60000 Xbox Saved Game
612 >>0x344 belong 0x70000 Xbox Download
613 >>0x344 belong 0x80000 Game Demo
614 >>0x344 belong 0x90000 Video
615 >>0x344 belong 0xA0000 Game
616 >>0x344 belong 0xB0000 Installer
617 >>0x344 belong 0xC0000 Game Trailer
618 >>0x344 belong 0xD0000 Arcade Title
619 >>0x344 belong 0xE0000 XNA
620 >>0x344 belong 0xF0000 License Store
621 >>0x344 belong 0x100000 Movie
622 >>0x344 belong 0x200000 TV
623 >>0x344 belong 0x300000 Music Video
624 >>0x344 belong 0x400000 Game Video
625 >>0x344 belong 0x500000 Podcast Video
626 >>0x344 belong 0x600000 Viral Video
627 >>0x344 belong 0x2000000 Community Game
629 0 string CON\x20 Microsoft Xbox 360 package (console-signed)
630 >0 use xbox-360-package
631 0 string PIRS Microsoft Xbox 360 package (non-Xbox Live)
632 >0 use xbox-360-package
633 0 string LIVE Microsoft Xbox 360 package (Xbox Live)
634 >0 use xbox-360-package
636 # Atari Lynx cartridge dump (EXE/BLL header)
637 # From: "Stefan A. Haubenthal" <polluks@web.de>
639 # Double-check that the image type matches too, 0x8008 conflicts with
640 # 8 character OMF-86 object file headers.
642 >6 string BS93 Lynx homebrew cartridge
643 !:mime application/x-atari-lynx-rom
644 >>2 beshort x \b, RAM start $%04x
645 >6 string LYNX Lynx cartridge
646 !:mime application/x-atari-lynx-rom
647 >>2 beshort x \b, RAM start $%04x
649 # Opera file system that is used on the 3DO console
650 # From: Serge van den Boom <svdb@stack.nl>
651 0 string \x01ZZZZZ\x01 3DO "Opera" file system
653 # From: Alex Myczko <alex@aiei.ch>
654 # From: David Pflug <david@pflug.email>
655 # is the offset 12 or the offset 16 correct?
656 # GBS (Game Boy Sound) magic
657 # ftp://ftp.modland.com/pub/documents/format_documentation/\
658 # Gameboy%20Sound%20System%20(.gbs).txt
659 0 string GBS Nintendo Gameboy Music/Audio Data
660 #12 string GameBoy\ Music\ Module Nintendo Gameboy Music Module
661 >16 string >\0 ("%.32s" by
662 >48 string >\0 %.32s, copyright
663 >80 string >\0 %.32s),
664 >3 byte x version %u,
667 # IPS Patch Files from: From: Thomas Klausner <tk@giga.or.at>
668 # see https://zerosoft.zophar.net/ips.php
669 0 string PATCH IPS patch file
671 # Playstations Patch Files from: From: Thomas Klausner <tk@giga.or.at>
672 0 string PPF30 Playstation Patch File version 3.0
673 >5 byte 0 \b, PPF 1.0 patch
674 >5 byte 1 \b, PPF 2.0 patch
675 >5 byte 2 \b, PPF 3.0 patch
676 >>56 byte 0 \b, Imagetype BIN (any)
677 >>56 byte 1 \b, Imagetype GI (PrimoDVD)
678 >>57 byte 0 \b, Blockcheck disabled
679 >>57 byte 1 \b, Blockcheck enabled
680 >>58 byte 0 \b, Undo data not available
681 >>58 byte 1 \b, Undo data available
682 >6 string x \b, description: %s
684 0 string PPF20 Playstation Patch File version 2.0
685 >5 byte 0 \b, PPF 1.0 patch
686 >5 byte 1 \b, PPF 2.0 patch
687 >>56 lelong >0 \b, size of file to patch %d
688 >6 string x \b, description: %s
690 0 string PPF10 Playstation Patch File version 1.0
691 >5 byte 0 \b, Simple Encoding
692 >6 string x \b, description: %s
694 # From: Daniel Dawson <ddawson@icehouse.net>
695 # SNES9x .smv "movie" file format.
696 0 string SMV\x1A SNES9x input recording
697 >0x4 lelong x \b, version %d
698 # version 4 is latest so far
700 >>0x8 ledate x \b, recorded at %s
701 >>0xc lelong >0 \b, rerecorded %d times
702 >>0x10 lelong x \b, %d frames long
703 >>0x14 byte >0 \b, data for controller(s):
708 >>>0x14 byte &0x10 #5
709 >>0x15 byte ^0x1 \b, begins from snapshot
710 >>0x15 byte &0x1 \b, begins from reset
711 >>0x15 byte ^0x2 \b, NTSC standard
712 >>0x15 byte &0x2 \b, PAL standard
713 >>0x17 byte &0x1 \b, settings:
714 # WIP1Timing not used as of version 4
716 >>>>0x17 byte &0x2 WIP1Timing
717 >>>0x17 byte &0x4 Left+Right
718 >>>0x17 byte &0x8 VolumeEnvX
719 >>>0x17 byte &0x10 FakeMute
720 >>>0x17 byte &0x20 SyncSound
721 # New flag as of version 4
723 >>>>0x17 byte &0x80 NoCPUShutdown
727 >>>>>0x20 lestring16 x \b, metadata: "%s"
729 >>>0x24 byte >0 \b, port 1:
730 >>>>0x24 byte 1 joypad
731 >>>>0x24 byte 2 mouse
732 >>>>0x24 byte 3 SuperScope
733 >>>>0x24 byte 4 Justifier
734 >>>>0x24 byte 5 multitap
735 >>>0x24 byte >0 \b, port 2:
736 >>>>0x25 byte 1 joypad
737 >>>>0x25 byte 2 mouse
738 >>>>0x25 byte 3 SuperScope
739 >>>>0x25 byte 4 Justifier
740 >>>>0x25 byte 5 multitap
743 >>>>>0x40 lestring16 x \b, metadata: "%s"
744 >>0x17 byte &0x40 \b, ROM:
745 >>>(0x18.l-26) lelong x CRC32 0x%08x
746 >>>(0x18.l-23) string x "%s"
748 # Type: scummVM savegame files
749 # From: Sven Hartge <debian@ds9.argh.org>
750 0 string SCVM ScummVM savegame
753 #------------------------------------------------------------------------------
754 # Nintendo GameCube / Wii file formats.
757 # Type: Nintendo GameCube/Wii common disc header data.
758 # From: David Korth <gerbilsoft@gerbilsoft.com>
759 # Reference: https://wiibrew.org/wiki/Wii_Disc
760 0 name nintendo-gcn-disc-common
761 >0x20 string x "%.64s"
764 >>0x06 byte 1 \b, Disc 2
765 >>0x06 byte 2 \b, Disc 3
766 >>0x06 byte 3 \b, Disc 4
767 >0x07 byte x \b, Rev.%02u)
768 >0x18 belong 0x5D1C9EA3
769 >>0x60 beshort 0x0101 \b (Unencrypted)
771 # Type: Nintendo GameCube disc image
772 # From: David Korth <gerbilsoft@gerbilsoft.com>
773 # Reference: https://wiibrew.org/wiki/Wii_Disc
774 0x1C belong 0xC2339F3D Nintendo GameCube disc image:
775 !:mime application/x-gamecube-rom
776 >0 use nintendo-gcn-disc-common
778 # Type: Nintendo GameCube embedded disc image
779 # Commonly found on demo discs.
780 # From: David Korth <gerbilsoft@gerbilsoft.com>
781 # Reference: http://hitmen.c02.at/files/yagcd/yagcd/index.html#idx14.8
783 >0x0C belong 0x00100000
784 >>(8.L+0x1C) belong 0xC2339F3D Nintendo GameCube embedded disc image:
785 !:mime application/x-gamecube-rom
786 >>>(8.L) use nintendo-gcn-disc-common
788 # Type: Nintendo Wii disc image
789 # From: David Korth <gerbilsoft@gerbilsoft.com>
790 # Reference: https://wiibrew.org/wiki/Wii_Disc
791 0x18 belong 0x5D1C9EA3 Nintendo Wii disc image:
792 >0 use nintendo-gcn-disc-common
794 # Type: Nintendo Wii disc image (WBFS format)
795 # From: David Korth <gerbilsoft@gerbilsoft.com>
796 # Reference: https://wiibrew.org/wiki/Wii_Disc
798 >0x218 belong 0x5D1C9EA3 Nintendo Wii disc image (WBFS format):
799 !:mime application/x-wii-rom
800 >>0x200 use nintendo-gcn-disc-common
802 # Type: Nintendo GameCube/Wii disc image (CISO format)
803 # NOTE: This is NOT the same as Compact ISO or PSP CISO,
804 # though it has the same magic number.
806 # Other fields are used to determine what type of CISO this is:
807 # - 0x04 == 0x00200000: GameCube/Wii CISO (block_size)
808 # - 0x10 == 0x00000800: PSP CISO (ISO-9660 sector size)
809 # - None of the above: Compact ISO.
812 >>>0x801C belong 0xC2339F3D Nintendo GameCube disc image (CISO format):
813 !:mime application/x-wii-rom
814 >>>>0x8000 use nintendo-gcn-disc-common
815 >>>0x8018 belong 0x5D1C9EA3 Nintendo Wii disc image (CISO format):
816 !:mime application/x-wii-rom
817 >>>>0x8000 use nintendo-gcn-disc-common
819 # Type: Nintendo GameCube/Wii disc image (GCZ format)
820 # Due to zlib compression, we can't get the actual disc information.
822 >4 lelong 0 Nintendo GameCube disc image (GCZ format)
823 !:mime application/x-gamecube-rom
824 >4 lelong 1 Nintendo Wii disc image (GCZ format)
825 !:mime application/x-wii-rom
826 >4 default x Nintendo GameCube/Wii disc image (GCZ format)
828 # Type: Nintendo GameCube/Wii disc image (WDF format)
832 >>0x54 belong 0xC2339F3D Nintendo GameCube disc image (WDFv1 format):
833 !:mime application/x-gamecube-rom
834 >>>0x38 use nintendo-gcn-disc-common
835 >>0x58 belong 0x5D1C9EA3 Nintendo Wii disc image (WDFv1 format):
836 !:mime application/x-wii-rom
837 >>>0x38 use nintendo-gcn-disc-common
840 >>(12.L+0x1C) belong 0xC2339F3D Nintendo GameCube disc image (WDFv2 format):
841 !:mime application/x-gamecube-rom
842 >>>(12.L) use nintendo-gcn-disc-common
843 >>(12.L+0x18) belong 0x5D1C9EA3 Nintendo Wii disc image (WDFv2 format):
844 !:mime application/x-wii-rom
845 >>>(12.L) use nintendo-gcn-disc-common
847 # Type: Nintendo GameCube/Wii disc image (WIA format)
848 0 string WIA\001 Nintendo
849 >0x48 belong 1 GameCube
850 !:mime application/x-gamecube-rom
852 !:mime application/x-wii-rom
853 >0x48 default x GameCube/Wii
854 >0x48 belong x disc image (WIA format):
855 >>0x58 use nintendo-gcn-disc-common
857 # Type: Nintendo GameCube/Wii disc image (with SDK header)
858 # From: David Korth <gerbilsoft@gerbilsoft.com>
859 # Reference: https://wiibrew.org/wiki/Wii_Disc
861 >0x18 belong 0x00000000
862 >>0x1C belong 0x00000000
863 >>>0x8018 belong 0x5D1C9EA3 Nintendo Wii SDK disc image:
864 !:mime application/x-wii-rom
865 >>>>0x8000 use nintendo-gcn-disc-common
866 >>>0x801C belong 0xC2339F3D Nintendo GameCube SDK disc image:
867 !:mime application/x-gamecube-rom
868 >>>>0x8000 use nintendo-gcn-disc-common
870 #------------------------------------------------------------------------------
871 # Nintendo 3DS file formats.
874 # Type: Nintendo 3DS "NCSD" image. (game cards and eMMC)
875 # From: David Korth <gerbilsoft@gerbilsoft.com>
876 # Reference: https://www.3dbrew.org/wiki/NCSD
878 >0x118 lequad 0 Nintendo 3DS Game Card image
879 # NCCH header for partition 0. (game data)
880 >>0x1150 string >\0 \b: "%.16s"
881 >>0x312 byte x (Rev.%02u)
882 >>0x118C byte 2 (New3DS only)
883 >>0x18D byte 0 (inner device)
884 >>0x18D byte 1 (Card1)
885 >>0x18D byte 2 (Card2)
886 >>0x18D byte 3 (extended device)
887 >0x118 bequad 0x0102020202000000 Nintendo 3DS eMMC dump (Old3DS)
888 >0x118 bequad 0x0102020203000000 Nintendo 3DS eMMC dump (New3DS)
890 # Nintendo 3DS version code.
891 # Reference: https://www.3dbrew.org/wiki/Titles
892 # Format: leshort containing three fields:
896 # NOTE: Only supporting major/minor versions from 0-15 right now.
897 # NOTE: Should be prefixed with "v".
898 0 name nintendo-3ds-version-code
902 >0 leshort&0xFC00 0x0000 0
903 >0 leshort&0xFC00 0x0400 1
904 >0 leshort&0xFC00 0x0800 2
905 >0 leshort&0xFC00 0x0C00 3
906 >0 leshort&0xFC00 0x1000 4
907 >0 leshort&0xFC00 0x1400 5
908 >0 leshort&0xFC00 0x1800 6
909 >0 leshort&0xFC00 0x1C00 7
910 >0 leshort&0xFC00 0x2000 8
911 >0 leshort&0xFC00 0x2400 9
912 >0 leshort&0xFC00 0x2800 10
913 >0 leshort&0xFC00 0x2C00 11
914 >0 leshort&0xFC00 0x3000 12
915 >0 leshort&0xFC00 0x3400 13
916 >0 leshort&0xFC00 0x3800 14
917 >0 leshort&0xFC00 0x3C00 15
919 >0 leshort&0x03F0 0x0000 \b.0
920 >0 leshort&0x03F0 0x0010 \b.1
921 >0 leshort&0x03F0 0x0020 \b.2
922 >0 leshort&0x03F0 0x0030 \b.3
923 >0 leshort&0x03F0 0x0040 \b.4
924 >0 leshort&0x03F0 0x0050 \b.5
925 >0 leshort&0x03F0 0x0060 \b.6
926 >0 leshort&0x03F0 0x0070 \b.7
927 >0 leshort&0x03F0 0x0080 \b.8
928 >0 leshort&0x03F0 0x0090 \b.9
929 >0 leshort&0x03F0 0x00A0 \b.10
930 >0 leshort&0x03F0 0x00B0 \b.11
931 >0 leshort&0x03F0 0x00C0 \b.12
932 >0 leshort&0x03F0 0x00D0 \b.13
933 >0 leshort&0x03F0 0x00E0 \b.14
934 >0 leshort&0x03F0 0x00F0 \b.15
936 >0 leshort&0x000F x \b.%u
938 # Type: Nintendo 3DS "NCCH" container.
939 # https://www.3dbrew.org/wiki/NCCH
940 0x100 string NCCH Nintendo 3DS
941 >0x18D byte&2 0 File Archive (CFA)
942 >0x18D byte&2 2 Executable Image (CXI)
943 >0x150 string >\0 \b: "%.16s"
945 >>0x10E leshort x (Old3DS System Update v
946 >>0x10E use nintendo-3ds-version-code
947 >>0x10E leshort x \b)
949 >>0x10E leshort x (New3DS System Update v
950 >>0x10E use nintendo-3ds-version-code
951 >>0x10E leshort x \b)
955 >>>0x112 use nintendo-3ds-version-code
957 >0x18C byte 2 (New3DS only)
959 # Type: Nintendo 3DS "SMDH" file. (application description)
960 # From: David Korth <gerbilsoft@gerbilsoft.com>
961 # Reference: https://3dbrew.org/wiki/SMDH
962 0 string SMDH Nintendo 3DS SMDH file
964 >>0x208 lestring16 x \b: "%.128s"
966 >>>0x388 lestring16 x by %.128s
969 >>>0x008 lestring16 x \b: "%.128s"
971 >>>>0x188 lestring16 x by %.128s
973 # Type: Nintendo 3DS Homebrew Application.
974 # From: David Korth <gerbilsoft@gerbilsoft.com>
975 # Reference: https://3dbrew.org/wiki/3DSX_Format
976 0 string 3DSX Nintendo 3DS Homebrew Application (3DSX)
978 #------------------------------------------------------------------------------
979 # a7800: file(1) magic for the Atari 7800 raw ROM format.
980 # From: David Korth <gerbilsoft@gerbilsoft.com>
981 # Reference: https://sites.google.com/site/atari7800wiki/a78-header
985 >>1 string ATARI7800 Atari 7800 ROM image
986 !:mime application/x-atari-7800-rom
987 >>>0x11 string >\0 \b: "%.32s"
989 >>>0x39 byte 0 (NTSC)
991 >>>0x36 byte&1 1 (POKEY)
993 #------------------------------------------------------------------------------
994 # vectrex: file(1) magic for the GCE Vectrex raw ROM format.
995 # From: David Korth <gerbilsoft@gerbilsoft.com>
996 # Reference: http://www.playvectrex.com/designit/chrissalo/hello1.htm
998 # NOTE: Title is terminated with 0x80, not 0.
999 # The header is terminated with a 0, so that will
1000 # terminate the title as well.
1002 0 string g\ GCE Vectrex ROM image
1003 >0x11 string >\0 \b: "%.16s"
1005 #------------------------------------------------------------------------------
1006 # amiibo: file(1) magic for Nintendo amiibo NFC dumps.
1007 # From: David Korth <gerbilsoft@gerbilsoft.com>
1008 # Reference: https://www.3dbrew.org/wiki/Amiibo
1010 >0x0A beshort 0x0FE0
1011 >>0x0C belong 0xF110FFEE
1012 >>>0x208 beshort 0x0100
1013 >>>>0x020A byte 0x0F
1014 >>>>>0x020C bequad 0x000000045F000000
1015 >>>>>>0x5B byte 0x02
1016 >>>>>>>0x54 belong x Nintendo amiibo NFC dump - amiibo ID: %08X-
1017 >>>>>>>0x58 belong x \b%08X