console 25 KB

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