/*
 * $Log: bg_misc.h,v $
 * Revision 1.1  2003/02/07 18:15:44  wheeler
 * Fox's version of libultra and friends.
 *
 * Revision 1.15  1997/02/07  10:55:18  hayakawa
 * BATCH
 *
 * Revision 1.14  1996/11/21  05:45:10  hayakawa
 * テクスチャのロード等を移した
 *
 * Revision 1.13  1996/11/07  02:27:31  hayakawa
 * 従来のSetup_TexRectModeのパッチ
 *
 */

#ifndef __BG_MISC_H_
#define __BG_MISC_H_

#include "bg.h"			/* BG_Funcx */
#include "macro.h"		/* rgba_t */

extern void *cache_tlut;		/* カラーパレットのキャッシュ */

#ifdef __cplusplus
extern "C" {
#endif


#define Setup_TexMode(glistpp, low, high) \
{ \
    gDPPipeSync((*(glistpp))++); \
    gDPSetOtherMode((*(glistpp))++, (low), \
		    G_TC_FILT|G_CD_DISABLE|G_AD_DISABLE|(high)); \
}
void Setup_TexPolyModeR(
   Gfx **glistpp,		/* ディスプレイリストへのポインタのポインタ */
   int tt,
   int no
);
void Setup_TexRectModeR(
   Gfx **glistpp,		/* ディスプレイリストへのポインタのポインタ */
   int tt,
   int no
);
#define Setup_TexRectMode(glistpp, tt) Setup_TexRectModeR(glistpp, tt, 0)
#define Setup_TexPolyMode(glistpp, tt) Setup_TexPolyModeR(glistpp, tt, 0)
#define Reset_tlut() (cache_tlut = NULL)
#define Reset_All() (NeedInit = 1)
#define Setup_tlut(glistpp, fmt, siz, tlut) setup_tlut(glistpp, fmt, siz, tlut)
/*
 * 0:再初期化不要
 * !0:全種類初期化(将来的には変えます)
 * RSP,RDP,TMEM,MTX,COLOR,LIGHT
 */
extern int NeedInit;

void
draw_fillrect(
    Gfx **glistpp,		/* ディスプレイリストへのポインタのポインタ */
    const int x1,		/* 左座標 */
    const int y1,		/* 上座標 */
    const int x2,		/* 右座標 */
    const int y2,		/* 下座標 */
    const u32 color		/* 色(RGBA5551) */
);
void
LoadTextureImage(
    Gfx **glistpp,		/* ディスプレイリストへのポインタのポインタ */
    void *timg,			/* テクスチャアドレス */
    int siz,			/* テクセルのサイズ(4,8,16,32) */
    int xDot,			/* テクスチャ幅 */
    int yDot			/* テクスチャ高さ */
);
void
LoadTextureImageAll(
    Gfx **glistpp,		/* ディスプレイリストへのポインタのポインタ */
    void *timg,			/* テクスチャアドレス */
    int fmt,
    int siz,			/* テクセルのサイズ(4,8,16,32) */
    int xDot,			/* テクスチャ幅 */
    int yDot			/* テクスチャ高さ */
);
void
SetRenderTile(
    Gfx **glistpp,		/* ディスプレイリストへのポインタのポインタ */
    int fmt,			/* テクセルのフォーマット(RGBA,CI,IA,I) */
    int siz,			/* テクセルのサイズ(4,8,16,32) */
    int xDot,
    int yDot,
    int pal
);
void
LoadTextureTile_cache_flush(void);
void
LoadTextureTile_cache(
    Gfx **glistpp,		/* ディスプレイリストへのポインタのポインタ */
    void *timg,			/* NULLならキャッシュのフラッシュ */
    int fmt,			/* テクセルのフォーマット(RGBA,CI,IA,I) */
    int siz,			/* テクセルのサイズ(4,8,16,32) */
    int xDot,			/* 横ドット数 */
    int yDot,			/* 縦ドット数 */
    int pal			/* パレット */
);
void
setup_tlut(
    Gfx **glistpp,		/* ディスプレイリストへのポインタのポインタ */
    int fmt,
    int siz,
    void *tlut			/* CIの時のカラーテーブル */
);
int
isIntoScreen(
    int xPos,			/* Ｘ座標 */
    int yPos,			/* Ｙ座標 */
    int xDot,
    int yDot,
    float xScale,
    float yScale
);

typedef struct fadeout_s {
    rgba_t color;
    int xl, yl, xh, yh;
} fadeout_t;

void
fadeout(BG_Funcx *const funcx, void *const bgptr);

void
LoadMultiTextureImage(
    Gfx **glistpp,		/* ディスプレイリストへのポインタのポインタ */
    void *timg,			/* テクスチャアドレス */
    int siz,			/* テクセルのサイズ(4,8,16,32) */
    int xDot,			/* テクスチャ幅 */
    int yDot,			/* テクスチャ高さ */
    int tmem
);
void
SetMultiRenderTile(
    Gfx **glistpp,		/* ディスプレイリストへのポインタのポインタ */
    int fmt,			/* テクセルのフォーマット(RGBA,CI,IA,I) */
    int siz,			/* テクセルのサイズ(4,8,16,32) */
    int xDot,
    int yDot,
    int pal,
    int fmt2,			/* テクセルのフォーマット(RGBA,CI,IA,I) */
    int siz2,			/* テクセルのサイズ(4,8,16,32) */
    int tmem2
);

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif
