Thursday, May 31, 2012

Getting closer.

Suspicion confirmed.  SOM is processing 16x16 JPEG blocks one at a time from almost the time you load the ROM.  The Y channel is stored at $1600 (upper left 8x8 block), $1700 (lower left), $1800 (lower right), and $1900 (upper right).  At $1A00 and 1B00 you find the downsampled Cb and Cr, respectively.

I wrote a little MATLAB script to generate an RGB image from data I found at these locations for the first block to test my theory.  Here's the result compared against a zoomed-in screenshot of the game:

The colors are slightly off; I attribute this to one of three possible things.. one, the most likely, I fucked something up.  Two, the game uses an 8-bit palette in the end (haven't gotten that far yet) and these color shifts are an artifact of paletting.  Three, it's a difference between 16-bit and 24-bit color.  I'd call three unlikely.

Anyway, it shouldn't be long before the editor can load this image, because (with minor bugs) the processing up to this point, including the Huffman tree lookup from the ROM data, Quantization matrix processing, and DCT are all implemented.  Dropping a new image in as the title screen background will be interesting to implement.


RetroHelix said...

So you could prove it.
I'm a bit skeptical about the colors, for some pixels they are the same in the original but different in the Matlab generated one. Isn't this an indication for a higher colordepth?

Matt said...

Awesome :D