Example #1
0
 protected virtual void OP_QUIT(IZInstruction inst)
 {
     Stop();  // Probably need a QUIT handler, because this is insufficient
 }
Example #2
0
 protected virtual void OP_TEST_ATTR(IZInstruction inst)
 {
     Branch(z_objtable.hasAttribute(inst.Operands[0], inst.Operands[1]), inst);
 }
Example #3
0
 protected virtual void OP_VERIFY(IZInstruction inst)
 {
     throw new NotImplementedException("Opcode not yet coded.");
 }
Example #4
0
 protected virtual void OP_STOREB(IZInstruction inst)
 {
     z_memory.PutByte(inst.Operands[0] + inst.Operands[1], (byte)(inst.Operands[2] & 0xff));
 }
Example #5
0
 protected virtual void OP_SUB(IZInstruction inst)
 {
     z_memory.PutVariable(inst.Result, (short)(inst.Operands[0] - inst.Operands[1]));
 }
Example #6
0
 protected virtual void OP_SOUND_EFFECT(IZInstruction inst)
 {
     throw new NotImplementedException("Opcode OP_SOUND_EFFECT is not implemented");
 }
Example #7
0
        protected virtual void OP_SREAD(IZInstruction inst)
        {
            string input = z_io.ReadString(null);

            if (string.IsNullOrEmpty(input))
                Stop();
            else
                ParseInput(input, inst);
        }
Example #8
0
 protected virtual void OP_RESTORE_UNDO(IZInstruction inst)
 {
     throw new NotImplementedException("Opcode OP_RESTORE_UNDO is not implemented");
 }
Example #9
0
 protected virtual void OP_RET(IZInstruction inst)
 {
     Return(inst.Operands[0]);
 }
Example #10
0
        protected virtual void OP_RESTART(IZInstruction inst)
        {
            Stop();

            if (OnRestart != null)
                OnRestart();
            else
                z_io.Print("\n*** Restart not currently handled ***\n");
        }
Example #11
0
 protected virtual void OP_RESTORE(IZInstruction inst)
 {
     if (OnRestore != null)
         OnRestore();
     else
         z_io.Print("\n*** Restore not currently handled ***\n");
 }
Example #12
0
 protected virtual void OP_REMOVE_OBJ(IZInstruction inst)
 {
     if (z_memory.Header.VersionNumber < 4)
         z_objtable.removeObject(z_objtable.getParent((byte)inst.Operands[0]), (byte)inst.Operands[0]);
     else
         z_objtable.removeObject(z_objtable.getParent(inst.Operands[0]), inst.Operands[0]);
 }
Example #13
0
        protected virtual void OP_READ_CHAR(IZInstruction inst)
        {
            int? time = null;

            //// TODO: Need to handle time/result
            //if (inst.Operands[1] > 0)
            //    time = inst.Operands[1];

            char c = z_io.ReadChar(time);

            z_memory.PutVariable(inst.Result, (short)c);
        }
Example #14
0
        protected virtual void OP_RANDOM(IZInstruction inst)
        {
            short rnd = 0;

            if (inst.Operands[0] < 0)
            {
                z_random = new Random(inst.Operands[0]);
            }

            else if (inst.Operands[0] == 0)
            {
                z_random = new Random();
            }

            else
            {
                rnd = (short)z_random.Next(1, inst.Operands[0]);
            }

            z_memory.PutVariable(inst.Result, rnd);
        }
Example #15
0
 protected virtual void OP_SET_CURSOR(IZInstruction inst)
 {
     z_io.SetCursor((byte)inst.Operands[0], (byte)inst.Operands[1]);
 }
Example #16
0
 protected virtual void OP_RET_POPPED(IZInstruction inst)
 {
     Return(z_memory.GetVariable(0));
 }
Example #17
0
 protected virtual void OP_SET_TEXT_STYLE(IZInstruction inst)
 {
     z_io.SetStyle(inst.Operands[0]);
 }
Example #18
0
 protected virtual void OP_RFALSE(IZInstruction inst)
 {
     Return(0);
 }
Example #19
0
 protected virtual void OP_SPLIT_WINDOW(IZInstruction inst)
 {
     z_io.SplitWindow(inst.Operands[0]);
 }
Example #20
0
 protected virtual void OP_RTRUE(IZInstruction inst)
 {
     Return(1);
 }
Example #21
0
 protected virtual void OP_STORE(IZInstruction inst)
 {
     z_memory.PutVariable(inst.Operands[0], inst.Operands[1]);
 }
Example #22
0
 protected virtual void OP_SAVE(IZInstruction inst)
 {
     if (OnSave != null)
         OnSave();
     else
         z_io.Print("\n*** Save not currently handled ***\n");
 }
Example #23
0
 protected virtual void OP_STOREW(IZInstruction inst)
 {
     z_memory.PutWord(inst.Operands[0] + (2 * inst.Operands[1]), inst.Operands[2]);
 }
Example #24
0
 protected virtual void OP_SAVE_UNDO(IZInstruction inst)
 {
 }
Example #25
0
 protected virtual void OP_TEST(IZInstruction inst)
 {
     Branch((inst.Operands[0] & inst.Operands[1]) == inst.Operands[1], inst);
 }
Example #26
0
 protected virtual void OP_SET_ATTR(IZInstruction inst)
 {
     z_objtable.setAttribute(inst.Operands[0], inst.Operands[1]);
 }
