public static string GetString(int index) { var stream = GetDataStream(); stream.Skip(EntrySize * index); var data = stream.GetBytes(EntrySize); var name = string.Join("", data.Where(x => x != BufferByte).Select(x => BasicTable.Lookup(x))); return(name); }
public static string AttemptTranslate(ByteArrayStream stream, int depthLeft = 2) { var code = stream.Byte(); if (code >= 0x80) { return(BasicTable.Lookup(code)); } if (code < 0x30) { if (code == 0x01) { return($"{{windowbreak}}"); } if (code == 0x05) { return($"{{05:{stream.Byte().ToString("x2")}}}"); } if (code == 0x1b) { return($"{{swapspeaker:{stream.Byte().ToString("x2")}}}"); } if (code == 0x1d) { return($"{{character:{CharacterNames.GetString(stream.Byte())}}}"); } if (code == 0x1e) { return($"{{item:{ItemNames.GetString(stream.Byte())}}}"); } if (code == 0x1f) { return($"{{location:{LocationNames.GetString(stream.Byte())}}}"); } //if (code == 0x2f) { // return $"{{if:{stream.Byte().ToString("x2")} {stream.Byte().ToString("x2")} {stream.Byte().ToString("x2")}}}"; //} return($"{{{code.ToString("x2")}}}"); } if (depthLeft == 0) { return($"{{{code.ToString("x2")}}}"); } //var text = string.Join("", LookupBytes(code).Select(x => AttemptTranslate(x, depthLeft - 1))); var text = AttemptTranslateLine(LookupBytes(code), depthLeft - 1); return(text); }
public static string AttemptTranslate(byte code, int depthLeft = 2) { if (code < 0x30) { return($"{{{code.ToString("x2")}}}"); } else if (code >= 0x80) { return(BasicTable.Lookup(code)); } else if (depthLeft == 0) { return($"{{{code.ToString("x2")}}}"); } var text = string.Join("", LookupBytes(code).Select(x => AttemptTranslate(x, depthLeft - 1))); return(text); }