#define vdp_setreg(reg, val) \
(VDP_CTL = 0x8000 | ((reg) << 8) | (val))
+#define vdp_wait_vblank() \
+ while(!(VDP_STAT & VDP_ST_VBLANK))
+
+#define vdp_wait_vblank_end() \
+ while((VDP_STAT & VDP_ST_VBLANK))
+
+#define vdp_vsync() \
+ (vdp_wait_vblank_end(), vdp_wait_vblank())
+
+
#define VDP_TILE_BG 0
#define VDP_TILE_FG 0x8000
#define VDP_TILE_PAL(x) ((x) << 13)
#define VDP_TILE_VFLIP 0x1000
#define VDP_TILE_HFLIP 0x0800
+#define VDP_TILE_HVFLIP (VDP_TILE_HFLIP | VDP_TILE_VFLIP)
#define VDP_TILENAME(tile, pal, flags) \
((tile) | VDP_TILE_PAL(pal) | (flags))
+#define VDP_ADDR2TILE(x) ((x) >> 5)
+
void vdp_init(void);
void vdp_setcolor(int pal, int cidx, int r, int g, int b);