using System.Text;

namespace QCRPG.TSL.FM.Packets;

public static class RegisterMapInfo
{
	public static RegisterMapEnum ValueToRegisterMap(uint value)
	{
		return value switch
		{
			0u => RegisterMapEnum.INTSTAT1, 
			1u => RegisterMapEnum.INTSTAT2, 
			2u => RegisterMapEnum.INTSTAT3, 
			3u => RegisterMapEnum.RDCTRL, 
			4u => RegisterMapEnum.FREQ, 
			5u => RegisterMapEnum.TUNECTRL, 
			6u => RegisterMapEnum.SRCHRDS1, 
			7u => RegisterMapEnum.SRCHRDS2, 
			8u => RegisterMapEnum.SRCHCTRL, 
			9u => RegisterMapEnum.IOCTRL, 
			10u => RegisterMapEnum.RDSCTRL, 
			11u => RegisterMapEnum.ADVCTRL, 
			12u => RegisterMapEnum.AUDIOCTRL, 
			13u => RegisterMapEnum.RMSSI, 
			14u => RegisterMapEnum.IOVERC, 
			15u => RegisterMapEnum.RDS1MSB, 
			16u => RegisterMapEnum.RDS1LSB, 
			17u => RegisterMapEnum.RDS1STAT, 
			18u => RegisterMapEnum.RDS2MSB, 
			19u => RegisterMapEnum.RDS2LSB, 
			20u => RegisterMapEnum.RDS2STAT, 
			21u => RegisterMapEnum.RDS3MSB, 
			22u => RegisterMapEnum.RDS3LSB, 
			23u => RegisterMapEnum.RDS3STAT, 
			24u => RegisterMapEnum.RDS4MSB, 
			25u => RegisterMapEnum.RDS4LSB, 
			26u => RegisterMapEnum.RDS4STAT, 
			27u => RegisterMapEnum.RDSGROUP, 
			28u => RegisterMapEnum.RDSSNRMSB, 
			29u => RegisterMapEnum.RDSSNRLSB, 
			30u => RegisterMapEnum.AUDIOIND, 
			31u => RegisterMapEnum.XFRCTRL, 
			32u => RegisterMapEnum.XFRDAT0, 
			33u => RegisterMapEnum.XFRDAT1, 
			34u => RegisterMapEnum.XFRDAT2, 
			35u => RegisterMapEnum.XFRDAT3, 
			36u => RegisterMapEnum.XFRDAT4, 
			37u => RegisterMapEnum.XFRDAT5, 
			38u => RegisterMapEnum.XFRDAT6, 
			39u => RegisterMapEnum.XFRDAT7, 
			40u => RegisterMapEnum.XFRDAT8, 
			41u => RegisterMapEnum.XFRDAT9, 
			42u => RegisterMapEnum.XFRDAT10, 
			43u => RegisterMapEnum.XFRDAT11, 
			44u => RegisterMapEnum.XFRDAT12, 
			45u => RegisterMapEnum.XFRDAT13, 
			46u => RegisterMapEnum.XFRDAT14, 
			47u => RegisterMapEnum.XFRDAT15, 
			_ => RegisterMapEnum.InvalidRegisterMapValue, 
		};
	}

