/*
 *	clipafxs.h
 *
 *	AfterEffects傾僯儊乕僔儑儞僔乕働儞僒
 *
 *	CLiP - Common Library for P/ECE
 *	Copyright (C) 2016 Naoyuki Sawa
 *
 *	* Fri Apr 22 21:42:56 JST 2016 Naoyuki Sawa
 *	- 1st 儕儕乕僗丅
 *	  /clip/tool/MkAfxSeqXml.jsx偱弌椡偝傟偨丄AfterEffects傾僯儊乕僔儑儞僨乕僞傪撉傒崬傫偱嵞惗偟傑偡丅
 *	* Mon Apr 25 22:45:55 JST 2016 Naoyuki Sawa
 *	- /clip/tool/MkAfxSeqXml.jsx偑<layer>僞僌撪偵<blendingMode>僞僌傪弌椡偡傞傛偆偵側偭偨帠偵敽偄丄摉儌僕儏乕儖偵傕僽儗儞僪儌乕僪偺張棟傪捛壛偟傑偟偨丅
 *	* Tue Apr 26 22:39:26 JST 2016 Naoyuki Sawa
 *	- /clip/tool/MkAfxSeqXml.jsx偑'footage'僉乕偵楢斣僔乕働儞僗僼傽僀儖偺偨傔偺忣曬傕奿擺偡傞傛偆偵側偭偨帠偵敽偄丄摉儌僕儏乕儖偵傕楢斣僔乕働儞僗僼傽僀儖偺偨傔偺張棟傪捛壛偟傑偟偨丅
 *	* Wed Apr 27 21:14:58 JST 2016 Naoyuki Sawa
 *	- /clip/tool/MkAfxSeqXml.jsx偑丄慺嵽偑摦夋偐楢斣僔乕働儞僗偐傪嬫暿偟偰sequenceLength偵揔愗側抣傪奿擺偡傞傛偆偵側偭偨帠偵敽偄丄幚峴帪偵摦夋偐偳偆偐傪敾掕偟偰'footageData.sequenceLength=1'偵彂偒姺偊偰偄偨張棟偼晄梫偵側傝嶍彍偟傑偟偨丅
 *	- /clip/tool/MkAfxSeqXml.jsx偑丄'frame'僉乕偵僐乕僫乕僺儞偺忣曬傕奿擺偡傞傛偆偵側偭偨帠偵敽偄丄摉儌僕儏乕儖傕僐乕僫乕僺儞偺忣曬傪嶲徠偟偰昤夋偡傞傛偆偵曄峏偟傑偟偨丅
 *	- /clip/tool/MkAfxSeqXml.jsx偑丄僾儘僕僃僋僩僷僱儖偱慖戰偝傟偰偄傞暋悢偺僐儞億僕僔儑儞傪傑偲傔偰堦偮偺XML偵彂偒弌偡傛偆偵側偭偨帠偵敽偄丄摉儌僕儏乕儖傕AfxSeq_Load()偺娭悢巇條傪曄峏偟傑偟偨丅
 *	  曄峏慜偼<AfxSeq>僞僌撪偺堦屄栚偺<comp>傪撉傒崬傫偱曉偟偰偄傑偟偨偑丄曄峏屻偼<AfxSeq>僞僌撪偺慡偰偺<comp>傪撉傒崬傫偱丄屇傃弌偟懁偺傾僾儕働乕僔儑儞偵偼屄乆偵僐乕儖僶僢僋偱捠抦偡傞傛偆偵偟傑偟偨丅
 *	* Thu May 05 21:24:20 JST 2016 Naoyuki Sawa
 *	- AfxSeq_Draw()偺昤夋娭悢偺慺嵽ID偺堷悢傪丄偙傟傑偱偼慺嵽偺儀乕僗ID偵僔乕働儞僗抣傪壛嶼偟偨抣傪搉偟偰偄傑偟偨偑丄慺嵽偺儀乕僗ID偲僔乕働儞僗抣傪屄暿偵搉偡傛偆偵曄峏偟傑偟偨丅
 *	  曄峏偟偨棟桼偼丄AfxBin_Draw()偺昤夋娭悢偺堷悢偺宍幃傪(偍偍傛偦)崌傢偣傞偨傔偱偡丅
 *	  AfxBin_Draw()偺昤夋娭悢偼丄慺嵽傪柤慜偱搉偡偺偱丄僔乕働儞僗抣傪壛嶼偡傞帠偑弌棃側偄偐傜偱偡丅
 *	  AfxSeq_Draw()偺昤夋娭悢偵偼偦偺栤戣偼側偄偺偱丄偙傟傑偱捠傝慺嵽偺儀乕僗ID偵僔乕働儞僗抣傪壛嶼偟偨抣傪搉偟偰傕峔傢側偄偺偱偡偑丄昤夋娭悢偺堷悢偺宍幃傪(偍偍傛偦)崌傢偣傞曽偑敾傝堈偄偲巚偆偺偱丄AfxSeq_Draw()偺昤夋娭悢偺堷悢偺宍幃傕曄峏偡傞帠偵偟傑偟偨丅
 *	- USE_AFXSEQ傪掕媊偟側偗傟偽丄AfxSeq_Load(),AfxSeq_Free(),AfxSeq_Draw()傪娷傔側偄傛偆偵偟傑偟偨丅
 *	  P/ECE偱偼儊儌儕愡栺偺偨傔偵丄偙傟傜偺娭悢傪娷傔側偄傛偆偵偟傑偟偨(娷傔傞帠傕壜擻偱偼偁傝傑偡)丅
 *	* Mon May 23 22:46:16 JST 2016 Naoyuki Sawa
 *	- ST_AfxSeq峔憿懱偲ST_AfxLyr峔憿懱偵丄name僼傿乕儖僪傪捛壛偟傑偟偨丅
 *	  捛壛偟偨棟桼偼丄崱屻僐儞億僕僔儑儞傗儗僀儎偺嵎偟懼偊傪峴偆応崌偵丄幚峴帪偵柤慜偺忣曬偑昁梫偵側傞偲巚偭偨偐傜偱偡丅
 *	  尰帪揰偱偼傑偩丄捛壛偟偨name僼傿乕儖僪傪棙梡偟偰偄傑偣傫偑丄崱屻棙梡偡傞梊掕偱偡丅
 *	- 忋婰偺曄峏偵敽偄丄clipafxs.c,媦傃,clipafxb.c偺僐乕僪傪丄戝暆偵曄峏偟傑偟偨丅
 *	  傾僾儕働乕僔儑儞偺娤揰偱曄傢偭偨揰偼丄fnLoad娭悢傊偺僐儞億僕僔儑儞柤偺堷偒搉偟偑丄屄暿偺娭悢堷悢偱偼側偔丄pAfxSeq->name宱桼偱嶲徠偡傞傛偆偵側偭偨揰偺傒偱偡丅
 *	* Mon May 23 23:04:00 JST 2016 Naoyuki Sawa
 *	- 捛壛偟偨name僼傿乕儖僪傪丄傾僾儕働乕僔儑儞偑棙梡偡傞偨傔偺巇慻傒傪捛壛偟傑偟偨丅
 *	  1. 摉儌僕儏乕儖偺昤夋娭悢偵丄fnFilter堷悢傪捛壛偟傑偟偨丅傾僾儕働乕僔儑儞掕媊偺僼傿儖僞娭悢傪巜掕偡傞帠偱丄僩儔僶乕僗張棟偵妱傝崬傫偱僐儞億僕僔儑儞扨埵偺嵎偟懼偊偑壜擻偱偡丅
 *	  2. 傾僾儕働乕僔儑儞掕媊偺fnDraw娭悢偵丄layerDepth,layerPath堷悢傪捛壛偟傑偟偨丅傾僾儕働乕僔儑儞掕媊偺fnDraw娭悢偺拞偱偙傟傜偺忣曬傪嶲徠偟偰丄昤夋捈慜偱偺嵎偟懼偊偑壜擻偱偡丅
 *	- 傑偩丄忋婰偺巇慻傒偺巊梡椺傪彂偄偰偄傑偣傫丅	仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仼仸TODO:
 */
