#ifndef	KO_BLOCK_H		  
#define	KO_BLOCK_H

#define OBJ_BLOCK_MAX 32

typedef struct {
	int kind;
	int pattern,pattern2;
	int disp_x,disp_y;
	char pri,disp_on;
	int sd_number;//seq_data_number
	int work1,work2;
	float workf1;
} OBJBlock;

typedef struct {
	//int mode;
	short mode;
	unsigned short *tex_data_ptr;
	unsigned short w,h;
	unsigned int dma_size;
} TexBlock;

typedef struct {
	TexBlock *tex_block_ptr;
	int count;
} TexBlockSeq;

typedef struct {
	TexBlockSeq *seq_ptr;
	short pattern;
	short count;
	short pri;
	short buffer;/* 今どちらのバッファを使っているか[0-1] */
	ushort *ptr1,*ptr2;/* ダブルバッファのそれぞれのポインタ */
	//int block_num;
} SeqData;

typedef struct {
    TexBlock *tex_block_ptr;
	ushort *dest_ptr;/* 転送先ポインタ */
    //int block_num;/*  for mariokart64 */
} ChangeTexBuff;

typedef struct {
	unsigned short *tex_rom_ptr;//テクスチャデータのROMのアドレス
	unsigned short *tex_ram_ptr;//テクスチャデータのRAMのアドレス
} TexMap;


#define TexBuffLoad(tp) TexBuffLoad_base(tp,0)
#define TexBuffLoad_w(tp) TexBuffLoad_base(tp,1)
#define TexBuffLoad2(tex_data_ptr,size)\
	TexBuffLoad2_base(tex_data_ptr,size,0,0,0)
#define TexBuffLoad2p(tex_data_ptr,size)\
	TexBuffLoad2_base(tex_data_ptr,size,0,1,0)
#define TexBuffLoad2p_noalloc(tex_data_ptr,size)\
	TexBuffLoad2_base(tex_data_ptr,size,0,1,1)
#define DOB_moving1_x(ptr,x) DOB_moving1_x_base(ptr,x,4)
#define DOB_moving1_x5(ptr,x) DOB_moving1_x_base(ptr,x,5)
#define DOB_moving2_x(ptr,x) DOB_moving2_x_base(ptr,x,192)


#define KB_COPY		0x01
#define KB_COPY_S	0x02
#define KB_IA8		0x03
#define KB_I4		0x04
#define KB_I4_S		0x05
/* Packed Ver. */
#define KBP_COPY	0x11
#define KBP_COPY_S	0x12
#define KBP_I4		0x14
#define KBP_I4_S	0x15

#define DTL_TYPE_NORMAL	0
#define DTL_TYPE_PRIM	1
#define DTL_TYPE_FLIP	2
#define DTL_TYPE_ZOOM	3
#define DTL_TYPE_ZOOMPRIM	4
#define DTL_TYPE_ZOOMFLIP	5

#define doTexList(gdl,tp,x,y)\
	doTexList_base(gdl,tp,x,y,DTL_TYPE_NORMAL,0,0,1.0,1.0)
#define doTexList_p(gdl,tp,x,y)\
	doTexList_base(gdl,tp,x,y,DTL_TYPE_PRIM,0,0,1.0,1.0)
#define doTexList_f(gdl,tp,x,y,hf,vf)\
	doTexList_base(gdl,tp,x,y,DTL_TYPE_FLIP,hf,vf,1.0,1.0)
#define doTexList2(gdl,tp,x,y,zoom_x,zoom_y)\
	doTexList_base(gdl,tp,x,y,DTL_TYPE_ZOOM,0,0,zoom_x,zoom_y)
#define doTexList2_f(gdl,tp,x,y,zoom_x,zoom_y)\
	doTexList_base(gdl,tp,x,y,DTL_TYPE_ZOOMFLIP,0,0,zoom_x,zoom_y)
#define doTexList2_p(gdl,tp,x,y,zoom_x,zoom_y)\
	doTexList_base(gdl,tp,x,y,DTL_TYPE_ZOOMPRIM,0,0,zoom_x,zoom_y)

#define doTexList_w(gdl,tp,x,y)\
	doTexList_w_base(gdl,tp,x,y,DTL_TYPE_NORMAL,0,0,1.0,1.0)
#define doTexList_wp(gdl,tp,x,y)\
	doTexList_w_base(gdl,tp,x,y,DTL_TYPE_PRIM,0,0,1.0,1.0)
#define doTexList_wf(gdl,tp,x,y,hf,vf)\
	doTexList_w_base(gdl,tp,x,y,DTL_TYPE_FLIP,hf,vf,1.0,1.0)
#define doTexList2_w(gdl,tp,x,y,zoom_x,zoom_y)\
	doTexList_w_base(gdl,tp,x,y,DTL_TYPE_ZOOM,0,0,zoom_x,zoom_y)
