osViSetMode
Sets VI modes
#include <ultra64.h> /* os.h */ void osViSetMode(OSViMode *mode);
None.
This function sets the display mode in the VI. The VI supports a total of 56 display modes. These break down into 14 NTSC modes, 14 PAL modes, 14 MPAL modes, and 14 full-screen display PAL (FPAL) modes. The attributes of each mode, such as interlace and non-interlace, 16-bit color pixels and 32-bit color pixels, low-resolution and high-resolution, etc., can be set. In addition, the resolution can be dropped or images can be rescaled in order to increase rendering speed.
The 56 modes are indicated by 5 switches, viz., high/low resolution, 16/32-bit color pixels, anti-aliasing/point sampling, filter/non-filter processing, and NTSC/PAL/MPAL/FPAL format. The defined symbol names for these modes are in <os.h>. For example, "OS_VI_NTSC_LPN1" indicates that low-resolution, point sampling, non-interlace, and 16-bit color pixels are supported, while "OS_VI_PAL_LPN1" indicates that the same content are supported in PAL format.
The last 4 characters of the symbol name (LPN1, etc.) comprise 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-interlaced |
F = Interlaced | ||
High resolution | N = Normal interlaced | |
F = Deflickered interlaced | ||
4th Character | 1 = 16-bit pixel size | |
2 = 32-bit pixel size |
At low resolution (320 pixels x 240 lines in PAL/MPAL/NTSC modes, 320 pixels x 288 lines in FPAL mode), non-interlaced mode and interlaced mode can be selected. Non-interlaced mode repeats the same frame in each field (scan). In contrast, interlaced mode interpolates between adjacent lines. First, in the first field, the upper line is weighted 75% and the lower line is weighted 25%. Then, interpolation is performed in the next in the next field, by weighting the upper line 25% and weighting the lower line 75%. In this case, there is no flicker because there is not high blanking frequency.
At high resolution (640 pixels x 480 lines in PAL/MPAL/NTSC modes, 640 pixels x 576 lines in FPAL mode), normal interlaced mode and de-flickered interlaced mode can be selected. In normal interlaced mode, only those data, which have been rendered for that field, are used in one field. While the current field is being displayed, the next field is being rendered, and since they have no effect on one another, there is no need to use a double-buffer. However, since it is high resolution, pixels, which are only displayed in one field, will flicker. On the other hand, in de-flickered interlaced mode, the lines are averaged and displayed to eliminate the high-frequency components. However, the data for both fields are required to display one field in this mode, double-buffer processing becomes necessary.
The register settings for these 56 modes are in the VI mode table osViModeTable, which is defined as an external variable. osViSetMode overwrites all VI registers with data referenced by mode (the pointer to osViModeTable) at the timing of the next vertical retrace. All previous settings (XY scale, gamma correction, etc.) will be reset. The VI mode table is an array of 56 OSViMode structures, but each mode is individually defined in <os.h> as an external variable in the OS source file. For instance, there are two ways, as shown below, to write it when registering NTSC, low-resolution, anti-aliasing, non-interlaced processing, and 16-bit mode in the VI.
osViSetMode(&osViModeNtscLan1);or
osViSetMode(&osViModeTable[OS_VI_NTSC_LAN1]);
Since the latter method is linked to data, which are not used, it uses a lot of memory. It is recommended that the former method be used.
osViSetMode will return all of the settings for functions that are set by X/Y scale processing or osViSetSpecialFeatures (e.g., gamma correction) to their default values as defined in the VI mode table.
References VI Mode Type List
NTSC | OS_VI_NTSC_LPN1 | 0 |
OS_VI_NTSC_LPF1 | 1 | |
OS_VI_NTSC_LAN1 | 2 | |
OS_VI_NTSC_LAF1 | 3 | |
OS_VI_NTSC_LPN2 | 4 | |
OS_VI_NTSC_LPF2 | 5 | |
OS_VI_NTSC_LAN2 | 6 | |
OS_VI_NTSC_LAF2 | 7 | |
OS_VI_NTSC_HPN1 | 8 | |
OS_VI_NTSC_HPF1 | 9 | |
OS_VI_NTSC_HAN1 | 10 | |
OS_VI_NTSC_HAF1 | 11 | |
OS_VI_NTSC_HPN2 | 12 | |
OS_VI_NTSC_HPF2 | 13 | |
PAL | OS_VI_PAL_LPN1 | 14 |
OS_VI_PAL_LPF1 | 15 | |
OS_VI_PAL_LAN1 | 16 | |
OS_VI_PAL_LAF1 | 17 | |
OS_VI_PAL_LPN2 | 18 | |
OS_VI_PAL_LPF2 | 19 | |
OS_VI_PAL_LAN2 | 20 | |
OS_VI_PAL_LAF2 | 21 | |
OS_VI_PAL_HPN1 | 22 | |
OS_VI_PAL_HPF1 | 23 | |
OS_VI_PAL_HAN1 | 24 | |
OS_VI_PAL_HAF1 | 25 | |
OS_VI_PAL_HPN2 | 26 | |
OS_VI_PAL_HPF2 | 27 | |
MPAL (Mainly Brazil) |
OS_VI_MPAL_LPN1 | 28 |
OS_VI_MPAL_LPF1 | 29 | |
OS_VI_MPAL_LAN1 | 30 | |
OS_VI_MPAL_LAF1 | 31 | |
OS_VI_MPAL_LPN2 | 32 | |
OS_VI_MPAL_LPF2 | 33 | |
OS_VI_MPAL_LAN2 | 34 | |
OS_VI_MPAL_LAF2 | 35 | |
OS_VI_MPAL_HPN1 | 36 | |
OS_VI_MPAL_HPF1 | 37 | |
OS_VI_MPAL_HAN1 | 38 | |
OS_VI_MPAL_HAF1 | 39 | |
OS_VI_MPAL_HPN2 | 40 | |
OS_VI_MPAL_HPF2 | 41 | |
FPAL (Full-screen PAL) |
OS_VI_FPAL_LPN1 | 42 |
OS_VI_FPAL_LPF1 | 43 | |
OS_VI_FPAL_LAN1 | 44 | |
OS_VI_FPAL_LAF1 | 45 | |
OS_VI_FPAL_LPN2 | 46 | |
OS_VI_FPAL_LPF2 | 47 | |
OS_VI_FPAL_LAN2 | 48 | |
OS_VI_FPAL_LAF2 | 49 | |
OS_VI_FPAL_HPN1 | 50 | |
OS_VI_FPAL_HPF1 | 51 | |
OS_VI_FPAL_HAN1 | 52 | |
OS_VI_FPAL_HAF1 | 53 | |
OS_VI_FPAL_HPN2 | 54 | |
OS_VI_FPAL_HPF2 | 55 |
// Start VI manager & blackout osCreateViManager(OS_PRIORITY_VIMGR); #if (SCREEN_WD==320)&&(SCREEN_HT==240) // Settings for low resolution osViSetMode(&osViModeNtscLan1); #elif (SCREEN_WD==640)&&(SCREEN_HT==480) // Settings for high resolution osViSetMode(&osViModeNtscHaf1); #else #error "Illegal Screen size" #endif osViBlack(TRUE);
osViGetCurrentMode, osViSetSpecialFeatures
02/01/99 Completely revised.