Friday, October 30, 2009

Video mode refactoring

In search of something small, I refactored the video mode calculation today, in preparation for a more complete VSC (SCC66470) emulation and CD-i File video decoding. This gets a bit technical...

It turns out that the VSC chip supports much more video modes than the "standard" CD-i ones supported by the VDSC, and in the interest of accuracy I will eventually want to emulate that. These modes include widths of 224, 256 and 320 pixels in addition to the standard ones of 360 (NTSC) and 384 (PAL) and an height of 210 lines in addition to the standard ones of 240 (NTSC) and 280 (PAL). Charles Doty accidentally hit one of these resolutions during his Frog Feast development and we were both extremely baffled until we figured out that a stray bit had been set in his "set video mode" instruction. The VSC chip is only used in Mini- and Maxi-MMC players which means these resolutions exist only on the CD-i 180, CD-i 220 F1 and CD-i 60x players.

I also wanted to generalize the mode stuff in preparation for the decoding of arbitrarily sized images as needed by future versions of CD-i File.

So instead of four bits (CF,ST,FD,SM) taken directly from the VDSC registers DCR1 and CSR1 the CCdiVideo::SetMode function now takes an SCdiVideoMode structure containing all the parameters previously derived from these four bits: field and line count, starting video line and total number of video lines, video pixels and decoded pixels. I've also added pixel resolution which previously was a separate parameter that chooses between decoding to normal resolution (384) or double resolution (768).

The calculations of the parameters from the hardware register bits have been moved into the CCdiVdsc and CCdiVsc classes (the VDSC and VSC emulations) so that the VSC emulation can in the future extend the calculation to include the non-standard video modes.

No comments:

Post a Comment