public void SetInitializer(uint address, uint size) { if (Program.m_IsROMFolder) { List <Ndst.Overlay> overlays = JsonConvert.DeserializeObject <List <Ndst.Overlay> >(NitroROM.GetExtractedLines("__ROM__/arm9Overlays.json")); Ndst.Overlay o = overlays.Where(x => x.Id == m_ID).ElementAt(0); o.StaticInitStart = address; o.StaticInitEnd = address + size; string toWrite = JsonConvert.SerializeObject(overlays, Formatting.Indented); NitroROM.WriteExtractedLines("__ROM__/arm9Overlays.json", toWrite); return; } bool autorw = !m_ROM.CanRW(); if (autorw) { m_ROM.BeginRW(); } m_ROM.Write32(m_OVTEntryAddr + 0x10, address); m_ROM.Write32(m_OVTEntryAddr + 0x14, address + size); m_ROM.m_OverlayEntries[m_ID].StaticInitStart = address; m_ROM.m_OverlayEntries[m_ID].StaticInitEnd = address + size; if (autorw) { m_ROM.EndRW(); } }
public void SaveChangesOld() { if (Program.m_IsROMFolder) { // first, ensure that the size is aligned to 4 byte boundary if (m_Data.Length % 4 != 0) { SetSize((uint)((m_Data.Length + 3) & ~3)); } List <Ndst.Overlay> overlays = JsonConvert.DeserializeObject <List <Ndst.Overlay> >(NitroROM.GetExtractedLines("__ROM__/arm9Overlays.json")); Ndst.Overlay o = overlays.Where(x => x.Id == m_ID).ElementAt(0); o.RAMSize = (uint)m_Data.Length; o.Flags &= 0xFFFFFFFE; NitroROM.WriteExtractedBytes("__ROM__/Arm9/" + m_ID + ".bin", m_Data); string toWrite = JsonConvert.SerializeObject(overlays, Formatting.Indented); NitroROM.WriteExtractedLines("__ROM__/arm9Overlays.json", toWrite); return; } bool autorw = !m_ROM.CanRW(); if (autorw) { m_ROM.BeginRW(); } // first, ensure that the size is aligned to 4 byte boundary if (m_Data.Length % 4 != 0) { SetSize((uint)((m_Data.Length + 3) & ~3)); } // reinsert file data m_ROM.ReinsertFileOld(m_FileID, m_Data); Update(); // fix overlay size m_ROM.Write32(m_OVTEntryAddr + 0x08, (uint)((m_Data.Length + 3) & ~3)); // tweak the overlay table entry byte flags = m_ROM.Read8(m_OVTEntryAddr + 0x1F); flags &= 0xFE; // [Treeki] disable compression :) m_ROM.Write8(m_OVTEntryAddr + 0x1F, flags); if (autorw) { m_ROM.EndRW(); } }
public NitroOverlay(NitroROM rom, uint id) { m_ROM = rom; m_ID = id; if (Program.m_IsROMFolder) { List <Ndst.Overlay> overlays = JsonConvert.DeserializeObject <List <Ndst.Overlay> >(NitroROM.GetExtractedLines("__ROM__/arm9Overlays.json")); Ndst.Overlay o = overlays.Where(x => x.Id == id).ElementAt(0); m_FileID = o.FileId; m_RAMAddr = o.RAMAddress; m_Data = NitroROM.GetExtractedBytes("__ROM__/Arm9/" + id + ".bin"); if ((o.Flags & 0x01000000) > 0) { Jap77.Decompress(ref m_Data); } return; } bool autorw = !m_ROM.CanRW(); if (autorw) { m_ROM.BeginRW(); } m_OVTEntryAddr = m_ROM.GetOverlayEntryOffset(m_ID); m_FileID = m_ROM.GetFileIDFromOverlayID(m_ID); m_RAMAddr = m_ROM.Read32(m_OVTEntryAddr + 0x04); Byte flags = m_ROM.Read8(m_OVTEntryAddr + 0x1F); m_Data = m_ROM.ExtractFile(m_FileID); if ((flags & 0x01) == 0x01) { Jap77.Decompress(ref m_Data); } if (autorw) { m_ROM.EndRW(); } }
public static bool CheckOverlayCompressed(uint id) { if (Program.m_IsROMFolder) { List <Ndst.Overlay> overlays = JsonConvert.DeserializeObject <List <Ndst.Overlay> >(NitroROM.GetExtractedLines("__ROM__/arm9Overlays.json")); Ndst.Overlay o = overlays.Where(x => x.Id == id).ElementAt(0); return((o.Flags & 0x01000000) > 0); } uint OVTEntryAddr = Program.m_ROM.GetOverlayEntryOffset(id); Byte flags = Program.m_ROM.Read8(OVTEntryAddr + 0x1F); if ((flags & 0x01) == 0x01) { return(true); } else { return(false); } }
public override void SaveChanges() { if (this.m_Data.Length % 4 != 0) { this.SetSize((uint)(this.m_Data.Length + 3 & -4)); } if (Program.m_IsROMFolder) { List <Ndst.Overlay> overlays = JsonConvert.DeserializeObject <List <Ndst.Overlay> >(NitroROM.GetExtractedLines("__ROM__/arm9Overlays.json")); Ndst.Overlay o = overlays.Where(x => x.Id == m_ID).ElementAt(0); o.RAMSize = (uint)m_Data.Length; o.Flags &= 0xFFFFFFFE; NitroROM.WriteExtractedBytes("__ROM__/Arm9/" + m_ID + ".bin", m_Data); string toWrite = JsonConvert.SerializeObject(overlays, Formatting.Indented); NitroROM.WriteExtractedLines("__ROM__/arm9Overlays.json", toWrite); return; } NitroROM.OverlayEntry[] overlayEntries = this.m_ROM.GetOverlayEntries(); NitroROM.OverlayEntry overlayEntry = overlayEntries[(int)this.m_ID]; overlayEntry.RAMSize = (uint)this.m_Data.Length; overlayEntries[(int)this.m_ID] = overlayEntry; this.m_ROM.ReinsertFile(this.m_FileID, this.m_Data); this.Update(); int num = !this.m_ROM.CanRW() ? 1 : 0; if (num != 0) { this.m_ROM.BeginRW(); } this.m_ROM.Write8(this.m_OVTEntryAddr + 31U, (byte)((uint)this.m_ROM.Read8(this.m_OVTEntryAddr + 31U) & 254U)); if (num == 0) { return; } this.m_ROM.EndRW(); }