示例#1
0
        public ScriptInstruction(Script script, long offset, BinaryReader reader, ScriptOpcode opcode)
            : this(script, offset, opcode)
        {
            string operands;

            if (!KnownOpcodes.TryGetValue(opcode, out operands))
            {
                return;
            }

            for (int index = 0; index < operands.Length; index++)
            {
                if (!ReadOperand(reader, operands, ref index, (ScriptArgument)operands[index]))
                {
                    break;
                }
            }
        }
示例#2
0
        private void LoadOpcodes(EncogFileSection section)
        {
            bool first = true;

            foreach (string line in section.Lines)
            {
                if (!first)
                {
                    IList <string> cols       = EncogFileSection.SplitColumns(line);
                    string         name       = cols[0];
                    int            childCount = int.Parse(cols[1]);
                    var            opcode     = new ScriptOpcode(name, childCount);
                    _script.Opcodes.Add(opcode);
                }
                else
                {
                    first = false;
                }
            }
        }
示例#3
0
 private void btnTextToList_Click(object sender, EventArgs e)
 {
     try
     {
         var code = new ScriptOpcode((byte)0, textOpcode.Text + "(" + textParams.Text + ")");
         if (code.param.Count > 12)
         {
             throw new Exception();
         }
         paramsList.Clear();
         foreach (ParamType t in code.param)
         {
             paramsList.Items.Add((t.export ? "@" : "") + (t.nullable ? "!" : "") + t.type);
         }
     }
     catch (Exception)
     {
         MessageBox.Show("格式错误!\n参数类型不区分大小写,使用英文','分隔,最多12个参数。");
         return;
     }
 }
示例#4
0
        public static ScriptInstruction Read(Script script, BinaryReader reader)
        {
            long          offset      = reader.BaseStream.Position;
            ScriptOperand opcodeToken = new ScriptOperand(reader, ScriptArgument.Opcode);

            if (!opcodeToken.IsOpcode)
            {
                return(new Invalid(script, offset, opcodeToken));
            }

            ScriptOpcode opcode = opcodeToken.GetOpcode();

            switch (opcode)
            {
            case ScriptOpcode.Call: return(new Call(script, offset, reader));

            case ScriptOpcode.Switch: return(new Switch(script, offset, reader));

            case ScriptOpcode.If: return(new If(script, offset, reader));

            default: return(new ScriptInstruction(script, offset, reader, opcode));
            }
        }
示例#5
0
        private ScriptOpcode listToOpcode()
        {
            var opcode = new ScriptOpcode((byte)opcodeEntity.CurrentOpcodeIndex);

            opcode.opcode = textOpcode.Text;
            foreach (ListViewItem item in paramsList.Items)
            {
                string str = item.Text;
                bool   nullable = false, export = false;
                if (str[0] == '@')
                {
                    str    = str.Remove(0, 1);
                    export = true;
                }
                if (str[0] == '!')
                {
                    str      = str.Remove(0, 1);
                    nullable = true;
                }
                DataType t = (DataType)Enum.Parse(typeof(DataType), str, true);
                opcode.param.Add(new ParamType(t, nullable, export));
            }
            return(opcode);
        }
示例#6
0
 protected ScriptInstruction(Script script, long offset, ScriptOpcode opcode)
 {
     Script  = script;
     Address = offset + Script.AddressOffset;
     Opcode  = opcode;
 }
 protected ScriptInstruction(Script script, long offset, ScriptOpcode opcode)
 {
     Script = script;
     Address = offset + Script.AddressOffset;
     Opcode = opcode;
 }
        public ScriptInstruction(Script script, long offset, BinaryReader reader, ScriptOpcode opcode)
            : this(script, offset, opcode)
        {
            string operands;

            if (!KnownOpcodes.TryGetValue(opcode, out operands))
                return;

            for (int index = 0; index < operands.Length; index++)
                if (!ReadOperand(reader, operands, ref index, (ScriptArgument)operands[index]))
                    break;
        }
示例#9
0
 /// <summary>
 /// 重新读取当前codeline 临时
 /// </summary>
 public void ReReadCodeLine(ScriptOpcode opcode)
 {
     reader.ReadScript_Seek(CurrentScript.Position, SeekOrigin.Begin);
     CurrentCodeLine = reader.ReadScript_StepReadByOpcode(opcode);
 }
