console 41 KB

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