Esempio n. 1
0
        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);
        }