+#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)
+