Esempio n. 1
0
        public override bool OnInitialize()
        {
            base.OnInitialize();

            _fileId         = Header->_fileId;
            _playerId       = Header->_playerId;
            _volume         = Header->_volume;
            _playerPriority = Header->_playerPriority;
            _soundType      = Header->_soundType;
            _remoteFilter   = Header->_remoteFilter;
            _panMode        = Header->_panMode;
            _panCurve       = Header->_panCurve;
            _actorPlayerId  = Header->_actorPlayerId;
            _p1             = Header->_userParam1;
            _p2             = Header->_userParam2;

            INFOHeader *info = RSARNode.Header->INFOBlock;

            _sound3dParam = *Header->GetParam3dRef(&info->_collection);

            VoidPtr addr = Header->GetSoundInfoRef(&info->_collection);

            switch (Header->_soundInfoRef._dataType)
            {
            case 1: _seqInfo = *(SeqSoundInfo *)addr; break;

            case 2: _strmInfo = *(StrmSoundInfo *)addr; break;

            case 3: _waveInfo = *(WaveSoundInfo *)addr; break;
            }

            _soundFileNode = RSARNode.Files[_fileId];
            _soundFileNode.AddSoundRef(this);

            if (_soundFileNode is RSEQNode)
            {
                foreach (RSEQLabelNode r in _soundFileNode.Children)
                {
                    if (_seqInfo._dataID == r.Id)
                    {
                        _seqLabl = r;
                        break;
                    }
                }
            }

            if (_waveInfo._soundIndex >= 0 &&
                _soundFileNode is RWSDNode &&
                _soundFileNode.Children.Count > 0 &&
                _soundFileNode.Children[0].Children.Count > _waveInfo._soundIndex)
            {
                _waveDataNode = _soundFileNode.Children[0].Children[_waveInfo._soundIndex] as RWSDDataNode;
                if (_waveDataNode != null)
                {
                    _waveDataNode._refs.Add(this);
                }
            }

            return(false);
        }
Esempio n. 2
0
        protected override bool OnInitialize()
        {
            base.OnInitialize();

            INFOHeader *info = RSARNode.Header->INFOBlock;

            _part1 = *Header->GetPart1(&info->_collection);
            _part2 = *Header->GetPart2(&info->_collection);

            _soundNode = RSARNode.Files[FileId];

            return(false);
        }