#define doTexList2_wf(gdl,tp,x,y,zoom_x,zoom_y)\
	doTexList_w_base(gdl,tp,x,y,DTL_TYPE_ZOOMFLIP,0,0,zoom_x,zoom_y)
#define doTexList2_wp(gdl,tp,x,y,zoom_x,zoom_y)\
	doTexList_w_base(gdl,tp,x,y,DTL_TYPE_ZOOMPRIM,0,0,zoom_x,zoom_y)


/* SetOBJBlock で使うパーツ名*/
#define KO_GDL_INIT	5

#define KO_TITLE_BACK	10
#define KO_TITLE_NOISE1	(KO_TITLE_BACK+2)
#define KO_TITLE_NOISE2	(KO_TITLE_BACK+3)
#define KO_TITLE_SINDO	(KO_TITLE_BACK+4)
#define KO_TITLE_LOGO2A	(KO_TITLE_BACK+5)
#define KO_TITLE_LOGO2B	(KO_TITLE_BACK+6)
#define KO_TITLE_START	(KO_TITLE_BACK+7)
#define KO_TITLE_RUBY	(KO_TITLE_BACK+8)
#define KO_TITLE_NINTENDO	(KO_TITLE_BACK+9)
#define KO_TITLE_DD_MES	(KO_TITLE_BACK+10)

#define KO_MSEL_BACK		30
#define KO_MSEL_LOGO		(KO_MSEL_BACK+1)
#define KO_MSEL_DRIVER		(KO_MSEL_BACK+2)
#define KO_MSEL_DRIVER2_1	(KO_MSEL_BACK+3)
#define KO_MSEL_DRIVER2_2	(KO_MSEL_DRIVER2_1+1)
#define KO_MSEL_DRIVER2_3	(KO_MSEL_DRIVER2_1+2)
#define KO_MSEL_DRIVER2_4	(KO_MSEL_DRIVER2_1+3)
#define KO_MSEL_CURSOR1		(KO_MSEL_BACK+10)
#define KO_MSEL_CURSOR2		(KO_MSEL_CURSOR1+1)
#define KO_MSEL_CURSOR3		(KO_MSEL_CURSOR1+2)
#define KO_MSEL_CURSOR4		(KO_MSEL_CURSOR1+3)
#define KO_MSEL_CURSOR_BACK	(KO_MSEL_CURSOR1+4)
#define KO_MSEL1_MACHINES	(KO_MSEL_BACK+15)
#define KO_MSEL1_OK			(KO_MSEL_BACK+16)
#define KO_MSEL1_CUP		(KO_MSEL_BACK+17)
#define KO_MSEL1_INFO1P		(KO_MSEL_BACK+18)

#define KO_MSEL2_MACHINE_NAME	(KO_MSEL_BACK+20)
#define KO_MSEL2_METER			(KO_MSEL2_MACHINE_NAME+1)
#define KO_MSEL2_METER2			(KO_MSEL2_MACHINE_NAME+2)
#define KO_MSEL2_MACHINE		(KO_MSEL2_MACHINE_NAME+3)
#define KO_MSEL2_PILOT_NAME		(KO_MSEL2_MACHINE_NAME+4)
#define KO_MSEL2_ARROW			(KO_MSEL2_MACHINE_NAME+5)
#define KO_MSEL2_GRID			(KO_MSEL2_MACHINE_NAME+6)
#define KO_MSEL2_OK				(KO_MSEL2_MACHINE_NAME+7)
#define KO_MSEL2_METER2_4_2P	(KO_MSEL2_MACHINE_NAME+8)
#define KO_MSEL2_BACK			(KO_MSEL2_MACHINE_NAME+9)

#define KO_MSEL_DRIVER_1		(KO_MSEL_BACK+30)
#define KO_MSEL_DRIVER_2		(KO_MSEL_DRIVER_1+1)
#define KO_MSEL_DRIVER_3		(KO_MSEL_DRIVER_1+2)
#define KO_MSEL_DRIVER_4		(KO_MSEL_DRIVER_1+3)
#define KO_MSEL1_GRADE_1		(KO_MSEL_BACK+35)
#define KO_MSEL1_GRADE_2		(KO_MSEL1_GRADE_1+1)
#define KO_MSEL1_GRADE_3		(KO_MSEL1_GRADE_1+2)
#define KO_MSEL1_GRADE_4		(KO_MSEL1_GRADE_1+3)

