Пример #1
0
        public static void load(File f)
        {
            int size = f.fileSize;

            int offs = 0x10; //Asisuming always same header size.
            while (offs+8 <= size)
            {
                uint magic = f.getUintAt(offs);
                uint sectionSize = f.getUintAt(offs + 4);
                if (sectionSize == 0) break; //Some files appear to have extra 0's at the end !?
                gotSection(f, offs, (int)sectionSize);
                offs += (int) sectionSize;
            }
        }
Пример #2
0
        public static void gotSection(File f, int offs, int size)
        {
            uint magic = f.getUintAt(offs);

            if (magic == 0x504C5454) //PLTT
                new PaletteViewer(new InlineFile(f, offs + 0x18, size - 0x18, f.name)).Show();
            else if (magic == 0x43484152) //CHAR
            {
                LevelChooser.showImgMgr();
                int tileWidth = f.getUshortAt(offs + 0xA);
                if (tileWidth == 0xFFFF)
                    tileWidth = 8;
                LevelChooser.imgMgr.m.addImage(new Image2D(new InlineFile(f, offs + 0x20, size - 0x20, f.name), 8*tileWidth, true, false));
            }
            else if (magic == 0x5343524E) //SCRN
            {
                if (LevelChooser.imgMgr == null) return;
                Image2D img = LevelChooser.imgMgr.m.getSelectedImage();
                Palette[] pals = LevelChooser.imgMgr.m.getPalettes();
                if (img == null) return;
                if (pals == null) return;
                if (pals.Length == 0) return;
                InlineFile ff = new InlineFile(f, offs + 0x14, size - 0x14, f.name);
                Tilemap t = new Tilemap(ff, 32, img, pals, 0, 0);
                new TilemapEditorWindow(t).Show();
            }
            else
                Console.WriteLine(String.Format("Unknown magic: {0:X8}", magic));
        }
Пример #3
0
        public virtual void refreshOffsets()
        {
            if (beginFile != null)
            {
                fileBeginP = (int)beginFile.getUintAt(beginOffset) + filesystemDataOffset;
            }

            if (endFile != null)
            {
                int end = (int)endFile.getUintAt(endOffset);
                if (endIsSize)
                {
                    fileSizeP = (int)end;
                }
                else
                {
                    fileSizeP = (int)end + filesystemDataOffset - fileBegin;
                }
            }
        }
Пример #4
0
        private void decompressWithHeaderButton_Click(object sender, EventArgs e)
        {
            File f = fileTreeView.SelectedNode.Tag as File;

            try
            {
                try
                {
                    f.beginEdit(this);
                }
                catch (AlreadyEditingException)
                {
                    MessageBox.Show(LanguageManager.Get("Errors", "File"));
                    return;
                }

                if (f.getUintAt(0) != 0x37375A4C)
                {
                    MessageBox.Show(LanguageManager.Get("Errors", "NoLZHeader"));
                    f.endEdit(this);
                    return;
                }

                byte[] CompFile = f.getContents();
                byte[] CompFileWithoutHeader = new byte[CompFile.Length - 4];
                Array.Copy(CompFile, 4, CompFileWithoutHeader, 0, CompFileWithoutHeader.Length);
                byte[] RawFile = ROM.LZ77_Decompress(CompFileWithoutHeader);
                f.replace(RawFile, this);
                UpdateFileInfo();
                f.endEdit(this);
            }
            catch (Exception)
            {
                MessageBox.Show(LanguageManager.Get("FilesystemBrowser", "DecompressionFail"));
                if (f.beingEditedBy(this))
                {
                    f.endEdit(this);
                }
            }
        }
Пример #5
0
        public OverlayFile(Filesystem parent, Directory parentDir,
            int id,  File alFile, int alBeg, int alEnd,
            File ovTableFile, uint ovTableOffs)
            : base(parent, parentDir, true, id, ":::", alFile, alBeg, alEnd)
        {
            this.nameP = string.Format(LanguageManager.Get("NitroClass", "OverlayFile"),
                id, ramAddr.ToString("X"), ramSize.ToString("X"));

            this.ovTableFile = ovTableFile;
            this.ovTableOffs = ovTableOffs;

            ovId = ovTableFile.getUintAt((int)ovTableOffs + 0x00);
            ramAddr = ovTableFile.getUintAt((int)ovTableOffs + 0x04);
            ramSize = ovTableFile.getUintAt((int)ovTableOffs + 0x08);
            bssSize = ovTableFile.getUintAt((int)ovTableOffs + 0x0C);
            staticInitStart = ovTableFile.getUintAt((int)ovTableOffs + 0x10);
            staticInitEnd = ovTableFile.getUintAt((int)ovTableOffs + 0x14);

            nameP = String.Format("{0:X8} - {1:X8}, OV {2}, FILE {3}", ramAddr, ramAddr + ramSize - 1, ovId, id);
        }
Пример #6
0
        public static void load(Filesystem fs)
        {
            filename = fs.getRomPath();
            FS = fs;
            if(fs is NitroROMFilesystem)
                romfile = new System.IO.FileInfo(filename);

			arm9binFile = FS.getFileByName("arm9.bin");			
			arm9ovFile = FS.getFileByName("arm9ovt.bin");	
			arm9ovs = loadOvTable(arm9ovFile);
			arm7binFile = FS.getFileByName("arm7.bin");			
			arm7ovFile = FS.getFileByName("arm7ovt.bin");			
			arm7ovs = loadOvTable(arm7ovFile);
			rsaSigFile = FS.getFileByName("rsasig.bin");			
			headerFile = FS.getFileByName("header.bin");

            arm9RAMAddress = headerFile.getUintAt(0x28);
			
            ByteArrayInputStream header = new ByteArrayInputStream(headerFile.getContents());
            romInternalName = header.ReadString(12);
            romGamecode = header.ReadString(4);

            if (romGamecode == "A2DE")
                Region = Origin.US;
            else if (romGamecode == "A2DP")
                Region = Origin.EU;
            else if (romGamecode == "A2DJ")
                Region = Origin.JP;
            else if (romGamecode == "A2DK")
                Region = Origin.KR;
            else
            {
                isNSMBRom = false;
                Region = Origin.UNK;
            }

            if (isNSMBRom)
            {
                UserInfo = new ROMUserInfo(filename);
                LoadOverlay0();
            }
        }