public void Execute() { foreach (var item in _entries) { PCSX2_RAM.WriteInteger(item.Address, item.Value); } }
private object ReadByType(int address, Type t) { if (t == typeof(int)) { return(PCSX2_RAM.ReadInteger(address)); } else if (t == typeof(short)) { return(PCSX2_RAM.ReadShort(address)); } else if (t == typeof(string)) { return(PCSX2_RAM.ReadString(address)); } else if (t == typeof(byte[])) { return(PCSX2_RAM.ReadBytes(address, 4)); } else if (t == typeof(uint)) { return(PCSX2_RAM.ReadUInteger(address)); } else { return(PCSX2_RAM.ReadBytes(address, 4)); } }
public bool IsBARPointer(int offset) { if (PCSX2_RAM.ReadString(offset) == "BAR") { return(true); } return(false); }
public void Execute() { foreach (var item in _entries) { var newaddr = AddressConverter.To2Offset(item.Address); PCSX2_RAM.WriteInteger(newaddr, item.Value); } }
public static RoomInformation ReadRoomInforation() { RoomInformation r = new RoomInformation(); r.WorldNumber = PCSX2_RAM.ReadBytes(IngameConstants.WORLD_PTR, 1)[0]; r.RoomNumber = PCSX2_RAM.ReadShort(IngameConstants.ROOM_PTR); r.EventNumberMain = PCSX2_RAM.ReadShort(IngameConstants.EVENT1_PTR); return(r); }
public void RunTrigger(Trigger t, RoomInformation r) { if (t.IsTriggered(r)) { if (t.StopWhenMapIsLoaded) { if (PCSX2_RAM.IsRoomWithPlayerLoaded()) { return; } } //Console.WriteLine("Executing trigger - " + t.RoomInfo.ToString()); t.CodeEntries.Execute(); } }
public MainWindow() { InitializeComponent(); if (PCSX2_RAM.SeekPCSX2()) { lblStatusPCSX2.Content = "PCSX2 found!"; } else { lblStatusPCSX2.Content = "PCSX2 NOT found!"; } DataQuery.Instance.AllTriggers.CollectionChanged += AllTriggers_CollectionChanged; TreeViewItem groups = new TreeViewItem(); groups.Expanded += Groups_Expanded; groups.Collapsed += Groups_Collapsed; }
public void SearchHeartBlock(int offset) { int HeartBlock = 0; int barPointer = 0; HeartBlock = AddressConverter.To2Offset( PCSX2_RAM.SearchBytes( BitConverter.GetBytes(0x0000 + _ucm), offset)); Console.WriteLine("Found possible HeartBlock at " + HeartBlock.ToString("X8")); WriteToLog("Found possible HeartBlock at " + HeartBlock.ToString("X8")); barPointer = AddressConverter.To2Offset(PCSX2_RAM.ReadInteger(HeartBlock + 16)); if (IsBARPointer(barPointer)) { Console.WriteLine("BAR pointer at " + barPointer.ToString("X8")); WriteToLog("BAR pointer at " + barPointer.ToString("X8")); ReadBARFile(barPointer); } else { SearchHeartBlock(HeartBlock + 4); } }
private void WriteByType(int address, object value, Type t) { if (t == typeof(int)) { PCSX2_RAM.WriteInteger(address, Convert.ToInt32(value)); } else if (t == typeof(short)) { PCSX2_RAM.WriteShort(address, Convert.ToInt16(value)); } else if (t == typeof(byte[])) { PCSX2_RAM.WriteBytes(address, (byte[])value); } else if (t == typeof(uint)) { PCSX2_RAM.WriteUInteger(address, Convert.ToUInt32(value)); } else { PCSX2_RAM.WriteBytes(address, (byte[])value); } }
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); //} } }
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); }
public MainWindow() { InitializeComponent(); PCSX2_RAM.SeekPCSX2(); }
public void ScanAI() { List <AIEntry> temp_entries = new List <AIEntry>(); int found = AddressConverter.To2Offset( PCSX2_RAM.SearchBytes( BitConverter.GetBytes(0x0000 + _ucm))) + 8; int jumpto_addr = AddressConverter.To2Offset(PCSX2_RAM.ReadInteger(found)); int aientries = AddressConverter.To2Offset(PCSX2_RAM.ReadInteger(jumpto_addr + 72)); //Start reverse parsing int CounterZeroBytes = 0; bool bFoundFirstReverseChar = false; bool bExecute = true; bool bInAttack = false; bool bStopAttack = false; //string temp = string.Empty; byte prev = 0x00; AIEntry temp = new AIEntry(); int i = aientries; while (bExecute) { Console.WriteLine("Reading address " + i.ToString("X")); byte current = PCSX2_RAM.ReadBytes(i, 1)[0]; if (!IsAllowedAsciiByte(prev) && IsAllowedAsciiByte(current)) { CounterZeroBytes = 0; bStopAttack = false; bInAttack = true; //Maybe new AI entry? temp = new AIEntry(); //this is the address of the last character //afterwards, call (Address - Length-1) to get real start temp.Address = i; } else if (IsAllowedAsciiByte(prev) && !IsAllowedAsciiByte(current)) { //Valid AI entry ended, separator //set flag CounterZeroBytes++; bStopAttack = true; bInAttack = false; } else if (!IsAllowedAsciiByte(current) || (!IsAllowedAsciiByte(prev) && !IsAllowedAsciiByte(current))) { //After jumping to end of AI list, 0x00 or other invalid bytes. //Also trying to figure out if we fully parsed the list, //b/c before AI list are 0x00 or other inv. bytes CounterZeroBytes++; prev = current; i--; //This is for the begining of the AI list. //Could cause problem b/c the aientries variable //can be over 6 characters from reverse start. //Is there any possibility to get to the start of //AI list rather than the end? if (CounterZeroBytes > 6) { bExecute = false; } continue; } else { if (!bFoundFirstReverseChar) { //Found first character in reverse parsing bFoundFirstReverseChar = true; CounterZeroBytes = 0; bInAttack = true; } } if (bInAttack) { //we currently parse an AI command temp.Name += System.Text.Encoding.ASCII.GetString(new[] { current }); } if (bStopAttack) { //AI entry ended, add to temporary list //TODO: filtering invalid entries, such as //single or two-byte entries (i.e: entry name '45') //entries containing a space (ask Xaddgx) temp_entries.Add(temp); temp = new AIEntry(); } //if (CounterZeroBytes > 4) // bExecute = false; i--; prev = current; } SortAIEntries(temp_entries); }
private void btnTestMap_Click(object sender, RoutedEventArgs e) { MessageBox.Show("" + PCSX2_RAM.IsRoomWithPlayerLoaded()); }