コード例 #1
0
        static void Main(string[] args)
        {
            string pathToMiniZork = @"..\..\..\minizork.z3";
            GameMemory minizork = GameMemory.OpenFile(pathToMiniZork);

            //ReadDictionaryTillBreak(minizork);

            DictionaryHelper dictionary = new DictionaryHelper();

            Console.WriteLine($"Dictionary is expected to have {dictionary.CountOfEntries(minizork)} entries");
            string expectedFirst10EntriesString = "$ve . , #comm #rand #reco #unre \" a about";
            string[] expectedFirst10Entries = expectedFirst10EntriesString.Split(' ');

            List<string> nEntries = new List<string>();
            int n = 10;
            for(int i = 0; i < n; i++ )
            {
                string entry = dictionary.ReadNthEntry(i, minizork).Print;
                Console.WriteLine($"Expected: {expectedFirst10Entries[i]} but Found: {entry}");
            }

            WordAddress testText = new WordAddress(0xb106);
            IEnumerable<Zchar> story = Zchar.ReadWordsTillBreak(testText, minizork);
            char[] toPrint = Zchar.DecodeFromZString(story, minizork).ToArray();
            string printMe = new string(toPrint);
            Console.Write(printMe);

            TestMemoryBase();
            TestReadingAndWritingGameState();
            TestReadVersionNumberFromFile(pathToMiniZork);

            //TestBitTwiddling();

            //19 t 0d h 0a e 00 _ 05 ? 05 ?
            //1e y 14 o 1a u 17 r 00 _ 05 ?
            ReadFromAbbrTable(pathToMiniZork);

            Console.WriteLine("Now reading every abbreviation in order");

            for(int i = 0; i < 96; i++)
            {
                AbbreviationNumber num = new AbbreviationNumber(i);
                var zchars = Zchar.ReadAbbrevTillBreak(num, minizork);
                var normalChars = Zchar.DecodeFromZString(zchars, minizork, false)
                    .ToArray();
                Console.WriteLine($"Abbrev number {i} : {new string(normalChars)}");
            }

            Console.ReadKey();
        }
コード例 #2
0
        private static void ReadDictionaryTillBreak(GameMemory zorkFile)
        {
            DictionaryHelper dictionary = new DictionaryHelper();

            WordAddress startOfEntries = dictionary.GetOffSetOfNthEntry(0, zorkFile);
            WordAddress ptrFirstEntry = new WordAddress(startOfEntries.Value);

            var test = Zchar.ReadWordsTillBreak(ptrFirstEntry, zorkFile);
            char[] result = Zchar.DecodeFromZString(test, zorkFile, permitRecurse: false)
                .ToArray();

            Console.Write(new string(result));
        }