7.6 VI Mode and Special Functions

Next we will move on to a different subject in this section and talk about the video interface (VI).

One of the main settings relating to the video interface is the VI mode. The VI mode must be set appropriately in order to use high-resolution displays and a 32bit framebuffer. The VI mode is set using the osViSetMode function. However, what you pass to the osViSetMode function is not an integer value indicating the VI mode, but rather the address of the table holding the settings for the various VI parameters.

 
void osViSetMode(OSViMode *mode);
  mode -- VI mode  
Return value -- None

The display mode is set in the VI. The VI supports a total of 56 display modes: 14 NTSC, 14 PAL, 14 MPAL, and 14 full-screen PAL (FPAL). For each of these modes, you can set attributes for interlace or non-interlace, 16bit color pixels or 32bit color pixels, and low resolution or high resolution.

The 56 modes are indicated with five switches for high/low resolution, 16/32bit color pixels, anti-aliasing/point sampling, filtering/non-filtering and MPAL^PAL^FPAL^NTSC format. The symbol names for these modes are defined in . So for example, OS_VI_NTSC_LPN1 indicates support for low-resolution, point sampling, non-interlace and 16bit color pixels. OS_VI_PAL_LPN1 indicates support for the same, but in PAL format.

The last four characters in the symbol name (LPN1, etc.) are made up from the following codes:

 
1st character H = High resolution
L = Low resolution
2nd character A = Anti-aliasing
P = Point sampling
3rd character Low resolution N = Non-interlace
F = Interlace
High resolution N = Non-interlace
F = De-flickered interlace
4th character 1 = 16bit pixel size
2 = 32bit pixel size

There is a systematic naming convention followed for these VI mode symbol names. You can read more about this in the Function Reference. Here we will provide an explanation using concrete examples.

If you take a look at the SetupResolution function in gfx7.c, you will see how the VI mode changes according to the macro definitions. When the __HIRES__ macro is defined, the VI mode is changed as follows to high-resolution, anti-aliasing, non-interlace and a 16bit framebuffer.

List 7-4

  osViSetMode(&osViModeTable[OS_VI_NTSC_HAN1]);

In the same way, when the __32BIT__ macro is defined (and __HIRES__ is not defined) then the VI mode is set to low-resolution, anti-aliasing, non-interlace and a 32bit framebuffer.

List 7-5

  osViSetMode(&osViModeTable[OS_VI_NTSC_LAN2]);

When you use an array like that in List 7-4 and 7-5, the entire array is linked. If you want to avoid this, set something like &osViModeNtscHan1 using individual VI mode variables.

You can switch gamma correction on and off in the gfx7.c sample program using the osViSetSpecialFeatures function. On line 51, change __GAMMA__ to either OS_VI_GAMMA_ON or OS_VI_GAMMA_OFF and then run the program to see what difference gamma correction makes to the brightness of the image output to the screen. The osViSetSpecialFeatures function can be used to switch the settings ON/OFF for four different special features: gamma correction, gamma correction dithering, divot elimination, and dither filtering.

Note that when you call osViSetMode the VI special feature settings are all set to that VI mode's default values. In NuSystem, gamma correction is turned off by default, so you will notice a brighter screen display when you define __HIRES__ or __32BIT__ and change the VI mode to one with gamma correction turned on.

Of course, when you change the resolution and framebuffer size you must also change the view port settings and display list to match those changes. The size of the framebuffer and the Z buffer also change. We will not go into detail in this tutorial, but if you look at gfx7.c, you will see how to customize the framebuffer and the Z buffer when using NuSystem and how to clear the 32bit framebuffer.