/*
	マシンセレクト時に転送  
*/
#include	<ultra64.h>
#include	"../../ot_system.h"
#include	"../../sot_world.h"

#include "f_waku1.tex"
#include "meter1.tex"
#include "meter2.tex"
#include "select_1p.tex"
#include "select_2p.tex"
#include "select_back.tex"

/* 日本語メッセージ */
#include "jf_machine_select18.tex"

#include "jf_machine_setting10.tex"
#include "jf_custom10.tex"
#include "jf_handling10.tex"
#include "jf_gear10.tex"
#include "jf_grip10.tex"
#include "jf_light8.tex"
#include "jf_heavy8.tex"
#include "jf_low8.tex"
#include "jf_high8.tex"
#include "jf_grip8.tex"
#include "jf_slip8.tex"

#include "jf_sel_start2_12.tex"

#define	KZ_RM_CLEAR_CVG(clk)					\
	FORCE_BL | CVG_X_ALPHA | IM_RD | CVG_DST_FULL |	 	\
	GBL_c##clk(G_BL_CLR_MEM, G_BL_0, G_BL_CLR_MEM, G_BL_1MA)
/* ======================================================================= */
static Vp vp = {
	SCREEN_WD*2, SCREEN_HT*2, G_MAXZ/2, 0,	/* scale */
	SCREEN_WD*2, SCREEN_HT*2, G_MAXZ/2, 0,	/* translate */
} ;
static Vp vpMachine0 = {
	SCREEN_WD*2, SCREEN_HT*2, G_MAXZ/2, 0,	/* scale */
	(DISPLAY_X1_1P+20+63/2)<<2, (DISPLAY_Y1_1P+35+9+36/2)<<2, G_MAXZ/2, 0,	/* translate */
} ;
static Vp vpMachine1 = {
	SCREEN_WD*2, SCREEN_HT*2, G_MAXZ/2, 0,	/* scale */
	(DISPLAY_X1_1P+87+63/2)<<2, (DISPLAY_Y1_1P+35+9+36/2)<<2, G_MAXZ/2, 0,	/* translate */
} ;
static Vp vpMachine2 = {
	SCREEN_WD*2, SCREEN_HT*2, G_MAXZ/2, 0,	/* scale */
	(DISPLAY_X1_1P+154+63/2)<<2, (DISPLAY_Y1_1P+35+9+36/2)<<2, G_MAXZ/2, 0,	/* translate */
} ;
static Vp vpMachine3 = {
	SCREEN_WD*2, SCREEN_HT*2, G_MAXZ/2, 0,	/* scale */
	(DISPLAY_X1_1P+221+63/2)<<2, (DISPLAY_Y1_1P+35+9+36/2)<<2, G_MAXZ/2, 0,	/* translate */
} ;

/* =========================================================================*/
/*
	マシンセレクトのディスプレイリスト(1PLAYER)
*/
#define KN_CC_TEXC_PRIMA 0,0,0,TEXEL0,0,0,0,PRIMITIVE

Gfx dlMachineBG[] = {
	/***********************************************************************
	 	Setting RSP
	************************************************************************/
	gsSPClearGeometryMode( 0xffffffff ),
	gsSPViewport( &vp ),
	gsSPTexture( 0, 0, 0, 0, G_OFF ),
	/***********************************************************************
	 	Setting RDP
	************************************************************************/
	gsDPPipeSync(),
	gsDPSetCycleType( G_CYC_1CYCLE ),
	gsDPSetPrimColor( 0, 0, 0, 0, 0, 255 ),
	gsDPSetCombineMode( G_CC_PRIMITIVE, G_CC_PRIMITIVE ),
	gsDPSetRenderMode( G_RM_OPA_SURF, G_RM_OPA_SURF2 ),
	gsDPSetAlphaCompare( G_AC_NONE ),

	/***********************************************************************
	 	Draw Black Box
	************************************************************************/
    gsDPFillRectangle( DISPLAY_X1 +  20, DISPLAY_Y1 + 35,
					   DISPLAY_X1 +  20 + 63 - 1, DISPLAY_Y1 + 35 + 36 - 1 ),
    gsDPFillRectangle( DISPLAY_X1 +  87, DISPLAY_Y1 + 35,
					   DISPLAY_X1 +  87 + 63 - 1, DISPLAY_Y1 + 35 + 36 - 1 ),
    gsDPFillRectangle( DISPLAY_X1 + 154, DISPLAY_Y1 + 35,
					   DISPLAY_X1 + 154 + 63 - 1, DISPLAY_Y1 + 35 + 36 - 1 ),
    gsDPFillRectangle( DISPLAY_X1 + 221, DISPLAY_Y1 + 35,
					   DISPLAY_X1 + 221 + 63 - 1, DISPLAY_Y1 + 35 + 36 - 1 ),

	/***********************************************************************
	 	END
	************************************************************************/
	gsSPEndDisplayList()
};

