private void TrajectoryEditor_Shown(object sender, EventArgs e) { var data = rommgr.GetBinaryRom(FileAccess.Read); trajectories.ReadTrajectories(data); data.Close(); LoadTrajectoriesList(); }
public void Read(RomManager rommgr, bool clearList) { try { BinaryRom rom; if (clearList) { ContentTable.Clear(); } rom = rommgr.GetBinaryRom(FileAccess.Read); // Get RAM location uint address = GetRamLocation(rom); // Set ROM position if (address == TableRamLocation) { address = TableRomLocationCustom; } else { address = TableRomLocationOriginal; } // Read table Read(rom, address); rom.Close(); } catch (Exception ex) { throw new Exception("Error at reading table from ROM.", ex); } }
// M e t h o d s public void Read(RomManager rommgr) { BinaryData s = rommgr.GetBinaryRom(FileAccess.Read); s.Position = 0x1210002; short musicCount = s.ReadInt16(); // Read NInsts var tNInstList = ReadNInsts(s, 0x7F0000, musicCount); // Read Sequence Names var tNames = ReadSequenceNames(rommgr); if (!tNames.Any()) { tNames = ReadSequenceNames(s, 0x7F1000, musicCount); } // Read Sequences Clear(); AddRange(ReadSequences(s, addrMusicStart, musicCount, tNInstList, tNames)); // Check for Music Hack s.Position = 0xD213A; ushort t001 = s.ReadUInt16(); s.Position = 0xD213E; ushort t002 = s.ReadUInt16(); EnableMusicHack = t001 == 0x807C & t002 == 0x0; s.Close(); }
public void WriteCollisionPointers(RomManager rommgr) { BinaryData data = rommgr.GetBinaryRom(FileAccess.ReadWrite); WriteCollisionPointers(data); data.Close(); }
protected override Stream GetBaseStream() { if (RomManager is object) { var s = RomManager.GetBinaryRom(FileAccess.Read); SegBank.ReadDataIfNull(s.BaseStream); s.Close(); } return(SegBank.Data); }
public void Write(RomManager rommgr, ref int lastPosition) { BinaryData s = rommgr.GetBinaryRom(FileAccess.ReadWrite); // Enable/Disable Music Hack if (NeedToSaveMusicHackSettings) { s.Position = 0xD213A; s.Write(Conversions.ToUShort(EnableMusicHack ? 0x807C : 0x801D)); s.Position = 0xD213E; s.Write(Conversions.ToUShort(EnableMusicHack ? 0x0 : 0xE000)); s.Position = 0xD215A; s.Write(Conversions.ToUShort(EnableMusicHack ? 0x807C : 0x801D)); s.Position = 0xD215E; s.Write(Conversions.ToUShort(EnableMusicHack ? 0x0 : 0xE000)); s.Position = 0xD459A; s.Write(Conversions.ToUShort(EnableMusicHack ? 0x807C : 0x801D)); s.Position = 0xD459E; s.Write(Conversions.ToUShort(EnableMusicHack ? 0x0 : 0xE000)); s.Position = 0xEE2B0; s.Write(Conversions.ToUInteger(EnableMusicHack ? 0xBD00 : 0x6D00)); s.Position = 0xD48B4; s.Write(Conversions.ToUInteger(EnableMusicHack ? 0x3C02803D : 0x3C02807C)); // &H3C02807C s.Position = 0xD48B8; s.Write(Conversions.ToUInteger(EnableMusicHack ? 0x34420000 : 0x34420000)); } var arrMe = ToArray(); // Write Music Names if (NeedToSaveSequenceNames) { WriteSequenceNames(rommgr, arrMe); } // Write NInsts if (NeedToSaveNInsts) { WriteNInst(s, 0x7F0000, arrMe); } // Write Music Sequences lastPosition = WriteSequences(s, addrMusicStart, arrMe, NeedToSaveSequences); // Reset NeedToSave Properties NeedToSaveSequences = false; NeedToSaveNInsts = false; NeedToSaveSequenceNames = false; NeedToSaveMusicHackSettings = false; s.Close(); }
public void ResetToOriginal(RomManager rommgr) { try { var rom = rommgr.GetBinaryRom(FileAccess.Read); ContentTable.Clear(); Read(rom, TableRomLocationOriginal); rom.Close(); } catch (Exception ex) { throw new Exception("Error at reading original content from ROM.", ex); } }
public void Save(RomManager romManager) { var startAddr = Config.GetRomStartAddress(); var curRomAddr = startAddr; if (Areas.Any()) { var data = romManager.GetBinaryRom(System.IO.FileAccess.ReadWrite); foreach (var area in Areas) { curRomAddr += area.Save(data, curRomAddr, Config); } data.Close(); } Config.Areas.Clear(); Config.Areas.AddRange(Areas.Select(n => n.Config)); Config.Length = curRomAddr - startAddr; }
public void Load(RomManager romManager) { Areas.Clear(); bool canLoadArea(CustomAsmAreaConfig areaConfig) => areaConfig.RomAddress != -1 && areaConfig.Length > 0; if (Config.Areas.Where(n => canLoadArea(n)).Any()) { var data = romManager.GetBinaryRom(System.IO.FileAccess.Read); foreach (var areaConfig in Config.Areas) { var area = new CustomAsmArea(areaConfig); area.Config.ID.GenerateIfNull(); area.Load(data, Config); Areas.Add(area); } data.Close(); } }
public void Write(RomManager rommgr) { try { var rom = rommgr.GetBinaryRom(FileAccess.ReadWrite); // Set ROM position rom.Position = TableRomLocationCustom; // Write data of each entry in the list for (int i = 0, loopTo = ContentTable.Count - 1; i <= loopTo; i++) { var entry = ContentTable[i]; rom.Write(Conversions.ToByte(i)); rom.Write(entry.BParam1); rom.Write(entry.BParam2); rom.Write(entry.ModelID); rom.Write(entry.BehavAddress); } // Finish table rom.Write(0x6300000000000000); // Update RAM Pointer in the ASM Code bool shouldUpdate = WriteNewPointer(rom); rom.Close(); // Update Checksum if (shouldUpdate) { General.PatchClass.UpdateChecksum(rommgr.RomFile); } } catch (Exception ex) { throw new Exception("Error at writing table to ROM.", ex); } }
public void SavePosition(RomManager rommgr) { var rom = rommgr.GetBinaryRom(FileAccess.ReadWrite); if (!new[] { StarNames.KoopaTheQuick1, StarNames.KoopaTheQuick2 }.Contains(Name)) { WriteStarWrapperFunction(rom); } var switchExpr = Name; switch (switchExpr) { case StarNames.KoopaTheQuick1: { WritePositionAsShort(rom, Position, 0xED868); break; } case StarNames.KoopaTheQuick2: { WritePositionAsShort(rom, Position, 0xED878); break; } case StarNames.KingBobOmbBoss: { WritePositionAsSingle(rom, Position, 0x1204F00); rom.Position = 0x62AD4; rom.Write(0x3C048040); // LUI A0, &H8040 rom.Write(0xC1009C0); // JAL &H80402700 rom.Write(0x34844F00); // ORI A0, A0, &H4F40 rom.Write(0x0); rom.Write(0x0); rom.Write(0x0); rom.Write(0x0); rom.Write(0x0); break; } case StarNames.WhompBoss: { WritePositionAsSingle(rom, Position, 0x1204F10); rom.Position = 0x82900; rom.Write(0x3C018040); rom.Write(0xC42C4F10); rom.Write(0xC42E4F14); rom.Write(0x8C264F18); rom.Position = 0x82914; rom.Write(0x0); break; } case StarNames.EyerockBoss: { WritePositionAsSingle(rom, Position, 0x1204F20); rom.Position = 0xC9A1C; // 0x8030EA1c rom.Write(0x3C048040); // LUI A0, &H8040 rom.Write(0xC1009C0); // JAL &H80402700 rom.Write(0x34844F20); // ORI A0, A0, &H4F20 rom.Write(0x0); // NOPs rom.Write(0x0); rom.Write(0x0); break; } case StarNames.BigBullyBoss: { WritePositionAsSingle(rom, Position, 0x1204F30); rom.Position = 0xA6970; // 0x802EB970 rom.Write(0x3C048040); // LUI A0, 0x8040 rom.Write(0xC1009C0); // JAL 0x80402700 rom.Write(0x34844F30); // ORI A0, A0, 0x4F30 break; } case StarNames.ChillBullyBoss: { WritePositionAsSingle(rom, Position, 0x1204F40); rom.Position = 0xA6950; // 0x802EB950 rom.Write(0x3C048040); // LUI A0, 0x8040 rom.Write(0xC1009C0); // JAL 0x80402700 rom.Write(0x34844F40); // ORI A0, A0, 0x4F40 break; } case StarNames.GiantPiranhaPlants: { WritePositionAsSingle(rom, Position, 0x1204F50); rom.Position = 0xC802C; // 0x8030D02C rom.Write(0x3C048040); // LUI A0, 0x8040 rom.Write(0xC1009C0); // JAL 0x80402700 rom.Write(0x34844F50); // ORI A0, A0, 0x4F50 break; } case StarNames.PenguinMother: { WritePositionAsSingle(rom, Position, 0x1204F60); rom.Position = 0x605E4; // 0x802a55e4 rom.Write(0x3C048040); // LUI A0, 0x8040 rom.Write(0xC1009C0); // JAL 0x80402700 rom.Write(0x34844F60); break; } case StarNames.WigglerBoss: { WritePositionAsSingle(rom, Position, 0x1204F70); rom.Position = 0xBCFE0; // 80301FE0 rom.Write(0x3C048040); // LUI A0, 0x8040 rom.Write(0xC1009C0); // JAL 0x80402700 rom.Write(0x34844F70); break; } case StarNames.PeachSlideStar: { WritePositionAsSingle(rom, Position, 0x1204F80); rom.Position = 0xB7D0; // 80301FE0 rom.Write(0x3C048040); // LUI A0, 0x8040 rom.Write(0xC1009C0); // JAL 0x80402700 rom.Write(0x34844F80); break; } case StarNames.BigPenguinRace: { WritePositionAsSingle(rom, Position, 0x1204F90); rom.Position = 0x605E4; // 80301FE0 rom.Write(0x3C048040); // LUI A0, 0x8040 rom.Write(0xC1009C0); // JAL 0x80402700 rom.Write(0x34844F90); break; } case StarNames.TreasureChests: { WritePositionAsSingle(rom, Position, 0x1204FA0); rom.Position = 0xB32B0; rom.Write(0x3C048040); // LUI A0, 0x8040 rom.Write(0xC1009C0); // JAL 0x80402700 rom.Write(0x34844FA0); break; } case StarNames.BooInHauntedHouse: { WritePositionAsSingle(rom, Position, 0x1204FAC); rom.Position = 0x7FBB0; rom.Write(0x3C048040); // LUI A0, 0x8040 rom.Write(0xC1009C0); // JAL 0x80402700 rom.Write(0x34844FAC); break; } case StarNames.Klepto: { WritePositionAsSingle(rom, Position, 0x1204FC4); rom.Position = 0xCC47C; rom.Write(0x3C048040); // LUI A0, 0x8040 rom.Write(0xC1009C0); // JAL 0x80402700 rom.Write(0x34844FC4); break; } case StarNames.MerryGoRoundboss: { WritePositionAsSingle(rom, Position, 0x1204FB8); rom.Position = 0x7FC24; rom.Write(0x3C048040); // LUI A0, 0x8040 rom.Write(0xC1009C0); // JAL 0x80402700 rom.Write(0x34844FB8); break; } case StarNames.MrIboss: { WritePositionAsSingle(rom, Position, 0x1204FD0); rom.Position = 0x61450; rom.Write(0x3C048040); // LUI A0, 0x8040 rom.Write(0xC1009C0); // JAL 0x80402700 rom.Write(0x34844FD0); break; } case StarNames.RooftopBoo: { WritePositionAsSingle(rom, Position, 0x1204FDC); rom.Position = 0x7FBEC; rom.Write(0x3C048040); // LUI A0, 0x8040 rom.Write(0xC1009C0); // JAL 0x80402700 rom.Write(0x34844FDC); break; } case StarNames.SecondactBigBully: { WritePositionAsSingle(rom, Position, 0x1204FE4); rom.Position = 0x7FBEC; rom.Write(0x3C048040); // LUI A0, 0x8040 rom.Write(0xC1009C0); // JAL 0x80402700 rom.Write(0x34844FE4); break; } } rom.Close(); }
public static void Prepaire(RomManager rommgr) { BinaryData s = rommgr.GetBinaryRom(FileAccess.ReadWrite); s.Position = 0x7B0863; byte musicCount = s.ReadByte(); // Set original Names var tNames = new[] { "No Music", "Star Catch", "Title Screen", "Bob-Omb Battlefield", "Inside Castle", "Dire, Dire Docks", "Lethal Lava Land", "Bowser Battle", "Snow", "Slide", "Haunted House", "Piranha Plant Lullaby", "Hazy Maze Cave", "Star Select", "Wing Cap", "Metal Cap", "Bowser Message", "Bowser Course", "High Score", "Merry-Go-Round", "Start and End Race with Koopa the Quick", "Star Appears", "Boss Fight", "Take a Key", "Endless Stairs", "Final Boss", "Staff Credits", "Puzzle Solved", "Toad Message", "Peach Message", "Introduction Scene", "Last Star Fanfare", "Ending Scene", "File Select", "Lakitu Appears" }; // Read original sequences var tSequences = ReadSequences(s, 0x7B0860, musicCount, Array.Empty <InstrumentSetList>(), tNames); s.Position = 0xDC0B8; s.Write(0); // Write sequences to the new Position WriteSequences(s, addrMusicStart, tSequences, true); // Write new sequence names WriteSequenceNames(rommgr, tSequences); // Write NInsts WriteNInst(s, 0x7F0000, tSequences); // Edit ASM-Code to load from the new location s.Position = 0x7B085F; s.Write(17); s.Position = 0xD4714; s.Write(0x3C040121); s.Position = 0xD471C; s.Write(0x24840000); s.Position = 0xD4768; s.Write(0x3C040121); s.Position = 0xD4770; s.Write(0x24840000); s.Position = 0xD4784; s.Write(0x3C050121); s.Position = 0xD4788; s.Write(0x24A50000); s.Position = 0xD48B4; s.Write(0x3C02807C); s.Position = 0xD48B8; s.Write(0x34420000); // Edit ASM-Code to load from new location s.Position = 0xD48C6; s.Write(Conversions.ToShort(0x7F)); s.Position = 0xD48CC; s.Write(0x34840000); s.Position = 0xD48DA; s.Write(Conversions.ToShort(0x200)); // Check for Music Hack s.Position = 0xD213A; ushort t001 = s.ReadUInt16(); s.Position = 0xD213E; ushort t002 = s.ReadUInt16(); if (t001 == 0x805D & t002 == 0xC000) { s.Position = 0xD213A; s.Write(Conversions.ToUShort(0x807C)); s.Position = 0xD213E; s.Write(Conversions.ToUShort(0x0)); s.Position = 0xD215A; s.Write(Conversions.ToUShort(0x807C)); s.Position = 0xD215E; s.Write(Conversions.ToUShort(0x0)); s.Position = 0xD459A; s.Write(Conversions.ToUShort(0x807C)); s.Position = 0xD459E; s.Write(Conversions.ToUShort(0x0)); s.Position = 0xEE2B0; s.Write(Conversions.ToUInteger(0xBD00)); } s.Close(); }