#ifndef __SAVAGE_H__
#define __SAVAGE_H__
#define CURSOR_BYTES 1024
#define ADVANCED_FUNC_CTRL 0x850C
#define SYSTEM_CONTROL_REG 0x83DA
#define PRI_STREAM_FBUF_ADDR0 0x81c0
#define PRI_STREAM_FBUF_ADDR1 0x81c4
#define PRI_STREAM_STRIDE 0x81c8
#define PRI_STREAM2_FBUF_ADDR0 0x81b0
#define PRI_STREAM2_FBUF_ADDR1 0x81b4
#define PRI_STREAM2_STRIDE 0x81b8
#define S3_GLOBAL_GBD_REG 0x816C
#define MEMORY_CTRL0_REG 0xCA
#define MEM_PS1 0x10
#define MEM_PS2 0x20
#define SRC_BASE 0xa4d4
#define DEST_BASE 0xa4d8
#define CLIP_L_R 0xa4dc
#define CLIP_T_B 0xa4e0
#define DEST_SRC_STR 0xa4e4
#define MONO_PAT_0 0xa4e8
#define MONO_PAT_1 0xa4ec
#define DISABLE_BLOCK_WRITE_2D 0x10
#define STATUS_WORD0 (ReadReg32(0x48C00))
#define ALT_STATUS_WORD0 (ReadReg32(0x48C60))
#define MAXFIFO 0x7f00
#define TILE_FORMAT_LINEAR 0
#define BCI_ENABLE 8
#define BCI_ENABLE_TWISTER 0
#define S3_BIG_ENDIAN 4
#define S3_LITTLE_ENDIAN 0
#define S3_BD64 1
#define BCI_BD_BW_DISABLE 0x10000000
#define BCI_BUFFER_OFFSET 0x10000
#define BCI_GET_PTR vuint32* bci_ptr = ((uint32*)(gInfo.regs + BCI_BUFFER_OFFSET))
#define BCI_SEND(dw) (*bci_ptr++ = ((uint32)(dw)))
#define BCI_CMD_NOP 0x40000000
#define BCI_CMD_RECT 0x48000000
#define BCI_CMD_RECT_XP 0x01000000
#define BCI_CMD_RECT_YP 0x02000000
#define BCI_CMD_GET_ROP(cmd) (((cmd) >> 16) & 0xFF)
#define BCI_CMD_SET_ROP(cmd, rop) ((cmd) |= ((rop & 0xFF) << 16))
#define BCI_CMD_SEND_COLOR 0x00008000
#define BCI_CMD_DEST_PBD_NEW 0x00000C00
#define BCI_CMD_SRC_SOLID 0x00000000
#define BCI_CMD_SRC_SBD_COLOR_NEW 0x00000140
#define BCI_W_H(w, h) ((((h) << 16) | (w)) & 0x0FFF0FFF)
#define BCI_X_Y(x, y) ((((y) << 16) | (x)) & 0x0FFF0FFF)
static inline void VerticalRetraceWait()
{
if (ReadCrtcReg(0x17) & 0x80) {
int i = 0x10000;
while ((ReadReg8(SYSTEM_CONTROL_REG) & 0x08) == 0x08 && i--) ;
i = 0x10000;
while ((ReadReg8(SYSTEM_CONTROL_REG) & 0x08) == 0x00 && i--) ;
}
}
#endif