// note: performance-intensive function. be really careful when adding stuff here. public RomByte DecodeRomByte(string line) { var input = PrepLine(line); var newByte = new RomByte(); var flagTxt = input[0]; var otherFlags1 = Fake64Encoding.DecodeHackyBase64(input[1]); newByte.DataBank = ByteUtil.ByteParseHex2(input[2], input[3]); newByte.DirectPage = (int)ByteUtil.ByteParseHex4(input[4], input[5], input[6], input[7]); newByte.Arch = (Data.Architecture)(ByteUtil.ByteParseHex1(input[8]) & 0x3); newByte.BaseAddr = (int)ByteUtil.ByteParseHex6(input[9], input[10], input[11], input[12], input[13], input[14]); newByte.IndirectAddr = (int)ByteUtil.ByteParseHex6(input[15], input[16], input[17], input[18], input[19], input[20]); newByte.TypeConstant = (Data.ConstantType)(ByteUtil.ByteParseHex1(input[21])); #if EXTRA_DEBUG_CHECKS Debug.Assert(Fake64Encoding.EncodeHackyBase64(otherFlags1) == o1_str); #endif newByte.XFlag = ((otherFlags1 >> 2) & 0x1) != 0; newByte.MFlag = ((otherFlags1 >> 3) & 0x1) != 0; newByte.Point = (Data.InOutPoint)((otherFlags1 >> 4) & 0xF); var found = false; foreach (var e in FlagEncodeTable) { if (e.C != flagTxt) { continue; } newByte.TypeFlag = e.F; found = true; break; } if (!found) { throw new InvalidDataException("Unknown FlagType"); } return(newByte); }
public static void TestHex4() { Assert.Equal((uint)0xF029, ByteUtil.ByteParseHex4('F', '0', '2', '9')); }