Esempio n. 3
0
        internal int EncodeINFOBlock(INFOHeader *header, RSAREntryList entries, RSARNode node)
        {
            int len = 0;

            VoidPtr    baseAddr = header->_collection.Address;
            ruint *    values   = (ruint *)baseAddr;
            VoidPtr    dataAddr = baseAddr + 0x30;
            RuintList *entryList;
            int        index = 0;

            //Set up sound ruint list
            values[0] = (uint)dataAddr - (uint)baseAddr;
            entryList = (RuintList *)dataAddr;
            entryList->_numEntries = entries._sounds.Count;
            dataAddr += entries._sounds.Count * 8 + 4;

            //Write sound entries
            foreach (RSAREntryNode r in entries._sounds)
            {
                r._rebuildBase = baseAddr;
                entryList->Entries[index++] = (uint)dataAddr - (uint)baseAddr;
                r.Rebuild(dataAddr, r._calcSize, true);
                dataAddr += r._calcSize;
            }
            index = 0;
            //Set up bank ruint list
            values[1] = (uint)dataAddr - (uint)baseAddr;
            entryList = (RuintList *)dataAddr;
            entryList->_numEntries = entries._banks.Count;
            dataAddr += entries._banks.Count * 8 + 4;

            //Write bank entries
            foreach (RSAREntryNode r in entries._banks)
            {
                r._rebuildBase = baseAddr;
                entryList->Entries[index++] = (uint)dataAddr - (uint)baseAddr;
                r.Rebuild(dataAddr, r._calcSize, true);
                dataAddr += r._calcSize;
            }
            index = 0;
            //Set up playerInfo ruint list
            values[2] = (uint)dataAddr - (uint)baseAddr;
            entryList = (RuintList *)dataAddr;
            entryList->_numEntries = entries._playerInfo.Count;
            dataAddr += entries._playerInfo.Count * 8 + 4;

            //Write playerInfo entries
            foreach (RSAREntryNode r in entries._playerInfo)
            {
                r._rebuildBase = baseAddr;
                entryList->Entries[index++] = (uint)dataAddr - (uint)baseAddr;
                r.Rebuild(dataAddr, r._calcSize, true);
                dataAddr += r._calcSize;
            }
            index = 0;
            //Set up file ruint list
            values[3] = (uint)dataAddr - (uint)baseAddr;
            entryList = (RuintList *)dataAddr;
            entryList->_numEntries = entries._files.Count;
            dataAddr += entries._files.Count * 8 + 4;

            //Write file entries
            foreach (RSARFileNode file in entries._files)
            {
                //if (file._groupRefs.Count == 0 && !(file is RSARExtFileNode))
                //    continue;

                entryList->Entries[index++] = (uint)dataAddr - (uint)baseAddr;
                INFOFileHeader *fileHdr = (INFOFileHeader *)dataAddr;
                dataAddr += INFOFileHeader.Size;
                RuintList *list = (RuintList *)dataAddr;
                fileHdr->_entryNumber = -1;
                if (file is RSARExtFileNode)
                {
                    uint extFileSize = 0;

                    //Make an attempt to get current file size
                    if (file.ExternalFileInfo.Exists)
                    {
                        extFileSize = (uint)file.ExternalFileInfo.Length;
                    }

                    if (file._extFileSize != extFileSize && extFileSize != 0)
                    {
                        file._extFileSize = extFileSize;
                    }

                    //Shouldn't matter if 0
                    fileHdr->_headerLen = file._extFileSize;

                    fileHdr->_dataLen      = 0;
                    fileHdr->_stringOffset = (uint)((VoidPtr)list - (VoidPtr)baseAddr);

                    sbyte *dPtr = (sbyte *)list;
                    file._extPath.Write(ref dPtr);
                    dataAddr += ((int)((VoidPtr)dPtr - (VoidPtr)dataAddr)).Align(4);

                    fileHdr->_listOffset = (uint)((VoidPtr)dataAddr - (VoidPtr)baseAddr);
                    dataAddr            += 4; //Empty list
                }
                else
                {
                    fileHdr->_headerLen = (uint)file._headerLen;
                    fileHdr->_dataLen   = (uint)file._audioLen;
                    //fileHdr->_stringOffset = 0;
                    fileHdr->_listOffset = (uint)((VoidPtr)list - (VoidPtr)baseAddr);
                    list->_numEntries    = file._groupRefs.Count;
                    INFOFileEntry *fileEntries = (INFOFileEntry *)((VoidPtr)list + 4 + file._groupRefs.Count * 8);
                    int            z           = 0;
                    List <int>     used        = new List <int>();
                    foreach (RSARGroupNode g in file._groupRefs)
                    {
                        list->Entries[z]        = (uint)((VoidPtr)(&fileEntries[z]) - baseAddr);
                        fileEntries[z]._groupId = g._rebuildIndex;
                        int[] all  = g._files.FindAllOccurences(file);
                        bool  done = false;
                        foreach (int i in all)
                        {
                            if (!used.Contains(i))
                            {
                                fileEntries[z]._index = i;
                                used.Add(i);
                                done = true;
                                break;
                            }
                        }
                        if (!done)
                        {
                            fileEntries[z]._index = g._files.IndexOf(file);
                        }
                        z++;
                    }
                    dataAddr = (VoidPtr)fileEntries + file._groupRefs.Count * INFOFileEntry.Size;
                }
            }
            index = 0;
            //Set up group ruint list
            values[4] = (uint)dataAddr - (uint)baseAddr;
            entryList = (RuintList *)dataAddr;
            entryList->_numEntries = entries._groups.Count;
            dataAddr += entries._groups.Count * 8 + 4;

            //Write group entries
            foreach (RSAREntryNode r in entries._groups)
            {
                r._rebuildBase = baseAddr;
                entryList->Entries[index++] = (uint)dataAddr - (uint)baseAddr;
                r.Rebuild(dataAddr, r._calcSize, true);
                dataAddr += r._calcSize;
            }

            //Write footer
            values[5] = (uint)dataAddr - (uint)baseAddr;
            *(INFOFooter *)dataAddr = node._ftr;

            //Set header
            header->_header._tag    = INFOHeader.Tag;
            header->_header._length = len = ((int)((dataAddr + INFOFooter.Size) - (baseAddr - 8))).Align(0x20);

            return(len);
        }
