コード例 #1
0
        private static Overlay[] loadOvTable2(File table)
        {
            Overlay[] ovs2 = new Overlay[table.fileSize / 32]; // initialize secondary overlay table

            ByteArrayInputStream tbl = new ByteArrayInputStream(table.getContents());

            int i = 0;

            while (tbl.lengthAvailable(32))
            {
                uint   ovId            = tbl.readUInt();
                uint   ramAddr         = tbl.readUInt();
                uint   ramSize         = tbl.readUInt();
                uint   bssSize         = tbl.readUInt();
                uint   staticInitStart = tbl.readUInt();
                uint   staticInitEnd   = tbl.readUInt();
                ushort fileID          = tbl.readUShort();
                tbl.skip(6);                                                             //unused 0's

                ovs2[fileID] = new Overlay(FS.getFileById(fileID), table, (uint)i * 32); //secondary overlay table used for overlay decompression

                i++;
            }

            return(ovs2);
        }
コード例 #2
0
        private static Overlay[] loadOvTable(File table)
        {
            Overlay[] ovs = new Overlay[table.fileSize / 32];

            ByteArrayInputStream tbl = new ByteArrayInputStream(table.getContents());

            int i = 0;

            while (tbl.lengthAvailable(32))
            {
                uint   ovId            = tbl.readUInt();
                uint   ramAddr         = tbl.readUInt();
                uint   ramSize         = tbl.readUInt();
                uint   bssSize         = tbl.readUInt();
                uint   staticInitStart = tbl.readUInt();
                uint   staticInitEnd   = tbl.readUInt();
                ushort fileID          = tbl.readUShort();
                tbl.skip(6); //unused 0's

                ovs[ovId] = new Overlay(FS.getFileById(fileID), table, (uint)i * 32);

                i++;
            }

            return(ovs);
        }
コード例 #3
0
        private void loadTileBehaviors()
        {
            byte[] x = null;

            if (TilesetNumber == 0)
            {
                x = ROM.GetInlineFile(ROM.Data.File_Jyotyu_CHK);
            }
            else if (TilesetNumber == 1 || TilesetNumber == 2)
            {
                x = TileBehaviorFile.getContents();
            }

            ByteArrayInputStream inp = new ByteArrayInputStream(x);

            int len = inp.available / 4;

            TileBehaviors = new uint[len];

            for (int i = 0; i < len; i++)
            {
                TileBehaviors[i] = inp.readUInt();
            }
        }
コード例 #4
0
ファイル: Bncd.cs プロジェクト: poudink/NSMB-Editor
        ushort unk;         //Let's save it just in case.

        public Bncd(File f)
        {
            ByteArrayInputStream inp = new ByteArrayInputStream(f.getContents());

            inp.readInt();     //Magic;
            unk = inp.readUShort();
            ushort entryCount       = inp.readUShort();
            uint   entriesOffset    = inp.readUInt();
            uint   subEntriesOffset = inp.readUInt();
            uint   dataOffset       = inp.readUInt();
            uint   dataSize         = inp.readUInt();
            bool   BPP4             = true;

            //*/BPP4 = false;

            inp.seek(entriesOffset);

            //Stores tilenum, tilecount to imageid
            Dictionary <uint, int> imagesDict = new Dictionary <uint, int> ();

            for (uint entryId = 0; entryId < entryCount; entryId++)
            {
                BncdEntry e = new BncdEntry();
                e.width  = inp.readByte();
                e.height = inp.readByte();

                uint subEntryIdx = inp.readUShort();
                uint subEntryCt  = inp.readUShort();

                inp.savePos();
                inp.seek(subEntriesOffset + subEntryIdx * 12);
                for (int i = 0; i < subEntryCt; i++)
                {
                    BncdSubEntry se = new BncdSubEntry();
                    e.subEntries.Add(se);

                    se.oamAttr0   = inp.readUShort();
                    se.oamAttr1   = inp.readUShort();
                    se.unk        = inp.readUInt();
                    se.tileNumber = inp.readUShort();
                    se.tileCount  = inp.readUShort();
                    //*/se.tileCount *= 2;

                    uint imageCode = (uint)((se.tileNumber << 16) | se.tileCount);
                    int  imageId   = imagesDict.Count;
                    if (imagesDict.ContainsKey(imageCode))
                    {
                        imageId = imagesDict[imageCode];
                    }
                    else
                    {
                        imagesDict[imageCode] = imageId;
                        BncdImage img = new BncdImage();
                        images.Add(img);
                        img.tileNumber = se.tileNumber;
                        img.tileCount  = se.tileCount;

                        int oamShape = se.oamAttr0 >> 14;
                        int oamSize  = se.oamAttr1 >> 14;

                        img.tileWidth = widths[oamSize, oamShape];
                    }

                    se.imageId = imageId;
                }
                inp.loadPos();
            }

            LevelChooser.showImgMgr();
            int tileLen = 8 * 8 / 2;

            foreach (BncdImage img in images)
            {
                File imgFile = new InlineFile(f, (int)dataOffset + img.tileNumber * tileLen, img.tileCount * tileLen, f.name);
                LevelChooser.imgMgr.m.addImage(new Image2D(imgFile, 8 * img.tileWidth, BPP4));
            }
        }
