public void Show(int index)
 {
     _originalMset = Communicator.Instance.Movesets[index];
     _index        = index;
     comboEffectData.ItemsSource = _originalMset.Effect.DataModifiers;
     comboMset.ItemsSource       = Communicator.Instance.Movesets;
     comboRef.ItemsSource        = _originalMset.AddressReferences;
     this.Title = "Edit Moveset - " + _originalMset.Name;
     base.Show();
 }
Exemple #2
0
        public void ReadBARFile(int offset)
        {
            if (PCSX2_RAM.ReadString(offset) == "BAR")
            {
                int headerCount          = PCSX2_RAM.ReadInteger(offset + 4);
                int StartOfHeaderEntries = offset + 16;
                int i = StartOfHeaderEntries;

                for (int j = 0; j < headerCount; j++)
                {
                    string EntryName = PCSX2_RAM.ReadString(i + 4);
                    if (EntryName == "DUMM")
                    {
                        _slotcounter++;
                        i += 16;
                        continue;
                    }
                    Console.WriteLine("BAR entry at " + i.ToString("X"));
                    WriteToLog("BAR entry at " + i.ToString("X"));
                    int AddressRefInRAM   = i + 8;
                    int barMovesetPointer = 0;

                    barMovesetPointer = PCSX2_RAM.ReadInteger(AddressRefInRAM);
                    //else
                    //    barMovesetPointer = AddressConverter.To10Offset(PCSX2_RAM.ReadInteger(AddressRefInRAM));
                    //Check if current moveset is a duplicate
                    //If yes, get moveset with same label and add current reference address
                    Moveset item = _movesets.FirstOrDefault(x => x.ANBAddress == barMovesetPointer) as Moveset;
                    if (item != null)
                    {
                        if (item.ANBAddress == barMovesetPointer)
                        {
                            item.AddressReferences.Add(AddressRefInRAM);
                        }
                        i += 16;
                        _slotcounter++;
                        continue;
                    }
                    Regex rgx    = new Regex("\\d{2}[A-Z]"); // 00A, 01A, 01B etc
                    Regex rgx2   = new Regex("[A-Z]\\d{3}"); //A000
                    Match match  = rgx.Match(EntryName);
                    Match match2 = rgx2.Match(EntryName);
                    if (match.Success || match2.Success)
                    {
                        Moveset m = new Moveset();
                        m.Name = EntryName;
                        m.AddressReferences.Add(AddressRefInRAM);
                        m.ANBAddress = barMovesetPointer;
                        m.SlotNumber = _slotcounter;
                        ReadMoveset(m);
                        i += 16;
                        _slotcounter++;
                    }
                    else
                    {
                        i += 16;
                        _slotcounter++;
                    }
                }
                //    string tempMsetString = string.Empty;
                //    string tempMsetString2 = string.Empty;

                //    //Reading the BAR file
                //    while (tempMsetString2 != "BAR")
                //    {
                //        Console.WriteLine("BAR entry at " + i.ToString("x8"));
                //        _slotcounter++;
                //        tempMsetString2 = PCSX2_RAM.ReadString(i);
                //        tempMsetString = PCSX2_RAM.ReadString(i + 4);
                //        if (tempMsetString == "DUMM")
                //        {
                //            i += 16;
                //            continue;
                //        }

                //        tempMsetString = tempMsetString.Replace("\0", string.Empty);
                //        Regex rgx = new Regex("\\d{2}[A-Z]"); // 00A, 01A, 01B etc
                //        Regex rgx2 = new Regex("[A-Z]\\d{3}"); //A000
                //        Match match = rgx.Match(tempMsetString);
                //        Match match2 = rgx2.Match(tempMsetString);
                //        if (match.Success || match2.Success)
                //        {

                //        }
                //        else
                //            i += 16;
                //    }

                //}
                //else
                //{
                //    int newOffset = AddressConverter.To2Offset(
                //                            PCSX2_RAM.SearchBytes(
                //                             BitConverter.GetBytes(0x0000 + _ucm), offset))+16;

                //    ReadBARFile(newOffset);
                //}
            }
        }
