Wednesday, November 11, 2009

IFF writing and DYUV color keying

Today I implemented proper IFF writing with two new classes: CIffIoBase and CIffWriter. I will need this to write WAV files for the new -writewav option, as WAV files use the Microsoft RIFF format which is a variation of Electronic Arts IFF (Interchange File Format).

The new -writewav option will be a companion to -writepng and -writemng that I can mostly implement using MESS source code (just like -writeavi); the license for the MESS WAV writing code does not allow me to use it and reuse would not be feasible on technical grounds anyway because this code is not as modularly written as the MESS PNG/MNG and AVI writing code.

Proper IFF writing will also be useful for savestates, but that is not for the current beta.

Microsoft says that RIFF stands for Resource Interchange File Format but my source code calls it "Reversed IFF" which is also a correct description :-)

I tested the new IFF writer code by rewriting the CInputStream::Record functions to use it. These functions already wrote IFF format, but now they properly fill in the chunk sizes (previously I left them at 0xFFFFFFFF which limited the file to a single data chunk).

Debugging it took more time then I expected because my binary CArchive class turned out to have bugs in its Position() / SetPosition() functions for file i/o. So I didn't get to the WAV file writing but that is not hard.

Also faithfully emulated a hardware "quirk" that allows Jeopardy to properly display its menu screens, it makes assumptions about the color key bit when using DYUV mode; this was uncovered by the MESS guys. I've implemented this by adding a transparancy test against black which matches the Jeopardy DCP and seems more "correct" then the simple MESS fix of always forcing color key to true. To know this for sure a test program would have to be written but I didn't feel like it.

No comments:

Post a Comment