Exemple #1
0
        public void DumpToLog(SpanLocation memory, int size)
        {
            var sb = new StringBuilder();

            sb.Append($"\t{ToString()}");
            sb.Append($"\t{memory.ToString(size)}");

            log.Verbose(sb.ToString());
        }
Exemple #2
0
        public DecodedString Decode(SpanLocation location)
        {
            var  position = 0;
            bool end      = false;
            var  builder  = new StringBuilder();

            log.Verbose($"\tDecoding string from bytes {location.ToString()}");

            while (!end)
            {
                var value = Bits.MakeWord(location.Bytes.Slice(position, 2));
                end = (value & 0x8000) > 0;
                log.Verbose($"\tDecoding {value:X} {Bits.BreakIntoZscii(value)}");

                for (var i = 10; i >= 0; i -= 5)
                {
                    var zchar = (value >> i) & 0x1F;
                    var(letter, abbreviation) = Translate(zchar);

                    if (letter.HasValue)
                    {
                        builder.Append(letter.Value);
                    }
                    else if (abbreviation != null)
                    {
                        builder.Append(abbreviation);
                    }
                }

                position += 2;
            }

            state = State.A0;
            return(new DecodedString
            {
                Text = builder.ToString(),
                BytesConsumed = position
            });
        }