Gfx dlMachineMeter[] = {
	/***********************************************************************
	 	Setting RDP
	************************************************************************/
	gsDPPipeSync(),
	gsDPSetRenderMode( G_RM_OPA_SURF, G_RM_OPA_SURF2 ),
	gsDPSetCombineMode( G_CC_DECALRGBA, G_CC_DECALRGBA ),

	/***********************************************************************
	 	Draw Meter
	************************************************************************/
	gsDPLoadTextureTile( (uint)(texMeter1), G_IM_FMT_RGBA, G_IM_SIZ_16b,
		121, 8,
		0, 0,
		120, 7,
		0,
		G_TX_CLAMP, G_TX_CLAMP,
		G_TX_NOMASK, G_TX_NOMASK,
		G_TX_NOLOD, G_TX_NOLOD ),

	gsSPTextureRectangle( 
		(DISPLAY_X1 + 24) << 2, (DISPLAY_Y1 + 126) << 2,
		(DISPLAY_X1 + 24 + 121) << 2, (DISPLAY_Y1 + 126 + 8) << 2,
		G_TX_RENDERTILE,
		0, 0,
		1 << 10, 1 << 10 ),
	gsSPTextureRectangle( 
		(DISPLAY_X1 + 24) << 2, (DISPLAY_Y1 + 155) << 2,
		(DISPLAY_X1 + 24 + 121) << 2, (DISPLAY_Y1 + 155 + 8) << 2,
		G_TX_RENDERTILE,
		0, 0,
		1 << 10, 1 << 10 ),
	gsSPTextureRectangle( 
		(DISPLAY_X1 + 24) << 2, (DISPLAY_Y1 + 184) << 2,
		(DISPLAY_X1 + 24 + 121) << 2, (DISPLAY_Y1 + 184 + 8) << 2,
		G_TX_RENDERTILE,
		0, 0,
		1 << 10, 1 << 10 ),

	/***********************************************************************
	 	END
	************************************************************************/
	gsSPEndDisplayList()
};

/* =========================================================================*/
/*
	マシンセレクトのディスプレイリスト(2PLAYER)
*/
/* =========================================================================*/

/*--------------------------------------------------------------------------*/
/*
	共通ＢＧ
*/
Gfx dlMachineBG2P[] = {
	/***********************************************************************
	 	Setting RSP
	************************************************************************/
	gsSPClearGeometryMode( 0xffffffff ),
	gsSPViewport( &vp ),
	gsSPTexture( 0, 0, 0, 0, G_OFF ),
	/***********************************************************************
	 	Setting RDP
	************************************************************************/
	gsDPPipeSync(),
	gsDPSetCycleType( G_CYC_1CYCLE ),
	gsDPSetPrimColor( 0, 0, 0, 0, 0, 255 ),
	gsDPSetCombineMode( G_CC_PRIMITIVE, G_CC_PRIMITIVE ),
	gsDPSetRenderMode( G_RM_OPA_SURF, G_RM_OPA_SURF2 ),
	gsDPSetAlphaCompare( G_AC_NONE ),

	/***********************************************************************
	 	Draw Black Box
	************************************************************************/
    gsDPFillRectangle( DISPLAY_X1 +  20, DISPLAY_Y1 + 35,
					   DISPLAY_X1 +  20 + 63 - 1, DISPLAY_Y1 + 35 + 36 - 1 ),
    gsDPFillRectangle( DISPLAY_X1 +  87, DISPLAY_Y1 + 35,
					   DISPLAY_X1 +  87 + 63 - 1, DISPLAY_Y1 + 35 + 36 - 1 ),
    gsDPFillRectangle( DISPLAY_X1 + 154, DISPLAY_Y1 + 35,
					   DISPLAY_X1 + 154 + 63 - 1, DISPLAY_Y1 + 35 + 36 - 1 ),
    gsDPFillRectangle( DISPLAY_X1 + 221, DISPLAY_Y1 + 35,
					   DISPLAY_X1 + 221 + 63 - 1, DISPLAY_Y1 + 35 + 36 - 1 ),

	/***********************************************************************
	 	END
	************************************************************************/
	gsSPEndDisplayList()
};

