コード例 #1
0
ファイル: RBNKNode.cs プロジェクト: soopercool101/BrawlCrate
        public override void OnRebuild(VoidPtr address, int length, bool force)
        {
            VoidPtr addr = address + 0x20;

            RBNKHeader *header = (RBNKHeader *)address;

            header->_header._length      = length;
            header->_header._tag         = RBNKHeader.Tag;
            header->_header._numEntries  = (ushort)(VersionMinor >= 2 ? 1 : 2);
            header->_header._firstOffset = 0x20;
            header->_header.Endian       = Endian.Big;
            header->_header._version     = (ushort)(0x100 + VersionMinor);
            header->_dataOffset          = 0x20;
            header->_dataLength          = Children[0]._calcSize;

            Children[0].Rebuild(addr, Children[0]._calcSize, true);
            addr += Children[0]._calcSize;

            if (VersionMinor < 2)
            {
                header->_waveOffset = 0x20 + Children[0]._calcSize;
                header->_waveLength = Children[1]._calcSize;

                VoidPtr audio = addr;
                if (RSARNode == null)
                {
                    audio += Children[1]._calcSize;
                }
                else
                {
                    audio = _rebuildAudioAddr;
                }

                (Children[1] as RBNKSoundGroupNode)._audioAddr = audio;
                _audioSource = new DataSource(audio, _audioLen);

                Children[1].Rebuild(addr, Children[1]._calcSize, true);
                addr += Children[1]._calcSize;
            }
            else
            {
                header->_waveOffset = 0;
                header->_waveLength = 0;

                VoidPtr audio = addr;
                if (RSARNode != null)
                {
                    audio = _rebuildAudioAddr;
                }

                _audioSource = new DataSource(audio, _audioLen);
                Children[1].Rebuild(audio, Children[1]._calcSize, true);
            }

            SetSizeInternal(_headerLen);
        }
コード例 #2
0
ファイル: RBNKNode.cs プロジェクト: KingAtreyu/super-sawndz
        //protected override void GetStrings(LabelBuilder builder)
        //{
        //    foreach (RWSDDataNode node in Children[0].Children)
        //        builder.Add(node._soundIndex, node._name);
        //}

        //Finds labels using LABL block between header and footer, also initializes array
        protected bool GetLabels(int count)
        {
            RBNKHeader *     header = (RBNKHeader *)WorkingUncompressed.Address;
            int              len    = header->_header._length;
            RSEQ_LABLHeader *labl   = (RSEQ_LABLHeader *)((int)header + len);

            if ((WorkingUncompressed.Length > len) && (labl->_tag == RSEQ_LABLHeader.Tag))
            {
                _labels = new LabelItem[count];
                count   = labl->_numEntries;
                for (int i = 0; i < count; i++)
                {
                    RSEQ_LABLEntry *entry = labl->Get(i);
                    _labels[i] = new LabelItem()
                    {
                        String = entry->Name, Tag = entry->_id
                    };
                }
                return(true);
            }

            return(false);
        }
コード例 #3
0
ファイル: RBNKNode.cs プロジェクト: KingAtreyu/super-sawndz
        protected override void OnPopulate()
        {
            RSARNode    rsar     = RSARNode;
            SYMBHeader *symb     = null;
            RuintList * bankList = null;
            //INFOBankEntry** soundIndices = null;
            VoidPtr soundOffset = null;
            //INFOBankEntry* sEntry;
            RBNKGroupNode    g;
            RBNKHeader *     rwsd = Header;
            RBNK_DATAHeader *data = rwsd->Data;
            //RWSD_WAVEHeader* wave = rwsd->Wave;
            RuintList *list = &data->_list;
            //RuintList* waveList = &wave->_list;
            int count = list->_numEntries;

            //Get sound info from RSAR (mainly for names)
            if (rsar != null)
            {
                symb        = rsar.Header->SYMBBlock;
                soundOffset = &rsar.Header->INFOBlock->_collection;
                bankList    = rsar.Header->INFOBlock->Banks;
                //soundIndices = (INFOBankEntry**)Marshal.AllocHGlobal(count * 4);

                //int sIndex = 0;
                //int soundCount = soundList->_numEntries;
                //for (int i = 0; i < soundCount; i++)
                //    if ((sEntry = (INFOBankEntry*)soundList->Get(soundOffset, i))->_fileId == _fileIndex)
                //        soundIndices[((INFOSoundPart2*)sEntry->GetPart2(soundOffset))->_soundIndex] = sEntry;
            }
            (g = new RBNKGroupNode()).Initialize(this, Header->Data, Header->_dataLength);
            for (int i = 0; i < count; i++)
            {
                RBNK_DATAEntry *entry = (RBNK_DATAEntry *)list->Get(list, i);
                RBNKDataNode    node  = new RBNKDataNode();
                node._offset = list;
                node.Initialize(g, entry, 0);

                //Attach from INFO block
                //if (soundIndices != null)
                //{
                //    sEntry = soundIndices[i];
                //    node._name = symb->GetStringEntry(sEntry->_stringId);
                //}
            }

            //if (soundIndices != null)
            //    Marshal.FreeHGlobal((IntPtr)soundIndices);

            //Get labels
            RSARNode parent;
            int      count2 = Header->Data->_list._numEntries;

            if ((_labels == null) && ((parent = RSARNode) != null))
            {
                _labels = new LabelItem[count2];// new string[count];

                //Get them from RSAR
                SYMBHeader *symb2 = parent.Header->SYMBBlock;
                INFOHeader *info  = parent.Header->INFOBlock;

                VoidPtr    offset    = &info->_collection;
                RuintList *bankList2 = info->Banks;
                count2 = bankList2->_numEntries;

                //INFOBankEntry* entry;
                //for (int i = 0; i < count2; i++)
                //    if ((entry = (INFOBankEntry*)soundList2->Get(offset, i))->_fileId == _fileIndex)
                //        _labels[((INFOSoundPart2*)entry->GetPart2(offset))->_soundIndex] = new LabelItem() { Tag = i, String = symb2->GetStringEntry(entry->_stringId) };
            }

            new RBNKGroupNode().Initialize(this, Header->Wave, Header->_waveLength);
        }