Esempio n. 1
0
        public OverlayRecord GetOverlayRecord(int index, TableInfo.Type type)
        {
            RomFileToken token = GetCodeFileToken();
            RomFile      code  = GetFile(token);

            var table = Tables.GetTable(type);

            if (!Addresser.TryGetRom(token, Version, table.Id, out int addr))
            {
                return(null);
            }
            code.Stream.Position = code.Record.GetRelativeAddress(addr + (index * table.Length));

            switch (type)
            {
            case TableInfo.Type.Actors: return(new ActorOverlayRecord(index, new BinaryReader(code)));

            case TableInfo.Type.GameOvls: return(new GameStateRecord(index, new BinaryReader(code)));

            case TableInfo.Type.Particles: return(new ParticleOverlayRecord(index, new BinaryReader(code)));

            case TableInfo.Type.PlayerPause: return(new PlayPauseOverlayRecord(index, new BinaryReader(code)));

            case TableInfo.Type.Transitions: return(new TransitionOverlayRecord(index, new BinaryReader(code)));

            default: return(null);
            }
        }
Esempio n. 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);
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        public PlayPauseOverlayRecord GetPlayPauseOverlayRecord(int index)
        {
            RomFileToken token = GetCodeFileToken();
            RomFile      code  = GetFile(token);

            if (!Addresser.TryGetRom(token, Version, Tables.PlayerPause.Id, out int addr))
            {
                return(null);
            }
            code.Stream.Position = code.Record.GetRelativeAddress(addr + (index * 0x1C));
            return(new PlayPauseOverlayRecord(index, new BinaryReader(code)));
        }
Esempio n. 5
0
        public GameStateRecord GetGameContextRecord(int index)
        {
            RomFileToken token = GetCodeFileToken();
            RomFile      code  = GetFile(token);

            if (!Addresser.TryGetRom(token, Version, Tables.GameOvls.Id, out int addr))
            {
                return(null);
            }
            code.Stream.Position = code.Record.GetRelativeAddress(addr + (index * 0x30));
            return(new GameStateRecord(index, new BinaryReader(code)));
        }
Esempio n. 6
0
        public ActorOverlayRecord GetActorOverlayRecord(int actor)
        {
            RomFileToken token = GetCodeFileToken();
            RomFile      code  = GetFile(token);

            if (!Addresser.TryGetRom(token, Version, Tables.Actors.Id, out int addr))
            {
                return(null);
            }
            code.Stream.Position = code.Record.GetRelativeAddress(addr + (actor * 0x20));
            return(new ActorOverlayRecord(actor, new BinaryReader(code)));
        }
Esempio n. 7
0
        private void LoadNtsc()
        {
            Dialogs = new Dictionary <ORom.Language, Dictionary <ushort, TextboxMessage> >();

            if (Addresser.TryGetRom(ORom.FileList.code, rom.Version, AddressToken.TextbankTable, out int textbank))
            {
                using (BinaryReader file = new BinaryReader(rom.Files.GetFile(ORom.FileList.code)))
                {
                    textbank = (int)rom.Files.GetFileStart(textbank).GetRelativeAddress(textbank);
                    file.BaseStream.Position = textbank;

                    LoadTextTable(file, Rom.Language.Japanese);
                    LoadTextTable(file, Rom.Language.English);
                }
            }
        }
Esempio n. 8
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);
        }
Esempio n. 9
0
        private void LoadPal()
        {
            Dialogs = new Dictionary <Rom.Language, Dictionary <ushort, TextboxMessage> >();

            if (Addresser.TryGetRom(ORom.FileList.code, rom.Version, AddressToken.TextbankTable, out int textbank))
            {
                RomFile codefile = rom.Files.GetFile(ORom.FileList.code);
                using (BinaryReader file = new BinaryReader(codefile.Stream))
                {
                    textbank = (int)codefile.Record.GetRelativeAddress(textbank);
                    file.BaseStream.Position = textbank;

                    LoadTextTable(file, Rom.Language.English);
                    LoadTextTable_Pal2(file, Dialogs[Rom.Language.English], Rom.Language.German);
                    LoadTextTable_Pal2(file, Dialogs[Rom.Language.English], Rom.Language.French);
                }
            }
        }
Esempio n. 10
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);
        }
Esempio n. 11
0
        public PlayPauseOverlayRecord GetPlayPauseOverlayRecord(int index)
        {
            int          addr;
            RomFileToken token = ORom.FileList.invalid;

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

            RomFile code = GetFile(token);

            if (!Addresser.TryGetRom(token, Version, PlayerPauseTable.StartKey, out addr))
            {
                return(null);
            }
            code.Stream.Position = code.Record.GetRelativeAddress(addr + (index * 0x1C));
            return(new PlayPauseOverlayRecord(index, new BinaryReader(code)));
        }
Esempio n. 12
0
        public ActorOverlayRecord GetActorOverlayRecord(int actor)
        {
            int          addr;
            RomFileToken token = ORom.FileList.invalid;

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

            RomFile code = GetFile(token);

            if (!Addresser.TryGetRom(token, Version, ActorTable.StartKey, out addr))
            {
                return(null);
            }
            code.Stream.Position = code.Record.GetRelativeAddress(addr + (actor * 0x20));
            return(new ActorOverlayRecord(actor, new BinaryReader(code)));
        }
Esempio n. 13
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"));