/* シノブのローダー */
#include <stdrr.h>
#include <string.h>
#include "game.h"
#include "global.h"
#include "function.h"

#define	OFFSET_CHAR_PAT		char_addr[player].offset[offset_case]

int load_shinobu(int player, int collor)
{
	int offset = 0;
	int offset_case = 0;
	int i, no, r,g,b;
	short pal[16];
	
	if( player )
		strcpy(INFO.name, "KAGE");
	else
		strcpy(INFO.name, "SHINOBU");
	
	char_addr[player].use_ptr = 0;
	
	
	/* ボイス */
	voice_read(player, "shinobu/", 10);
	/* 飛び道具定義 */
	shinobu_fire_init(player);
	/* 体重 */
	INFO.weight = 58;
	
	/* ダメージ系		パターンセット0 */
	OFFSET_CHAR_PAT = offset;
	load_char_pat("shinobu/s_dam.sp6",
		&offset, player, PAL_CHAR(player,0));
	offset_case++;
	
	
	
	/* 構えポーズ		パターンセット1	*/
	OFFSET_CHAR_PAT = offset;
	load_char_pat("shinobu/s_stand1.sp6",
		&offset, player, PAL_CHAR(player,0));
	offset_case++;
	
	
	/* ダメージ			パターンセット2	*/
	/*
	OFFSET_CHAR_PAT = offset;
	load_char_pat("shinobu/s_damage.sp6",
		&offset, player, PAL_CHAR(player,0));
	offset_case++;
	*/
	/* かわりにLAH 2*/
	OFFSET_CHAR_PAT = offset;
	load_char_pat("shinobu/lah.sp6",
		&offset, player, PAL_CHAR(player,30));
	offset_case++;
	
	
	/* 小パンチ			パターンセット3	*/
	OFFSET_CHAR_PAT = offset;
	load_char_pat("shinobu/s_pun1.sp6",
		&offset, player, PAL_CHAR(player,0));
	offset_case++;
	
	
	/* 鼻血ゲロ			パターンセット4	*/
	OFFSET_CHAR_PAT = offset;
	load_char_pat("shinobu/s_dam_add.sp6",
		&offset, player, PAL_CHAR(player,9));
	offset_case++;
	
	
	/* タマの読み込み	パターンセット5テスト */
	OFFSET_CHAR_PAT = offset;
	load_char_pat("shinobu/tama.sp6", &offset, player, PAL_CHAR(player,4));
	offset_case++;
	
	
	/* 垂直ジャンプ	パターンセット6 */
	OFFSET_CHAR_PAT = offset;
	load_char_pat("shinobu/s_jpv.sp6", &offset, player, PAL_CHAR(player,0));
	offset_case++;
	
	
	/* 横ジャンプ	パターンセット7 */
	OFFSET_CHAR_PAT = offset;
	load_char_pat("shinobu/s_jpfr.sp6",&offset,player,PAL_CHAR(player,0));
	offset_case++;
	
	
	/* しゃがみ+ガード	パターンセット8 */
	OFFSET_CHAR_PAT = offset;
	load_char_pat("shinobu/s_cr_gd.sp6",&offset,player,PAL_CHAR(player,0));
	offset_case++;
	
	
	/* しゃがみ小パンチ	パターンセット9 */
	OFFSET_CHAR_PAT = offset;
	load_char_pat("shinobu/s_cr_pn1.sp6",&offset,player,PAL_CHAR(player,0));
	offset_case++;
	
	
	/* 立ちガード	パターンセット10 */
	OFFSET_CHAR_PAT = offset;
	load_char_pat("shinobu/s_st_gd.sp6",&offset,player,PAL_CHAR(player,0));
	offset_case++;
	
	
	/* ジャンプキック	パターンセット11 */
	OFFSET_CHAR_PAT = offset;
	load_char_pat("shinobu/s_jp_kik.sp6",&offset,player,PAL_CHAR(player,0));
	offset_case++;
	
	
	/* タマ2の読み込み	パターンセット12テスト */
	OFFSET_CHAR_PAT = offset;
	load_char_pat("shinobu/force.sp6", &offset, player, PAL_CHAR(player,5));
	offset_case++;
	
	
	/* 昇龍拳もどき		パターンセット13テスト */
	OFFSET_CHAR_PAT = offset;
	load_char_pat("shinobu/s_shou.sp6", &offset, player, PAL_CHAR(player,0));
	offset_case++;
	
	
	
	
	/* 影 */
	load_sp6_pal("shinobu/s_bs.sp6", PAL_CHAR(player,1), 3);
	
	
	/* 顔とか */
	load_char_face("shinobu/s_face.sp6", player);
	
	
	/* プレイヤーカラー読み取り */
	load_player_pal("shinobu/s_col.vrm", player, player/*collor*/);
	
	
	
	/* ビーム用パレット設定 */
	no = 31;/* パレット番号 */
	b = 31;
	r = 31;
	g = 31;
	pal[1] = 32767;
	SPR_setPaletteBlock(PAL_CHAR(player,no++), 1, (char*)&pal);
	
	for(i=0; i<12; i++){
		if( collor==1 ){
			g -= 2;
			b -= 2;
		} else if( collor==2 ){
			r -= 2;
			b -= 2;
		}
		pal[1] = (g<<10)|(r<<5)|(b<<0);
		SPR_setPaletteBlock(PAL_CHAR(player,no++), 1, (char*)&pal);
	}
	for(i=0; i<7; i++){
		if( collor==1 ){
			g -= 1;
			b -= 1;
		} else if( collor==2 ){
			r -= 1;
			b -= 1;
		}
		pal[1] = (g<<10)|(r<<5)|(b<<0);
		SPR_setPaletteBlock(PAL_CHAR(player,no++), 1, (char*)&pal);
	}
	for(i=0; i<12; i++){
		if( collor==1 ){
			r -= 1;
		} else if( collor==2 ){
			g -= 1;
		}
		pal[1] = (g<<10)|(r<<5)|(b<<0);
		SPR_setPaletteBlock(PAL_CHAR(player,no++), 1, (char*)&pal);
	}
	
	return 0;
}

