al - Audio Library Functions gDP - DP GBI Macros gdSP - General GBI Macros gSP - SP GBI Macros gt - Turbo Microcode RDP gu - Graphics Utilities Math - Math Functions nuSys - NuSystem os - N64 Operating System sp - Sprite Library Functions uh - Host to Target IO 64DD - N64 Disk Drive
|
Video Interface (VI) ManagementVI Management FunctionsThere are 16 management functions for the video interface (VI):
42 Video Display Modes The VI is responsible for displaying the RDP-rendered images in different video modes. Currently, VI supports 42 video display modes -- 14 for NTSC, 14 for PAL, and 14 for MPAL. Each mode contains different settings to handle attributes such as interlaced and non- interlaced, 16-bit and 32-bit color pixel, and low and high resolution. Furthermore, a mode can be configured to rescale the image to sacrifice resolution for rendering speed. These supported modes can be represented by 5 switches:
LPN1 HPN1 LPF1 HPF1 LAN1 HAN1 LAF1 HAF1 LPN2 HPN2 LPF2 HPF2 LAN2 LAF2In low resolution (320 pixels by 240 lines), you have a choice between non-interlaced and interlaced mode. Non-interlaced mode repeats the same frame each field. Interlaced mode interpolates between adjacent lines, weighting 75% of the line above plus 25% of the line below in the first field, and then weighting 25% of the line above plus 75% of the line below in the second field. Note that there is no flicker because there are no high spatial frequencies. In high resolution (640 pixels by 480 lines), you have a choice between normal interlace and deflickered interlace. Normal interlace uses just the data rendered in one field to display that field. This mode can use one high resolution frame buffer without additional double buffering because one field can be displayed while the next is being rendered without stepping on each other. However, any single pixel with high detail will flicker because it is only displayed in one field. Deflickered interlace averages adjacent lines to filter out the high frequency vertical detail, but at the cost of requiring double buffering of the entire high resolution frame because both rendered fields are used to display each field. VI Management Functions You can use the 16 functions described in this section to manage the VI. Currently, there is a global VI mode table (osViModeTable) that contains register settings for these 42 modes. You can use the osViSetMode function to register one of these modes with the VI to be used at the next vertical retrace. This function simply overwrites all the VI registers with data from the location pointed to by the mode argument, which is a pointer into osViModeTable. All previous settings (such as XY scaling and gamma correction) are reset. For example, to register the NTSC, low resolution, anti-aliased, non-interlaced, 16-bit mode with the VI, use this code: osViSetMode(osViModeTable[OS_VI_NTSC_LAN1]); For storage efficiency, the global VI mode table is divided into 42 separate mode structures with each structure globally defined in a separate source file. These structures are externally declared in <os.h>. To gain access to the equivalent mode mentioned above, use this code: osViSetMode(osViModeNtscLan1); You can call osViGetCurrentMode to return the VI mode currently being used. After setting the display mode, the application should call osViSetEvent to register a message queue (mq) and a message (m) with the VI manager. This allows the program to receive the notification message (m) at the message queue (mq) from the VI manager when a vertical retrace occurs. Setting retraceCount to a value higher than 1 (such as 2) decreases the frequency with which the application receives the vertical retrace notification. This allows it to run at a slower speed such as 30 Hz instead of 60 Hz. The VI manager is a system thread that must be invoked at the beginning of the application. To do this, call osCreateViManager with the priority (pri) at which it is to run. Usually, this priority should be set to OS_PRIORITY_VIMGR, which is defined in <os.h>. The VI manager is designed to service both the VI interrupt (OS_EVENT_VI) and CPU counter interrupt (OS_EVENT_COUNTER) in the most efficient manner. The counter interrupt is used by the timer manager. Once the display mode and message queue have been registered with the VI manager, the application needs to call osViSwapBuffer to register the frame buffer (frameBufPtr) to be displayed at the next vertical retrace interrupt. When Nintendo 64 powers on, the boot code sets the timing to NTSC, PAL, or MPAL and blanks out the video. The call to osCreateViManager initializes the video to LAN1 (in either NTSC, PAL, or MPAL mode) and also blanks out the video. The first time video is enabled is when osViSetMode is called. To keep the screen blank until after the first use of osViSwapBuffer, call osViBlack(TRUE) immediately after the osViSetMode call. Then call osViBlack(FALSE) right before the first call to osViSwapBuffer. Call osViSetXScale to scale the image up horizontally (in the X direction) to the required display format from a reduced number of rendered pixels per line. The value argument specifies the scaling factor and can range from 0.25 to 1.0. Call osViSetYScale to scale the image up vertically (in the Y direction) to the required display format from a reduced number of rendered lines per frame. Use Y-scaling only in low resolution and non-interlaced modes such as LAN1, LAN2, LPN1, and LPN2. The value argument specifies the scaling factor and can range from 0.05 to 1.0. Call osViSetSpecialFeatures to enable or disable various VI special features such as GAMMA, GAMMA_DITHER, DIVOT, and DITHER_FILTER. There are symbolic names defined in <os.h> including:
Call osViGetStatus to get the value of the video interface status/control register. The unsigned 32-bit returned value contains various bit patterns that are defined in <rcp.h>. Some of these patterns include:
The osViGetCurrentLine function returns the current half line, sampled once per line. The least significant bit (lsb) of this value is constant within a field in non-interlaced modes but toggles to give the field number (0 or 1) in interlaced modes. The osViGetCurrentField function returns the field number (either 0 or 1) currently being accessed by the VI. The osViGetCurrentFramebuffer function returns an opaque pointer to the currently displayed frame buffer. The osViGetNextFramebuffer function returns an opaque pointer to the next frame buffer to be displayed. Based on the active flag setting, which can be TRUE (enabled, screen black) or FALSE (disabled), the osViBlack function can black out the screen and still generate vertical retrace signals. You can only use osViBlack when the YScale factor for the video mode is 1.0. Using it for YScale factors that are not 1.0 creates the potential for the video interface to malfunction and enter a state that cannot be exited without resetting the system. In low-resolution, point-sampled, and non-interlaced modes (such as LPN1 and LPN2), you can use the 10-bit fractional interpolation factor in the osViFade function to fade between the first two scan lines of the frame buffer. You can call the osViRepeatLine function to repeat the first scan line of the frame buffer for the entire frame. Notes The VI manager must be started at the beginning of the program so that vertical retrace interrupts can be serviced as quickly as possible. Note that osViSetMode resets all current settings such as X-Y scaling and special features such as gamma to the default values defined in the global mode table. The video back-end filter can only execute an anti-aliasing filter or a dither filter, but not both simultaneously. This is especially visible on "billboard" cutouts in texture edge mode during magnification in the region of the cutout where alpha goes from 1 to 0. In this region, the dither pattern is visible because the back-end filter executes an anti-alias filter (due to partial coverage) and turns off the dither filter. This problem also occurs on anti-aliased silhouette edges of polygons, but it is not obvious due to the small width of the partially covered region. See Also osViGetStatus osViGetCurrentMode osViGetCurrentLine osViGetCurrentField osViGetCurrentFramebuffer osViGetNextFramebuffer osViSetMode osViSetEvent osViSetSpecialFeatures osViSetXScale osViSetYScale osViSwapBuffer osViBlack osViFade osViRepeatLine osCreateViManager osSetEventMesg osGetTime
|