KallistiOS  ##version##
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
video.h File Reference

Functions related to video output. More...

#include <sys/cdefs.h>
#include <arch/types.h>

Go to the source code of this file.

Data Structures

struct  vid_mode
 Video mode structure. More...
 

Macros

#define CT_ANY   -1
 Any cable type. Used only internally. More...
 
#define CT_VGA   0
 VGA Box. More...
 
#define CT_NONE   1
 Nothing connected. More...
 
#define CT_RGB   2
 RGB/SCART cable. More...
 
#define CT_COMPOSITE   3
 Composite cable or RF switch. More...
 
#define PM_RGB555   0
 RGB555 pixel mode (15-bit) More...
 
#define PM_RGB565   1
 RGB565 pixel mode (16-bit) More...
 
#define PM_RGB888   3
 RGB888 pixel mode (24-bit) More...
 
#define DM_MULTIBUFFER   0x2000
 Multi-buffered mode setting. More...
 
#define VID_MAX_FB   4
 The maximum number of framebuffers available. More...
 
#define VID_INTERLACE   0x00000001
 Interlaced display. More...
 
#define VID_LINEDOUBLE   0x00000002
 Display each scanline twice. More...
 
#define VID_PIXELDOUBLE   0x00000004
 Display each pixel twice. More...
 
#define VID_PAL   0x00000008
 50Hz refresh rate, if not VGA More...
 

Typedefs

typedef struct vid_mode vid_mode_t
 Video mode structure. More...
 

Enumerations

enum  {
  DM_GENERIC_FIRST = 0x1000, DM_320x240 = 0x1000, DM_640x480, DM_800x608,
  DM_256x256, DM_768x480, DM_768x576, DM_GENERIC_LAST = DM_768x576
}
 Generic display modes. More...
 
enum  {
  DM_INVALID = 0, DM_320x240_VGA = 1, DM_320x240_NTSC, DM_640x480_VGA,
  DM_640x480_NTSC_IL, DM_800x608_VGA, DM_640x480_PAL_IL, DM_256x256_PAL_IL,
  DM_768x480_NTSC_IL, DM_768x576_PAL_IL, DM_768x480_PAL_IL, DM_320x240_PAL,
  DM_320x240_VGA_MB, DM_320x240_NTSC_MB, DM_640x480_VGA_MB, DM_640x480_NTSC_IL_MB,
  DM_800x608_VGA_MB, DM_640x480_PAL_IL_MB, DM_256x256_PAL_IL_MB, DM_768x480_NTSC_IL_MB,
  DM_768x576_PAL_IL_MB, DM_768x480_PAL_IL_MB, DM_320x240_PAL_MB, DM_SENTINEL,
  DM_MODE_COUNT
}
 Specific display modes. More...
 

Functions

int vid_check_cable ()
 Retrieve the connected video cable type. More...
 
void vid_set_start (uint32 base)
 Set the VRAM base of the framebuffer. More...
 
void vid_flip (int fb)
 Set the current framebuffer in a multibuffered setup. More...
 
uint32 vid_border_color (int r, int g, int b)
 Set the border color of the display. More...
 
void vid_clear (int r, int g, int b)
 Clear the display. More...
 
void vid_empty ()
 Clear VRAM. More...
 
void vid_waitvbl ()
 Wait for VBlank. More...
 
void vid_set_mode (int dm, int pm)
 Set the video mode. More...
 
void vid_set_mode_ex (vid_mode_t *mode)
 Set the video mode. More...
 
void vid_init (int disp_mode, int pixel_mode)
 Initialize the video system. More...
 
void vid_shutdown ()
 Shut down the video system. More...
 
int vid_screen_shot (const char *destfn)
 Take a screenshot. More...
 

Variables

vid_mode_t vid_builtin [DM_MODE_COUNT]
 The list of builtin video modes. Do not modify these! More...
 
vid_mode_tvid_mode
 The current video mode. Do not modify directly! More...
 
uint16vram_s
 16-bit size pointer to the current drawing area. More...
 
uint32vram_l
 32-bit size pointer to the current drawing area. More...
 

Detailed Description

Functions related to video output.

This file deals with the video output hardware in the Dreamcast. There are functions defined herein that deal with setting up the video hardware, defining the resolution of the display, dealing with the framebuffer, etc.

Author
Anders Clerwall
Dan Potter

Macro Definition Documentation

#define DM_MULTIBUFFER   0x2000

Multi-buffered mode setting.

OR this with the generic mode to get four framebuffers instead of one.

#define VID_MAX_FB   4

The maximum number of framebuffers available.

Typedef Documentation

typedef struct vid_mode vid_mode_t

Video mode structure.

KOS maintains a list of valid video modes internally that correspond to the specific display modes enumeration. Each of them is built of one of these.

Enumeration Type Documentation

anonymous enum

Generic display modes.

Enumerator
DM_GENERIC_FIRST 

First valid generic mode.

DM_320x240 

320x240 resolution

DM_640x480 

640x480 resolution

DM_800x608 

800x608 resolution

DM_256x256 

256x256 resolution

DM_768x480 

768x480 resolution

DM_768x576 

768x576 resolution

DM_GENERIC_LAST 

Last valid generic mode.

anonymous enum

Specific display modes.

Enumerator
DM_INVALID 

Invalid display mode.

DM_320x240_VGA 

