sgdk
vdp.h File Reference

VDP main. More...

Go to the source code of this file.

Defines

#define VDP_DATA_PORT   0xC00000
 VDP Data port address.
#define VDP_CTRL_PORT   0xC00004
 VDP Control port address.
#define VDP_HVCOUNTER_PORT   0xC00008
 VDP HV counter port address.
#define GFX_DATA_PORT   _Pragma("GCC error \"This definition is deprecated, use VDP_DATA_PORT instead.\"")
#define GFX_CTRL_PORT   _Pragma("GCC error \"This definition is deprecated, use VDP_CTRL_PORT instead.\"")
#define GFX_HVCOUNTER_PORT   _Pragma("GCC error \"This definition is deprecated, use VDP_HVCOUNTER_PORT instead.\"")
#define VDP_FIFOEMPTY_FLAG   (1 << 9)
 VDP FIFO empty flag.
#define VDP_FIFOFULL_FLAG   (1 << 8)
 VDP FIFO full flag.
#define VDP_VINTPENDING_FLAG   (1 << 7)
 VDP Vertical interrupt pending flag.
#define VDP_SPROVERFLOW_FLAG   (1 << 6)
 VDP sprite overflow flag.
#define VDP_SPRCOLLISION_FLAG   (1 << 5)
 VDP sprite collision flag.
#define VDP_ODDFRAME_FLAG   (1 << 4)
 VDP odd frame flag.
#define VDP_VBLANK_FLAG   (1 << 3)
 VDP Vertical blanking flag.
#define VDP_HBLANK_FLAG   (1 << 2)
 VDP Horizontal blanking flag.
#define VDP_DMABUSY_FLAG   (1 << 1)
 VDP DMA busy flag.
#define VDP_PALMODE_FLAG   (1 << 0)
 VDP PAL mode flag.
#define VDP_PLAN_A   _Pragma("GCC error \"This definition is deprecated, use VDP_BG_A instead.\"")
#define VDP_PLAN_B   _Pragma("GCC error \"This definition is deprecated, use VDP_BG_B instead.\"")
#define VDP_PLAN_WINDOW   _Pragma("GCC error \"This definition is deprecated, use VDP_WINDOW instead.\"")
#define VDP_BG_A   bga_addr
 VDP background A tilemap address in VRAM.
#define VDP_BG_B   bgb_addr
 VDP background B tilemap address in VRAM.
#define VDP_WINDOW   window_addr
 VDP window tilemap address in VRAM.
#define VDP_HSCROLL_TABLE   hscrl_addr
 VDP horizontal scroll table address in VRAM.
#define VDP_SPRITE_TABLE   slist_addr
 VDP sprite list table address in VRAM.
#define VDP_MAPS_START   maps_addr
 Address in VRAM where tilemaps start (= address of first tilemap / table in VRAM).
#define HSCROLL_PLANE   0
 Definition to set horizontal scroll to mode plane.
#define HSCROLL_TILE   2
 Definition to set horizontal scroll to mode tile.
#define HSCROLL_LINE   3
 Definition to set horizontal scroll to mode line.
#define VSCROLL_PLANE   0
 Definition to set vertical scroll to mode plane.
#define VSCROLL_COLUMN   1
 Definition to set vertical scroll to mode column (2 tiles width).
#define VSCROLL_2TILE   _Pragma("GCC error \"This definition is deprecated, use VSCROLL_COLUMN instead.\"")
#define INTERLACED_NONE   0
 Interlaced scanning mode disabled.
That is the default mode for the VDP.
#define INTERLACED_MODE1   1
 Interlaced Scanning Mode 1 - 8x8 dots per cell (normal vertical resolution)
In Interlaced Mode 1, the same pattern will be displayed on the adjacent lines of even and odd numbered fields.
#define INTERLACED_MODE2   2
 Interlaced Scanning Mode 2 - 8x16 dots per cell (double vertical resolution)
In Interlaced Mode 2, different patterns can be displayed on the adjacent lines of even and odd numbered fields.
#define FONT_LEN   96
 SGDK font length.
#define TILE_SIZE   32
 Size of a single tile in byte.
#define TILE_INDEX_MASK   (0xFFFF / TILE_SIZE)
#define TILE_SPACE   VDP_MAPS_START
 Space in byte for tile in VRAM (tile space ends where tilemaps starts)
#define TILE_MAX_NUM   (TILE_SPACE / TILE_SIZE)
 Maximum number of tile in VRAM (related to TILE_SPACE).
#define TILE_MAX_INDEX   (TILE_MAXNUM - 1)
 Maximum tile index in VRAM (related to TILE_MAXNUM).