Exemple #3
0
        public void ReadMoveset(Moveset mset)
        {
            Console.WriteLine("ReadMoveset Method - " + mset.ANBAddress.ToString("x8") + " - " + mset.Name);
            WriteToLog("ReadMoveset Method - " + mset.ANBAddress.ToString("x8") + " - " + mset.Name);
            int startBarOff = 0;

            startBarOff = AddressConverter.To2Offset(mset.ANBAddress + 20);

            MovesetAnimation manim = new MovesetAnimation();

            manim.Address  = startBarOff + 4;
            manim.Value    = PCSX2_RAM.ReadInteger(manim.Address);
            mset.Animation = manim;

            MovesetEffect meffect = new MovesetEffect();

            meffect.Address = startBarOff + 20;
            meffect.Value   = PCSX2_RAM.ReadInteger(meffect.Address);

            meffect.BoneStructure         = new MovesetEffectBoneStructure();
            meffect.BoneStructure.Address = startBarOff + 32;
            meffect.BoneStructure.Value   = PCSX2_RAM.ReadInteger(meffect.BoneStructure.Address);

            //Wth can effects have a 0 value??
            if (meffect.Value != 0)
            {
                //Read Effect Data Modifiers (name according to Xaddgx)
                List <MovesetEffectDataModifierRaw> modifiers = new List <MovesetEffectDataModifierRaw>();
                int    startOfDataModifiers = AddressConverter.To2Offset(meffect.Value);
                string tempDataMod          = string.Empty;
                int    countertemp          = 1;
                while (tempDataMod != "BAR")
                {
                    Console.WriteLine("Reading effect data modifier - " + startOfDataModifiers.ToString("X8"));
                    WriteToLog("Reading effect data modifier - " + startOfDataModifiers.ToString("X8"));
                    MovesetEffectDataModifierRaw mod = new MovesetEffectDataModifierRaw();
                    mod.Address       = startOfDataModifiers;
                    mod.Value         = PCSX2_RAM.ReadInteger(AddressConverter.To2Offset(startOfDataModifiers));
                    mod.DisplayNumber = countertemp;
                    modifiers.Add(mod);

                    startOfDataModifiers += 4;
                    countertemp++;
                    tempDataMod = PCSX2_RAM.ReadString(startOfDataModifiers);
                }

                meffect.DataModifiers = modifiers;
            }

            //Parsing that into Effect Casters (name according to SoraikoSan)
            //if (meffect.Value != 0)
            //{
            //    ECasterList eclist = new ECasterList();
            //    eclist.Children = new List<ECaster>();
            //    var start = AddressConverter.To2Offset(meffect.Value);
            //    eclist.Header = PCSX2_RAM.ReadBytes(start, 4);
            //    eclist.Group1Entries = Convert.ToInt32(eclist.Header[0]);
            //    eclist.Group2Entries = Convert.ToInt32(eclist.Header[1]);
            //    start += 4;

            //    for(int i = 0; i<eclist.Group1Entries; i++)
            //    {
            //        ECaster ec = new ECaster();
            //        ec.StartAddress = start;
            //        ec.Group = ECasterGroup.Group1;
            //        ec.StartAnimationFrame = PCSX2_RAM.ReadShort(start);
            //        ec.EndAnimationFrame = PCSX2_RAM.ReadShort(start + 2);
            //        ec.EffectType = PCSX2_RAM.ReadBytes(start + 4, 1)[0];
            //        Group1Effects eff = (Group1Effects)ec.EffectType;
            //        var addbytes = PCSX2_RAM.ReadBytes(start + 5, 1)[0];
            //        if (addbytes > 0)
            //        {
            //            ec.AdditionalBytes = PCSX2_RAM.ReadBytes(start+6, addbytes*2);
            //        }
            //        ec.Length = 6 + (addbytes * 2);

            //        eclist.Children.Add(ec);

            //        start += ec.Length;
            //    }

            //    for (int j = 0; j<eclist.Group2Entries; j++)
            //    {
            //        ECaster ec = new ECaster();
            //        ec.StartAddress = start;
            //        ec.Group = ECasterGroup.Group2;
            //        ec.StartAnimationFrame = PCSX2_RAM.ReadShort(start);
            //        ec.EffectType = PCSX2_RAM.ReadBytes(start + 2, 1)[0];
            //        Group2Effects ec2 = (Group2Effects)ec.EffectType;
            //        var addbytes = PCSX2_RAM.ReadBytes(start + 3, 1)[0];
            //        if (addbytes > 0)
            //        {
            //            ec.AdditionalBytes = PCSX2_RAM.ReadBytes(start + 4, addbytes * 2);
            //        }

            //        ec.Length = 4 + (addbytes * 2);
            //        eclist.Children.Add(ec);

            //        start += ec.Length;
            //    }
            //    meffect.EffectCasterList = eclist;
            //}
            mset.Effect = meffect;

            _movesets.Add(mset);
        }
        private void comboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            //dirty solution
            Moveset item = comboBox.SelectedValue as Moveset;

            //Header info
            //txtSlotNum.Text = item.SlotNumber.ToString();
            txtAnbAddress.Text = item.ANBAddress.ToString("X8");
            lstRefBAR.Items.Clear();
            foreach (var ic in item.AddressReferences)
            {
                lstRefBAR.Items.Add(ic.ToString("X8"));
            }

            //Animation
            txtAnimAddr.Text  = item.Animation.Address.ToString("X8");
            txtAnimValue.Text = item.Animation.Value.ToString("X8");

            //Effect
            txtEffectAddr.Text  = item.Effect.Address.ToString("X8");
            txtEffectValue.Text = item.Effect.Value.ToString("X8");

            //Bone Structure
            txtBoneAddr.Text  = item.Effect.BoneStructure.Address.ToString("X8");
            txtBoneValue.Text = item.Effect.BoneStructure.Value.ToString("X8");

            gridDataMods.Items.Clear();
            //gridECgrp1.Items.Clear();
            //gridECgrp2.Items.Clear();
            if (item.Effect.DataModifiers != null)
            {
                //Effect Data Mods
                for (int i = 0; i < item.Effect.DataModifiers.Count; i++)
                {
                    gridDataMods.Items.Add(item.Effect.DataModifiers[i]);
                }

                //ECaster
                //for (int i=0; i<item.Effect.EffectCasterList.Children.Count; i++)
                //{
                //    if (item.Effect.EffectCasterList.Children[i].Group == ECasterGroup.Group1)
                //    {
                //        gridECgrp1.Items.Add(item.Effect.EffectCasterList.Children[i]);
                //    }
                //    else
                //    {
                //        gridECgrp2.Items.Add(item.Effect.EffectCasterList.Children[i]);
                //    }
                //}
            }
            ObservableCollection <Change> list;

            Communicator.Instance.Changelog.ListOfChanges.TryGetValue(comboBox.SelectedIndex, out list);
            if (list != null)
            {
                lstChanges.ItemsSource = list;
            }
            else
            {
                lstChanges.ItemsSource = null;
            }
        }