コード例 #5
0
ファイル: Bncd256.cs プロジェクト: poudink/NSMB-Editor
        public Bncd256(File f)
        {
            ByteArrayInputStream arrayInputStream = new ByteArrayInputStream(f.getContents());

            arrayInputStream.readInt();
            this.unk = arrayInputStream.readUShort();
            ushort num1 = arrayInputStream.readUShort();
            uint   pos  = arrayInputStream.readUInt();
            uint   num2 = arrayInputStream.readUInt();
            uint   num3 = arrayInputStream.readUInt();

            arrayInputStream.readUInt();
            arrayInputStream.seek(pos);
            Dictionary <uint, int> dictionary = new Dictionary <uint, int>();

            for (uint index1 = 0; index1 < (uint)num1; ++index1)
            {
                Bncd256.Bncd256Entry bncdEntry = new Bncd256.Bncd256Entry();
                bncdEntry.width  = (int)arrayInputStream.readByte();
                bncdEntry.height = (int)arrayInputStream.readByte();
                uint num4 = (uint)arrayInputStream.readUShort();
                uint num5 = (uint)arrayInputStream.readUShort();
                arrayInputStream.savePos();
                arrayInputStream.seek(num2 + num4 * 12U);
                for (int index2 = 0; (long)index2 < (long)num5; ++index2)
                {
                    Bncd256.Bncd256SubEntry bncdSubEntry = new Bncd256.Bncd256SubEntry();
                    bncdEntry.subEntries.Add(bncdSubEntry);
                    bncdSubEntry.oamAttr0   = arrayInputStream.readUShort();
                    bncdSubEntry.oamAttr1   = arrayInputStream.readUShort();
                    bncdSubEntry.unk        = arrayInputStream.readUInt();
                    bncdSubEntry.tileNumber = arrayInputStream.readUShort();
                    bncdSubEntry.tileCount  = arrayInputStream.readUShort();
                    bncdSubEntry.tileCount *= (ushort)2;
                    uint key   = (uint)bncdSubEntry.tileNumber << 16 | (uint)bncdSubEntry.tileCount;
                    int  count = dictionary.Count;
                    if (dictionary.ContainsKey(key))
                    {
                        count = dictionary[key];
                    }
                    else
                    {
                        dictionary[key] = count;
                        Bncd256.Bncd256Image bncdImage = new Bncd256.Bncd256Image();
                        this.images.Add(bncdImage);
                        bncdImage.tileNumber = (int)bncdSubEntry.tileNumber;
                        bncdImage.tileCount  = (int)bncdSubEntry.tileCount;
                        int index3 = (int)bncdSubEntry.oamAttr0 >> 14;
                        int index4 = (int)bncdSubEntry.oamAttr1 >> 14;
                        bncdImage.tileWidth = Bncd256.widths[index4, index3];
                    }
                    bncdSubEntry.imageId = count;
                }
                arrayInputStream.loadPos();
            }
            LevelChooser.showImgMgr();
            int num6 = 32;

            foreach (Bncd256.Bncd256Image image in this.images)
            {
                File f1 = (File) new InlineFile(f, (int)num3 + image.tileNumber * num6, image.tileCount * num6, f.name);
                LevelChooser.imgMgr.m.addImage((PalettedImage) new Image2D(f1, 8 * image.tileWidth, false));
            }
        }