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

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.


Defines

#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 TV_TYPE_LOC   0x80000300
 Memory location to read which determines the TV type.
#define UNCACHED_ADDR(x)   ((void *)(((uint32_t)(x)) | 0xA0000000))
 Return the uncached memory address of a cached address.
#define ALIGN_16BYTE(x)   ((void *)(((uint32_t)(x)+15) & 0xFFFFFFF0))
 Align a memory address to 16 byte offset.

Typedefs

typedef int display_context_t
 Display context.

Enumerations

enum  tvtype_t { TV_TYPE_PAL, TV_TYPE_NTSC, TV_TYPE_MPAL }
 Valid television types. More...
enum  resolution_t { RESOLUTION_320x240, RESOLUTION_640x480, RESOLUTION_256x240, RESOLUTION_512x480 }
 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

static void __write_registers (uint32_t const *const registers)
 Write a set of video registers to the VI.
static void __write_dram_register (void const *const dram_val)
 Update the framebuffer pointer in the VI.
static void __display_callback ()
 Interrupt handler for vertical blank.
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.
void display_init_ex (tvtype_t tv, resolution_t res, bitdepth_t bit, uint32_t num_buffers, gamma_t gamma, antialias_t aa)
 Initialize the display to a particular tv type, resolution, and bit depth.
void display_close ()
 Close the display.
display_context_t display_lock ()
 Lock a display buffer for rendering.
void display_show (display_context_t disp)
 Display a previously locked buffer.

Variables

static void * buffer [NUM_BUFFERS]
 Video buffer pointers.
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.
uint32_t __registers [REGISTER_COUNT *2]
 Current VI register settings (for two fields)
static int now_showing = -1
 Currently displayed buffer.
static int show_next = -1
 Complete drawn buffer to display next.
static int now_drawing = -1
 Buffer currently being drawn on.

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.


Define Documentation

#define ALIGN_16BYTE (   x)    ((void *)(((uint32_t)(x)+15) & 0xFFFFFFF0))

Align a memory address to 16 byte offset.

Parameters:
[in]xUnaligned memory address
Returns:
An aligned address guaranteed to be >= the unaligned address
#define UNCACHED_ADDR (   x)    ((void *)(((uint32_t)(x)) | 0xA0000000))

Return the uncached memory address of a cached address.

Parameters:
[in]xThe cached address uint32_t
Returns:
The uncached address

Enumeration Type Documentation

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.

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)

enum gamma_t

Valid gamma correction settings.

Enumerator:
GAMMA_NONE 

Uncorrected gamma.

GAMMA_CORRECT 

Corrected gamma.

GAMMA_CORRECT_DITHER 

Corrected gamma with hardware dither.

Valid video resolutions.

Enumerator:
RESOLUTION_320x240 

320x240 mode

RESOLUTION_640x480 

640x480 mode

RESOLUTION_256x240 

256x240 mode

RESOLUTION_512x480 

512x480 mode

enum tvtype_t

Valid television types.

Enumerator:
TV_TYPE_PAL 

PAL.

TV_TYPE_NTSC 

NTSC.

TV_TYPE_MPAL 

MPAL.


Function Documentation

static void __display_callback ( ) [static]

Interrupt handler for vertical blank.

If there is another frame to display, display the frame

static void __write_dram_register ( void const *const  dram_val) [static]

Update the framebuffer pointer in the VI.

Parameters:
[in]dram_valThe new framebuffer to use for display. Should be aligned and uncached.
static void __write_registers ( uint32_t const *const  registers) [static]

Write a set of video registers to the VI.

Parameters:
[in]registersA pointer to a set of register values to be written
void display_close ( )

Close the display.

Close a display and free buffer memory associated with it.

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. Uses the default tv type for region.

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
void display_init_ex ( tvtype_t  tv,
resolution_t  res,
bitdepth_t  bit,
uint32_t  num_buffers,
gamma_t  gamma,
antialias_t  aa 
)

Initialize the display to a particular tv type, 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]tvThe requested tv type
[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

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 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
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines