public static IEnumerable<Zchar> ReadWordsTillBreak(WordAddress address, GameMemory memory, ISet<char> breakers = null) { while (true) { Word word = memory.ReadWord(address); Zchar low = new Zchar(Bits.FetchBits(BitNumber.Bit14, BitSize.Size5, word)); Zchar mid = new Zchar(Bits.FetchBits(BitNumber.Bit9, BitSize.Size5, word)); Zchar high = new Zchar(Bits.FetchBits(BitNumber.Bit4, BitSize.Size5, word)); yield return low; yield return mid; yield return high; if (word.IsTerminal(breakers)) { yield break; } address = address + 1; } }
private static AbbreviationNumber GetFromZcharAndState(state st, Zchar value) { // 32(z-1)+x int z = 0; switch (st) { case state.abbr: z = 1; break; case state.abbr32: z = 2; break; case state.abbr64: z = 3; break; default: throw new ArgumentException("Apparently invalid state"); } int x = value.Value; return new AbbreviationNumber(32 * (z - 1) + x); }
public static IEnumerable<Zchar> ReadWordAsZchars(Word word) { Zchar low = new Zchar(Bits.FetchBits(BitNumber.Bit14, BitSize.Size5, word)); Zchar mid = new Zchar(Bits.FetchBits(BitNumber.Bit9, BitSize.Size5, word)); Zchar high = new Zchar(Bits.FetchBits(BitNumber.Bit4, BitSize.Size5, word)); return new Zchar[] { low, mid, high }; }