#define TILE_SYSTEM_INDEX   0x0000
 System base tile index in VRAM.
#define TILE_SYSTEM_LENGTH   16
 Number of system tile.
#define TILE_USER_INDEX   (TILE_SYSTEM_INDEX + TILE_SYSTEM_LENGTH)
 User base tile index.
#define TILE_FONT_INDEX   (TILE_MAX_NUM - FONT_LEN)
 Font base tile index.
#define TILE_SPRITE_INDEX   (TILE_FONT_INDEX - spriteVramSize)
 Sprite engine base tile index (equal TILE_FONT_INDEX if Sprite Engine is not initialized).
#define TILE_USER_LENGTH   ((userTileMaxIndex - TILE_USER_INDEX) + 1)
 Number of available user tile.
#define TILE_USER_MAX_INDEX   userTileMaxIndex
 Maximum tile index in VRAM reserved for user (for background and user managed sprites)
#define TILE_MAXNUM   _Pragma("GCC error \"This definition is deprecated, use TILE_MAX_NUM instead.\"")
#define TILE_MAXINDEX   _Pragma("GCC error \"This definition is deprecated, use TILE_MAX_INDEX instead.\"")
#define TILE_SYSTEM_LENGHT   _Pragma("GCC error \"This definition is deprecated, use TILE_SYSTEM_LENGTH instead.\"")
#define TILE_SYSTEMLENGTH   _Pragma("GCC error \"This definition is deprecated, use TILE_SYSTEM_LENGTH instead.\"")
#define TILE_SYSTEMINDEX   _Pragma("GCC error \"This definition is deprecated, use TILE_SYSTEM_INDEX instead.\"")
#define TILE_USERINDEX   _Pragma("GCC error \"This definition is deprecated, use TILE_USER_INDEX instead.\"")
#define TILE_FONTINDEX   _Pragma("GCC error \"This definition is deprecated, use TILE_FONT_INDEX instead.\"")
#define TILE_SPRITEINDEX   _Pragma("GCC error \"This definition is deprecated, use TILE_SPRITE_INDEX instead.\"")
#define TILE_USERLENGTH   _Pragma("GCC error \"This definition is deprecated, use TILE_USER_LENGTH instead.\"")
#define TILE_USERMAXINDEX   _Pragma("GCC error \"This definition is deprecated, use TILE_USER_MAX_INDEX instead.\"")
#define TILE_SYSTEM   (TILE_SYSTEM_INDEX * TILE_SIZE)
 System tile address in VRAM.
#define TILE_USER   (TILE_USER_INDEX * TILE_SIZE)
 User tile address in VRAM.
#define TILE_FONT   (TILE_FONT_INDEX * TILE_SIZE)
 Font tile address in VRAM.
#define PAL0   0
 Palette 0.
#define PAL1   1
 Palette 1.
#define PAL2   2
 Palette 2.
#define PAL3   3
 Palette 3.
#define VDP_READ_VRAM_ADDR(adr)   (((0x0000 + ((adr) & 0x3FFF)) << 16) + (((adr) >> 14) | 0x00))
 Set VDP command to read specified VRAM address.
#define VDP_READ_CRAM_ADDR(adr)   (((0x0000 + ((adr) & 0x7F)) << 16) + 0x20)
 Set VDP command to read specified CRAM address.
#define VDP_READ_VSRAM_ADDR(adr)   (((0x0000 + ((adr) & 0x7F)) << 16) + 0x10)
 Set VDP command to read specified VSRAM address.
#define VDP_WRITE_VRAM_ADDR(adr)   (((0x4000 + ((adr) & 0x3FFF)) << 16) + (((adr) >> 14) | 0x00))
 Set VDP command to write at specified VRAM address.
#define VDP_WRITE_CRAM_ADDR(adr)   (((0xC000 + ((adr) & 0x7F)) << 16) + 0x00)
 Set VDP command to write at specified CRAM address.
#define VDP_WRITE_VSRAM_ADDR(adr)   (((0x4000 + ((adr) & 0x7F)) << 16) + 0x10)
 Set VDP command to write at specified VSRAM address.
#define VDP_DMA_VRAM_ADDR(adr)   (((0x4000 + ((adr) & 0x3FFF)) << 16) + (((adr) >> 14) | 0x80))
 Set VDP command to issue a DMA transfert to specified VRAM address.
#define VDP_DMA_CRAM_ADDR(adr)   (((0xC000 + ((adr) & 0x7F)) << 16) + 0x80)
 Set VDP command to issue a DMA transfert to specified CRAM address.
