
unit Pack
{
	public const uint16 ID = 0;
	
	//[i] var_int32_w Angle;
	public mydata int32 Angle;
	int32 angle;
	
	public memory mydata
	{
		
	}
	void set_uint32( uint32 d )
	{
		SetAngle( (int)d );
	}
	uint32 get_uint32()
	{
		return (uint)angle;
	}
	
	//[i] var_int32 R;
	int32 R;
	//[i] var_int32 G;
	int32 G;
	//[i] var_int32 B;
	int32 B;
	
	//---------------------------------------------------
	//[i] function_void OS_init;
	public void OS_init()
	{
		Angle = 0;
		
		R = 255;
		G = 0;
		B = 0;
	}
	//---------------------------------------------------
	//[i] function_void SetAngle int32 int32;
	public void SetAngle( int32 an )
	{
		angle = an;
		if( angle > 360 ) {
			angle % 360;
		}
		else if( angle < 0 ) {
			angle = -angle;
			angle % 360;
			angle = 360 - angle;
		}
		
		an = angle * 512 / 120;
		if( an < 256 ) {
			R = 256;
			G = an;
			B = 0;
			return;
		}
		if( an < 512 ) {
			R = 512 - an;
			G = 256;
			B = 0;
			return;
		}
		if( an < 768 ) {
			R = 0;
			G = 256;
			B = an - 512;
			return;
		}
		if( an < 1024 ) {
			R = 0;
			G = 1024 - an;
			B = 256;
			return;
		}
		if( an < 1280 ) {
			R = an - 1024;
			G = 0;
			B = 256;
			return;
		}
		R = 256;
		G = 0;
		B = 1536 - an;
	}
}













