
unit ControlPad
{
	//[i] memory linka;
	//[i] function_void OS_init,
	//[i] function_void Connect,
	//[i] function_void OS_ClearWatchDog,
	//[i] function_void SetString,
	//[i] function_void SetValue,
	//[i] function_void GetValue,
	//[i] var_array FlagList,
	//[i] var_bool isBusy,
	//[i] var_bool isNeed,
	
	#include "$chip$.txt"


	//link memory linka {} = #.linker.linka;
	
	//[i] linksysconst_uint8 ID;
	public const uint8 ID = 0;
	
	//[i] var_int32 Width;
	public linka int32 Width = #addr ID * 0x0100 + 0x03;
	//[i] var_int32 Height;
	public linka int32 Height = #addr ID * 0x0100 + 0x04;
	//[i] var_int32 BackColor;
	public linka int32 BackColor = #addr ID * 0x0100 + 0x05;
	
	///[i] var_int32 ButtonIndex;
	public linka int32 ButtonIndex = #addr ID * 0x0100 + 0x20;
	//[i] var_int32 MouseX;
	public linka int32 MouseX = #addr ID * 0x0100 + 0x21;
	//[i] var_int32 MouseY;
	public linka int32 MouseY = #addr ID * 0x0100 + 0x22;

	//[i] var_uint8 OS_EventFlag;
	//public uint8 OS_EventFlag;
	
	//[i] event press_event;
	//[i] event up_event;
	//[i] event move_event;
	//[i] event StartEvent;
	//[i] event IdleEvent;

	//---------------------------------------------------
	//[i] function_void OS_thread;
	public void OS_thread()
	{
		OS_EventFlag.4(bit) = 1;
	}
	//---------------------------------------------------
	//[i] function_void OS_WaitOk;
	public void OS_WaitOk()
	{
	}
	//---------------------------------------------------
	//[i] function_bool MousePress;
	public bool MousePress()
	{
		if( ButtonIndex == 0 ) {
			return false;
		}
		else if( ButtonIndex == 1 ) {
			return true;
		}
		else {
			return true;
		}
	}
	
	//---------------------------------------------------
	//[i] function_void SetImage Cstring;
	public void SetImage( [#.code uint16*?] string )
	{
		#.linker.SetString( ID, 0x30, string );
	}
	//---------------------------------------------------
	//[i] function_void SetText Cstring;
	public void SetText( [#.code uint16*?] string )
	{
		#.linker.SetString( ID, 0x10, string );
	}
}