#define VDP_DMA_VSRAM_ADDR(adr)   (((0x4000 + ((adr) & 0x7F)) << 16) + 0x90)
 Set VDP command to issue a DMA transfert to specified VSRAM address.
#define VDP_DMA_VRAMCOPY_ADDR(adr)   (((0x4000 + ((adr) & 0x3FFF)) << 16) + (((adr) >> 14) | 0xC0))
 Set VDP command to issue a DMA VRAM copy to specified VRAM address.
#define VDP_VERT_SCROLL(adr)   VDP_WRITE_VSRAM_ADDR(adr)
 Helper to write in vertical scroll table (same as VDP_WRITE_VSRAM_ADDR).
#define VDP_HORZ_SCROLL(adr)   VDP_WRITE_VRAM_ADDR(VDP_SCROLL_H + (adr))
 Helper to write in horizontal scroll table (same as VDP_WRITE_VRAM_ADDR(VDP_SCROLL_H + adr)).
#define GFX_READ_VRAM_ADDR(adr)   _Pragma("GCC error \"This definition is deprecated, use VDP_READ_VRAM_ADDR instead.\""))
#define GFX_READ_CRAM_ADDR(adr)   _Pragma("GCC error \"This definition is deprecated, use VDP_READ_CRAM_ADDR instead.\"")
#define GFX_READ_VSRAM_ADDR(adr)   _Pragma("GCC error \"This definition is deprecated, use VDP_READ_VSRAM_ADDR instead.\"")
#define GFX_WRITE_VRAM_ADDR(adr)   _Pragma("GCC error \"This definition is deprecated, use VDP_WRITE_VRAM_ADDR instead.\"")
#define GFX_WRITE_CRAM_ADDR(adr)   _Pragma("GCC error \"This definition is deprecated, use VDP_WRITE_CRAM_ADDR instead.\"")
#define GFX_WRITE_VSRAM_ADDR(adr)   _Pragma("GCC error \"This definition is deprecated, use VDP_WRITE_VSRAM_ADDR instead.\"")
#define GFX_DMA_VRAM_ADDR(adr)   _Pragma("GCC error \"This definition is deprecated, use VDP_DMA_VRAM_ADDR instead.\"")
#define GFX_DMA_CRAM_ADDR(adr)   _Pragma("GCC error \"This definition is deprecated, use VDP_DMA_CRAM_ADDR instead.\"")
#define GFX_DMA_VSRAM_ADDR(adr)   _Pragma("GCC error \"This definition is deprecated, use VDP_DMA_VSRAM_ADDR instead.\"")
#define GFX_DMA_VRAMCOPY_ADDR(adr)   _Pragma("GCC error \"This definition is deprecated, use VDP_DMA_VRAMCOPY_ADDR instead.\"")
#define GFX_VERT_SCROLL(adr)   _Pragma("GCC error \"This definition is deprecated, use VDP_VERT_SCROLL instead.\"")
#define GFX_HORZ_SCROLL(adr)   _Pragma("GCC error \"This definition is deprecated, use VDP_HORZ_SCROLL instead.\"")
#define GET_VDP_STATUS(flag)   ((*(vu16*)(VDP_CTRL_PORT)) & (flag))
 Tests VDP status against specified flag (see VDP_XXX_FLAG).
#define IS_PAL_SYSTEM   GET_VDP_STATUS(VDP_PALMODE_FLAG)
 Tests if current system is a PAL system (50 Hz).
#define GET_HVCOUNTER   (*(vu16*)(VDP_HVCOUNTER_PORT))
 Returns HV counter.
#define GET_HCOUNTER   (GET_HVCOUNTER & 0xFF)
 Returns Horizontal counter.
#define GET_VCOUNTER   (GET_HVCOUNTER >> 8)
 Returns Vertical counter.
#define VDP_setPlanSize(w, h)   _Pragma("GCC error \"This definition is deprecated, use VDP_setPlaneSize(..) instead.\"")
#define VDP_getAPlanAddress()   _Pragma("GCC error \"This definition is deprecated, use VDP_getBGAAddress() instead.\"")
#define VDP_getBPlanAddress()   _Pragma("GCC error \"This definition is deprecated, use VDP_getBGBAddress() instead.\"")
#define VDP_getWindowPlanAddress()   _Pragma("GCC error \"This definition is deprecated, use VDP_getWindowAddress() instead.\"")
#define VDP_setAPlanAddress(value)   _Pragma("GCC error \"This definition is deprecated, use VDP_setBGAAddress(..) instead.\"")
#define VDP_setBPlanAddress(value)   _Pragma("GCC error \"This definition is deprecated, use VDP_setBGBAddress(..) instead.\"")
#define VDP_setWindowPlanAddress(value)   _Pragma("GCC error \"This definition is deprecated, use VDP_setWindowAddress(..) instead.\"")

