private CompiledStrings CompileStrings(string filePath)
{
List<int> pointers = new List<int>();
List<byte> compiledStrings = new List<byte>();
int index = 0;
Dictionary<byte, char> characterValues = ReadTableFile(System.Windows.Forms.Application.StartupPath + @"\Data\table.ini");
foreach (string s in dynamicStrings.Keys)
{
if (s.StartsWith("@"))
{
pointers.Add(compiledStrings.Count);
index = 0;
bool ignoreNextIndex = false;
foreach (char c in dynamicStrings[s])
{
if (ignoreNextIndex)
{
ignoreNextIndex = false;
index += 2;
continue;
}
if (c == '\\')
{
char c2 = (dynamicStrings[s][index + 1]);
switch (c2)
{
case 'n':
compiledStrings.Add(0xFE);
break;
case 'p':
compiledStrings.Add(0xFA);
break;
case 'l':
compiledStrings.Add(0xFB);
break;
default:
break;
}
ignoreNextIndex = true;
continue;
}
else
{
byte toStore = 0;
foreach (byte b in characterValues.Keys)
{
if (characterValues[b] == c)
{
toStore = b;
}
}
compiledStrings.Add(toStore);
}
index++;
}
compiledStrings.Add(0xFF);
}
else
{
int location2 = 0;
index = 0;
int index2 = 0;
try
{
location2 = Int32.Parse(s);
}
catch (FormatException)
{
location2 = Int32.Parse(ToDecimal(s));
}
catch
{
MessageBox.Show("There was an unknown error.");
}
pointers.Add(location2 + 0x08000000);
byte[] rom = File.ReadAllBytes(filePath);
bool ignoreNextIndex = false;
foreach (char c in dynamicStrings[s])
{
if (ignoreNextIndex)
{
ignoreNextIndex = false;
index += 2;
index2++;
continue;
}
if (c == '\\')
{
char c2 = (dynamicStrings[s][index + 1]);
switch (c2)
{
case 'n':
rom[location2 + index2] = 0xFE;
break;
case 'p':
rom[location2 + index2] = 0xFA;
break;
case 'l':
rom[location2 + index2] = 0xFB;
break;
default:
break;
}
ignoreNextIndex = true;
continue;
}
else
{
byte toStore = 0;
foreach (byte b in characterValues.Keys)
{
if (characterValues[b] == c)
{
toStore = b;
}
}
rom[location2 + index2] = toStore;
}
index++;
index2++;
}
rom[location2 + index2] = 0xFF;
rom[location2 + index2 + 1] = 0x0;
File.WriteAllBytes(filePath, rom);
}
}
if (compiledStrings.Count > 0)
{
compiledStrings.Add(0);
}
return new CompiledStrings(pointers.ToArray(), compiledStrings.ToArray());
}