示例#10
0
 public void SetOpcodeDict(ScriptOpcode opcode)
 {
     bytesToOpcodeDict[opcode.opcode_byte] = opcode;
 }
示例#11
0
 public void SetOpcodeDict(byte opcode_byte, string text)
 {
     bytesToOpcodeDict[opcode_byte] = new ScriptOpcode(opcode_byte, text);
 }
示例#12
0
 public void SetOpcodeDict(byte opcode_byte, string opcode, params ParamType[] values)
 {
     bytesToOpcodeDict[opcode_byte] = new ScriptOpcode(opcode_byte, opcode, values);
 }
示例#13
0
        private static void ParseOpcode(ScriptOpcode opcode)
        {
            int stack1 = 0;
            int stack2 = 0;

            //int stack3 = 0;
            switch (opcode.opcode)
            {
            case JSMopcodes.NOP:
                return;

            case JSMopcodes.LBL:
                return;

            case JSMopcodes.SETMODEL:     //TODO
                Console.WriteLine("TODO: ENTITY SUBSYSTEM");
                return;

            case JSMopcodes.PSHN_L:
                Stack.Add(opcode.parameter);
                return;

            case JSMopcodes.BASEANIME:     //TODO
                if (Stack.Count > 0)
                {
                    stack1 = POPstack();
                }
                if (Stack.Count > 0)
                {
                    stack2 = POPstack();
                }
                Console.WriteLine("TODO: ENTITY SUBSYSTEM; ANIMATION");
                return;

            case JSMopcodes.SETPC:     //TODO
                stack1 = POPstack();
                Console.WriteLine("TODO: PARTY SUBSYSTEM");
                return;

            case JSMopcodes.HIDE:     //TODO
                Console.WriteLine("TODO: ENTITY SUBSYSTEM");
                return;

            case JSMopcodes.UCOFF:     //TODO
                Console.WriteLine("TODO: I/O SUBSYSTEM");
                return;

            case JSMopcodes.CLEAR:     //TODO
                Console.WriteLine("TODO: CLEAR()");
                return;

            case JSMopcodes.POPM_B:
                if (Stack.Count > 0)
                {
                    stack1 = POPstack();
                }
                if (stack1 < Memory.FieldHolder.FieldMemory.Length)                  // had one come out of range.
                {
                    Memory.FieldHolder.FieldMemory[stack1] = (byte)opcode.parameter; //stack was count 0 something wrong here?
                }
                return;

            case JSMopcodes.POPM_W:
                if (Stack.Count > 0)
                {
                    stack1 = POPstack();
                }
                if (stack1 < Memory.FieldHolder.FieldMemory.Length)
                {
                    Memory.FieldHolder.FieldMemory[stack1] = (ushort)opcode.parameter;
                }
                return;

            case JSMopcodes.BATTLEOFF:     //TODO
                return;

            case JSMopcodes.MAPFADEOFF:     //TODO
                return;

            case JSMopcodes.ADDMEMBER:     //todo
                return;

            case JSMopcodes.ADDPARTY:     //todo
                return;

            case JSMopcodes.SETBATTLEMUSIC:
                Memory.SetBattleMusic = POPstack();
                return;

            case JSMopcodes.CAL:     //todo
                if (Stack.Count > 0)
                {
                    stack1 = POPstack();
                }
                if (Stack.Count > 0)
                {
                    stack2 = POPstack();
                }
                return;

            case JSMopcodes.MOVIEREADY:     //todo
                if (Stack.Count > 0)
                {
                    stack1 = POPstack();
                }
                if (Stack.Count > 0)
                {
                    stack2 = POPstack();
                }
                return;

            case JSMopcodes.MOVIE:     //todo
                return;

            case JSMopcodes.MOVIESYNC:     //todo
                return;

            case JSMopcodes.MAPJUMPO:     //todo
                if (Stack.Count > 0)
                {
                    stack2 = POPstack();     //walkmesh id
                }
                if (Stack.Count > 0)
                {
                    stack1 = POPstack();     //field map id
                    Memory.FieldHolder.FieldID = (ushort)stack1;
                }
                ResetField();
                //todo
                return;
            }
        }