public static WordAddress AddressOfAbbreviationByNumber(AbbreviationNumber number, GameMemory memory)
 {
     AbbreviationTableBase basePtr = new AbbreviationTableBase(memory);
     WordAddress addressOfPtrToAbbrTable = new WordAddress(24);
     WordAddress ptrToAbbrevTable = new WordAddress(memory.ReadWord(addressOfPtrToAbbrTable).Value);
     WordAddress ptrToChosenAbbrv = ptrToAbbrevTable + (number.Value);
     WordAddress decompressedAbbrvPtr = new WordAddress(memory.ReadWord(ptrToChosenAbbrv).Value * 2);
     return decompressedAbbrvPtr;
 }
        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();
        }
 public static IEnumerable<char> YieldAbbreviationFromAbbreviationNumber(AbbreviationNumber number, GameMemory memory)
 {
     WordAddress addressOfPtrToAbbrTable = new WordAddress(24);
     WordAddress ptrToAbbrevTable = new WordAddress(memory.ReadWord(addressOfPtrToAbbrTable).Value);
     WordAddress address = AbbreviationTableBase.AddressOfAbbreviationByNumber(number, memory);
     Word word = memory.ReadWord(address);
     while (true)
     {
         char[] firstThree = Zchar.PrintWordAsZchars(word).ToCharArray();
         foreach (char ch in firstThree)
         {
             yield return ch;
         }
         if (word.IsTerminal())
         {
             yield break;
         }
         address = address + 1;
         word = memory.ReadWord(address);
     }
 }
 public static IEnumerable<Zchar> ReadAbbrevTillBreak(AbbreviationNumber num, GameMemory memory)
 {
     WordAddress addressOfPtrToAbbrTable = new WordAddress(24);
     WordAddress ptrToAbbrevTable = new WordAddress(memory.ReadWord(addressOfPtrToAbbrTable).Value);
     WordAddress ptrChosenAbbrev = AbbreviationTableBase.AddressOfAbbreviationByNumber(num, memory);
     return ReadWordsTillBreak(ptrChosenAbbrev, memory);
 }