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. |
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 ALIGN_16BYTE | ( | x | ) | ((void *)(((uint32_t)(x)+15) & 0xFFFFFFF0)) |
Align a memory address to 16 byte offset.
[in] | x | Unaligned memory address |
#define UNCACHED_ADDR | ( | x | ) | ((void *)(((uint32_t)(x)) | 0xA0000000)) |
Return the uncached memory address of a cached address.
[in] | x | The cached address uint32_t |
enum antialias_t |
enum bitdepth_t |
enum gamma_t |
enum resolution_t |
enum tvtype_t |
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.
[in] | dram_val | The 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.
[in] | registers | A 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.
[in] | res | The requested resolution |
[in] | bit | The requested bit depth |
[in] | num_buffers | Number of buffers (2 or 3) |
[in] | gamma | The requested gamma setting |
[in] | aa | The 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.
[in] | tv | The requested tv type |
[in] | res | The requested resolution |
[in] | bit | The requested bit depth |
[in] | num_buffers | Number of buffers (2 or 3) |
[in] | gamma | The requested gamma setting |
[in] | aa | The 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.
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.
[in] | disp | A display context retrieved using display_lock |