Esempio n. 4
0
        protected override void OnPopulate()
        {
            //RSARNode rsar = RSARNode;
            //SYMBHeader* symb = null;
            //RuintList* soundList = null;
            //INFOSoundEntry** soundIndices = null;
            //VoidPtr soundOffset = null;
            //INFOSoundEntry* sEntry;

            //RWSDHeader* rwsd = Header;
            //RWSD_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;
            //    soundList = rsar.Header->INFOBlock->Sounds;
            //    soundIndices = (INFOSoundEntry**)Marshal.AllocHGlobal(count * 4);

            //    //int sIndex = 0;
            //    int soundCount = soundList->_numEntries;
            //    for (int i = 0; i < soundCount; i++)
            //        if ((sEntry = (INFOSoundEntry*)soundList->Get(soundOffset, i))->_fileId == _fileIndex)
            //            soundIndices[((INFOSoundPart2*)sEntry->GetPart2(soundOffset))->_soundIndex] = sEntry;
            //}

            //for (int i = 0; i < count; i++)
            //{
            //    RWSD_DATAEntry* entry = (RWSD_DATAEntry*)list->Get(list, i);
            //    RWSDDataNode node = new RWSDDataNode();
            //    node.Initialize(this, 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      count = Header->Data->_list._numEntries;

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

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

                VoidPtr    offset    = &info->_collection;
                RuintList *soundList = info->Sounds;
                count = soundList->_numEntries;

                INFOSoundEntry *entry;
                for (int i = 0; i < count; i++)
                {
                    if ((entry = (INFOSoundEntry *)soundList->Get(offset, i))->_fileId == _fileIndex)
                    {
                        _labels[((INFOSoundPart2 *)entry->GetPart2(offset))->_soundIndex] = new LabelItem()
                        {
                            Tag = i, String = symb->GetStringEntry(entry->_stringId)
                        }
                    }
                }
                ;
            }

            new RWSDGroupNode().Initialize(this, Header->Data, Header->_dataLength);
            new RWSDGroupNode().Initialize(this, Header->Wave, Header->_waveLength);
        }