	public static uint RegisterMapToValue(RegisterMapEnum enumItem)
	{
		return enumItem switch
		{
			RegisterMapEnum.INTSTAT1 => 0u, 
			RegisterMapEnum.INTSTAT2 => 1u, 
			RegisterMapEnum.INTSTAT3 => 2u, 
			RegisterMapEnum.RDCTRL => 3u, 
			RegisterMapEnum.FREQ => 4u, 
			RegisterMapEnum.TUNECTRL => 5u, 
			RegisterMapEnum.SRCHRDS1 => 6u, 
			RegisterMapEnum.SRCHRDS2 => 7u, 
			RegisterMapEnum.SRCHCTRL => 8u, 
			RegisterMapEnum.IOCTRL => 9u, 
			RegisterMapEnum.RDSCTRL => 10u, 
			RegisterMapEnum.ADVCTRL => 11u, 
			RegisterMapEnum.AUDIOCTRL => 12u, 
			RegisterMapEnum.RMSSI => 13u, 
			RegisterMapEnum.IOVERC => 14u, 
			RegisterMapEnum.RDS1MSB => 15u, 
			RegisterMapEnum.RDS1LSB => 16u, 
			RegisterMapEnum.RDS1STAT => 17u, 
			RegisterMapEnum.RDS2MSB => 18u, 
			RegisterMapEnum.RDS2LSB => 19u, 
			RegisterMapEnum.RDS2STAT => 20u, 
			RegisterMapEnum.RDS3MSB => 21u, 
			RegisterMapEnum.RDS3LSB => 22u, 
			RegisterMapEnum.RDS3STAT => 23u, 
			RegisterMapEnum.RDS4MSB => 24u, 
			RegisterMapEnum.RDS4LSB => 25u, 
			RegisterMapEnum.RDS4STAT => 26u, 
			RegisterMapEnum.RDSGROUP => 27u, 
			RegisterMapEnum.RDSSNRMSB => 28u, 
			RegisterMapEnum.RDSSNRLSB => 29u, 
			RegisterMapEnum.AUDIOIND => 30u, 
			RegisterMapEnum.XFRCTRL => 31u, 
			RegisterMapEnum.XFRDAT0 => 32u, 
			RegisterMapEnum.XFRDAT1 => 33u, 
			RegisterMapEnum.XFRDAT2 => 34u, 
			RegisterMapEnum.XFRDAT3 => 35u, 
			RegisterMapEnum.XFRDAT4 => 36u, 
			RegisterMapEnum.XFRDAT5 => 37u, 
			RegisterMapEnum.XFRDAT6 => 38u, 
			RegisterMapEnum.XFRDAT7 => 39u, 
			RegisterMapEnum.XFRDAT8 => 40u, 
			RegisterMapEnum.XFRDAT9 => 41u, 
			RegisterMapEnum.XFRDAT10 => 42u, 
			RegisterMapEnum.XFRDAT11 => 43u, 
			RegisterMapEnum.XFRDAT12 => 44u, 
			RegisterMapEnum.XFRDAT13 => 45u, 
			RegisterMapEnum.XFRDAT14 => 46u, 
			RegisterMapEnum.XFRDAT15 => 47u, 
			_ => uint.MaxValue, 
		};
	}

	public static string RegisterMapToString(RegisterMapEnum enumItem)
	{
		return enumItem switch
		{
			RegisterMapEnum.INTSTAT1 => "INTSTAT1", 
			RegisterMapEnum.INTSTAT2 => "INTSTAT2", 
			RegisterMapEnum.INTSTAT3 => "INTSTAT3", 
			RegisterMapEnum.RDCTRL => "RDCTRL", 
			RegisterMapEnum.FREQ => "FREQ", 
			RegisterMapEnum.TUNECTRL => "TUNECTRL", 
			RegisterMapEnum.SRCHRDS1 => "SRCHRDS1", 
			RegisterMapEnum.SRCHRDS2 => "SRCHRDS2", 
			RegisterMapEnum.SRCHCTRL => "SRCHCTRL", 
			RegisterMapEnum.IOCTRL => "IOCTRL", 
			RegisterMapEnum.RDSCTRL => "RDSCTRL", 
			RegisterMapEnum.ADVCTRL => "ADVCTRL", 
			RegisterMapEnum.AUDIOCTRL => "AUDIOCTRL", 
			RegisterMapEnum.RMSSI => "RMSSI", 
			RegisterMapEnum.IOVERC => "IOVERC", 
			RegisterMapEnum.RDS1MSB => "RDS1MSB", 
			RegisterMapEnum.RDS1LSB => "RDS1LSB", 
			RegisterMapEnum.RDS1STAT => "RDS1STAT", 
			RegisterMapEnum.RDS2MSB => "RDS2MSB", 
			RegisterMapEnum.RDS2LSB => "RDS2LSB", 
			RegisterMapEnum.RDS2STAT => "RDS2STAT", 
			RegisterMapEnum.RDS3MSB => "RDS3MSB", 
			RegisterMapEnum.RDS3LSB => "RDS3LSB", 
			RegisterMapEnum.RDS3STAT => "RDS3STAT", 
			RegisterMapEnum.RDS4MSB => "RDS4MSB", 
			RegisterMapEnum.RDS4LSB => "RDS4LSB", 
			RegisterMapEnum.RDS4STAT => "RDS4STAT", 
			RegisterMapEnum.RDSGROUP => "RDSGROUP", 
			RegisterMapEnum.RDSSNRMSB => "RDSSNRMSB", 
			RegisterMapEnum.RDSSNRLSB => "RDSSNRLSB", 
			RegisterMapEnum.AUDIOIND => "AUDIOIND", 
			RegisterMapEnum.XFRCTRL => "XFRCTRL", 
			RegisterMapEnum.XFRDAT0 => "XFRDAT0", 
			RegisterMapEnum.XFRDAT1 => "XFRDAT1", 
			RegisterMapEnum.XFRDAT2 => "XFRDAT2", 
			RegisterMapEnum.XFRDAT3 => "XFRDAT3", 
			RegisterMapEnum.XFRDAT4 => "XFRDAT4", 
			RegisterMapEnum.XFRDAT5 => "XFRDAT5", 
			RegisterMapEnum.XFRDAT6 => "XFRDAT6", 
			RegisterMapEnum.XFRDAT7 => "XFRDAT7", 
			RegisterMapEnum.XFRDAT8 => "XFRDAT8", 
			RegisterMapEnum.XFRDAT9 => "XFRDAT9", 
			RegisterMapEnum.XFRDAT10 => "XFRDAT10", 
			RegisterMapEnum.XFRDAT11 => "XFRDAT11", 
			RegisterMapEnum.XFRDAT12 => "XFRDAT12", 
			RegisterMapEnum.XFRDAT13 => "XFRDAT13", 
			RegisterMapEnum.XFRDAT14 => "XFRDAT14", 
			RegisterMapEnum.XFRDAT15 => "XFRDAT15", 
			_ => "Invalid RegisterMap Value", 
		};
	}

