public static int LongRead_LoHiBank(int loAddress, int hiAddress, int bankAddress) { return(AddressLoROM.SnesToPc( ROM.DATA[loAddress], ROM.DATA[hiAddress], ROM.DATA[bankAddress])); }
internal indoor_telepathy() { dataAddress = AddressLoROM.SnesToPc( ROM.DATA[POINTER_LOCATION + 0], ROM.DATA[POINTER_LOCATION + 1], AddressLoROM.PcToSnes_Bank(POINTER_LOCATION)); }
private void updatePointer(byte[] rawData, ref int[] pointer, int length, int start = 0) { for (int i = 0, j = 0; (i < length - 1) && (j < rawData.Length - 1); i += 1, j += 3) { pointer[i + start] = AddressLoROM.SnesToPc((rawData[j]), (rawData[j + 1]), (rawData[j + 2])); } }
public void movePointers(int newAddress) { if (!isConnPatched) { if (ROM.IsEmpty(newAddress, size)) { if (AddressLoROM.PcToSnes_Hi(newAddress) == AddressLoROM.PcToSnes_Bank(primaryPointer)) { ROM.Swap(secondaryPointer, newAddress, size); byte[] b = new byte[] { (byte)(AddressLoROM.PcToSnes_Lo(newAddress)), (byte)(AddressLoROM.PcToSnes_Hi(newAddress + 1)), }; ROM.Write(primaryPointer, b.Length, b); updatePointers(); } else { throw new Exception("Address must be within the bank."); } } else { throw new Exception(TextAndTranslationManager.GetString(Dungeon.moveError)); } } else { throw new NotImplementedException(); } }
public static byte[] GeneratePointer2(int address) { return(new byte[] { (byte)AddressLoROM.PcToSnes_Lo(address), (byte)AddressLoROM.PcToSnes_Hi(address), }); }
public static int ShortRead_LoHi(int address) { return(AddressLoROM.SnesToPc ( ROM.DATA[address], ROM.DATA[address + 1], AddressLoROM.PcToSnes_Bank(address) )); }
private void readPointer() { if (ROM.Read(primaryPointer + bankOffset1) != ROM.Read(primaryPointer + bankOffset2)) { throw new Exception(); } secondaryPointer = PointerRead.LongRead_LoHiBank(primaryPointer); secondaryPointer = PointerRead.LongRead_LoHiBank(primaryPointer, primaryPointer + 1, pointer_bank); roomHeaderPointers = new int[numberOfHeaders]; for (int i = 0; i < numberOfHeaders; i++) { int temp = secondaryPointer + i * 2; roomHeaderPointers[i] = AddressLoROM.SnesToPc( ROM.Read(temp + 0), ROM.Read(temp + 1), AddressLoROM.PcToSnes_Bank(secondaryPointer)); roomHeaders[i] = new i_roomHeader(ROM.Read(roomHeaderPointers[i], sizeOfEachHeader)); } }
/// <summary> /// Load a project /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void loadToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog of = new OpenFileDialog(); of.Filter = "ZScream Project (*.zscr)|*.zscr"; if (of.ShowDialog() == DialogResult.OK) { loadedProject = Path.GetDirectoryName(of.FileName); configs = JsonConvert.DeserializeObject <string[]>(File.ReadAllText(loadedProject + "//Project.zscr")); emulatorPath = configs[0]; JsonData data = new JsonData(Path.GetDirectoryName(of.FileName)); overworldForm.setData(data); overworldForm.Enabled = true; allScriptsFiles = Directory.EnumerateFiles(loadedProject + "\\ASM").ToArray(); foreach (string script in allScriptsFiles) { string f = Path.GetFileName(script); if (f == "Main.asm") { string[] usedFiles = File.ReadAllLines(script); foreach (string s in usedFiles) { if (s.Contains("incsrc")) { scriptsActive.Add(s.Remove(0, 7)); } } continue; } if (f != "Readme.txt") { scriptsDetected.Add(f); } } } else { return; } foreach (string s in scriptsDetected) { //Create information of each scripts StringBuilder information = new StringBuilder(); bool description = false; string[] asmfileLines = File.ReadAllLines(loadedProject + "\\ASM\\" + s); Console.WriteLine("Lines : " + asmfileLines.Length); int id = 0; foreach (string line in asmfileLines) { if (line.Contains(";#=")) { description = !description; continue; } if (description == true) { information.AppendLine(line); } else { if (line.Length > 0) { if (line[0] != ';') //if line is a comment { if (line.Contains("org $")) { string addr = line.Substring(line.IndexOf('$') + 1, 6); string comment = ""; if (addr.Contains(";")) //address is shorter than 6 { addr = line.Substring(line.IndexOf('$') + 1, line.IndexOf(';') - line.IndexOf('$'));; } if (line.Contains(";")) { comment = line.Substring(line.IndexOf(';'), line.Length - line.IndexOf(';')); } int snesAddr = ParseHexString(addr); int pcAddr = AddressLoROM.SnesToPc(snesAddr); information.AppendLine("SNES:" + snesAddr.ToString("X6") + " PC:" + pcAddr.ToString("X6") + " ;" + comment); } } } } } scriptsInformation.Add(information.ToString()); //add the script in the script list ToolStripItem item = scriptsToolStripMenuItem.DropDownItems.Add(s); if (scriptsActive.Contains(s)) { //check the script if it active (item as ToolStripMenuItem).Checked = true; (item as ToolStripMenuItem).CheckOnClick = true; } if (item.Text == "EditorCore.asm") { (item as ToolStripMenuItem).CheckOnClick = false; } ToolStripItem itemInfo = scriptsToolStripMenuItem.DropDownItems.Add("Information"); itemInfo.Tag = id; itemInfo.Click += ItemInfo_Click; (item as ToolStripMenuItem).DropDownItems.Add(itemInfo); //add an information tab with tag value id++; } Console.WriteLine(scriptsInformation[0]); }
public void writeAllSprites(SortedList <ushort, List <i_sprite> > allSprites) { int[] pointers = new int[roomPointers.Length]; const int blah = 2; //inspired by HM source code int lowestPointer = int.MaxValue; foreach (int i in roomPointers) { lowestPointer = Math.Min(lowestPointer, i); } List <byte> data = new List <byte>(); for (ushort i = 0; i < roomPointers.Length; i++) { if (!allSprites.ContainsKey(i)) { allSprites.Add(i, new List <i_sprite>()); } } foreach (ushort i in allSprites.Keys) { if (allSprites[i].Count == 0) { pointers[i] = lowestPointer + sizeOfData - blah; } else { List <byte> data2 = new List <byte>(); byte byteSortByte = 0x0; bool first = true; foreach (i_sprite s in allSprites[i]) { byte[] b = null; if (first) { b = s.getBytes(out byteSortByte); first = false; data2.Add(byteSortByte); } else { b = s.getBytes(out byte temp); if (temp != byteSortByte) { throw new Exception(); } } data2 = data2.Concat(b).ToList(); } data2.Add(sprite_delim); pointers[i] = lowestPointer + data.Count; data = data.Concat(data2).ToList(); } } if (data.Count > sizeOfData - blah) { throw new Exception(); } while (data.Count < sizeOfData - blah) { data.Add(sprite_delim); } data.Add(0xAA); data.Add(sprite_delim); List <byte> pointerData = new List <byte>(); foreach (int address in pointers) { byte[] d = new byte[] { (byte)AddressLoROM.PcToSnes_Lo(address), (byte)AddressLoROM.PcToSnes_Hi(address) }; pointerData = pointerData.Concat(d).ToList(); } ROM.Write(secondaryPointer, size, pointerData.ToArray()); ROM.Write(lowestPointer, sizeOfData, data.ToArray()); updatePointers(); }