Esempio n. 5
0
        public override void OnPopulate()
        {
            RWSDHeader *     rwsd = Header;
            RWSD_DATAHeader *data = rwsd->Data;
            RuintList *      list = &data->_list;
            int count             = list->_numEntries;

            new RWSDDataGroupNode().Initialize(this, Header->Data, Header->_dataLength);
            if (Header->_waveOffset > 0 && VersionMinor < 3)
            {
                new RWSDSoundGroupNode().Initialize(this, Header->Wave, Header->_waveLength);
            }
            else if (VersionMinor >= 3)
            {
                new RWARNode {
                    _name = "Audio"
                }.Initialize(this, _audioSource.Address, _audioSource.Length);
            }

            //Get labels
            RSARNode parent;

            if (_labels == null && (parent = RSARNode) != null)
            {
                //Get them from RSAR
                SYMBHeader *symb2 = parent.Header->SYMBBlock;
                INFOHeader *info  = parent.Header->INFOBlock;

                VoidPtr    offset    = &info->_collection;
                RuintList *soundList = info->Sounds;
                int        count2    = soundList->_numEntries;

                _labels = new LabelItem[count2];

                INFOSoundEntry *entry;
                for (uint i = 0; i < count2; i++)
                {
                    if ((entry = (INFOSoundEntry *)soundList->Get(offset, (int)i))->_fileId == _fileIndex)
                    {
                        int x = ((WaveSoundInfo *)entry->GetSoundInfoRef(offset))->_soundIndex;
                        if (x >= 0 && x < count2)
                        {
                            _labels[x] = new LabelItem {
                                Tag = i, String = symb2->GetStringEntry(entry->_stringId)
                            };
                        }
                    }
                }
            }

            for (int i = 0; i < count; i++)
            {
                string name = "Entry" + i;
                if (_labels != null && i < _labels.Length)
                {
                    name = _labels[i].String;
                }

                RWSD_DATAEntry *entry = (RWSD_DATAEntry *)list->Get(list, i);
                RWSDDataNode    node  = new RWSDDataNode {
                    _name = name
                };
                node._offset = list;
                node.Initialize(Children[0], entry, 0);
            }
        }
Esempio n. 6
0
 internal static int EncodeINFOBlock(INFOHeader *header, RSAREntryList entries)
 {
     return(0);
 }
