private void ReadCharLookup() { Settings.CharLookup = new Dictionary<short, string>(); // Build a lookup table from the font metadata IBinaryReader sjisReader = new BinaryReader(Source, true); sjisReader.Position = Settings.BankAddresses["MainFont"]; for (int i = 0; i < 7332; i++) { byte[] sjis = sjisReader.ReadByteArray(2); sjisReader.Position += 20; string value = sjisEncoding.GetString(sjis); Settings.CharLookup.Add((short)i, value); } }
public override string ReadDialogString(IBinaryReader reader) { List<byte> decoded = new List<byte>(); bool first = true; for (;;) { byte value = DecodeByte(reader); if (value == 0xEF) { // Custom article code decoded.Add(0xEF); decoded.Add(DecodeByte(reader)); } else if (first && value == 0xFE) { // Custom hotspot code decoded.Add(0xFF); decoded.Add(0xFE); decoded.Add(DecodeByte(reader)); decoded.Add(DecodeByte(reader)); } // Check for other control codes else if (value >= 0xF0) { if (value == 0xFF) { decoded.Add(0xFF); decoded.Add(0xFF); break; } else { int length = (value & 0xF) * 2; byte code = DecodeByte(reader); decoded.Add(code); decoded.Add(0xFF); for (int i = 0; i < length; i++) { decoded.Add(DecodeByte(reader)); } } } else { decoded.Add(value); decoded.Add(0); } first = false; } BinaryReader decodedReader = new BinaryReader(new ByteArraySource(decoded.ToArray())); return ReadCodedString(decodedReader); }
private void ReadEncodingPadData() { BinaryReader reader = new BinaryReader(Source); ScriptEncodingParameters encodingParameters = Settings.ScriptEncoding; reader.Position = encodingParameters.EvenPadAddress; encodingParameters.EvenPad = reader.ReadByteArray(encodingParameters.EvenPadModulus); reader.Position = encodingParameters.OddPadAddress; encodingParameters.OddPad = reader.ReadByteArray(encodingParameters.OddPadModulus); }