Enumerations

enum  VDPPlane { BG_A = 0, BG_B = 1, WINDOW = 2 }
 Type used to define on which plane to work (used by some methods).

Functions

void VDP_init (void)
 Initialize the whole VDP sub system.
void VDP_resetScreen (void)
 Reset background planes and palettes.
u8 VDP_getReg (u16 reg)
 Get VDP register value.
void VDP_setReg (u16 reg, u8 value)
 Set VDP register value.
bool VDP_getEnable (void)
 Returns VDP enable state.
bool VDP_isEnable (void)
 Returns VDP enable state.
void VDP_setEnable (bool value)
 Set VDP enable state.
u16 VDP_getScanlineNumber (void)
 Returns number of total scanline.
u16 VDP_getScreenHeight (void)
 Returns vertical screen resolution.
void VDP_setScreenHeight224 (void)
 Set vertical resolution to 224 pixels.
void VDP_setScreenHeight240 (void)
 Set vertical resolution to 240 pixels.
u16 VDP_getScreenWidth (void)
 Returns horizontal screen resolution.
void VDP_setScreenWidth256 (void)
 Set horizontal resolution to 256 pixels.
void VDP_setScreenWidth320 (void)
 Set horizontal resolution to 320 pixels.
u16 VDP_getPlaneWidth (void)
 Return background plane width (in tile).
u16 VDP_getPlaneHeight (void)
 Return background plane height (in tile).
void VDP_setPlaneSize (u16 w, u16 h, bool setupVram)
 Set background plane size (in tile).
WARNING: take attention to properly setup VRAM so tilemaps has enough space.
u8 VDP_getHorizontalScrollingMode (void)
 Returns plane horizontal scrolling mode.
u8 VDP_getVerticalScrollingMode (void)
 Returns plane vertical scrolling mode.
void VDP_setScrollingMode (u16 hscroll, u16 vscroll)
 Set plane scrolling mode.
u8 VDP_getBackgroundColor (void)
 Returns the background color index.
void VDP_setBackgroundColor (u8 value)
 Set the background color index.
u8 VDP_getAutoInc (void)
 Returns auto increment register value.
void VDP_setAutoInc (u8 value)
 Set auto increment register value.
u8 VDP_getDMAEnabled (void)
 Returns DMA enabled state.
void VDP_setDMAEnabled (bool value)
 Set DMA enabled state.
u8 VDP_getHVLatching (void)
 Returns HV counter latching on INT2 (used for light gun)
void VDP_setHVLatching (bool value)
 Set HV counter latching on INT2 (used for light gun)