Example #27
0
 protected virtual void OP_TOKENIZE(IZInstruction inst)
 {
     throw new NotImplementedException("Opcode OP_TOKENIZE is not implemented");
 }
Example #28
0
 protected virtual void OP_SET_COLOR(IZInstruction inst)
 {
     z_io.SetColor(inst.Operands[0], inst.Operands[1]);
 }
Example #29
0
        protected virtual void ParseInput(string input, IZInstruction inst)
        {
            #if (DEBUG)
            System.Diagnostics.Debug.WriteLine("SREAD: " + input);
            #endif

            int maxchars = z_memory.GetByte(inst.Operands[0]);
            input = input.ToLower();
            if (input.Length > maxchars)
                input = input.Substring(0, maxchars);

            short termlen = (short)input.Length;

            for (int i = 0; i < input.Length; i++)
            {
                z_memory.PutByte(inst.Operands[0] + i + 1, (byte)input[i]);
            }
            z_memory.PutByte(inst.Operands[0] + input.Length + 2, 0);

            string splitters = z_dict.GetWordSeparatorsAsString();
            for (int i = 0; i < splitters.Length; i++)
            {
                input = input.Replace(splitters[i].ToString(), String.Format(" {0} ", splitters[i]));
            }
            string[] split = input.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

            int maxwords = z_memory.GetByte(inst.Operands[1]);

            if (split.Length < maxwords)
            {
                maxwords = split.Length;
            }

            z_memory.PutByte(inst.Operands[1] + 1, (byte)maxwords);

            for (int i = 0; i < maxwords; i++)
            {
                int entryAddr = z_dict.GetAddressForEntry(split[i]);
                // addr=2bytes, numLetters=1byte, textBuffPos=1byte

                z_memory.PutWord(inst.Operands[1] + (4 * i) + 2, (short)entryAddr);
                z_memory.PutByte(inst.Operands[1] + (4 * i) + 4, (byte)split[i].Length);
                z_memory.PutByte(inst.Operands[1] + (4 * i) + 5, (byte)(input.IndexOf(split[i]) + 1)); //not totally correct
            }

            if (z_memory.Header.VersionNumber >= 5)
                z_memory.PutVariable(inst.Result, termlen);

            //    putVariable(curResult, termChar);

            //
            //String s;
            //StringBuffer sb;
            //int termChar;
            //int len;
            //int curaddr;
            //int baddr1, baddr2;
            //int time = 0, raddr = 0;

            //baddr1 = vops[0];
            //baddr2 = vops[1];
            //if (numvops > 2)
            //{
            //    time = vops[2];
            //    raddr = vops[3];
            //}

            //// Flush the I/O card's output buffer
            //ioCard.outputFlush();

            //// This implies a SHOW_STATUS in V1-3.
            //if (version < 4)
            //    zop_show_status();

            //// Read a line of text
            //sb = new StringBuffer();
            //if ((time > 0) && (raddr > 0))
            //{ // A timed READ
            //    while (true)
            //    { // Ick.
            //        termChar = ioCard.readLine(sb, time);
            //        if (termChar == -1)
            //        { // A timeout
            //            // ioCard.outputFlush();
            //            // did_newline = false;
            //            for (int i = 0; i < sb.length(); i++)
            //                ioCard.printString("\b");
            //            int rc = interrupt(raddr);
            //            if (rc == 0)
            //            {
            //                // if (did_newline) {
            //                // ioCard.printString("\n" + sb.toString());
            //                // ioCard.outputFlush();
            //                // }
            //                ioCard.printString(sb.toString());
            //                ioCard.outputFlush();
            //                continue;
            //            }
            //            else
            //            {
            //                ioCard.outputFlush();
            //                sb = new StringBuffer();
            //                termChar = 0;
            //                break;
            //            }
            //        }
            //        else // Not a timeout
            //            break;
            //    }
            //}
            //else
            //    termChar = ioCard.readLine(sb, 0);
            //s = sb.toString();

            // If V1-4, just store the line. If V5+, possibly
            // store it after other characters in the buffer.
            //if (version <= 4)
            //{
            //    curaddr = baddr1 + 1;
            //    len = s.length();
            //    for (int i = 0; i < len; i++)
            //    {
            //        memory.putByte(curaddr, Character.toLowerCase(s.charAt(i)));
            //        curaddr++;
            //    }
            //    memory.putByte(curaddr, 0);
            //}
            //else
            //{
            //    int nchars = memory.fetchByte(baddr1 + 1);
            //    curaddr = baddr1 + 2 + nchars;
            //    len = s.length();
            //    for (int i = 0; i < len; i++)
            //    {
            //        memory.putByte(curaddr, Character.toLowerCase(s.charAt(i)));
            //        curaddr++;
            //    }
            //    memory.putByte(baddr1 + 1, (nchars + len));
            //}

            //// Tokenize input
            //if (baddr2 != 0)
            //{
            //    vops[0] = baddr1;
            //    vops[1] = baddr2;
            //    numvops = 2;
            //    zop_tokenise();
            //}

            //// If V5+, store result
            //if (version >= 5)
            //    putVariable(curResult, termChar);
        }
Example #30
0
 protected virtual void OP_PUT_PROP(IZInstruction inst)
 {
     z_objtable.putProperty(inst.Operands[0], inst.Operands[1], inst.Operands[2]);
 }