private void VerifyCodeBlocks(byte[] allBytes, SymbolCollection newSymbols, List<CodeBlock> newCodeBlocks)
{
//000001=automatic,000002=manual,000003=4wd ????
Tools.Instance.m_codeBlock5ID = 0;
Tools.Instance.m_codeBlock6ID = 0;
Tools.Instance.m_codeBlock7ID = 0;
bool found = true;
int offset = 0;
int defaultCodeBlockLength = 0x10000;
int currentCodeBlockLength = 0;
int prevCodeBlockStart = 0;
while (found)
{
//int CodeBlockAddress = Tools.Instance.findSequence(allBytes, offset, new byte[11] { 0xC1, 0x02, 0x00, 0x68, 0x00, 0x25, 0x03, 0x00, 0x00, 0x10, 0x27 }, new byte[11] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 });
int CodeBlockAddress = Tools.Instance.findSequence(allBytes, offset, new byte[11] { 0x14, 0x3A, 0x21, 0x3C, 0x23, 0x52, 0x21, 0x5E, 0x21, 0x6A, 0x21 }, new byte[11] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 });
if (CodeBlockAddress > 0)
{
CodeBlock newcodeblock = new CodeBlock();
newcodeblock.StartAddress = CodeBlockAddress - 1;
if (prevCodeBlockStart == 0) prevCodeBlockStart = newcodeblock.StartAddress;
else if (currentCodeBlockLength == 0)
{
currentCodeBlockLength = newcodeblock.StartAddress - prevCodeBlockStart;
if (currentCodeBlockLength > 0x10000) currentCodeBlockLength = 0x10000;
}
// find the next occurence of the checksum
newCodeBlocks.Add(newcodeblock);
offset = CodeBlockAddress + 1;
}
else found = false;
}
foreach (CodeBlock cb in newCodeBlocks)
{
if (currentCodeBlockLength != 0)
{
cb.EndAddress = cb.StartAddress + currentCodeBlockLength - 1;
if (cb.EndAddress > 0x80000) cb.EndAddress = 0x80000;
}
else cb.EndAddress = cb.StartAddress + defaultCodeBlockLength - 1;
}
foreach (CodeBlock cb in newCodeBlocks)
{
int autoSequenceIndex = Tools.Instance.findSequence(allBytes, cb.StartAddress, new byte[7] { 0x45, 0x44, 0x43, 0x20, 0x20, 0x41, 0x47 }, new byte[7] { 1, 1, 1, 1, 1, 1, 1 });
int manualSequenceIndex = Tools.Instance.findSequence(allBytes, cb.StartAddress, new byte[7] { 0x45, 0x44, 0x43, 0x20, 0x20, 0x53, 0x47 }, new byte[7] { 1, 1, 1, 1, 1, 1, 1 });
if (autoSequenceIndex < cb.EndAddress && autoSequenceIndex >= cb.StartAddress) cb.BlockGearboxType = GearboxType.Automatic;
if (manualSequenceIndex < cb.EndAddress && manualSequenceIndex >= cb.StartAddress) cb.BlockGearboxType = GearboxType.Manual;
}
foreach (CodeBlock cb in newCodeBlocks)
{
CheckCodeBlock(cb.StartAddress - 0xc00, allBytes, newSymbols, newCodeBlocks);
}
/*if (Tools.Instance.m_currentfilelength >= 0x80000)
{
Tools.Instance.m_codeBlock5ID = CheckCodeBlock(0, allBytes, newSymbols, newCodeBlocks); //manual specific
Tools.Instance.m_codeBlock6ID = CheckCodeBlock(0x8000, allBytes, newSymbols, newCodeBlocks); //manual specific
Tools.Instance.m_codeBlock7ID = CheckCodeBlock(0x78000, allBytes, newSymbols, newCodeBlocks); //manual specific
}*/
}