public BranchHelper1Byte(Stream binary, IRomMapper mapper) { Binary = binary; Mapper = mapper; Target = null; Sources = null; Disposed = false; }
public static bool TryMapRomToRam(this IRomMapper mapper, int romAddress, out int value) { ulong i = (uint)romAddress; ulong o; bool b = mapper.TryMapRomToRam(i, out o); value = (int)(uint)(o & 0xffffffffu); return(b); }
public static bool TryMapRamToRom(this IRomMapper mapper, long ramAddress, out long value) { ulong i = (ulong)ramAddress; ulong o; bool b = mapper.TryMapRamToRom(i, out o); value = (long)o; return(b); }
public static bool TryMapRamToRom(this IRomMapper mapper, uint ramAddress, out uint value) { ulong i = ramAddress; ulong o; bool b = mapper.TryMapRamToRom(i, out o); value = (uint)(o & 0xffffffffu); return(b); }
public static long MapRomToRam(this IRomMapper mapper, long romAddress) { long v; if (mapper.TryMapRomToRam(romAddress, out v)) { return(v); } throw new Exception("Address not mappable."); }
public static ulong MapRamToRom(this IRomMapper mapper, ulong ramAddress) { ulong v; if (mapper.TryMapRamToRom(ramAddress, out v)) { return(v); } throw new Exception("Address not mappable."); }
private static void ReadStringsInBlocks(List <MainDolString> output, IRomMapper dol, Stream stream, long pos, int byteSizeTotal, int blockSize, int stringsPerBlock, bool keepInvalid) { stream.Position = pos; int count = byteSizeTotal / blockSize; long[] positions = new long[stringsPerBlock]; uint[] ramAddresses = new uint[stringsPerBlock]; uint[] romAddresses = new uint[stringsPerBlock]; string[] strings = new string[stringsPerBlock]; uint[] stringByteCounts = new uint[stringsPerBlock]; for (int i = 0; i < count; ++i) { for (int j = 0; j < stringsPerBlock; ++j) { positions[j] = stream.Position; ramAddresses[j] = stream.ReadUInt32().FromEndian(EndianUtils.Endianness.BigEndian); } stream.DiscardBytes((uint)(blockSize - 4 * stringsPerBlock)); bool isValid = false; for (int j = 0; j < stringsPerBlock; ++j) { if (ramAddresses[j] == 0) { romAddresses[j] = 0; strings[j] = null; stringByteCounts[j] = 0; } else { romAddresses[j] = dol.MapRamToRom(ramAddresses[j]); long tmp = stream.Position; stream.Position = romAddresses[j]; string s = stream.ReadNulltermString(TextUtils.GameTextEncoding.ShiftJIS); uint bytesRead = (uint)(stream.Position - romAddresses[j]); stream.Position = tmp; strings[j] = s; stringByteCounts[j] = bytesRead; isValid = true; } } if (isValid || keepInvalid) { for (int j = 0; j < stringsPerBlock; ++j) { output.Add(new MainDolString((uint)positions[j], romAddresses[j], strings[j], stringByteCounts[j])); } } } }
public static void ReadStrings(List <MainDolString> output, IRomMapper dol, Stream stream, long start, long bytecount) { stream.Position = start; while (stream.Position < start + bytecount) { long p = stream.Position; uint a = stream.ReadUInt32().FromEndian(EndianUtils.Endianness.BigEndian); if (a != 0) { uint rom; if (dol.TryMapRamToRom(a, out rom)) { long tmp = stream.Position; stream.Position = rom; string s = stream.ReadNulltermString(TextUtils.GameTextEncoding.ShiftJIS); uint bytesRead = (uint)(stream.Position - rom); stream.Position = tmp; output.Add(new MainDolString((uint)p, rom, s, bytesRead)); } } } }
private static List <(uint where, uint count, uint skip)> GetChunksForTexPointersFix(IRomMapper mapper) { List <(uint where, uint count, uint skip)> patches = new List <(uint where, uint count, uint skip)>(); patches.Add((mapper.MapRomToRam(0x5742A8u), 35, 0x04)); patches.Add((mapper.MapRomToRam(0x574338u), 218, 0x0C)); patches.Add((mapper.MapRomToRam(0x585F18u), 252, 0x24)); patches.Add((mapper.MapRomToRam(0x585F1Cu), 252, 0x24)); return(patches); }