libdragon
Modules | Files | Macros | Typedefs | Enumerations | Functions | Variables
Display Subsystem

Video interface system for configuring video output modes and displaying rendered graphics. More...

Modules

 Console Support
 Software console emulation for debugging and simple text output.
 
 2D Graphics
 Software routines for manipulating graphics in a display context.
 
 Hardware Display Interface
 Interface to the hardware sprite/triangle rasterizer (RDP).
 

Files

file  display.c
 Display Subsystem.
 
file  display.h
 Display Subsystem.
 

Macros

#define NUM_BUFFERS   3
 Maximum number of video backbuffers.
 
#define REGISTER_BASE   0xA4400000
 Register location in memory of VI.
 
#define REGISTER_COUNT   14
 Number of 32-bit registers at the register base.
 
#define UNCACHED_ADDR(x)   ((void *)(((uint32_t)(x)) | 0xA0000000))
 Return the uncached memory address of a cached address. More...
 

Typedefs

typedef int display_context_t
 Display context.
 

Enumerations

enum  resolution_t {
  RESOLUTION_320x240 , RESOLUTION_640x480 , RESOLUTION_256x240 , RESOLUTION_512x480 ,
  RESOLUTION_512x240 , RESOLUTION_640x240
}
 Valid video resolutions. More...
 
enum  bitdepth_t { DEPTH_16_BPP , DEPTH_32_BPP }
 Valid bit depths. More...
 
enum  gamma_t { GAMMA_NONE , GAMMA_CORRECT , GAMMA_CORRECT_DITHER }
 Valid gamma correction settings. More...
 
enum  antialias_t { ANTIALIAS_OFF , ANTIALIAS_RESAMPLE , ANTIALIAS_RESAMPLE_FETCH_NEEDED , ANTIALIAS_RESAMPLE_FETCH_ALWAYS }
 Valid antialiasing settings. More...
 

Functions

void display_init (resolution_t res, bitdepth_t bit, uint32_t num_buffers, gamma_t gamma, antialias_t aa)
 Initialize the display to a particular resolution and bit depth. More...
 
void display_close ()
 Close the display. More...
 
display_context_t display_lock ()
 Lock a display buffer for rendering. More...
 
void display_show (display_context_t disp)
 Display a previously locked buffer. More...
 
void display_show_force (display_context_t disp)
 Force-display a previously locked buffer. More...
 

Variables

uint32_t __bitdepth
 Currently active bit depth.
 
uint32_t __width
 Currently active video width (calculated)
 
uint32_t __height
 Currently active video height (calculated)
 
uint32_t __buffers = NUM_BUFFERS
 Number of active buffers.
 
void * __safe_buffer [NUM_BUFFERS]
 Pointer to uncached 16-bit aligned version of buffers.
 

Detailed Description

Video interface system for configuring video output modes and displaying rendered graphics.

The display subsystem handles interfacing with the video interface (VI) and the hardware rasterizer (RDP) to allow software and hardware graphics operations. It consists of the Display Subsystem, the 2D Graphics and the Hardware Display Interface modules. A separate module, the Console Support, provides a rudimentary console for developers. Only the display subsystem or the console can be used at the same time. However, commands to draw console text to the display subsystem are available.

The display subsystem module is responsible for initializing the proper video mode for displaying 2D, 3D and softward graphics. To set up video on the N64, code should call display_init with the appropriate options. Once the display has been set, a display context can be requested from the display subsystem using display_lock. To draw to the acquired display context, code should use functions present in the 2D Graphics and the Hardware Display Interface modules. Once drawing to a display context is complete, the rendered graphic can be displayed to the screen using display_show. Once code has finished rendering all graphics, display_close can be used to shut down the display subsystem.

Macro Definition Documentation

◆ UNCACHED_ADDR

#define UNCACHED_ADDR (   x)    ((void *)(((uint32_t)(x)) | 0xA0000000))

Return the uncached memory address of a cached address.

Parameters
[in]xThe cached address
Returns
The uncached address

Enumeration Type Documentation

◆ resolution_t

Valid video resolutions.

Enumerator
RESOLUTION_320x240 

320x240 mode

RESOLUTION_640x480 

640x480 mode

RESOLUTION_256x240 

256x240 mode

RESOLUTION_512x480 

512x480 mode

RESOLUTION_512x240 

512x240 mode, high-res progressive

RESOLUTION_640x240 

640x240 mode, high-res progressive

◆ bitdepth_t

enum bitdepth_t

Valid bit depths.

Enumerator
DEPTH_16_BPP 

16 bits per pixel (5-5-5-1)

DEPTH_32_BPP 

32 bits per pixel (8-8-8-8)

◆ gamma_t

enum gamma_t

Valid gamma correction settings.

Enumerator
GAMMA_NONE 

Uncorrected gamma.

GAMMA_CORRECT 

Corrected gamma.

GAMMA_CORRECT_DITHER 

Corrected gamma with hardware dither.

◆ antialias_t

Valid antialiasing settings.

Enumerator
ANTIALIAS_OFF 

No anti-aliasing.

ANTIALIAS_RESAMPLE 

Resampling anti-aliasing.

ANTIALIAS_RESAMPLE_FETCH_NEEDED 

Anti-aliasing and resampling with fetch-on-need.

ANTIALIAS_RESAMPLE_FETCH_ALWAYS 

Anti-aliasing and resampling with fetch-always.

Function Documentation

◆ display_init()

void display_init ( resolution_t  res,
bitdepth_t  bit,
uint32_t  num_buffers,
gamma_t  gamma,
antialias_t  aa 
)

Initialize the display to a particular resolution and bit depth.

Initialize video system. This sets up a double or triple buffered drawing surface which can be blitted or rendered to using software or hardware.

Parameters
[in]resThe requested resolution
[in]bitThe requested bit depth
[in]num_buffersNumber of buffers (2 or 3)
[in]gammaThe requested gamma setting
[in]aaThe requested anti-aliasing setting

◆ display_close()

void display_close ( )

Close the display.

Close a display and free buffer memory associated with it.

◆ display_lock()

display_context_t display_lock ( )

Lock a display buffer for rendering.

Grab a display context that is safe for drawing. If none is available then this will return 0. Do not check out more than one display context at a time.

Returns
A valid display context to render to or 0 if none is available.

◆ display_show()

void display_show ( display_context_t  disp)

Display a previously locked buffer.

Display a valid display context to the screen on the next vblank. Display contexts should be locked via display_lock.

Parameters
[in]dispA display context retrieved using display_lock

◆ display_show_force()

void display_show_force ( display_context_t  disp)

Force-display a previously locked buffer.

Display a valid display context to the screen right away, without waiting for vblank interrupt. This function works also with interrupts disabled.

NOTE: this is currently not part of the public API as we use it only internally.

Parameters
[in]dispA display context retrieved using display_lock