#ifndef __CLIP_AFXS_H__
#define __CLIP_AFXS_H__
#ifdef  __cplusplus
extern "C" {
#endif//__cplusplus
#ifndef PIECE
  #define USE_AFXSEQ	//AfxSeq_Load(),AfxSeq_Free(),AfxSeq_Draw()傪巊梡偡傞応崌偼丄偙偺僔儞儃儖傪掕媊偟偰壓偝偄丅	P/ECE偱偼AfxBin_Draw()偟偐巊梡偟側偄偲巚偆偺偱儊儌儕愡栺偺偨傔偵奜偡帠偵偟傑偟偨(娷傔傞帠傕壜擻偱偼偁傝傑偡)丅AfxBin_Draw()偩偗傪巊偆応崌傕丄儀僋僩儖丒曄姺峴楍偺娭悢,媦傃,ST_AfxSeq峔憿懱偺掕媊偼昁梫偱偡丅	Windows偱傕幚峴帪偵偼傑偢巊梡偟側偄偲巚偄傑偡偑梕検偺惂栺偑彮側偄偺偱忢偵娷傔偰偍偔帠偵偟傑偟偨丅
#endif//PIECE
//劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒
//仭儀僋僩儖丒曄姺峴楍
//劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒
/****************************************************************************
 *	掕悢丄儅僋儘丄峔憿懱
 ****************************************************************************/
//儀僋僩儖
typedef struct _ST_AfxVec {
	double			x, y;
} ST_AfxVec;
extern const ST_AfxVec		AfxVec_0;	//僛儘儀僋僩儖
extern const ST_AfxVec		AfxVec_x;	//x幉偺婎掙儀僋僩儖
extern const ST_AfxVec		AfxVec_y;	//y幉偺婎掙儀僋僩儖
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
//曄姺峴楍
typedef struct _ST_AfxMat {
	//			 +------------- 巔惃儀僋僩儖偺x惉暘
	//			 |    +-------- 巔惃儀僋僩儖偺y惉暘
	//			 |    |    +--- 暯峴堏摦惉暘
	double			a00, a01, a02;
	double			a10, a11, a12;
} ST_AfxMat;
extern const ST_AfxMat		AfxMat_0;	//僛儘峴楍
extern const ST_AfxMat		AfxMat_1;	//扨埵峴楍
/****************************************************************************
 *	僌儘乕僶儖娭悢
 ****************************************************************************/
void AfxVec_Transform(const ST_AfxMat* pAfxMat, ST_AfxVec* pAfxVec);	//嵍偐傜峴楍傪妡偗偰丄塃偺儀僋僩儖傪曄姺偡傞丅
void AfxMat_Transform(ST_AfxMat* pAfxMat1, const ST_AfxMat* pAfxMat2);	//塃偐傜峴楍傪妡偗偰丄嵍偺峴楍傪曄姺偡傞丅
void AfxMat_AnchorPoint(ST_AfxMat* pAfxMat, double x, double y);	//塃偐傜峴楍傪妡偗偰丄嵍偺峴楍傪曄姺偡傞丅
void AfxMat_Position(ST_AfxMat* pAfxMat, double x, double y);	//塃偐傜峴楍傪妡偗偰丄嵍偺峴楍傪曄姺偡傞丅
void AfxMat_Scale(ST_AfxMat* pAfxMat, double x, double y);	//塃偐傜峴楍傪妡偗偰丄嵍偺峴楍傪曄姺偡傞丅
void AfxMat_Rotation(ST_AfxMat* pAfxMat, double z);	//塃偐傜峴楍傪妡偗偰丄嵍偺峴楍傪曄姺偡傞丅
//劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒
//仭AfterEffects傾僯儊乕僔儑儞僔乕働儞僒
//劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒劒
/****************************************************************************
 *	掕悢丄儅僋儘丄峔憿懱
 ****************************************************************************/
//僼儗乕儉
typedef struct _ST_AfxFra {
	short			anchorPoint[2];			//+ 0, 4  傾儞僇乕億僀儞僩丅僺僋僙儖扨埵丅	[0]=x,[1]=y
	short			position[2];			//+ 4, 4  埵抲丅僺僋僙儖扨埵丅			[0]=x,[1]=y
	short			scale[2];			//+ 8, 4  僗働乕儖丅僷乕僙儞僩扨埵丅		[0]=x,[1]=y
	short			rotation;			//+12, 2  夞揮丅搙偺扨埵丅
	unsigned short		opacity;			//+14  2  晄摟柧搙丅僷乕僙儞僩扨埵丅
	short			cornerPin[4][2];		//+16,16  僐乕僫乕僺儞丅僺僋僙儖扨埵丅		[0][0]=topLeft.x,[0][1]=topLeft.y,[1][0]=topRight.x,[1][1]=topRight.y,[2][0]=bottomRight.x,[2][1]=bottomRight.y,[3][0]=bottomLeft.x,[3][1]=bottomLeft.y
} ST_AfxFra;							//=32						//                                                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~AfterEffects忋偱僐乕僫乕僺儞偺僾儘僷僥傿偺弴彉偼TriangleStrip偺暲傃偱偡偑丄摉儌僕儏乕儖偱撉傒崬傓帪偵TriangleFan偺暲傃偱奿擺偡傞帠偵偟傑偟偨丅P/ECE偱傕Windows(DxLib)偱傕TriangleFan偺暲傃偺曽偑埖偄堈偄偐傜偱偡丅
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
//儗僀儎			AfterEffects忋偺儗僀儎偵憡摉偡傞丅
typedef struct _ST_AfxLyr {
	const char*		name;				//+ 0, 4  儗僀儎柤丅																																																										//僶僀僫儕宍幃偱偼丄(ST_AfxLyr*)偺愭摢傾僪儗僗偐傜丄暥帤楍僥乕僽儖撪偺儗僀儎柤傊偺僆僼僙僢僩偑奿擺偝傟偰偄傑偡丅
	struct _ST_AfxSeq*	pAfxSeq;			//+ 4, 4  巕奒憌偺僐儞億僕僔儑儞丅柍偗傟偽NULL丅																																																						//僶僀僫儕宍幃偱偼丄(ST_AfxLyr*)偺愭摢傾僪儗僗偐傜丄(ST_AfxSeq*)傊偺僆僼僙僢僩偑奿擺偝傟偰偄傑偡丅
	int			footage;			//+ 8, 4  偙偺儗僀儎偱昤夋偡傞慺嵽偺儀乕僗ID丅(sequenceLength=0)側傜偽(footage=晄掕抣)丅	'<footage><fileName>fileName</fileName>乣</footage>'偺fileName偵懳偟偰丄(*fnGetFootage)()偑曉偟偨抣傪奿擺偟傑偡丅抣偺夝庍偼傾僾儕働乕僔儑儞偺擟堄偱偡丅P/ECE側傜偽TEX_*傗SPR_*丄Windows側傜偽TexNo_*傗SprNo_*傪奿擺偡傞偺偑堦斒揑偩偲巚偄傑偡偑丄偦傟埲奜偺抣傪夝庍偟偰傕峔偄傑偣傫丅														//僶僀僫儕宍幃偱偼丄(ST_AfxLyr*)偺愭摢傾僪儗僗偐傜丄暥帤楍僥乕僽儖撪偺慺嵽僼傽僀儖柤傊偺僆僼僙僢僩偑奿擺偝傟偰偄傑偡丅
	unsigned short		sequenceLength;			//+12, 2  僔乕働儞僗偺挿偝丅(sequenceLength=0)側傜偽偙偺儗僀儎偼昤夋柍偟丅			惷巭夋,枖偼,摦夋側傜偽1傪奿擺偟傑偡丅楢斣僔乕働儞僗側傜偽楢斣僔乕働儞僗傪峔惉偡傞惷巭夋偺悢傪奿擺偟傑偡丅偙偺儗僀儎偱昞帵偡傞慺嵽偺ID偼[ST_AfxLyr.footage乣ST_AfxLyr.footage+(ST_AfxLyr.sequenceLength-1)]偲側傝傑偡丅慺嵽偺ID偑柤慜偺徃弴偱,偐偮,暲傃偑曵傟傞傛偆側曄懃揑側柤慜偺晅偗曽傪偟偰偄側偄帠偑慜採偱偡丅AfterEffects偺楢斣僔乕働儞僗傕柤慜弴側偺偱偦傟偵堦抳偝偣傞僀儊乕僕偱偡丅
	unsigned short		blendingMode;			//+14, 2  僽儗儞僪儌乕僪丅									0:NORMAL,1:ADD	崱屻丄AfterEffects忋偺懠偺僽儗儞僪儌乕僪偵傕懳墳偟偨傜丄庢傝摼傞抣傪憹傗偡梊掕偱偡丅AfterEffects僗僋儕僾僩忋偺楍嫇抣(BlendingMode.*)偲丄摨偠抣偱偼側偄帠偵拲堄偟偰壓偝偄丅嵍婰偺楍嫇抣偼拞搑敿抂偵戝偒側側抣(NORMAL=4412側偳)偱丄偦偺傑傑偺抣偱偼巊偄偯傜偄偐傜偱偡丅
	unsigned short		startFrame;			//+16, 2  昞帵婜娫偺奐巒僼儗乕儉斣崋丅
	unsigned short		nFrames;			//+18, 2  昞帵婜娫偺僼儗乕儉悢丅
	ST_AfxFra		frames[0/*nFrames*/];		//+20,32N 僼儗乕儉攝楍丅									僼儗乕儉攝楍偺梫慺悢偑摿偵懡偔側傞偲巚偆偺偱丄梕検嶍尭偺偨傔億僀儞僞攝楍偱側偔抣攝楍偲偟偨丅
} ST_AfxLyr;							//=20+32N
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
//僔乕働儞僒			AfterEffects忋偺僐儞億僕僔儑儞偵憡摉偡傞丅
typedef struct _ST_AfxSeq {
	const char*		name;				//+ 0, 4  僐儞億僕僔儑儞柤丅																																																									//僶僀僫儕宍幃偱偼丄(ST_AfxSeq*)偺愭摢傾僪儗僗偐傜丄暥帤楍僥乕僽儖撪偺僐儞億僕僔儑儞柤傊偺僆僼僙僢僩偑奿擺偝傟偰偄傑偡丅
	unsigned short		totalFrame;			//+ 4, 2  嵞惗婜娫偺僼儗乕儉悢丅
	unsigned short		nLayers;			//+ 6, 2  儗僀儎悢丅
	ST_AfxLyr*		layers[0/*nLayers*/];		//+ 8, 4N 儗僀儎偺億僀儞僞攝楍丅																																																								//僶僀僫儕宍幃偱偼丄(ST_AfxSeq*)偺愭摢傾僪儗僗偐傜丄(ST_AfxLyr*)傊偺僆僼僙僢僩偑奿擺偝傟偰偄傑偡丅
} ST_AfxSeq;							//= 8+ 4N
#ifdef  USE_AFXSEQ
/****************************************************************************
 *	僌儘乕僶儖娭悢
 ****************************************************************************/
void AfxSeq_Load(const char* path, void (*fnLoad)(ST_AfxSeq* pAfxSeq, void* user_data), int (*fnGetFootage)(const char* fileName, void* user_data), void* user_data);
void AfxSeq_Free(ST_AfxSeq* pAfxSeq);
void AfxSeq_Draw(const ST_AfxSeq* pAfxSeq, int iFrame, int bLoop, const ST_AfxMat* pAfxMat, double opacity, int blendingMode,
                 void (*fnDraw/*NULL壜*/)(int layerDepth, const char* layerPath[], int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, int footage, int sequence, double opacity, int blendingMode, void* user_data),
                 const ST_AfxSeq* (*fnFilter/*NULL壜*/)(int layerDepth, const char* layerPath[], const ST_AfxSeq* pAfxSeq, void* user_data),
                 void* user_data);
/****************************************************************************
 *	巊梡椺
 ****************************************************************************/
#if 0
//Windows偱巊梡偡傞応崌偺丄傾僾儕働乕僔儑儞掕媊娭悢偺僒儞僾儖傪帵偟傑偡丅
//幚嵺偺傾僾儕働乕僔儑儞偵崌傢偣偰曄峏偟偨傝丄慡偔暿偺張棟偵偟偰傕峔偄傑偣傫丅
/*--------------------------------------------------------------------------*/
//仩AfxSeq_Load()偵搉偡傾僾儕働乕僔儑儞掕媊娭悢偺僒儞僾儖
static void fnLoad(ST_AfxSeq* pAfxSeq, void* user_data) {
	ght_hash_table_t* p_ht = (ght_hash_table_t*)user_data;
	if(ght_insert(p_ht, pAfxSeq, strlen(pAfxSeq->name) + 1/*nul*/, pAfxSeq->name)) { DIE(); }
}
static int fnGetFootage_compar(const void* key, const void* data) {
	const char* fname = (const char*)key;
	const char* pName = EnmDef_GetName(pEnmKey, RegKey_SprNo, (int)data);
//	return strcasecmp(   fname, pName);	//dTexDefC.exe偵'-n'僆僾僔儑儞傪巜掕偟側偐偭偨応崌	劍偳偪傜偐堦曽傪慖戰偟偰壓偝偄丅
	return strnatcasecmp(fname, pName);	//dTexDefC.exe偵'-n'僆僾僔儑儞傪巜掕偟偨応崌		劊
}
static int fnGetFootage(const char* fileName, void* user_data) {
	//僼僢僥乕僕偺慺嵽僼傽僀儖柤(乣/乣/foobar.png)偐傜丄儀乕僗柤(foobar)偩偗傪庢傝弌偡丅
	char fname[MAX_FNAME];
	splitpath(fileName, NULL, NULL, fname, NULL);
	//僗僾儔僀僩偺楍嫇掕媊柤偑丄儀乕僗柤偵堦抳偟偰偄傞偲壖掕偟偰丄僗僾儔僀僩傪専嶕偡傞丅
	int iSprNo = (int)bsearch(fname, (void*)1, SprNo_Max, 1, fnGetFootage_compar);
	//           ~~~~~               ~~~~~~~~~~~~~~~~~~~~~~bsearch()傪斣崋偵懳偟偰巊梡偡傞僥僋僯僢僋偱偡丅傾僪儗僗傪斣崋偲尒側偟偰(iSprNo=1乣SprNo_Max)偵懳偟偰専嶕傪峴偄傑偡丅
	if(!iSprNo) { DIE(); }	//僗僾儔僀僩偑尒偮偐傜側偗傟偽丄僄儔乕掆巭偡傞丅
	return iSprNo;
}
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
//仩AfxSeq_Draw()偵巜掕偡傞傾僾儕働乕僔儑儞掕媊娭悢偺僒儞僾儖
static void fnDraw(int layerDepth, const char* layerPath[], int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, int footage, int sequence, double opacity, int blendingMode, void* user_data) {
	//僗僾儔僀僩忣曬傪庢摼偡傞丅
	ST_SprDef stSprDef;
	get_sprDef(footage + sequence, &stSprDef);
	//帺桼曄宍僗僾儔僀僩傪昤夋偡傞丅
	CbkQue_draw_spr3(pCbkQue,
		0,
		x1, y1,	//topLeft
		x2, y2,	//topRight
		x3, y3,	//bottomRight	//劍TriangleFan偺暲傃
		x4, y4,	//bottomLeft	//劊
		footage + sequence,
		D3DRGBA(1.0,1.0,1.0,opacity),
		blendingMode ? DX_BLENDMODE_ADD : DX_BLENDMODE_ALPHA);
}
/*--------------------------------------------------------------------------*/
//傾僾儕働乕僔儑儞偐傜偺巊梡椺
int cpp_main(int argc, char* argv[]) {
	ght_hash_table_t* p_ht = ght_create(0);
	ght_set_rehash(p_ht, 1);
	AfxSeq_Load("sample1.xml", fnLoad, fnGetFootage, p_ht);	//劉
	AfxSeq_Load("sample2.xml", fnLoad, fnGetFootage, p_ht);	//劌暋悢壜
	AfxSeq_Load("sample3.xml", fnLoad, fnGetFootage, p_ht);	//劊
	{                        /*~~~~~~  ~~~~~~~~~~~~*/
		const char* name = "animation1";
		ST_AfxSeq* pAfxSeq = (ST_AfxSeq*)ght_get(p_ht, strlen(name) + 1/*nul*/, name);
		if(!setjmp(env_exit)) {
			for(;;) {
				schedule();
				ST_AfxMat tmp = AfxMat_1;
				AfxMat_Position(&tmp, DISP_X/2, DISP_Y/2);
				AfxMat_Rotation(&tmp, now * ((M_PI * 2.0) / SEC(10.0)));
				AfxMat_Scale(&tmp, 0.75, 0.75);
				AfxMat_AnchorPoint(&tmp, 580, 490);
				AfxSeq_Draw(pAfxSeq, now, 1, &tmp, 1.0, 0, fnDraw, NULL, NULL);
			}                                                /*~~~~~~*/
		}
		ght_iterator_t it;
		for(pAfxSeq = (ST_AfxSeq*)ght_first(p_ht, &it, (const void**)&name);
		    pAfxSeq;
		    pAfxSeq = (ST_AfxSeq*)ght_next( p_ht, &it, (const void**)&name)) {
			AfxSeq_Free(pAfxSeq);
		}
	}
	ght_finalize(p_ht);
	return EXIT_SUCCESS;
}
/*--------------------------------------------------------------------------*/
#endif
#endif//USE_AFXSEQ
#ifdef  __cplusplus
}//extern "C"
#endif//__cplusplus
#endif//__CLIP_AFXS_H__