/*--------------------------------------------------------------------------*/
/*
	２Ｐ用メーター
*/
Gfx dlMachineMeter_2P[] = {
	/***********************************************************************
	 	Setting RDP
	************************************************************************/
	gsDPPipeSync(),
	gsDPSetRenderMode( G_RM_OPA_SURF, G_RM_OPA_SURF2 ),
	gsDPSetCombineMode( G_CC_DECALRGBA, G_CC_DECALRGBA ),

	/***********************************************************************
	 	Draw Meter
	************************************************************************/
	gsDPLoadTextureTile( (uint)(texMeter1), G_IM_FMT_RGBA, G_IM_SIZ_16b,
		121, 8,
		0, 0,
		120, 7,
		0,
		G_TX_CLAMP, G_TX_CLAMP,
		G_TX_NOMASK, G_TX_NOMASK,
		G_TX_NOLOD, G_TX_NOLOD ),

	gsSPTextureRectangle( 
		(DISPLAY_X1 + 158) << 2, (DISPLAY_Y1 + 126) << 2,
		(DISPLAY_X1 + 158 + 121) << 2, (DISPLAY_Y1 + 126 + 8) << 2,
		G_TX_RENDERTILE,
		0, 0,
		1 << 10, 1 << 10 ),
	gsSPTextureRectangle( 
		(DISPLAY_X1 + 158) << 2, (DISPLAY_Y1 + 155) << 2,
		(DISPLAY_X1 + 158 + 121) << 2, (DISPLAY_Y1 + 155 + 8) << 2,
		G_TX_RENDERTILE,
		0, 0,
		1 << 10, 1 << 10 ),
	gsSPTextureRectangle( 
		(DISPLAY_X1 + 158) << 2, (DISPLAY_Y1 + 184) << 2,
		(DISPLAY_X1 + 158 + 121) << 2, (DISPLAY_Y1 + 184 + 8) << 2,
		G_TX_RENDERTILE,
		0, 0,
		1 << 10, 1 << 10 ),

	/***********************************************************************
	 	END
	************************************************************************/
	gsSPEndDisplayList()
};

/* =========================================================================*/
/*
	ジェットのディスプレイリスト
*/
Gfx dlInitMachineView0[] = {
	gsSPViewport( &vpMachine0 ),

	gsSPEndDisplayList()
};
Gfx dlInitMachineView1[] = {
	gsSPViewport( &vpMachine1 ),

	gsSPEndDisplayList()
};
Gfx dlInitMachineView2[] = {
	gsSPViewport( &vpMachine2 ),

	gsSPEndDisplayList()
};
Gfx dlInitMachineView3[] = {
	gsSPViewport( &vpMachine3 ),

	gsSPEndDisplayList()
};

/* ======================================================================= */
/*
	カバレッジのクリア
*/
Gfx dlMachineClearCvgL[] = {
	gsDPPipeSync(),
	gsDPSetCycleType( G_CYC_1CYCLE ),
	gsDPPipelineMode( G_PM_NPRIMITIVE ),
	gsDPSetRenderMode( KZ_RM_CLEAR_CVG(1), KZ_RM_CLEAR_CVG(2) ),
	gsDPSetCombineMode( G_CC_SHADE, G_CC_SHADE ),
	gsDPSetAlphaCompare( G_AC_NONE ),
	gsDPSetFillColor( 0xFFFFFFFF ),

	gsDPFillRectangle( DISPLAY_X1 +  18, DISPLAY_Y1 + 76 , DISPLAY_X1 +  20, DISPLAY_Y1 + 196 ),
	gsDPFillRectangle( DISPLAY_X1 + 147, DISPLAY_Y1 + 76 , DISPLAY_X1 + 149, DISPLAY_Y1 + 196 ),
	gsDPFillRectangle( DISPLAY_X1 +  19, DISPLAY_Y1 + 194, DISPLAY_X1 + 149, DISPLAY_Y1 + 196 ),

	gsSPEndDisplayList()
};
Gfx dlMachineClearCvgR[] = {
	gsDPPipeSync(),
	gsDPSetCycleType( G_CYC_1CYCLE ),
	gsDPPipelineMode( G_PM_NPRIMITIVE ),
	gsDPSetRenderMode( KZ_RM_CLEAR_CVG(1), KZ_RM_CLEAR_CVG(2) ),
	gsDPSetCombineMode( G_CC_SHADE, G_CC_SHADE ),
	gsDPSetAlphaCompare( G_AC_NONE ),
	gsDPSetFillColor( 0xFFFFFFFF ),

	gsDPFillRectangle( DISPLAY_X1 + 152, DISPLAY_Y1 + 76, DISPLAY_X1 + 154, DISPLAY_Y1 + 196 ),
	gsDPFillRectangle( DISPLAY_X1 + 281, DISPLAY_Y1 + 76, DISPLAY_X1 + 283, DISPLAY_Y1 + 196 ),
	gsDPFillRectangle( DISPLAY_X1 + 153, DISPLAY_Y1 + 194, DISPLAY_X1 + 283, DISPLAY_Y1 + 196 ),

	gsSPEndDisplayList()
};
/* ======================================================================= */
