/********************************************************************************
					-------------------------
				 	 Ultra 64 MARIO Brothers
					-------------------------

					File		: pathgrass.s
					Description	: 
					Date		: 1995.11.16
					Author		: H.yajima

 ********************************************************************************/


/*################*/
#ifdef ASSEMBLER
/*################*/

e_effectgrass:
	p_initialize(option)
	p_setbit(flag,stf_moveON )
	p_program(s_effectgrass)
	p_wait(1)
	p_killshape


e_effectsnow_parts:
	p_initialize(effect)
	p_setbit(flag,stf_moveON | stf_FspeedON )
	p_softspritemodeON
	p_while
		p_program(s_effectgrass_parts)
	p_loop

e_effectgrass_parts:
	p_initialize(effect)
	p_setbit(flag,stf_moveON | stf_FspeedON )
	p_while
		p_program(s_effectgrass_parts)
	p_loop


/*################*/
#else
/*################*/
/********************************************************************************
			effect grass
 ********************************************************************************/
extern void s_effectgrass_parts(void)
{

	s_groundcheck();

	if ( obj_timer == 0 ){ 
		obj_anglespeedX = (Randomf()-0.5)*0x1000;
		obj_anglespeedZ = (Randomf()-0.5)*0x1000;
		obj_work1 		= 4;
		obj_work2		= 0x600+Randomf()*0x400;
	}

	if ( obj_worldY  < obj_groundY  ) 					s_remove_obj(execstp);
	if ( obj_groundY < -11000		) 					s_remove_obj(execstp);
	if ( obj_timer	 > 100			) 					s_remove_obj(execstp); 
	if ( beforeframe_objcount > ( NUM_STRATEGY - 28 ))	s_remove_obj(execstp);

	obj_animeangleX 	+= obj_anglespeedX;
	obj_animeangleZ 	+= obj_anglespeedZ;
	obj_speedY 			+= -3;
	if ( obj_speedY < -8 ) obj_speedY = -8;
//	if ( obj_speedY < -20 ) obj_speedY = -20;
	if ( obj_speedF > 0   ) obj_speedF -= 0.3; 
	else					obj_speedF = 0;

	obj_worldX 	+= 	sin(obj_angleY)*sin(obj_work0)*obj_work1;
	obj_worldZ 	+= 	cos(obj_angleY)*sin(obj_work0)*obj_work1;
	obj_work0 	+= 	obj_work2;
	obj_worldY 	+= 	obj_speedY;

}

/********************************************************************************
		========================
			effect grass & snow
		========================
 ********************************************************************************/

extern void s_effectgrass(void)
{

	StrategyRecord *stratp;
	int				i;
	int				flag;
	float			sc;
	float			scale;

	Mbitclr( player1stp->s[stw_effect].d , stf_grass );	/* effect flag off */


	if ( ( activeStageNo == 5 ) || ( activeStageNo == 10 ) ) flag = 1;
	else													 flag = 0;

	if ( flag ){
		if ( Randomf() < 0.5 ){
			stratp 	= s_makeobj_nowpos(execstp,S_snowdust,e_effectsnow_parts);
			sc   = Randomf();
			stSetScale(stratp,sc,sc,sc);
			stratp->s[stw_angleY].d = Randomd();
			stratp->s[stw_speedF].f = Randomf()*5;
			stratp->s[stw_speedY].f = Randomf()*15;
		}
	} else {
		if ( Randomf() < 0.3 ){
			stratp 	= s_makeobj_nowpos(execstp,S_grass,e_effectgrass_parts);
			sc   = Randomf()*3;
			stSetScale(stratp,sc,sc,sc);
			stratp->s[stw_angleY].d = Randomd();
			stratp->s[stw_speedF].f = Randomf()*5+5;
			stratp->s[stw_speedY].f = Randomf()*15;
			stratp->s[stw_animeangleX].d = Randomd();
			stratp->s[stw_animeangleZ].d = Randomd();
			stratp->s[stw_animeangleY].d = Randomd();
		}
	}


}

/*################*/
#endif
/*################*/
/*===============================================================================
		end end end end end end end end 
===============================================================================*/

