Example #1
0
        public bool FixCRC()
        {
            //Only apply crc fix to the full rom data container, not to the separated dma table data container
            if (N64Sums.FixChecksum(_romData))
            {
                IsValidRom = true;
                uint crc1 = ToolSettings.ReadUInt(_romData, 16, ROMEndianness);
                uint crc2 = ToolSettings.ReadUInt(_romData, 20, ROMEndianness);

                Info = new ROMInfo(Info.Title, Info.GameID, Info.Version, crc1, crc2, Info.DMATableOffset);

                return(true);
            }
            return(false);
        }
Example #2
0
        private void FixDMATable()
        {
            for (int i = 0; i < DMATable.Count; i++)
            {
                if (i < 2) //Don't apply to early entries, it's okay
                {
                    continue;
                }

                int CurrentPos = (int)Info.DMATableOffset + 16 * i;

                ToolSettings.WriteUInt(DMATable[i].VStart, _romData, CurrentPos, ROMEndianness);
                ToolSettings.WriteUInt(DMATable[i].PStart, _romData, CurrentPos + 4, ROMEndianness);
                ToolSettings.WriteUInt(DMATable[i].PEnd, _romData, CurrentPos + 8, ROMEndianness);
                ToolSettings.WriteUInt(DMATable[i].CompFlag, _romData, CurrentPos + 12, ROMEndianness);
            }
        }
Example #3
0
        private bool DecompressDMA()
        {
            if (!IsDMALoaded)
            {
                return(false);
            }

            for (int i = 0; i < DMATable.Count; i++)
            {
                DMATableEntry dma = DMATable[i];
                if (dma.CompFlag == 0x1)
                {
                    //compressed

                    //Decompress here
                    byte[] newDMAData;
                    if (ToolSettings.DecompressMIO0(dma.DMAData, out newDMAData))
                    {
                        dma.DMAData = newDMAData;

                        dma.PEnd     = dma.VStart + (uint)newDMAData.Length;
                        dma.PStart   = dma.VStart;
                        dma.CompFlag = 0x0;
                    }
                    else
                    {
                        //Catastrophic failure, just quit out
                        return(false);
                    }
                }
                else
                {
                    //uncompressed
                    dma.PEnd   = dma.VStart + (dma.PEnd - dma.PStart);
                    dma.PStart = dma.VStart;
                }

                DMATable[i] = dma;
            }

            return(true);
        }
Example #4
0
        private void SetRomInfo(uint dmaTableOffset = 0x0)
        {
            string title   = System.Text.Encoding.UTF8.GetString(_romData, 32, 20);
            string gameID  = System.Text.Encoding.UTF8.GetString(_romData, 59, 4);
            byte   version = _romData[63];

            uint endian = ToolSettings.ReadUInt(_romData, 0);

            ROMEndianness = StarFoxRomInfo.GetEndianness(endian);

            uint crc1 = ToolSettings.ReadUInt(_romData, 16, ROMEndianness);
            uint crc2 = ToolSettings.ReadUInt(_romData, 20, ROMEndianness);

            if (dmaTableOffset == 0x0)
            {
                dmaTableOffset = StarFoxRomInfo.GetDMATableOffset(gameID, version);
            }

            //To be discovered: will this need to be changed to also change the CRC values??? Or can I leave them untouched?
            Info = new ROMInfo(title, gameID, version, crc1, crc2, dmaTableOffset);

            IsValidRom = StarFoxRomInfo.IsValidVersion(Info);
        }