Inheritance: IGameDataStructure, IResource
Example #1
0
        //F3DEXParser.GameObject gameObject)
        public int[] ReadGameObject(DMAFile dma, byte[] bytes, uint fullOffset)
        {
            //byte bankNo = (byte)((gameObject.DListOffset & 0xFF000000) >> 24);
            uint offset = fullOffset & 0x00FFFFFF;

            _currentDMA = dma;

            //Is 0 a valid location?
            if (offset == 0)// || !MemoryManager.Instance.HasBank(bankNo) || !MemoryManager.Instance.LocateBank(bankNo, offset).IsValid())
            {
                return InvalidBox;
            }
            else
            {
                int listBase = GL.GenLists(3);
                //GL.ListBase(listBase);

                //Normal
                GL.NewList(listBase, ListMode.Compile);

                GL.PushMatrix();

                DrawingMode = F3DEXParser.DrawingModeType.Texture;

                ReadF3DEX(bytes, offset);

                GL.PopMatrix();

                GL.EndList();

                //Selected
                GL.NewList(listBase + 1, ListMode.Compile);

                GL.PushMatrix();

                DrawingMode = F3DEXParser.DrawingModeType.TextureSelected;

                ReadF3DEX(bytes, offset);

                GL.PopMatrix();

                GL.EndList();

                //Wireframe
                GL.NewList(listBase + 2, ListMode.Compile);

                GL.PushMatrix();

                DrawingMode = F3DEXParser.DrawingModeType.Wireframe;

                ReadF3DEX(bytes, offset);

                GL.PopMatrix();

                GL.EndList();

                return new int[3] { listBase, listBase + 1, listBase + 2 };
            }
        }
Example #2
0
        private bool BytesToDMATable(byte[] data, Endianness RomEndianness)
        {
            //Using the DMA Table offset, break up the file into its constituent DMA blocks.
            if (DMATableOffset == 0x0)
            {
                return false;
            }

            IsCompressed = false;

            DMATable.Clear();
            _levelDMAs.Clear();
            _headerDMA = null;
            _dmaTableDMA = null;
            _referenceDMA = null;

            int CurrentPos = (int)DMATableOffset;

            try
            {
                while (CurrentPos < data.Length - 16)
                {
                    uint VStart = ByteHelper.ReadUInt(data, CurrentPos, RomEndianness);
                    uint PStart = ByteHelper.ReadUInt(data, CurrentPos + 4, RomEndianness);
                    uint PEnd = ByteHelper.ReadUInt(data, CurrentPos + 8, RomEndianness);
                    uint CompFlag = ByteHelper.ReadUInt(data, CurrentPos + 12, RomEndianness);

                    //End of the DMA Header
                    if ((PStart == 0x00) && (PEnd == 0x00)) break;

                    //Create the actual data
                    byte[] dmaBytes = new byte[PEnd - PStart];
                    Array.Copy(data, PStart, dmaBytes, 0, dmaBytes.Length);

                    DMAFile entry;
                    switch(DMATable.Count) //Should act as an index for the current dma file
                    {
                        case 0: //Header DMA
                            entry = new HeaderDMAFile(dmaBytes, DMATable.Count);
                            _headerDMA = (HeaderDMAFile)entry;
                            break;
                        case 1: //Reference DMA
                            entry = new ReferenceDMAFile(dmaBytes, DMATable.Count);
                            _referenceDMA = (ReferenceDMAFile)entry;
                            break;
                        case 2: //DMA Table DMA
                            entry = new DMATableDMAFile(dmaBytes, DMATable.Count);
                            _dmaTableDMA = (DMATableDMAFile)entry;
                            break;
                        case 54: //Dialogue DMA
                            entry = new DialogueDMAFile(dmaBytes, DMATable.Count);
                            _dialogueDMA = (DialogueDMAFile)entry;
                            break;
                        //case 12: Appears broken right now, the Game Object table is set up differently than the other files. Possibly a prototype setup?
                        case 18:
                        case 19:
                        case 20:
                        case 26:
                        case 27:
                        case 28:
                        case 29:
                        case 30:
                        case 31:
                        case 33:
                        case 34:
                        case 35:
                        case 36:
                        case 37:
                        case 38:
                        case 39:
                        case 47:
                        case 53:
                            entry = new LevelDMAFile(dmaBytes, DMATable.Count, (int)_referenceDMA.LevelHeaderOffsets[StarFoxRomInfo.DMATableToLevelIndex(DMATable.Count)], 
                                (int)_referenceDMA.LevelInfoOffsets[StarFoxRomInfo.DMATableToLevelIndex(DMATable.Count)]);
                            _levelDMAs.Add(entry as LevelDMAFile);
                            break;
                        default: //Others
                            entry = new DMAFile(dmaBytes, DMATable.Count);
                            break;
                    }

                    DMATable.Add(entry);

                    CurrentPos += 16;
                }

                //Now set the DMA Headers
                if (_dmaTableDMA != null)
                {
                    for (int i = 0; i < DMATable.Count; i++)
                    {
                        DMATable[i].DMAInfo = _dmaTableDMA.DMATableEntries[i];

                        if (DMATable[i].DMAInfo.CFlag == 1)
                            IsCompressed = true;
                    }
                }

                if (_referenceDMA != null && _levelDMAs.Count > 0)
                {
                    //Parse out the F3DEX info
                    //LoadROMResources();
                }
            }
            catch
            {
                //Error log entry?
                return false;
            }

            return true;

            ////Automatically decompress on loading?
            //if (IsCompressed)
            //{
            //    if (DecompressDMA())
            //    {
            //        FixCRC();
            //    }
            //}
        }
Example #3
0
 //NOTE: We should make a way to clean up [DELETE] the old GL display lists
 public int[] ReadGameObject(DMAFile dma, uint fullOffset)
 {
     return ReadGameObject(dma, dma.GetAsBytes(), fullOffset);
 }