console 38 KB

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