console 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849
  1. #------------------------------------------------------------------------------
  2. # $File: console,v 1.35 2017/11/14 15:48:36 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. # - http://wiki.nesdev.com/w/index.php/INES
  9. # - http://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. >0 use nes-rom-image-ines
  47. # Wii U Virtual Console iNES ROM header.
  48. 0 belong 0x4E455300 NES ROM image (Wii U Virtual Console)
  49. >0 use nes-rom-image-ines
  50. #------------------------------------------------------------------------------
  51. # unif: file(1) magic for UNIF-format Nintendo Entertainment System ROM images
  52. # Reference: http://wiki.nesdev.com/w/index.php/UNIF
  53. # From: David Korth <gerbilsoft@gerbilsoft.com>
  54. #
  55. # NOTE: The UNIF format uses chunks instead of a fixed header,
  56. # so most of the data isn't easily parseable.
  57. #
  58. 0 string UNIF
  59. >4 lelong <16 NES ROM image (UNIF v%d format)
  60. #------------------------------------------------------------------------------
  61. # fds: file(1) magic for Famciom Disk System disk images
  62. # Reference: http://wiki.nesdev.com/w/index.php/Family_Computer_Disk_System#.FDS_format
  63. # From: David Korth <gerbilsoft@gerbilsoft.com>
  64. # TODO: Check "Disk info block" and get info from that in addition to the optional header.
  65. # Disk info block. (block 1)
  66. 0 name nintendo-fds-disk-info-block
  67. >23 byte !1 FMC-
  68. >23 byte 1 FSC-
  69. >16 string x \b%.3s
  70. >15 byte x \b, mfr %02X
  71. >20 byte x (Rev.%02u)
  72. # Headered version.
  73. 0 string FDS\x1A
  74. >0x11 string *NINTENDO-HVC* Famicom Disk System disk image:
  75. >>0x10 use nintendo-fds-disk-info-block
  76. >4 byte 1 (%u side)
  77. >4 byte !1 (%u sides)
  78. # Unheadered version.
  79. 1 string *NINTENDO-HVC* Famicom Disk System disk image:
  80. >0 use nintendo-fds-disk-info-block
  81. #------------------------------------------------------------------------------
  82. # tnes: file(1) magic for TNES-format Nintendo Entertainment System ROM images
  83. # Used by Nintendo 3DS NES Virtual Console games.
  84. # From: David Korth <gerbilsoft@gerbilsoft.com>
  85. #
  86. 0 string TNES NES ROM image (Nintendo 3DS Virtual Console)
  87. >4 byte 100 \b: FDS,
  88. >>0x2010 use nintendo-fds-disk-info-block
  89. >4 byte !100 \b: TNES mapper %u
  90. >>5 byte x \b, %ux8k PRG
  91. >>6 byte x \b, %ux8k CHR
  92. >>7 byte&0x08 =1 [WRAM]
  93. >>8 byte&0x09 =1 [H-mirror]
  94. >>8 byte&0x09 =2 [V-mirror]
  95. >>8 byte&0x02 =3 [VRAM]
  96. #------------------------------------------------------------------------------
  97. # gameboy: file(1) magic for the Nintendo (Color) Gameboy raw ROM format
  98. # Reference: http://gbdev.gg8.se/wiki/articles/The_Cartridge_Header
  99. #
  100. 0x104 bequad 0xCEED6666CC0D000B Game Boy ROM image
  101. >0x143 byte&0x80 0x80
  102. >>0x134 string >\0 \b: "%.15s"
  103. >0x143 byte&0x80 !0x80
  104. >>0x134 string >\0 \b: "%.16s"
  105. >0x14c byte x (Rev.%02u)
  106. # Machine type. (SGB, CGB, SGB+CGB)
  107. >0x14b byte 0x33
  108. >>0x146 byte 0x03
  109. >>>0x143 byte&0x80 0x80 [SGB+CGB]
  110. >>>0x143 byte&0x80 !0x80 [SGB]
  111. >>0x146 byte !0x03
  112. >>>0x143 byte&0xC0 0x80 [CGB]
  113. >>>0x143 byte&0xC0 0xC0 [CGB ONLY]
  114. # Mapper.
  115. >0x147 byte 0x00 [ROM ONLY]
  116. >0x147 byte 0x01 [MBC1]
  117. >0x147 byte 0x02 [MBC1+RAM]
  118. >0x147 byte 0x03 [MBC1+RAM+BATT]
  119. >0x147 byte 0x05 [MBC2]
  120. >0x147 byte 0x06 [MBC2+BATTERY]
  121. >0x147 byte 0x08 [ROM+RAM]
  122. >0x147 byte 0x09 [ROM+RAM+BATTERY]
  123. >0x147 byte 0x0B [MMM01]
  124. >0x147 byte 0x0C [MMM01+SRAM]
  125. >0x147 byte 0x0D [MMM01+SRAM+BATT]
  126. >0x147 byte 0x0F [MBC3+TIMER+BATT]
  127. >0x147 byte 0x10 [MBC3+TIMER+RAM+BATT]
  128. >0x147 byte 0x11 [MBC3]
  129. >0x147 byte 0x12 [MBC3+RAM]
  130. >0x147 byte 0x13 [MBC3+RAM+BATT]
  131. >0x147 byte 0x19 [MBC5]
  132. >0x147 byte 0x1A [MBC5+RAM]
  133. >0x147 byte 0x1B [MBC5+RAM+BATT]
  134. >0x147 byte 0x1C [MBC5+RUMBLE]
  135. >0x147 byte 0x1D [MBC5+RUMBLE+SRAM]
  136. >0x147 byte 0x1E [MBC5+RUMBLE+SRAM+BATT]
  137. >0x147 byte 0xFC [Pocket Camera]
  138. >0x147 byte 0xFD [Bandai TAMA5]
  139. >0x147 byte 0xFE [Hudson HuC-3]
  140. >0x147 byte 0xFF [Hudson HuC-1]
  141. # ROM size.
  142. >0x148 byte 0 \b, ROM: 256Kbit
  143. >0x148 byte 1 \b, ROM: 512Kbit
  144. >0x148 byte 2 \b, ROM: 1Mbit
  145. >0x148 byte 3 \b, ROM: 2Mbit
  146. >0x148 byte 4 \b, ROM: 4Mbit
  147. >0x148 byte 5 \b, ROM: 8Mbit
  148. >0x148 byte 6 \b, ROM: 16Mbit
  149. >0x148 byte 7 \b, ROM: 32Mbit
  150. >0x148 byte 0x52 \b, ROM: 9Mbit
  151. >0x148 byte 0x53 \b, ROM: 10Mbit
  152. >0x148 byte 0x54 \b, ROM: 12Mbit
  153. # RAM size.
  154. >0x149 byte 1 \b, RAM: 16Kbit
  155. >0x149 byte 2 \b, RAM: 64Kbit
  156. >0x149 byte 3 \b, RAM: 128Kbit
  157. >0x149 byte 4 \b, RAM: 1Mbit
  158. >0x149 byte 5 \b, RAM: 512Kbit
  159. #------------------------------------------------------------------------------
  160. # genesis: file(1) magic for various Sega Mega Drive / Genesis ROM image and disc formats
  161. # Updated by David Korth <gerbilsoft@gerbilsoft.com>
  162. # References:
  163. # - http://www.retrodev.com/segacd.html
  164. # - http://devster.monkeeh.com/sega/32xguide1.txt
  165. #
  166. # Common Sega Mega Drive header format.
  167. # FIXME: Name fields are 48 bytes, but have spaces for padding instead of 00s.
  168. 0 name sega-mega-drive-header
  169. # ROM title. (Use domestic if present; if not, use international.)
  170. >0x120 byte >0x20
  171. >>0x120 string >\0 \b: "%.16s"
  172. >0x120 byte <0x21
  173. >>0x150 string >\0 \b: "%.16s"
  174. # Other information.
  175. >0x180 string >\0 (%.14s
  176. >>0x110 string >\0 \b, %.16s
  177. >0x180 byte 0
  178. >>0x110 string >\0 (%.16s
  179. >0 byte x \b)
  180. # TODO: Check for 32X CD?
  181. # Sega Mega CD disc images: 2048-byte sectors.
  182. 0 string SEGADISCSYSTEM\ \ Sega Mega CD disc image
  183. >0 use sega-mega-drive-header
  184. >0 byte x \b, 2048-byte sectors
  185. 0 string SEGABOOTDISC\ \ \ \ Sega Mega CD disc image
  186. >0 use sega-mega-drive-header
  187. >0 byte x \b, 2048-byte sectors
  188. # Sega Mega CD disc images: 2352-byte sectors.
  189. 0x10 string SEGADISCSYSTEM\ \ Sega Mega CD disc image
  190. >0x10 use sega-mega-drive-header
  191. >0 byte x \b, 2352-byte sectors
  192. 0x10 string SEGABOOTDISC\ \ \ \ Sega Mega CD disc image
  193. >0x10 use sega-mega-drive-header
  194. >0 byte x \b, 2352-byte sectors
  195. # Sega Mega Drive, 32X, Pico, and Mega CD Boot ROM images.
  196. 0x100 string SEGA
  197. >0x3C0 bequad 0x4D41525320434845 Sega 32X ROM image
  198. >>0 use sega-mega-drive-header
  199. >0x3C0 bequad !0x4D41525320434845
  200. >>0x105 belong 0x5049434F Sega Pico ROM image
  201. >>>0 use sega-mega-drive-header
  202. >>0x105 belong !0x5049434F
  203. >>>0x180 beshort 0x4252 Sega Mega CD Boot ROM image
  204. >>>0x180 beshort !0x4252 Sega Mega Drive / Genesis ROM image
  205. >>>0 use sega-mega-drive-header
  206. #------------------------------------------------------------------------------
  207. # genesis: file(1) magic for the Super MegaDrive ROM dump format
  208. #
  209. # NOTE: Due to interleaving, we can't display anything
  210. # other than the copier header information.
  211. 0 name sega-genesis-smd-header
  212. >0 byte x %dx16k blocks
  213. >2 byte 0 \b, last in series or standalone
  214. >2 byte >0 \b, split ROM
  215. # "Sega Genesis" header.
  216. 0x280 string EAGN
  217. >8 beshort 0xAABB Sega Mega Drive / Genesis ROM image (SMD format):
  218. >>0 use sega-genesis-smd-header
  219. # "Sega Mega Drive" header.
  220. 0x280 string EAMG
  221. >8 beshort 0xAABB Sega Mega Drive / Genesis ROM image (SMD format):
  222. >>0 use sega-genesis-smd-header
  223. #------------------------------------------------------------------------------
  224. # smsgg: file(1) magic for Sega Master System and Game Gear ROM images
  225. # Detects all Game Gear and export Sega Master System ROM images,
  226. # and some Japanese Sega Master System ROM images.
  227. # From: David Korth <gerbilsoft@gerbilsoft.com>
  228. # Reference: http://www.smspower.org/Development/ROMHeader
  229. #
  230. # General SMS header rule.
  231. # The SMS boot ROM checks the header at three locations.
  232. 0 name sega-master-system-rom-header
  233. # Machine type.
  234. >0x0F byte&0xF0 0x30 Sega Master System
  235. >0x0F byte&0xF0 0x40 Sega Master System
  236. >0x0F byte&0xF0 0x50 Sega Game Gear
  237. >0x0F byte&0xF0 0x60 Sega Game Gear
  238. >0x0F byte&0xF0 0x70 Sega Game Gear
  239. >0x0F byte&0xF0 <0x30 Sega Master System / Game Gear
  240. >0x0F byte&0xF0 >0x70 Sega Master System / Game Gear
  241. >0 byte x ROM image:
  242. # Product code.
  243. >0x0E byte&0xF0 0x10 1
  244. >0x0E byte&0xF0 0x20 2
  245. >0x0E byte&0xF0 0x30 3
  246. >0x0E byte&0xF0 0x40 4
  247. >0x0E byte&0xF0 0x50 5
  248. >0x0E byte&0xF0 0x60 6
  249. >0x0E byte&0xF0 0x70 7
  250. >0x0E byte&0xF0 0x80 8
  251. >0x0E byte&0xF0 0x90 9
  252. >0x0E byte&0xF0 0xA0 10
  253. >0x0E byte&0xF0 0xB0 11
  254. >0x0E byte&0xF0 0xC0 12
  255. >0x0E byte&0xF0 0xD0 13
  256. >0x0E byte&0xF0 0xE0 14
  257. >0x0E byte&0xF0 0xF0 15
  258. # If the product code is 5 digits, we'll need to backspace here.
  259. >0x0E byte&0xF0 !0
  260. >>0x0C leshort x \b%04x
  261. >0x0E byte&0xF0 0
  262. >>0x0C leshort x %04x
  263. # Revision.
  264. >0x0E byte&0x0F x (Rev.%02d)
  265. # ROM size. (Used for the boot ROM checksum routine.)
  266. >0x0F byte&0x0F 0x0A (8 KB)
  267. >0x0F byte&0x0F 0x0B (16 KB)
  268. >0x0F byte&0x0F 0x0C (32 KB)
  269. >0x0F byte&0x0F 0x0D (48 KB)
  270. >0x0F byte&0x0F 0x0E (64 KB)
  271. >0x0F byte&0x0F 0x0F (128 KB)
  272. >0x0F byte&0x0F 0x00 (256 KB)
  273. >0x0F byte&0x0F 0x01 (512 KB)
  274. >0x0F byte&0x0F 0x02 (1 MB)
  275. # SMS/GG header locations.
  276. 0x7FF0 string TMR\ SEGA
  277. >0x7FF0 use sega-master-system-rom-header
  278. 0x3FF0 string TMR\ SEGA
  279. >0x3FF0 use sega-master-system-rom-header
  280. 0x1FF0 string TMR\ SEGA
  281. >0x1FF0 use sega-master-system-rom-header
  282. #------------------------------------------------------------------------------
  283. # saturn: file(1) magic for the Sega Saturn disc image format.
  284. # From: David Korth <gerbilsoft@gerbilsoft.com>
  285. #
  286. # Common Sega Saturn disc header format.
  287. # NOTE: Title is 112 bytes, but we're only showing 32 due to space padding.
  288. # TODO: Release date, device information, region code, others?
  289. 0 name sega-saturn-disc-header
  290. >0x60 string >\0 \b: "%.32s"
  291. >0x20 string >\0 (%.10s
  292. >>0x2A string >\0 \b, %.6s)
  293. >>0x2A byte 0 \b)
  294. # 2048-byte sector version.
  295. 0 string SEGA\ SEGASATURN\ Sega Saturn disc image
  296. >0 use sega-saturn-disc-header
  297. >0 byte x (2048-byte sectors)
  298. # 2352-byte sector version.
  299. 0x10 string SEGA\ SEGASATURN\ Sega Saturn disc image
  300. >0x10 use sega-saturn-disc-header
  301. >0 byte x (2352-byte sectors)
  302. #------------------------------------------------------------------------------
  303. # dreamcast: file(1) magic for the Sega Dreamcast disc image format.
  304. # From: David Korth <gerbilsoft@gerbilsoft.com>
  305. # Reference: http://mc.pp.se/dc/ip0000.bin.html
  306. #
  307. # Common Sega Dreamcast disc header format.
  308. # NOTE: Title is 128 bytes, but we're only showing 32 due to space padding.
  309. # TODO: Release date, device information, region code, others?
  310. 0 name sega-dreamcast-disc-header
  311. >0x80 string >\0 \b: "%.32s"
  312. >0x40 string >\0 (%.10s
  313. >>0x4A string >\0 \b, %.6s)
  314. >>0x4A byte 0 \b)
  315. # 2048-byte sector version.
  316. 0 string SEGA\ SEGAKATANA\ Sega Dreamcast disc image
  317. >0 use sega-dreamcast-disc-header
  318. >0 byte x (2048-byte sectors)
  319. # 2352-byte sector version.
  320. 0x10 string SEGA\ SEGAKATANA\ Sega Dreamcast disc image
  321. >0x10 use sega-dreamcast-disc-header
  322. >0 byte x (2352-byte sectors)
  323. #------------------------------------------------------------------------------
  324. # dreamcast: file(1) uncertain magic for the Sega Dreamcast VMU image format
  325. #
  326. 0 belong 0x21068028 Sega Dreamcast VMU game image
  327. 0 string LCDi Dream Animator file
  328. #------------------------------------------------------------------------------
  329. # z64: file(1) magic for the Z64 format N64 ROM dumps
  330. # Reference: http://forum.pj64-emu.com/showthread.php?t=2239
  331. # From: David Korth <gerbilsoft@gerbilsoft.com>
  332. #
  333. 0 bequad 0x803712400000000F Nintendo 64 ROM image
  334. >0x20 string >\0 \b: "%.20s"
  335. >0x3B string x (%.4s
  336. >0x3F byte x \b, Rev.%02u)
  337. #------------------------------------------------------------------------------
  338. # v64: file(1) magic for the V64 format N64 ROM dumps
  339. # Same as z64 format, but with 16-bit byteswapping.
  340. #
  341. 0 bequad 0x3780401200000F00 Nintendo 64 ROM image (V64)
  342. #------------------------------------------------------------------------------
  343. # n64-swap2: file(1) magic for the swap2 format N64 ROM dumps
  344. # Same as z64 format, but with swapped 16-bit words.
  345. #
  346. 0 bequad 0x12408037000F0000 Nintendo 64 ROM image (wordswapped)
  347. #------------------------------------------------------------------------------
  348. # n64-le32: file(1) magic for the 32-bit byteswapped format N64 ROM dumps
  349. # Same as z64 format, but with 32-bit byteswapping.
  350. #
  351. 0 bequad 0x401237800F000000 Nintendo 64 ROM image (32-bit byteswapped)
  352. #------------------------------------------------------------------------------
  353. # gba: file(1) magic for the Nintendo Game Boy Advance raw ROM format
  354. # Reference: http://problemkaputt.de/gbatek.htm#gbacartridgeheader
  355. #
  356. # Original version from: "Nelson A. de Oliveira" <naoliv@gmail.com>
  357. # Updated version from: David Korth <gerbilsoft@gerbilsoft.com>
  358. #
  359. 4 bequad 0x24FFAE51699AA221 Game Boy Advance ROM image
  360. >0xA0 string >\0 \b: "%.12s"
  361. >0xAC string x (%.6s
  362. >0xBC byte x \b, Rev.%02u)
  363. #------------------------------------------------------------------------------
  364. # nds: file(1) magic for the Nintendo DS(i) raw ROM format
  365. # Reference: http://problemkaputt.de/gbatek.htm#dscartridgeheader
  366. #
  367. # Original version from: "Nelson A. de Oliveira" <naoliv@gmail.com>
  368. # Updated version from: David Korth <gerbilsoft@gerbilsoft.com>
  369. #
  370. 0xC0 bequad 0x24FFAE51699AA221 Nintendo DS ROM image
  371. >0x00 string >\0 \b: "%.12s"
  372. >0x0C string x (%.6s
  373. >0x1E byte x \b, Rev.%02u)
  374. >0x12 byte 2 (DSi enhanced)
  375. >0x12 byte 3 (DSi only)
  376. # Secure Area check.
  377. >0x20 lelong <0x4000 (homebrew)
  378. >0x20 lelong >0x3FFF
  379. >>0x4000 lequad 0x0000000000000000 (multiboot)
  380. >>0x4000 lequad !0x0000000000000000
  381. >>>0x4000 lequad 0xE7FFDEFFE7FFDEFF (decrypted)
  382. >>>0x4000 lequad !0xE7FFDEFFE7FFDEFF
  383. >>>>0x1000 lequad 0x0000000000000000 (encrypted)
  384. >>>>0x1000 lequad !0x0000000000000000 (mask ROM)
  385. #------------------------------------------------------------------------------
  386. # nds_passme: file(1) magic for Nintendo DS ROM images for GBA cartridge boot.
  387. # This is also used for loading .nds files using the MSET exploit on 3DS.
  388. # Reference: https://github.com/devkitPro/ndstool/blob/master/source/ndscreate.cpp
  389. 0xC0 bequad 0xC8604FE201708FE2 Nintendo DS Slot-2 ROM image (PassMe)
  390. #------------------------------------------------------------------------------
  391. # ngp: file(1) magic for the Neo Geo Pocket (Color) raw ROM format.
  392. # From: David Korth <gerbilsoft@gerbilsoft.com>
  393. # References:
  394. # - https://neogpc.googlecode.com/svn-history/r10/trunk/src/core/neogpc.cpp
  395. # - http://www.devrs.com/ngp/files/ngpctech.txt
  396. #
  397. 0x0A string BY\ SNK\ CORPORATION Neo Geo Pocket
  398. >0x23 byte 0x10 Color
  399. >0 byte x ROM image
  400. >0x24 string >\0 \b: "%.12s"
  401. >0x1F byte 0xFF (debug mode enabled)
  402. #------------------------------------------------------------------------------
  403. # msx: file(1) magic for MSX game cartridge dumps
  404. # Too simple - MPi
  405. #0 beshort 0x4142 MSX game cartridge dump
  406. #------------------------------------------------------------------------------
  407. # Sony Playstation executables (Adam Sjoegren <asjo@diku.dk>) :
  408. 0 string PS-X\ EXE Sony Playstation executable
  409. >16 lelong x PC=0x%08x,
  410. >20 lelong !0 GP=0x%08x,
  411. >24 lelong !0 .text=[0x%08x,
  412. >>28 lelong x \b0x%x],
  413. >32 lelong !0 .data=[0x%08x,
  414. >>36 lelong x \b0x%x],
  415. >40 lelong !0 .bss=[0x%08x,
  416. >>44 lelong x \b0x%x],
  417. >48 lelong !0 Stack=0x%08x,
  418. >48 lelong =0 No Stack!,
  419. >52 lelong !0 StackSize=0x%x,
  420. #>76 string >\0 (%s)
  421. # Area:
  422. >113 string x (%s)
  423. # CPE executables
  424. 0 string CPE CPE executable
  425. >3 byte x (version %d)
  426. #------------------------------------------------------------------------------
  427. # Microsoft Xbox executables .xbe (Esa Hyytia <ehyytia@cc.hut.fi>)
  428. 0 string XBEH XBE, Microsoft Xbox executable
  429. # probabilistic checks whether signed or not
  430. >0x0004 ulelong =0x0
  431. >>&2 ulelong =0x0
  432. >>>&2 ulelong =0x0 \b, not signed
  433. >0x0004 ulelong >0
  434. >>&2 ulelong >0
  435. >>>&2 ulelong >0 \b, signed
  436. # expect base address of 0x10000
  437. >0x0104 ulelong =0x10000
  438. >>(0x0118-0x0FF60) ulelong&0x80000007 0x80000007 \b, all regions
  439. >>(0x0118-0x0FF60) ulelong&0x80000007 !0x80000007
  440. >>>(0x0118-0x0FF60) ulelong >0 (regions:
  441. >>>>(0x0118-0x0FF60) ulelong &0x00000001 NA
  442. >>>>(0x0118-0x0FF60) ulelong &0x00000002 Japan
  443. >>>>(0x0118-0x0FF60) ulelong &0x00000004 Rest_of_World
  444. >>>>(0x0118-0x0FF60) ulelong &0x80000000 Manufacturer
  445. >>>(0x0118-0x0FF60) ulelong >0 \b)
  446. # --------------------------------
  447. # Microsoft Xbox data file formats
  448. 0 string XIP0 XIP, Microsoft Xbox data
  449. 0 string XTF0 XTF, Microsoft Xbox data
  450. # Atari Lynx cartridge dump (EXE/BLL header)
  451. # From: "Stefan A. Haubenthal" <polluks@web.de>
  452. # Double-check that the image type matches too, 0x8008 conflicts with
  453. # 8 character OMF-86 object file headers.
  454. 0 beshort 0x8008
  455. >6 string BS93 Lynx homebrew cartridge
  456. >>2 beshort x \b, RAM start $%04x
  457. >6 string LYNX Lynx cartridge
  458. >>2 beshort x \b, RAM start $%04x
  459. # Opera file system that is used on the 3DO console
  460. # From: Serge van den Boom <svdb@stack.nl>
  461. 0 string \x01ZZZZZ\x01 3DO "Opera" file system
  462. # From: Alex Myczko <alex@aiei.ch>
  463. # From: David Pflug <david@pflug.email>
  464. # is the offset 12 or the offset 16 correct?
  465. # GBS (Game Boy Sound) magic
  466. # ftp://ftp.modland.com/pub/documents/format_documentation/\
  467. # Gameboy%20Sound%20System%20(.gbs).txt
  468. 0 string GBS Nintendo Gameboy Music/Audio Data
  469. #12 string GameBoy\ Music\ Module Nintendo Gameboy Music Module
  470. >16 string >\0 ("%s" by
  471. >48 string >\0 %s, copyright
  472. >80 string >\0 %s),
  473. >3 byte x version %d,
  474. >4 byte x %d tracks
  475. # IPS Patch Files from: From: Thomas Klausner <tk@giga.or.at>
  476. # see http://zerosoft.zophar.net/ips.php
  477. 0 string PATCH IPS patch file
  478. # Playstations Patch Files from: From: Thomas Klausner <tk@giga.or.at>
  479. 0 string PPF30 Playstation Patch File version 3.0
  480. >5 byte 0 \b, PPF 1.0 patch
  481. >5 byte 1 \b, PPF 2.0 patch
  482. >5 byte 2 \b, PPF 3.0 patch
  483. >>56 byte 0 \b, Imagetype BIN (any)
  484. >>56 byte 1 \b, Imagetype GI (PrimoDVD)
  485. >>57 byte 0 \b, Blockcheck disabled
  486. >>57 byte 1 \b, Blockcheck enabled
  487. >>58 byte 0 \b, Undo data not available
  488. >>58 byte 1 \b, Undo data available
  489. >6 string x \b, description: %s
  490. 0 string PPF20 Playstation Patch File version 2.0
  491. >5 byte 0 \b, PPF 1.0 patch
  492. >5 byte 1 \b, PPF 2.0 patch
  493. >>56 lelong >0 \b, size of file to patch %d
  494. >6 string x \b, description: %s
  495. 0 string PPF10 Playstation Patch File version 1.0
  496. >5 byte 0 \b, Simple Encoding
  497. >6 string x \b, description: %s
  498. # From: Daniel Dawson <ddawson@icehouse.net>
  499. # SNES9x .smv "movie" file format.
  500. 0 string SMV\x1A SNES9x input recording
  501. >0x4 lelong x \b, version %d
  502. # version 4 is latest so far
  503. >0x4 lelong <5
  504. >>0x8 ledate x \b, recorded at %s
  505. >>0xc lelong >0 \b, rerecorded %d times
  506. >>0x10 lelong x \b, %d frames long
  507. >>0x14 byte >0 \b, data for controller(s):
  508. >>>0x14 byte &0x1 #1
  509. >>>0x14 byte &0x2 #2
  510. >>>0x14 byte &0x4 #3
  511. >>>0x14 byte &0x8 #4
  512. >>>0x14 byte &0x10 #5
  513. >>0x15 byte ^0x1 \b, begins from snapshot
  514. >>0x15 byte &0x1 \b, begins from reset
  515. >>0x15 byte ^0x2 \b, NTSC standard
  516. >>0x15 byte &0x2 \b, PAL standard
  517. >>0x17 byte &0x1 \b, settings:
  518. # WIP1Timing not used as of version 4
  519. >>>0x4 lelong <4
  520. >>>>0x17 byte &0x2 WIP1Timing
  521. >>>0x17 byte &0x4 Left+Right
  522. >>>0x17 byte &0x8 VolumeEnvX
  523. >>>0x17 byte &0x10 FakeMute
  524. >>>0x17 byte &0x20 SyncSound
  525. # New flag as of version 4
  526. >>>0x4 lelong >3
  527. >>>>0x17 byte &0x80 NoCPUShutdown
  528. >>0x4 lelong <4
  529. >>>0x18 lelong >0x23
  530. >>>>0x20 leshort !0
  531. >>>>>0x20 lestring16 x \b, metadata: "%s"
  532. >>0x4 lelong >3
  533. >>>0x24 byte >0 \b, port 1:
  534. >>>>0x24 byte 1 joypad
  535. >>>>0x24 byte 2 mouse
  536. >>>>0x24 byte 3 SuperScope
  537. >>>>0x24 byte 4 Justifier
  538. >>>>0x24 byte 5 multitap
  539. >>>0x24 byte >0 \b, port 2:
  540. >>>>0x25 byte 1 joypad
  541. >>>>0x25 byte 2 mouse
  542. >>>>0x25 byte 3 SuperScope
  543. >>>>0x25 byte 4 Justifier
  544. >>>>0x25 byte 5 multitap
  545. >>>0x18 lelong >0x43
  546. >>>>0x40 leshort !0
  547. >>>>>0x40 lestring16 x \b, metadata: "%s"
  548. >>0x17 byte &0x40 \b, ROM:
  549. >>>(0x18.l-26) lelong x CRC32 0x%08x
  550. >>>(0x18.l-23) string x "%s"
  551. # Type: scummVM savegame files
  552. # From: Sven Hartge <debian@ds9.argh.org>
  553. 0 string SCVM ScummVM savegame
  554. >12 string >\0 "%s"
  555. #------------------------------------------------------------------------------
  556. # Nintendo GameCube / Wii file formats.
  557. #
  558. # Type: Nintendo GameCube/Wii common disc header data.
  559. # From: David Korth <gerbilsoft@gerbilsoft.com>
  560. # Reference: http://wiibrew.org/wiki/Wii_Disc
  561. 0 name nintendo-gcn-disc-common
  562. >0x20 string x "%.64s"
  563. >0x00 string x (%.6s
  564. >0x06 byte >0
  565. >>0x06 byte 1 \b, Disc 2
  566. >>0x06 byte 2 \b, Disc 3
  567. >>0x06 byte 3 \b, Disc 4
  568. >0x07 byte x \b, Rev.%02u)
  569. # Type: Nintendo GameCube disc image
  570. # From: David Korth <gerbilsoft@gerbilsoft.com>
  571. # Reference: http://wiibrew.org/wiki/Wii_Disc
  572. 0x1C belong 0xC2339F3D Nintendo GameCube disc image:
  573. >0 use nintendo-gcn-disc-common
  574. # Type: Nintendo GameCube embedded disc image
  575. # Commonly found on demo discs.
  576. # From: David Korth <gerbilsoft@gerbilsoft.com>
  577. # Reference: http://hitmen.c02.at/files/yagcd/yagcd/index.html#idx14.8
  578. 0 belong 0xAE0F38A2
  579. >0x0C belong 0x00100000
  580. >>(8.L+0x1C) belong 0xC2339F3D Nintendo GameCube embedded disc image:
  581. >>>(8.L) use nintendo-gcn-disc-common
  582. # Type: Nintendo Wii disc image
  583. # From: David Korth <gerbilsoft@gerbilsoft.com>
  584. # Reference: http://wiibrew.org/wiki/Wii_Disc
  585. 0x18 belong 0x5D1C9EA3 Nintendo Wii disc image:
  586. >0 use nintendo-gcn-disc-common
  587. # Type: Nintendo Wii disc image (WBFS format)
  588. # From: David Korth <gerbilsoft@gerbilsoft.com>
  589. # Reference: http://wiibrew.org/wiki/Wii_Disc
  590. 0 string WBFS
  591. >0x218 belong 0x5D1C9EA3 Nintendo Wii disc image (WBFS format):
  592. >>0x200 use nintendo-gcn-disc-common
  593. # Type: Nintendo GameCube/Wii disc image (CISO format)
  594. # NOTE: This is NOT the same as Compact ISO or PSP CISO,
  595. # though it has the same magic number.
  596. 0 string CISO
  597. # Other fields are used to determine what type of CISO this is:
  598. # - 0x04 == 0x00200000: GameCube/Wii CISO (block_size)
  599. # - 0x10 == 0x00000800: PSP CISO (ISO-9660 sector size)
  600. # - None of the above: Compact ISO.
  601. >4 lelong 0x200000
  602. >>8 byte 1
  603. >>>0x801C belong 0xC2339F3D Nintendo GameCube disc image (CISO format):
  604. >>>>0x8000 use nintendo-gcn-disc-common
  605. >>>0x8018 belong 0x5D1C9EA3 Nintendo Wii disc image (CISO format):
  606. >>>>0x8000 use nintendo-gcn-disc-common
  607. # Type: Nintendo GameCube/Wii disc image (GCZ format)
  608. # Due to zlib compression, we can't get the actual disc information.
  609. 0 lelong 0xB10BC001
  610. >4 lelong 0 Nintendo GameCube disc image (GCZ format)
  611. >4 lelong 1 Nintendo Wii disc image (GCZ format)
  612. >4 lelong >1 Nintendo GameCube/Wii disc image (GCZ format)
  613. # Type: Nintendo GameCube/Wii disc image (WDF format)
  614. 0 string WII\001DISC
  615. >8 belong 1
  616. # WDFv1
  617. >>0x54 belong 0xC2339F3D Nintendo GameCube disc image (WDFv1 format):
  618. >>>0x38 use nintendo-gcn-disc-common
  619. >>0x58 belong 0x5D1C9EA3 Nintendo Wii disc image (WDFv1 format):
  620. >>>0x38 use nintendo-gcn-disc-common
  621. >8 belong 2
  622. # WDFv2
  623. >>(12.L+0x1C) belong 0xC2339F3D Nintendo GameCube disc image (WDFv2 format):
  624. >>>(12.L) use nintendo-gcn-disc-common
  625. >>(12.L+0x18) belong 0x5D1C9EA3 Nintendo Wii disc image (WDFv2 format):
  626. >>>(12.L) use nintendo-gcn-disc-common
  627. # Type: Nintendo GameCube/Wii disc image (WIA format)
  628. 0 string WIA\001 Nintendo
  629. >0x48 belong 0 GameCube/Wii
  630. >0x48 belong 1 GameCube
  631. >0x48 belong 2 Wii
  632. >0x48 belong >2 GameCube/Wii
  633. >0x48 belong x disc image (WIA format):
  634. >>0x58 use nintendo-gcn-disc-common
  635. #------------------------------------------------------------------------------
  636. # Nintendo 3DS file formats.
  637. #
  638. # Type: Nintendo 3DS "NCSD" image. (game cards and eMMC)
  639. # From: David Korth <gerbilsoft@gerbilsoft.com>
  640. # Reference: https://www.3dbrew.org/wiki/NCSD
  641. 0x100 string NCSD
  642. >0x118 lequad 0 Nintendo 3DS Game Card image
  643. # NCCH header for partition 0. (game data)
  644. >>0x1150 string >\0 \b: "%.16s"
  645. >>0x312 byte x (Rev.%02u)
  646. >>0x118C byte 2 (New3DS only)
  647. >>0x18D byte 0 (inner device)
  648. >>0x18D byte 1 (Card1)
  649. >>0x18D byte 2 (Card2)
  650. >>0x18D byte 3 (extended device)
  651. >0x118 bequad 0x0102020202000000 Nintendo 3DS eMMC dump (Old3DS)
  652. >0x118 bequad 0x0102020203000000 Nintendo 3DS eMMC dump (New3DS)
  653. # Nintendo 3DS version code.
  654. # Reference: https://www.3dbrew.org/wiki/Titles
  655. # Format: leshort containing three fields:
  656. # - 6-bit: Major
  657. # - 6-bit: Minor
  658. # - 4-bit: Revision
  659. # NOTE: Only supporting major/minor versions from 0-15 right now.
  660. # NOTE: Should be prefixed with "v".
  661. 0 name nintendo-3ds-version-code
  662. # Raw version.
  663. >0 leshort x \b%u,
  664. # Major version.
  665. >0 leshort&0xFC00 0x0000 0
  666. >0 leshort&0xFC00 0x0400 1
  667. >0 leshort&0xFC00 0x0800 2
  668. >0 leshort&0xFC00 0x0C00 3
  669. >0 leshort&0xFC00 0x1000 4
  670. >0 leshort&0xFC00 0x1400 5
  671. >0 leshort&0xFC00 0x1800 6
  672. >0 leshort&0xFC00 0x1C00 7
  673. >0 leshort&0xFC00 0x2000 8
  674. >0 leshort&0xFC00 0x2400 9
  675. >0 leshort&0xFC00 0x2800 10
  676. >0 leshort&0xFC00 0x2C00 11
  677. >0 leshort&0xFC00 0x3000 12
  678. >0 leshort&0xFC00 0x3400 13
  679. >0 leshort&0xFC00 0x3800 14
  680. >0 leshort&0xFC00 0x3C00 15
  681. # Minor version.
  682. >0 leshort&0x03F0 0x0000 \b.0
  683. >0 leshort&0x03F0 0x0010 \b.1
  684. >0 leshort&0x03F0 0x0020 \b.2
  685. >0 leshort&0x03F0 0x0030 \b.3
  686. >0 leshort&0x03F0 0x0040 \b.4
  687. >0 leshort&0x03F0 0x0050 \b.5
  688. >0 leshort&0x03F0 0x0060 \b.6
  689. >0 leshort&0x03F0 0x0070 \b.7
  690. >0 leshort&0x03F0 0x0080 \b.8
  691. >0 leshort&0x03F0 0x0090 \b.9
  692. >0 leshort&0x03F0 0x00A0 \b.10
  693. >0 leshort&0x03F0 0x00B0 \b.11
  694. >0 leshort&0x03F0 0x00C0 \b.12
  695. >0 leshort&0x03F0 0x00D0 \b.13
  696. >0 leshort&0x03F0 0x00E0 \b.14
  697. >0 leshort&0x03F0 0x00F0 \b.15
  698. # Revision.
  699. >0 leshort&0x000F x \b.%u
  700. # Type: Nintendo 3DS "NCCH" container.
  701. # https://www.3dbrew.org/wiki/NCCH
  702. 0x100 string NCCH Nintendo 3DS
  703. >0x18D byte&2 0 File Archive (CFA)
  704. >0x18D byte&2 2 Executable Image (CXI)
  705. >0x150 string >\0 \b: "%.16s"
  706. >0x18D byte 0x05
  707. >>0x10E leshort x (Old3DS System Update v
  708. >>0x10E use nintendo-3ds-version-code
  709. >>0x10E leshort x \b)
  710. >0x18D byte 0x15
  711. >>0x10E leshort x (New3DS System Update v
  712. >>0x10E use nintendo-3ds-version-code
  713. >>0x10E leshort x \b)
  714. >0x18D byte !0x05
  715. >>0x18D byte !0x15
  716. >>>0x112 byte x (v
  717. >>>0x112 use nintendo-3ds-version-code
  718. >>>0x112 byte x \b)
  719. >0x18C byte 2 (New3DS only)
  720. # Type: Nintendo 3DS "SMDH" file. (application description)
  721. # From: David Korth <gerbilsoft@gerbilsoft.com>
  722. # Reference: https://3dbrew.org/wiki/SMDH
  723. 0 string SMDH Nintendo 3DS SMDH file
  724. >0x208 leshort !0
  725. >>0x208 lestring16 x \b: "%.128s"
  726. >>0x388 leshort !0
  727. >>>0x388 lestring16 x by %.128s
  728. >0x208 leshort 0
  729. >>0x008 leshort !0
  730. >>>0x008 lestring16 x \b: "%.128s"
  731. >>>0x188 leshort !0
  732. >>>>0x188 lestring16 x by %.128s
  733. # Type: Nintendo 3DS Homebrew Application.
  734. # From: David Korth <gerbilsoft@gerbilsoft.com>
  735. # Reference: https://3dbrew.org/wiki/3DSX_Format
  736. 0 string 3DSX Nintendo 3DS Homebrew Application (3DSX)
  737. #------------------------------------------------------------------------------
  738. # a7800: file(1) magic for the Atari 7800 raw ROM format.
  739. # From: David Korth <gerbilsoft@gerbilsoft.com>
  740. # Reference: https://sites.google.com/site/atari7800wiki/a78-header
  741. 0 byte >0
  742. >0 byte <3
  743. >>1 string ATARI7800 Atari 7800 ROM image
  744. >>>0x11 string >\0 \b: "%.32s"
  745. # Display type.
  746. >>>0x39 byte 0 (NTSC)
  747. >>>0x39 byte 1 (PAL)
  748. >>>0x36 byte&1 1 (POKEY)
  749. #------------------------------------------------------------------------------
  750. # vectrex: file(1) magic for the GCE Vectrex raw ROM format.
  751. # From: David Korth <gerbilsoft@gerbilsoft.com>
  752. # Reference: http://www.playvectrex.com/designit/chrissalo/hello1.htm
  753. #
  754. # NOTE: Title is terminated with 0x80, not 0.
  755. # The header is terminated with a 0, so that will
  756. # terminate the title as well.
  757. #
  758. 0 string g\ GCE Vectrex ROM image
  759. >0x11 string >\0 \b: "%.16s"
  760. #------------------------------------------------------------------------------
  761. # amiibo: file(1) magic for Nintendo amiibo NFC dumps.
  762. # From: David Korth <gerbilsoft@gerbilsoft.com>
  763. # Reference: https://www.3dbrew.org/wiki/Amiibo
  764. 0x00 byte 0x04
  765. >0x0A beshort 0x0FE0
  766. >>0x0C belong 0xF110FFEE
  767. >>>0x208 beshort 0x0100
  768. >>>>0x020A byte 0x0F
  769. >>>>>0x020C bequad 0x000000045F000000
  770. >>>>>>0x5B byte 0x02
  771. >>>>>>>0x54 belong x Nintendo amiibo NFC dump - amiibo ID: %08X-
  772. >>>>>>>0x58 belong x \b%08X