	public static string RegisterMapToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0 = INTSTAT1");
		stringBuilder.AppendLine("0x1 = INTSTAT2");
		stringBuilder.AppendLine("0x2 = INTSTAT3");
		stringBuilder.AppendLine("0x3 = RDCTRL");
		stringBuilder.AppendLine("0x4 = FREQ");
		stringBuilder.AppendLine("0x5 = TUNECTRL");
		stringBuilder.AppendLine("0x6 = SRCHRDS1");
		stringBuilder.AppendLine("0x7 = SRCHRDS2");
		stringBuilder.AppendLine("0x8 = SRCHCTRL");
		stringBuilder.AppendLine("0x9 = IOCTRL");
		stringBuilder.AppendLine("0xA = RDSCTRL");
		stringBuilder.AppendLine("0xB = ADVCTRL");
		stringBuilder.AppendLine("0xC = AUDIOCTRL");
		stringBuilder.AppendLine("0xD = RMSSI");
		stringBuilder.AppendLine("0xE = IOVERC");
		stringBuilder.AppendLine("0xF = RDS1MSB");
		stringBuilder.AppendLine("0x10 = RDS1LSB");
		stringBuilder.AppendLine("0x11 = RDS1STAT");
		stringBuilder.AppendLine("0x12 = RDS2MSB");
		stringBuilder.AppendLine("0x13 = RDS2LSB");
		stringBuilder.AppendLine("0x14 = RDS2STAT");
		stringBuilder.AppendLine("0x15 = RDS3MSB");
		stringBuilder.AppendLine("0x16 = RDS3LSB");
		stringBuilder.AppendLine("0x17 = RDS3STAT");
		stringBuilder.AppendLine("0x18 = RDS4MSB");
		stringBuilder.AppendLine("0x19 = RDS4LSB");
		stringBuilder.AppendLine("0x1A = RDS4STAT");
		stringBuilder.AppendLine("0x1B = RDSGROUP");
		stringBuilder.AppendLine("0x1C = RDSSNRMSB");
		stringBuilder.AppendLine("0x1D = RDSSNRLSB");
		stringBuilder.AppendLine("0x1E = AUDIOIND");
		stringBuilder.AppendLine("0x1F = XFRCTRL");
		stringBuilder.AppendLine("0x20 = XFRDAT0");
		stringBuilder.AppendLine("0x21 = XFRDAT1");
		stringBuilder.AppendLine("0x22 = XFRDAT2");
		stringBuilder.AppendLine("0x23 = XFRDAT3");
		stringBuilder.AppendLine("0x24 = XFRDAT4");
		stringBuilder.AppendLine("0x25 = XFRDAT5");
		stringBuilder.AppendLine("0x26 = XFRDAT6");
		stringBuilder.AppendLine("0x27 = XFRDAT7");
		stringBuilder.AppendLine("0x28 = XFRDAT8");
		stringBuilder.AppendLine("0x29 = XFRDAT9");
		stringBuilder.AppendLine("0x2A = XFRDAT10");
		stringBuilder.AppendLine("0x2B = XFRDAT11");
		stringBuilder.AppendLine("0x2C = XFRDAT12");
		stringBuilder.AppendLine("0x2D = XFRDAT13");
		stringBuilder.AppendLine("0x2E = XFRDAT14");
		stringBuilder.AppendLine("0x2F = XFRDAT15");
		return stringBuilder.ToString();
	}
}
