public ZObjectTable(IZMemory mem) { // V4+ constants DEFAULTSIZE = 126; // 63 words = 126 bytes OBJATTRSIZE = 6; OBJHANDLESIZE = 2; objEntrySize = (OBJATTRSIZE + (3 * OBJHANDLESIZE) + 2); m_memory = mem; }
public ZObjectTable(IZMemory mem) { // V3 constants DEFAULTSIZE = 62; // 31 words = 62 bytes OBJATTRSIZE = 4; OBJHANDLESIZE = 1; objEntrySize = (OBJATTRSIZE + (3 * OBJHANDLESIZE) + 2); m_memory = mem; }
public ScanTable(IZMemory memory) : base((ushort)OpCodes.ScanTable, memory) { }
public Call1S(IZMemory memory) : base((ushort)OpCodes.Call1S, memory) { }
public SplitWindow(IZMemory memory, IUserIo io) : base((ushort)OpCodes.SplitWindow, memory) { _io = io; }
public Newline(IZMemory memory, IUserIo io) : base((ushort)OpCodes.NewLine, memory) { _io = io; }
public Quit(IZMemory memory, IUserIo io) : base((ushort)OpCodes.Quit, memory) { _io = io; }
public Or(IZMemory memory) : base((ushort)OpCodes.Or, memory) { }
public And(IZMemory memory) : base((ushort)OpCodes.And, memory) { }
public PrintObj(IZMemory memory, IUserIo io) : base((ushort)OpCodes.PrintObj, memory) { _io = io; }
public RetPopped(IZMemory memory) : base((ushort)OpCodes.RetPopped, memory) { }
public SoundEffect(IZMemory memory, IUserIo io) : base((ushort)OpCodes.SoundEffect, memory) { _io = io; }
public Jz(IZMemory memory) : base((ushort)OpCodes.Jz, memory) { }
public Verify(IZMemory memory) : base((ushort)OpCodes.Verify, memory) { }
public CopyTable(IZMemory memory) : base((ushort)OpCodes.CopyTable, memory) { }
internal static string DecodeZString(Queue<byte> zBytes, IZMemory z_memory) { var sb = new StringBuilder(); int currentAlphabet = 0; int lockAlphabet = 0; char c, c2, c3; int abbrevAddr = 0; while (zBytes.Count > 0) { c = (char)zBytes.Dequeue(); switch ((int)c) { case 1: case 2: case 3: // Abbreviation in V2+ if (zBytes.Count == 0) // This is all we're getting. break; c2 = (char)zBytes.Dequeue(); abbrevAddr = z_memory.GetWord(z_memory.Header.AbbreviationTableLocation + (((((int)c) - 1) * 32 + ((int)c2)) * 2)); abbrevAddr *= 2; // Word address sb.Append(PrintZString(z_memory, abbrevAddr)); break; case 4: // Always a shift up if (currentAlphabet == 2) currentAlphabet = 0; else currentAlphabet++; break; case 5: // Always a shift down if (currentAlphabet == 0) currentAlphabet = 2; else if (currentAlphabet == 2) currentAlphabet = 1; else currentAlphabet = 0; break; case 6: // Literal output character if alphabet is P. if (currentAlphabet == 2) { if (zBytes.Count == 0) break; c2 = (char)zBytes.Dequeue(); if (zBytes.Count == 0) break; c3 = (char)zBytes.Dequeue(); int w = ((((int)c2 << 5) & 0x03e0) | ((int)c3 & 0x1f)); sb.Append((char)w); currentAlphabet = lockAlphabet; } else { sb.Append(Alpha[currentAlphabet][(int)c]); currentAlphabet = lockAlphabet; } break; default: sb.Append(Alpha[currentAlphabet][(int)c]); currentAlphabet = lockAlphabet; break; } } // We're done! return sb.ToString(); }
public InsertObj(IZMemory memory) : base((ushort)OpCodes.InsertObj, memory) { }
protected ZHeaderBase(IZMemory mem) { m_memory = mem; }
public GetPropLen(IZMemory memory) : base((ushort)OpCodes.GetPropLen, memory) { }
public Jg(IZMemory memory) : base((ushort)OpCodes.Jg, memory) { }
public BufferMode(IZMemory memory, IUserIo io) : base((ushort)OpCodes.BufferMode, memory) { _io = io; }
public Store(IZMemory memory) : base((ushort)OpCodes.Store, memory) { }
public Save(IZMemory memory, IFileIo io) : base(OpCodes.Save, memory, io) { }
public Pop(IZMemory memory) : base((ushort)OpCodes.Pop, memory) { }
public Div(IZMemory memory) : base((ushort)OpCodes.Div, memory) { }
public ZOperations(IUserIo userIo, IFileIo fileIo, IZMemory zMemory) { _zMemory = zMemory; _operations = new Operations(userIo, fileIo, _zMemory); _extendedOperations = new KindExtOperations(_operations, _zMemory); }
public OutputStream(IZMemory memory) : base((ushort)OpCodes.OutputStream, memory) { }
public Random(IZMemory memory) : base((ushort)OpCodes.Random, memory) { }
public LogShift(IZMemory memory) : base((ushort)KindExtOpCodes.LogShift, memory) { }
public Jin(IZMemory memory) : base((ushort)OpCodes.Jin, memory) { }
public string Read(int max, IZMemory memory) { throw new System.NotImplementedException(); }
public Sub(IZMemory memory) : base((ushort)OpCodes.Sub, memory) { }
public Operations(IUserIo io, IFileIo fileIo, IZMemory memory) { // OP2 _operations.Add(OpCodes.Je, new Je(memory)); _operations.Add(OpCodes.Jl, new Jl(memory)); _operations.Add(OpCodes.Jg, new Jg(memory)); _operations.Add(OpCodes.DecCheck, new DecCheck(memory)); _operations.Add(OpCodes.IncCheck, new IncCheck(memory)); _operations.Add(OpCodes.Jin, new Jin(memory)); _operations.Add(OpCodes.Test, new Test(memory)); _operations.Add(OpCodes.Or, new Or(memory)); _operations.Add(OpCodes.And, new And(memory)); _operations.Add(OpCodes.TestAttribute, new TestAttribute(memory)); _operations.Add(OpCodes.SetAttribute, new SetAttribute(memory)); _operations.Add(OpCodes.ClearAttribute, new ClearAttribute(memory)); _operations.Add(OpCodes.Store, new Store(memory)); _operations.Add(OpCodes.InsertObj, new InsertObj(memory)); _operations.Add(OpCodes.LoadW, new LoadW(memory)); _operations.Add(OpCodes.LoadB, new LoadB(memory)); _operations.Add(OpCodes.GetProp, new GetProp(memory)); _operations.Add(OpCodes.GetPropAddr, new GetPropAddr(memory)); _operations.Add(OpCodes.GetNextProp, new GetNextProp(memory)); _operations.Add(OpCodes.Add, new Add(memory)); _operations.Add(OpCodes.Sub, new Sub(memory)); _operations.Add(OpCodes.Mul, new Mul(memory)); _operations.Add(OpCodes.Div, new Div(memory)); _operations.Add(OpCodes.Mod, new Mod(memory)); _operations.Add(OpCodes.Call2S, new Call2S(memory)); _operations.Add(OpCodes.Call2N, new Call2N(memory)); _operations.Add(OpCodes.SetColor, new SetColor(memory, io)); // OP1 _operations.Add(OpCodes.Jz, new Jz(memory)); _operations.Add(OpCodes.GetSibling, new GetSibling(memory)); _operations.Add(OpCodes.GetChild, new GetChild(memory)); _operations.Add(OpCodes.GetParent, new GetParent(memory)); _operations.Add(OpCodes.GetPropLen, new GetPropLen(memory)); _operations.Add(OpCodes.Inc, new Inc(memory)); _operations.Add(OpCodes.Dec, new Dec(memory)); _operations.Add(OpCodes.PrintAddr, new PrintAddr(memory, io)); _operations.Add(OpCodes.Call1S, new Call1S(memory)); _operations.Add(OpCodes.RemoveObj, new RemoveObj(memory)); _operations.Add(OpCodes.PrintObj, new PrintObj(memory, io)); _operations.Add(OpCodes.Ret, new Ret(memory)); _operations.Add(OpCodes.Jump, new Jump(memory)); _operations.Add(OpCodes.PrintPAddr, new PrintPAddr(memory, io)); _operations.Add(OpCodes.Load, new Load(memory)); if (memory.Header.Version <= 4) { _operations.Add(OpCodes.Not, new Not(memory)); } else { _operations.Add(OpCodes.Call1N, new Call1N(memory)); } // OP0 _operations.Add(OpCodes.RTrue, new RTrue(memory)); _operations.Add(OpCodes.RFalse, new RFalse(memory)); _operations.Add(OpCodes.Print, new Print(memory, io)); _operations.Add(OpCodes.PrintRet, new PrintRet(memory, io, (RTrue)_operations[OpCodes.RTrue])); _operations.Add(OpCodes.Nop, new Nop(memory)); _operations.Add(OpCodes.Save, new Save(memory, fileIo)); _operations.Add(OpCodes.Restore, new Restore(memory, fileIo)); _operations.Add(OpCodes.Restart, new Restart(memory)); _operations.Add(OpCodes.RetPopped, new RetPopped(memory)); _operations.Add(OpCodes.Pop, new Pop(memory)); _operations.Add(OpCodes.Quit, new Quit(memory, io)); _operations.Add(OpCodes.NewLine, new Newline(memory, io)); _operations.Add(OpCodes.ShowStatus, new ShowStatus(memory, io)); _operations.Add(OpCodes.Verify, new Verify(memory)); _operations.Add(OpCodes.Piracy, new Piracy(memory)); // OPVAR _operations.Add(OpCodes.Call, new Call(memory)); _operations.Add(OpCodes.StoreB, new StoreB(memory)); _operations.Add(OpCodes.StoreW, new StoreW(memory)); _operations.Add(OpCodes.PutProp, new PutProp(memory)); _operations.Add(OpCodes.Read, new Read(memory, io)); _operations.Add(OpCodes.PrintChar, new PrintChar(memory, io)); _operations.Add(OpCodes.PrintNum, new PrintNum(memory, io)); _operations.Add(OpCodes.Random, new Random(memory)); _operations.Add(OpCodes.Push, new Push(memory)); _operations.Add(OpCodes.Pull, new Pull(memory)); _operations.Add(OpCodes.SplitWindow, new SplitWindow(memory, io)); _operations.Add(OpCodes.SetWindow, new SetWindow(memory, io)); _operations.Add(OpCodes.CallVs2, new CallVs2(memory)); _operations.Add(OpCodes.EraseWindow, new EraseWindow(memory, io)); _operations.Add(OpCodes.SetCursor, new SetCursor(memory, io)); _operations.Add(OpCodes.SetTextStyle, new SetTextStyle(memory, io)); _operations.Add(OpCodes.BufferMode, new BufferMode(memory, io)); _operations.Add(OpCodes.OutputStream, new OutputStream(memory)); _operations.Add(OpCodes.SoundEffect, new SoundEffect(memory, io)); _operations.Add(OpCodes.ReadChar, new ReadChar(memory, io)); _operations.Add(OpCodes.ScanTable, new ScanTable(memory)); _operations.Add(OpCodes.NotVar, new Not(memory)); _operations.Add(OpCodes.CallVn, new CallVn(memory)); _operations.Add(OpCodes.CallVn2, new CallVn2(memory)); _operations.Add(OpCodes.CopyTable, new CopyTable(memory)); _operations.Add(OpCodes.PrintTable, new PrintTable(memory, io)); _operations.Add(OpCodes.CheckArgCount, new CheckArgCount(memory)); }
public SetColor(IZMemory memory, IUserIo io) : base((ushort)OpCodes.SetColor, memory) { _io = io; }
internal static string PrintZString(IZMemory z_memory, int addr) { int tmp = 0; Queue<byte> zBytes = new Queue<byte>(); while ((tmp & 0x8000) == 0) { tmp = z_memory.GetWord(addr); addr += 2; zBytes.Enqueue((byte)((tmp >> 10) & 0x1f)); zBytes.Enqueue((byte)((tmp >> 5) & 0x1f)); zBytes.Enqueue((byte)(tmp & 0x1f)); } string ret = ZMachine.Common.ZText.DecodeZString(zBytes, z_memory); zBytes = null; return ret; }