Esempio n. 7
0
        internal int EncodeINFOBlock(INFOHeader* header, RSAREntryList entries, RSARNode node)
        {
            int len = 0;

            VoidPtr baseAddr = header->_collection.Address;
            ruint* values = (ruint*)baseAddr;
            VoidPtr dataAddr = baseAddr + 0x30;
            RuintList* entryList;
            int index = 0;

            //Set up sound ruint list
            values[0] = (uint)dataAddr - (uint)baseAddr;
            entryList = (RuintList*)dataAddr;
            entryList->_numEntries = entries._sounds.Count;
            dataAddr += entries._sounds.Count * 8 + 4;

            //Write sound entries
            foreach (RSAREntryState r in entries._sounds)
            {
                r._node._rebuildBase = baseAddr;
                entryList->Entries[index++] = (uint)dataAddr - (uint)baseAddr;
                r._node.Rebuild(dataAddr, r._node._calcSize, true);
                dataAddr += r._node._calcSize;
            }
            index = 0;
            //Set up bank ruint list
            values[1] = (uint)dataAddr - (uint)baseAddr;
            entryList = (RuintList*)dataAddr;
            entryList->_numEntries = entries._banks.Count;
            dataAddr += entries._banks.Count * 8 + 4;

            //Write bank entries
            foreach (RSAREntryState r in entries._banks)
            {
                r._node._rebuildBase = baseAddr;
                entryList->Entries[index++] = (uint)dataAddr - (uint)baseAddr;
                r._node.Rebuild(dataAddr, r._node._calcSize, true);
                dataAddr += r._node._calcSize;
            }
            index = 0;
            //Set up playerInfo ruint list
            values[2] = (uint)dataAddr - (uint)baseAddr;
            entryList = (RuintList*)dataAddr;
            entryList->_numEntries = entries._playerInfo.Count;
            dataAddr += entries._playerInfo.Count * 8 + 4;

            //Write playerInfo entries
            foreach (RSAREntryState r in entries._playerInfo)
            {
                r._node._rebuildBase = baseAddr;
                entryList->Entries[index++] = (uint)dataAddr - (uint)baseAddr;
                r._node.Rebuild(dataAddr, r._node._calcSize, true);
                dataAddr += r._node._calcSize;
            }
            index = 0;
            //Set up file ruint list
            values[3] = (uint)dataAddr - (uint)baseAddr;
            entryList = (RuintList*)dataAddr;
            entryList->_numEntries = entries._files.Count;
            dataAddr += entries._files.Count * 8 + 4;

            //Write file entries
            foreach (RSARFileNode file in entries._files)
            {
                entryList->Entries[index++] = (uint)dataAddr - (uint)baseAddr;
                INFOFileHeader* fileHdr = (INFOFileHeader*)dataAddr;
                dataAddr += INFOFileHeader.Size;
                RuintList* list = (RuintList*)dataAddr;
                fileHdr->_entryNumber = -1;
                if (file is RSARExtFileNode)
                {
                    //Make an attempt to get current file size
                    uint s = 0;
                    if (file.ExternalFileInfo.Exists)
                        s = (uint)file.ExternalFileInfo.Length;
                    if (file._extFileSize != s && s != 0) file._extFileSize = s;
                    //Shouldn't matter if 0
                    fileHdr->_headerLen = file._extFileSize;

                    fileHdr->_dataLen = 0;
                    fileHdr->_stringOffset = (uint)((VoidPtr)list - (VoidPtr)baseAddr);

                    sbyte* dPtr = (sbyte*)list;
                    file._extPath.Write(ref dPtr);
                    dataAddr += ((int)((VoidPtr)dPtr - (VoidPtr)dataAddr)).Align(4);

                    fileHdr->_listOffset = (uint)((VoidPtr)dataAddr - (VoidPtr)baseAddr);
                    dataAddr += 4; //Empty list
                }
                else
                {
                    fileHdr->_headerLen = (uint)file._headerLen;
                    fileHdr->_dataLen = (uint)file._audioLen;
                    //fileHdr->_stringOffset = 0;
                    fileHdr->_listOffset = (uint)((VoidPtr)list - (VoidPtr)baseAddr);
                    list->_numEntries = file._groups.Count;
                    INFOFileEntry* fileEntries = (INFOFileEntry*)((VoidPtr)list + 4 + file._groups.Count * 8);
                    int z = 0;
                    List<int> used = new List<int>();
                    foreach (RSARGroupNode g in file._groups)
                    {
                        list->Entries[z] = (uint)((VoidPtr)(&fileEntries[z]) - baseAddr);
                        fileEntries[z]._groupId = g._rebuildIndex;
                        int[] all = g._files.FindAllOccurences(file);
                        bool done = false;
                        foreach (int i in all)
                            if (!used.Contains(i))
                            {
                                fileEntries[z]._index = i;
                                used.Add(i);
                                done = true;
                                break;
                            }
                        if (!done)
                            fileEntries[z]._index = g._files.IndexOf(file);
                        z++;
                    }
                    dataAddr = (VoidPtr)fileEntries + file._groups.Count * INFOFileEntry.Size;
                }
            }
            index = 0;
            //Set up group ruint list
            values[4] = (uint)dataAddr - (uint)baseAddr;
            entryList = (RuintList*)dataAddr;
            entryList->_numEntries = entries._groups.Count + 1;
            dataAddr += (entries._groups.Count + 1) * 8 + 4;

            //Write group entries
            foreach (RSAREntryState r in entries._groups)
            {
                r._node._rebuildBase = baseAddr;
                entryList->Entries[index++] = (uint)dataAddr - (uint)baseAddr;
                r._node.Rebuild(dataAddr, r._node._calcSize, true);
                dataAddr += r._node._calcSize;
            }
            //Null group at the end
            entryList->Entries[entries._groups.Count] = (uint)dataAddr - (uint)baseAddr;
            INFOGroupHeader* grp = (INFOGroupHeader*)dataAddr;
            node._nullGroup._rebuildAddr = grp;
            node._nullGroup._rebuildBase = baseAddr;
            *(bint*)(dataAddr + INFOGroupHeader.Size) = 0;
            grp->_entryNum = -1;
            grp->_stringId = -1;
            //grp->_extFilePathRef = 0;
            //grp->_extFilePathRef._dataType = 0;
            grp->_headerLength = 0;
            grp->_waveDataLength = 0;
            grp->_headerOffset = grp->_waveDataOffset = _headerLen + _symbLen + _infoLen + _fileLen;
            grp->_listOffset = (uint)((VoidPtr)(dataAddr + INFOGroupHeader.Size) - baseAddr);
            dataAddr += INFOGroupHeader.Size;
            RuintList* l = (RuintList*)dataAddr;
            INFOGroupEntry* e = (INFOGroupEntry*)((VoidPtr)l + 4 + node._nullGroup.Files.Count * 8);
            l->_numEntries = node._nullGroup.Files.Count;
            int y = 0;
            foreach (RSARFileNode file in node._nullGroup.Files)
            {
                l->Entries[y] = (uint)((VoidPtr)(&e[y]) - baseAddr);
                e[y++]._fileId = file._fileIndex;
                //entries[i]._dataLength = 0;
                //entries[i]._dataOffset = 0;
                //entries[i]._headerLength = 0;
                //entries[i]._headerOffset = 0;
            }
            dataAddr = (VoidPtr)e + node._nullGroup.Files.Count * 0x18;

            //Write footer
            values[5] = (uint)dataAddr - (uint)baseAddr;
            *(INFOFooter*)dataAddr = node.ftr;

            //Set header
            header->_header._tag = INFOHeader.Tag;
            header->_header._length = len = ((int)((dataAddr + INFOFooter.Size) - (baseAddr - 8))).Align(0x20);

            return len;
        }
