<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Breaking Eggs And Making Omelettes &#187; Game Hacking</title>
	<atom:link href="http://multimedia.cx/eggs/category/game-hacking/feed/" rel="self" type="application/rss+xml" />
	<link>http://multimedia.cx/eggs</link>
	<description>Topics On Multimedia Technology and Reverse Engineering</description>
	<lastBuildDate>Sun, 29 Apr 2012 05:01:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>The 11th Hour RoQ Variation</title>
		<link>http://multimedia.cx/eggs/the-11th-hour-roq-variation/</link>
		<comments>http://multimedia.cx/eggs/the-11th-hour-roq-variation/#comments</comments>
		<pubDate>Thu, 12 Apr 2012 04:25:48 +0000</pubDate>
		<dc:creator>Multimedia Mike</dc:creator>
				<category><![CDATA[Game Hacking]]></category>
		<category><![CDATA[dreamroq]]></category>
		<category><![CDATA[Reverse Engineering]]></category>
		<category><![CDATA[roq]]></category>
		<category><![CDATA[Vector Quantization]]></category>

		<guid isPermaLink="false">http://multimedia.cx/eggs/?p=3766</guid>
		<description><![CDATA[Investigating how to play the RoQ multimedia files found on the 4-CD game The 11th Hour, the original game to use this file format]]></description>
			<content:encoded><![CDATA[<p>I have been looking at the <a href="http://wiki.multimedia.cx/index.php?title=RoQ">RoQ file format</a> almost as long as I have been doing practical multimedia hacking. However, I have never figured out how the RoQ format works on <a href="http://www.mobygames.com/game/dos/11th-hour">The 11th Hour</a>, which was the game for which the RoQ format was initially developed. When I <a href="http://multimedia.cx/mmentry-2003-03-24.html">procured the game years ago</a>, I remember finding what appeared to be RoQ files and shoving them through the open source decoders but not getting the right images out.</p>
<p>I decided to dust off that old copy of The 11th Hour and have another go at it.</p>
<p><center><br />
<a href="http://multimedia.cx/eggs/wp-content/uploads/2012/04/the-11th-hour-box-and-cdroms.jpg"><img src="http://multimedia.cx/eggs/wp-content/uploads/2012/04/the-11th-hour-box-and-cdroms.jpg" alt="" title="Photo of 11th hour box + CD-ROMs" width="400" height="263" class="aligncenter size-full wp-image-3769" /></a><br />
</center></p>
<p><strong>Baseline</strong><br />
The game consists of 4 CD-ROMs. Each disc has a media/ directory that has a series of files bearing the extension .gjd, likely the initials of one <a href="http://www.mobygames.com/developer/sheet/view/developerId,2913/">Graeme J. Devine</a>. These are resource files which are merely headerless concatenations of other files. Thus, at first glance, one file might appear to be a single RoQ file. So that&#8217;s the source of some of the difficulty: Sending an apparent RoQ .gjd file through a RoQ player will often cause the program to complain when it encounters the header of another RoQ file.</p>
<p><a href="http://samples.libav.org/game-formats/idroq/11th-hour/"><strong>I have uploaded some samples to the usual place.</strong></a></p>
<p>However, even the frames that a player can decode (before encountering a file boundary within the resource file) look wrong.</p>
<p><strong>Investigating Codebooks Using dreamroq</strong><br />
I wrote <a href="https://github.com/multimediamike/dreamroq">dreamroq</a> last year&#8211; an independent RoQ playback library targeted towards embedded systems. I aimed it at a gjd file and quickly hit a codebook error.</p>
<p>RoQ is a vector quantizer video codec that maintains a codebook of 256 2&#215;2 pixel vectors. In the Quake III and later RoQ files, these are transported using a YUV 4:2:0 colorspace&#8211; 4 Y samples, a U sample, and a V sample to represent 4 pixels. This totals 6 bytes per vector. A RoQ codebook chunk contains a field that indicates the number of 2&#215;2 vectors as well as the number of 4&#215;4 vectors. The latter vectors are each comprised of 4 2&#215;2 vectors.</p>
<p>Thus, the total size of a codebook chunk ought to be (# of 2&#215;2 vectors) * 6 + (# of 4&#215;4 vectors) * 4.</p>
<p><em>However, this is not the case with The 11th Hour RoQ files.</em></p>
<p><strong>Longer Codebooks And Mystery Colorspace</strong><br />
Juggling the numbers for a few of the codebook chunks, I empirically determined that the 2&#215;2 vectors are represented by <strong>10 bytes instead of 6</strong>. Now I need to determine what exactly these 10 bytes represent.</p>
<p>I should note that I suspect that everything else about these files lines up with successive generations of the format. For example if a file has 640&#215;320 resolution, that amounts to 40&#215;20 macroblocks. dreamroq iterates through 40&#215;20 8&#215;8 blocks and precisely exhausts the VQ bitstream. So that all looks valid. I&#8217;m just puzzled on the codebook format.</p>
<p>Here is an example codebook dump:<br />
<span id="more-3766"></span></p>
<pre>
ID 0x1002, len = 0x0000014C, args = 0x1C0D
  0: 00 00 00 00 00 00 00 00 80 80
  1: 08 07 00 00 1F 5B 00 00 7E 81
  2: 00 00 15 0F 00 00 40 3B 7F 84
  3: 00 00 00 00 3A 5F 18 13 7E 84
  4: 00 00 00 00 3B 63 1B 17 7E 85
  5: 18 13 00 00 3C 63 00 00 7E 88
  6: 00 00 00 00 00 00 59 3B 7F 81
  7: 00 00 56 23 00 00 61 2B 80 80
  8: 00 00 2F 13 00 00 79 63 81 83
  9: 00 00 00 00 5E 3F AC 9B 7E 81
  10: 1B 17 00 00 B6 EF 77 AB 7E 85
  11: 2E 43 00 00 C1 F7 75 AF 7D 88
  12: 6A AB 28 5F B6 B3 8C B3 80 8A
  13: 86 BF 0A 03 D5 FF 3A 5F 7C 8C
  14: 00 00 9E 6B AB 97 F5 EF 7F 80
  15: 86 73 C8 CB B6 B7 B7 B7 85 8B
  16: 31 17 84 6B E7 EF FF FF 7E 81
  17: 79 AF 3B 5F FC FF E2 FF 7D 87
  18: DC FF AE EF B3 B3 B8 B3 85 8B
  19: EF FF F5 FF BA B7 B6 B7 88 8B
  20: F8 FF F7 FF B3 B7 B7 B7 88 8B
  21: FB FF FB FF B8 B3 B4 B3 85 88
  22: F7 FF F7 FF B7 B7 B9 B7 87 8B
  23: FD FF FE FF B9 B7 BB B7 85 8A
  24: E4 FF B7 EF FF FF FF FF 7F 83
  25: FF FF AC EB FF FF FC FF 7F 83
  26: CC C7 F7 FF FF FF FF FF 7F 81
  27: FF FF FE FF FF FF FF FF 80 80
</pre>
<p>Note that 0x14C (the chunk size) = 332, 0x1C and 0x0D (the chunk arguments &#8212; count of 2&#215;2 and 4&#215;4 vectors, respectively) are 28 and 13. 28 * 10 + 13 * 4 = 332, so the numbers check out.</p>
<p>Do you see any patterns in the codebook? Here are some things I tried:</p>
<ul>
<li>Treating the last 2 bytes as U &#038; V and treating the first 4 as the 4 Y samples:<br />
<center><br />
<img src="http://multimedia.cx/eggs/wp-content/uploads/2012/04/roq-y8.png" alt="" title="RoQ, selected 8-bit Y samples" width="70" height="60" class="aligncenter size-full wp-image-3773" /><br />
</center>
</li>
<li>Treating the last 2 bytes as U &#038; V and treating the first 8 as 4 16-bit little-endian Y samples:<br />
<center><br />
<img src="http://multimedia.cx/eggs/wp-content/uploads/2012/04/roq-y16.png" alt="" title="RoQ, 16-bit Y samples" width="70" height="60" class="aligncenter size-full wp-image-3774" /><br />
</center>
</li>
<li>Disregarding the final 2 bytes and treating the first 8 bytes as 4 RGB565 pixels (both little- and big-endian, respectively, shown here):<br />
<center><br />
<img src="http://multimedia.cx/eggs/wp-content/uploads/2012/04/roq-rgb16le.png" alt="" title="RoQ, 16-bit little-endian RGB" width="70" height="60" class="aligncenter size-full wp-image-3775" /> <img src="http://multimedia.cx/eggs/wp-content/uploads/2012/04/roq-rgb16be.png" alt="" title="RoQ, 16-bit big-endian RGB" width="70" height="60" class="aligncenter size-full wp-image-3776" /><br />
</center>
</li>
<li>Based on the type of data I&#8217;m seeing in these movies (which appears to be intended as overlays), I figured that some of these bits might indicate transparency; here is 15-bit big-endian RGB which disregards the top bit of each pixel:<br />
<center><br />
<img src="http://multimedia.cx/eggs/wp-content/uploads/2012/04/roq-rgb15.png" alt="" title="RoQ, 15-bit RGB" width="70" height="60" class="aligncenter size-full wp-image-3777" /><br />
</center>
</li>
</ul>
<p>These images are taken from the uploaded sample bdpuz.gjd, apparently a component of <a href="http://www.mobygames.com/game/dos/11th-hour/screenshots/gameShotId,50221/">the puzzle represented in this screenshot</a>.</p>
<p><strong>Unseen Types</strong><br />
It has long been rumored that early RoQ files could contain JPEG images. I finally found one such specimen. One of the files bundled early in the uploaded fhpuz.gjd sample contains a JPEG frame. It&#8217;s a standard JFIF file and can easily be decoded after separating the bytes from the resource using &#8216;dd&#8217;. JPEGs serve as intraframes in the coding scheme, with successive RoQ frames moving objects on top.</p>
<p>However, a new chunk type showed up as well, one identified by 0&#215;1030. I have never encountered this type. Where could I possibly find data about this? Fortunately, <a href="https://github.com/id-Software/">iD Games recently posted all of their open sourced games at Github</a>. Reading through <a href="https://github.com/id-Software/Quake-III-Arena/blob/master/code/client/cl_cin.c">the code for their official RoQ decoder</a>, I see that this is called a RoQ_PACKET. The name and the code behind it are both supremely unhelpful. The code is basically a no-op. The payloads of the various RoQ_PACKETs from one sample are observed to be either 8784, 14752, or 14760 bytes in length. It&#8217;s very likely that this serves the same purpose as the JPEG intraframes.</p>
<p><strong>Other Tidbits</strong><br />
I read through the readme.txt on the first game disc and found this nugget:</p>
<pre>
        g)      Animations displayed normally or in SPOOKY MODE

                SPOOKY MODE is blue-tinted grayscale with color cursors, puzzle
                and game pieces.  It is the preferred display setting of the
                developers at Trilobyte.  Just for fun, try out the SPOOKY
                MODE.
</pre>
<p>The <a href="http://www.mobygames.com/game/dos/11th-hour/screenshots">MobyGames screenshot page</a> has a number of screenshots labeled as being captured in spooky mode. Color tricks?</p>
<p>Meanwhile, another twist arose as I kept tweaking dreamroq to deal with more RoQ weirdness: After modifying my dreamroq code to handle these 10-byte vectors, it eventually chokes on another codebook. These codebooks happen to have 6-byte vectors again! Fortunately, I was already working on a scheme to automatically detect which codebook is in play (plugging the numbers into a formula and seeing which vector size checks out).</p>
]]></content:encoded>
			<wfw:commentRss>http://multimedia.cx/eggs/the-11th-hour-roq-variation/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Pushing Projects to Github</title>
		<link>http://multimedia.cx/eggs/pushing-projects-to-github/</link>
		<comments>http://multimedia.cx/eggs/pushing-projects-to-github/#comments</comments>
		<pubDate>Fri, 17 Feb 2012 05:25:11 +0000</pubDate>
		<dc:creator>Multimedia Mike</dc:creator>
				<category><![CDATA[Game Hacking]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://multimedia.cx/eggs/?p=3722</guid>
		<description><![CDATA[I pushed some old projects up to Github: GhettoRSS, xbfuse, gcfuse]]></description>
			<content:encoded><![CDATA[<p>I finally got around to importing some old projects into <a href="https://github.com/multimediamike">my Github account</a>. I guess it&#8217;s good to have a backup out there in the cloud.</p>
<p><strong>GhettoRSS</strong><br />
<a href="https://github.com/multimediamike/GhettoRSS">https://github.com/multimediamike/GhettoRSS</a><br />
I describe this as a true offline RSS reader. Technically, it&#8217;s arguably not a true offline RSS reader. Rather, it does what most people <em>actually want</em> an offline RSS reader to do.</p>
<p>I wrote this about 2 years ago when I had a long daily train ride with a disconnected netbook. I quickly learned that I couldn&#8217;t count on offline RSS readers simply because most RSS feeds to not contain much meat. Thus, I created a program that follows URLs in RSS feeds, downloads web pages and supporting images and CSS files, and caches them in an offline database which can be read via a local web browser.</p>
<p>I wrote more information about this little project 2 years ago (<a href="http://multimedia.cx/eggs/my-own-offline-rss-reader/">here is part 1</a> and <a href="http://multimedia.cx/eggs/my-own-offline-rss-reader-part-2/">here is part 2</a>). I fixed a few bugs in preparation for posting it but I probably won&#8217;t work on this anymore since I don&#8217;t have any use for it (the commute is long gone, but I didn&#8217;t even use it when I was commuting because I decided I just didn&#8217;t care enough to read the feeds on the train).</p>
<p><strong>xbfuse</strong><br />
<a href="https://github.com/multimediamike/xbfuse">https://github.com/multimediamike/xbfuse</a><br />
This is a FUSE module for mounting Xbox/360 optical disc filesystems. <a href="http://multimedia.cx/eggs/xbfuse/">Here is when I first discussed it.</a> The tool has had <a href="http://multimedia.cx/xbfuse/">its own little homepage</a> for a long time. This tool has seen some development, as I learned from Googling for &#8220;xbfuse&#8221;. Regrettably, no one who has modified the tool has ever contacted me about it (at least, not that I can recall). This is unfortunate because the patches I have seen floating around which fix my xbfuse for various installations usually boil down replacing many occurrences of an include path in the autotool-generated build system. There is probably a simpler, cleaner fix.</p>
<p><strong>gcfuse</strong><br />
<a href="https://github.com/multimediamike/gcfuse">https://github.com/multimediamike/gcfuse</a><br />
Written prior to xbfuse, this is a FUSE module for mounting GameCube optical disc filesystems. I first discussed this <a href="http://multimedia.cx/eggs/gcfuse/">here</a> and <a href="http://multimedia.cx/eggs/gcfuse-exe/">here</a>. This tool has not seen too much direct development although someone eventually used it as the basis for <a href="http://wiibrew.org/wiki/Wiifuse">WiiFuse</a> which, as you can predict, mounts optical disc filesystems from Nintendo Wii games.</p>
]]></content:encoded>
			<wfw:commentRss>http://multimedia.cx/eggs/pushing-projects-to-github/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Origin Crusader Media</title>
		<link>http://multimedia.cx/eggs/origin-crusader-media/</link>
		<comments>http://multimedia.cx/eggs/origin-crusader-media/#comments</comments>
		<pubDate>Tue, 14 Feb 2012 06:45:19 +0000</pubDate>
		<dc:creator>Multimedia Mike</dc:creator>
				<category><![CDATA[Game Hacking]]></category>

		<guid isPermaLink="false">http://multimedia.cx/eggs/?p=3711</guid>
		<description><![CDATA[Crusader: No Remorse from Origin has some custom video files and music tracker format]]></description>
			<content:encoded><![CDATA[<p>A gleaming copy of the old Origin game <a href="http://www.mobygames.com/game/crusader-no-remorse">Crusader: No Remorse</a> showed up today:</p>
<p><center><br />
<a href="http://www.mobygames.com/game/crusader-no-remorse"><img src="http://multimedia.cx/eggs/wp-content/uploads/2012/02/crusader-no-remorse-cdrom-classics-gold-box.jpg" alt="" title="Crusader: No Remorse -- CD-ROM Classics Gold release" width="250" height="294" class="aligncenter size-full wp-image-3712" /></a><br />
</center></p>
<p>Immediately, I delved in expecting to find <a href="http://wiki.multimedia.cx/index.php?title=Origin_Xan_Codec">Xan-encoded AVI files</a> that would play perfectly using FFmpeg/Libav. Instead, I found a directory labeled flics/ that indeed has a lot of AVI files, but not in Xan. The programs attempt to interpret them as raw RGB. The strangest thing is the first frame often looks correct, if upside down:</p>
<p><center><br />
<img src="http://multimedia.cx/eggs/wp-content/uploads/2012/02/crusader-screenshot-001.png" alt="" title="Strange screenshot from Crusader: No Remorse" width="240" height="180" class="aligncenter size-full wp-image-3714" /><br />
</center></p>
<p>The first file I peered inside had the video FourCC &#8216;RRV1&#8242;. Searching for this led me to <a href="http://cyberionsystems.com/echosector/index.php?topic=537.0">this discussion forum</a> where people have already been hacking on this very format (Origin games invariably get a heap of lasting love). The forum participants have observed that 3 codecs are in play in this flics/ directory, including &#8216;RRV1&#8242;, &#8216;RRV2&#8242;, and &#8216;JYV1&#8242;, which apparently correspond to the initials of certain developers. The reason that the programs identify the files as raw RGB is because the FourCCs don&#8217;t appear everywhere that they&#8217;re supposed to. Additionally, there are several trailers for other Origin/EA games stored in Cinepak format elsewhere on the disc.</p>
<p>It seems that I&#8217;m the person who <a href="http://wiki.multimedia.cx/index.php?title=Origin_Xan_Codec&#038;diff=2881&#038;oldid=2841">added this title to the Xan wiki page</a>, obviously with no first-hand evidence to back it up. Meanwhile, the forum participants speculate that the files are descended from the old Autodesk FLIC format (which would explain why they live in a directory called flics/). Corroborating strings extracted from the CRUSADER.EXE file include &#8220;FlicWait&#8221;, &#8220;FlicPlayer&#8221;, &#8220;Flic %s not found.&#8221;, &#8220;flicpath&#8221;, and &#8220;FLICPLAY.C&#8221;.</p>
<p>The disc also features a sound/ directory which contains AMF files. Suxen Drol already documented these on the wiki as <a href="http://wiki.multimedia.cx/index.php?title=Asylum_Music_Format">Asylum Media Format files</a>. The disc contains an ASYLUM.DLL file as well as a utility called MOD2AMF.EXE. The latter works beautifully on a random MOD file I had laying around. The AMF file is a bit larger.</p>
<p><a href="http://samples.mplayerhq.hu/game-formats/crusader-no-remorse/">Samples for all 3 FourCCs can be found here</a>, while <a href="http://samples.mplayerhq.hu/game-formats/crusader-no-remorse/amf/">the AMF files and associated utilities are here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://multimedia.cx/eggs/origin-crusader-media/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Samples RSS And Flashback Samples</title>
		<link>http://multimedia.cx/eggs/rss-and-flashback-samples/</link>
		<comments>http://multimedia.cx/eggs/rss-and-flashback-samples/#comments</comments>
		<pubDate>Thu, 22 Dec 2011 07:06:46 +0000</pubDate>
		<dc:creator>Multimedia Mike</dc:creator>
				<category><![CDATA[Game Hacking]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://multimedia.cx/eggs/?p=3648</guid>
		<description><![CDATA[There is now a RSS feed for our vast samples repository-- stay up to date; also, samples from 2 games (Flashback and Mario Teaches Typing)]]></description>
			<content:encoded><![CDATA[<p>I made good on <a href="http://multimedia.cx/eggs/the-new-samples-regime/">my claim that I would create an RSS feed</a> for the samples repository. </p>
<p><strong><a href="http://samples.mplayerhq.hu/samples-rss.xml">Here is the link to the samples RSS feed [ http://samples.mplayerhq.hu/samples-rss.xml ].</a></strong> Also, <a href="https://github.com/multimediamike/multimedia-samples-rss">here is the Python source code I threw together</a> for the task.</p>
<p><em>I just want to check: I&#8217;m not the only person who still relies on RSS these days, right? The tech press has been cheerfully proclaiming its demise for some time now. But then, they have been proclaiming the same for Adobe Flash as well.</em></p>
<p>I&#8217;m no expert in RSS. If you have any suggestions for how to improve the features presented in the feed, please let me know. And, of course, keep the samples coming. This script should help provide more visibility for a broader audience.</p>
<p><strong>Mario and Flashback Samples</strong><br />
<a href="http://multimedia.cx/eggs/more-cinepak-madness/#comment-178856">Thanks to LuigiBlood</a> who sent in some samples that allowed me to test out my new script for automatically syncing the repositories and updating the samples RSS feed. First, there are <a href="http://samples.mplayerhq.hu/game-formats/flashback/">CPC multimedia files</a> from the Japanese 3DO port of <a href="http://www.mobygames.com/game/flashback-the-quest-for-identity">Flashback: The Quest for Identity</a>. Then, there is an Interplay MVE file on the CD version of <a href="http://www.mobygames.com/game/mario-teaches-typing">Mario Teaches Typing</a> in which the video doesn&#8217;t decode correctly.</p>
<p>LuigiBlood also sent in another file from the latter game. It&#8217;s big and has the extension .AV. It could be a multimedia file as it appears to have a palette and PCM audio inside. But there&#8217;s no header and I&#8217;m a bit unsure about how to catalog it.</p>
]]></content:encoded>
			<wfw:commentRss>http://multimedia.cx/eggs/rss-and-flashback-samples/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Space Adventure CD-ROM</title>
		<link>http://multimedia.cx/eggs/space-adventure-cd-rom/</link>
		<comments>http://multimedia.cx/eggs/space-adventure-cd-rom/#comments</comments>
		<pubDate>Sat, 01 Oct 2011 05:55:46 +0000</pubDate>
		<dc:creator>Multimedia Mike</dc:creator>
				<category><![CDATA[Game Hacking]]></category>

		<guid isPermaLink="false">http://multimedia.cx/eggs/?p=3586</guid>
		<description><![CDATA[Multimedia format archaeology featuring a 1993 CD-ROM title named Space Adventure]]></description>
			<content:encoded><![CDATA[<p>I <a href="http://games.multimedia.cx/acquisition-log-starcraft-ii/">acquired a CD-ROM</a> entitled <a href="http://www.mobygames.com/game/dos/space-adventure">Space Adventure</a> by Knowledge Adventure (I like these people; they make decent, entertaining educational games). The physical media displays a copyright date of 1993, very early in the multimedia era.</p>
<p><center><br />
<img src="http://multimedia.cx/eggs/wp-content/uploads/2011/09/space-adventure-space-movie.png" alt="" title="Space Adventure: Space Movies menu" width="477" height="307" class="aligncenter size-full wp-image-3590" /><br />
</center></p>
<p>This 1993 CD-ROM makes proud use of multimedia files. What kind? There&#8217;s a movies/ directory with 17 .mov files. It would be way too simple if these were QuickTime files, though. These represent a custom format, and video-only since a separate sounds/ directory contains .snd files with filenames corresponding to the .mov files. The .snd files are actually <a href="http://wiki.multimedia.cx/index.php?title=Creative_Voice">Creative Voice (a.k.a. VOC) files</a>. As for this MOV format, <a href="http://wiki.multimedia.cx/index.php?title=Space_Adventure_MOV">wiki page</a> and <a href="http://samples.mplayerhq.hu/game-formats/space-adventure-mov/">samples</a>.</p>
<p><center><br />
<img src="http://multimedia.cx/eggs/wp-content/uploads/2011/09/space-adventure-saturn-fly-by.jpg" alt="" title="Space Adventure: movie of Saturn fly-by" width="500" height="333" class="aligncenter size-full wp-image-3593" /><br />
</center></p>
<p>I was also surprised to find the binary ultrasnd.exe file among the drivers on the disc. <a href="http://multimedia.cx/eggs/ode-to-the-gravis-ultrasound/">The Gravis UltraSound</a> was released in 1992. The sound setup utility does not have an option for the GUS, however. No matter since DOSBox has great SB/Pro/16 emulation.</p>
<p>I&#8217;m also a bit puzzled about why the DOSBox screenshots are 720 x 480 (posted here are various cropping and resizings).</p>
]]></content:encoded>
			<wfw:commentRss>http://multimedia.cx/eggs/space-adventure-cd-rom/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Metal Gear Solid VP3 Easter Egg</title>
		<link>http://multimedia.cx/eggs/mgs-vp3-easter-egg/</link>
		<comments>http://multimedia.cx/eggs/mgs-vp3-easter-egg/#comments</comments>
		<pubDate>Thu, 04 Aug 2011 05:19:13 +0000</pubDate>
		<dc:creator>Multimedia Mike</dc:creator>
				<category><![CDATA[Game Hacking]]></category>

		<guid isPermaLink="false">http://multimedia.cx/eggs/?p=3510</guid>
		<description><![CDATA[Metal Gear Solid: The Twin Snakes uses VP3; here's something weird I found in one of the videos]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.mobygames.com/game/gamecube/metal-gear-solid-the-twin-snakes">Metal Gear Solid: The Twin Snakes for the Nintendo GameCube</a> is very heavy on the cutscenes. Most of them are animated in real-time but there are a bunch of clips &#8212; normally of a more photo-realistic nature &#8212; that the developers needed to compress using a conventional video codec. What did they decide to use for this task? On2 VP3 (forerunner of Theora) in a custom transport format. This is only the second game I have seen in the wild that uses pure On2 VP3 (<a href="http://multimedia.cx/eggs/vp3-in-the-wild/">first was a horse game</a>). Reimar and I <a href="http://wiki.multimedia.cx/index.php?title=Metal_Gear_Solid_VP3">sorted out most of the details</a> sometime ago. I sat down today and wrote a <a href="http://ffmpeg.org/">FFmpeg</a> / <a href="http://libav.org/">Libav</a> demuxer for the format, mostly to prove to myself that I still could.</p>
<p>Things went pretty smoothly. We suspected that there was an integer field that indicated the frame rate, but 18 fps is a bit strange. I kept fixating on a header field that read <code>0x41F00000</code>. Where have I seen that number before? Oh, of course &#8212; it&#8217;s the number 30.0 expressed as an IEEE 32-bit float. <a href="http://wiki.multimedia.cx/index.php?title=4xm_Format">The 4XM format</a> pulled the same trick.</p>
<p><strong>Hexadecimal Easter Egg</strong><br />
I know I finished the game years ago but I really can&#8217;t recall any of the clips present in <a href="http://samples.mplayerhq.hu/game-formats/mgs1-vp3/">the samples directory</a>. The file mgs1-60.vp3 contains a computer screen granting the player access and illustrates this with a hexdump. It looks something like this:</p>
<p><center><br />
<img src="http://multimedia.cx/eggs/wp-content/uploads/2011/08/metal-gear-solid-hexdump.jpg" alt="" title="Metal Gear Solid: Hexdump" width="320" height="240" class="aligncenter size-full wp-image-3512" /><br />
</center></p>
<p>Funny, there are only 22 bytes on a line when there should be 32 according to the offsets. But, leave it to me to try to figure out what the file type is, regardless. I squinted and copied the first 22 bytes into a file:</p>
<pre>
 1F 8B 08 00   85 E2 17 38   00 03 EC 3A   0D 78 54 D5
 38 00 03 EC   3A 0D
</pre>
<p>And the answer to the big question:</p>
<pre>
$ file mgsfile
mgsfile: gzip compressed data, from Unix, last modified: Wed Oct 27 22:43:33 1999
</pre>
<p>A gzip&#8217;d file from 1999. I don&#8217;t know why I find this stuff so interesting, but I do. I guess it&#8217;s no more and less strange than writing playback systems like this.</p>
]]></content:encoded>
			<wfw:commentRss>http://multimedia.cx/eggs/mgs-vp3-easter-egg/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Multimedia Exploration Journal: The Past Doesn&#8217;t Die</title>
		<link>http://multimedia.cx/eggs/mmjournal-the-past-doesnt-die/</link>
		<comments>http://multimedia.cx/eggs/mmjournal-the-past-doesnt-die/#comments</comments>
		<pubDate>Tue, 12 Jul 2011 05:51:18 +0000</pubDate>
		<dc:creator>Multimedia Mike</dc:creator>
				<category><![CDATA[Game Hacking]]></category>

		<guid isPermaLink="false">http://multimedia.cx/eggs/?p=3483</guid>
		<description><![CDATA[Custom Cyclemania video format spread across multiple file types; Interplay ACMP files which might have ACOMP audio data]]></description>
			<content:encoded><![CDATA[<p><a href="http://games.multimedia.cx/acquisition-log-strategic-acquisition/">New haul of games</a>, new (old) multimedia formats.</p>
<p><strong>Lords of Midnight</strong><br />
Check out the <a href="http://www.mobygames.com/game/dos/lords-of-midnight/cover-art/gameCoverId,29530/">box copy scan for Lords of Midnight</a> in MobyGames. In particular, I&#8217;d like to call your attention to this little blurb:</p>
<p><center><br />
<img src="http://multimedia.cx/eggs/wp-content/uploads/2011/07/lords-of-midnight-box-copy.jpg" alt="" title="Lords of Midnight puzzling CD-ROM box blurb" width="197" height="164" class="aligncenter size-full wp-image-3485" /><br />
</center></p>
<p>Ahem, &#8220;Journey through an immense world &#8212; the equivalent of 8 CD-ROMs.&#8221; Yet, when I procured the game, it only came on a single CD-ROM. It&#8217;s definitely a CD-ROM (says so on the disc) and, coming from 1995, certainly predates the earliest DVD-ROMs (which can easily store 8 CD-ROMs on a disc). Thus, I wanted to jump in a see if they were using some phenomenal compression in order to squeeze so much info into 600 or so megabytes.</p>
<p>I was surprised to see the contents of the disc clocking in at just under 40 megabytes. An intro movie and an outro movie account for 75% of that. Format? None other than that curious ASCII anomaly, <a href="http://wiki.multimedia.cx/index.php?title=ARMovie">ARMovie/RPL</a> with <a href="http://wiki.multimedia.cx/index.php?title=Escape_122">Escape 122 codec data</a>.</p>
<p><strong>Cyclemania</strong></p>
<p><center><br />
<img src="http://multimedia.cx/eggs/wp-content/uploads/2011/07/cyclemania-cover.jpg" alt="" title="Cyclemania jewel case cover" width="225" height="222" class="aligncenter size-full wp-image-3488" /><br />
</center></p>
<p><a href="http://www.mobygames.com/game/dos/cyclemania">Cyclemania</a> is one of those FMV backdrop action games, but with a motorcycle theme. I had a good feeling I would find some odd multimedia artifacts here and the game didn&#8217;t disappoint. The videos are apparently handled using 3-4 discrete files per animation. I&#8217;ve documented my cursory guesses and linked some samples <a href="http://wiki.multimedia.cx/index.php?title=Cyclemania_Video">at the new MultimediaWiki page</a>.</p>
<p><strong>Interplay ACMP</strong><br />
This is unrelated to this particular acquistion, but I was contacted today about audio files harvested from the 1993 DOS game <a href="http://www.mobygames.com/game/dos/star-trek-judgment-rites">Star Trek: Judgment Rites</a>. The files begin with the ASCII signature &#8220;Interplay ACMP Data&#8221;. This reminds me of <a href="http://wiki.multimedia.cx/index.php?title=Interplay_MVE">Interplay MVE</a> files which begin with the similar string &#8220;Interplay MVE File&#8221;. My theory is that these files use the <a href="http://drdobbs.com/database/184408798">ACOMP</a> compression format, though I&#8217;m still trying to make it fit.</p>
<p><a href="http://wiki.multimedia.cx/index.php?title=Interplay_ACMP">Wiki and samples</a> are available as usual if you&#8217;d like to add your own research.</p>
]]></content:encoded>
			<wfw:commentRss>http://multimedia.cx/eggs/mmjournal-the-past-doesnt-die/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SNES Hardware Compression</title>
		<link>http://multimedia.cx/eggs/snes-hardware-compression/</link>
		<comments>http://multimedia.cx/eggs/snes-hardware-compression/#comments</comments>
		<pubDate>Thu, 16 Jun 2011 07:01:43 +0000</pubDate>
		<dc:creator>Multimedia Mike</dc:creator>
				<category><![CDATA[Game Hacking]]></category>

		<guid isPermaLink="false">http://multimedia.cx/eggs/?p=3440</guid>
		<description><![CDATA[A survey of hardware compression schemes supported by various SNES coprocessors]]></description>
			<content:encoded><![CDATA[<p>I was browsing the source code for some <a href="http://en.wikipedia.org/wiki/Super_Nintendo_Entertainment_System">Super Nintendo Entertainment System (SNES)</a> emulators recently. I learned some interesting things about compression hardware. I had previously uncovered <a href="http://multimedia.cx/eggs/nes-compression/">one compression algorithm used in an SNES title</a> but that was implemented in software.</p>
<p>SNES game cartridges &#8212; being all hardware &#8212; were at liberty to expand the hardware capabilities of the base system by adding new processors. The most well-known of these processors was the <a href="http://en.wikipedia.org/wiki/Super_FX">Super FX</a> which allows for basic polygon graphical rendering, powering such games as <a href="http://www.mobygames.com/game/star-fox_">Star Fox</a>. It was by no means the only such add-on processor, though. <a href="http://en.wikipedia.org/wiki/List_of_Super_NES_enhancement_chips">Here is a Wikipedia page of all the enhancement chips used in assorted SNES games.</a> A number of them mention compression and so I delved into the emulators to find the details:</p>
<ul>
<li>The Super FX is listed in Wikipedia vaguely as being able to decompress graphics. I see no reference to decompression in emulator source code.</li>
<li>DSP-3 emulation source code makes reference to LZ-type compression as well as tree/symbol decoding. I&#8217;m not sure if the latter is a component of the former. Wikipedia lists the chip as supporting &#8220;Shannon-Fano bitstream decompression.&#8221;</li>
<li>Similar to Super FX, the SA-1 chip is listed in Wikipedia as having some compression capabilities. Again, either that&#8217;s not true or none of the games that use the chip (notably <a href="http://www.mobygames.com/game/super-mario-rpg-legend-of-the-seven-stars">Super Mario RPG</a>) make use of the feature.</li>
<li>The S-DD1 chip uses arithmetic and Golomb encoding for compressing graphics. Wikipedia refers to this as the ABS Lossless Entropy Algorithm. Googling for further details on that algorithm name yields no results, but I suspect it&#8217;s unrelated to anti-lock brakes. The algorithm is alleged to allow <a href="http://www.mobygames.com/game/snes/star-ocean">Star Ocean</a> to smash 13 MB of graphics into a 4 MB cartridge ROM (largest size of an SNES cartridge).</li>
<li>The SPC7110 can decompress data using a combination of arithmetic coding and <a href="http://en.wikipedia.org/wiki/Z-order_curve">Z-curve/Morton curve</a> reordering.</li>
</ul>
<p>No, I don&#8217;t plan to implement codecs for these schemes. But it&#8217;s always comforting to know that I <em>could</em>.</p>
<p>Not directly a compression scheme, but still a curious item is <a href="http://byuu.org/snes/msu1/">the MSU1 concept</a> put forth by the <a href="http://byuu.org/bsnes/">bsnes</a> emulator. This is a hypothetical coprocessor implemented by bsnes that gives an emulated cartridge access to a 4 GB address space. What to do with all this space? Allow for the playback of uncompressed PCM audio as well as uncompressed video at 240x144x256 colors @ 30 fps. According to the docs and the source code, the latter feature doesn&#8217;t appear to be implemented, though; only the raw PCM playback.</p>
]]></content:encoded>
			<wfw:commentRss>http://multimedia.cx/eggs/snes-hardware-compression/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Cracking Aztec Game Audio</title>
		<link>http://multimedia.cx/eggs/cracking-aztec-game-audio/</link>
		<comments>http://multimedia.cx/eggs/cracking-aztec-game-audio/#comments</comments>
		<pubDate>Tue, 07 Jun 2011 06:01:24 +0000</pubDate>
		<dc:creator>Multimedia Mike</dc:creator>
				<category><![CDATA[Game Hacking]]></category>

		<guid isPermaLink="false">http://multimedia.cx/eggs/?p=3407</guid>
		<description><![CDATA[A quick game hacking challenge]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a mild multimedia-related reverse engineering challenge for you. It&#8217;s pretty straightforward for those skilled in the art.</p>
<p><strong>The Setup</strong><br />
One side effect of running this ridiculously niche interest blog at the intersection of multimedia, reverse engineering, and game hacking is that people occasionally contact me for assistance on those very matters. So it was when one of my <a href="http://mobygames.com/">MobyGames</a> peers asked if I can help to extract some music from a game called <a href="http://www.mobygames.com/game/windows/aztec-wars">Aztec Wars</a>. The game consists of 2 discs, each with a music.xbe file that contains multiple tunes and is hundreds of megabytes large.</p>
<p><center><br />
<a href="http://www.mobygames.com/game/windows/aztec-wars"><img src="http://multimedia.cx/eggs/wp-content/uploads/2011/06/aztec-wars-cover.jpg" alt="" title="Aztec Wars cover" width="120" height="166" class="aligncenter size-full wp-image-3408" /><br />
</a></center></p>
<p>That&#8217;s all the data I received from the first email. At first I&#8217;m wondering what makes people think I have some magical insight into cracking these formats with such little information. Ordinarily, I would need to have the entire data file to work with and possibly the game binaries. But I didn&#8217;t want to ask him to upload hundreds of megabytes of data and I didn&#8217;t feel like downloading it; commitment issues and all.</p>
<p>But then I gathered a little confidence and remembered that the .xbe files are probably just Game Resource Archive Formats (GRAF) which are, traditionally, absurdly simple. I asked my colleague to send me a hexdump of the first kilobyte of one of the .xbe GRAFs (<code>'hexdump -C -n 1024 music.xbe &gt; file'</code>) as well as the total file size of the GRAF.</p>
<p><strong>The Hexdump</strong><br />
The first music.xbe file is 192817376 bytes large. These are the first <strike>1024</strike> <em>144</em> bytes (more than enough):</p>
<pre>
00000000  01 00 00 00 60 04 00 00  14 00 00 00 01 00 00 00  |....`...........|
00000010  0d 00 00 00 48 00 00 00  94 39 63 01 1c a4 21 03  |....H....9c..¤!.|
00000020  7a d2 54 04 04 28 ad 05  d8 88 fd 06 d8 88 fd 06  |zÒT..(­.Ø.ý.Ø.ý.|
00000030  2a 6e 46 08 2a 6e 46 08  2a 6e 46 08 2a 6e 46 08  |*nF.*nF.*nF.*nF.|
00000040  50 13 2f 0a e0 28 7e 0b  52 49 46 46 44 39 63 01  |P./.à(~.RIFFD9c.|
00000050  57 41 56 45 66 6d 74 20  10 00 00 00 01 00 02 00  |WAVEfmt ........|
00000060  44 ac 00 00 10 b1 02 00  04 00 10 00 64 61 74 61  |D¬...±......data|
00000070  fc 13 63 01 00 00 00 00  00 00 00 00 00 00 00 00  |ü.c.............|
00000080  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
</pre>
<p><strong>The Challenge</strong><br />
Armed with only the information in the foregoing section, figure out a method for extracting all the audio files in that file and advise on their playback/conversion. Ideally, this method should require minimal effort from both you and the person on the other end of the conversation.</p>
<p><strong>The Resolution</strong><br />
The reason I ask is because I came up with a solution but knew, deep down, that there must be a slightly easier way. How would you solve this?</p>
<p><a href="http://www.youtube.com/playlist?p=PL4165E0DB23EA9865">The music files in question are now preserved on YouTube</a> (until they see fit to remove them for one reason or another).</p>
]]></content:encoded>
			<wfw:commentRss>http://multimedia.cx/eggs/cracking-aztec-game-audio/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Revisiting Nosefart and Discovering GME</title>
		<link>http://multimedia.cx/eggs/nosefart-and-gme/</link>
		<comments>http://multimedia.cx/eggs/nosefart-and-gme/#comments</comments>
		<pubDate>Mon, 30 May 2011 05:30:49 +0000</pubDate>
		<dc:creator>Multimedia Mike</dc:creator>
				<category><![CDATA[Game Hacking]]></category>

		<guid isPermaLink="false">http://multimedia.cx/eggs/?p=3373</guid>
		<description><![CDATA[Methods for playing old video game music]]></description>
			<content:encoded><![CDATA[<p>I found the following screenshot buried deep in an old directory structure of mine:</p>
<p><center><br />
<img src="http://multimedia.cx/eggs/wp-content/uploads/2011/05/knosefart.png" alt="" title="Knosefart -- proposed KDE frontend to the Nosefart player" width="308" height="253" class="aligncenter size-full wp-image-3375" /><br />
</center></p>
<p>I tried to recall how this screenshot came to exist. Had I actually created a functional KDE frontend to Nosefart yet neglected to release it? I think it&#8217;s more likely that I used some designer tool (possibly <a href="http://kdevelop.org/">KDevelop</a>) to prototype a frontend. This would have been sometime in 2000.</p>
<p>However, this screenshot prompted me to revisit Nosefart.</p>
<p><strong>Nosefart Background</strong><br />
<a href="http://nosefart.sourceforge.net/">Nosefart is a program</a> that can play <a href="http://en.wikipedia.org/wiki/NES_Sound_Format">Nintendo Sound Format (NSF) files</a>. NSF files are files containing components that were surgically separated from Nintendo Entertainment System (NES) ROM dumps. These components contain the music playback engines for various games. An NSF player is a stripped down emulation system that can simulate the NES6502 CPU along with the custom hardware (2 square waves, 1 triangle wave, 1 noise generator, and 1 limited digital channel).</p>
<p>Nosefart was written by <a href="http://baisoku.org/">Matt Conte</a> and eventually imported into <a href="http://nosefart.sourceforge.net/">a Sourceforge project</a>, though it has not seen any development since then. The distribution contains standalone command line players for Linux and DOS, a GTK frontend for the Linux command line version, and plugins for Winamp, XMMS, and CL-Amp.</p>
<p>The Sourceforge project page notes that Nosefart is also part of XBMC. Let the record show that Nosefart is also incorporated into <a href="http://www.xine-project.org/">xine</a> (I did that in 2002, I think).</p>
<p><strong>Upgrading the API</strong><br />
When I tried running the command line version of Nosefart under Linux, I hit hard against the legacy audio API: OSS. Remember that?</p>
<p>In fairly short order, I was able to upgrade the CL program to use PulseAudio. The  program is not especially sophisticated. It&#8217;s a single-threaded affair which checks for a keypress, processes an audio frame, and sends the frame out to the OSS file interface. All that was needed was to rewrite open_hardware() and close_hardware() for PA and then replace the write statement in play(). The only quirk that stood out is that including &lt;pulse/pulseaudio.h&gt; is insufficient for programming PA&#8217;s simple API. &lt;pulse/simple.h&gt; must be included separately.</p>
<p>For extra credit, I adapted the program to ALSA. The program uses the most simplistic audio output API possible &#8212; just keep filling a buffer and sending it out to the DAC.</p>
<p><strong>Discovering GME</strong><br />
I&#8217;m not sure what to do with the the program now since, during my research to attempt to bring Nosefart up to date, I became aware of a software library named <a href="http://www.fly.net/~ant/libs/audio.html">Game Music Emu, or GME</a>. It&#8217;s a pure C++ library that can essentially play any classic video game format you can possible name. Wow. A lot can happen in 10 years when you&#8217;re not paying attention.</p>
<p>It&#8217;s such a well-written library that I didn&#8217;t need any tutorial or documentation to come up to speed. Just a quick read of the main gme.h header library enabled me in short order to whip up a quick C program that could play NSF and SPC files. Path of least resistance: Client program asks library to open a hardcoded file, synthesize 10 seconds of audio, and dump it into a file; ask the FLAC command line program to transcode raw data to .flac file; use ffplay to verify the results.</p>
<p>I might develop some other uses for this library.</p>
]]></content:encoded>
			<wfw:commentRss>http://multimedia.cx/eggs/nosefart-and-gme/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