void VDP_setVInterrupt (bool value)
 Enable or Disable Vertical interrupt (it's *strongly* recommanded to keep it enabled).
void VDP_setHInterrupt (bool value)
 Enable or Disable Horizontal interrupt.
void VDP_setExtInterrupt (bool value)
 Enable or Disable External interrupt.
void VDP_setHilightShadow (bool value)
 Enable or Disable Hilight / Shadow effect.
u8 VDP_getHIntCounter (void)
 Get Horizontal interrupt counter value.
void VDP_setHIntCounter (u8 value)
 Set Horizontal interrupt counter value.
u16 VDP_getBGAAddress (void)
 Get VRAM address (location) of BG A tilemap.
u16 VDP_getBGBAddress (void)
 Get VRAM address (location) of BG B tilemap.
u16 VDP_getWindowAddress (void)
 Get VRAM address (location) of Window tilemap.
u16 VDP_getSpriteListAddress (void)
 Get VRAM address (location) of Sprite list.
u16 VDP_getHScrollTableAddress (void)
 Get VRAM address (location) of H SCroll table.
void VDP_setBGAAddress (u16 value)
 Set VRAM address (location) of BG A tilemap. The address should be at multiple of $2000

Ex:
VDP_setBGAAddress(0xC000)
Will set the BG A to at address 0xC000 in VRAM.
void VDP_setBGBAddress (u16 value)
 Set VRAM address (location) of BG B tilemap.
The address should be at multiple of $2000

Ex:
VDP_setBGBAddress(0xE000)
Will set the BG B tilemap at address 0xE000 in VRAM.
void VDP_setWindowAddress (u16 value)
 Set VRAM address (location) of Window tilemap.
The address should be at multiple of $1000 in H40 and $800 in H32

Ex:
VDP_setWindowAddress(0xA000)
Will set the Window tilemap at address 0xA000 in VRAM.
void VDP_setSpriteListAddress (u16 value)
 Set VRAM address (location) of Sprite list.
The address should be at multiple of $400 in H40 and $200 in H32

Ex:
VDP_setSpriteListAddress(0xD800)
Will set the Sprite list to at address 0xD800 in VRAM.
void VDP_setHScrollTableAddress (u16 value)
 Set VRAM address (location) of H Scroll table.
The address should be at multiple of $400

Ex:
VDP_setHScrollTableAddress(0xD400)
Will set the HScroll table to at address 0xD400 in VRAM.
void VDP_setScanMode (u16 mode)
 Sets the scan mode of the display.
void VDP_setWindowHPos (u16 right, u16 pos)
 Sets the window Horizontal position.
void VDP_setWindowVPos (u16 down, u16 pos)
 Sets the window Vertical position.
void VDP_waitDMACompletion (void)
 Wait for DMA operation to complete - same as DMA_waitCompletion()
void VDP_waitFIFOEmpty (void)
 Wait for VDP FIFO to be empty.
bool VDP_waitVInt (void)
 Wait for next Vertical Interruption.
bool VDP_waitVBlank (bool forceNext)
 Wait for next vertical blank period (same as VDP_waitVSync())
bool VDP_waitVSync (void)
 Wait for Vertical Synchro.
void VDP_waitVActive (bool forceNext)
 Wait for next vertical active area (end of vertical blank period)
u16 VDP_getAdjustedVCounter (void)
 Return an enhanced V Counter representation.
void VDP_showFPS (u16 asFloat)
 Display number of Frame Per Second.
void VDP_showCPULoad (void)
 Display the estimated CPU load (in %).

Variables

u16 window_addr
u16 bga_addr
u16 bgb_addr
u16 hscrl_addr
u16 slist_addr
u16 maps_addr
u16 userTileMaxIndex
u16 screenWidth
 Current screen width (horizontale resolution)
u16 screenHeight
 Current screen height (verticale resolution)
u16 planeWidth
 Current background plane width (in tile)
u16 planeHeight
 Current background plane height (in tile)
u16 windowWidth
 Current window width (in tile)
u16 planeWidthSft
 Current background plane width bit shift.
u16 planeHeightSft
 Current background plane height bit shift.
u16 windowWidthSft
 Current window width bit shift.

Detailed Description

VDP main.

Author:
Stephane Dallongeville
Date:
08/2011

This unit provides general VDP (Video Display Processor) methods:

  • initialisation
  • get / set register
  • get / set resolution
  • enable / disable VDP features

    WARNING: It's very important that VRAM is organized with tile data being located before tilemaps and tables:
    0000-XXXX = tile data
    XXXX-FFFF = tilemaps & tables (H scroll table, sprite table, B/A plane and window plane).

    If you don't respect that you may get in troubles as SGDK expect it ;)

Define Documentation

#define GFX_CTRL_PORT   _Pragma("GCC error \"This definition is deprecated, use VDP_CTRL_PORT instead.\"")
#define GFX_DATA_PORT   _Pragma("GCC error \"This definition is deprecated, use VDP_DATA_PORT instead.\"")
#define GFX_DMA_CRAM_ADDR (   adr)    _Pragma("GCC error \"This definition is deprecated, use VDP_DMA_CRAM_ADDR instead.\"")
#define GFX_DMA_VRAM_ADDR (   adr)    _Pragma("GCC error \"This definition is deprecated, use VDP_DMA_VRAM_ADDR instead.\"")
#define GFX_DMA_VRAMCOPY_ADDR (   adr)    _Pragma("GCC error \"This definition is deprecated, use VDP_DMA_VRAMCOPY_ADDR instead.\"")
#define GFX_DMA_VSRAM_ADDR (   adr)    _Pragma("GCC error \"This definition is deprecated, use VDP_DMA_VSRAM_ADDR instead.\"")
#define GFX_HORZ_SCROLL (   adr)    _Pragma("GCC error \"This definition is deprecated, use VDP_HORZ_SCROLL instead.\"")
#define GFX_HVCOUNTER_PORT   _Pragma("GCC error \"This definition is deprecated, use VDP_HVCOUNTER_PORT instead.\"")
#define GFX_READ_CRAM_ADDR (   adr)    _Pragma("GCC error \"This definition is deprecated, use VDP_READ_CRAM_ADDR instead.\"")
#define GFX_READ_VRAM_ADDR (   adr)    _Pragma("GCC error \"This definition is deprecated, use VDP_READ_VRAM_ADDR instead.\""))
#define GFX_READ_VSRAM_ADDR (   adr)    _Pragma("GCC error \"This definition is deprecated, use VDP_READ_VSRAM_ADDR instead.\"")
#define GFX_VERT_SCROLL (   adr)    _Pragma("GCC error \"This definition is deprecated, use VDP_VERT_SCROLL instead.\"")
#define GFX_WRITE_CRAM_ADDR (   adr)    _Pragma("GCC error \"This definition is deprecated, use VDP_WRITE_CRAM_ADDR instead.\"")
#define GFX_WRITE_VRAM_ADDR (   adr)    _Pragma("GCC error \"This definition is deprecated, use VDP_WRITE_VRAM_ADDR instead.\"")
#define GFX_WRITE_VSRAM_ADDR (   adr)    _Pragma("GCC error \"This definition is deprecated, use VDP_WRITE_VSRAM_ADDR instead.\"")
#define TILE_FONTINDEX   _Pragma("GCC error \"This definition is deprecated, use TILE_FONT_INDEX instead.\"")
Deprecated:
Use TILE_FONT_INDEX instead
#define TILE_MAXINDEX   _Pragma("GCC error \"This definition is deprecated, use TILE_MAX_INDEX instead.\"")
Deprecated:
Use TILE_MAX_INDEX instead
#define TILE_MAXNUM   _Pragma("GCC error \"This definition is deprecated, use TILE_MAX_NUM instead.\"")
Deprecated:
Use TILE_MAX_NUM instead
#define TILE_SPRITEINDEX   _Pragma("GCC error \"This definition is deprecated, use TILE_SPRITE_INDEX instead.\"")
Deprecated:
Use TILE_SPRITE_INDEX instead
#define TILE_SYSTEM_LENGHT   _Pragma("GCC error \"This definition is deprecated, use TILE_SYSTEM_LENGTH instead.\"")
Deprecated:
Use TILE_SYSTEM_LENGTH instead.
#define TILE_SYSTEMINDEX   _Pragma("GCC error \"This definition is deprecated, use TILE_SYSTEM_INDEX instead.\"")
Deprecated:
Use TILE_SYSTEM_INDEX instead
#define TILE_SYSTEMLENGTH   _Pragma("GCC error \"This definition is deprecated, use TILE_SYSTEM_LENGTH instead.\"")
Deprecated:
Use TILE_SYSTEM_LENGTH instead
#define TILE_USERINDEX   _Pragma("GCC error \"This definition is deprecated, use TILE_USER_INDEX instead.\"")
Deprecated:
Use TILE_USER_INDEX instead
#define TILE_USERLENGTH   _Pragma("GCC error \"This definition is deprecated, use TILE_USER_LENGTH instead.\"")
Deprecated:
Use TILE_USER_LENGTH instead
#define TILE_USERMAXINDEX   _Pragma("GCC error \"This definition is deprecated, use TILE_USER_MAX_INDEX instead.\"")
Deprecated:
Use TILE_USER_MAX_INDEX instead
#define VDP_getAPlanAddress ( )    _Pragma("GCC error \"This definition is deprecated, use VDP_getBGAAddress() instead.\"")
Deprecated:
Use VDP_getBGAAddress(..) instead.
#define VDP_getBPlanAddress ( )    _Pragma("GCC error \"This definition is deprecated, use VDP_getBGBAddress() instead.\"")
Deprecated:
Use VDP_getBGBAddress(..) instead.
#define VDP_getWindowPlanAddress ( )    _Pragma("GCC error \"This definition is deprecated, use VDP_getWindowAddress() instead.\"")
#define VDP_PLAN_A   _Pragma("GCC error \"This definition is deprecated, use VDP_BG_A instead.\"")
Deprecated:
Use VDP_BG_A instead
#define VDP_PLAN_B   _Pragma("GCC error \"This definition is deprecated, use VDP_BG_B instead.\"")
Deprecated:
Use VDP_BG_B instead
#define VDP_PLAN_WINDOW   _Pragma("GCC error \"This definition is deprecated, use VDP_WINDOW instead.\"")
Deprecated:
Use VDP_WINDOW instead
#define VDP_setAPlanAddress (   value)    _Pragma("GCC error \"This definition is deprecated, use VDP_setBGAAddress(..) instead.\"")
Deprecated:
Use VDP_setBGAAddress(..) instead.
#define VDP_setBPlanAddress (   value)    _Pragma("GCC error \"This definition is deprecated, use VDP_setBGBAddress(..) instead.\"")
Deprecated:
Use VDP_setBGBAddress(..) instead.
#define VDP_setPlanSize (   w,
 
)    _Pragma("GCC error \"This definition is deprecated, use VDP_setPlaneSize(..) instead.\"")
Deprecated:
Use VDP_setPlaneSize(..) instead.
#define VDP_setWindowPlanAddress (   value)    _Pragma("GCC error \"This definition is deprecated, use VDP_setWindowAddress(..) instead.\"")
#define VSCROLL_2TILE   _Pragma("GCC error \"This definition is deprecated, use VSCROLL_COLUMN instead.\"")
Deprecated:
Use VSCROLL_COLUMN instead

