Tidy the Intel Hex file parser a little.

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon 2019-07-14 17:35:19 +01:00
parent b4c37ea006
commit 6f79136706

View File

@ -73,12 +73,10 @@ namespace EightBit
var address = Convert.ToUInt16(addressString, 16);
var recordTypeString = line.Substring(7, 2);
var recordType = Convert.ToByte(recordTypeString, 16);
switch (recordType)
switch (Convert.ToByte(recordTypeString, 16))
{
case 0x00:
return ParseDataRecord(line, address, count);
return new Tuple<ushort, byte[]>(address, ParseDataRecord(line, count));
case 0x01:
this.eof = true;
@ -89,7 +87,7 @@ namespace EightBit
}
}
private static Tuple<ushort, byte[]> ParseDataRecord(string line, ushort address, byte count)
private static byte[] ParseDataRecord(string line, byte count)
{
if (string.IsNullOrEmpty(line))
{
@ -110,7 +108,7 @@ namespace EightBit
data[i] = Convert.ToByte(extracted, 16);
}
return new Tuple<ushort, byte[]>(address, data);
return data;
}
}
}