예제 #1
0
        public static void ExportLevelDataToXML(NitroOverlay overlay, int levelID, LevelSettings levelSettings, 
            Dictionary<uint, LevelObject> levelObjects, List<LevelTexAnim>[] texAnims, string filename = "level.xml")
        {
            m_Overlay = overlay;
            m_LevelID = levelID;
            m_LevelSettings = levelSettings;
            m_LevelObjects = levelObjects;
            m_TexAnims = texAnims;
            m_NumAreas = m_Overlay.Read8(0x74);
            m_FileName = filename;
            m_Path = Path.GetDirectoryName(m_FileName);

            ExportXML();

            System.IO.File.WriteAllBytes(m_Path + "/OVL_" + (m_LevelID + 103) + ".bin", m_Overlay.m_Data);
        }
예제 #2
0
        public static void ExportLevelDataToXML(NitroOverlay overlay, int levelID, LevelSettings levelSettings,
                                                Dictionary <uint, LevelObject> levelObjects, List <LevelTexAnim>[] texAnims, string filename = "level.xml")
        {
            m_Overlay       = overlay;
            m_LevelID       = levelID;
            m_LevelSettings = levelSettings;
            m_LevelObjects  = levelObjects;
            m_TexAnims      = texAnims;
            m_NumAreas      = m_Overlay.Read8(0x74);
            m_FileName      = filename;
            m_Path          = Path.GetDirectoryName(m_FileName);

            ExportXML();

            System.IO.File.WriteAllBytes(m_Path + "/OVL_" + (m_LevelID + 103) + ".bin", m_Overlay.m_Data);
        }
예제 #3
0
        public DL_Editor(LevelEditorForm lf)
        {
            InitializeComponent();

            this.availableTree.Nodes.Clear();
            ROMFileSelect.LoadFileList(this.availableTree);
            this.lf   = lf;
            no        = new NitroOverlay(Program.m_ROM, (uint)(103 + lf.m_LevelID));
            tableAddr = no.Read32(0x30);

            uint count = no.Read16(tableAddr);

            for (uint i = 0; i < count; i++)
            {
                currentTree.Nodes.Add(Program.m_ROM.GetFileNameFromID(Program.m_ROM.GetFileIDFromInternalID(no.Read16(i * 2 + tableAddr + 2))));
            }
        }
        public void makeBinBackup(int file)
        {
            System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(ASMDir + "/bak");
            //Console.Out.WriteLine("Backing up " + file + " "+dir.FullName);
            if (!dir.Exists)
            {
                dir.Create();
            }

            dir = new System.IO.DirectoryInfo(ASMDir);
            System.IO.FileStream fs;

            string filename;

            if (file == -1)
            {
                filename = dir.FullName + "/bak/" + "main.bin";
            }
            else
            {
                filename = dir.FullName + "/bak/" + file + ".bin";
            }

            if (System.IO.File.Exists(filename))
            {
                return;
            }

            fs = new System.IO.FileStream(filename, System.IO.FileMode.CreateNew);

            NitroFile f = Program.m_ROM.GetFileFromName("arm9.bin");

            if (file != -1)
            {
                NitroOverlay ov = new NitroOverlay(Program.m_ROM, (uint)file);
                ov.SaveChanges();
                fs.Write(ov.m_Data, 0, f.m_Data.Length);
                fs.Close();
            }
            else
            {
                fs.Write(f.m_Data, 0, f.m_Data.Length);
                fs.Close();
            }
        }
