Пример #1
0
        public string[] GetAnimCode(SpellCommands commands)
        {
            List <string> result = new List <string>();

            result.Add("Constructor");
            result.AddRange(GetAnimCode(GetASM_Constructor(), commands));
            result.Add("");
            result.Add("LoopRoutine");
            result.AddRange(GetAnimCode(GetASM_LoopRoutine(), commands));
            result.Add("");
            result.Add("AnimLoading");
            result.AddRange(GetAnimCode(GetASM_AnimLoading(), commands));

            return(result.ToArray());
        }
Пример #2
0
        List <string> GetAnimCode(ASM.Instruction[] routine, SpellCommands commands)
        {
            routine = GetCleanASM(routine);

            int           count  = 1;
            int           indent = 0;
            string        command;
            List <string> result = new List <string>();
            List <Tuple <Pointer, string> > labels = new List <Tuple <Pointer, string> >();

            for (int i = 0; i < routine.Length; i++)
            {
                command = commands.Get(routine, ref i);
                while (labels.Count > 0 && routine[i].Address >= labels[0].Item1)
                {
                    result.Add(labels[0].Item2);
                    labels.RemoveAt(0);
                }
                if (command == "}")
                {
                    indent--;
                }
                if (command != null)
                {
                    if (command.StartsWith("goto_"))
                    {
                        Pointer address = Util.StringToAddress(command.Substring(command.IndexOf('(') + 1, 8));
                        string  label   = (address == routine[routine.Length - 3].Address) ? "return" : "label_" + count;
                        int     index   = 0;
                        while (index < labels.Count && labels[index].Item1 <= address)
                        {
                            index++;
                        }
                        if (labels.Count == 0)
                        {
                            count++;
                            labels.Add(Tuple.Create(address, label));
                            command = command.Substring(5, command.IndexOf('(') - 5) + ' ' + label;
                        }
                        else if (index == 0)
                        {
                            count++;
                            labels.Insert(0, Tuple.Create(address, label));
                            command = command.Substring(5, command.IndexOf('(') - 5) + ' ' + label;
                        }
                        else if (labels[index - 1].Item1 == address)
                        {
                            command = command.Substring(5, command.IndexOf('(') - 5) + ' ' + labels[index - 1].Item2;
                        }
                        else
                        {
                            count++;
                            labels.Insert(index, Tuple.Create(address, label));
                            command = command.Substring(5, command.IndexOf('(') - 5) + ' ' + label;
                        }
                    }
                    result.Add(new string(' ', indent * 4) + command);
                }
                else
                {
                    result.Add(new string(' ', indent * 4) + routine[i].Code);
                }
                if (command == "{")
                {
                    indent++;
                }
            }
            return(result);
        }