Exemple #1
0
        protected FileAddress GetFileByTable(TableInfo.Table refTable, int index)
        {
            RomFileToken token = ORom.FileList.invalid;

            if (Version.Game == Game.OcarinaOfTime)
            {
                token = ORom.FileList.code;
            }
            if (Version.Game == Game.MajorasMask)
            {
                token = MRom.FileList.code;
            }

            int size = refTable.Length;
            int offset = refTable.StartOff;
            int recordAddr, startAddr, endAddr;

            recordAddr = Addresser.GetRom(token, Version, refTable.Id);
            startAddr  = recordAddr + (index * size) + offset;
            endAddr    = startAddr + 4;
            startAddr  = ReadInt32(startAddr);
            endAddr    = ReadInt32(endAddr);
            FileAddress result = new FileAddress();

            try
            {
                result = GetVRomAddress(startAddr);
            }
            catch
            {
                result = new FileAddress(startAddr, endAddr);
            }

            return(result);
        }
Exemple #2
0
        protected FileAddress GetFileByRomTable(FileRefTable refTable, int index)
        {
            string       table = refTable.StartKey;
            int          size = refTable.RecSize;
            int          offset = refTable.FileStartOff;
            int          recordAddr, startAddr, endAddr;
            RomFileToken token = ORom.FileList.invalid;

            if (Version.Game == Game.OcarinaOfTime)
            {
                token = ORom.FileList.code;
            }
            if (Version.Game == Game.MajorasMask)
            {
                token = MRom.FileList.code;
            }

            recordAddr = Addresser.GetRom(token, Version, table);
            startAddr  = recordAddr + (index * size) + offset;
            startAddr  = ReadInt32(startAddr);
            endAddr    = recordAddr + (index * size) + refTable.FileEndOff;
            endAddr    = ReadInt32(endAddr);
            FileAddress result = new FileAddress();

            try
            {
                result = GetVRomAddress(startAddr);
            }
            catch
            {
                result = new FileAddress(startAddr, endAddr);
            }

            return(result);
        }
Exemple #3
0
        public DmaData(Stream s, RomVersion version)
        {
            RomFileToken token = ORom.FileList.invalid;

            if (version.Game == Game.OcarinaOfTime)
            {
                token = ORom.FileList.dmadata;
            }
            else if (version.Game == Game.MajorasMask)
            {
                token = MRom.FileList.dmadata;
            }

            int address = Addresser.GetRom(token, version, AddressToken.__Start);

            InitializeTable(s, address);
        }
Exemple #4
0
        /// <summary>
        /// Converts the scene index value stored in an entrance index into the internal scene number
        /// </summary>
        /// <param name="entranceSceneIndex"></param>
        /// <returns></returns>
        public byte?GetInternalSceneIndex(int entranceSceneIndex)
        {
            var entranceTableBase = Addresser.GetRom(MRom.FileList.code, Version, "EntranceIndexTable_Start");
            var entranceTableAddr = entranceTableBase + (sizeof(int) * 3) * entranceSceneIndex + 4;

            //Capture pointer
            if (!Addresser.TryGetRom(MRom.FileList.code, Version, (uint)ReadInt32(entranceTableAddr), out int entranceAddr) ||
                !Addresser.TryGetRom(MRom.FileList.code, Version, (uint)ReadInt32(entranceAddr), out entranceAddr))
            {
                return(null);
            }
            uint EntranceRecord = (uint)ReadInt32(entranceAddr);

            sbyte sceneIndex = (sbyte)(EntranceRecord >> 24);

            sceneIndex = Math.Abs(sceneIndex);

            return((byte?)sceneIndex);
        }
Exemple #5
0
 /// <summary>
 /// Returns a stream pointed to the decompressed file at the given address
 /// </summary>
 /// <param name="file"></param>
 /// <returns></returns>
 public RomFile GetFile(RomFileToken file) => GetFile(Addresser.GetRom(file, Version, "__Start"));