예제 #5
0
        public static bool PatchToSupportBigASMHacks()
        {
            bool autorw = Program.m_ROM.CanRW();

            if (!autorw)
            {
                Program.m_ROM.BeginRW();
            }
            if (Program.m_ROM.Read32(0x6590) != 0) //the patch makes this not 0
            {
                if (!autorw)
                {
                    Program.m_ROM.EndRW();
                }
                return(true);
            }
            if (!autorw)
            {
                Program.m_ROM.EndRW();
            }

            if (MessageBox.Show("This requires the ROM to be further patched. " +
                                "Continue with the patch?", "Table Shifting Patch", MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return(false);
            }

            if (!autorw)
            {
                Program.m_ROM.BeginRW();
            }
            NitroOverlay ov2 = new NitroOverlay(Program.m_ROM, 2);

            //Move the ACTOR_SPAWN_TABLE so it can expand
            Program.m_ROM.WriteBlock(0x6590, Program.m_ROM.ReadBlock(0x90864, 0x61c));
            Program.m_ROM.WriteBlock(0x90864, new byte[0x61c]);

            //Adjust pointers
            Program.m_ROM.Write32(0x1a198, 0x02006590);

            //Move the OBJ_TO_ACTOR_TABLE so it can expand
            Program.m_ROM.WriteBlock(0x4b00, ov2.ReadBlock(0x0210cbf4 - ov2.GetRAMAddr(), 0x28c));
            ov2.WriteBlock(0x0210cbf4 - ov2.GetRAMAddr(), new byte[0x28c]);

            //Adjust pointers
            ov2.Write32(0x020fe890 - ov2.GetRAMAddr(), 0x02004b00);
            ov2.Write32(0x020fe958 - ov2.GetRAMAddr(), 0x02004b00);
            ov2.Write32(0x020fea44 - ov2.GetRAMAddr(), 0x02004b00);

            //Add the dynamic library loading and cleanup code
            Program.m_ROM.WriteBlock(0x90864, Properties.Resources.dynamic_library_loader);

            //Add the hooks (by replacing LoadObjBankOverlays())
            Program.m_ROM.WriteBlock(0x2df70, Properties.Resources.static_overlay_loader);

            if (!autorw)
            {
                Program.m_ROM.EndRW();
            }
            ov2.SaveChanges();

            return(true);
        }
예제 #6
0
        public void makeOverlay(uint overlayID)
        {
            FileInfo f = new FileInfo(romdir.FullName + "/newcode.bin");

            if (!f.Exists)
            {
                return;
            }
            FileStream   fs      = f.OpenRead();
            FileInfo     symFile = new FileInfo(romdir.FullName + "/newcode.sym");
            StreamReader symStr  = symFile.OpenText();

            byte[] newdata = new byte[fs.Length];
            fs.Read(newdata, 0, (int)fs.Length);
            fs.Close();


            BinaryWriter newOvl  = new BinaryWriter(new MemoryStream());
            BinaryReader newOvlR = new BinaryReader(newOvl.BaseStream);

            try
            {
                newOvl.Write(newdata);
                alignStream(newOvl.BaseStream, 4);

                uint staticInitCount = 0;

                while (!symStr.EndOfStream)
                {
                    string line = symStr.ReadLine();

                    if (line.Contains("_Z4initv")) //gcc name mangling of init()
                    {
                        uint addr = (uint)parseHex(line.Substring(0, 8));
                        newOvl.Write(addr);
                        ++staticInitCount;
                    }
                }

                /*if (newOvl.BaseStream.Length > 0x4d20)
                 *  throw new InvalidDataException
                 *      ("The overlay must have no more than 19776 bytes; this one will have " + newOvl.BaseStream.Length);*/

                NitroOverlay ovl = new NitroOverlay(Program.m_ROM, overlayID);
                newOvl.BaseStream.Position = 0;
                ovl.SetInitializer(ovl.GetRAMAddr() + (uint)newOvl.BaseStream.Length - 4 * staticInitCount,
                                   4 * staticInitCount);
                ovl.SetSize((uint)newOvl.BaseStream.Length);
                ovl.WriteBlock(0, newOvlR.ReadBytes((int)newOvl.BaseStream.Length));
                ovl.SaveChanges();
            }
            catch (Exception ex)
            {
                new ExceptionMessageBox("Error", ex).ShowDialog();
                return;
            }
            finally
            {
                symStr.Close();
                newOvl.Dispose();
                newOvlR.Close();
            }
        }