Function Documentation

u16 VDP_getAdjustedVCounter ( void  )

Return an enhanced V Counter representation.

Using direct V counter from VDP may give troubles as the VDP V-Counter rollback during V-Blank period.
This function aim to make ease the use of V-Counter by adjusting it to a [0-255] range where 0 is the start of VBlank area and 255 the end of active display area.

u8 VDP_getHorizontalScrollingMode ( void  )

Returns plane horizontal scrolling mode.

Possible values are: HSCROLL_PLANE, HSCROLL_TILE, HSCROLL_LINE

See also:
VDP_setScrollingMode for more informations about scrolling mode.
u8 VDP_getReg ( u16  reg)

Get VDP register value.

Parameters:
regRegister number we want to retrieve value.
Returns:
specified register value.
u16 VDP_getScanlineNumber ( void  )

Returns number of total scanline.

312 for PAL system and 262 for NTSC system.

u16 VDP_getScreenHeight ( void  )

Returns vertical screen resolution.

Always returns 224 on NTSC system as they only support this mode.
PAL system supports 240 pixels mode.

u16 VDP_getScreenWidth ( void  )

Returns horizontal screen resolution.

Returns 320 or 256 depending current horizontal resolution mode.

u8 VDP_getVerticalScrollingMode ( void  )

