30#define VDP_DATA_PORT 0xC00000
35#define VDP_CTRL_PORT 0xC00004
40#define VDP_HVCOUNTER_PORT 0xC00008
46#define GFX_DATA_PORT _Pragma("GCC error \"This definition is deprecated, use VDP_DATA_PORT instead.\"")
52#define GFX_CTRL_PORT _Pragma("GCC error \"This definition is deprecated, use VDP_CTRL_PORT instead.\"")
57#define GFX_HVCOUNTER_PORT _Pragma("GCC error \"This definition is deprecated, use VDP_HVCOUNTER_PORT instead.\"")
64#define VDP_FIFOEMPTY_FLAG (1 << 9)
69#define VDP_FIFOFULL_FLAG (1 << 8)
74#define VDP_VINTPENDING_FLAG (1 << 7)
79#define VDP_SPROVERFLOW_FLAG (1 << 6)
84#define VDP_SPRCOLLISION_FLAG (1 << 5)
89#define VDP_ODDFRAME_FLAG (1 << 4)
94#define VDP_VBLANK_FLAG (1 << 3)
99#define VDP_HBLANK_FLAG (1 << 2)
104#define VDP_DMABUSY_FLAG (1 << 1)
109#define VDP_PALMODE_FLAG (1 << 0)
115#define VDP_PLAN_A _Pragma("GCC error \"This definition is deprecated, use VDP_BG_A instead.\"")
120#define VDP_PLAN_B _Pragma("GCC error \"This definition is deprecated, use VDP_BG_B instead.\"")
125#define VDP_PLAN_WINDOW _Pragma("GCC error \"This definition is deprecated, use VDP_WINDOW instead.\"")
131#define VDP_BG_A bga_addr
136#define VDP_BG_B bgb_addr
141#define VDP_WINDOW window_addr
146#define VDP_HSCROLL_TABLE hscrl_addr
151#define VDP_SPRITE_TABLE slist_addr
156#define VDP_MAPS_START maps_addr
162#define HSCROLL_PLANE 0
167#define HSCROLL_TILE 2
172#define HSCROLL_LINE 3
178#define VSCROLL_PLANE 0
183#define VSCROLL_COLUMN 1
188#define VSCROLL_2TILE _Pragma("GCC error \"This definition is deprecated, use VSCROLL_COLUMN instead.\"")
195#define INTERLACED_NONE 0
201#define INTERLACED_MODE1 1
207#define INTERLACED_MODE2 2
220#define TILE_INDEX_MASK (0xFFFF / TILE_SIZE)
226#define TILE_SPACE VDP_MAPS_START
232#define TILE_MAX_NUM (TILE_SPACE / TILE_SIZE)
237#define TILE_MAX_INDEX (TILE_MAXNUM - 1)
242#define TILE_SYSTEM_INDEX 0x0000
247#define TILE_SYSTEM_LENGTH 16
252#define TILE_USER_INDEX (TILE_SYSTEM_INDEX + TILE_SYSTEM_LENGTH)
257#define TILE_FONT_INDEX (TILE_MAX_NUM - FONT_LEN)
262#define TILE_SPRITE_INDEX (TILE_FONT_INDEX - spriteVramSize)
267#define TILE_USER_LENGTH ((userTileMaxIndex - TILE_USER_INDEX) + 1)
272#define TILE_USER_MAX_INDEX userTileMaxIndex
278#define TILE_MAXNUM _Pragma("GCC error \"This definition is deprecated, use TILE_MAX_NUM instead.\"")
283#define TILE_MAXINDEX _Pragma("GCC error \"This definition is deprecated, use TILE_MAX_INDEX instead.\"")
287#define TILE_SYSTEM_LENGHT _Pragma("GCC error \"This definition is deprecated, use TILE_SYSTEM_LENGTH instead.\"")
292#define TILE_SYSTEMLENGTH _Pragma("GCC error \"This definition is deprecated, use TILE_SYSTEM_LENGTH instead.\"")
297#define TILE_SYSTEMINDEX _Pragma("GCC error \"This definition is deprecated, use TILE_SYSTEM_INDEX instead.\"")
302#define TILE_USERINDEX _Pragma("GCC error \"This definition is deprecated, use TILE_USER_INDEX instead.\"")
307#define TILE_FONTINDEX _Pragma("GCC error \"This definition is deprecated, use TILE_FONT_INDEX instead.\"")
312#define TILE_SPRITEINDEX _Pragma("GCC error \"This definition is deprecated, use TILE_SPRITE_INDEX instead.\"")
317#define TILE_USERLENGTH _Pragma("GCC error \"This definition is deprecated, use TILE_USER_LENGTH instead.\"")
322#define TILE_USERMAXINDEX _Pragma("GCC error \"This definition is deprecated, use TILE_USER_MAX_INDEX instead.\"")
328#define TILE_SYSTEM (TILE_SYSTEM_INDEX * TILE_SIZE)
333#define TILE_USER (TILE_USER_INDEX * TILE_SIZE)
338#define TILE_FONT (TILE_FONT_INDEX * TILE_SIZE)
365#define VDP_READ_VRAM_ADDR(adr) (((0x0000 + ((adr) & 0x3FFF)) << 16) + (((adr) >> 14) | 0x00))
370#define VDP_READ_CRAM_ADDR(adr) (((0x0000 + ((adr) & 0x7F)) << 16) + 0x20)
375#define VDP_READ_VSRAM_ADDR(adr) (((0x0000 + ((adr) & 0x7F)) << 16) + 0x10)
381#define VDP_WRITE_VRAM_ADDR(adr) (((0x4000 + ((adr) & 0x3FFF)) << 16) + (((adr) >> 14) | 0x00))
386#define VDP_WRITE_CRAM_ADDR(adr) (((0xC000 + ((adr) & 0x7F)) << 16) + 0x00)
391#define VDP_WRITE_VSRAM_ADDR(adr) (((0x4000 + ((adr) & 0x7F)) << 16) + 0x10)
397#define VDP_DMA_VRAM_ADDR(adr) (((0x4000 + ((adr) & 0x3FFF)) << 16) + (((adr) >> 14) | 0x80))
402#define VDP_DMA_CRAM_ADDR(adr) (((0xC000 + ((adr) & 0x7F)) << 16) + 0x80)
407#define VDP_DMA_VSRAM_ADDR(adr) (((0x4000 + ((adr) & 0x7F)) << 16) + 0x90)
413#define VDP_DMA_VRAMCOPY_ADDR(adr) (((0x4000 + ((adr) & 0x3FFF)) << 16) + (((adr) >> 14) | 0xC0))
419#define VDP_VERT_SCROLL(adr) VDP_WRITE_VSRAM_ADDR(adr)
424#define VDP_HORZ_SCROLL(adr) VDP_WRITE_VRAM_ADDR(VDP_SCROLL_H + (adr))
430#define GFX_READ_VRAM_ADDR(adr) _Pragma("GCC error \"This definition is deprecated, use VDP_READ_VRAM_ADDR instead.\""))
435#define GFX_READ_CRAM_ADDR(adr) _Pragma("GCC error \"This definition is deprecated, use VDP_READ_CRAM_ADDR instead.\"")
440#define GFX_READ_VSRAM_ADDR(adr) _Pragma("GCC error \"This definition is deprecated, use VDP_READ_VSRAM_ADDR instead.\"")
445#define GFX_WRITE_VRAM_ADDR(adr) _Pragma("GCC error \"This definition is deprecated, use VDP_WRITE_VRAM_ADDR instead.\"")
450#define GFX_WRITE_CRAM_ADDR(adr) _Pragma("GCC error \"This definition is deprecated, use VDP_WRITE_CRAM_ADDR instead.\"")
455#define GFX_WRITE_VSRAM_ADDR(adr) _Pragma("GCC error \"This definition is deprecated, use VDP_WRITE_VSRAM_ADDR instead.\"")
460#define GFX_DMA_VRAM_ADDR(adr) _Pragma("GCC error \"This definition is deprecated, use VDP_DMA_VRAM_ADDR instead.\"")
465#define GFX_DMA_CRAM_ADDR(adr) _Pragma("GCC error \"This definition is deprecated, use VDP_DMA_CRAM_ADDR instead.\"")
470#define GFX_DMA_VSRAM_ADDR(adr) _Pragma("GCC error \"This definition is deprecated, use VDP_DMA_VSRAM_ADDR instead.\"")
475#define GFX_DMA_VRAMCOPY_ADDR(adr) _Pragma("GCC error \"This definition is deprecated, use VDP_DMA_VRAMCOPY_ADDR instead.\"")
480#define GFX_VERT_SCROLL(adr) _Pragma("GCC error \"This definition is deprecated, use VDP_VERT_SCROLL instead.\"")
485#define GFX_HORZ_SCROLL(adr) _Pragma("GCC error \"This definition is deprecated, use VDP_HORZ_SCROLL instead.\"")
492#define GET_VDP_STATUS(flag) ((*(vu16*)(VDP_CTRL_PORT)) & (flag))
497#define IS_PAL_SYSTEM GET_VDP_STATUS(VDP_PALMODE_FLAG)
503#define GET_HVCOUNTER (*(vu16*)(VDP_HVCOUNTER_PORT))
508#define GET_HCOUNTER (GET_HVCOUNTER & 0xFF)
513#define GET_VCOUNTER (GET_HVCOUNTER >> 8)
522 BG_A = 0, BG_B = 1, WINDOW = 2
527extern u16 window_addr;
530extern u16 hscrl_addr;
531extern u16 slist_addr;
533extern u16 userTileMaxIndex;
723#define VDP_setPlanSize(w, h) _Pragma("GCC error \"This definition is deprecated, use VDP_setPlaneSize(..) instead.\"")
866#define VDP_getAPlanAddress() _Pragma("GCC error \"This definition is deprecated, use VDP_getBGAAddress() instead.\"")
871#define VDP_getBPlanAddress() _Pragma("GCC error \"This definition is deprecated, use VDP_getBGBAddress() instead.\"")
882#define VDP_getWindowPlanAddress() _Pragma("GCC error \"This definition is deprecated, use VDP_getWindowAddress() instead.\"")
918#define VDP_setAPlanAddress(value) \
919_Pragma("GCC error \"This definition is deprecated, use VDP_setBGAAddress(..) instead.\"")
924#define VDP_setBPlanAddress(value) \
925_Pragma("GCC error \"This definition is deprecated, use VDP_setBGBAddress(..) instead.\"")
940#define VDP_setWindowPlanAddress(value) _Pragma("GCC error \"This definition is deprecated, use VDP_setWindowAddress(..) instead.\"")
void VDP_setScanMode(u16 mode)
Sets the scan mode of the display.
Definition vdp.c:764
void VDP_setWindowOff()
Turns off the window.
Definition vdp.c:810
void VDP_setSpriteListAddress(u16 value)
Set VRAM address (location) of Sprite list. The address should be at multiple of $400 in H40 and $20...
Definition vdp.c:735
void VDP_setHIntCounter(u8 value)
Set Horizontal interrupt counter value.
Definition vdp.c:656
void VDP_setBGBAddress(u16 value)
Set VRAM address (location) of BG B tilemap. The address should be at multiple of $2000 Ex: VDP_...
Definition vdp.c:706
u8 VDP_getAutoInc(void)
Returns auto increment register value.
Definition vdp.c:558
void VDP_waitFIFOEmpty(void)
Wait for VDP FIFO to be empty.
Definition vdp.c:846
void VDP_setWindowOnBottom(u16 rows)
Positions the window from the bottom edge of the screen by the specified number of rows (tiles).
Definition vdp.c:821
void VDP_setWindowAddress(u16 value)
Set VRAM address (location) of Window tilemap. The address should be at multiple of $1000 in H40 and...
Definition vdp.c:719
void VDP_setHInterrupt(bool value)
Enable or Disable Horizontal interrupt.
Definition vdp.c:617
void VDP_resetScreen(void)
Reset background planes and palettes.
Definition vdp.c:133
VDPPlane
Type used to define on which plane to work (used by some methods).
Definition vdp.h:521
void VDP_setBGAAddress(u16 value)
Set VRAM address (location) of BG A tilemap. The address should be at multiple of $2000 Ex: VDP_s...
Definition vdp.c:693
u8 VDP_getBackgroundColor(void)
Returns the background color index.
Definition vdp.c:542
void VDP_setAutoInc(u8 value)
Set auto increment register value.
Definition vdp.c:563
void VDP_setHVLatching(bool value)
Set HV counter latching on INT2 (used for light gun).
Definition vdp.c:595
void VDP_waitVActive(bool forceNext)
Wait for next vertical active area (end of vertical blank period).
Definition vdp.c:934
void VDP_setVInterrupt(bool value)
Enable or Disable Vertical interrupt (it's strongly recommanded to keep it enabled).
Definition vdp.c:606
void VDP_setWindowOnTop(u16 rows)
Positions the window from the top edge of the screen by the specified number of rows (tiles).
Definition vdp.c:816
u16 VDP_getSpriteListAddress(void)
Get VRAM address (location) of Sprite list.
Definition vdp.c:682
u16 planeWidth
Current background plane width (in tile).
Definition vdp.c:54
void VDP_setScreenHeight224(void)
Set vertical resolution to 224 pixels.
Definition vdp.c:350
u8 VDP_getHVLatching(void)
Returns HV counter latching on INT2 (used for light gun).
Definition vdp.c:590
u16 planeHeight
Current background plane height (in tile).
Definition vdp.c:55
u16 windowWidthSft
Current window width bit shift.
Definition vdp.c:59
void VDP_setWindowOnRight(u16 cols)
Positions the window from the right edge of the screen by the specified number of columns,...
Definition vdp.c:831
u16 VDP_getScanlineNumber(void)
Returns number of total scanline.
Definition vdp.c:339
void VDP_init(void)
Initialize the whole VDP sub system.
Definition vdp.c:64
void VDP_setReg(u16 reg, u8 value)
Set VDP register value.
Definition vdp.c:199
void VDP_setWindowHPos(u16 right, u16 pos)
Sets the window Horizontal position.
Definition vdp.c:782
bool VDP_waitVSync(void)
Wait for Vertical Synchro.
Definition vdp.c:952
u16 windowWidth
Current window width (in tile).
Definition vdp.c:56
u16 VDP_getScreenHeight(void)
Returns vertical screen resolution.
Definition vdp.c:345
void VDP_setHScrollTableAddress(u16 value)
Set VRAM address (location) of H Scroll table. The address should be at multiple of $400 Ex: VDP...
Definition vdp.c:751
u16 screenHeight
Current screen height (verticale resolution).
Definition vdp.c:53
void VDP_setScreenWidth320(void)
Set horizontal resolution to 320 pixels.
Definition vdp.c:393
u16 VDP_getBGAAddress(void)
Get VRAM address (location) of BG A tilemap.
Definition vdp.c:667
void VDP_setWindowVPos(u16 down, u16 pos)
Sets the window Vertical position.
Definition vdp.c:796
u16 VDP_getAdjustedVCounter(void)
Return an enhanced V Counter representation.
Definition vdp.c:989
u16 VDP_getBGBAddress(void)
Get VRAM address (location) of BG B tilemap.
Definition vdp.c:672
u8 VDP_getHIntCounter(void)
Get Horizontal interrupt counter value.
Definition vdp.c:651
void VDP_setEnable(bool value)
Set VDP enable state.
Definition vdp.c:327
u8 VDP_getReg(u16 reg)
Get VDP register value.
Definition vdp.c:193
u8 VDP_getDMAEnabled(void)
Returns DMA enabled state.
Definition vdp.c:574
void VDP_showCPULoad(u16 x, u16 y)
Display the estimated CPU load (in %).
Definition vdp.c:1013
bool VDP_getEnable(void)
Returns VDP enable state.
Definition vdp.c:317
u16 VDP_getScreenWidth(void)
Returns horizontal screen resolution.
Definition vdp.c:375
void VDP_setExtInterrupt(bool value)
Enable or Disable External interrupt.
Definition vdp.c:628
void VDP_waitDMACompletion(void)
Wait for DMA operation to complete - same as DMA_waitCompletion().
Definition vdp.c:841
bool VDP_waitVBlank(bool forceNext)
Wait for next vertical blank period (same as VDP_waitVSync()).
Definition vdp.c:886
void VDP_setBackgroundColor(u8 value)
Set the background color index.
Definition vdp.c:547
void VDP_setScrollingMode(u16 hscroll, u16 vscroll)
Set plane scrolling mode.
Definition vdp.c:530
void VDP_setScreenWidth256(void)
Set horizontal resolution to 256 pixels.
Definition vdp.c:380
u16 VDP_getPlaneHeight(void)
Return background plane height (in tile).
Definition vdp.c:412
void VDP_setDMAEnabled(bool value)
Set DMA enabled state.
Definition vdp.c:579
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 ...
Definition vdp.c:417
u16 VDP_getHScrollTableAddress(void)
Get VRAM address (location) of H SCroll table.
Definition vdp.c:687
u16 VDP_getWindowAddress(void)
Get VRAM address (location) of Window tilemap.
Definition vdp.c:677
u8 VDP_getHorizontalScrollingMode(void)
Returns plane horizontal scrolling mode.
Definition vdp.c:525
bool VDP_waitVInt(void)
Wait for next Vertical Interruption.
Definition vdp.c:852
u16 planeHeightSft
Current background plane height bit shift.
Definition vdp.c:58
void VDP_setHilightShadow(bool value)
Enable or Disable Hilight / Shadow effect.
Definition vdp.c:639
u16 screenWidth
Current screen width (horizontale resolution).
Definition vdp.c:52
u16 VDP_getPlaneWidth(void)
Return background plane width (in tile).
Definition vdp.c:407
bool VDP_isEnable(void)
Returns VDP enable state.
Definition vdp.c:322
u16 planeWidthSft
Current background plane width bit shift.
Definition vdp.c:57
void VDP_showFPS(u16 asFloat, u16 x, u16 y)
Display number of Frame Per Second.
Definition vdp.c:995
u8 VDP_getVerticalScrollingMode(void)
Returns plane vertical scrolling mode.
Definition vdp.c:520
void VDP_setWindowOnLeft(u16 cols)
Positions the window from the left edge of the screen by the specified number of columns,...
Definition vdp.c:826
void VDP_setScreenHeight240(void)
Set vertical resolution to 240 pixels.
Definition vdp.c:361
void VDP_setWindowFullScreen()
Positions the window to full screen.
Definition vdp.c:836
unsigned short u16
Definition types.h:100
unsigned char u8
Definition types.h:95