Esempio n. 8
0
        protected override void OnPopulate()
        {
            RSARHeader *rsar   = Header;
            INFOHeader *info   = Header->INFOBlock;
            VoidPtr     offset = &info->_collection;
            RuintList * list   = (RuintList *)info->_collection[_listIndex];
            int         count  = list->_numEntries;

            Type t;

            switch (_listIndex)
            {
            case 2:
                t = typeof(RSARTypeNode);
                break;  //Types

            case 3:     //Files
                INFOFileHeader * fileHeader;
                INFOFileEntry *  fileEntry;
                RuintList *      entryList;
                INFOGroupHeader *group;
                INFOGroupEntry * gEntry;
                RuintList *      groupList = info->Groups;
                RSARFileNode     n;
                DataSource       source;

                for (int i = 0; i < count; i++)
                {
                    fileHeader = (INFOFileHeader *)list->Get(offset, i);
                    entryList  = fileHeader->GetList(offset);
                    if (entryList->_numEntries == 0)
                    {
                        //Must be external file.
                        n            = new RSARExtFileNode();
                        n._fileIndex = i;
                        n.Initialize(this, fileHeader, 0);
                    }
                    else
                    {
                        //use first entry
                        fileEntry = (INFOFileEntry *)entryList->Get(offset, 0);
                        //Find group with matching ID
                        group = (INFOGroupHeader *)groupList->Get(offset, fileEntry->_groupId);
                        //Find group entry with matching index
                        gEntry = (INFOGroupEntry *)group->GetCollection(offset)->Get(offset, fileEntry->_index);

                        //Create node and parse
                        source = new DataSource((int)rsar + group->_headerOffset + gEntry->_headerOffset, gEntry->_headerLength);
                        if ((n = NodeFactory.GetRaw(source) as RSARFileNode) == null)
                        {
                            n = new RSARFileNode();
                        }

                        n._audioSource = new DataSource((int)rsar + group->_dataOffset + gEntry->_dataOffset, gEntry->_dataLength);
                        n._fileIndex   = i;
                        n.Initialize(this, source);
                    }
                }

                return;

            case 4:
                t = typeof(RSARGroupNode);
                break;     //Groups

            default:
                return;
            }


            for (int i = 0; i < count; i++)
            {
                ResourceNode node = Activator.CreateInstance(t) as ResourceNode;
                node.Initialize(this, list->Get(offset, i), 0);
            }

            base.OnPopulate();
        }