Пример #1
0
        public ZAbbreviations(ZHeader header, IMemoryManager manager)
        {
            var abbreviationsTable = manager.AsSpan(header.AbbreviationsTable).ToArray();
            var dynamicMemory      = manager.AsSpan(0, header.DynamicMemorySize);
            var abbrevs            = new List <string>();
            var anyMoreEntries     = true;

            var abbrIdx = 0;

            while (anyMoreEntries && abbrIdx < 96)
            {
                var addr = abbreviationsTable.GetUShort((ushort)(abbrIdx * 2));
                anyMoreEntries = addr != 0;
                if (anyMoreEntries)
                {
                    var zStr = ZsciiString.Get(dynamicMemory.AsSpan((ushort)(addr * 2)), null, header);
                    abbrevs.Add(zStr);
                    abbrIdx++;
                }
            }

//            for (int abbrIdx = 0; abbrIdx < 96 ; abbrIdx++)
//            {
//                var addr = abbreviationsTable.GetUShort((ushort) (abbrIdx * 2));
//
//                if (addr == 0) break;
//
//                var zStr = ZsciiString.Get(dynamicMemory.AsSpan((ushort)(addr * 2)), null);
//                abbrevs.Add(zStr);
//            }

            Abbreviations = abbrevs.ToArray();
        }
Пример #2
0
        public ZsciiStringArray(Span <byte> data, ZAbbreviations abbreviations, ZHeader header)
        {
            var bytes = data.ToArray();

            ushort ptr = 0;

            EntryLength = bytes[ptr++];
            var numEntries = bytes.GetUShort(ptr);

            ptr += 2;

            WordStart = ptr;

            Words = new string[numEntries];
            for (var i = 0; i < numEntries; i++)
            {
                var stringData = bytes.AsSpan(ptr);
                var zStr       = new ZsciiString(stringData, abbreviations, header, header.Version <= 3
                    ? 2 : 3);

                ptr     += EntryLength;
                Words[i] = zStr.String;
            }
        }
Пример #3
0
 public string GetZscii(byte[] data)
 {
     return(ZsciiString.Get(data, Abbreviations, Header));
 }
Пример #4
0
 public string GetZscii(ushort address)
 {
     return(ZsciiString.Get(Manager.AsSpan(address), Abbreviations, Header));
 }