#define KO_GSEL_BACK	80
#define KO_GSEL_GP		(KO_GSEL_BACK+1)
#define KO_GSEL_TA		(KO_GSEL_BACK+2)
#define KO_GSEL_VS		(KO_GSEL_BACK+3)
#define KO_GSEL_SLOT	(KO_GSEL_BACK+4)
#define KO_GSEL_RECORDS	(KO_GSEL_BACK+5)
#define KO_GSEL_OPTION	(KO_GSEL_BACK+6)
#define KO_GSEL_DD1		(KO_GSEL_BACK+7)
#define KO_GSEL_DD2		(KO_GSEL_BACK+8)
#define KO_GSEL_LOGO	(KO_GSEL_BACK+9)
#define KO_GSEL_VS_SELECT	(KO_GSEL_BACK+10)
#define KO_GSEL_BATU	(KO_GSEL_BACK+11)
#define KO_GSEL_LV_SELECT	(KO_GSEL_BACK+12)
#define KO_GSEL_OK		(KO_GSEL_BACK+13)
#define KO_GSEL_COMMAND_CHECKER		(KO_GSEL_BACK+14)
#define KO_GSEL_TA_SELECT		(KO_GSEL_BACK+15)

#define KO_LSEL_BACK		100

#define KO_CSEL_BACK		120
#define KO_CSEL_COURSE		(KO_CSEL_BACK+1)
#define KO_CSEL_JACK		(KO_CSEL_BACK+2)
#define KO_CSEL_QUEEN		(KO_CSEL_BACK+3)
#define KO_CSEL_KING		(KO_CSEL_BACK+4)
#define KO_CSEL_JOKER		(KO_CSEL_BACK+5)
#define KO_CSEL_MUGEN		(KO_CSEL_BACK+6)
#define KO_CSEL_EDIT		(KO_CSEL_BACK+7)
#define KO_CSEL_OK			(KO_CSEL_BACK+8)
#define KO_CSEL_ARROW		(KO_CSEL_BACK+9)
#define KO_CSEL_COURSE_NAME	(KO_CSEL_BACK+10)
#define KO_CSEL_LOGO		(KO_CSEL_BACK+11)
#define KO_CSEL_GHOST		(KO_CSEL_BACK+12)
#define KO_CSEL_TA_TYPE		(KO_CSEL_BACK+13)

#define KO_RECORD_BACK		140

#define KO_WIN_BACK			150
//#define KO_WIN_CONGRATURATIONS	(KO_WIN_BACK+1)
#define KO_WIN_DRIVER		(KO_WIN_BACK+2)
#define KO_WIN_MACHINE		(KO_WIN_BACK+3)

#define KO_ME_DRIVER		170
#define KO_ME_GRADE			(KO_ME_DRIVER+1)
#define KO_ME_MACHINE		(KO_ME_DRIVER+2)
#define KO_ME_CURSOR		(KO_ME_DRIVER+3)
#define KO_CM_DRIVER		(KO_ME_DRIVER+4)

/* 190番以降はスタッフロールにて使用中 */







extern SeqData seq_data_block[];

extern void tex_data_Dma(unsigned short *tex_ptr,unsigned int number,
				  unsigned short *tex_buff_ptr);
extern unsigned short *TexBuffLoad_base(TexBlock *tp,int no_check_flg);
extern void *TexBuffLoad2_base(void *tex_data_ptr,int size,int no_check_flg,
							   int press_flg,int no_alloc_flg);


extern void *GetTexBuffPointer(void *tex_ptr);
extern Gfx *doTexList_base(Gfx *gdl,TexBlock *tp,int x,int y,
						   int type,int hf,int vf,float zoom_x,float zoom_y);
extern Gfx *doTexList_w_base(Gfx *gdl,SeqData *sd_ptr,int x,int y,
							 int type,int hf,int vf,float zoom_x,float zoom_y);

extern void doChangeTexData(void);
extern int SetSeqData(TexBlockSeq *tbs_ptr);
extern void ChangeSeqData(int i,int pat,TexBlockSeq *tbs_ptr);
extern void SetOBJBlock(int kind,int x,int y,char pri);
extern Gfx *DispOBJBlock(Gfx *gdl,OBJBlock *ptr);
extern Gfx *doOBJBlock(Gfx *gdl);
extern OBJBlock *Get_OBJBlock_ptr(int kind);
extern void Init_kawano(void);
extern void Init_kawano2(void);
void DOB_moving1(OBJBlock *ptr,int x,int y);
void DOB_moving1_x_base(OBJBlock *ptr,int x,int speed);
void DOB_moving1_y(OBJBlock *ptr,int y);
void DOB_moving2_x_base(OBJBlock *ptr,int x,int moving_speed_x_max);
void DOB_moving2_y(OBJBlock *ptr,int y);
void DOB_moving3_x(OBJBlock *ptr,int x);
void DOB_moving4_x(OBJBlock *ptr,int x,int plusminus);
void DOB_moving4_y(OBJBlock *ptr,int y,int plusminus);



#endif