320x240 VGA 60Hz

DM_320x240_NTSC 

320x240 NTSC 60Hz

DM_640x480_VGA 

640x480 VGA 60Hz

DM_640x480_NTSC_IL 

640x480 NTSC Interlaced 60Hz

DM_800x608_VGA 

800x608 VGA 60Hz

DM_640x480_PAL_IL 

640x480 PAL Interlaced 50Hz

DM_256x256_PAL_IL 

256x256 PAL Interlaced 50Hz

DM_768x480_NTSC_IL 

768x480 NTSC Interlaced 60Hz

DM_768x576_PAL_IL 

768x576 PAL Interlaced 50Hz

DM_768x480_PAL_IL 

768x480 PAL Interlaced 50Hz

DM_320x240_PAL 

320x240 PAL 50Hz

DM_320x240_VGA_MB 

320x240 VGA 60Hz, 4FBs

DM_320x240_NTSC_MB 

320x240 NTSC 60Hz, 4FBs

DM_640x480_VGA_MB 

640x480 VGA 60Hz, 4FBs

DM_640x480_NTSC_IL_MB 

640x480 NTSC IL 60Hz, 4FBs

DM_800x608_VGA_MB 

800x608 VGA 60Hz, 4FBs

DM_640x480_PAL_IL_MB 

640x480 PAL IL 50Hz, 4FBs

DM_256x256_PAL_IL_MB 

256x256 PAL IL 50Hz, 4FBs

DM_768x480_NTSC_IL_MB 

768x480 NTSC IL 60Hz, 4FBs

DM_768x576_PAL_IL_MB 

768x576 PAL IL 50Hz, 4FBs

DM_768x480_PAL_IL_MB 

768x480 PAL IL 50Hz, 4FBs

DM_320x240_PAL_MB 

320x240 PAL 50Hz, 4FBs

DM_SENTINEL 

Sentinel value, for counting.

DM_MODE_COUNT 

Number of modes.

Function Documentation

uint32 vid_border_color ( int  r,
int  g,
int  b 
)

Set the border color of the display.

This sets the color of the border area of the display. On some screens, the border area may not be shown at all, whereas on some displays you may see the whole thing.

Parameters
rThe red value of the color (0-255).
gThe green value of the color (0-255).
bThe blue value of the color (0-255).
Returns
Old border color value (RGB888)
int vid_check_cable ( )

Retrieve the connected video cable type.

This function checks the video cable and reports what it finds.

Return values
CT_VGAIf a VGA Box or cable is connected.
CT_NONEIf nothing is connected.
CT_RGBIf a RGB/SCART cable is connected.
CT_COMPOSITEIf a composite cable or RF switch is connected.
void vid_clear ( int  r,
int  g,
int  b 
)

Clear the display.

This function sets the whole display to the specified color. Internally, this uses the store queues to actually clear the display entirely.

Parameters
rThe red value of the color (0-255).
gThe green value of the color (0-255).
bThe blue value of the color (0-255).
void vid_empty ( )

Clear VRAM.

This function is essentially a memset() for the whole of VRAM that will clear it all to 0 bytes.

void vid_flip ( int  fb)

Set the current framebuffer in a multibuffered setup.

This function sets the displayed framebuffer to the specified buffer and sets the vram_s and vram_l pointers to point at the next framebuffer, to allow for tearing-free framebuffer-direct drawing.

Parameters
fbThe framebuffer to display (or -1 for the next one).
void vid_init ( int  disp_mode,
int  pixel_mode 
)

Initialize the video system.

This function initializes the video display, setting the mode to the specified parameters, clearing vram, and setting the first framebuffer as active.

Parameters
disp_modeThe display mode to use. One of the DM_* values.
pixel_modeThe pixel mode to use. One of the PM_* values.
int vid_screen_shot ( const char *  destfn)

Take a screenshot.

This function takes the current framebuffer (vram_s/vram_l) and dumps it out to a PPM file.

Parameters
destfnThe filename to save to.
Returns
0 on success, <0 on failure.
void vid_set_mode ( int  dm,
int  pm 
)

Set the video mode.

This function sets the current video mode to the one specified by the parameters.

Parameters
dmThe display mode to use. One of the DM_* values.
pmThe pixel mode to use. One of the PM_* values.
void vid_set_mode_ex ( vid_mode_t mode)

Set the video mode.

This function sets the current video mode to the mode structure passed in. You can use this to add support to your program for modes that KOS doesn't have support for built-in (of course, you should tell us the settings so we can add them into KOS if you do this).

Parameters
modeA filled in vid_mode_t for the mode wanted.
void vid_set_start ( uint32  base)

Set the VRAM base of the framebuffer.

This function sets the vram_s and vram_l pointsers to specified offset within VRAM and sets the start position of the framebuffer to the same offset.

Parameters
baseThe offset within VRAM to set the base to.
void vid_shutdown ( )

Shut down the video system.

This function reinitializes the video system to what dcload and friends expect it to be.

void vid_waitvbl ( )

Wait for VBlank.

This function busy loops until the vertical blanking period starts.

Variable Documentation

vid_mode_t vid_builtin[DM_MODE_COUNT]

The list of builtin video modes. Do not modify these!

The current video mode. Do not modify directly!

uint32* vram_l

32-bit size pointer to the current drawing area.

uint16* vram_s

16-bit size pointer to the current drawing area.