Ejemplo n.º 1
0
        private static VolumeResourceMap ReadResourceMap(byte[] data)
        {
            var map = new VolumeResourceMap();

            int offset = 0;

            // [0][1] = Offset of logdir
            int logOffset = (data[offset + 1] * 0x100) + data[offset];

            offset += 2;

            // [2][3] = Offset of picdir
            int picOffset = (data[offset + 1] * 0x100) + data[offset];

            offset += 2;

            // [4][5] = Offset of viewdir
            int viewOffset = (data[offset + 1] * 0x100) + data[offset];

            offset += 2;

            // [6][7] = Offset of snddir
            int sndOffset = (data[offset + 1] * 0x100) + data[offset];

            offset += 2;

            VolumeDecoder.ReadResourceMap(data, logOffset, picOffset - logOffset, map.LogicResources);
            VolumeDecoder.ReadResourceMap(data, picOffset, viewOffset - picOffset, map.PictureResources);
            VolumeDecoder.ReadResourceMap(data, viewOffset, sndOffset - viewOffset, map.ViewResources);
            VolumeDecoder.ReadResourceMap(data, sndOffset, data.Length - sndOffset, map.SoundResources);

            return(map);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ResourceLoader"/> class.
        /// </summary>
        /// <param name="gameContainer">Game container.</param>
        /// <param name="gameId">Game id.</param>
        /// <param name="platform">Game platform.</param>
        /// <param name="version">Interpreter version.</param>
        public ResourceLoader(IGameContainer gameContainer, string gameId, Platform platform, InterpreterVersion version)
        {
            if (gameContainer == null)
            {
                throw new ArgumentNullException(nameof(gameContainer));
            }

            if (gameId == null)
            {
                throw new ArgumentNullException(nameof(gameId));
            }

            if (!IsGameFolder(gameContainer))
            {
                throw new GameNotFoundException();
            }

            this.gameContainer   = gameContainer;
            this.platform        = platform;
            this.version         = version;
            this.inventoryPadded = platform == Platform.Amiga;
            if (this.IsVersion2())
            {
                this.volumeDecoder   = new VolumeDecoderV2();
                this.gameCompression = false;
            }
            else if (this.IsVersion3())
            {
                this.volumeDecoder   = new VolumeDecoderV3(gameId, platform);
                this.gameCompression = true;
            }

            this.resourceMap = this.volumeDecoder.LoadResourceMap(gameContainer);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Load the resource map located in the specified folder.
        /// </summary>
        /// <param name="container">Game container where the resource map file(s) are located.</param>
        /// <returns>Resource map.</returns>
        VolumeResourceMap IVolumeDecoder.LoadResourceMap(IGameContainer container)
        {
            if (container == null)
            {
                throw new ArgumentNullException(nameof(container));
            }

            var map = new VolumeResourceMap();

            VolumeDecoderV2.LoadResourceMapFile(container.Read(LogMapFile), map.LogicResources);
            VolumeDecoderV2.LoadResourceMapFile(container.Read(ViewMapFile), map.ViewResources);
            VolumeDecoderV2.LoadResourceMapFile(container.Read(PicMapFile), map.PictureResources);
            VolumeDecoderV2.LoadResourceMapFile(container.Read(SndMapFile), map.SoundResources);

            return(map);
        }