Exemple #5
0
        //public int MovesetCount
        //{
        //    get
        //    {
        //        return _msetcount;
        //    }
        //    set
        //    {
        //        _msetcount = value;
        //    }
        //}

        public CodeEntries ConvertToCodes()
        {
            CodeEntries en = new CodeEntries();

            foreach (KeyValuePair <int, ObservableCollection <Change> > kvp in _listOfChanges)
            {
                Moveset m = Communicator.Instance.Movesets[kvp.Key];
                foreach (var cha in kvp.Value)
                {
                    if (cha is WholeMovesetChange)
                    {
                        WholeMovesetChange wmc = (WholeMovesetChange)cha;

                        if (wmc.TypeOfRef == TypeOfWhole.eAll)
                        {
                            int writeTo;
                            if (wmc.NewMset == -1)
                            {
                                writeTo = 0;
                            }
                            else
                            {
                                writeTo = Communicator.Instance.Movesets[wmc.NewMset].ANBAddress;
                            }
                            foreach (var item in m.AddressReferences)
                            {
                                en.Add(item, writeTo);
                            }
                        }
                        else
                        {
                            int writeTo;
                            if (wmc.NewMset == -1)
                            {
                                writeTo = 0;
                            }
                            else
                            {
                                writeTo = Communicator.Instance.Movesets[wmc.NewMset].ANBAddress;
                            }

                            en.Add(wmc.SingleRef, writeTo);
                        }
                        //Moveset other = Communicator.Instance.Movesets[wmc.NewMset];
                        //foreach(var item in m.AddressReferences)
                        //{
                        //    en.Add(item, other.ANBAddress);
                        //}
                    }
                    else if (cha is AnimEffectBoneChange)
                    {
                        AnimEffectBoneChange aebc = (AnimEffectBoneChange)cha;
                        Moveset oth = Communicator.Instance.Movesets[aebc.FromMset];
                        if (aebc.type == TypeOfChange.eAnimation)
                        {
                            en.Add(m.Animation.Address, oth.Animation.Value);
                        }
                        else if (aebc.type == TypeOfChange.eEffect)
                        {
                            en.Add(m.Effect.Address, oth.Effect.Value);
                        }
                        else if (aebc.type == TypeOfChange.eBoneStructure)
                        {
                            en.Add(m.Effect.BoneStructure.Address, oth.Effect.BoneStructure.Value);
                        }
                    }
                    else if (cha is EffectDataChange)
                    {
                        EffectDataChange edc = (EffectDataChange)cha;
                        en.Add(m.Effect.DataModifiers[edc.LineNumber].Address, edc.NewValue);
                    }
                }
            }
            return(en);
        }