Returns plane vertical scrolling mode.

Possible values are: VSCROLL_PLANE, VSCROLL_2TILE

See also:
VDP_setScrollingMode for more informations about scrolling mode.
void VDP_init ( void  )

Initialize the whole VDP sub system.

Reset VDP registers, reset sprites then call VDP_resetScreen() to reset BG and palettes.

void VDP_resetScreen ( void  )

Reset background planes and palettes.

Reset VRAM (clear BG planes and reload font), reset scrolls and reset palettes (set to default grey / red / green / blue ramps).

void VDP_setDMAEnabled ( bool  value)

Set DMA enabled state.

Note that by default SGDK always enable DMA (there is no reason to disable it)

void VDP_setEnable ( bool  value)

Set VDP enable state.

You can temporary disable VDP to speed up VDP memory transfert.

void VDP_setExtInterrupt ( bool  value)

Enable or Disable External interrupt.

See also:
VDP_setExtIntCounter()
void VDP_setHIntCounter ( u8  value)

Set Horizontal interrupt counter value.

When Horizontal interrupt is enabled, setting 5 here means that H int will occurs each (5+1) scanline.
Set value 0 to get H int at each scanline.

void VDP_setHInterrupt ( bool  value)

Enable or Disable Horizontal interrupt.

See also:
VDP_setHIntCounter()
void VDP_setHVLatching ( bool  value)

Set HV counter latching on INT2 (used for light gun)

You can ask the HV Counter to fix its value on INT2 for accurate light gun positionning.

void VDP_setPlaneSize ( u16  w,
u16  h,
bool  setupVram 
)

Set background plane size (in tile).
WARNING: take attention to properly setup VRAM so tilemaps has enough space.

Parameters:
wwidth in tile.
Possible values are 32, 64 or 128.
hheight in tile.
Possible values are 32, 64 or 128.
setupVramIf set to TRUE then tilemaps and tables will be automatically remapped in VRAM depending the plane size. If you don't know what that means then it's better to keep this value to TRUE :p
Be careful to redraw your backgrounds, also the sprite engine may need to re-allocate its VRAM region if location changed.
void VDP_setReg ( u16  reg,
u8  value 
)

Set VDP register value.

Parameters:
regRegister number we want to set value.
valuevalue to set.
void VDP_setScanMode ( u16  mode)

Sets the scan mode of the display.

Parameters:
modeAccepted values : INTERLACED_NONE, INTERLACED_MODE1, INTERLACED_MODE2

This function changes the scanning mode on the next display blanking period.
In Interlaced Mode 1, the same pattern will be displayed on the adjacent lines of even and odd numbered fields.
In Interlaced Mode 2, different patterns can be displayed on the adjacent lines of even and odd numbered fields.
The number of cells on the screen stays the same regardless of which scanning mode is active.

void VDP_setScreenHeight224 ( void  )

Set vertical resolution to 224 pixels.

This is the only accepted mode for NTSC system.

void VDP_setScreenHeight240 ( void  )

Set vertical resolution to 240 pixels.

Only work on PAL system.

void VDP_setScrollingMode ( u16  hscroll,
u16  vscroll 
)

Set plane scrolling mode.

Parameters:
hscrollHorizontal scrolling mode :
HSCROLL_PLANE = Scroll offset is applied to the whole plane.
HSCROLL_TILE = Scroll offset is applied on a tile basis granularity (8 pixels bloc).
HSCROLL_LINE = Scroll offset is applied on a line basis granularity (1 pixel).
vscrollVertical scrolling mode :
VSCROLL_PLANE = Scroll offset is applied to the whole plane.
VSCROLL_2TILE = Scroll offset is applied on 2 tiles basis granularity (16 pixels bloc).
See also:
VDP_setHorizontalScroll() to set horizontal scroll offset in mode plane.
VDP_setHorizontalScrollTile() to set horizontal scroll offset(s) in mode tile.
VDP_setHorizontalScrollLine() to set horizontal scroll offset(s) in mode line.
VDP_setVerticalScroll() to set vertical scroll offset in mode plane.
VDP_setVerticalScrollTile() to set vertical scroll offset(s) in mode 2-tile.
void VDP_setVInterrupt ( bool  value)

Enable or Disable Vertical interrupt (it's *strongly* recommanded to keep it enabled).

See also:
VDP_setHInterrupt()
void VDP_setWindowHPos ( u16  right,
u16  pos 
)

Sets the window Horizontal position.

Parameters:
rightIf set to FALSE the window is displayed from column 0 up to column pos If set to TRUE the window is displayed from column pos up to last column
posThe Horizontal position of the window in 2 tiles unit (16 pixels).
void VDP_setWindowVPos ( u16  down,
u16  pos 
)

Sets the window Vertical position.

Parameters:
downIf set to FALSE the window is displayed from row 0 up to row pos If set to TRUE the window is displayed from row pos up to last row
posThe Vertical position of the window in 1 tile unit (8 pixels).
void VDP_showCPULoad ( void  )

Display the estimated CPU load (in %).

This function actually display an estimation of the CPU load (in %) for the last frame.

See also:
SYS_getCPULoad()
void VDP_showFPS ( u16  asFloat)

Display number of Frame Per Second.

Parameters:
asFloatDisplay in float number format.

This function actually display the number of time it was called in the last second.
i.e: for benchmarking you should call this method only once per frame update.

See also:
SYS_getFPS(..)
void VDP_waitVActive ( bool  forceNext)

Wait for next vertical active area (end of vertical blank period)

Parameters:
forceNextForce waiting for next start of V-Active if we are already in V-Active period when calling the method.

The method wait until we are in Vertical active area/period.

bool VDP_waitVBlank ( bool  forceNext)

Wait for next vertical blank period (same as VDP_waitVSync())

Returns:
TRUE if a frame miss was detected (more than 1 frame elapsed since last call)
Parameters:
forceNextForce waiting for next start of VBlank if we are already in VBlank period when calling the method.

The method wait until we are in Vertical blanking area/period.

bool VDP_waitVInt ( void  )

Wait for next Vertical Interruption.

Returns:
TRUE if a frame miss was detected (more than 1 frame elapsed since last call)

The method actually wait for the start of Vertical Interruption. It returns immediately if we are already in V-Int handler.

bool VDP_waitVSync ( void  )

Wait for Vertical Synchro.

Returns:
TRUE if a frame miss was detected (more than 1 frame elapsed since last call)

The method actually wait for the *next* start of Vertical blanking.


Variable Documentation

Current background plane height (in tile)

Possible values are: 32, 64, 128

Current background plane height bit shift.

Possible values are: 5, 6 or 7 (corresponding to plane height 32, 64 and 128)

Current background plane width (in tile)

Possible values are: 32, 64, 128

Current background plane width bit shift.

Possible values are: 5, 6 or 7 (corresponding to plane width 32, 64 and 128)

Current window width (in tile)

Possible values are: 32, 64

Current window width bit shift.

Possible values are: 5 or 6 (corresponding to window width 32 or 64)

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines